Apply various features and fixes from NetBSD basesrc:

* Implement options:
	expandtab
	gtagsmode
	matchchars
* Fix tty garbling when quitting from recovery mode.
* Don't coredump during autoindent edge case.
* Set internal version to "nvi-1.81.6nb4 (2009-08-07)"
* Crank pkgrevision to nb4.
This commit is contained in:
lukem 2009-08-07 16:39:20 +00:00
parent 014eac6264
commit 6d74174604
29 changed files with 1277 additions and 7 deletions

View file

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.36 2009/02/22 12:20:17 obache Exp $
# $NetBSD: Makefile,v 1.37 2009/08/07 16:39:20 lukem Exp $
#
DISTNAME= nvi-1.81.6
PKGREVISION= 3
PKGREVISION= 4
CATEGORIES= editors
MASTER_SITES= ${HOMEPAGE}
EXTRACT_SUFX= .tar.bz2

View file

@ -1,6 +1,32 @@
$NetBSD: distinfo,v 1.10 2008/12/21 23:02:24 epg Exp $
$NetBSD: distinfo,v 1.11 2009/08/07 16:39:20 lukem Exp $
SHA1 (nvi-1.81.6.tar.bz2) = d3445ed69166102735335a2ff60d092d9a9143c6
RMD160 (nvi-1.81.6.tar.bz2) = 0db8568bea96392d9a027044177c60317c8ade36
Size (nvi-1.81.6.tar.bz2) = 1758309 bytes
SHA1 (patch-aa) = 3dcd5033fd0d50a17dd3963640ae8f2aea2c8884
SHA1 (patch-aa) = 05b8dedd194b09ed5af1fb62273e771ebd7f4326
SHA1 (patch-ab) = 3687d1006015e84c1f9746b84e167602ae37b7fb
SHA1 (patch-ac) = 3c345cb8871cb887a07ce83bbd43b1c49ebe4b33
SHA1 (patch-ad) = d940a8c748c087aaf131817902d1f51d48b752c6
SHA1 (patch-ae) = ad1f45c2feb26ab68626825cd5a1be1b33c30afb
SHA1 (patch-af) = 69b9fff85c852df143eb1ff99a9d45aa7d83d2c4
SHA1 (patch-ag) = 01df157bd10e03fe28dad7cbb06205c2cfc75691
SHA1 (patch-ah) = c76390627309fecc852fd4fe7b73fc83aedeb060
SHA1 (patch-ai) = 0a08e7f24adb0e6f2868e62cf6016d69ae728bb6
SHA1 (patch-aj) = b81d2f3c320910b11dbb487fff8cd33aa2c23c04
SHA1 (patch-ak) = 1e83a5f50fdb97c37e93536ac90e58513e81f77d
SHA1 (patch-al) = 3d48b2af0f8651b100b82044e267b4d81b6c2772
SHA1 (patch-am) = 65fb052102c91991af9326defeac7c729ba560b5
SHA1 (patch-an) = a6535dfdaceb41209261d729d8b8c2da813149ea
SHA1 (patch-ao) = 5dde6860125272f0687f5156485f3d1f43f6d93b
SHA1 (patch-ap) = f7d23b584a9ea29cf62abf6a1a2e19e6ed120b34
SHA1 (patch-aq) = 88b7c21c564fc817d615f3ae72fbc0dd517bc5f6
SHA1 (patch-ar) = c2f139cc92e8a815345ae81e7cb57d2109ad4564
SHA1 (patch-as) = ca88e0416999ad81098a41d041e51031092d2f4d
SHA1 (patch-at) = 1fc5d51b90d282de9a8c2ed13ff85498167e98f3
SHA1 (patch-au) = c34912b6d07acf95973426b352f55110c936a66f
SHA1 (patch-av) = 218174e98f01ed8344aae44dcc28db77cc0fdc60
SHA1 (patch-aw) = 678945c18fbbd9c5908aee4b1348ddfc2a3bda00
SHA1 (patch-ax) = a93cc5271ff924d561b7d532dec280093637f42d
SHA1 (patch-ay) = db7c5d05a28bb14fb351645de9426b34b659ed4b
SHA1 (patch-az) = ba04f94a768c0c9d72f9810689c2f0c46e2e4e92
SHA1 (patch-ba) = 3249565cb20d4b73acce2cc27945bddb0f9ab0da

View file

@ -1,10 +1,10 @@
$NetBSD: patch-aa,v 1.3 2008/12/21 23:02:24 epg Exp $
$NetBSD: patch-aa,v 1.4 2009/08/07 16:39:20 lukem Exp $
BDB 4.4 and up requires DB_CREATE or it will spew "DB_CREATE must be
specified to create databases." when nvi edits a file.
--- ../common/db.h.orig 2007-11-18 16:41:42.000000000 +0000
+++ ../common/db.h 2008-12-21 00:18:11.000000000 +0000
--- ../common/db.h.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../common/db.h
@@ -16,7 +16,10 @@
(env)->remove(env, path, NULL, flags)
#endif

View file

@ -0,0 +1,13 @@
$NetBSD: patch-ab,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../common/exf.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../common/exf.c
@@ -184,7 +184,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_
CALLOC_RET(sp, ep, EXF *, 1, sizeof(EXF));
CIRCLEQ_INIT(&ep->scrq);
sp->c_lno = ep->c_nlines = OOBLNO;
- ep->rcv_fd = ep->fcntl_fd = -1;
+ ep->fd = ep->rcv_fd = ep->fcntl_fd = -1;
F_SET(ep, F_FIRSTMODIFY);
/*

View file

@ -0,0 +1,14 @@
$NetBSD: patch-ac,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../catalog/dutch.base.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../catalog/dutch.base
@@ -43,8 +43,7 @@
044 "De lisp optie is niet ondersteund"
045 "messages niet uitgeschakeld: %s"
046 "messages niet geactiveerd: %s"
-048 "De paragraph optie moet karakter paren bevatten"
-049 "De section optie moet karakter paren bevatten"
+047 "set: de %s optie moet karakter paren bevatten"
053 "De standaard buffer is leeg"
054 "Buffer %s is leeg"
055 "Bestanden met newlines in de naam kunnen niet hersteld worden"

View file

@ -0,0 +1,14 @@
$NetBSD: patch-ad,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../catalog/french.base.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../catalog/french.base
@@ -43,8 +43,7 @@
044 "L'option lisp n'est pas implémentée"
045 "Les messages ne sont pas désactivés : %s"
046 "Les messages ne sont pas activés : %s"
-048 "L'option de paragraphe doit être en groupe de deux caractères"
-049 "L'option de section doit être en groupe de deux caractères"
+047 "Dfinition : l'option de %s doit ˆtre en groupe de deux caractŠres"
053 "Le tampon par défaut est vide"
054 "Le tampon %s est vide"
055 "Les fichiers dont le nom contient des caractères de saut de ligne sont irrécupérables"

View file

@ -0,0 +1,14 @@
$NetBSD: patch-ae,v 1.5 2009/08/07 16:39:21 lukem Exp $
--- ../catalog/german.base.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../catalog/german.base
@@ -43,8 +43,7 @@
044 "Die lisp-Option ist nicht implementiert"
045 "Meldungen nicht abgeschaltet: %s"
046 "Meldungen nicht eingeschaltet: %s"
-048 "Die paragraph-Option muß Gruppen zu zwei Zeichen enthalten"
-049 "Die section-Option muß Gruppen zu zwei Zeichen enthalten"
+047 "set: Die %s Option muss Gruppen zu zwei Zeichen enthalten"
053 "Der Standardpuffer ist leer"
054 "Puffer %s ist leer"
055 "Dateien mit newlines im Namen sind nicht wiederherstellbar"

View file

@ -0,0 +1,14 @@
$NetBSD: patch-af,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../catalog/spanish.base.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../catalog/spanish.base
@@ -43,8 +43,7 @@
044 "La opci¢n lisp no est  implementada"
045 "mensajes no desconectados: %s"
046 "mensajes no conectados: %s"
-048 "La opci¢n de p rrafo debe estar en dos grupos de caracteres"
-049 "La opci¢n de secci¢n debe estar en dos grupos de caracteres"
+047 "determinar: La opci¢n de %s debe estar en dos grupos de caracteres"
053 "El buffer por omisi¢n est  vac¡o"
054 "El buffer %s est  vac¡o"
055 "Los archivos con nuevas l¡neas en el nombre son irrecuperables"

View file

@ -0,0 +1,14 @@
$NetBSD: patch-ag,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../catalog/swedish.base.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../catalog/swedish.base
@@ -43,8 +43,7 @@
044 "Lisp flaggan är inte implementerad"
045 "meddelanden är inte avslagna: %s"
046 "meddelanden är inte påslagna: %s"
-048 "Paragraph flaggan måste ges i teckengrupper om två"
-049 "Section flaggan måste ges i teckengrupper om två"
+047 "set: %s flaggan måste ges i teckengrupper om två"
053 "Standardbufferten är tom"
054 "Buffer %s är tom"
055 "Filer med radmatning i namnet kan inte återskapas"

View file

@ -0,0 +1,25 @@
$NetBSD: patch-ah,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../common/options.awk.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../common/options.awk
@@ -2,6 +2,18 @@
/^\/\* O_[0-9A-Z_]*/ {
- printf("#define %s %d\n", $2, cnt++);
- next;
+ opt = $2
+ printf("#define %s %d\n", opt, cnt++)
+ ofs = FS
+ FS="\""
+ do getline
+ while ($1 != " {L(")
+ FS=ofs
+ opt_name = $2
+ if (opt_name < prev_name) {
+ printf "missorted %s: \"%s\" < \"%s\"\n", opt, opt_name, prev_name >"/dev/stderr"
+ exit 1
+ }
+ prev_name = opt_name
+ next
}
END {

View file

@ -0,0 +1,111 @@
$NetBSD: patch-ai,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../common/options.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../common/options.c
@@ -48,6 +48,8 @@ static int opts_print __P((SCR *, OPT
*
* HPUX noted options and abbreviations are from "The Ultimate Guide to the
* VI and EX Text Editors", 1990.
+ *
+ * This list must be sorted...
*/
OPTLIST const optlist[] = {
/* O_ALTWERASE 4.4BSD */
@@ -76,10 +78,12 @@ OPTLIST const optlist[] = {
{L("directory"), NULL, OPT_STR, 0},
/* O_EDCOMPATIBLE 4BSD */
{L("edcompatible"),NULL, OPT_0BOOL, 0},
-/* O_ESCAPETIME 4.4BSD */
- {L("escapetime"), NULL, OPT_NUM, 0},
/* O_ERRORBELLS 4BSD */
{L("errorbells"), NULL, OPT_0BOOL, 0},
+/* O_ESCAPETIME 4.4BSD */
+ {L("escapetime"), NULL, OPT_NUM, 0},
+/* O_EXPANDTAB NetBSD 5.0 */
+ {L("expandtab"), NULL, OPT_0BOOL, 0},
/* O_EXRC System V (undocumented) */
{L("exrc"), NULL, OPT_0BOOL, 0},
/* O_EXTENDED 4.4BSD */
@@ -90,6 +94,8 @@ OPTLIST const optlist[] = {
{L("fileencoding"),f_encoding, OPT_STR, OPT_WC},
/* O_FLASH HPUX */
{L("flash"), NULL, OPT_1BOOL, 0},
+/* O_GTAGSMODE FreeBSD/NetBSD */
+ {L("gtagsmode"),NULL, OPT_1BOOL, 0},
/* O_HARDTABS 4BSD */
{L("hardtabs"), NULL, OPT_NUM, 0},
/* O_ICLOWER 4.4BSD */
@@ -120,6 +126,8 @@ OPTLIST const optlist[] = {
{L("lock"), NULL, OPT_1BOOL, 0},
/* O_MAGIC 4BSD */
{L("magic"), NULL, OPT_1BOOL, 0},
+/* O_MATCHCHARS netbsd 2.0 */
+ {L("matchchars"), NULL, OPT_STR, OPT_PAIRS},
/* O_MATCHTIME 4.4BSD */
{L("matchtime"), NULL, OPT_NUM, 0},
/* O_MESG 4BSD */
@@ -146,7 +154,7 @@ OPTLIST const optlist[] = {
/* O_OPTIMIZE 4BSD */
{L("optimize"), NULL, OPT_1BOOL, 0},
/* O_PARAGRAPHS 4BSD */
- {L("paragraphs"), f_paragraph, OPT_STR, 0},
+ {L("paragraphs"), NULL, OPT_STR, OPT_PAIRS},
/* O_PATH 4.4BSD */
{L("path"), NULL, OPT_STR, 0},
/* O_PRINT 4.4BSD */
@@ -170,7 +178,7 @@ OPTLIST const optlist[] = {
/* O_SEARCHINCR 4.4BSD */
{L("searchincr"), NULL, OPT_0BOOL, 0},
/* O_SECTIONS 4BSD */
- {L("sections"), f_section, OPT_STR, 0},
+ {L("sections"), NULL, OPT_STR, OPT_PAIRS},
/* O_SECURE 4.4BSD */
{L("secure"), NULL, OPT_0BOOL, OPT_NOUNSET},
/* O_SHELL 4BSD */
@@ -255,7 +263,9 @@ static OABBREV const abbrev[] = {
{L("dir"), O_TMP_DIRECTORY}, /* 4BSD */
{L("eb"), O_ERRORBELLS}, /* 4BSD */
{L("ed"), O_EDCOMPATIBLE}, /* 4BSD */
+ {L("et"), O_EXPANDTAB}, /* NetBSD 5.0 */
{L("ex"), O_EXRC}, /* System V (undocumented) */
+ {L("gt"), O_GTAGSMODE}, /* FreeBSD, NetBSD */
{L("fe"), O_FILEENCODING},
{L("ht"), O_HARDTABS}, /* 4BSD */
{L("ic"), O_IGNORECASE}, /* 4BSD */
@@ -307,6 +317,13 @@ opts_init(SCR *sp, int *oargs)
CHAR_T *wp;
size_t wlen;
+ if (sizeof optlist / sizeof optlist[0] - 1 != O_OPTIONCOUNT) {
+ fprintf(stderr, "vi: option table size error (%d != %d)\n",
+ (int)(sizeof optlist / sizeof optlist[0] - 1),
+ O_OPTIONCOUNT);
+ exit(1);
+ }
+
a.bp = b2;
b.bp = NULL;
a.len = b.len = 0;
@@ -358,6 +375,7 @@ opts_init(SCR *sp, int *oargs)
OI(O_TMP_DIRECTORY, b2);
OI(O_ESCAPETIME, L("escapetime=1"));
OI(O_KEYTIME, L("keytime=6"));
+ OI(O_MATCHCHARS, L("matchchars=()[]{}<>"));
OI(O_MATCHTIME, L("matchtime=7"));
(void)SPRINTF(b2, SIZE(b2), L("msgcat=%s"), _PATH_MSGCAT);
OI(O_MSGCAT, b2);
@@ -708,6 +726,14 @@ badnum: INT2CHAR(sp, name, STRLEN(nam
break;
}
+ /* Check for strings that must have even length */
+ if (F_ISSET(op, OPT_PAIRS) && STRLEN(sep) & 1) {
+ msgq_wstr(sp, M_ERR, name,
+ "047|set: the %s option must be in two character groups");
+ rval = 1;
+ break;
+ }
+
/*
* Do nothing if the value is unchanged, the underlying
* functions can be expensive.

View file

@ -0,0 +1,12 @@
$NetBSD: patch-aj,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../common/options.h.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../common/options.h
@@ -89,6 +89,7 @@ struct _optlist {
#define OPT_NOSET 0x010 /* Option may not be set. */
#define OPT_NOUNSET 0x020 /* Option may not be unset. */
#define OPT_NOZERO 0x040 /* Option may not be set to 0. */
+#define OPT_PAIRS 0x080 /* String with even length */
u_int8_t flags;
};

View file

@ -0,0 +1,154 @@
$NetBSD: patch-ak,v 1.3 2009/08/07 16:39:21 lukem Exp $
--- ../common/options_def.h.orig 2007-11-19 03:43:54.000000000 +1100
+++ ../common/options_def.h
@@ -1,4 +1,3 @@
-/* Do not edit: automatically built by build/distrib. */
#define O_ALTWERASE 0
#define O_AUTOINDENT 1
#define O_AUTOPRINT 2
@@ -12,72 +11,75 @@
#define O_COMMENT 10
#define O_TMP_DIRECTORY 11
#define O_EDCOMPATIBLE 12
-#define O_ESCAPETIME 13
-#define O_ERRORBELLS 14
-#define O_EXRC 15
-#define O_EXTENDED 16
-#define O_FILEC 17
-#define O_FILEENCODING 18
-#define O_FLASH 19
-#define O_HARDTABS 20
-#define O_ICLOWER 21
-#define O_IGNORECASE 22
-#define O_INPUTENCODING 23
-#define O_KEYTIME 24
-#define O_LEFTRIGHT 25
-#define O_LINES 26
-#define O_LISP 27
-#define O_LIST 28
-#define O_LOCKFILES 29
-#define O_MAGIC 30
-#define O_MATCHTIME 31
-#define O_MESG 32
-#define O_MODELINE 33
-#define O_MSGCAT 34
-#define O_NOPRINT 35
-#define O_NUMBER 36
-#define O_OCTAL 37
-#define O_OPEN 38
-#define O_OPTIMIZE 39
-#define O_PARAGRAPHS 40
-#define O_PATH 41
-#define O_PRINT 42
-#define O_PROMPT 43
-#define O_READONLY 44
-#define O_RECDIR 45
-#define O_REDRAW 46
-#define O_REMAP 47
-#define O_REPORT 48
-#define O_RULER 49
-#define O_SCROLL 50
-#define O_SEARCHINCR 51
-#define O_SECTIONS 52
-#define O_SECURE 53
-#define O_SHELL 54
-#define O_SHELLMETA 55
-#define O_SHIFTWIDTH 56
-#define O_SHOWMATCH 57
-#define O_SHOWMODE 58
-#define O_SIDESCROLL 59
-#define O_SLOWOPEN 60
-#define O_SOURCEANY 61
-#define O_TABSTOP 62
-#define O_TAGLENGTH 63
-#define O_TAGS 64
-#define O_TERM 65
-#define O_TERSE 66
-#define O_TILDEOP 67
-#define O_TIMEOUT 68
-#define O_TTYWERASE 69
-#define O_VERBOSE 70
-#define O_W1200 71
-#define O_W300 72
-#define O_W9600 73
-#define O_WARN 74
-#define O_WINDOW 75
-#define O_WINDOWNAME 76
-#define O_WRAPLEN 77
-#define O_WRAPMARGIN 78
-#define O_WRAPSCAN 79
-#define O_WRITEANY 80
-#define O_OPTIONCOUNT 81
+#define O_ERRORBELLS 13
+#define O_ESCAPETIME 14
+#define O_EXPANDTAB 15
+#define O_EXRC 16
+#define O_EXTENDED 17
+#define O_FILEC 18
+#define O_FILEENCODING 19
+#define O_FLASH 20
+#define O_GTAGSMODE 21
+#define O_HARDTABS 22
+#define O_ICLOWER 23
+#define O_IGNORECASE 24
+#define O_INPUTENCODING 25
+#define O_KEYTIME 26
+#define O_LEFTRIGHT 27
+#define O_LINES 28
+#define O_LISP 29
+#define O_LIST 30
+#define O_LOCKFILES 31
+#define O_MAGIC 32
+#define O_MATCHCHARS 33
+#define O_MATCHTIME 34
+#define O_MESG 35
+#define O_MODELINE 36
+#define O_MSGCAT 37
+#define O_NOPRINT 38
+#define O_NUMBER 39
+#define O_OCTAL 40
+#define O_OPEN 41
+#define O_OPTIMIZE 42
+#define O_PARAGRAPHS 43
+#define O_PATH 44
+#define O_PRINT 45
+#define O_PROMPT 46
+#define O_READONLY 47
+#define O_RECDIR 48
+#define O_REDRAW 49
+#define O_REMAP 50
+#define O_REPORT 51
+#define O_RULER 52
+#define O_SCROLL 53
+#define O_SEARCHINCR 54
+#define O_SECTIONS 55
+#define O_SECURE 56
+#define O_SHELL 57
+#define O_SHELLMETA 58
+#define O_SHIFTWIDTH 59
+#define O_SHOWMATCH 60
+#define O_SHOWMODE 61
+#define O_SIDESCROLL 62
+#define O_SLOWOPEN 63
+#define O_SOURCEANY 64
+#define O_TABSTOP 65
+#define O_TAGLENGTH 66
+#define O_TAGS 67
+#define O_TERM 68
+#define O_TERSE 69
+#define O_TILDEOP 70
+#define O_TIMEOUT 71
+#define O_TTYWERASE 72
+#define O_VERBOSE 73
+#define O_W1200 74
+#define O_W300 75
+#define O_W9600 76
+#define O_WARN 77
+#define O_WINDOW 78
+#define O_WINDOWNAME 79
+#define O_WRAPLEN 80
+#define O_WRAPMARGIN 81
+#define O_WRAPSCAN 82
+#define O_WRITEANY 83
+#define O_OPTIONCOUNT 84

View file

@ -0,0 +1,64 @@
$NetBSD: patch-al,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../common/options_f.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../common/options_f.c
@@ -60,7 +60,7 @@ f_columns(SCR *sp, OPTION *op, char *str
* number of lines/columns for the screen, but at least we don't drop
* core.
*/
-#define MAXIMUM_SCREEN_COLS 500
+#define MAXIMUM_SCREEN_COLS 4000
if (*valp > MAXIMUM_SCREEN_COLS) {
msgq(sp, M_ERR, "041|Screen columns too large, greater than %d",
MAXIMUM_SCREEN_COLS);
@@ -90,7 +90,7 @@ f_lines(SCR *sp, OPTION *op, char *str,
* number of lines/columns for the screen, but at least we don't drop
* core.
*/
-#define MAXIMUM_SCREEN_ROWS 500
+#define MAXIMUM_SCREEN_ROWS 4000
if (*valp > MAXIMUM_SCREEN_ROWS) {
msgq(sp, M_ERR, "043|Screen lines too large, greater than %d",
MAXIMUM_SCREEN_ROWS);
@@ -143,20 +143,6 @@ f_msgcat(SCR *sp, OPTION *op, char *str,
}
/*
- * PUBLIC: int f_paragraph __P((SCR *, OPTION *, char *, u_long *));
- */
-int
-f_paragraph(SCR *sp, OPTION *op, char *str, u_long *valp)
-{
- if (strlen(str) & 1) {
- msgq(sp, M_ERR,
- "048|The paragraph option must be in two character groups");
- return (1);
- }
- return (0);
-}
-
-/*
* PUBLIC: int f_print __P((SCR *, OPTION *, char *, u_long *));
*/
int
@@ -226,20 +212,6 @@ f_reformat(SCR *sp, OPTION *op, char *st
}
/*
- * PUBLIC: int f_section __P((SCR *, OPTION *, char *, u_long *));
- */
-int
-f_section(SCR *sp, OPTION *op, char *str, u_long *valp)
-{
- if (strlen(str) & 1) {
- msgq(sp, M_ERR,
- "049|The section option must be in two character groups");
- return (1);
- }
- return (0);
-}
-
-/*
* PUBLIC: int f_ttywerase __P((SCR *, OPTION *, char *, u_long *));
*/
int

View file

@ -0,0 +1,99 @@
$NetBSD: patch-am,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../docs/vi.man/vi.1.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../docs/vi.man/vi.1
@@ -17,7 +17,7 @@ ex, vi, view \- text editors
.SH SYNOPSIS
.B ex
[\c
-.B -eFRrSsv\c
+.B -eFGRrSsv\c
] [\c
.BI -c " cmd"\c
] [\c
@@ -39,7 +39,7 @@ ex, vi, view \- text editors
.br
.B view
[\c
-.B -eFRrSv\c
+.B -eFGRrSv\c
] [\c
.BI -c " cmd"\c
] [\c
@@ -118,6 +118,9 @@ Don't copy the entire file when first st
(The default is to make a copy in case someone else modifies
the file during your edit session.)
.TP
+.B \-G
+Start editing in gtags mode, as if the gtagsmode option was set.
+.TP
.B \-l
Start editing with the lisp and showmatch options set.
.TP
@@ -429,6 +432,8 @@ commands or cancel partial commands.
.TP
.B "<control-]>"
Push a tag reference onto the tag stack.
+In gtagsmode, if at the first column of line,
+locate function references otherwise function definitions.
.TP
.B "<control-^>"
Switch to the most recently edited file.
@@ -774,6 +779,11 @@ and
characters to move forward to the next
.B shiftwidth
column boundary.
+If
+.B expandtab
+is set, only insert
+.I <space>
+characters.
.TP
.B "<erase>
.TP
@@ -940,6 +950,9 @@ Grow or shrink the current screen.
.B "rew[ind][!]"
Rewind the argument list.
.TP
+.B "rta[g][!] tagstring"
+Edit the file refering the specified tag. (Only in gtagsmode)
+.TP
.B "se[t] [option[=[value]] ...] [nooption ...] [option? ...] [all]"
Display or set editor options.
.TP
@@ -1095,6 +1108,15 @@ command.
only.
Announce error messages with a bell.
.TP
+.B "expandtab, et [off]"
+Prevent the use of
+.I <tab>
+characters in leading whitespace when shifting text, autoindenting,
+indenting with
+.BR "<control-T>" ,
+or outdenting with
+.BR "<control-D>" .
+.TP
.B "exrc, ex [off]"
Read the startup files in the local directory.
.TP
@@ -1110,6 +1132,9 @@ command line.
.B "flash [on]"
Flash the screen instead of beeping the keyboard on error.
.TP
+.B "gtagsmode, gt [off]"
+Use GTAGS and GRTAGS instead of tags.
+.TP
.B "hardtabs, ht [8]"
Set the spacing between hardware tab settings.
.TP
@@ -1151,6 +1176,9 @@ read or written.
.B "magic [on]"
Treat certain characters specially in regular expressions.
.TP
+.B "matchchars [[]{}()<>]"
+Character pairs looked for by the % command.
+.TP
.B "matchtime [7]"
.I \&Vi
only.

View file

@ -0,0 +1,49 @@
$NetBSD: patch-an,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../docs/vi.ref/set.opt.texi.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../docs/vi.ref/set.opt.texi
@@ -97,7 +97,10 @@ the first nonblank character of the line
Lines are indented using tab characters to the extent possible (based on
the value of the
@OP{tabstop}
-option) and then using space characters as necessary.
+option,
+and if
+@OP{expandtab}
+is not set) and then using space characters as necessary.
For commands inserting text into the middle of a line, any blank characters
to the right of the cursor are discarded, and the first nonblank character
to the right of the cursor is aligned as described above.
@@ -407,6 +410,16 @@ only.
error messages are normally presented in inverse video.
If that is not possible for the terminal, setting this option causes
error messages to be announced by ringing the terminal bell.
+@cindex expandtab
+@IP{expandtab, et [off]}
+
+Prevent the use of
+@LI{<tab>}
+characters in leading whitespace when shifting text, autoindenting,
+indenting with
+@CO{<control-T>},
+or outdenting with
+@CO{<control-D>}.
@cindex exrc
@IP{exrc, ex [off]}
@@ -593,6 +606,15 @@ character.
See the section entitled
@QB{Regular Expressions and Replacement Strings}
for more information.
+@cindex matchchars
+@IP{matchchars [[]{}()<>]}
+
+@CO{Vi}
+only.
+This option defines the character pairs used by the
+@CO{%}
+command.
+
@cindex matchtime
@IP{matchtime [7]}

View file

@ -0,0 +1,32 @@
$NetBSD: patch-ao,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../docs/vi.ref/vi.cmd.texi.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../docs/vi.ref/vi.cmd.texi
@@ -1044,13 +1044,23 @@ None.
@deftypefn Command {} {%}
Move to the matching character.
-The cursor moves to the parenthesis or curly brace which
+The cursor moves to the bracket character which
@emph{matches}
-the parenthesis or curly brace found at the current cursor position
+the bracket found at the current cursor position
or which is the closest one to the right of the cursor on the line.
-It is an error to execute the
+The bracket characters are defined by the
+@OP{matchchars}
+option.
+An error will be reported if none of the
+@OP{matchchars}
+characters is found, or if no matching character is found.
+If the open and close brackes are identical (e.g.: if they are
+@QT{'}
+or
+@QT{"},
+then repeating a
@CO{%}
-command on a line without a parenthesis or curly brace.
+command will perform a backwards search from the original opening bracket.
Historically, any
@LI{count}specified to the
@CO{%}

View file

@ -0,0 +1,111 @@
$NetBSD: patch-ap,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../vi/v_match.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../vi/v_match.c
@@ -39,6 +39,19 @@ v_match(SCR *sp, VICMD *vp)
size_t cno, len, off;
int cnt, isempty, matchc, startc, (*gc)__P((SCR *, VCS *));
CHAR_T *p;
+ char *cp;
+ char *match_chars;
+
+ static int match_lno, match_col, match_dir;
+
+ /*
+ * Historically vi would match (), {} and [] however
+ * an update included <>. This is ok for editing HTML
+ * but a pain in the butt for C source.
+ * Making it an option lets the user decide what is 'right'.
+ * Also fixed to do something sensible with "".
+ */
+ match_chars = O_STR(sp, O_MATCHCHARS);
/*
* !!!
@@ -58,44 +71,27 @@ v_match(SCR *sp, VICMD *vp)
nomatch: msgq(sp, M_BERR, "184|No match character on this line");
return (1);
}
- switch (startc = p[off]) {
- case '(':
- matchc = ')';
- gc = cs_next;
- break;
- case ')':
- matchc = '(';
- gc = cs_prev;
- break;
- case '[':
- matchc = ']';
- gc = cs_next;
- break;
- case ']':
- matchc = '[';
- gc = cs_prev;
- break;
- case '{':
- matchc = '}';
- gc = cs_next;
- break;
- case '}':
- matchc = '{';
- gc = cs_prev;
+ startc = p[off];
+ cp = strchr(match_chars, startc);
+ if (cp != NULL)
break;
- case '<':
- matchc = '>';
- gc = cs_next;
- break;
- case '>':
- matchc = '<';
- gc = cs_prev;
- break;
- default:
- continue;
- }
- break;
}
+ cnt = cp - match_chars;
+ matchc = match_chars[cnt ^ 1];
+
+ /* Alternate back-forward search if startc and matchc the same */
+ if (startc == matchc) {
+ /* are we continuing from where last match finished? */
+ if (match_lno == vp->m_start.lno && match_col ==vp->m_start.cno)
+ /* yes - continue in sequence */
+ match_dir++;
+ else
+ /* no - go forward, back, back, forward */
+ match_dir = 1;
+ if (match_dir & 2)
+ cnt++;
+ }
+ gc = cnt & 1 ? cs_prev : cs_next;
cs.cs_lno = vp->m_start.lno;
cs.cs_cno = off;
@@ -109,10 +105,10 @@ nomatch: msgq(sp, M_BERR, "184|No match
break;
continue;
}
+ if (cs.cs_ch == matchc && --cnt == 0)
+ break;
if (cs.cs_ch == startc)
++cnt;
- else if (cs.cs_ch == matchc && --cnt == 0)
- break;
}
if (cnt) {
msgq(sp, M_BERR, "185|Matching character not found");
@@ -139,6 +135,9 @@ nomatch: msgq(sp, M_BERR, "184|No match
else
vp->m_final = vp->m_stop;
+ match_lno = vp->m_final.lno;
+ match_col = vp->m_final.cno;
+
/*
* !!!
* If the motion is across lines, and the earliest cursor position

View file

@ -0,0 +1,48 @@
$NetBSD: patch-aq,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../common/main.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../common/main.c
@@ -62,6 +62,7 @@ editor(WIN *wp, int argc, char **argv)
size_t len;
u_int flags;
int ch, flagchk, lflag, secure, startup, readonly, rval, silent;
+ int gtags = 0;
char *tag_f, *wsizearg, path[256];
CHAR_T *w;
size_t wlen;
@@ -102,11 +103,13 @@ editor(WIN *wp, int argc, char **argv)
/* Set the file snapshot flag. */
F_SET(gp, G_SNAPSHOT);
+ while ((ch = getopt(argc, argv, "c:"
#ifdef DEBUG
- while ((ch = getopt(argc, argv, "c:D:eFlRrSsT:t:vw:")) != EOF)
-#else
- while ((ch = getopt(argc, argv, "c:eFlRrSst:vw:")) != EOF)
+ "D:"
#endif
+ "eF"
+ "G"
+ "lRrSsT:t:vw:")) != EOF)
switch (ch) {
case 'c': /* Run the command. */
/*
@@ -147,6 +150,9 @@ editor(WIN *wp, int argc, char **argv)
case 'l': /* Set lisp, showmatch options. */
lflag = 1;
break;
+ case 'G': /* gtags mode. */
+ gtags = 1;
+ break;
case 'R': /* Readonly. */
readonly = 1;
break;
@@ -240,6 +246,8 @@ editor(WIN *wp, int argc, char **argv)
}
if (readonly)
*oargp++ = O_READONLY;
+ if (gtags)
+ *oargp++ = O_GTAGSMODE;
if (secure)
*oargp++ = O_SECURE;
*oargp = -1; /* Options initialization. */

View file

@ -0,0 +1,12 @@
$NetBSD: patch-ar,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/ex.h.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../ex/ex.h
@@ -152,6 +152,7 @@ struct _excmd {
#define E_SEARCH_WMSG 0x01000000 /* Display search-wrapped message. */
#define E_USELASTCMD 0x02000000 /* Use the last command. */
#define E_VISEARCH 0x04000000 /* It's really a vi search command. */
+#define E_REFERENCE 0x08000000 /* locate function references */
u_int32_t flags; /* Current flags. */
};

View file

@ -0,0 +1,16 @@
$NetBSD: patch-as,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/ex_cmd.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../ex/ex_cmd.c
@@ -302,6 +302,11 @@ EXCMDLIST const cmds[] = {
"!",
"rew[ind][!]",
"re-edit all the files in the file argument list"},
+/* C_RTAG */
+ {L("rtag"), ex_rtag_push, E_NEWSCREEN,
+ "!w1o",
+ "rta[g][!] [string]",
+ "edit the file containing the tag"},
/*
* !!!
* Adding new commands starting with 's' may break the substitute command code

View file

@ -0,0 +1,69 @@
$NetBSD: patch-at,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/ex_def.h.orig 2007-11-19 03:43:54.000000000 +1100
+++ ../ex/ex_def.h
@@ -48,33 +48,34 @@
#define C_RECOVER 46
#define C_RESIZE 47
#define C_REWIND 48
-#define C_SUBSTITUTE 49
-#define C_SCRIPT 50
-#define C_SET 51
-#define C_SHELL 52
-#define C_SOURCE 53
-#define C_STOP 54
-#define C_SUSPEND 55
-#define C_T 56
-#define C_TAG 57
-#define C_TAGNEXT 58
-#define C_TAGPOP 59
-#define C_TAGPREV 60
-#define C_TAGTOP 61
-#define C_TCLCMD 62
-#define C_UNDO 63
-#define C_UNABBREVIATE 64
-#define C_UNMAP 65
-#define C_V 66
-#define C_VERSION 67
-#define C_VISUAL_EX 68
-#define C_VISUAL_VI 69
-#define C_VIUSAGE 70
-#define C_VSPLIT 71
-#define C_WRITE 72
-#define C_WN 73
-#define C_WQ 74
-#define C_XIT 75
-#define C_YANK 76
-#define C_Z 77
-#define C_SUBTILDE 78
+#define C_RTAG 49
+#define C_SUBSTITUTE 50
+#define C_SCRIPT 51
+#define C_SET 52
+#define C_SHELL 53
+#define C_SOURCE 54
+#define C_STOP 55
+#define C_SUSPEND 56
+#define C_T 57
+#define C_TAG 58
+#define C_TAGNEXT 59
+#define C_TAGPOP 60
+#define C_TAGPREV 61
+#define C_TAGTOP 62
+#define C_TCLCMD 63
+#define C_UNDO 64
+#define C_UNABBREVIATE 65
+#define C_UNMAP 66
+#define C_V 67
+#define C_VERSION 68
+#define C_VISUAL_EX 69
+#define C_VISUAL_VI 70
+#define C_VIUSAGE 71
+#define C_VSPLIT 72
+#define C_WRITE 73
+#define C_WN 74
+#define C_WQ 75
+#define C_XIT 76
+#define C_YANK 77
+#define C_Z 78
+#define C_SUBTILDE 79

View file

@ -0,0 +1,179 @@
$NetBSD: patch-au,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/ex_tag.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../ex/ex_tag.c
@@ -46,6 +46,8 @@ static char *binary_search __P((char *,
static int compare __P((char *, char *, char *));
static void ctag_file __P((SCR *, TAGF *, char *, char **, size_t *));
static int ctag_search __P((SCR *, CHAR_T *, size_t, char *));
+static int getentry __P((char *, char **, char **, char **));
+static TAGQ *gtag_slist __P((SCR *, CHAR_T *, int));
static int ctag_sfile __P((SCR *, TAGF *, TAGQ *, char *));
static TAGQ *ctag_slist __P((SCR *, CHAR_T *));
static char *linear_search __P((char *, char *, char *, long));
@@ -87,6 +89,21 @@ ex_tag_first(SCR *sp, CHAR_T *tagarg)
}
/*
+ * ex_rtag_push -- ^]
+ * :rtag[!] [string]
+ *
+ * Enter a new TAGQ context based on a ctag string.
+ *
+ * PUBLIC: int ex_rtag_push __P((SCR *, EXCMD *));
+ */
+int
+ex_rtag_push(SCR *sp, EXCMD *cmdp)
+{
+ F_SET(cmdp, E_REFERENCE);
+ return ex_tag_push(sp, cmdp);
+}
+
+/*
* ex_tag_push -- ^]
* :tag[!] [string]
*
@@ -129,6 +146,11 @@ ex_tag_push(SCR *sp, EXCMD *cmdp)
}
/* Get the tag information. */
+ if (O_ISSET(sp, O_GTAGSMODE)) {
+ if ((tqp = gtag_slist(sp, exp->tag_last,
+ F_ISSET(cmdp, E_REFERENCE))) == NULL)
+ return (1);
+ } else
if ((tqp = ctag_slist(sp, exp->tag_last)) == NULL)
return (1);
@@ -980,6 +1002,131 @@ notfound: tag_msg(sp, TAG_SEARCH, tag)
}
/*
+ * getentry --
+ * get tag information from current line.
+ *
+ * gtags temporary file format.
+ * <tag> <lineno> <file> <image>
+ *
+ * sample.
+ * +------------------------------------------------
+ * |main 30 main.c main(argc, argv)
+ * |func 21 subr.c func(arg)
+ */
+static int
+getentry(char *buf, char **tag, char **file, char **line)
+{
+ char *p = buf;
+
+ for (*tag = p; *p && !isspace(*p); p++) /* tag name */
+ ;
+ if (*p == 0)
+ goto err;
+ *p++ = 0;
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
+ ;
+ if (*p == 0)
+ goto err;
+ *line = p; /* line no */
+ for (*line = p; *p && !isspace(*p); p++)
+ ;
+ if (*p == 0)
+ goto err;
+ *p++ = 0;
+ for (; *p && isspace(*p); p++) /* (skip blanks) */
+ ;
+ if (*p == 0)
+ goto err;
+ *file = p; /* file name */
+ for (*file = p; *p && !isspace(*p); p++)
+ ;
+ if (*p == 0)
+ goto err;
+ *p = 0;
+
+ /* value check */
+ if (strlen(*tag) && strlen(*line) && strlen(*file) && atoi(*line) > 0)
+ return 1; /* OK */
+err:
+ return 0; /* ERROR */
+}
+
+/*
+ * gtag_slist --
+ * Search the list of tags files for a tag, and return tag queue.
+ */
+static TAGQ *
+gtag_slist(SCR *sp, CHAR_T *tag, int ref)
+{
+ EX_PRIVATE *exp;
+ TAGF *tfp;
+ TAGQ *tqp;
+ size_t len, nlen, slen, wlen;
+ int echk;
+ TAG *tp;
+ char *np;
+ char *name, *file, *search;
+ char command[BUFSIZ];
+ char buf[BUFSIZ];
+ CHAR_T *wp;
+ FILE *fp;
+
+ /* Allocate and initialize the tag queue structure. */
+ INT2CHAR(sp, tag, STRLEN(tag) + 1, np, nlen);
+ len = nlen - 1;
+ CALLOC_GOTO(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + len + 1);
+ CIRCLEQ_INIT(&tqp->tagq);
+ tqp->tag = tqp->buf;
+ memcpy(tqp->tag, np, (tqp->tlen = len) + 1);
+
+ /*
+ * Find the tag, only display missing file messages once, and
+ * then only if we didn't find the tag.
+ */
+ snprintf(command, sizeof(command), "global -%s '%s'", ref ? "rx" : "x",
+ np);
+ if (fp = popen(command, "r")) {
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (buf[strlen(buf)-1] == '\n') /* chop(buf) */
+ buf[strlen(buf)-1] = 0;
+ else
+ while (fgetc(fp) != '\n')
+ ;
+ if (getentry(buf, &name, &file, &search) == 0) {
+ echk = 1;
+ F_SET(tfp, TAGF_ERR);
+ break;
+ }
+ slen = strlen(search);
+ CALLOC_GOTO(sp, tp,
+ TAG *, 1, sizeof(TAG) + strlen(file) + 1 +
+ (slen + 1) * sizeof(CHAR_T));
+ tp->fname = (char *)tp->buf;
+ strcpy(tp->fname, file);
+ tp->fnlen = strlen(file);
+ tp->search = (CHAR_T *)(tp->fname + tp->fnlen + 1);
+ CHAR2INT(sp, search, slen + 1, wp, wlen);
+ MEMCPYW(tp->search, wp, (tp->slen = slen) + 1);
+ CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q);
+ }
+ pclose(fp);
+ }
+
+ /* Check to see if we found anything. */
+ if (tqp->tagq.cqh_first == (void *)&tqp->tagq) {
+ msgq_str(sp, M_ERR, np, "162|%s: tag not found");
+ free(tqp);
+ return (NULL);
+ }
+
+ tqp->current = tqp->tagq.cqh_first;
+ return (tqp);
+
+alloc_err:
+ return (NULL);
+}
+
+/*
* ctag_slist --
* Search the list of tags files for a tag, and return tag queue.
*/

View file

@ -0,0 +1,12 @@
$NetBSD: patch-av,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/extern.h.orig 2007-11-19 03:43:54.000000000 +1100
+++ ../ex/extern.h
@@ -91,6 +91,7 @@ int re_compile __P((SCR *,
CHAR_T *, size_t, CHAR_T **, size_t *, regex_t *, u_int));
void re_error __P((SCR *, int, regex_t *));
int ex_tag_first __P((SCR *, CHAR_T *));
+int ex_rtag_push __P((SCR *, EXCMD *));
int ex_tag_push __P((SCR *, EXCMD *));
int ex_tag_next __P((SCR *, EXCMD *));
int ex_tag_prev __P((SCR *, EXCMD *));

View file

@ -0,0 +1,14 @@
$NetBSD: patch-aw,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../vi/v_ex.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../vi/v_ex.c
@@ -209,6 +209,9 @@ v_tagpush(SCR *sp, VICMD *vp)
{
EXCMD cmd;
+ if (O_ISSET(sp, O_GTAGSMODE) && vp->m_start.cno == 0)
+ ex_cinit(sp, &cmd, C_RTAG, 0, OOBLNO, 0, 0);
+ else
ex_cinit(sp, &cmd, C_TAG, 0, OOBLNO, 0, 0);
argv_exp0(sp, &cmd, VIP(sp)->keyw, STRLEN(VIP(sp)->keyw) + 1);
return (v_exec_ex(sp, vp, &cmd));

View file

@ -0,0 +1,22 @@
$NetBSD: patch-ax,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/ex_shift.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../ex/ex_shift.c
@@ -131,10 +131,13 @@ shift(SCR *sp, EXCMD *cmdp, enum which r
* Build a new indent string and count the number of
* characters it uses.
*/
- for (tbp = bp, newidx = 0;
- newcol >= O_VAL(sp, O_TABSTOP); ++newidx) {
- *tbp++ = '\t';
- newcol -= O_VAL(sp, O_TABSTOP);
+ tbp = bp;
+ newidx = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+ for (; newcol >= O_VAL(sp, O_TABSTOP); ++newidx) {
+ *tbp++ = '\t';
+ newcol -= O_VAL(sp, O_TABSTOP);
+ }
}
for (; newcol > 0; --newcol, ++newidx)
*tbp++ = ' ';

View file

@ -0,0 +1,19 @@
$NetBSD: patch-ay,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/ex_txt.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../ex/ex_txt.c
@@ -403,8 +403,12 @@ txt_dent(SCR *sp, TEXT *tp)
*
* Count up spaces/tabs needed to get to the target.
*/
- for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs)
- cno += COL_OFF(cno, ts);
+ cno = 0;
+ tabs = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+ for (; cno + COL_OFF(cno, ts) <= scno; ++tabs)
+ cno += COL_OFF(cno, ts);
+ }
spaces = scno - cno;
/* Make sure there's enough room. */

View file

@ -0,0 +1,106 @@
$NetBSD: patch-az,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../vi/v_txt.c.orig 2007-11-19 03:41:42.000000000 +1100
+++ ../vi/v_txt.c
@@ -948,7 +948,7 @@ k_escape: LINE_RESOLVE;
switch (carat) {
case C_CARATSET: /* ^^D */
- if (tp->ai == 0 || tp->cno > tp->ai + tp->offset + 1)
+ if (tp->ai == 0 || tp->cno != tp->ai + tp->offset + 1)
goto ins_ch;
/* Save the ai string for later. */
@@ -961,17 +961,18 @@ k_escape: LINE_RESOLVE;
carat = C_NOCHANGE;
goto leftmargin;
case C_ZEROSET: /* 0^D */
- if (tp->ai == 0 || tp->cno > tp->ai + tp->offset + 1)
+ if (tp->ai == 0 || tp->cno != tp->ai + tp->offset + 1)
goto ins_ch;
carat = C_NOTSET;
leftmargin: tp->lb[tp->cno - 1] = ' ';
tp->owrite += tp->cno - tp->offset;
- tp->ai = 0;
tp->cno = tp->offset;
break;
+ case C_NOCHANGE: /* ^D after reset with ^^D */
+ /* FALLTHROUGH */
case C_NOTSET: /* ^D */
- if (tp->ai == 0 || tp->cno > tp->ai + tp->offset)
+ if (tp->ai == 0 || tp->cno != tp->ai + tp->offset)
goto ins_ch;
(void)txt_dent(sp, tp, 0);
@@ -1719,13 +1720,19 @@ txt_ai_resolve(SCR *sp, TEXT *tp, int *c
/*
* If there are no spaces, or no tabs after spaces and less than
* ts spaces, it's already minimal.
+ * Keep analysing if expandtab is set.
*/
- if (!spaces || !tab_after_sp && spaces < ts)
+ if ((!spaces || (!tab_after_sp && spaces < ts)) &&
+ !O_ISSET(sp, O_EXPANDTAB))
return;
/* Count up spaces/tabs needed to get to the target. */
- for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs)
- cno += COL_OFF(cno, ts);
+ cno = 0;
+ tabs = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+ for (; cno + COL_OFF(cno, ts) <= scno; ++tabs)
+ cno += COL_OFF(cno, ts);
+ }
spaces = scno - cno;
/*
@@ -1889,7 +1896,6 @@ txt_dent(SCR *sp, TEXT *tp, int isindent
CHAR_T ch;
u_long sw, ts;
size_t cno, current, spaces, target, tabs, off;
- int ai_reset;
ts = O_VAL(sp, O_TABSTOP);
sw = O_VAL(sp, O_SHIFTWIDTH);
@@ -1921,16 +1927,6 @@ txt_dent(SCR *sp, TEXT *tp, int isindent
target -= --target % sw;
/*
- * The AI characters will be turned into overwrite characters if the
- * cursor immediately follows them. We test both the cursor position
- * and the indent flag because there's no single test. (^T can only
- * be detected by the cursor position, and while we know that the test
- * is always true for ^D, the cursor can be in more than one place, as
- * "0^D" and "^D" are different.)
- */
- ai_reset = !isindent || tp->cno == tp->ai + tp->offset;
-
- /*
* Back up over any previous <blank> characters, changing them into
* overwrite characters (including any ai characters). Then figure
* out the current screen column.
@@ -1957,15 +1953,16 @@ txt_dent(SCR *sp, TEXT *tp, int isindent
if (current >= target)
spaces = tabs = 0;
else {
- for (cno = current,
- tabs = 0; cno + COL_OFF(cno, ts) <= target; ++tabs)
- cno += COL_OFF(cno, ts);
+ cno = current;
+ tabs = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+ for (; cno + COL_OFF(cno, ts) <= target; ++tabs)
+ cno += COL_OFF(cno, ts);
+ }
spaces = target - cno;
}
- /* If we overwrote ai characters, reset the ai count. */
- if (ai_reset)
- tp->ai = tabs + spaces;
+ tp->ai = tabs + spaces;
/*
* Call txt_insch() to insert each character, so that we get the

View file

@ -0,0 +1,7 @@
$NetBSD: patch-ba,v 1.1 2009/08/07 16:39:21 lukem Exp $
--- ../ex/version.h.orig 2007-11-19 03:43:55.000000000 +1100
+++ ../ex/version.h
@@ -1 +1 @@
-#define VI_VERSION "nvi-1.81.6 (2007-11-18)"
+#define VI_VERSION "nvi-1.81.6nb4 (2009-08-07)"