Browse Source

* fpc_{ansistr|widestr}_unique is now a function so it can be used as
compilerproc

Jonas Maebe 22 years ago
parent
commit
394b70f94d
3 changed files with 29 additions and 9 deletions
  1. 9 3
      rtl/inc/astrings.inc
  2. 10 3
      rtl/inc/compproc.inc
  3. 10 3
      rtl/inc/wstrings.inc

+ 9 - 3
rtl/inc/astrings.inc

@@ -512,7 +512,7 @@ end;
 { overloaded version of UniqueString for interface }
 Procedure UniqueString(Var S : AnsiString); [external name 'FPC_ANSISTR_UNIQUE'];
 
-Procedure fpc_ansistr_Unique(Var S : AnsiString); [Public,Alias : 'FPC_ANSISTR_UNIQUE']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Function fpc_ansistr_Unique(Var S : Pointer): Ansistring; [Public,Alias : 'FPC_ANSISTR_UNIQUE']; {$ifdef hascompilerproc} compilerproc; {$endif}
 {
   Make sure reference count of S is 1,
   using copy-on-write semantics.
@@ -521,6 +521,7 @@ Var
   SNew : Pointer;
   L    : Longint;
 begin
+  pointer(result) := pointer(s);
   If Pointer(S)=Nil then
     exit;
   if PAnsiRec(Pointer(S)-Firstoff)^.Ref<>1 then
@@ -530,7 +531,8 @@ begin
      Move (Pointer(S)^,SNew^,L+1);
      PAnsiRec(SNew-FirstOff)^.len:=L;
      fpc_ansistr_decr_ref (Pointer(S));  { Thread safe }
-     Pointer(S):=SNew;
+     pointer(S):=SNew;
+     pointer(result):=SNew;
    end;
 end;
 
@@ -833,7 +835,11 @@ end;
 
 {
   $Log$
-  Revision 1.37  2003-05-01 08:05:23  florian
+  Revision 1.38  2003-06-17 16:38:53  jonas
+    * fpc_{ansistr|widestr}_unique is now a function so it can be used as
+      compilerproc
+
+  Revision 1.37  2003/05/01 08:05:23  florian
     * started to make the rtl 64 bit save by introducing SizeInt and SizeUInt (similar to size_t of C)
 
   Revision 1.36  2003/02/26 19:16:55  jonas

+ 10 - 3
rtl/inc/compproc.inc

@@ -100,7 +100,10 @@ Procedure fpc_AnsiStr_SetLength (Var S : AnsiString; l : Longint); compilerproc;
 {$ifdef EXTRAANSISHORT}
 Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString): Longint; compilerproc;
 {$endif EXTRAANSISHORT}
-Procedure fpc_ansistr_Unique(Var S : AnsiString); compilerproc;
+{ pointer argument because otherwise when calling this, we get }
+{ an endless loop since a 'var s: ansistring' must be made     }
+{ unique as well                                               }
+Function fpc_ansistr_Unique(Var S : Pointer): Ansistring; compilerproc;
 
 Procedure fpc_WideStr_Decr_Ref (Var S : Pointer); compilerproc;
 Procedure fpc_WideStr_Incr_Ref (S : Pointer); compilerproc;
@@ -118,7 +121,7 @@ Function fpc_WideStr_Compare(const S1,S2 : WideString): Longint; compilerproc;
 Procedure fpc_WideStr_CheckZero(p : pointer); compilerproc;
 Procedure fpc_WideStr_CheckRange(len,index : longint); compilerproc;
 Procedure fpc_WideStr_SetLength (Var S : WideString; l : Longint); compilerproc;
-Procedure fpc_widestr_Unique(Var S : WideString); compilerproc;
+function fpc_widestr_Unique(Var S : Pointer): Widestring; compilerproc;
 
 {$ifdef HASWIDECHAR}
 Function fpc_PWideChar_To_AnsiStr(const p : pwidechar): ansistring; compilerproc;
@@ -291,7 +294,11 @@ function fpc_qword_to_double(q: qword): double; compilerproc;
 
 {
   $Log$
-  Revision 1.43  2003-05-26 19:36:46  peter
+  Revision 1.44  2003-06-17 16:38:53  jonas
+    * fpc_{ansistr|widestr}_unique is now a function so it can be used as
+      compilerproc
+
+  Revision 1.43  2003/05/26 19:36:46  peter
     * fpc_shortstr_concat is now the same for all targets
     * fpc_shortstr_append_shortstr added for optimized code generation
 

+ 10 - 3
rtl/inc/wstrings.inc

@@ -670,10 +670,11 @@ begin
 end;
 {$endif INTERNLENGTH}
 
+
 { overloaded version of UniqueString for interface }
 procedure UniqueString(Var S : WideString); [external name 'FPC_WIDESTR_UNIQUE'];
 
-Procedure fpc_widestr_Unique(Var S : WideString); [Public,Alias : 'FPC_WIDESTR_UNIQUE']; {$ifdef hascompilerproc} compilerproc; {$endif}
+Function fpc_widestr_Unique(Var S : Pointer): Widestring; [Public,Alias : 'FPC_WIDESTR_UNIQUE']; {$ifdef hascompilerproc} compilerproc; {$endif}
 {
   Make sure reference count of S is 1,
   using copy-on-write semantics.
@@ -682,6 +683,7 @@ Var
   SNew : Pointer;
   L    : Longint;
 begin
+  pointer(result) := pointer(s);
   If Pointer(S)=Nil then
     exit;
   if PWideRec(Pointer(S)-WideFirstOff)^.Ref<>1 then
@@ -691,7 +693,8 @@ begin
      Move (PWideChar(S)^,SNew^,(L+1)*sizeof(WideChar));
      PWideRec(SNew-WideFirstOff)^.len:=L;
      fpc_widestr_decr_ref (Pointer(S));  { Thread safe }
-     Pointer(S):=SNew;
+     pointer(S):=SNew;
+     pointer(result):=SNew;
    end;
 end;
 
@@ -990,7 +993,11 @@ end;
 
 {
   $Log$
-  Revision 1.29  2003-05-01 08:05:23  florian
+  Revision 1.30  2003-06-17 16:38:53  jonas
+    * fpc_{ansistr|widestr}_unique is now a function so it can be used as
+      compilerproc
+
+  Revision 1.29  2003/05/01 08:05:23  florian
     * started to make the rtl 64 bit save by introducing SizeInt and SizeUInt (similar to size_t of C)
 
   Revision 1.28  2002/12/29 16:59:17  peter