LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org> To: LKML <linux-kernel@vger.kernel.org> Cc: Sam Ravnborg <sam@ravnborg.org> Subject: [PATCH] kconfig: factor out code in confdata.c Date: Sat, 10 Nov 2007 21:43:25 +0100 [thread overview] Message-ID: <11947274093185-git-send-email-sam@ravnborg.org> (raw) In-Reply-To: <20071110204038.GA13140@uranus.ravnborg.org> This patch introduce no functional changes. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Roman Zippel <zippel@linux-m68k.org> --- scripts/kconfig/confdata.c | 119 +++++++++++++++++++++++-------------------- 1 files changed, 64 insertions(+), 55 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index b2913e9..e0f402f 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -83,6 +83,68 @@ char *conf_get_default_confname(void) return name; } +static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) +{ + char *p2; + + switch (sym->type) { + case S_TRISTATE: + if (p[0] == 'm') { + sym->def[def].tri = mod; + sym->flags |= def_flags; + break; + } + case S_BOOLEAN: + if (p[0] == 'y') { + sym->def[def].tri = yes; + sym->flags |= def_flags; + break; + } + if (p[0] == 'n') { + sym->def[def].tri = no; + sym->flags |= def_flags; + break; + } + conf_warning("symbol value '%s' invalid for %s", p, sym->name); + break; + case S_OTHER: + if (*p != '"') { + for (p2 = p; *p2 && !isspace(*p2); p2++) + ; + sym->type = S_STRING; + goto done; + } + 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) { + conf_warning("invalid string found"); + return 1; + } + case S_INT: + case S_HEX: + done: + if (sym_string_valid(sym, p)) { + sym->def[def].val = strdup(p); + sym->flags |= def_flags; + } else { + conf_warning("symbol value '%s' invalid for %s", p, sym->name); + return 1; + } + break; + default: + ; + } + return 0; +} + int conf_read_simple(const char *name, int def) { FILE *in = NULL; @@ -213,61 +275,8 @@ load: conf_warning("trying to reassign symbol %s", sym->name); break; } - switch (sym->type) { - case S_TRISTATE: - if (p[0] == 'm') { - sym->def[def].tri = mod; - sym->flags |= def_flags; - break; - } - case S_BOOLEAN: - if (p[0] == 'y') { - sym->def[def].tri = yes; - sym->flags |= def_flags; - break; - } - if (p[0] == 'n') { - sym->def[def].tri = no; - sym->flags |= def_flags; - break; - } - conf_warning("symbol value '%s' invalid for %s", p, sym->name); - break; - case S_OTHER: - if (*p != '"') { - for (p2 = p; *p2 && !isspace(*p2); p2++) - ; - sym->type = S_STRING; - goto done; - } - 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) { - conf_warning("invalid string found"); - continue; - } - case S_INT: - case S_HEX: - done: - if (sym_string_valid(sym, p)) { - sym->def[def].val = strdup(p); - sym->flags |= def_flags; - } else { - conf_warning("symbol value '%s' invalid for %s", p, sym->name); - continue; - } - break; - default: - ; - } + if (conf_set_sym_val(sym, def, def_flags, p)) + continue; break; case '\r': case '\n': -- 1.5.3.4.1157.g0e74-dirty
next prev parent reply other threads:[~2007-11-10 20:42 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-11-10 20:40 [PATCH 0/5] introduce K64BIT=y and backward compatibility ARCH={i386,x86_64} for x86 Sam Ravnborg 2007-11-10 20:43 ` Sam Ravnborg [this message] 2007-11-10 20:43 ` [PATCH] kconfig: use $K64BIT to set 64BIT with all*config targets Sam Ravnborg 2007-11-10 20:43 ` [PATCH] x86: Use CONFIG_64BIT to select between 32 and 64 bit in Kconfig Sam Ravnborg 2007-11-10 20:43 ` [PATCH] kconfig: document make K64BIT=y in README Sam Ravnborg 2007-11-10 20:43 ` [PATCH] x86: introduce ARCH=i386,ARCH=x86_64 to select 32/64 bit Sam Ravnborg 2007-11-10 22:23 ` [PATCH] kconfig: document make K64BIT=y in README Randy Dunlap 2007-11-10 22:18 ` [PATCH] x86: Use CONFIG_64BIT to select between 32 and 64 bit in Kconfig Randy Dunlap 2007-11-10 20:55 ` [PATCH] kconfig: use $K64BIT to set 64BIT with all*config targets Guillaume Chazarain 2007-11-11 5:14 ` Adrian Bunk 2007-11-11 12:43 ` Guillaume Chazarain 2007-11-11 13:07 ` Adrian Bunk 2007-11-11 14:59 ` Guillaume Chazarain 2007-11-11 15:30 ` Sam Ravnborg 2007-11-11 15:55 ` Guillaume Chazarain 2007-11-10 22:16 ` Randy Dunlap 2007-11-10 22:31 ` Sam Ravnborg 2007-11-14 20:57 ` Roman Zippel 2007-11-14 22:08 ` Sam Ravnborg 2007-11-15 15:43 ` Roman Zippel 2007-11-15 19:25 ` Sam Ravnborg 2007-11-15 19:43 ` Roman Zippel 2007-11-15 20:45 ` Sam Ravnborg 2007-11-15 21:24 ` Roman Zippel 2007-11-15 22:06 ` Sam Ravnborg 2007-11-16 1:28 ` Roman Zippel 2007-11-16 3:44 ` Randy Dunlap 2007-11-16 13:02 ` Roman Zippel 2007-11-16 5:41 ` Sam Ravnborg 2007-11-16 12:54 ` Roman Zippel 2008-01-06 13:26 ` kconfig: support option env="" [Was: kconfig: use $K64BIT to set 64BIT with all*config targets] Sam Ravnborg 2008-01-14 3:49 ` Roman Zippel 2008-01-14 5:58 ` Sam Ravnborg 2008-01-14 3:50 ` [PATCH 1/3] explicitly introduce expression list Roman Zippel 2008-01-14 3:50 ` [PATCH 2/3] environment symbol support Roman Zippel 2008-01-14 3:51 ` [PATCH 3/3] use environment option Roman Zippel 2007-11-10 22:33 ` [PATCH 0/5] introduce K64BIT=y and backward compatibility ARCH={i386,x86_64} for x86 Randy Dunlap 2007-11-10 22:50 ` Sam Ravnborg 2007-11-11 5:09 ` Adrian Bunk 2007-11-11 11:54 ` Sam Ravnborg 2007-11-12 2:47 ` Roman Zippel 2007-11-12 5:23 ` Sam Ravnborg 2007-11-12 20:54 [PATCH revised] enable make ARCH=x86 (and stay backward compatible) Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: unification of cfufreq/Kconfig Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: start unification of arch/x86/Kconfig.* Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: arch/x86/Kconfig.cpu unification Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: add X86_32 dependency to i386 specific symbols in Kconfig.i386 Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: add X86_64 dependency to x86_64 specific symbols in Kconfig.x86_64 Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: copy x86_64 specific Kconfig symbols to Kconfig.i386 Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: move all simple arch settings to Kconfig Sam Ravnborg 2007-11-12 21:00 ` [PATCH] x86: move the rest of the menu's " Sam Ravnborg 2007-11-12 21:00 ` [PATCH] kconfig: factor out code in confdata.c Sam Ravnborg
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=11947274093185-git-send-email-sam@ravnborg.org \ --to=sam@ravnborg.org \ --cc=linux-kernel@vger.kernel.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).