From: David Lawrence Ramsey Date: Sat, 11 Sep 2004 21:28:36 +0000 (+0000) Subject: for more compatibility with Pico, remove extra space after a character X-Git-Tag: v1.3.5~187 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=fd73c462f4a733f66e7fdb6d78110f0ceaf20751;p=nano.git for more compatibility with Pico, remove extra space after a character in punct if that character is the same as the one before it git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1933 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index e784c94d..62adf7f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,11 @@ CVS code - die_save_file() - Clarify the error message when there are too many backup files and the current one can't be written. (DLR) + justify_format() + - For more compatibility with Pico, remove extra space after a + character in punct if that character is the same as the one + before it. For example, with the default values of punct and + brackets, only one space will be left after "...". (DLR) do_para_begin(), do_para_end() - Maintain current_y's value when moving up or down lines so that smooth scrolling works correctly. (DLR) diff --git a/src/nano.c b/src/nano.c index eb6011f0..2c3c8970 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1833,9 +1833,9 @@ size_t indent_length(const char *line) #ifndef DISABLE_JUSTIFY /* justify_format() replaces Tab by Space and multiple spaces by 1 - * (except it maintains 2 after a character in punct followed by a - * character in brackets). Note that the terminating \0 counts as a - * space. + * (except it maintains 2 after a non-repeated character in punct + * followed by a character in brackets). Note that the terminating \0 + * counts as a space. * * justify_format() might make line->data shorter, and change the actual * pointer with null_at(). @@ -1864,12 +1864,16 @@ void justify_format(filestruct *line, size_t skip) /* These tests are safe since line->data + skip is not a * space. */ if ((*front == '\0' || *front == ' ') && *(front - 1) == ' ') { - const char *bob = front - 2; + const char *bob = back - 2; remove_space = TRUE; - for (bob = back - 2; bob >= line->data + skip; bob--) { + for (; bob >= line->data + skip; bob--) { if (strchr(punct, *bob) != NULL) { - remove_space = FALSE; + /* If this character is in punct, don't remove the + * space unless this character and the character + * before it are the same. */ + remove_space = (bob > line->data + skip && + *bob == *(bob - 1)); break; } if (strchr(brackets, *bob) == NULL)