scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1#include <ctype.h>
 2#include <stdlib.h>
 3
 4#include "../libc.h"
 5
 6#undef atol
 7
 8long
 9atol(const char *s)
10{
11	int d, sign = -1;
12	long n;
13
14	while (isspace(*s))
15		++s;
16
17	switch (*s) {
18	case '-':
19		sign = 1;
20	case '+':
21		++s;
22	}
23
24	/* Compute n as a negative number to avoid overflow on LONG_MIN */
25	for (n = 0; (d = _dtoi(*s)) < 10; ++s)
26		n = n*10 - d;
27
28	return sign * n;
29}