]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
lib/bb/utils.py: Fix a bug in edit_metadata() that could corrupt vars
authorRandy Witt <randy.e.witt@linux.intel.com>
Thu, 7 Apr 2016 06:55:39 +0000 (23:55 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 9 Apr 2016 06:58:09 +0000 (07:58 +0100)
edit_metadata() would corrupt a variable that was multiline, but
had the ending quotes on the same line as the last value. For example:

    TEST_VAR = " foo \
    bar"

would become " foo ba" because the code would always delete the last
character on the line and then do it again if the line ended in the
quote. This however doesn't show up if you have:

    TEST_VAR = " foo \
    bar \
    "

which is how all the test cases were written.

This patch fixes that bug and adds and fixes a test that matched the bugs
behavior rather than the expected behavior.

Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/tests/utils.py
lib/bb/utils.py

index a035ccf179353c553052f506d97a4652dc57a68d..6ded4dfd1344fe4a2d49c54170fc376579314119 100644 (file)
@@ -176,7 +176,7 @@ do_functionname() {
         # Test file doesn't get modified with some the same values
         self._testeditfile({'THIS': ('that', None, 0, True),
                         'OTHER': ('anothervalue', None, 0, True),
-                        'MULTILINE3': ('               c1               c2               c3', None, 4, False)}, self._origfile)
+                        'MULTILINE3': ('               c1               c2               c3 ', None, 4, False)}, self._origfile)
 
     def test_edit_metadata_file_1(self):
 
index e9ad68f2d751222b242bcb27c8c7bfa94d77ee52..8d7df13be788ed901f9c2f7fa36db80327391813 100644 (file)
@@ -1158,7 +1158,7 @@ def edit_metadata(meta_lines, variables, varfunc, match_overrides=False):
                 if in_var.endswith('()'):
                     if full_value.count('{') - full_value.count('}') >= 0:
                         continue
-                full_value = full_value[:-1]
+                    full_value = full_value[:-1]
                 if handle_var_end():
                     updated = True
                     checkspc = True