/* ScummVM - Scumm Interpreter * Copyright (C) 2006 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $URL$ * $Id$ * */ #include "parallaction/defs.h" #include "parallaction/parser.h" namespace Parallaction { char _tokens[20][40]; static char *_src = NULL; void parseInit(char *s) { _src = s; } char *parseNextLine(char *s, uint16 count) { uint16 _si; char v2 = 0; for ( _si = 0; _si 0) { v4 = parseNextToken(v4, _tokens[_si], 40, " \t\n"); if (_tokens[_si][0] == '"' && _tokens[_si][strlen(_tokens[_si]) - 1] != '"') { v4 = parseNextToken(v4, _tokens[_si+1], 40, "\"\"\""); strcat(_tokens[_si], _tokens[_si+1]); _tokens[_si][0] = ' '; v4++; } v4 = skip_whitespace(v4); _si++; } return _si; } // looks for next token in a string // // scans 's' until one of the stop-chars in 'brk' is found // builds a token and return the part of the string which hasn't been parsed char *parseNextToken(char *s, char *tok, uint16 count, const char *brk) { while (*s != '\0') { if (brk[0] == *s) break; if (brk[1] == *s) break; if (brk[2] == *s) break; *tok++ = *s++; } *tok = '\0'; return s; } char *skip_whitespace(char *s) { while (*s == 0x20 || *s == 0xA || *s == 0x9) s++; return s; } } // namespace Parallaction