diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-19 23:08:33 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-19 23:08:33 +0200 |
commit | f04ca74ab5eb6ee57a573c6e1ab3e84d3f0a0af8 (patch) | |
tree | ea91d502006651c8a6c52751f15a16d1081bc3b8 /util-linux | |
parent | 0016bcee374606e79c48a1a97479b0521f947942 (diff) | |
download | busybox-f04ca74ab5eb6ee57a573c6e1ab3e84d3f0a0af8.tar.gz |
dmesg: more correct skipping of <N>; use faster putchar for most output
function old new delta
dmesg_main 246 291 +45
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/dmesg.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index 06a03d3fb..6e43a22f5 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -45,20 +45,25 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv) if (len == 0) return EXIT_SUCCESS; - /* Skip <#> at the start of lines, and make sure we end with a newline */ if (ENABLE_FEATURE_DMESG_PRETTY) { int last = '\n'; int in = 0; - do { - if (last == '\n' && buf[in] == '<') + /* Skip <#> at the start of lines */ + while (1) { + if (last == '\n' && buf[in] == '<') { in += 3; - else { - last = buf[in++]; - bb_putchar(last); + if (in >= len) + break; } - } while (in < len); + last = buf[in]; + putchar(last); + in++; + if (in >= len) + break; + } + /* Make sure we end with a newline */ if (last != '\n') bb_putchar('\n'); } else { |