Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 220665
b: refs/heads/master
c: 76a5409
h: refs/heads/master
i:
  220663: 7ec4970
v: v3
  • Loading branch information
Arnaud Lacombe committed Sep 19, 2010
1 parent 6df8b40 commit 9915377
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c0920a1cbd7aecefa5f9768e82136935132ef1cf
refs/heads/master: 76a540958af5390a94b7f68c46cb7f2aed34ccf1
1 change: 1 addition & 0 deletions trunk/scripts/kconfig/lkc_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);

P(sym_lookup,struct symbol *,(const char *name, int flags));
P(sym_find,struct symbol *,(const char *name));
P(sym_expand_string_value,const char *,(const char *in));
P(sym_re_search,struct symbol **,(const char *pattern));
P(sym_type_name,const char *,(enum symbol_type type));
P(sym_calc_value,void,(struct symbol *sym));
Expand Down
49 changes: 49 additions & 0 deletions trunk/scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,55 @@ struct symbol *sym_find(const char *name)
return symbol;
}

/*
* Expand symbol's names embedded in the string given in argument. Symbols'
* name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
* the empty string.
*/
const char *sym_expand_string_value(const char *in)
{
const char *src;
char *res;
size_t reslen;

reslen = strlen(in) + 1;
res = malloc(reslen);
res[0] = '\0';

while ((src = strchr(in, '$'))) {
char *p, name[SYMBOL_MAXLENGTH];
const char *symval = "";
struct symbol *sym;
size_t newlen;

strncat(res, in, src - in);
src++;

p = name;
while (isalnum(*src) || *src == '_')
*p++ = *src++;
*p = '\0';

sym = sym_find(name);
if (sym != NULL) {
sym_calc_value(sym);
symval = sym_get_string_value(sym);
}

newlen = strlen(res) + strlen(symval) + strlen(src);
if (newlen > reslen) {
reslen = newlen;
realloc(res, reslen);
}

strcat(res, symval);
in = src;
}
strcat(res, in);

return res;
}

struct symbol **sym_re_search(const char *pattern)
{
struct symbol *sym, **sym_arr = NULL;
Expand Down

0 comments on commit 9915377

Please sign in to comment.