From: Elliot Lee Date: Tue, 28 Nov 2000 23:44:21 +0000 (+0000) Subject: Fix warnings. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=790a7bd3be608d9b12a18711d4400490d96b2a46;p=dana%2Fcg-glib.git Fix warnings. * gmarkup.c: Fix warnings. * guniprop.c, gunidecomp.c: Make warnings go away by using GPOINTER_TO_INT() instead of (int). * gcompletion.[ch]: Add g_completion_set_compare(), to allow (for example) using case-insensitive completion. * gobject/gsignal.c: Fix warnings about possible use of uninitialized variables, and fix logic that would leave 'node' unset in cases that it might be used in. * gobject/glib-genmarshal.c: Fix warning about printf format. --- diff --git a/ChangeLog b/ChangeLog index 5582acd2..8be78221 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 5582acd2..8be78221 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5582acd2..8be78221 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 5582acd2..8be78221 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 5582acd2..8be78221 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 5582acd2..8be78221 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 5582acd2..8be78221 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 5582acd2..8be78221 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +2000-11-28 Elliot Lee + + * gmarkup.c: Fix warnings. + + * guniprop.c, gunidecomp.c: Make warnings go away by using + GPOINTER_TO_INT() instead of (int). + + * gcompletion.[ch]: Add g_completion_set_compare(), + to allow (for example) using case-insensitive completion. + 2000-11-28 Tor Lillqvist Patches by Hans Breuer: diff --git a/gcompletion.c b/gcompletion.c index cf1ca010..21bf69ca 100644 --- a/gcompletion.c +++ b/gcompletion.c @@ -44,6 +44,7 @@ g_completion_new (GCompletionFunc func) gcomp->cache = NULL; gcomp->prefix = NULL; gcomp->func = func; + gcomp->strncmp_func = strncmp; return gcomp; } @@ -175,13 +176,13 @@ g_completion_complete (GCompletion* cmp, if (cmp->prefix && cmp->cache) { plen = strlen (cmp->prefix); - if (plen <= len && !strncmp (prefix, cmp->prefix, plen)) + if (plen <= len && ! cmp->strncmp_func (prefix, cmp->prefix, plen)) { /* use the cache */ list = cmp->cache; while (list) { - if (strncmp (prefix, + if (cmp->strncmp_func (prefix, cmp->func ? cmp->func (list->data) : (gchar*) list->data, len)) { @@ -204,7 +205,7 @@ g_completion_complete (GCompletion* cmp, list = cmp->items; while (*prefix && list) { - if (!strncmp (prefix, + if (!cmp->strncmp_func (prefix, cmp->func ? cmp->func (list->data) : (gchar*) list->data, len)) cmp->cache = g_list_prepend (cmp->cache, list->data); @@ -232,6 +233,13 @@ g_completion_free (GCompletion* cmp) g_free (cmp); } +void +g_completion_set_compare(GCompletion *cmp, + GCompletionStrncmpFunc strncmp_func) +{ + cmp->strncmp_func = strncmp_func; +} + #ifdef TEST_COMPLETION #include int diff --git a/gcompletion.h b/gcompletion.h index 5af9475d..6ad65338 100644 --- a/gcompletion.h +++ b/gcompletion.h @@ -28,6 +28,7 @@ #define __G_COMPLETION_H__ #include +#include G_BEGIN_DECLS @@ -38,6 +39,9 @@ typedef gchar* (*GCompletionFunc) (gpointer); /* GCompletion */ +typedef int (*GCompletionStrcmpFunc)(const char *s1, const char *s2); +typedef int (*GCompletionStrncmpFunc)(const char *s1, const char *s2, size_t n); + struct _GCompletion { GList* items; @@ -45,6 +49,7 @@ struct _GCompletion gchar* prefix; GList* cache; + GCompletionStrncmpFunc strncmp_func; }; GCompletion* g_completion_new (GCompletionFunc func); @@ -56,6 +61,8 @@ void g_completion_clear_items (GCompletion* cmp); GList* g_completion_complete (GCompletion* cmp, gchar* prefix, gchar** new_prefix); +void g_completion_set_compare (GCompletion *cmp, + GCompletionStrncmpFunc strncmp_func); void g_completion_free (GCompletion* cmp); G_END_DECLS diff --git a/glib/gcompletion.c b/glib/gcompletion.c index cf1ca010..21bf69ca 100644 --- a/glib/gcompletion.c +++ b/glib/gcompletion.c @@ -44,6 +44,7 @@ g_completion_new (GCompletionFunc func) gcomp->cache = NULL; gcomp->prefix = NULL; gcomp->func = func; + gcomp->strncmp_func = strncmp; return gcomp; } @@ -175,13 +176,13 @@ g_completion_complete (GCompletion* cmp, if (cmp->prefix && cmp->cache) { plen = strlen (cmp->prefix); - if (plen <= len && !strncmp (prefix, cmp->prefix, plen)) + if (plen <= len && ! cmp->strncmp_func (prefix, cmp->prefix, plen)) { /* use the cache */ list = cmp->cache; while (list) { - if (strncmp (prefix, + if (cmp->strncmp_func (prefix, cmp->func ? cmp->func (list->data) : (gchar*) list->data, len)) { @@ -204,7 +205,7 @@ g_completion_complete (GCompletion* cmp, list = cmp->items; while (*prefix && list) { - if (!strncmp (prefix, + if (!cmp->strncmp_func (prefix, cmp->func ? cmp->func (list->data) : (gchar*) list->data, len)) cmp->cache = g_list_prepend (cmp->cache, list->data); @@ -232,6 +233,13 @@ g_completion_free (GCompletion* cmp) g_free (cmp); } +void +g_completion_set_compare(GCompletion *cmp, + GCompletionStrncmpFunc strncmp_func) +{ + cmp->strncmp_func = strncmp_func; +} + #ifdef TEST_COMPLETION #include int diff --git a/glib/gcompletion.h b/glib/gcompletion.h index 5af9475d..6ad65338 100644 --- a/glib/gcompletion.h +++ b/glib/gcompletion.h @@ -28,6 +28,7 @@ #define __G_COMPLETION_H__ #include +#include G_BEGIN_DECLS @@ -38,6 +39,9 @@ typedef gchar* (*GCompletionFunc) (gpointer); /* GCompletion */ +typedef int (*GCompletionStrcmpFunc)(const char *s1, const char *s2); +typedef int (*GCompletionStrncmpFunc)(const char *s1, const char *s2, size_t n); + struct _GCompletion { GList* items; @@ -45,6 +49,7 @@ struct _GCompletion gchar* prefix; GList* cache; + GCompletionStrncmpFunc strncmp_func; }; GCompletion* g_completion_new (GCompletionFunc func); @@ -56,6 +61,8 @@ void g_completion_clear_items (GCompletion* cmp); GList* g_completion_complete (GCompletion* cmp, gchar* prefix, gchar** new_prefix); +void g_completion_set_compare (GCompletion *cmp, + GCompletionStrncmpFunc strncmp_func); void g_completion_free (GCompletion* cmp); G_END_DECLS diff --git a/glib/gmarkup.c b/glib/gmarkup.c index 46064910..58f9438c 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c @@ -1263,8 +1263,8 @@ g_markup_parse_context_parse (GMarkupParseContext *context, if (context->parser->start_element) (* context->parser->start_element) (context, start_name, - attr_names, - attr_values, + (const gchar *)attr_names, + (const gchar *)attr_values, context->user_data, &tmp_error); diff --git a/glib/gunidecomp.c b/glib/gunidecomp.c index 19d39e8c..e6cf97f3 100644 --- a/glib/gunidecomp.c +++ b/glib/gunidecomp.c @@ -29,9 +29,9 @@ /* We cheat a bit and cast type values to (char *). We detect these using the &0xff trick. */ #define CC(Page, Char) \ - (((((int) (combining_class_table[Page])) & 0xff) \ - == ((int) combining_class_table[Page])) \ - ? ((int) combining_class_table[Page]) \ + ((((GPOINTER_TO_INT(combining_class_table[Page])) & 0xff) \ + == GPOINTER_TO_INT(combining_class_table[Page])) \ + ? GPOINTER_TO_INT(combining_class_table[Page]) \ : (combining_class_table[Page][Char])) #define COMBINING_CLASS(Char) \ diff --git a/glib/guniprop.c b/glib/guniprop.c index 8a1b41d6..b1513c1e 100644 --- a/glib/guniprop.c +++ b/glib/guniprop.c @@ -34,8 +34,8 @@ /* We cheat a bit and cast type values to (char *). We detect these using the &0xff trick. */ #define TTYPE(Page, Char) \ - (((((int) type_table[Page]) & 0xff) == ((int) type_table[Page])) \ - ? ((int) (type_table[Page])) \ + (((GPOINTER_TO_INT(type_table[Page]) & 0xff) == GPOINTER_TO_INT(type_table[Page])) \ + ? GPOINTER_TO_INT(type_table[Page]) \ : (type_table[Page][Char])) #define TYPE(Char) (((Char) > (G_UNICODE_LAST_CHAR)) ? G_UNICODE_UNASSIGNED : TTYPE ((Char) >> 8, (Char) & 0xff)) diff --git a/gmarkup.c b/gmarkup.c index 46064910..58f9438c 100644 --- a/gmarkup.c +++ b/gmarkup.c @@ -1263,8 +1263,8 @@ g_markup_parse_context_parse (GMarkupParseContext *context, if (context->parser->start_element) (* context->parser->start_element) (context, start_name, - attr_names, - attr_values, + (const gchar *)attr_names, + (const gchar *)attr_values, context->user_data, &tmp_error); diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 973493e0..082a0a59 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,11 @@ +2000-11-28 Elliot Lee + + * gsignal.c: Fix warnings about possible use of uninitialized + variables, and fix logic that would leave 'node' unset in cases + that it might be used in. + + * glib-genmarshal.c: Fix warning about printf format. + 2000-11-28 Tor Lillqvist * gboxed.c: Include for memset (). diff --git a/gobject/glib-genmarshal.c b/gobject/glib-genmarshal.c index d702dadc..0c3214a3 100644 --- a/gobject/glib-genmarshal.c +++ b/gobject/glib-genmarshal.c @@ -201,7 +201,7 @@ pad (const gchar *string) { g_free (buffer); buffer = g_strdup_printf ("%s ", string); - g_warning ("overfull string (%u bytes) for padspace", strlen (string)); + g_warning ("overfull string (%lu bytes) for padspace", strlen (string)); return buffer; } diff --git a/gobject/gsignal.c b/gobject/gsignal.c index beb6dbda..3964c1fd 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -376,9 +376,9 @@ handlers_find (gpointer instance, { HandlerList *hlist = handler_list_lookup (signal_id, instance); Handler *handler; - SignalNode *node; + SignalNode *node = NULL; - if (mask & G_SIGNAL_MATCH_FUNC) + if (!(mask & G_SIGNAL_MATCH_FUNC)) { node = LOOKUP_SIGNAL_NODE (signal_id); if (!node || !node->c_marshaller) @@ -413,7 +413,7 @@ handlers_find (gpointer instance, for (i = 0; i < hlbsa->n_nodes; i++) { HandlerList *hlist = g_bsearch_array_get_nth (hlbsa, i); - SignalNode *node; + SignalNode *node = NULL; Handler *handler; if (!(mask & G_SIGNAL_MATCH_FUNC)) diff --git a/gunidecomp.c b/gunidecomp.c index 19d39e8c..e6cf97f3 100644 --- a/gunidecomp.c +++ b/gunidecomp.c @@ -29,9 +29,9 @@ /* We cheat a bit and cast type values to (char *). We detect these using the &0xff trick. */ #define CC(Page, Char) \ - (((((int) (combining_class_table[Page])) & 0xff) \ - == ((int) combining_class_table[Page])) \ - ? ((int) combining_class_table[Page]) \ + ((((GPOINTER_TO_INT(combining_class_table[Page])) & 0xff) \ + == GPOINTER_TO_INT(combining_class_table[Page])) \ + ? GPOINTER_TO_INT(combining_class_table[Page]) \ : (combining_class_table[Page][Char])) #define COMBINING_CLASS(Char) \ diff --git a/guniprop.c b/guniprop.c index 8a1b41d6..b1513c1e 100644 --- a/guniprop.c +++ b/guniprop.c @@ -34,8 +34,8 @@ /* We cheat a bit and cast type values to (char *). We detect these using the &0xff trick. */ #define TTYPE(Page, Char) \ - (((((int) type_table[Page]) & 0xff) == ((int) type_table[Page])) \ - ? ((int) (type_table[Page])) \ + (((GPOINTER_TO_INT(type_table[Page]) & 0xff) == GPOINTER_TO_INT(type_table[Page])) \ + ? GPOINTER_TO_INT(type_table[Page]) \ : (type_table[Page][Char])) #define TYPE(Char) (((Char) > (G_UNICODE_LAST_CHAR)) ? G_UNICODE_UNASSIGNED : TTYPE ((Char) >> 8, (Char) & 0xff)) diff --git a/tests/shell-test.c b/tests/shell-test.c index aa5c8c65..c71b10d7 100644 --- a/tests/shell-test.c +++ b/tests/shell-test.c @@ -164,7 +164,6 @@ do_argv_test (const gchar *cmdline, const TestResult *result) static void run_tests (void) { - GError *err; gint i; i = 0;