From 8beb99064006b9256a1ef02ec0650443cd18da1c Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 28 Oct 2013 21:26:30 +0000 Subject: [PATCH] m32script: when failing to load file, don't append '.m32' if already there. So that there are no error messages like "M32 file `a.m32.m32' not found." Also, in build.c's 'save as' code, add a bound check that would probably always pass in practice, but looks a bit safer and may fail in very cornerly cases. git-svn-id: https://svn.eduke32.com/eduke32@4124 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/build.c | 2 +- polymer/eduke32/source/m32def.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 0f797fa88..072d61b1a 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -7770,7 +7770,7 @@ CANCEL: i = 0; while (boardfilename[i] != 0 && i < 64) i++; - if (boardfilename[i-4] == '.') + if (i >= 4 && boardfilename[i-4] == '.') i -= 4; boardfilename[i] = 0; diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index 45219e7c2..f4f38fc9f 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -3677,6 +3677,8 @@ void C_CompilationInfo(void) initprintf(" %d/%d quotes, %d/%d quote redefinitions\n", k,MAXQUOTES, g_numQuoteRedefinitions,MAXQUOTES); } +EDUKE32_STATIC_ASSERT((sizeof(keyw)/sizeof(keyw[0]))-1 == CON_END); + void C_Compile(const char *filenameortext, int32_t isfilename) { char *mptr = NULL; @@ -3719,9 +3721,6 @@ void C_Compile(const char *filenameortext, int32_t isfilename) return; } - if ((sizeof(keyw)/sizeof(keyw[0]))-1 != CON_END) - initprintf("INTERNAL WARNING: keyw[] and CON_END don't match!\n"); - g_scriptPtr = script+1; firstime = 0; @@ -3742,8 +3741,12 @@ void C_Compile(const char *filenameortext, int32_t isfilename) fp = kopen4load(mptr, 0 /*g_loadFromGroupOnly*/); if (fp == -1) // JBF: was 0 { - Bstrcat(&mptr[fs], ".m32"); - fp = kopen4load(mptr, 0 /*g_loadFromGroupOnly*/); + if (fs >= 4 && Bmemcmp(&mptr[fs-4], ".m32", 4) != 0) + { + Bstrcat(&mptr[fs], ".m32"); + fp = kopen4load(mptr, 0 /*g_loadFromGroupOnly*/); + } + if (fp == -1) { initprintf("M32 file `%s' not found.\n", mptr);