Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2000-11

ParamStr & argv bug in FPC/2

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

KO Myung-Hun

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...

Reply by email

Unknown author
to KO Myung-Hun

Date sent: Sun, 12 Nov 2000 00:52:39 +0900
From: KO Myung-Hun
To: FPC mail
Subject: [fpc-devel]ParamStr & argv bug in FPC/2 Send reply to:

In VP, 0th parameter is processed separately. I applied the way of VP to FPC/2. Below is the modifed part.

.
.

Thanks. I'll have to modify your patch a bit, since we shouldn't modify argv probably (and argv isn't assumed to return the full path anyway). OTOH, I won't have to search for the appropriate API, at least for OS/2. Regarding DOS, we'll probably have to use something like FSearch ('PATH') to locate the executable.

Tomas

Reply by email