From b4043cb4035677319c3e3455e7724896d9f32250 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Dec 2007 01:47:45 +0000 Subject: Bugfix for correctly handling \n characters in WordWrap method svn-id: r29903 --- engines/lure/surface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/lure/surface.cpp') diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp index 05da32c2bb..5cdd338ab1 100644 --- a/engines/lure/surface.cpp +++ b/engines/lure/surface.cpp @@ -352,13 +352,13 @@ void Surface::wordWrap(char *text, uint16 width, char **&lines, uint8 &numLines) (uint32)(wordStart - text), (uint32)((wordEnd == NULL) ? -1 : wordEnd - text), newLine ? 1 : 0); if (wordEnd) { - if (!newLine) --wordEnd; + if (*wordEnd != '\0') --wordEnd; } else { wordEnd = strchr(wordStart, '\0') - 1; } int wordBytes = (int) (wordEnd - s + 1); - uint16 wordSize = textWidth(s, wordBytes); + uint16 wordSize = (wordBytes == 0) ? 0 : textWidth(s, wordBytes); if (gDebugLevel >= ERROR_DETAILED) { char wordBuffer[MAX_DESC_SIZE]; strncpy(wordBuffer, wordStart, wordBytes); @@ -375,7 +375,7 @@ void Surface::wordWrap(char *text, uint16 width, char **&lines, uint8 &numLines) } else if (newLine) { // Break on newline ++numLines; - *wordEnd = '\0'; + *++wordEnd = '\0'; lineWidth = 0; } else { // Add word's length to total for line -- cgit v1.2.3