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/dmesg.c | |
parent | 0016bcee374606e79c48a1a97479b0521f947942 (diff) | |
download | busybox-w32-f04ca74ab5eb6ee57a573c6e1ab3e84d3f0a0af8.tar.gz busybox-w32-f04ca74ab5eb6ee57a573c6e1ab3e84d3f0a0af8.tar.bz2 busybox-w32-f04ca74ab5eb6ee57a573c6e1ab3e84d3f0a0af8.zip |
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/dmesg.c')
-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) | |||
45 | if (len == 0) | 45 | if (len == 0) |
46 | return EXIT_SUCCESS; | 46 | return EXIT_SUCCESS; |
47 | 47 | ||
48 | /* Skip <#> at the start of lines, and make sure we end with a newline */ | ||
49 | 48 | ||
50 | if (ENABLE_FEATURE_DMESG_PRETTY) { | 49 | if (ENABLE_FEATURE_DMESG_PRETTY) { |
51 | int last = '\n'; | 50 | int last = '\n'; |
52 | int in = 0; | 51 | int in = 0; |
53 | 52 | ||
54 | do { | 53 | /* Skip <#> at the start of lines */ |
55 | if (last == '\n' && buf[in] == '<') | 54 | while (1) { |
55 | if (last == '\n' && buf[in] == '<') { | ||
56 | in += 3; | 56 | in += 3; |
57 | else { | 57 | if (in >= len) |
58 | last = buf[in++]; | 58 | break; |
59 | bb_putchar(last); | ||
60 | } | 59 | } |
61 | } while (in < len); | 60 | last = buf[in]; |
61 | putchar(last); | ||
62 | in++; | ||
63 | if (in >= len) | ||
64 | break; | ||
65 | } | ||
66 | /* Make sure we end with a newline */ | ||
62 | if (last != '\n') | 67 | if (last != '\n') |
63 | bb_putchar('\n'); | 68 | bb_putchar('\n'); |
64 | } else { | 69 | } else { |