Commit Graph

6390 Commits

Author SHA1 Message Date
Philip Withnall
5c5920d968 Merge branch 'fix-fileutils-test-windows' into 'master'
glib/tests/fileutils.c: Fix stdio Wrapper Test on Windows

See merge request GNOME/glib!931
2019-06-19 08:44:39 +00:00
Chun-wei Fan
7a72d3bbae glib/tests/fileutils.c: Fix stdio Wrapper Test on Windows
The g_creat() call was done in *nix style in regards to the mode parameter,
which the Windows CRT isn't going to understand (nor like, on newer CRTs).

Update the program such that it will pass, by using Windows-style
permission mode parameters for g_creat(), on Windows.
2019-06-19 11:21:20 +08:00
Chun-wei Fan
6e224f7677 glib/tests/convert.c: Skip tests that aren't meaningful for Windows
On Windows, everything is assumed as UTF-8 in g_get_filename_charsets(),
so setting G_FILENAME_ENCODING envvar has no effect, so we can just skip
the test on g_get_filename_charsets() where we try to influence it by
setting the G_FILENAME_ENCODING envvar.
2019-06-19 10:55:17 +08:00
Philip Withnall
1888deecfc Merge branch 'glib.fixtools.i18n' into 'master'
Tools: Correctly show translated messages on more recent Visual Studio builds

Closes #1169

See merge request GNOME/glib!895
2019-06-18 10:18:31 +00:00
Chun-wei Fan
3e5d1bd6ff glib-private.h: Set the appropriate string for setlocale()
On Windows, in particular the CRTs on and after Visual Studio 2012, it
is not enough just to do setlocale (LC_ALL, "") to set the default
system locale, which results in the tools that use the translated
messages to show unreadable messages when running the commmand line
tools.

This adds an entry in glib-private.h.in which denotes the appropriate
string to use for setlocale() to set the default system locale by
setting it to ".ACP" if we are building on Windows and "" for
other systems (as we are doing now).

The tools in gio/ will be updated in the next commit to make use of this
entry so that the translated messages can be shown correctly.
2019-06-18 17:29:36 +08:00
Chun-wei Fan
bf40b7c746 glib/tests/refcount.c: Only expect saturation tests to pass on GCC
From grefcount.h, in order to disable warnings when G_DISABLE_CHECKS is
defined, we need to make use of the GCC-isque-only __extension__ for it
to work.  This means that in the saturation tests, we can only expect no
warnings to show if we are building on GCC-isque compilers with
G_DISABLE_CHECKS defined.

This will fix the refcount-macro test on Visual Studio builds at least.
2019-06-18 16:42:51 +08:00
Emmanuele Bassi
23d33b7630 Check if compiler symbols are defined before using them
If we don't do this, projects using `-Werror=undef` will break.
2019-06-17 16:39:57 +01:00
Philip Withnall
dddcf90dda gmacros: Only use deprecated attributes on enumerators with GCC ≥ 6.1
The reference I found online which said they were supported by GCC ≥ 5.2
was obviously lying.

The GCC 6.1.0 documentation says they’re supported:
https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/Enumerator-Attributes.html.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-14 13:51:44 +01:00
Philip Withnall
fa5996927f Merge branch 'drop-g-disable-deprecated' into 'master'
Drop G_DISABLE_DEPRECATED

Closes #1060 and #638

See merge request GNOME/glib!871
2019-06-14 11:24:25 +00:00
Philip Withnall
9740b58814 Merge branch '77-wrap-on-linux' into 'master'
glib: Rename G_STDIO_NO_WRAP_ON_UNIX → G_STDIO_WRAP_ON_UNIX

Closes #77

See merge request GNOME/glib!830
2019-06-11 11:37:35 +00:00
Sebastian Dröge
65c80701ca Merge branch '1438-deprecate-gtime' into 'master'
gdate: Officially mark GTime as deprecated

See merge request GNOME/glib!817
2019-06-11 11:29:35 +00:00
Philip Withnall
71973c722a gmain: Clarify that g_source_destroy() doesn’t drop a reference
This always confuses people.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-07 11:26:47 +01:00
Philip Withnall
973406ab58 Merge branch 'dboles/atomit' into 'master'
garcbox.c: Fix typo atomit => atomic

See merge request GNOME/glib!884
2019-06-04 19:50:41 +00:00
Daniel Boles
c9b255f6c6 garcbox.c: Fix typo atomit => atomic 2019-06-04 20:08:46 +01:00
Chun-wei Fan
5e0f384f88 glib/tests/win32.c: Fix test variable types
The variable types for the PID (bp) and event (be) are accidentally
reversed in the test program.  Correct their types so that tests do not
fail on Visual Studio x64 builds.

Fixes issue #1797
2019-06-04 20:08:20 +01:00
Christoph Reiter
b49e767e2e gunicollate: work around FreeBSD wchar_t not matching our gunichar type
In !863 I assumed that a 4 byte wchar_t would be equal to gunichar on all platforms,
but this is not the case for FreeBSD. It previously was using the non wchar_t based API
because it doesn't define __STDC_ISO_10646__.

Add back the __STDC_ISO_10646__ check again and introduce a more meaningful macro for guarding
the code paths that are mixing gunichar and wchar_t.

Fixes #1798
2019-06-04 18:20:18 +02:00
Sebastian Dröge
41f68f8b19 Merge branch '590-rwlock-docs' into 'master'
gthread: Fix g_rw_lock_reader_lock() documentation

Closes #590

See merge request GNOME/glib!882
2019-06-03 10:44:32 +00:00
Philip Withnall
e1992a0e0e goption: Clarify G_OPTION_ARG_FILENAME documentation
It’s already documented elsewhere, but not particularly obviously.
Clarify argument encodings in the GOptionArg documentation.

As reported on StackOverflow:
https://stackoverflow.com/q/56416098/2931197.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-03 10:57:18 +01:00
Philip Withnall
231661e46c gthread: Fix g_rw_lock_reader_lock() documentation
The documentation erroneously said that a thread calling
g_rw_lock_reader_lock() would always block if another thread was waiting
for the write lock. That’s not true: if no thread holds the lock, it is
implementation defined which of a waiting reader and writer gets the
lock.

See
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_rwlock_rdlock.html.

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

Fixes: #590
2019-05-31 21:36:34 +01:00
Philip Withnall
40ff475977 Annotate various types and macros as deprecated
These have all been documented as deprecated for a long time, but we’ve
never had a way to programmatically mark them as deprecated. Do that
now.

This is based on the list of deprecations from the reverted commit
80fcb1bc2.

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

Fixes: #638
2019-05-30 10:39:11 +01:00
Philip Withnall
99b412bb19 gdate: Drop unnecessary use of G_DISABLE_DEPRECATED
The function is already annotated with `GLIB_DEPRECATED_FOR()`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
e62e89f2f8 Fix various deprecation warnings in code and tests
This code uses, or tests, deprecated functions, types or macros; so
needs to be compiled with deprecation warnings disabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
f0fb7b77a1 glib, gobject: Annotate deprecated types and enumerators
Use the new `GLIB_DEPRECATED_{TYPE,ENUMERATOR}*` macros to annotate types
and enumerators as deprecated, rather than using `G_DISABLE_DEPRECATED`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
6554c91b13 gutils: Move g_ATEXIT() and g_memmove() definitions from glibconfig.h
The definitions weren’t templated in glibconfig.h.in at all, so didn’t
vary between configurations of GLib — so they should be in a normal
header.

Move them to gutils.h and fix the deprecation annotations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
74ca348e99 glib: Unconditionally include deprecated headers
This allows the symbols there to be used conditionally, depending on the
user’s stated `GLIB_VERSION_MIN_REQUIRED` and `GLIB_VERSION_MAX_ALLOWED`
preferences.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
b4d58a7105 glib, gio: Use GLIB_DEPRECATED_MACRO instead of G_DISABLE_DEPRECATED
When defining deprecated macros, annotate them with
`GLIB_DEPRECATED_MACRO_IN_*()` and `GLIB_DEPRECATED_MACRO_IN_*_FOR()` to
conditionally emit warnings if people use them, depending on their
declared minimum and maximum GLib version requirements (see
`GLIB_VERSION_MIN_REQUIRED` and `GLIB_VERSION_MAX_ALLOWED`).

The old way of doing this was for users to define `G_DISABLE_DEPRECATED`
if they didn’t want to use deprecated APIs, but it reported errors via
missing symbols, and wasn’t version-dependent. It’s being phased out.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
db270e3c2d gmacros: Add GLIB_DEPRECATED_{MACRO,ENUMERATOR,TYPE}{,_FOR}
These will be used to annotate deprecated macros, types and enumerators.

`GLIB_DEPRECATED_MACRO{,_FOR}` are based very heavily on the
corresponding macros from Clutter, written by Emmanuele Bassi.

The other deprecation annotators use the standard annotations supported
by Clang and GCC. They need to be separated as they are supported in
different versions of the compilers.

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

Fixes: #1060
2019-05-30 10:38:45 +01:00
Philip Withnall
05f7ea9fc5 gtimezone: Stop using deprecated API
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
52b38ba6da tests: Don’t use a deprecated Unicode character type enumerator
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Philip Withnall
5ad9d3fd61 glib: Move some documentation comments to where the symbols are defined
This makes it easier to maintain the documentation and code at the same
time. The documentation comments haven’t been modified.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Sebastian Dröge
0f056ebea3 Use atomic reference counting for GSource
If attached to a context already it would use a mutex instead but at
least before that the reference counting is not thread-safe currently.
2019-05-28 18:46:18 +03:00
Patrick Storz
56149722ae Add g_get_console_charset
Queries the charset used by the associated console, which does not
necessarily match the charset of the current locale as returned by
g_get_charset.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1270
2019-05-27 17:51:40 +00:00
Philip Withnall
73f8ff82ed Merge branch 'cygwin-gunicollate-check-sizeof-wchar-t' into 'master'
gunicollate/cygwin: Don't use __STDC_ISO_10646__ for wchar_t related checks

See merge request GNOME/glib!863
2019-05-27 10:26:14 +00:00
Emmanuele Bassi
50dcccc504 docs: Document pitfall of deprecation pragmas
As we discovered in GNOME/gtk#1280, GCC considers the pragmas to control
the deprecation warnings as statements. This means we cannot just use
the GLib wrappers as markers around the call site, but we must be aware
of their side effects.

Let's document this, to avoid falling into the trap.
2019-05-24 18:17:13 +01:00
Christoph Reiter
0030408299 gunicollate/cygwin: Don't use __STDC_ISO_10646__ for wchar_t related checks
The code in gunicollate uses __STDC_ISO_10646__ to check that wchar.h is avilable,
that it includes the wide character related functions and that sizeof(wchar_t) == 4.

cygwin defines __STDC_ISO_10646__ and has sizeof(wchar_t) == 2 and the C standard text isn't
that clear on whether wchar_t should always be 4 bytes in this case, so we better not use if for
assuming the size here.

Instead of relying on __STDC_ISO_10646__ add HAVE_WCHAR_H and SIZEOF_WCHAR_T macros.
With HAVE_WCHAR_H defined we assume wchar_t exists and wchar.h exists. With SIZEOF_WCHAR_T we
guard the parts where the size of wchar_t is assumed to be 4 (currently all of them).

Note that this doesn't make the collate tests pass under cygwin, they fail before and after this patch for me.

See !755 for related discussions.
2019-05-22 19:44:13 +02:00
Philip Withnall
4da8b7b35a gtestutils: Add g_test_summary() to add summary metadata to unit tests
This is a new function along the same lines as g_test_bug(): to allow
developers to annotate unit tests with information about the test (what
it tests, how it tests it) for future developers to read and learn from.

It will also output this summary as a comment in the test’s TAP output,
which might clarify test results.

Includes a unit test.

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

Fixes: #1450
2019-05-21 12:33:15 +01:00
Philip Withnall
81dbc7b07b tests: Set locale in gtestutils tests to allow UTF-8 output
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-21 12:29:39 +01:00
Philip Withnall
dfa7a5b5b5 Merge branch '1780-fix-ghashprinter' into 'master'
Update gdb pretty-printer for GHashTable

Closes #1780

See merge request GNOME/glib!852
2019-05-21 11:16:37 +00:00
Allison Karlitskaya
115033338b ghash: fix small array handling in g_hash_table_remove_all_nodes()
Factor out the code for setting up the hash table size, mask and mod,
detecting valgrind and allocating the arrays for hashes, keys, and
values.

Make use of this new function from g_hash_table_remove_all_nodes().

The handling of have_big_keys and have_big_values was never correct in
this function because it reallocated the array without changing the
flags in the struct.  Any calls in to the hashtable from destroy
notifies would find the table in an inconsistent state.

Many thanks to Thomas Haller who is essentially responsible for all the
real work in this patch: both discovering and identifying the original
problem, as well as finding the solution to it.
2019-05-20 17:03:49 +02:00
Allison Karlitskaya
9add93e5a4 ghash: Be more explicit about memory in g_hash_table_destroy_all_nodes()
Make it clear that there is a reference transfer going on here, rather
than relying on the fields being overwritten on each branch of the
conditional below.
2019-05-20 17:03:49 +02:00
Allison Karlitskaya
b3fbf6c18b ghash: do less work when destroying the table
We were calling g_hash_table_set_shift() to reinitialise the hash table
even in the case of destroying it.  Only do that for the non-destruction
case, and fill the relevant fields with zeros for the destruction case.
This has a nice side effect of causing more certain crashes in case of
invalid reuse of the table after (or during) destruction.
2019-05-20 17:03:49 +02:00
Allison Karlitskaya
c5462cb3c1 ghash: Improve internal documentation
The changes introduced by 18745ff674 made
the comment at the top of g_hash_table_remove_all_nodes() no longer
correct.  Fix that inaccuracy and add more documentation all-around.
2019-05-20 17:03:49 +02:00
Allison Karlitskaya
96ce92025d ghash: fix bug introduced by valgrind fix
g_hash_table_new_full() had an invocation of
g_hash_table_realloc_key_or_value_array() with the @is_big argument
incorrectly hardcoded to FALSE, even though later in the function the
values of have_big_keys and have_big_values would be set conditionally.

This never caused problems before because on 64bit platforms, this would
result in the allocation of a guint-sized array (which would be fine, as
have_big_keys and have_big_values would always start out as false) and
on 32bit platforms, this function ignored the value and always allocated
a gpointer-sized array.

Since merge request GNOME/glib!845 we have the possibility for
have_big_keys and have_big_values to start out as TRUE on 64bit
platforms.  We need to make sure we pass the argument through correctly.
2019-05-20 17:03:49 +02:00
zb3
d1d81c8a07 Update gdb pretty-printer for GHashTable
Fixes #1780
2019-05-17 17:46:24 +02:00
Philip Withnall
522e74982e Merge branch '1441-1619-deprecate-gtester' into 'master'
Deprecate gtester and use TAP output for tests by default

Closes #1619 and #1441

See merge request GNOME/glib!842
2019-05-17 12:12:53 +00:00
Philip Withnall
1ff1e7d57a Merge branch 'fix_g_format_size_full' into 'master'
Fixing g_format_size_full() on Windows-x64

See merge request GNOME/glib!845
2019-05-15 11:27:49 +00:00
Emmanuel Fleury
101c8b3c19 Fixing g_format_size_full() on Windows-x64
For some reasons, the buffer used in the Format struct was not long
enough on Windows-x64 and the final null ('\0') character was omitted
leading to a limited memory disclosure.
2019-05-15 10:18:22 +02:00
Philip Withnall
4e2acb47bd Merge branch 'wip/desrt/ghash-valgrind' into 'master'
ghash: Disable small-arrays under valgrind

Closes #1749

See merge request GNOME/glib!840
2019-05-14 15:50:05 +00:00
Allison Karlitskaya
436ca1f376 ghash: Disable small-arrays under valgrind
Valgrind can't find 64bit pointers when we pack them into an array of
32bit values.  Disable this optimisation if we detect that we are
running under valgrind.

Fixes #1749
2019-05-14 16:31:37 +02:00
Philip Withnall
4f5fe35385 Merge branch 'fix_g_unichar_totitle' into 'master'
Fix g unichar totitle

Closes #135

See merge request GNOME/glib!843
2019-05-14 12:05:30 +00:00
Philip Withnall
505f45ef95 tests: Remove redundant --tap options
Now that TAP output is used by default, passing `--tap` is unnecessary.

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

Helps: #1619
2019-05-14 12:42:51 +01:00
Philip Withnall
ad17576657 gtestutils: Output in TAP format by default
Only disable TAP output if the `--GTestLogFD` argument is passed to the
test, which is passed in by the (deprecated) gtester harness, and
shouldn’t ever have been passed in by anything else.

Also disable it when running a subprocess, using `--GTestSubprocess`,
since users commonly strictly check the stdout and stderr of test
subprocesses.

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

Fixes: #1619
2019-05-14 12:42:51 +01:00
Emmanuel Fleury
7dcaa7eeda Add the corresponding test for g_unichar_totitle(0) 2019-05-14 13:38:14 +02:00
Emmanuel Fleury
48d65634a5 Handling U+0000 explicitely to avoid collision with other cases
Fix issue #135
2019-05-14 13:35:49 +02:00
Philip Withnall
662cddcb4b glib: Deprecate gtester and gtester-report
Add warnings about their deprecation everywhere. The tools will continue
to work until we break API, but will be less well maintained. You should
use TAP for communicating test results to the test harness provided by
your build system or CI system instead.

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

Fixes: #1441
2019-05-14 12:14:54 +01:00
Philip Withnall
bd8658e16a Merge branch 'g_format_size_is_broken_on_Windows' into 'master'
Fixing g_format_size() on Windows

Closes #429

See merge request GNOME/glib!837
2019-05-14 10:25:30 +00:00
Rafal Luzynski
35c28be327 tests: Update month name check for Greek locale
Update the abbreviated month name in the test to match the actual
translation. Otherwise the test fails with false positive.

Vocabulary:

July (nominative)  - Greek: Ιούλιος (abbreviated: Ιούλ)
Of July (genitive) - Greek: Ιουλίου (abbreviated: Ιουλ)

This is similar to commit 4d215e006e
and commit 7fe793e125.

Closes #1776
2019-05-13 23:11:56 +02:00
Emmanuel Fleury
08f08448ec Fixing g_format_size() on Windows
It seems that the issue went away on current Window systems.

Fix #429
2019-05-13 14:23:57 +02:00
Philip Withnall
9974cec26b glib: Rename G_STDIO_NO_WRAP_ON_UNIX → G_STDIO_WRAP_ON_UNIX
This clarifies the meaning a bit. Don’t change the logic associated with
it. Add a few comments to clarify things further.

Based on work done by Emmanuel Fleury.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes: #77
2019-05-10 12:58:56 +01:00
Kalev Lember
e4bd6dd515 Add autoptr support for GRWLock 2019-05-10 12:48:20 +02:00
Philip Withnall
a1d5395f10 Merge branch 'autoptr-assertions' into 'master'
Various minor cleanups to autoptrs

See merge request GNOME/glib!821
2019-05-08 20:51:58 +00:00
Sebastian Dröge
6ce96382d3 Merge branch 'unicode-12.1' into 'master'
glib: Update Unicode Character Database to version 12.1.0

See merge request GNOME/glib!822
2019-05-08 20:48:41 +00:00
Philip Withnall
5a30f852d6 docs: Improve formatting of g_autoptr() documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-08 21:21:39 +01:00
Philip Withnall
62be3d5d3e tests: Use g_assert_*() in autoptr tests rather than g_assert()
It gives clearer failure messages, and won’t get compiled out when
building with G_DISABLE_ASSERT.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-08 21:21:39 +01:00
Philip Withnall
ae47f0d156 Merge branch 'more-auto-macros' into 'master'
Add g_autoqueue

See merge request GNOME/glib!474
2019-05-08 20:19:43 +00:00
Marco Trevisan (Treviño)
1d96e94070 gmacros: Add g_autoqueue to automatically free queues
This works as g_auto(s)list already does, and allows to create queues that are
fully auto free'd on destruction.
2019-05-08 14:25:24 -05:00
Philip Withnall
64ddd32b79 glib: Update Unicode Character Database to version 12.1.0
Using commands:
```
glib/gen-unicode-tables.pl -both 12.1.0 path/to/UCD
tests/gen-casefold-txt.py 12.1.0 path/to/UCD/CaseFolding.txt \
   > tests/casefold.txt
tests/gen-casemap-txt.py 12.1.0 path/to/UCD/UnicodeData.txt \
   path/to/UCD/SpecialCasing.txt > tests/casemap.txt
```

Using UCD release https://www.unicode.org/Public/zipped/12.1.0/UCD.zip.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-08 13:07:55 +01:00
Philip Withnall
f666502dd2 gdate: Officially mark GTime as deprecated
The documentation has marked it as deprecated for a long time, but not
in a structured way. Use the gtk-doc ‘Deprecated’ tag to mark it as
deprecated.

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

Helps: #1438
2019-05-08 12:09:54 +01:00
Emmanuel Fleury
17fb60c165 Improving code coverage of glib/guniprop.c 2019-05-07 18:31:04 +02:00
Emmanuel Fleury
ae4eea7a39 Formating test cases to the new standards
- Added comments at the begin of each test case
- Changed 'g_assert()' into 'g_assert_xxx()'
- Sorted the 'g_test_add_func()' entries
2019-05-07 18:31:04 +02:00
Emmanuel Fleury
d8cc47831d Getting fullwidth for g_unichar_xdigit(_value)
Fix issue #58.
2019-05-07 18:31:04 +02:00
Sebastian Dröge
9be2ce31d5 Merge branch '1768-strlcat-test-fix' into 'master'
tests: Increase buffer size for g_strlcat() tests

Closes #1768

See merge request GNOME/glib!811
2019-05-02 14:55:36 +00:00
Sebastian Dröge
d5f9b5327a Merge branch 'queue-tests' into 'master'
Get to 100% coverage on GQueue tests

See merge request GNOME/glib!806
2019-05-02 14:51:24 +00:00
Philip Withnall
d5093350f3 gqueue: Remove a redundant branch
queue->tail->next cannot be non-NULL, as pushing onto the end of the
queue is handled by the call to g_queue_push_tail_link() above.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-02 13:53:09 +01:00
Philip Withnall
4f38620b13 tests: Add unit tests for g_queue_push_nth_link()
This should get its branch coverage up to 100%. For completeness’ sake.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-02 13:53:09 +01:00
Philip Withnall
f033948998 tests: Add a test for calling g_queue_clear_full() with a NULL free_func
This improves the branch coverage of gqueue.c a little.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-02 13:53:09 +01:00
Philip Withnall
2aa71ab63b tests: Rearrange assertions in the g_queue_clear_full() test
This makes it a bit clearer that we expect the queue to be empty as a
result of calling g_queue_clear_full(), rather than as a result of any
of the later cleanup.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-02 13:50:38 +01:00
Sebastian Dröge
aaf0a7c943 Merge branch '1713-ucd-12' into 'master'
glib: Update Unicode Character Database to version 12.0.0

Closes #1713

See merge request GNOME/glib!804
2019-05-02 12:49:16 +00:00
Philip Withnall
81ba6e54fe tests: Remove redundant non-NULL checks in g_strlcat() test
The buffer is a local array, not a pointer, so can never be NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-02 13:28:55 +01:00
Philip Withnall
777a6030a6 tests: Add checks for buffer sizing in g_strlcat() tests
Just to ensure we’re passing a valid value for dest_size.

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

Helps: #1768
2019-05-02 13:28:27 +01:00
Philip Withnall
7541085589 tests: Increase buffer size for g_strlcat() tests
There was a buffer overflow on the last g_strlcat() call in the test.

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

Fixes: #1768
2019-05-02 13:27:53 +01:00
Sebastian Dröge
0095056008 Merge branch '1755-revert-gstrfunc' into 'master'
Revert "macros: Try to use the standard __func__ first in G_STRFUNC"

Closes #1755

See merge request GNOME/glib!799
2019-05-02 12:24:15 +00:00
Philip Withnall
22d4a44cd6 Merge branch 'emmanuel.fleury/glib-g_strcanon_documentation_fix' into 'master'
Modified version of !784 — Adding tests cases for a better coverage of glib/tests/strfuncs.c

See merge request GNOME/glib!809
2019-05-01 23:30:07 +00:00
Emmanuel Fleury
4afab02376 Adding tests cases for a better coverage of glib/tests/strfuncs.c 2019-05-02 00:13:25 +01:00
Christian Hergert
b3925ff5e4 glist: code style cleanup for g_list_insert_before()
This makes the g_list_insert_before() follow more closely the guidelines
for GLib, which is to avoid implicit pointer boolean value and to prefer
for over while to improve readability.
2019-05-01 13:01:14 -07:00
Christian Hergert
a4c3feb835 queue: add g_queue_insert_before_link() and g_queue_insert_after_link()
This adds two new helpers that allow for inserting pre-allocated GList
elements to the queue similar to existing helpers. This may be advantagous
in some situations such as statically allocated GList elements.
2019-05-01 13:01:14 -07:00
Christian Hergert
b0132bb64f list: add g_list_insert_before_link()
This adds a new insertion helper using a pre-allocated link which may be
advantagous in some situations such as statically linked GList elements.
2019-05-01 13:01:14 -07:00
Emmanuele Bassi
eb55d6413d Check GCC version before ignoring diagnostic message
The `alloc-size-larger-than` warning is available starting with GCC 7,
and using it in a pragma will generate a warning on older versions of
GCC.
2019-04-30 14:49:00 +01:00
Emmanuele Bassi
6cb6b418bf Add a version check for duplicated-branches warning
The GHashTable code ignores the duplicated-branches GCC warning, but we
need to do a compiler and version check, as either non-GCC compatible
compilers, or older versions of GCC will warn about the unknown pragma
or diagnostic.

If we don't do this while turning warnings into error, we're going to
fail the build unnecessarily.
2019-04-30 14:49:00 +01:00
Emmanuel Fleury
b3eab1deaf Fixing glib/tests/strfuncs.c to conform to new test coding standards 2019-04-30 09:43:01 +02:00
Emmanuel Fleury
95a5f63775 Fix some documentation issue in glib/gstrfuncs.c
Apparently, the documentation of g_strcanon() was not really cristal
clear, so this new code sample try to make it clear the fact that we
are working on the given string and not a copy. Moreover, it provides
a way to keep the original string at once.

Fix #29
2019-04-30 09:43:01 +02:00
Simon McVittie
a537e538be testing: Run tests specified with -p in the order specified
Closes: #1763
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 17:28:55 +01:00
Simon McVittie
48cc3abede testing: Comment that test order with -p is reversed
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 16:12:02 +01:00
Simon McVittie
dfec3c6789 Test what happens when GTestSkipCount is 0 or more than number of tests
Using --GTestSkipCount 0 is the same as omitting it. A skip count
greater than the number of tests is the same as equalling the number
of tests: they are all skipped.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 16:08:55 +01:00
Simon McVittie
bcee67e29c gtestutils: Test the combination of --tap and -p
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 15:54:10 +01:00
Simon McVittie
b24cdffd5c gtestutils: Allow combining --tap with -p
The -p option is documented, and can be used to select and repeat
test-cases. This is particularly useful when debugging a single
failure among a large number of test-cases, or when debugging a
test-case that you suspect influences another test-case by leaking
global state.

Until now, -p was only supported with GLib's default (GLib-specific)
textual output format, and not with the standardized TAP format that
we are now encouraging. If we are considering making TAP the new default
(see glib#1619) it should get feature-equivalence with the current
default.

Because -p allows test-cases to be re-ordered and repeated, and an entry
in the test_paths list can match any number of test-cases (including
zero), we don't know ahead of time how many test-cases we are going to
run. TAP allows the "plan" to be deferred to the end, exactly to support
situations like this.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 15:54:10 +01:00
Simon McVittie
efa56aa957 gtestutils: Test the combination of --tap and --GTestSkipCount
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 15:54:10 +01:00
Simon McVittie
14082191e8 gtestutils: Make --tap compatible with --GTestSkipCount
The undocumented --GTestSkipCount option is internal to the deprecated
gtester tool and rather obscure, but it's straightforward to support
by making G_TEST_LOG_SKIP_CASE produce TAP output similar to what already
happened when we emitted G_TEST_LOG_STOP_CASE with result
G_TEST_RUN_SKIPPED. I might as well do that while I'm looking at the
interaction between the --tap, -p and -s options.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 15:54:10 +01:00
Simon McVittie
88bac46287 gtestutils: Add regression test for combining -s with --tap
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-04-29 15:54:10 +01:00
Philip Withnall
87014c8e97 glib: Update Unicode Character Database to version 12.0.0
Using commands:
   glib/gen-unicode-tables.pl -both 12.0.0 path/to/UCD
   tests/gen-casefold-txt.py 12.0.0 path/to/UCD/CaseFolding.txt \
     > tests/casefold.txt
   tests/gen-casemap-txt.py 12.0.0 path/to/UCD/UnicodeData.txt \
      path/to/UCD/SpecialCasing.txt > tests/casemap.txt
plus some manual additions of the new G_UNICODE_SCRIPT_* symbols to
gunicode.h, guniprop.c and glib/tests/unicode.c.

Using UCD release https://www.unicode.org/Public/zipped/12.0.0/UCD.zip.

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

Fixes: #1713
2019-04-29 14:16:12 +01:00