From e54e692ba613c2170c66ce36a3791c009680af08 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 15 May 2011 23:42:09 -0400 Subject: kconfig: introduce specialized printer Make conf_write_symbol() grammar agnostic to be able to use it from different code path. These path pass a printer callback which will print a symbol's name and its value in different format. conf_write_symbol()'s job become mostly only to prepare a string for the printer. This avoid to have to pass specialized flag to generic functions Signed-off-by: Arnaud Lacombe [mmarek: rebased on top of de12518 (kconfig: autogenerated config_is_xxx macro)] Signed-off-by: Michal Marek --- scripts/kconfig/symbol.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'scripts/kconfig/symbol.c') diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index cf8edf4fc42..071f00c3046 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -750,7 +750,8 @@ const char *sym_get_string_value(struct symbol *sym) case no: return "n"; case mod: - return "m"; + sym_calc_value(modules_sym); + return (modules_sym->curr.tri == no) ? "n" : "m"; case yes: return "y"; } @@ -892,6 +893,49 @@ const char *sym_expand_string_value(const char *in) return res; } +const char *sym_escape_string_value(const char *in) +{ + const char *p; + size_t reslen; + char *res; + size_t l; + + reslen = strlen(in) + strlen("\"\"") + 1; + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + p += l; + + if (p[0] == '\0') + break; + + reslen++; + p++; + } + + res = malloc(reslen); + res[0] = '\0'; + + strcat(res, "\""); + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + strncat(res, p, l); + p += l; + + if (p[0] == '\0') + break; + + strcat(res, "\\"); + strncat(res, p++, 1); + } + + strcat(res, "\""); + return res; +} + struct symbol **sym_re_search(const char *pattern) { struct symbol *sym, **sym_arr = NULL; -- cgit v1.2.3-18-g5258