Add safe_strtoint() helper
Adds a safe strtol helper function, modeled loosely after Wayland
scanner's strtouint. This encapsulates the various quirks of strtol
behavior, and streamlines the interface to just handling base-10 numbers
with a simple true/false error indicator and a uint32_t return by
reference.
Test cases are loosely derived from an earlier patch by Imran Zaman.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
diff --git a/Makefile.am b/Makefile.am
index a2d0050..32627f5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1111,6 +1111,7 @@
shared_tests = \
config-parser.test \
+ string.test \
vertex-clip.test \
zuctest
@@ -1209,6 +1210,12 @@
$(AM_CFLAGS) \
-I$(top_srcdir)/tools/zunitc/inc
+string_test_SOURCES = \
+ tests/string-test.c \
+ shared/string-helpers.h
+string_test_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
+string_test_LDADD = libtest-client.la
+
vertex_clip_test_SOURCES = \
tests/vertex-clip-test.c \
shared/helpers.h \