[fpc-devel]ParamStr & argv bug in FPC/2
KO Myung-Hun
komh at chollian.net
Sat Nov 11 16:52:39 CET 2000
Hi/2 all.
I posted writing about MAKE & 0th Parameter previously. At first,
I thought that it was a bug of MAKE, however Virtual Pascal or BC++
worked well. Only FPC/2 and GCC/EMX casued a corrupt result.
Maybe, this is a bug of EMX startup code. I know, FPC/2 also is using
startup code converted from EMX sources.
In VP, 0th parameter is processed separately. I applied the way of VP
to FPC/2. Below is the modifed part.
--------- sysos2.pas
case os_mode of
osDOS:
stackbottom:=0; {In DOS mode, heap_brk is also the
stack bottom.}
osOS2:
begin
dosgetinfoblocks(tib,pib);
stackbottom:=longint(tib^.stack);
(* ---- !!! ---- *)
cmd := PChar( pib^.cmd ); (* fix up 0th parameter *)
Dec( cmd, 2 );
while cmd^ <> #0 do
Dec( cmd );
argv[ 0 ] := cmd + 1;
(* ---- !!!! ---- *)
end;
osDPMI:
stackbottom:=0; {Not sure how to get it, but seems to be
always zero.}
---------
Above is sysos2.pas initialization part. and declare 'cmd' as 'PChar'
at 'var' part.
Below are simple sources posted previously.
---------- maketest.pas
program MakeTest;
uses
Dos;
begin
WriteLn( '----- MakeTest report ----- ' );
WriteLn( 'ParamStr( 0 ) : ', ParamStr( 0 ));
{$IFDEF FPC}
WriteLn( 'argv[ 0 ] : ', argv[ 0 ]);
{$ENDIF}
end.
---------
--------- makefile
default :
maketest.exe
---------
If you lauch make, you could see only file name. If you launch maketest,
you could see full path.
Fundamentally, I had to modify prt1.as, however, because I am poor at
assembly language, so fixed sysos2.pas.
For better FPC !!!
from KO Myung-Hun...
More information about the fpc-devel
mailing list