summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Ziermann <b@loet.de>2015-11-27 11:42:33 +0100
committerLubomir Rintel <lkundrak@v3.sk>2015-11-27 11:58:46 +0100
commit29dbfca8354315a81f075c3c1fff3557ac8c92e5 (patch)
tree42ae92544ec20c1508dcc47db283422c7452ab33
parentb0e9b25cf4d73255c90a201be0ec3e55b2479024 (diff)
downloaddev86-29dbfca8354315a81f075c3c1fff3557ac8c92e5.tar.gz
libc/msdos: program name missing in argv[0]
Correct the missing program name the arg[0].
-rw-r--r--libc/msdos/msdos.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libc/msdos/msdos.c b/libc/msdos/msdos.c
index 973b0a6..ab3d586 100644
--- a/libc/msdos/msdos.c
+++ b/libc/msdos/msdos.c
@@ -175,6 +175,29 @@ auto_func: ! Label for bcc -M to work.
#endasm
#endif
+void set_program_name(__argv)
+char ** __argv;
+{
+ unsigned char *ptr;
+ int src,len;
+
+ __set_es(__envseg);
+ src=0;
+ while(__peek_es(src++)!=0)
+ {
+ while(__peek_es(src++)!=0);
+ }
+ src+=2; // step over 0x0001
+ len=0;
+ while (__peek_es(src+len++)!=0);
+ ptr=sbrk(len);
+ __argv[0]=ptr;
+ while(len--)
+ {
+ *ptr++=__peek_es(src++);
+ }
+}
+
__mkargv(__argc, __argv)
int __argc;
char ** __argv;
@@ -183,6 +206,8 @@ char ** __argv;
unsigned char *ptr, *p;
int es=__get_es();
+ set_program_name(__argv);
+
__set_es(__psp); /* Pointer to the args */
length = __peek_es(0x80); /* Length of cmd line */
if( length > 0 )