Date: Thu, 30 Sep 1999 13:35:57 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Laurynas Biveinis cc: djgpp-workers AT delorie DOT com Subject: Re: Help with arg passing In-Reply-To: <37F25ABD.E4B89CAD@softhome.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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 > > 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 int main(void) { system("VeryLongName.exe" " 1234567890 1234567890 1234567890 1234567890 234567890" " 1234567890 1234567890 1234567890 1234567890 1234567890" " 1234567890 1234567890"); return 0; }