comparison src/eval.c @ 445:c773cb978acf v7.0116

updated for version 7.0116
author vimboss
date Mon, 25 Jul 2005 20:46:57 +0000
parents a1c5a6cb2675
children 7472c565592a
comparison
equal deleted inserted replaced
444:d0d15b184c56 445:c773cb978acf
12722 } 12722 }
12723 12723
12724 #define SP_NOMOVE 1 /* don't move cursor */ 12724 #define SP_NOMOVE 1 /* don't move cursor */
12725 #define SP_REPEAT 2 /* repeat to find outer pair */ 12725 #define SP_REPEAT 2 /* repeat to find outer pair */
12726 #define SP_RETCOUNT 4 /* return matchcount */ 12726 #define SP_RETCOUNT 4 /* return matchcount */
12727 #define SP_SETPCMARK 8 /* set previous context mark */
12727 12728
12728 static int get_search_arg __ARGS((typval_T *varp, int *flagsp)); 12729 static int get_search_arg __ARGS((typval_T *varp, int *flagsp));
12729 12730
12730 /* 12731 /*
12731 * Get flags for a search function. 12732 * Get flags for a search function.
12759 switch (*flags) 12760 switch (*flags)
12760 { 12761 {
12761 case 'n': mask = SP_NOMOVE; break; 12762 case 'n': mask = SP_NOMOVE; break;
12762 case 'r': mask = SP_REPEAT; break; 12763 case 'r': mask = SP_REPEAT; break;
12763 case 'm': mask = SP_RETCOUNT; break; 12764 case 'm': mask = SP_RETCOUNT; break;
12765 case 's': mask = SP_SETPCMARK; break;
12764 } 12766 }
12765 if (mask == 0) 12767 if (mask == 0)
12766 { 12768 {
12767 EMSG2(_(e_invarg2), flags); 12769 EMSG2(_(e_invarg2), flags);
12768 dir = 0; 12770 dir = 0;
12797 12799
12798 pat = get_tv_string(&argvars[0]); 12800 pat = get_tv_string(&argvars[0]);
12799 dir = get_search_arg(&argvars[1], &flags); /* may set p_ws */ 12801 dir = get_search_arg(&argvars[1], &flags); /* may set p_ws */
12800 if (dir == 0) 12802 if (dir == 0)
12801 goto theend; 12803 goto theend;
12802 if ((flags & ~SP_NOMOVE) != 0) 12804 /*
12805 * This function accepts only SP_NOMOVE and SP_SETPCMARK flags.
12806 * Check to make sure only those flags are set.
12807 * Also, Only the SP_NOMOVE or the SP_SETPCMARK flag can be set. Both
12808 * flags cannot be set. Check for that condition also.
12809 */
12810 if (((flags & ~(SP_NOMOVE | SP_SETPCMARK)) != 0) ||
12811 ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)))
12803 { 12812 {
12804 EMSG2(_(e_invarg2), get_tv_string(&argvars[1])); 12813 EMSG2(_(e_invarg2), get_tv_string(&argvars[1]));
12805 goto theend; 12814 goto theend;
12806 } 12815 }
12807 12816
12808 pos = save_cursor = curwin->w_cursor; 12817 pos = save_cursor = curwin->w_cursor;
12809 if (searchit(curwin, curbuf, &pos, dir, pat, 1L, 12818 if (searchit(curwin, curbuf, &pos, dir, pat, 1L,
12810 SEARCH_KEEP, RE_SEARCH) != FAIL) 12819 SEARCH_KEEP, RE_SEARCH) != FAIL)
12811 { 12820 {
12812 rettv->vval.v_number = pos.lnum; 12821 rettv->vval.v_number = pos.lnum;
12822 if (flags & SP_SETPCMARK)
12823 setpcmark();
12813 curwin->w_cursor = pos; 12824 curwin->w_cursor = pos;
12814 /* "/$" will put the cursor after the end of the line, may need to 12825 /* "/$" will put the cursor after the end of the line, may need to
12815 * correct that here */ 12826 * correct that here */
12816 check_cursor(); 12827 check_cursor();
12817 } 12828 }
12851 12862
12852 /* Handle the optional fourth argument: flags */ 12863 /* Handle the optional fourth argument: flags */
12853 dir = get_search_arg(&argvars[3], &flags); /* may set p_ws */ 12864 dir = get_search_arg(&argvars[3], &flags); /* may set p_ws */
12854 if (dir == 0) 12865 if (dir == 0)
12855 goto theend; 12866 goto theend;
12867 /*
12868 * Only one of the SP_NOMOVE or SP_SETPCMARK flags can be set.
12869 */
12870 if ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK))
12871 {
12872 EMSG2(_(e_invarg2), get_tv_string(&argvars[1]));
12873 goto theend;
12874 }
12856 12875
12857 /* Optional fifth argument: skip expresion */ 12876 /* Optional fifth argument: skip expresion */
12858 if (argvars[3].v_type == VAR_UNKNOWN 12877 if (argvars[3].v_type == VAR_UNKNOWN
12859 || argvars[4].v_type == VAR_UNKNOWN) 12878 || argvars[4].v_type == VAR_UNKNOWN)
12860 skip = (char_u *)""; 12879 skip = (char_u *)"";
12978 /* Found the match: return matchcount or line number. */ 12997 /* Found the match: return matchcount or line number. */
12979 if (flags & SP_RETCOUNT) 12998 if (flags & SP_RETCOUNT)
12980 ++retval; 12999 ++retval;
12981 else 13000 else
12982 retval = pos.lnum; 13001 retval = pos.lnum;
13002 if (flags & SP_SETPCMARK)
13003 setpcmark();
12983 curwin->w_cursor = pos; 13004 curwin->w_cursor = pos;
12984 if (!(flags & SP_REPEAT)) 13005 if (!(flags & SP_REPEAT))
12985 break; 13006 break;
12986 nest = 1; /* search for next unmatched */ 13007 nest = 1; /* search for next unmatched */
12987 } 13008 }