Commit Graph

189 Commits

Author SHA1 Message Date
Dan Winship
6e4a7fca43 Require C90 compliance
Assume all supported platforms implement C90, and therefore they
(correctly) implement atexit(), memmove(), setlocale(), strerror(),
and vprintf(), and have <float.h> and <limits.h>.

(Also remove the configure check testing that "do ... while (0)" works
correctly; the non-do/while-based version of G_STMT_START and
G_STMT_END was removed years ago, but the check remained. Also, remove
some checks that configure.ac claimed were needed for libcharset, but
aren't actually used.)

Note that removing the g_memmove() function is not an ABI break even
on systems where g_memmove() was previously not a macro, because it
was never marked GLIB_AVAILABLE_IN_ALL or listed in glib.symbols, so
it would have been glib-internal since 2004.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:16:16 -05:00
Philip Withnall
cb889d9580 gstrfuncs: Mention nullability in g_ascii_strcasecmp() documentation
Like strcmp(), g_ascii_strcasecmp() requires that both of its parameters
be non-%NULL.
2013-11-14 18:06:32 +00:00
Michael Catanzaro
5627452048 gstrfuncs: fix small typo in documentation 2013-11-07 18:41:29 -06:00
Xavier Claessens
4fea5c0029 Fix wrong function names in g_str_match_string() documentation 2013-10-15 11:02:40 -04:00
Ryan Lortie
38dfce5992 Add simple string "search" function
Add a pair of functions to make it easier to do simple string matching.

This will be useful for use with things like GtkSearchBar and will also
be the basis of the searching done by the (soon to appear)
g_desktop_app_info_search()

https://bugzilla.gnome.org/show_bug.cgi?id=709753
2013-10-14 16:48:42 -04:00
Ryan Lortie
4c510801cf Add g_str_is_ascii()
Add a function for checking if a string is pure ASCII.

https://bugzilla.gnome.org/show_bug.cgi?id=709753
2013-10-14 16:48:37 -04:00
John Ralls
ab5aa2aa3a Fix the -Werror=format-nonliteral fixes for older GCCs
They don't allow that pragma inside functions.
2013-09-29 11:33:30 -07:00
John Ralls
09d83640a8 More -Werror=format-nonliteral fixes
This fixes the build with CLang.

https://bugzilla.gnome.org/show_bug.cgi?id=702516
2013-09-29 11:03:16 -04:00
Sebastian Dröge
bcbaf1bef0 Fix compilation on Android with the bionic C library
https://bugzilla.gnome.org/show_bug.cgi?id=689223
2013-04-16 13:24:26 +02:00
David King
0a13464df8 docs: Elaborate replacement for g_strncasecmp
https://bugzilla.gnome.org/show_bug.cgi?id=568405
2013-03-17 22:58:03 -04:00
Sebastian Dröge
c9affa778e Revert "Fix compilation on Android with the bionic C library"
This reverts commit cb0ed84d40.

It wasn't meant to be pushed yet.
2012-11-28 16:55:12 +01:00
Sebastian Dröge
cb0ed84d40 Fix compilation on Android with the bionic C library 2012-11-28 16:32:48 +01:00
Matthias Clasen
4c255d4602 Be more careful when using xlocale
Bug 680074 shows that we may end up in situations where only
some of the xlocale functions we need are available. Rather than
trying to find the minimal set of required functions for each
use, define a global USE_XLOCALE and only use any xlocale functions
if we have a full set.
2012-07-19 06:32:29 -04:00
Matthias Clasen
dd098405ad Cosmetic: Fix up line endings
Somehow a few ^M sneaked in here.
2012-07-19 06:20:41 -04:00
Robert Ancell
4143842eb4 Add missing allow-none annotations for function parameters.
Found using:
find . -name '*.c' | xargs grep 'or %NULL' | grep ' \* @' | grep -v '@error' | grep -v allow-none
2012-03-31 20:34:28 +11:00
Ravi Sankar Guntur
8ca2647c74 Fix to handle '\v' (vertical tab) by g_strescape() and g_strcompress().
fix enables g_strescape() and g_strcompress() to handle '\v' along with other
special characters - '\b', '\f', '\n', '\r', '\t', '\'.

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

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
2011-12-27 21:49:19 -05:00
Simon McVittie
0bf8378840 g_strcompress: check that source is non-NULL rather than just crashing
Calling this function with a NULL argument is considered to be invalid,
but one of the regression tests does it anyway (to watch it crash), which
seems a good indication that it's expected to be somewhat common.
Let's check it rather than segfaulting.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666113
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-12-14 12:26:17 +00:00
Stef Walter
7e92997539 documentation fixes
Fixes for gtk-doc warnings.

http://bugzilla.gnome.org/show_bug.cgi?id=66469

https://bugzilla.gnome.org/show_bug.cgi?id=664699
2011-12-13 23:01:51 -05:00
Matthias Clasen
65eb65b777 Avoid unused variable warnings in g_ascii_strtod 2011-11-14 23:30:18 -05:00
Chun-wei Fan
faebf0f653 gstrfuncs.c: Fix variable declaration
Declare variables at top of block to stop C89 compilers from complaining.
2011-11-12 10:38:31 +08:00
Kristian Rietveld
f218353e04 Need to include xlocale.h on Darwin for strtod_l
This fixes the build of gstrfuncs.c on Darwin.
2011-11-09 08:32:33 +01:00
Matthias Clasen
e52437982c Make g_ascii_strtod behave as documented
The docs explicitly state that we reset errno, so lets do that,
even if we just wrap strtod_l. Also move the argument check
out of the ifdef.

https://bugzilla.gnome.org/show_bug.cgi?id=662398
2011-10-21 15:00:14 -04:00
Matthias Clasen
2f71118e78 More include cleanups 2011-10-17 02:14:39 -04:00
Matthias Clasen
d9053e026c Make things compile again 2011-10-17 01:52:10 -04:00
Matthias Clasen
0e3f530185 Remove cruft from g_strerror and g_strsignal
We can just assume that strerror/strsignal are available
nowadays. At the same time, drop use of thread-private storage.
Instead, always return interned strings.

https://bugzilla.gnome.org/show_bug.cgi?id=660849
2011-10-05 01:12:53 -04:00
Ryan Lortie
47444dacc0 Deprecate g_thread_init()
Move the last few things that needed thread-safe initialisation to a
global ctor.

https://bugzilla.gnome.org/show_bug.cgi?id=660744
2011-10-04 15:31:49 -04:00
Matthias Clasen
ca77b0e252 Move string utility docs inline 2011-10-01 22:48:27 -04:00
Jasper Lievisse Adriaanse
e147d7aa2f Fix URL to strlcpy(3) manpage in comment. 2011-10-01 10:46:52 +02:00
Matthias Clasen
e02b062635 Use xlocale functions where available
Implement g_ascii_strto{d,ll,ull} and g_ascii_formatd using
xlocale functions where available. This is slightly faster
and a lot less icky than our homegrown code.

https://bugzilla.gnome.org/show_bug.cgi?id=640293
2011-09-17 22:48:39 -04:00
Matthias Clasen
1b28408b8b Spelling fixes
Spelling fixes in comments and docs, provided by
Kjartan Maraas in bug 657336.
2011-08-29 14:49:32 -04:00
Ryan Lortie
5dbc12e9f1 Replace @Varargs with @...
to make gtk-doc happy.
2011-07-22 15:47:24 +02:00
Ryan Lortie
8073759f8c Remove all uses of G_CONST_RETURN
Just use 'const'.

https://bugzilla.gnome.org/show_bug.cgi?id=644611
2011-06-09 11:15:40 -04:00
Dan Winship
e56498ee0b Fix usage of _GNU_SOURCE
_GNU_SOURCE must be defined before including any other (system)
header, so defining it in glib-unix.h (and hoping no one has included
anything else before that) is wrong. And the "#define _USE_GNU"
workaround for this problem in gnetworkingprivate.h is even wronger
(and still prone to failure anyway due to single-include guards).

Fix this by defining _GNU_SOURCE in config.h when building against
glibc. In theory this is bad because new releases of glibc may include
symbols that conflict with glib symbols, which could then cause
compile failures. However, most people only see new releases of glibc
when they upgrade their distro, at which point they also generally get
new releases of gcc, which have new warnings/errors to clean up
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=649201
2011-05-03 07:07:41 -04:00
Emmanuele Bassi
08f0a31289 Revert "Remove all uses of G_CONST_RETURN"
This reverts commit 36741245cc.

The removal has not been discussed, except on Bugzilla:

https://bugzilla.gnome.org/show_bug.cgi?id=644611
2011-03-15 09:03:28 +00:00
Ryan Lortie
36741245cc Remove all uses of G_CONST_RETURN
Just use 'const'.
2011-03-15 01:32:22 -04:00
Matthias Clasen
04077ff5c5 More include cleanups 2010-09-03 23:03:14 -04:00
Jon Nordby
fb15dde6c1 docs: Inline docs from tmpl/memory.smgl 2010-09-01 09:48:16 +02:00
Ryan Lortie
7791fce38a Fix some glib docs warnings
Remove some symbols from glib-sections.txt that gtk-doc has no idea
about.

Add proper callback typedefs for GTester (gtk-doc dislikes inline
function types).

Fix some other minor issues.
2010-07-12 16:56:52 -04:00
Matthias Clasen
7cfa23b177 Add a note about l10n to the g_strconcat docs
As requested in bug 576854
2010-07-08 19:03:18 -04:00
Ryan Lortie
2e53e50244 glib/: fully remove galias hacks 2010-07-07 19:34:35 -04:00
Christian Persch
41b3f6885d Add g_dc[p]gettext, and use it in gsettings
Avoid using LC_MESSAGES, and just call g_d[c]gettext directly.

Bug #617004.
2010-05-20 21:16:29 +02:00
Ryan Lortie
7b6c8a5605 g_strlcpy doc: small fixup
prevent the <note> from getting sucked in as part of the Returns:
2010-01-30 12:32:37 -05:00
Matthias Clasen
91925d2cf0 Another possible error code clash, yay 2009-07-10 13:11:28 -04:00
Matthias Clasen
b71046b70f Fix a typo
svn path=/trunk/; revision=7818
2009-01-19 07:01:57 +00:00
Matthias Clasen
34928d8d05 Move docs inline
svn path=/trunk/; revision=7761
2009-01-03 04:15:17 +00:00
Matthias Clasen
0f6b25ca96 Fix some compiler warnings
svn path=/trunk/; revision=7755
2008-12-31 05:51:47 +00:00
Ryan Lortie
2cf0f4853a [REVERT] Bug 548612 – g_strstr_len() should use memmem when available
2008-08-28  Ryan Lortie  <desrt@desrt.ca>

        [REVERT] Bug 548612 – g_strstr_len() should use memmem when available

        * glib/gstrfuncs.c (g_strstr_len): fix off-by-one memory access error
        * glib/tests/strfuncs.c (test_bounds): add some new test cases that
        would catch problems like this
        * glib/tests/4096-random-bytes: test data for the previous
        * glib/tests/Makefile.am: add previous to EXTRA_DIST


svn path=/trunk/; revision=7414
2008-08-28 23:03:24 +00:00
Ryan Lortie
ef4df848e0 [REVERT] Bug 548612 – g_strstr_len() should use memmem when available
2008-08-28  Ryan Lortie  <desrt@desrt.ca>

        [REVERT] Bug 548612 – g_strstr_len() should use memmem when available

        * configure.in:
        * glib/gstrfuncs.c (g_strstr_len): revert use of memmem (see bug)


svn path=/trunk/; revision=7413
2008-08-28 22:55:36 +00:00
Michael Natterer
13fe35b66d make "endptr" const since it's always a pointer into the const string
2008-08-28  Michael Natterer  <mitch@imendio.com>

	* glib/gstrfuncs.c (g_parse_long_long): make "endptr" const since
	it's always a pointer into the const string passed. Remove some
	casting to (gchar*) in this function.

	(g_ascii_strtoull)
	(g_ascii_strtoll): cast "endptr" to (const gchar**) here when
	passing it to above function.


svn path=/trunk/; revision=7410
2008-08-28 14:47:56 +00:00
Bastien Nocera
f84518e35b Bug 548612 – g_strstr_len() should use memmem when available
2008-08-28  Bastien Nocera  <hadess@hadess.net>

	Bug 548612 – g_strstr_len() should use memmem when available

	* glib/tests/strfuncs.c (test_strstr):
	* tests/string-test.c (main): Patch by Paolo Borelli
	<pborelli@katamail.com> to move the tests to the right place,
	and add more tests

	* glib/gstrfuncs.c (g_strstr_len): Fix problem with memmem ignoring
	nul-terminators in strings, and using the haystack_len instead


svn path=/trunk/; revision=7409
2008-08-28 12:53:59 +00:00