aboutsummaryrefslogtreecommitdiff
path: root/src/lzma/util.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-06-11 15:08:44 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-06-11 15:08:44 +0300
commit0ea98e52ba87453497b1355c51f13bad55c8924a (patch)
tree23bd63c8c2638bee97d137f89679e8437f0391f0 /src/lzma/util.c
parents/decompressed/compressed/ in the command line tool's (diff)
downloadxz-0ea98e52ba87453497b1355c51f13bad55c8924a.tar.xz
Improve command line integer parsing a little in lzma and
lzmadec to make them accept also KiB in addition Ki etc. Fix also memory usage information in lzmadec --help.
Diffstat (limited to '')
-rw-r--r--src/lzma/util.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lzma/util.c b/src/lzma/util.c
index 6ef6eb0d..4bdbf8ec 100644
--- a/src/lzma/util.c
+++ b/src/lzma/util.c
@@ -60,20 +60,25 @@ str_to_uint64(const char *name, const char *value, uint64_t min, uint64_t max)
if (*value != '\0') {
// Look for suffix.
static const struct {
- const char *name;
+ const char name[4];
uint64_t multiplier;
} suffixes[] = {
- { "k", UINT64_C(1000) },
- { "M", UINT64_C(1000000) },
- { "G", UINT64_C(1000000000) },
- { "Ki", UINT64_C(1024) },
- { "Mi", UINT64_C(1048576) },
- { "Gi", UINT64_C(1073741824) },
- { NULL, 0 }
+ { "k", UINT64_C(1000) },
+ { "kB", UINT64_C(1000) },
+ { "M", UINT64_C(1000000) },
+ { "MB", UINT64_C(1000000) },
+ { "G", UINT64_C(1000000000) },
+ { "GB", UINT64_C(1000000000) },
+ { "Ki", UINT64_C(1024) },
+ { "KiB", UINT64_C(1024) },
+ { "Mi", UINT64_C(1048576) },
+ { "MiB", UINT64_C(1048576) },
+ { "Gi", UINT64_C(1073741824) },
+ { "GiB", UINT64_C(1073741824) }
};
uint64_t multiplier = 0;
- for (size_t i = 0; suffixes[i].name != NULL; ++i) {
+ for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i) {
if (strcmp(value, suffixes[i].name) == 0) {
multiplier = suffixes[i].multiplier;
break;