]> git.baikalelectronics.ru Git - uboot.git/commit
moveconfig: Fix code relying on now-stripped newline characters
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>
Sat, 29 Jan 2022 15:22:08 +0000 (18:22 +0300)
committerSimon Glass <sjg@chromium.org>
Mon, 31 Jan 2022 03:40:58 +0000 (20:40 -0700)
commit2267334b8ec80fd383213666a0a4781f12a8e19f
tree3a4a84f12c17779fa93462998ed6007ca583abe3
parenta2523bca22550165af8fd0b8bc9e593e8482c584
moveconfig: Fix code relying on now-stripped newline characters

Commit 5db353b261e1 ("moveconfig: Use a function to read files") adds a
helper function that can read a file as lines, but strips the newline
characters. This change broke parts of moveconfig code that relied on
their existence, resulting in a few issues:

Configs that are defined as empty aren't removed from header files (e.g.
"#define CONFIG_REMAKE_ELF"). Make regex patterns use '\b' to match word
boundaries instead of '\W' (which matched the newlines) so these lines
still match and get removed.

All changes in defconfig are considered removed by savedefconfig even
if they weren't, and line continuations in the headers aren't recognized
and removed properly, because their checks explicitly look for a newline
character. Remove the character from both comparisons.

The printed diff of header files is wrongly formatted and raises an
IndexError if a blank line was removed. Let print() print the new lines,
and use size-independent ways to check strings to fix the diff output.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
tools/moveconfig.py