To: vim-dev@vim.org Subject: Patch 6.1.355 (fixed!) Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ [The previously posted patch 6.1.355 contained an error. Use this one instead. If you did include it already, first back out that one (use "patch -R b_p_inf) p_scs = FALSE; ! regmatch.regprog = vim_regcomp(pat, (int)p_magic); /* ignore case depends on 'ignorecase', 'smartcase' and "pat" */ regmatch.rm_ic = ignorecase(pat); while (buf != NULL && regmatch.regprog != NULL && *dict != NUL --- 2071,2077 ---- save_p_scs = p_scs; if (curbuf->b_p_inf) p_scs = FALSE; ! regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); /* ignore case depends on 'ignorecase', 'smartcase' and "pat" */ regmatch.rm_ic = ignorecase(pat); while (buf != NULL && regmatch.regprog != NULL && *dict != NUL *** ../vim61.354/src/eval.c Thu Feb 20 21:36:44 2003 --- src/eval.c Mon Feb 17 20:53:42 2003 *************** *** 1669,1675 **** /* avoid 'l' flag in 'cpoptions' */ save_cpo = p_cpo; p_cpo = (char_u *)""; ! regmatch.regprog = vim_regcomp(s2, TRUE); regmatch.rm_ic = ic; if (regmatch.regprog != NULL) { --- 1669,1676 ---- /* avoid 'l' flag in 'cpoptions' */ save_cpo = p_cpo; p_cpo = (char_u *)""; ! regmatch.regprog = vim_regcomp(s2, ! RE_MAGIC + RE_STRING); regmatch.rm_ic = ic; if (regmatch.regprog != NULL) { *************** *** 5251,5257 **** str += start; } ! regmatch.regprog = vim_regcomp(pat, TRUE); if (regmatch.regprog != NULL) { regmatch.rm_ic = p_ic; --- 5258,5264 ---- str += start; } ! regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { regmatch.rm_ic = p_ic; *************** *** 9236,9242 **** do_all = (flags[0] == 'g'); regmatch.rm_ic = p_ic; ! regmatch.regprog = vim_regcomp(pat, TRUE); if (regmatch.regprog != NULL) { tail = str; --- 9243,9249 ---- do_all = (flags[0] == 'g'); regmatch.rm_ic = p_ic; ! regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { tail = str; *** ../vim61.354/src/ex_cmds2.c Sat Feb 1 16:43:17 2003 --- src/ex_cmds2.c Mon Feb 17 21:53:35 2003 *************** *** 348,354 **** pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE); if (pat != NULL) { ! bp->dbg_prog = vim_regcomp(pat, TRUE); vim_free(pat); } if (pat == NULL || bp->dbg_prog == NULL) --- 348,354 ---- pat = file_pat_to_reg_pat(bp->dbg_name, NULL, NULL, FALSE); if (pat != NULL) { ! bp->dbg_prog = vim_regcomp(pat, RE_MAGIC + RE_STRING); vim_free(pat); } if (pat == NULL || bp->dbg_prog == NULL) *************** *** 992,998 **** p = file_pat_to_reg_pat(p, NULL, NULL, FALSE); if (p == NULL) break; ! regmatch.regprog = vim_regcomp(p, (int)p_magic); if (regmatch.regprog == NULL) { vim_free(p); --- 994,1000 ---- p = file_pat_to_reg_pat(p, NULL, NULL, FALSE); if (p == NULL) break; ! regmatch.regprog = vim_regcomp(p, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) { vim_free(p); *** ../vim61.354/src/ex_docmd.c Sun Feb 16 22:49:44 2003 --- src/ex_docmd.c Sun Feb 23 11:56:13 2003 *************** *** 8976,8982 **** c = *end; *end = NUL; ! curwin->w_match.regprog = vim_regcomp(p + 1, TRUE); *end = c; if (curwin->w_match.regprog == NULL) { --- 8988,8994 ---- c = *end; *end = NUL; ! curwin->w_match.regprog = vim_regcomp(p + 1, RE_MAGIC); *end = c; if (curwin->w_match.regprog == NULL) { *** ../vim61.354/src/ex_getln.c Thu Feb 20 21:44:37 2003 --- src/ex_getln.c Sat Feb 22 12:36:16 2003 *************** *** 3234,3240 **** if (xp->xp_context == EXPAND_COMPILER) return ExpandRTDir(pat, num_file, file, "compiler"); ! regmatch.regprog = vim_regcomp(pat, (int)p_magic); if (regmatch.regprog == NULL) return FAIL; --- 3234,3240 ---- if (xp->xp_context == EXPAND_COMPILER) return ExpandRTDir(pat, num_file, file, "compiler"); ! regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) return FAIL; *************** *** 3889,3895 **** && histype < HIST_COUNT && *str != NUL && (idx = hisidx[histype]) >= 0 ! && (regmatch.regprog = vim_regcomp(str, TRUE)) != NULL) { i = last = idx; do --- 3889,3896 ---- && histype < HIST_COUNT && *str != NUL && (idx = hisidx[histype]) >= 0 ! && (regmatch.regprog = vim_regcomp(str, RE_MAGIC + RE_STRING)) ! != NULL) { i = last = idx; do *** ../vim61.354/src/fileio.c Sun Feb 16 21:55:12 2003 --- src/fileio.c Sat Feb 22 12:41:02 2003 *************** *** 7710,7720 **** no_pattern = TRUE; /* Always matches - don't check pat. */ } else ! regmatch.regprog = vim_regcomp(pattern + 1, TRUE); } else #endif ! regmatch.regprog = vim_regcomp(pattern, TRUE); /* * Try for a match with the pattern with: --- 7728,7738 ---- no_pattern = TRUE; /* Always matches - don't check pat. */ } else ! regmatch.regprog = vim_regcomp(pattern + 1, RE_MAGIC); } else #endif ! regmatch.regprog = vim_regcomp(pattern, RE_MAGIC); /* * Try for a match with the pattern with: *** ../vim61.354/src/misc1.c Wed Jan 29 22:08:43 2003 --- src/misc1.c Wed Feb 19 20:13:36 2003 *************** *** 6651,6657 **** /* compile the regexp into a program */ regmatch.rm_ic = TRUE; /* Always ignore case */ ! regmatch.regprog = vim_regcomp(pat, TRUE); vim_free(pat); if (regmatch.regprog == NULL) --- 6662,6668 ---- /* compile the regexp into a program */ regmatch.rm_ic = TRUE; /* Always ignore case */ ! regmatch.regprog = vim_regcomp(pat, RE_MAGIC); vim_free(pat); if (regmatch.regprog == NULL) *** ../vim61.354/src/option.c Wed Jan 29 22:08:43 2003 --- src/option.c Wed Feb 19 20:13:36 2003 *************** *** 5577,5583 **** else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) { p += 8; ! new_exclude_prog = vim_regcomp(p, TRUE); if (new_exclude_prog == NULL) errmsg = e_invarg; break; --- 5584,5590 ---- else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) { p += 8; ! new_exclude_prog = vim_regcomp(p, RE_MAGIC); if (new_exclude_prog == NULL) errmsg = e_invarg; break; *** ../vim61.354/src/os_mac.c Sat Feb 1 18:48:57 2003 --- src/os_mac.c Sun Feb 16 16:01:47 2003 *************** *** 151,157 **** /* compile the regexp into a program */ regmatch.rm_ic = FALSE; /* Don't ever ignore case */ ! regmatch.regprog = vim_regcomp(pat, TRUE); vim_free(pat); if (regmatch.regprog == NULL) --- 151,157 ---- /* compile the regexp into a program */ regmatch.rm_ic = FALSE; /* Don't ever ignore case */ ! regmatch.regprog = vim_regcomp(pat, RE_MAGIC); vim_free(pat); if (regmatch.regprog == NULL) *************** *** 390,396 **** #else regmatch.rm_ic = FALSE; /* Don't ever ignore case */ #endif ! regmatch.regprog = vim_regcomp(pat, TRUE); vim_free(pat); if (regmatch.regprog == NULL) --- 390,396 ---- #else regmatch.rm_ic = FALSE; /* Don't ever ignore case */ #endif ! regmatch.regprog = vim_regcomp(pat, RE_MAGIC); vim_free(pat); if (regmatch.regprog == NULL) *** ../vim61.354/src/os_unix.c Sat Feb 1 18:48:57 2003 --- src/os_unix.c Sun Feb 16 16:01:52 2003 *************** *** 4210,4216 **** #else regmatch.rm_ic = FALSE; /* Don't ever ignore case */ #endif ! regmatch.regprog = vim_regcomp(pat, TRUE); vim_free(pat); if (regmatch.regprog == NULL) --- 4210,4216 ---- #else regmatch.rm_ic = FALSE; /* Don't ever ignore case */ #endif ! regmatch.regprog = vim_regcomp(pat, RE_MAGIC); vim_free(pat); if (regmatch.regprog == NULL) *** ../vim61.354/src/quickfix.c Thu Jan 9 21:50:31 2003 --- src/quickfix.c Wed Feb 19 19:54:19 2003 *************** *** 402,408 **** } *ptr++ = '$'; *ptr = NUL; ! if ((fmt_ptr->prog = vim_regcomp(fmtstr, TRUE)) == NULL) goto error2; /* * Advance to next part --- 402,408 ---- } *ptr++ = '$'; *ptr = NUL; ! if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL) goto error2; /* * Advance to next part *** ../vim61.354/src/regexp.c Sun Feb 16 21:46:15 2003 --- src/regexp.c Sun Feb 16 16:10:21 2003 *************** *** 632,637 **** --- 632,640 ---- #define MAGIC_ON 3 /* "\m" or 'magic' */ #define MAGIC_ALL 4 /* "\v" very magic */ + static int reg_string; /* matching with a string instead of a buffer + line */ + /* * META contains all characters that may be magic, except '^' and '$'. */ *************** *** 675,681 **** static int peekchr __ARGS((void)); static void skipchr __ARGS((void)); static void ungetchr __ARGS((void)); ! static void regcomp_start __ARGS((char_u *expr, int magic)); static char_u *reg __ARGS((int, int *)); static char_u *regbranch __ARGS((int *flagp)); static char_u *regconcat __ARGS((int *flagp)); --- 678,684 ---- static int peekchr __ARGS((void)); static void skipchr __ARGS((void)); static void ungetchr __ARGS((void)); ! static void regcomp_start __ARGS((char_u *expr, int flags)); static char_u *reg __ARGS((int, int *)); static char_u *regbranch __ARGS((int *flagp)); static char_u *regconcat __ARGS((int *flagp)); *************** *** 790,800 **** * * Beware that the optimization-preparation code in here knows about some * of the structure of the compiled regexp. */ regprog_T * ! vim_regcomp(expr, magic) char_u *expr; ! int magic; { regprog_T *r; char_u *scan; --- 793,804 ---- * * Beware that the optimization-preparation code in here knows about some * of the structure of the compiled regexp. + * "re_flags": RE_MAGIC and/or RE_STRING. */ regprog_T * ! vim_regcomp(expr, re_flags) char_u *expr; ! int re_flags; { regprog_T *r; char_u *scan; *************** *** 810,816 **** /* * First pass: determine size, legality. */ ! regcomp_start(expr, magic); regcode = JUST_CALC_SIZE; regc(REGMAGIC); if (reg(REG_NOPAREN, &flags) == NULL) --- 814,820 ---- /* * First pass: determine size, legality. */ ! regcomp_start(expr, re_flags); regcode = JUST_CALC_SIZE; regc(REGMAGIC); if (reg(REG_NOPAREN, &flags) == NULL) *************** *** 830,836 **** /* * Second pass: emit code. */ ! regcomp_start(expr, magic); regcode = r->program; regc(REGMAGIC); if (reg(REG_NOPAREN, &flags) == NULL) --- 834,840 ---- /* * Second pass: emit code. */ ! regcomp_start(expr, re_flags); regcode = r->program; regc(REGMAGIC); if (reg(REG_NOPAREN, &flags) == NULL) *************** *** 924,938 **** * Setup to parse the regexp. Used once to get the length and once to do it. */ static void ! regcomp_start(expr, magic) char_u *expr; ! int magic; { initchr(expr); ! if (magic) reg_magic = MAGIC_ON; else reg_magic = MAGIC_OFF; num_complex_braces = 0; regnpar = 1; vim_memset(had_endbrace, 0, sizeof(had_endbrace)); --- 928,944 ---- * Setup to parse the regexp. Used once to get the length and once to do it. */ static void ! regcomp_start(expr, re_flags) char_u *expr; ! int re_flags; /* see vim_regcomp() */ { initchr(expr); ! if (re_flags & RE_MAGIC) reg_magic = MAGIC_ON; else reg_magic = MAGIC_OFF; + reg_string = (re_flags & RE_STRING); + num_complex_braces = 0; regnpar = 1; vim_memset(had_endbrace, 0, sizeof(had_endbrace)); *************** *** 1463,1470 **** break; case Magic('n'): ! ret = regnode(NEWL); ! *flagp |= HASWIDTH | HASNL; break; case Magic('('): --- 1469,1488 ---- break; case Magic('n'): ! if (reg_string) ! { ! /* In a string "\n" matches a newline character. */ ! ret = regnode(EXACTLY); ! regc(NL); ! regc(NUL); ! *flagp |= HASWIDTH | SIMPLE; ! } ! else ! { ! /* In buffer text "\n" matches the end of a line. */ ! ret = regnode(NEWL); ! *flagp |= HASWIDTH | HASNL; ! } break; case Magic('('): *************** *** 2340,2350 **** if (c == NUL) curchr = '\\'; /* trailing '\' */ #ifdef EBCDIC ! else if (vim_strchr(META, c)) #else ! else if (c <= '~' && META_flags[c]) #endif { /* * META contains everything that may be magic sometimes, --- 2358,2370 ---- if (c == NUL) curchr = '\\'; /* trailing '\' */ + else if ( #ifdef EBCDIC ! vim_strchr(META, c) #else ! c <= '~' && META_flags[c] #endif + ) { /* * META contains everything that may be magic sometimes, *** ../vim61.354/src/search.c Mon Nov 11 21:29:07 2002 --- src/search.c Sun Feb 16 16:03:55 2003 *************** *** 188,194 **** } regmatch->rmm_ic = ignorecase(pat); ! regmatch->regprog = vim_regcomp(pat, magic); if (regmatch->regprog == NULL) return FAIL; return OK; --- 188,194 ---- } regmatch->rmm_ic = ignorecase(pat); ! regmatch->regprog = vim_regcomp(pat, magic ? RE_MAGIC : 0); if (regmatch->regprog == NULL) return FAIL; return OK; *************** *** 3483,3489 **** sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr); /* ignore case according to p_ic, p_scs and pat */ regmatch.rm_ic = ignorecase(pat); ! regmatch.regprog = vim_regcomp(pat, (int)p_magic); vim_free(pat); if (regmatch.regprog == NULL) goto fpip_end; --- 3483,3489 ---- sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr); /* ignore case according to p_ic, p_scs and pat */ regmatch.rm_ic = ignorecase(pat); ! regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); vim_free(pat); if (regmatch.regprog == NULL) goto fpip_end; *************** *** 3491,3497 **** if (*curbuf->b_p_inc != NUL || *p_inc != NUL) { incl_regmatch.regprog = vim_regcomp(*curbuf->b_p_inc == NUL ! ? p_inc : curbuf->b_p_inc, (int)p_magic); if (incl_regmatch.regprog == NULL) goto fpip_end; incl_regmatch.rm_ic = FALSE; /* don't ignore case in incl. pat. */ --- 3491,3497 ---- if (*curbuf->b_p_inc != NUL || *p_inc != NUL) { incl_regmatch.regprog = vim_regcomp(*curbuf->b_p_inc == NUL ! ? p_inc : curbuf->b_p_inc, p_magic ? RE_MAGIC : 0); if (incl_regmatch.regprog == NULL) goto fpip_end; incl_regmatch.rm_ic = FALSE; /* don't ignore case in incl. pat. */ *************** *** 3499,3505 **** if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) { def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL ! ? p_def : curbuf->b_p_def, (int)p_magic); if (def_regmatch.regprog == NULL) goto fpip_end; def_regmatch.rm_ic = FALSE; /* don't ignore case in define pat. */ --- 3499,3505 ---- if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) { def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL ! ? p_def : curbuf->b_p_def, p_magic ? RE_MAGIC : 0); if (def_regmatch.regprog == NULL) goto fpip_end; def_regmatch.rm_ic = FALSE; /* don't ignore case in define pat. */ *** ../vim61.354/src/syntax.c Sun Oct 13 20:08:14 2002 --- src/syntax.c Sun Feb 16 16:04:40 2003 *************** *** 5102,5108 **** /* Make 'cpoptions' empty, to avoid the 'l' flag */ cpo_save = p_cpo; p_cpo = (char_u *)""; ! ci->sp_prog = vim_regcomp(ci->sp_pattern, TRUE); p_cpo = cpo_save; if (ci->sp_prog == NULL) --- 5104,5110 ---- /* Make 'cpoptions' empty, to avoid the 'l' flag */ cpo_save = p_cpo; p_cpo = (char_u *)""; ! ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC); p_cpo = cpo_save; if (ci->sp_prog == NULL) *************** *** 5283,5289 **** cpo_save = p_cpo; p_cpo = (char_u *)""; curbuf->b_syn_linecont_prog = ! vim_regcomp(curbuf->b_syn_linecont_pat, TRUE); p_cpo = cpo_save; if (curbuf->b_syn_linecont_prog == NULL) --- 5285,5291 ---- cpo_save = p_cpo; p_cpo = (char_u *)""; curbuf->b_syn_linecont_prog = ! vim_regcomp(curbuf->b_syn_linecont_pat, RE_MAGIC); p_cpo = cpo_save; if (curbuf->b_syn_linecont_prog == NULL) *************** *** 5435,5441 **** */ *name = '^'; STRCAT(name, "$"); ! regmatch.regprog = vim_regcomp(name, TRUE); if (regmatch.regprog == NULL) { failed = TRUE; --- 5437,5443 ---- */ *name = '^'; STRCAT(name, "$"); ! regmatch.regprog = vim_regcomp(name, RE_MAGIC); if (regmatch.regprog == NULL) { failed = TRUE; *** ../vim61.354/src/tag.c Thu Feb 20 21:40:42 2003 --- src/tag.c Sun Feb 16 16:05:01 2003 *************** *** 1057,1063 **** help_save = curbuf->b_help; if (has_re) ! regmatch.regprog = vim_regcomp(pat, p_magic); else regmatch.regprog = NULL; --- 1057,1063 ---- help_save = curbuf->b_help; if (has_re) ! regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); else regmatch.regprog = NULL; *** ../vim61.354/src/vim.h Sun Feb 16 20:29:05 2003 --- src/vim.h Sun Feb 16 15:57:09 2003 *************** *** 766,771 **** --- 766,775 ---- #define RE_BOTH 2 /* save pat in both patterns */ #define RE_LAST 2 /* use last used pattern if "pat" is NULL */ + /* Second argument for vim_regcomp(). */ + #define RE_MAGIC 1 /* 'magic' option */ + #define RE_STRING 2 /* match in string instead of buffer text */ + #ifdef FEAT_SYN_HL /* values for reg_do_extmatch */ # define REX_SET 1 /* to allow \z\(...\), */ *** ../vim61.354/src/version.c Sun Feb 23 17:14:04 2003 --- src/version.c Sun Feb 23 17:15:50 2003 *************** *** 608,609 **** --- 612,615 ---- { /* Add new patch number below this line */ + /**/ + 355, /**/ -- -rwxr-xr-x 1 root 24 Oct 29 1929 /bin/ed -rwxr-xr-t 4 root 131720 Jan 1 1970 /usr/ucb/vi -rwxr-xr-x 1 root 5.89824e37 Oct 22 1990 /usr/bin/emacs /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///