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 atoi
 7
 8int
 9atoi(const char *s)
10{
11	int n, d, sign = -1;
12
13	while (isspace(*s))
14		++s;
15
16	switch (*s) {
17	case '-':
18		sign = 1;
19	case '+':
20		++s;
21	}
22
23	/* Compute n as a negative number to avoid overflow on INT_MIN */
24	for (n = 0; (d = _dtoi(*s)) < 10; ++s)
25		n = n*10 - d;
26
27	return sign * n;
28}