[Patch] Add command ":wn" to vi-applet
Bernhard Fischer
rep.nop at aon.at
Thu Mar 23 22:15:58 UTC 2006
On Thu, Mar 23, 2006 at 06:42:09PM +0100, Alexander Griesser wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>I don't know if you want this feature in the current vi release, I think
>the difference in sizes with this patch applied isn't that dramatically
>and I really like :wn ;)
>
>OLD:
> text data bss dec hex filename
> 20429 4 924 21357 536d vi.o
>
>NEW:
> text data bss dec hex filename
> 20456 4 924 21384 5388 vi.o
The patch you sent doesn't apply. The *.no. variants are your patch,
the smaller ones (the busybox.vi-add_wn.01_02.diff) would add a byte
less, fwiw.
text data bss dec hex filename
01_02 alone:
20403 4 924 21331 5353 editors/vi.o.orig-4.0
20430 4 924 21358 536e editors/vi.o.no-4.0
20429 4 924 21357 536d editors/vi.o-4.0
19823 4 816 20643 50a3 editors/vi.o.orig-4.2
19850 4 816 20670 50be editors/vi.o.no-4.2
19849 4 816 20669 50bd editors/vi.o-4.2
both 01_02 and 02_02
20393 4 924 21321 5349 editors/vi.o-4.0-svn-version
19825 4 816 20645 50a5 editors/vi.o-4.2-svn-version
I'd drop the :version altogether, but the busybox.vi-add_wn.02_02.diff
at least doesn't use the now obsolete CVS $ID: $ stuff but the actual
busybox version and build-date.
I don't want to know why there are *two* places which check for the very
same "wq" (with strncasecmp) and i didn't look..
Not sure who feels responsible for vi, but i certainly like :wn
-------------- next part --------------
Index: editors/vi.c
===================================================================
--- editors/vi.c (revision 14631)
+++ editors/vi.c (working copy)
@@ -1085,7 +1085,9 @@
} else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version
psb("%s", vi_Version);
} else if ((strncasecmp((char *) cmd, "write", i) == 0) || // write text to file
- (strncasecmp((char *) cmd, "wq", i) == 0) ||
+ (i==2&&((cmd[0]=='w'||cmd[0]=='W')
+ &&(cmd[1]=='q'||cmd[1]=='Q'||cmd[1]=='n'||cmd[1]=='N'))
+ ) ||
(strncasecmp((char *) cmd, "x", i) == 0)) {
// is there a file name to write to?
if (strlen((char *) args) > 0) {
@@ -1123,7 +1125,7 @@
file_modified = 0;
last_file_modified = -1;
}
- if ((cmd[0] == 'x' || cmd[1] == 'q') && l == ch) {
+ if ((cmd[0] == 'x' || cmd[1] == 'q' || cmd[1] == 'n') && l == ch) {
editing = 0;
}
}
@@ -3433,7 +3435,9 @@
editing = 0;
}
} else if (strncasecmp((char *) p, "write", cnt) == 0 ||
- strncasecmp((char *) p, "wq", cnt) == 0 ||
+ (i==2&&((cmd[0]=='w'||cmd[0]=='W')
+ &&(cmd[1]=='q'||cmd[1]=='Q'||cmd[1]=='n'||cmd[1]=='N'))
+ ) ||
strncasecmp((char *) p, "x", cnt) == 0) {
cnt = file_write(cfn, text, end - 1);
if (cnt < 0) {
@@ -3443,7 +3447,7 @@
file_modified = 0;
last_file_modified = -1;
psb("\"%s\" %dL, %dC", cfn, count_lines(text, end - 1), cnt);
- if (p[0] == 'x' || p[1] == 'q') {
+ if (p[0] == 'x' || p[1] == 'q' || p[1] == 'n') {
editing = 0;
}
}
-------------- next part --------------
Index: editors/vi.c
===================================================================
--- editors/vi.c (revision 14631)
+++ editors/vi.c (working copy)
@@ -3,24 +3,9 @@
* tiny vi.c: A small 'vi' clone
* Copyright (C) 2000, 2001 Sterling Huxley <sterling at europa.com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
-static const char vi_Version[] =
- "$Id: vi.c,v 1.38 2004/08/19 19:15:06 andersen Exp $";
-
/*
* To compile for standalone use:
* gcc -Wall -Os -s -DSTANDALONE -o vi vi.c
@@ -85,6 +70,9 @@
#include <stdarg.h>
#ifndef STANDALONE
#include "busybox.h"
+#define vi_Version BB_VER " " BB_BT
+#else
+#define vi_Version "standalone"
#endif /* STANDALONE */
#ifdef CONFIG_LOCALE_SUPPORT
More information about the busybox
mailing list