cinera.c: Fix template validity checking

This commit is contained in:
Matt Mascarenhas 2018-09-20 01:13:41 +01:00
parent 9d0cdfb488
commit c4ef54c742
1 changed files with 8 additions and 7 deletions

View File

@ -17,7 +17,7 @@ typedef struct
version CINERA_APP_VERSION = { version CINERA_APP_VERSION = {
.Major = 0, .Major = 0,
.Minor = 6, .Minor = 6,
.Patch = 2 .Patch = 3
}; };
#include <stdarg.h> // NOTE(matt): varargs #include <stdarg.h> // NOTE(matt): varargs
@ -3935,7 +3935,7 @@ RecordTag:
return RC_INVALID_TEMPLATE; return RC_INVALID_TEMPLATE;
} }
if(FoundSearch) if(!HaveErrors && FoundIncludes && FoundSearch)
{ {
Template->Metadata.Validity |= PAGE_SEARCH; Template->Metadata.Validity |= PAGE_SEARCH;
} }
@ -3949,7 +3949,8 @@ RecordTag:
{ {
if(Type == TEMPLATE_SEARCH && !(Template->Metadata.Validity & PAGE_SEARCH)) if(Type == TEMPLATE_SEARCH && !(Template->Metadata.Validity & PAGE_SEARCH))
{ {
CopyStringToBuffer(&Errors, "Search template %s must include one <!-- __CINERA_SEARCH__ --> tag\n", Template->File.Path); if(!FoundIncludes) { CopyStringToBuffer(&Errors, "%sSearch template%s must include one <!-- __CINERA_INCLUDES__ --> tag\n", ColourStrings[CS_ERROR], ColourStrings[CS_END]); };
if(!FoundSearch) { CopyStringToBuffer(&Errors, "%sSearch template%s must include one <!-- __CINERA_SEARCH__ --> tag\n", ColourStrings[CS_ERROR], ColourStrings[CS_END]); };
fprintf(stderr, "%s", Errors.Location); fprintf(stderr, "%s", Errors.Location);
DeclaimBuffer(&Errors); DeclaimBuffer(&Errors);
FreeTemplate(Template); FreeTemplate(Template);
@ -3957,10 +3958,10 @@ RecordTag:
} }
else if((Type == TEMPLATE_PLAYER || Type == TEMPLATE_BESPOKE) && !(Template->Metadata.Validity & PAGE_PLAYER)) else if((Type == TEMPLATE_PLAYER || Type == TEMPLATE_BESPOKE) && !(Template->Metadata.Validity & PAGE_PLAYER))
{ {
if(!FoundIncludes){ CopyStringToBuffer(&Errors, "Player template %s must include one <!-- __CINERA_INCLUDES__ --> tag\n", Template->File.Path); }; if(!FoundIncludes){ CopyStringToBuffer(&Errors, "%s%slayer template%s must include one <!-- __CINERA_INCLUDES__ --> tag\n", ColourStrings[CS_ERROR], Type == TEMPLATE_BESPOKE ? "Bespoke p" : "P", ColourStrings[CS_END]); };
if(!FoundMenus){ CopyStringToBuffer(&Errors, "Player template %s must include one <!-- __CINERA_MENUS__ --> tag\n", Template->File.Path); }; if(!FoundMenus){ CopyStringToBuffer(&Errors, "%s%slayer template%s must include one <!-- __CINERA_MENUS__ --> tag\n", ColourStrings[CS_ERROR], Type == TEMPLATE_BESPOKE ? "Bespoke p" : "P", ColourStrings[CS_END]); };
if(!FoundPlayer){ CopyStringToBuffer(&Errors, "Player template %s must include one <!-- __CINERA_PLAYER__ --> tag\n", Template->File.Path); }; if(!FoundPlayer){ CopyStringToBuffer(&Errors, "%s%slayer template%s must include one <!-- __CINERA_PLAYER__ --> tag\n", ColourStrings[CS_ERROR], Type == TEMPLATE_BESPOKE ? "Bespoke p" : "P", ColourStrings[CS_END]); };
if(!FoundScript){ CopyStringToBuffer(&Errors, "Player template %s must include one <!-- __CINERA_SCRIPT__ --> tag\n", Template->File.Path); }; if(!FoundScript){ CopyStringToBuffer(&Errors, "%s%slayer template%s must include one <!-- __CINERA_SCRIPT__ --> tag\n", ColourStrings[CS_ERROR], Type == TEMPLATE_BESPOKE ? "Bespoke p" : "P", ColourStrings[CS_END]); };
fprintf(stderr, "%s", Errors.Location); fprintf(stderr, "%s", Errors.Location);
DeclaimBuffer(&Errors); DeclaimBuffer(&Errors);
FreeTemplate(Template); FreeTemplate(Template);