diff --git a/gobject/glib-mkenums.in b/gobject/glib-mkenums.in index e0c0b39af..353e53ae3 100755 --- a/gobject/glib-mkenums.in +++ b/gobject/glib-mkenums.in @@ -149,8 +149,7 @@ output = '' # Filename to write result into def parse_trigraph(opts): result = {} - - for opt in re.split(r'\s*,\s*', opts): + for opt in re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', opts): opt = re.sub(r'^\s*', '', opt) opt = re.sub(r'\s*$', '', opt) m = re.search(r'(\w+)(?:=(.+))?', opt) @@ -161,7 +160,7 @@ def parse_trigraph(opts): val = groups[1] else: val = 1 - result[key] = val + result[key] = val.strip('"') if val is not None else None return result def parse_entries(file, file_name): diff --git a/gobject/tests/mkenums.py b/gobject/tests/mkenums.py index b58d23e79..0b40daeaf 100644 --- a/gobject/tests/mkenums.py +++ b/gobject/tests/mkenums.py @@ -520,6 +520,31 @@ comment: {standard_bottom_comment} "0", ) + def test_with_double_quotes(self): + """Test trigraphs with double-quoted expressions. Issue #65.""" + h_contents = """ + typedef enum { + FOO_VALUE /*< nick="eek, a comma" >*/ + } Foo; + """ + result = self.runMkenumsWithHeader(h_contents) + self.assertEqual("", result.err) + self.assertSingleEnum( + result, + "Foo", + "foo_", + "FOO_", + "", + "FOO", + "", + "enum", + "Enum", + "ENUM", + "FOO_VALUE", + "eek, a comma", + "0", + ) + def test_filename_basename_in_fhead_ftail(self): template_contents = """ /*** BEGIN file-header ***/