dd: code shrink
[oweals/busybox.git] / util-linux / dmesg.c
index 412bf024bbd12f151870522ca6d3984f95e1545e..81ba1c9d14c59870f1e5e65732bd04572be55df4 100644 (file)
@@ -13,7 +13,6 @@
 //usage:       "[-c] [-n LEVEL] [-s SIZE]"
 //usage:#define dmesg_full_usage "\n\n"
 //usage:       "Print or control the kernel ring buffer\n"
-//usage:     "\nOptions:"
 //usage:     "\n       -c              Clear ring buffer after printing"
 //usage:     "\n       -n LEVEL        Set console logging level"
 //usage:     "\n       -s SIZE         Buffer size"
@@ -60,16 +59,15 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
                int last = '\n';
                int in = 0;
 
-               /* Skip <#> at the start of lines */
+               /* Skip <[0-9]+> at the start of lines */
                while (1) {
                        if (last == '\n' && buf[in] == '<') {
-                               in += 3;
-                               if (in >= len)
-                                       break;
+                               while (buf[in++] != '>' && in < len)
+                                       ;
+                       } else {
+                               last = buf[in++];
+                               putchar(last);
                        }
-                       last = buf[in];
-                       putchar(last);
-                       in++;
                        if (in >= len)
                                break;
                }