-const char* CScriptParser::GetToken(bool bAllowLinebreaks) {
- int c = 0, len;
- char token[MAX_TOKEN_STRING];
- bool bNewLines = false;
-
- m_pLastScriptSection = m_pScriptSection;
-
- len = 0;
- *token = '\0';
-
- if(!m_pScript || !m_pScriptSection) {
- return MakeToken(token);
- }
-
- while ( true ) {
- SkipWhitespace( &bNewLines );
- if ( !*m_pScriptSection ) {
- return MakeToken(token);
- }
- if ( bNewLines && !bAllowLinebreaks ) {
- return MakeToken(token);
- }
-
- c = *m_pScriptSection;
-
- if ( c == '/' && m_pScriptSection[1] == '/' ) { // C style comments
- m_pScriptSection += 2;
- while (*m_pScriptSection && *m_pScriptSection != '\n') {
- m_pScriptSection++;
- }
- } else if ( c=='/' && m_pScriptSection[1] == '*' ) { // C++ style comments
- m_pScriptSection += 2;
- while ( *m_pScriptSection && ( *m_pScriptSection != '*' || m_pScriptSection[1] != '/' ) ) {
- m_pScriptSection++;
- }
- if ( *m_pScriptSection ) {
- m_pScriptSection += 2;
- }
- } else {
- break;
- }
- }
-
- if (c == '\"') {
- m_pScriptSection++;
- while ( true ) {
- c = *m_pScriptSection++;
- if (c=='\"' || !c) {
- token[len] = 0;
- return MakeToken(token);
- }
- if (len < MAX_TOKEN_STRING) {
- token[len] = c;
- len++;
- }
- }
- }
-
- do {
- if(len > 0 && IsBreakChar(*m_pScriptSection)) {
- break;
- }
-
- if (len < MAX_TOKEN_STRING) {
- token[len] = c;
- len++;
- }
- m_pScriptSection++;
-
- if(IsBreakChar(c)) {
- break;
- }
-
- c = *m_pScriptSection;
- } while (c > 32);
-
- if (len == MAX_TOKEN_STRING) {
- len = 0;
- }
- token[len] = 0;
-
- return MakeToken(token);
+const char *CScriptParser::GetToken(bool bAllowLinebreaks)
+{
+ int c = 0, len;
+ char token[MAX_TOKEN_STRING];
+ bool bNewLines = false;
+
+ m_pLastScriptSection = m_pScriptSection;
+
+ len = 0;
+ *token = '\0';
+
+ if (!m_pScript || !m_pScriptSection) {
+ return MakeToken(token);
+ }
+
+ while (true) {
+ SkipWhitespace(&bNewLines);
+ if (!*m_pScriptSection) {
+ return MakeToken(token);
+ }
+ if (bNewLines && !bAllowLinebreaks) {
+ return MakeToken(token);
+ }
+
+ c = *m_pScriptSection;
+
+ if (c == '/' && m_pScriptSection[1] == '/') { // C style comments
+ m_pScriptSection += 2;
+ while (*m_pScriptSection && *m_pScriptSection != '\n') {
+ m_pScriptSection++;
+ }
+ } else if (c == '/' && m_pScriptSection[1] == '*') { // C++ style comments
+ m_pScriptSection += 2;
+ while (*m_pScriptSection && (*m_pScriptSection != '*' || m_pScriptSection[1] != '/')) {
+ m_pScriptSection++;
+ }
+ if (*m_pScriptSection) {
+ m_pScriptSection += 2;
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (c == '\"') {
+ m_pScriptSection++;
+ while (true) {
+ c = *m_pScriptSection++;
+ if (c == '\"' || !c) {
+ token[len] = 0;
+ return MakeToken(token);
+ }
+ if (len < MAX_TOKEN_STRING) {
+ token[len] = c;
+ len++;
+ }
+ }
+ }
+
+ do {
+ if (len > 0 && IsBreakChar(*m_pScriptSection)) {
+ break;
+ }
+
+ if (len < MAX_TOKEN_STRING) {
+ token[len] = c;
+ len++;
+ }
+ m_pScriptSection++;
+
+ if (IsBreakChar(c)) {
+ break;
+ }
+
+ c = *m_pScriptSection;
+ } while (c > 32);
+
+ if (len == MAX_TOKEN_STRING) {
+ len = 0;
+ }
+ token[len] = 0;
+
+ return MakeToken(token);