Commit Graph

18218 Commits

Author SHA1 Message Date
Philip Withnall
2c9a84e5a3 garray: Factor out implementation of g_ptr_array_remove_index*()
They were almost identically the same. This introduces no functional
changes, but will help with upcoming additions to GPtrArray.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795376
2018-05-09 13:52:05 +01:00
Nirbheek Chauhan
3e96523e6b meson: Fix atomic ops test to match configure.ac
We must try linking, not just compiling. That will give a false
positive.
2018-05-09 18:04:59 +05:30
Nirbheek Chauhan
91c9cb5a52 config.h.meson: Add some missing #mesondefines
The compiler checks were being completely ignored.
2018-05-09 18:04:09 +05:30
Xavier Claessens
b6cb22f32b Meson: Do not build tests with nodelete/Bsymbolic-functions
-z nodelete breaks the libresourceplugin module usage in the resources.c
test, which expects to be able to unload it.

Make the Meson build match what the autotools build does: only pass
glib_link_flags to the headline libraries (glib-2.0, gio-2.0,
gobject-2.0, gthread-2.0, gmodule-2.0) and omit it from all other build
targets.

https://bugzilla.gnome.org/show_bug.cgi?id=788771
2018-05-09 12:52:59 +01:00
Christian Hergert
e924f77736 gtype: improve get_type fast path
The -fstack-protector-strong used in many distributions by default has a
rather drastic slowdown of the fast path in generated _get_type()
functions using G_DEFINE_* macros. The amount can vary by architecture,
GCC version, and compiler flags.

To work around this, and ensure a higher probability that our fast-path
will match what we had previously, we need to break out the slow-path
(registering the type) into a secondary function that is not a candidate
for inlining.

This ensures that the common case (type registered, return the GType id)
is the hot path and handled in the prologue of the generated assembly even
when -fstack-protector-strong is enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=795180
2018-05-09 12:25:06 +01:00
Christian Hergert
ede5c3f8d9 macros: add G_GNUC_NO_INLINE function attribute
https://bugzilla.gnome.org/show_bug.cgi?id=795180
2018-05-09 12:25:06 +01:00
okimoto
2fd0627326 gutils: Fix deprecation annotation for g_format_size_for_display()
It was deprecated in 2.30.

https://bugzilla.gnome.org/show_bug.cgi?id=795960
2018-05-09 10:52:15 +01:00
Philip Withnall
6acece5074 ghash: Add g_hash_table_steal_extended()
This is a combination of g_hash_table_lookup_extended() and
g_hash_table_steal(), so that users can combine the two to reduce code
and eliminate a pointless second hash table lookup by
g_hash_table_steal().

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795302
2018-05-08 12:41:13 +01:00
Philip Withnall
864cb71524 glib: Update internal copy of valgrind.h from Valgrind 3.13 release
Update our copy of valgrind.h from the Valgrind 3.13 release tarball.
This seems to include fixes for PPC and Solaris. No changes made to the
header file.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=736741
2018-05-08 12:37:20 +01:00
Philip Withnall
0adbeacd01 gregex: Highlight in the docs that input must be in UTF-8
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=748620
2018-05-08 12:27:55 +01:00
Philip Withnall
f75624f593 gregex: Highlight some argument names in the documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=748620
2018-05-08 12:27:55 +01:00
Philip Withnall
fe35f577b0 gregex: Clarify units in documentation
Make it a bit clearer that all lengths passed to GRegex methods are in
bytes (not characters). This is mentioned in the section overview, but
who reads that?

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=748620
2018-05-08 12:27:55 +01:00
Philip Withnall
9870de442f gobject: Fix a typo in the G_VALUE_LCOPY documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-05-07 20:43:59 +01:00
Christoph Reiter
98a0ab929d Always assume that we use a gnu/c99 printf implementation
On Windows we use gnulib and elsewhere we use glibc or similar.

Also change G_GNUC_PRINTF to use gnu_printf instead of __format__ if
possible because __format__ evaluates to ms_printf under MinGW,
but we use gnulib there and not the system printf.
gnu_printf is only available with GCC>=4.4 and not with clang.

https://bugzilla.gnome.org/show_bug.cgi?id=795569
2018-05-07 19:50:25 +02:00
Matthew Leeds
b437a13a70 gio: Fix a typo in the docs for g_file_is_native() 2018-05-04 18:32:43 -07:00
Philip Withnall
cc4de801c9 gobject: Reimplement g_param_values_cmp() for GParamSpecVariant
The existing implementation was completely incorrect (despite the fix in
commit 566e64a66) — it always compared GVariants by pointer, rather than
by value.

Reimplement it to compare them by value where possible, depending on
their type. The core of this implementation is g_variant_compare(). See
the documentation and tests for further details of the new sort order.

This adds documentation and tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795735
2018-05-04 18:17:59 +01:00
Philip Withnall
a06117d062 Revert "Fix the cmp implementation for variant values"
This reverts commit 566e64a660.

This fix went from one broken state to another. The real fix is to use
g_variant_compare(), which is pending review. See bug #795735.

https://bugzilla.gnome.org/show_bug.cgi?id=795735
2018-05-04 17:22:17 +01:00
Iñigo Martínez
5faac84413 gdbus-codegen: Fix header include in the body file
When body file is generated, the header name to be included is
built by using the path passed by `--output` directory. However,
this might not be correct because, if the path includes a
subdirectory, the whole path will be used instead of only the
base name.

Please see:
  https://github.com/mesonbuild/meson/issues/3488
  https://github.com/gnome-mpv/gnome-mpv/issues/305#issuecomment-385056156

https://bugzilla.gnome.org/show_bug.cgi?id=795802
2018-05-04 17:16:10 +01:00
Tomasz Miąsko
9d40f64960 gdesktopappinfo: Mark GDesktopAppInfo constructors as nullable.
GDesktopAppInfo constructors return NULL on error without having
separate **GError parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=795152
2018-05-04 17:13:39 +01:00
Marek Černocký
47c4a9f694 Updated Czech translation 2018-05-04 00:38:05 +02:00
Havard Graff
71fba3b3be kqueue/meson: add missing dependency
gioenumtypes needs to be generated:
In file included from ../../../../external/glib/gio/kqueue/gkqueuefilemonitor.c:37:
In file included from ../../../../external/./glib/gio/glocalfilemonitor.h:25:
In file included from ../../../../external/./glib/gio/gunixmounts.h:24:
../../../../external/./glib/gio/gio.h:86:10: fatal error: 'gio/gioenumtypes.h' file not found
#include <gio/gioenumtypes.h>
         ^~~~~~~~~~~~~~~~~~~~

https://bugzilla.gnome.org/show_bug.cgi?id=794325
2018-05-03 00:01:50 +01:00
Ting-Wei Lan
50677e9336 gtimezone: Fallback to /var/db/zoneinfo on FreeBSD
The timezone setup utility of FreeBSD, tzsetup, which is run during the
installation, creates /etc/localtime by copying the chosen timezone file
from /usr/share/zoneinfo. Although it can correctly deal with the case
where /etc/localtime is a symlink, it is not the default and there is no
user interface to change the default copying behaviour.

Fortunately, tzsetup has been modified to write the name of the chosen
timezone to /var/db/zoneinfo in 2009, so we can know the name of the
current timezone by reading it. DragonflyBSD also seems to do the same
thing in its tzsetup.

https://svnweb.freebsd.org/changeset/base/198267
https://bugzilla.gnome.org/show_bug.cgi?id=795165
2018-05-02 17:33:10 +01:00
Christoph Reiter
3d2ab4680d ci: use timeout-multiplier=2 for running the tests
It looks like the coverage generation makes the tests a bit slower and
some are now hitting timeouts. Flaky tests are always more annoying than
slow ones, and we don't know how much resources we get under CI,
so increase the timeout.

https://bugzilla.gnome.org/show_bug.cgi?id=795636
2018-05-02 14:52:50 +02:00
Matthias Clasen
566e64a660 Fix the cmp implementation for variant values
This was causing g_param_value_defaults to return 1
for GVariant values even when the value is clearly
different from the default.

This was showing up as gtk-builder-tool stripping
non-default values for GtkActionable::action-target
from ui files.
2018-05-02 08:30:59 -04:00
Matthias Clasen
2d67f91e26 2.57.0 2018-05-02 08:30:40 -04:00
Christoph Reiter
961be2b0bf ci: collect test coverage and deploy a html report through gitlab pages
Use lcov for both Fedora and MSYS2 to create coverage reports and add a second
ci stage which merges the coverage and creates a html report using genhtml.

In the final stage, which is only run on master, the result is published on
gitlab pages.

https://bugzilla.gnome.org/show_bug.cgi?id=795636
2018-05-02 11:14:45 +01:00
Christoph Reiter
e8798a4c22 ci: update meson
Rebuild the fedora docker image to get the newest meson release and
use pip to install the newest version for MSYS2.

https://bugzilla.gnome.org/show_bug.cgi?id=795711
2018-05-02 11:09:25 +01:00
Ting-Wei Lan
a0c7f85437 tests: Fix GDateTime format tests on non-English locales
It seems that the test expects g_date_time_format to return formatted
results in English, and there is no setlocale (LC_ALL, "") call in the
file so the test does run in the default C locale. However, gettext
seems to read the value of LC_MESSAGES from the environment by itself.
Even if the value of LC_MESSAGES locale is C because of not calling
setlocale, gettext still translates the name of the month according to
the LC_MESSAGES environment variable, causing g_date_time_format_locale
to fail on the "%b" test case because it cannot convert UTF-8 text
returned by get_month_name_with_day to ASCII.

To avoid the test failure, we set the LC_MESSAGES environment variable
to C before format tests and restore it at the end of the function.

https://bugzilla.gnome.org/show_bug.cgi?id=795165
2018-05-01 21:43:23 +01:00
Philip Withnall
c47cf7355c gfileutils: Add missing ‘Since’ line to g_canonicalize_filename() docs
I missed this in code review.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-05-01 08:51:57 +01:00
Georges Basile Stavracas Neto
cb32614382 timezone: Correctly resolve symlink from /etc/localtime
The return value of g_file_read_link ("/etc/localtime") can
be a relative path in the form of "../usr/share/zoneinfo".
This breaks the prefix check that is performed, and makes
the timezone identifier be "../usr/share/zoneinfo/America/Sao_Paulo",
for example, which breaks other parts of the system.

Fix that by canonicalizing the symlink path if we detect
is it a relative path.

(Tweaked by Philip Withnall <withnall@endlessm.com> to remove a
conditional which was unnecessary.)

https://bugzilla.gnome.org/show_bug.cgi?id=111848
2018-04-30 21:59:22 +01:00
Georges Basile Stavracas Neto
0f37af7e9b glocalfile: Use g_canonicalize_filename
Drop the local function in favor of the exposed
one.

https://bugzilla.gnome.org/show_bug.cgi?id=111848
2018-04-30 21:54:49 +01:00
Georges Basile Stavracas Neto
b9b642de06 fileutils: Add g_canonicalize_filename
Getting the canonical filename is a relatively common
operation when dealing with symbolic links.

This commit exposes GLocalFile's implementation of a
filename canonicalizer function, with a few additions
to make it more useful for consumers of it.

Instead of always assuming g_get_current_dir(), the
exposed function allows passing it as an additional
parameter.

This will be used to fix the GTimeZone code to retrieve
the local timezone from a zoneinfo symlink.

(Tweaked by Philip Withnall <withnall@endlessm.com> to drop g_autofree
usage and add some additional tests.)

https://bugzilla.gnome.org/show_bug.cgi?id=111848
2018-04-30 21:54:31 +01:00
Xavier Claessens
a67dc37e9c Meson: Add -Wl,-z,nodelete and -Wl,-Bsymbolic-functions where supported
https://bugzilla.gnome.org/show_bug.cgi?id=788771
2018-04-30 12:14:07 -04:00
Xavier Claessens
9d12af9ef8 configure.ac: Remove --disable-znodelete options
There is no reason to disable this linker flags, and we are not going to
add this option in our meson build system, so remove it from autotools
too to be on par. If anyone complains with a valid use-case we can add
them back.

Keeping -Bsymbolc for now because it is used for refdbg and Debian has a
package that build glib with that flag.

https://bugzilla.gnome.org/show_bug.cgi?id=788771
2018-04-30 12:14:07 -04:00
Christoph Reiter
fe9457dedd gliststore: Improve the test coverage
https://bugzilla.gnome.org/show_bug.cgi?id=795307
2018-04-30 13:02:41 +02:00
Christoph Reiter
758d7073a9 g_list_store_splice: Add items in the order of the input array and at the given position
It inserted the new items one position after the given one and inserted all new items
at the same position resulting in the items being in the reverse order of the
input array.

It was decided to make these behavioural changes because this function has according to
https://codesearch.debian.net/search?q=g_list_store_splice only one real user (nautilus)
and it didn't do what one would expect from reading the documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=795307
2018-04-30 13:02:41 +02:00
Philip Withnall
1af84aa435 gobject: Fix documentation for G_VALUE_LCOPY
It was previously a copy–paste of G_VALUE_COLLECT, which is wrong,
because it’s the inverse function of G_VALUE_COLLECT. Document that, so
the whole thing is a little less confusing (but by no means perfect).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-27 18:44:41 +01:00
Philip Withnall
9b4c50f63d all: Remove trailing newlines from g_message()/g_warning()/g_error()s
All those logging functions already add a newline to any message they
print, so there’s no need to add a trailing newline in the message
passed to them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-27 16:46:19 +01:00
Philip Withnall
16e58dc901 gclosure: Expand documentation and fix some typos
The critical omission from the GClosure documentation is that you need
to call g_closure_set_marshal() when implementing a custom GClosure.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 18:04:47 +01:00
Philip Withnall
8056b753e5 tests: Fix a free function in the GIO tests
The monitor_path comes from g_file_get_path(), so should be freed with
g_free() rather than free(). This makes no difference because they are
the same function in practice, but using free() is a bit confusing.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 15:36:11 +01:00
Philip Withnall
9365e212f8 More const-correctness fixes
This continues one of the const-correctness fixes from the previous
commit (it needed some more transitive fixes), and reverts another of
them, since it was over-zealous.

This fixes CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/27125.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 15:35:58 +01:00
Philip Withnall
22cd18500d Fix various const-correctness issues
Spotted when temporarily compiling with -Wwrite-strings. This only goes
a small way towards making the code base -Wwrite-strings–clean. It
introduces no functional changes, and fixes no bugs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 15:19:17 +01:00
Philip Withnall
9cbfb56061 gutils: Fix deadlock if g_get_home_dir() fails when called twice
If g_get_home_dir() calculated a NULL home directory (due to $HOME being
unset and /etc/passwd being inaccessible, for example due to an
overly-zealous LSM), it would call g_once_init_leave (&home_dir, NULL),
which would emit a critical and fail to leave the GOnce critical
section. That meant that the following call to g_get_home_dir() would
deadlock in g_once_init_enter().

Fix that by setting the home directory to a made-up value in such cases
(which the documentation handily already explicitly allows).

Thanks to Simon McVittie for the analysis leading to an easy patch.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=773435
2018-04-26 15:19:17 +01:00
Florian Müllner
f9f497a702 tests: Add .desktop file for non-existent binary ...
... to test that it is filtered out correctly by
g_desktop_app_info_load_from_keyfile() (but not
g_desktop_app_info_search()).

https://bugzilla.gnome.org/show_bug.cgi?id=795488
2018-04-26 16:03:39 +02:00
Christoph Reiter
0d10dd9fe5 tests/autoptr: Don't use /dev/null under Windows
Use the "nul" device instead.

https://bugzilla.gnome.org/show_bug.cgi?id=795569
2018-04-26 13:01:25 +02:00
Philip Withnall
a8b4d516aa gsequence: Various minor typo and reference fixes to the documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 11:34:15 +01:00
Philip Withnall
a20c8d4421 ci: Rename build-job to fedora-meson-x86_64 for uniqueness
Makes it a bit more easily differentiable from the new `msys2-mingw32`
job.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-04-26 10:11:29 +01:00
Xavier Claessens
01e8396301 Fix build when pthread_getname_np is not available
On Android _setname_ is always available but _getname_ is available only
with API level >= 26.

https://bugzilla.gnome.org/show_bug.cgi?id=795406
2018-04-25 13:56:14 -04:00
Xavier Claessens
d123717947 Meson: Add missing link on libintl in tests
This fix undefined symbol link error when building for non-glibc
platform. Applications must link on libintl, it is not a public
dependency of libglib.

On glibc platforms libintl is a not found dependency and is just ignored
by meson, so it doesn't hurt to always have it.

https://bugzilla.gnome.org/show_bug.cgi?id=795406
2018-04-25 13:56:14 -04:00
Christoph Reiter
97c28f7fe1 ci: fix warnings and enable --werror for the mingw build
Fix various warnings regarding unused variables, duplicated
branches etc by adjusting the ifdeffery and some missing casts.

gnulib triggers -Wduplicated-branches in one of the copied files,
disable as that just makes updating the code harder.

The warning indicating missing features are made none fatal through
pragmas. They still show but don't abort the build.

https://bugzilla.gnome.org/show_bug.cgi?id=793729
2018-04-25 17:23:50 +02:00