Browse Source

+ several widestring/pwidechar related helpers added

florian 23 years ago
parent
commit
c6ea429567
3 changed files with 60 additions and 4 deletions
  1. 12 1
      rtl/inc/compproc.inc
  2. 19 2
      rtl/inc/generic.inc
  3. 29 1
      rtl/inc/wstrings.inc

+ 12 - 1
rtl/inc/compproc.inc

@@ -45,6 +45,7 @@ function fpc_shortstr_compare(const dstr,sstr:shortstring) : longint; compilerpr
 
 
 function fpc_pchar_to_shortstr(p:pchar):shortstring; compilerproc;
 function fpc_pchar_to_shortstr(p:pchar):shortstring; compilerproc;
 function fpc_pchar_length(p:pchar):longint; compilerproc;
 function fpc_pchar_length(p:pchar):longint; compilerproc;
+function fpc_pwidechar_length(p:pwidechar):longint; compilerproc;
 
 
 function fpc_chararray_to_shortstr(const arr: array of char):shortstring; compilerproc;
 function fpc_chararray_to_shortstr(const arr: array of char):shortstring; compilerproc;
 function fpc_shortstr_to_chararray(arraysize: longint; const src: ShortString): fpc_big_chararray; compilerproc;
 function fpc_shortstr_to_chararray(arraysize: longint; const src: ShortString): fpc_big_chararray; compilerproc;
@@ -112,6 +113,13 @@ Procedure fpc_WideStr_CheckRange(len,index : longint); compilerproc;
 Procedure fpc_WideStr_SetLength (Var S : WideString; l : Longint); compilerproc;
 Procedure fpc_WideStr_SetLength (Var S : WideString; l : Longint); compilerproc;
 Procedure fpc_widestr_Unique(Var S : WideString); compilerproc;
 Procedure fpc_widestr_Unique(Var S : WideString); compilerproc;
 
 
+{$ifdef HASWIDECHAR}
+Function fpc_PWideChar_To_AnsiStr(const p : pwidechar): ansistring; compilerproc;
+Function fpc_PWideChar_To_WideStr(const p : pwidechar): widestring; compilerproc;
+Function fpc_PWideChar_To_ShortStr(const p : pwidechar): shortstring; compilerproc;
+Function fpc_PWideChar_To_LongStr(const p : pwidechar): longstring; compilerproc;
+{$endif HASWIDECHAR}
+
 Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; compilerproc;
 Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; compilerproc;
 Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; compilerproc;
 Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; compilerproc;
 Function fpc_Val_SInt_AnsiStr (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; compilerproc;
 Function fpc_Val_SInt_AnsiStr (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; compilerproc;
@@ -267,7 +275,10 @@ function fpc_qword_to_double(q: qword): double; compilerproc;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.25  2002-10-05 14:20:16  peter
+  Revision 1.26  2002-10-10 16:08:50  florian
+    + several widestring/pwidechar related helpers added
+
+  Revision 1.25  2002/10/05 14:20:16  peter
     * fpc_pchar_length compilerproc and strlen alias
     * fpc_pchar_length compilerproc and strlen alias
 
 
   Revision 1.24  2002/10/02 18:21:51  peter
   Revision 1.24  2002/10/02 18:21:51  peter

+ 19 - 2
rtl/inc/generic.inc

@@ -738,7 +738,7 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
 
-function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
+function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
 var i : longint;
 var i : longint;
 begin
 begin
   i:=0;
   i:=0;
@@ -748,6 +748,20 @@ end;
 
 
 {$endif ndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$endif ndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
 
+{$ifdef HASWIDESTRING}
+{$ifndef FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
+
+function fpc_pwidechar_length(p:pwidechar):longint;[public,alias:'FPC_PWIDECHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
+var i : longint;
+begin
+  i:=0;
+  while p[i]<>#0 do inc(i);
+  exit(i);
+end;
+
+{$endif ndef FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
+{$endif HASWIDESTRING}
+
 {****************************************************************************
 {****************************************************************************
                        Caller/StackFrame Helpers
                        Caller/StackFrame Helpers
 ****************************************************************************}
 ****************************************************************************}
@@ -927,7 +941,10 @@ end;
 {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
 {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
 {
 {
   $Log$
   $Log$
-  Revision 1.39  2002-10-05 14:20:16  peter
+  Revision 1.40  2002-10-10 16:08:50  florian
+    + several widestring/pwidechar related helpers added
+
+  Revision 1.39  2002/10/05 14:20:16  peter
     * fpc_pchar_length compilerproc and strlen alias
     * fpc_pchar_length compilerproc and strlen alias
 
 
   Revision 1.38  2002/10/02 18:21:51  peter
   Revision 1.38  2002/10/02 18:21:51  peter

+ 29 - 1
rtl/inc/wstrings.inc

@@ -301,6 +301,31 @@ begin
     end;
     end;
 end;
 end;
 
 
+{ compilers with widestrings should have compiler procs }
+Function fpc_PWideChar_To_AnsiStr(const p : pwidechar): ansistring; compilerproc;
+begin
+   runerror(218);
+end;
+
+
+Function fpc_PWideChar_To_WideStr(const p : pwidechar): widestring; compilerproc;
+begin
+   runerror(218);
+end;
+
+
+Function fpc_PWideChar_To_ShortStr(const p : pwidechar): shortstring; compilerproc;
+begin
+   runerror(218);
+end;
+
+
+Function fpc_PWideChar_To_LongStr(const p : pwidechar): longstring; compilerproc;
+begin
+   runerror(218);
+end;
+
+
 { old style helper }
 { old style helper }
 {$ifndef hascompilerproc}
 {$ifndef hascompilerproc}
 Procedure fpc_AnsiStr_To_WideStr (Var S1 : Pointer; Const S2 : AnsiString);[Public, alias: 'FPC_ANSISTR_TO_WIDESTR'];
 Procedure fpc_AnsiStr_To_WideStr (Var S1 : Pointer; Const S2 : AnsiString);[Public, alias: 'FPC_ANSISTR_TO_WIDESTR'];
@@ -888,7 +913,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2002-10-02 18:21:52  peter
+  Revision 1.24  2002-10-10 16:08:50  florian
+    + several widestring/pwidechar related helpers added
+
+  Revision 1.23  2002/10/02 18:21:52  peter
     * Copy() changed to internal function calling compilerprocs
     * Copy() changed to internal function calling compilerprocs
     * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
     * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
       new copy functions
       new copy functions