aboutsummaryrefslogtreecommitdiff
path: root/lib/x_atoi.c
diff options
context:
space:
mode:
authorKlaatu <[email protected]>2015-05-17 15:33:21 +1200
committerKlaatu <[email protected]>2015-05-17 15:33:21 +1200
commitb0de699679e8f1e39af847ed172d1ba605b4370c (patch)
tree01dac00471d61f727394e508c613b29cff0ceae5 /lib/x_atoi.c
bulk upload of source
Diffstat (limited to 'lib/x_atoi.c')
-rw-r--r--lib/x_atoi.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/x_atoi.c b/lib/x_atoi.c
new file mode 100644
index 0000000..2f6a5fb
--- /dev/null
+++ b/lib/x_atoi.c
@@ -0,0 +1,12 @@
+
+int x_atoi(const char *src) /*EXTRACT_INCL*/ {
+ register const char *s;
+ register long int dest=0;
+ register unsigned char c;
+
+ s=src;
+ if (*s=='-' /* || *s=='+' */) ++s;
+
+ while ((c=*s-'0')<10) { ++s; dest=dest*10 + c; }
+ return (*src=='-') ? -dest : dest;
+}