Commit Graph

5365 Commits

Author SHA1 Message Date
Philip Withnall
90b255ee93 docs: Fix minor cross-linking problem in GVariant documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-29 22:53:44 +01:00
Sébastien Wilmet
f9faac7661 glib/: LGPLv2+ -> LGPLv2.1+
All glib/*.{c,h} files have been processed, as well as gtester-report.

12 of those files are not licensed under LGPL:

	gbsearcharray.h
	gconstructor.h
	glibintl.h
	gmirroringtable.h
	gscripttable.h
	gtranslit-data.h
	gunibreak.h
	gunichartables.h
	gunicomp.h
	gunidecomp.h
	valgrind.h
	win_iconv.c

Some of them are generated files, some are licensed under a BSD-style
license and win_iconv.c is in the public domain.

Sub-directories inside glib/:

	deprecated/: processed in a previous commit
	glib-mirroring-tab/: already LGPLv2.1+
	gnulib/: not modified, the code is copied from gnulib
	libcharset/: a copy
	pcre/: a copy
	tests/: processed in a previous commit

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-24 11:58:19 +02:00
Sébastien Wilmet
95cad9c3e0 glib/tests/: LGPLv2+ -> LGPLv2.1+
There are other tests in glib/tests/ that are licensed under a BSD-style
license, and other tests that don't have any license header.

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-24 11:58:19 +02:00
Sébastien Wilmet
e7a6cd1cb6 glib/deprecated/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-24 11:58:19 +02:00
Daniel Boles
8a12fb47ce array-test: Fix a comment 2017-05-12 10:05:56 +01:00
Krzesimir Nowak
e8222c3343 gstrfuncs: Fix translation issues
The tool that extracts the translatable strings to .po files does not
cope with the G_GUINTX_FORMAT macros, so we preformat the numbers to
strings and use the strings in the translatable error messages.
2017-05-10 16:11:02 +02:00
Krzesimir Nowak
4fe89b0437 gstrfuncs: Add replacement for string-to-number functions
Very often when we want to convert a string to number, we assume that
the string contains only a number. We have g_ascii_strto* family of
functions to do the conversion but they are awkward to use - one has
to check if errno is zero, end_ptr is not NULL and *end_ptr points to
the terminating nul and then do the bounds checking. Many projects
need this kind of functionality, so it gets reimplemented all the
time.

This commit adds some replacement functions that convert a string to a
signed or unsigned number that also follows the usual way of error
reporting - returning FALSE on failure and filling an error output
parameter.
2017-05-10 12:04:03 +02:00
Philip Withnall
b7ffc07d98 tests: Improve error handling for fileutils test
The test_stdio_wrappers() test will spuriously fail if the mkdir-test
directory already exists and is non-empty, which can happen if a
previous test run has failed and left a coredump file in the directory.
Tighten up the error checking around the pre-test rmdir() call to catch
this failure.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782237
2017-05-08 11:19:46 +01:00
Philip Withnall
5c1e85669a tests: Update g_assert()s in fileutils test to be more descriptive
Use the new g_assert_{non,}null(), g_assert_cmpint(), g_assert_true(),
etc., to get more descriptive output when the tests fail.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782237
2017-05-07 20:18:30 +01:00
Philip Withnall
f9a6a9ba53 gtimer: Handle gmtime() failure in g_time_val_to_iso8601()
g_time_val_to_iso8601() has a limit to the future dates it can convert,
imposed by what gmtime() can fit in its year field. If gmtime() fails,
gracefully return NULL from g_time_val_to_iso8601() rather than trying
to dereference the NULL structure and crashing.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782075
2017-05-05 11:41:37 +01:00
Philip Withnall
9374ecc3cb gdatetime: Fix overflow checks when constructing from timestamps
GDateTime does overflow checks to see if the timestamp being passed in
is too big to be represented. However, it only does those after
converting from a timestamp to an interval, which involves some
multiplications and additions — and hence can overflow, and cause the
later bounds check to erroneously succeed. This results in a non-NULL
GDateTime being returned which represents completely the wrong date.

Fix the overflow checks (do them earlier) and add some unit tests.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782089
2017-05-05 10:51:08 +01:00
Philip Withnall
b1cd3378fb gdatetime: Remove an unnecessary NULL pointer check
datetime->tz can never be NULL, so this pointer check is unnecessary and
confusing, and messes up static analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=732000
2017-05-02 23:42:16 +01:00
Philip Withnall
404c2d2454 ghash: Document that GHashTable is not suitable for static hash tables
Instead, gperf should be used for that kind of thing.

Inspired by http://stackoverflow.com/q/42372382/2931197.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-02 16:59:50 +01:00
Philip Withnall
f6f6b3d83c garray: Add g_ptr_array_find[_with_equal_func]()
Partially based on telepathy-glib’s tp_g_ptr_array_contains(), and a
patch by Xavier Claessens <xavier.claessens@collabora.co.uk>.

Test cases included.

https://bugzilla.gnome.org/show_bug.cgi?id=698064
2017-05-02 16:54:41 +01:00
Philip Withnall
42a8e952ef gtimer: Whitespace fixes
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-02 16:02:30 +01:00
Krzesimir Nowak
070383ca36 gvariant: Fix the max unsigned 64-bit integer value
It should be 2^64-1, not just 2^64.

Reviewed-by: Philip Withnall <philip@tecnocode.co.uk>
2017-05-02 15:02:44 +02:00
Philip Withnall
d21fb0ed3c docs: Add an example for using the g_spawn_*() APIs
And clarify that you must add a child watch or *not* use the
G_SPAWN_DO_NOT_REAP_CHILD flag, otherwise your child will become a
zombie on exit, and will not be reaped until the parent process exits.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2017-04-30 09:41:35 +01:00
Philip Withnall
b63469d726 docs: Fix (nullable) (optional) annotations
There are a few places where commit 18a33f72 replaced valid (nullable)
(optional) annotations with just (optional). That has a different
meaning.

(nullable) (optional) can only be applied to gpointer* parameters, and
means that both the gpointer* and returned gpointer can be NULL. i.e.
The caller can pass in NULL to ignore the return value; and the returned
value can be NULL.

(optional) can be applied to anything* parameters, and means that the
anything* can be NULL. i.e. The caller can pass in NULL to ignore the
return value. The return value cannot be NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-28 12:32:12 +01:00
Krzesimir Nowak
75cd848ea8 gvariant: Fix some typos in documentation
Reformatted the docs for G_VARIANT_TYPE_UINT64 to avoid having a
number in the beginning of the line, because apparently gtk-doc treats
that as a first element of the numbered list. The number being that
big probably makes gtk-doc to treat it as 1.

Fixed the g_variant_new_fixed_array documentation - it was partially
copy-pasted from the g_variant_get_fixed_array documentation.

The rest should be quite obvious.

https://bugzilla.gnome.org/show_bug.cgi?id=781830
2017-04-27 15:44:08 +01:00
Philip Withnall
281e301036 gmain: Allow GSource methods to be called from a finalize() callback
Temporarily increase the ref count of a GSource to 1 while calling its
finalize() callback, so that the finalize() implementation can call
GSource methods (like g_source_set_ready_time()) without causing
critical warnings. It’s safe to call those methods at this point, as the
source has been destroyed, but nothing has been freed.

This is an indirect way of fixing a race between GCancellable and
GCancellableSource, whereby the GCancellable::cancelled callback for the
GCancellableSource is not disconnected until the GCancellableSource’s
finalize() function is called. Previously, this meant there was a window
in which the GCancellableSource’s ref count was 0, but the ::cancelled
callback was still connected, and could legitimately be called as a
result of another thread calling g_cancellable_cancel() on the
GCancellable. The callback calls g_source_set_ready_time() on the
GSource, and there’s no thread-safe way of checking whether the GSource
has been destroyed. Instead, we have to change GSource so its ref count
is only decremented to 0 inside the locked section in
g_source_unref_internal() *after* the finalize() function has been
called, and hence after the GCancellable::cancelled callback has been
disconnected. The use of g_cancellable_disconnect() ensures that the
callback disconnection is thread safe.

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

https://bugzilla.gnome.org/show_bug.cgi?id=781601
2017-04-25 10:21:04 +01:00
Philip Withnall
e8487812b9 gmessages: Fix documentation formatting 2017-04-18 11:58:28 +01:00
John Lindgren
7641cf29e3 Do not mix declarations with code.
https://bugzilla.gnome.org/show_bug.cgi?id=781298
2017-04-14 05:24:48 +00:00
Paolo Bonzini
9ba95e25b7 gmain: only signal GWakeup right before or during a blocking poll
Since commit e4ee307 ("Do not wake up main loop if change is from same
thread", bug 761102), GMainContext uses context->owner to decide if the
event loop is being run in the current thread.  However, what really
matters is the phase in the prepare/query/poll/check/dispatch sequence.
Wakeups are only needed between the end of prepare and the end of poll,
and then only if prepare found that no sources were ready.

There is no need to take threads into account, because prepare, check
and all callers of conditional_wakeup all look at the new need_wakeup
flag inside LOCK_CONTEXT/UNLOCK_CONTEXT.

With this change, g_main_context_is_owner and g_main_context_wait are
the only functions for which acquire/release matters, just like before
commit e4ee307.

Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
2017-04-11 13:27:31 -04:00
Paolo Bonzini
0c0469b56d gmain: Signal wakeups if context has never been acquired as well
Should address backwards compatibility with how qemu is using
`GMainContext`.

See https://bugzilla.gnome.org/show_bug.cgi?id=761102#c14

Input-into-keyboard-by: Colin Walters <walters@verbum.org>
2017-04-11 11:49:32 -04:00
Philip Withnall
a5b58da6bf gfileutils: Add precondition checks to g_file_test()
Otherwise g_file_test(NULL, …) causes a call to access(NULL, …) on
Linux, which is disallowed and valgrind complains about it.

https://bugzilla.gnome.org/show_bug.cgi?id=755046
2017-04-08 01:16:04 -04:00
Jan Alexander Steffens (heftig)
47a02c8561 g_unix_signal_source_new: Add SIGWINCH
Assume this won't go into 2.52 anymore, so say it was added in 2.54.

https://bugzilla.gnome.org/show_bug.cgi?id=769534
2017-04-08 01:02:31 -04:00
Christoph Reiter
5067d25a74 gwin32: Remove old win32 codepage ABI compat code
Makes new code link against the normal symbol names again.
Variants with utf8 suffix are there for existing binaries/ABI compat.

https://bugzilla.gnome.org/show_bug.cgi?id=780634
2017-04-06 19:25:09 +02:00
Christoph Reiter
23dffdd949 gspawn: Remove old win32 codepage ABI compat code
Makes new code link against the normal symbol names again.
Variants with utf8 suffix are there for existing binaries/ABI compat.

https://bugzilla.gnome.org/show_bug.cgi?id=780634
2017-04-06 19:24:00 +02:00
Christoph Reiter
fad5f5bd17 giochannel: Remove old win32 codepage ABI compat code
Makes new code link against the normal symbol names again.
Variants with utf8 suffix are there for existing binaries/ABI compat.

https://bugzilla.gnome.org/show_bug.cgi?id=780634
2017-04-06 19:22:43 +02:00
Christoph Reiter
d1528402ab gfileutils: Remove old win32 codepage ABI compat code
Makes new code link against the normal symbol names again.
Variants with utf8 suffix are there for existing binaries/ABI compat.

https://bugzilla.gnome.org/show_bug.cgi?id=780634
2017-04-06 19:21:20 +02:00
Christoph Reiter
b67d071321 genviron: Remove old win32 codepage ABI compat code
Makes new code link against the normal symbol names again.
Variants with utf8 suffix are there for existing binaries/ABI compat.

https://bugzilla.gnome.org/show_bug.cgi?id=780634
2017-04-06 19:19:20 +02:00
Christoph Reiter
d43b3d889a gdir: Remove old win32 codepage ABI compat code
Makes new code link against the normal symbol names again.
Variants with utf8 suffix are there for existing binaries/ABI compat.

https://bugzilla.gnome.org/show_bug.cgi?id=780634
2017-04-06 19:17:56 +02:00
Christoph Reiter
713788413d gconvert: Remove old win32 codepage ABI compat code
Makes new code link against the normal symbol names again.
Variants with utf8 suffix are there for existing binaries/ABI compat.

https://bugzilla.gnome.org/show_bug.cgi?id=780634
2017-04-06 19:17:03 +02:00
Philip Withnall
1b64ddb933 gvariant: Minor documentation tweak for g_variant_get_fixed_array()
Add a missing clausal comma, and add some backtick formatting.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-04 15:10:01 +01:00
Colin Walters
2087024049 main: Create a helper function for "owner wakeup" optimization
The original patch really should have introduced a helper - among
other things it deserves a code comment.  We're likely to make
further changes too, so it's obviously better to only do it in one
place.

See: https://bugzilla.gnome.org/show_bug.cgi?id=761102
2017-04-03 13:28:13 -04:00
Cosimo Cecchi
69e448bc28 datetime: add fallback logic for AM/PM specifier
When the locale does not provide any string for AM/PM, fallback to the
default.

https://bugzilla.gnome.org/show_bug.cgi?id=761889
2017-04-03 08:31:37 -07:00
Cosimo Cecchi
6e192588e0 datetime: don't conflate heap/non-heap allocations in same variable
Use an extra variable instead of casting out the const specifier.

https://bugzilla.gnome.org/show_bug.cgi?id=761889
2017-04-03 08:31:28 -07:00
Cosimo Cecchi
62edcf03d3 datetime: factor out fallback AM/PM function
We will reuse this.

https://bugzilla.gnome.org/show_bug.cgi?id=761889
2017-04-03 08:13:19 -07:00
Cosimo Cecchi
9163306de2 datetime: factor out a common function
The 'p' and 'P' cases are exactly the same, except for one line. Factor
out a common function for both.

https://bugzilla.gnome.org/show_bug.cgi?id=761889
2017-04-03 08:13:16 -07:00
Philip Withnall
21b6b1fba7 gmessages: Don’t check G_MESSAGES_DEBUG in old logging API
Now that the old logging API forwards through to the new structured
logging API, we don’t need to check the level or domain of a message
against INFO_LEVELS or G_MESSAGES_DEBUG — just pass it straight through
to the new structured logging API writer function.

https://bugzilla.gnome.org/show_bug.cgi?id=775879
2017-03-24 15:08:16 +00:00
Philip Withnall
aebcb15a9b gversionmacros: Add version macros for GLib 2.54
Let the new API season commence.
2017-03-23 16:21:28 +00:00
Philip Withnall
b3362bb834 ghash: Document order of parameters in GEqualFunc usage
See https://bugzilla.gnome.org/show_bug.cgi?id=698064#c15.
2017-03-23 15:55:31 +00:00
Philip Withnall
fb5a07ad39 ghash: Fix gtk-doc syntax in a documentation comment 2017-03-23 15:55:05 +00:00
Philip Withnall
35c0dd2755 gbase64: Fix base-64 stepped encoding with small chunks
If encoding with small chunks such that the call to
g_base64_encode_close() has to deal with 0 < x < 24 bits of remaining
state, the encoding code would not correctly use zeroes to pad out the
state — it would use left-over state from an earlier iteration in the
encoding process.

This resulted in invalid base-64 encodings.

Add a unit test for incremental encoding using different sized chunks
too.

Thanks to Rainier Perske for reporting and analysing the bug.

https://bugzilla.gnome.org/show_bug.cgi?id=780066

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-03-23 15:34:11 +00:00
Philip Withnall
32aae79db5 gmain: Document that set_ready_time() is safe on destroyed GSources
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=778049
2017-03-23 15:07:49 +00:00
Philip Withnall
c408256b52 gmain: Document threading properties of g_source_is_destroyed()
https://bugzilla.gnome.org/show_bug.cgi?id=778049
2017-03-23 15:03:13 +00:00
Daniel Macks
929e1b1fde Do not build utf8_encode on CARBON platform
utf8_encode is not used by g_utf8_collate_key on this platform.

https://bugzilla.gnome.org/show_bug.cgi?id=780306
2017-03-21 08:43:43 +00:00
Philip Withnall
69b4c72fe5 gutf8: Clarify documentation for g_utf8_get_char_validated()
There is no such thing as ‘no maximum’ when reading a string. It’s got
to end somewhere.

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

https://bugzilla.gnome.org/show_bug.cgi?id=780095
2017-03-20 11:07:48 +00:00
Philip Withnall
1c56a87c08 gutf8: Clarify return values from g_utf8_get_char_extended()
It’s hard to remember what the difference is between -1 and -2, so give
them names.

This introduces no functional changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=780095
2017-03-20 11:07:48 +00:00
Philip Withnall
e6e38f4b8a gbase64: Document that g_base64_encode_close() does not nul-terminate
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-03-17 11:33:13 +00:00