Mail Archives: djgpp-workers/1998/01/29/03:23:29
The following patch allows to read the DJGPP.ENV file before parsing the
command line. It has not been tested very thoroughly; especially, I'm
unable to test it on a machine with LFN support. I would also like to know
if this kind of change can cause any trouble.
diff -C 2 crt0~/crt1.c crt0/crt1.c
*** crt0~/crt1.c Sun Sep 1 20:52:34 1996
--- crt0/crt1.c Tue Jan 27 18:02:22 1998
***************
*** 126,129 ****
--- 126,150 ----
}
+ static char *prog_name;
+
+ static void
+ setup_pname(void)
+ {
+ char *ap, *fc;
+
+ fc = __dos_argv0;
+ for(ap = __dos_argv0; *ap; ap++)
+ if(*ap == ':' || *ap == '\\' || *ap == '/')
+ fc = ap + 1;
+
+ if(_stubinfo->argv0[0])
+ {
+ fc = _stubinfo->argv0;
+ }
+
+ prog_name = (char *)calloc(1, strlen(fc) + 1);
+ strncpy(prog_name, fc, 16);
+ }
+
extern void __main(void);
extern int main(int, char **, char **);
***************
*** 136,140 ****
__crt1_startup(void)
{
- char *pn;
__bss_count ++;
__crt0_argv = 0;
--- 157,160 ----
***************
*** 147,155 ****
/* Make so rest of startup could use LFN. */
(void)_USE_LFN;
! __crt0_setup_arguments();
! pn = __crt0_argv ? __crt0_argv[0] : __dos_argv0;
! __crt0_load_environment_file(pn);
(void)_USE_LFN; /* DJGPP.ENV might have set $LFN */
! _npxsetup(pn);
_crt0_init_mcount();
__main();
--- 167,176 ----
/* Make so rest of startup could use LFN. */
(void)_USE_LFN;
! setup_pname();
! __crt0_load_environment_file(prog_name);
(void)_USE_LFN; /* DJGPP.ENV might have set $LFN */
! free(prog_name);
! __crt0_setup_arguments();
! _npxsetup(__crt0_argv ? __crt0_argv[0] : __dos_argv0);
_crt0_init_mcount();
__main();
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/
- Raw text -