diff options
author | Dan Winship <danw@gnome.org> | 2009-11-23 10:52:09 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2009-11-23 10:52:09 -0500 |
commit | ab127091d84336a851e0cec9cfdd0435065d9e2a (patch) | |
tree | ee774a422964ee3d70e531521ef3f5dc814a4ea8 /giscanner/transformer.py | |
parent | 0bb6ce54f796c00fcf370de07f3bfcfa8d574834 (diff) | |
download | gobject-introspection-ab127091d84336a851e0cec9cfdd0435065d9e2a.tar.gz |
Fix enum prefix stripping to work only up to word boundaries
https://bugzilla.gnome.org/show_bug.cgi?id=602672
Diffstat (limited to 'giscanner/transformer.py')
-rw-r--r-- | giscanner/transformer.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 86a21146..a131e3c1 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -214,15 +214,13 @@ class Transformer(object): def _enum_common_prefix(self, symbol): def common_prefix(a, b): - alen = len(a) - blen = len(b) - l = min(alen, blen) - for i in xrange(l): - if a[i] != b[i]: - return a[:i] - if alen > blen: - return b - return a + commonparts = [] + for aword, bword in zip(a.split('_'), b.split('_')): + if aword != bword: + return '_'.join(commonparts) + '_' + commonparts.append(aword) + return min(a, b) + # Nothing less than 2 has a common prefix if len(list(symbol.base_type.child_list)) < 2: return None |