svn commit: trunk/busybox/editors

vda at busybox.net vda at busybox.net
Wed Oct 29 00:58:05 UTC 2008


Author: vda
Date: 2008-10-28 17:58:04 -0700 (Tue, 28 Oct 2008)
New Revision: 23839

Log:
vi: fix uninitialized last_search_pattern (bug 5794)



Modified:
   trunk/busybox/editors/vi.c


Changeset:
Modified: trunk/busybox/editors/vi.c
===================================================================
--- trunk/busybox/editors/vi.c	2008-10-29 00:27:31 UTC (rev 23838)
+++ trunk/busybox/editors/vi.c	2008-10-29 00:58:04 UTC (rev 23839)
@@ -270,6 +270,7 @@
 #define INIT_G() do { \
 	SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
 	last_file_modified = -1; \
+	last_search_pattern = xzalloc(2); /* "" but has space for 2 chars */ \
 } while (0)
 
 
@@ -2857,7 +2858,7 @@
 	const char *msg = msg; // for compiler
 	char *p, *q, *save_dot;
 	char buf[12];
-	int dir = dir; // for compiler
+	int dir;
 	int cnt, i, j;
 	int c1;
 
@@ -3196,7 +3197,7 @@
 		q = get_input_line(buf);	// get input line- use "status line"
 		if (q[0] && !q[1]) {
 			if (last_search_pattern[0])
-			    last_search_pattern[0] = c;
+				last_search_pattern[0] = c;
 			goto dc3; // if no pat re-use old pat
 		}
 		if (q[0]) {       // strlen(q) > 1: new pat- save it and find
@@ -3226,14 +3227,8 @@
 			do_cmd(c);
 		}				// repeat cnt
  dc3:
-		if (last_search_pattern == 0) {
-			msg = "No previous regular expression";
-			goto dc2;
-		}
-		if (last_search_pattern[0] == '/') {
-			dir = FORWARD;	// assume FORWARD search
-			p = dot + 1;
-		}
+		dir = FORWARD;	// assume FORWARD search
+		p = dot + 1;
 		if (last_search_pattern[0] == '?') {
 			dir = BACK;
 			p = dot - 1;




More information about the busybox-cvs mailing list