Mercurial > vim
comparison src/regexp.c @ 639:c79d4df4686e
updated for version 7.0185
author | vimboss |
---|---|
date | Sun, 22 Jan 2006 23:25:56 +0000 |
parents | a1059cda45f2 |
children | 5acda076fb0c |
comparison
equal
deleted
inserted
replaced
638:593092a5362b | 639:c79d4df4686e |
---|---|
226 #define CURSOR 203 /* Match location of cursor. */ | 226 #define CURSOR 203 /* Match location of cursor. */ |
227 | 227 |
228 #define RE_LNUM 204 /* nr cmp Match line number */ | 228 #define RE_LNUM 204 /* nr cmp Match line number */ |
229 #define RE_COL 205 /* nr cmp Match column number */ | 229 #define RE_COL 205 /* nr cmp Match column number */ |
230 #define RE_VCOL 206 /* nr cmp Match virtual column number */ | 230 #define RE_VCOL 206 /* nr cmp Match virtual column number */ |
231 | |
232 #define RE_MARK 207 /* mark cmp Match mark position */ | |
233 #define RE_VISUAL 208 /* Match Visual area */ | |
231 | 234 |
232 /* | 235 /* |
233 * Magic characters have a special meaning, they don't match literally. | 236 * Magic characters have a special meaning, they don't match literally. |
234 * Magic characters are negative. This separates them from literal characters | 237 * Magic characters are negative. This separates them from literal characters |
235 * (possibly multi-byte). Only ASCII characters can be Magic. | 238 * (possibly multi-byte). Only ASCII characters can be Magic. |
1835 | 1838 |
1836 case '#': | 1839 case '#': |
1837 ret = regnode(CURSOR); | 1840 ret = regnode(CURSOR); |
1838 break; | 1841 break; |
1839 | 1842 |
1843 case 'V': | |
1844 ret = regnode(RE_VISUAL); | |
1845 break; | |
1846 | |
1840 /* \%[abc]: Emit as a list of branches, all ending at the last | 1847 /* \%[abc]: Emit as a list of branches, all ending at the last |
1841 * branch which matches nothing. */ | 1848 * branch which matches nothing. */ |
1842 case '[': | 1849 case '[': |
1843 if (one_exactly) /* doesn't nest */ | 1850 if (one_exactly) /* doesn't nest */ |
1844 EMSG_ONE_RET_NULL; | 1851 EMSG_ONE_RET_NULL; |
1927 *flagp |= HASWIDTH; | 1934 *flagp |= HASWIDTH; |
1928 break; | 1935 break; |
1929 } | 1936 } |
1930 | 1937 |
1931 default: | 1938 default: |
1932 if (VIM_ISDIGIT(c) || c == '<' || c == '>') | 1939 if (VIM_ISDIGIT(c) || c == '<' || c == '>' |
1940 || c == '\'') | |
1933 { | 1941 { |
1934 long_u n = 0; | 1942 long_u n = 0; |
1935 int cmp; | 1943 int cmp; |
1936 | 1944 |
1937 cmp = c; | 1945 cmp = c; |
1940 while (VIM_ISDIGIT(c)) | 1948 while (VIM_ISDIGIT(c)) |
1941 { | 1949 { |
1942 n = n * 10 + (c - '0'); | 1950 n = n * 10 + (c - '0'); |
1943 c = getchr(); | 1951 c = getchr(); |
1944 } | 1952 } |
1945 if (c == 'l' || c == 'c' || c == 'v') | 1953 if (c == '\'' && n == 0) |
1954 { | |
1955 /* "\%'m", "\%<'m" and "\%>'m": Mark */ | |
1956 c = getchr(); | |
1957 ret = regnode(RE_MARK); | |
1958 if (ret == JUST_CALC_SIZE) | |
1959 regsize += 2; | |
1960 else | |
1961 { | |
1962 *regcode++ = c; | |
1963 *regcode++ = cmp; | |
1964 } | |
1965 break; | |
1966 } | |
1967 else if (c == 'l' || c == 'c' || c == 'v') | |
1946 { | 1968 { |
1947 if (c == 'l') | 1969 if (c == 'l') |
1948 ret = regnode(RE_LNUM); | 1970 ret = regnode(RE_LNUM); |
1949 else if (c == 'c') | 1971 else if (c == 'c') |
1950 ret = regnode(RE_COL); | 1972 ret = regnode(RE_COL); |
3783 || (reglnum + reg_firstlnum != reg_win->w_cursor.lnum) | 3805 || (reglnum + reg_firstlnum != reg_win->w_cursor.lnum) |
3784 || ((colnr_T)(reginput - regline) != reg_win->w_cursor.col)) | 3806 || ((colnr_T)(reginput - regline) != reg_win->w_cursor.col)) |
3785 status = RA_NOMATCH; | 3807 status = RA_NOMATCH; |
3786 break; | 3808 break; |
3787 | 3809 |
3810 case RE_MARK: | |
3811 /* Compare the mark position to the match position. NOTE: Always | |
3812 * uses the current buffer. */ | |
3813 { | |
3814 int mark = OPERAND(scan)[0]; | |
3815 int cmp = OPERAND(scan)[1]; | |
3816 pos_T *pos; | |
3817 | |
3818 pos = getmark(mark, FALSE); | |
3819 if (pos == NULL /* mark doesn't exist) */ | |
3820 || pos->lnum <= 0 /* mark isn't set (in curbuf) */ | |
3821 || (pos->lnum == reglnum + reg_firstlnum | |
3822 ? (pos->col == (colnr_T)(reginput - regline) | |
3823 ? (cmp == '<' || cmp == '>') | |
3824 : (pos->col < (colnr_T)(reginput - regline) | |
3825 ? cmp != '>' | |
3826 : cmp != '<')) | |
3827 : (pos->lnum < reglnum + reg_firstlnum | |
3828 ? cmp != '>' | |
3829 : cmp != '<'))) | |
3830 status = RA_NOMATCH; | |
3831 } | |
3832 break; | |
3833 | |
3834 case RE_VISUAL: | |
3835 #ifdef FEAT_VISUAL | |
3836 /* Check if the buffer is the current buffer. and whether the | |
3837 * position is inside the Visual area. */ | |
3838 if (reg_buf != curbuf || VIsual.lnum == 0) | |
3839 status = RA_NOMATCH; | |
3840 else | |
3841 { | |
3842 pos_T top, bot; | |
3843 linenr_T lnum; | |
3844 colnr_T col; | |
3845 win_T *wp = reg_win == NULL ? curwin : reg_win; | |
3846 int mode; | |
3847 | |
3848 if (VIsual_active) | |
3849 { | |
3850 if (lt(VIsual, wp->w_cursor)) | |
3851 { | |
3852 top = VIsual; | |
3853 bot = wp->w_cursor; | |
3854 } | |
3855 else | |
3856 { | |
3857 top = wp->w_cursor; | |
3858 bot = VIsual; | |
3859 } | |
3860 mode = VIsual_mode; | |
3861 } | |
3862 else | |
3863 { | |
3864 top = curbuf->b_visual_start; | |
3865 bot = curbuf->b_visual_end; | |
3866 mode = curbuf->b_visual_mode; | |
3867 } | |
3868 lnum = reglnum + reg_firstlnum; | |
3869 col = (colnr_T)(reginput - regline); | |
3870 if (lnum < top.lnum || lnum > bot.lnum) | |
3871 status = RA_NOMATCH; | |
3872 else if (mode == 'v') | |
3873 { | |
3874 if ((lnum == top.lnum && col < top.col) | |
3875 || (lnum == bot.lnum | |
3876 && col >= bot.col + (*p_sel != 'e'))) | |
3877 status = RA_NOMATCH; | |
3878 } | |
3879 else if (mode == Ctrl_V) | |
3880 { | |
3881 colnr_T start, end; | |
3882 colnr_T start2, end2; | |
3883 colnr_T col; | |
3884 | |
3885 getvvcol(wp, &top, &start, NULL, &end); | |
3886 getvvcol(wp, &bot, &start2, NULL, &end2); | |
3887 if (start2 < start) | |
3888 start = start2; | |
3889 if (end2 > end) | |
3890 end = end2; | |
3891 if (top.col == MAXCOL || bot.col == MAXCOL) | |
3892 end = MAXCOL; | |
3893 col = win_linetabsize(wp, | |
3894 regline, (colnr_T)(reginput - regline)); | |
3895 if (col < start || col > end - (*p_sel == 'e')) | |
3896 status = RA_NOMATCH; | |
3897 } | |
3898 } | |
3899 #else | |
3900 status = RA_NOMATCH; | |
3901 #endif | |
3902 break; | |
3903 | |
3788 case RE_LNUM: | 3904 case RE_LNUM: |
3789 if (!REG_MULTI || !re_num_cmp((long_u)(reglnum + reg_firstlnum), | 3905 if (!REG_MULTI || !re_num_cmp((long_u)(reglnum + reg_firstlnum), |
3790 scan)) | 3906 scan)) |
3791 status = RA_NOMATCH; | 3907 status = RA_NOMATCH; |
3792 break; | 3908 break; |
5786 p = "EOF"; | 5902 p = "EOF"; |
5787 break; | 5903 break; |
5788 case CURSOR: | 5904 case CURSOR: |
5789 p = "CURSOR"; | 5905 p = "CURSOR"; |
5790 break; | 5906 break; |
5907 case RE_VISUAL: | |
5908 p = "RE_VISUAL"; | |
5909 break; | |
5791 case RE_LNUM: | 5910 case RE_LNUM: |
5792 p = "RE_LNUM"; | 5911 p = "RE_LNUM"; |
5912 break; | |
5913 case RE_MARK: | |
5914 p = "RE_MARK"; | |
5793 break; | 5915 break; |
5794 case RE_COL: | 5916 case RE_COL: |
5795 p = "RE_COL"; | 5917 p = "RE_COL"; |
5796 break; | 5918 break; |
5797 case RE_VCOL: | 5919 case RE_VCOL: |