diff options
Diffstat (limited to 'apps/wps-display.c')
-rw-r--r-- | apps/wps-display.c | 20 |
1 files changed, 12 insertions, 8 deletions
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) | |||
83 | 83 | ||
84 | while (*buf) | 84 | while (*buf) |
85 | { | 85 | { |
86 | switch (*buf++) | 86 | switch (*buf) |
87 | { | 87 | { |
88 | case '\r': | 88 | case '\r': |
89 | *(buf - 1) = 0; | 89 | *buf = 0; |
90 | break; | 90 | break; |
91 | 91 | ||
92 | case '\n': /* LF */ | 92 | case '\n': /* LF */ |
93 | *(buf - 1) = 0; | 93 | *buf = 0; |
94 | line++; | ||
95 | 94 | ||
96 | if (line < MAX_LINES) | 95 | if (++line < MAX_LINES) |
97 | { | 96 | { |
98 | format_lines[line] = buf; | 97 | /* the next line starts on the next byte */ |
98 | format_lines[line] = buf+1; | ||
99 | } | 99 | } |
100 | |||
101 | break; | 100 | break; |
102 | } | 101 | } |
102 | buf++; | ||
103 | } | 103 | } |
104 | 104 | ||
105 | if(buf != format_lines[line]) | ||
106 | /* the last line didn't terminate with a newline */ | ||
107 | line++; | ||
108 | |||
105 | for (; line < MAX_LINES; line++) | 109 | for (; line < MAX_LINES; line++) |
106 | { | 110 | { |
107 | format_lines[line] = NULL; | 111 | format_lines[line] = NULL; |