www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/08/03/08:39:08

Message-Id: <m0z3Jqx-000XepC@sloep06.cs.vu.nl>
Date: Mon, 3 Aug 98 14:36:39 MET DST
From: Michel de Ruiter <mdruiter AT cs DOT vu DOT nl>
To: djgpp-workers AT delorie DOT com
cc: dj AT delorie DOT com
Subject: argv[0] behaviour.

Hi, workers,

I have noticed inconsistent behaviour in the value of the
`argv[0]'-variable. Does anyone have comments about this?

Say I have argv0.exe compiled from the following source:

#include <stdio.h>
int main(int argc __attribute__((unused)), char *argv[])
{
  puts(argv[0]);
  return 0;
}

About _crt0_startup_flags, info/libc.inf says:

`_CRT0_FLAG_USE_DOS_SLASHES'
     If set, reverse slashes (dos-style) are preserved in argv[0].  If
     not set, all reverse slashes are replaced with unix-style slashes.

And `include/crt0.h' says:

 *  The default is all flags off.

But, the output differs when run from `make'. If I have the following
makefile:

all:
	@argv0

This results for instance in the following output, depending on if run
from `make' or not and in which directory `argv0.exe' is:

Command	| Somewhere in %PATH%		| In current directory
--------+-------------------------------+-----------------------------
argv0	| e:/djgpp/bin/argv0.exe	| j:/share/mcsim/argv0.exe
make	| e:\djgpp\bin/argv0.exe	| argv0.exe

So, not "all reverse slashes are replaced with unix-style slashes",
when run from `make'. Also, when run from the current directory, the
path to the executable fails. Is this a bug in libc.a somewhere? A
feature? Or is it a documentation bug?

I've looked somewhat into it in the djlsr, and it appears to have a
reason (args are set back to DOS-defaults if !proxy is used), but...
what reason?

--
Groeten, Michel.        http://www.cs.vu.nl/~mdruiter
  ____________
  \  /====\  /          "You know, Beavis, you need things that suck,
   \/      \/           to have things that are cool", Butt-Head.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019