Merge "16kb: bionic: Re-align libtest_invalid-empty_shdr_table.so to 16kb" into main
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index aa76b96..df50806 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:
@@ -2584,6 +2584,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