indentation fixes.

This commit is contained in:
Tim Janik 1998-07-25 03:03:01 +00:00
parent b813e192c6
commit ce85619724
10 changed files with 634 additions and 556 deletions

View File

@ -8,7 +8,7 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public * You should have received a copy of the GNU Library General Public
@ -20,219 +20,258 @@
#include "glib.h" #include "glib.h"
#include <string.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* GCompletion*
g_completion_new (GCompletionFunc func) { g_completion_new (GCompletionFunc func)
GCompletion* gcomp; {
GCompletion* gcomp;
gcomp = g_new(GCompletion, 1); gcomp = g_new (GCompletion, 1);
gcomp->items = NULL; gcomp->items = NULL;
gcomp->cache = NULL; gcomp->cache = NULL;
gcomp->prefix = NULL; gcomp->prefix = NULL;
if ( func ) gcomp->func = func;
gcomp->func = func;
else return gcomp;
gcomp->func = NULL;
return gcomp;
} }
void void
g_completion_add_items (GCompletion* cmp, GList* items) { g_completion_add_items (GCompletion* cmp,
GList* it; GList* items)
{
GList* it;
g_return_if_fail( cmp != NULL); g_return_if_fail (cmp != NULL);
g_return_if_fail( items != NULL); g_return_if_fail (items != NULL);
/* optimize adding to cache? */ /* optimize adding to cache? */
if ( cmp->cache ) { if (cmp->cache)
g_list_free(cmp->cache); {
cmp->cache = NULL; g_list_free (cmp->cache);
} cmp->cache = NULL;
if ( cmp->prefix ) { }
g_free(cmp->prefix);
cmp->prefix = NULL;
}
it = items; if (cmp->prefix)
while ( it ) { {
cmp->items = g_list_prepend(cmp->items, it->data); g_free (cmp->prefix);
it = it->next; cmp->prefix = NULL;
} }
it = items;
while (it)
{
cmp->items = g_list_prepend (cmp->items, it->data);
it = it->next;
}
} }
void void
g_completion_remove_items (GCompletion* cmp, GList* items) { g_completion_remove_items (GCompletion* cmp,
GList* it; GList* items)
{
GList* it;
g_return_if_fail( cmp != NULL); g_return_if_fail (cmp != NULL);
g_return_if_fail( items != NULL); g_return_if_fail (items != NULL);
it = items; it = items;
while ( cmp->items && it ) { while (cmp->items && it)
cmp->items = g_list_remove(cmp->items, it->data); {
it = it->next; 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 = items;
it = it->next; while (cmp->cache && it)
} {
cmp->cache = g_list_remove(cmp->cache, it->data);
it = it->next;
}
} }
void void
g_completion_clear_items (GCompletion* cmp) { g_completion_clear_items (GCompletion* cmp)
g_return_if_fail(cmp != NULL); {
g_return_if_fail (cmp != NULL);
g_list_free(cmp->items); g_list_free (cmp->items);
cmp->items = NULL; cmp->items = NULL;
g_list_free(cmp->cache); g_list_free (cmp->cache);
cmp->cache = NULL; cmp->cache = NULL;
g_free(cmp->prefix); g_free (cmp->prefix);
cmp->prefix = NULL; cmp->prefix = NULL;
} }
static void static void
completion_check_cache (GCompletion* cmp, gchar** new_prefix) { completion_check_cache (GCompletion* cmp,
register GList* list; gchar** new_prefix)
register gint len; {
register gint i; register GList* list;
register gint plen; register gint len;
gchar* postfix=NULL; register gint i;
gchar* s; register gint plen;
gchar* postfix=NULL;
gchar* s;
if ( !new_prefix ) if (!new_prefix)
return; return;
if ( !cmp->cache ) { if (!cmp->cache)
*new_prefix = NULL; {
return; *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;
} }
plen = i;
list = list->next;
}
len = strlen(cmp->prefix); *new_prefix = g_new0 (gchar, len + plen + 1);
list = cmp->cache; strncpy (*new_prefix, cmp->prefix, len);
s = cmp->func?(*cmp->func)(list->data):(gchar*)list->data; strncpy (*new_prefix + len, postfix, plen);
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);
} }
GList* GList*
g_completion_complete (GCompletion* cmp, gchar* prefix, gchar** new_prefix) { g_completion_complete (GCompletion* cmp,
gint plen, len; gchar* prefix,
gint done=0; gchar** new_prefix)
GList* list; {
gint plen, len;
gint done = 0;
GList* list;
g_return_val_if_fail(cmp != NULL, NULL); g_return_val_if_fail (cmp != NULL, NULL);
g_return_val_if_fail(prefix != NULL, NULL); g_return_val_if_fail (prefix != NULL, NULL);
len = strlen(prefix); len = strlen (prefix);
if ( cmp->prefix && cmp->cache ) { if (cmp->prefix && cmp->cache)
plen = strlen(cmp->prefix); {
if ( plen <= len && !strncmp(prefix, cmp->prefix, plen) ) { plen = strlen (cmp->prefix);
/* use the cache */ if (plen <= len && !strncmp (prefix, cmp->prefix, plen))
list = cmp->cache; {
while ( list ) { /* use the cache */
if ( strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) ) { list = cmp->cache;
list = g_list_remove_link(cmp->cache, list); while (list)
if ( list != cmp->cache ) {
cmp->cache = list; if (strncmp (prefix,
} else cmp->func ? cmp->func (list->data) : (gchar*) list->data,
list = list->next; len))
} {
done = 1; 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 */ if (!done)
g_list_free(cmp->cache); {
cmp->cache = NULL; /* normal code */
list = cmp->items; g_list_free (cmp->cache);
while (*prefix && list) { cmp->cache = NULL;
if ( !strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) ) list = cmp->items;
cmp->cache = g_list_prepend(cmp->cache, list->data); while (*prefix && list)
list = list->next; {
} 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->prefix ) { }
g_free(cmp->prefix); if (cmp->prefix)
cmp->prefix = NULL; {
} g_free (cmp->prefix);
if ( cmp->cache ) cmp->prefix = NULL;
cmp->prefix = g_strdup(prefix); }
completion_check_cache(cmp, new_prefix); if (cmp->cache)
return *prefix?cmp->cache:cmp->items; cmp->prefix = g_strdup (prefix);
completion_check_cache (cmp, new_prefix);
return *prefix ? cmp->cache : cmp->items;
} }
void void
g_completion_free (GCompletion* cmp) { g_completion_free (GCompletion* cmp)
g_return_if_fail(cmp != NULL); {
g_return_if_fail (cmp != NULL);
g_completion_clear_items(cmp); g_completion_clear_items (cmp);
g_free(cmp); g_free (cmp);
} }
#ifdef TEST_COMPLETION #ifdef TEST_COMPLETION
#include <stdio.h> #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;
int main (int argc, char* argv[]) { if (argc < 3)
{
g_warning ("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]);
return 1;
}
FILE * file; file = fopen (argv[1], "r");
gchar buf[1024]; if (!file)
GList *list; {
GList *result; g_warning ("Cannot open %s\n", argv[1]);
GList *tmp; return 1;
GCompletion * cmp; }
gint i;
gchar* longp=NULL;
if ( argc < 3 ) { cmp = g_completion_new (NULL);
g_warning("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]); list = g_list_alloc ();
return 1; while (fgets (buf, 1024, file))
} {
list->data = g_strdup (buf);
g_completion_add_items (cmp, list);
}
fclose (file);
if ( !(file=fopen(argv[1], "r")) ) { for (i = 2; i < argc; ++i)
g_warning("Cannot open %s\n", argv[1]); {
return 1; 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;
}
cmp = g_completion_new(NULL); g_list_foreach (cmp->items, (GFunc) g_free, NULL);
list = g_list_alloc(); g_completion_free (cmp);
while (fgets(buf, 1024, file)) { g_list_free (list);
list->data = g_strdup(buf);
g_completion_add_items(cmp, list);
}
fclose(file);
for ( i= 2; i < argc; ++i) { return 0;
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 #endif

38
glib.h
View File

@ -469,6 +469,7 @@ typedef struct _GDebugKey GDebugKey;
typedef struct _GScannerConfig GScannerConfig; typedef struct _GScannerConfig GScannerConfig;
typedef struct _GScanner GScanner; typedef struct _GScanner GScanner;
typedef union _GValue GValue; typedef union _GValue GValue;
typedef struct _GCompletion GCompletion;
typedef struct _GRelation GRelation; typedef struct _GRelation GRelation;
typedef struct _GTuples GTuples; typedef struct _GTuples GTuples;
@ -497,6 +498,7 @@ typedef void (*GDestroyNotify) (gpointer data);
typedef guint (*GHashFunc) (gconstpointer key); typedef guint (*GHashFunc) (gconstpointer key);
typedef gint (*GCompareFunc) (gconstpointer a, typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b); gconstpointer b);
typedef gchar* (*GCompletionFunc) (gpointer);
struct _GList struct _GList
{ {
@ -880,6 +882,7 @@ void g_stack_trace (const gchar *progname,
gint query); gint query);
/* String Chunks /* String Chunks
*/ */
GStringChunk* g_string_chunk_new (gint size); GStringChunk* g_string_chunk_new (gint size);
@ -1263,29 +1266,26 @@ gint g_scanner_stat_mode (const gchar *filename);
/* Completion */ /* Completion */
typedef gchar* (*GCompletionFunc)(gpointer); struct _GCompletion
{
typedef struct _GCompletion GCompletion; GList* items;
GCompletionFunc func;
struct _GCompletion {
GList* items;
GCompletionFunc func;
gchar* prefix;
GList* cache;
gchar* prefix;
GList* cache;
}; };
GCompletion* g_completion_new (GCompletionFunc func); GCompletion* g_completion_new (GCompletionFunc func);
void g_completion_add_items (GCompletion* cmp, void g_completion_add_items (GCompletion* cmp,
GList* items); GList* items);
void g_completion_remove_items (GCompletion* cmp, void g_completion_remove_items (GCompletion* cmp,
GList* items); GList* items);
void g_completion_clear_items (GCompletion* cmp); void g_completion_clear_items (GCompletion* cmp);
GList* g_completion_complete (GCompletion* cmp, GList* g_completion_complete (GCompletion* cmp,
gchar* prefix, gchar* prefix,
gchar** new_prefix); gchar** new_prefix);
void g_completion_free (GCompletion* cmp); void g_completion_free (GCompletion* cmp);
/* GRelation: Indexed Relations. Imagine a really simple table in a /* GRelation: Indexed Relations. Imagine a really simple table in a
* database. Relations are not ordered. This data type is meant for * database. Relations are not ordered. This data type is meant for

View File

@ -8,7 +8,7 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * 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. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public * You should have received a copy of the GNU Library General Public
@ -20,219 +20,258 @@
#include "glib.h" #include "glib.h"
#include <string.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* GCompletion*
g_completion_new (GCompletionFunc func) { g_completion_new (GCompletionFunc func)
GCompletion* gcomp; {
GCompletion* gcomp;
gcomp = g_new(GCompletion, 1); gcomp = g_new (GCompletion, 1);
gcomp->items = NULL; gcomp->items = NULL;
gcomp->cache = NULL; gcomp->cache = NULL;
gcomp->prefix = NULL; gcomp->prefix = NULL;
if ( func ) gcomp->func = func;
gcomp->func = func;
else return gcomp;
gcomp->func = NULL;
return gcomp;
} }
void void
g_completion_add_items (GCompletion* cmp, GList* items) { g_completion_add_items (GCompletion* cmp,
GList* it; GList* items)
{
GList* it;
g_return_if_fail( cmp != NULL); g_return_if_fail (cmp != NULL);
g_return_if_fail( items != NULL); g_return_if_fail (items != NULL);
/* optimize adding to cache? */ /* optimize adding to cache? */
if ( cmp->cache ) { if (cmp->cache)
g_list_free(cmp->cache); {
cmp->cache = NULL; g_list_free (cmp->cache);
} cmp->cache = NULL;
if ( cmp->prefix ) { }
g_free(cmp->prefix);
cmp->prefix = NULL;
}
it = items; if (cmp->prefix)
while ( it ) { {
cmp->items = g_list_prepend(cmp->items, it->data); g_free (cmp->prefix);
it = it->next; cmp->prefix = NULL;
} }
it = items;
while (it)
{
cmp->items = g_list_prepend (cmp->items, it->data);
it = it->next;
}
} }
void void
g_completion_remove_items (GCompletion* cmp, GList* items) { g_completion_remove_items (GCompletion* cmp,
GList* it; GList* items)
{
GList* it;
g_return_if_fail( cmp != NULL); g_return_if_fail (cmp != NULL);
g_return_if_fail( items != NULL); g_return_if_fail (items != NULL);
it = items; it = items;
while ( cmp->items && it ) { while (cmp->items && it)
cmp->items = g_list_remove(cmp->items, it->data); {
it = it->next; 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 = items;
it = it->next; while (cmp->cache && it)
} {
cmp->cache = g_list_remove(cmp->cache, it->data);
it = it->next;
}
} }
void void
g_completion_clear_items (GCompletion* cmp) { g_completion_clear_items (GCompletion* cmp)
g_return_if_fail(cmp != NULL); {
g_return_if_fail (cmp != NULL);
g_list_free(cmp->items); g_list_free (cmp->items);
cmp->items = NULL; cmp->items = NULL;
g_list_free(cmp->cache); g_list_free (cmp->cache);
cmp->cache = NULL; cmp->cache = NULL;
g_free(cmp->prefix); g_free (cmp->prefix);
cmp->prefix = NULL; cmp->prefix = NULL;
} }
static void static void
completion_check_cache (GCompletion* cmp, gchar** new_prefix) { completion_check_cache (GCompletion* cmp,
register GList* list; gchar** new_prefix)
register gint len; {
register gint i; register GList* list;
register gint plen; register gint len;
gchar* postfix=NULL; register gint i;
gchar* s; register gint plen;
gchar* postfix=NULL;
gchar* s;
if ( !new_prefix ) if (!new_prefix)
return; return;
if ( !cmp->cache ) { if (!cmp->cache)
*new_prefix = NULL; {
return; *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;
} }
plen = i;
list = list->next;
}
len = strlen(cmp->prefix); *new_prefix = g_new0 (gchar, len + plen + 1);
list = cmp->cache; strncpy (*new_prefix, cmp->prefix, len);
s = cmp->func?(*cmp->func)(list->data):(gchar*)list->data; strncpy (*new_prefix + len, postfix, plen);
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);
} }
GList* GList*
g_completion_complete (GCompletion* cmp, gchar* prefix, gchar** new_prefix) { g_completion_complete (GCompletion* cmp,
gint plen, len; gchar* prefix,
gint done=0; gchar** new_prefix)
GList* list; {
gint plen, len;
gint done = 0;
GList* list;
g_return_val_if_fail(cmp != NULL, NULL); g_return_val_if_fail (cmp != NULL, NULL);
g_return_val_if_fail(prefix != NULL, NULL); g_return_val_if_fail (prefix != NULL, NULL);
len = strlen(prefix); len = strlen (prefix);
if ( cmp->prefix && cmp->cache ) { if (cmp->prefix && cmp->cache)
plen = strlen(cmp->prefix); {
if ( plen <= len && !strncmp(prefix, cmp->prefix, plen) ) { plen = strlen (cmp->prefix);
/* use the cache */ if (plen <= len && !strncmp (prefix, cmp->prefix, plen))
list = cmp->cache; {
while ( list ) { /* use the cache */
if ( strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) ) { list = cmp->cache;
list = g_list_remove_link(cmp->cache, list); while (list)
if ( list != cmp->cache ) {
cmp->cache = list; if (strncmp (prefix,
} else cmp->func ? cmp->func (list->data) : (gchar*) list->data,
list = list->next; len))
} {
done = 1; 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 */ if (!done)
g_list_free(cmp->cache); {
cmp->cache = NULL; /* normal code */
list = cmp->items; g_list_free (cmp->cache);
while (*prefix && list) { cmp->cache = NULL;
if ( !strncmp(prefix, cmp->func?(*cmp->func)(list->data):(gchar*)list->data, len) ) list = cmp->items;
cmp->cache = g_list_prepend(cmp->cache, list->data); while (*prefix && list)
list = list->next; {
} 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->prefix ) { }
g_free(cmp->prefix); if (cmp->prefix)
cmp->prefix = NULL; {
} g_free (cmp->prefix);
if ( cmp->cache ) cmp->prefix = NULL;
cmp->prefix = g_strdup(prefix); }
completion_check_cache(cmp, new_prefix); if (cmp->cache)
return *prefix?cmp->cache:cmp->items; cmp->prefix = g_strdup (prefix);
completion_check_cache (cmp, new_prefix);
return *prefix ? cmp->cache : cmp->items;
} }
void void
g_completion_free (GCompletion* cmp) { g_completion_free (GCompletion* cmp)
g_return_if_fail(cmp != NULL); {
g_return_if_fail (cmp != NULL);
g_completion_clear_items(cmp); g_completion_clear_items (cmp);
g_free(cmp); g_free (cmp);
} }
#ifdef TEST_COMPLETION #ifdef TEST_COMPLETION
#include <stdio.h> #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;
int main (int argc, char* argv[]) { if (argc < 3)
{
g_warning ("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]);
return 1;
}
FILE * file; file = fopen (argv[1], "r");
gchar buf[1024]; if (!file)
GList *list; {
GList *result; g_warning ("Cannot open %s\n", argv[1]);
GList *tmp; return 1;
GCompletion * cmp; }
gint i;
gchar* longp=NULL;
if ( argc < 3 ) { cmp = g_completion_new (NULL);
g_warning("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]); list = g_list_alloc ();
return 1; while (fgets (buf, 1024, file))
} {
list->data = g_strdup (buf);
g_completion_add_items (cmp, list);
}
fclose (file);
if ( !(file=fopen(argv[1], "r")) ) { for (i = 2; i < argc; ++i)
g_warning("Cannot open %s\n", argv[1]); {
return 1; 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;
}
cmp = g_completion_new(NULL); g_list_foreach (cmp->items, (GFunc) g_free, NULL);
list = g_list_alloc(); g_completion_free (cmp);
while (fgets(buf, 1024, file)) { g_list_free (list);
list->data = g_strdup(buf);
g_completion_add_items(cmp, list);
}
fclose(file);
for ( i= 2; i < argc; ++i) { return 0;
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 #endif

View File

@ -469,6 +469,7 @@ typedef struct _GDebugKey GDebugKey;
typedef struct _GScannerConfig GScannerConfig; typedef struct _GScannerConfig GScannerConfig;
typedef struct _GScanner GScanner; typedef struct _GScanner GScanner;
typedef union _GValue GValue; typedef union _GValue GValue;
typedef struct _GCompletion GCompletion;
typedef struct _GRelation GRelation; typedef struct _GRelation GRelation;
typedef struct _GTuples GTuples; typedef struct _GTuples GTuples;
@ -497,6 +498,7 @@ typedef void (*GDestroyNotify) (gpointer data);
typedef guint (*GHashFunc) (gconstpointer key); typedef guint (*GHashFunc) (gconstpointer key);
typedef gint (*GCompareFunc) (gconstpointer a, typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b); gconstpointer b);
typedef gchar* (*GCompletionFunc) (gpointer);
struct _GList struct _GList
{ {
@ -880,6 +882,7 @@ void g_stack_trace (const gchar *progname,
gint query); gint query);
/* String Chunks /* String Chunks
*/ */
GStringChunk* g_string_chunk_new (gint size); GStringChunk* g_string_chunk_new (gint size);
@ -1263,29 +1266,26 @@ gint g_scanner_stat_mode (const gchar *filename);
/* Completion */ /* Completion */
typedef gchar* (*GCompletionFunc)(gpointer); struct _GCompletion
{
typedef struct _GCompletion GCompletion; GList* items;
GCompletionFunc func;
struct _GCompletion {
GList* items;
GCompletionFunc func;
gchar* prefix;
GList* cache;
gchar* prefix;
GList* cache;
}; };
GCompletion* g_completion_new (GCompletionFunc func); GCompletion* g_completion_new (GCompletionFunc func);
void g_completion_add_items (GCompletion* cmp, void g_completion_add_items (GCompletion* cmp,
GList* items); GList* items);
void g_completion_remove_items (GCompletion* cmp, void g_completion_remove_items (GCompletion* cmp,
GList* items); GList* items);
void g_completion_clear_items (GCompletion* cmp); void g_completion_clear_items (GCompletion* cmp);
GList* g_completion_complete (GCompletion* cmp, GList* g_completion_complete (GCompletion* cmp,
gchar* prefix, gchar* prefix,
gchar** new_prefix); gchar** new_prefix);
void g_completion_free (GCompletion* cmp); void g_completion_free (GCompletion* cmp);
/* GRelation: Indexed Relations. Imagine a really simple table in a /* GRelation: Indexed Relations. Imagine a really simple table in a
* database. Relations are not ordered. This data type is meant for * database. Relations are not ordered. This data type is meant for

View File

@ -682,7 +682,7 @@ g_strdown (gchar *string)
} }
void void
g_strup (gchar *string) g_strup (gchar *string)
{ {
register gchar *s; register gchar *s;
@ -698,7 +698,7 @@ g_strup (gchar *string)
} }
void void
g_strreverse (gchar *string) g_strreverse (gchar *string)
{ {
g_return_if_fail (string != NULL); g_return_if_fail (string != NULL);
@ -739,7 +739,7 @@ g_strcasecmp (const gchar *s1,
c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1; c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2; c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
if (c1 != c2) if (c1 != c2)
return (c1 - c2); return (c1 - c2);
s1++; s2++; s1++; s2++;
} }
@ -748,9 +748,9 @@ g_strcasecmp (const gchar *s1,
} }
void void
g_strdelimit (gchar *string, g_strdelimit (gchar *string,
const gchar *delimiters, const gchar *delimiters,
gchar new_delim) gchar new_delim)
{ {
register gchar *c; register gchar *c;

View File

@ -682,7 +682,7 @@ g_strdown (gchar *string)
} }
void void
g_strup (gchar *string) g_strup (gchar *string)
{ {
register gchar *s; register gchar *s;
@ -698,7 +698,7 @@ g_strup (gchar *string)
} }
void void
g_strreverse (gchar *string) g_strreverse (gchar *string)
{ {
g_return_if_fail (string != NULL); g_return_if_fail (string != NULL);
@ -739,7 +739,7 @@ g_strcasecmp (const gchar *s1,
c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1; c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2; c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
if (c1 != c2) if (c1 != c2)
return (c1 - c2); return (c1 - c2);
s1++; s2++; s1++; s2++;
} }
@ -748,9 +748,9 @@ g_strcasecmp (const gchar *s1,
} }
void void
g_strdelimit (gchar *string, g_strdelimit (gchar *string,
const gchar *delimiters, const gchar *delimiters,
gchar new_delim) gchar new_delim)
{ {
register gchar *c; register gchar *c;