summaryrefslogtreecommitdiffstats
path: root/main/glib/strtoul.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/glib/strtoul.c')
-rw-r--r--main/glib/strtoul.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/main/glib/strtoul.c b/main/glib/strtoul.c
index 7ca41b6..61b37d7 100644
--- a/main/glib/strtoul.c
+++ b/main/glib/strtoul.c
@@ -30,6 +30,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * Modified (removed locale) for use in Micromonitor
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -40,8 +42,11 @@ __FBSDID("$FreeBSD$");
#include <limits.h>
#include <ctype.h>
+#include <errno.h>
#include <stdlib.h>
+#define HAVE_ERRNO 0
+
/*
* Convert a string to an unsigned long integer.
*
@@ -115,11 +120,20 @@ strtoul(const char *__restrict nptr, char **__restrict endptr, int base)
}
if(any < 0) {
acc = ULONG_MAX;
+#if HAVE_ERRNO
+ errno = ERANGE;
+#endif
} else if(!any) {
+#if HAVE_ERRNO
+noconv:
+ errno = EINVAL;
+#endif
} else if(neg) {
acc = -acc;
}
+#if !HAVE_ERRNO
noconv:
+#endif
if(endptr != NULL) {
*endptr = (char *)(any ? s - 1 : nptr);
}