From 8974228a205a5905c8be4f00afdabdaba858d194 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 18 May 2014 09:55:41 +0000 Subject: [PATCH] C-CON: scan label names according to stricter LunaCON rules instead of char blacklist. These ones: http://lunatic.eduke32.com/lunacon.html#_ambiguous_lexical_elements Seriously, defining a token kind by excluding certain characters (instead of allowing a given set) is really, really broken. git-svn-id: https://svn.eduke32.com/eduke32@4474 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gamedef.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index f6cafa372..5d08c494f 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1423,6 +1423,12 @@ static int32_t isaltok(const char c) c == '*' || c == '-' || c == '_' || c == '.'); } +static int32_t C_IsLabelChar(const char c, int32_t i) +{ + return (isalnum(c) || c=='_' || c=='*' || c=='?' || + (i > 0 && (c=='+' || c=='-' || c=='.'))); +} + static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, hashtable_t *tH, const char *psz) { // find the label psz in the table pLabel. @@ -1446,7 +1452,8 @@ static void C_GetNextLabelName(void) C_SkipComments(); - while (ispecial(*textptr) == 0 && *textptr!='['&& *textptr!=']' && *textptr!='\t' && *textptr!='\n' && *textptr!='\r') +// while (ispecial(*textptr) == 0 && *textptr!='['&& *textptr!=']' && *textptr!='\t' && *textptr!='\n' && *textptr!='\r') + while (C_IsLabelChar(*textptr, i)) label[(g_numLabels<<6)+(i++)] = *(textptr++); label[(g_numLabels<<6)+i] = 0;