Browse Source

* small ansistring fixes
* val_ansistr_sint destsize changed to longint
* don't write low/hi ascii with -al

peter 26 years ago
parent
commit
e1b6682670
3 changed files with 64 additions and 49 deletions
  1. 8 4
      compiler/cg386add.pas
  2. 7 2
      compiler/temp_gen.pas
  3. 49 43
      rtl/inc/astrings.inc

+ 8 - 4
compiler/cg386add.pas

@@ -230,9 +230,8 @@ implementation
                         emit_reg_reg(A_OR,S_L,R_EAX,R_EAX);
                         emit_reg_reg(A_OR,S_L,R_EAX,R_EAX);
                         popusedregisters(pushedregs);
                         popusedregisters(pushedregs);
                         maybe_loadesi;
                         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;
                 end;
                 end;
                { the result of ansicompare is signed }
                { the result of ansicompare is signed }
@@ -2111,7 +2110,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $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
     * make cycle fixed i.e. compilation with 0.99.10
     * some fixes for qword
     * some fixes for qword
     * start of register calling conventions
     * start of register calling conventions

+ 7 - 2
compiler/temp_gen.pas

@@ -326,7 +326,7 @@ unit temp_gen;
 {$endif}
 {$endif}
             templist^.temptype:=tt_ansistring;
             templist^.temptype:=tt_ansistring;
             { set result to false, we don't need an decr_ansistr }
             { set result to false, we don't need an decr_ansistr }
-            gettempansistringreference:=false;
+            gettempansistringreference:=true;
           end;
           end;
          exprasmlist^.concat(new(paitempalloc,alloc(ref.offset,target_os.size_of_pointer)));
          exprasmlist^.concat(new(paitempalloc,alloc(ref.offset,target_os.size_of_pointer)));
       end;
       end;
@@ -524,7 +524,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $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
    * extdebug wrong warning removed
 
 
   Revision 1.30  1999/05/31 20:35:47  peter
   Revision 1.30  1999/05/31 20:35:47  peter

+ 49 - 43
rtl/inc/astrings.inc

@@ -392,36 +392,34 @@ Procedure SetLength (Var S : AnsiString; l : Longint);
 Var
 Var
   Temp : Pointer;
   Temp : Pointer;
 begin
 begin
-   If (Pointer(S)=Nil) and (l>0) then
+   if (l>0) then
     begin
     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;
       PByte(Pointer(S)+l)^:=0;
-    PAnsiRec(Pointer(S)-FirstOff)^.Len:=l;
+      PAnsiRec(Pointer(S)-FirstOff)^.Len:=l;
     end
     end
   else
   else
-    { Length=0 }
     begin
     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;
 end;
 end;
 
 
@@ -458,7 +456,7 @@ begin
     Size:=Length(S)-Index;
     Size:=Length(S)-Index;
   If Size>0 then
   If Size>0 then
     begin
     begin
-    If Index<0 Then 
+    If Index<0 Then
       Index:=0;
       Index:=0;
     ResultAddress:=Pointer(NewAnsiString (Size));
     ResultAddress:=Pointer(NewAnsiString (Size));
     if ResultAddress<>Nil then
     if ResultAddress<>Nil then
@@ -498,40 +496,43 @@ begin
   pos := j;
   pos := j;
 end;
 end;
 
 
+
 {$IfDef ValInternCompiled}
 {$IfDef ValInternCompiled}
 
 
 Function ValAnsiFloat(Const S : AnsiString; Var Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_ANSISTR'];
 Function ValAnsiFloat(Const S : AnsiString; Var Code : ValSInt): ValReal; [public, alias:'FPC_VAL_REAL_ANSISTR'];
-Var SS : String;
+Var
+  SS : String;
 begin
 begin
- AnsiStr_To_ShortStr(SS,Pointer(S));
- ValAnsiFloat := ValFloat(SS,Code);
+  AnsiStr_To_ShortStr(SS,Pointer(S));
+  ValAnsiFloat := ValFloat(SS,Code);
 end;
 end;
 
 
 
 
 Function ValAnsiUnsigendInt (Const S : AnsiString; Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_ANSISTR'];
 Function ValAnsiUnsigendInt (Const S : AnsiString; Code : ValSInt): ValUInt; [public, alias:'FPC_VAL_UINT_ANSISTR'];
-Var SS : ShortString;
-
+Var
+  SS : ShortString;
 begin
 begin
- AnsiStr_To_ShortStr(SS,Pointer(S));
- ValAnsiUnsigendInt := ValUnsignedInt(SS,Code);
+  AnsiStr_To_ShortStr(SS,Pointer(S));
+  ValAnsiUnsigendInt := ValUnsignedInt(SS,Code);
 end;
 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
 begin
- AnsiStr_To_ShortStr (SS,Pointer(S));
- ValAnsiSignedInt := ValSignedInt(DestSize,SS,Code);
+  AnsiStr_To_ShortStr (SS,Pointer(S));
+  ValAnsiSignedInt := ValSignedInt(DestSize,SS,Code);
 end;
 end;
 
 
+
 {$IfDef SUPPORT_FIXED}
 {$IfDef SUPPORT_FIXED}
 Function ValAnsiFixed(Const S : AnsiString; Var Code : ValSint): ValReal; [public, alias:'FPC_VAL_FIXED_ANSISTR'];
 Function ValAnsiFixed(Const S : AnsiString; Var Code : ValSint): ValReal; [public, alias:'FPC_VAL_FIXED_ANSISTR'];
-Var SS : String;
+Var
+  SS : String;
 begin
 begin
- AnsiStr_To_ShortStr (SS,Pointer(S));
- ValAnsiFixed := Fixed(ValFloat(SS,Code));
+  AnsiStr_To_ShortStr (SS,Pointer(S));
+  ValAnsiFixed := Fixed(ValFloat(SS,Code));
 end;
 end;
 {$EndIf SUPPORT_FIXED}
 {$EndIf SUPPORT_FIXED}
 
 
@@ -784,7 +785,12 @@ end;
 
 
 {
 {
   $Log$
   $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.
   Copy checks index now for negative values.
 
 
   Revision 1.26  1999/05/31 20:37:39  peter
   Revision 1.26  1999/05/31 20:37:39  peter