delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/01/29/03:23:29

Date: Thu, 29 Jan 1998 10:22:04 +0200 (EET)
From: Esa A E Peuha <peuha AT cc DOT helsinki DOT fi>
Reply-To: Esa DOT Peuha AT Helsinki DOT FI
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: Patch for crt1.c
Message-ID: <Pine.OSF.3.96.980128093617.9603A-100000@vesuri.Helsinki.FI>
MIME-Version: 1.0

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 -


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