After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 602672 - Fix enum prefix stripping to work only up to word boundaries
Fix enum prefix stripping to work only up to word boundaries
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2009-11-22 21:41 UTC by Dan Winship
Modified: 2015-02-07 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix enum prefix stripping to work only up to word boundaries (3.09 KB, patch)
2009-11-22 21:41 UTC, Dan Winship
reviewed Details | Review
Fix enum prefix stripping to work only up to word boundaries (3.26 KB, patch)
2009-11-23 16:05 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2009-11-22 21:41:01 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".
Comment 1 Dan Winship 2009-11-22 21:41:02 UTC
Created attachment 148296 [details] [review]
Fix enum prefix stripping to work only up to word boundaries
Comment 2 Johan (not receiving bugmail) Dahlin 2009-11-23 00:05:46 UTC
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
Comment 3 Dan Winship 2009-11-23 16:05:50 UTC
pushed with the suggested change, after testing
Comment 4 Dan Winship 2009-11-23 16:05:55 UTC
Created attachment 148327 [details] [review]
Fix enum prefix stripping to work only up to word boundaries
Comment 5 André Klapper 2015-02-07 17:00:42 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]