From 78ca3a89b94dea261c88441df044709dd4ca8e7a Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Thu, 11 Sep 2014 15:15:25 +0200 Subject: simplify and generalize deh_allow_extended_strings usage --- src/deh_io.c | 3 +-- src/deh_main.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/deh_io.c b/src/deh_io.c index 46f4c9fb..fa02aa2e 100644 --- a/src/deh_io.c +++ b/src/deh_io.c @@ -28,7 +28,6 @@ #include "deh_defs.h" #include "deh_io.h" -#include "deh_main.h" typedef enum { @@ -251,7 +250,7 @@ char *DEH_ReadLine(deh_context_t *context, boolean extended) } // extended string support - if (deh_allow_extended_strings && extended && c == '\\') + if (extended && c == '\\') { c = DEH_GetChar(context); diff --git a/src/deh_main.c b/src/deh_main.c index 55e26c70..be1e5611 100644 --- a/src/deh_main.c +++ b/src/deh_main.c @@ -88,6 +88,14 @@ static deh_section_t *GetSectionByName(char *name) { unsigned int i; + // we explicitely do not recognize [STRINGS] sections at all + // if extended strings are not allowed + + if (!deh_allow_extended_strings && !strncasecmp("[STRINGS]", name, 9)) + { + return NULL; + } + for (i=0; deh_section_types[i] != NULL; ++i) { if (!strcasecmp(deh_section_types[i]->name, name)) @@ -253,14 +261,14 @@ static void DEH_ParseContext(deh_context_t *context) DEH_Error(context, "This is not a valid dehacked patch file!"); } + // extended string support required? + + bexstr = GetSectionByName("[STRINGS]"); + // Read the file for (;;) { - // extended string support required? - - bexstr = GetSectionByName("[STRINGS]"); - // read a new line line = DEH_ReadLine(context, bexstr && current_section == bexstr); -- cgit v1.2.3