fix endless word_wrap() loop when a label has a newline and no spaces

This commit is contained in:
Brad Parker 2016-11-27 22:02:10 -05:00
parent d57d672d15
commit ee49eeec09

View File

@ -1911,7 +1911,7 @@ char* word_wrap (char* buffer, char* string, int line_width) {
i++; i++;
} }
/* check for whitespace */ /* check for whitespace */
if ( isspace( string[ i ] ) ) if (string[i] == ' ')
{ {
buffer[i] = '\n'; buffer[i] = '\n';
i++; i++;
@ -1921,7 +1921,7 @@ char* word_wrap (char* buffer, char* string, int line_width) {
/* check for nearest whitespace back in string */ /* check for nearest whitespace back in string */
for ( k = i; k > 0; k--) for ( k = i; k > 0; k--)
{ {
if ( isspace( string[ k ] ) ) if (string[k] == ' ')
{ {
buffer[ k ] = '\n'; buffer[ k ] = '\n';
/* set string index back to character after this one */ /* set string index back to character after this one */