logcat: white and blacklist failure

- logcat improperly squashes out count
- logcat test enhanced to catch failure
- logd places entries in ascending sorted order

Change-Id: If39d8e2c40852b520c98e7840034ab63c2538e5d
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index 5960609..5a80efe 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -807,7 +807,10 @@
         // squash out the byte count
         cp = buf;
         if (!truncated) {
-            while (isdigit(*cp) || (*cp == '\n')) {
+            while (isdigit(*cp)) {
+                ++cp;
+            }
+            if (*cp == '\n') {
                 ++cp;
             }
         }
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
index 818a978..0c75695 100644
--- a/logcat/tests/logcat_test.cpp
+++ b/logcat/tests/logcat_test.cpp
@@ -601,7 +601,7 @@
 
     ASSERT_EQ(true, get_white_black(&list));
 
-    static const char adjustment[] = "~! ~1000";
+    static const char adjustment[] = "~! 300/20 300/25 2000 ~1000/5 ~1000/30";
     ASSERT_EQ(true, set_white_black(adjustment));
     ASSERT_EQ(true, get_white_black(&adjust));
     if (strcmp(adjustment, adjust)) {
@@ -611,6 +611,16 @@
     free(adjust);
     adjust = NULL;
 
+    static const char adjustment2[] = "300/20 300/21 2000 ~1000";
+    ASSERT_EQ(true, set_white_black(adjustment2));
+    ASSERT_EQ(true, get_white_black(&adjust));
+    if (strcmp(adjustment2, adjust)) {
+        fprintf(stderr, "ERROR: '%s' != '%s'\n", adjustment2, adjust);
+    }
+    ASSERT_STREQ(adjustment2, adjust);
+    free(adjust);
+    adjust = NULL;
+
     ASSERT_EQ(true, set_white_black(list));
     ASSERT_EQ(true, get_white_black(&adjust));
     if (strcmp(list, adjust)) {