diff --git a/Changes b/Changes index 24ede1d..c4dc938 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,8 @@ Release ... was continued after vi had been stopped by ^Z, with the cursor positioned in a line longer than the terminal width as the last line of the current screen. +* Made multicolumn characters work in lines longer than the screen width in + visual mode (Bugreport by Matthew Fischer). * Made it work for Big5 locales (Patches by Matthew Fischer). * Fixed a problem with the 'r' command in EUC-JP and Big5 locales (Bugreport by Matthew Fischer). @@ -13,6 +15,11 @@ Release ... locales now works with terminals that have the 'ic' but no 'im' termcap capability (Bugreport by Matthew Fischer). * The argument to the -w option is correctly recognized now. +* If the SHELL environment variable is set to the empty string, it is now + ignored. +* A non-null exit status is now returned if a file could not be opened. +* If the match for a substitution is of length zero, a line overflow is + now avoided when compiled with the 'UNIX(R) Regular Expression Library'. Release 1/19/05 * The last release erroneously made 'X' work like 'x' in visual mode. It now diff --git a/README b/README index d9f5681..526f57d 100644 --- a/README +++ b/README @@ -10,7 +10,7 @@ changes were made to get closer to the POSIX.2 guidelines for ex and vi. Some issues that were clearly bugs and not features have also been resolved; see the Changes file for details. -New releases are announced on Fresmeat. If you want to get +New releases are announced on Freshmeat. If you want to get notified by email on each release, use their subscription service at . @@ -110,7 +110,7 @@ the erase key once after entering a multibyte character will result in an incomplete byte sequence. -Gunnar Ritter 1/29/05 +Gunnar Ritter 2/15/05 Freiburg i. Br. Germany diff --git a/ex.c b/ex.c index c01ba77..7461788 100644 --- a/ex.c +++ b/ex.c @@ -77,7 +77,7 @@ char *copyright = "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; -static char sccsid[] = "@(#)ex.c 1.35 (gritter) 2/13/05"; +static char sccsid[] = "@(#)ex.c 1.36 (gritter) 2/13/05"; #endif /* DOSCCS */ #endif /* !lint */ @@ -565,7 +565,7 @@ argend: setrupt(); intty = isatty(0); value(PROMPT) = intty; - if (cp = getenv("SHELL")) + if ((cp = getenv("SHELL")) != NULL && *cp != '\0') safecp(shell, cp, sizeof shell, "$SHELL too long"); if (fast || !intty) setterm("dumb"); diff --git a/ex.h b/ex.h index 664ec23..73b6ada 100644 --- a/ex.h +++ b/ex.h @@ -72,7 +72,7 @@ * * from ex.h 7.7.1.1 (Berkeley) 8/12/86 * - * @(#)ex.h 1.49 (gritter) 1/13/05 + * @(#)ex.h 1.50 (gritter) 2/13/05 */ /* @@ -437,6 +437,7 @@ var bool verbose; /* -V option; print command input to stderr */ var JMP_BUF vreslab; /* For error throws to a visual catch */ var bool writing; /* 1 if in middle of a file write */ var int xchng; /* Suppresses multiple "No writes" in !cmd */ +var int failed; /* exit with a non-zero status */ /* * Macros diff --git a/ex_io.c b/ex_io.c index d5a9ebc..fa5a29b 100644 --- a/ex_io.c +++ b/ex_io.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_io.c 1.37 (gritter) 12/2/04"; +static char sccsid[] = "@(#)ex_io.c 1.38 (gritter) 2/13/05"; #endif #endif @@ -428,6 +428,7 @@ rop(int c) return; } } + failed = 1; syserror(); } if (fstat(io, &stbuf)) diff --git a/ex_re.c b/ex_re.c index ef77424..c6a2023 100644 --- a/ex_re.c +++ b/ex_re.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_re.c 1.44 (gritter) 1/9/05"; +static char sccsid[] = "@(#)ex_re.c 1.45 (gritter) 2/13/05"; #endif #endif @@ -682,6 +682,12 @@ ovflo: } lp = loc2; loc2 = sp + (linebuf - genbuf); +#ifdef UXRE + if (loc1 == lp) { + nextc(c, loc2, n); + loc2 += n; + } +#endif /* UXRE */ while (*sp++ = *lp++) if (sp >= &genbuf[LBSIZE]) goto ovflo; diff --git a/ex_subr.c b/ex_subr.c index a72a043..11e3374 100644 --- a/ex_subr.c +++ b/ex_subr.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_subr.c 1.34 (gritter) 1/13/05"; +static char sccsid[] = "@(#)ex_subr.c 1.36 (gritter) 2/15/05"; #endif #endif @@ -659,12 +659,20 @@ qcolumn(register char *lim, register char *gp) int qcount(int c) { + int sc; if (c == '\t') { vcntcol += value(TABSTOP) - vcntcol % value(TABSTOP); return c; } - vcntcol += c & MULTICOL ? 1 : colsc(c); + /* + * Take account of filler characters inserted at the end of + * the visual line if a multi-column character does not fit. + */ + sc = colsc(c); + while (vcntcol < WCOLS && vcntcol + sc - 1 >= WCOLS) + vcntcol++; + vcntcol += c & MULTICOL ? 1 : sc; return c; } @@ -1025,6 +1033,8 @@ exitex(int i) if (trace) fclose(trace); # endif + if (failed != 0 && i == 0) + i = failed; _exit(i); /*NOTREACHED*/ return 0; diff --git a/ex_version.c b/ex_version.c index ed22851..9b58336 100644 --- a/ex_version.c +++ b/ex_version.c @@ -70,12 +70,12 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Sccsid @(#)ex_version.c 1.123 (gritter) 2/13/05 + * Sccsid @(#)ex_version.c 1.124 (gritter) 2/15/05 */ #include "ex.h" -static char *versionstring = "@(#)Version 4.0 (gritter) 2/13/05"; +static char *versionstring = "@(#)Version 4.0 (gritter) 2/15/05"; void printver(void) diff --git a/ex_vput.c b/ex_vput.c index d7fe992..957c940 100644 --- a/ex_vput.c +++ b/ex_vput.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_vput.c 1.47 (gritter) 2/4/05"; +static char sccsid[] = "@(#)ex_vput.c 1.48 (gritter) 2/15/05"; #endif #endif @@ -374,7 +374,9 @@ vgoto(register int y, register int x) } #ifdef MB if (y >= 0 && y <= WLINES && mb_cur_max > 1 && !insmode) { - while (x > 0 && (vtube[y][x]&(MULTICOL|TRIM)) == MULTICOL) + while (x > 0 && (vtube[y][x]&(MULTICOL|TRIM)) == MULTICOL && + vtube[y][x-1] & MULTICOL && + (vtube[y][x-1]&(MULTICOL|TRIM)) != MULTICOL) x--; } #endif /* MB */ @@ -586,6 +588,7 @@ vinschar(int c) register cell *tp; char *OIM; bool OXN; + int noim; insmc1 = colsc(c) - 1; if ((!IM || !EI) && ((hold & HOLDQIK) || !value(REDRAW) || value(SLOWOPEN))) { @@ -739,15 +742,19 @@ vinschar(int c) tabend, tabslack, linend); } #endif - /* - * This code was used to temporarily disable insert mode for - * multi-column characters because of a bug in a terminal program - * used for development that has been fixed in the meantime. It - * remains here just in case similar problems occur again. - */ OIM = IM; OXN = XN; - if (0 && insmc1) { + noim = 0; +#ifdef MB + if (mb_cur_max > 1) { + for (i = inscol; vtube0[i]; i++) + if (i + 1 >= WCOLS && vtube0[i] & MULTICOL) { + noim = 1; + break; + } + } +#endif /* MB */ + if (noim) { endim(); IM = 0; XN = 0; @@ -1072,8 +1079,8 @@ viin(int c) * * You asked for it, you get it. */ - tp = vtube0 + inscol + insmc0 + doomed; - for (i = inscol + insmc0 + doomed; i < tabstart; i++) + tp = vtube0 + inscol + doomed; + for (i = inscol + doomed; i < tabstart; i++) vputchar(*tp++); hold = oldhold; vigotoCL(tabstart + inssiz + insmc0 - doomed); @@ -1235,6 +1242,26 @@ vputchar(register int c) /* Fix problem of >79 chars on echo line. */ if (destcol >= WCOLS-1 && splitw && destline == WECHO) pofix(); +#ifdef MB + if (mb_cur_max > 1) { + if (c == MULTICOL) + return c; + /* + * If a multicolumn character extends beyond the screen + * width, it must be put on the next line. A tilde is + * printed as an indicator but must disappear when the + * text is moved at a later time. + */ + if (c == ('~'|INVBIT|QUOTE)) + c = '~'|INVBIT; + else if (c == ('~'|INVBIT)) + return c; + else if (destcol < WCOLS && destcol + + colsc(c==QUOTE ? ' ' : c&TRIM&~MULTICOL) - 1 + >= WCOLS) + vputchar('~'|INVBIT|QUOTE); + } +#endif /* MB */ if (destcol >= WCOLS) { destline += destcol / WCOLS; destcol %= WCOLS; @@ -1312,7 +1339,7 @@ def: * and if we are in hardopen, that the terminal has overstrike. */ if ((d & ~MULTICOL) == (c & TRIM & ~MULTICOL) && !insmode && - (state != HARDOPEN || OS)) { + (state != HARDOPEN || OS) && c != MULTICOL) { n = colsc(d); for (m = 1; m < n; m++) if ((tp[m] & (MULTICOL|TRIM)) != MULTICOL) @@ -1422,16 +1449,14 @@ def: } } #ifdef MB - if (mb_cur_max > 1 && (d = colsc(c&TRIM)) > 1) { - if ((*tp&MULTICOL) == 0) { + if (mb_cur_max > 1 && (d = colsc(c&TRIM&~MULTICOL)) > 1) { + if ((hold & HOLDPUPD) == 0) + *tp |= MULTICOL; + while (--d) { if ((hold & HOLDPUPD) == 0) - *tp |= MULTICOL; - while (--d) { - if ((hold & HOLDPUPD) == 0) - *++tp = MULTICOL; - destcol++; - outcol++; - } + *++tp = MULTICOL; + destcol++; + outcol++; } } #endif /* MB */