From fefcb864e35f595f82b6053a7a5857860eecbe69 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Thu, 17 Jul 2008 09:51:19 +0000 Subject: Use the prefix G_IO_ for stripping constants instead of just G_ Check so 2008-07-17 Johan Dahlin * gio/giomodule.c (init_gio): Use the prefix G_IO_ for stripping constants instead of just G_ * gobject/gobjectmodule.c (pyg_constant_strip_prefix): Check so the fist part of name and strip_prefix are the same, if they don't, just strip of the part of strip_prefix which matches. This removes the initial IO_* prefix for some constants in gio. Eg, gio.IO_ERROR_* -> gio.ERROR_* svn path=/trunk/; revision=817 --- gobject/gobjectmodule.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'gobject/gobjectmodule.c') diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 3bd5645..d9b22ed 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -2964,15 +2964,24 @@ const gchar * pyg_constant_strip_prefix(const gchar *name, const gchar *strip_prefix) { gint prefix_len; - guint j; + guint i; prefix_len = strlen(strip_prefix); - + + /* Check so name starts with strip_prefix, if it doesn't: + * return the rest of the part which doesn't match + */ + for (i = 0; i < prefix_len; i++) { + if (name[i] != strip_prefix[i] && name[i] != '_') { + return &name[i]; + } + } + /* strip off prefix from value name, while keeping it a valid * identifier */ - for (j = prefix_len; j >= 0; j--) { - if (g_ascii_isalpha(name[j]) || name[j] == '_') { - return &name[j]; + for (i = prefix_len; i >= 0; i--) { + if (g_ascii_isalpha(name[i]) || name[i] == '_') { + return &name[i]; } } return name; -- cgit