DOS/Mac format, at least one line has already been converted,
so setting NOCONVERT (which is supposed to signal that none
of the file should be converted) makes no sense. (DLR)
+- nano.c:
+ justify_format()
+ - Fix ugly behavior when wrapping spaces at the end of long
+ words (David Benbennick).
- nanorc.5:
- Fix formatting error and update copyright year (Jordi).
- Several enhancements (David Benbennick).
back = line->data + skip;
front = back;
- for (; *front; front++) {
+ for (front = back; ; front++) {
int remove_space = 0;
/* Do we want to remove this space? */
*front = ' ';
}
/* these tests are safe since line->data + skip is not a space */
- if (*front == ' ' && *(front - 1) == ' ') {
+ if ((*front == '\0' || *front == ' ') && *(front - 1) == ' ') {
const char *bob = front - 2;
remove_space = 1;
- for (bob = front - 2; bob >= line->data + skip; bob--) {
+ for (bob = back - 2; bob >= line->data + skip; bob--) {
if (strchr(punct, *bob) != NULL) {
remove_space = 0;
break;
if (mark_beginbuf == line && back - line->data < mark_beginx)
mark_beginx--;
#endif
+ if (*front == '\0')
+ *(back - 1) = '\0';
} else {
*back = *front;
back++;
}
+ if (*front == '\0')
+ break;
}
- /* Remove spaces from the end of the line, except maintain 1 after a
- * sentence punctuation. */
- while (line->data < back && *(back - 1) == ' ')
- back--;
- if (line->data < back && *back == ' ' &&
- strchr(punct, *(back - 1)) != NULL)
- back++;
- if (!changes_allowed && back != front)
- return 1;
+ back--;
+ assert(*back == '\0');
/* This assert merely documents a fact about the loop above. */
assert(changes_allowed != 0 || back == front);
/* No space found short enough. */
if (force)
for(; *line != '\0'; line++, cur_loc++)
- if (*line == ' ' && *(line + 1) != ' ')
+ if (*line == ' ' && *(line + 1) != ' ' && *(line + 1) != '\0')
return cur_loc;
return -1;
}