]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - scripts/kconfig/confdata.c
Kconfig: Enable usage of escape char '\' in string values
[people/ms/u-boot.git] / scripts / kconfig / confdata.c
index f88d90f20228e8783b5ca39accc436140af7b3ff..2f778df206f5b4e19b959c9044ab78afd5de40a6 100644 (file)
@@ -155,18 +155,14 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
        case S_STRING:
                if (*p++ != '"')
                        break;
-               for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
-                       if (*p2 == '"') {
-                               *p2 = 0;
-                               break;
-                       }
-                       memmove(p2, p2 + 1, strlen(p2));
-               }
-               if (!p2) {
+               /* Last char has to be a '"' */
+               if (p[strlen(p) - 1] != '"') {
                        if (def != S_DEF_AUTO)
                                conf_warning("invalid string found");
                        return 1;
                }
+               /* Overwrite '"' with \0 for string termination */
+               p[strlen(p) - 1] = 0;
                /* fall through */
        case S_INT:
        case S_HEX:
@@ -624,6 +620,7 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym,
                              struct conf_printer *printer, void *printer_arg)
 {
        const char *str;
+       char *str2;
 
        switch (sym->type) {
        case S_OTHER:
@@ -631,9 +628,10 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym,
                break;
        case S_STRING:
                str = sym_get_string_value(sym);
-               str = sym_escape_string_value(str);
-               printer->print_symbol(fp, sym, str, printer_arg);
-               free((void *)str);
+               str2 = xmalloc(strlen(str) + 3);
+               sprintf(str2, "\"%s\"", str);
+               printer->print_symbol(fp, sym, str2, printer_arg);
+               free((void *)str2);
                break;
        default:
                str = sym_get_string_value(sym);