From f64aaf971176305233f16a11911a660fa6f99561 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 2 Oct 2017 12:47:43 +0200 Subject: Clean up _expand_sym_refs() a bit Get the symbol name without the '$' straight from the regex. --- kconfiglib.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kconfiglib.py b/kconfiglib.py index 6b5b80f..186c931 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1723,12 +1723,10 @@ class Config(object): if sym_ref_match is None: return s - sym_name = sym_ref_match.group(0)[1:] - sym = self._syms.get(sym_name) - expansion = "" if sym is None else sym.get_value() + sym = self._syms.get(sym_ref_match.group(1)) s = s[:sym_ref_match.start()] + \ - expansion + \ + (sym.get_value() if sym is not None else "") + \ s[sym_ref_match.end():] def _expr_val_str(self, expr, no_value_str="(none)", @@ -3730,7 +3728,7 @@ _initial_token_re_match = re.compile(r"[^\w#]*(\w+)\s*").match _id_keyword_re_match = re.compile(r"([\w./-]+)\s*").match # Regular expression for finding $-references to symbols in strings -_sym_ref_re_search = re.compile(r"\$[A-Za-z0-9_]+").search +_sym_ref_re_search = re.compile(r"\$([A-Za-z0-9_]+)").search # Strings to use for types _TYPENAME = { -- cgit v1.2.3