mirror of https://git.sr.ht/~rabbits/modal
Added negative numbers support
This commit is contained in:
parent
3d9ecb0b7b
commit
d24af00098
|
@ -34,10 +34,11 @@ walk(char *s)
|
||||||
static int
|
static int
|
||||||
sint(char *s)
|
sint(char *s)
|
||||||
{
|
{
|
||||||
int r = 0;
|
|
||||||
char c;
|
char c;
|
||||||
|
int r = 0, n = 1;
|
||||||
|
if(*s == '-') { n = -1, s++; }
|
||||||
while((c = *s++) && c > 0x20) r = r * 10 + c - '0';
|
while((c = *s++) && c > 0x20) r = r * 10 + c - '0';
|
||||||
return r;
|
return r * n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue