[klibc] [PATCH] option parsing in kinit/kinit.c get_arg()
Olaf Hering
olh at suse.de
Sat Nov 22 19:39:20 PST 2003
what is the purpose of get_arg()? should it return the option itself
and/or the arguments passed to an option?
this patch returns either 'rw' or '/dev/nfs' if name was root=/dev/nfs
--- usr/klibc/klibc-0.81.orig/kinit/kinit.c 2003-06-01 08:18:41.000000000 +0200
+++ usr/klibc/klibc-0.81/kinit/kinit.c 2003-11-22 19:19:17.000000000 +0100
@@ -181,10 +181,15 @@ char *get_arg(int argc, char *argv[], co
int i;
for (i = 1; i < argc; i++) {
- if (argv[i] && strncmp(argv[i], name, len) == 0 &&
- (argv[i][len] == '\0')) {
- ret = argv[i] + len;
- break;
+ if (argv[i] && strncmp(argv[i], name, len) == 0) {
+ if (argv[i][len] == '\0') {
+ ret = argv[i];
+ break;
+ }
+ if (len && argv[i][len-1] == '=') {
+ ret = argv[i] + len;
+ break;
+ }
}
}
--
USB is for mice, FireWire is for men!
sUse lINUX ag, nÜRNBERG
More information about the klibc
mailing list