summaryrefslogtreecommitdiff
path: root/coreutils/head.c
diff options
context:
space:
mode:
author"Vladimir N. Oleynik"2006-01-30 11:15:11 +0000
committer"Vladimir N. Oleynik"2006-01-30 11:15:11 +0000
commite75b41d9905d91b388b18d4395dae72ab17d31b7 (patch)
tree142f634a50b1df75150d9794dd52f4cb0898769d /coreutils/head.c
parentb1fd52e0b7e58a678766d2f67190d9b30399b628 (diff)
downloadbusybox-e75b41d9905d91b388b18d4395dae72ab17d31b7.zip
busybox-e75b41d9905d91b388b18d4395dae72ab17d31b7.tar.gz
support GNU suffixes for fancy mode: b(512), k(1024) and m(1024*1024)
Diffstat (limited to 'coreutils/head.c')
-rw-r--r--coreutils/head.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/coreutils/head.c b/coreutils/head.c
index 17d3ef8..184e816 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -25,6 +25,15 @@ static const char head_opts[] =
#endif
;
+#if ENABLE_FEATURE_FANCY_HEAD
+static const struct suffix_mult head_suffixes[] = {
+ { "b", 512 },
+ { "k", 1024 },
+ { "m", 1024*1024 },
+ { NULL, 0 }
+};
+#endif
+
static const char header_fmt_str[] = "\n==> %s <==\n";
int head_main(int argc, char **argv)
@@ -75,7 +84,14 @@ int head_main(int argc, char **argv)
#if !ENABLE_DEBUG_YANK_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
GET_COUNT:
#endif
+
+#if !ENABLE_FEATURE_FANCY_HEAD
count = bb_xgetularg10(p);
+#else
+ count = bb_xgetularg_bnd_sfx(p, 10,
+ 0, ULONG_MAX,
+ head_suffixes);
+#endif
break;
default:
bb_show_usage();