summaryrefslogtreecommitdiff
path: root/glib/gstrfuncs.c
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2018-12-04 12:51:09 +0000
committerPhilip Withnall <withnall@endlessm.com>2018-12-04 12:51:09 +0000
commit8d0a163000b02c1bae6a0a8b279a11990ce8ad54 (patch)
treeb44105a472890be209b2a8be7e0346e746c66035 /glib/gstrfuncs.c
parentd4cc0b32fd41ef8802b374a6be81f7a38edf2db9 (diff)
downloadglib-8d0a163000b02c1bae6a0a8b279a11990ce8ad54.tar.gz
gstrfuncs: Clarify that g_ascii_strtoull() accepts signed numbers
It’s perverse, but explicitly documented that strtoull() accepts numbers with a leading minus sign (`-`) and explicitly casts them to signed output. g_ascii_strtoull() is documented to do what strtoull() does (but locale independently), and its behaviour is correct. However, the documentation could be a lot clearer about this unexpected behaviour. Add a unit test for it too. Signed-off-by: Philip Withnall <withnall@endlessm.com>
Diffstat (limited to 'glib/gstrfuncs.c')
-rw-r--r--glib/gstrfuncs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index a9889dd50..4bde7dbd1 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -1140,6 +1140,11 @@ g_parse_long_long (const gchar *nptr,
* changing the current locale, since that would not be
* thread-safe.
*
+ * Note that input with a leading minus sign (`-`) is accepted, and will return
+ * the negation of the parsed number, unless that would overflow a #guint64.
+ * Critically, this means you cannot assume that a short fixed length input will
+ * never result in a low return value, as the input could have a leading `-`.
+ *
* This function is typically used when reading configuration
* files or other non-user input that should be locale independent.
* To handle input from the user you should normally use the