diff options
author | Gregory Montoir | 2007-02-13 21:06:57 +0000 |
---|---|---|
committer | Gregory Montoir | 2007-02-13 21:06:57 +0000 |
commit | 1ce912e1063ae297407b4a9dfd5f30d4819eb284 (patch) | |
tree | a60c5b02027b991908299884d60ada4d014a9b2c /engines | |
parent | 474d49dc146876b773bfef80335b740d1b1fa8a7 (diff) | |
download | scummvm-rg350-1ce912e1063ae297407b4a9dfd5f30d4819eb284.tar.gz scummvm-rg350-1ce912e1063ae297407b4a9dfd5f30d4819eb284.tar.bz2 scummvm-rg350-1ce912e1063ae297407b4a9dfd5f30d4819eb284.zip |
made rtrim() and ltrim() global functions, to reduce code duplication (it seems parallaction/parser.cpp code re-use them too
svn-id: r25564
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agi/predictive.cpp | 15 | ||||
-rw-r--r-- | engines/queen/logic.cpp | 30 |
2 files changed, 9 insertions, 36 deletions
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp index e65e1bf2b4..731384b5c7 100644 --- a/engines/agi/predictive.cpp +++ b/engines/agi/predictive.cpp @@ -315,19 +315,6 @@ bool AgiEngine::predictiveDialog(void) { return rc; } -static char *ltrim(char *t) { - while (isspace(*t)) - t++; - return t; -} - -static char *rtrim(char *t) { - int l = strlen(t) - 1; - while (l >= 0 && isspace(t[l])) - t[l--] = 0; - return t; -} - #define MAXLINELEN 80 void AgiEngine::loadDict(void) { @@ -343,7 +330,7 @@ void AgiEngine::loadDict(void) { while (!in.eos() && in.readLine(buf, MAXLINELEN)) { // Skip leading & trailing whitespaces - char *word = rtrim(ltrim(buf)); + char *word = Common::trim(buf); // Skip empty lines if (*word == 0) diff --git a/engines/queen/logic.cpp b/engines/queen/logic.cpp index 9973386b65..f7a23eeb3d 100644 --- a/engines/queen/logic.cpp +++ b/engines/queen/logic.cpp @@ -44,20 +44,6 @@ namespace Queen { -static Common::String trim(const Common::String &s) { - const char *p; - - p = s.c_str(); - while (*p == ' ') ++p; - int start = p - s.c_str(); - - p = s.c_str() + s.size() - 1; - while (p != s.c_str() && *p == ' ') --p; - int end = p - s.c_str(); - - return Common::String(s.c_str() + start, end - start + 1); -} - Logic::Logic(QueenEngine *vm) : _credits(NULL), _objectData(NULL), _roomData(NULL), _sfxName(NULL), _itemData(NULL), _graphicData(NULL), _walkOffData(NULL), _objectDescription(NULL), @@ -227,16 +213,16 @@ void Logic::readQueenJas() { _joeResponse.push_back(""); for (i = 1; i <= JOE_RESPONSE_MAX; i++) { - _joeResponse.push_back(queen2jas.nextLine()); - } + char *defaultResponse = queen2jas.nextLine(); - // Spanish version adds some space characters (0x20) at the beginning - // and the end of the journal button captions. As the engine computes - // the text width to center it, we need to trim those strings. - if (_vm->resource()->getLanguage() == Common::ES_ESP) { - for (i = 30; i <= 35; i++) { - _joeResponse[i] = trim(_joeResponse[i]); + // In the spanish version, captions of journal buttons have leading & trailing + // whitespaces (they probably did it that way to center the texts). As we do + // differently (see code in journal.cpp), we remove these extra characters here. + if (_vm->resource()->getLanguage() == Common::ES_ESP && i >= 30 && i <= 35) { + defaultResponse = Common::trim(defaultResponse); } + + _joeResponse.push_back(defaultResponse); } _aAnim.push_back(""); |