diff options
author | neal <neal> | 2008-07-08 14:07:56 +0000 |
---|---|---|
committer | neal <neal> | 2008-07-08 14:07:56 +0000 |
commit | 6df49ca1a377b5d0e70682ba7118076af2cc801a (patch) | |
tree | 77edd358a230872900340357680c15f50d3f3082 /libc-parts/ia32-cmain.c | |
parent | 062419af3894fc9be7accfc0ec9bd223edf61bd3 (diff) |
hieronymus/
2008-07-08 Neal H. Walfield <neal@gnu.org>
* Makefile.am (modules.h): Generate an array of arguments from
each module's command line.
(ruth_commandline): Don't quote arguments.
* hieronymus.c (struct module): Remove field commandline, replace
with args.
(main): Create the argument vector based on the MODULES[I].ARGS.
libc-parts/
2008-07-08 Neal H. Walfield <neal@gnu.org>
* process-spawn.c (process_spawn): Don't add an extra trailing NUL
to the argment vector or the environment vector.
* ia32-cmain.c (finish): Assume the command line is in argz
format and parse it appropriately.
Diffstat (limited to 'libc-parts/ia32-cmain.c')
-rw-r--r-- | libc-parts/ia32-cmain.c | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/libc-parts/ia32-cmain.c b/libc-parts/ia32-cmain.c index f9afdd3..f67937c 100644 --- a/libc-parts/ia32-cmain.c +++ b/libc-parts/ia32-cmain.c @@ -51,48 +51,31 @@ finish (void) int argc = 0; char **argv = 0; - char *str = __hurd_startup_data->argz; - if (str) - /* A command line was passed. */ + if (__hurd_startup_data->argz_len) + /* A command line was passed. We assume that it is in argz + format. */ { - int nr = 0; + char *str = __hurd_startup_data->argz; /* First time around we count the number of arguments. */ - argc = 1; - while (*str && *str == ' ') - str++; - - while (*str) - if (*(str++) == ' ') - { - while (*str && *str == ' ') - str++; - if (*str) - argc++; - } + int offset; + + argc = 0; + for (offset = 0; + offset < __hurd_startup_data->argz_len; + offset += strlen (str + offset) + 1) + argc ++; + + /* Now we fill in the argv. */ argv = alloca (sizeof (char *) * (argc + 1)); - /* Second time around we fill in the argv. */ - str = (char *) __hurd_startup_data->argz; - - while (*str && *str == ' ') - str++; - argv[nr++] = str; - - while (*str) - { - if (*str == ' ') - { - *(str++) = '\0'; - while (*str && *str == ' ') - str++; - if (*str) - argv[nr++] = str; - } - else - str++; - } - argv[nr] = 0; + str = __hurd_startup_data->argz; + argc = 0; + for (offset = 0; + offset < __hurd_startup_data->argz_len; + offset += strlen (str + offset) + 1) + argv[argc ++] = str + offset; + argv[argc] = 0; } else { |