Commit Graph

5326 Commits

Author SHA1 Message Date
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
Javier Jardón
4e78a0a9df Revert "Use upstream gettext instead the glib one"
This causes several problems:
- Compilation in FreeBSD with --enable-gtk-doc broke
- Modules that still use the AM_GLIB_GNU_GETTEXT macro
  doesnt compile anymore because /usr/share/glib-2.0/gettext
  is not filled with the correct files, as this was done in
  the glib custom po/Makefile.in.in

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

This reverts commit e5c752371c.
2016-01-10 22:44:24 +00:00
Javier Jardón
e5c752371c Use upstream gettext instead the glib one
https://bugzilla.gnome.org/show_bug.cgi?id=622991
2016-01-09 18:49:22 +00:00
Christophe Fergeau
b6edac5aca glib: Clarify g_warn_if_reached API doc
Its documentation mentions that it logs a 'critical warning', but since
the macro implementation calls g_warn_message(), it does not log a
critical message, but a regular warning.
2016-01-07 15:21:04 +01:00
Stephan Bergmann
b44fba25fb G_LIKELY/_UNLIKELY macros need more parentheses
...for cases like

  #include "glib.h"
  #define COMMA ,
  void f(void) { if (G_LIKELY(0 COMMA 1)); }

https://bugzilla.gnome.org/show_bug.cgi?id=760215
2016-01-06 10:33:04 -05:00
Chun-wei Fan
786b4c8b87 gwin32.c: Fix build on MinGW
Apparently unlike mingw-w64 and Visual Studio, MinGW does not come with
winternl.h, which defines NTSTATUS, so we need to include ntdef.h instead
on MinGW for NTSTATUS.

Based on patch by Cédric Krier.

https://bugzilla.gnome.org/show_bug.cgi?id=756875
2016-01-05 15:15:38 +08:00
Philip Withnall
30788dff5b gutf8: Fix typo in GIR annotation for g_utf8_to_ucs4() 2015-12-23 16:48:10 +00:00
Christian Hergert
3272267b99 macros: add G_GNUC_CHECK_VERSION() for compiler checks.
https://bugzilla.gnome.org/show_bug.cgi?id=728099
2015-12-16 07:47:53 -05:00
Ryan Lortie
aa16359986 Stop supporting non-POSIX getpwuid_r, getgrgid_r
Bug 13403 introduced support for the non-POSIX variants of these APIs
found on a system called "DG/UX".  Meanwhile, the complicated checks
here are breaking cross-builds on systems that we actually care about.

Remove the complicated checks and replace them with AC_CHECK_FUNCS.
Remove the resulting dead code from a couple of .c files.

https://bugzilla.gnome.org/show_bug.cgi?id=756475
2015-12-16 07:47:53 -05:00
Marius Gedminas
c935237e75 glib.py: Fix Python 3 TypeError in gdb pretty-printers
https://bugzilla.gnome.org/show_bug.cgi?id=749092
2015-12-15 19:40:43 -05:00
Matthias Clasen
61136c2c73 Trivial doc comment fix
Use the same Since: syntax throughout.
2015-12-14 07:43:24 -05:00
Chun-wei Fan
cfdd4cabe7 glib/glibconfig.h.win32.in: Clean up a bit further
Also get rid of the items regarding G_HAVE_*INLINE as they aren't used
anymore as they are removed from configure.ac.

Thanks to John Emmas and desrt for the earlier patch for getting
rid of the C4005 warnings.
2015-11-30 11:22:17 +08:00
Allison Ryan Lortie
f2fb877ef7 glibconfig.h.win32.in: remove G_CAN_INLINE
We now define this unconditionally in gmacros.h.

Thanks to John Emmas for the tip.

https://bugzilla.gnome.org/show_bug.cgi?id=757374
2015-11-27 11:31:41 -05:00
Allison Ryan Lortie
ec6971b864 gtypes.h: move G_STATIC_ASSERT to function scope
It seems that some compilers get upset if this is done at global scope,
so let's move it to function scope where we know it works.
2015-11-27 11:27:51 -05:00
Allison Ryan Lortie
a266ac62ea tests: fix a test on 32-bit builds
We were trying to squeeze 64-bit test vectors into gsize, which is fine
on 64bit systems but doesn't work very well on 32-bit.

Change that to a guint64.
2015-11-26 09:26:45 -05:00
Allison Ryan Lortie
ba12fbf8f8 gutils: g_bit_ inlines: add visibility macros
My careful efforts to preserve the exporting of these symbols on our ABI
was thwarted by our symbol visibility filtering.  Let's fix that.
2015-11-25 08:48:53 -05:00
Allison Ryan Lortie
7bc6f021d7 gmacros: fix unguarded use of __STDC_VERSION__
According to the C spec, any undefined identifier used in a #if
expression is taken to have a numerical value of zero.

Commit db2367e878 introduced an #i
statement which depended on this behaviour.

gcc has a -Wundef option which warns about depending on this behaviour,
and unfortunately there are projects that are using -Werror=undef in
builds that include our headers.

Adding a check for defined(__STDC_VERSION__) before using the macro is
enough to silence gcc.
2015-11-17 13:43:49 -05:00
Dan Winship
f87e002313 Fix g_strerror() on non-glibc
When using one of the codepaths that copies the error string into buf,
make sure the string gets strdup() afterward.

https://bugzilla.gnome.org/show_bug.cgi?id=758194
2015-11-16 16:57:38 -05:00
Allison Ryan Lortie
db2367e878 GLib: clean up the "inline" mess once and for all
It's been a long time since we've been unconditionally saying "static
inline" in GLib headers without complaints so it's safe to assume that
all compilers that we care about support this.

One thing that is not yet totally supported is the unadorned use of the
word "inline".  Depending on the flags (-std=c89, for example), even GCC
will complain about this.  Detect missing C99 support and define
"inline" to "__inline" in that case.  Some research shows "__inline"
appears to be the most widely-supported keyword here, but we may need to
tweak this if we get some reports of breakage.

Clean up all of the configure checks around this and define G_CAN_INLINE
unconditionally.  Unfortunately, we must assume that some people are
still using G_IMPLEMENT_INLINES, we must continue to implement that
(including undefining G_CAN_INLINE and redefining G_INLINE_FUNC) if
requested.

It is not our intent to break existing users of the old-style
G_INLINE_FUNC approach and if that has happened, we may need to make
some further adjustments.

https://bugzilla.gnome.org/show_bug.cgi?id=757374
2015-11-16 13:14:19 -05:00
Allison Ryan Lortie
9834f79279 gutils: clean up bit funcs inlining mess
gutils.h and gutils.c define three utility functions as inlines that are
also exported via the ABI.  This is done via complicated G_INLINE_FUNC
and G_IMPLEMENT_INLINES logic.

In order to be able to remove this mess, we create a another convoluted
but slightly cleaner approach: write straight-up inline versions of the
functions named _impl() in the header.  Define macros with the "public"
function names that call these inlines.  From the .c file, export the
ABI versions of these functions, implemented using the _impl() version.

https://bugzilla.gnome.org/show_bug.cgi?id=757374
2015-11-16 13:14:19 -05:00
Allison Ryan Lortie
0bfbb0d257 GTrashStack: uninline and deprecate
Deprecate GTrashStack and remove the inline implementations for the
functions.  This will help us clean up the mess that is inline functions
in GLib.

Because of how G_INLINE_FUNC worked, we have these functions on our ABI,
so we must continue to export them as normal functions.  We are safe to
remove the inline versions, however, because any existing binaries will
continue to carry them and any new builds will just start using the
non-inline versions.

https://bugzilla.gnome.org/show_bug.cgi?id=757374
2015-11-16 13:14:19 -05:00
Chun-wei Fan
db4df9908e gconstructor: Work around constructors being optimized away on MSVC
Whole program optimization is enabled by default in visual studio
release builds, and this causes constructors (for e.g. resources) to be
optimized away as they are not referenced from elsewhere.

This works around this by some pragma magic.

https://bugzilla.gnome.org/show_bug.cgi?id=752837
2015-11-12 15:01:54 +08:00
Mikhail Zabaluev
0a10d38d15 Return value of g_hash_table_get_{keys,values} is (transfer container)
https://bugzilla.gnome.org/show_bug.cgi?id=757742
2015-11-07 18:55:17 +02:00
Mikhail Zabaluev
42463b840f ghash: Correctly annotate (nullable) and (out) parameters
https://bugzilla.gnome.org/show_bug.cgi?id=757742
2015-11-07 18:55:17 +02:00
Philip Withnall
779b5c9af0 gtestutils: Fix a function name in a documentation example 2015-11-07 13:55:24 +01:00
Philip Withnall
25a7c817d3 glib: Add missing (nullable) and (optional) annotations
Add various (nullable) and (optional) annotations which were missing
from a variety of functions. Also port a couple of existing (allow-none)
annotations in the same files to use (nullable) and (optional) as
appropriate instead.

Secondly, add various (not nullable) annotations as needed by the new
default in gobject-introspection of marking gpointers as (nullable). See
https://bugzilla.gnome.org/show_bug.cgi?id=729660.

This includes adding some stub documentation comments for the
assertion macro error functions, which weren’t previously documented.
The new comments are purely to allow for annotations, and hence are
marked as (skip) to prevent the symbols appearing in the GIR file.

https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-11-07 10:48:32 +01:00
Dan Winship
751d3f00a8 Update .gitignore for overflow tests 2015-11-05 09:42:36 -05:00
Jan de Groot
4d74ca4c3a Make gtester-report compatible with Python 3
Convert tabs to spaces and replace print with print().
The script still works with Python 2.x.

https://bugzilla.gnome.org/show_bug.cgi?id=696324
2015-11-05 12:53:19 +01:00
Mikhail Zabaluev
0dbc81c73a Move G_POLLFD_FORMAT to glibconfig.h
It's a platform-specific macro, so it belongs in glibconfig.h.
This ensures that g-ir-scanner will not pick the wrong definition
for introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=757294
2015-11-02 20:03:38 +02:00
Xavier Claessens
df352203d6 Stop using g_sequence_get_length() to check if it's empty
g_sequence_is_empty() is more efficient for that task.

https://bugzilla.gnome.org/show_bug.cgi?id=756988
2015-10-30 11:35:28 -04:00
Xavier Claessens
2bc32606c7 GSequence: document that _get_length() is not O(1)
https://bugzilla.gnome.org/show_bug.cgi?id=756988
2015-10-30 11:35:27 -04:00
Xavier Claessens
2331437df3 Doc: fix some gtk-doc warnings
https://bugzilla.gnome.org/show_bug.cgi?id=755364
2015-10-30 10:30:55 -04:00
Allison Ryan Lortie
7dd9ffbcff tests: test bounds-checked int arithmetic
Add some simple testcases for the new bounds-checked integer arithmetic
helpers.

Include a second build of the testcase to make sure we test the fallback
code even if we are on a compiler that supports the intrinsics.

https://bugzilla.gnome.org/show_bug.cgi?id=503096
2015-10-30 11:58:49 +01:00
Allison Ryan Lortie
d0219f2597 GLib: add bounds-checked unsigned int arithmetic
Add some helpers for builds-checked unsigned integer arithmetic to GLib.
These will be based on compiler intrinsics where they are available,
falling back to standard manual checks otherwise.

The fallback case needs to be implemented as a function (which we do
inline) because we cannot rely on statement expressions.  We also
implement the intrinsics case as an inline in order to avoid people
accidentally writing non-portable code which depends on static
evaluation of the builtin.

For now there is only support for addition and multiplication for guint,
guint64 and gsize.  It may make sense to add support for subtraction or
for the signed equivalents of those types in the future if we find a use
for that.

https://bugzilla.gnome.org/show_bug.cgi?id=503096
2015-10-30 11:58:49 +01:00
Allison Ryan Lortie
89bda59170 macros: add dummy __has_builtin()
Add a dummy definition for Clang's __has_builtin() macro.  This will
allow us to use __has_builtin() unconditionally, in the same way as we
already do for __has_feature().

https://bugzilla.gnome.org/show_bug.cgi?id=503096
2015-10-30 11:58:49 +01:00
Chun-wei Fan
d52625a94a gwin32.c: Fix g_win32_check_windows_version() on 32-bit
The Windows API function RtlGetVersion() is actually a function that is
decorated by WINAPI (i.e. __stdcall), so we need to correct this so that
the symbol can be loaded correctly from ntdll.dll, so that we won't crash as
a result.  Should fix the crash due to stack overflow on 32-bit builds.

https://bugzilla.gnome.org/show_bug.cgi?id=756179
2015-10-27 09:28:10 +08:00
Chun-wei Fan
556705cb9c gwin32.c: Fix build on Visual Studio
ntdef.h is a header that is normally only shipped with MinGW, not Visual
Studio, which broke the build in commit 975cb91.  Fix this by including
winternl.h, which typedef's the NTSTATUS type in question on both Visual
Studio and MinGW/mingw-w64, as well as pre-2008 Visual Studio.

Clean up this inclusion part a little bit as well.
2015-10-24 11:05:27 +08:00
Dan Winship
af0a47701d gtypes.h: fix G_MAXUINT64 definition to use G_GUINT64_CONSTANT
(Noticed as part of https://bugzilla.gnome.org/show_bug.cgi?id=756550)
2015-10-23 11:38:31 -04:00
Ignacio Casal Quinteiro
50d704ab8f win32: make sure bytes_read/written is set to 0 on error
If we fail to PeekMessage or PostMessage we should make sure
that the output parameter bytes_read/written is set 0 instead
of being left uninitialized. This fixes an assertion in the io
channel call where the following invariant is checked:
(status == G_IO_STATUS_NORMAL) || (read_size == 0)
2015-10-23 10:34:50 +02:00
Robert Ancell
31c45cb6ae gkeyfile: Handle whitespace after boolean values
Ignore trailing whitespace when reading boolean values. Currently it is
very easy to manually edit a keyfile to be:

[section]
key=true_

Where '_' is a space character. g_key_file_get_boolean will read this value as
false and this is hard for a user to detect (it will be reported in GError
as an invalid value).

Trailing whitespace is ignored for numbers for the same reason. This was
fixed in 7a45dde4fe.

https://bugzilla.gnome.org/show_bug.cgi?id=664740
2015-10-21 15:26:53 +13:00
Robert Ancell
51ed0f0405 gkeyfile: Test that whitespace is allowed after numbers
Test that whitespace is allowed after numbers - this was fixed in
commit 7a45dde4fe.
2015-10-21 15:26:17 +13:00
Sebastian Dröge
975cb91085 win32: Include ntdef.h for NTSTATUS
https://bugzilla.gnome.org/show_bug.cgi?id=756875
2015-10-20 20:47:07 +03:00
Ryan Lortie
419f57137a GDateTime test: fix occasional failures
We were using the time() library call to get the current time from the
system in order to compare it to the time returned by
g_date_time_new_now().

Of course, we took care to ensure that the time (in seconds) didn't
change in the middle of this process by checking the before and after
value of the system time.

Unfortunately, the system time as measured by time() was being taken
from a less-accurate clock source than the time used by GDateTime.  As a
result, we could have GDateTime already into the next second while the
"seconds" value of the time returned by time() was still in the last
one, even when checked "after".

Avoid the problem by using the same ultimate source for time --
g_get_real_time().

This is based on a similar patch from Iain Lane, but it uses
g_get_real_time() instead of g_get_current_time().

https://bugzilla.gnome.org/show_bug.cgi?id=754994
2015-10-16 12:10:50 +01:00
Mikhail Zabaluev
75eaf5091c g_main_context_query(): Annotate @n_fds as (in) parameter
The default is picked up as (out), which is bogus.

https://bugzilla.gnome.org/show_bug.cgi?id=756099
2015-10-15 23:57:06 +03:00
Mikhail Zabaluev
05aafe2cff gtypes.h: Make G_MININTn literals negative
This is more friendly to the GIR scanner; with previous definitions,
the constant values end up out of range for their stated integer type.

https://bugzilla.gnome.org/show_bug.cgi?id=756550
2015-10-15 23:47:04 +03:00
Christian Hergert
01baf39685 sequence: fix style issue in previous commit
Use g_assert_true() rather than integer comparison in sequence unit test.
2015-10-15 13:07:27 -07:00
Christian Hergert
8fccf8e4e3 sequence: add g_sequence_is_empty()
This function provides an O(1) check to determine if a sequence is empty.
Compare this to the two following alternatives to perform the same check.

O(h):  if (0 == g_sequence_get_length (seq))
O(2h): if (g_sequence_get_begin_iter(seq) == g_sequence_get_end_iter(seq))

Where `h' is the height of the tree.

https://bugzilla.gnome.org/show_bug.cgi?id=756316
2015-10-15 12:54:09 -07:00
Ignacio Casal Quinteiro
0b84596f6e gnulib: forgot some changes from HAVE_LONG_LONG_INT to HAVE_LONG_LONG
https://bugzilla.gnome.org/show_bug.cgi?id=756382
2015-10-15 17:42:02 +02:00
Ignacio Casal Quinteiro
212e4232e7 Update gnulib
It updates it to the version c5d07ce91a8ad51591154450442fa4376441fdfa
As a difference with upstream we need to ensure:
 * Include "g-gnulib.h" so the methods get the gnulib namespace.
 * xsize.h uses G_MAXSIZE instead of SIZE_MAX and the methods are
   marked as static inline.
 * Some defines are named different from the ones in glib i.e
   HAVE_LONG_LONG_INT is HAVE_LONG_LONG

All the unit tests pass properly with and without --enable-included-printf.
It has also been tested on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=756382
2015-10-15 14:54:42 +02:00
Ignacio Casal Quinteiro
fb9df27776 Change message system to use fputs instead of write
By default g_log_default_handler always assumes that stdout
and stderr are file descriptors 1 and 2. On Win32 this isn't
always the case as the win32 API functions AttachConsole and
freopen can be used to dynamically attach GUI applications to
a console and the file descriptors of stderr and stdout will
become different than 1 and 2.

Fix it by using fputs with the FILE directly instead of
using the file descriptors.

https://bugzilla.gnome.org/show_bug.cgi?id=692085
2015-10-08 17:32:29 +02:00
Emmanuele Bassi
99ff9bb5e0 Maintain the struct order when initializing
Otherwise it'll break every GLIB_PRIVATE_CALL user.
2015-10-08 12:32:58 +01:00
Philip Withnall
0cc8c0f3e1 gerror: Add (optional) annotation to g_propagate_error()
Also clarify in the documentation that @src must be non-%NULL.
2015-10-08 11:16:02 +01:00
Philip Withnall
2e078f1fc0 gstrfuncs: Add missing annotations to g_[ascii_]strto*() functions
Add missing (out) (transfer none) (optional) annotations to g_strtod(),
g_ascii_strtod(), g_ascii_strtoull() and g_ascii_strtoll().
2015-10-08 11:10:39 +01:00
Matthias Clasen
e0dce8a9ae Export glib_init via GLIB_PRIVATE_CALL
This will be used in the next commit to call glib_init from the
gobject constructor, to ensure proper constructor ordering with
non-GNU libc.

https://bugzilla.gnome.org/show_bug.cgi?id=756139
2015-10-07 23:39:29 -04:00
Matthias Clasen
342d329685 Make glib_init safe to call more than once
This will be needed to fix constructor order for non-GNU libc.

https://bugzilla.gnome.org/show_bug.cgi?id=756139
2015-10-07 23:39:29 -04:00
Chun-wei Fan
46a20470fa gwin32.c: Avoid deprecated Win32 API usage
The VerifyVersionInfo() Win32 API has been deprecated in Windows 10, and
there is no direct replacement for it, except by using a lower-level
RtlGetVersion() that we aquire from the Windows DDK or from ntdll.dll.

Switch g_win32_check_windows_version() to use RtlGetVersion(), and
compare its results with the input parameters.

https://bugzilla.gnome.org/show_bug.cgi?id=756179
2015-10-07 20:46:31 +08:00
Marc-André Lureau
f91d1a2a76 docs: misc spelling 2015-10-05 15:33:05 +02:00
Marc-André Lureau
dabf662788 testutils: remove internal ABI comment
Some testutils external symbols are marked semi-internals, other
internals. It is not obvious what guarantees these symbols provide.
However, tests are now installable, and require the ABI stability
that glib provides for the rest of the symbols.

In my case, I would like to introduce g_assert* compat code for older
glib versions, and be able to use the so-called "internal" ABI.

I propose this change to the headers comments to explain the stability
guarantees. Removing the "internal" = you must not use this, in favor
of semi-internal = this is not documented.

https://bugzilla.gnome.org/show_bug.cgi?id=756077
2015-10-05 15:32:41 +02:00
Matthias Clasen
f9d9f9c056 Update to Unicode 8.0
Regenerate data tables from the Unicode Character Database, add
new scripts, and update tests to include some of the new data.
2015-10-04 10:24:06 -04:00
Philip Withnall
58ec667480 gkeyfile: Remove dead code and unused string literals
In all these functions, group_name is guaranteed to be non-NULL by the
function preconditions, so there is no need to handle it as NULL when
building error messages. Remove some unnecessary string literals as a
result.

Coverity CID: 1325438–1325441
2015-10-03 23:31:44 +01:00
Mikhail Zabaluev
0448e758cf Skip g_bytes_new_with_free_func() in introspection
The tricky ownership/mutability semantics on data make this function
unusable in introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=755961
2015-10-01 21:15:22 -04:00
Mikhail Zabaluev
1e1e6c1086 gbytes: fix up annotations
Annotate array elements as bytes.
Annotate a missed output parameter.
Replace (allow-none) with the corresponding modern annotations.

https://bugzilla.gnome.org/show_bug.cgi?id=755961
2015-10-01 21:14:54 -04:00
Ryan Lortie
56b164a195 g_variant_get_child(): flatten-first logic on '&'
Copy the flatten-first logic from g_variant_get(), and for the same
reason: if the user is requesting a direct pointer access to a
tree-based child inside of argument to this function then that child
could disappear later.

Forcing serialisation means that the pointer will remain valid as long
as the passed-in instance exists, which is the usual expectation with
GVariant API.

https://bugzilla.gnome.org/show_bug.cgi?id=755374
2015-09-29 10:17:28 -04:00
Nicolas Dufresne
b36b4941a6 glib: Add 2.48 availibity macros
https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-09-29 08:26:13 -04:00
Philip Withnall
de04fd1304 gerror: Document the disadvantages of using GError
And move the discussion to a new subsection in the GError documentation.
Follow-up from commit 04662a8667.

https://bugzilla.gnome.org/show_bug.cgi?id=743011
2015-09-28 13:32:36 +01:00
Philip Withnall
04662a8667 gerror: Document advantages of GError over numeric error codes
Despite knowing about GError, there are multiple cases where developers
have still used traditional numeric error codes, and then got themselves
into a mess about bindability and generation of error messages.

Try and avoid this by including a brief paragraph on the benefits of
GError over EINVAL-style error codes.

https://bugzilla.gnome.org/show_bug.cgi?id=743011
2015-09-28 13:04:25 +01:00
Philip Withnall
5ceaeef832 gerror: Add an extra heading to the GError documentation
This means that the top of the documentation can link forward to this
important section, and random people on the internet can link directly
to it on developer.gnome.org.

https://bugzilla.gnome.org/show_bug.cgi?id=743011
2015-09-28 13:04:25 +01:00
Matthias Clasen
2d7817887a Revert "list store: Fix a parameter check"
This reverts commit d28639507d.

This wasn't meant to go in.

https://bugzilla.gnome.org/show_bug.cgi?id=755496
2015-09-23 18:55:28 -04:00
Xavier Claessens
b81f3ced71 Move GStrv typedef to glib.h instead of gobject.h
GStrv was historically only needed for the boxed G_TYPE_STRV,
but it is now useful for g_auto(GStrv) as well. This is not
an ABI change.

https://bugzilla.gnome.org/show_bug.cgi?id=755355
2015-09-22 11:18:30 -04:00
Emmanuele Bassi
ab26dd5433 Revert use of the system_header GCC pragma
This reverts commit 662bf991c0. It is not
a straight up revert because the old commit involved various long since
removed ChangeLog files and we'd end up mudding the patch.

The system_header GCC pragma is breaking warnings in the various
g_return_* macros; GCC stopped warning when using a macro with a return
value in a function that returns void, as well as when using a macro
with no return value in a function that has a non-void return value.
Suppressing this kind of warnings is not a good idea.

Other compilers are unaffected, even ones like Clang with a GCC
compatibility layer.

Given the fact that the original commit was added 14 years ago as a
workaround in the old days of GTK+ 1.2, I think it's safe to drop it.

https://bugzilla.gnome.org/show_bug.cgi?id=753310
2015-09-22 15:14:14 +01:00
Xavier Claessens
d488d75909 Remove useless NULL check before g_free() 2015-09-22 09:43:47 -04:00
Xavier Claessens
9348af3651 Doc: g_autoptr(gchar) has been replaced by g_autofree
https://bugzilla.gnome.org/show_bug.cgi?id=755351
2015-09-21 10:47:50 -04:00
Xavier Claessens
3ffed912c1 doc: small clarification in g_autoptr()
https://bugzilla.gnome.org/show_bug.cgi?id=755077
2015-09-21 08:38:33 -04:00
Matthias Clasen
2bc094264b Documentation fixups
Various parameter fixups and symbol list additions.
2015-09-21 06:44:58 -04:00
Mikhail Zabaluev
67c5bbaf03 glib/tests/utf8-validate: test known-length case along with null-terminated
For all test cases where the text length is given as -1, also
call g_utf8_validate() with the actual string length to exercise
the known-length case. Unknown-length and known-length validation
use different code paths, but most of the tests only exercised with
unknown-length parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=754924
2015-09-13 13:12:25 -04:00
Mikhail Zabaluev
8ab28b448b glib/tests/utf8-validate: add another test for invalid continuation bytes
This would have caught the regression committed in the course of
bug #738504.
2015-09-13 13:04:59 -04:00
Mikhail Zabaluev
d1f4d4a91a g_utf8_validate: fix a regression
A recent change permitted some characters from range 0x80-0xbf as
would-be valid sequence starters for length 2, as long as
continuation characters were OK.

https://bugzilla.gnome.org/show_bug.cgi?id=738504
2015-09-13 13:04:59 -04:00
Matthias Clasen
b9a27679ec Revert "Cleanups after we dropped mem vtables"
This reverts commit 627854fee1.

It has been argued that not aborting on malloc() failure is
an incompatible change.
2015-09-12 12:05:31 -04:00
Matthias Clasen
c90f283be3 Speed up g_dataset_id_dup_data
This code is used in the property notification path, so it
better be fast. This commit removes a g_return_if_fail check and
treats the common case of just a single data element better.
2015-09-12 11:13:45 -04:00
Matthias Clasen
59df5440f3 Drop g_slice_set_config tests
With g_quark_init, we are now calling GSlice from a constructor
(this was already the case when linking against gobject).
2015-09-12 11:13:45 -04:00
Matthias Clasen
2fe992b099 Move quark initialization to a constructor
This removes a branch from the very frequently called
quark functions.
2015-09-12 11:13:45 -04:00
Matthias Clasen
627854fee1 Cleanups after we dropped mem vtables
Since g_malloc is now always malloc, we can just use
strdup and strndup directly.
2015-09-12 11:13:45 -04:00
Matthias Clasen
97a25d1203 Optimize g_unichar_iswide
Apply the same optimization that was done for g_unichar_get_script
long ago: Use a quick check for the low end, and then remember the
midpoint of the last bsearch, since we're likely to be called for
characters that are close to each other.

This change made g_unichar_iswide disappear from profiles of the
gtk3-demo listbox example.
2015-09-12 11:13:44 -04:00
Dan Winship
96675446c5 Make g_strerror() do less work
Store the (translated, UTF-8-encoded) error strings in a hash table to
avoid doing translation and (possibly) g_locale_to_utf8() in every
g_strerror() call.

https://bugzilla.gnome.org/show_bug.cgi?id=754788
2015-09-11 12:39:44 -04:00
Dan Winship
19eb511ba4 More g_strerror() fixes
Add a check to configure.ac for strerror_r, since we don't currently
require POSIX.1-2001 conformance in general. Add back a
plain-strerror() case as a fallback, and rearrange the glibc-vs-POSIX
strerror_r() branches.

Update the docs to not claim that "not all platforms support the
strerror() function" (we require C90), but still mention the UTF-8 and
always-valid-string benefits. (And make test_strerror() check that
last part.)

https://bugzilla.gnome.org/show_bug.cgi?id=754788
2015-09-11 12:38:18 -04:00
Kalev Lember
d19411a76f autocleanups: Add GString type
https://bugzilla.gnome.org/show_bug.cgi?id=754831
2015-09-10 14:36:43 +02:00
Ting-Wei Lan
ebf961a58d Make g_strerror work with non-glibc POSIX systems
We should only use GNU-specific strerror_r on glibc. On other systems,
we should use the XSI-compliant version.

https://bugzilla.gnome.org/show_bug.cgi?id=754601
2015-09-07 15:18:01 -04:00
Matthias Clasen
23229bfd0c GString: Avoid some repeated parameter checking
Many of the append and prepend variants are just thin wrappers
around another one. Remove parameter checking in the wrapper
for these cases. The wrapped function is checking them anyway.
2015-09-07 10:35:13 -04:00
Matthias Clasen
03db1f455b Remove some unused code
The function unescape_gstring_inplace was maintaining a line count
without ever making use of it. Drop that.
2015-09-07 09:50:41 -04:00
Mikhail Zabaluev
401f78652c Reorganized utf8-performance tests
Now each function-string pair gets its own test path to track
a single performance result.

https://bugzilla.gnome.org/show_bug.cgi?id=738504
2015-09-05 13:14:11 -04:00
Mikhail Zabaluev
b963565125 Unrolled implementation of g_utf8_to_ucs4_fast()
Unrolling the branches and expressions for all expected cases
of UTF-8 sequences facilitates the work of both an optimizing compiler
and the branch prediction logic in the CPU. This speeds up decoding
noticeably on text composed primarily of longer sequences.

https://bugzilla.gnome.org/show_bug.cgi?id=738504
2015-09-05 13:12:48 -04:00
Mikhail Zabaluev
3188b8ee79 Optimized branching in g_utf8_validate()
The number of branches and logical operations can be reduced by
never producing a resulting wide character value to check its range.
Instead, individual bytes in the sequence are validated
depending on the branch taken on the basis of preceding bytes.
The syntax given in RFC 3629 is made use of.

https://bugzilla.gnome.org/show_bug.cgi?id=738504
2015-09-05 13:10:57 -04:00
Matthias Clasen
5644ee5083 markup: trivial refactor
Avoid an unnecessary branch.
2015-09-05 13:02:33 -04:00
Matthias Clasen
d28639507d list store: Fix a parameter check
Getting this wrong causes build failures.

https://bugzilla.gnome.org/show_bug.cgi?id=754582
2015-09-04 13:56:57 -04:00
Chun-wei Fan
041e77249a Cleanup and Enhance the MSVC Project Generation
Make use of the common autotools module that is used to generate the MSVC
project files from their respective templates so that the main build files
beccome cleaner, and enhance them in a way that the headers that should be
installed can be written to the property sheets during 'make dist', so that
the chances of missing headers for MSVC builds can be greatly reduced.

Also use this autotools module to fill in the projects for
glib-compile-schemas and glib-compile-resources.

https://bugzilla.gnome.org/show_bug.cgi?id=735429
2015-09-03 19:10:06 +08:00
Philip Withnall
7a65d1d3fb gmem: Fix a typo in the g_try_new0() documentation 2015-09-02 14:52:52 +01:00
Philip Withnall
b77fe970db gstring: Mark g_string_free() as taking (transfer full) input
This is unusual, but the correct annotation for a free() function.

https://bugzilla.gnome.org/show_bug.cgi?id=742903
2015-09-02 14:51:51 +01:00
Chun-wei Fan
4cad3f5e1b glib/strfuncs.c: Fix Build on Windows
Windows does not have strerror_r(), but does have strerror_s(), which is
threadsafe, and does more or less the same thing, so use it on Windows to
fix the build.

https://bugzilla.gnome.org/show_bug.cgi?id=754431
2015-09-02 17:03:44 +08:00
Dan Winship
9f2e3f6b72 gtestutils: add g_assert_cmpmem()
Add a test macro to compare two buffers (which are not already known
to be the same length) for equality.

https://bugzilla.gnome.org/show_bug.cgi?id=754283
2015-08-31 13:59:48 -04:00
Dan Winship
367f36d630 gtestutils: forbid having two tests with the same full path
In the same way that gtestutils used to let you create multiple suites
with the same name, it also let you create multiple tests with the
same name. Make that an error instead (and fix glib/tests/base64.c,
which was registering three separate tests named
"/base64/incremental/nobreak/4", and glib/tests/autoptr.c, which was
running test_g_variant_builder() twice).

https://bugzilla.gnome.org/show_bug.cgi?id=754286
2015-08-31 13:58:56 -04:00
Dan Winship
123ea70d74 gtestutils: improve non-TAP output, fix handling of incomplete tests
In non-TAP mode, tests that used g_test_skip() were labelled "OK", and
tests that used g_test_incomplete() were labelled "FAIL". Explicitly
show them as "SKIP" and "TODO" instead, like in the TAP case.

Also, incomplete/TODO tests are not supposed to be treated as
failures, so fix that too.

https://bugzilla.gnome.org/show_bug.cgi?id=754286
2015-08-31 13:58:56 -04:00
Dan Winship
6e382208f7 gtestutils: print the TAP test plan first, not last
TAP allows you to print the "test plan" (ie, the expected number of
tests" either at the start or the end of the test program, but if you
put it at the end, and the program crashes, automake will complain
"missing test plan", which is confusing to users (particularly since
it prints that *before* it prints that the test program crashed,
suggesting that somehow the lack of test plan was responsible for the
crash or something, rather than vice versa).

Anyway, change it to count the tests ahead of time, and print the test
plan first. Keeping this simple requires disallowing the '-p', '-s',
and '--GTestSkipCount' options when using '--tap' (although we were
already printing the wrong number in the --GTestSkipCount case
anyway).

https://bugzilla.gnome.org/show_bug.cgi?id=754284
2015-08-31 13:58:25 -04:00
Dan Winship
51c91ed53d gtestutils: move "/subprocess" path special-casing
https://bugzilla.gnome.org/show_bug.cgi?id=754284
2015-08-31 13:58:25 -04:00
Dan Winship
91ff2ba844 gtestutils: make g_test_suite_run{,internal} less confusing
Rewrite g_test_suite_run() and g_test_suite_run_internal() to make it
clearer what they do (while still preserving exact backward
compatibility, meaning we need to handle the "-p" case differently
from the non-"-p" case).

https://bugzilla.gnome.org/show_bug.cgi?id=754284
2015-08-31 13:58:25 -04:00
Dan Winship
510331bacf gtestutils: reorganize g_test_name manipulation
https://bugzilla.gnome.org/show_bug.cgi?id=754284
2015-08-31 13:58:25 -04:00
Matthias Clasen
30d95388e7 Test g_strerror some more
Set a locale here, so we actually do conversion, and also
run the loop far enough that we hit the 'unknown error' case.
2015-08-28 16:05:05 -04:00
Matthias Clasen
36fac0849c Make g_strerror threadsafe
We need to use strerror_r here, in order to be threadsafe.
2015-08-28 15:54:46 -04:00
Matthias Clasen
eb7ffccf44 test repeated g_hash_table_remove_all calls
I just came across a situation where code ended up stuck in
an infinite loop in GHashTable code, so lets verify that this
is a safe thing.
2015-08-28 14:15:54 -04:00
Philip Withnall
91a6ec8d07 gutils: Clarify return values of g_bit_nth_[lsf|msf]()
Clarify in the documentation that both functions return -1 if no high
bits could be found.
2015-08-25 10:49:06 +01:00
Michael Catanzaro
a6ae52fa13 docs: Fix a typo finalised -> finalized
db8455f07d added use of both "finalised"
and "finalized". We generally use American spelling, so prefer that.
2015-08-21 16:46:33 -05:00
Matthias Clasen
09b618f0a1 Avoid a false deprecation
gtk-doc misinterprets this comment and marks
g_find_program_in_path as deprecated, which it isn't.
2015-08-20 20:20:48 -04:00
Philip Withnall
5a642651c7 gmessages: Mention g_return_if_fail() in g_warning() and g_error() docs
It seems to be common for people to use g_warning() or g_error() as pre-
and post-condition error reporting functions, which is not really what
they’re intended for. Similarly, it is generally a sign of bad API
design to use g_warning() to report errors — use GError instead.

Try and suggest this to the user in the hope that nice code results.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 12:56:38 +01:00
Philip Withnall
db8455f07d gmain: Document memory management best practices for GSources
It’s very common to see code where a timeout is scheduled using
g_timeout_add(), yet the owning object could be destroyed shortly
afterwards, before the timeout is fired, leading to use-after-free.

Try and prevent this happening with new code by documenting best
practices for memory management of user data for GSource callbacks.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 12:56:38 +01:00
Philip Withnall
d624bf4e66 gthread: Suggest using *_async() functions instead of threads
It’s unfortunately common to see worker threads being spawned all over
the place to do operations which could be brought into the main thread
with an async call, simplifying everything.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 11:38:55 +01:00
Philip Withnall
5ee333e4cb gstrfuncs: Add a string formatting note about using G_GUINT64_FORMAT
…and friends. The ‘String precision pitfalls’ section is already linked
to from all the relevant printf()-style functions, so this documentation
should hopefully be easy to find.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 11:36:43 +01:00
Philip Withnall
8c858a018d gvariant: Clarify that nullable strings should use maybe types
Otherwise people might try to encode a NULL string as "NULL". I’m not
even kidding.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-08-19 11:36:43 +01:00
Dan Winship
a366053253 glib: remove deprecated g_mem_is_system_malloc() check in gprintf.c 2015-08-07 09:49:50 -04:00
Dan Winship
ebaa1de304 glib: drop array-test test for bug 568760
The test relied on g_mem_set_vtable(), so it fails now. But no one
ever touches that code so it's not like we're going to break it again
anyway.
2015-08-07 09:49:35 -04:00
Benjamin Otte
a2a3587036 gmain: Document return value of GSourceFuncs.dispatch 2015-08-02 17:37:12 +02:00
Matthias Clasen
b173244b7d Remove malloc tests
These tests were about the no longer supported
vtable functionality, so just remove them.
2015-07-28 00:04:35 -04:00
Alexander Larsson
3be6ed60aa Deprecate and drop support for memory vtables
The memory vtables no longer work, because glib contructors are called
before main(), so there is no way to set it them before use. This stops using
the vtable at all, and deprecates and stubs out the related functions.

https://bugzilla.gnome.org/show_bug.cgi?id=751592
2015-07-27 23:30:20 -04:00
Matthias Clasen
08a3f3f3d2 GOptionContext: Don't crash without main group
This was introduced in 126c685f4a and caused e.g. gdbus
to crash when called without arguments.

https://bugzilla.gnome.org/show_bug.cgi?id=752210
2015-07-27 07:53:40 -04:00
Matthias Clasen
17871e6881 Add a note to the g_str_hash docs
Point out some shortcomings of the djb hash, as found in

https://bugzilla.gnome.org/show_bug.cgi?id=751610
2015-07-27 06:51:17 -04:00
Matthias Clasen
9c4887027d Remove some questionable documentation
A function that takes a lock can certainly block in the sense
that it has to wait if the lock is taken.

https://bugzilla.gnome.org/show_bug.cgi?id=751751
2015-07-27 06:42:46 -04:00
Peter Meerwald
0441ae1ccf ghash: Fix typo in g_hash_table_replace() documentation
https://bugzilla.gnome.org/show_bug.cgi?id=752767
2015-07-24 12:41:01 -04:00
TingPing
b65287fea5 win32: Fix leak in g_win32_get_command_line()
https://bugzilla.gnome.org/show_bug.cgi?id=741822
2015-07-23 04:22:59 -04:00
TingPing
3cc349b04e win32: Replace usage of __wgetmainargs()
It was an internal function that has been removed with VS 2015

Use g_win32_get_command_line() or CommandLineToArgvW() directly.

https://bugzilla.gnome.org/show_bug.cgi?id=741822
2015-07-23 04:22:59 -04:00
Daniel Macks
dab2097587 Use GRegexMatchFlags not GRegexCompileFlags for TEST_MATCH _match_opts
Fix the enums used in some test cases to use the correct enum type in
some test cases.

https://bugzilla.gnome.org/show_bug.cgi?id=751798
2015-07-13 19:44:45 +01:00
Ilya Konstantinov
27fae83909 gbacktrace: fix G_BREAKPOINT on Darwin (OSX, iOS)
Using __builtin_trap() according to Apple's own documentation:
https://developer.apple.com/library/mac/technotes/tn2124/_index.html#//apple_ref/doc/uid/DTS10003391-CH1-SECCONTROLLEDCRASH

https://bugzilla.gnome.org/show_bug.cgi?id=750807
2015-07-09 10:39:42 -04:00
Emmanuele Bassi
475445e6e0 tests: Fix compiler warning
Use `const gchar * const` to define a const array of const strings, and
initialize the array when declaring it.

https://bugzilla.gnome.org/show_bug.cgi?id=751672
2015-06-29 20:14:40 +01:00
Matthias Clasen
9486f697bb GThreadPool: Add some queue manipulation api
GTask has a need for an api that boosts an unprocessed
item to the front of the queue, so add one.

https://bugzilla.gnome.org/show_bug.cgi?id=751160
2015-06-29 08:20:26 -07:00
Matthias Clasen
26d8792710 Add tests for new GAsyncQueue api
https://bugzilla.gnome.org/show_bug.cgi?id=751160
2015-06-29 08:20:26 -07:00
Matthias Clasen
b662c6f09f GAsyncQueue: Add some useful api
The underlying queue supports removing and pushing items to
the front, and these operations can sometimes be useful.

https://bugzilla.gnome.org/show_bug.cgi?id=751160
2015-06-29 08:20:26 -07:00
Ting-Wei Lan
5574315b52 tests: Fix tests that fail with non-English locales
Some tests check whether the translated messages are expected, so we have to
force the use of English locales for them.

https://bugzilla.gnome.org/show_bug.cgi?id=748610
2015-06-29 22:49:17 +08:00
Ting-Wei Lan
93dadb17ce gmessages: Add G_GNUC_NORETURN to g_error static function declaration
https://bugzilla.gnome.org/show_bug.cgi?id=741901
2015-06-29 04:11:39 +08:00
Ting-Wei Lan
d7a1d890c1 gmacros: Only set G_ANALYZER_ANALYZING to 1 when clang static analyzer is in use
We set G_ANALYZER_ANALYZING to 1 when clang supporting static analyzing before,
but this will cause compilation error when -Werror=return-type is used and the
static analyzer is not in use because g_error static function only has
__attribute__((analyzer_noreturn)), which is useless for normal compilation.

https://bugzilla.gnome.org/show_bug.cgi?id=741901
2015-06-29 04:11:39 +08:00
Philip Withnall
409202c1fd build: Ensure glibconfig.h.win32 is in DISTCLEANFILES
Otherwise it’s possible for it to not be regenerated when glibconfig.h
is, leading to inconsistencies.

https://bugzilla.gnome.org/show_bug.cgi?id=727829
2015-06-25 10:42:35 +01:00
Matthias Clasen
6e57650387 key file: Clarify documentation around comments
The documentation was not very clear about the handling
of the '#' comment markers. State clearly how these are
handled by the getter and the setter.

https://bugzilla.gnome.org/show_bug.cgi?id=479730
2015-06-16 18:38:27 -04:00
Rico Tzschichholz
1f0a11c59a g_log_set_handler_full: Bump "Since" version accordingly 2015-06-11 07:52:40 +02:00
Matthias Clasen
2471d9cf86 Add g_log_set_handler_full
This is a bindable version of g_log_set_handler that takes
a destroy notify for the user_data.

https://bugzilla.gnome.org/show_bug.cgi?id=740516
2015-06-10 22:03:19 -04:00
Simon McVittie
bf181a3ac7 regex: if PCRE is 8.34 or later, disable auto-possessification for DFA
Normally, recent PCRE behaves as if certain patterns were replaced
by a more "possessive" pattern that gives the same answer for normal
regex matching, but is more efficient. However, the modified pattern
produces fewer results under DFA. If we want the full set of results
we have to apply PCRE_NO_AUTO_POSSESS, and that's a compile-time flag.

This currently only affects a system PCRE, but would also work fine for
an internal PCRE 8.34 or later if the embedded copy is updated.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=733325
Reviewed-by: Christian Persch <chpe@gnome.org>
2015-06-09 18:15:28 +01:00
Mikhail Zabaluev
5bc0bc2fde Added g_utf8_validate() to UTF-8 performance testing
https://bugzilla.gnome.org/show_bug.cgi?id=738504
2015-06-05 15:36:13 -04:00
Mikhail Zabaluev
16190d2dcd glib/genviron.c, GSubprocessLauncher: ain't no "filename encoding"
Removed all mentions of GLib file name encoding referring to
the environment strings. The env var content has no defined relation
to GLib's notion of filename encoding, or any encoding whatsoever.
It would be wrong to pass all UTF-8 strings through
g_filename_from_utf8() in order to put them into the environment,
for one thing.

https://bugzilla.gnome.org/show_bug.cgi?id=738185
2015-06-05 14:53:34 -04:00
Matthias Clasen
c20f3b239c Fix a markup confusion
"0." at the beginning of a line is interpreted as a numeric list
by the gtk-doc markdown parser, so be careful to avoid that.

https://bugzilla.gnome.org/show_bug.cgi?id=750399
2015-06-05 11:54:40 -04:00
Matthias Clasen
07b3595c23 Trivial: fix a typo
Pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=750399
2015-06-05 11:54:40 -04:00
Mattias Ellert
f7b13e05f9 thread: Check sysconf value before using it
sysconf() is documented as returning -1 if it can't determine
a minimum thread stack size. Check for this case before using
the return value.

https://bugzilla.gnome.org/show_bug.cgi?id=739122
2015-05-28 21:54:52 -04:00
Matthias Clasen
126c685f4a GOptionContext: Improve help in simple cases
Only add [OPTION...] to the usage line if the context
has options. And shorten "Application Options" to just
"Options" if we don't have to differentiate from other
kinds of options.
2015-05-25 13:29:58 -04:00
Simon McVittie
ace7846322 regex test: do not assert that system PCRE still has an 8.31 bug
This was fixed in 8.32, so if we have that version, assert that it is
fixed; if we don't (e.g. the current internal pcre), still don't
assert that it *isn't* fixed.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=733325
Reviewed-by: Christian Persch <chpe@gnome.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 18:39:57 +01:00
Philip Withnall
6ac2e8c79a gmessages: Tweak docs for G_LOG_DOMAIN to use AM_CPPFLAGS
Instead of INCLUDES, which is deprecated in automake. Using AM_CPPFLAGS
also gives the hint that the -D argument should be a CPPFLAGS variable,
rather than CFLAGS.
2015-05-13 15:22:57 +01:00
Simon McVittie
45dae4b506 tests: replace most g_print() with g_printerr()
I searched all files that mention g_test_run, and replaced most
g_print() calls. This avoids interfering with TAP. Exceptions:

* gio/tests/network-monitor: a manual mode that is run by
  "./network-monitor --watch" is unaffected
* glib/gtester.c: not a test
* glib/gtestutils.c: not a test
* glib/tests/logging.c: specifically exercising g_print()
* glib/tests/markup-parse.c: a manual mode that is run by
  "./markup-parse --cdata-as-text" is unaffected
* glib/tests/testing.c: specifically exercising capture of stdout
  in subprocesses
* glib/tests/utils.c: captures a subprocess's stdout
* glib/tests/testglib.c: exercises an assertion failure in g_print()

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Colin Walters <walters@verbum.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 20:24:56 +01:00
Simon McVittie
472dee3909 gdatetime test: don't assume that time stands still
If we call time(NULL), then do something (however trivial), then call
g_date_time_new_now_utc(), they do not necessarily share a seconds
value. Let's say the gmtime call takes 2ms. time(NULL) could
return xx:xx:23 when the time is actually xx:xx:23.999999, resulting
in the g_date_time_new_now_utc() happening at xx:xx:24.000001. This is
unlikely, but did happen to me in a parallel build:

GLib:ERROR:.../glib/tests/gdatetime.c:674:test_GDateTime_now_utc: assertion failed (tm.tm_sec == g_date_time_get_second (dt)): (23 == 24)

A similar argument applies to the rollover from xx:23:59.999999 to
xx:24:00, so comparing seconds with a 1s "fuzz" or a >= comparison
is not sufficient; and so on into higher-order fields.

I haven't seen the other tests that use _now() fail in the same way,
but they could.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=749080
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 17:48:02 +01:00
Piotr Drąg
474877d916 Fix a minor typo in a comment 2015-05-10 20:09:48 +02:00
Simon McVittie
d92a67afcb gtestutils: better diagnostics if a captured subprocess fails
It's unhelpful to get an error saying that stderr didn't match a
desired pattern, or matched an undesired pattern, without also
telling you what *was* on stderr. Similarly, if a test subprocess
exits 1, there's probably something useful on its stderr that
could have told you why.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=748534
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Dan Winship <danw@gnome.org>
2015-05-08 16:05:22 +01:00
Ting-Wei Lan
34e946838d tests: Use de_DE.UTF-8 instead of de_DE
de_DE.UTF-8 is supported by more operating systems, including FreeBSD,
NetBSD and OpenBSD.

https://bugzilla.gnome.org/show_bug.cgi?id=748612
2015-05-01 23:07:45 +08:00
Hans Petter Jansson
c71b16c3be gmarkup: Make append_escaped_text() slightly more robust.
https://bugzilla.gnome.org/show_bug.cgi?id=631597
2015-04-28 16:50:42 +02:00
Simon McVittie
4e29e9a079 regex test: do not assert that system PCRE allows "(?P<1>)"
Perl >= 5.18, and PCRE >= 8.34, disallow this.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=733325
Reviewed-by: Christian Persch <chpe@gnome.org>
2015-04-27 14:33:06 +01:00
Simon McVittie
1fdece4f22 regex test: improve diagnostics for some failures
These fail with system PCRE 8.35, but the improved diagnostics are
generic.

Reviewed-by: Christian Persch <chpe@gnome.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=733325
2015-04-27 14:31:22 +01:00
Philip Withnall
1b3dbec065 gvariant-parser: Clarify g_variant_parse() returns a non-floating ref
Unlike, say, g_variant_new(), which returns a floating reference.
g_variant_parse() returns a non-floating one, so must always have
g_variant_unref() called on the result.
2015-04-22 00:02:06 +01:00
Behdad Esfahbod
46779a3122 Remove UTF-8 quotation marks
https://bugzilla.gnome.org/show_bug.cgi?id=747772
2015-04-13 12:30:16 -07:00
Christophe Fergeau
b470b12c49 gatomic: Add missing new line in API doc comment
This causes an overlong line, and a spurious '*' in the generated
documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=747363
2015-04-07 10:41:47 +02:00
Руслан Ижбулатов
eac975c682 Make sure GStatBuf is typedefed correctly
https://bugzilla.gnome.org/show_bug.cgi?id=728663
2015-04-05 11:09:22 +00:00
Dan Winship
e2655cd455 tests: clean up / ignore some more generated files 2015-04-04 10:00:39 -04:00
Matthias Clasen
b0e330b68c Fix the build
The world would be a better place if gcc had __has_feature(), too.
2015-03-22 15:05:13 -04:00
Matthias Clasen
42870201f8 Account for clangs lack of __alloc_size__
clang's emulation of gcc 4.3 is not perfect, despite its
pretending that it is.

https://bugzilla.gnome.org/show_bug.cgi?id=745821
2015-03-22 14:20:00 -04:00
Dan Winship
15c5e643c6 gversionmacros: add 2.46 version macros 2015-03-21 09:50:29 -04:00
Ryan Lortie
7c70377abf gmain: Save errno when handling unix signals
Our signal handler calls write() on a pipe or an eventfd in order to
deliver the notification.  It's unlikely, but this could fail, setting
errno.  We even check the case that it fails with EINTR.

If it does set errno, then it has potentially blown away the value or
errno that the preempted code cared about (ie: if the signal arrived
shortly after a system call but before errno was checked).

Wrap the handler with code to save errno.

https://bugzilla.gnome.org/show_bug.cgi?id=741791
2015-03-20 13:32:45 -04:00
Jasper St. Pierre
93c8cbcfcd Update .gitignore 2015-03-18 14:28:14 -07:00
Philip Withnall
c5c8bac693 goption: Mention type of G_OPTION_ARG_CALLBACK in documentation 2015-03-13 09:10:25 +00:00
Tim-Philipp Müller
627a145e16 threads: use FUTEX_WAIT_PRIVATE and FUTEX_WAKE_PRIVATE if possible
This avoids some expensive code paths in the kernel, see
http://lwn.net/Articles/229668/

https://bugzilla.gnome.org/show_bug.cgi?id=741442
2015-03-12 21:01:36 -04:00
Ryan Lortie
6fffce2588 docs: clean up a few glib issues
Fix a few typical problems, and also stop wrapping the inline definition
of g_steal_pointer in parens, since it is not necessary and it confuses
gtk-doc.
2015-03-12 17:24:05 -04:00
Ryan Lortie
d9de830b65 Convert remaining uses of 'Rename to:'
This was replaced by (rename-to) in 2013 (see bug 676133).

They're also causing gtk-doc trouble, so let's get rid of them.
2015-03-12 16:55:22 -04:00
Xavier Claessens
8b654e24a5 Win32: Move g_win32_check_windows_version() to the correct place in header
It was added after G_END_DECLS, outside the #ifdef G_PLATFORM_WIN32,
and inside a #ifndef __GTK_DOC_IGNORE__ block. So it was missing from
the doc.

https://bugzilla.gnome.org/show_bug.cgi?id=743661
2015-03-12 16:09:14 -04:00
Philip Withnall
bdfc8231c6 gerror: Minor clarifications to the GError documentation
• Clarify that GError** parameters are for the return of _newly
   allocated_ GError*s.
 • Clarify that errors may need to be checked for explicitly if the
   return value of a function doesn’t reliably indicate them.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-04 08:45:00 +00:00
Philip Withnall
2a581fab7d gvariant: Use ‘UTF-8’ in docs rather than ‘utf8’
Nitpicky correction.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Philip Withnall
8df6e5fa3f gmain: Explicitly document the threading behaviour of g_timeout_add()
i.e. That calling g_timeout_add() from a thread other than the main one
probably doesn’t do what you want. Same for g_idle_add() and the
*_full() variants.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Philip Withnall
18c9a4e17a gmem: Clarify that a NULL check is not needed before calling g_free()
It was documented before, but wasn’t especially clear. Doing
    if (X)
        g_free (X);
is apparently quite a pervasive real-world anti-pattern, so perhaps it
could be documented more explicitly.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Philip Withnall
984576c01e glist: Clarify that g_list_nth() is expensive
Just in case people have forgotten their basic algorithms course. Seen
in some pretty terrible code in the wild; hopefully mentioning the cost
in the documentation will make people think twice about using a counter
variable when iterating over a linked list.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Philip Withnall
c6312daba0 glist: Clarify how g_list_free_1() handles links
It doesn’t, which is fine, but could be unexpected if undocumented.

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Philip Withnall
59748c3be0 ghash: Document that g_hash_get_[keys|values]() are expensive
And definitely not the right way to iterate over a hash table (as seen
in code in the wild).

https://bugzilla.gnome.org/show_bug.cgi?id=741779
2015-03-03 18:40:33 +00:00
Philip Withnall
f829bde76a gstring: Mark the return value from g_string_free() as nullable
It’s NULL iff free_segment is TRUE, so the annotation doesn’t quite
capture all the function definition, but is a safe over-estimate of the
return value’s nullability.

https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-03-03 17:59:50 +00:00
Philip Withnall
b9c94b344e gfileutils: Mark the return value from g_path_skip_root() as nullable
It returns NULL for non-absolute paths.

https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-03-03 17:59:50 +00:00
Colin Walters
0550708ca7 tests: Add many autoptr tests
I love Emacs keyboard macros, used them to convert the list of
defines cleverly into a list of tests, then iterated and filled in
the necessary constructor arguments.
2015-02-23 10:40:40 -05:00
Colin Walters
1b348a876f autocleanups: Remove g_autoptr(gchar)
- It's not sufficient, there are other bare array types
  like guint8, gdouble, etc.

- Other types like GVariant* always come as pointers, whereas
  there's a rather fundamental distinction between "gchar" and
  "gchar*" that has been signified to C programmers for 30+ years via
  the '*' character, and we're hiding that.

https://bugzilla.gnome.org/show_bug.cgi?id=744747
2015-02-23 07:56:34 -05:00
Colin Walters
d0105f1c08 Add g_autofree
The g_autoptr() being associated with the type name works out really
well for things like GHashTable.  However, it's a bit more awkward to
associate with "gchar".  Also because one can't use "char".
Similarly, there are a lot of other "bare primitive array" types that
one might reasonably use.

This patch does not remove the autoptr for "gchar", even though I
think it's rather awkward and strange.

Also while we're here, add a test case for the cleanup bits.

https://bugzilla.gnome.org/show_bug.cgi?id=744747
2015-02-22 22:18:07 -05:00
Colin Walters
9d6d30475b autocleanups: Add G*Array types
Not sure how these were omitted.  Probably few people are really using
this yet...and we don't have test cases (that's in the other patch).

https://bugzilla.gnome.org/show_bug.cgi?id=744830
2015-02-20 07:08:50 -05:00
Colin Walters
619832f729 autocleanups: Use g_option_context_unref()
This fixes a use of a deprecated API.
2015-02-17 13:37:03 -05:00
Phillip Wood
a074c7a6f2 Test functions should have async scope
The testing utilities execute fixture and test functions
asynchronously.

https://bugzilla.gnome.org/show_bug.cgi?id=739724
2015-02-13 16:16:06 -05:00
Bastien Nocera
43df97ab86 goption: Add boxed type for GOptionGroup
This would allow bindings to use _get_option_group() functions, which
would then allow them to use GOption parsing.

This also adds introspection annotations to
g_option_context_add_group(), g_option_context_set_main_group() and
g_option_context_get_main_group().

https://bugzilla.gnome.org/show_bug.cgi?id=743349
2015-02-11 15:32:00 +01:00
Philip Withnall
93f2998765 glist: Mention that g_list_length() is bad for checking list emptiness
Despite linked lists being a fairly fundamental computer science
concept, some developers insist on using:
    g_list_length (list) > 0
to determine whether a list is non-empty, rather than using:
    list != NULL

Add a comment to the documentation for g_list_length() and
g_slist_length() pointing out the better alternative in the hope that it
will prevent some of this abuse.

https://bugzilla.gnome.org/show_bug.cgi?id=741024
2015-02-11 09:17:33 +00:00
Chun-wei Fan
433fc9475d gmem.h, gthread.h: Include glib/gutils.h
gmem.h and gthread.h made use of the inline keyword, that is not available
on all compilers in C-mode, causing builds to break on such compilers.

Include glib/gutils.h which handles the inline issue, in place of
glib/gtypes.h if applicable, which is included quite early on by
glib/gutils.h.

https://bugzilla.gnome.org/show_bug.cgi?id=744190
2015-02-10 23:17:07 +08:00
Sébastien Wilmet
59c0ff4825 GI annotation for g_get_charset()
https://bugzilla.gnome.org/show_bug.cgi?id=736914
2015-02-08 16:06:17 +01:00
Ryan Lortie
0110f2a810 g_steal_pointer: make it C++ clean
We have a test that #includes our headers from a C++ program to make
sure we don't throw any errors or warnings as a result of that.

The new inline implementation of g_steal_pointer() does an implicit
conversion from (void *), which is not valid in C++.

Add a cast to avoid the problem.

Thanks to Ignacio Casal Quinteiro for the report.
2015-02-06 17:01:56 +01:00
Ryan Lortie
aa68b3d6d6 tests: add a test case for g_steal_pointer()
Just some basic checking to make sure it works as intended.

https://bugzilla.gnome.org/show_bug.cgi?id=742456
2015-02-06 15:17:27 +01:00
Ryan Lortie
e668796c5a Add new API g_steal_pointer()
This is particularly nice when used with g_autoptr().  See examples in
the docs.

This patch is based upon an idea (and original patch submission) from
Will Manley <will@williammanley.net>.

https://bugzilla.gnome.org/show_bug.cgi?id=742456
2015-02-06 15:14:57 +01:00
Xavier Claessens
1404d3e128 Add GMutexLocker
https://bugzilla.gnome.org/show_bug.cgi?id=744012
2015-02-06 12:11:18 +01:00
Xavier Claessens
d4791bd383 Doc: Fix g_auto and g_autoptr typo 2015-02-04 15:07:15 +01:00
Aurélien Zanelli
5b74681f5b gnulib/vasprintf: handle unsigned modifier for long long
Otherwise, an unsigned integer will be displayed as a signed one if we
use internal printf and if HAVE_LONG_LONG_FORMAT is not defined.

https://bugzilla.gnome.org/show_bug.cgi?id=743936
2015-02-03 11:48:18 -05:00
Chun-wei Fan
696db75615 gmacros.h: Add Private Macro _GLIB_DEFINE_AUTOPTR_CHAINUP
This is necessary as we are using _GLIB_AUTOPTR_TYPENAME and
_GLIB_AUTOPTR_FUNC_NAME in gtype.h for G_DECLARE_DERIVABLE_TYPE and
G_DECLARE_FINAL_TYPE, but _GLIB_AUTOPTR_TYPENAME and
_GLIB_AUTOPTR_FUNC_NAME expand to nothing on non-GCC, causing builds on
non-GCC to break, due to bad typedef and function definitions.

This patch defines a new private macro which does what is needed on GCC
builds and does nothing on non-GCC builds, thus fixing the build.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-02-03 18:11:30 +08:00
Ryan Lortie
57a49f6891 fix G_DEFINE_AUTO_CLEANUP_FREE_FUNC on non-GCC
Add the missing 'none' argument to this macro in the non-GCC case.  The
none parameter was added after the others and I forgot to update the
non-GCC case.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-02-02 09:17:44 +01:00
Ryan Lortie
3d5de34def gobject: add support for g_auto() and g_autoptr()
Add support to libgobject types for the new cleanup macros.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:52:36 +01:00
Ryan Lortie
663834671d glib: add support for g_auto() and g_autoptr()
Add support to the libglib types for the new cleanup macros.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:52:36 +01:00
Ryan Lortie
2596919c58 macros: add support for GNUC cleanup __attribute__
Add g_auto() and g_autoptr() as helpers for declaring variables with
automatic cleanup.

Add some macros to help types define cleanup functions for themselves.

Going forward it will be an expectation that people use this macro when
creating a new type, even if they do not intend to use the auto-cleanup
functionality for themselves.

These new macros only work on GCC and clang, which is why we resisted
adding them for so long.  There exist many people who are only
interested in writing programs for these compilers, however, and a
similar API in libgsystem has proven to be extremely popular, so let's
expose this functionality to an even wider audience.

We ignore deprecation warnings when emitting the free functions, which
seems suspicious.  The reason that we do this is not because we want to
call deprecated functions, but just the opposite: sometimes the free
function will be an _unref() function that is only AVAILABLE_IN newer
versions, and these warnings are also implemented as deprecation
warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:49:53 +01:00
Chun-wei Fan
bcbf80c355 gwin32: Add g_win32_check_windows_version() API
This adds a public API where one can use to see whether the running version
of Windows where the code is run is at least the specified version, service
pack level, and the type (non-server, server, any) of the running Windows
OS.

This API is done as:
-GetVersion()/GetVersionEx() changed in the way they work since Windows 8.1
 [1][2], so a newer mechanism to check the version of the running Windows
 operating system is needed.  MSDN also states that GetVersion() might be
 further changed or removed after Windows 8.1.  This provides a wrapper for
 VerfyVersionInfo() as well in GLib for most cases, which was recommended
 in place of g_win32_get_windows_version() for more detailed Windows
 version checking.
-Provides an OS-level functionality check, for those that we don't need to
 venture into GetProcAddress(), and also to determine system API behavior
 changes due to differences in OS versions.

Also added a note for the g_win32_get_windows_version() API that since the
behavior of GetVersion() which it uses, is changed since Windows 8.1, users
of the API should be aware.

[1]:
http://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724451%28v=vs.85%29.aspx
[2]:
http://msdn.microsoft.com/zh-tw/library/windows/desktop/ms724451%28v=vs.85%29.aspx

https://bugzilla.gnome.org/show_bug.cgi?id=741895
2015-01-27 12:17:14 +08:00
Ilya Konstantinov
2a0c18041b gthread: add thread name support on Mac OS
https://bugzilla.gnome.org/show_bug.cgi?id=741807
2015-01-26 09:06:13 +00:00
Philip Withnall
4462cd30bc gthread: Fix a typo in a documentation comment 2015-01-25 17:09:24 +00:00
Philip Withnall
92041f4b3b gstrfuncs: Document that g_ascii_dtostr() writes a nul terminator
And g_ascii_formatd().

Reviewed-by: Ryan Lortie <desrt@desrt.ca>
2015-01-25 16:22:43 +00:00
Philip Withnall
11a846b6bf gtestutils: Add an example of using test fixtures
Add a simple example of a test suite with two unit tests both using the
same fixture.

https://bugzilla.gnome.org/show_bug.cgi?id=743014
2015-01-18 23:04:05 +00:00
Philip Withnall
2c5076cd58 gtestutils: Add links to gtester and gtester-report documentation
Link some existing text to make cross-referencing a little easier.
2015-01-16 09:22:21 +00:00
Philip Withnall
056f50ce94 gtestutils: Fix a typo in the g_test_add() documentation 2015-01-16 09:18:41 +00:00
Philip Withnall
7dd7c04148 gtestutils: Clarify that test fixtures are allocated by GLib
Make it a little clearer that the user’s fixture setup and teardown
functions don’t have to do the allocation or freeing.
2015-01-16 09:15:07 +00:00
Philip Withnall
123bd7aecf gtestutils: Fix a typo in the g_test_run() documentation 2015-01-16 09:15:07 +00:00
Philip Withnall
9114923db2 ggettext: Include an example of setlocale() and friends in the i18n docs
Include an example main() function, and include a link to the gettext
manual’s section on integrating gettext with build systems.

That should work as a complete reference for how to add i18n support to
an application.

https://bugzilla.gnome.org/show_bug.cgi?id=742972
2015-01-15 14:22:25 +00:00
Paolo Borelli
7a8ef00aae Avoid warning when using G_STMT_END macro with MSVC
Workaround found on
http://cnicholson.net/2009/03/stupid-c-tricks-dowhile0-and-c4127/

https://bugzilla.gnome.org/show_bug.cgi?id=742851
2015-01-14 16:21:00 +01:00
Paolo Borelli
432476355b Use G_STMT_START/END in gslice.h 2015-01-14 16:21:00 +01:00
Paolo Borelli
be0c9e507a Use G_STMT_START/END in gtestutils 2015-01-14 16:21:00 +01:00
Chun-wei Fan
1632d5716e Win32: Update Pre-configured Config Headers
Update config.h.win32.in and glibconfig.h.win32.in so that they will be
in-line with the ones that are produced with configure.ac, for use on
Windows builds.

Thanks to Philip Withnall for pointing out the changes needed to update
glibconfig.h.win32.in in bug 727829.
2015-01-07 09:59:47 +08:00
Matthias Clasen
48293bb47d Fix a typo 2014-12-23 19:49:41 -05:00
Matthias Clasen
30abc73c1a Silence the build some more 2014-12-20 21:32:53 -05:00
Xavier Claessens
1a2a689dea Doc: glib: Fix all undocumented/unused/undeclared symbols
There is one issue left in gscanner.h due to a bug #741305 in gtk-doc.

https://bugzilla.gnome.org/show_bug.cgi?id=740814
2014-12-12 11:01:37 -05:00
Ryan Lortie
de65723877 ghash: minor docs tweak
We should not advise people to cast the result of
g_hash_table_get_keys_as_array() to a type that looks suitable for use
with g_strfreev().  Advise to use (const gchar **) instead.
2014-12-11 18:50:07 -05:00
Colin Walters
a12f546b3b keyfile: Add "in group" to GError message consistently
This originated with https://github.com/GNOME/ostree/pull/23
It's nicer for the user if we also mention which group the expected
key would be in.

And in fact, every other error *except* _get_value() already had it.

https://bugzilla.gnome.org/show_bug.cgi?id=741226
2014-12-07 22:00:41 -05:00
Ryan Lortie
296c710c64 GVariant tests: test with larger strings
Allocate some larger strings in the testcase to make sure we handle them
correctly as well.
2014-11-29 14:22:03 -05:00
Ryan Lortie
5aba9ca837 gmain: fix poll record comparison
We intend to keep the list of poll records sorted by (integer) file
descriptor, but due to a typo we are actually keeping it sorted by
pointer address of the GPollFD.

Fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=11059
2014-11-28 23:54:02 -05:00
Xavier Claessens
71944b1bfd gstrfuncs: Add g_strv_contains()
Includes unit tests.

https://bugzilla.gnome.org/show_bug.cgi?id=685880
2014-11-25 12:51:36 +00:00
Alberto Ruiz
6c080721fc glib: Improve documentation for g_strfreev()
Fixes #740309.
2014-11-18 14:43:41 +00:00
David King
61cecd5a68 docs: Add missing opening parenthesis
https://mail.gnome.org/archives/gnome-web-list/2014-November/msg00003.html
2014-11-13 17:49:31 +00:00
Sébastien Wilmet
20f6cc2a10 Simplify code that uses g_queue_insert_before() and insert_after()
g_queue_insert_before() and g_queue_insert_after() now accept a NULL
sibling.

https://bugzilla.gnome.org/show_bug.cgi?id=736620
2014-11-09 20:42:50 +01:00
Sébastien Wilmet
8a90f5e9f6 GQueue: accept a NULL sibling for insert_before() and insert_after()
It simplifies a little bit some code that inserts data relative to a
GList location, that might be NULL for the tail of the queue. A NULL
sibling is probably less useful for insert_after(), so it's more for
consistency with insert_before().

https://bugzilla.gnome.org/show_bug.cgi?id=736620
2014-11-09 20:42:49 +01:00
Dan Winship
b3e3ed7386 gmain: don't pass the same fd to g_poll() multiple times
If a given fd is being polled by multiple sources, we used to pass it
multiple times to g_poll(), which is technically illegal (and not
supported by the select()-based fallback implementation of poll() in
gpoll.c), and also made it more likely that we'd exceed the maximum
number of pollfds.

Fix it to merge together "duplicate" GPollFDs. The easiest way to do
this involves re-sorting context->poll_records into fd order rather
than priority order. This means we now have to walk the entire pollrec
list for every g_main_context_query() and g_main_context_poll(),
rather than only walking the list up to the current max_priority.
However, this will only have a noticeable effect if you have tons of
GPollFDs, and we're already too slow in that case anyway because of
other O(n) operations that happen too often. So this shouldn't change
much (and the new poll API will eventually let us be cleverer).

Remove some win32-specific code which did the same thing (but was
O(n^2)).

https://bugzilla.gnome.org/show_bug.cgi?id=11059
2014-10-29 17:19:20 -04:00
Ryan Lortie
817f82da6c GOption: stop calling getopt()
We called getopt() to try to find out of the platform on which we are
running defaults to strict POSIX-style argument handling (ie: flags
following the first filename are considered as further filenames rather
than flags).

This is the default case on BSDs, for example.  It is also the case on
GNU systems with the POSIXLY_CORRECT environment variable set.

Unfortunately many of our tools rely on being able to accept commandline
arguments in the non-strict ordering and the code for making these calls
is spread widely (for example in Makefile fragments invoking some of our
build tools).

For this reason we need to revert the getopt() check and only enable
strict POSIX mode in the case that the application explicitly opts into
it using the _set_strict_posix() API.

This also fixs a failure to build on Windows due to missing getopt().

https://bugzilla.gnome.org/show_bug.cgi?id=723160
2014-10-20 14:34:52 +02:00
Ryan Lortie
e9b7c70240 GHashTable: small docs fix
We use g_hash_table_unref() here, not g_object_unref().
2014-10-17 14:39:09 +02:00
Benjamin Berg
18745ff674 Allow hash table destroy notifiers to remove other entries
With this patch it is fine to call g_hash_table_lookup and
g_hash_table_remove from destroy notification functions. Before
this could lead to an infinitie loop if g_hash_table_remove_all
was used.

https://bugzilla.gnome.org/show_bug.cgi?id=695082
2014-10-17 14:29:26 +02:00
Ryan Lortie
ae52ab3d11 GOption: add strict posix mode
Add a "posixly correct" mode to GOption to stop parsing arguments as
soon as the first non-option argument is encountered.

We determine the default value on the basis of duplicating the behaviour
of the system getopt() implementation (which we directly check the
behaviour of at runtime).  On GNU systems this allows the user to modify
our behaviour using POSIXLY_CORRECT.

The user can change the value by g_option_context_set_strict_posix(),
which might be useful for some usecases of GOptionContext (as mentioned
in the doc string of this new function).

https://bugzilla.gnome.org/show_bug.cgi?id=723160
2014-10-15 23:37:45 +02:00
Matthias Clasen
26c66ab1b9 Clarify g_propagate_error docs
I just ran into a bug that was caused by having src being a
persistent GError* that was not cleared after propagating it.
2014-10-10 14:17:56 -04:00
Benjamin Gilbert
0bfea5e772 Fix g_cond_timed_wait() timeout with !CLOCK_MONOTONIC
g_get_monotonic_time() and g_get_real_time() now always use different
clocks, so we cannot avoid correcting for their offset.  Fixes failure
to time out on Mac OS X.

https://bugzilla.gnome.org/show_bug.cgi?id=738197
2014-10-10 06:41:55 -04:00
Aleksander Morgado
549e7b0de6 garray: initialize allocated size in g_byte_array_new_take()
Internal allocation size (array->alloc) was being kept to 0 when a new
GByteArray was created from an already existing heap-allocated buffer.

Among other things, this was making g_byte_array_set_size() fully clear all
the buffer contents (not just the newly allocated memory) when
G_DEBUG=gc-friendly was being used...

  if (G_UNLIKELY (g_mem_gc_friendly))
    memset (array->data + array->alloc, 0, want_alloc - array->alloc);

https://bugzilla.gnome.org/show_bug.cgi?id=738170
2014-10-08 20:51:47 +02:00
Michael Catanzaro
4454b81536 Fix typo 2014-10-05 12:11:21 -05:00