fix: align POSIX stdio and argument handling, clarify Intel iwlwifi licensing

This commit is contained in:
2026-08-09 10:42:09 +02:00
parent a06ef0192d
commit 771c3a5a98
15 changed files with 197 additions and 19 deletions
+26 -6
View File
@@ -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';
}
}