MCPcopy Create free account
hub / github.com/coreutils/coreutils / parse_size

Function parse_size

src/stdbuf.c:63–81  ·  view source on GitHub ↗

Set size to the value of STR, interpreted as a decimal integer, optionally multiplied by various values. Return -1 on error, 0 on success. This supports dd BLOCK size suffixes. Note we don't support dd's b=512, c=1, w=2 or 21x512MiB formats. */

Source from the content-addressed store, hash-verified

61 This supports dd BLOCK size suffixes.
62 Note we don't support dd's b=512, c=1, w=2 or 21x512MiB formats. */
63static int
64parse_size (char const *str, size_t *size)
65{
66 uintmax_t tmp_size;
67 enum strtol_error e = xstrtoumax (str, NULL, 10,
68 &tmp_size, "EGkKMPQRTYZ0");
69 if (e == LONGINT_OK && SIZE_MAX < tmp_size)
70 e = LONGINT_OVERFLOW;
71
72 if (e == LONGINT_OK)
73 {
74 errno = 0;
75 *size = tmp_size;
76 return 0;
77 }
78
79 errno = (e == LONGINT_OVERFLOW ? EOVERFLOW : errno);
80 return -1;
81}
82
83void
84usage (int status)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected