You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static_assert(sizeof(unsigned long long int) ==sizeof(size_t), "The original author designed this for x86_64 machine with the compiler that expects unsigned long long int and size_t to be the same thing, so they could use strtoull() function to parse it. Please adjust this code for your case and maybe even send the patch to upstream to make it work on a wider range of environments.");
251
+
char*endptr;
252
+
// TODO: replace strtoull with a custom solution
253
+
// That way we can get rid of the dependency on errno and static_assert
254
+
unsigned long long intresult=strtoull(arg, &endptr, 10);
255
+
256
+
// TODO: handle more multiplicative suffixes like in dd(1). From the dd(1) man page:
257
+
// > N and BYTES may be followed by the following
258
+
// > multiplicative suffixes: c =1, w =2, b =512, kB =1000, K
259
+
// > =1024, MB =1000*1000, M =1024*1024, xM =M, GB
260
+
// > =1000*1000*1000, G =1024*1024*1024, and so on for T, P,
261
+
// > E, Z, Y.
262
+
if (strcmp(endptr, "K") ==0) {
263
+
result *= 1024;
264
+
} elseif (strcmp(endptr, "M") ==0) {
265
+
result *= 1024*1024;
266
+
} elseif (strcmp(endptr, "G") ==0) {
267
+
result *= 1024*1024*1024;
268
+
} elseif (strcmp(endptr, "") !=0) {
269
+
c->flag_error=FLAG_ERROR_INVALID_SIZE_SUFFIX;
270
+
c->flag_error_name=flag;
271
+
// TODO: capability to report what exactly is the wrong suffix
0 commit comments