|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 8192 (0x2000) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body C_Strings, seg_04b924
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
with A_Strings; with Unchecked_Conversion; with System; use System; package body C_Strings is use Ascii; function C_Length (S : C_String) return Integer is begin for I in S'Range loop if S (I) = Nul then return I - 1; end if; end loop; end C_Length; function Convert_C_To_String (S : C_String) return String is begin if S = null then return ""; else return S (1 .. C_Length (S)); end if; end Convert_C_To_String; function Convert_C_To_A (S : C_String) return A_Strings.A_String is begin return A_Strings.To_A (Convert_C_To_String (S)); end Convert_C_To_A; function Convert_A_To_C (S : A_Strings.A_String) return C_String is begin return Address_To_C (A_Strings.To_C (S)); end Convert_A_To_C; function To_C (S : A_Strings.A_String; Buf : System.Address) return C_String is C : C_String := Address_To_C (Buf); begin C (1 .. S.Len) := S.S (1 .. S.Len); C (S.Len + 1) := Ascii.Nul; return C; end To_C; function Convert_String_To_C (S : String) return C_String is Len : Integer := (S'Last - S'First + 1) + 1; type String_Ptr is access String (1 .. Len); Buffer : String_Ptr := new String (1 .. Len); begin return To_C (S, Buffer (1)'Address); end Convert_String_To_C; function To_C (S : String; Buf : System.Address) return C_String is C : C_String := Address_To_C (Buf); Len : Integer := S'Length; begin C (1 .. Len) := S; C (Len + 1) := Ascii.Nul; return C; end To_C; function Strcmp (A, B : C_String) return Boolean is Len : Integer; begin if A = null then return B = null; elsif B = null then return False; end if; Len := C_Length (A) + 1; return A (1 .. Len) = B (1 .. Len); -- include nul in compare end Strcmp; function Strcmp (A : C_String; B : A_Strings.A_String) return Boolean is Len : Integer; begin if A = null then return A_Strings."=" (B, null); elsif A_Strings."=" (B, null) then return False; end if; Len := C_Length (A); return B.Len = Len and then A (1 .. Len) = B.S; end Strcmp; function Strcmp (A : A_Strings.A_String; B : C_String) return Boolean is Len : Integer; begin if B = null then return A_Strings."=" (A, null); elsif A_Strings."=" (A, null) then return False; end if; Len := C_Length (B); return A.Len = Len and then B (1 .. Len) = A.S; end Strcmp; function Strcmp (A : C_String; B : String) return Boolean is Len : Integer; begin Len := C_Length (A); return B'Length = Len and then A (1 .. Len) = B; end Strcmp; function Strcmp (A : String; B : C_String) return Boolean is Len : Integer := C_Length (B); begin return A'Length = Len and then B (1 .. Len) = A; end Strcmp; function Strcmp (X, Y : C_String) return Integer is J : Integer; begin J := Y'First; for I in X'First .. C_Length (X) loop if X (I) < Y (J) then return -1; elsif X (I) > Y (J) then return 1; end if; J := J + 1; end loop; if J <= C_Length (Y) then return -1; else return 0; end if; exception when Constraint_Error => return 1; end Strcmp; function Strcpy (To : C_String; From : String) return C_String is I : Integer; begin I := 1; for J in From'Range loop To (I) := From (J); I := I + 1; end loop; To (I) := Ascii.Nul; return To; end Strcpy; function Strcpy (To : C_String; From : A_Strings.A_String) return C_String is I : Integer; begin I := 1; for J in 1 .. From.Len loop To (I) := From.S (J); I := I + 1; end loop; To (I) := Ascii.Nul; return To; end Strcpy; function Strcpy (To : C_String; From : C_String) return C_String is I : Integer; begin I := 1; for J in 1 .. C_Length (From) loop To (I) := From (J); I := I + 1; end loop; To (I) := Ascii.Nul; return To; end Strcpy; function Strcat (To : C_String; From : String) return C_String is I : Integer; begin I := C_Length (To) + 1; for J in From'Range loop To (I) := From (J); I := I + 1; end loop; To (I) := Ascii.Nul; return To; end Strcat; function Strcat (To : C_String; From : A_Strings.A_String) return C_String is I : Integer; begin I := C_Length (To) + 1; for J in 1 .. From.Len loop To (I) := From.S (J); I := I + 1; end loop; To (I) := Ascii.Nul; return To; end Strcat; function Strcat (To : C_String; From : C_String) return C_String is I : Integer; begin I := C_Length (To) + 1; for J in 1 .. C_Length (From) loop To (I) := From (J); I := I + 1; end loop; To (I) := Ascii.Nul; return To; end Strcat; function String_Copy (A : C_String) return C_String is begin return Convert_A_To_C (A_Strings.To_A (A (1 .. C_Length (A)))); end String_Copy; function Rindex (Str : C_Strings.C_String; Ch : Character) return Integer is Last : Integer := 0; begin for I in Str'Range loop if Str (I) = Ch then Last := I; elsif Str (I) = Ascii.Nul then return Last; end if; end loop; return 0; end Rindex; end C_Strings;
nblk1=7 nid=0 hdr6=e [0x00] rec0=27 rec1=00 rec2=01 rec3=00a [0x01] rec0=1f rec1=00 rec2=02 rec3=028 [0x02] rec0=1f rec1=00 rec2=03 rec3=020 [0x03] rec0=24 rec1=00 rec2=04 rec3=012 [0x04] rec0=26 rec1=00 rec2=05 rec3=036 [0x05] rec0=24 rec1=00 rec2=06 rec3=050 [0x06] rec0=10 rec1=00 rec2=07 rec3=000 tail 0x21750b7f0868434aeedd9 0x42a00088462060003