2001-04-03 David Mosberger <davidm@hpl.hp.com>
[deliverable/binutils-gdb.git] / libiberty / strtol.c
index 37d170660f2522a6380f4b82a06c158289a511e8..7095c7254bed03516ad86ed8681069f36ab6dd09 100644 (file)
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
+ * 3. [rescinded 22 July 1999]
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  * SUCH DAMAGE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#include <ctype.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
 #include <errno.h>
-#if 0
-#include <stdlib.h>
+#ifdef NEED_DECLARATION_ERRNO
+extern int errno;
 #endif
-#include "ansidecl.h"
+#include "safe-ctype.h"
 
 /* FIXME: It'd be nice to configure around these, but the include files are too
    painful.  These macros should at least be more portable than hardwired hex
@@ -80,7 +84,7 @@ strtol(nptr, endptr, base)
         */
        do {
                c = *s++;
-       } while (isspace(c));
+       } while (ISSPACE(c));
        if (c == '-') {
                neg = 1;
                c = *s++;
@@ -116,10 +120,10 @@ strtol(nptr, endptr, base)
        cutlim = cutoff % (unsigned long)base;
        cutoff /= (unsigned long)base;
        for (acc = 0, any = 0;; c = *s++) {
-               if (isdigit(c))
+               if (ISDIGIT(c))
                        c -= '0';
-               else if (isalpha(c))
-                       c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+               else if (ISALPHA(c))
+                       c -= ISUPPER(c) ? 'A' - 10 : 'a' - 10;
                else
                        break;
                if (c >= base)
This page took 0.023362 seconds and 4 git commands to generate.