fix: align POSIX stdio and argument handling, clarify Intel iwlwifi licensing
This commit is contained in:
@@ -91,6 +91,14 @@ void _start(void) {
|
||||
|
||||
argbuf[len] = '\0';
|
||||
|
||||
/* Split on spaces, honouring '...' and "..." so an argument can
|
||||
contain them: `git commit -m "two words"` has to reach main()
|
||||
as two arguments, not three. The quotes are removed, and the
|
||||
token is rewritten in place -- the unquoted form is never
|
||||
longer than the quoted one, so it always fits. Quotes are the
|
||||
only metacharacter: there is no escaping and no substitution,
|
||||
which is deliberate. The kernel hands over one flat string
|
||||
(SYS_GETARGS) and this is a tokenizer, not a shell. */
|
||||
char* p = argbuf;
|
||||
while (*p != '\0' && argc < 255) {
|
||||
while (*p == ' ') {
|
||||
@@ -101,15 +109,27 @@ void _start(void) {
|
||||
break;
|
||||
}
|
||||
|
||||
argv[argc++] = p;
|
||||
char* out = p;
|
||||
argv[argc++] = out;
|
||||
|
||||
while (*p != '\0' && *p != ' ') {
|
||||
char quote = 0;
|
||||
while (*p != '\0' && (quote != 0 || *p != ' ')) {
|
||||
if (quote == 0 && (*p == '"' || *p == '\'')) {
|
||||
quote = *p++;
|
||||
} else if (quote != 0 && *p == quote) {
|
||||
quote = 0;
|
||||
p++;
|
||||
} else {
|
||||
*out++ = *p++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Step over the separator before terminating: the write
|
||||
below lands on the byte p is about to leave behind. */
|
||||
if (*p != '\0') {
|
||||
p++;
|
||||
}
|
||||
|
||||
if (*p != '\0') {
|
||||
*p++ = '\0';
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user