Rename "expandtabs" to "expandtab" to match documentation (and vim, where I got the idea from). Actually implement the "et" abbreviation for expandtab.diff -r1.5 -r1.6 src/dist/nvi/common/options.c
(lukem)
--- src/dist/nvi/common/Attic/options.c 2008/12/12 22:55:55 1.5
+++ src/dist/nvi/common/Attic/options.c 2009/08/07 16:19:53 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: options.c,v 1.5 2008/12/12 22:55:55 lukem Exp $ */ | 1 | /* $NetBSD: options.c,v 1.6 2009/08/07 16:19:53 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1991, 1993, 1994 | 4 | * Copyright (c) 1991, 1993, 1994 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1991, 1993, 1994, 1995, 1996 | 6 | * Copyright (c) 1991, 1993, 1994, 1995, 1996 | |
7 | * Keith Bostic. All rights reserved. | 7 | * Keith Bostic. All rights reserved. | |
8 | * | 8 | * | |
9 | * See the LICENSE file for redistribution information. | 9 | * See the LICENSE file for redistribution information. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | #include "config.h" | 12 | #include "config.h" | |
13 | 13 | |||
14 | #ifndef lint | 14 | #ifndef lint | |
@@ -74,28 +74,28 @@ OPTLIST const optlist[] = { | @@ -74,28 +74,28 @@ OPTLIST const optlist[] = { | |||
74 | {L("columns"), f_columns, OPT_NUM, OPT_NOSAVE}, | 74 | {L("columns"), f_columns, OPT_NUM, OPT_NOSAVE}, | |
75 | /* O_COMBINED */ | 75 | /* O_COMBINED */ | |
76 | {L("combined"), NULL, OPT_0BOOL, OPT_NOSET|OPT_WC}, | 76 | {L("combined"), NULL, OPT_0BOOL, OPT_NOSET|OPT_WC}, | |
77 | /* O_COMMENT 4.4BSD */ | 77 | /* O_COMMENT 4.4BSD */ | |
78 | {L("comment"), NULL, OPT_0BOOL, 0}, | 78 | {L("comment"), NULL, OPT_0BOOL, 0}, | |
79 | /* O_TMP_DIRECTORY 4BSD */ | 79 | /* O_TMP_DIRECTORY 4BSD */ | |
80 | {L("directory"), NULL, OPT_STR, 0}, | 80 | {L("directory"), NULL, OPT_STR, 0}, | |
81 | /* O_EDCOMPATIBLE 4BSD */ | 81 | /* O_EDCOMPATIBLE 4BSD */ | |
82 | {L("edcompatible"),NULL, OPT_0BOOL, 0}, | 82 | {L("edcompatible"),NULL, OPT_0BOOL, 0}, | |
83 | /* O_ERRORBELLS 4BSD */ | 83 | /* O_ERRORBELLS 4BSD */ | |
84 | {L("errorbells"), NULL, OPT_0BOOL, 0}, | 84 | {L("errorbells"), NULL, OPT_0BOOL, 0}, | |
85 | /* O_ESCAPETIME 4.4BSD */ | 85 | /* O_ESCAPETIME 4.4BSD */ | |
86 | {L("escapetime"), NULL, OPT_NUM, 0}, | 86 | {L("escapetime"), NULL, OPT_NUM, 0}, | |
87 | /* O_EXPANDTABS NetBSD 5.0 */ | 87 | /* O_EXPANDTAB NetBSD 5.0 */ | |
88 | {L("expandtabs"), NULL, OPT_0BOOL, 0}, | 88 | {L("expandtab"), NULL, OPT_0BOOL, 0}, | |
89 | /* O_EXRC System V (undocumented) */ | 89 | /* O_EXRC System V (undocumented) */ | |
90 | {L("exrc"), NULL, OPT_0BOOL, 0}, | 90 | {L("exrc"), NULL, OPT_0BOOL, 0}, | |
91 | /* O_EXTENDED 4.4BSD */ | 91 | /* O_EXTENDED 4.4BSD */ | |
92 | {L("extended"), f_recompile, OPT_0BOOL, 0}, | 92 | {L("extended"), f_recompile, OPT_0BOOL, 0}, | |
93 | /* O_FILEC 4.4BSD */ | 93 | /* O_FILEC 4.4BSD */ | |
94 | {L("filec"), NULL, OPT_STR, 0}, | 94 | {L("filec"), NULL, OPT_STR, 0}, | |
95 | /* O_FILEENCODING */ | 95 | /* O_FILEENCODING */ | |
96 | {L("fileencoding"),f_encoding, OPT_STR, OPT_WC}, | 96 | {L("fileencoding"),f_encoding, OPT_STR, OPT_WC}, | |
97 | /* O_FLASH HPUX */ | 97 | /* O_FLASH HPUX */ | |
98 | {L("flash"), NULL, OPT_1BOOL, 0}, | 98 | {L("flash"), NULL, OPT_1BOOL, 0}, | |
99 | #ifdef GTAGS | 99 | #ifdef GTAGS | |
100 | /* O_GTAGSMODE FreeBSD/NetBSD */ | 100 | /* O_GTAGSMODE FreeBSD/NetBSD */ | |
101 | {L("gtagsmode"),NULL, OPT_1BOOL, 0}, | 101 | {L("gtagsmode"),NULL, OPT_1BOOL, 0}, | |
@@ -257,26 +257,27 @@ typedef struct abbrev { | @@ -257,26 +257,27 @@ typedef struct abbrev { | |||
257 | const CHAR_T *name; | 257 | const CHAR_T *name; | |
258 | int offset; | 258 | int offset; | |
259 | } OABBREV; | 259 | } OABBREV; | |
260 | 260 | |||
261 | static OABBREV const abbrev[] = { | 261 | static OABBREV const abbrev[] = { | |
262 | {L("ai"), O_AUTOINDENT}, /* 4BSD */ | 262 | {L("ai"), O_AUTOINDENT}, /* 4BSD */ | |
263 | {L("ap"), O_AUTOPRINT}, /* 4BSD */ | 263 | {L("ap"), O_AUTOPRINT}, /* 4BSD */ | |
264 | {L("aw"), O_AUTOWRITE}, /* 4BSD */ | 264 | {L("aw"), O_AUTOWRITE}, /* 4BSD */ | |
265 | {L("bf"), O_BEAUTIFY}, /* 4BSD */ | 265 | {L("bf"), O_BEAUTIFY}, /* 4BSD */ | |
266 | {L("co"), O_COLUMNS}, /* 4.4BSD */ | 266 | {L("co"), O_COLUMNS}, /* 4.4BSD */ | |
267 | {L("dir"), O_TMP_DIRECTORY}, /* 4BSD */ | 267 | {L("dir"), O_TMP_DIRECTORY}, /* 4BSD */ | |
268 | {L("eb"), O_ERRORBELLS}, /* 4BSD */ | 268 | {L("eb"), O_ERRORBELLS}, /* 4BSD */ | |
269 | {L("ed"), O_EDCOMPATIBLE}, /* 4BSD */ | 269 | {L("ed"), O_EDCOMPATIBLE}, /* 4BSD */ | |
270 | {L("et"), O_EXPANDTAB}, /* NetBSD 5.0 */ | |||
270 | {L("ex"), O_EXRC}, /* System V (undocumented) */ | 271 | {L("ex"), O_EXRC}, /* System V (undocumented) */ | |
271 | #ifdef GTAGS | 272 | #ifdef GTAGS | |
272 | {L("gt"), O_GTAGSMODE}, /* FreeBSD, NetBSD */ | 273 | {L("gt"), O_GTAGSMODE}, /* FreeBSD, NetBSD */ | |
273 | #endif | 274 | #endif | |
274 | {L("fe"), O_FILEENCODING}, | 275 | {L("fe"), O_FILEENCODING}, | |
275 | {L("ht"), O_HARDTABS}, /* 4BSD */ | 276 | {L("ht"), O_HARDTABS}, /* 4BSD */ | |
276 | {L("ic"), O_IGNORECASE}, /* 4BSD */ | 277 | {L("ic"), O_IGNORECASE}, /* 4BSD */ | |
277 | {L("ie"), O_INPUTENCODING}, | 278 | {L("ie"), O_INPUTENCODING}, | |
278 | {L("li"), O_LINES}, /* 4.4BSD */ | 279 | {L("li"), O_LINES}, /* 4.4BSD */ | |
279 | {L("modelines"), O_MODELINE}, /* HPUX */ | 280 | {L("modelines"), O_MODELINE}, /* HPUX */ | |
280 | {L("nu"), O_NUMBER}, /* 4BSD */ | 281 | {L("nu"), O_NUMBER}, /* 4BSD */ | |
281 | {L("opt"), O_OPTIMIZE}, /* 4BSD */ | 282 | {L("opt"), O_OPTIMIZE}, /* 4BSD */ | |
282 | {L("para"), O_PARAGRAPHS}, /* 4BSD */ | 283 | {L("para"), O_PARAGRAPHS}, /* 4BSD */ |
--- src/dist/nvi/ex/Attic/ex_shift.c 2008/12/12 22:55:56 1.2
+++ src/dist/nvi/ex/Attic/ex_shift.c 2009/08/07 16:19:54 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ex_shift.c,v 1.2 2008/12/12 22:55:56 lukem Exp $ */ | 1 | /* $NetBSD: ex_shift.c,v 1.3 2009/08/07 16:19:54 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1992, 1993, 1994 | 4 | * Copyright (c) 1992, 1993, 1994 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | 6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | |
7 | * Keith Bostic. All rights reserved. | 7 | * Keith Bostic. All rights reserved. | |
8 | * | 8 | * | |
9 | * See the LICENSE file for redistribution information. | 9 | * See the LICENSE file for redistribution information. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | #include "config.h" | 12 | #include "config.h" | |
13 | 13 | |||
14 | #ifndef lint | 14 | #ifndef lint | |
@@ -125,27 +125,27 @@ shift(SCR *sp, EXCMD *cmdp, enum which r | @@ -125,27 +125,27 @@ shift(SCR *sp, EXCMD *cmdp, enum which r | |||
125 | continue; | 125 | continue; | |
126 | } | 126 | } | |
127 | } | 127 | } | |
128 | 128 | |||
129 | /* Get a buffer that will hold the new line. */ | 129 | /* Get a buffer that will hold the new line. */ | |
130 | ADD_SPACE_RETW(sp, bp, blen, newcol + len); | 130 | ADD_SPACE_RETW(sp, bp, blen, newcol + len); | |
131 | 131 | |||
132 | /* | 132 | /* | |
133 | * Build a new indent string and count the number of | 133 | * Build a new indent string and count the number of | |
134 | * characters it uses. | 134 | * characters it uses. | |
135 | */ | 135 | */ | |
136 | tbp = bp; | 136 | tbp = bp; | |
137 | newidx = 0; | 137 | newidx = 0; | |
138 | if (!O_ISSET(sp, O_EXPANDTABS)) { | 138 | if (!O_ISSET(sp, O_EXPANDTAB)) { | |
139 | for (; newcol >= O_VAL(sp, O_TABSTOP); ++newidx) { | 139 | for (; newcol >= O_VAL(sp, O_TABSTOP); ++newidx) { | |
140 | *tbp++ = '\t'; | 140 | *tbp++ = '\t'; | |
141 | newcol -= O_VAL(sp, O_TABSTOP); | 141 | newcol -= O_VAL(sp, O_TABSTOP); | |
142 | } | 142 | } | |
143 | } | 143 | } | |
144 | for (; newcol > 0; --newcol, ++newidx) | 144 | for (; newcol > 0; --newcol, ++newidx) | |
145 | *tbp++ = ' '; | 145 | *tbp++ = ' '; | |
146 | 146 | |||
147 | /* Add the original line. */ | 147 | /* Add the original line. */ | |
148 | MEMCPYW(tbp, p + oldidx, len - oldidx); | 148 | MEMCPYW(tbp, p + oldidx, len - oldidx); | |
149 | 149 | |||
150 | /* Set the replacement line. */ | 150 | /* Set the replacement line. */ | |
151 | if (db_set(sp, from, bp, (tbp + (len - oldidx)) - bp)) { | 151 | if (db_set(sp, from, bp, (tbp + (len - oldidx)) - bp)) { |
--- src/dist/nvi/ex/Attic/ex_txt.c 2008/12/12 22:55:56 1.3
+++ src/dist/nvi/ex/Attic/ex_txt.c 2009/08/07 16:19:54 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ex_txt.c,v 1.3 2008/12/12 22:55:56 lukem Exp $ */ | 1 | /* $NetBSD: ex_txt.c,v 1.4 2009/08/07 16:19:54 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1992, 1993, 1994 | 4 | * Copyright (c) 1992, 1993, 1994 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | 6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | |
7 | * Keith Bostic. All rights reserved. | 7 | * Keith Bostic. All rights reserved. | |
8 | * | 8 | * | |
9 | * See the LICENSE file for redistribution information. | 9 | * See the LICENSE file for redistribution information. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | #include "config.h" | 12 | #include "config.h" | |
13 | 13 | |||
14 | #ifndef lint | 14 | #ifndef lint | |
@@ -397,27 +397,27 @@ txt_dent(SCR *sp, TEXT *tp) | @@ -397,27 +397,27 @@ txt_dent(SCR *sp, TEXT *tp) | |||
397 | 397 | |||
398 | /* | 398 | /* | |
399 | * Since we don't know what comes before the character(s) being | 399 | * Since we don't know what comes before the character(s) being | |
400 | * deleted, we have to resolve the autoindent characters . The | 400 | * deleted, we have to resolve the autoindent characters . The | |
401 | * example is a <tab>, which doesn't take up a full shiftwidth | 401 | * example is a <tab>, which doesn't take up a full shiftwidth | |
402 | * number of columns because it's preceded by <space>s. This is | 402 | * number of columns because it's preceded by <space>s. This is | |
403 | * easy to get if the user sets shiftwidth to a value less than | 403 | * easy to get if the user sets shiftwidth to a value less than | |
404 | * tabstop, and then uses ^T to indent, and ^D to outdent. | 404 | * tabstop, and then uses ^T to indent, and ^D to outdent. | |
405 | * | 405 | * | |
406 | * Count up spaces/tabs needed to get to the target. | 406 | * Count up spaces/tabs needed to get to the target. | |
407 | */ | 407 | */ | |
408 | cno = 0; | 408 | cno = 0; | |
409 | tabs = 0; | 409 | tabs = 0; | |
410 | if (!O_ISSET(sp, O_EXPANDTABS)) { | 410 | if (!O_ISSET(sp, O_EXPANDTAB)) { | |
411 | for (; cno + COL_OFF(cno, ts) <= scno; ++tabs) | 411 | for (; cno + COL_OFF(cno, ts) <= scno; ++tabs) | |
412 | cno += COL_OFF(cno, ts); | 412 | cno += COL_OFF(cno, ts); | |
413 | } | 413 | } | |
414 | spaces = scno - cno; | 414 | spaces = scno - cno; | |
415 | 415 | |||
416 | /* Make sure there's enough room. */ | 416 | /* Make sure there's enough room. */ | |
417 | BINC_RETW(sp, tp->lb, tp->lb_len, tabs + spaces + 1); | 417 | BINC_RETW(sp, tp->lb, tp->lb_len, tabs + spaces + 1); | |
418 | 418 | |||
419 | /* Adjust the final ai character count. */ | 419 | /* Adjust the final ai character count. */ | |
420 | tp->ai = tabs + spaces; | 420 | tp->ai = tabs + spaces; | |
421 | 421 | |||
422 | /* Enter the replacement characters. */ | 422 | /* Enter the replacement characters. */ | |
423 | for (tp->len = 0; tabs > 0; --tabs) | 423 | for (tp->len = 0; tabs > 0; --tabs) |
--- src/dist/nvi/vi/Attic/v_txt.c 2009/01/18 03:45:50 1.5
+++ src/dist/nvi/vi/Attic/v_txt.c 2009/08/07 16:19:54 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: v_txt.c,v 1.5 2009/01/18 03:45:50 lukem Exp $ */ | 1 | /* $NetBSD: v_txt.c,v 1.6 2009/08/07 16:19:54 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1993, 1994 | 4 | * Copyright (c) 1993, 1994 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | 6 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | |
7 | * Keith Bostic. All rights reserved. | 7 | * Keith Bostic. All rights reserved. | |
8 | * | 8 | * | |
9 | * See the LICENSE file for redistribution information. | 9 | * See the LICENSE file for redistribution information. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | #include "config.h" | 12 | #include "config.h" | |
13 | 13 | |||
14 | #ifndef lint | 14 | #ifndef lint | |
@@ -1715,36 +1715,36 @@ txt_ai_resolve(SCR *sp, TEXT *tp, int *c | @@ -1715,36 +1715,36 @@ txt_ai_resolve(SCR *sp, TEXT *tp, int *c | |||
1715 | spaces = tab_after_sp = 0; len-- && isblank(*p); ++p) | 1715 | spaces = tab_after_sp = 0; len-- && isblank(*p); ++p) | |
1716 | if (*p == '\t') { | 1716 | if (*p == '\t') { | |
1717 | if (spaces) | 1717 | if (spaces) | |
1718 | tab_after_sp = 1; | 1718 | tab_after_sp = 1; | |
1719 | scno += COL_OFF(scno, ts); | 1719 | scno += COL_OFF(scno, ts); | |
1720 | } else { | 1720 | } else { | |
1721 | ++spaces; | 1721 | ++spaces; | |
1722 | ++scno; | 1722 | ++scno; | |
1723 | } | 1723 | } | |
1724 | 1724 | |||
1725 | /* | 1725 | /* | |
1726 | * If there are no spaces, or no tabs after spaces and less than | 1726 | * If there are no spaces, or no tabs after spaces and less than | |
1727 | * ts spaces, it's already minimal. | 1727 | * ts spaces, it's already minimal. | |
1728 | * Keep analysing if expandtabs is set. | 1728 | * Keep analysing if expandtab is set. | |
1729 | */ | 1729 | */ | |
1730 | if ((!spaces || (!tab_after_sp && spaces < ts)) && | 1730 | if ((!spaces || (!tab_after_sp && spaces < ts)) && | |
1731 | !O_ISSET(sp, O_EXPANDTABS)) | 1731 | !O_ISSET(sp, O_EXPANDTAB)) | |
1732 | return; | 1732 | return; | |
1733 | 1733 | |||
1734 | /* Count up spaces/tabs needed to get to the target. */ | 1734 | /* Count up spaces/tabs needed to get to the target. */ | |
1735 | cno = 0; | 1735 | cno = 0; | |
1736 | tabs = 0; | 1736 | tabs = 0; | |
1737 | if (!O_ISSET(sp, O_EXPANDTABS)) { | 1737 | if (!O_ISSET(sp, O_EXPANDTAB)) { | |
1738 | for (; cno + COL_OFF(cno, ts) <= scno; ++tabs) | 1738 | for (; cno + COL_OFF(cno, ts) <= scno; ++tabs) | |
1739 | cno += COL_OFF(cno, ts); | 1739 | cno += COL_OFF(cno, ts); | |
1740 | } | 1740 | } | |
1741 | spaces = scno - cno; | 1741 | spaces = scno - cno; | |
1742 | 1742 | |||
1743 | /* | 1743 | /* | |
1744 | * Figure out how many characters we're dropping -- if we're not | 1744 | * Figure out how many characters we're dropping -- if we're not | |
1745 | * dropping any, it's already minimal, we're done. | 1745 | * dropping any, it's already minimal, we're done. | |
1746 | */ | 1746 | */ | |
1747 | old = p - tp->lb; | 1747 | old = p - tp->lb; | |
1748 | new = spaces + tabs; | 1748 | new = spaces + tabs; | |
1749 | if (old == new) | 1749 | if (old == new) | |
1750 | return; | 1750 | return; | |
@@ -1952,27 +1952,27 @@ txt_dent(SCR *sp, TEXT *tp, int isindent | @@ -1952,27 +1952,27 @@ txt_dent(SCR *sp, TEXT *tp, int isindent | |||
1952 | * ^D to move to the beginning of a line. An example of this is: | 1952 | * ^D to move to the beginning of a line. An example of this is: | |
1953 | * | 1953 | * | |
1954 | * :set ai sw=4<cr>i<space>a<esc>i^T^D | 1954 | * :set ai sw=4<cr>i<space>a<esc>i^T^D | |
1955 | * | 1955 | * | |
1956 | * Otherwise, count up the total spaces/tabs needed to get from the | 1956 | * Otherwise, count up the total spaces/tabs needed to get from the | |
1957 | * beginning of the line (or the last non-<blank> character) to the | 1957 | * beginning of the line (or the last non-<blank> character) to the | |
1958 | * target. | 1958 | * target. | |
1959 | */ | 1959 | */ | |
1960 | if (current >= target) | 1960 | if (current >= target) | |
1961 | spaces = tabs = 0; | 1961 | spaces = tabs = 0; | |
1962 | else { | 1962 | else { | |
1963 | cno = current; | 1963 | cno = current; | |
1964 | tabs = 0; | 1964 | tabs = 0; | |
1965 | if (!O_ISSET(sp, O_EXPANDTABS)) { | 1965 | if (!O_ISSET(sp, O_EXPANDTAB)) { | |
1966 | for (; cno + COL_OFF(cno, ts) <= target; ++tabs) | 1966 | for (; cno + COL_OFF(cno, ts) <= target; ++tabs) | |
1967 | cno += COL_OFF(cno, ts); | 1967 | cno += COL_OFF(cno, ts); | |
1968 | } | 1968 | } | |
1969 | spaces = target - cno; | 1969 | spaces = target - cno; | |
1970 | } | 1970 | } | |
1971 | 1971 | |||
1972 | tp->ai = tabs + spaces; | 1972 | tp->ai = tabs + spaces; | |
1973 | 1973 | |||
1974 | /* | 1974 | /* | |
1975 | * Call txt_insch() to insert each character, so that we get the | 1975 | * Call txt_insch() to insert each character, so that we get the | |
1976 | * correct effect when we add a <tab> to replace N <spaces>. | 1976 | * correct effect when we add a <tab> to replace N <spaces>. | |
1977 | */ | 1977 | */ | |
1978 | for (ch = '\t'; tabs > 0; --tabs) | 1978 | for (ch = '\t'; tabs > 0; --tabs) |