diff options
author | Dan Nicholson <dbn.lists@gmail.com> | 2012-08-22 05:49:02 -0700 |
---|---|---|
committer | Dan Nicholson <dbn.lists@gmail.com> | 2012-08-22 05:53:32 -0700 |
commit | 617963c55e128eb182868c8a21782d2b65ea8110 (patch) | |
tree | 23735b27f6213785e6aaa8ac78b615993966f46f | |
parent | f8978af7bf5b45287181df05f5c3b0bed2804544 (diff) | |
download | pkg-config-617963c55e128eb182868c8a21782d2b65ea8110.tar.gz |
glib: Update snapshot to 2.32.4
This gets us to the latest stable release for glib and probably a good
stopping point for a while since the 2.32 series seems to be slowing
down.
-rw-r--r-- | glib-patches/no-pkg-config.patch | 8 | ||||
-rwxr-xr-x | glib-patches/update-glib.sh | 2 | ||||
-rw-r--r-- | glib/NEWS | 41 | ||||
-rw-r--r-- | glib/configure.ac | 4 | ||||
-rw-r--r-- | glib/glib/gatomic.h | 4 | ||||
-rw-r--r-- | glib/glib/gdir.c | 8 | ||||
-rw-r--r-- | glib/glib/genviron.c | 26 | ||||
-rw-r--r-- | glib/glib/gfileutils.c | 1 | ||||
-rw-r--r-- | glib/glib/gfileutils.h | 3 | ||||
-rw-r--r-- | glib/glib/ghash.h | 1 | ||||
-rw-r--r-- | glib/glib/ghmac.h | 9 | ||||
-rw-r--r-- | glib/glib/gkeyfile.c | 14 | ||||
-rw-r--r-- | glib/glib/glib-unix.h | 6 | ||||
-rw-r--r-- | glib/glib/gmain.c | 2 | ||||
-rw-r--r-- | glib/glib/gmain.h | 4 | ||||
-rw-r--r-- | glib/glib/goption.c | 6 | ||||
-rw-r--r-- | glib/glib/grand.c | 5 | ||||
-rw-r--r-- | glib/glib/gspawn.c | 2 | ||||
-rw-r--r-- | glib/glib/gtimezone.c | 2 | ||||
-rw-r--r-- | glib/glib/gunicode.h | 1 | ||||
-rw-r--r-- | glib/glib/gutf8.c | 4 | ||||
-rw-r--r-- | glib/glib/gutils.c | 44 | ||||
-rw-r--r-- | glib/glib/gutils.h | 2 | ||||
-rw-r--r-- | glib/glib/gvariant-serialiser.c | 11 | ||||
-rw-r--r-- | glib/glib/gvariant.c | 34 | ||||
-rw-r--r-- | glib/glib/gvariant.h | 2 |
26 files changed, 189 insertions, 57 deletions
diff --git a/glib-patches/no-pkg-config.patch b/glib-patches/no-pkg-config.patch index bfa4374..07a6712 100644 --- a/glib-patches/no-pkg-config.patch +++ b/glib-patches/no-pkg-config.patch @@ -1,5 +1,5 @@ diff --git a/glib/configure.ac b/glib/configure.ac -index 641c0a9..9d3eb6d 100644 +index 99de9f7..e582232 100644 --- a/glib/configure.ac +++ b/glib/configure.ac @@ -294,8 +294,6 @@ AC_PROG_INSTALL @@ -35,7 +35,7 @@ index 641c0a9..9d3eb6d 100644 dnl gettext support dnl -@@ -1768,30 +1749,6 @@ dnl failure. try libattr +@@ -1779,30 +1760,6 @@ dnl failure. try libattr fi AC_SUBST(XATTR_LIBS) @@ -43,7 +43,7 @@ index 641c0a9..9d3eb6d 100644 -dnl *** check for libelf *** -dnl ************************ - --PKG_CHECK_MODULES([LIBELF], [libelf], [have_libelf=yes], [have_libelf=maybe]) +-PKG_CHECK_MODULES([LIBELF], [libelf >= 0.8.12], [have_libelf=yes], [have_libelf=maybe]) - -if test $have_libelf = maybe; then - glib_save_LIBS=$LIBS @@ -66,7 +66,7 @@ index 641c0a9..9d3eb6d 100644 dnl **************************************** dnl *** platform dependent source checks *** dnl **************************************** -@@ -3326,12 +3283,7 @@ AC_CHECK_ALIGNOF([unsigned long]) +@@ -3280,12 +3237,7 @@ AC_CHECK_ALIGNOF([unsigned long]) # Check for libdbus1 - Optional - is only used in the GDBus test cases # # 1.2.14 required for dbus_message_set_serial diff --git a/glib-patches/update-glib.sh b/glib-patches/update-glib.sh index db83b63..1b80a2c 100755 --- a/glib-patches/update-glib.sh +++ b/glib-patches/update-glib.sh @@ -4,7 +4,7 @@ GIT=${GIT-git} PATCH=${PATCH-patch} SED=${SED-sed} repo= -tag=2.32.3 +tag=2.32.4 commit=n usage() @@ -1,3 +1,44 @@ +Overview of changes from GLib 2.32.3 to 2.32.4 +============================================== + +* Bugs fixed: + 639771 g_dir_read_name() can also return NULL on error + 660851 Breakage of code due to changes in the GThread... + 666386 Empathy doesn't open Redirect URI with particu... + 671545 Constify collect and lcopy strings in GTypeVal... + 672329 memory leaks in gutils.c and glib tests + 672548 g_utf8_validate: @str shouldn't end up annotat... + 672889 GLib.utf8_validate does segfault + 673253 Not strict enough autconf test for libelf + 674452 SEGFAULT in gio contenttype test + 674777 What's the (transfer) of g_variant_lookup()? + 675309 gkeyfile: Fix annotations for g_key_file_load_... + 675446 gfile: Plug memory leak in g_file_make_directo... + 675832 Incomplete gsettings bash auto-completion + 676265 GNetworkMonitor leaks a lot of memory + 676277 Document that g_app_info_create_from_commandli... + 676397 g_environ_* should work with NULL envp + 676594 [Patch] fix g_reload_user_special_dirs_cache + 676816 Add more GLIB_AVAILABLE_IN_* + 677235 Clarify the comment at the top of gmarshal.list + 677782 Install bash completion files in /usr/share + 677817 g_key_file_to_data adds extra blank lines in so... + 677952 Missing annotation for GDBusConnection signal "... + 678052 g_wakeup_acknowledge is called too often. + 678066 gdbus codegen does not work with python3 + 678273 unicode othercasing is wrong in gregex + 678333 gdbus-codegen code causes warnings under -Wfloa... + 678758 GTlsInteraction unlocks an unlocked mutex + 678881 Test failures in /socket/timed_wait in some cas... + 678941 /contenttype/guess test case failure + 678944 gio returns the wrong default applications for ... + 678949 wrong definition of ulong_bool for 64 bit big e... + 678959 /mainloop/timeouts race condition: assertion fa... + 679258 The 'Since' tag for G_SOURCE_CONTINUE and G_SOU... + 679671 Misc fixes for g_dbus_node_info_new_for_xml + 679813 Documentation bug on http://developer.gnome.org... + + Overview of changes from GLib 2.32.2 to 2.32.3 ============================================== diff --git a/glib/configure.ac b/glib/configure.ac index 5495c75..9e48cc9 100644 --- a/glib/configure.ac +++ b/glib/configure.ac @@ -31,8 +31,8 @@ m4_define(glib_configure_ac) m4_define([glib_major_version], [2]) m4_define([glib_minor_version], [32]) -m4_define([glib_micro_version], [3]) -m4_define([glib_interface_age], [3]) +m4_define([glib_micro_version], [4]) +m4_define([glib_interface_age], [4]) m4_define([glib_binary_age], [m4_eval(100 * glib_minor_version + glib_micro_version)]) m4_define([glib_version], diff --git a/glib/glib/gatomic.h b/glib/glib/gatomic.h index 5403f28..8b52e0b 100644 --- a/glib/glib/gatomic.h +++ b/glib/glib/gatomic.h @@ -40,8 +40,10 @@ gboolean g_atomic_int_compare_and_exchange (volatile gint *a gint newval); gint g_atomic_int_add (volatile gint *atomic, gint val); +GLIB_AVAILABLE_IN_2_30 guint g_atomic_int_and (volatile guint *atomic, guint val); +GLIB_AVAILABLE_IN_2_30 guint g_atomic_int_or (volatile guint *atomic, guint val); guint g_atomic_int_xor (volatile guint *atomic, @@ -55,8 +57,10 @@ gboolean g_atomic_pointer_compare_and_exchange (volatile void *a gpointer newval); gssize g_atomic_pointer_add (volatile void *atomic, gssize val); +GLIB_AVAILABLE_IN_2_30 gsize g_atomic_pointer_and (volatile void *atomic, gsize val); +GLIB_AVAILABLE_IN_2_30 gsize g_atomic_pointer_or (volatile void *atomic, gsize val); gsize g_atomic_pointer_xor (volatile void *atomic, diff --git a/glib/glib/gdir.c b/glib/glib/gdir.c index 3173ae7..e89de89 100644 --- a/glib/glib/gdir.c +++ b/glib/glib/gdir.c @@ -188,7 +188,11 @@ g_dir_open (const gchar *path, * Retrieves the name of another entry in the directory, or %NULL. * The order of entries returned from this function is not defined, * and may vary by file system or other operating-system dependent - * factors. + * factors. + * + * %NULL may also be returned in case of errors. On Unix, you can + * check <literal>errno</literal> to find out if %NULL was returned + * because of an error. * * On Unix, the '.' and '..' entries are omitted, and the returned * name is in the on-disk encoding. @@ -196,7 +200,7 @@ g_dir_open (const gchar *path, * On Windows, as is true of all GLib functions which operate on * filenames, the returned name is in UTF-8. * - * Return value: The entry's name or %NULL if there are no + * Return value: The entry's name or %NULL if there are no * more entries. The return value is owned by GLib and * must not be modified or freed. **/ diff --git a/glib/glib/genviron.c b/glib/glib/genviron.c index b92c865..59a8bbe 100644 --- a/glib/glib/genviron.c +++ b/glib/glib/genviron.c @@ -54,6 +54,9 @@ g_environ_find (gchar **envp, { gint len, i; + if (envp == NULL) + return -1; + len = strlen (variable); for (i = 0; envp[i]; i++) @@ -68,8 +71,9 @@ g_environ_find (gchar **envp, /** * g_environ_getenv: - * @envp: (array zero-terminated=1) (transfer none): an environment - * list (eg, as returned from g_get_environ()) + * @envp: (allow-none) (array zero-terminated=1) (transfer none): an environment + * list (eg, as returned from g_get_environ()), or %NULL + * for an empty environment list * @variable: the environment variable to get, in the GLib file name * encoding * @@ -96,7 +100,6 @@ g_environ_getenv (gchar **envp, { gint index; - g_return_val_if_fail (envp != NULL, NULL); g_return_val_if_fail (variable != NULL, NULL); index = g_environ_find (envp, variable); @@ -108,8 +111,9 @@ g_environ_getenv (gchar **envp, /** * g_environ_setenv: - * @envp: (array zero-terminated=1) (transfer full): an environment - * list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()) + * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment + * list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), or %NULL + * for an empty environment list * @variable: the environment variable to set, must not contain '=' * @value: the value for to set the variable to * @overwrite: whether to change the variable if it already exists @@ -134,7 +138,6 @@ g_environ_setenv (gchar **envp, { gint index; - g_return_val_if_fail (envp != NULL, NULL); g_return_val_if_fail (variable != NULL, NULL); g_return_val_if_fail (strchr (variable, '=') == NULL, NULL); @@ -151,7 +154,7 @@ g_environ_setenv (gchar **envp, { gint length; - length = g_strv_length (envp); + length = envp ? g_strv_length (envp) : 0; envp = g_renew (gchar *, envp, length + 2); envp[length] = g_strdup_printf ("%s=%s", variable, value); envp[length + 1] = NULL; @@ -197,8 +200,9 @@ g_environ_unsetenv_internal (gchar **envp, /** * g_environ_unsetenv: - * @envp: (array zero-terminated=1) (transfer full): an environment - * list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()) + * @envp: (allow-none) (array zero-terminated=1) (transfer full): an environment + * list that can be freed using g_strfreev() (e.g., as returned from g_get_environ()), + * or %NULL for an empty environment list * @variable: the environment variable to remove, must not contain '=' * * Removes the environment variable @variable from the provided @@ -213,10 +217,12 @@ gchar ** g_environ_unsetenv (gchar **envp, const gchar *variable) { - g_return_val_if_fail (envp != NULL, NULL); g_return_val_if_fail (variable != NULL, NULL); g_return_val_if_fail (strchr (variable, '=') == NULL, NULL); + if (envp == NULL) + return NULL; + return g_environ_unsetenv_internal (envp, variable, TRUE); } diff --git a/glib/glib/gfileutils.c b/glib/glib/gfileutils.c index cb306ef..0df9305 100644 --- a/glib/glib/gfileutils.c +++ b/glib/glib/gfileutils.c @@ -1166,7 +1166,6 @@ write_to_temp_file (const gchar *contents, display_name, g_strerror (save_errno)); - fclose (file); g_unlink (tmp_name); goto out; diff --git a/glib/glib/gfileutils.h b/glib/glib/gfileutils.h index f591461..7c2eb1d 100644 --- a/glib/glib/gfileutils.h +++ b/glib/glib/gfileutils.h @@ -100,7 +100,9 @@ gchar *g_file_read_link (const gchar *filename, GError **error); /* Wrapper / workalike for mkdtemp() */ +GLIB_AVAILABLE_IN_2_30 gchar *g_mkdtemp (gchar *tmpl); +GLIB_AVAILABLE_IN_2_30 gchar *g_mkdtemp_full (gchar *tmpl, gint mode); @@ -114,6 +116,7 @@ gint g_mkstemp_full (gchar *tmpl, gint g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error); +GLIB_AVAILABLE_IN_2_30 gchar *g_dir_make_tmp (const gchar *tmpl, GError **error); diff --git a/glib/glib/ghash.h b/glib/glib/ghash.h index b369989..3eb8912 100644 --- a/glib/glib/ghash.h +++ b/glib/glib/ghash.h @@ -107,6 +107,7 @@ gboolean g_hash_table_iter_next (GHashTableIter *iter, gpointer *value); GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter); void g_hash_table_iter_remove (GHashTableIter *iter); +GLIB_AVAILABLE_IN_2_30 void g_hash_table_iter_replace (GHashTableIter *iter, gpointer value); void g_hash_table_iter_steal (GHashTableIter *iter); diff --git a/glib/glib/ghmac.h b/glib/glib/ghmac.h index e9b57de..d03d71f 100644 --- a/glib/glib/ghmac.h +++ b/glib/glib/ghmac.h @@ -41,25 +41,34 @@ G_BEGIN_DECLS */ typedef struct _GHmac GHmac; +GLIB_AVAILABLE_IN_2_30 GHmac * g_hmac_new (GChecksumType digest_type, const guchar *key, gsize key_len); +GLIB_AVAILABLE_IN_2_30 GHmac * g_hmac_copy (const GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 GHmac * g_hmac_ref (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 void g_hmac_unref (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 void g_hmac_update (GHmac *hmac, const guchar *data, gssize length); +GLIB_AVAILABLE_IN_2_30 const gchar * g_hmac_get_string (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 void g_hmac_get_digest (GHmac *hmac, guint8 *buffer, gsize *digest_len); +GLIB_AVAILABLE_IN_2_30 gchar *g_compute_hmac_for_data (GChecksumType digest_type, const guchar *key, gsize key_len, const guchar *data, gsize length); +GLIB_AVAILABLE_IN_2_30 gchar *g_compute_hmac_for_string (GChecksumType digest_type, const guchar *key, gsize key_len, diff --git a/glib/glib/gkeyfile.c b/glib/glib/gkeyfile.c index 949c8b2..98adf99 100644 --- a/glib/glib/gkeyfile.c +++ b/glib/glib/gkeyfile.c @@ -454,7 +454,6 @@ struct _GKeyFileGroup const gchar *name; /* NULL for above first group (which will be comments) */ GKeyFileKeyValuePair *comment; /* Special comment that is stuck to the top of a group */ - gboolean has_trailing_blank_line; GList *key_value_pairs; @@ -862,7 +861,7 @@ g_key_file_load_from_file (GKeyFile *key_file, /** * g_key_file_load_from_data: * @key_file: an empty #GKeyFile struct - * @data: key file loaded in memory + * @data: (length length): key file loaded in memory * @length: the length of @data in bytes (or -1 if data is nul-terminated) * @flags: flags from #GKeyFileFlags * @error: return location for a #GError, or %NULL @@ -1190,9 +1189,6 @@ g_key_file_parse_comment (GKeyFile *key_file, key_file->current_group->key_value_pairs = g_list_prepend (key_file->current_group->key_value_pairs, pair); - - if (length == 0 || line[0] != '#') - key_file->current_group->has_trailing_blank_line = TRUE; } static void @@ -1454,7 +1450,6 @@ g_key_file_to_data (GKeyFile *key_file, { GString *data_string; GList *group_node, *key_file_node; - gboolean has_blank_line = TRUE; g_return_val_if_fail (key_file != NULL, NULL); @@ -1469,9 +1464,9 @@ g_key_file_to_data (GKeyFile *key_file, group = (GKeyFileGroup *) group_node->data; /* separate groups by at least an empty line */ - if (!has_blank_line) - g_string_append_c (data_string, '\n'); - has_blank_line = group->has_trailing_blank_line; + if (data_string->len >= 2 && + data_string->str[data_string->len - 2] != '\n') + g_string_append_c (data_string, '\n'); if (group->comment != NULL) g_string_append_printf (data_string, "%s\n", group->comment->value); @@ -3792,7 +3787,6 @@ g_key_file_add_key_value_pair (GKeyFile *key_file, { g_hash_table_replace (group->lookup_map, pair->key, pair); group->key_value_pairs = g_list_prepend (group->key_value_pairs, pair); - group->has_trailing_blank_line = FALSE; } static void diff --git a/glib/glib/glib-unix.h b/glib/glib/glib-unix.h index 0b3bec1..c04f66f 100644 --- a/glib/glib/glib-unix.h +++ b/glib/glib/glib-unix.h @@ -57,24 +57,30 @@ G_BEGIN_DECLS */ #define G_UNIX_ERROR (g_unix_error_quark()) +GLIB_AVAILABLE_IN_2_30 GQuark g_unix_error_quark (void); +GLIB_AVAILABLE_IN_2_30 gboolean g_unix_open_pipe (gint *fds, gint flags, GError **error); +GLIB_AVAILABLE_IN_2_30 gboolean g_unix_set_fd_nonblocking (gint fd, gboolean nonblock, GError **error); +GLIB_AVAILABLE_IN_2_30 GSource *g_unix_signal_source_new (gint signum); +GLIB_AVAILABLE_IN_2_30 guint g_unix_signal_add_full (gint priority, gint signum, GSourceFunc handler, gpointer user_data, GDestroyNotify notify); +GLIB_AVAILABLE_IN_2_30 guint g_unix_signal_add (gint signum, GSourceFunc handler, gpointer user_data); diff --git a/glib/glib/gmain.c b/glib/glib/gmain.c index 760f179..60c80c7 100644 --- a/glib/glib/gmain.c +++ b/glib/glib/gmain.c @@ -2976,7 +2976,7 @@ g_main_context_check (GMainContext *context, return FALSE; } - if (context->wake_up_rec.events) + if (context->wake_up_rec.revents) g_wakeup_acknowledge (context->wakeup); /* If the set of poll file descriptors changed, bail out diff --git a/glib/glib/gmain.h b/glib/glib/gmain.h index cba45fd..fadf7fc 100644 --- a/glib/glib/gmain.h +++ b/glib/glib/gmain.h @@ -266,7 +266,7 @@ struct _GSourceFuncs * Use this macro as the return value of a #GSourceFunc to remove * the #GSource from the main loop. * - * Since: 2.28 + * Since: 2.32 */ #define G_SOURCE_REMOVE FALSE @@ -276,7 +276,7 @@ struct _GSourceFuncs * Use this macro as the return value of a #GSourceFunc to leave * the #GSource in the main loop. * - * Since: 2.28 + * Since: 2.32 */ #define G_SOURCE_CONTINUE TRUE diff --git a/glib/glib/goption.c b/glib/glib/goption.c index f5372ff..9f54be0 100644 --- a/glib/glib/goption.c +++ b/glib/glib/goption.c @@ -648,7 +648,7 @@ group_has_visible_entries (GOptionContext *context, } static gboolean -group_list_has_visible_entires (GOptionContext *context, +group_list_has_visible_entries (GOptionContext *context, GList *group_list, gboolean main_entries) { @@ -914,7 +914,7 @@ g_option_context_get_help (GOptionContext *context, /* Print application options if --help or --help-all has been specified */ if ((main_help || !group) && (group_has_visible_entries (context, context->main_group, TRUE) || - group_list_has_visible_entires (context, context->groups, TRUE))) + group_list_has_visible_entries (context, context->groups, TRUE))) { list = context->groups; @@ -1680,7 +1680,7 @@ platform_get_argv0 (void) cmdline = (char **) realloc (cmdline, len); - if (sysctl (mib, nitems (mib), cmdline, &len, NULL, 0) == -1) + if (sysctl (mib, G_N_ELEMENTS (mib), cmdline, &len, NULL, 0) == -1) { g_free (cmdline); return NULL; diff --git a/glib/glib/grand.c b/glib/glib/grand.c index 0405628..4d6a0a6 100644 --- a/glib/glib/grand.c +++ b/glib/glib/grand.c @@ -216,11 +216,10 @@ g_rand_new (void) FILE* dev_urandom; do - { - errno = 0; + { dev_urandom = fopen("/dev/urandom", "rb"); } - while G_UNLIKELY (errno == EINTR); + while G_UNLIKELY (dev_urandom == NULL && errno == EINTR); if (dev_urandom) { diff --git a/glib/glib/gspawn.c b/glib/glib/gspawn.c index 7df271f..e0a19ae 100644 --- a/glib/glib/gspawn.c +++ b/glib/glib/gspawn.c @@ -1083,6 +1083,7 @@ do_exec (gint child_err_report_fd, { /* Keep process from blocking on a read of stdin */ gint read_null = open ("/dev/null", O_RDONLY); + g_assert (read_null != -1); sane_dup2 (read_null, 0); close_and_invalidate (&read_null); } @@ -1101,6 +1102,7 @@ do_exec (gint child_err_report_fd, else if (stdout_to_null) { gint write_null = sane_open ("/dev/null", O_WRONLY); + g_assert (write_null != -1); sane_dup2 (write_null, 1); close_and_invalidate (&write_null); } diff --git a/glib/glib/gtimezone.c b/glib/glib/gtimezone.c index 8195106..e513f3b 100644 --- a/glib/glib/gtimezone.c +++ b/glib/glib/gtimezone.c @@ -591,7 +591,7 @@ interval_valid (GTimeZone *tz, * * This function may, however, modify @time_ in order to deal with * non-existent times. If the non-existent local @time_ of 02:30 were - * requested on March 13th 2010 in Toronto then this function would + * requested on March 14th 2010 in Toronto then this function would * adjust @time_ to be 03:00 and return the interval containing the * adjusted time. * diff --git a/glib/glib/gunicode.h b/glib/glib/gunicode.h index 83b4941..aafe933 100644 --- a/glib/glib/gunicode.h +++ b/glib/glib/gunicode.h @@ -628,6 +628,7 @@ gchar* g_utf8_find_prev_char (const gchar *str, glong g_utf8_strlen (const gchar *p, gssize max) G_GNUC_PURE; +GLIB_AVAILABLE_IN_2_30 gchar *g_utf8_substring (const gchar *str, glong start_pos, glong end_pos) G_GNUC_MALLOC; diff --git a/glib/glib/gutf8.c b/glib/glib/gutf8.c index 19be759..e61d33d 100644 --- a/glib/glib/gutf8.c +++ b/glib/glib/gutf8.c @@ -1595,9 +1595,9 @@ fast_validate_len (const char *str, /** * g_utf8_validate: - * @str: a pointer to character data + * @str: (array length=max_len) (element-type guint8): a pointer to character data * @max_len: max bytes to validate, or -1 to go until NUL - * @end: (allow-none) (out): return location for end of valid data + * @end: (allow-none) (out) (transfer none): return location for end of valid data * * Validates UTF-8 encoded text. @str is the text to validate; * if @str is nul-terminated, then @max_len can be -1, otherwise diff --git a/glib/glib/gutils.c b/glib/glib/gutils.c index 4992ecc..38b5e44 100644 --- a/glib/glib/gutils.c +++ b/glib/glib/gutils.c @@ -377,7 +377,7 @@ g_find_program_in_path (const gchar *program) * variable. If the program is found, the return value contains the * full name including the type suffix. * - * Return value: absolute path, or %NULL + * Return value: a newly-allocated string with the absolute path, or %NULL **/ #ifdef G_OS_WIN32 static gchar * @@ -660,19 +660,32 @@ g_get_any_init_do (void) gchar hostname[100]; g_tmp_dir = g_strdup (g_getenv ("TMPDIR")); + if (g_tmp_dir == NULL || *g_tmp_dir == '\0') - g_tmp_dir = g_strdup (g_getenv ("TMP")); + { + g_free (g_tmp_dir); + g_tmp_dir = g_strdup (g_getenv ("TMP")); + } + if (g_tmp_dir == NULL || *g_tmp_dir == '\0') - g_tmp_dir = g_strdup (g_getenv ("TEMP")); + { + g_free (g_tmp_dir); + g_tmp_dir = g_strdup (g_getenv ("TEMP")); + } #ifdef G_OS_WIN32 if (g_tmp_dir == NULL || *g_tmp_dir == '\0') - g_tmp_dir = get_windows_directory_root (); -#else + { + g_free (g_tmp_dir); + g_tmp_dir = get_windows_directory_root (); + } +#else + #ifdef P_tmpdir if (g_tmp_dir == NULL || *g_tmp_dir == '\0') { - gsize k; + gsize k; + g_free (g_tmp_dir); g_tmp_dir = g_strdup (P_tmpdir); k = strlen (g_tmp_dir); if (k > 1 && G_IS_DIR_SEPARATOR (g_tmp_dir[k - 1])) @@ -682,7 +695,8 @@ g_get_any_init_do (void) if (g_tmp_dir == NULL || *g_tmp_dir == '\0') { - g_tmp_dir = g_strdup ("/tmp"); + g_free (g_tmp_dir); + g_tmp_dir = g_strdup (g_getenv ("/tmp")); } #endif /* !G_OS_WIN32 */ @@ -1717,14 +1731,18 @@ g_reload_user_special_dirs_cache (void) /* only leak changed directories */ for (i = 0; i < G_USER_N_DIRECTORIES; i++) { - old_val = old_g_user_special_dirs[i]; - if (g_strcmp0 (old_val, g_user_special_dirs[i]) == 0) + old_val = old_g_user_special_dirs[i]; + if (g_user_special_dirs[i] == NULL) { - /* don't leak */ - g_free (g_user_special_dirs[i]); - g_user_special_dirs[i] = old_val; + g_user_special_dirs[i] = old_val; } - else + else if (g_strcmp0 (old_val, g_user_special_dirs[i]) == 0) + { + /* don't leak */ + g_free (g_user_special_dirs[i]); + g_user_special_dirs[i] = old_val; + } + else g_free (old_val); } diff --git a/glib/glib/gutils.h b/glib/glib/gutils.h index 1dd5e56..213a39f 100644 --- a/glib/glib/gutils.h +++ b/glib/glib/gutils.h @@ -207,8 +207,10 @@ typedef enum G_FORMAT_SIZE_IEC_UNITS = 1 << 1 } GFormatSizeFlags; +GLIB_AVAILABLE_IN_2_30 gchar *g_format_size_full (guint64 size, GFormatSizeFlags flags); +GLIB_AVAILABLE_IN_2_30 gchar *g_format_size (guint64 size); GLIB_DEPRECATED_FOR(g_format_size) diff --git a/glib/glib/gvariant-serialiser.c b/glib/glib/gvariant-serialiser.c index d4b668b..4ee6c72 100644 --- a/glib/glib/gvariant-serialiser.c +++ b/glib/glib/gvariant-serialiser.c @@ -1593,11 +1593,20 @@ gboolean g_variant_serialiser_is_string (gconstpointer data, gsize size) { + const gchar *expected_end; const gchar *end; + if (size == 0) + return FALSE; + + expected_end = ((gchar *) data) + size - 1; + + if (*expected_end != '\0') + return FALSE; + g_utf8_validate (data, size, &end); - return data == end - (size - 1); + return end == expected_end; } /* < private > diff --git a/glib/glib/gvariant.c b/glib/glib/gvariant.c index 3526f12..5f2337c 100644 --- a/glib/glib/gvariant.c +++ b/glib/glib/gvariant.c @@ -954,7 +954,10 @@ g_variant_new_dict_entry (GVariant *key, * this function returns %FALSE. Otherwise, it unpacks the returned * value and returns %TRUE. * - * See g_variant_get() for information about @format_string. + * @format_string determines the C types that are used for unpacking + * the values and also determines if the values are copied or borrowed, + * see the section on + * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>. * * Returns: %TRUE if a value was unpacked * @@ -2745,6 +2748,10 @@ g_variant_compare (gconstpointer one, switch (g_variant_classify (a)) { + case G_VARIANT_CLASS_BOOLEAN: + return g_variant_get_boolean (a) - + g_variant_get_boolean (b); + case G_VARIANT_CLASS_BYTE: return ((gint) g_variant_get_byte (a)) - ((gint) g_variant_get_byte (b)); @@ -4614,6 +4621,11 @@ g_variant_new_va (const gchar *format_string, * Please note that the syntax of the format string is very likely to be * extended in the future. * + * @format_string determines the C types that are used for unpacking + * the values and also determines if the values are copied or borrowed, + * see the section on + * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>. + * * Since: 2.24 **/ void @@ -4662,6 +4674,11 @@ g_variant_get (GVariant *value, * g_variant_new_va() and g_variant_get_va() within a single actual * varargs call by the user. * + * @format_string determines the C types that are used for unpacking + * the values and also determines if the values are copied or borrowed, + * see the section on + * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>. + * * Since: 2.24 **/ void @@ -4748,6 +4765,11 @@ g_variant_builder_add (GVariantBuilder *builder, * essentially a combination of g_variant_get_child_value() and * g_variant_get(). * + * @format_string determines the C types that are used for unpacking + * the values and also determines if the values are copied or borrowed, + * see the section on + * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>. + * * Since: 2.24 **/ void @@ -4816,6 +4838,11 @@ g_variant_get_child (GVariant *value, * For a solution that is likely to be more convenient to C programmers * when dealing with loops, see g_variant_iter_loop(). * + * @format_string determines the C types that are used for unpacking + * the values and also determines if the values are copied or borrowed, + * see the section on + * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>. + * * Returns: %TRUE if a value was unpacked, or %FALSE if there as no value * * Since: 2.24 @@ -4914,6 +4941,11 @@ g_variant_iter_next (GVariantIter *iter, * types, use the '&' prefix to avoid allocating any memory at all (and * thereby avoiding the need to free anything as well). * + * @format_string determines the C types that are used for unpacking + * the values and also determines if the values are copied or borrowed, + * see the section on + * <link linkend='gvariant-format-strings-pointers'>GVariant Format Strings</link>. + * * Returns: %TRUE if a value was unpacked, or %FALSE if there was no * value * diff --git a/glib/glib/gvariant.h b/glib/glib/gvariant.h index 9abcc0b..d0cd857 100644 --- a/glib/glib/gvariant.h +++ b/glib/glib/gvariant.h @@ -86,6 +86,7 @@ gboolean g_variant_is_signature (const g GVariant * g_variant_new_variant (GVariant *value); GVariant * g_variant_new_strv (const gchar * const *strv, gssize length); +GLIB_AVAILABLE_IN_2_30 GVariant * g_variant_new_objv (const gchar * const *strv, gssize length); GVariant * g_variant_new_bytestring (const gchar *string); @@ -114,6 +115,7 @@ const gchar ** g_variant_get_strv (GVarian gsize *length); gchar ** g_variant_dup_strv (GVariant *value, gsize *length); +GLIB_AVAILABLE_IN_2_30 const gchar ** g_variant_get_objv (GVariant *value, gsize *length); gchar ** g_variant_dup_objv (GVariant *value, |