summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcompletion.c413
-rw-r--r--glib.h58
-rw-r--r--glib/gcompletion.c413
-rw-r--r--glib/glib.h58
-rw-r--r--glib/gscanner.c68
-rw-r--r--glib/gstrfuncs.c56
-rw-r--r--glib/gutils.c6
-rw-r--r--gscanner.c68
-rw-r--r--gstrfuncs.c56
-rw-r--r--gutils.c6
10 files changed, 640 insertions, 562 deletions
diff --git a/gcompletion.c b/gcompletion.c
index 947a6bd60..62ec244bc 100644
--- a/gcompletion.c
+++ b/gcompletion.c
@@ -8,7 +8,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@@ -20,219 +20,258 @@
#include "glib.h"
#include <string.h>
-static void completion_check_cache (GCompletion* cmp, gchar** new_prefix);
+static void completion_check_cache (GCompletion* cmp,
+ gchar** new_prefix);
GCompletion*
-g_completion_new (GCompletionFunc func) {
- GCompletion* gcomp;
-
- gcomp = g_new(GCompletion, 1);
- gcomp->items = NULL;
- gcomp->cache = NULL;
- gcomp->prefix = NULL;
- if ( func )
- gcomp->func = func;
- else
- gcomp->func = NULL;
- return gcomp;
+g_completion_new (GCompletionFunc func)
+{
+ GCompletion* gcomp;
+
+ gcomp = g_new (GCompletion, 1);
+ gcomp->items = NULL;
+ gcomp->cache = NULL;
+ gcomp->prefix = NULL;
+ gcomp->func = func;
+
+ return gcomp;
}
void
-g_completion_add_items (GCompletion* cmp, GList* items) {
- GList* it;
-
- g_return_if_fail( cmp != NULL);
- g_return_if_fail( items != NULL);
-
- /* optimize adding to cache? */
- if ( cmp->cache ) {
- g_list_free(cmp->cache);
- cmp->cache = NULL;
- }
- if ( cmp->prefix ) {
- g_free(cmp->prefix);
- cmp->prefix = NULL;
- }
-
- it = items;
- while ( it ) {
- cmp->items = g_list_prepend(cmp->items, it->data);
- it = it->next;
- }
+g_completion_add_items (GCompletion* cmp,
+ GList* items)
+{
+ GList* it;
+
+ g_return_if_fail (cmp != NULL);
+ g_return_if_fail (items != NULL);
+
+ /* optimize adding to cache? */
+ if (cmp->cache)
+ {
+ g_list_free (cmp->cache);
+ cmp->cache = NULL;
+ }
+
+ if (cmp->prefix)
+ {
+ g_free (cmp->prefix);
+ cmp->prefix = NULL;
+ }
+
+ it = items;
+ while (it)
+ {
+ cmp->items = g_list_prepend (cmp->items, it->data);
+ it = it->next;
+ }
}
void
-g_completion_remove_items (GCompletion* cmp, GList* items) {
- GList* it;
-
- g_return_if_fail( cmp != NULL);
- g_return_if_fail( items != NULL);
-
- it = items;
- while ( cmp->items && it ) {
- cmp->items = g_list_remove(cmp->items, it->data);
- it = it->next;
- }
- it = items;
- while ( cmp->cache && it ) {
- cmp->cache = g_list_remove(cmp->cache, it->data);
- it = it->next;
- }
+g_completion_remove_items (GCompletion* cmp,
+ GList* items)
+{
+ GList* it;
+
+ g_return_if_fail (cmp != NULL);
+ g_return_if_fail (items != NULL);
+
+ it = items;
+ while (cmp->items && it)
+ {
+ cmp->items = g_list_remove (cmp->items, it->data);
+ it = it->next;
+ }
+
+ it = items;
+ while (cmp->cache && it)
+ {
+ cmp->cache = g_list_remove(cmp->cache, it->data);
+ it = it->next;
+ }
}
void
-g_completion_clear_items (GCompletion* cmp) {
- g_return_if_fail(cmp != NULL);
-
- g_list_free(cmp->items);
- cmp->items = NULL;
- g_list_free(cmp->cache);
- cmp->cache = NULL;
- g_free(cmp->prefix);
- cmp->prefix = NULL;
+g_completion_clear_items (GCompletion* cmp)
+{
+ g_return_if_fail (cmp != NULL);
+
+ g_list_free (cmp->items);
+ cmp->items = NULL;
+ g_list_free (cmp->cache);
+ cmp->cache = NULL;
+ g_free (cmp->prefix);
+ cmp->prefix = NULL;
}
static void
-completion_check_cache (GCompletion* cmp, gchar** new_prefix) {
- register GList* list;
- register gint len;
- register gint i;
- register gint plen;
- gchar* postfix=NULL;
- gchar* s;
-
- if ( !new_prefix )
- return;
- if ( !cmp->cache ) {
- *new_prefix = NULL;
- return;
+completion_check_cache (GCompletion* cmp,
+ gchar** new_prefix)
+{
+ register GList* list;
+ register gint len;
+ register gint i;
+ register gint plen;
+ gchar* postfix=NULL;
+ gchar* s;
+
+ if (!new_prefix)
+ return;
+ if (!cmp->cache)
+ {
+ *new_prefix = NULL;
+ return;
+ }
+
+ len = strlen(cmp->prefix);
+ list = cmp->cache;
+ s = cmp->func ? cmp->func (list->data) : (gchar*) list->data;
+ postfix = s + len;
+ plen = strlen (postfix);
+ list = list->next;
+
+ while (list && plen)
+ {
+ s = cmp->func ? cmp->func (list->data) : (gchar*) list->data;
+ s += len;
+ for (i = 0; i < plen; ++i)
+ {
+ if (postfix[i] != s[i])
+ break;
}
-
- len = strlen(cmp->prefix);
- list = cmp->cache;
- s = cmp->func?(*cmp->func)(list->data):(gchar*)list->data;
- postfix = s + len;
- plen = strlen(postfix);
- list = list->next;
-
- while (list && plen) {
- s = cmp->func?(*cmp->func)(list->data):(gchar*)list->data;
- s += len;
- for (i=0; i < plen; ++i) {
- if ( postfix[i] != s[i] )
- break;
- }
- plen = i;
- list = list->next;
- }
-
- *new_prefix = g_new0(gchar, len+plen+1);
- strncpy(*new_prefix, cmp->prefix, len);
- strncpy(*new_prefix+len, postfix, plen);
+ plen = i;
+ list = list->next;
+ }
+
+ *new_prefix = g_new0 (gchar, len + plen + 1);
+ strncpy (*new_prefix, cmp->prefix, len);
+ strncpy (*new_prefix + len, postfix, plen);
}
GList*
-g_completion_complete (GCompletion* cmp, gchar* prefix, gchar** new_prefix) {
- gint plen, len;
- gint done=0;
- GList* list;
-
- g_return_val_if_fail(cmp != NULL, NULL);
- g_return_val_if_fail(prefix != NULL, NULL);
-
- len = strlen(prefix);
- if ( cmp->prefix && cmp->cache ) {
- plen = strlen(cmp->prefix);
- if ( plen <= len && !strncmp(prefix, cmp->prefix, plen) ) {
- /* use the cache */
- list = cmp->cache;
- while ( list ) {
- if ( strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) ) {
- list = g_list_remove_link(cmp->cache, list);
- if ( list != cmp->cache )
- cmp->cache = list;
- } else
- list = list->next;
- }
- done = 1;
- }
- }
-
- if (!done) { /* normal code */
- g_list_free(cmp->cache);
- cmp->cache = NULL;
- list = cmp->items;
- while (*prefix && list) {
- if ( !strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) )
- cmp->cache = g_list_prepend(cmp->cache, list->data);
- list = list->next;
+g_completion_complete (GCompletion* cmp,
+ gchar* prefix,
+ gchar** new_prefix)
+{
+ gint plen, len;
+ gint done = 0;
+ GList* list;
+
+ g_return_val_if_fail (cmp != NULL, NULL);
+ g_return_val_if_fail (prefix != NULL, NULL);
+
+ len = strlen (prefix);
+ if (cmp->prefix && cmp->cache)
+ {
+ plen = strlen (cmp->prefix);
+ if (plen <= len && !strncmp (prefix, cmp->prefix, plen))
+ {
+ /* use the cache */
+ list = cmp->cache;
+ while (list)
+ {
+ if (strncmp (prefix,
+ cmp->func ? cmp->func (list->data) : (gchar*) list->data,
+ len))
+ {
+ list = g_list_remove_link (cmp->cache, list);
+ if (list != cmp->cache)
+ cmp->cache = list;
}
+ else
+ list = list->next;
+ }
+ done = 1;
}
- if ( cmp->prefix ) {
- g_free(cmp->prefix);
- cmp->prefix = NULL;
+ }
+
+ if (!done)
+ {
+ /* normal code */
+ g_list_free (cmp->cache);
+ cmp->cache = NULL;
+ list = cmp->items;
+ while (*prefix && list)
+ {
+ if (!strncmp (prefix,
+ cmp->func ? cmp->func (list->data) : (gchar*) list->data,
+ len))
+ cmp->cache = g_list_prepend (cmp->cache, list->data);
+ list = list->next;
}
- if ( cmp->cache )
- cmp->prefix = g_strdup(prefix);
- completion_check_cache(cmp, new_prefix);
- return *prefix?cmp->cache:cmp->items;
-
+ }
+ if (cmp->prefix)
+ {
+ g_free (cmp->prefix);
+ cmp->prefix = NULL;
+ }
+ if (cmp->cache)
+ cmp->prefix = g_strdup (prefix);
+ completion_check_cache (cmp, new_prefix);
+
+ return *prefix ? cmp->cache : cmp->items;
}
void
-g_completion_free (GCompletion* cmp) {
- g_return_if_fail(cmp != NULL);
-
- g_completion_clear_items(cmp);
- g_free(cmp);
+g_completion_free (GCompletion* cmp)
+{
+ g_return_if_fail (cmp != NULL);
+
+ g_completion_clear_items (cmp);
+ g_free (cmp);
}
#ifdef TEST_COMPLETION
-
#include <stdio.h>
-
-int main (int argc, char* argv[]) {
-
- FILE * file;
- gchar buf[1024];
- GList *list;
- GList *result;
- GList *tmp;
- GCompletion * cmp;
- gint i;
- gchar* longp=NULL;
-
- if ( argc < 3 ) {
- g_warning("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]);
- return 1;
- }
-
- if ( !(file=fopen(argv[1], "r")) ) {
- g_warning("Cannot open %s\n", argv[1]);
- return 1;
- }
-
- cmp = g_completion_new(NULL);
- list = g_list_alloc();
- while (fgets(buf, 1024, file)) {
- list->data = g_strdup(buf);
- g_completion_add_items(cmp, list);
- }
- fclose(file);
-
- for ( i= 2; i < argc; ++i) {
- printf("COMPLETING: %s\n", argv[i]);
- result = g_completion_complete(cmp, argv[i], &longp);
- g_list_foreach(result, (GFunc)printf, NULL);
- printf("LONG MATCH: %s\n", longp);
- g_free(longp);
- longp = NULL;
- }
-
- g_list_foreach(cmp->items, (GFunc)g_free, NULL);
- g_completion_free(cmp);
- g_list_free(list);
- return 0;
+int
+main (int argc,
+ char* argv[])
+{
+ FILE *file;
+ gchar buf[1024];
+ GList *list;
+ GList *result;
+ GList *tmp;
+ GCompletion *cmp;
+ gint i;
+ gchar *longp = NULL;
+
+ if (argc < 3)
+ {
+ g_warning ("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]);
+ return 1;
+ }
+
+ file = fopen (argv[1], "r");
+ if (!file)
+ {
+ g_warning ("Cannot open %s\n", argv[1]);
+ return 1;
+ }
+
+ cmp = g_completion_new (NULL);
+ list = g_list_alloc ();
+ while (fgets (buf, 1024, file))
+ {
+ list->data = g_strdup (buf);
+ g_completion_add_items (cmp, list);
+ }
+ fclose (file);
+
+ for (i = 2; i < argc; ++i)
+ {
+ printf ("COMPLETING: %s\n", argv[i]);
+ result = g_completion_complete (cmp, argv[i], &longp);
+ g_list_foreach (result, (GFunc) printf, NULL);
+ printf ("LONG MATCH: %s\n", longp);
+ g_free (longp);
+ longp = NULL;
+ }
+
+ g_list_foreach (cmp->items, (GFunc) g_free, NULL);
+ g_completion_free (cmp);
+ g_list_free (list);
+
+ return 0;
}
-
#endif
diff --git a/glib.h b/glib.h
index 4c177902d..6436295a4 100644
--- a/glib.h
+++ b/glib.h
@@ -469,6 +469,7 @@ typedef struct _GDebugKey GDebugKey;
typedef struct _GScannerConfig GScannerConfig;
typedef struct _GScanner GScanner;
typedef union _GValue GValue;
+typedef struct _GCompletion GCompletion;
typedef struct _GRelation GRelation;
typedef struct _GTuples GTuples;
@@ -497,6 +498,7 @@ typedef void (*GDestroyNotify) (gpointer data);
typedef guint (*GHashFunc) (gconstpointer key);
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
+typedef gchar* (*GCompletionFunc) (gpointer);
struct _GList
{
@@ -855,7 +857,7 @@ gint g_snprintf (gchar *string,
gchar* g_basename (const gchar *file_name);
gchar* g_getcwd (void);
gchar* g_dirname (const gchar *file_name);
-
+
/* We make the assumption that if memmove isn't available, then
* bcopy will do the job. This isn't safe everywhere. (bcopy can't
@@ -880,6 +882,7 @@ void g_stack_trace (const gchar *progname,
gint query);
+
/* String Chunks
*/
GStringChunk* g_string_chunk_new (gint size);
@@ -1163,31 +1166,31 @@ struct _GScanner
/* unused fields */
gpointer user_data;
guint max_parse_errors;
-
+
/* g_scanner_error() increments this field */
guint parse_errors;
-
+
/* name of input stream, featured by the default message handler */
const gchar *input_name;
-
+
/* data pointer for derived structures */
gpointer derived_data;
-
+
/* link into the scanner configuration */
GScannerConfig *config;
-
+
/* fields filled in after g_scanner_get_next_token() */
GTokenType token;
GValue value;
guint line;
guint position;
-
+
/* fields filled in after g_scanner_peek_next_token() */
GTokenType next_token;
GValue next_value;
guint next_line;
guint next_position;
-
+
/* to be considered private */
GHashTable *symbol_table;
const gchar *text;
@@ -1195,7 +1198,7 @@ struct _GScanner
gint input_fd;
gint peeked_char;
guint scope_id;
-
+
/* handler function for _warn and _error */
GScannerMsgFunc msg_handler;
};
@@ -1263,29 +1266,26 @@ gint g_scanner_stat_mode (const gchar *filename);
/* Completion */
-typedef gchar* (*GCompletionFunc)(gpointer);
-
-typedef struct _GCompletion GCompletion;
-
-struct _GCompletion {
- GList* items;
- GCompletionFunc func;
-
- gchar* prefix;
- GList* cache;
-
+struct _GCompletion
+{
+ GList* items;
+ GCompletionFunc func;
+
+ gchar* prefix;
+ GList* cache;
};
GCompletion* g_completion_new (GCompletionFunc func);
-void g_completion_add_items (GCompletion* cmp,
- GList* items);
-void g_completion_remove_items (GCompletion* cmp,
- GList* items);
-void g_completion_clear_items (GCompletion* cmp);
-GList* g_completion_complete (GCompletion* cmp,
- gchar* prefix,
- gchar** new_prefix);
-void g_completion_free (GCompletion* cmp);
+void g_completion_add_items (GCompletion* cmp,
+ GList* items);
+void g_completion_remove_items (GCompletion* cmp,
+ GList* items);
+void g_completion_clear_items (GCompletion* cmp);
+GList* g_completion_complete (GCompletion* cmp,
+ gchar* prefix,
+ gchar** new_prefix);
+void g_completion_free (GCompletion* cmp);
+
/* GRelation: Indexed Relations. Imagine a really simple table in a
* database. Relations are not ordered. This data type is meant for
diff --git a/glib/gcompletion.c b/glib/gcompletion.c
index 947a6bd60..62ec244bc 100644
--- a/glib/gcompletion.c
+++ b/glib/gcompletion.c
@@ -8,7 +8,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@@ -20,219 +20,258 @@
#include "glib.h"
#include <string.h>
-static void completion_check_cache (GCompletion* cmp, gchar** new_prefix);
+static void completion_check_cache (GCompletion* cmp,
+ gchar** new_prefix);
GCompletion*
-g_completion_new (GCompletionFunc func) {
- GCompletion* gcomp;
-
- gcomp = g_new(GCompletion, 1);
- gcomp->items = NULL;
- gcomp->cache = NULL;
- gcomp->prefix = NULL;
- if ( func )
- gcomp->func = func;
- else
- gcomp->func = NULL;
- return gcomp;
+g_completion_new (GCompletionFunc func)
+{
+ GCompletion* gcomp;
+
+ gcomp = g_new (GCompletion, 1);
+ gcomp->items = NULL;
+ gcomp->cache = NULL;
+ gcomp->prefix = NULL;
+ gcomp->func = func;
+
+ return gcomp;
}
void
-g_completion_add_items (GCompletion* cmp, GList* items) {
- GList* it;
-
- g_return_if_fail( cmp != NULL);
- g_return_if_fail( items != NULL);
-
- /* optimize adding to cache? */
- if ( cmp->cache ) {
- g_list_free(cmp->cache);
- cmp->cache = NULL;
- }
- if ( cmp->prefix ) {
- g_free(cmp->prefix);
- cmp->prefix = NULL;
- }
-
- it = items;
- while ( it ) {
- cmp->items = g_list_prepend(cmp->items, it->data);
- it = it->next;
- }
+g_completion_add_items (GCompletion* cmp,
+ GList* items)
+{
+ GList* it;
+
+ g_return_if_fail (cmp != NULL);
+ g_return_if_fail (items != NULL);
+
+ /* optimize adding to cache? */
+ if (cmp->cache)
+ {
+ g_list_free (cmp->cache);
+ cmp->cache = NULL;
+ }
+
+ if (cmp->prefix)
+ {
+ g_free (cmp->prefix);
+ cmp->prefix = NULL;
+ }
+
+ it = items;
+ while (it)
+ {
+ cmp->items = g_list_prepend (cmp->items, it->data);
+ it = it->next;
+ }
}
void
-g_completion_remove_items (GCompletion* cmp, GList* items) {
- GList* it;
-
- g_return_if_fail( cmp != NULL);
- g_return_if_fail( items != NULL);
-
- it = items;
- while ( cmp->items && it ) {
- cmp->items = g_list_remove(cmp->items, it->data);
- it = it->next;
- }
- it = items;
- while ( cmp->cache && it ) {
- cmp->cache = g_list_remove(cmp->cache, it->data);
- it = it->next;
- }
+g_completion_remove_items (GCompletion* cmp,
+ GList* items)
+{
+ GList* it;
+
+ g_return_if_fail (cmp != NULL);
+ g_return_if_fail (items != NULL);
+
+ it = items;
+ while (cmp->items && it)
+ {
+ cmp->items = g_list_remove (cmp->items, it->data);
+ it = it->next;
+ }
+
+ it = items;
+ while (cmp->cache && it)
+ {
+ cmp->cache = g_list_remove(cmp->cache, it->data);
+ it = it->next;
+ }
}
void
-g_completion_clear_items (GCompletion* cmp) {
- g_return_if_fail(cmp != NULL);
-
- g_list_free(cmp->items);
- cmp->items = NULL;
- g_list_free(cmp->cache);
- cmp->cache = NULL;
- g_free(cmp->prefix);
- cmp->prefix = NULL;
+g_completion_clear_items (GCompletion* cmp)
+{
+ g_return_if_fail (cmp != NULL);
+
+ g_list_free (cmp->items);
+ cmp->items = NULL;
+ g_list_free (cmp->cache);
+ cmp->cache = NULL;
+ g_free (cmp->prefix);
+ cmp->prefix = NULL;
}
static void
-completion_check_cache (GCompletion* cmp, gchar** new_prefix) {
- register GList* list;
- register gint len;
- register gint i;
- register gint plen;
- gchar* postfix=NULL;
- gchar* s;
-
- if ( !new_prefix )
- return;
- if ( !cmp->cache ) {
- *new_prefix = NULL;
- return;
+completion_check_cache (GCompletion* cmp,
+ gchar** new_prefix)
+{
+ register GList* list;
+ register gint len;
+ register gint i;
+ register gint plen;
+ gchar* postfix=NULL;
+ gchar* s;
+
+ if (!new_prefix)
+ return;
+ if (!cmp->cache)
+ {
+ *new_prefix = NULL;
+ return;
+ }
+
+ len = strlen(cmp->prefix);
+ list = cmp->cache;
+ s = cmp->func ? cmp->func (list->data) : (gchar*) list->data;
+ postfix = s + len;
+ plen = strlen (postfix);
+ list = list->next;
+
+ while (list && plen)
+ {
+ s = cmp->func ? cmp->func (list->data) : (gchar*) list->data;
+ s += len;
+ for (i = 0; i < plen; ++i)
+ {
+ if (postfix[i] != s[i])
+ break;
}
-
- len = strlen(cmp->prefix);
- list = cmp->cache;
- s = cmp->func?(*cmp->func)(list->data):(gchar*)list->data;
- postfix = s + len;
- plen = strlen(postfix);
- list = list->next;
-
- while (list && plen) {
- s = cmp->func?(*cmp->func)(list->data):(gchar*)list->data;
- s += len;
- for (i=0; i < plen; ++i) {
- if ( postfix[i] != s[i] )
- break;
- }
- plen = i;
- list = list->next;
- }
-
- *new_prefix = g_new0(gchar, len+plen+1);
- strncpy(*new_prefix, cmp->prefix, len);
- strncpy(*new_prefix+len, postfix, plen);
+ plen = i;
+ list = list->next;
+ }
+
+ *new_prefix = g_new0 (gchar, len + plen + 1);
+ strncpy (*new_prefix, cmp->prefix, len);
+ strncpy (*new_prefix + len, postfix, plen);
}
GList*
-g_completion_complete (GCompletion* cmp, gchar* prefix, gchar** new_prefix) {
- gint plen, len;
- gint done=0;
- GList* list;
-
- g_return_val_if_fail(cmp != NULL, NULL);
- g_return_val_if_fail(prefix != NULL, NULL);
-
- len = strlen(prefix);
- if ( cmp->prefix && cmp->cache ) {
- plen = strlen(cmp->prefix);
- if ( plen <= len && !strncmp(prefix, cmp->prefix, plen) ) {
- /* use the cache */
- list = cmp->cache;
- while ( list ) {
- if ( strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) ) {
- list = g_list_remove_link(cmp->cache, list);
- if ( list != cmp->cache )
- cmp->cache = list;
- } else
- list = list->next;
- }
- done = 1;
- }
- }
-
- if (!done) { /* normal code */
- g_list_free(cmp->cache);
- cmp->cache = NULL;
- list = cmp->items;
- while (*prefix && list) {
- if ( !strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) )
- cmp->cache = g_list_prepend(cmp->cache, list->data);
- list = list->next;
+g_completion_complete (GCompletion* cmp,
+ gchar* prefix,
+ gchar** new_prefix)
+{
+ gint plen, len;
+ gint done = 0;
+ GList* list;
+
+ g_return_val_if_fail (cmp != NULL, NULL);
+ g_return_val_if_fail (prefix != NULL, NULL);
+
+ len = strlen (prefix);
+ if (cmp->prefix && cmp->cache)
+ {
+ plen = strlen (cmp->prefix);
+ if (plen <= len && !strncmp (prefix, cmp->prefix, plen))
+ {
+ /* use the cache */
+ list = cmp->cache;
+ while (list)
+ {
+ if (strncmp (prefix,
+ cmp->func ? cmp->func (list->data) : (gchar*) list->data,
+ len))
+ {
+ list = g_list_remove_link (cmp->cache, list);
+ if (list != cmp->cache)
+ cmp->cache = list;
}
+ else
+ list = list->next;
+ }
+ done = 1;
}
- if ( cmp->prefix ) {
- g_free(cmp->prefix);
- cmp->prefix = NULL;
+ }
+
+ if (!done)
+ {
+ /* normal code */
+ g_list_free (cmp->cache);
+ cmp->cache = NULL;
+ list = cmp->items;
+ while (*prefix && list)
+ {
+ if (!strncmp (prefix,
+ cmp->func ? cmp->func (list->data) : (gchar*) list->data,
+ len))
+ cmp->cache = g_list_prepend (cmp->cache, list->data);
+ list = list->next;
}
- if ( cmp->cache )
- cmp->prefix = g_strdup(prefix);
- completion_check_cache(cmp, new_prefix);
- return *prefix?cmp->cache:cmp->items;
-
+ }
+ if (cmp->prefix)
+ {
+ g_free (cmp->prefix);
+ cmp->prefix = NULL;
+ }
+ if (cmp->cache)
+ cmp->prefix = g_strdup (prefix);
+ completion_check_cache (cmp, new_prefix);
+
+ return *prefix ? cmp->cache : cmp->items;
}
void
-g_completion_free (GCompletion* cmp) {
- g_return_if_fail(cmp != NULL);
-
- g_completion_clear_items(cmp);
- g_free(cmp);
+g_completion_free (GCompletion* cmp)
+{
+ g_return_if_fail (cmp != NULL);
+
+ g_completion_clear_items (cmp);
+ g_free (cmp);
}
#ifdef TEST_COMPLETION
-
#include <stdio.h>
-
-int main (int argc, char* argv[]) {
-
- FILE * file;
- gchar buf[1024];
- GList *list;
- GList *result;
- GList *tmp;
- GCompletion * cmp;
- gint i;
- gchar* longp=NULL;
-
- if ( argc < 3 ) {
- g_warning("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]);
- return 1;
- }
-
- if ( !(file=fopen(argv[1], "r")) ) {
- g_warning("Cannot open %s\n", argv[1]);
- return 1;
- }
-
- cmp = g_completion_new(NULL);
- list = g_list_alloc();
- while (fgets(buf, 1024, file)) {
- list->data = g_strdup(buf);
- g_completion_add_items(cmp, list);
- }
- fclose(file);
-
- for ( i= 2; i < argc; ++i) {
- printf("COMPLETING: %s\n", argv[i]);
- result = g_completion_complete(cmp, argv[i], &longp);
- g_list_foreach(result, (GFunc)printf, NULL);
- printf("LONG MATCH: %s\n", longp);
- g_free(longp);
- longp = NULL;
- }
-
- g_list_foreach(cmp->items, (GFunc)g_free, NULL);
- g_completion_free(cmp);
- g_list_free(list);
- return 0;
+int
+main (int argc,
+ char* argv[])
+{
+ FILE *file;
+ gchar buf[1024];
+ GList *list;
+ GList *result;
+ GList *tmp;
+ GCompletion *cmp;
+ gint i;
+ gchar *longp = NULL;
+
+ if (argc < 3)
+ {
+ g_warning ("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]);
+ return 1;
+ }
+
+ file = fopen (argv[1], "r");
+ if (!file)
+ {
+ g_warning ("Cannot open %s\n", argv[1]);
+ return 1;
+ }
+
+ cmp = g_completion_new (NULL);
+ list = g_list_alloc ();
+ while (fgets (buf, 1024, file))
+ {
+ list->data = g_strdup (buf);
+ g_completion_add_items (cmp, list);
+ }
+ fclose (file);
+
+ for (i = 2; i < argc; ++i)
+ {
+ printf ("COMPLETING: %s\n", argv[i]);
+ result = g_completion_complete (cmp, argv[i], &longp);
+ g_list_foreach (result, (GFunc) printf, NULL);
+ printf ("LONG MATCH: %s\n", longp);
+ g_free (longp);
+ longp = NULL;
+ }
+
+ g_list_foreach (cmp->items, (GFunc) g_free, NULL);
+ g_completion_free (cmp);
+ g_list_free (list);
+
+ return 0;
}
-
#endif
diff --git a/glib/glib.h b/glib/glib.h
index 4c177902d..6436295a4 100644
--- a/glib/glib.h
+++ b/glib/glib.h
@@ -469,6 +469,7 @@ typedef struct _GDebugKey GDebugKey;
typedef struct _GScannerConfig GScannerConfig;
typedef struct _GScanner GScanner;
typedef union _GValue GValue;
+typedef struct _GCompletion GCompletion;
typedef struct _GRelation GRelation;
typedef struct _GTuples GTuples;
@@ -497,6 +498,7 @@ typedef void (*GDestroyNotify) (gpointer data);
typedef guint (*GHashFunc) (gconstpointer key);
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
+typedef gchar* (*GCompletionFunc) (gpointer);
struct _GList
{
@@ -855,7 +857,7 @@ gint g_snprintf (gchar *string,
gchar* g_basename (const gchar *file_name);
gchar* g_getcwd (void);
gchar* g_dirname (const gchar *file_name);
-
+
/* We make the assumption that if memmove isn't available, then
* bcopy will do the job. This isn't safe everywhere. (bcopy can't
@@ -880,6 +882,7 @@ void g_stack_trace (const gchar *progname,
gint query);
+
/* String Chunks
*/
GStringChunk* g_string_chunk_new (gint size);
@@ -1163,31 +1166,31 @@ struct _GScanner
/* unused fields */
gpointer user_data;
guint max_parse_errors;
-
+
/* g_scanner_error() increments this field */
guint parse_errors;
-
+
/* name of input stream, featured by the default message handler */
const gchar *input_name;
-
+
/* data pointer for derived structures */
gpointer derived_data;
-
+
/* link into the scanner configuration */
GScannerConfig *config;
-
+
/* fields filled in after g_scanner_get_next_token() */
GTokenType token;
GValue value;
guint line;
guint position;
-
+
/* fields filled in after g_scanner_peek_next_token() */
GTokenType next_token;
GValue next_value;
guint next_line;
guint next_position;
-
+
/* to be considered private */
GHashTable *symbol_table;
const gchar *text;
@@ -1195,7 +1198,7 @@ struct _GScanner
gint input_fd;
gint peeked_char;
guint scope_id;
-
+
/* handler function for _warn and _error */
GScannerMsgFunc msg_handler;
};
@@ -1263,29 +1266,26 @@ gint g_scanner_stat_mode (const gchar *filename);
/* Completion */
-typedef gchar* (*GCompletionFunc)(gpointer);
-
-typedef struct _GCompletion GCompletion;
-
-struct _GCompletion {
- GList* items;
- GCompletionFunc func;
-
- gchar* prefix;
- GList* cache;
-
+struct _GCompletion
+{
+ GList* items;
+ GCompletionFunc func;
+
+ gchar* prefix;
+ GList* cache;
};
GCompletion* g_completion_new (GCompletionFunc func);
-void g_completion_add_items (GCompletion* cmp,
- GList* items);
-void g_completion_remove_items (GCompletion* cmp,
- GList* items);
-void g_completion_clear_items (GCompletion* cmp);
-GList* g_completion_complete (GCompletion* cmp,
- gchar* prefix,
- gchar** new_prefix);
-void g_completion_free (GCompletion* cmp);
+void g_completion_add_items (GCompletion* cmp,
+ GList* items);
+void g_completion_remove_items (GCompletion* cmp,
+ GList* items);
+void g_completion_clear_items (GCompletion* cmp);
+GList* g_completion_complete (GCompletion* cmp,
+ gchar* prefix,
+ gchar** new_prefix);
+void g_completion_free (GCompletion* cmp);
+
/* GRelation: Indexed Relations. Imagine a really simple table in a
* database. Relations are not ordered. This data type is meant for
diff --git a/glib/gscanner.c b/glib/gscanner.c
index cb4bf5927..aa0239554 100644
--- a/glib/gscanner.c
+++ b/glib/gscanner.c
@@ -208,14 +208,14 @@ g_scanner_new (GScannerConfig *config_templ)
scanner->next_value.v_int = 0;
scanner->next_line = 1;
scanner->next_position = 0;
-
+
scanner->symbol_table = g_hash_table_new (g_scanner_key_hash, g_scanner_key_equal);
scanner->text = NULL;
scanner->text_len = 0;
scanner->input_fd = -1;
scanner->peeked_char = -1;
scanner->scope_id = 0;
-
+
scanner->msg_handler = g_scanner_msg_handler;
return scanner;
@@ -227,7 +227,7 @@ g_scanner_destroy_symbol_table_entry (gpointer _key,
gpointer _data)
{
GScannerKey *key = _key;
-
+
g_free (key->symbol);
g_free (key);
}
@@ -252,7 +252,7 @@ g_scanner_msg_handler (GScanner *scanner,
gint is_error)
{
g_return_if_fail (scanner != NULL);
-
+
fprintf (stdout, "%s:%d: ", scanner->input_name, scanner->line);
if (is_error)
fprintf (stdout, "error: ");
@@ -266,9 +266,9 @@ g_scanner_error (GScanner *scanner,
{
g_return_if_fail (scanner != NULL);
g_return_if_fail (format != NULL);
-
+
scanner->parse_errors++;
-
+
if (scanner->msg_handler)
{
va_list args, args2;
@@ -279,11 +279,11 @@ g_scanner_error (GScanner *scanner,
string = g_vsprintf ((gchar*) format, &args, &args2);
va_end (args);
va_end (args2);
-
+
string = g_strdup (string);
-
+
scanner->msg_handler (scanner, string, TRUE);
-
+
g_free (string);
}
}
@@ -358,7 +358,7 @@ g_scanner_key_equal (gconstpointer v1,
{
register const GScannerKey *key1 = v1;
register const GScannerKey *key2 = v2;
-
+
return (key1->scope_id == key2->scope_id) && (strcmp (key1->symbol, key2->symbol) == 0);
}
@@ -368,12 +368,12 @@ g_scanner_key_hash (gconstpointer v)
register const GScannerKey *key = v;
register gchar *c;
register guint h;
-
+
h = key->scope_id;
for (c = key->symbol; *c; c++)
{
register guint g;
-
+
h = (h << 4) + *c;
g = h & 0xf0000000;
if (g)
@@ -382,7 +382,7 @@ g_scanner_key_hash (gconstpointer v)
h = h ^ g;
}
}
-
+
return h;
}
@@ -393,7 +393,7 @@ g_scanner_lookup_internal (GScanner *scanner,
{
register GScannerKey *key_p;
GScannerKey key;
-
+
key.scope_id = scope_id;
if (!scanner->config->case_sensitive)
@@ -439,7 +439,7 @@ g_scanner_scope_add_symbol (GScanner *scanner,
if (!scanner->config->case_sensitive)
{
register gchar *c;
-
+
c = key->symbol;
while (*c != 0)
{
@@ -462,7 +462,7 @@ g_scanner_scope_remove_symbol (GScanner *scanner,
g_return_if_fail (scanner != NULL);
g_return_if_fail (symbol != NULL);
-
+
key = g_scanner_lookup_internal (scanner, scope_id, symbol);
if (key)
@@ -484,7 +484,7 @@ g_scanner_lookup_symbol (GScanner *scanner,
if (!symbol)
return NULL;
-
+
scope_id = scanner->scope_id;
key = g_scanner_lookup_internal (scanner, scope_id, symbol);
if (!key && scope_id && scanner->config->scope_0_fallback)
@@ -521,12 +521,12 @@ g_scanner_set_scope (GScanner *scanner,
guint scope_id)
{
register guint old_scope_id;
-
+
g_return_val_if_fail (scanner != NULL, 0);
-
+
old_scope_id = scanner->scope_id;
scanner->scope_id = scope_id;
-
+
return old_scope_id;
}
@@ -540,13 +540,13 @@ g_scanner_foreach_internal (gpointer _key,
register GHFunc func;
register gpointer func_data;
register guint *scope_id;
-
+
d = _user_data;
func = (GHFunc) d[0];
func_data = d[1];
scope_id = d[2];
key = _value;
-
+
if (key->scope_id == *scope_id)
func (key->symbol, key->value, func_data);
}
@@ -558,13 +558,13 @@ g_scanner_scope_foreach_symbol (GScanner *scanner,
gpointer func_data)
{
gpointer d[3];
-
+
g_return_if_fail (scanner != NULL);
-
+
d[0] = (gpointer) func;
d[1] = func_data;
d[2] = &scope_id;
-
+
g_hash_table_foreach (scanner->symbol_table, g_scanner_foreach_internal, d);
}
@@ -572,7 +572,7 @@ void
g_scanner_freeze_symbol_table (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
-
+
g_hash_table_freeze (scanner->symbol_table);
}
@@ -580,7 +580,7 @@ void
g_scanner_thaw_symbol_table (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
-
+
g_hash_table_thaw (scanner->symbol_table);
}
@@ -1046,15 +1046,15 @@ g_scanner_stat_mode (const gchar *filename)
{
struct stat *stat_buf;
gint st_mode;
-
+
stat_buf = g_new0 (struct stat, 1);
-
+
lstat (filename, stat_buf);
-
+
st_mode = stat_buf->st_mode;
-
+
g_free (stat_buf);
-
+
return st_mode;
}
@@ -1634,7 +1634,7 @@ g_scanner_get_token_ll (GScanner *scanner,
{
register GScannerKey *key;
register guint scope_id;
-
+
scope_id = scanner->scope_id;
key = g_scanner_lookup_internal (scanner, scope_id, value.v_identifier);
if (!key && scope_id && scanner->config->scope_0_fallback)
@@ -1647,7 +1647,7 @@ g_scanner_get_token_ll (GScanner *scanner,
value.v_symbol = key->value;
}
}
-
+
if (token == G_TOKEN_IDENTIFIER &&
config->scan_identifier_NULL &&
strlen (value.v_identifier) == 4)
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index 7f94d019f..71d24ec43 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -86,23 +86,23 @@ g_strtod (const gchar *nptr,
gchar *fail_pos_2;
gdouble val_1;
gdouble val_2 = 0;
-
+
g_return_val_if_fail (nptr != NULL, 0);
-
+
fail_pos_1 = NULL;
fail_pos_2 = NULL;
-
+
val_1 = strtod (nptr, &fail_pos_1);
-
+
if (fail_pos_1 && fail_pos_1[0] != 0)
{
gchar *old_locale;
-
+
old_locale = setlocale (LC_NUMERIC, "C");
val_2 = strtod (nptr, &fail_pos_2);
setlocale (LC_NUMERIC, old_locale);
}
-
+
if (!fail_pos_1 || fail_pos_1[0] == 0 || fail_pos_1 >= fail_pos_2)
{
if (endptr)
@@ -542,11 +542,11 @@ g_strerror (gint errnum)
#else /* NO_SYS_ERRLIST */
extern int sys_nerr;
extern char *sys_errlist[];
-
+
if ((errnum > 0) && (errnum <= sys_nerr))
return sys_errlist [errnum];
#endif /* NO_SYS_ERRLIST */
-
+
sprintf (msg, "unknown error (%d)", errnum);
return msg;
}
@@ -555,7 +555,7 @@ gchar*
g_strsignal (gint signum)
{
static char msg[64];
-
+
#ifdef HAVE_STRSIGNAL
extern char *strsignal (int sig);
return strsignal (signum);
@@ -660,7 +660,7 @@ g_strsignal (gint signum)
extern char *sys_siglist[];
return sys_siglist [signum];
#endif /* NO_SYS_SIGLIST */
-
+
sprintf (msg, "unknown signal (%d)", signum);
return msg;
}
@@ -669,11 +669,11 @@ void
g_strdown (gchar *string)
{
register gchar *s;
-
+
g_return_if_fail (string != NULL);
-
+
s = string;
-
+
while (*s)
{
*s = tolower (*s);
@@ -682,14 +682,14 @@ g_strdown (gchar *string)
}
void
-g_strup (gchar *string)
+g_strup (gchar *string)
{
register gchar *s;
-
+
g_return_if_fail (string != NULL);
-
+
s = string;
-
+
while (*s)
{
*s = toupper (*s);
@@ -698,14 +698,14 @@ g_strup (gchar *string)
}
void
-g_strreverse (gchar *string)
+g_strreverse (gchar *string)
{
g_return_if_fail (string != NULL);
-
+
if (*string)
{
register gchar *h, *t;
-
+
h = string;
t = string + strlen (string) - 1;
@@ -730,7 +730,7 @@ g_strcasecmp (const gchar *s1,
return strcasecmp (s1, s2);
#else
gint c1, c2;
-
+
while (*s1 && *s2)
{
/* According to A. Cox, some platforms have islower's that
@@ -739,26 +739,26 @@ g_strcasecmp (const gchar *s1,
c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
if (c1 != c2)
- return (c1 - c2);
+ return (c1 - c2);
s1++; s2++;
}
-
+
return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
#endif
}
void
-g_strdelimit (gchar *string,
+g_strdelimit (gchar *string,
const gchar *delimiters,
- gchar new_delim)
+ gchar new_delim)
{
register gchar *c;
-
+
g_return_if_fail (string != NULL);
-
+
if (!delimiters)
delimiters = G_STR_DELIMITERS;
-
+
for (c = string; *c; c++)
{
if (strchr (delimiters, *c))
diff --git a/glib/gutils.c b/glib/gutils.c
index 19271fa33..02802567d 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -141,11 +141,11 @@ g_dirname (const gchar *file_name)
while (base > file_name && *base == '/')
base--;
len = (guint) 1 + base - file_name;
-
+
base = g_new (gchar, len + 1);
g_memmove (base, file_name, len);
base[len] = 0;
-
+
return base;
}
@@ -261,7 +261,7 @@ void
g_set_prgname (const gchar *prgname)
{
gchar *c = g_prgname;
-
+
g_prgname = g_strdup (prgname);
g_free (c);
}
diff --git a/gscanner.c b/gscanner.c
index cb4bf5927..aa0239554 100644
--- a/gscanner.c
+++ b/gscanner.c
@@ -208,14 +208,14 @@ g_scanner_new (GScannerConfig *config_templ)
scanner->next_value.v_int = 0;
scanner->next_line = 1;
scanner->next_position = 0;
-
+
scanner->symbol_table = g_hash_table_new (g_scanner_key_hash, g_scanner_key_equal);
scanner->text = NULL;
scanner->text_len = 0;
scanner->input_fd = -1;
scanner->peeked_char = -1;
scanner->scope_id = 0;
-
+
scanner->msg_handler = g_scanner_msg_handler;
return scanner;
@@ -227,7 +227,7 @@ g_scanner_destroy_symbol_table_entry (gpointer _key,
gpointer _data)
{
GScannerKey *key = _key;
-
+
g_free (key->symbol);
g_free (key);
}
@@ -252,7 +252,7 @@ g_scanner_msg_handler (GScanner *scanner,
gint is_error)
{
g_return_if_fail (scanner != NULL);
-
+
fprintf (stdout, "%s:%d: ", scanner->input_name, scanner->line);
if (is_error)
fprintf (stdout, "error: ");
@@ -266,9 +266,9 @@ g_scanner_error (GScanner *scanner,
{
g_return_if_fail (scanner != NULL);
g_return_if_fail (format != NULL);
-
+
scanner->parse_errors++;
-
+
if (scanner->msg_handler)
{
va_list args, args2;
@@ -279,11 +279,11 @@ g_scanner_error (GScanner *scanner,
string = g_vsprintf ((gchar*) format, &args, &args2);
va_end (args);
va_end (args2);
-
+
string = g_strdup (string);
-
+
scanner->msg_handler (scanner, string, TRUE);
-
+
g_free (string);
}
}
@@ -358,7 +358,7 @@ g_scanner_key_equal (gconstpointer v1,
{
register const GScannerKey *key1 = v1;
register const GScannerKey *key2 = v2;
-
+
return (key1->scope_id == key2->scope_id) && (strcmp (key1->symbol, key2->symbol) == 0);
}
@@ -368,12 +368,12 @@ g_scanner_key_hash (gconstpointer v)
register const GScannerKey *key = v;
register gchar *c;
register guint h;
-
+
h = key->scope_id;
for (c = key->symbol; *c; c++)
{
register guint g;
-
+
h = (h << 4) + *c;
g = h & 0xf0000000;
if (g)
@@ -382,7 +382,7 @@ g_scanner_key_hash (gconstpointer v)
h = h ^ g;
}
}
-
+
return h;
}
@@ -393,7 +393,7 @@ g_scanner_lookup_internal (GScanner *scanner,
{
register GScannerKey *key_p;
GScannerKey key;
-
+
key.scope_id = scope_id;
if (!scanner->config->case_sensitive)
@@ -439,7 +439,7 @@ g_scanner_scope_add_symbol (GScanner *scanner,
if (!scanner->config->case_sensitive)
{
register gchar *c;
-
+
c = key->symbol;
while (*c != 0)
{
@@ -462,7 +462,7 @@ g_scanner_scope_remove_symbol (GScanner *scanner,
g_return_if_fail (scanner != NULL);
g_return_if_fail (symbol != NULL);
-
+
key = g_scanner_lookup_internal (scanner, scope_id, symbol);
if (key)
@@ -484,7 +484,7 @@ g_scanner_lookup_symbol (GScanner *scanner,
if (!symbol)
return NULL;
-
+
scope_id = scanner->scope_id;
key = g_scanner_lookup_internal (scanner, scope_id, symbol);
if (!key && scope_id && scanner->config->scope_0_fallback)
@@ -521,12 +521,12 @@ g_scanner_set_scope (GScanner *scanner,
guint scope_id)
{
register guint old_scope_id;
-
+
g_return_val_if_fail (scanner != NULL, 0);
-
+
old_scope_id = scanner->scope_id;
scanner->scope_id = scope_id;
-
+
return old_scope_id;
}
@@ -540,13 +540,13 @@ g_scanner_foreach_internal (gpointer _key,
register GHFunc func;
register gpointer func_data;
register guint *scope_id;
-
+
d = _user_data;
func = (GHFunc) d[0];
func_data = d[1];
scope_id = d[2];
key = _value;
-
+
if (key->scope_id == *scope_id)
func (key->symbol, key->value, func_data);
}
@@ -558,13 +558,13 @@ g_scanner_scope_foreach_symbol (GScanner *scanner,
gpointer func_data)
{
gpointer d[3];
-
+
g_return_if_fail (scanner != NULL);
-
+
d[0] = (gpointer) func;
d[1] = func_data;
d[2] = &scope_id;
-
+
g_hash_table_foreach (scanner->symbol_table, g_scanner_foreach_internal, d);
}
@@ -572,7 +572,7 @@ void
g_scanner_freeze_symbol_table (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
-
+
g_hash_table_freeze (scanner->symbol_table);
}
@@ -580,7 +580,7 @@ void
g_scanner_thaw_symbol_table (GScanner *scanner)
{
g_return_if_fail (scanner != NULL);
-
+
g_hash_table_thaw (scanner->symbol_table);
}
@@ -1046,15 +1046,15 @@ g_scanner_stat_mode (const gchar *filename)
{
struct stat *stat_buf;
gint st_mode;
-
+
stat_buf = g_new0 (struct stat, 1);
-
+
lstat (filename, stat_buf);
-
+
st_mode = stat_buf->st_mode;
-
+
g_free (stat_buf);
-
+
return st_mode;
}
@@ -1634,7 +1634,7 @@ g_scanner_get_token_ll (GScanner *scanner,
{
register GScannerKey *key;
register guint scope_id;
-
+
scope_id = scanner->scope_id;
key = g_scanner_lookup_internal (scanner, scope_id, value.v_identifier);
if (!key && scope_id && scanner->config->scope_0_fallback)
@@ -1647,7 +1647,7 @@ g_scanner_get_token_ll (GScanner *scanner,
value.v_symbol = key->value;
}
}
-
+
if (token == G_TOKEN_IDENTIFIER &&
config->scan_identifier_NULL &&
strlen (value.v_identifier) == 4)
diff --git a/gstrfuncs.c b/gstrfuncs.c
index 7f94d019f..71d24ec43 100644
--- a/gstrfuncs.c
+++ b/gstrfuncs.c
@@ -86,23 +86,23 @@ g_strtod (const gchar *nptr,
gchar *fail_pos_2;
gdouble val_1;
gdouble val_2 = 0;
-
+
g_return_val_if_fail (nptr != NULL, 0);
-
+
fail_pos_1 = NULL;
fail_pos_2 = NULL;
-
+
val_1 = strtod (nptr, &fail_pos_1);
-
+
if (fail_pos_1 && fail_pos_1[0] != 0)
{
gchar *old_locale;
-
+
old_locale = setlocale (LC_NUMERIC, "C");
val_2 = strtod (nptr, &fail_pos_2);
setlocale (LC_NUMERIC, old_locale);
}
-
+
if (!fail_pos_1 || fail_pos_1[0] == 0 || fail_pos_1 >= fail_pos_2)
{
if (endptr)
@@ -542,11 +542,11 @@ g_strerror (gint errnum)
#else /* NO_SYS_ERRLIST */
extern int sys_nerr;
extern char *sys_errlist[];
-
+
if ((errnum > 0) && (errnum <= sys_nerr))
return sys_errlist [errnum];
#endif /* NO_SYS_ERRLIST */
-
+
sprintf (msg, "unknown error (%d)", errnum);
return msg;
}
@@ -555,7 +555,7 @@ gchar*
g_strsignal (gint signum)
{
static char msg[64];
-
+
#ifdef HAVE_STRSIGNAL
extern char *strsignal (int sig);
return strsignal (signum);
@@ -660,7 +660,7 @@ g_strsignal (gint signum)
extern char *sys_siglist[];
return sys_siglist [signum];
#endif /* NO_SYS_SIGLIST */
-
+
sprintf (msg, "unknown signal (%d)", signum);
return msg;
}
@@ -669,11 +669,11 @@ void
g_strdown (gchar *string)
{
register gchar *s;
-
+
g_return_if_fail (string != NULL);
-
+
s = string;
-
+
while (*s)
{
*s = tolower (*s);
@@ -682,14 +682,14 @@ g_strdown (gchar *string)
}
void
-g_strup (gchar *string)
+g_strup (gchar *string)
{
register gchar *s;
-
+
g_return_if_fail (string != NULL);
-
+
s = string;
-
+
while (*s)
{
*s = toupper (*s);
@@ -698,14 +698,14 @@ g_strup (gchar *string)
}
void
-g_strreverse (gchar *string)
+g_strreverse (gchar *string)
{
g_return_if_fail (string != NULL);
-
+
if (*string)
{
register gchar *h, *t;
-
+
h = string;
t = string + strlen (string) - 1;
@@ -730,7 +730,7 @@ g_strcasecmp (const gchar *s1,
return strcasecmp (s1, s2);
#else
gint c1, c2;
-
+
while (*s1 && *s2)
{
/* According to A. Cox, some platforms have islower's that
@@ -739,26 +739,26 @@ g_strcasecmp (const gchar *s1,
c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
if (c1 != c2)
- return (c1 - c2);
+ return (c1 - c2);
s1++; s2++;
}
-
+
return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
#endif
}
void
-g_strdelimit (gchar *string,
+g_strdelimit (gchar *string,
const gchar *delimiters,
- gchar new_delim)
+ gchar new_delim)
{
register gchar *c;
-
+
g_return_if_fail (string != NULL);
-
+
if (!delimiters)
delimiters = G_STR_DELIMITERS;
-
+
for (c = string; *c; c++)
{
if (strchr (delimiters, *c))
diff --git a/gutils.c b/gutils.c
index 19271fa33..02802567d 100644
--- a/gutils.c
+++ b/gutils.c
@@ -141,11 +141,11 @@ g_dirname (const gchar *file_name)
while (base > file_name && *base == '/')
base--;
len = (guint) 1 + base - file_name;
-
+
base = g_new (gchar, len + 1);
g_memmove (base, file_name, len);
base[len] = 0;
-
+
return base;
}
@@ -261,7 +261,7 @@ void
g_set_prgname (const gchar *prgname)
{
gchar *c = g_prgname;
-
+
g_prgname = g_strdup (prgname);
g_free (c);
}