diff -u nano/nano.c nano-justify/nano.c --- nano/nano.c Mon Sep 30 17:06:32 2002 +++ nano-justify/nano.c Sat Oct 5 23:46:18 2002 @@ -1973,14 +1973,32 @@ back = line->data + skip; front = back; for (; *front; front++) { + int remove_space = 0; + /* Do we want to remove this space? */ + if (*front == '\t') { if (!changes_allowed) return 1; *front = ' '; } /* these tests are safe since line->data + skip is not a space */ - if (*front == ' ' && *(front - 1) == ' ' && *(front - 2) != '.' && - *(front - 2) != '!' && *(front - 2) != '?') { + if (*front == ' ' && *(front-1) == ' ') { + const char *brackets = "'\")}]>"; + const char *punct = ".?!"; + const char *bob = front - 2; + + remove_space = 1; + for (bob = front - 2; bob >= line->data + skip; bob--) { + if (strchr(punct, *bob) != NULL) { + remove_space = 0; + break; + } + if (strchr(brackets, *bob) == NULL) + break; + } + } + + if (remove_space) { /* Now *front is a space we want to remove. We do that by * simply failing to assign it to *back */ if (!changes_allowed)