Re: BPCOMPAT v1.10 -released!
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, Erlangen, Germany heckenb@mi.uni-erlangen.de http://home.pages.de/~fjf/links.htm
participants (2)
-
Frank Heckenbach -
The African Chief