summaryrefslogtreecommitdiffstats
path: root/main/glib/strtol.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/glib/strtol.c')
-rw-r--r--main/glib/strtol.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/main/glib/strtol.c b/main/glib/strtol.c
index ce18845..1890c5a 100644
--- a/main/glib/strtol.c
+++ b/main/glib/strtol.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,10 @@ __FBSDID("$FreeBSD$");
#include <limits.h>
#include <ctype.h>
+#include <errno.h>
#include <stdlib.h>
+#define HAVE_ERRNO 0
/*
* Convert a string to a long integer.
@@ -137,12 +141,20 @@ strtol(const char *__restrict nptr, char **__restrict endptr, int base)
}
if(any < 0) {
acc = neg ? LONG_MIN : LONG_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);
}