Browse Source

* Started unicode changes for win32 rtl. Does not compile yet.

git-svn-id: branches/unicodertl@12124 -
yury 17 years ago
parent
commit
9d48637bdd
11 changed files with 128 additions and 122 deletions
  1. 21 13
      rtl/inc/file.inc
  2. 1 1
      rtl/inc/filerec.inc
  3. 10 7
      rtl/inc/system.inc
  4. 20 19
      rtl/inc/systemh.inc
  5. 20 12
      rtl/inc/text.inc
  6. 2 2
      rtl/inc/textrec.inc
  7. 18 19
      rtl/win/sysdir.inc
  8. 5 5
      rtl/win/sysfile.inc
  9. 21 38
      rtl/win/sysos.inc
  10. 0 2
      rtl/win/sysosh.inc
  11. 10 4
      rtl/win32/system.pp

+ 21 - 13
rtl/inc/file.inc

@@ -18,7 +18,7 @@
 type
 type
   UnTypedFile=File;
   UnTypedFile=File;
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:string);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:RtlString);
 {
 {
   Assign Name to file f so it can be used with the file routines
   Assign Name to file f so it can be used with the file routines
 }
 }
@@ -30,21 +30,21 @@ Begin
 End;
 End;
 
 
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:pchar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:PRtlChar);
 {
 {
   Assign Name to file f so it can be used with the file routines
   Assign Name to file f so it can be used with the file routines
 }
 }
 begin
 begin
-  Assign(f,StrPas(p));
+  Assign(f,p);
 end;
 end;
 
 
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:RtlChar);
 {
 {
   Assign Name to file f so it can be used with the file routines
   Assign Name to file f so it can be used with the file routines
 }
 }
 begin
 begin
-  Assign(f,string(c));
+  Assign(f,c);
 end;
 end;
 
 
 
 
@@ -69,7 +69,7 @@ Begin
   else
   else
    Begin
    Begin
      { Reopen with filemode 2, to be Tp compatible (PFV) }
      { Reopen with filemode 2, to be Tp compatible (PFV) }
-     Do_Open(f,PChar(@FileRec(f).Name),$1002);
+     Do_Open(f,PRtlChar(@FileRec(f).Name),$1002);
      FileRec(f).RecSize:=l;
      FileRec(f).RecSize:=l;
    End;
    End;
 End;
 End;
@@ -95,7 +95,7 @@ Begin
    InOutRes:=2
    InOutRes:=2
   else
   else
    Begin
    Begin
-     Do_Open(f,PChar(@FileRec(f).Name),Filemode);
+     Do_Open(f,PRtlChar(@FileRec(f).Name),Filemode);
      FileRec(f).RecSize:=l;
      FileRec(f).RecSize:=l;
    End;
    End;
 End;
 End;
@@ -383,25 +383,33 @@ Begin
   If InOutRes <> 0 then
   If InOutRes <> 0 then
    exit;
    exit;
   If FileRec(f).mode=fmClosed Then
   If FileRec(f).mode=fmClosed Then
-   Do_Erase(PChar(@FileRec(f).Name));
+   Do_Erase(PRtlChar(@FileRec(f).Name));
 End;
 End;
 
 
 
 
-Procedure Rename(var f : File;p:pchar);[IOCheck];
+Procedure Rename(var f : File;p:PRtlChar);[IOCheck];
+var
+  len: longint;
 Begin
 Begin
   If InOutRes <> 0 then
   If InOutRes <> 0 then
    exit;
    exit;
   If FileRec(f).mode=fmClosed Then
   If FileRec(f).mode=fmClosed Then
    Begin
    Begin
-     Do_Rename(PChar(@FileRec(f).Name),p);
+     Do_Rename(PRtlChar(@FileRec(f).Name),p);
      { check error code of do_rename }
      { check error code of do_rename }
      If InOutRes = 0 then
      If InOutRes = 0 then
-        Move(p^,FileRec(f).Name,StrLen(p)+1);
+      begin
+        len:=StrLen(p)*SizeOf(RtlChar);
+        if len > SizeOf(FileRec(f).Name) - SizeOf(RtlChar) then
+          len:=SizeOf(FileRec(f).Name) - SizeOf(RtlChar);
+        Move(p^,FileRec(f).Name,len);
+        FileRec(f).Name[len]:=#0;
+      end;
    End;
    End;
 End;
 End;
 
 
 
 
-Procedure Rename(var f : File;const s : string);[IOCheck];
+Procedure Rename(var f : File;const s : RtlString);[IOCheck];
 var
 var
   p : array[0..255] Of Char;
   p : array[0..255] Of Char;
 Begin
 Begin
@@ -413,7 +421,7 @@ Begin
 End;
 End;
 
 
 
 
-Procedure Rename(var f : File;c : char);[IOCheck];
+Procedure Rename(var f : File;c : RtlChar);[IOCheck];
 var
 var
   p : array[0..1] Of Char;
   p : array[0..1] Of Char;
 Begin
 Begin

+ 1 - 1
rtl/inc/filerec.inc

@@ -29,6 +29,6 @@ type
     RecSize   : SizeInt;
     RecSize   : SizeInt;
     _private  : array[1..3 * SizeOf(SizeInt) + 5 * SizeOf (pointer)] of byte;
     _private  : array[1..3 * SizeOf(SizeInt) + 5 * SizeOf (pointer)] of byte;
     UserData  : array[1..32] of byte;
     UserData  : array[1..32] of byte;
-    name      : array[0..filerecnamelength] of char;
+    name      : array[0..filerecnamelength div SizeOf(RtlChar)] of RtlChar;
   End;
   End;
 
 

+ 10 - 7
rtl/inc/system.inc

@@ -587,7 +587,8 @@ End;
 *****************************************************************************}
 *****************************************************************************}
 
 
 {$if defined(FPC_HAS_FEATURE_FILEIO) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
 {$if defined(FPC_HAS_FEATURE_FILEIO) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
-Procedure getdir(drivenr:byte;Var dir:ansistring);
+(*
+Procedure getdir(drivenr:byte;Var dir:RtlString);
 { this is needed to also allow ansistrings, the shortstring version is
 { this is needed to also allow ansistrings, the shortstring version is
   OS dependent }
   OS dependent }
 var
 var
@@ -596,6 +597,7 @@ begin
   getdir(drivenr,s);
   getdir(drivenr,s);
   dir:=s;
   dir:=s;
 end;
 end;
+*)
 {$endif}
 {$endif}
 
 
 {$ifopt R+}
 {$ifopt R+}
@@ -1273,13 +1275,13 @@ end;
 *****************************************************************************}
 *****************************************************************************}
 
 
 { Allow slash and backslash as separators }
 { Allow slash and backslash as separators }
-procedure DoDirSeparators(p:Pchar);
-var
-  i : longint;
+procedure DoDirSeparators(p:PRtlChar);
 begin
 begin
-  for i:=0 to strlen(p) do
-    if p[i] in AllowDirectorySeparators then
-      p[i]:=DirectorySeparator;
+  while p^ <> #0 do begin
+    if AnsiChar(p^) in AllowDirectorySeparators then
+      p^:=DirectorySeparator;
+    Inc(p);
+  end;
 end;
 end;
 
 
 procedure DoDirSeparators(var p:shortstring);
 procedure DoDirSeparators(var p:shortstring);
@@ -1337,3 +1339,4 @@ begin
   CtrlBreakHandler := Handler;
   CtrlBreakHandler := Handler;
 end;
 end;
 {$ENDIF FPC_HAS_SETCTRLBREAKHANDLER}
 {$ENDIF FPC_HAS_SETCTRLBREAKHANDLER}
+

+ 20 - 19
rtl/inc/systemh.inc

@@ -485,7 +485,7 @@ var
 
 
 {$ifndef HAS_CMDLINE}
 {$ifndef HAS_CMDLINE}
 {Value should be changed during system initialization as appropriate.}
 {Value should be changed during system initialization as appropriate.}
-var cmdline:Pchar=nil;
+var cmdline:PRtlChar=nil;
 {$endif}
 {$endif}
 
 
 
 
@@ -728,7 +728,8 @@ Function  Sseg:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 ****************************************************************************}
 ****************************************************************************}
 
 
 function strpas(p:pchar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
 function strpas(p:pchar):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
-function strlen(p:pchar):longint;external name 'FPC_PCHAR_LENGTH';
+function strlen(p:pchar):longint;external name 'FPC_PCHAR_LENGTH'; overload;
+function strlen(p:PWideChar):longint; external name 'FPC_PWIDECHAR_LENGTH'; overload;
 
 
 { Shortstring functions }
 { Shortstring functions }
 Procedure Delete(var s:shortstring;index:SizeInt;count:SizeInt);
 Procedure Delete(var s:shortstring;index:SizeInt;count:SizeInt);
@@ -800,9 +801,9 @@ function  lowercase(const s : ansistring) : ansistring;
 ****************************************************************************}
 ****************************************************************************}
 
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:string);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:pchar);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;const Name:RtlString);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;p:PRtlChar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} f:File;c:RtlChar);
 Procedure Rewrite(var f:File;l:Longint);
 Procedure Rewrite(var f:File;l:Longint);
 Procedure Rewrite(var f:File);
 Procedure Rewrite(var f:File);
 Procedure Reset(var f:File;l:Longint);
 Procedure Reset(var f:File;l:Longint);
@@ -825,9 +826,9 @@ Function  FileSize(var f:File):Int64;
 Procedure Seek(var f:File;Pos:Int64);
 Procedure Seek(var f:File;Pos:Int64);
 Function  EOF(var f:File):Boolean;
 Function  EOF(var f:File):Boolean;
 Procedure Erase(var f:File);
 Procedure Erase(var f:File);
-Procedure Rename(var f:File;const s:string);
-Procedure Rename(var f:File;p:pchar);
-Procedure Rename(var f:File;c:char);
+Procedure Rename(var f:File;const s:RtlString);
+Procedure Rename(var f:File;p:PRtlChar);
+Procedure Rename(var f:File;c:RtlChar);
 Procedure Truncate (var F:File);
 Procedure Truncate (var F:File);
 {$endif FPC_HAS_FEATURE_FILEIO}
 {$endif FPC_HAS_FEATURE_FILEIO}
 
 
@@ -849,18 +850,18 @@ Procedure Rewrite(var f : TypedFile); [INTERNPROC: fpc_in_Rewrite_TypedFile];
 ****************************************************************************}
 ****************************************************************************}
 
 
 {$ifdef FPC_HAS_FEATURE_TEXTIO}
 {$ifdef FPC_HAS_FEATURE_TEXTIO}
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:string);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:pchar);
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:RtlString);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:PRtlChar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:RtlChar);
 Procedure Close(var t:Text);
 Procedure Close(var t:Text);
 Procedure Rewrite(var t:Text);
 Procedure Rewrite(var t:Text);
 Procedure Reset(var t:Text);
 Procedure Reset(var t:Text);
 Procedure Append(var t:Text);
 Procedure Append(var t:Text);
 Procedure Flush(var t:Text);
 Procedure Flush(var t:Text);
 Procedure Erase(var t:Text);
 Procedure Erase(var t:Text);
-Procedure Rename(var t:Text;const s:string);
-Procedure Rename(var t:Text;p:pchar);
-Procedure Rename(var t:Text;c:char);
+Procedure Rename(var t:Text;const s:RtlString);
+Procedure Rename(var t:Text;p:PRtlChar);
+Procedure Rename(var t:Text;c:RtlChar);
 Function  EOF(var t:Text):Boolean;
 Function  EOF(var t:Text):Boolean;
 Function  EOF:Boolean;
 Function  EOF:Boolean;
 Function  EOLn(var t:Text):Boolean;
 Function  EOLn(var t:Text):Boolean;
@@ -880,12 +881,12 @@ Procedure SetTextLineEnding(var f:Text; Ending:string);
 
 
 
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-Procedure chdir(const s:string);
-Procedure mkdir(const s:string);
-Procedure rmdir(const s:string);
-Procedure getdir(drivenr:byte;var dir:shortstring);
+Procedure chdir(const s:RtlString);
+Procedure mkdir(const s:RtlString);
+Procedure rmdir(const s:RtlString);
+Procedure getdir(drivenr:byte;var dir:RtlString);
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
-Procedure getdir(drivenr:byte;var dir:ansistring);
+//Procedure getdir(drivenr:byte;var dir:RtlString);
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 {$endif FPC_HAS_FEATURE_ANSISTRINGS}
 {$endif FPC_HAS_FEATURE_FILEIO}
 {$endif FPC_HAS_FEATURE_FILEIO}
 
 

+ 20 - 12
rtl/inc/text.inc

@@ -57,7 +57,7 @@ Begin
      exit;
      exit;
    end;
    end;
   End;
   End;
-  Do_Open(t,PChar(@t.Name),Flags);
+  Do_Open(t,PRtlChar(@t.Name),Flags);
   t.CloseFunc:=@FileCloseFunc;
   t.CloseFunc:=@FileCloseFunc;
   t.FlushFunc:=nil;
   t.FlushFunc:=nil;
   if t.Mode=fmInput then
   if t.Mode=fmInput then
@@ -75,7 +75,7 @@ Begin
 End;
 End;
 
 
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:String);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;const s:RtlString);
 Begin
 Begin
   FillChar(t,SizeOf(TextRec),0);
   FillChar(t,SizeOf(TextRec),0);
 { only set things that are not zero }
 { only set things that are not zero }
@@ -93,15 +93,15 @@ Begin
 End;
 End;
 
 
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:pchar);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;p:PRtlChar);
 begin
 begin
-  Assign(t,StrPas(p));
+  Assign(t,p);
 end;
 end;
 
 
 
 
-Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:char);
+Procedure Assign({$ifdef PARAOUTFILE}out{$else}var{$endif} t:Text;c:RtlChar);
 begin
 begin
-  Assign(t,string(c));
+  Assign(t,RtlString(c));
 end;
 end;
 
 
 
 
@@ -198,25 +198,33 @@ Begin
   If InOutRes <> 0 then
   If InOutRes <> 0 then
    exit;
    exit;
   If TextRec(t).mode=fmClosed Then
   If TextRec(t).mode=fmClosed Then
-   Do_Erase(PChar(@TextRec(t).Name));
+   Do_Erase(PRtlChar(@TextRec(t).Name));
 End;
 End;
 
 
 
 
-Procedure Rename(var t : text;p:pchar);[IOCheck];
+Procedure Rename(var t : text;p:PRtlChar);[IOCheck];
+var
+  len: longint;
 Begin
 Begin
   If InOutRes <> 0 then
   If InOutRes <> 0 then
    exit;
    exit;
   If TextRec(t).mode=fmClosed Then
   If TextRec(t).mode=fmClosed Then
    Begin
    Begin
-     Do_Rename(PChar(@TextRec(t).Name),p);
+     Do_Rename(PRtlChar(@TextRec(t).Name),p);
      { check error code of do_rename }
      { check error code of do_rename }
      If InOutRes = 0 then
      If InOutRes = 0 then
-         Move(p^,TextRec(t).Name,StrLen(p)+1);
+      begin
+        len:=StrLen(p)*SizeOf(RtlChar);
+        if len > SizeOf(TextRec(t).Name) - SizeOf(RtlChar) then
+          len:=SizeOf(TextRec(t).Name) - SizeOf(RtlChar);
+        Move(p^,TextRec(t).Name,len);
+        TextRec(t).Name[len]:=#0;
+      end;
    End;
    End;
 End;
 End;
 
 
 
 
-Procedure Rename(var t : Text;const s : string);[IOCheck];
+Procedure Rename(var t : Text;const s : RtlString);[IOCheck];
 var
 var
   p : array[0..255] Of Char;
   p : array[0..255] Of Char;
 Begin
 Begin
@@ -228,7 +236,7 @@ Begin
 End;
 End;
 
 
 
 
-Procedure Rename(var t : Text;c : char);[IOCheck];
+Procedure Rename(var t : Text;c : RtlChar);[IOCheck];
 var
 var
   p : array[0..1] Of Char;
   p : array[0..1] Of Char;
 Begin
 Begin

+ 2 - 2
rtl/inc/textrec.inc

@@ -25,7 +25,7 @@ const
   TextRecBufSize    = 256;
   TextRecBufSize    = 256;
 type
 type
   TLineEndStr = string [3];
   TLineEndStr = string [3];
-  TextBuf = array[0..TextRecBufSize-1] of char;
+  TextBuf = array[0..(TextRecBufSize div SizeOf(RtlChar))-1] of RtlChar;
   TextRec = Packed Record
   TextRec = Packed Record
     Handle    : THandle;
     Handle    : THandle;
     Mode      : longint;
     Mode      : longint;
@@ -39,7 +39,7 @@ type
     flushfunc,
     flushfunc,
     closefunc : pointer;
     closefunc : pointer;
     UserData  : array[1..32] of byte;
     UserData  : array[1..32] of byte;
-    name      : array[0..textrecnamelength-1] of char;
+    name      : array[0..(TextRecNameLength div SizeOf(RtlChar))-1] of RtlChar;
     LineEnd   : TLineEndStr;
     LineEnd   : TLineEndStr;
     buffer    : textbuf;
     buffer    : textbuf;
   End;
   End;

+ 18 - 19
rtl/win/sysdir.inc

@@ -19,35 +19,34 @@
 *****************************************************************************}
 *****************************************************************************}
 
 
 type
 type
- TDirFnType=function(name:pointer):longbool;stdcall;
+ TDirFnType=function(name:PRtlChar):longbool;stdcall;
 
 
-procedure dirfn(afunc : TDirFnType;const s:string);
+procedure dirfn(afunc : TDirFnType;const s:RtlString);
 var
 var
-  buffer : array[0..255] of char;
+  buffer : RtlString;
 begin
 begin
-  move(s[1],buffer,length(s));
-  buffer[length(s)]:=#0;
-  DoDirSeparators(pchar(@buffer));
-  if not aFunc(@buffer) then
+  buffer:=s;
+  DoDirSeparators(PRtlChar(buffer));
+  if not aFunc(PRtlChar(buffer)) then
     begin
     begin
       errno:=GetLastError;
       errno:=GetLastError;
       Errno2InoutRes;
       Errno2InoutRes;
     end;
     end;
 end;
 end;
 
 
-function CreateDirectoryTrunc(name:pointer):longbool;stdcall;
+function CreateDirectoryTrunc(name:PRtlChar):longbool;stdcall;
 begin
 begin
   CreateDirectoryTrunc:=CreateDirectory(name,nil);
   CreateDirectoryTrunc:=CreateDirectory(name,nil);
 end;
 end;
 
 
-procedure mkdir(const s:string);[IOCHECK];
+procedure mkdir(const s:RtlString);[IOCHECK];
 begin
 begin
   If (s='') or (InOutRes <> 0) then
   If (s='') or (InOutRes <> 0) then
    exit;
    exit;
   dirfn(TDirFnType(@CreateDirectoryTrunc),s);
   dirfn(TDirFnType(@CreateDirectoryTrunc),s);
 end;
 end;
 
 
-procedure rmdir(const s:string);[IOCHECK];
+procedure rmdir(const s:RtlString);[IOCHECK];
 begin
 begin
   if (s ='.') then
   if (s ='.') then
     InOutRes := 16;
     InOutRes := 16;
@@ -64,7 +63,7 @@ begin
 {$endif WINCE}
 {$endif WINCE}
 end;
 end;
 
 
-procedure chdir(const s:string);[IOCHECK];
+procedure chdir(const s:RtlString);[IOCHECK];
 begin
 begin
 {$ifndef WINCE}
 {$ifndef WINCE}
   If (s='') or (InOutRes <> 0) then
   If (s='') or (InOutRes <> 0) then
@@ -77,34 +76,34 @@ begin
 {$endif WINCE}
 {$endif WINCE}
 end;
 end;
 
 
-procedure GetDir (DriveNr: byte; var Dir: ShortString);
+procedure GetDir (DriveNr: byte; var Dir: RtlString);
 {$ifndef WINCE}
 {$ifndef WINCE}
 const
 const
-  Drive:array[0..3]of char=(#0,':',#0,#0);
+  Drive:array[0..3]of RtlChar=(#0,':',#0,#0);
 var
 var
   defaultdrive:boolean;
   defaultdrive:boolean;
-  DirBuf,SaveBuf:array[0..259] of Char;
+  DirBuf,SaveBuf:array[0..259] of RtlChar;
 {$endif WINCE}
 {$endif WINCE}
 begin
 begin
 {$ifndef WINCE}
 {$ifndef WINCE}
   defaultdrive:=drivenr=0;
   defaultdrive:=drivenr=0;
   if not defaultdrive then
   if not defaultdrive then
    begin
    begin
-    byte(Drive[0]):=Drivenr+64;
-    GetCurrentDirectory(SizeOf(SaveBuf),SaveBuf);
+    Drive[0]:=RtlChar(Drivenr+64);
+    GetCurrentDirectory(High(SaveBuf)+1,SaveBuf);
     if not SetCurrentDirectory(@Drive) then
     if not SetCurrentDirectory(@Drive) then
      begin
      begin
       errno := word (GetLastError);
       errno := word (GetLastError);
       Errno2InoutRes;
       Errno2InoutRes;
-      Dir := char (DriveNr + 64) + ':\';
+      Dir := RtlChar (DriveNr + 64) + ':\';
       SetCurrentDirectory(@SaveBuf);
       SetCurrentDirectory(@SaveBuf);
       Exit;
       Exit;
      end;
      end;
    end;
    end;
-  GetCurrentDirectory(SizeOf(DirBuf),DirBuf);
+  GetCurrentDirectory(High(SaveBuf)+1,DirBuf);
   if not defaultdrive then
   if not defaultdrive then
    SetCurrentDirectory(@SaveBuf);
    SetCurrentDirectory(@SaveBuf);
-  dir:=strpas(DirBuf);
+  dir:=DirBuf;
   if not FileNameCaseSensitive then
   if not FileNameCaseSensitive then
    dir:=upcase(dir);
    dir:=upcase(dir);
 {$else WINCE}
 {$else WINCE}

+ 5 - 5
rtl/win/sysfile.inc

@@ -36,7 +36,7 @@ begin
 end;
 end;
 
 
 
 
-procedure do_erase(p : pchar);
+procedure do_erase(p : PRtlChar);
 begin
 begin
    DoDirSeparators(p);
    DoDirSeparators(p);
    if DeleteFile(p)=0 then
    if DeleteFile(p)=0 then
@@ -44,7 +44,7 @@ begin
       errno:=GetLastError;
       errno:=GetLastError;
       if errno=5 then
       if errno=5 then
        begin
        begin
-         if ((GetFileAttributes(p) and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY) then
+         if ((GetFileAttributes(_W(p)) and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY) then
           errno:=2;
           errno:=2;
        end;
        end;
       Errno2InoutRes;
       Errno2InoutRes;
@@ -52,7 +52,7 @@ begin
 end;
 end;
 
 
 
 
-procedure do_rename(p1,p2 : pchar);
+procedure do_rename(p1,p2 : PRtlChar);
 begin
 begin
   DoDirSeparators(p1);
   DoDirSeparators(p1);
   DoDirSeparators(p2);
   DoDirSeparators(p2);
@@ -189,7 +189,7 @@ begin
 end;
 end;
 
 
 
 
-procedure do_open(var f;p:pchar;flags:longint);
+procedure do_open(var f;p:PRtlChar;flags:longint);
 {
 {
   filerec and textrec have both handle and mode as the first items so
   filerec and textrec have both handle and mode as the first items so
   they could use the same routine for opening/creating.
   they could use the same routine for opening/creating.
@@ -276,7 +276,7 @@ begin
   security.nLength := Sizeof(TSecurityAttributes);
   security.nLength := Sizeof(TSecurityAttributes);
   security.bInheritHandle:=true;
   security.bInheritHandle:=true;
   security.lpSecurityDescriptor:=nil;
   security.lpSecurityDescriptor:=nil;
-  filerec(f).handle:=CreateFile(p,oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
+  filerec(f).handle:=CreateFile(_W(p),oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
 
 
   { append mode }
   { append mode }
   if ((flags and $100)<>0) and
   if ((flags and $100)<>0) and

+ 21 - 38
rtl/win/sysos.inc

@@ -111,15 +111,9 @@ type
    UINT  = cardinal;
    UINT  = cardinal;
    BOOL  = longbool;
    BOOL  = longbool;
 //   WCHAR = word;
 //   WCHAR = word;
-{$ifdef UNICODE}
-   LPTCH   = ^word;
-   LPTSTR  = ^word;
-   LPCTSTR = ^word;
-{$else UNICODE}
-   LPTCH   = ^char;
-   LPTSTR  = ^char;
-   LPCTSTR = ^char;
-{$endif UNICODE}
+   LPTCH   = ^wchar;
+   LPTSTR  = ^wchar;
+   LPCTSTR = ^wchar;
    LPWSTR  = ^wchar;
    LPWSTR  = ^wchar;
    PVOID   = pointer;
    PVOID   = pointer;
    LPVOID  = pointer;
    LPVOID  = pointer;
@@ -187,15 +181,12 @@ threadvar
 
 
    { Startup }
    { Startup }
    procedure GetStartupInfo(p : pointer);
    procedure GetStartupInfo(p : pointer);
-     stdcall;external KernelDLL name 'GetStartupInfoA';
+     stdcall;external KernelDLL name 'GetStartupInfoW';
    function GetStdHandle(nStdHandle:DWORD):THANDLE;
    function GetStdHandle(nStdHandle:DWORD):THANDLE;
      stdcall;external KernelDLL name 'GetStdHandle';
      stdcall;external KernelDLL name 'GetStdHandle';
 
 
    { command line/enviroment functions }
    { command line/enviroment functions }
-   function GetCommandLine : pchar;
-     stdcall;external KernelDLL name 'GetCommandLineA';
-
-   function GetCommandLineW : pwidechar;
+   function GetCommandLine : pwidechar;
      stdcall;external KernelDLL name 'GetCommandLineW';
      stdcall;external KernelDLL name 'GetCommandLineW';
 
 
   function GetCurrentProcessId:DWORD;
   function GetCurrentProcessId:DWORD;
@@ -206,10 +197,10 @@ threadvar
 {$endif WINCE}
 {$endif WINCE}
 
 
    { module functions }
    { module functions }
-   function GetModuleFileName(l1:longint;p:pointer;l2:longint):longint;
-     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleFileName' + ApiSuffix;
-   function GetModuleHandle(p : pointer) : PtrUInt;
-     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleHandle' + ApiSuffix;
+   function GetModuleFileName(l1:thandle;p:pwidechar;l2:dword):longint;
+     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleFileNameW';
+   function GetModuleHandle(p : pwidechar) : PtrUInt;
+     {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'GetModuleHandleW';
 
 
    { file functions }
    { file functions }
    function WriteFile(fh:thandle;buf:pointer;len:longint;var loaded:longint;
    function WriteFile(fh:thandle;buf:pointer;len:longint;var loaded:longint;
@@ -229,30 +220,22 @@ threadvar
    function FreeLibrary(hLibModule:THandle):ByteBool; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'FreeLibrary';
    function FreeLibrary(hLibModule:THandle):ByteBool; {$ifdef wince}cdecl{$else}stdcall{$endif};external KernelDLL name 'FreeLibrary';
 
 
 {$ifndef WINCE}
 {$ifndef WINCE}
-   function LoadLibrary(lpLibFileName:pchar):THandle; stdcall; external KernelDLL name 'LoadLibraryA';
-   function GetFileType(Handle:thandle):DWord;
-     stdcall;external KernelDLL name 'GetFileType';
-   function GetFileAttributes(p : pchar) : dword;
-     stdcall;external KernelDLL name 'GetFileAttributesA';
-   function DeleteFile(p : pchar) : longint;
-     stdcall;external KernelDLL name 'DeleteFileA';
-   function MoveFile(old,_new : pchar) : longint;
-     stdcall;external KernelDLL name 'MoveFileA';
-   function CreateFile(lpFileName:pchar; dwDesiredAccess:DWORD; dwShareMode:DWORD;
+   function LoadLibrary(lpLibFileName:pwidechar):THandle; stdcall; external KernelDLL name 'LoadLibraryW';
+   function GetFileType(Handle:thandle):DWord; stdcall;external KernelDLL name 'GetFileType';
+   function GetFileAttributes(p : pwidechar) : dword; stdcall;external KernelDLL name 'GetFileAttributesW';
+   function DeleteFile(p : pwidechar) : longint; stdcall;external KernelDLL name 'DeleteFileW';
+   function MoveFile(old,_new : pwidechar) : longint; stdcall;external KernelDLL name 'MoveFileW';
+   function CreateFile(lpFileName:pwidechar; dwDesiredAccess:DWORD; dwShareMode:DWORD;
                        lpSecurityAttributes:PSECURITYATTRIBUTES; dwCreationDisposition:DWORD;
                        lpSecurityAttributes:PSECURITYATTRIBUTES; dwCreationDisposition:DWORD;
                        dwFlagsAndAttributes:DWORD; hTemplateFile:DWORD):THandle;
                        dwFlagsAndAttributes:DWORD; hTemplateFile:DWORD):THandle;
-     stdcall;external KernelDLL name 'CreateFileA';
-   function GetProcAddress(hModule:THandle; lpProcName:pchar):pointer; stdcall; external KernelDLL name 'GetProcAddress';
+     stdcall;external KernelDLL name 'CreateFileW';
+   function GetProcAddress(hModule:THandle; lpProcName:pansichar):pointer; stdcall; external KernelDLL name 'GetProcAddress';
 
 
    { Directory }
    { Directory }
-   function CreateDirectory(name : pointer;sec : pointer) : longbool;
-     stdcall;external KernelDLL name 'CreateDirectoryA';
-   function RemoveDirectory(name:pointer):longbool;
-     stdcall;external KernelDLL name 'RemoveDirectoryA';
-   function SetCurrentDirectory(name : pointer) : longbool;
-     stdcall;external KernelDLL name 'SetCurrentDirectoryA';
-   function GetCurrentDirectory(bufsize : longint;name : pchar) : longbool;
-     stdcall;external KernelDLL name 'GetCurrentDirectoryA';
+   function CreateDirectory(name : pwidechar;sec : pointer) : longbool; stdcall;external KernelDLL name 'CreateDirectoryW';
+   function RemoveDirectory(name:pwidechar):longbool; stdcall;external KernelDLL name 'RemoveDirectoryW';
+   function SetCurrentDirectory(name : pwidechar) : longbool; stdcall;external KernelDLL name 'SetCurrentDirectoryW';
+   function GetCurrentDirectory(bufsize : longint;name : pwidechar) : longbool; stdcall;external KernelDLL name 'GetCurrentDirectoryW';
 
 
    var
    var
      SetFilePointerEx : function(hFile : THandle;
      SetFilePointerEx : function(hFile : THandle;

+ 0 - 2
rtl/win/sysosh.inc

@@ -52,10 +52,8 @@ type
 const
 const
 {$ifdef WINCE}
 {$ifdef WINCE}
   KernelDLL = 'coredll';
   KernelDLL = 'coredll';
-  ApiSuffix = 'W';
 {$else WINCE}
 {$else WINCE}
   KernelDLL = 'kernel32';
   KernelDLL = 'kernel32';
-  ApiSuffix = 'A';
 {$endif WINCE}
 {$endif WINCE}
 
 
 function OleStrToString(source: PWideChar) : ansistring;inline;
 function OleStrToString(source: PWideChar) : ansistring;inline;

+ 10 - 4
rtl/win32/system.pp

@@ -97,7 +97,7 @@ type
 var
 var
 { C compatible arguments }
 { C compatible arguments }
   argc : longint;
   argc : longint;
-  argv : ppchar;
+  argv : ^PRtlChar;
 { Win32 Info }
 { Win32 Info }
   startupinfo : tstartupinfo;
   startupinfo : tstartupinfo;
   hprevinst,
   hprevinst,
@@ -118,6 +118,11 @@ const
 
 
 implementation
 implementation
 
 
+function _W(const s: RtlString): PWideChar; inline;
+begin
+  Result:=PWideChar(UnicodeString(s));
+end;
+
 var
 var
   EntryInformation : TEntryInformation;
   EntryInformation : TEntryInformation;
   SysInstance : Longint;public name '_FPC_SysInstance';
   SysInstance : Longint;public name '_FPC_SysInstance';
@@ -147,10 +152,11 @@ var
   arglen,
   arglen,
   count   : longint;
   count   : longint;
   argstart,
   argstart,
-  pc,arg  : pchar;
+  pc      : pwidechar;
+  arg     : PRtlChar;
   quote   : Boolean;
   quote   : Boolean;
   argvlen : longint;
   argvlen : longint;
-  buf: array[0..259] of char;  // need MAX_PATH bytes, not 256!
+  buf: array[0..259] of WideChar;  // need MAX_PATH bytes, not 256!
 
 
   procedure allocarg(idx,len:longint);
   procedure allocarg(idx,len:longint);
     var
     var
@@ -176,7 +182,7 @@ begin
   count:=0;
   count:=0;
   argv:=nil;
   argv:=nil;
   argvlen:=0;
   argvlen:=0;
-  ArgLen := GetModuleFileName(0, @buf[0], sizeof(buf));
+  ArgLen := GetModuleFileName(0, @buf[0], High(buf)-1);
   buf[ArgLen] := #0; // be safe
   buf[ArgLen] := #0; // be safe
   allocarg(0,arglen);
   allocarg(0,arglen);
   move(buf,argv[0]^,arglen+1);
   move(buf,argv[0]^,arglen+1);