diff options
Diffstat (limited to 'glib')
-rw-r--r-- | glib/ChangeLog | 149 | ||||
-rw-r--r-- | glib/Makefile.am | 10 | ||||
-rw-r--r-- | glib/configure.in | 34 | ||||
-rw-r--r-- | glib/gerror.c | 14 | ||||
-rw-r--r-- | glib/glib.h | 402 | ||||
-rw-r--r-- | glib/glibconfig.h.in | 3 | ||||
-rw-r--r-- | glib/glist.c | 50 | ||||
-rw-r--r-- | glib/gmem.c | 33 | ||||
-rw-r--r-- | glib/gscanner.c | 393 | ||||
-rw-r--r-- | glib/gslist.c | 48 | ||||
-rw-r--r-- | glib/gstring.c | 130 | ||||
-rw-r--r-- | glib/gtimer.c | 2 | ||||
-rw-r--r-- | glib/gutils.c | 266 | ||||
-rwxr-xr-x | glib/ltconfig | 87 | ||||
-rw-r--r-- | glib/ltmain.sh | 111 | ||||
-rw-r--r-- | glib/testglib.c | 10 |
16 files changed, 1254 insertions, 488 deletions
diff --git a/glib/ChangeLog b/glib/ChangeLog index 2ab8ab1f9b..541430f3c3 100644 --- a/glib/ChangeLog +++ b/glib/ChangeLog @@ -1,3 +1,152 @@ +Sun May 17 10:48:27 1998 Tim Janik <timj@gtk.org> + + * gscanner.c (g_scanner_unexp_token): provide usefull default + specifications for identifier_spec and symbol_spec. + + * glib.h: new functions g_slist_nth_data and g_list_nth_data to return + the data of the nth element in the list. + +Fri May 15 22:31:49 1998 Tim Janik <timj@gtk.org> + + * gscanner.c (g_scanner_unexp_token): removed spurious va_end(args) + that for some reason didn't produce a compiler wrning on my machine + (is va_end undefined for i386?). + +Fri May 15 12:32:08 1998 rodo <doulik@karlin.mff.cuni.cz> + + * gscanner.c: replaced some snprintf with g_snprintf + +Fri May 15 00:56:59 1998 Tim Janik <timj@gtk.org> + + * glib.h: further support for gcc function attributes: G_GNUC_FORMAT, + G_GNUC_NORETURN and G_GNUC_CONST. + + * gscanner.c (g_scanner_stat_mode): changed stat() to lstat(). + (g_scanner_msg_handler): "\n" at end of line! + (g_scanner_foreach_symbol): new function to iterate over the symbol + table (GScanner does value-wrapping). + +Thu May 14 04:14:12 1998 Tim Janik <timj@gtk.org> + + * glib.h: typedef gint gboolean; + this is needed to provide portability with big-endian platforms (e.g. + try sizeof(bool) for c++ on big-endians - it's 4). + this is also needed to maintain some_union.d_gint==some_union.d_gboolean. + plus, gint to gboolean casts and vice versa need to be possible without + loss. + +Tue May 12 19:22:58 1998 Owen Taylor <otaylor@gtk.org> + + * glib/glib.h: Added macros G[U]INT_TO_POINTER() and + GPOINTER_TO_[U]INT for storing small integers integers + inside pointers. + + * glib/testglib.c: Print sizeof() results + as g_print("%ld", (glong)sizeof(foo)), to deal with + size_t being long on Alpha's. + +Tue May 12 16:54:15 1998 Owen Taylor <otaylor@gtk.org> + (James A <jamesa@demon.net> : gtk-jamesa-980511-4.patch) + + * glib.h gstring.c gmessages.c: Added some missing + const to arguments. + + * gutils.c (g_strsignal.c): Added missing return statements. + +Mon May 11 21:11:54 1998 Owen Taylor <otaylor@gtk.org> + + * gutils.c gmessages.c: Moved g_error, g_warning, g_message and + g_print from gutils.c to new file gmessages.c, to avoid having to + include <unistd.h> in gutils.c which was causing problems for the + g_strsignal implementation on FreeBSD boxes. + +Mon May 11 09:53:43 1998 Tim Janik <timj@gtk.org> + + * configure.in: preserve automake CFLAGS. + + * Makefile.am: fully rename the created library to libglib-1.1.la. + this means we need to change certain portions of the Makefile.am on + major/minor version bumps. + + * ltmain.sh: the -release option is not required anymore. + + * glib.h: provide G_GNUC_FUNCTION and G_GNUC_PRETTY_FUNCTION to + avoid conditionals. unconditionally define NULL, TRUE, FALSE, MAX, + MIN, ABS and CLAMP, these macros might be screwed from other headers. + +Mon May 11 01:44:10 1998 Tim Janik <timj@gtk.org> + + * gdataset.c: new file, gdatasets implement the object data + mechanism from GtkObject. a generic data pointer is associated with + a certain location and a key id. + +Sat May 9 20:08:12 1998 Owen Taylor <otaylor@gtk.org> + + * glib/gmem.c: Experimentally restore GMemChunk + to its primeval state - where mem areas are + freed incrementally instead of searching the tree + every time a mem area is completely empty. Also, + always keep one mem chunk around. (Reduced calls + to malloc() a lot, but doesn't really improve + performance significiantly) + +Thu May 7 08:17:28 1998 Tim Janik <timj@gtk.org> + + * glib.h (G_GNUC_PRINTF): + (G_GNUC_SCANF): macros to facilitate the printf/scanf format argument + checking of gcc. + + * gstring.c: const corrections, string!=NULL checks at function entry. + (g_string_down): new function for tolower(3) conversion. + (g_string_up): new function for toupper(3) conversion. + + * gutils.c: const corrections. + (g_strdown): g_string_down() counterpart. + (g_strup): g_string_up() counterpart. + + * gscanner.c (g_scanner_unexp_token): + (g_scanner_error): + (g_scanner_warn): new functions to let a scanner put out warnings + or errors, especially to react on unexpected tokens. + + * gslist.c: + (g_slist_index): find out about about the position of a + certain data pointer. + (g_slist_position): find out about about the position of a + certain node. + + * glist.c: + (g_list_index): find out about about the position of a + certain data pointer. + +Thu May 7 05:14:19 1998 Tim Janik <timj@gtk.org> + + * ltmain.sh: added a new commandline flag -postfix similar to -release, + but will immediately change the library name. + + * Makefile.am: specify -postfix and -version-info + + * configure.in: version bump to 1.1.0. added GLIB_INTERFACE_AGE and + GLIB_BINARY_AGE. calculate LT_* variables for libtool. + +Fri May 1 16:36:08 1998 Owen Taylor <otaylor@gtk.org> + + * gutils.c: (g_strcasecmp). Check for isupper before + taking tolower, and account for macroized tolower. + + * gutils.c (g_error): Check for recursion. + +1998-04-27 Elliot Lee <sopwith@cuc.ml.org> + + * glist.c (g_list_position): New function to find the position of + a link in a list - should be the inverse of g_list_nth(), but + haven't tested it so poof. + +Thu Apr 30 21:41:30 1998 Owen Taylor <otaylor@gtk.org> + + * gstring.c : Check arguments more carefully, + (gtk-draco-980423-1.patch; ramsey@rhrk.uni-kl.de) + Tue Apr 7 19:36:48 1998 Owen Taylor <owt1@cornell.edu> * gutils.c (g_direct_compare): Removed, because that's what diff --git a/glib/Makefile.am b/glib/Makefile.am index 7ee39bae91..ef28c3e2f4 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -2,15 +2,17 @@ configincludedir = $(pkglibdir)/include -lib_LTLIBRARIES = libglib.la +lib_LTLIBRARIES = libglib-1.1.la -libglib_la_SOURCES = \ +libglib_1_1_la_SOURCES = \ garray.c \ gcache.c \ + gdataset.c \ gerror.c \ ghash.c \ glist.c \ gmem.c \ + gmessages.c \ gprimes.c \ gslist.c \ gtimer.c \ @@ -25,12 +27,12 @@ include_HEADERS = \ configinclude_DATA = \ glibconfig.h -libglib_la_LDFLAGS = -version-info 1:0:0 +libglib_1_1_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) INCLUDES = -I$(top_srcdir) noinst_PROGRAMS = testglib -testglib_LDADD = libglib.la +testglib_LDADD = libglib-@LT_RELEASE@.la .PHONY: files release diff --git a/glib/configure.in b/glib/configure.in index cc78947c5d..ecec5f975f 100644 --- a/glib/configure.in +++ b/glib/configure.in @@ -4,8 +4,36 @@ AC_INIT(glist.c) # Save this value here, since automake will set cflags later cflags_set=${CFLAGS+set} -dnl Initialize automake stuff -AM_INIT_AUTOMAKE(glib, 1.0.0) +# Making releases: +# GLIB_MICRO_VERSION += 1; +# GLIB_INTERFACE_AGE += 1; +# GLIB_BINARY_AGE += 1; +# if any functions have been added, set GLIB_INTERFACE_AGE to 0. +# if backwards compatibility has been broken, +# set GLIB_BINARY_AGE and GLIB_INTERFACE_AGE to 0. +# +GLIB_MAJOR_VERSION=1 +GLIB_MINOR_VERSION=1 +GLIB_MICRO_VERSION=0 +GLIB_INTERFACE_AGE=0 +GLIB_BINARY_AGE=0 +GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION +AC_SUBST(GLIB_VERSION) + +# libtool versioning +LT_RELEASE=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION +LT_CURRENT=`expr $GLIB_MICRO_VERSION - $GLIB_INTERFACE_AGE` +LT_REVISION=$GLIB_INTERFACE_AGE +LT_AGE=`expr $GLIB_BINARY_AGE - $GLIB_INTERFACE_AGE` +AC_SUBST(LT_RELEASE) +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) + +VERSION=$GLIB_VERSION +PACKAGE=glib + +AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define) # Specify a configuration file AM_CONFIG_HEADER(glibconfig.h) @@ -24,7 +52,7 @@ AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]] , enable_ansi=no) if test "x$enable_debug" = "xyes"; then - test "$cflags_set" = set || CFLAGS="-g" + test "$cflags_set" = set || CFLAGS="$CFLAGS -g" CFLAGS="$CFLAGS -DG_ENABLE_DEBUG" else if test "x$enable_debug" = "xno"; then diff --git a/glib/gerror.c b/glib/gerror.c index d84ea38ca6..1c4ce5c31c 100644 --- a/glib/gerror.c +++ b/glib/gerror.c @@ -55,7 +55,7 @@ static int do_query (char *prompt); -static void debug (char *progname, int method); +static void debug (const gchar *progname, int method); static void stack_trace (char **); static void stack_trace_sigchld (int); @@ -63,7 +63,7 @@ static void stack_trace_sigchld (int); static int stack_trace_done; void -g_debug (char *progname) +g_debug (const gchar *progname) { char buf[32]; @@ -82,14 +82,16 @@ g_debug (char *progname) } void -g_attach_process (char *progname, int query) +g_attach_process (const gchar *progname, + int query) { if (!query || do_query ("attach to process")) debug (progname, INTERACTIVE); } void -g_stack_trace (char *progname, int query) +g_stack_trace (const gchar *progname, + int query) { if (!query || do_query ("print stack trace")) debug (progname, STACK_TRACE); @@ -114,7 +116,7 @@ do_query (char *prompt) } static void -debug (char *progname, +debug (const char *progname, int method) { pid_t pid; @@ -124,7 +126,7 @@ debug (char *progname, sprintf (buf, "%d", (int) getpid ()); - args[1] = progname; + args[1] = (gchar*) progname; args[2] = buf; switch (method) diff --git a/glib/glib.h b/glib/glib.h index bc63541997..282288c977 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -89,38 +89,85 @@ /* Provide definitions for some commonly used macros. - * These are only provided if they haven't already - * been defined. It is assumed that if they are already - * defined then the current definition is correct. */ -#ifndef FALSE -#define FALSE 0 -#endif /* FALSE */ +#undef NULL +#define NULL ((void*) 0) -#ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ +#undef FALSE +#define FALSE 0 -#ifndef NULL -#define NULL ((void*) 0) -#endif /* NULL */ +#undef TRUE +#define TRUE 1 -#ifndef MAX +#undef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif /* MAX */ -#ifndef MIN +#undef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif /* MIN */ -#ifndef ABS +#undef ABS #define ABS(a) (((a) < 0) ? -(a) : (a)) -#endif /* ABS */ -#ifndef CLAMP +#undef CLAMP #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) -#endif /* CLAMP */ + +/* Provide simple macro statement wrappers (adapted from Pearl): + * G_STMT_START { statements; } G_STMT_END; + * can be used as a single statement, as in + * if (x) G_STMT_START { ... } G_STMT_END; else ... + * + * For gcc we will wrap the statements within `({' and `})' braces. + * For SunOS they will be wrapped within `if (1)' and `else (void)0', + * and otherwise within `do' and `while (0)'. + */ +#if !(defined (G_STMT_START) && defined (G_STMT_END)) +# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus) +# define G_STMT_START (void)( +# define G_STMT_END ) +# else +# if (defined (sun) || defined (__sun__)) +# define G_STMT_START if (1) +# define G_STMT_END else (void)0 +# else +# define G_STMT_START do +# define G_STMT_END while (0) +# endif +# endif +#endif + +/* Provide macros to feature GCC function attributes. + */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((format (printf, format_idx, arg_idx))) +#define G_GNUC_SCANF( format_idx, arg_idx ) \ + __attribute__((format (scanf, format_idx, arg_idx))) +#define G_GNUC_FORMAT( arg_idx ) \ + __attribute__((format_arg (arg_idx))) +#define G_GNUC_NORETURN \ + __attribute__((noreturn)) +#define G_GNUC_CONST \ + __attribute__((const)) +#else /* !__GNUC__ */ +#define G_GNUC_PRINTF( format_idx, arg_idx ) +#define G_GNUC_SCANF( format_idx, arg_idx ) +#define G_GNUC_FORMAT( arg_idx ) +#define G_GNUC_NORETURN +#define G_GNUC_CONST +#endif /* !__GNUC__ */ + +/* Wrap the __PRETTY_FUNCTION__ and __FUNCTION__ variables with macros, + * so we can refer to them as strings unconditionally. + */ +#ifdef __GNUC__ +#define G_GNUC_FUNCTION (__FUNCTION__) +#define G_GNUC_PRETTY_FUNCTION (__PRETTY_FUNCTION__) +#else /* !__GNUC__ */ +#define G_GNUC_FUNCTION ("") +#define G_GNUC_PRETTY_FUNCTION ("") +#endif /* !__GNUC__ */ + #ifndef ATEXIT # ifdef HAVE_ATEXIT @@ -156,29 +203,6 @@ #define g_string(x) #x -/* Provide simple macro statement wrappers (adapted from Pearl): - * G_STMT_START { statements; } G_STMT_END; - * can be used as a single statement, as in - * if (x) G_STMT_START { ... } G_STMT_END; else ... - * - * For gcc we will wrap the statements within `({' and `})' braces. - * For SunOS they will be wrapped within `if (1)' and `else (void)0', - * and otherwise within `do' and `while (0)'. - */ -#if !(defined (G_STMT_START) && defined (G_STMT_END)) -# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus) -# define G_STMT_START (void)( -# define G_STMT_END ) -# else -# if (defined (sun) || defined (__sun__)) -# define G_STMT_START if (1) -# define G_STMT_END else (void)0 -# else -# define G_STMT_START do -# define G_STMT_END while (0) -# endif -# endif -#endif /* Provide macros for error handling. The "assert" macros will @@ -285,8 +309,11 @@ #endif /* G_DISABLE_CHECKS */ + + #ifdef __cplusplus extern "C" { +#pragma } #endif /* __cplusplus */ /* Provide type definitions for commonly used types. @@ -300,7 +327,7 @@ typedef char gchar; typedef short gshort; typedef long glong; typedef int gint; -typedef char gboolean; +typedef gint gboolean; typedef unsigned char guchar; typedef unsigned short gushort; @@ -343,35 +370,69 @@ typedef signed long gint32; typedef unsigned long guint32; #endif /* SIZEOF_INT */ +/* Define macros for storing integers inside pointers */ + +#if (SIZEOF_INT == SIZEOF_VOID_P) + +#define GPOINTER_TO_INT(p) ((gint)(p)) +#define GPOINTER_TO_UINT(p) ((guint)(p)) + +#define GINT_TO_POINTER(i) ((gpointer)(i)) +#define GUINT_TO_POINTER(u) ((gpointer)(u)) + +#elif (SIZEOF_LONG == SIZEOF_VOID_P) + +#define GPOINTER_TO_INT(p) ((gint)(glong)(p)) +#define GPOINTER_TO_UINT(p) ((guint)(gulong)(p)) + +#define GINT_TO_POINTER(i) ((gpointer)(glong)(i)) +#define GUINT_TO_POINTER(u) ((gpointer)(gulong)(u)) + +#else +#error "No integer type of the same size as a pointer" +#endif + -typedef struct _GList GList; -typedef struct _GSList GSList; -typedef struct _GHashTable GHashTable; -typedef struct _GCache GCache; -typedef struct _GTree GTree; -typedef struct _GTimer GTimer; -typedef struct _GMemChunk GMemChunk; -typedef struct _GListAllocator GListAllocator; -typedef struct _GStringChunk GStringChunk; -typedef struct _GString GString; -typedef struct _GArray GArray; -typedef struct _GDebugKey GDebugKey; - -typedef void (*GFunc) (gpointer data, gpointer user_data); -typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data); -typedef guint (*GHashFunc) (gpointer key); -typedef gint (*GCompareFunc) (gpointer a, gpointer b); -typedef gpointer (*GCacheNewFunc) (gpointer key); -typedef gpointer (*GCacheDupFunc) (gpointer value); -typedef void (*GCacheDestroyFunc) (gpointer value); -typedef gint (*GTraverseFunc) (gpointer key, - gpointer value, - gpointer data); -typedef gint (*GSearchFunc) (gpointer key, - gpointer data); -typedef void (*GErrorFunc) (gchar *str); -typedef void (*GWarningFunc) (gchar *str); -typedef void (*GPrintFunc) (gchar *str); +typedef struct _GList GList; +typedef struct _GSList GSList; +typedef struct _GHashTable GHashTable; +typedef struct _GCache GCache; +typedef struct _GTree GTree; +typedef struct _GTimer GTimer; +typedef struct _GMemChunk GMemChunk; +typedef struct _GListAllocator GListAllocator; +typedef struct _GStringChunk GStringChunk; +typedef struct _GString GString; +typedef struct _GArray GArray; +typedef struct _GDebugKey GDebugKey; +typedef struct _GScannerConfig GScannerConfig; +typedef struct _GScanner GScanner; +typedef union _GValue GValue; + + +typedef void (*GFunc) (gpointer data, + gpointer user_data); +typedef void (*GHFunc) (gpointer key, + gpointer value, + gpointer user_data); +typedef guint (*GHashFunc) (gpointer key); +typedef gint (*GCompareFunc) (gpointer a, + gpointer b); +typedef gpointer (*GCacheNewFunc) (gpointer key); +typedef gpointer (*GCacheDupFunc) (gpointer value); +typedef void (*GCacheDestroyFunc) (gpointer value); +typedef gint (*GTraverseFunc) (gpointer key, + gpointer value, + gpointer data); +typedef gint (*GSearchFunc) (gpointer key, + gpointer data); +typedef void (*GErrorFunc) (gchar *str); +typedef void (*GWarningFunc) (gchar *str); +typedef void (*GPrintFunc) (gchar *str); +typedef void (*GScannerMsgFunc) (GScanner *scanner, + gchar *message, + gint error); +typedef void (*GDestroyNotify) (gpointer data); struct _GList @@ -447,12 +508,18 @@ GList* g_list_nth (GList *list, guint n); GList* g_list_find (GList *list, gpointer data); +gint g_list_position (GList *list, + GList *link); +gint g_list_index (GList *list, + gpointer data); GList* g_list_last (GList *list); GList* g_list_first (GList *list); guint g_list_length (GList *list); void g_list_foreach (GList *list, GFunc func, gpointer user_data); +gpointer g_list_nth_data (GList *list, + guint n); #define g_list_previous(list) ((list) ? (((GList *)list)->prev) : NULL) #define g_list_next(list) ((list) ? (((GList *)list)->next) : NULL) @@ -484,11 +551,17 @@ GSList* g_slist_nth (GSList *list, guint n); GSList* g_slist_find (GSList *list, gpointer data); +gint g_slist_position (GSList *list, + GSList *link); +gint g_slist_index (GSList *list, + gpointer data); GSList* g_slist_last (GSList *list); guint g_slist_length (GSList *list); void g_slist_foreach (GSList *list, GFunc func, gpointer user_data); +gpointer g_slist_nth_data (GSList *list, + guint n); #define g_slist_next(list) ((list) ? (((GSList *)list)->next) : NULL) @@ -646,31 +719,35 @@ gdouble g_timer_elapsed (GTimer *timer, /* Output */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -void g_error (gchar *format, ...) __attribute__ ((format (printf, 1, 2))); -void g_warning (gchar *format, ...) __attribute__ ((format (printf, 1, 2))); -void g_message (gchar *format, ...) __attribute__ ((format (printf, 1, 2))); -void g_print (gchar *format, ...) __attribute__ ((format (printf, 1, 2))); -#else -void g_error (gchar *format, ...); -void g_warning (gchar *format, ...); -void g_message (gchar *format, ...); -void g_print (gchar *format, ...); -#endif +void g_error (const gchar *format, ...) G_GNUC_PRINTF (1, 2); +void g_warning (const gchar *format, ...) G_GNUC_PRINTF (1, 2); +void g_message (const gchar *format, ...) G_GNUC_PRINTF (1, 2); +void g_print (const gchar *format, ...) G_GNUC_PRINTF (1, 2); /* Utility functions */ -gchar* g_strdup (const gchar *str); -gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */ -gdouble g_strtod (const gchar *nptr, gchar **endptr); -gchar* g_strerror (gint errnum); -gchar* g_strsignal (gint signum); -gint g_strcasecmp (const gchar *s1, const gchar *s2); -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -gint g_snprintf (gchar *str, gulong n, gchar const *fmt, ...) __attribute__ ((format (printf, 3, 4))); -#else -gint g_snprintf (gchar *str, gulong n, gchar const *fmt, ...); -#endif +#define G_STR_DELIMITERS "_-|> <." +void g_strdelimit (gchar *string, + const gchar *delimiters, + gchar new_delimiter); +gchar* g_strdup (const gchar *str); +gchar* g_strconcat (const gchar *string1, + ...); /* NULL terminated */ +gdouble g_strtod (const gchar *nptr, + gchar **endptr); +gchar* g_strerror (gint errnum); +gchar* g_strsignal (gint signum); +gint g_strcasecmp (const gchar *s1, + const gchar *s2); +void g_strdown (gchar *string); +void g_strup (gchar *string); +guint g_parse_debug_string (const gchar *string, + GDebugKey *keys, + guint nkeys); +gint g_snprintf (gchar *string, + gulong n, + gchar const *format, + ...) G_GNUC_PRINTF (3, 4); /* We make the assumption that if memmove isn't available, then * bcopy will do the job. This isn't safe everywhere. (bcopy can't @@ -688,13 +765,11 @@ GWarningFunc g_set_warning_handler (GWarningFunc func); GPrintFunc g_set_message_handler (GPrintFunc func); GPrintFunc g_set_print_handler (GPrintFunc func); -guint g_parse_debug_string (const gchar *string, - GDebugKey *keys, - guint nkeys); - -void g_debug (char *progname); -void g_attach_process (char *progname, int query); -void g_stack_trace (char *progname, int query); +void g_debug (const gchar *progname); +void g_attach_process (const gchar *progname, + gint query); +void g_stack_trace (const gchar *progname, + gint query); /* String Chunks @@ -702,53 +777,44 @@ void g_stack_trace (char *progname, int query); GStringChunk* g_string_chunk_new (gint size); void g_string_chunk_free (GStringChunk *chunk); gchar* g_string_chunk_insert (GStringChunk *chunk, - gchar* string); + const gchar *string); gchar* g_string_chunk_insert_const (GStringChunk *chunk, - gchar* string); + const gchar *string); /* Strings */ -GString* g_string_new (gchar *init); -void g_string_free (GString *string, - gint free_segment); -GString* g_string_assign (GString *lval, - gchar *rval); -GString* g_string_truncate (GString *string, - gint len); -GString* g_string_append (GString *string, - gchar *val); -GString* g_string_append_c (GString *string, - gchar c); -GString* g_string_prepend (GString *string, - gchar *val); -GString* g_string_prepend_c (GString *string, - gchar c); -GString* g_string_insert (GString *fstring, - gint pos, - gchar *val); -GString* g_string_insert_c (GString *fstring, - gint pos, - gchar c); -GString* g_string_erase (GString *fstring, - gint pos, - gint len); -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -void g_string_sprintf (GString *string, - gchar *fmt, - ...) __attribute__ ((format (printf, 2, 3))); - -void g_string_sprintfa (GString *string, - gchar *fmt, - ...) __attribute__ ((format (printf, 2, 3))); -#else -void g_string_sprintf (GString *string, - gchar *fmt, - ...); - -void g_string_sprintfa (GString *string, - gchar *fmt, - ...); -#endif +GString* g_string_new (const gchar *init); +void g_string_free (GString *string, + gint free_segment); +GString* g_string_assign (GString *lval, + const gchar *rval); +GString* g_string_truncate (GString *string, + gint len); +GString* g_string_append (GString *string, + const gchar *val); +GString* g_string_append_c (GString *string, + gchar c); +GString* g_string_prepend (GString *string, + const gchar *val); +GString* g_string_prepend_c (GString *string, + gchar c); +GString* g_string_insert (GString *string, + gint pos, + const gchar *val); +GString* g_string_insert_c (GString *string, + gint pos, + gchar c); +GString* g_string_erase (GString *string, + gint pos, + gint len); +GString* g_string_down (GString *string); +GString* g_string_up (GString *string); +void g_string_sprintf (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +void g_string_sprintfa (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); /* Resizable arrays */ @@ -791,8 +857,31 @@ guint g_str_hash (const gpointer v); guint g_direct_hash (gpointer key); +/* Associated Data + */ +void g_dataset_destroy (const gpointer dataset_location); +guint g_dataset_try_key (const gchar *key); +guint g_dataset_force_id (const gchar *key); +gpointer g_dataset_id_get_data (const gpointer dataset_location, + guint key_id); +void g_dataset_id_set_data_full (const gpointer dataset_location, + guint key_id, + gpointer data, + GDestroyNotify destroy_func); +void g_dataset_id_set_destroy (const gpointer dataset_location, + guint key_id, + GDestroyNotify destroy_func); + +#define g_dataset_id_set_data(l,k,d) G_STMT_START{g_dataset_id_set_data_full((l),(k),(d),NULL);}G_STMT_END +#define g_dataset_id_remove_data(l,k) G_STMT_START{g_dataset_id_set_data((l),(k),NULL);}G_STMT_END +#define g_dataset_get_data(l,k) (g_dataset_id_get_data((l),g_dataset_try_key(k))) +#define g_dataset_set_data_full(l,k,d,f) G_STMT_START{g_dataset_id_set_data_full((l),g_dataset_force_id(k),(d),(f));}G_STMT_END +#define g_dataset_set_destroy(l,k,f) G_STMT_START{g_dataset_id_set_destroy((l),g_dataset_force_id(k),(f));}G_STMT_END +#define g_dataset_set_data(l,k,d) G_STMT_START{g_dataset_set_data_full((l),(k),(d),NULL);}G_STMT_END +#define g_dataset_remove_data(l,k) G_STMT_START{g_dataset_set_data((l),(k),NULL);}G_STMT_END + + /* GScanner: Flexible lexical scanner for general purpose. - * Copyright (C) 1997 Tim Janik */ /* Character sets */ @@ -807,10 +896,6 @@ guint g_direct_hash (gpointer key); "\361\362\363\364\365\366"\ "\370\371\372\373\374\375\376\377" -typedef union _GValue GValue; -typedef struct _GScannerConfig GScannerConfig; -typedef struct _GScanner GScanner; - /* Error types */ typedef enum { @@ -936,6 +1021,8 @@ struct _GScanner guint text_len; gint input_fd; gint peeked_char; + + GScannerMsgFunc msg_handler; }; GScanner* g_scanner_new (GScannerConfig *config_templ); @@ -957,8 +1044,25 @@ void g_scanner_add_symbol (GScanner *scanner, gpointer value); gpointer g_scanner_lookup_symbol (GScanner *scanner, const gchar *symbol); +void g_scanner_foreach_symbol (GScanner *scanner, + GHFunc func, + gpointer func_data); void g_scanner_remove_symbol (GScanner *scanner, const gchar *symbol); +void g_scanner_unexp_token (GScanner *scanner, + GTokenType expected_token, + const gchar *identifier_spec, + const gchar *symbol_spec, + const gchar *symbol_name, + const gchar *message, + gint is_error); +void g_scanner_error (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); +void g_scanner_warn (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); +gint g_scanner_stat_mode (const gchar *filename); diff --git a/glib/glibconfig.h.in b/glib/glibconfig.h.in index 4d4ad2dc78..8fae1ffb7c 100644 --- a/glib/glibconfig.h.in +++ b/glib/glibconfig.h.in @@ -35,9 +35,6 @@ #undef NO_SYS_ERRLIST #undef NO_SYS_SIGLIST -/* #undef PACKAGE */ -/* #undef VERSION */ - /* The number of bytes in a char. */ #undef SIZEOF_CHAR diff --git a/glib/glist.c b/glib/glist.c index 70a97ea2db..a24751cbc3 100644 --- a/glib/glist.c +++ b/glib/glist.c @@ -33,7 +33,7 @@ static GRealListAllocator *current_allocator = NULL; GListAllocator* -g_list_allocator_new () +g_list_allocator_new (void) { GRealListAllocator* allocator = g_new (GRealListAllocator, 1); @@ -80,7 +80,7 @@ g_list_set_allocator (GListAllocator* fallocator) GList* -g_list_alloc () +g_list_alloc (void) { GList *new_list; @@ -300,6 +300,16 @@ g_list_nth (GList *list, return list; } +gpointer +g_list_nth_data (GList *list, + guint n) +{ + while ((n-- > 0) && list) + list = list->next; + + return list ? list->data : NULL; +} + GList* g_list_find (GList *list, gpointer data) @@ -314,6 +324,42 @@ g_list_find (GList *list, return list; } +gint +g_list_position (GList *list, + GList *link) +{ + gint i; + + i = 0; + while (list) + { + if (list == link) + return i; + i++; + list = list->next; + } + + return -1; +} + +gint +g_list_index (GList *list, + gpointer data) +{ + gint i; + + i = 0; + while (list) + { + if (list->data == data) + return i; + i++; + list = list->next; + } + + return -1; +} + GList* g_list_last (GList *list) { diff --git a/glib/gmem.c b/glib/gmem.c index b1498f936a..101255966a 100644 --- a/glib/gmem.c +++ b/glib/gmem.c @@ -326,7 +326,7 @@ g_free (gpointer mem) void -g_mem_profile () +g_mem_profile (void) { #ifdef MEM_PROFILE gint i; @@ -498,7 +498,6 @@ g_mem_chunk_alloc (GMemChunk *mem_chunk) if (rmem_chunk->free_mem_area) { rmem_chunk->num_mem_areas -= 1; - rmem_chunk->num_marked_areas -= 1; if (temp_area->next) temp_area->next->prev = temp_area->prev; @@ -506,13 +505,15 @@ g_mem_chunk_alloc (GMemChunk *mem_chunk) temp_area->prev->next = temp_area->next; if (temp_area == rmem_chunk->mem_areas) rmem_chunk->mem_areas = rmem_chunk->mem_areas->next; - if (temp_area == rmem_chunk->mem_area) - rmem_chunk->mem_area = NULL; + if (rmem_chunk->type == G_ALLOC_AND_FREE) + g_tree_remove (rmem_chunk->mem_tree, temp_area); g_free (temp_area); } else rmem_chunk->free_mem_area = temp_area; + + rmem_chunk->num_marked_areas -= 1; } } else @@ -562,23 +563,6 @@ g_mem_chunk_alloc (GMemChunk *mem_chunk) rmem_chunk->mem_area->allocated = 0; rmem_chunk->mem_area->mark = 0; } - else if (rmem_chunk->free_mem_area) - { - rmem_chunk->num_mem_areas -= 1; - - if (rmem_chunk->free_mem_area->next) - rmem_chunk->free_mem_area->next->prev = rmem_chunk->free_mem_area->prev; - if (rmem_chunk->free_mem_area->prev) - rmem_chunk->free_mem_area->prev->next = rmem_chunk->free_mem_area->next; - if (rmem_chunk->free_mem_area == rmem_chunk->mem_areas) - rmem_chunk->mem_areas = rmem_chunk->mem_areas->next; - - if (rmem_chunk->type == G_ALLOC_AND_FREE) - g_tree_remove (rmem_chunk->mem_tree, rmem_chunk->free_mem_area); - - g_free (rmem_chunk->free_mem_area); - rmem_chunk->free_mem_area = NULL; - } /* Get the memory and modify the state variables appropriately. */ @@ -624,12 +608,11 @@ g_mem_chunk_free (GMemChunk *mem_chunk, { temp_area->mark = 1; rmem_chunk->num_marked_areas += 1; - - g_mem_chunk_clean (mem_chunk); } } } +/* This doesn't free the free_area if there is one */ void g_mem_chunk_clean (GMemChunk *mem_chunk) { @@ -749,7 +732,7 @@ g_mem_chunk_print (GMemChunk *mem_chunk) } void -g_mem_chunk_info () +g_mem_chunk_info (void) { GRealMemChunk *mem_chunk; gint count; @@ -773,7 +756,7 @@ g_mem_chunk_info () } void -g_blow_chunks () +g_blow_chunks (void) { GRealMemChunk *mem_chunk; diff --git a/glib/gscanner.c b/glib/gscanner.c index a5d359461e..d8f7f6805a 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * * GScanner: Flexible lexical scanner for general purpose. - * Copyright (C) 1997 Tim Janik + * Copyright (C) 1997, 1998 Tim Janik * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -22,9 +22,13 @@ #define __gscanner_c__ #include <stdlib.h> +#include <stdarg.h> #include <string.h> +#include <stdio.h> #include <unistd.h> #include <errno.h> +#include <sys/types.h> /* needed for sys/stat.h */ +#include <sys/stat.h> #include "glib.h" @@ -32,9 +36,9 @@ /* --- defines --- */ #define to_lower(c) ( \ (guchar) ( \ - ( (((guchar)(c))>='A' && ((guchar)(c))<='Z') * ('a'-'A') ) + \ - ( (((guchar)(c))>=192 && ((guchar)(c))<=214) * (224-192) ) + \ - ( (((guchar)(c))>=216 && ((guchar)(c))<=222) * (248-216) ) + \ + ( (((guchar)(c))>='A' && ((guchar)(c))<='Z') * ('a'-'A') ) | \ + ( (((guchar)(c))>=192 && ((guchar)(c))<=214) * (224-192) ) | \ + ( (((guchar)(c))>=216 && ((guchar)(c))<=222) * (248-216) ) | \ ((guchar)(c)) \ ) \ ) @@ -96,6 +100,7 @@ static GScannerConfig g_scanner_config_template = /* --- prototypes --- */ +extern char* g_vsprintf (gchar *fmt, va_list *args, va_list *args2); static GScannerHashVal* g_scanner_lookup_internal (GScanner *scanner, const gchar *symbol); static void g_scanner_get_token_ll (GScanner *scanner, @@ -118,6 +123,9 @@ static guchar g_scanner_peek_next_char(GScanner *scanner); static guchar g_scanner_get_char (GScanner *scanner, guint *line_p, guint *position_p); +static void g_scanner_msg_handler (GScanner *scanner, + gchar *message, + gint is_error); /* --- functions --- */ @@ -197,6 +205,8 @@ g_scanner_new (GScannerConfig *config_templ) scanner->text_len = 0; scanner->input_fd = -1; scanner->peeked_char = -1; + + scanner->msg_handler = g_scanner_msg_handler; return scanner; } @@ -224,6 +234,75 @@ g_scanner_destroy (GScanner *scanner) g_free (scanner); } +static void +g_scanner_msg_handler (GScanner *scanner, + gchar *message, + gint is_error) +{ + g_return_if_fail (scanner != NULL); + + fprintf (stdout, "%s:%d: ", scanner->input_name, scanner->line); + if (is_error) + fprintf (stdout, "error: "); + fprintf (stdout, "%s\n", message); +} + +void +g_scanner_error (GScanner *scanner, + const gchar *format, + ...) +{ + g_return_if_fail (scanner != NULL); + g_return_if_fail (format != NULL); + + scanner->parse_errors++; + + if (scanner->msg_handler) + { + va_list args, args2; + gchar *string; + + va_start (args, format); + va_start (args2, format); + 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); + } +} + +void +g_scanner_warn (GScanner *scanner, + const gchar *format, + ...) +{ + g_return_if_fail (scanner != NULL); + g_return_if_fail (format != NULL); + + if (scanner->msg_handler) + { + va_list args, args2; + gchar *string; + + va_start (args, format); + va_start (args2, format); + string = g_vsprintf ((gchar*) format, &args, &args2); + va_end (args); + va_end (args2); + + string = g_strdup (string); + + scanner->msg_handler (scanner, string, FALSE); + + g_free (string); + } +} + void g_scanner_input_file (GScanner *scanner, gint input_fd) @@ -245,7 +324,7 @@ g_scanner_input_file (GScanner *scanner, void g_scanner_input_text (GScanner *scanner, const gchar *text, - guint text_len) + guint text_len) { g_return_if_fail (text != NULL); @@ -311,6 +390,39 @@ g_scanner_lookup_symbol (GScanner *scanner, return NULL; } +static void +g_scanner_foreach_internal (gpointer key, + gpointer value, + gpointer user_data) +{ + register GScannerHashVal *hash_val; + register GHFunc func; + register gpointer func_data; + register gpointer *d; + + d = user_data; + func = d[0]; + func_data = d[1]; + hash_val = value; + + func (key, hash_val->value, func_data); +} + +void +g_scanner_foreach_symbol (GScanner *scanner, + GHFunc func, + gpointer func_data) +{ + gpointer d[2]; + + g_return_if_fail (scanner != NULL); + + d[0] = func; + d[1] = func_data; + + g_hash_table_foreach (scanner->symbol_table, g_scanner_foreach_internal, d); +} + void g_scanner_remove_symbol (GScanner *scanner, const gchar *symbol) @@ -530,6 +642,277 @@ g_scanner_get_char (GScanner *scanner, return fchar; } +void +g_scanner_unexp_token (GScanner *scanner, + GTokenType expected_token, + const gchar *identifier_spec, + const gchar *symbol_spec, + const gchar *symbol_name, + const gchar *message, + gint is_error) +{ + register gchar *token_string; + register guint token_string_len; + register gchar *expected_string; + register guint expected_string_len; + register gchar *message_prefix; + register gboolean print_unexp; + void (*msg_handler) (GScanner*, const gchar*, ...); + + g_return_if_fail (scanner != NULL); + + if (is_error) + msg_handler = g_scanner_error; + else + msg_handler = g_scanner_warn; + + if (!identifier_spec) + identifier_spec = "identifier"; + if (!symbol_spec) + symbol_spec = "symbol"; + + token_string_len = 56; + token_string = g_new (gchar, token_string_len + 1); + expected_string_len = 64; + expected_string = g_new (gchar, expected_string_len + 1); + print_unexp = TRUE; + + switch (scanner->token) + { + + case G_TOKEN_EOF: + g_snprintf (token_string, token_string_len, "end of file"); + break; + + default: /* 1 ... 255 */ + if (scanner->token >= 1 && scanner->token <= 255) + { + if ((scanner->token >= ' ' && scanner->token <= '~') || + strchr (scanner->config->cset_identifier_first, scanner->token) || + strchr (scanner->config->cset_identifier_nth, scanner->token)) + g_snprintf (token_string, expected_string_len, "character `%c'", scanner->token); + else + g_snprintf (token_string, expected_string_len, "character `\\%o'", scanner->token); + } + else + g_snprintf (token_string, token_string_len, "(unknown) token <%d>", scanner->token); + break; + + case G_TOKEN_ERROR: + print_unexp = FALSE; + expected_token = G_TOKEN_NONE; + switch (scanner->value.v_error) + { + case G_ERR_UNEXP_EOF: + g_snprintf (token_string, token_string_len, "scanner: unexpected end of file"); + break; + + case G_ERR_UNEXP_EOF_IN_STRING: + g_snprintf (token_string, token_string_len, "scanner: unterminated string constant"); + break; + + case G_ERR_UNEXP_EOF_IN_COMMENT: + g_snprintf (token_string, token_string_len, "scanner: unterminated comment"); + break; + + case G_ERR_NON_DIGIT_IN_CONST: + g_snprintf (token_string, token_string_len, "scanner: non digit in constant"); + break; + + case G_ERR_FLOAT_RADIX: + g_snprintf (token_string, token_string_len, "scanner: invalid radix for floating constant"); + break; + + case G_ERR_FLOAT_MALFORMED: + g_snprintf (token_string, token_string_len, "scanner: malformed floating constant"); + break; + + case G_ERR_DIGIT_RADIX: + g_snprintf (token_string, token_string_len, "scanner: digit is beyond radix"); + break; + + case G_ERR_UNKNOWN: + default: + g_snprintf (token_string, token_string_len, "scanner: unknown error"); + break; + } + break; + + case G_TOKEN_CHAR: + g_snprintf (token_string, token_string_len, "character `%c'", scanner->value.v_char); + break; + + case G_TOKEN_SYMBOL: + if (expected_token == G_TOKEN_SYMBOL) + print_unexp = FALSE; + if (symbol_name) + g_snprintf (token_string, + token_string_len, + "%s%s `%s'", + print_unexp ? "" : "invalid ", + symbol_spec, + symbol_name); + else + g_snprintf (token_string, + token_string_len, + "%s%s", + print_unexp ? "" : "invalid ", + symbol_spec); + break; + + case G_TOKEN_IDENTIFIER: + if (expected_token == G_TOKEN_IDENTIFIER) + print_unexp = FALSE; + g_snprintf (token_string, + token_string_len, + "%s%s `%s'", + print_unexp ? "" : "invalid ", + identifier_spec, + scanner->value.v_string); + break; + + case G_TOKEN_BINARY: + case G_TOKEN_OCTAL: + case G_TOKEN_INT: + case G_TOKEN_HEX: + g_snprintf (token_string, token_string_len, "number `%ld'", scanner->value.v_int); + break; + + case G_TOKEN_FLOAT: + g_snprintf (token_string, token_string_len, "number `%.3f'", scanner->value.v_float); + break; + + case G_TOKEN_STRING: + g_snprintf (token_string, + token_string_len, + "%sstring constant \"%s\"", + scanner->value.v_string[0] == 0 ? "empty " : "", + scanner->value.v_string); + token_string[token_string_len - 2] = '"'; + token_string[token_string_len - 1] = 0; + break; + + case G_TOKEN_COMMENT_SINGLE: + case G_TOKEN_COMMENT_MULTI: + g_snprintf (token_string, token_string_len, "comment"); + break; + + case G_TOKEN_NONE: + g_assert_not_reached (); + break; + } + + + switch (expected_token) + { + default: /* 1 ... 255 */ + if (expected_token >= 1 && expected_token <= 255) + { + if ((expected_token >= ' ' && expected_token <= '~') || + strchr (scanner->config->cset_identifier_first, expected_token) || + strchr (scanner->config->cset_identifier_nth, expected_token)) + g_snprintf (expected_string, expected_string_len, "character `%c'", expected_token); + else + g_snprintf (expected_string, expected_string_len, "character `\\%o'", expected_token); + } + else + g_snprintf (expected_string, expected_string_len, "(unknown) token <%d>", expected_token); + break; + + case G_TOKEN_INT: + g_snprintf (expected_string, expected_string_len, "number (integer)"); + break; + + case G_TOKEN_FLOAT: + g_snprintf (expected_string, expected_string_len, "number (float)"); + break; + + case G_TOKEN_STRING: + g_snprintf (expected_string, expected_string_len, "string constant"); + break; + + case G_TOKEN_SYMBOL: + g_snprintf (expected_string, + expected_string_len, + "%s%s", + scanner->token == G_TOKEN_SYMBOL ? "valid " : "", + symbol_spec); + break; + + case G_TOKEN_IDENTIFIER: + g_snprintf (expected_string, + expected_string_len, + "%s%s", + scanner->token == G_TOKEN_IDENTIFIER ? "valid " : "", + identifier_spec); + break; + + case G_TOKEN_NONE: + break; + } + + if (message && message[0] != 0) + message_prefix = " - "; + else + { + message_prefix = ""; + message = ""; + } + + if (expected_token != G_TOKEN_NONE) + { + if (print_unexp) + msg_handler (scanner, + "unexpected %s, expected %s%s%s", + token_string, + expected_string, + message_prefix, + message); + else + msg_handler (scanner, + "%s, expected %s%s%s", + token_string, + expected_string, + message_prefix, + message); + } + else + { + if (print_unexp) + msg_handler (scanner, + "unexpected %s%s%s", + token_string, + message_prefix, + message); + else + msg_handler (scanner, + "%s%s%s", + token_string, + message_prefix, + message); + } + + g_free (token_string); + g_free (expected_string); +} + +gint +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; +} + static void g_scanner_free_value (GTokenType *token_p, GValue *value_p) diff --git a/glib/gslist.c b/glib/gslist.c index 7045687ca2..636dd37dc4 100644 --- a/glib/gslist.c +++ b/glib/gslist.c @@ -57,7 +57,7 @@ g_slist_set_allocator (GListAllocator* fallocator) GSList* -g_slist_alloc () +g_slist_alloc (void) { GSList *new_list; @@ -289,6 +289,16 @@ g_slist_nth (GSList *list, return list; } +gpointer +g_slist_nth_data (GSList *list, + guint n) +{ + while ((n-- > 0) && list) + list = list->next; + + return list ? list->data : NULL; +} + GSList* g_slist_find (GSList *list, gpointer data) @@ -303,6 +313,42 @@ g_slist_find (GSList *list, return list; } +gint +g_slist_position (GSList *list, + GSList *link) +{ + gint i; + + i = 0; + while (list) + { + if (list == link) + return i; + i++; + list = list->next; + } + + return -1; +} + +gint +g_slist_index (GSList *list, + gpointer data) +{ + gint i; + + i = 0; + while (list) + { + if (list->data == data) + return i; + i++; + list = list->next; + } + + return -1; +} + GSList* g_slist_last (GSList *list) { diff --git a/glib/gstring.c b/glib/gstring.c index fc0780e2b4..91a5e1e2c9 100644 --- a/glib/gstring.c +++ b/glib/gstring.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <ctype.h> typedef struct _GRealStringChunk GRealStringChunk; @@ -101,6 +102,8 @@ g_string_chunk_free (GStringChunk *fchunk) GRealStringChunk *chunk = (GRealStringChunk*) fchunk; GSList *tmp_list; + g_return_if_fail (chunk != NULL); + if (chunk->storage_list) { GListAllocator *tmp_allocator = g_slist_set_allocator (NULL); @@ -121,12 +124,14 @@ g_string_chunk_free (GStringChunk *fchunk) gchar* g_string_chunk_insert (GStringChunk *fchunk, - gchar* string) + const gchar *string) { GRealStringChunk *chunk = (GRealStringChunk*) fchunk; gint len = strlen (string); char* pos; + g_return_val_if_fail (chunk != NULL, NULL); + if ((chunk->storage_next + len + 1) > chunk->this_size) { GListAllocator *tmp_allocator = g_slist_set_allocator (NULL); @@ -155,15 +160,17 @@ g_string_chunk_insert (GStringChunk *fchunk, gchar* g_string_chunk_insert_const (GStringChunk *fchunk, - gchar* string) + const gchar *string) { GRealStringChunk *chunk = (GRealStringChunk*) fchunk; char* lookup; + g_return_val_if_fail (chunk != NULL, NULL); + if (!chunk->const_table) chunk->const_table = g_hash_table_new (g_str_hash, g_str_equal); - lookup = (char*) g_hash_table_lookup (chunk->const_table, string); + lookup = (char*) g_hash_table_lookup (chunk->const_table, (gchar *)string); if (!lookup) { @@ -198,7 +205,7 @@ g_string_maybe_expand (GRealString* string, gint len) } GString* -g_string_new (gchar *init) +g_string_new (const gchar *init) { GRealString *string; @@ -220,8 +227,11 @@ g_string_new (gchar *init) } void -g_string_free (GString *string, gint free_segment) +g_string_free (GString *string, + gint free_segment) { + g_return_if_fail (string != NULL); + if (free_segment) g_free (string->str); @@ -230,7 +240,7 @@ g_string_free (GString *string, gint free_segment) GString* g_string_assign (GString *lval, - char *rval) + const gchar *rval) { g_string_truncate (lval, 0); g_string_append (lval, rval); @@ -239,10 +249,13 @@ g_string_assign (GString *lval, } GString* -g_string_truncate (GString* fstring, gint len) +g_string_truncate (GString* fstring, + gint len) { GRealString *string = (GRealString*)fstring; + g_return_val_if_fail (string != NULL, NULL); + string->len = len; string->str[len] = 0; @@ -251,11 +264,16 @@ g_string_truncate (GString* fstring, gint len) } GString* -g_string_append (GString *fstring, gchar *val) +g_string_append (GString *fstring, + const gchar *val) { GRealString *string = (GRealString*)fstring; - int len = strlen (val); + int len; + g_return_val_if_fail (string != NULL, NULL); + g_return_val_if_fail (val != NULL, fstring); + + len = strlen (val); g_string_maybe_expand (string, len); strcpy (string->str + string->len, val); @@ -266,10 +284,12 @@ g_string_append (GString *fstring, gchar *val) } GString* -g_string_append_c (GString *fstring, char c) +g_string_append_c (GString *fstring, + gchar c) { GRealString *string = (GRealString*)fstring; + g_return_val_if_fail (string != NULL, NULL); g_string_maybe_expand (string, 1); string->str[string->len++] = c; @@ -279,11 +299,16 @@ g_string_append_c (GString *fstring, char c) } GString* -g_string_prepend (GString *fstring, gchar *val) +g_string_prepend (GString *fstring, + const gchar *val) { GRealString *string = (GRealString*)fstring; - gint len = strlen (val); + gint len; + + g_return_val_if_fail (string != NULL, NULL); + g_return_val_if_fail (val != NULL, fstring); + len = strlen (val); g_string_maybe_expand (string, len); g_memmove (string->str + len, string->str, string->len); @@ -298,10 +323,12 @@ g_string_prepend (GString *fstring, gchar *val) } GString* -g_string_prepend_c (GString *fstring, char c) +g_string_prepend_c (GString *fstring, + gchar c) { GRealString *string = (GRealString*)fstring; + g_return_val_if_fail (string != NULL, NULL); g_string_maybe_expand (string, 1); g_memmove (string->str + 1, string->str, string->len); @@ -315,14 +342,20 @@ g_string_prepend_c (GString *fstring, char c) return fstring; } -GString * -g_string_insert (GString *fstring, gint pos, gchar *val) +GString* +g_string_insert (GString *fstring, + gint pos, + const gchar *val) { GRealString *string = (GRealString*)fstring; - gint len = strlen (val); + gint len; + g_return_val_if_fail (string != NULL, NULL); + g_return_val_if_fail (val != NULL, fstring); + g_return_val_if_fail (pos >= 0, fstring); g_return_val_if_fail (pos <= string->len, fstring); + len = strlen (val); g_string_maybe_expand (string, len); g_memmove (string->str + pos + len, string->str + pos, string->len - pos); @@ -337,10 +370,13 @@ g_string_insert (GString *fstring, gint pos, gchar *val) } GString * -g_string_insert_c (GString *fstring, gint pos, gchar c) +g_string_insert_c (GString *fstring, + gint pos, + gchar c) { GRealString *string = (GRealString*)fstring; + g_return_val_if_fail (string != NULL, NULL); g_return_val_if_fail (pos <= string->len, fstring); g_string_maybe_expand (string, 1); @@ -356,15 +392,21 @@ g_string_insert_c (GString *fstring, gint pos, gchar c) return fstring; } -GString * -g_string_erase (GString *fstring, gint pos, gint len) +GString* +g_string_erase (GString *fstring, + gint pos, + gint len) { GRealString *string = (GRealString*)fstring; + g_return_val_if_fail (string != NULL, NULL); + g_return_val_if_fail (len >= 0, fstring); + g_return_val_if_fail (pos >= 0, fstring); g_return_val_if_fail (pos <= string->len, fstring); g_return_val_if_fail (pos + len <= string->len, fstring); - g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len)); + if (pos + len < string->len) + g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len)); string->len -= len; @@ -373,6 +415,44 @@ g_string_erase (GString *fstring, gint pos, gint len) return fstring; } +GString* +g_string_down (GString *fstring) +{ + GRealString *string = (GRealString*)fstring; + gchar *s; + + g_return_val_if_fail (string != NULL, NULL); + + s = string->str; + + while (*s) + { + *s = tolower (*s); + s++; + } + + return fstring; +} + +GString* +g_string_up (GString *fstring) +{ + GRealString *string = (GRealString*)fstring; + gchar *s; + + g_return_val_if_fail (string != NULL, NULL); + + s = string->str; + + while (*s) + { + *s = toupper (*s); + s++; + } + + return fstring; +} + static int get_length_upper_bound (const gchar* fmt, va_list *args) { @@ -512,7 +592,7 @@ g_vsprintf (const gchar *fmt, static void g_string_sprintfa_int (GString *string, - gchar *fmt, + const gchar *fmt, va_list *args, va_list *args2) { @@ -520,7 +600,9 @@ g_string_sprintfa_int (GString *string, } void -g_string_sprintf (GString *string, gchar *fmt, ...) +g_string_sprintf (GString *string, + const gchar *fmt, + ...) { va_list args, args2; @@ -536,7 +618,9 @@ g_string_sprintf (GString *string, gchar *fmt, ...) } void -g_string_sprintfa (GString *string, gchar *fmt, ...) +g_string_sprintfa (GString *string, + const gchar *fmt, + ...) { va_list args, args2; diff --git a/glib/gtimer.c b/glib/gtimer.c index 860c76cffb..47946b39b5 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -32,7 +32,7 @@ struct _GRealTimer GTimer* -g_timer_new () +g_timer_new (void) { GRealTimer *timer; diff --git a/glib/gutils.c b/glib/gutils.c index e23280ff62..ef51134828 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -25,13 +25,6 @@ #include "glib.h" -static GErrorFunc glib_error_func = NULL; -static GWarningFunc glib_warning_func = NULL; -static GPrintFunc glib_message_func = NULL; -static GPrintFunc glib_print_func = NULL; - -extern char* g_vsprintf (const gchar *fmt, va_list *args, va_list *args2); - gchar* g_strdup (const gchar *str) { @@ -577,85 +570,85 @@ g_strsignal (gint signum) case SIGQUIT: return "Quit"; #endif #ifdef SIGILL - case SIGILL: "Illegal instruction"; + case SIGILL: return "Illegal instruction"; #endif #ifdef SIGTRAP - case SIGTRAP: "Trace/breakpoint trap"; + case SIGTRAP: return "Trace/breakpoint trap"; #endif #ifdef SIGABRT - case SIGABRT: "IOT trap/Abort"; + case SIGABRT: return "IOT trap/Abort"; #endif #ifdef SIGBUS - case SIGBUS: "Bus error"; + case SIGBUS: return "Bus error"; #endif #ifdef SIGFPE - case SIGFPE: "Floating point exception"; + case SIGFPE: return "Floating point exception"; #endif #ifdef SIGKILL - case SIGKILL: "Killed"; + case SIGKILL: return "Killed"; #endif #ifdef SIGUSR1 - case SIGUSR1: "User defined signal 1"; + case SIGUSR1: return "User defined signal 1"; #endif #ifdef SIGSEGV - case SIGSEGV: "Segmentation fault"; + case SIGSEGV: return "Segmentation fault"; #endif #ifdef SIGUSR2 - case SIGUSR2: "User defined signal 2"; + case SIGUSR2: return "User defined signal 2"; #endif #ifdef SIGPIPE - case SIGPIPE: "Broken pipe"; + case SIGPIPE: return "Broken pipe"; #endif #ifdef SIGALRM - case SIGALRM: "Alarm clock"; + case SIGALRM: return "Alarm clock"; #endif #ifdef SIGTERM - case SIGTERM: "Terminated"; + case SIGTERM: return "Terminated"; #endif #ifdef SIGSTKFLT - case SIGSTKFLT: "Stack fault"; + case SIGSTKFLT: return "Stack fault"; #endif #ifdef SIGCHLD - case SIGCHLD: "Child exited"; + case SIGCHLD: return "Child exited"; #endif #ifdef SIGCONT - case SIGCONT: "Continued"; + case SIGCONT: return "Continued"; #endif #ifdef SIGSTOP - case SIGSTOP: "Stopped (signal)"; + case SIGSTOP: return "Stopped (signal)"; #endif #ifdef SIGTSTP - case SIGTSTP: "Stopped"; + case SIGTSTP: return "Stopped"; #endif #ifdef SIGTTIN - case SIGTTIN: "Stopped (tty input)"; + case SIGTTIN: return "Stopped (tty input)"; #endif #ifdef SIGTTOU - case SIGTTOU: "Stopped (tty output)"; + case SIGTTOU: return "Stopped (tty output)"; #endif #ifdef SIGURG - case SIGURG: "Urgent condition"; + case SIGURG: return "Urgent condition"; #endif #ifdef SIGXCPU - case SIGXCPU: "CPU time limit exceeded"; + case SIGXCPU: return "CPU time limit exceeded"; #endif #ifdef SIGXFSZ - case SIGXFSZ: "File size limit exceeded"; + case SIGXFSZ: return "File size limit exceeded"; #endif #ifdef SIGVTALRM - case SIGVTALRM: "Virtual time alarm"; + case SIGVTALRM: return "Virtual time alarm"; #endif #ifdef SIGPROF - case SIGPROF: "Profile signal"; + case SIGPROF: return "Profile signal"; #endif #ifdef SIGWINCH - case SIGWINCH: "Window size changed"; + case SIGWINCH: return "Window size changed"; #endif #ifdef SIGIO - case SIGIO: "Possible I/O"; + case SIGIO: return "Possible I/O"; #endif #ifdef SIGPWR - case SIGPWR: "Power failure"; + case SIGPWR: return "Power failure"; #endif #ifdef SIGUNUSED case SIGUNUSED: return "Unused signal"; @@ -670,146 +663,6 @@ g_strsignal (gint signum) return msg; } -void -g_error (gchar *format, ...) -{ - va_list args, args2; - char *buf; - - va_start (args, format); - va_start (args2, format); - buf = g_vsprintf (format, &args, &args2); - va_end (args); - va_end (args2); - - if (glib_error_func) - { - (* glib_error_func) (buf); - } - else - { - fputs ("\n** ERROR **: ", stderr); - fputs (buf, stderr); - fputc ('\n', stderr); - } - - abort (); -} - -void -g_warning (gchar *format, ...) -{ - va_list args, args2; - char *buf; - - va_start (args, format); - va_start (args2, format); - buf = g_vsprintf (format, &args, &args2); - va_end (args); - va_end (args2); - - if (glib_warning_func) - { - (* glib_warning_func) (buf); - } - else - { - fputs ("\n** WARNING **: ", stderr); - fputs (buf, stderr); - fputc ('\n', stderr); - } -} - -void -g_message (gchar *format, ...) -{ - va_list args, args2; - char *buf; - - va_start (args, format); - va_start (args2, format); - buf = g_vsprintf (format, &args, &args2); - va_end (args); - va_end (args2); - - if (glib_message_func) - { - (* glib_message_func) (buf); - } - else - { - fputs ("message: ", stdout); - fputs (buf, stdout); - fputc ('\n', stdout); - } -} - -void -g_print (gchar *format, ...) -{ - va_list args, args2; - char *buf; - - va_start (args, format); - va_start (args2, format); - buf = g_vsprintf (format, &args, &args2); - va_end (args); - va_end (args2); - - if (glib_print_func) - { - (* glib_print_func) (buf); - } - else - { - fputs (buf, stdout); - } -} - -GErrorFunc -g_set_error_handler (GErrorFunc func) -{ - GErrorFunc old_error_func; - - old_error_func = glib_error_func; - glib_error_func = func; - - return old_error_func; -} - -GWarningFunc -g_set_warning_handler (GWarningFunc func) -{ - GWarningFunc old_warning_func; - - old_warning_func = glib_warning_func; - glib_warning_func = func; - - return old_warning_func; -} - -GPrintFunc -g_set_message_handler (GPrintFunc func) -{ - GPrintFunc old_message_func; - - old_message_func = glib_message_func; - glib_message_func = func; - - return old_message_func; -} - -GPrintFunc -g_set_print_handler (GPrintFunc func) -{ - GPrintFunc old_print_func; - - old_print_func = glib_print_func; - glib_print_func = func; - - return old_print_func; -} - gint g_snprintf (gchar *str, gulong n, @@ -845,25 +698,82 @@ g_snprintf (gchar *str, #endif } +void +g_strdown (gchar *string) +{ + register gchar *s; + + g_return_if_fail (string != NULL); + + s = string; + + while (*s) + { + *s = tolower (*s); + s++; + } +} + +void +g_strup (gchar *string) +{ + register gchar *s; + + g_return_if_fail (string != NULL); + + s = string; + + while (*s) + { + *s = toupper (*s); + s++; + } +} + gint -g_strcasecmp (const gchar *s1, const gchar *s2) +g_strcasecmp (const gchar *s1, + const gchar *s2) { #ifdef HAVE_STRCASECMP - return strcasecmp(s1, s2); + return strcasecmp (s1, s2); #else gint c1, c2; while (*s1 && *s2) { - c1 = tolower((guchar)(*s1++)); c2 = tolower((guchar)(*s2++)); + /* According to A. Cox, some platforms have islower's that + * don't work right on non-uppercase + */ + c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1; + c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2; if (c1 != c2) return (c1 - c2); + s1++; s2++; } return (((gint)(guchar) *s1) - ((gint)(guchar) *s2)); #endif } +void +g_strdelimit (gchar *string, + const gchar *delimiters, + 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)) + *c = new_delim; + } +} + guint g_parse_debug_string (const gchar *string, GDebugKey *keys, @@ -913,6 +823,6 @@ g_parse_debug_string (const gchar *string, guint g_direct_hash(gpointer key) { - return (guint) key; + return GPOINTER_TO_UINT (key); } diff --git a/glib/ltconfig b/glib/ltconfig index 7ebb9be8c0..878a7c8122 100755 --- a/glib/ltconfig +++ b/glib/ltconfig @@ -32,23 +32,43 @@ if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi echo=echo if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : else - # The Solaris and AIX default echo program unquotes backslashes. - # This makes it impossible to quote backslashes using + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' - # So, we emulate echo with printf '%s\n' - echo="printf %s\\n" - if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : - else - # Oops. We have no working printf. Try to find a not-so-buggy echo. - echo=echo - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" - for dir in $PATH /usr/ucb; do - if test -f $dir/echo && test "X`$dir/echo '\t'`" = 'X\t'; then - echo="$dir/echo" - break + # + # So, first we look for a working echo in the user's PATH. + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH /usr/ucb; do + if test -f $dir/echo && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t'; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t'; then + # This shell has a builtin print -r that does the trick. + echo='print -r' +# +# The following is from libtool-1.2a, won't work with this patched +# libtool-1.2 +# +# elif test -f /bin/ksh && test "X$CONFIG_SHELL" != X/bin/ksh; then +# # If we have ksh, try running ltconfig again with it. +# CONFIG_SHELL=/bin/ksh +# export CONFIG_SHELL +# exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then : + else + # Oops. We lost completely, so just stick with echo. + echo=echo fi - done - IFS="$save_ifs" + fi fi fi @@ -66,7 +86,7 @@ progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` # Constants: PROGRAM=ltconfig PACKAGE=libtool -VERSION=1.1 +VERSION=1.2 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5' rm="rm -f" @@ -421,7 +441,7 @@ if test "$with_gcc" != yes || test -z "$CC"; then # Now see if the compiler is really GCC. with_gcc=no echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 - echo "$progname:424: checking whether we are using GNU C" >&5 + echo "$progname:444: checking whether we are using GNU C" >&5 $rm conftest.c cat > conftest.c <<EOF @@ -429,7 +449,7 @@ if test "$with_gcc" != yes || test -z "$CC"; then yes; #endif EOF - if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:432: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:452: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then with_gcc=yes fi $rm conftest.c @@ -544,14 +564,15 @@ if test -n "$pic_flag"; then echo > conftest.c save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $pic_flag -DPIC" - echo "$progname:547: checking if $compiler PIC flag $pic_flag works" >&5 - if { (eval echo $progname:548: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then - # Append any errors to the config.log. + echo "$progname:567: checking if $compiler PIC flag $pic_flag works" >&5 + if { (eval echo $progname:568: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then + # Append any warnings to the config.log. cat conftest.err 1>&5 - # On HP-UX, the stripped-down bundled CC does not accept +Z, but also - # reports no error. So, we need to grep stderr for (Bundled). - if grep '(Bundled)' conftest.err >/dev/null; then + # On HP-UX, both CC and GCC only warn that PIC is supported... then they + # create non-PIC objects. So, if there were any warnings, we assume that + # PIC is not supported. + if test -s conftest.err; then echo "$ac_t"no 1>&6 can_build_shared=no pic_flag= @@ -587,8 +608,8 @@ $rm conftest* echo 'main(){return(0);}' > conftest.c save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $link_static_flag" -echo "$progname:590: checking if $compiler static flag $link_static_flag works" >&5 -if { (eval echo $progname:591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +echo "$progname:611: checking if $compiler static flag $link_static_flag works" >&5 +if { (eval echo $progname:612: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then echo "$ac_t$link_static_flag" 1>&6 else echo "$ac_t"none 1>&6 @@ -620,7 +641,7 @@ if test -z "$LD"; then if test "$with_gcc" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 - echo "$progname:623: checking for ld used by GCC" >&5 + echo "$progname:644: checking for ld used by GCC" >&5 ac_prog=`($CC -print-prog-name=ld) 2>&5` case "$ac_prog" in # Accept absolute paths. @@ -638,10 +659,10 @@ if test -z "$LD"; then esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld... $ac_c" 1>&6 - echo "$progname:641: checking for GNU ld" >&5 + echo "$progname:662: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 - echo "$progname:644: checking for non-GNU ld" >&5 + echo "$progname:665: checking for non-GNU ld" >&5 fi if test -z "$LD"; then @@ -967,11 +988,11 @@ void nm_test_func(){} main(){nm_test_var='a';nm_test_func();return(0);} EOF -echo "$progname:970: checking if global_symbol_pipe works" >&5 -if { (eval echo $progname:971: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then +echo "$progname:991: checking if global_symbol_pipe works" >&5 +if { (eval echo $progname:992: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then # Now try to grab the symbols. nlist=conftest.nm - if { echo "$progname:974: eval \"$NM conftest.o | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then + if { echo "$progname:995: eval \"$NM conftest.o | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.o | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then @@ -1029,7 +1050,7 @@ EOF save_CFLAGS="$CFLAGS" LIBS='conftestm.o' CFLAGS="$CFLAGS$no_builtin_flag" - if { (eval echo $progname:1032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + if { (eval echo $progname:1053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then pipe_works=yes else echo "$progname: failed program was:" >&5 diff --git a/glib/ltmain.sh b/glib/ltmain.sh index 9b8e94784b..0e884205b8 100644 --- a/glib/ltmain.sh +++ b/glib/ltmain.sh @@ -30,7 +30,7 @@ modename="$progname" # Constants. PROGRAM=ltmain.sh PACKAGE=libtool -VERSION=1.1 +VERSION=1.2 default_mode= help="Try \`$progname --help' for more information." @@ -386,6 +386,7 @@ if test -z "$show_help"; then prev= prevarg= release= + postfix= rpath= perm_rpath= temp_rpath= @@ -437,6 +438,11 @@ if test -z "$show_help"; then prev= continue ;; + postfix) + postfix="-$arg" + prev= + continue + ;; rpath) rpath="$rpath $arg" prev= @@ -481,7 +487,7 @@ if test -z "$show_help"; then if test "$export_dynamic" != yes; then export_dynamic=yes if test -n "$export_dynamic_flag_spec"; then - arg=`eval \\$echo "$export_dynamic_flag_spec"` + eval arg=\"$export_dynamic_flag_spec\" else arg= fi @@ -520,6 +526,11 @@ if test -z "$show_help"; then continue ;; + -postfix) + prev=postfix + continue + ;; + -rpath) prev=rpath continue @@ -682,7 +693,7 @@ if test -z "$show_help"; then fi if test -n "$libdir"; then - flag=`eval \\$echo \"$hardcode_libdir_flag_spec\"` + eval flag=\"$hardcode_libdir_flag_spec\" compile_command="$compile_command $flag" finalize_command="$finalize_command $flag" @@ -842,8 +853,8 @@ if test -z "$show_help"; then ;; esac - name=`$echo "X$output" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - libname=`eval \\$echo \"$libname_spec\"` + name=`$echo "X$output" | $Xsed -e 's/\.la$//' -e 's/^lib//'`$postfix + eval libname=\"$libname_spec\" # All the library-specific variables (install_libdir is set above). library_names= @@ -1006,13 +1017,13 @@ if test -z "$show_help"; then if test "$build_libtool_libs" = yes; then # Get the real and link names of the library. - library_names=`eval \\$echo \"$library_names_spec\"` + eval library_names=\"$library_names_spec\" set dummy $library_names realname="$2" shift; shift if test -n "$soname_spec"; then - soname=`eval \\$echo \"$soname_spec\"` + eval soname=\"$soname_spec\" else soname="$realname" fi @@ -1027,7 +1038,7 @@ if test -z "$show_help"; then test -z "$pic_flag" && libobjs=`$echo "X$libobjs " | $Xsed -e 's/\.lo /.o /g' -e 's/ $//g'` # Do each of the archive commands. - cmds=`eval \\$echo \"$archive_cmds\"` + eval cmds=\"$archive_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1104,7 +1115,7 @@ if test -z "$show_help"; then reload_objs="$objs"`$echo "X$libobjs " | $Xsed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` output="$obj" - cmds=`eval \\$echo \"$reload_cmds\"` + eval cmds=\"$reload_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1128,7 +1139,7 @@ if test -z "$show_help"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs" output="$libobj" - cmds=`eval \\$echo \"$reload_cmds\"` + eval cmds=\"$reload_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1177,7 +1188,7 @@ if test -z "$show_help"; then fi if test -n "$libdir"; then - flag=`eval \\$echo \"$hardcode_libdir_flag_spec\"` + eval flag=\"$hardcode_libdir_flag_spec\" compile_command="$compile_command $flag" finalize_command="$finalize_command $flag" @@ -1254,8 +1265,8 @@ if test -z "$show_help"; then case "$dlsyms" in "") ;; *.c) - $echo > "$objdir/$dlsyms" \ -"/* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */ + $echo > "$objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$output' dlsym emulation. */ /* Generated by $PROGRAM - GNU $PACKAGE $VERSION */ #ifdef __cplusplus @@ -1266,17 +1277,17 @@ extern \"C\" { #define dld_preloaded_symbol_count some_other_symbol #define dld_preloaded_symbols some_other_symbol -/* External symbol declarations for the compiler. */" +/* External symbol declarations for the compiler. */\ +" if test -f "$nlist"; then sed -e 's/^.* \(.*\)$/extern char \1;/' < "$nlist" >> "$objdir/$dlsyms" else echo '/* NONE */' >> "$objdir/$dlsyms" -EOF fi - $echo >> "$objdir/$dlsyms" \ -" + $echo >> "$objdir/$dlsyms" "\ + #undef dld_preloaded_symbol_count #undef dld_preloaded_symbols @@ -1295,19 +1306,21 @@ struct { __ptr_t address; } dld_preloaded_symbols[] = -{" +{\ +" if test -f "$nlist"; then sed 's/^\(.*\) \(.*\)$/ {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$objdir/$dlsyms" fi - $echo >> "$objdir/$dlsyms" \ -" {0, (__ptr_t) 0} + $echo >> "$objdir/$dlsyms" "\ + {0, (__ptr_t) 0} }; #ifdef __cplusplus } -#endif" +#endif\ +" ;; *) @@ -1427,8 +1440,8 @@ dld_preloaded_symbols[] = $rm $output trap "$rm $output; exit 1" 1 2 15 - $echo > $output \ -"#! /bin/sh + $echo > $output "\ +#! /bin/sh # $output - temporary wrapper script for $objdir/$output # Generated by ltmain.sh - GNU $PACKAGE $VERSION @@ -1459,10 +1472,9 @@ else else echo=\"$qecho\" file=\"\$0\" - fi -" - $echo >> $output \ + fi\ " + $echo >> $output "\ # Find the directory that this script lives in. thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` @@ -1496,8 +1508,8 @@ else # Export our shlibpath_var if we have one. if test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output \ -" # Add our own library path to $shlibpath_var + $echo >> $output "\ + # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var @@ -1507,24 +1519,17 @@ else " fi - echo >> $output \ -" if test \"\$libtool_execute_magic\" != \"$magic\"; then + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. - args= - for arg - do - # Quote arguments (to preserve shell metacharacters). - arg=\`\$echo \"X\$arg\" | \$Xsed -e \"\$sed_quote_subst\"\` - args=\"\$args \\\"\$arg\\\"\" - done # Export the path to the program. PATH=\"\$progdir:\$PATH\" export PATH - eval \"exec \$program \$args\" + exec \$program \${1+\"\$@\"} - \$echo \"\$0: cannot exec \$program \$args\" + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" exit 1 fi else @@ -1534,7 +1539,8 @@ else echo \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi -fi" +fi\ +" chmod +x $output fi exit 0 @@ -1548,9 +1554,9 @@ fi" # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - cmds=`eval \\$echo \"$old_archive_from_new_cmds\"` + eval cmds=\"$old_archive_from_new_cmds\" else - cmds=`eval \\$echo \"$old_archive_cmds\"` + eval cmds=\"$old_archive_cmds\" fi IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do @@ -1571,8 +1577,8 @@ fi" # Only create the output if not a dry run. if test -z "$run"; then - echo > $output \ -"# $output - a libtool library file + $echo > $output "\ +# $output - a libtool library file # Generated by ltmain.sh - GNU $PACKAGE $VERSION # The name that we can dlopen(3). @@ -1593,7 +1599,8 @@ age=$age revision=$revision # Directory that this library needs to be installed in: -libdir='$install_libdir'" +libdir='$install_libdir'\ +" fi # Do a symbolic link so that the libtool archive can be found in @@ -1835,7 +1842,7 @@ libdir='$install_libdir'" # Do each command in the postinstall commands. lib="$destdir/$realname" - cmds=`eval \\$echo \"$postinstall_cmds\"` + eval cmds=\"$postinstall_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1972,7 +1979,7 @@ libdir='$install_libdir'" $run eval "$install_prog \$file \$oldlib" || exit $? # Do each command in the postinstall commands. - cmds=`eval \\$echo \"$old_postinstall_cmds\"` + eval cmds=\"$old_postinstall_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -2010,7 +2017,7 @@ libdir='$install_libdir'" for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. - cmds=`eval \\$echo \"$finish_cmds\"` + eval cmds=\"$finish_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -2021,7 +2028,7 @@ libdir='$install_libdir'" fi if test -n "$finish_eval"; then # Do the single finish_eval. - cmds=`eval \\$echo \"$finish_eval\"` + eval cmds=\"$finish_eval\" $run eval "$cmds" fi done @@ -2047,7 +2054,7 @@ libdir='$install_libdir'" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR - flag=`eval \\$echo \"$hardcode_libdir_flag_spec\"` + eval flag=\"$hardcode_libdir_flag_spec\" echo " - use the \`$flag' linker flag" fi @@ -2238,7 +2245,7 @@ libdir='$install_libdir'" if test -n "$library_names"; then # Do each command in the postuninstall commands. - cmds=`eval \\$echo \"$postuninstall_cmds\"` + eval cmds=\"$postuninstall_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -2250,7 +2257,7 @@ libdir='$install_libdir'" if test -n "$old_library"; then # Do each command in the old_postuninstall commands. - cmds=`eval \\$echo \"$old_postuninstall_cmds\"` + eval cmds=\"$old_postuninstall_cmds\" IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" diff --git a/glib/testglib.c b/glib/testglib.c index d4bd85a530..4c223667ac 100644 --- a/glib/testglib.c +++ b/glib/testglib.c @@ -108,9 +108,9 @@ main (int argc, GTree *tree; char chars[62]; - g_print ("checking size of gint8...%d (should be 1)\n", sizeof (gint8)); - g_print ("checking size of gint16...%d (should be 2)\n", sizeof (gint16)); - g_print ("checking size of gint32...%d (should be 4)\n", sizeof (gint32)); + g_print ("checking size of gint8...%ld (should be 1)\n", (glong)sizeof (gint8)); + g_print ("checking size of gint16...%ld (should be 2)\n", (glong)sizeof (gint16)); + g_print ("checking size of gint32...%ld (should be 4)\n", (glong)sizeof (gint32)); g_print ("checking doubly linked lists..."); @@ -126,6 +126,10 @@ main (int argc, g_error ("Regular insert failed"); } + for (i = 0; i < 10; i++) + if(g_list_position(list, g_list_nth (list, i)) != i) + g_error("g_list_position does not seem to be the inverse of g_list_nth\n"); + g_list_free (list); list = NULL; |