GNOME Bugzilla – Bug 602672
Fix enum prefix stripping to work only up to word boundaries
Last modified: 2015-02-07 17:00:42 UTC
typedef enum { SOUP_ADDRESS_FAMILY_INVALID = -1, SOUP_ADDRESS_FAMILY_IPV4 = G_SOCKET_FAMILY_IPV4, SOUP_ADDRESS_FAMILY_IPV6 = G_SOCKET_FAMILY_IPV6 } SoupAddressFamily; g-ir-scanner is currently parsing that as having values "nvalid", "pv4", and "pv6".
Created attachment 148296 [details] [review] Fix enum prefix stripping to work only up to word boundaries
Comment on attachment 148296 [details] [review] Fix enum prefix stripping to work only up to word boundaries >From 450fd7691440e6033d67cd5d1441431776badca2 Mon Sep 17 00:00:00 2001 >From: Dan Winship <danw@gnome.org> >Date: Sun, 22 Nov 2009 16:38:34 -0500 >Subject: [PATCH] Fix enum prefix stripping to work only up to word boundaries > Looks good. > def _enum_common_prefix(self, symbol): > def common_prefix(a, b): >+ aparts = a.split('_') >+ bparts = b.split('_') >+ alen = len(aparts) >+ blen = len(bparts) > l = min(alen, blen) > for i in xrange(l): >+ if aparts[i] != bparts[i]: >+ return '_'.join(aparts[:i]) + '_' > if alen > blen: > return b > return a This can be simplified a bit (untested): commonparts = [] for aword, bword in zip(a.split('_'), b.split('_')): if aword != bword: return '_'.join(commonparts) + '_' commonparts.append(aword) return min(a, b) Which should be easier to read
pushed with the suggested change, after testing
Created attachment 148327 [details] [review] Fix enum prefix stripping to work only up to word boundaries
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]