summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-30 18:42:29 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-30 18:42:29 +0000
commit6a5dc5d75a1368464fc7e085aa1f1d4c453d27cd (patch)
treed270e6fa41ae3b327aaef60a956328961795594a
parent3bba545a54addf59b63a003e7ada03fd8b29b5ba (diff)
downloadbusybox-w32-6a5dc5d75a1368464fc7e085aa1f1d4c453d27cd.tar.gz
busybox-w32-6a5dc5d75a1368464fc7e085aa1f1d4c453d27cd.tar.bz2
busybox-w32-6a5dc5d75a1368464fc7e085aa1f1d4c453d27cd.zip
next bunch of fixes for bugs found by randconfig
-rw-r--r--editors/vi.c407
-rw-r--r--libbb/Kbuild2
-rw-r--r--modutils/insmod.c7
-rw-r--r--util-linux/fdisk.c30
-rw-r--r--util-linux/fdisk_aix.c2
-rw-r--r--util-linux/fdisk_osf.c2
-rw-r--r--util-linux/fdisk_sgi.c6
-rw-r--r--util-linux/fdisk_sun.c6
8 files changed, 234 insertions, 228 deletions
diff --git a/editors/vi.c b/editors/vi.c
index dc93bc424..46181cf60 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -21,10 +21,11 @@
21 * An "ex" line oriented mode- maybe using "cmdedit" 21 * An "ex" line oriented mode- maybe using "cmdedit"
22 */ 22 */
23 23
24
25#include "busybox.h" 24#include "busybox.h"
26 25
27#ifdef CONFIG_LOCALE_SUPPORT 26#define ENABLE_FEATURE_VI_CRASHME 0
27
28#if ENABLE_LOCALE_SUPPORT
28#define Isprint(c) isprint((c)) 29#define Isprint(c) isprint((c))
29#else 30#else
30#define Isprint(c) ( (c) >= ' ' && (c) != 127 && (c) != ((unsigned char)'\233') ) 31#define Isprint(c) ( (c) >= ' ' && (c) != 127 && (c) != ((unsigned char)'\233') )
@@ -127,35 +128,35 @@ static Byte erase_char; // the users erase character
127static Byte last_input_char; // last char read from user 128static Byte last_input_char; // last char read from user
128static Byte last_forward_char; // last char searched for with 'f' 129static Byte last_forward_char; // last char searched for with 'f'
129 130
130#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 131#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
131static int last_row; // where the cursor was last moved to 132static int last_row; // where the cursor was last moved to
132#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 133#endif
133#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 134#if ENABLE_FEATURE_VI_USE_SIGNALS
134static jmp_buf restart; // catch_sig() 135static jmp_buf restart; // catch_sig()
135#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */ 136#endif
136#if defined(CONFIG_FEATURE_VI_USE_SIGNALS) || defined(CONFIG_FEATURE_VI_CRASHME) 137#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
137static int my_pid; 138static int my_pid;
138#endif 139#endif
139#ifdef CONFIG_FEATURE_VI_DOT_CMD 140#if ENABLE_FEATURE_VI_DOT_CMD
140static int adding2q; // are we currently adding user input to q 141static int adding2q; // are we currently adding user input to q
141static Byte *last_modifying_cmd; // last modifying cmd for "." 142static Byte *last_modifying_cmd; // last modifying cmd for "."
142static Byte *ioq, *ioq_start; // pointer to string for get_one_char to "read" 143static Byte *ioq, *ioq_start; // pointer to string for get_one_char to "read"
143#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 144#endif
144#if defined(CONFIG_FEATURE_VI_DOT_CMD) || defined(CONFIG_FEATURE_VI_YANKMARK) 145#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
145static Byte *modifying_cmds; // cmds that modify text[] 146static Byte *modifying_cmds; // cmds that modify text[]
146#endif /* CONFIG_FEATURE_VI_DOT_CMD || CONFIG_FEATURE_VI_YANKMARK */ 147#endif
147#ifdef CONFIG_FEATURE_VI_READONLY 148#if ENABLE_FEATURE_VI_READONLY
148static int vi_readonly, readonly; 149static int vi_readonly, readonly;
149#endif /* CONFIG_FEATURE_VI_READONLY */ 150#endif
150#ifdef CONFIG_FEATURE_VI_YANKMARK 151#if ENABLE_FEATURE_VI_YANKMARK
151static Byte *reg[28]; // named register a-z, "D", and "U" 0-25,26,27 152static Byte *reg[28]; // named register a-z, "D", and "U" 0-25,26,27
152static int YDreg, Ureg; // default delete register and orig line for "U" 153static int YDreg, Ureg; // default delete register and orig line for "U"
153static Byte *mark[28]; // user marks points somewhere in text[]- a-z and previous context '' 154static Byte *mark[28]; // user marks points somewhere in text[]- a-z and previous context ''
154static Byte *context_start, *context_end; 155static Byte *context_start, *context_end;
155#endif /* CONFIG_FEATURE_VI_YANKMARK */ 156#endif
156#ifdef CONFIG_FEATURE_VI_SEARCH 157#if ENABLE_FEATURE_VI_SEARCH
157static Byte *last_search_pattern; // last pattern from a '/' or '?' search 158static Byte *last_search_pattern; // last pattern from a '/' or '?' search
158#endif /* CONFIG_FEATURE_VI_SEARCH */ 159#endif
159 160
160 161
161static void edit_file(Byte *); // edit one file 162static void edit_file(Byte *); // edit one file
@@ -220,42 +221,42 @@ static void Indicate_Error(void); // use flash or beep to indicate error
220#define indicate_error(c) Indicate_Error() 221#define indicate_error(c) Indicate_Error()
221static void Hit_Return(void); 222static void Hit_Return(void);
222 223
223#ifdef CONFIG_FEATURE_VI_SEARCH 224#if ENABLE_FEATURE_VI_SEARCH
224static Byte *char_search(Byte *, Byte *, int, int); // search for pattern starting at p 225static Byte *char_search(Byte *, Byte *, int, int); // search for pattern starting at p
225static int mycmp(Byte *, Byte *, int); // string cmp based in "ignorecase" 226static int mycmp(Byte *, Byte *, int); // string cmp based in "ignorecase"
226#endif /* CONFIG_FEATURE_VI_SEARCH */ 227#endif
227#ifdef CONFIG_FEATURE_VI_COLON 228#if ENABLE_FEATURE_VI_COLON
228static Byte *get_one_address(Byte *, int *); // get colon addr, if present 229static Byte *get_one_address(Byte *, int *); // get colon addr, if present
229static Byte *get_address(Byte *, int *, int *); // get two colon addrs, if present 230static Byte *get_address(Byte *, int *, int *); // get two colon addrs, if present
230static void colon(Byte *); // execute the "colon" mode cmds 231static void colon(Byte *); // execute the "colon" mode cmds
231#endif /* CONFIG_FEATURE_VI_COLON */ 232#endif
232#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 233#if ENABLE_FEATURE_VI_USE_SIGNALS
233static void winch_sig(int); // catch window size changes 234static void winch_sig(int); // catch window size changes
234static void suspend_sig(int); // catch ctrl-Z 235static void suspend_sig(int); // catch ctrl-Z
235static void catch_sig(int); // catch ctrl-C and alarm time-outs 236static void catch_sig(int); // catch ctrl-C and alarm time-outs
236#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */ 237#endif
237#ifdef CONFIG_FEATURE_VI_DOT_CMD 238#if ENABLE_FEATURE_VI_DOT_CMD
238static void start_new_cmd_q(Byte); // new queue for command 239static void start_new_cmd_q(Byte); // new queue for command
239static void end_cmd_q(void); // stop saving input chars 240static void end_cmd_q(void); // stop saving input chars
240#else /* CONFIG_FEATURE_VI_DOT_CMD */ 241#else
241#define end_cmd_q() 242#define end_cmd_q() ((void)0)
242#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 243#endif
243#ifdef CONFIG_FEATURE_VI_SETOPTS 244#if ENABLE_FEATURE_VI_SETOPTS
244static void showmatching(Byte *); // show the matching pair () [] {} 245static void showmatching(Byte *); // show the matching pair () [] {}
245#endif /* CONFIG_FEATURE_VI_SETOPTS */ 246#endif
246#if defined(CONFIG_FEATURE_VI_YANKMARK) || (defined(CONFIG_FEATURE_VI_COLON) && defined(CONFIG_FEATURE_VI_SEARCH)) || defined(CONFIG_FEATURE_VI_CRASHME) 247#if ENABLE_FEATURE_VI_YANKMARK || (ENABLE_FEATURE_VI_COLON && ENABLE_FEATURE_VI_SEARCH) || ENABLE_FEATURE_VI_CRASHME
247static Byte *string_insert(Byte *, Byte *); // insert the string at 'p' 248static Byte *string_insert(Byte *, Byte *); // insert the string at 'p'
248#endif /* CONFIG_FEATURE_VI_YANKMARK || CONFIG_FEATURE_VI_SEARCH || CONFIG_FEATURE_VI_CRASHME */ 249#endif
249#ifdef CONFIG_FEATURE_VI_YANKMARK 250#if ENABLE_FEATURE_VI_YANKMARK
250static Byte *text_yank(Byte *, Byte *, int); // save copy of "p" into a register 251static Byte *text_yank(Byte *, Byte *, int); // save copy of "p" into a register
251static Byte what_reg(void); // what is letter of current YDreg 252static Byte what_reg(void); // what is letter of current YDreg
252static void check_context(Byte); // remember context for '' command 253static void check_context(Byte); // remember context for '' command
253#endif /* CONFIG_FEATURE_VI_YANKMARK */ 254#endif
254#ifdef CONFIG_FEATURE_VI_CRASHME 255#if ENABLE_FEATURE_VI_CRASHME
255static void crash_dummy(); 256static void crash_dummy();
256static void crash_test(); 257static void crash_test();
257static int crashme = 0; 258static int crashme = 0;
258#endif /* CONFIG_FEATURE_VI_CRASHME */ 259#endif
259 260
260 261
261static void write1(const char *out) 262static void write1(const char *out)
@@ -268,52 +269,52 @@ int vi_main(int argc, char **argv)
268 int c; 269 int c;
269 RESERVE_CONFIG_BUFFER(STATUS_BUFFER, STATUS_BUFFER_LEN); 270 RESERVE_CONFIG_BUFFER(STATUS_BUFFER, STATUS_BUFFER_LEN);
270 271
271#ifdef CONFIG_FEATURE_VI_YANKMARK 272#if ENABLE_FEATURE_VI_YANKMARK
272 int i; 273 int i;
273#endif /* CONFIG_FEATURE_VI_YANKMARK */ 274#endif
274#if defined(CONFIG_FEATURE_VI_USE_SIGNALS) || defined(CONFIG_FEATURE_VI_CRASHME) 275#if defined(CONFIG_FEATURE_VI_USE_SIGNALS) || defined(CONFIG_FEATURE_VI_CRASHME)
275 my_pid = getpid(); 276 my_pid = getpid();
276#endif 277#endif
277#ifdef CONFIG_FEATURE_VI_CRASHME 278#if ENABLE_FEATURE_VI_CRASHME
278 (void) srand((long) my_pid); 279 (void) srand((long) my_pid);
279#endif /* CONFIG_FEATURE_VI_CRASHME */ 280#endif
280 281
281 status_buffer = (Byte *)STATUS_BUFFER; 282 status_buffer = (Byte *)STATUS_BUFFER;
282 last_status_cksum = 0; 283 last_status_cksum = 0;
283 284
284#ifdef CONFIG_FEATURE_VI_READONLY 285#if ENABLE_FEATURE_VI_READONLY
285 vi_readonly = readonly = FALSE; 286 vi_readonly = readonly = FALSE;
286 if (strncmp(argv[0], "view", 4) == 0) { 287 if (strncmp(argv[0], "view", 4) == 0) {
287 readonly = TRUE; 288 readonly = TRUE;
288 vi_readonly = TRUE; 289 vi_readonly = TRUE;
289 } 290 }
290#endif /* CONFIG_FEATURE_VI_READONLY */ 291#endif
291 vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE | VI_ERR_METHOD; 292 vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE | VI_ERR_METHOD;
292#ifdef CONFIG_FEATURE_VI_YANKMARK 293#if ENABLE_FEATURE_VI_YANKMARK
293 for (i = 0; i < 28; i++) { 294 for (i = 0; i < 28; i++) {
294 reg[i] = 0; 295 reg[i] = 0;
295 } // init the yank regs 296 } // init the yank regs
296#endif /* CONFIG_FEATURE_VI_YANKMARK */ 297#endif
297#if defined(CONFIG_FEATURE_VI_DOT_CMD) || defined(CONFIG_FEATURE_VI_YANKMARK) 298#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
298 modifying_cmds = (Byte *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[] 299 modifying_cmds = (Byte *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[]
299#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 300#endif
300 301
301 // 1- process $HOME/.exrc file 302 // 1- process $HOME/.exrc file
302 // 2- process EXINIT variable from environment 303 // 2- process EXINIT variable from environment
303 // 3- process command line args 304 // 3- process command line args
304 while ((c = getopt(argc, argv, "hCR")) != -1) { 305 while ((c = getopt(argc, argv, "hCR")) != -1) {
305 switch (c) { 306 switch (c) {
306#ifdef CONFIG_FEATURE_VI_CRASHME 307#if ENABLE_FEATURE_VI_CRASHME
307 case 'C': 308 case 'C':
308 crashme = 1; 309 crashme = 1;
309 break; 310 break;
310#endif /* CONFIG_FEATURE_VI_CRASHME */ 311#endif
311#ifdef CONFIG_FEATURE_VI_READONLY 312#if ENABLE_FEATURE_VI_READONLY
312 case 'R': // Read-only flag 313 case 'R': // Read-only flag
313 readonly = TRUE; 314 readonly = TRUE;
314 vi_readonly = TRUE; 315 vi_readonly = TRUE;
315 break; 316 break;
316#endif /* CONFIG_FEATURE_VI_READONLY */ 317#endif
317 //case 'r': // recover flag- ignore- we don't use tmp file 318 //case 'r': // recover flag- ignore- we don't use tmp file
318 //case 'x': // encryption flag- ignore 319 //case 'x': // encryption flag- ignore
319 //case 'c': // execute command first 320 //case 'c': // execute command first
@@ -351,12 +352,12 @@ static void edit_file(Byte * fn)
351 Byte c; 352 Byte c;
352 int cnt, size, ch; 353 int cnt, size, ch;
353 354
354#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 355#if ENABLE_FEATURE_VI_USE_SIGNALS
355 int sig; 356 int sig;
356#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */ 357#endif
357#ifdef CONFIG_FEATURE_VI_YANKMARK 358#if ENABLE_FEATURE_VI_YANKMARK
358 static Byte *cur_line; 359 static Byte *cur_line;
359#endif /* CONFIG_FEATURE_VI_YANKMARK */ 360#endif
360 361
361 rawmode(); 362 rawmode();
362 rows = 24; 363 rows = 24;
@@ -378,20 +379,20 @@ static void edit_file(Byte * fn)
378 } 379 }
379 file_modified = 0; 380 file_modified = 0;
380 last_file_modified = -1; 381 last_file_modified = -1;
381#ifdef CONFIG_FEATURE_VI_YANKMARK 382#if ENABLE_FEATURE_VI_YANKMARK
382 YDreg = 26; // default Yank/Delete reg 383 YDreg = 26; // default Yank/Delete reg
383 Ureg = 27; // hold orig line for "U" cmd 384 Ureg = 27; // hold orig line for "U" cmd
384 for (cnt = 0; cnt < 28; cnt++) { 385 for (cnt = 0; cnt < 28; cnt++) {
385 mark[cnt] = 0; 386 mark[cnt] = 0;
386 } // init the marks 387 } // init the marks
387 mark[26] = mark[27] = text; // init "previous context" 388 mark[26] = mark[27] = text; // init "previous context"
388#endif /* CONFIG_FEATURE_VI_YANKMARK */ 389#endif
389 390
390 last_forward_char = last_input_char = '\0'; 391 last_forward_char = last_input_char = '\0';
391 crow = 0; 392 crow = 0;
392 ccol = 0; 393 ccol = 0;
393 394
394#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 395#if ENABLE_FEATURE_VI_USE_SIGNALS
395 catch_sig(0); 396 catch_sig(0);
396 signal(SIGWINCH, winch_sig); 397 signal(SIGWINCH, winch_sig);
397 signal(SIGTSTP, suspend_sig); 398 signal(SIGTSTP, suspend_sig);
@@ -399,7 +400,7 @@ static void edit_file(Byte * fn)
399 if (sig != 0) { 400 if (sig != 0) {
400 screenbegin = dot = text; 401 screenbegin = dot = text;
401 } 402 }
402#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */ 403#endif
403 404
404 editing = 1; 405 editing = 1;
405 cmd_mode = 0; // 0=command 1=insert 2='R'eplace 406 cmd_mode = 0; // 0=command 1=insert 2='R'eplace
@@ -407,18 +408,18 @@ static void edit_file(Byte * fn)
407 tabstop = 8; 408 tabstop = 8;
408 offset = 0; // no horizontal offset 409 offset = 0; // no horizontal offset
409 c = '\0'; 410 c = '\0';
410#ifdef CONFIG_FEATURE_VI_DOT_CMD 411#if ENABLE_FEATURE_VI_DOT_CMD
411 free(last_modifying_cmd); 412 free(last_modifying_cmd);
412 free(ioq_start); 413 free(ioq_start);
413 ioq = ioq_start = last_modifying_cmd = 0; 414 ioq = ioq_start = last_modifying_cmd = 0;
414 adding2q = 0; 415 adding2q = 0;
415#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 416#endif
416 redraw(FALSE); // dont force every col re-draw 417 redraw(FALSE); // dont force every col re-draw
417 show_status_line(); 418 show_status_line();
418 419
419 //------This is the main Vi cmd handling loop ----------------------- 420 //------This is the main Vi cmd handling loop -----------------------
420 while (editing > 0) { 421 while (editing > 0) {
421#ifdef CONFIG_FEATURE_VI_CRASHME 422#if ENABLE_FEATURE_VI_CRASHME
422 if (crashme > 0) { 423 if (crashme > 0) {
423 if ((end - text) > 1) { 424 if ((end - text) > 1) {
424 crash_dummy(); // generate a random command 425 crash_dummy(); // generate a random command
@@ -429,23 +430,23 @@ static void edit_file(Byte * fn)
429 refresh(FALSE); 430 refresh(FALSE);
430 } 431 }
431 } 432 }
432#endif /* CONFIG_FEATURE_VI_CRASHME */ 433#endif
433 last_input_char = c = get_one_char(); // get a cmd from user 434 last_input_char = c = get_one_char(); // get a cmd from user
434#ifdef CONFIG_FEATURE_VI_YANKMARK 435#if ENABLE_FEATURE_VI_YANKMARK
435 // save a copy of the current line- for the 'U" command 436 // save a copy of the current line- for the 'U" command
436 if (begin_line(dot) != cur_line) { 437 if (begin_line(dot) != cur_line) {
437 cur_line = begin_line(dot); 438 cur_line = begin_line(dot);
438 text_yank(begin_line(dot), end_line(dot), Ureg); 439 text_yank(begin_line(dot), end_line(dot), Ureg);
439 } 440 }
440#endif /* CONFIG_FEATURE_VI_YANKMARK */ 441#endif
441#ifdef CONFIG_FEATURE_VI_DOT_CMD 442#if ENABLE_FEATURE_VI_DOT_CMD
442 // These are commands that change text[]. 443 // These are commands that change text[].
443 // Remember the input for the "." command 444 // Remember the input for the "." command
444 if (!adding2q && ioq_start == 0 445 if (!adding2q && ioq_start == 0
445 && strchr((char *) modifying_cmds, c) != NULL) { 446 && strchr((char *) modifying_cmds, c) != NULL) {
446 start_new_cmd_q(c); 447 start_new_cmd_q(c);
447 } 448 }
448#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 449#endif
449 do_cmd(c); // execute the user command 450 do_cmd(c); // execute the user command
450 // 451 //
451 // poll to see if there is input already waiting. if we are 452 // poll to see if there is input already waiting. if we are
@@ -456,10 +457,10 @@ static void edit_file(Byte * fn)
456 refresh(FALSE); 457 refresh(FALSE);
457 show_status_line(); 458 show_status_line();
458 } 459 }
459#ifdef CONFIG_FEATURE_VI_CRASHME 460#if ENABLE_FEATURE_VI_CRASHME
460 if (crashme > 0) 461 if (crashme > 0)
461 crash_test(); // test editor variables 462 crash_test(); // test editor variables
462#endif /* CONFIG_FEATURE_VI_CRASHME */ 463#endif
463 } 464 }
464 //------------------------------------------------------------------- 465 //-------------------------------------------------------------------
465 466
@@ -469,25 +470,25 @@ static void edit_file(Byte * fn)
469} 470}
470 471
471//----- The Colon commands ------------------------------------- 472//----- The Colon commands -------------------------------------
472#ifdef CONFIG_FEATURE_VI_COLON 473#if ENABLE_FEATURE_VI_COLON
473static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present 474static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present
474{ 475{
475 int st; 476 int st;
476 Byte *q; 477 Byte *q;
477 478
478#ifdef CONFIG_FEATURE_VI_YANKMARK 479#if ENABLE_FEATURE_VI_YANKMARK
479 Byte c; 480 Byte c;
480#endif /* CONFIG_FEATURE_VI_YANKMARK */ 481#endif
481#ifdef CONFIG_FEATURE_VI_SEARCH 482#if ENABLE_FEATURE_VI_SEARCH
482 Byte *pat, buf[BUFSIZ]; 483 Byte *pat, buf[BUFSIZ];
483#endif /* CONFIG_FEATURE_VI_SEARCH */ 484#endif
484 485
485 *addr = -1; // assume no addr 486 *addr = -1; // assume no addr
486 if (*p == '.') { // the current line 487 if (*p == '.') { // the current line
487 p++; 488 p++;
488 q = begin_line(dot); 489 q = begin_line(dot);
489 *addr = count_lines(text, q); 490 *addr = count_lines(text, q);
490#ifdef CONFIG_FEATURE_VI_YANKMARK 491#if ENABLE_FEATURE_VI_YANKMARK
491 } else if (*p == '\'') { // is this a mark addr 492 } else if (*p == '\'') { // is this a mark addr
492 p++; 493 p++;
493 c = tolower(*p); 494 c = tolower(*p);
@@ -500,8 +501,8 @@ static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present
500 *addr = count_lines(text, q); // count lines 501 *addr = count_lines(text, q); // count lines
501 } 502 }
502 } 503 }
503#endif /* CONFIG_FEATURE_VI_YANKMARK */ 504#endif
504#ifdef CONFIG_FEATURE_VI_SEARCH 505#if ENABLE_FEATURE_VI_SEARCH
505 } else if (*p == '/') { // a search pattern 506 } else if (*p == '/') { // a search pattern
506 q = buf; 507 q = buf;
507 for (p++; *p; p++) { 508 for (p++; *p; p++) {
@@ -518,7 +519,7 @@ static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present
518 *addr = count_lines(text, q); 519 *addr = count_lines(text, q);
519 } 520 }
520 free(pat); 521 free(pat);
521#endif /* CONFIG_FEATURE_VI_SEARCH */ 522#endif
522 } else if (*p == '$') { // the last line in file 523 } else if (*p == '$') { // the last line in file
523 p++; 524 p++;
524 q = begin_line(end - 1); 525 q = begin_line(end - 1);
@@ -561,7 +562,7 @@ ga0:
561 return p; 562 return p;
562} 563}
563 564
564#ifdef CONFIG_FEATURE_VI_SETOPTS 565#if ENABLE_FEATURE_VI_SET && ENABLE_FEATURE_VI_SETOPTS
565static void setops(const Byte *args, const char *opname, int flg_no, 566static void setops(const Byte *args, const char *opname, int flg_no,
566 const char *short_opname, int opt) 567 const char *short_opname, int opt)
567{ 568{
@@ -747,7 +748,7 @@ static void colon(Byte * buf)
747 } 748 }
748 file_modified = 0; 749 file_modified = 0;
749 last_file_modified = -1; 750 last_file_modified = -1;
750#ifdef CONFIG_FEATURE_VI_YANKMARK 751#if ENABLE_FEATURE_VI_YANKMARK
751 if (Ureg >= 0 && Ureg < 28 && reg[Ureg] != 0) { 752 if (Ureg >= 0 && Ureg < 28 && reg[Ureg] != 0) {
752 free(reg[Ureg]); // free orig line reg- for 'U' 753 free(reg[Ureg]); // free orig line reg- for 'U'
753 reg[Ureg]= 0; 754 reg[Ureg]= 0;
@@ -759,18 +760,18 @@ static void colon(Byte * buf)
759 for (li = 0; li < 28; li++) { 760 for (li = 0; li < 28; li++) {
760 mark[li] = 0; 761 mark[li] = 0;
761 } // init the marks 762 } // init the marks
762#endif /* CONFIG_FEATURE_VI_YANKMARK */ 763#endif
763 // how many lines in text[]? 764 // how many lines in text[]?
764 li = count_lines(text, end - 1); 765 li = count_lines(text, end - 1);
765 psb("\"%s\"%s" 766 psb("\"%s\"%s"
766#ifdef CONFIG_FEATURE_VI_READONLY 767#if ENABLE_FEATURE_VI_READONLY
767 "%s" 768 "%s"
768#endif /* CONFIG_FEATURE_VI_READONLY */ 769#endif
769 " %dL, %dC", cfn, 770 " %dL, %dC", cfn,
770 (sr < 0 ? " [New file]" : ""), 771 (sr < 0 ? " [New file]" : ""),
771#ifdef CONFIG_FEATURE_VI_READONLY 772#if ENABLE_FEATURE_VI_READONLY
772 ((vi_readonly || readonly) ? " [Read only]" : ""), 773 ((vi_readonly || readonly) ? " [Read only]" : ""),
773#endif /* CONFIG_FEATURE_VI_READONLY */ 774#endif
774 li, ch); 775 li, ch);
775 } else if (strncasecmp((char *) cmd, "file", i) == 0) { // what File is this 776 } else if (strncasecmp((char *) cmd, "file", i) == 0) { // what File is this
776 if (b != -1 || e != -1) { 777 if (b != -1 || e != -1) {
@@ -823,9 +824,9 @@ static void colon(Byte * buf)
823 if (c_is_no_print) 824 if (c_is_no_print)
824 standout_end(); 825 standout_end();
825 } 826 }
826#ifdef CONFIG_FEATURE_VI_SET 827#if ENABLE_FEATURE_VI_SET
827 vc2: 828 vc2:
828#endif /* CONFIG_FEATURE_VI_SET */ 829#endif
829 Hit_Return(); 830 Hit_Return();
830 } else if ((strncasecmp((char *) cmd, "quit", i) == 0) || // Quit 831 } else if ((strncasecmp((char *) cmd, "quit", i) == 0) || // Quit
831 (strncasecmp((char *) cmd, "next", i) == 0)) { // edit next file 832 (strncasecmp((char *) cmd, "next", i) == 0)) { // edit next file
@@ -865,11 +866,11 @@ static void colon(Byte * buf)
865 // read after current line- unless user said ":0r foo" 866 // read after current line- unless user said ":0r foo"
866 if (b != 0) 867 if (b != 0)
867 q = next_line(q); 868 q = next_line(q);
868#ifdef CONFIG_FEATURE_VI_READONLY 869#if ENABLE_FEATURE_VI_READONLY
869 l= readonly; // remember current files' status 870 l= readonly; // remember current files' status
870#endif 871#endif
871 ch = file_insert(fn, q, file_size(fn)); 872 ch = file_insert(fn, q, file_size(fn));
872#ifdef CONFIG_FEATURE_VI_READONLY 873#if ENABLE_FEATURE_VI_READONLY
873 readonly= l; 874 readonly= l;
874#endif 875#endif
875 if (ch < 0) 876 if (ch < 0)
@@ -877,13 +878,13 @@ static void colon(Byte * buf)
877 // how many lines in text[]? 878 // how many lines in text[]?
878 li = count_lines(q, q + ch - 1); 879 li = count_lines(q, q + ch - 1);
879 psb("\"%s\"" 880 psb("\"%s\""
880#ifdef CONFIG_FEATURE_VI_READONLY 881#if ENABLE_FEATURE_VI_READONLY
881 "%s" 882 "%s"
882#endif /* CONFIG_FEATURE_VI_READONLY */ 883#endif
883 " %dL, %dC", fn, 884 " %dL, %dC", fn,
884#ifdef CONFIG_FEATURE_VI_READONLY 885#if ENABLE_FEATURE_VI_READONLY
885 ((vi_readonly || readonly) ? " [Read only]" : ""), 886 ((vi_readonly || readonly) ? " [Read only]" : ""),
886#endif /* CONFIG_FEATURE_VI_READONLY */ 887#endif
887 li, ch); 888 li, ch);
888 if (ch > 0) { 889 if (ch > 0) {
889 // if the insert is before "dot" then we need to update 890 // if the insert is before "dot" then we need to update
@@ -899,7 +900,7 @@ static void colon(Byte * buf)
899 optind = fn_start - 1; 900 optind = fn_start - 1;
900 editing = 0; 901 editing = 0;
901 } 902 }
902#ifdef CONFIG_FEATURE_VI_SET 903#if ENABLE_FEATURE_VI_SET
903 } else if (strncasecmp((char *) cmd, "set", i) == 0) { // set or clear features 904 } else if (strncasecmp((char *) cmd, "set", i) == 0) { // set or clear features
904 i = 0; // offset into args 905 i = 0; // offset into args
905 if (strlen((char *) args) == 0) { 906 if (strlen((char *) args) == 0) {
@@ -907,7 +908,7 @@ static void colon(Byte * buf)
907 place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen 908 place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen
908 clear_to_eol(); // clear the line 909 clear_to_eol(); // clear the line
909 printf("----------------------------------------\r\n"); 910 printf("----------------------------------------\r\n");
910#ifdef CONFIG_FEATURE_VI_SETOPTS 911#if ENABLE_FEATURE_VI_SETOPTS
911 if (!autoindent) 912 if (!autoindent)
912 printf("no"); 913 printf("no");
913 printf("autoindent "); 914 printf("autoindent ");
@@ -921,13 +922,13 @@ static void colon(Byte * buf)
921 printf("no"); 922 printf("no");
922 printf("showmatch "); 923 printf("showmatch ");
923 printf("tabstop=%d ", tabstop); 924 printf("tabstop=%d ", tabstop);
924#endif /* CONFIG_FEATURE_VI_SETOPTS */ 925#endif
925 printf("\r\n"); 926 printf("\r\n");
926 goto vc2; 927 goto vc2;
927 } 928 }
928 if (strncasecmp((char *) args, "no", 2) == 0) 929 if (strncasecmp((char *) args, "no", 2) == 0)
929 i = 2; // ":set noautoindent" 930 i = 2; // ":set noautoindent"
930#ifdef CONFIG_FEATURE_VI_SETOPTS 931#if ENABLE_FEATURE_VI_SETOPTS
931 setops(args, "autoindent ", i, "ai", VI_AUTOINDENT); 932 setops(args, "autoindent ", i, "ai", VI_AUTOINDENT);
932 setops(args, "flash ", i, "fl", VI_ERR_METHOD); 933 setops(args, "flash ", i, "fl", VI_ERR_METHOD);
933 setops(args, "ignorecase ", i, "ic", VI_IGNORECASE); 934 setops(args, "ignorecase ", i, "ic", VI_IGNORECASE);
@@ -937,9 +938,9 @@ static void colon(Byte * buf)
937 if (ch > 0 && ch < columns - 1) 938 if (ch > 0 && ch < columns - 1)
938 tabstop = ch; 939 tabstop = ch;
939 } 940 }
940#endif /* CONFIG_FEATURE_VI_SETOPTS */ 941#endif /* FEATURE_VI_SETOPTS */
941#endif /* CONFIG_FEATURE_VI_SET */ 942#endif /* FEATURE_VI_SET */
942#ifdef CONFIG_FEATURE_VI_SEARCH 943#if ENABLE_FEATURE_VI_SEARCH
943 } else if (strncasecmp((char *) cmd, "s", 1) == 0) { // substitute a pattern with a replacement pattern 944 } else if (strncasecmp((char *) cmd, "s", 1) == 0) { // substitute a pattern with a replacement pattern
944 Byte *ls, *F, *R; 945 Byte *ls, *F, *R;
945 int gflag; 946 int gflag;
@@ -986,7 +987,7 @@ static void colon(Byte * buf)
986 } 987 }
987 q = next_line(ls); 988 q = next_line(ls);
988 } 989 }
989#endif /* CONFIG_FEATURE_VI_SEARCH */ 990#endif /* FEATURE_VI_SEARCH */
990 } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version 991 } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version
991 psb("%s", BB_VER " " BB_BT); 992 psb("%s", BB_VER " " BB_BT);
992 } else if (strncasecmp((char *) cmd, "write", i) == 0 // write text to file 993 } else if (strncasecmp((char *) cmd, "write", i) == 0 // write text to file
@@ -997,12 +998,12 @@ static void colon(Byte * buf)
997 if (strlen((char *) args) > 0) { 998 if (strlen((char *) args) > 0) {
998 fn = args; 999 fn = args;
999 } 1000 }
1000#ifdef CONFIG_FEATURE_VI_READONLY 1001#if ENABLE_FEATURE_VI_READONLY
1001 if ((vi_readonly || readonly) && ! useforce) { 1002 if ((vi_readonly || readonly) && ! useforce) {
1002 psbs("\"%s\" File is read only", fn); 1003 psbs("\"%s\" File is read only", fn);
1003 goto vc3; 1004 goto vc3;
1004 } 1005 }
1005#endif /* CONFIG_FEATURE_VI_READONLY */ 1006#endif
1006 // how many lines in text[]? 1007 // how many lines in text[]?
1007 li = count_lines(q, r); 1008 li = count_lines(q, r);
1008 ch = r - q + 1; 1009 ch = r - q + 1;
@@ -1035,10 +1036,10 @@ static void colon(Byte * buf)
1035 editing = 0; 1036 editing = 0;
1036 } 1037 }
1037 } 1038 }
1038#ifdef CONFIG_FEATURE_VI_READONLY 1039#if ENABLE_FEATURE_VI_READONLY
1039 vc3:; 1040 vc3:;
1040#endif /* CONFIG_FEATURE_VI_READONLY */ 1041#endif
1041#ifdef CONFIG_FEATURE_VI_YANKMARK 1042#if ENABLE_FEATURE_VI_YANKMARK
1042 } else if (strncasecmp((char *) cmd, "yank", i) == 0) { // yank lines 1043 } else if (strncasecmp((char *) cmd, "yank", i) == 0) { // yank lines
1043 if (b < 0) { // no addr given- use defaults 1044 if (b < 0) { // no addr given- use defaults
1044 q = begin_line(dot); // assume .,. for the range 1045 q = begin_line(dot); // assume .,. for the range
@@ -1048,7 +1049,7 @@ static void colon(Byte * buf)
1048 li = count_lines(q, r); 1049 li = count_lines(q, r);
1049 psb("Yank %d lines (%d chars) into [%c]", 1050 psb("Yank %d lines (%d chars) into [%c]",
1050 li, strlen((char *) reg[YDreg]), what_reg()); 1051 li, strlen((char *) reg[YDreg]), what_reg());
1051#endif /* CONFIG_FEATURE_VI_YANKMARK */ 1052#endif
1052 } else { 1053 } else {
1053 // cmd unknown 1054 // cmd unknown
1054 ni((Byte *) cmd); 1055 ni((Byte *) cmd);
@@ -1056,13 +1057,13 @@ static void colon(Byte * buf)
1056 vc1: 1057 vc1:
1057 dot = bound_dot(dot); // make sure "dot" is valid 1058 dot = bound_dot(dot); // make sure "dot" is valid
1058 return; 1059 return;
1059#ifdef CONFIG_FEATURE_VI_SEARCH 1060#if ENABLE_FEATURE_VI_SEARCH
1060colon_s_fail: 1061colon_s_fail:
1061 psb(":s expression missing delimiters"); 1062 psb(":s expression missing delimiters");
1062#endif 1063#endif
1063} 1064}
1064 1065
1065#endif /* CONFIG_FEATURE_VI_COLON */ 1066#endif /* FEATURE_VI_COLON */
1066 1067
1067static void Hit_Return(void) 1068static void Hit_Return(void)
1068{ 1069{
@@ -1391,17 +1392,17 @@ static Byte *new_text(int size)
1391 return text; 1392 return text;
1392} 1393}
1393 1394
1394#ifdef CONFIG_FEATURE_VI_SEARCH 1395#if ENABLE_FEATURE_VI_SEARCH
1395static int mycmp(Byte * s1, Byte * s2, int len) 1396static int mycmp(Byte * s1, Byte * s2, int len)
1396{ 1397{
1397 int i; 1398 int i;
1398 1399
1399 i = strncmp((char *) s1, (char *) s2, len); 1400 i = strncmp((char *) s1, (char *) s2, len);
1400#ifdef CONFIG_FEATURE_VI_SETOPTS 1401#if ENABLE_FEATURE_VI_SETOPTS
1401 if (ignorecase) { 1402 if (ignorecase) {
1402 i = strncasecmp((char *) s1, (char *) s2, len); 1403 i = strncasecmp((char *) s1, (char *) s2, len);
1403 } 1404 }
1404#endif /* CONFIG_FEATURE_VI_SETOPTS */ 1405#endif
1405 return i; 1406 return i;
1406} 1407}
1407 1408
@@ -1494,9 +1495,9 @@ static Byte *char_search(Byte * p, Byte * pat, int dir, int range) // search for
1494 p = p - i; 1495 p = p - i;
1495 } 1496 }
1496 return p; 1497 return p;
1497#endif /*REGEX_SEARCH */ 1498#endif /* REGEX_SEARCH */
1498} 1499}
1499#endif /* CONFIG_FEATURE_VI_SEARCH */ 1500#endif /* FEATURE_VI_SEARCH */
1500 1501
1501static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p' 1502static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
1502{ 1503{
@@ -1530,7 +1531,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
1530 c = '\n'; // translate \r to \n 1531 c = '\n'; // translate \r to \n
1531 sp = p; // remember addr of insert 1532 sp = p; // remember addr of insert
1532 p = stupid_insert(p, c); // insert the char 1533 p = stupid_insert(p, c); // insert the char
1533#ifdef CONFIG_FEATURE_VI_SETOPTS 1534#if ENABLE_FEATURE_VI_SETOPTS
1534 if (showmatch && strchr(")]}", *sp) != NULL) { 1535 if (showmatch && strchr(")]}", *sp) != NULL) {
1535 showmatching(sp); 1536 showmatching(sp);
1536 } 1537 }
@@ -1542,7 +1543,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
1542 p = stupid_insert(p, *q); // insert the char 1543 p = stupid_insert(p, *q); // insert the char
1543 } 1544 }
1544 } 1545 }
1545#endif /* CONFIG_FEATURE_VI_SETOPTS */ 1546#endif
1546 } 1547 }
1547 return p; 1548 return p;
1548} 1549}
@@ -1712,7 +1713,7 @@ static Byte *find_pair(Byte * p, Byte c)
1712 return q; 1713 return q;
1713} 1714}
1714 1715
1715#ifdef CONFIG_FEATURE_VI_SETOPTS 1716#if ENABLE_FEATURE_VI_SETOPTS
1716// show the matching char of a pair, () [] {} 1717// show the matching char of a pair, () [] {}
1717static void showmatching(Byte * p) 1718static void showmatching(Byte * p)
1718{ 1719{
@@ -1732,7 +1733,7 @@ static void showmatching(Byte * p)
1732 refresh(FALSE); 1733 refresh(FALSE);
1733 } 1734 }
1734} 1735}
1735#endif /* CONFIG_FEATURE_VI_SETOPTS */ 1736#endif /* FEATURE_VI_SETOPTS */
1736 1737
1737// open a hole in text[] 1738// open a hole in text[]
1738static Byte *text_hole_make(Byte * p, int size) // at "p", make a 'size' byte hole 1739static Byte *text_hole_make(Byte * p, int size) // at "p", make a 'size' byte hole
@@ -1819,9 +1820,9 @@ static Byte *yank_delete(Byte * start, Byte * stop, int dist, int yf)
1819 } 1820 }
1820 } 1821 }
1821 p = start; 1822 p = start;
1822#ifdef CONFIG_FEATURE_VI_YANKMARK 1823#if ENABLE_FEATURE_VI_YANKMARK
1823 text_yank(start, stop, YDreg); 1824 text_yank(start, stop, YDreg);
1824#endif /* CONFIG_FEATURE_VI_YANKMARK */ 1825#endif
1825 if (yf == YANKDEL) { 1826 if (yf == YANKDEL) {
1826 p = text_hole_delete(start, stop); 1827 p = text_hole_delete(start, stop);
1827 } // delete lines 1828 } // delete lines
@@ -1831,33 +1832,33 @@ static Byte *yank_delete(Byte * start, Byte * stop, int dist, int yf)
1831static void show_help(void) 1832static void show_help(void)
1832{ 1833{
1833 puts("These features are available:" 1834 puts("These features are available:"
1834#ifdef CONFIG_FEATURE_VI_SEARCH 1835#if ENABLE_FEATURE_VI_SEARCH
1835 "\n\tPattern searches with / and ?" 1836 "\n\tPattern searches with / and ?"
1836#endif /* CONFIG_FEATURE_VI_SEARCH */ 1837#endif
1837#ifdef CONFIG_FEATURE_VI_DOT_CMD 1838#if ENABLE_FEATURE_VI_DOT_CMD
1838 "\n\tLast command repeat with \'.\'" 1839 "\n\tLast command repeat with \'.\'"
1839#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 1840#endif
1840#ifdef CONFIG_FEATURE_VI_YANKMARK 1841#if ENABLE_FEATURE_VI_YANKMARK
1841 "\n\tLine marking with 'x" 1842 "\n\tLine marking with 'x"
1842 "\n\tNamed buffers with \"x" 1843 "\n\tNamed buffers with \"x"
1843#endif /* CONFIG_FEATURE_VI_YANKMARK */ 1844#endif
1844#ifdef CONFIG_FEATURE_VI_READONLY 1845#if ENABLE_FEATURE_VI_READONLY
1845 "\n\tReadonly if vi is called as \"view\"" 1846 "\n\tReadonly if vi is called as \"view\""
1846 "\n\tReadonly with -R command line arg" 1847 "\n\tReadonly with -R command line arg"
1847#endif /* CONFIG_FEATURE_VI_READONLY */ 1848#endif
1848#ifdef CONFIG_FEATURE_VI_SET 1849#if ENABLE_FEATURE_VI_SET
1849 "\n\tSome colon mode commands with \':\'" 1850 "\n\tSome colon mode commands with \':\'"
1850#endif /* CONFIG_FEATURE_VI_SET */ 1851#endif
1851#ifdef CONFIG_FEATURE_VI_SETOPTS 1852#if ENABLE_FEATURE_VI_SETOPTS
1852 "\n\tSettable options with \":set\"" 1853 "\n\tSettable options with \":set\""
1853#endif /* CONFIG_FEATURE_VI_SETOPTS */ 1854#endif
1854#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 1855#if ENABLE_FEATURE_VI_USE_SIGNALS
1855 "\n\tSignal catching- ^C" 1856 "\n\tSignal catching- ^C"
1856 "\n\tJob suspend and resume with ^Z" 1857 "\n\tJob suspend and resume with ^Z"
1857#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */ 1858#endif
1858#ifdef CONFIG_FEATURE_VI_WIN_RESIZE 1859#if ENABLE_FEATURE_VI_WIN_RESIZE
1859 "\n\tAdapt to window re-sizes" 1860 "\n\tAdapt to window re-sizes"
1860#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */ 1861#endif
1861 ); 1862 );
1862} 1863}
1863 1864
@@ -1895,7 +1896,7 @@ static inline void print_literal(Byte * buf, Byte * s) // copy s to buf, convert
1895 } 1896 }
1896} 1897}
1897 1898
1898#ifdef CONFIG_FEATURE_VI_DOT_CMD 1899#if ENABLE_FEATURE_VI_DOT_CMD
1899static void start_new_cmd_q(Byte c) 1900static void start_new_cmd_q(Byte c)
1900{ 1901{
1901 // release old cmd 1902 // release old cmd
@@ -1913,15 +1914,17 @@ static void start_new_cmd_q(Byte c)
1913 1914
1914static void end_cmd_q(void) 1915static void end_cmd_q(void)
1915{ 1916{
1916#ifdef CONFIG_FEATURE_VI_YANKMARK 1917#if ENABLE_FEATURE_VI_YANKMARK
1917 YDreg = 26; // go back to default Yank/Delete reg 1918 YDreg = 26; // go back to default Yank/Delete reg
1918#endif /* CONFIG_FEATURE_VI_YANKMARK */ 1919#endif
1919 adding2q = 0; 1920 adding2q = 0;
1920 return; 1921 return;
1921} 1922}
1922#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 1923#endif /* FEATURE_VI_DOT_CMD */
1923 1924
1924#if defined(CONFIG_FEATURE_VI_YANKMARK) || (defined(CONFIG_FEATURE_VI_COLON) && defined(CONFIG_FEATURE_VI_SEARCH)) || defined(CONFIG_FEATURE_VI_CRASHME) 1925#if ENABLE_FEATURE_VI_YANKMARK \
1926 || (ENABLE_FEATURE_VI_COLON && ENABLE_FEATURE_VI_SEARCH) \
1927 || ENABLE_FEATURE_VI_CRASHME
1925static Byte *string_insert(Byte * p, Byte * s) // insert the string at 'p' 1928static Byte *string_insert(Byte * p, Byte * s) // insert the string at 'p'
1926{ 1929{
1927 int cnt, i; 1930 int cnt, i;
@@ -1933,14 +1936,14 @@ static Byte *string_insert(Byte * p, Byte * s) // insert the string at 'p'
1933 if (*s == '\n') 1936 if (*s == '\n')
1934 cnt++; 1937 cnt++;
1935 } 1938 }
1936#ifdef CONFIG_FEATURE_VI_YANKMARK 1939#if ENABLE_FEATURE_VI_YANKMARK
1937 psb("Put %d lines (%d chars) from [%c]", cnt, i, what_reg()); 1940 psb("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
1938#endif /* CONFIG_FEATURE_VI_YANKMARK */ 1941#endif
1939 return p; 1942 return p;
1940} 1943}
1941#endif /* CONFIG_FEATURE_VI_YANKMARK || CONFIG_FEATURE_VI_COLON || CONFIG_FEATURE_VI_CRASHME */ 1944#endif
1942 1945
1943#ifdef CONFIG_FEATURE_VI_YANKMARK 1946#if ENABLE_FEATURE_VI_YANKMARK
1944static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a register 1947static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a register
1945{ 1948{
1946 Byte *t; 1949 Byte *t;
@@ -2010,7 +2013,7 @@ static inline Byte *swap_context(Byte * p) // goto new context for '' command ma
2010 } 2013 }
2011 return p; 2014 return p;
2012} 2015}
2013#endif /* CONFIG_FEATURE_VI_YANKMARK */ 2016#endif /* FEATURE_VI_YANKMARK */
2014 2017
2015static int isblnk(Byte c) // is the char a blank or tab 2018static int isblnk(Byte c) // is the char a blank or tab
2016{ 2019{
@@ -2038,7 +2041,7 @@ static void cookmode(void)
2038} 2041}
2039 2042
2040//----- Come here when we get a window resize signal --------- 2043//----- Come here when we get a window resize signal ---------
2041#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 2044#if ENABLE_FEATURE_VI_USE_SIGNALS
2042static void winch_sig(int sig ATTRIBUTE_UNUSED) 2045static void winch_sig(int sig ATTRIBUTE_UNUSED)
2043{ 2046{
2044 signal(SIGWINCH, winch_sig); 2047 signal(SIGWINCH, winch_sig);
@@ -2079,7 +2082,7 @@ static void catch_sig(int sig)
2079 if(sig) 2082 if(sig)
2080 longjmp(restart, sig); 2083 longjmp(restart, sig);
2081} 2084}
2082#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */ 2085#endif /* FEATURE_VI_USE_SIGNALS */
2083 2086
2084static int mysleep(int hund) // sleep for 'h' 1/100 seconds 2087static int mysleep(int hund) // sleep for 'h' 1/100 seconds
2085{ 2088{
@@ -2226,7 +2229,7 @@ static Byte get_one_char(void)
2226{ 2229{
2227 static Byte c; 2230 static Byte c;
2228 2231
2229#ifdef CONFIG_FEATURE_VI_DOT_CMD 2232#if ENABLE_FEATURE_VI_DOT_CMD
2230 // ! adding2q && ioq == 0 read() 2233 // ! adding2q && ioq == 0 read()
2231 // ! adding2q && ioq != 0 *ioq 2234 // ! adding2q && ioq != 0 *ioq
2232 // adding2q *last_modifying_cmd= read() 2235 // adding2q *last_modifying_cmd= read()
@@ -2259,9 +2262,9 @@ static Byte get_one_char(void)
2259 } 2262 }
2260 } 2263 }
2261 } 2264 }
2262#else /* CONFIG_FEATURE_VI_DOT_CMD */ 2265#else
2263 c = readit(); // get the users input 2266 c = readit(); // get the users input
2264#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 2267#endif /* FEATURE_VI_DOT_CMD */
2265 return c; // return the char, where ever it came from 2268 return c; // return the char, where ever it came from
2266} 2269}
2267 2270
@@ -2324,9 +2327,9 @@ static int file_insert(Byte * fn, Byte * p, int size)
2324 int fd, cnt; 2327 int fd, cnt;
2325 2328
2326 cnt = -1; 2329 cnt = -1;
2327#ifdef CONFIG_FEATURE_VI_READONLY 2330#if ENABLE_FEATURE_VI_READONLY
2328 readonly = FALSE; 2331 readonly = FALSE;
2329#endif /* CONFIG_FEATURE_VI_READONLY */ 2332#endif
2330 if (fn == 0 || strlen((char*) fn) <= 0) { 2333 if (fn == 0 || strlen((char*) fn) <= 0) {
2331 psbs("No filename given"); 2334 psbs("No filename given");
2332 goto fi0; 2335 goto fi0;
@@ -2346,13 +2349,13 @@ static int file_insert(Byte * fn, Byte * p, int size)
2346 } 2349 }
2347 2350
2348 // see if we can open the file 2351 // see if we can open the file
2349#ifdef CONFIG_FEATURE_VI_READONLY 2352#if ENABLE_FEATURE_VI_READONLY
2350 if (vi_readonly) goto fi1; // do not try write-mode 2353 if (vi_readonly) goto fi1; // do not try write-mode
2351#endif 2354#endif
2352 fd = open((char *) fn, O_RDWR); // assume read & write 2355 fd = open((char *) fn, O_RDWR); // assume read & write
2353 if (fd < 0) { 2356 if (fd < 0) {
2354 // could not open for writing- maybe file is read only 2357 // could not open for writing- maybe file is read only
2355#ifdef CONFIG_FEATURE_VI_READONLY 2358#if ENABLE_FEATURE_VI_READONLY
2356 fi1: 2359 fi1:
2357#endif 2360#endif
2358 fd = open((char *) fn, O_RDONLY); // try read-only 2361 fd = open((char *) fn, O_RDONLY); // try read-only
@@ -2360,10 +2363,10 @@ static int file_insert(Byte * fn, Byte * p, int size)
2360 psbs("\"%s\" %s", fn, "cannot open file"); 2363 psbs("\"%s\" %s", fn, "cannot open file");
2361 goto fi0; 2364 goto fi0;
2362 } 2365 }
2363#ifdef CONFIG_FEATURE_VI_READONLY 2366#if ENABLE_FEATURE_VI_READONLY
2364 // got the file- read-only 2367 // got the file- read-only
2365 readonly = TRUE; 2368 readonly = TRUE;
2366#endif /* CONFIG_FEATURE_VI_READONLY */ 2369#endif
2367 } 2370 }
2368 p = text_hole_make(p, size); 2371 p = text_hole_make(p, size);
2369 cnt = read(fd, p, size); 2372 cnt = read(fd, p, size);
@@ -2425,12 +2428,12 @@ static void place_cursor(int row, int col, int opti)
2425{ 2428{
2426 char cm1[BUFSIZ]; 2429 char cm1[BUFSIZ];
2427 char *cm; 2430 char *cm;
2428#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 2431#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
2429 char cm2[BUFSIZ]; 2432 char cm2[BUFSIZ];
2430 Byte *screenp; 2433 Byte *screenp;
2431 // char cm3[BUFSIZ]; 2434 // char cm3[BUFSIZ];
2432 int Rrow= last_row; 2435 int Rrow= last_row;
2433#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2436#endif
2434 2437
2435 memset(cm1, '\0', BUFSIZ - 1); // clear the buffer 2438 memset(cm1, '\0', BUFSIZ - 1); // clear the buffer
2436 2439
@@ -2444,7 +2447,7 @@ static void place_cursor(int row, int col, int opti)
2444 cm= cm1; 2447 cm= cm1;
2445 if (! opti) goto pc0; 2448 if (! opti) goto pc0;
2446 2449
2447#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 2450#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
2448 //----- find the minimum # of chars to move cursor ------------- 2451 //----- find the minimum # of chars to move cursor -------------
2449 //----- 2. Try moving with discreet chars (Newline, [back]space, ...) 2452 //----- 2. Try moving with discreet chars (Newline, [back]space, ...)
2450 memset(cm2, '\0', BUFSIZ - 1); // clear the buffer 2453 memset(cm2, '\0', BUFSIZ - 1); // clear the buffer
@@ -2477,8 +2480,8 @@ static void place_cursor(int row, int col, int opti)
2477 } /* else if (strlen(cm3) < strlen(cm)) { 2480 } /* else if (strlen(cm3) < strlen(cm)) {
2478 cm= cm3; 2481 cm= cm3;
2479 } */ 2482 } */
2480#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2483#endif /* FEATURE_VI_OPTIMIZE_CURSOR */
2481 pc0: 2484 pc0:
2482 write1(cm); // move the cursor 2485 write1(cm); // move the cursor
2483} 2486}
2484 2487
@@ -2518,10 +2521,10 @@ static void flash(int h)
2518 2521
2519static void Indicate_Error(void) 2522static void Indicate_Error(void)
2520{ 2523{
2521#ifdef CONFIG_FEATURE_VI_CRASHME 2524#if ENABLE_FEATURE_VI_CRASHME
2522 if (crashme > 0) 2525 if (crashme > 0)
2523 return; // generate a random command 2526 return; // generate a random command
2524#endif /* CONFIG_FEATURE_VI_CRASHME */ 2527#endif
2525 if (!err_method) { 2528 if (!err_method) {
2526 write1(bell); // send out a bell character 2529 write1(bell); // send out a bell character
2527 } else { 2530 } else {
@@ -2649,14 +2652,14 @@ static int format_edit_status(void) // show file status on status line
2649 columns : STATUS_BUFFER_LEN-1; 2652 columns : STATUS_BUFFER_LEN-1;
2650 2653
2651 ret = snprintf((char *) status_buffer, trunc_at+1, 2654 ret = snprintf((char *) status_buffer, trunc_at+1,
2652#ifdef CONFIG_FEATURE_VI_READONLY 2655#if ENABLE_FEATURE_VI_READONLY
2653 "%c %s%s%s %d/%d %d%%", 2656 "%c %s%s%s %d/%d %d%%",
2654#else 2657#else
2655 "%c %s%s %d/%d %d%%", 2658 "%c %s%s %d/%d %d%%",
2656#endif 2659#endif
2657 (cmd_mode ? (cmd_mode == 2 ? 'R':'I'):'-'), 2660 (cmd_mode ? (cmd_mode == 2 ? 'R':'I'):'-'),
2658 (cfn != 0 ? (char *) cfn : "No file"), 2661 (cfn != 0 ? (char *) cfn : "No file"),
2659#ifdef CONFIG_FEATURE_VI_READONLY 2662#if ENABLE_FEATURE_VI_READONLY
2660 ((vi_readonly || readonly) ? " [Read-only]" : ""), 2663 ((vi_readonly || readonly) ? " [Read-only]" : ""),
2661#endif 2664#endif
2662 (file_modified ? " [modified]" : ""), 2665 (file_modified ? " [modified]" : ""),
@@ -2733,9 +2736,9 @@ static void refresh(int full_screen)
2733 int li, changed; 2736 int li, changed;
2734 Byte buf[MAX_SCR_COLS]; 2737 Byte buf[MAX_SCR_COLS];
2735 Byte *tp, *sp; // pointer into text[] and screen[] 2738 Byte *tp, *sp; // pointer into text[] and screen[]
2736#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 2739#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
2737 int last_li= -2; // last line that changed- for optimizing cursor movement 2740 int last_li= -2; // last line that changed- for optimizing cursor movement
2738#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2741#endif
2739 2742
2740 if (ENABLE_FEATURE_VI_WIN_RESIZE) 2743 if (ENABLE_FEATURE_VI_WIN_RESIZE)
2741 get_terminal_width_height(0, &columns, &rows); 2744 get_terminal_width_height(0, &columns, &rows);
@@ -2801,15 +2804,15 @@ static void refresh(int full_screen)
2801 // to handle offsets correctly 2804 // to handle offsets correctly
2802 place_cursor(li, cs, FALSE); 2805 place_cursor(li, cs, FALSE);
2803 } else { 2806 } else {
2804#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 2807#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
2805 // if this just the next line 2808 // if this just the next line
2806 // try to optimize cursor movement 2809 // try to optimize cursor movement
2807 // otherwise, use standard ESC sequence 2810 // otherwise, use standard ESC sequence
2808 place_cursor(li, cs, li == (last_li+1) ? TRUE : FALSE); 2811 place_cursor(li, cs, li == (last_li+1) ? TRUE : FALSE);
2809 last_li= li; 2812 last_li= li;
2810#else /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2813#else
2811 place_cursor(li, cs, FALSE); // use standard ESC sequence 2814 place_cursor(li, cs, FALSE); // use standard ESC sequence
2812#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2815#endif /* FEATURE_VI_OPTIMIZE_CURSOR */
2813 } 2816 }
2814 2817
2815 // write line out to terminal 2818 // write line out to terminal
@@ -2822,18 +2825,18 @@ static void refresh(int full_screen)
2822 out++; 2825 out++;
2823 } 2826 }
2824 } 2827 }
2825#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 2828#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
2826 last_row = li; 2829 last_row = li;
2827#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2830#endif
2828 } 2831 }
2829 } 2832 }
2830 2833
2831#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 2834#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
2832 place_cursor(crow, ccol, (crow == last_row) ? TRUE : FALSE); 2835 place_cursor(crow, ccol, (crow == last_row) ? TRUE : FALSE);
2833 last_row = crow; 2836 last_row = crow;
2834#else 2837#else
2835 place_cursor(crow, ccol, FALSE); 2838 place_cursor(crow, ccol, FALSE);
2836#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2839#endif
2837 2840
2838 if (offset != old_offset) 2841 if (offset != old_offset)
2839 old_offset = offset; 2842 old_offset = offset;
@@ -2922,11 +2925,11 @@ key_cmd_mode:
2922 //case 0x10: // dle 2925 //case 0x10: // dle
2923 //case 0x11: // dc1 2926 //case 0x11: // dc1
2924 //case 0x13: // dc3 2927 //case 0x13: // dc3
2925#ifdef CONFIG_FEATURE_VI_CRASHME 2928#if ENABLE_FEATURE_VI_CRASHME
2926 case 0x14: // dc4 ctrl-T 2929 case 0x14: // dc4 ctrl-T
2927 crashme = (crashme == 0) ? 1 : 0; 2930 crashme = (crashme == 0) ? 1 : 0;
2928 break; 2931 break;
2929#endif /* CONFIG_FEATURE_VI_CRASHME */ 2932#endif
2930 //case 0x16: // syn 2933 //case 0x16: // syn
2931 //case 0x17: // etb 2934 //case 0x17: // etb
2932 //case 0x18: // can 2935 //case 0x18: // can
@@ -2973,14 +2976,14 @@ key_cmd_mode:
2973 case VI_K_PAGEUP: // Cursor Key Page Up 2976 case VI_K_PAGEUP: // Cursor Key Page Up
2974 dot_scroll(rows - 2, -1); 2977 dot_scroll(rows - 2, -1);
2975 break; 2978 break;
2976#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 2979#if ENABLE_FEATURE_VI_USE_SIGNALS
2977 case 0x03: // ctrl-C interrupt 2980 case 0x03: // ctrl-C interrupt
2978 longjmp(restart, 1); 2981 longjmp(restart, 1);
2979 break; 2982 break;
2980 case 26: // ctrl-Z suspend 2983 case 26: // ctrl-Z suspend
2981 suspend_sig(SIGTSTP); 2984 suspend_sig(SIGTSTP);
2982 break; 2985 break;
2983#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */ 2986#endif
2984 case 4: // ctrl-D scroll down half screen 2987 case 4: // ctrl-D scroll down half screen
2985 dot_scroll((rows - 2) / 2, 1); 2988 dot_scroll((rows - 2) / 2, 1);
2986 break; 2989 break;
@@ -3050,7 +3053,7 @@ key_cmd_mode:
3050 } // repeat cnt 3053 } // repeat cnt
3051 dot_right(); 3054 dot_right();
3052 break; 3055 break;
3053#ifdef CONFIG_FEATURE_VI_YANKMARK 3056#if ENABLE_FEATURE_VI_YANKMARK
3054 case '"': // "- name a register to use for Delete/Yank 3057 case '"': // "- name a register to use for Delete/Yank
3055 c1 = get_one_char(); 3058 c1 = get_one_char();
3056 c1 = tolower(c1); 3059 c1 = tolower(c1);
@@ -3132,7 +3135,7 @@ key_cmd_mode:
3132 dot_skip_over_ws(); 3135 dot_skip_over_ws();
3133 } 3136 }
3134 break; 3137 break;
3135#endif /* CONFIG_FEATURE_VI_YANKMARK */ 3138#endif /* FEATURE_VI_YANKMARK */
3136 case '$': // $- goto end of line 3139 case '$': // $- goto end of line
3137 case VI_K_END: // Cursor Key End 3140 case VI_K_END: // Cursor Key End
3138 if (cmdcnt-- > 1) { 3141 if (cmdcnt-- > 1) {
@@ -3181,7 +3184,7 @@ key_cmd_mode:
3181 dot_prev(); 3184 dot_prev();
3182 dot_skip_over_ws(); 3185 dot_skip_over_ws();
3183 break; 3186 break;
3184#ifdef CONFIG_FEATURE_VI_DOT_CMD 3187#if ENABLE_FEATURE_VI_DOT_CMD
3185 case '.': // .- repeat the last modifying command 3188 case '.': // .- repeat the last modifying command
3186 // Stuff the last_modifying_cmd back into stdin 3189 // Stuff the last_modifying_cmd back into stdin
3187 // and let it be re-executed. 3190 // and let it be re-executed.
@@ -3189,8 +3192,8 @@ key_cmd_mode:
3189 ioq = ioq_start = (Byte *) xstrdup((char *) last_modifying_cmd); 3192 ioq = ioq_start = (Byte *) xstrdup((char *) last_modifying_cmd);
3190 } 3193 }
3191 break; 3194 break;
3192#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 3195#endif
3193#ifdef CONFIG_FEATURE_VI_SEARCH 3196#if ENABLE_FEATURE_VI_SEARCH
3194 case '?': // /- search for a pattern 3197 case '?': // /- search for a pattern
3195 case '/': // /- search for a pattern 3198 case '/': // /- search for a pattern
3196 buf[0] = c; 3199 buf[0] = c;
@@ -3274,7 +3277,7 @@ key_cmd_mode:
3274 dot = next_line(q); // move to next blank line 3277 dot = next_line(q); // move to next blank line
3275 } 3278 }
3276 break; 3279 break;
3277#endif /* CONFIG_FEATURE_VI_SEARCH */ 3280#endif /* FEATURE_VI_SEARCH */
3278 case '0': // 0- goto begining of line 3281 case '0': // 0- goto begining of line
3279 case '1': // 1- 3282 case '1': // 1-
3280 case '2': // 2- 3283 case '2': // 2-
@@ -3293,9 +3296,9 @@ key_cmd_mode:
3293 break; 3296 break;
3294 case ':': // :- the colon mode commands 3297 case ':': // :- the colon mode commands
3295 p = get_input_line((Byte *) ":"); // get input line- use "status line" 3298 p = get_input_line((Byte *) ":"); // get input line- use "status line"
3296#ifdef CONFIG_FEATURE_VI_COLON 3299#if ENABLE_FEATURE_VI_COLON
3297 colon(p); // execute the command 3300 colon(p); // execute the command
3298#else /* CONFIG_FEATURE_VI_COLON */ 3301#else
3299 if (*p == ':') 3302 if (*p == ':')
3300 p++; // move past the ':' 3303 p++; // move past the ':'
3301 cnt = strlen((char *) p); 3304 cnt = strlen((char *) p);
@@ -3333,7 +3336,7 @@ key_cmd_mode:
3333 } else { // unrecognised cmd 3336 } else { // unrecognised cmd
3334 ni((Byte *) p); 3337 ni((Byte *) p);
3335 } 3338 }
3336#endif /* CONFIG_FEATURE_VI_COLON */ 3339#endif /* !FEATURE_VI_COLON */
3337 break; 3340 break;
3338 case '<': // <- Left shift something 3341 case '<': // <- Left shift something
3339 case '>': // >- Right shift something 3342 case '>': // >- Right shift something
@@ -3397,10 +3400,10 @@ key_cmd_mode:
3397 dot = yank_delete(save_dot, dot, 0, YANKDEL); // delete to e-o-l 3400 dot = yank_delete(save_dot, dot, 0, YANKDEL); // delete to e-o-l
3398 if (c == 'C') 3401 if (c == 'C')
3399 goto dc_i; // start inserting 3402 goto dc_i; // start inserting
3400#ifdef CONFIG_FEATURE_VI_DOT_CMD 3403#if ENABLE_FEATURE_VI_DOT_CMD
3401 if (c == 'D') 3404 if (c == 'D')
3402 end_cmd_q(); // stop adding to q 3405 end_cmd_q(); // stop adding to q
3403#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 3406#endif
3404 break; 3407 break;
3405 case 'G': // G- goto to a line number (default= E-O-F) 3408 case 'G': // G- goto to a line number (default= E-O-F)
3406 dot = end - 1; // assume E-O-F 3409 dot = end - 1; // assume E-O-F
@@ -3503,12 +3506,12 @@ key_cmd_mode:
3503 break; 3506 break;
3504 } 3507 }
3505 if (file_modified) { 3508 if (file_modified) {
3506#ifdef CONFIG_FEATURE_VI_READONLY 3509#if ENABLE_FEATURE_VI_READONLY
3507 if (vi_readonly || readonly) { 3510 if (vi_readonly || readonly) {
3508 psbs("\"%s\" File is read only", cfn); 3511 psbs("\"%s\" File is read only", cfn);
3509 break; 3512 break;
3510 } 3513 }
3511#endif /* CONFIG_FEATURE_VI_READONLY */ 3514#endif
3512 cnt = file_write(cfn, text, end - 1); 3515 cnt = file_write(cfn, text, end - 1);
3513 if (cnt < 0) { 3516 if (cnt < 0) {
3514 if (cnt == -1) 3517 if (cnt == -1)
@@ -3546,15 +3549,15 @@ key_cmd_mode:
3546 break; 3549 break;
3547 case 'c': // c- change something 3550 case 'c': // c- change something
3548 case 'd': // d- delete something 3551 case 'd': // d- delete something
3549#ifdef CONFIG_FEATURE_VI_YANKMARK 3552#if ENABLE_FEATURE_VI_YANKMARK
3550 case 'y': // y- yank something 3553 case 'y': // y- yank something
3551 case 'Y': // Y- Yank a line 3554 case 'Y': // Y- Yank a line
3552#endif /* CONFIG_FEATURE_VI_YANKMARK */ 3555#endif
3553 yf = YANKDEL; // assume either "c" or "d" 3556 yf = YANKDEL; // assume either "c" or "d"
3554#ifdef CONFIG_FEATURE_VI_YANKMARK 3557#if ENABLE_FEATURE_VI_YANKMARK
3555 if (c == 'y' || c == 'Y') 3558 if (c == 'y' || c == 'Y')
3556 yf = YANKONLY; 3559 yf = YANKONLY;
3557#endif /* CONFIG_FEATURE_VI_YANKMARK */ 3560#endif
3558 c1 = 'y'; 3561 c1 = 'y';
3559 if (c != 'Y') 3562 if (c != 'Y')
3560 c1 = get_one_char(); // get the type of thing to delete 3563 c1 = get_one_char(); // get the type of thing to delete
@@ -3601,7 +3604,7 @@ key_cmd_mode:
3601 if (c == 'd') { 3604 if (c == 'd') {
3602 strcpy((char *) buf, "Delete"); 3605 strcpy((char *) buf, "Delete");
3603 } 3606 }
3604#ifdef CONFIG_FEATURE_VI_YANKMARK 3607#if ENABLE_FEATURE_VI_YANKMARK
3605 if (c == 'y' || c == 'Y') { 3608 if (c == 'y' || c == 'Y') {
3606 strcpy((char *) buf, "Yank"); 3609 strcpy((char *) buf, "Yank");
3607 } 3610 }
@@ -3613,7 +3616,7 @@ key_cmd_mode:
3613 } 3616 }
3614 psb("%s %d lines (%d chars) using [%c]", 3617 psb("%s %d lines (%d chars) using [%c]",
3615 buf, cnt, strlen((char *) reg[YDreg]), what_reg()); 3618 buf, cnt, strlen((char *) reg[YDreg]), what_reg());
3616#endif /* CONFIG_FEATURE_VI_YANKMARK */ 3619#endif
3617 end_cmd_q(); // stop adding to q 3620 end_cmd_q(); // stop adding to q
3618 } 3621 }
3619 break; 3622 break;
@@ -3712,9 +3715,9 @@ key_cmd_mode:
3712 if (dot != end) { 3715 if (dot != end) {
3713 dot = bound_dot(dot); // make sure "dot" is valid 3716 dot = bound_dot(dot); // make sure "dot" is valid
3714 } 3717 }
3715#ifdef CONFIG_FEATURE_VI_YANKMARK 3718#if ENABLE_FEATURE_VI_YANKMARK
3716 check_context(c); // update the current context 3719 check_context(c); // update the current context
3717#endif /* CONFIG_FEATURE_VI_YANKMARK */ 3720#endif
3718 3721
3719 if (!isdigit(c)) 3722 if (!isdigit(c))
3720 cmdcnt = 0; // cmd was not a number, reset cmdcnt 3723 cmdcnt = 0; // cmd was not a number, reset cmdcnt
@@ -3724,7 +3727,7 @@ key_cmd_mode:
3724 dot--; 3727 dot--;
3725} 3728}
3726 3729
3727#ifdef CONFIG_FEATURE_VI_CRASHME 3730#if ENABLE_FEATURE_VI_CRASHME
3728static int totalcmds = 0; 3731static int totalcmds = 0;
3729static int Mp = 85; // Movement command Probability 3732static int Mp = 85; // Movement command Probability
3730static int Np = 90; // Non-movement command Probability 3733static int Np = 90; // Non-movement command Probability
@@ -3927,4 +3930,4 @@ static void crash_test()
3927 } 3930 }
3928 return; 3931 return;
3929} 3932}
3930#endif /* CONFIG_FEATURE_VI_CRASHME */ 3933#endif
diff --git a/libbb/Kbuild b/libbb/Kbuild
index 64e4531ce..c80d1be51 100644
--- a/libbb/Kbuild
+++ b/libbb/Kbuild
@@ -105,7 +105,7 @@ lib-$(CONFIG_VLOCK) += correct_password.o
105lib-$(CONFIG_SU) += correct_password.o 105lib-$(CONFIG_SU) += correct_password.o
106lib-$(CONFIG_LOGIN) += correct_password.o 106lib-$(CONFIG_LOGIN) += correct_password.o
107lib-$(CONFIG_DF) += find_mount_point.o 107lib-$(CONFIG_DF) += find_mount_point.o
108lib-$(CONFIG_EJECT) += find_mount_point.o 108lib-$(CONFIG_MKFS_MINIX) += find_mount_point.o
109 109
110# We shouldn't build xregcomp.c if we don't need it - this ensures we don't 110# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
111# require regex.h to be in the include dir even if we don't need it thereby 111# require regex.h to be in the include dir even if we don't need it thereby
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 842ef09d0..866e333ec 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -3859,11 +3859,12 @@ add_ksymoops_symbols(struct obj_file *f, const char *filename,
3859#if ENABLE_FEATURE_INSMOD_LOAD_MAP 3859#if ENABLE_FEATURE_INSMOD_LOAD_MAP
3860static void print_load_map(struct obj_file *f) 3860static void print_load_map(struct obj_file *f)
3861{ 3861{
3862 struct obj_symbol *sym;
3863 struct obj_symbol **all, **p;
3864 struct obj_section *sec; 3862 struct obj_section *sec;
3863#if ENABLE_FEATURE_INSMOD_LOAD_MAP_FULL
3864 struct obj_symbol **all, **p;
3865 int i, nsyms, *loaded; 3865 int i, nsyms, *loaded;
3866 3866 struct obj_symbol *sym;
3867#endif
3867 /* Report on the section layout. */ 3868 /* Report on the section layout. */
3868 3869
3869 printf("Sections: Size %-*s Align\n", 3870 printf("Sections: Size %-*s Align\n",
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 64ebb60e3..27b041e8e 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -257,7 +257,7 @@ set_changed(int i)
257{ 257{
258 ptes[i].changed = 1; 258 ptes[i].changed = 1;
259} 259}
260#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 260#endif /* FEATURE_FDISK_WRITABLE */
261 261
262static ATTRIBUTE_ALWAYS_INLINE struct partition * 262static ATTRIBUTE_ALWAYS_INLINE struct partition *
263get_part_table(int i) 263get_part_table(int i)
@@ -344,7 +344,7 @@ read_hex(const struct systypes *sys)
344 return v; 344 return v;
345 } 345 }
346} 346}
347#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 347#endif /* FEATURE_FDISK_WRITABLE */
348 348
349#include "fdisk_aix.c" 349#include "fdisk_aix.c"
350 350
@@ -418,7 +418,9 @@ STATIC_SGI int sgi_get_sysid(int i);
418STATIC_SGI void sgi_delete_partition(int i); 418STATIC_SGI void sgi_delete_partition(int i);
419STATIC_SGI void sgi_change_sysid(int i, int sys); 419STATIC_SGI void sgi_change_sysid(int i, int sys);
420STATIC_SGI void sgi_list_table(int xtra); 420STATIC_SGI void sgi_list_table(int xtra);
421#if ENABLE_FEATURE_FDISK_ADVANCED
421STATIC_SGI void sgi_set_xcyl(void); 422STATIC_SGI void sgi_set_xcyl(void);
423#endif
422STATIC_SGI int verify_sgi(int verbose); 424STATIC_SGI int verify_sgi(int verbose);
423STATIC_SGI void sgi_add_partition(int n, int sys); 425STATIC_SGI void sgi_add_partition(int n, int sys);
424STATIC_SGI void sgi_set_swappartition(int i); 426STATIC_SGI void sgi_set_swappartition(int i);
@@ -427,21 +429,21 @@ STATIC_SGI void sgi_set_bootfile(const char* aFile);
427STATIC_SGI void create_sgiinfo(void); 429STATIC_SGI void create_sgiinfo(void);
428STATIC_SGI void sgi_write_table(void); 430STATIC_SGI void sgi_write_table(void);
429STATIC_SGI void sgi_set_bootpartition(int i); 431STATIC_SGI void sgi_set_bootpartition(int i);
430
431#include "fdisk_sgi.c" 432#include "fdisk_sgi.c"
432 433
433STATIC_SUN const struct systypes sun_sys_types[]; 434STATIC_SUN const struct systypes sun_sys_types[];
434STATIC_SUN void sun_delete_partition(int i); 435STATIC_SUN void sun_delete_partition(int i);
435STATIC_SUN void sun_change_sysid(int i, int sys); 436STATIC_SUN void sun_change_sysid(int i, int sys);
436STATIC_SUN void sun_list_table(int xtra); 437STATIC_SUN void sun_list_table(int xtra);
437STATIC_SUN void sun_set_xcyl(void);
438STATIC_SUN void add_sun_partition(int n, int sys); 438STATIC_SUN void add_sun_partition(int n, int sys);
439#if ENABLE_FEATURE_FDISK_ADVANCED
439STATIC_SUN void sun_set_alt_cyl(void); 440STATIC_SUN void sun_set_alt_cyl(void);
440STATIC_SUN void sun_set_ncyl(int cyl); 441STATIC_SUN void sun_set_ncyl(int cyl);
441STATIC_SUN void sun_set_xcyl(void); 442STATIC_SUN void sun_set_xcyl(void);
442STATIC_SUN void sun_set_ilfact(void); 443STATIC_SUN void sun_set_ilfact(void);
443STATIC_SUN void sun_set_rspeed(void); 444STATIC_SUN void sun_set_rspeed(void);
444STATIC_SUN void sun_set_pcylcount(void); 445STATIC_SUN void sun_set_pcylcount(void);
446#endif
445STATIC_SUN void toggle_sunflags(int i, unsigned char mask); 447STATIC_SUN void toggle_sunflags(int i, unsigned char mask);
446STATIC_SUN void verify_sun(void); 448STATIC_SUN void verify_sun(void);
447STATIC_SUN void sun_write_table(void); 449STATIC_SUN void sun_write_table(void);
@@ -564,7 +566,7 @@ store4_little_endian(unsigned char *cp, unsigned val)
564 cp[2] = val >> 16; 566 cp[2] = val >> 16;
565 cp[3] = val >> 24; 567 cp[3] = val >> 24;
566} 568}
567#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 569#endif /* FEATURE_FDISK_WRITABLE */
568 570
569static unsigned 571static unsigned
570read4_little_endian(const unsigned char *cp) 572read4_little_endian(const unsigned char *cp)
@@ -784,7 +786,7 @@ menu(void)
784#endif 786#endif
785 } 787 }
786} 788}
787#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 789#endif /* FEATURE_FDISK_WRITABLE */
788 790
789 791
790#if ENABLE_FEATURE_FDISK_ADVANCED 792#if ENABLE_FEATURE_FDISK_ADVANCED
@@ -873,7 +875,7 @@ get_sys_types(void)
873} 875}
874#else 876#else
875#define get_sys_types() i386_sys_types 877#define get_sys_types() i386_sys_types
876#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 878#endif /* FEATURE_FDISK_WRITABLE */
877 879
878static const char *partition_type(unsigned char type) 880static const char *partition_type(unsigned char type)
879{ 881{
@@ -921,7 +923,7 @@ void list_types(const struct systypes *sys)
921 } while (done < last[0]); 923 } while (done < last[0]);
922 putchar('\n'); 924 putchar('\n');
923} 925}
924#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 926#endif /* FEATURE_FDISK_WRITABLE */
925 927
926static int 928static int
927is_cleared_partition(const struct partition *p) 929is_cleared_partition(const struct partition *p)
@@ -1149,7 +1151,7 @@ create_doslabel(void)
1149 set_changed(0); 1151 set_changed(0);
1150 get_boot(create_empty_dos); 1152 get_boot(create_empty_dos);
1151} 1153}
1152#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 1154#endif /* FEATURE_FDISK_WRITABLE */
1153 1155
1154static void 1156static void
1155get_sectorsize(void) 1157get_sectorsize(void)
@@ -1348,7 +1350,7 @@ get_boot(enum action what)
1348#endif 1350#endif
1349 1351
1350 if (!valid_part_table_flag(MBRbuffer)) { 1352 if (!valid_part_table_flag(MBRbuffer)) {
1351#ifndef CONFIG_FEATURE_FDISK_WRITABLE 1353#if !ENABLE_FEATURE_FDISK_WRITABLE
1352 return -1; 1354 return -1;
1353#else 1355#else
1354 switch (what) { 1356 switch (what) {
@@ -1374,7 +1376,7 @@ get_boot(enum action what)
1374 default: 1376 default:
1375 bb_error_msg_and_die(_("internal error")); 1377 bb_error_msg_and_die(_("internal error"));
1376 } 1378 }
1377#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 1379#endif /* FEATURE_FDISK_WRITABLE */
1378 } 1380 }
1379 1381
1380#if ENABLE_FEATURE_FDISK_WRITABLE 1382#if ENABLE_FEATURE_FDISK_WRITABLE
@@ -1769,7 +1771,7 @@ change_sysid(void)
1769 } 1771 }
1770 } 1772 }
1771} 1773}
1772#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 1774#endif /* FEATURE_FDISK_WRITABLE */
1773 1775
1774 1776
1775/* check_consistency() and linear2chs() added Sat Mar 6 12:28:16 1993, 1777/* check_consistency() and linear2chs() added Sat Mar 6 12:28:16 1993,
@@ -2517,7 +2519,7 @@ reread_partition_table(int leave)
2517 exit(i != 0); 2519 exit(i != 0);
2518 } 2520 }
2519} 2521}
2520#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 2522#endif /* FEATURE_FDISK_WRITABLE */
2521 2523
2522#if ENABLE_FEATURE_FDISK_ADVANCED 2524#if ENABLE_FEATURE_FDISK_ADVANCED
2523#define MAX_PER_LINE 16 2525#define MAX_PER_LINE 16
@@ -3035,5 +3037,5 @@ int fdisk_main(int argc, char **argv)
3035 } 3037 }
3036 } 3038 }
3037 return 0; 3039 return 0;
3038#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 3040#endif /* FEATURE_FDISK_WRITABLE */
3039} 3041}
diff --git a/util-linux/fdisk_aix.c b/util-linux/fdisk_aix.c
index a3d5fe15f..2402e294a 100644
--- a/util-linux/fdisk_aix.c
+++ b/util-linux/fdisk_aix.c
@@ -1,4 +1,4 @@
1#ifdef CONFIG_FEATURE_AIX_LABEL 1#if ENABLE_FEATURE_AIX_LABEL
2/* 2/*
3 * Copyright (C) Andreas Neuper, Sep 1998. 3 * Copyright (C) Andreas Neuper, Sep 1998.
4 * This file may be redistributed under 4 * This file may be redistributed under
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index 3d654d392..2daafe6c7 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -1,4 +1,4 @@
1#ifdef CONFIG_FEATURE_OSF_LABEL 1#if ENABLE_FEATURE_OSF_LABEL
2/* 2/*
3 * Copyright (c) 1987, 1988 Regents of the University of California. 3 * Copyright (c) 1987, 1988 Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c
index 7687103c9..d8acd6bc7 100644
--- a/util-linux/fdisk_sgi.c
+++ b/util-linux/fdisk_sgi.c
@@ -1,4 +1,4 @@
1#ifdef CONFIG_FEATURE_SGI_LABEL 1#if ENABLE_FEATURE_SGI_LABEL
2 2
3/* 3/*
4 * Copyright (C) Andreas Neuper, Sep 1998. 4 * Copyright (C) Andreas Neuper, Sep 1998.
@@ -751,7 +751,7 @@ sgi_add_partition(int n, int sys)
751 sgi_set_partition(n, first, last-first, sys); 751 sgi_set_partition(n, first, last-first, sys);
752} 752}
753 753
754#ifdef CONFIG_FEATURE_FDISK_ADVANCED 754#if ENABLE_FEATURE_FDISK_ADVANCED
755static void 755static void
756create_sgilabel(void) 756create_sgilabel(void)
757{ 757{
@@ -861,7 +861,7 @@ sgi_set_xcyl(void)
861{ 861{
862 /* do nothing in the beginning */ 862 /* do nothing in the beginning */
863} 863}
864#endif /* CONFIG_FEATURE_FDISK_ADVANCED */ 864#endif /* FEATURE_FDISK_ADVANCED */
865 865
866/* _____________________________________________________________ 866/* _____________________________________________________________
867 */ 867 */
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index af85fb2c4..a3ca66f68 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -1,4 +1,4 @@
1#ifdef CONFIG_FEATURE_SUN_LABEL 1#if ENABLE_FEATURE_SUN_LABEL
2 2
3#define SUN_LABEL_MAGIC 0xDABE 3#define SUN_LABEL_MAGIC 0xDABE
4#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA 4#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA
@@ -663,7 +663,7 @@ sun_list_table(int xtra)
663 } 663 }
664} 664}
665 665
666#ifdef CONFIG_FEATURE_FDISK_ADVANCED 666#if ENABLE_FEATURE_FDISK_ADVANCED
667 667
668static void 668static void
669sun_set_alt_cyl(void) 669sun_set_alt_cyl(void)
@@ -710,7 +710,7 @@ sun_set_pcylcount(void)
710 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->pcylcount), 65535, 0, 710 SUN_SSWAP16(read_int(0, SUN_SSWAP16(sunlabel->pcylcount), 65535, 0,
711 _("Number of physical cylinders"))); 711 _("Number of physical cylinders")));
712} 712}
713#endif /* CONFIG_FEATURE_FDISK_ADVANCED */ 713#endif /* FEATURE_FDISK_ADVANCED */
714 714
715static void 715static void
716sun_write_table(void) 716sun_write_table(void)