Support replacing nested kernel structs

When replacing structs with bits/ includes, count the number of
opening and closing braces to find the end of the struct.

Test: tools/update_all.py
Change-Id: Ic9712a385da517710ceffccbdb223c89ae0b5f65
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 5488641..26121ca 100755
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1417,9 +1417,14 @@
                         if struct_name in kernel_struct_replacements:
                             extra_includes.append("<bits/%s.h>" % struct_name)
                             end = i + 2
-                            while end < len(b.tokens) and b.tokens[end].id != '}':
+                            depth = 1
+                            while end < len(b.tokens) and depth > 0:
+                                if b.tokens[end].id == '}':
+                                    depth -= 1
+                                elif b.tokens[end].id == '{':
+                                    depth += 1
                                 end += 1
-                            end += 1 # Swallow '}'
+                            end += 1 # Swallow last '}'
                             while end < len(b.tokens) and b.tokens[end].id != ';':
                                 end += 1
                             end += 1 # Swallow ';'