Browse Source

* Char -> AnsiChar

Michael VAN CANNEYT 2 years ago
parent
commit
2ce2bab2a6
7 changed files with 59 additions and 59 deletions
  1. 8 8
      rtl/wasi/dos.pp
  2. 4 4
      rtl/wasi/sysdir.inc
  3. 6 6
      rtl/wasi/sysfile.inc
  4. 7 7
      rtl/wasi/system.pp
  5. 18 18
      rtl/wasi/sysutils.pp
  6. 13 13
      rtl/wasi/wasiinc/wasiprocs.inc
  7. 3 3
      rtl/wasi/wasiutil.pp

+ 8 - 8
rtl/wasi/dos.pp

@@ -60,7 +60,7 @@ Uses
 {$DEFINE HAS_GETMSCOUNT}
 
 {$DEFINE FPC_FEXPAND_TILDE} { Tilde is expanded to home }
-{$DEFINE FPC_FEXPAND_GETENVPCHAR} { GetEnv result is a PChar }
+{$DEFINE FPC_FEXPAND_GETENVPCHAR} { GetEnv result is a PAnsiChar }
 
 {$I dos.inc}
 
@@ -222,7 +222,7 @@ End;
   They both return -1 when a failure occurs.
 }
 Const
-  FixDriveStr : array[0..3] of pchar=(
+  FixDriveStr : array[0..3] of PAnsiChar=(
     '.',
     '/fd0/.',
     '/fd1/.',
@@ -231,7 +231,7 @@ Const
 const
   Drives   : byte = 4;
 var
-  DriveStr : array[4..26] of pchar;
+  DriveStr : array[4..26] of PAnsiChar;
 
 Function AddDisk(const path:string) : byte;
 begin
@@ -424,7 +424,7 @@ Begin
       DosError:=3;
       exit;
     end;
-  if __wasi_path_filestat_get(fd,__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW,PChar(pr),length(pr),@Info)<>__WASI_ERRNO_SUCCESS then
+  if __wasi_path_filestat_get(fd,__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW,PAnsiChar(pr),length(pr),@Info)<>__WASI_ERRNO_SUCCESS then
     begin
       DosError:=3;
       exit;
@@ -475,7 +475,7 @@ Begin
       doserror:=3;
       exit;
     end;
-  if __wasi_path_filestat_set_times(fd,0,PChar(pr),length(pr),0,modtime,
+  if __wasi_path_filestat_set_times(fd,0,PAnsiChar(pr),length(pr),0,modtime,
      __WASI_FSTFLAGS_MTIM or __WASI_FSTFLAGS_ATIM_NOW)<>__WASI_ERRNO_SUCCESS then
     doserror:=3;
 End;
@@ -487,7 +487,7 @@ End;
 Function EnvCount: Longint;
 var
   envcnt : longint;
-  p      : ppchar;
+  p      : PPAnsiChar;
 Begin
   envcnt:=0;
   p:=envp;      {defined in system}
@@ -504,7 +504,7 @@ End;
 Function EnvStr (Index: longint): String;
 Var
   i : longint;
-  p : ppchar;
+  p : PPAnsiChar;
 Begin
   if (Index <= 0) or (envp=nil) then
     envstr:=''
@@ -527,7 +527,7 @@ end;
 
 Function GetEnv(EnvVar: String): String;
 var
-  hp : ppchar;
+  hp : PPAnsiChar;
   hs : string;
   eqpos : longint;
 Begin

+ 4 - 4
rtl/wasi/sysdir.inc

@@ -27,7 +27,7 @@ begin
   InOutRes:=ConvertToFdRelativePath(s,fd,pr);
   if InOutRes<>0 then
     exit;
-  res:=__wasi_path_create_directory(fd,PChar(pr),Length(pr));
+  res:=__wasi_path_create_directory(fd,PAnsiChar(pr),Length(pr));
   if res<>__WASI_ERRNO_SUCCESS then
     InOutRes:=Errno2InoutRes(res);
 end;
@@ -41,7 +41,7 @@ begin
   InOutRes:=ConvertToFdRelativePath(s,fd,pr);
   if InOutRes<>0 then
     exit;
-  res:=__wasi_path_remove_directory(fd,PChar(pr),Length(pr));
+  res:=__wasi_path_remove_directory(fd,PAnsiChar(pr),Length(pr));
   if res<>__WASI_ERRNO_SUCCESS then
     InOutRes:=Errno2InoutRes(res);
 end;
@@ -137,7 +137,7 @@ begin
           InOutRes:=3;
           exit;
         end;
-        res:=__wasi_path_filestat_get(fd,0,PChar(pr),Length(pr),@st);
+        res:=__wasi_path_filestat_get(fd,0,PAnsiChar(pr),Length(pr),@st);
         if res<>__WASI_ERRNO_SUCCESS then
         begin
           if res=__WASI_ERRNO_NOENT then
@@ -148,7 +148,7 @@ begin
         end;
         if st.filetype=__WASI_FILETYPE_SYMBOLIC_LINK then
         begin
-          res:=fpc_wasi_path_readlink_ansistring(fd,PChar(pr),Length(pr),symlink);
+          res:=fpc_wasi_path_readlink_ansistring(fd,PAnsiChar(pr),Length(pr),symlink);
           if res<>__WASI_ERRNO_SUCCESS then
           begin
             InOutRes:=Errno2InoutRes(res);

+ 6 - 6
rtl/wasi/sysfile.inc

@@ -26,7 +26,7 @@ begin
     InOutRes:=Errno2InoutRes(res);
 end;
 
-procedure Do_Erase(p: pchar; pchangeable: boolean);
+procedure Do_Erase(p: PAnsiChar; pchangeable: boolean);
 var
   fd: __wasi_fd_t;
   pr: RawByteString;
@@ -35,7 +35,7 @@ begin
   InOutRes:=ConvertToFdRelativePath(p,fd,pr);
   if InOutRes<>0 then
     exit;
-  res:=__wasi_path_unlink_file(fd,PChar(pr),Length(pr));
+  res:=__wasi_path_unlink_file(fd,PAnsiChar(pr),Length(pr));
   if res<>__WASI_ERRNO_SUCCESS then
     InOutRes:=Errno2InoutRes(res);
 end;
@@ -51,7 +51,7 @@ begin
     InOutRes:=Errno2InoutRes(res);
 end;
 
-procedure Do_Rename(p1,p2:pchar; p1changeable, p2changeable: boolean);
+procedure Do_Rename(p1,p2:PAnsiChar; p1changeable, p2changeable: boolean);
 var
   fd1,fd2: __wasi_fd_t;
   pr1,pr2: RawByteString;
@@ -63,7 +63,7 @@ begin
   InOutRes:=ConvertToFdRelativePath(p2,fd2,pr2);
   if InOutRes<>0 then
     exit;
-  res:=__wasi_path_rename(fd1,PChar(pr1),Length(pr1),fd2,PChar(pr2),Length(pr2));
+  res:=__wasi_path_rename(fd1,PAnsiChar(pr1),Length(pr1),fd2,PAnsiChar(pr2),Length(pr2));
   if res<>__WASI_ERRNO_SUCCESS then
     InOutRes:=Errno2InoutRes(res);
 end;
@@ -180,7 +180,7 @@ begin
   end;
 end;
 
-procedure Do_Open(var f; p: pchar; flags: longint; pchangeable: boolean);
+procedure Do_Open(var f; p: PAnsiChar; flags: longint; pchangeable: boolean);
 {
   FileRec and textrec have both Handle and mode as the first items so
   they could use the same routine for opening/creating.
@@ -285,7 +285,7 @@ Begin
   repeat
     res:=__wasi_path_open(fd,
                           0,
-                          PChar(pr),
+                          PAnsiChar(pr),
                           length(pr),
                           oflags,
                           fs_rights_base,

+ 7 - 7
rtl/wasi/system.pp

@@ -33,8 +33,8 @@ const
   DriveSeparator = '';
   ExtensionSeparator = '.';
   PathSeparator = ':';
-  AllowDirectorySeparators : set of char = ['\','/'];
-  AllowDriveSeparators : set of char = [];
+  AllowDirectorySeparators : set of AnsiChar = ['\','/'];
+  AllowDriveSeparators : set of AnsiChar = [];
 {  FileNameCaseSensitive and FileNameCasePreserving are defined below! }
   maxExitCode = 65535;
   MaxPathLen = 4096;
@@ -55,8 +55,8 @@ const
 
 var
   argc: longint;
-  argv: PPChar;
-  envp: PPChar;
+  argv: PPAnsiChar;
+  envp: PPAnsiChar;
   ___fpc_wasm_suspender: WasmExternRef; section 'WebAssembly.Global';
 
 function __fpc_get_wasm_suspender: WasmExternRef;
@@ -98,7 +98,7 @@ function ConvertToFdRelativePath(path: RawByteString; out fd: LongInt; out relfd
 
 function fpc_wasi_path_readlink_ansistring(
                  fd: __wasi_fd_t;
-                 const path: PChar;
+                 const path: PAnsiChar;
                  path_len: size_t;
                  out link: rawbytestring): __wasi_errno_t;[Public, Alias : 'FPC_WASI_PATH_READLINK_ANSISTRING'];
 const
@@ -323,7 +323,7 @@ begin
     envp:=nil;
     exit;
   end;
-  envp_size:=(environc+1)*SizeOf(PChar);
+  envp_size:=(environc+1)*SizeOf(PAnsiChar);
   GetMem(envp, envp_size);
   GetMem(environ_buf, environ_buf_size);
   envp[environc]:=nil;
@@ -345,7 +345,7 @@ begin
     argv:=nil;
     exit;
   end;
-  argv_size:=(argc+1)*SizeOf(PChar);
+  argv_size:=(argc+1)*SizeOf(PAnsiChar);
   GetMem(argv, argv_size);
   GetMem(argv_buf, argv_buf_size);
   if __wasi_args_get(Pointer(argv), argv_buf)<>__WASI_ERRNO_SUCCESS then

+ 18 - 18
rtl/wasi/sysutils.pp

@@ -94,7 +94,7 @@ end;
                               File Functions
 ****************************************************************************}
 
-Function WasiToWinAttr (const FN : RawByteString; fd: __wasi_fd_t; pr: PChar; pr_len: size_t; Const Info : __wasi_filestat_t) : Longint;
+Function WasiToWinAttr (const FN : RawByteString; fd: __wasi_fd_t; pr: PAnsiChar; pr_len: size_t; Const Info : __wasi_filestat_t) : Longint;
 Var
   LinkInfo : __wasi_filestat_t;
   nm : RawByteString;
@@ -176,7 +176,7 @@ Begin
   repeat
     res:=__wasi_path_open(fd,
                           0,
-                          PChar(pr),
+                          PAnsiChar(pr),
                           length(pr),
                           0,
                           fs_rights_base,
@@ -221,7 +221,7 @@ Begin
   repeat
     res:=__wasi_path_open(fd,
                           0,
-                          PChar(pr),
+                          PAnsiChar(pr),
                           length(pr),
                           __WASI_OFLAGS_CREAT or __WASI_OFLAGS_TRUNC,
                           fs_rights_base,
@@ -347,7 +347,7 @@ begin
       result:=-1;
       exit;
     end;
-  res:=__wasi_path_filestat_get(fd,0,PChar(pr),length(pr),@Info);
+  res:=__wasi_path_filestat_get(fd,0,PAnsiChar(pr),length(pr),@Info);
   if res=__WASI_ERRNO_SUCCESS then
     result:=Info.mtim div 1000000000
   else
@@ -367,18 +367,18 @@ begin
   result:=false;
   if ConvertToFdRelativePath(FileName,fd,pr)<>0 then
     exit;
-  if __wasi_path_filestat_get(fd,0,PChar(pr),length(pr),@Info)<>__WASI_ERRNO_SUCCESS then
+  if __wasi_path_filestat_get(fd,0,PAnsiChar(pr),length(pr),@Info)<>__WASI_ERRNO_SUCCESS then
     exit;
   if Info.filetype<>__WASI_FILETYPE_SYMBOLIC_LINK then
     exit;
-  if fpc_wasi_path_readlink_ansistring(fd,PChar(pr),Length(pr),symlink)<>__WASI_ERRNO_SUCCESS then
+  if fpc_wasi_path_readlink_ansistring(fd,PAnsiChar(pr),Length(pr),symlink)<>__WASI_ERRNO_SUCCESS then
     exit;
   SymLinkRec.TargetName:=symlink;
 
-  res:=__wasi_path_filestat_get(fd,__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW,PChar(pr),length(pr),@Info);
+  res:=__wasi_path_filestat_get(fd,__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW,PAnsiChar(pr),length(pr),@Info);
   if res<>__WASI_ERRNO_SUCCESS then
     raise EDirectoryNotFoundException.Create('Error ' + IntToStr(res){todo: SysErrorMessage SysErrorMessage(GetLastOSError)});
-  SymLinkRec.Attr := WasiToWinAttr(FileName,fd,PChar(pr),length(pr),Info);
+  SymLinkRec.Attr := WasiToWinAttr(FileName,fd,PAnsiChar(pr),length(pr),Info);
   SymLinkRec.Size := Info.size;
   result:=true;
 end;
@@ -399,7 +399,7 @@ begin
     flags:=__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW
   else
     flags:=0;
-  if __wasi_path_filestat_get(fd,flags,PChar(pr),length(pr),@Info)=__WASI_ERRNO_SUCCESS then
+  if __wasi_path_filestat_get(fd,flags,PAnsiChar(pr),length(pr),@Info)=__WASI_ERRNO_SUCCESS then
     result:=Info.filetype<>__WASI_FILETYPE_DIRECTORY
   else
     result:=false;
@@ -421,7 +421,7 @@ begin
     flags:=__WASI_LOOKUPFLAGS_SYMLINK_FOLLOW
   else
     flags:=0;
-  if __wasi_path_filestat_get(fd,flags,PChar(pr),length(pr),@Info)=__WASI_ERRNO_SUCCESS then
+  if __wasi_path_filestat_get(fd,flags,PAnsiChar(pr),length(pr),@Info)=__WASI_ERRNO_SUCCESS then
     result:=Info.filetype=__WASI_FILETYPE_DIRECTORY
   else
     result:=false;
@@ -508,7 +508,7 @@ begin
       result:=-1;
       exit;
     end;
-  if __wasi_path_filestat_set_times(fd,0,PChar(pr),length(pr),Age*1000000000,Age*1000000000,
+  if __wasi_path_filestat_set_times(fd,0,PAnsiChar(pr),length(pr),Age*1000000000,Age*1000000000,
      __WASI_FSTFLAGS_MTIM or __WASI_FSTFLAGS_ATIM)=__WASI_ERRNO_SUCCESS then
     result:=0
   else
@@ -527,8 +527,8 @@ begin
       result:=-1;
       exit;
     end;
-  if __wasi_path_filestat_get(fd,0,PChar(pr),length(pr),@Info)=__WASI_ERRNO_SUCCESS then
-    result:=WasiToWinAttr(FileName,fd,PChar(pr),length(pr),Info)
+  if __wasi_path_filestat_get(fd,0,PAnsiChar(pr),length(pr),@Info)=__WASI_ERRNO_SUCCESS then
+    result:=WasiToWinAttr(FileName,fd,PAnsiChar(pr),length(pr),Info)
   else
     result:=-1;
 end;
@@ -551,7 +551,7 @@ begin
       result:=false;
       exit;
     end;
-  result:=__wasi_path_unlink_file(fd,PChar(pr),Length(pr))=__WASI_ERRNO_SUCCESS;
+  result:=__wasi_path_unlink_file(fd,PAnsiChar(pr),Length(pr))=__WASI_ERRNO_SUCCESS;
 end;
 
 
@@ -566,7 +566,7 @@ begin
     exit;
   if ConvertToFdRelativePath(NewName,fd2,pr2)<>0 then
     exit;
-  result:=__wasi_path_rename(fd1,PChar(pr1),Length(pr1),fd2,PChar(pr2),Length(pr2))=__WASI_ERRNO_SUCCESS;
+  result:=__wasi_path_rename(fd1,PAnsiChar(pr1),Length(pr1),fd2,PAnsiChar(pr2),Length(pr2))=__WASI_ERRNO_SUCCESS;
 end;
 
 
@@ -663,7 +663,7 @@ end;
 
 Function GetEnvironmentVariable(Const EnvVar : String) : String;
 var
-  hp : ppchar;
+  hp : PPAnsiChar;
   hs : string;
   eqpos : longint;
 begin
@@ -685,7 +685,7 @@ end;
 
 Function GetEnvironmentVariableCount : Integer;
 var
-  p: ppchar;
+  p: PPAnsiChar;
 begin
   result:=0;
   p:=envp;      {defined in system}
@@ -700,7 +700,7 @@ end;
 Function GetEnvironmentString(Index : Integer) : {$ifdef FPC_RTL_UNICODE}UnicodeString{$else}AnsiString{$endif};
 Var
   i : longint;
-  p : ppchar;
+  p : PPAnsiChar;
 begin
   if (Index <= 0) or (envp=nil) then
     result:=''

+ 13 - 13
rtl/wasi/wasiinc/wasiprocs.inc

@@ -170,14 +170,14 @@ function __wasi_fd_write(
 
 function __wasi_path_create_directory(
   fd: __wasi_fd_t;
-  const path: PChar;
+  const path: PAnsiChar;
   path_len: size_t
 ): __wasi_errno_t; external 'wasi_snapshot_preview1' name 'path_create_directory';
 
 function __wasi_path_filestat_get(
   fd: __wasi_fd_t;
   flags: __wasi_lookupflags_t;
-  const path: PChar;
+  const path: PAnsiChar;
   path_len: size_t;
   buf: P__wasi_filestat_t
 ): __wasi_errno_t; external 'wasi_snapshot_preview1' name 'path_filestat_get';
@@ -185,7 +185,7 @@ function __wasi_path_filestat_get(
 function __wasi_path_filestat_set_times(
   fd: __wasi_fd_t;
   flags: __wasi_lookupflags_t;
-  const path: PChar;
+  const path: PAnsiChar;
   path_len: size_t;
   atim: __wasi_timestamp_t;
   mtim: __wasi_timestamp_t;
@@ -195,17 +195,17 @@ function __wasi_path_filestat_set_times(
 function __wasi_path_link(
   old_fd: __wasi_fd_t;
   old_flags: __wasi_lookupflags_t;
-  const old_path: PChar;
+  const old_path: PAnsiChar;
   old_path_len: size_t;
   new_fd: __wasi_fd_t;
-  const new_path: PChar;
+  const new_path: PAnsiChar;
   new_path_len: size_t
 ): __wasi_errno_t; external 'wasi_snapshot_preview1' name 'path_link';
 
 function __wasi_path_open(
   fd: __wasi_fd_t;
   dirflags: __wasi_lookupflags_t;
-  const path: PChar;
+  const path: PAnsiChar;
   path_len: size_t;
   oflags: __wasi_oflags_t;
   fs_rights_base: __wasi_rights_t;
@@ -216,7 +216,7 @@ function __wasi_path_open(
 
 function __wasi_path_readlink(
   fd: __wasi_fd_t;
-  const path: PChar;
+  const path: PAnsiChar;
   path_len: size_t;
   buf: PUInt8;
   buf_len: __wasi_size_t;
@@ -225,30 +225,30 @@ function __wasi_path_readlink(
 
 function __wasi_path_remove_directory(
   fd: __wasi_fd_t;
-  const path: PChar;
+  const path: PAnsiChar;
   path_len: size_t
 ): __wasi_errno_t; external 'wasi_snapshot_preview1' name 'path_remove_directory';
 
 function __wasi_path_rename(
   fd: __wasi_fd_t;
-  const old_path: PChar;
+  const old_path: PAnsiChar;
   old_path_len: size_t;
   new_fd: __wasi_fd_t;
-  const new_path: PChar;
+  const new_path: PAnsiChar;
   new_path_len: size_t
 ): __wasi_errno_t; external 'wasi_snapshot_preview1' name 'path_rename';
 
 function __wasi_path_symlink(
-  const old_path: PChar;
+  const old_path: PAnsiChar;
   old_path_len: size_t;
   fd: __wasi_fd_t;
-  const new_path: PChar;
+  const new_path: PAnsiChar;
   new_path_len: size_t
 ): __wasi_errno_t; external 'wasi_snapshot_preview1' name 'path_symlink';
 
 function __wasi_path_unlink_file(
   fd: __wasi_fd_t;
-  const path: PChar;
+  const path: PAnsiChar;
   path_len: size_t
 ): __wasi_errno_t; external 'wasi_snapshot_preview1' name 'path_unlink_file';
 

+ 3 - 3
rtl/wasi/wasiutil.pp

@@ -39,7 +39,7 @@ type
   End;
 
 function ConvertToFdRelativePath(path: RawByteString; out fd: LongInt; out relfd_path: RawByteString): Word; external name 'FPC_WASI_CONVERTTOFDRELATIVEPATH';
-function fpc_wasi_path_readlink_ansistring(fd: __wasi_fd_t; const path: PChar; path_len: size_t; out link: rawbytestring): __wasi_errno_t; external name 'FPC_WASI_PATH_READLINK_ANSISTRING';
+function fpc_wasi_path_readlink_ansistring(fd: __wasi_fd_t; const path: PAnsiChar; path_len: size_t; out link: rawbytestring): __wasi_errno_t; external name 'FPC_WASI_PATH_READLINK_ANSISTRING';
 function FNMatch(const Pattern,Name:rawbytestring):Boolean;
 function WasiFindFirst(const Path: RawByteString; Attr: Word; var f: TWasiSearchRec): longint;
 function WasiFindNext(var f: TWasiSearchRec): longint;
@@ -198,7 +198,7 @@ begin
   if ConvertToFdRelativePath(s,fd,pr)<>0 then
     exit;
   { todo: __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW??? }
-  if __wasi_path_filestat_get(fd,0,PChar(pr),Length(pr),@st)<>__WASI_ERRNO_SUCCESS then
+  if __wasi_path_filestat_get(fd,0,PAnsiChar(pr),Length(pr),@st)<>__WASI_ERRNO_SUCCESS then
     exit;
   info.FSize:=st.size;
   info.FMTime:=st.mtim;
@@ -290,7 +290,7 @@ Begin
            repeat
              res:=__wasi_path_open(fd,
                                    0,
-                                   PChar(pr),
+                                   PAnsiChar(pr),
                                    length(pr),
                                    __WASI_OFLAGS_DIRECTORY,
                                    __WASI_RIGHTS_FD_READDIR,