Mercurial > hg > toybox
comparison lib/lib.c @ 715:3417db95f24b
Add expand command as described in POSIX-2008.
Erratum: Do not handle backspace.
author | Jonathan Clairembault <jonathan@clairembault.fr> |
---|---|
date | Fri, 23 Nov 2012 00:06:28 +0100 |
parents | 50d759f8b371 |
children | 075eaff297f8 |
comparison
equal
deleted
inserted
replaced
714:ed026abefd63 | 715:3417db95f24b |
---|---|
1180 else return xmsprintf("%llu%c", size, units[index]); | 1180 else return xmsprintf("%llu%c", size, units[index]); |
1181 } | 1181 } |
1182 return NULL; //not reached | 1182 return NULL; //not reached |
1183 } | 1183 } |
1184 | 1184 |
1185 // strtoul with exit on error | |
1186 unsigned long xstrtoul(const char *nptr, char **endptr, int base) | |
1187 { | |
1188 unsigned long l; | |
1189 errno = 0; | |
1190 l = strtoul(nptr, endptr, base); | |
1191 if (errno) | |
1192 perror_exit("xstrtoul"); | |
1193 return l; | |
1194 } | |
1195 | |
1185 /* | 1196 /* |
1186 * used to get the interger value. | 1197 * used to get the interger value. |
1187 */ | 1198 */ |
1188 unsigned long get_int_value(const char *numstr, unsigned lowrange, unsigned highrange) | 1199 unsigned long get_int_value(const char *numstr, unsigned lowrange, unsigned highrange) |
1189 { | 1200 { |