[BusyBox] Patch adds standard '-ccmd' option vi.c
Brent Roman
brent at mbari.org
Tue Apr 1 05:46:25 UTC 2003
Hi,
I patched vi.c in busybox 0.60.5 to add the
standard vi/vim -c command option.
We use
it to bring up the editor at a specific line number
as in:
$ vi -c123 file.c
But, as with the standard vi, any : mode
command may follow the -c option.
It's a very small, staightforward patch that
adds a useful, standard feature.
I hope you'll consider adding it to the next release.
The command used to generate the diff was:
diff -bu vi.c busybox-0.60.5 >vi.diff
--
Brent Roman
mailto:brent at mbari.org http://www.mbari.org/~brent
-------------- next part --------------
--- vi.c Wed Feb 26 17:26:03 2003
+++ busybox-0.60.5/vi.c Sat Oct 26 03:19:07 2002
@@ -19,7 +19,7 @@
*/
static const char vi_Version[] =
- "$Id: vi.c,v 1.2 2003/02/27 01:26:03 brent Exp $";
+ "$Id: vi.c,v 1.19 2002/10/26 10:19:07 andersen Exp $";
/*
* To compile for standalone use:
@@ -264,7 +264,6 @@
static int mycmp(Byte *, Byte *, int); // string cmp based in "ignorecase"
#endif /* BB_FEATURE_VI_SEARCH */
#ifdef BB_FEATURE_VI_COLON
-static char *initialCmd = NULL; //remember arg of -c on cmd line if specified
static void Hit_Return(void);
static Byte *get_one_address(Byte *, int *); // get colon addr, if present
static Byte *get_address(Byte *, int *, int *); // get two colon addrs, if present
@@ -350,7 +349,7 @@
// 1- process $HOME/.exrc file
// 2- process EXINIT variable from environment
// 3- process command line args
- while ((c = getopt(argc, argv, "c:hCR")) != -1) {
+ while ((c = getopt(argc, argv, "hCR")) != -1) {
switch (c) {
#ifdef BB_FEATURE_VI_CRASHME
case 'C':
@@ -364,13 +363,7 @@
#endif /* BB_FEATURE_VI_READONLY */
//case 'r': // recover flag- ignore- we don't use tmp file
//case 'x': // encryption flag- ignore
-
-#ifdef BB_FEATURE_VI_COLON
- case 'c': // execute command first
- free (initialCmd); //ignore any previous -c args
- initialCmd = strdup (optarg);
- break;
-#endif
+ //case 'c': // execute command first
//case 'h': // help -- just use default
default:
show_help();
@@ -497,13 +490,13 @@
offset = 0; // no horizontal offset
c = '\0';
#ifdef BB_FEATURE_VI_DOT_CMD
+ if (last_modifying_cmd != 0)
free(last_modifying_cmd);
+ if (ioq_start != NULL)
free(ioq_start);
ioq = ioq_start = last_modifying_cmd = 0;
adding2q = 0;
#endif /* BB_FEATURE_VI_DOT_CMD */
-
- if (initialCmd) colon(initialCmd); //run initial command just before main loop
redraw(FALSE); // dont force every col re-draw
show_status_line();
@@ -2995,15 +2988,13 @@
"\n\tLine marking with 'x"
"\n\tNamed buffers with \"x"
#endif /* BB_FEATURE_VI_YANKMARK */
-#ifdef BB_FEATURE_VI_SET
- "\n\tSome colon mode commands with \':\'"
-#ifdef BB_FEATURE_VI_COLON
- "\n\t & after -c cmd line arg"
-#endif /* BB_FEATURE_VI_COLON */
-#endif /* BB_FEATURE_VI_SET */
#ifdef BB_FEATURE_VI_READONLY
+ "\n\tReadonly if vi is called as \"view\""
"\n\tReadonly with -R command line arg"
#endif /* BB_FEATURE_VI_READONLY */
+#ifdef BB_FEATURE_VI_SET
+ "\n\tSome colon mode commands with \':\'"
+#endif /* BB_FEATURE_VI_SET */
#ifdef BB_FEATURE_VI_SETOPTS
"\n\tSettable options with \":set\""
#endif /* BB_FEATURE_VI_SETOPTS */
More information about the busybox
mailing list