From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] stubdom: support quotes in argument passing
Date: Tue, 26 Aug 2008 17:32:10 +0100 [thread overview]
Message-ID: <20080826163210.GF4555@implementation.uk.xensource.com> (raw)
stubdom: support quotes in argument passing
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
diff -r c2472ded5c7c extras/mini-os/main.c
--- a/extras/mini-os/main.c Tue Aug 26 15:16:57 2008 +0100
+++ b/extras/mini-os/main.c Tue Aug 26 17:26:28 2008 +0100
@@ -42,7 +42,7 @@ extern char __app_bss_start, __app_bss_e
extern char __app_bss_start, __app_bss_end;
static void call_main(void *p)
{
- char *c;
+ char *c, quote;
#ifdef CONFIG_QEMU
char *domargs, *msg;
#endif
@@ -101,32 +101,53 @@ static void call_main(void *p)
argc = 1;
-#define PARSE_ARGS(ARGS,START,END) \
+#define PARSE_ARGS(ARGS,START,QUOTE,END) \
c = ARGS; \
+ quote = 0; \
while (*c) { \
if (*c != ' ') { \
START; \
- while (*c && *c != ' ') \
+ while (*c) { \
+ if (quote) { \
+ if (*c == quote) { \
+ quote = 0; \
+ QUOTE; \
+ continue; \
+ } \
+ } else if (*c == ' ') \
+ break; \
+ if (*c == '"' || *c == '\'') { \
+ quote = *c; \
+ QUOTE; \
+ continue; \
+ } \
c++; \
+ } \
} else { \
END; \
while (*c == ' ') \
c++; \
} \
+ } \
+ if (quote) {\
+ printk("Warning: unterminated quotation %c\n", quote); \
+ quote = 0; \
}
+#define PARSE_ARGS_COUNT(ARGS) PARSE_ARGS(ARGS, argc++, c++, )
+#define PARSE_ARGS_STORE(ARGS) PARSE_ARGS(ARGS, argv[argc++] = c, memmove(c, c + 1, strlen(c + 1) + 1), *c++ = 0)
- PARSE_ARGS((char*)start_info.cmd_line, argc++, );
+ PARSE_ARGS_COUNT((char*)start_info.cmd_line);
#ifdef CONFIG_QEMU
- PARSE_ARGS(domargs, argc++, );
+ PARSE_ARGS_COUNT(domargs);
#endif
argv = alloca((argc + 1) * sizeof(char *));
argv[0] = "main";
argc = 1;
- PARSE_ARGS((char*)start_info.cmd_line, argv[argc++] = c, *c++ = 0)
+ PARSE_ARGS_STORE((char*)start_info.cmd_line)
#ifdef CONFIG_QEMU
- PARSE_ARGS(domargs, argv[argc++] = c, *c++ = 0)
+ PARSE_ARGS_STORE(domargs)
#endif
argv[argc] = NULL;
reply other threads:[~2008-08-26 16:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080826163210.GF4555@implementation.uk.xensource.com \
--to=samuel.thibault@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.