--- gobject/glib-mkenums.in
+++ gobject/glib-mkenums.in
@@ -323,7 +323,7 @@
            \*/''', '', line)
 
         # ignore forward declarations
-        if re.match(r'\s*typedef\s+enum.*;/;', line):
+        if re.match(r'\s*typedef\s+enum.*;', line):
             continue
 
         m = re.match(r'''\s*typedef\s+enum\s*
@@ -334,14 +334,14 @@
                \s*({)?''', line, flags=re.X)
         if m:
             groups = m.groups()
-            if len(groups) >= 2 and groups[2] is not None:
-                options = parse_trigraph(groups[2]);
+            if len(groups) >= 2 and groups[1] is not None:
+                options = parse_trigraph(groups[1]);
                 if 'skip' in options:
                     continue
-                enum_prefix = options['prefix']
-                flags = options['flags']
-                option_lowercase_name = options['lowercase_name']
-                option_underscore_name = options['underscore_name']
+                enum_prefix = options.get('prefix', None)
+                flags = options.get('flags', None)
+                option_lowercase_name = options.get('lowercase_name', None)
+                option_underscore_name = options.get('underscore_name', None)
             else:
                 enum_prefix = None
                 flags = None
@@ -356,7 +356,7 @@
                     print("$0: $ARGV:$.: lowercase_name is deprecated, use underscore_name", file=sys.stderr)
 
             # Didn't have trailing '{' look on next lines
-            if groups[0] is None and (len(groups) < 5 or groups[4] is None):
+            if groups[0] is None and (len(groups) < 4 or groups[3] is None):
                 while True:
                     line = curfile.readline()
                     if re.match(r'\s*\{', line):
@@ -397,7 +397,7 @@
                 name = e[0]
                 num = e[1]
                 if len(e) < 3 or e[2] is None:
-                    nick = name = re.sub(r'^' + enum_prefix, '', name)
+                    nick = re.sub(r'^' + enum_prefix, '', name)
                     nick = nick.replace('_', '-').lower()
                     e = (name, num, nick)
                 fixed_entries.append(e)
