diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-06-27 15:11:36 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-06-27 15:11:36 +0200 |
commit | 8825cb6660b66c412296c2b1e10ca2f965a0a9cd (patch) | |
tree | 106ad24bd793e08bf623e8f64cde2d14b906f021 | |
parent | 4c58f246d400d59d21eb98e8d6b334e0447ebaaa (diff) | |
download | busybox-w32-8825cb6660b66c412296c2b1e10ca2f965a0a9cd.tar.gz busybox-w32-8825cb6660b66c412296c2b1e10ca2f965a0a9cd.tar.bz2 busybox-w32-8825cb6660b66c412296c2b1e10ca2f965a0a9cd.zip |
vi: placate "warning: variable orig_buf set but not used"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/editors/vi.c b/editors/vi.c index 61e988ce9..f103e0dc0 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -1070,10 +1070,13 @@ static void colon(char *buf) | |||
1070 | not_implemented(p); | 1070 | not_implemented(p); |
1071 | #else | 1071 | #else |
1072 | 1072 | ||
1073 | char c, *orig_buf, *buf1, *q, *r; | 1073 | char c, *buf1, *q, *r; |
1074 | char *fn, cmd[MAX_INPUT_LEN], args[MAX_INPUT_LEN]; | 1074 | char *fn, cmd[MAX_INPUT_LEN], args[MAX_INPUT_LEN]; |
1075 | int i, l, li, b, e; | 1075 | int i, l, li, b, e; |
1076 | int useforce; | 1076 | int useforce; |
1077 | # if ENABLE_FEATURE_VI_SEARCH || ENABLE_FEATURE_ALLOW_EXEC | ||
1078 | char *orig_buf; | ||
1079 | # endif | ||
1077 | 1080 | ||
1078 | // :3154 // if (-e line 3154) goto it else stay put | 1081 | // :3154 // if (-e line 3154) goto it else stay put |
1079 | // :4,33w! foo // write a portion of buffer to file "foo" | 1082 | // :4,33w! foo // write a portion of buffer to file "foo" |
@@ -1105,8 +1108,10 @@ static void colon(char *buf) | |||
1105 | // look for optional address(es) :. :1 :1,9 :'q,'a :% | 1108 | // look for optional address(es) :. :1 :1,9 :'q,'a :% |
1106 | buf = get_address(buf, &b, &e); | 1109 | buf = get_address(buf, &b, &e); |
1107 | 1110 | ||
1111 | # if ENABLE_FEATURE_VI_SEARCH || ENABLE_FEATURE_ALLOW_EXEC | ||
1108 | // remember orig command line | 1112 | // remember orig command line |
1109 | orig_buf = buf; | 1113 | orig_buf = buf; |
1114 | # endif | ||
1110 | 1115 | ||
1111 | // get the COMMAND into cmd[] | 1116 | // get the COMMAND into cmd[] |
1112 | buf1 = cmd; | 1117 | buf1 = cmd; |
@@ -1150,7 +1155,7 @@ static void colon(char *buf) | |||
1150 | dot_skip_over_ws(); | 1155 | dot_skip_over_ws(); |
1151 | } | 1156 | } |
1152 | } | 1157 | } |
1153 | #if ENABLE_FEATURE_ALLOW_EXEC | 1158 | # if ENABLE_FEATURE_ALLOW_EXEC |
1154 | else if (cmd[0] == '!') { // run a cmd | 1159 | else if (cmd[0] == '!') { // run a cmd |
1155 | int retcode; | 1160 | int retcode; |
1156 | // :!ls run the <cmd> | 1161 | // :!ls run the <cmd> |
@@ -1162,7 +1167,7 @@ static void colon(char *buf) | |||
1162 | rawmode(); | 1167 | rawmode(); |
1163 | Hit_Return(); // let user see results | 1168 | Hit_Return(); // let user see results |
1164 | } | 1169 | } |
1165 | #endif | 1170 | # endif |
1166 | else if (cmd[0] == '=' && !cmd[1]) { // where is the address | 1171 | else if (cmd[0] == '=' && !cmd[1]) { // where is the address |
1167 | if (b < 0) { // no addr given- use defaults | 1172 | if (b < 0) { // no addr given- use defaults |
1168 | b = e = count_lines(text, dot); | 1173 | b = e = count_lines(text, dot); |
@@ -1197,7 +1202,7 @@ static void colon(char *buf) | |||
1197 | 1202 | ||
1198 | size = init_text_buffer(fn); | 1203 | size = init_text_buffer(fn); |
1199 | 1204 | ||
1200 | #if ENABLE_FEATURE_VI_YANKMARK | 1205 | # if ENABLE_FEATURE_VI_YANKMARK |
1201 | if (Ureg >= 0 && Ureg < 28) { | 1206 | if (Ureg >= 0 && Ureg < 28) { |
1202 | free(reg[Ureg]); // free orig line reg- for 'U' | 1207 | free(reg[Ureg]); // free orig line reg- for 'U' |
1203 | reg[Ureg] = NULL; | 1208 | reg[Ureg] = NULL; |
@@ -1206,7 +1211,7 @@ static void colon(char *buf) | |||
1206 | free(reg[YDreg]); // free default yank/delete register | 1211 | free(reg[YDreg]); // free default yank/delete register |
1207 | reg[YDreg] = NULL; | 1212 | reg[YDreg] = NULL; |
1208 | } | 1213 | } |
1209 | #endif | 1214 | # endif |
1210 | // how many lines in text[]? | 1215 | // how many lines in text[]? |
1211 | li = count_lines(text, end - 1); | 1216 | li = count_lines(text, end - 1); |
1212 | status_line("'%s'%s" | 1217 | status_line("'%s'%s" |
@@ -1353,16 +1358,16 @@ static void colon(char *buf) | |||
1353 | optind = -1; /* start from 0th file */ | 1358 | optind = -1; /* start from 0th file */ |
1354 | editing = 0; | 1359 | editing = 0; |
1355 | } | 1360 | } |
1356 | #if ENABLE_FEATURE_VI_SET | 1361 | # if ENABLE_FEATURE_VI_SET |
1357 | } else if (strncmp(cmd, "set", i) == 0) { // set or clear features | 1362 | } else if (strncmp(cmd, "set", i) == 0) { // set or clear features |
1358 | #if ENABLE_FEATURE_VI_SETOPTS | 1363 | # if ENABLE_FEATURE_VI_SETOPTS |
1359 | char *argp; | 1364 | char *argp; |
1360 | #endif | 1365 | # endif |
1361 | i = 0; // offset into args | 1366 | i = 0; // offset into args |
1362 | // only blank is regarded as args delimiter. What about tab '\t'? | 1367 | // only blank is regarded as args delimiter. What about tab '\t'? |
1363 | if (!args[0] || strcasecmp(args, "all") == 0) { | 1368 | if (!args[0] || strcasecmp(args, "all") == 0) { |
1364 | // print out values of all options | 1369 | // print out values of all options |
1365 | #if ENABLE_FEATURE_VI_SETOPTS | 1370 | # if ENABLE_FEATURE_VI_SETOPTS |
1366 | status_line_bold( | 1371 | status_line_bold( |
1367 | "%sautoindent " | 1372 | "%sautoindent " |
1368 | "%sflash " | 1373 | "%sflash " |
@@ -1375,10 +1380,10 @@ static void colon(char *buf) | |||
1375 | showmatch ? "" : "no", | 1380 | showmatch ? "" : "no", |
1376 | tabstop | 1381 | tabstop |
1377 | ); | 1382 | ); |
1378 | #endif | 1383 | # endif |
1379 | goto ret; | 1384 | goto ret; |
1380 | } | 1385 | } |
1381 | #if ENABLE_FEATURE_VI_SETOPTS | 1386 | # if ENABLE_FEATURE_VI_SETOPTS |
1382 | argp = args; | 1387 | argp = args; |
1383 | while (*argp) { | 1388 | while (*argp) { |
1384 | if (strncmp(argp, "no", 2) == 0) | 1389 | if (strncmp(argp, "no", 2) == 0) |
@@ -1396,16 +1401,17 @@ static void colon(char *buf) | |||
1396 | argp = skip_non_whitespace(argp); | 1401 | argp = skip_non_whitespace(argp); |
1397 | argp = skip_whitespace(argp); | 1402 | argp = skip_whitespace(argp); |
1398 | } | 1403 | } |
1399 | #endif /* FEATURE_VI_SETOPTS */ | 1404 | # endif /* FEATURE_VI_SETOPTS */ |
1400 | #endif /* FEATURE_VI_SET */ | 1405 | # endif /* FEATURE_VI_SET */ |
1401 | #if ENABLE_FEATURE_VI_SEARCH | 1406 | |
1407 | # if ENABLE_FEATURE_VI_SEARCH | ||
1402 | } else if (cmd[0] == 's') { // substitute a pattern with a replacement pattern | 1408 | } else if (cmd[0] == 's') { // substitute a pattern with a replacement pattern |
1403 | char *F, *R, *flags; | 1409 | char *F, *R, *flags; |
1404 | size_t len_F, len_R; | 1410 | size_t len_F, len_R; |
1405 | int gflag; // global replace flag | 1411 | int gflag; // global replace flag |
1406 | #if ENABLE_FEATURE_VI_UNDO | 1412 | # if ENABLE_FEATURE_VI_UNDO |
1407 | int dont_chain_first_item = ALLOW_UNDO; | 1413 | int dont_chain_first_item = ALLOW_UNDO; |
1408 | #endif | 1414 | # endif |
1409 | 1415 | ||
1410 | // F points to the "find" pattern | 1416 | // F points to the "find" pattern |
1411 | // R points to the "replace" pattern | 1417 | // R points to the "replace" pattern |
@@ -1442,9 +1448,9 @@ static void colon(char *buf) | |||
1442 | // we found the "find" pattern - delete it | 1448 | // we found the "find" pattern - delete it |
1443 | // For undo support, the first item should not be chained | 1449 | // For undo support, the first item should not be chained |
1444 | text_hole_delete(found, found + len_F - 1, dont_chain_first_item); | 1450 | text_hole_delete(found, found + len_F - 1, dont_chain_first_item); |
1445 | #if ENABLE_FEATURE_VI_UNDO | 1451 | # if ENABLE_FEATURE_VI_UNDO |
1446 | dont_chain_first_item = ALLOW_UNDO_CHAIN; | 1452 | dont_chain_first_item = ALLOW_UNDO_CHAIN; |
1447 | #endif | 1453 | # endif |
1448 | // insert the "replace" patern | 1454 | // insert the "replace" patern |
1449 | bias = string_insert(found, R, ALLOW_UNDO_CHAIN); | 1455 | bias = string_insert(found, R, ALLOW_UNDO_CHAIN); |
1450 | found += bias; | 1456 | found += bias; |
@@ -1460,7 +1466,7 @@ static void colon(char *buf) | |||
1460 | } | 1466 | } |
1461 | q = next_line(ls); | 1467 | q = next_line(ls); |
1462 | } | 1468 | } |
1463 | #endif /* FEATURE_VI_SEARCH */ | 1469 | # endif /* FEATURE_VI_SEARCH */ |
1464 | } else if (strncmp(cmd, "version", i) == 0) { // show software version | 1470 | } else if (strncmp(cmd, "version", i) == 0) { // show software version |
1465 | status_line(BB_VER); | 1471 | status_line(BB_VER); |
1466 | } else if (strncmp(cmd, "write", i) == 0 // write text to file | 1472 | } else if (strncmp(cmd, "write", i) == 0 // write text to file |
@@ -1475,12 +1481,12 @@ static void colon(char *buf) | |||
1475 | if (args[0]) { | 1481 | if (args[0]) { |
1476 | fn = args; | 1482 | fn = args; |
1477 | } | 1483 | } |
1478 | #if ENABLE_FEATURE_VI_READONLY | 1484 | # if ENABLE_FEATURE_VI_READONLY |
1479 | if (readonly_mode && !useforce) { | 1485 | if (readonly_mode && !useforce) { |
1480 | status_line_bold("'%s' is read only", fn); | 1486 | status_line_bold("'%s' is read only", fn); |
1481 | goto ret; | 1487 | goto ret; |
1482 | } | 1488 | } |
1483 | #endif | 1489 | # endif |
1484 | //if (useforce) { | 1490 | //if (useforce) { |
1485 | // if "fn" is not write-able, chmod u+w | 1491 | // if "fn" is not write-able, chmod u+w |
1486 | // sprintf(syscmd, "chmod u+w %s", fn); | 1492 | // sprintf(syscmd, "chmod u+w %s", fn); |
@@ -1520,7 +1526,7 @@ static void colon(char *buf) | |||
1520 | } | 1526 | } |
1521 | } | 1527 | } |
1522 | } | 1528 | } |
1523 | #if ENABLE_FEATURE_VI_YANKMARK | 1529 | # if ENABLE_FEATURE_VI_YANKMARK |
1524 | } else if (strncmp(cmd, "yank", i) == 0) { // yank lines | 1530 | } else if (strncmp(cmd, "yank", i) == 0) { // yank lines |
1525 | if (b < 0) { // no addr given- use defaults | 1531 | if (b < 0) { // no addr given- use defaults |
1526 | q = begin_line(dot); // assume .,. for the range | 1532 | q = begin_line(dot); // assume .,. for the range |
@@ -1530,7 +1536,7 @@ static void colon(char *buf) | |||
1530 | li = count_lines(q, r); | 1536 | li = count_lines(q, r); |
1531 | status_line("Yank %d lines (%d chars) into [%c]", | 1537 | status_line("Yank %d lines (%d chars) into [%c]", |
1532 | li, strlen(reg[YDreg]), what_reg()); | 1538 | li, strlen(reg[YDreg]), what_reg()); |
1533 | #endif | 1539 | # endif |
1534 | } else { | 1540 | } else { |
1535 | // cmd unknown | 1541 | // cmd unknown |
1536 | not_implemented(cmd); | 1542 | not_implemented(cmd); |
@@ -1538,10 +1544,10 @@ static void colon(char *buf) | |||
1538 | ret: | 1544 | ret: |
1539 | dot = bound_dot(dot); // make sure "dot" is valid | 1545 | dot = bound_dot(dot); // make sure "dot" is valid |
1540 | return; | 1546 | return; |
1541 | #if ENABLE_FEATURE_VI_SEARCH | 1547 | # if ENABLE_FEATURE_VI_SEARCH |
1542 | colon_s_fail: | 1548 | colon_s_fail: |
1543 | status_line(":s expression missing delimiters"); | 1549 | status_line(":s expression missing delimiters"); |
1544 | #endif | 1550 | # endif |
1545 | #endif /* FEATURE_VI_COLON */ | 1551 | #endif /* FEATURE_VI_COLON */ |
1546 | } | 1552 | } |
1547 | 1553 | ||