From 88aeb7140cd46bf14009d463e2d5209684d405ec Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 4 Sep 2002 14:17:41 +0000 Subject: custom wps without an ending newline should still be OK git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2173 a1c6a512-1295-4272-9138-f99709370657 --- apps/wps-display.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'apps') diff --git a/apps/wps-display.c b/apps/wps-display.c index 3bd921ba3c..f21edb002a 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c @@ -83,25 +83,29 @@ static void wps_format(char* fmt) while (*buf) { - switch (*buf++) + switch (*buf) { case '\r': - *(buf - 1) = 0; - break; + *buf = 0; + break; case '\n': /* LF */ - *(buf - 1) = 0; - line++; + *buf = 0; - if (line < MAX_LINES) + if (++line < MAX_LINES) { - format_lines[line] = buf; + /* the next line starts on the next byte */ + format_lines[line] = buf+1; } - break; } + buf++; } + if(buf != format_lines[line]) + /* the last line didn't terminate with a newline */ + line++; + for (; line < MAX_LINES; line++) { format_lines[line] = NULL; -- cgit v1.2.3