Some minor comments:
Unit system:
The type declarations (especially string=bpstring with -D_Borland_Pascal_ should be in system.pas itself (or $included) rather than in a separate unit (gpctypes.pas) so that programs that use only system will see them.
My suggestion: remove the "{$W-}". Doing so will reveal a little bug in BinEof (a "=" used instead of ":="), and a lot of problem in FillChar and Move (which are not really portable, anyway). Until a (more optimized) version of them will be built in, here are some replacements (a bit slower, but should be portable and generate no warnings):
Procedure FillChar ( Var Dest : Void; Count : Integer; C : Char ); Var z:Integer; begin for z:=0 to Count-1 do TCharArray(Dest)[z] := C end;
Procedure Move ( Var Source, Dest : Void; Count : Integer ); Const PtrBitSize = BitSizeOf(Pointer); Type PtrCard = Cardinal(PtrBitSize); Var z:Integer; begin { Avoid overwriting of overlapping memory areas } if PtrCard (@Source) > PtrCard (@Dest) then for z:=0 to Count-1 do TCharArray(Dest)[z] := TCharArray(Source)[z] else for z:=Count-1 downto 0 do TCharArray(Dest)[z] := TCharArray(Source)[z] end;
To make it work, you have to remove the (now obsolete) declaration of Cardinal (and perferably ByteInt and Byte as well) from gpctypes.pas.
For the other type declarations, I suggest you use the more modern GPC integer types (as invented some months ago), rather than the old style __modifiers__. (Also for real types.)
With -D_Borland_16_Bit_, also redeclare Integer to be a 16 bit type, otherwise it'll probably confuse some BP programs.
A test program for FillChar and Move:
program x; uses system;
var a:array[1..20] of char; b:integer;
begin a:='foo'; fillchar(a[3],10,'x'); writeln(a); move(a[1],a[10],5); writeln(a); move(a[10],a[2],3); writeln(a) end.
The correct output is: foxxxxxxxxxx foxxxxxxxfoxxx ffoxxxxxxfoxxx
Procedures assgined to procedural variables can be in the main program now, so you can remove this comment for ExitProc.
I think it's not a good idea to declare BP variables like ErrorAddr that are not implemented in GPC. I'd prefer a compile time error when porting a BP program using them rather than possible unexpected problems at runtime.
Assign is built-in now, so you can remove it from system.pas. Str, Val, Insert and Delete will be soon... :-), perhaps also Pos, Copy, ParamCount, ParamStr, Int and Frac.
Unit Dos:
SearchRec, FindFirst, FindNext and GetEnv are not really BP compatible (also note the difference between SearchRec and TSearchRec in BP).
SwapVectors should be declared as an empty procedure.
Unit Printer:
can be written now (at least for DJGPP).
Frank Heckenbach wrote:
Some minor comments:
Unit system:
The type declarations (especially string=bpstring with -D_Borland_Pascal_ should be in system.pas itself (or $included) rather than in a separate unit (gpctypes.pas) so that programs that use only system will see them.
Yes, I had wondered about merging GPCTYPES with SYSTEM. I agree that they should be merged.
My suggestion: remove the "{$W-}". Doing so will reveal a little bug in BinEof (a "=" used instead of ":="),
Ooops! ;-/
and a lot of problem in FillChar and Move (which are not really portable, anyway). Until a (more optimized) version of them will be built in, here are some replacements (a bit slower, but should be portable and generate no warnings):
Okay thanks. I have replaced the current versions with your version.
For the other type declarations, I suggest you use the more modern GPC integer types (as invented some months ago), rather than the old style __modifiers__. (Also for real types.)
Frankly, I am totally lost as far as that is concerned. Is there any authoritative list of all the numerical types?
With -D_Borland_16_Bit_, also redeclare Integer to be a 16 bit type, otherwise it'll probably confuse some BP programs.
Done!
Procedures assgined to procedural variables can be in the main program now, so you can remove this comment for ExitProc.
I am still having some problems with this.
I think it's not a good idea to declare BP variables like ErrorAddr that are not implemented in GPC. I'd prefer a compile time error when porting a BP program using them rather than possible unexpected problems at runtime.
Fair enough. I have commented most of them out.
Assign is built-in now, so you can remove it from system.pas.
Done. Does it now cater for all file types?
Str, Val, Insert and Delete will be soon... :-), perhaps also Pos, Copy, ParamCount, ParamStr, Int and Frac.
Great!
Unit Dos:
SearchRec, FindFirst, FindNext and GetEnv are not really BP compatible (also note the difference between SearchRec and TSearchRec in BP).
Basically, DOS is a beast of a unit to implement - especially the Findxxx functions. There are still problems with a "DIR" listing using these functions if there are .EXE files in the list. There are all sorts of other problems as well. I don't think it will ever be portable. I have given up on the DOS unit. If someone else wants to do it, please feel free!
SwapVectors should be declared as an empty procedure.
Done!
Unit Printer:
can be written now (at least for DJGPP).
Done!
Thanks for the comments, suggestions, and code snippets!
Best regards, The Chief -------- Dr. Abimbola A. Olowofoyeku (The African Chief) Email: laa12@keele.ac.uk Author of: Chief's Installer Pro 4.01 for Win16 and Win32: Winner of PC PLUS Magazine Gold Award (April 1995 U.K. edition) http://ourworld.compuserve.com/homepages/African_Chief/
ftp://ftp.demon.co.uk/pub/ibmpc/win3/apps/chief/pro/chief401.zip