diff options
author | Ari Sundholm <ari@tuxera.com> | 2015-03-04 18:46:48 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-03-22 17:41:04 +0100 |
commit | 8893023ba27ea87b12a333960271c9f86cdebf7b (patch) | |
tree | 09664462b0bb252b1227b689a2240e02ec1b0f5b /coreutils | |
parent | 92edab1aa6eae45ac8fa0cec8c8df9a47f547300 (diff) | |
download | busybox-w32-8893023ba27ea87b12a333960271c9f86cdebf7b.tar.gz busybox-w32-8893023ba27ea87b12a333960271c9f86cdebf7b.tar.bz2 busybox-w32-8893023ba27ea87b12a333960271c9f86cdebf7b.zip |
dd: move suffix struct to xatonum.c
This way it can be used by other applets without duplication.
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/dd.c | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c index 302497074..53a843ca0 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -99,25 +99,6 @@ enum { | |||
99 | ofd = STDOUT_FILENO, | 99 | ofd = STDOUT_FILENO, |
100 | }; | 100 | }; |
101 | 101 | ||
102 | static const struct suffix_mult dd_suffixes[] = { | ||
103 | { "c", 1 }, | ||
104 | { "w", 2 }, | ||
105 | { "b", 512 }, | ||
106 | { "kB", 1000 }, | ||
107 | { "kD", 1000 }, | ||
108 | { "k", 1024 }, | ||
109 | { "K", 1024 }, /* compat with coreutils dd (it also accepts KB and KD, TODO?) */ | ||
110 | { "MB", 1000000 }, | ||
111 | { "MD", 1000000 }, | ||
112 | { "M", 1024*1024 }, | ||
113 | { "GB", 1000000000 }, | ||
114 | { "GD", 1000000000 }, | ||
115 | { "G", 1024*1024*1024 }, | ||
116 | /* "D" suffix for decimal is not in coreutils manpage, looks like it's deprecated */ | ||
117 | /* coreutils also understands TPEZY suffixes for tera- and so on, with B suffix for decimal */ | ||
118 | { "", 0 } | ||
119 | }; | ||
120 | |||
121 | struct globals { | 102 | struct globals { |
122 | off_t out_full, out_part, in_full, in_part; | 103 | off_t out_full, out_part, in_full, in_part; |
123 | #if ENABLE_FEATURE_DD_THIRD_STATUS_LINE | 104 | #if ENABLE_FEATURE_DD_THIRD_STATUS_LINE |
@@ -326,11 +307,11 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
326 | #if ENABLE_FEATURE_DD_IBS_OBS | 307 | #if ENABLE_FEATURE_DD_IBS_OBS |
327 | if (what == OP_ibs) { | 308 | if (what == OP_ibs) { |
328 | /* Must fit into positive ssize_t */ | 309 | /* Must fit into positive ssize_t */ |
329 | ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes); | 310 | ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); |
330 | /*continue;*/ | 311 | /*continue;*/ |
331 | } | 312 | } |
332 | if (what == OP_obs) { | 313 | if (what == OP_obs) { |
333 | obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes); | 314 | obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); |
334 | /*continue;*/ | 315 | /*continue;*/ |
335 | } | 316 | } |
336 | if (what == OP_conv) { | 317 | if (what == OP_conv) { |
@@ -356,22 +337,22 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
356 | } | 337 | } |
357 | #endif | 338 | #endif |
358 | if (what == OP_bs) { | 339 | if (what == OP_bs) { |
359 | ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes); | 340 | ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes); |
360 | obs = ibs; | 341 | obs = ibs; |
361 | /*continue;*/ | 342 | /*continue;*/ |
362 | } | 343 | } |
363 | /* These can be large: */ | 344 | /* These can be large: */ |
364 | if (what == OP_count) { | 345 | if (what == OP_count) { |
365 | G.flags |= FLAG_COUNT; | 346 | G.flags |= FLAG_COUNT; |
366 | count = XATOU_SFX(val, dd_suffixes); | 347 | count = XATOU_SFX(val, cwbkMG_suffixes); |
367 | /*continue;*/ | 348 | /*continue;*/ |
368 | } | 349 | } |
369 | if (what == OP_seek) { | 350 | if (what == OP_seek) { |
370 | seek = XATOU_SFX(val, dd_suffixes); | 351 | seek = XATOU_SFX(val, cwbkMG_suffixes); |
371 | /*continue;*/ | 352 | /*continue;*/ |
372 | } | 353 | } |
373 | if (what == OP_skip) { | 354 | if (what == OP_skip) { |
374 | skip = XATOU_SFX(val, dd_suffixes); | 355 | skip = XATOU_SFX(val, cwbkMG_suffixes); |
375 | /*continue;*/ | 356 | /*continue;*/ |
376 | } | 357 | } |
377 | if (what == OP_if) { | 358 | if (what == OP_if) { |