Mail Archives: djgpp-workers/1999/09/30/07:56:11
On Wed, 29 Sep 1999, Laurynas Biveinis wrote:
> > What is passed to DOS is the SFN, since 214B requires it. What the
> > invoked program gets in its argv[0] (via !proxy), if it is a DJGPP
> > program, is the original LFN file name with its full path prepended.
> > A non-DJGPP program gets the SFN, since it has no other means of
> > getting at the command line except as passed by DOS.
>
> If this above is true, then could you explain me what I'm doing wrong here:
[snip]
> file test.c:
> ----------
> #include <stdlib.h>
>
> int main(void)
> {
> system("VeryLongName.exe");
> return 0;
> }
> ----------
>
> When I call test, I see:
> c:/djgpp/programs/djgpp/verylong.exe
> and not
> c:/djgpp/programs/djgpp/VeryLongName.exe
>
> What I'm doing wrong here?
You aren't doing wrong anything, it's just one of the subtleties, and
my description above was lacking a crucial detail.
The missing piece in this puzzle is that the !proxy method is used by
`system' only if the command line is longer than the DOS limit;
otherwise, the child program is invoked as non-DJGPP programs would,
with all its command-line arguments passed via the DOS call. (The
reason for this is my own conservatism in the face of all the
subtleties that go on in system.c, dosexec.c, and c1args.c: when I did
the change that enabled long command lines in `system', I wanted to
minimize any adverse effects of some subtle misfeature that could be
lurking somewhere.)
Your test.c uses a very short command, so it doesn't get passed
through !proxy, in which case argv[0] on the child side gets set to
whatever was passed to DOS, which is the 8+3 alias. See the function
__crt0_setup_arguments in src/libc/crt0/c1args.c, and watch the logic
that sets the variable prepend_argv0 to zero or non-zero there.
Try the modified test.c below, and you will see the long file name in
argv[0]. I think that invoking with spawnXX will also cause an LFN
variant of argv[0] to be seen by the child.
#include <stdlib.h>
int main(void)
{
system("VeryLongName.exe"
" 1234567890 1234567890 1234567890 1234567890 234567890"
" 1234567890 1234567890 1234567890 1234567890 1234567890"
" 1234567890 1234567890");
return 0;
}
- Raw text -