From bd3767068db440322b9846dfb47102233ae80efc Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Thu, 1 Nov 2007 18:16:52 +0000 Subject: dont call trim(), which relies on isspace(), with specific game charset strings svn-id: r29365 --- engines/queen/journal.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'engines/queen') diff --git a/engines/queen/journal.cpp b/engines/queen/journal.cpp index af32be7322..22d746a4a0 100644 --- a/engines/queen/journal.cpp +++ b/engines/queen/journal.cpp @@ -383,9 +383,18 @@ void Journal::handleMouseDown(int x, int y) { void Journal::drawPanelText(int y, const char *text) { debug(7, "Journal::drawPanelText(%d, '%s')", y, text); char s[80]; - strcpy(s, text); + strncpy(s, text, 79); + s[79] = 0; + // remove leading and trailing spaces (necessary for spanish version) + for (char *p = s + strlen(s) - 1; p >= s && *p == ' '; --p) { + *p = 0; + } + for (char *p = s; *p == ' '; ++p) { + *p = 0; + } + // draw the substrings char *p = strchr(s, ' '); - if (p == NULL) { + if (!p) { int x = (128 - _vm->display()->textWidth(s)) / 2; _vm->display()->setText(x, y, s, false); assert(_panelTextCount < MAX_PANEL_TEXTS); @@ -423,14 +432,7 @@ void Journal::drawPanel(const int *frames, const int *titles, int n) { int y = 8; while (n--) { showBob(bobNum++, 32, y, *frames++); - // trim panel texts for spanish version - char buf[128]; - strncpy(buf, _vm->logic()->joeResponse(*titles++), 128); - buf[127] = 0; - if (_vm->resource()->getLanguage() != Common::GR_GRE) - drawPanelText(y + 12, Common::trim(buf)); - else - drawPanelText(y + 12, buf); // don't trim panel text in Greek version + drawPanelText(y + 12, _vm->logic()->joeResponse(*titles++)); y += 48; } } -- cgit v1.2.3