Updates from both Vladimir and Larry
[oweals/busybox.git] / vi.c
diff --git a/vi.c b/vi.c
index 54f1d265cdaf4339217bc4735044ec310e593ec8..6d15029667d053f0eac43619d32d42ab1d19093d 100644 (file)
--- a/vi.c
+++ b/vi.c
@@ -19,7 +19,7 @@
  */
 
 char *vi_Version =
-       "$Id: vi.c,v 1.6 2001/05/07 17:37:43 andersen Exp $";
+       "$Id: vi.c,v 1.8 2001/05/13 00:48:09 andersen Exp $";
 
 /*
  * To compile for standalone use:
@@ -1760,9 +1760,10 @@ static void colon(Byte * buf)
        while (isblnk(*buf))
                buf++;
        strcpy((char *) args, (char *) buf);
-       if (last_char_is((char *)cmd, '!')) {
+       buf1 = last_char_is((char *)cmd, '!');
+       if (buf1) {
                useforce = TRUE;
-               cmd[strlen((char *) cmd) - 1] = '\0';   // get rid of !
+               *buf1 = '\0';   // get rid of !
        }
        if (b >= 0) {
                // if there is only one addr, then the addr
@@ -2075,8 +2076,10 @@ static void colon(Byte * buf)
                c = orig_buf[1];        // what is the delimiter
                F = orig_buf + 2;       // start of "find"
                R = (Byte *) strchr((char *) F, c);     // middle delimiter
+               if (!R) goto colon_s_fail;
                *R++ = '\0';    // terminate "find"
                buf1 = (Byte *) strchr((char *) R, c);
+               if (!buf1) goto colon_s_fail;
                *buf1++ = '\0'; // terminate "replace"
                if (*buf1 == 'g') {     // :s/foo/bar/g
                        buf1++;
@@ -2167,6 +2170,12 @@ static void colon(Byte * buf)
   vc1:
        dot = bound_dot(dot);   // make sure "dot" is valid
        return;
+#ifdef BB_FEATURE_VI_SEARCH
+colon_s_fail:
+       psb(":s expression missing delimiters");
+       return;
+#endif
+
 }
 
 static void Hit_Return(void)
@@ -3919,9 +3928,11 @@ static void refresh(int full_screen)
                }
        }
 
-       place_cursor(crow, ccol, (crow == last_row) ? TRUE : FALSE);
 #ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR
+       place_cursor(crow, ccol, (crow == last_row) ? TRUE : FALSE);
        last_row = crow;
+#else
+       place_cursor(crow, ccol, FALSE);
 #endif                                                 /* BB_FEATURE_VI_OPTIMIZE_CURSOR */
        
        if (offset != old_offset)