From e1b6682670fc83fcc7757d85841931f00dbdd396 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 9 Jun 1999 23:00:11 +0000 Subject: [PATCH] * small ansistring fixes * val_ansistr_sint destsize changed to longint * don't write low/hi ascii with -al --- compiler/cg386add.pas | 12 ++++-- compiler/temp_gen.pas | 9 ++++- rtl/inc/astrings.inc | 92 +++++++++++++++++++++++-------------------- 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/compiler/cg386add.pas b/compiler/cg386add.pas index e7a0a872a9..972829465d 100644 --- a/compiler/cg386add.pas +++ b/compiler/cg386add.pas @@ -230,9 +230,8 @@ implementation emit_reg_reg(A_OR,S_L,R_EAX,R_EAX); popusedregisters(pushedregs); maybe_loadesi; - { done in temptoremove (PM) - ungetiftemp(p^.left^.location.reference); - ungetiftemp(p^.right^.location.reference); } + ungetiftempansi(p^.left^.location.reference); + ungetiftempansi(p^.right^.location.reference); end; end; { the result of ansicompare is signed } @@ -2111,7 +2110,12 @@ implementation end. { $Log$ - Revision 1.64 1999-06-02 10:11:39 florian + Revision 1.65 1999-06-09 23:00:11 peter + * small ansistring fixes + * val_ansistr_sint destsize changed to longint + * don't write low/hi ascii with -al + + Revision 1.64 1999/06/02 10:11:39 florian * make cycle fixed i.e. compilation with 0.99.10 * some fixes for qword * start of register calling conventions diff --git a/compiler/temp_gen.pas b/compiler/temp_gen.pas index d9e32ba52e..0367709077 100644 --- a/compiler/temp_gen.pas +++ b/compiler/temp_gen.pas @@ -326,7 +326,7 @@ unit temp_gen; {$endif} templist^.temptype:=tt_ansistring; { set result to false, we don't need an decr_ansistr } - gettempansistringreference:=false; + gettempansistringreference:=true; end; exprasmlist^.concat(new(paitempalloc,alloc(ref.offset,target_os.size_of_pointer))); end; @@ -524,7 +524,12 @@ begin end. { $Log$ - Revision 1.31 1999-06-01 22:46:26 pierre + Revision 1.32 1999-06-09 23:00:13 peter + * small ansistring fixes + * val_ansistr_sint destsize changed to longint + * don't write low/hi ascii with -al + + Revision 1.31 1999/06/01 22:46:26 pierre * extdebug wrong warning removed Revision 1.30 1999/05/31 20:35:47 peter diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc index 2f952de05f..ff33e28a9d 100644 --- a/rtl/inc/astrings.inc +++ b/rtl/inc/astrings.inc @@ -392,36 +392,34 @@ Procedure SetLength (Var S : AnsiString; l : Longint); Var Temp : Pointer; begin - If (Pointer(S)=Nil) and (l>0) then + if (l>0) then begin - { Need a complete new string...} - Pointer(s):=NewAnsiString(l); - PAnsiRec(Pointer(S)-FirstOff)^.Len:=l; - PAnsiRec(Pointer(S)-FirstOff)^.MaxLen:=l; - PByte (Pointer(S)+l)^:=0; - end - else if l>0 then - begin - If (PAnsiRec(Pointer(S)-FirstOff)^.Maxlen < L) or - (PAnsiRec(Pointer(S)-FirstOff)^.Ref <> 1) then - begin - { Reallocation is needed... } - Temp:=Pointer(NewAnsiString(L)); - if Length(S)>0 then - Move (Pointer(S)^,Temp^,Length(S)+1); - ansistr_decr_ref (Pointer(S)); - Pointer(S):=Temp; - end - else - //!! Force nil termination in case it gets shorter + if Pointer(S)=nil then + begin + { Need a complete new string...} + Pointer(s):=NewAnsiString(l); + end + else + If (PAnsiRec(Pointer(S)-FirstOff)^.Maxlen < L) or + (PAnsiRec(Pointer(S)-FirstOff)^.Ref <> 1) then + begin + { Reallocation is needed... } + Temp:=Pointer(NewAnsiString(L)); + if Length(S)>0 then + Move (Pointer(S)^,Temp^,Length(S)+1); + ansistr_decr_ref (Pointer(S)); + Pointer(S):=Temp; + end; + { Force nil termination in case it gets shorter } PByte(Pointer(S)+l)^:=0; - PAnsiRec(Pointer(S)-FirstOff)^.Len:=l; + PAnsiRec(Pointer(S)-FirstOff)^.Len:=l; end else - { Length=0 } begin - ansistr_decr_ref (Pointer(S)); - Pointer(S):=Nil; + { Length=0 } + if Pointer(S)<>nil then + ansistr_decr_ref (Pointer(S)); + Pointer(S):=Nil; end; end; @@ -458,7 +456,7 @@ begin Size:=Length(S)-Index; If Size>0 then begin - If Index<0 Then + If Index<0 Then Index:=0; ResultAddress:=Pointer(NewAnsiString (Size)); if ResultAddress<>Nil then @@ -498,40 +496,43 @@ begin pos := j; end; + {$IfDef ValInternCompiled} Function ValAnsiFloat(Const S : AnsiString; Var Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_ANSISTR']; -Var SS : String; +Var + SS : String; begin - AnsiStr_To_ShortStr(SS,Pointer(S)); - ValAnsiFloat := ValFloat(SS,Code); + AnsiStr_To_ShortStr(SS,Pointer(S)); + ValAnsiFloat := ValFloat(SS,Code); end; Function ValAnsiUnsigendInt (Const S : AnsiString; Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_ANSISTR']; -Var SS : ShortString; - +Var + SS : ShortString; begin - AnsiStr_To_ShortStr(SS,Pointer(S)); - ValAnsiUnsigendInt := ValUnsignedInt(SS,Code); + AnsiStr_To_ShortStr(SS,Pointer(S)); + ValAnsiUnsigendInt := ValUnsignedInt(SS,Code); end; -Function ValAnsiSignedInt (DestSize: Byte; Const S : AnsiString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_ANSISTR']; - -Var SS : ShortString; - +Function ValAnsiSignedInt (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; [public, alias:'FPC_VAL_SINT_ANSISTR']; +Var + SS : ShortString; begin - AnsiStr_To_ShortStr (SS,Pointer(S)); - ValAnsiSignedInt := ValSignedInt(DestSize,SS,Code); + AnsiStr_To_ShortStr (SS,Pointer(S)); + ValAnsiSignedInt := ValSignedInt(DestSize,SS,Code); end; + {$IfDef SUPPORT_FIXED} Function ValAnsiFixed(Const S : AnsiString; Var Code : ValSint): ValReal; [public, alias:'FPC_VAL_FIXED_ANSISTR']; -Var SS : String; +Var + SS : String; begin - AnsiStr_To_ShortStr (SS,Pointer(S)); - ValAnsiFixed := Fixed(ValFloat(SS,Code)); + AnsiStr_To_ShortStr (SS,Pointer(S)); + ValAnsiFixed := Fixed(ValFloat(SS,Code)); end; {$EndIf SUPPORT_FIXED} @@ -784,7 +785,12 @@ end; { $Log$ - Revision 1.27 1999-06-05 20:48:56 michael + Revision 1.28 1999-06-09 23:00:16 peter + * small ansistring fixes + * val_ansistr_sint destsize changed to longint + * don't write low/hi ascii with -al + + Revision 1.27 1999/06/05 20:48:56 michael Copy checks index now for negative values. Revision 1.26 1999/05/31 20:37:39 peter