Hi Karthick!

On Sa, 27 Okt 2012, Karthick wrote:

> Hello,
> 
> On the input pattern:
> ,,X
> 
> ..the following substitute command,
>    %s;\(^\|,\)\ze\(,\|X\);\1N;gc
> 
> ..changes it to (type 'y' for all prompts):
> N,N,NX
> 
> As expected. But if you type 'a' instead (for replace all), you get:
> N,,NX
> 
> Executing
>    %s;\(^\|,\)\ze\(,\|X\);\1N;g
> behaves the same as typing 'a' with confirmation.
> 
> Another user (Marcin Szamotulski) adds:
> Also the following pattern is behaving in this way:
> %s;\(^\|,\)\(,\|X\)\@=;\1N;gc
> 
> :version
> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May  4 2012 04:10:13)
> Included patches: 1-429
> Modified by <removed email address>
> Compiled by buildd@
> Huge version with GTK2 GUI.  Features included (+) or not (-):
> +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
> +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
> +conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff
> +digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi
> +file_in_path +find_in_path +float +folding -footer +fork() +gettext
> -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall
> +linebreak +lispindent +listcmds +localmap +lua +menu +mksession +modify_fname
> +mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm
> -mouse_sysmouse +mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme
> +netbeans_intg +path_extra +perl +persistent_undo +postscript +printer 
> +profile
>  +python -python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs
> +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
> +tag_old_static -tag_any_white +tcl +terminfo +termresponse +textobjects 
> +title
>  +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
> +vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim
> +xsmp_interact +xterm_clipboard -xterm_save
>    system vimrc file: "$VIM/vimrc"
>      user vimrc file: "$HOME/.vimrc"
>       user exrc file: "$HOME/.exrc"
>   system gvimrc file: "$VIM/gvimrc"
>     user gvimrc file: "$HOME/.gvimrc"
>     system menu file: "$VIMRUNTIME/menu.vim"
>   fall-back for $VIM: "/usr/share/vim"
> Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
> -pthread -I/usr/include/gtk-2.0
> -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0
> -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0
> -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/
> -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include
> -I/usr/include/pixman-1 -I/usr/include/freetype2
> -I/usr/include/libpng12     -g -O2 -fstack-protector
> --param=ssp-buffer-size=4 -Wformat -Wformat-security
> -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
> -I/usr/include/tcl8.5  -D_REENTRANT=1  -D_THREAD_SAFE=1
> -D_LARGEFILE64_SOURCE=1
> Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic
> -Wl,-export-dynamic  -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro
> -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
> -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo
> -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0   -lSM
> -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl  -lselinux
>  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.1  -Wl,-E
> -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.14/CORE -lperl
> -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config -lpython2.7
> -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1
> -Wl,-Bsymbolic-functions  -L/usr/lib -ltcl8.5 -ldl -lpthread -lieee
> -lm -lruby1.8 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib   -- INSERT
> ---- INSERT --

Attached patch fixes this issue and includes a test. However the 
substitute() function is also effected but so far, I haven't had luck 
fixing the do_string_sub() function in eval.c

regards,
Christian
-- 

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -4267,6 +4267,7 @@
 #ifdef FEAT_EVAL
     int         save_ma = 0;
 #endif
+    int		did_skip = FALSE;
 
     cmd = eap->arg;
     if (!global_busy)
@@ -4645,13 +4646,21 @@
 #endif
 			    ++matchcol;
 		    }
+		    did_skip = TRUE;
 		    goto skip;
 		}
 
 		/* Normally we continue searching for a match just after the
 		 * previous match. */
+		if (did_skip)
+		{
+		    regmatch.endpos[0].col = regmatch.startpos[0].col;
+		    copycol++; /* remember, we are looking one column further */
+		}
+
 		matchcol = regmatch.endpos[0].col;
 		prev_matchcol = matchcol;
+		did_skip = FALSE;
 
 		/*
 		 * 2. If do_count is set only increase the counter.
diff --git a/src/testdir/test80.in b/src/testdir/test80.in
--- a/src/testdir/test80.in
+++ b/src/testdir/test80.in
@@ -144,6 +144,17 @@
 TEST_8:
 
 STARTTEST
+:set magic&
+:set cpo&
+:$put =\"\n\nTEST_8:\"
+:$put =',,X'
+:s/\(^\|,\)\ze\(,\|X\)/\1N/g
+/^TEST_9
+ENDTEST
+
+TEST_9:
+
+STARTTEST
 :/^Results/,$wq! test.out
 ENDTEST
 
diff --git a/src/testdir/test80.ok b/src/testdir/test80.ok
--- a/src/testdir/test80.ok
+++ b/src/testdir/test80.ok
@@ -99,3 +99,7 @@
 A
A
 B
 B
+
+
+TEST_8:
+N,N,NX

Raspunde prin e-mail lui