From 9acdcbf3254277b44d4558cfe73fde272b7d6e91 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Fri, 19 Nov 2010 10:15:25 +0530 Subject: [PATCH] use single quotes in menuentry setparams command --- grub-core/commands/menuentry.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c index 9718d1eab..7a07698d8 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -206,20 +206,6 @@ setparams_prefix (int argc, char **args) char *p; char *result; grub_size_t len = 10; - static const char *escape_characters = "\"\\"; - - auto char *strescpy (char *, const char *, const char *); - char * strescpy (char *d, const char *s, const char *escapes) - { - while (*s) - { - if (grub_strchr (escapes, *s)) - *d++ = '\\'; - *d++ = *s++; - } - *d = '\0'; - return d; - } /* Count resulting string length */ for (i = 0; i < argc; i++) @@ -227,7 +213,7 @@ setparams_prefix (int argc, char **args) len += 3; /* 3 = 1 space + 2 quotes */ p = args[i]; while (*p) - len += grub_strchr (escape_characters, *p++) ? 2 : 1; + len += (*p++ == '\'' ? 3 : 1); } result = grub_malloc (len + 2); @@ -240,9 +226,18 @@ setparams_prefix (int argc, char **args) for (j = 0; j < argc; j++) { result[i++] = ' '; - result[i++] = '"'; - i = strescpy (result + i, args[j], escape_characters) - result; - result[i++] = '"'; + result[i++] = '\''; + p = args[j]; + while (*p) { + result[i++] = *p; + if (*p == '\'') { + result[i++] = '\\'; + result[i++] = '\''; + result[i++] = '\''; + } + p++; + } + result[i++] = '\''; } result[i++] = '\n'; result[i] = '\0';