]> Chaos Git - console/taihen-parser.git/commitdiff
parser: add support for GAME section
authorJon Feldman <chaos.kagami@gmail.com>
Mon, 9 Oct 2017 17:51:48 +0000 (13:51 -0400)
committerJon Feldman <chaos.kagami@gmail.com>
Mon, 9 Oct 2017 19:26:14 +0000 (15:26 -0400)
src/parser.c

index 65a732d5b87ef13f3dff872b3960586798584f68..638de5136705003d90bed2ea870e0d4a74e7c692 100644 (file)
@@ -16,6 +16,7 @@
 
 static const char *TOKEN_ALL_SECTION = "ALL";
 static const char *TOKEN_KERNEL_SECTION = "KERNEL";
+static const char *TOKEN_GAME_SECTION = "GAME";
 
 #ifdef NO_STRING
 #include <stddef.h>
@@ -42,6 +43,18 @@ static int strcmp(const char * s1, const char * s2)
     return (*s1 - *s2);
 }
 
+static int strncmp(const char * s1, const char * s2, size_t count)
+{
+    while ((*s1) && (*s1 == *s2) && count != 0)
+    {
+        ++s1;
+        ++s2;
+        --count;
+    }
+    if (count == 0) return 0;
+    return (*s1 - *s2);
+}
+
 #endif // NO_STRING
 
 static inline int is_continuation_byte(char b)
@@ -243,6 +256,11 @@ void taihen_config_parse(const char *input, const char *section, taihen_config_h
             {
                 record_entries = 1;
             }
+            else if (strcmp(ctx.line_pos, TOKEN_GAME_SECTION) == 0 && strcmp(section, TOKEN_KERNEL_SECTION) != 0 &&
+                     strlen(section) == 9 && strncmp(section, "PCS", 3) == 0 && section[3] >= 'A' && section[3] <= 'H')
+            {
+                record_entries = 1;
+            }
             else if (strcmp(section, ctx.line_pos) == 0)
             {
                 record_entries = 1;