2204,2205c2204,2205 < /* Skip first character regardless and leading whitespace. */ < for (i = 1; i < len; i++) { --- > /* Skip leading whitespace. */ > for (i = 0; i < len; i++) { 2215c2215,2216 < && (data[i - 2] != '.')) { --- > && (data[i - 2] != '.') > && (data[i-2]!='!') && (data[i-2]!='?')) { 2220a2222,2229 > /* Skip trailing whitespace. > * i<=len iff there was a non-space in the line. In that case, we > * strip spaces from the end of the line. Note that "line" means the > * whole paragraph. */ > if (i<=len) { > for(i=len-1; i>0 && isspace((int) data[i]); i--); > data[i+1] = '\0'; > } 2223a2233,2248 > /* Calculate the screen display width of the first size characters of > * string buf. This code was mostly copied from winio.c:strlenpt. It > * is needed in nano_disabled_msg, below. */ > int strnlenpt(char *buf, int size) { > int i, tabs = 0; > > if (buf==NULL) return 0; > for(i=0; i tabs++; > if (buf[i] == NANO_CONTROL_I) { > if (tabs%tabsize != 0) tabs += tabsize - (tabs % tabsize); > } else if (buf[i] < 32) tabs++; > } > return tabs; > } > 2336,2349d2360 < /* Start at fill , unless line isn't that long (but it < * appears at least fill long with tabs. < */ < if (slen > fill) < i = fill; < else < i = slen; < < for (; i > 0; i--) { < if (isspace((int) current->data[i]) && < ((strlenpt(current->data) - strlen(current->data + i)) < <= fill)) < break; < } 2351,2352c2362,2387 < if (!i) < break; --- > /* The following code maybe could be better. In particular, can we > * merely increment instead of calling strnlenpt for each new character? > * In fact, can we assume the only tabs are at the beginning of the line? > */ > /* Note that we CAN break before the first word, since that is how > * pico does it. */ > int last_space = -1; /* index of the last breakpoint */ > int allowed_width; > > i = qdepth * strlen(quotestr); /* the line starts with > indentation, so we must skip it! */ > allowed_width = fill - i; /* how wide can our lines be? */ > > for(; i if (isspace((int) current->data[i])) last_space = i; > if (last_space!=-1 && > strnlenpt(current->data,i) >= allowed_width) { > i = last_space; > break; > } > } > /* Now data[i] is a space. We want to break at the LAST space in this > * group. Probably, the only possibility is two in a row, but let's be > * generic. Note that we actually replace this final space with \0. Is > * this okay? It seems to work fine. */ > for(; idata[i+1]); i++) ;