diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/Config.src | 2 | ||||
-rw-r--r-- | editors/vi.c | 61 |
2 files changed, 36 insertions, 27 deletions
diff --git a/editors/Config.src b/editors/Config.src index 0920bc494..3b2e4a6c0 100644 --- a/editors/Config.src +++ b/editors/Config.src | |||
@@ -1,6 +1,6 @@ | |||
1 | # | 1 | # |
2 | # For a description of the syntax of this configuration file, | 2 | # For a description of the syntax of this configuration file, |
3 | # see scripts/kbuild/config-language.txt. | 3 | # see docs/Kconfig-language.txt. |
4 | # | 4 | # |
5 | 5 | ||
6 | menu "Editors" | 6 | menu "Editors" |
diff --git a/editors/vi.c b/editors/vi.c index 26487bee6..e79787977 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -752,7 +752,10 @@ static int query_screen_dimensions(void) | |||
752 | return err; | 752 | return err; |
753 | } | 753 | } |
754 | #else | 754 | #else |
755 | # define query_screen_dimensions() (0) | 755 | static ALWAYS_INLINE int query_screen_dimensions(void) |
756 | { | ||
757 | return 0; | ||
758 | } | ||
756 | #endif | 759 | #endif |
757 | 760 | ||
758 | static void edit_file(char *fn) | 761 | static void edit_file(char *fn) |
@@ -1069,10 +1072,13 @@ static void colon(char *buf) | |||
1069 | not_implemented(p); | 1072 | not_implemented(p); |
1070 | #else | 1073 | #else |
1071 | 1074 | ||
1072 | char c, *orig_buf, *buf1, *q, *r; | 1075 | char c, *buf1, *q, *r; |
1073 | char *fn, cmd[MAX_INPUT_LEN], args[MAX_INPUT_LEN]; | 1076 | char *fn, cmd[MAX_INPUT_LEN], args[MAX_INPUT_LEN]; |
1074 | int i, l, li, b, e; | 1077 | int i, l, li, b, e; |
1075 | int useforce; | 1078 | int useforce; |
1079 | # if ENABLE_FEATURE_VI_SEARCH || ENABLE_FEATURE_ALLOW_EXEC | ||
1080 | char *orig_buf; | ||
1081 | # endif | ||
1076 | 1082 | ||
1077 | // :3154 // if (-e line 3154) goto it else stay put | 1083 | // :3154 // if (-e line 3154) goto it else stay put |
1078 | // :4,33w! foo // write a portion of buffer to file "foo" | 1084 | // :4,33w! foo // write a portion of buffer to file "foo" |
@@ -1104,8 +1110,10 @@ static void colon(char *buf) | |||
1104 | // look for optional address(es) :. :1 :1,9 :'q,'a :% | 1110 | // look for optional address(es) :. :1 :1,9 :'q,'a :% |
1105 | buf = get_address(buf, &b, &e); | 1111 | buf = get_address(buf, &b, &e); |
1106 | 1112 | ||
1113 | # if ENABLE_FEATURE_VI_SEARCH || ENABLE_FEATURE_ALLOW_EXEC | ||
1107 | // remember orig command line | 1114 | // remember orig command line |
1108 | orig_buf = buf; | 1115 | orig_buf = buf; |
1116 | # endif | ||
1109 | 1117 | ||
1110 | // get the COMMAND into cmd[] | 1118 | // get the COMMAND into cmd[] |
1111 | buf1 = cmd; | 1119 | buf1 = cmd; |
@@ -1149,7 +1157,7 @@ static void colon(char *buf) | |||
1149 | dot_skip_over_ws(); | 1157 | dot_skip_over_ws(); |
1150 | } | 1158 | } |
1151 | } | 1159 | } |
1152 | #if ENABLE_FEATURE_ALLOW_EXEC | 1160 | # if ENABLE_FEATURE_ALLOW_EXEC |
1153 | else if (cmd[0] == '!') { // run a cmd | 1161 | else if (cmd[0] == '!') { // run a cmd |
1154 | int retcode; | 1162 | int retcode; |
1155 | // :!ls run the <cmd> | 1163 | // :!ls run the <cmd> |
@@ -1161,7 +1169,7 @@ static void colon(char *buf) | |||
1161 | rawmode(); | 1169 | rawmode(); |
1162 | Hit_Return(); // let user see results | 1170 | Hit_Return(); // let user see results |
1163 | } | 1171 | } |
1164 | #endif | 1172 | # endif |
1165 | else if (cmd[0] == '=' && !cmd[1]) { // where is the address | 1173 | else if (cmd[0] == '=' && !cmd[1]) { // where is the address |
1166 | if (b < 0) { // no addr given- use defaults | 1174 | if (b < 0) { // no addr given- use defaults |
1167 | b = e = count_lines(text, dot); | 1175 | b = e = count_lines(text, dot); |
@@ -1196,7 +1204,7 @@ static void colon(char *buf) | |||
1196 | 1204 | ||
1197 | size = init_text_buffer(fn); | 1205 | size = init_text_buffer(fn); |
1198 | 1206 | ||
1199 | #if ENABLE_FEATURE_VI_YANKMARK | 1207 | # if ENABLE_FEATURE_VI_YANKMARK |
1200 | if (Ureg >= 0 && Ureg < 28) { | 1208 | if (Ureg >= 0 && Ureg < 28) { |
1201 | free(reg[Ureg]); // free orig line reg- for 'U' | 1209 | free(reg[Ureg]); // free orig line reg- for 'U' |
1202 | reg[Ureg] = NULL; | 1210 | reg[Ureg] = NULL; |
@@ -1205,7 +1213,7 @@ static void colon(char *buf) | |||
1205 | free(reg[YDreg]); // free default yank/delete register | 1213 | free(reg[YDreg]); // free default yank/delete register |
1206 | reg[YDreg] = NULL; | 1214 | reg[YDreg] = NULL; |
1207 | } | 1215 | } |
1208 | #endif | 1216 | # endif |
1209 | // how many lines in text[]? | 1217 | // how many lines in text[]? |
1210 | li = count_lines(text, end - 1); | 1218 | li = count_lines(text, end - 1); |
1211 | status_line("'%s'%s" | 1219 | status_line("'%s'%s" |
@@ -1352,16 +1360,16 @@ static void colon(char *buf) | |||
1352 | optind = -1; /* start from 0th file */ | 1360 | optind = -1; /* start from 0th file */ |
1353 | editing = 0; | 1361 | editing = 0; |
1354 | } | 1362 | } |
1355 | #if ENABLE_FEATURE_VI_SET | 1363 | # if ENABLE_FEATURE_VI_SET |
1356 | } else if (strncmp(cmd, "set", i) == 0) { // set or clear features | 1364 | } else if (strncmp(cmd, "set", i) == 0) { // set or clear features |
1357 | #if ENABLE_FEATURE_VI_SETOPTS | 1365 | # if ENABLE_FEATURE_VI_SETOPTS |
1358 | char *argp; | 1366 | char *argp; |
1359 | #endif | 1367 | # endif |
1360 | i = 0; // offset into args | 1368 | i = 0; // offset into args |
1361 | // only blank is regarded as args delimiter. What about tab '\t'? | 1369 | // only blank is regarded as args delimiter. What about tab '\t'? |
1362 | if (!args[0] || strcasecmp(args, "all") == 0) { | 1370 | if (!args[0] || strcasecmp(args, "all") == 0) { |
1363 | // print out values of all options | 1371 | // print out values of all options |
1364 | #if ENABLE_FEATURE_VI_SETOPTS | 1372 | # if ENABLE_FEATURE_VI_SETOPTS |
1365 | status_line_bold( | 1373 | status_line_bold( |
1366 | "%sautoindent " | 1374 | "%sautoindent " |
1367 | "%sflash " | 1375 | "%sflash " |
@@ -1374,10 +1382,10 @@ static void colon(char *buf) | |||
1374 | showmatch ? "" : "no", | 1382 | showmatch ? "" : "no", |
1375 | tabstop | 1383 | tabstop |
1376 | ); | 1384 | ); |
1377 | #endif | 1385 | # endif |
1378 | goto ret; | 1386 | goto ret; |
1379 | } | 1387 | } |
1380 | #if ENABLE_FEATURE_VI_SETOPTS | 1388 | # if ENABLE_FEATURE_VI_SETOPTS |
1381 | argp = args; | 1389 | argp = args; |
1382 | while (*argp) { | 1390 | while (*argp) { |
1383 | if (strncmp(argp, "no", 2) == 0) | 1391 | if (strncmp(argp, "no", 2) == 0) |
@@ -1395,16 +1403,17 @@ static void colon(char *buf) | |||
1395 | argp = skip_non_whitespace(argp); | 1403 | argp = skip_non_whitespace(argp); |
1396 | argp = skip_whitespace(argp); | 1404 | argp = skip_whitespace(argp); |
1397 | } | 1405 | } |
1398 | #endif /* FEATURE_VI_SETOPTS */ | 1406 | # endif /* FEATURE_VI_SETOPTS */ |
1399 | #endif /* FEATURE_VI_SET */ | 1407 | # endif /* FEATURE_VI_SET */ |
1400 | #if ENABLE_FEATURE_VI_SEARCH | 1408 | |
1409 | # if ENABLE_FEATURE_VI_SEARCH | ||
1401 | } else if (cmd[0] == 's') { // substitute a pattern with a replacement pattern | 1410 | } else if (cmd[0] == 's') { // substitute a pattern with a replacement pattern |
1402 | char *F, *R, *flags; | 1411 | char *F, *R, *flags; |
1403 | size_t len_F, len_R; | 1412 | size_t len_F, len_R; |
1404 | int gflag; // global replace flag | 1413 | int gflag; // global replace flag |
1405 | #if ENABLE_FEATURE_VI_UNDO | 1414 | # if ENABLE_FEATURE_VI_UNDO |
1406 | int dont_chain_first_item = ALLOW_UNDO; | 1415 | int dont_chain_first_item = ALLOW_UNDO; |
1407 | #endif | 1416 | # endif |
1408 | 1417 | ||
1409 | // F points to the "find" pattern | 1418 | // F points to the "find" pattern |
1410 | // R points to the "replace" pattern | 1419 | // R points to the "replace" pattern |
@@ -1441,9 +1450,9 @@ static void colon(char *buf) | |||
1441 | // we found the "find" pattern - delete it | 1450 | // we found the "find" pattern - delete it |
1442 | // For undo support, the first item should not be chained | 1451 | // For undo support, the first item should not be chained |
1443 | text_hole_delete(found, found + len_F - 1, dont_chain_first_item); | 1452 | text_hole_delete(found, found + len_F - 1, dont_chain_first_item); |
1444 | #if ENABLE_FEATURE_VI_UNDO | 1453 | # if ENABLE_FEATURE_VI_UNDO |
1445 | dont_chain_first_item = ALLOW_UNDO_CHAIN; | 1454 | dont_chain_first_item = ALLOW_UNDO_CHAIN; |
1446 | #endif | 1455 | # endif |
1447 | // insert the "replace" patern | 1456 | // insert the "replace" patern |
1448 | bias = string_insert(found, R, ALLOW_UNDO_CHAIN); | 1457 | bias = string_insert(found, R, ALLOW_UNDO_CHAIN); |
1449 | found += bias; | 1458 | found += bias; |
@@ -1459,7 +1468,7 @@ static void colon(char *buf) | |||
1459 | } | 1468 | } |
1460 | q = next_line(ls); | 1469 | q = next_line(ls); |
1461 | } | 1470 | } |
1462 | #endif /* FEATURE_VI_SEARCH */ | 1471 | # endif /* FEATURE_VI_SEARCH */ |
1463 | } else if (strncmp(cmd, "version", i) == 0) { // show software version | 1472 | } else if (strncmp(cmd, "version", i) == 0) { // show software version |
1464 | status_line(BB_VER); | 1473 | status_line(BB_VER); |
1465 | } else if (strncmp(cmd, "write", i) == 0 // write text to file | 1474 | } else if (strncmp(cmd, "write", i) == 0 // write text to file |
@@ -1474,12 +1483,12 @@ static void colon(char *buf) | |||
1474 | if (args[0]) { | 1483 | if (args[0]) { |
1475 | fn = args; | 1484 | fn = args; |
1476 | } | 1485 | } |
1477 | #if ENABLE_FEATURE_VI_READONLY | 1486 | # if ENABLE_FEATURE_VI_READONLY |
1478 | if (readonly_mode && !useforce) { | 1487 | if (readonly_mode && !useforce) { |
1479 | status_line_bold("'%s' is read only", fn); | 1488 | status_line_bold("'%s' is read only", fn); |
1480 | goto ret; | 1489 | goto ret; |
1481 | } | 1490 | } |
1482 | #endif | 1491 | # endif |
1483 | //if (useforce) { | 1492 | //if (useforce) { |
1484 | // if "fn" is not write-able, chmod u+w | 1493 | // if "fn" is not write-able, chmod u+w |
1485 | // sprintf(syscmd, "chmod u+w %s", fn); | 1494 | // sprintf(syscmd, "chmod u+w %s", fn); |
@@ -1519,7 +1528,7 @@ static void colon(char *buf) | |||
1519 | } | 1528 | } |
1520 | } | 1529 | } |
1521 | } | 1530 | } |
1522 | #if ENABLE_FEATURE_VI_YANKMARK | 1531 | # if ENABLE_FEATURE_VI_YANKMARK |
1523 | } else if (strncmp(cmd, "yank", i) == 0) { // yank lines | 1532 | } else if (strncmp(cmd, "yank", i) == 0) { // yank lines |
1524 | if (b < 0) { // no addr given- use defaults | 1533 | if (b < 0) { // no addr given- use defaults |
1525 | q = begin_line(dot); // assume .,. for the range | 1534 | q = begin_line(dot); // assume .,. for the range |
@@ -1529,7 +1538,7 @@ static void colon(char *buf) | |||
1529 | li = count_lines(q, r); | 1538 | li = count_lines(q, r); |
1530 | status_line("Yank %d lines (%d chars) into [%c]", | 1539 | status_line("Yank %d lines (%d chars) into [%c]", |
1531 | li, strlen(reg[YDreg]), what_reg()); | 1540 | li, strlen(reg[YDreg]), what_reg()); |
1532 | #endif | 1541 | # endif |
1533 | } else { | 1542 | } else { |
1534 | // cmd unknown | 1543 | // cmd unknown |
1535 | not_implemented(cmd); | 1544 | not_implemented(cmd); |
@@ -1537,10 +1546,10 @@ static void colon(char *buf) | |||
1537 | ret: | 1546 | ret: |
1538 | dot = bound_dot(dot); // make sure "dot" is valid | 1547 | dot = bound_dot(dot); // make sure "dot" is valid |
1539 | return; | 1548 | return; |
1540 | #if ENABLE_FEATURE_VI_SEARCH | 1549 | # if ENABLE_FEATURE_VI_SEARCH |
1541 | colon_s_fail: | 1550 | colon_s_fail: |
1542 | status_line(":s expression missing delimiters"); | 1551 | status_line(":s expression missing delimiters"); |
1543 | #endif | 1552 | # endif |
1544 | #endif /* FEATURE_VI_COLON */ | 1553 | #endif /* FEATURE_VI_COLON */ |
1545 | } | 1554 | } |
1546 | 1555 | ||