Commit Graph

5162 Commits

Author SHA1 Message Date
Matthias Clasen
a17bbbc8a3 doc: Update a few links to the Unicode Standard 2016-05-07 12:38:09 -04:00
Chun-wei Fan
2ca496a2e7 glib/gmacros.h: Fix build on C++ mode in Visual Studio
Later Visual Studio versions does not allow one to define known keywords,
even if they are actually not known to the compiler.  Avoid this issue by
checking more conditions before we define inline as __inline:

-We are not building under C++ mode.
-We are on Visual Studio 2013 or earlier.

Where both of these conditions need to hold true.

https://bugzilla.gnome.org/show_bug.cgi?id=765990
2016-05-05 00:44:48 +08:00
Руслан Ижбулатов
210a9796f7 W32: Do not ignore short waits in g_poll
Do the actual wait dance even if wait timeout is < 10ms. Otherwise
we might busyloop.

https://bugzilla.gnome.org/show_bug.cgi?id=764415
2016-04-28 14:22:51 +00:00
Víctor Manuel Jáquez Leal
96c962de22 glib tests: add pthread flag to 'thread' test
Commit 99bdfd1b introduced a direct call to pthreads_setname_np in the
'thread' test case.  Because we are directly calling pthreads functions
from this file now, we need to make sure we link it with the system
thread library flags (as we already do for another file).

https://bugzilla.gnome.org/show_bug.cgi?id=765712
2016-04-28 11:21:52 +02:00
Emmanuele Bassi
41df41550f utils: Compile g_abort() only on Windows
Otherwise it will break the build on non-Windows because of the macro in
the header, and the unconditional use of Windows-only API.

https://bugzilla.gnome.org/show_bug.cgi?id=665446
2016-04-27 14:55:45 +01:00
Руслан Ижбулатов
e47904a26f Use g_abort() instead of abort() where possible
https://bugzilla.gnome.org/show_bug.cgi?id=665446
2016-04-27 13:17:28 +00:00
Руслан Ижбулатов
5974428d25 Add g_abort()
The new g_abort() macro just expands to abort() on systems where abort()
behaves in a sane way. On other systems (read: Windows) it does its best
to emulate a sane abort() behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=665446
2016-04-27 13:17:27 +00:00
Руслан Ижбулатов
e4aaae4ed6 glib: Add 2.50 availibity macros
https://bugzilla.gnome.org/show_bug.cgi?id=665446
2016-04-27 13:17:27 +00:00
Руслан Ижбулатов
999711abc8 gthread: Better fallback for W32 g_get_num_processors()
https://bugzilla.gnome.org/show_bug.cgi?id=748530
2016-04-26 13:52:45 +00:00
Руслан Ижбулатов
e118856430 Add g_system_thread_set_name() implementation for W32 threads
This works by using semi-documented[1] exception to tell the debugger
that a thread needs to have its name changed.

If this exception is not caught and handled by something, it will crash
the process, so we need to set up our own handler in case there's no
debugger attached or the debugger can't handle this type of exception.

Since SEH is not supported by gcc on i686 (at the moment), we need to use VEH
instead. For completeness the MSVC-oriented code still uses SEH, although
there is no reason why it shouldn't work with the VEH variant used by MinGW.

VEH handler has to be set up somewhere (g_thread_win32_init () works nicely)
and removed once it's not needed (g_thread_win32_process_detach () is added
expressly for that purpose). Note that g_thread_win32_process_detach() is
only called when glib is unloaded by FreeLibrary(), not when glib-using
process is terminating.

This exception is known to work with WinDbg, and adding support for it into
GDB proved to be feasible (GDB patch will be sent upstream, eventually).

[1] https://msdn.microsoft.com/en-us/library/xcb2z8hs%28v=vs.71%29.aspx

https://bugzilla.gnome.org/show_bug.cgi?id=747478
2016-04-26 10:40:07 +00:00
Matthias Clasen
99bdfd1bcb Stop using ptrctl for thread names
We now prefer pthread_setname_np when available, and don't
need the linux specific API anymore. Also change the test
for this functionality to use pthread_getname_np.
2016-04-26 06:35:06 -04:00
Alan Coopersmith
28f0160031 gthread: add thread name support on Solaris
https://bugzilla.gnome.org/show_bug.cgi?id=747478
2016-04-26 06:18:34 -04:00
Emmanuele Bassi
a772c28c95 docs: Clean up the GVariant introduction
Fix the example, as well as the consistency in the terms.

https://bugzilla.gnome.org/show_bug.cgi?id=748806
2016-04-13 09:53:00 +01:00
Phillip Wood
38c4e31c8a Fix documentation typos
Character entities are not supposed to be supported by gtk-doc¹ and
fix the spelling of ‘optional’

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

https://bugzilla.gnome.org/show_bug.cgi?id=758174
2016-04-11 23:31:38 -04:00
Bastian Ilsø
985ae37d19 gvariant.c: Elaborate on GVariant concept and its use
Inserts a paragraph in the start of the description
explaining briefly the concept of GVariant as a
variant datatypes using examples and explaining
a few use cases where GVariant can be useful.

https://bugzilla.gnome.org/show_bug.cgi?id=748806
2016-04-11 23:28:46 -04:00
Michael Catanzaro
026368add7 Fix a typo 2016-04-07 08:43:24 -05:00
Bastien Nocera
35bd69202d tests: Fix compilation errors due to Y2K format problems
Newer versions of GCC are particularly verbose in relation to
formatting errors, use GCC pragmas to disable warnings for this
section.

gdatetime.c: In function ‘test_strftime’:
gdatetime.c:1334:3: error: ‘%c’ yields only last 2 digits of year in some locales [-Werror=format-y2k]
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^
gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gdatetime.c:1334:3: error: ‘%g’ yields only last 2 digits of year [-Werror=format-y2k]
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^
gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gdatetime.c:1334:3: error: ‘%x’ yields only last 2 digits of year in some locales [-Werror=format-y2k]
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^
gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gdatetime.c:1334:3: error: ‘%y’ yields only last 2 digits of year [-Werror=format-y2k]
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^
gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’
   "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note that the pragma is outside the function as older versions of GCC
don't support pragma inside functions.

https://bugzilla.gnome.org/show_bug.cgi?id=764575
2016-04-04 15:08:31 +02:00
Bastien Nocera
21ad4c800c gstrfuncs: Add test for g_strjoinv() behaviour
https://bugzilla.gnome.org/show_bug.cgi?id=764092
2016-04-04 15:06:57 +02:00
Bastien Nocera
283c565af6 gstrfuncs: Document the behaviour of g_strjoinv()
The behaviour of g_strjoinv() isn't explicitely explained when the array
contains less than 2 items. This removes the guesswork.

https://bugzilla.gnome.org/show_bug.cgi?id=764092
2016-04-04 15:06:57 +02:00
Benjamin Gilbert
41888493f0 Fix thread safety of g_get_language_names()
https://bugzilla.gnome.org/show_bug.cgi?id=748474
2016-03-26 08:52:40 -04:00
Philip Withnall
58f56b2460 gkeyfile: Clear a variable after freeing it
find_file_in_data_dirs() doesn’t actually clear output_path to NULL on
failure, so this prevents a use-after-free on that (fd == -1) error
path.

Spotted by Coverity (CID: #1352981).
2016-03-21 12:35:25 +00:00
Philip Withnall
d8a7d5f168 gmessages: Clarify documentation for G_LOG_LEVEL_CRITICAL
Clarify that it’s a critical //warning//, not a critical something-else.
2016-03-15 12:30:01 +00:00
Marc-André Lureau
37ebc83f7f win32: use wide-char for constants
Use the appropriate type for comparisons and assignment of wide chars.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=762202
2016-03-15 11:14:57 +01:00
Marc-André Lureau
622748680c win32: fix indentation
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=762202
2016-03-15 11:14:57 +01:00
Marc-André Lureau
5be8cab966 win32: use wcslen() return type
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=762202
2016-03-15 11:14:57 +01:00
Marc-André Lureau
a1bcd1e45a win32: fix off-by-one length check
Laszlo Ersek said: "The length check is off by one (in the safe direction); it
should be (nchars >= 2). The processing should be active for the wide string
L"\r\n" -- resulting in the empty wide string --, I believe."

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=762202
2016-03-15 11:14:57 +01:00
Matthias Clasen
c49b70f61e Trivial whitespace fix 2016-03-14 08:07:50 -04:00
Stephan Hesse
4569161f81 gerror: Mention that g_clear_error can be used with an "empty" GError
It is fine to do:
GError *error = NULL;
g_clear_error (&error);

https://bugzilla.gnome.org/show_bug.cgi?id=762937
2016-03-10 09:11:13 +01:00
Allison Ryan Lortie
7c6141a546 g_get_user_runtime_dir(): ensure directory exists
If the XDG_RUNTIME_DIR environment variable is set, we are being told by
the OS that this directory exists and is appropriately configured
already.  In the fallback case of ~/.cache/, however, the directory may
not yet exist.

Rework the logic of this function a little so that we only check for the
environment variable once.  If it is not set, we will fall back to the
cache directory, and mkdir() it to make sure that it exists.

Meanwhile, remove a statement from the reference documentation that
promises a warning in this case (which has never been true) and replace
it with a statement that applications can rely on the directory
existing.

This change prevents each user of this API from having to check for the
directory for themselves; an example of that can be seen in bug 763274.

https://bugzilla.gnome.org/show_bug.cgi?id=763344
2016-03-09 10:41:17 -05:00
Philip Withnall
37756a06c9 array: Support clearing an empty array with g_array_remove_range()
Previously, calling g_array_remove_range(array, 0, array->len) on an
empty array would result in a precondition failure in
g_array_remove_range(), as the given start index (0), was not strictly
less than the array length (0).

Allow the index to equal the array length, so that zero elements can be
removed from any array. A subsequent check makes sure that the array
length is not overflowed by the index + length.

https://bugzilla.gnome.org/show_bug.cgi?id=763339
2016-03-09 07:50:07 +00:00
coypu
8cdbc7fb2c gdate: Move warning pragma outside of function
Commit 0817af40e8 breaks the build on
older versions of GCC, which don't allow pragma inside functions.

https://bugzilla.gnome.org/761550
2016-03-03 10:51:05 -05:00
Matthias Clasen
5efc8686ee Remove erroneous markup in GError docs 2016-03-02 19:06:49 -05:00
Colin Walters
ad2092bc68 build: Unconditionally dist tapset files
Apparently whoever made the last tarball didn't have `--enable-systemtap`.
Disted files shouldn't depend on build flags.

Also, it is cathartic for me to say tarballs are dumb and we should
just be pulling from git which is what's canonically tracking what's
source code and what's not and we don't need to repeat ourself in
`Makefile.am`.

https://bugzilla.gnome.org/show_bug.cgi?id=762637
2016-02-24 13:44:10 -05:00
Ignacio Casal Quinteiro
7a8abb20ab grand: rand_s is available in mingw64 2016-02-24 11:27:09 +01:00
Hanno Boeck
aead1c046d GVariant text: fix scan of positional parameters
The scanning to find the end of a positional parameter designator in
GVariant text format (e.g. '%i') is currently broken in case the 'end'
pointer is not specified.

The scan is controlled by a somewhat complicated loop that needs to deal
properly with cases like (123, %(ii)) [where '%(ii)' is to be taken
together, but the final ')' not].

This loop missed the case where a format string passed to
g_variant_new_parsed() ended immediately after such a conversion, with a
nul character.  In this case the 'end' pointer is NULL, so the only way
we can find the end is by scanning for nul in the string.

In case of g_variant_new_parsed() [which is what this code was designed
to be used for], the bug is somewhat unlikely in practice: the only way
that a valid text-form GVariant could ever contain a positional
parameter replacement at the end of the string is if this positional
parameter were the only thing being returned.  In that case, the user
would likely have opted for a more direct approach.

Unfortunately, this code is also active in the tokenisation phase of
g_variant_parse(), before positional parameters are rejected as invalid
for that case.  Anyone who calls this function with a nul-terminated
string (and no end pointer) is vulnerable to a crash from malicious user
input.  This can be seen, at the very least with many commandline tools:

  $ dconf write /x '%i'
  Segmentation fault

We fix this problem by searching for the nul character in this case, in
addition to comparing the end pointer.

This problem is almost certainly limited to being able to cause crashes.
The loop in question only performs reads and, in the security-sensitive
case, the token will be quickly rejected after the loop is finished
(since it starts with '%' and the 'app' pointer is unset).  This is
further mitigated by the fact that there are no known cases of GVariant
text format being used as part of a protocol at a privilege barrier.
2016-02-22 08:48:44 -05:00
Emmanuele Bassi
1964a8726b macros: Fix Clang attribute detection
For attributes we have to use __has_attribute().

https://bugzilla.gnome.org/show_bug.cgi?id=761843
2016-02-10 22:37:41 +00:00
coypu
0817af40e8 gdate: Suppress string format literal warning
Newer versions of GCC emit an error here, but we know it's safe.
https://bugzilla.gnome.org/761550
2016-02-08 10:26:58 +01:00
Rico Tzschichholz
927a4ed2f4 gstring: Explictly annotate return-values with (transfer none/full)
https://bugzilla.gnome.org/show_bug.cgi?id=744570
2016-02-02 17:38:05 +01:00
Sébastien Wilmet
f14052461b docs: GRegex: @start_position is in bytes
The start_position arguments are passed to pcre_exec() as the
startoffset, which is in bytes (not characters).

I had recently a doubt about this, so it's better to document it.

https://bugzilla.gnome.org/show_bug.cgi?id=747927
2016-01-28 18:49:28 +01:00
Chun-wei Fan
dfd74a271d gwin32.c: Avoid a GCC warning
Add a pair of braces to make things more clear, to avoid a warning
when -Wparentheses is used.

Reported by Ignacio Casel Quinteiro.
2016-01-28 15:55:11 +08:00
Ignacio Casal Quinteiro
9e805ffd43 winiconv: update to upstream version
To update this code you need to fetch the last version of the code
from: https://github.com/win-iconv/win-iconv

Then you need to ensure 3 things:
 - the line ends are in unix format
 - some of the methods do not expose a const on the prototype
   refer to the commit b8c13a01b6
   on how to fix it
 - fix one uninitialized variable if not yet fixed upstream
   refer to 7e0cb48dee

https://bugzilla.gnome.org/show_bug.cgi?id=761126
2016-01-26 12:55:55 +01:00
Sebastian Geiger
192781d4b5 gregex: improve documentation for g_regex_new 2016-01-24 22:04:33 +01:00
Philip Withnall
8c263008bb build: Calculate ABS_GLIB_RUNTIME_LIBDIR at build time
Rather than calculating it at configure time. This means it can expand
$libdir properly, and use the Make $(realpath) function rather than
invoking the non-portable `readlink -f`.

This fixes problems where `readlink` would be called on an invalid path
(due to a variable not being expanded) and would evaluate to "", which
would then cause things to be installed in the wrong place.

https://bugzilla.gnome.org/show_bug.cgi?id=744772
2016-01-24 14:44:44 +00:00
Iain Lane
476f30a004 regex test: Fix with --with-pcre=internal
We were linking with the wrong path for the internal libpcre, and
furthermore the function pcre_version was declared but never defined.
2016-01-18 18:37:28 +00:00
Iain Lane
9b8a34b5b3 regex test: Assert /(?P<sub>foo)\\g<sub/ changed behaviour at 8.35, not 8.38
https://bugzilla.gnome.org/show_bug.cgi?id=760683
2016-01-18 12:19:12 -05:00
Iain Lane
db90987990 regex test: Check the expected PCRE version at runtime
We might be built against a newer version than we're run against.

https://bugzilla.gnome.org/show_bug.cgi?id=760683
2016-01-18 12:19:12 -05:00
Chun-wei Fan
407a4e9e4e tests: Fix regex test conditions
Commit 855594c changed the expected error for the regex
/(?P<sub>foo)\g<sub/ for PCRE 8.38, but actually PCRE changed the error
raised by this invalid regex in 8.37, so we should check for the new error
from 8.37 and upwards.

Please see comments #21 and #22 of bug 740573 regarding this commit.
2016-01-18 14:08:40 +08:00
Руслан Ижбулатов
b7774b182d Make gnulib vfprintf return the number of bytes actually written
To be honest, i don't remember what problems were caused by it returning the
number of bytes it *wanted* to write instead of the number of bytes
it actually wrote. Probably related to the fact that fwrite could
independently fail, and ignoring its return value ignores that error.

https://bugzilla.gnome.org/show_bug.cgi?id=748064
2016-01-14 15:11:08 +00:00
Simon McVittie
855594c4de regex test: expect ASSERTION_EXPECTED for /(?(?<ab))/ with PCRE 8.38
PCRE 8.38 changed the parsing of this invalid regex. It still fails,
but with a different error (since PCRE r1539,
<http://vcs.pcre.org/pcre?view=revision&revision=1539>).

The regex /(?P<sub>foo)\g<sub/ used to raise MISSING_BACK_REFERENCE but
now raises MISSING_SUBPATTERN_NAME_TERMINATOR, so we can still have a
test for the latter.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Emmanuele Bassi <ebassi@gnome.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=759808
2016-01-14 12:54:25 +00:00
David King
18fe6d8312 docs: add Since for g_str_to_ascii 2016-01-11 09:33:32 +00:00