Ada 95 foundation library
修订版 | 19274b084e74d52b152537afefe7b8e4c06aa982 (tree) |
---|---|
时间 | 2019-10-06 19:03:50 |
作者 | Sergey Dukov <dukov54@live...> |
Commiter | Sergey Dukov |
#32763 Полная реализация "*"
@@ -3323,5 +3323,53 @@ | ||
3323 | 3323 | end if; |
3324 | 3324 | end Delete; |
3325 | 3325 | |
3326 | + function "*" | |
3327 | + (Left : Natural; | |
3328 | + Right : String_32) return Unbounded_Array_Type | |
3329 | + is | |
3330 | + RL : Natural := Right'Length; | |
3331 | + DL : Natural := Left * RL; | |
3332 | + SR : Positive := Right'First; | |
3333 | + ER : Positive := Right'Last; | |
3334 | + DR : Referenced_Buffer_Access; | |
3335 | + K : Positive := 1; | |
3336 | + BOMV : Boolean := False; | |
3337 | + begin | |
3338 | + if DL = 0 then | |
3339 | + DR := Empty_Referenced_Buffer'Access; | |
3340 | + return (AF.Controlled with Reference => DR); | |
3341 | + end if; | |
3342 | + if Right(SR) = BOM32 then | |
3343 | + RL := RL - 1; | |
3344 | + if RL = 0 then | |
3345 | + DR := Empty_Referenced_Buffer'Access; | |
3346 | + return (AF.Controlled with Reference => DR); | |
3347 | + end if; | |
3348 | + SR := SR + 1; | |
3349 | + DL := Left * RL + 1; | |
3350 | + BOMV := True; | |
3351 | + K := 2; | |
3352 | + end if; | |
3353 | + DR := Allocate (4*DL); | |
3354 | + declare | |
3355 | + subtype DSM is String_32(1 .. DL); | |
3356 | + package DTP is new ATOAC(DSM); | |
3357 | + Result_Ptr : DTP.Object_Pointer := | |
3358 | + DTP.To_Pointer(DR.Data(1)'Address); | |
3359 | + DA : DSM renames Result_Ptr.all; | |
3360 | + begin | |
3361 | + if BOMV then | |
3362 | + DA(1) := BOM32; | |
3363 | + end if; | |
3364 | + for J in 1 .. Left loop | |
3365 | + DA(K .. K + RL - 1) := Right(SR .. ER); | |
3366 | + K := K + RL; | |
3367 | + end loop; | |
3368 | + DR.Last := 4*DL; | |
3369 | + DR.UTF32 := True; | |
3370 | + end; | |
3371 | + return (AF.Controlled with Reference => DR); | |
3372 | + end "*"; | |
3373 | + | |
3326 | 3374 | |
3327 | 3375 | end Unbounded_Array; |
@@ -361,6 +361,10 @@ | ||
361 | 361 | |
362 | 362 | function "*" |
363 | 363 | (Left : Natural; |
364 | + Right : String_32) return Unbounded_Array_Type; | |
365 | + | |
366 | + function "*" | |
367 | + (Left : Natural; | |
364 | 368 | Right : Unbounded_Array_Type) return Unbounded_Array_Type; |
365 | 369 | |
366 | 370 |
@@ -42,11 +42,12 @@ | ||
42 | 42 | declare |
43 | 43 | Unicode_String : String_32 := To_String_32(Unicode_Array); |
44 | 44 | begin |
45 | - Append(Unicode_Array, Unicode_Array); | |
46 | - Append(Unicode_Array, Unicode_String); | |
45 | +-- Append(Unicode_Array, Unicode_Array); | |
46 | +-- Append(Unicode_Array, Unicode_String); | |
47 | 47 | -- Unicode_Array := Delete(Unicode_Array, |
48 | 48 | -- 2, |
49 | 49 | -- 9); |
50 | + Unicode_Array := 3 * Unicode_String; | |
50 | 51 | Delete(Unicode_Array, |
51 | 52 | 2, |
52 | 53 | 9); |