Line 0
Link Here
|
|
|
1 |
Adapted from: |
2 |
|
3 |
http://flex.phys.tohoku.ac.jp/~okuyama/nvi-m17n-expandtab.html |
4 |
http://flex.phys.tohoku.ac.jp/~okuyama/src/nvi-m17n-expandtab.patch |
5 |
|
6 |
diff -u ../common/options.c.orig ../common/options.c |
7 |
--- ../common/options.c.orig 2007-11-18 16:41:42.000000000 +0000 |
8 |
+++ ../common/options.c 2019-02-01 23:18:48.173808000 +0000 |
9 |
@@ -78,6 +78,10 @@ |
10 |
{L("edcompatible"),NULL, OPT_0BOOL, 0}, |
11 |
/* O_ESCAPETIME 4.4BSD */ |
12 |
{L("escapetime"), NULL, OPT_NUM, 0}, |
13 |
+#ifdef O_EXPANDTAB |
14 |
+/* O_EXPANDTAB NetBSD 5.0 */ |
15 |
+ {L("expandtab"), NULL, OPT_0BOOL, 0}, |
16 |
+#endif |
17 |
/* O_ERRORBELLS 4BSD */ |
18 |
{L("errorbells"), NULL, OPT_0BOOL, 0}, |
19 |
/* O_EXRC System V (undocumented) */ |
20 |
diff -u ../common/options_def.h.orig ../common/options_def.h |
21 |
--- ../common/options_def.h.orig 2007-11-18 16:43:54.000000000 +0000 |
22 |
+++ ../common/options_def.h 2019-02-01 23:18:48.174244000 +0000 |
23 |
@@ -13,71 +13,72 @@ |
24 |
#define O_TMP_DIRECTORY 11 |
25 |
#define O_EDCOMPATIBLE 12 |
26 |
#define O_ESCAPETIME 13 |
27 |
-#define O_ERRORBELLS 14 |
28 |
-#define O_EXRC 15 |
29 |
-#define O_EXTENDED 16 |
30 |
-#define O_FILEC 17 |
31 |
-#define O_FILEENCODING 18 |
32 |
-#define O_FLASH 19 |
33 |
-#define O_HARDTABS 20 |
34 |
-#define O_ICLOWER 21 |
35 |
-#define O_IGNORECASE 22 |
36 |
-#define O_INPUTENCODING 23 |
37 |
-#define O_KEYTIME 24 |
38 |
-#define O_LEFTRIGHT 25 |
39 |
-#define O_LINES 26 |
40 |
-#define O_LISP 27 |
41 |
-#define O_LIST 28 |
42 |
-#define O_LOCKFILES 29 |
43 |
-#define O_MAGIC 30 |
44 |
-#define O_MATCHTIME 31 |
45 |
-#define O_MESG 32 |
46 |
-#define O_MODELINE 33 |
47 |
-#define O_MSGCAT 34 |
48 |
-#define O_NOPRINT 35 |
49 |
-#define O_NUMBER 36 |
50 |
-#define O_OCTAL 37 |
51 |
-#define O_OPEN 38 |
52 |
-#define O_OPTIMIZE 39 |
53 |
-#define O_PARAGRAPHS 40 |
54 |
-#define O_PATH 41 |
55 |
-#define O_PRINT 42 |
56 |
-#define O_PROMPT 43 |
57 |
-#define O_READONLY 44 |
58 |
-#define O_RECDIR 45 |
59 |
-#define O_REDRAW 46 |
60 |
-#define O_REMAP 47 |
61 |
-#define O_REPORT 48 |
62 |
-#define O_RULER 49 |
63 |
-#define O_SCROLL 50 |
64 |
-#define O_SEARCHINCR 51 |
65 |
-#define O_SECTIONS 52 |
66 |
-#define O_SECURE 53 |
67 |
-#define O_SHELL 54 |
68 |
-#define O_SHELLMETA 55 |
69 |
-#define O_SHIFTWIDTH 56 |
70 |
-#define O_SHOWMATCH 57 |
71 |
-#define O_SHOWMODE 58 |
72 |
-#define O_SIDESCROLL 59 |
73 |
-#define O_SLOWOPEN 60 |
74 |
-#define O_SOURCEANY 61 |
75 |
-#define O_TABSTOP 62 |
76 |
-#define O_TAGLENGTH 63 |
77 |
-#define O_TAGS 64 |
78 |
-#define O_TERM 65 |
79 |
-#define O_TERSE 66 |
80 |
-#define O_TILDEOP 67 |
81 |
-#define O_TIMEOUT 68 |
82 |
-#define O_TTYWERASE 69 |
83 |
-#define O_VERBOSE 70 |
84 |
-#define O_W1200 71 |
85 |
-#define O_W300 72 |
86 |
-#define O_W9600 73 |
87 |
-#define O_WARN 74 |
88 |
-#define O_WINDOW 75 |
89 |
-#define O_WINDOWNAME 76 |
90 |
-#define O_WRAPLEN 77 |
91 |
-#define O_WRAPMARGIN 78 |
92 |
-#define O_WRAPSCAN 79 |
93 |
-#define O_WRITEANY 80 |
94 |
-#define O_OPTIONCOUNT 81 |
95 |
+#define O_EXPANDTAB 14 |
96 |
+#define O_ERRORBELLS 15 |
97 |
+#define O_EXRC 16 |
98 |
+#define O_EXTENDED 17 |
99 |
+#define O_FILEC 18 |
100 |
+#define O_FILEENCODING 19 |
101 |
+#define O_FLASH 20 |
102 |
+#define O_HARDTABS 21 |
103 |
+#define O_ICLOWER 22 |
104 |
+#define O_IGNORECASE 23 |
105 |
+#define O_INPUTENCODING 24 |
106 |
+#define O_KEYTIME 25 |
107 |
+#define O_LEFTRIGHT 26 |
108 |
+#define O_LINES 27 |
109 |
+#define O_LISP 28 |
110 |
+#define O_LIST 29 |
111 |
+#define O_LOCKFILES 30 |
112 |
+#define O_MAGIC 31 |
113 |
+#define O_MATCHTIME 32 |
114 |
+#define O_MESG 33 |
115 |
+#define O_MODELINE 34 |
116 |
+#define O_MSGCAT 35 |
117 |
+#define O_NOPRINT 36 |
118 |
+#define O_NUMBER 37 |
119 |
+#define O_OCTAL 38 |
120 |
+#define O_OPEN 39 |
121 |
+#define O_OPTIMIZE 40 |
122 |
+#define O_PARAGRAPHS 41 |
123 |
+#define O_PATH 42 |
124 |
+#define O_PRINT 43 |
125 |
+#define O_PROMPT 44 |
126 |
+#define O_READONLY 45 |
127 |
+#define O_RECDIR 46 |
128 |
+#define O_REDRAW 47 |
129 |
+#define O_REMAP 48 |
130 |
+#define O_REPORT 49 |
131 |
+#define O_RULER 50 |
132 |
+#define O_SCROLL 51 |
133 |
+#define O_SEARCHINCR 52 |
134 |
+#define O_SECTIONS 53 |
135 |
+#define O_SECURE 54 |
136 |
+#define O_SHELL 55 |
137 |
+#define O_SHELLMETA 56 |
138 |
+#define O_SHIFTWIDTH 57 |
139 |
+#define O_SHOWMATCH 58 |
140 |
+#define O_SHOWMODE 59 |
141 |
+#define O_SIDESCROLL 60 |
142 |
+#define O_SLOWOPEN 61 |
143 |
+#define O_SOURCEANY 62 |
144 |
+#define O_TABSTOP 63 |
145 |
+#define O_TAGLENGTH 64 |
146 |
+#define O_TAGS 65 |
147 |
+#define O_TERM 66 |
148 |
+#define O_TERSE 67 |
149 |
+#define O_TILDEOP 68 |
150 |
+#define O_TIMEOUT 69 |
151 |
+#define O_TTYWERASE 70 |
152 |
+#define O_VERBOSE 71 |
153 |
+#define O_W1200 72 |
154 |
+#define O_W300 73 |
155 |
+#define O_W9600 74 |
156 |
+#define O_WARN 75 |
157 |
+#define O_WINDOW 76 |
158 |
+#define O_WINDOWNAME 77 |
159 |
+#define O_WRAPLEN 78 |
160 |
+#define O_WRAPMARGIN 79 |
161 |
+#define O_WRAPSCAN 80 |
162 |
+#define O_WRITEANY 81 |
163 |
+#define O_OPTIONCOUNT 82 |
164 |
diff -u ../ex/ex_shift.c.orig ../ex/ex_shift.c |
165 |
--- ../ex/ex_shift.c.orig 2007-11-18 16:41:42.000000000 +0000 |
166 |
+++ ../ex/ex_shift.c 2019-02-02 00:56:44.320820000 +0000 |
167 |
@@ -131,10 +131,19 @@ |
168 |
* Build a new indent string and count the number of |
169 |
* characters it uses. |
170 |
*/ |
171 |
+#ifdef O_EXPANDTAB |
172 |
+/* NetBSD 5.0 */ |
173 |
+ tbp = bp; |
174 |
+ newidx = 0; |
175 |
+ if (!O_ISSET(sp, O_EXPANDTAB)) { |
176 |
+#endif |
177 |
for (tbp = bp, newidx = 0; |
178 |
newcol >= O_VAL(sp, O_TABSTOP); ++newidx) { |
179 |
*tbp++ = '\t'; |
180 |
newcol -= O_VAL(sp, O_TABSTOP); |
181 |
+#ifdef O_EXPANDTAB |
182 |
+ } |
183 |
+#endif |
184 |
} |
185 |
for (; newcol > 0; --newcol, ++newidx) |
186 |
*tbp++ = ' '; |
187 |
diff -u ../ex/ex_txt.c.orig ../ex/ex_txt.c |
188 |
--- ../ex/ex_txt.c.orig 2007-11-18 16:41:42.000000000 +0000 |
189 |
+++ ../ex/ex_txt.c 2019-02-01 23:18:48.174717000 +0000 |
190 |
@@ -403,8 +403,17 @@ |
191 |
* |
192 |
* Count up spaces/tabs needed to get to the target. |
193 |
*/ |
194 |
+#ifdef O_EXPANDTAB |
195 |
+/* NetBSD 5.0 */ |
196 |
+ cno = 0; |
197 |
+ tabs = 0; |
198 |
+ if (!O_ISSET(sp, O_EXPANDTAB)) { |
199 |
+#endif |
200 |
for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs) |
201 |
cno += COL_OFF(cno, ts); |
202 |
+#ifdef O_EXPANDTAB |
203 |
+ } |
204 |
+#endif |
205 |
spaces = scno - cno; |
206 |
|
207 |
/* Make sure there's enough room. */ |
208 |
diff -u ../vi/v_txt.c.orig ../vi/v_txt.c |
209 |
--- ../vi/v_txt.c.orig 2007-11-18 16:41:42.000000000 +0000 |
210 |
+++ ../vi/v_txt.c 2019-02-01 23:18:48.175305000 +0000 |
211 |
@@ -1720,12 +1720,26 @@ |
212 |
* If there are no spaces, or no tabs after spaces and less than |
213 |
* ts spaces, it's already minimal. |
214 |
*/ |
215 |
+#ifdef O_EXPANDTAB |
216 |
+/* NetBSD 5.0 */ |
217 |
+ |
218 |
+ /* Keep analysing if expandtabs is set. */ |
219 |
+ if (!O_ISSET(sp, O_EXPANDTAB)) |
220 |
+#endif |
221 |
if (!spaces || !tab_after_sp && spaces < ts) |
222 |
return; |
223 |
|
224 |
/* Count up spaces/tabs needed to get to the target. */ |
225 |
+#ifdef O_EXPANDTAB |
226 |
+ cno = 0; |
227 |
+ tabs = 0; |
228 |
+ if (!O_ISSET(sp, O_EXPANDTAB)) { |
229 |
+#endif |
230 |
for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs) |
231 |
cno += COL_OFF(cno, ts); |
232 |
+#ifdef O_EXPANDTAB |
233 |
+ } |
234 |
+#endif |
235 |
spaces = scno - cno; |
236 |
|
237 |
/* |
238 |
@@ -1957,9 +1971,17 @@ |
239 |
if (current >= target) |
240 |
spaces = tabs = 0; |
241 |
else { |
242 |
+#ifdef O_EXPANDTAB |
243 |
+ cno = current; |
244 |
+ tabs = 0; |
245 |
+ if (!O_ISSET(sp, O_EXPANDTAB)) { |
246 |
+#endif |
247 |
for (cno = current, |
248 |
tabs = 0; cno + COL_OFF(cno, ts) <= target; ++tabs) |
249 |
cno += COL_OFF(cno, ts); |
250 |
+#ifdef O_EXPANDTAB |
251 |
+ } |
252 |
+#endif |
253 |
spaces = target - cno; |
254 |
} |
255 |
|