From a2df9a56472e744657c8895bf131fa7830dcd901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 28 May 2007 10:34:18 +0000 Subject: [PATCH] Tokenize: Replace '*(var+num)' with 'var[num]' --- tokenize.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tokenize.cpp b/tokenize.cpp index 0e473ae8a..80e88cbcd 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -636,6 +636,35 @@ void Tokenize(const char FileName[]) } } } + + + // Replace "*(str + num)" => "str[num]" + for (TOKEN *tok = tokens; tok; tok = tok->next) + { + if ( ! strchr(";{}(=<>", tok->str[0]) ) + continue; + + TOKEN *next = tok->next; + if ( ! next ) + break; + + if (match(next, "* ( var + num )")) + { + const char *str[4] = {"var","[","num","]"}; + str[0] = getstr(tok,3); + str[2] = getstr(tok,5); + + for (int i = 0; i < 4; i++) + { + tok = tok->next; + free(tok->str); + tok->str = strdup(str[i]); + } + + DeleteNextToken(tok); + DeleteNextToken(tok); + } + } } //---------------------------------------------------------------------------