ref: 402741bc017cfa9602e7d8ea8645696ace54f4cd
parent: d457a43461852636db313c4854590b2c62a21e23
author: cinap_lenrek <[email protected]>
date: Mon Aug 3 14:30:02 EDT 2015
resample: simplify getint()
--- a/sys/src/cmd/resample.c
+++ b/sys/src/cmd/resample.c
@@ -54,14 +54,13 @@
int
getint(char *s, int *percent)
{
+ int n;
+
if(s == nil)
usage();
- *percent = (s[strlen(s)-1] == '%');
- if(*s == '+')
- return atoi(s+1);
- if(*s == '-')
- return -atoi(s+1);
- return atoi(s);
+ n = strtol(s, &s, 0);
+ *percent = *s == '%';
+ return n;
}
void