cpp: Explicitly retain array definitions

Some arrays get default-retained when we reach the semicolon, because
the default solution is to treat them as functions. This strips the
semicolon though, leaving us with invalid syntax.

We should really treat arrays (and variable definitions) as "other
declarations", which can be OK to retain, as they don't rely on
kernel-internal data.

This parser is fairly unsound in general, but it isn't much more unsound
to assume that anything with an '=' token at depth 0 will be a variable
or array definition.

NB: there are existing UAPI arrays that *are* retained [1], because they
happen to look like struct declarations. I maintain that behavior as
well, encoded in the tests.

[1] example from asm/amd_hsmp.h:
static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
...
};

Bug: 369900761
Test: `ANDROID_BUILD_TOP=... pytest ./cpp.py` has no new failures
Test: `bionic/libc/kernel/tools/update_all.py` produces no diff
Change-Id: I5997672436f5ed232fdcd94aafaf792c75fa6bce
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 08b786a..73b9a12 100755
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1430,7 +1430,7 @@
                         state = VAR_DECL
                     elif state == NORMAL and token_id in ['struct', 'typedef',
                                                           'enum', 'union',
-                                                          '__extension__']:
+                                                          '__extension__', '=']:
                         state = OTHER_DECL
                         state_token = token_id
                     elif block.tokens[i].kind == TokenKind.IDENTIFIER:
@@ -2583,6 +2583,70 @@
 """
         self.assertEqual(self.parse(text), expected)
 
+    def test_var_definition(self):
+        # If we're definining the whole thing, it's probably worth keeping.
+        text = """\
+static const char *kString = "hello world";
+static const int kInteger = 42;
+"""
+        expected = """\
+static const char * kString = "hello world";
+static const int kInteger = 42;
+"""
+        self.assertEqual(self.parse(text), expected)
+
+    def test_struct_array_definition(self):
+        text = """\
+struct descriptor {
+  int args;
+  int size;
+};
+static const struct descriptor[] = {
+  {0, 0},
+  {1, 12},
+  {0, 42},
+};
+"""
+        expected = """\
+struct descriptor {
+  int args;
+  int size;
+};
+static const struct descriptor[] = {
+ {
+    0, 0
+  }
+ , {
+    1, 12
+  }
+ , {
+    0, 42
+  }
+ ,
+};
+"""
+        self.assertEqual(self.parse(text), expected)
+
+    def test_array_definition(self):
+        text = """\
+static const char *arr[] = {
+  "foo",
+  "bar",
+  "baz",
+};
+
+static int another_arr[5] = { 1, 2, 3, 4, 5};
+"""
+        expected = """\
+static const char * arr[] = {
+  "foo", "bar", "baz",
+};
+static int another_arr[5] = {
+  1, 2, 3, 4, 5
+};
+"""
+        self.assertEqual(self.parse(text), expected)
+
     def test_token_replacement(self):
         text = """\
 #define SIGRTMIN 32