summaryrefslogtreecommitdiff
path: root/libc/misc/atol.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/atol.c')
-rw-r--r--libc/misc/atol.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libc/misc/atol.c b/libc/misc/atol.c
new file mode 100644
index 0000000..901dfe2
--- /dev/null
+++ b/libc/misc/atol.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
+ * This file is part of the Linux-8086 C library and is distributed
+ * under the GNU Library General Public License.
+ */
+
+long
+atol(number)
+register char *number;
+{
+ register long n = 0, neg = 0;
+
+ while (*number <= ' ' && *number > 0)
+ ++number;
+ if (*number == '-')
+ {
+ neg = 1;
+ ++number;
+ }
+ else if (*number == '+')
+ ++number;
+ while (*number>='0' && *number<='9')
+ n = (n * 10) + ((*number++) - '0');
+ return (neg ? -n : n);
+}