]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
glib-2.0: Reset errno before calling strto*() functions. af236c9595e80803ff0e9b38b352e6a5153f4985 94/head
authorJeremy Philippe <jeremy.philippe@gmail.com>
Fri, 3 Jan 2020 23:41:37 +0000 (00:41 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 6 Jan 2020 08:34:27 +0000 (09:34 +0100)
Standard library functions only set errno on error and these particular
functions return an "in-band" error indicator (the error indicator is
also a normal return value).

vapi/glib-2.0.vapi

index 6a2109f3ea0ad5454230cefc9f3d1a549c88e111..e4ce4dcd6ea23e0060b119d0d69a55fc7efb89d5 100644 (file)
@@ -155,6 +155,7 @@ public struct int {
 
        public static bool try_parse (string str, out int result = null, out unowned string unparsed = null, uint _base = 0) {
                char* endptr;
+               errno = 0;
                long long_result = strtol (str, out endptr, (int) _base);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";
@@ -215,6 +216,7 @@ public struct uint {
 
        public static bool try_parse (string str, out uint result = null, out unowned string unparsed = null, uint _base = 0) {
                char* endptr;
+               errno = 0;
                ulong ulong_result = strtoul (str, out endptr, (int) _base);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";
@@ -316,6 +318,7 @@ public struct long {
 
        public static bool try_parse (string str, out long result = null, out unowned string unparsed = null, uint _base = 0) {
                char* endptr;
+               errno = 0;
                result = strtol (str, out endptr, (int) _base);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";
@@ -366,6 +369,7 @@ public struct ulong {
 
        public static bool try_parse (string str, out ulong result = null, out unowned string unparsed = null, uint _base = 0) {
                char* endptr;
+               errno = 0;
                result = strtoul (str, out endptr, (int) _base);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";
@@ -770,6 +774,7 @@ public struct int64 {
        [Version (since = "2.12")]
        public static bool try_parse (string str, out int64 result = null, out unowned string unparsed = null, uint _base = 0) {
                char* endptr;
+               errno = 0;
                result = ascii_strtoll (str, out endptr, _base);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";
@@ -829,6 +834,7 @@ public struct uint64 {
 
        public static bool try_parse (string str, out uint64 result = null, out unowned string unparsed = null, uint _base = 0) {
                char* endptr;
+               errno = 0;
                result = ascii_strtoull (str, out endptr, _base);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";
@@ -910,6 +916,7 @@ public struct float {
 
        public static bool try_parse (string str, out float result = null, out unowned string unparsed = null) {
                char* endptr;
+               errno = 0;
                result = strtof (str, out endptr);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";
@@ -991,6 +998,7 @@ public struct double {
 
        public static bool try_parse (string str, out double result = null, out unowned string unparsed = null) {
                char* endptr;
+               errno = 0;
                result = ascii_strtod (str, out endptr);
                if (endptr == (char*) str + str.length) {
                        unparsed = "";