Where is program_name?

2008-09-09 Thread Gisle Vanem
'program_name' is used in lib/error.c, but it is not allocated 
anywhere. Should it be added to main.c and initialised to exec_name?


--gv


Re: Where is program_name?

2008-09-09 Thread Saint Xavier

Hi,

* Gisle Vanem ([EMAIL PROTECTED]) wrote:
 'program_name' is used in lib/error.c, but it is not allocated anywhere. 
 Should it be added to main.c and initialised to exec_name?

$cd wget-mainline
$find . -name '*.[ch]' -exec fgrep -H -n 'program_name' '{}' \;
./lib/error.c:63:# define program_name program_invocation_name
   ^^^
./lib/error.c:95:/* The calling program should define program_name and set it 
to the
./lib/error.c:97:extern char *program_name;
./lib/error.c:248:  __fxprintf (NULL, %s: , program_name);
./lib/error.c:250:  fprintf (stderr, %s: , program_name);
./lib/error.c:307:  __fxprintf (NULL, %s:, program_name);
./lib/error.c:309:  fprintf (stderr, %s:, program_name);
./src/netrc.c:463:  char *program_name, *file, *target;
./src/netrc.c:472:  program_name = argv[0];

Google for that and you will find the corresponding man page. Like it's
written here 
http://www.tin.org/bin/man.cgi?section=3topic=PROGRAM_INVOCATION_NAME
These variables are automatically initialised by the glibc run-time
 startup code.

I've also opened Wget with GDB: the variable exists but seems to point to
a bad memory area... 

Sincerly,
Saint Xavier.


Re: Where is program_name?

2008-09-09 Thread Gisle Vanem

Google for that and you will find the corresponding man page. Like it's
written here 
http://www.tin.org/bin/man.cgi?section=3topic=PROGRAM_INVOCATION_NAME
These variables are automatically initialised by the glibc run-time
startup code.


I'm on Windows. So glibc is of no help here.

--gv


Re: Where is program_name?

2008-09-09 Thread Micah Cowan
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Saint Xavier wrote:
 Hi,
 
 * Gisle Vanem ([EMAIL PROTECTED]) wrote:
 'program_name' is used in lib/error.c, but it is not allocated anywhere. 
 Should it be added to main.c and initialised to exec_name?
 
 $cd wget-mainline
 $find . -name '*.[ch]' -exec fgrep -H -n 'program_name' '{}' \;
 ./lib/error.c:63:# define program_name program_invocation_name
^^^
 ./lib/error.c:95:/* The calling program should define program_name and set it 
 to the
  ^^^

Looks to me like we're expected to supply it. Line 63 is only evaluated
when we're using glibc; otherwise, we need to provide it. The differing
name is probably so we can define it unconditionally.

It appears that lib/error.c isn't even _built_ on my system, perhaps
because glibc supplies what it would fill in. This makes testing a
little dificult. Anyway, see if this fixes your trouble:

diff -r 0c2e02c4f4f3 src/ChangeLog
- --- a/src/ChangeLog Tue Sep 09 09:29:50 2008 -0700
+++ b/src/ChangeLog Tue Sep 09 09:40:00 2008 -0700
@@ -1,3 +1,7 @@
+2008-09-09  Micah Cowan  [EMAIL PROTECTED]
+
+   * main.c: Define program_name for lib/error.c.
+
 2008-09-02  Gisle Vanem  [EMAIL PROTECTED]

* mswindows.h: Must ensure stdio.h is included before
diff -r 0c2e02c4f4f3 src/main.c
- --- a/src/main.cTue Sep 09 09:29:50 2008 -0700
+++ b/src/main.cTue Sep 09 09:40:00 2008 -0700
@@ -826,6 +826,8 @@
   exit (0);
 }

+char *program_name; /* Needed by lib/error.c. */
+
 int
 main (int argc, char **argv)
 {
@@ -833,6 +835,8 @@
   int i, ret, longindex;
   int nurl, status;
   bool append_to_log = false;
+
+  program_name = argv[0];

   i18n_initialize ();



- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer.
GNU Maintainer: wget, screen, teseq
http://micah.cowan.name/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIxqf67M8hyUobTrERAq0+AJ9KIOFDn9FiDXIIlU6M7DsupDmPYQCcDuoo
9bgAQnuKpgYMvnwc18svfYg=
=DXYi
-END PGP SIGNATURE-