diff options
-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 { |