diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-01-27 10:45:18 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-01-27 12:25:50 +0100 |
| commit | ddf412070c2de5edd7fb39a7afb6778a4cf43e5c (patch) | |
| tree | fd8efdf16a04c7bf7496bdf88b9a9caa4d1559c8 /kconfiglib.py | |
| parent | a84848b823471b0e8385815c1a47563cbd139fd8 (diff) | |
Simplify help text parsing and _next_line()
- _saved_line already handles EOF automagically, so no need to
special-case it at the end of help text parsing.
- Check for EOF earlier in _next_line(). Bit silly to do it after line
joining.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index ab20ea6..c563e4d 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1114,12 +1114,18 @@ class Kconfig(object): Fetches and tokenizes the next line from the current Kconfig file. Returns False at EOF and True otherwise. """ - # This provides a single line of "unget" after help texts + # _saved_line provides a single line of "unget", currently only used + # for help texts. + # + # This also works as expected if _saved_line is "", indicating EOF: + # "" is falsy, and readline() returns "" over and over at EOF. if self._saved_line: self._line = self._saved_line self._saved_line = None else: self._line = self._file.readline() + if not self._line: + return False self._linenr += 1 # Handle line joining @@ -1127,9 +1133,6 @@ class Kconfig(object): self._line = self._line[:-2] + self._file.readline() self._linenr += 1 - if not self._line: - return False - self._tokenize() return True @@ -1730,10 +1733,6 @@ class Kconfig(object): add_help_line(_dedent_rstrip(line, indent)) node.help = "\n".join(help_lines).rstrip() + "\n" - - if not line: - break - self._saved_line = line # "Unget" the line elif t0 == _T_SELECT: |
