vi: placate "warning: variable orig_buf set but not used"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4c58f246d4
commit
8825cb6660
56
editors/vi.c
56
editors/vi.c
@ -1070,10 +1070,13 @@ static void colon(char *buf)
|
|||||||
not_implemented(p);
|
not_implemented(p);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
char c, *orig_buf, *buf1, *q, *r;
|
char c, *buf1, *q, *r;
|
||||||
char *fn, cmd[MAX_INPUT_LEN], args[MAX_INPUT_LEN];
|
char *fn, cmd[MAX_INPUT_LEN], args[MAX_INPUT_LEN];
|
||||||
int i, l, li, b, e;
|
int i, l, li, b, e;
|
||||||
int useforce;
|
int useforce;
|
||||||
|
# if ENABLE_FEATURE_VI_SEARCH || ENABLE_FEATURE_ALLOW_EXEC
|
||||||
|
char *orig_buf;
|
||||||
|
# endif
|
||||||
|
|
||||||
// :3154 // if (-e line 3154) goto it else stay put
|
// :3154 // if (-e line 3154) goto it else stay put
|
||||||
// :4,33w! foo // write a portion of buffer to file "foo"
|
// :4,33w! foo // write a portion of buffer to file "foo"
|
||||||
@ -1105,8 +1108,10 @@ static void colon(char *buf)
|
|||||||
// look for optional address(es) :. :1 :1,9 :'q,'a :%
|
// look for optional address(es) :. :1 :1,9 :'q,'a :%
|
||||||
buf = get_address(buf, &b, &e);
|
buf = get_address(buf, &b, &e);
|
||||||
|
|
||||||
|
# if ENABLE_FEATURE_VI_SEARCH || ENABLE_FEATURE_ALLOW_EXEC
|
||||||
// remember orig command line
|
// remember orig command line
|
||||||
orig_buf = buf;
|
orig_buf = buf;
|
||||||
|
# endif
|
||||||
|
|
||||||
// get the COMMAND into cmd[]
|
// get the COMMAND into cmd[]
|
||||||
buf1 = cmd;
|
buf1 = cmd;
|
||||||
@ -1150,7 +1155,7 @@ static void colon(char *buf)
|
|||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_ALLOW_EXEC
|
# if ENABLE_FEATURE_ALLOW_EXEC
|
||||||
else if (cmd[0] == '!') { // run a cmd
|
else if (cmd[0] == '!') { // run a cmd
|
||||||
int retcode;
|
int retcode;
|
||||||
// :!ls run the <cmd>
|
// :!ls run the <cmd>
|
||||||
@ -1162,7 +1167,7 @@ static void colon(char *buf)
|
|||||||
rawmode();
|
rawmode();
|
||||||
Hit_Return(); // let user see results
|
Hit_Return(); // let user see results
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
else if (cmd[0] == '=' && !cmd[1]) { // where is the address
|
else if (cmd[0] == '=' && !cmd[1]) { // where is the address
|
||||||
if (b < 0) { // no addr given- use defaults
|
if (b < 0) { // no addr given- use defaults
|
||||||
b = e = count_lines(text, dot);
|
b = e = count_lines(text, dot);
|
||||||
@ -1197,7 +1202,7 @@ static void colon(char *buf)
|
|||||||
|
|
||||||
size = init_text_buffer(fn);
|
size = init_text_buffer(fn);
|
||||||
|
|
||||||
#if ENABLE_FEATURE_VI_YANKMARK
|
# if ENABLE_FEATURE_VI_YANKMARK
|
||||||
if (Ureg >= 0 && Ureg < 28) {
|
if (Ureg >= 0 && Ureg < 28) {
|
||||||
free(reg[Ureg]); // free orig line reg- for 'U'
|
free(reg[Ureg]); // free orig line reg- for 'U'
|
||||||
reg[Ureg] = NULL;
|
reg[Ureg] = NULL;
|
||||||
@ -1206,7 +1211,7 @@ static void colon(char *buf)
|
|||||||
free(reg[YDreg]); // free default yank/delete register
|
free(reg[YDreg]); // free default yank/delete register
|
||||||
reg[YDreg] = NULL;
|
reg[YDreg] = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
// how many lines in text[]?
|
// how many lines in text[]?
|
||||||
li = count_lines(text, end - 1);
|
li = count_lines(text, end - 1);
|
||||||
status_line("'%s'%s"
|
status_line("'%s'%s"
|
||||||
@ -1353,16 +1358,16 @@ static void colon(char *buf)
|
|||||||
optind = -1; /* start from 0th file */
|
optind = -1; /* start from 0th file */
|
||||||
editing = 0;
|
editing = 0;
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_VI_SET
|
# if ENABLE_FEATURE_VI_SET
|
||||||
} else if (strncmp(cmd, "set", i) == 0) { // set or clear features
|
} else if (strncmp(cmd, "set", i) == 0) { // set or clear features
|
||||||
#if ENABLE_FEATURE_VI_SETOPTS
|
# if ENABLE_FEATURE_VI_SETOPTS
|
||||||
char *argp;
|
char *argp;
|
||||||
#endif
|
# endif
|
||||||
i = 0; // offset into args
|
i = 0; // offset into args
|
||||||
// only blank is regarded as args delimiter. What about tab '\t'?
|
// only blank is regarded as args delimiter. What about tab '\t'?
|
||||||
if (!args[0] || strcasecmp(args, "all") == 0) {
|
if (!args[0] || strcasecmp(args, "all") == 0) {
|
||||||
// print out values of all options
|
// print out values of all options
|
||||||
#if ENABLE_FEATURE_VI_SETOPTS
|
# if ENABLE_FEATURE_VI_SETOPTS
|
||||||
status_line_bold(
|
status_line_bold(
|
||||||
"%sautoindent "
|
"%sautoindent "
|
||||||
"%sflash "
|
"%sflash "
|
||||||
@ -1375,10 +1380,10 @@ static void colon(char *buf)
|
|||||||
showmatch ? "" : "no",
|
showmatch ? "" : "no",
|
||||||
tabstop
|
tabstop
|
||||||
);
|
);
|
||||||
#endif
|
# endif
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_VI_SETOPTS
|
# if ENABLE_FEATURE_VI_SETOPTS
|
||||||
argp = args;
|
argp = args;
|
||||||
while (*argp) {
|
while (*argp) {
|
||||||
if (strncmp(argp, "no", 2) == 0)
|
if (strncmp(argp, "no", 2) == 0)
|
||||||
@ -1396,16 +1401,17 @@ static void colon(char *buf)
|
|||||||
argp = skip_non_whitespace(argp);
|
argp = skip_non_whitespace(argp);
|
||||||
argp = skip_whitespace(argp);
|
argp = skip_whitespace(argp);
|
||||||
}
|
}
|
||||||
#endif /* FEATURE_VI_SETOPTS */
|
# endif /* FEATURE_VI_SETOPTS */
|
||||||
#endif /* FEATURE_VI_SET */
|
# endif /* FEATURE_VI_SET */
|
||||||
#if ENABLE_FEATURE_VI_SEARCH
|
|
||||||
|
# if ENABLE_FEATURE_VI_SEARCH
|
||||||
} else if (cmd[0] == 's') { // substitute a pattern with a replacement pattern
|
} else if (cmd[0] == 's') { // substitute a pattern with a replacement pattern
|
||||||
char *F, *R, *flags;
|
char *F, *R, *flags;
|
||||||
size_t len_F, len_R;
|
size_t len_F, len_R;
|
||||||
int gflag; // global replace flag
|
int gflag; // global replace flag
|
||||||
#if ENABLE_FEATURE_VI_UNDO
|
# if ENABLE_FEATURE_VI_UNDO
|
||||||
int dont_chain_first_item = ALLOW_UNDO;
|
int dont_chain_first_item = ALLOW_UNDO;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
// F points to the "find" pattern
|
// F points to the "find" pattern
|
||||||
// R points to the "replace" pattern
|
// R points to the "replace" pattern
|
||||||
@ -1442,9 +1448,9 @@ static void colon(char *buf)
|
|||||||
// we found the "find" pattern - delete it
|
// we found the "find" pattern - delete it
|
||||||
// For undo support, the first item should not be chained
|
// For undo support, the first item should not be chained
|
||||||
text_hole_delete(found, found + len_F - 1, dont_chain_first_item);
|
text_hole_delete(found, found + len_F - 1, dont_chain_first_item);
|
||||||
#if ENABLE_FEATURE_VI_UNDO
|
# if ENABLE_FEATURE_VI_UNDO
|
||||||
dont_chain_first_item = ALLOW_UNDO_CHAIN;
|
dont_chain_first_item = ALLOW_UNDO_CHAIN;
|
||||||
#endif
|
# endif
|
||||||
// insert the "replace" patern
|
// insert the "replace" patern
|
||||||
bias = string_insert(found, R, ALLOW_UNDO_CHAIN);
|
bias = string_insert(found, R, ALLOW_UNDO_CHAIN);
|
||||||
found += bias;
|
found += bias;
|
||||||
@ -1460,7 +1466,7 @@ static void colon(char *buf)
|
|||||||
}
|
}
|
||||||
q = next_line(ls);
|
q = next_line(ls);
|
||||||
}
|
}
|
||||||
#endif /* FEATURE_VI_SEARCH */
|
# endif /* FEATURE_VI_SEARCH */
|
||||||
} else if (strncmp(cmd, "version", i) == 0) { // show software version
|
} else if (strncmp(cmd, "version", i) == 0) { // show software version
|
||||||
status_line(BB_VER);
|
status_line(BB_VER);
|
||||||
} else if (strncmp(cmd, "write", i) == 0 // write text to file
|
} else if (strncmp(cmd, "write", i) == 0 // write text to file
|
||||||
@ -1475,12 +1481,12 @@ static void colon(char *buf)
|
|||||||
if (args[0]) {
|
if (args[0]) {
|
||||||
fn = args;
|
fn = args;
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_VI_READONLY
|
# if ENABLE_FEATURE_VI_READONLY
|
||||||
if (readonly_mode && !useforce) {
|
if (readonly_mode && !useforce) {
|
||||||
status_line_bold("'%s' is read only", fn);
|
status_line_bold("'%s' is read only", fn);
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
//if (useforce) {
|
//if (useforce) {
|
||||||
// if "fn" is not write-able, chmod u+w
|
// if "fn" is not write-able, chmod u+w
|
||||||
// sprintf(syscmd, "chmod u+w %s", fn);
|
// sprintf(syscmd, "chmod u+w %s", fn);
|
||||||
@ -1520,7 +1526,7 @@ static void colon(char *buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_VI_YANKMARK
|
# if ENABLE_FEATURE_VI_YANKMARK
|
||||||
} else if (strncmp(cmd, "yank", i) == 0) { // yank lines
|
} else if (strncmp(cmd, "yank", i) == 0) { // yank lines
|
||||||
if (b < 0) { // no addr given- use defaults
|
if (b < 0) { // no addr given- use defaults
|
||||||
q = begin_line(dot); // assume .,. for the range
|
q = begin_line(dot); // assume .,. for the range
|
||||||
@ -1530,7 +1536,7 @@ static void colon(char *buf)
|
|||||||
li = count_lines(q, r);
|
li = count_lines(q, r);
|
||||||
status_line("Yank %d lines (%d chars) into [%c]",
|
status_line("Yank %d lines (%d chars) into [%c]",
|
||||||
li, strlen(reg[YDreg]), what_reg());
|
li, strlen(reg[YDreg]), what_reg());
|
||||||
#endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
// cmd unknown
|
// cmd unknown
|
||||||
not_implemented(cmd);
|
not_implemented(cmd);
|
||||||
@ -1538,10 +1544,10 @@ static void colon(char *buf)
|
|||||||
ret:
|
ret:
|
||||||
dot = bound_dot(dot); // make sure "dot" is valid
|
dot = bound_dot(dot); // make sure "dot" is valid
|
||||||
return;
|
return;
|
||||||
#if ENABLE_FEATURE_VI_SEARCH
|
# if ENABLE_FEATURE_VI_SEARCH
|
||||||
colon_s_fail:
|
colon_s_fail:
|
||||||
status_line(":s expression missing delimiters");
|
status_line(":s expression missing delimiters");
|
||||||
#endif
|
# endif
|
||||||
#endif /* FEATURE_VI_COLON */
|
#endif /* FEATURE_VI_COLON */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user