diff --git a/ChangeLog b/ChangeLog index f2931991c17b5b59286f15211d924e7490d1d527..3fa7ae0d0ab3ab43796648db390fc90fd6d647b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,9 +3,6 @@ CVS code - - Miscellaneous comment fixes. (DLR) - Remove unnecessary #ifdef around termios.h #include in nano.c. (DLR) -- text.c: - justify_format() - - Remove redundant character parsing. (DLR) GNU nano 1.3.10 - 2005.12.23 - General: diff --git a/src/text.c b/src/text.c index f89262d34d3c807373503e526c7cc4c145ab92a1..fa62d5e10f3819f7b16d6cf9cf9d0d804b4b39f3 100644 --- a/src/text.c +++ b/src/text.c @@ -744,11 +744,13 @@ void justify_format(filestruct *paragraph, size_t skip) new_end = new_paragraph_data + skip; while (*end != '\0') { - int end_len = parse_mbchar(end, NULL, NULL); + int end_len; - /* If this character is blank, make sure that it's a space with - * no blanks after it. */ + /* If this character is blank, change it to a space if + * necessary, and skip over all blanks after it. */ if (is_blank_mbchar(end)) { + end_len = parse_mbchar(end, NULL, NULL); + *new_end = ' '; new_end++; end += end_len; @@ -768,10 +770,12 @@ void justify_format(filestruct *paragraph, size_t skip) #endif } /* If this character is punctuation optionally followed by a - * bracket and then followed by blanks, make sure there are no - * more than two blanks after it, and make sure that the blanks - * are spaces. */ + * bracket and then followed by blanks, change no more than two + * of the blanks to spaces if necessary, and skip over all + * blanks after them. */ } else if (mbstrchr(punct, end) != NULL) { + end_len = parse_mbchar(end, NULL, NULL); + while (end_len > 0) { *new_end = *end; new_end++; @@ -821,8 +825,10 @@ void justify_format(filestruct *paragraph, size_t skip) #endif } /* If this character is neither blank nor punctuation, leave it - * alone. */ + * unchanged. */ } else { + end_len = parse_mbchar(end, NULL, NULL); + while (end_len > 0) { *new_end = *end; new_end++; @@ -836,7 +842,7 @@ void justify_format(filestruct *paragraph, size_t skip) *new_end = *end; - /* Make sure that there are no spaces at the end of the line. */ + /* If there are spaces at the end of the line, remove them. */ while (new_end > new_paragraph_data + skip && *(new_end - 1) == ' ') { new_end--;