From 262b68446985507df3b4a5cbc7212dd4969a99bb Mon Sep 17 00:00:00 2001 From: twanvl Date: Tue, 25 Jan 2011 22:42:54 +0000 Subject: [PATCH] don't warn about \' escape sequence. added numeric escapes git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1643 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/script/parser.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/script/parser.cpp b/src/script/parser.cpp index c3d81409..36a0a7b7 100644 --- a/src/script/parser.cpp +++ b/src/script/parser.cpp @@ -288,9 +288,21 @@ void TokenIterator::readStringToken() { } c = input.GetChar(pos++); if (c == _('n')) str += _('\n'); + else if (c == _('r')) str += _('\r'); + else if (c == _('t')) str += _('\t'); + else if (c == _('&')); // escape for nothing else if (c == _('<')) str += _('\1'); // escape for < - else if (c == _('\\') || c == _('"') || c == _('{') || c == _('}')) { - str += c; // \ or { or " + else if (c == _('\\') || c == _('"') || c == _('\'') || c == _('{') || c == _('}')) { + str += c; // \ or { or " or ', don't warn about these, since they look escape-worthy + } else if (c >= _('0') && c <= _('9')) { + // numeric escape + int i = 0; + while (c >= _('0') && c <= _('9')) { + i = i * 10 + static_cast(c - _('0')); + c = input.GetChar(pos++); + } + pos--; + str += static_cast(i); // ignore } else { add_error(String::Format(_("Invalid string escape sequence: \"\\%c\""),c)); str += _('\\') + c; // ignore