Am 25.02.2007 um 17:42 schrieb Bram Moolenaar:
After thinking of how escaping the backslash to that it would be recogniced as such (as adding a simple backslash to the path wouldn't help) I decided to go the other way round - and replaced the bracket by the all-matching '.'... WANTED BEHAVIOUR: file_pat_to_reg_pat should convert "C:\DOKUME~1\(rax)\LOKALE~1\Temp\" to "^C:[\/]DOKUME\~1[\/](rax)[\/]LOKALE\~1[\/]Temp[\/]"CURRENT BEHAVIOUR: file_pat_to_reg_pat converts "C:\DOKUME~1\(rax)\LOKALE~1\Temp\" to "^C:[\/]DOKUME\~1\(rax)[\/]LOKALE\~1[\/]Temp[\/]" ...I'm glad you managed to figure out the problem and suggest a patch. However, I think this is the wrong place to fix it. The "\(" in'backupskip' must be seen as a special item in the pattern, after all itis a list of patterns and "\(" is a regexp item.We better make sure that when there are special things in $TEMP they areescaped when put in 'backupskip'. So that $TEMP is taken literally.That is in set_init_1(), around line 3000. Perhaps you can make a patchfor that?
This solution works fine for the matching of the paths and is not too much overhead. The code is now set to only convert '(' and ')', but can easily be extended to convert other characters which would break the regex as well.
Here is the patch, I also put it as attachment (not sure whether the mailinglist
gets attachments as well). Regards, Basti ------------------------------------- *** original_option.c Mon Feb 26 00:05:18 2007 --- option.c Mon Feb 26 00:04:59 2007 *************** *** 2924,2929 **** --- 2924,2931 ---- char_u *p; int opt_idx; long_u n; + char_u *backslash; + char_u *regexCharacter; #ifdef FEAT_LANGMAP langmap_init(); *************** *** 2985,2990 **** --- 2987,3016 ---- { /* First time count the NUL, otherwise count the ','. */ len = (int)STRLEN(p) + 3; + + /* Fix regex-warnings caused by temporary paths that have \( in them + e.g. c:\Dokumen~1\(rax)\temp */ + /* find all '\' and check the next sign */ + + backslash = vim_strchr(p, '\\'); + + while (backslash) + { + /* see if character after backslash is NUL (i.e. end of string) */ + if (backslash[1] == NUL) + break; + + /* check if next sign is potentially misleading regex character */ + regexCharacter = vim_strchr((char_u *)"()", backslash[1]); + if ( regexCharacter ) + /* if yes replace it by '.', the all matching regex sign */ + backslash[1] = '.'; + + /* finally find next backslash */ + backslash = vim_strchr(&backslash[1], '\\'); + } + + if (ga_grow(&ga, len) == OK) { if (ga.ga_len > 0) -------------------------------------
*** original_option.c Mon Feb 26 00:05:18 2007 --- option.c Mon Feb 26 00:04:59 2007 *************** *** 2924,2929 **** --- 2924,2931 ---- char_u *p; int opt_idx; long_u n; + char_u *backslash; + char_u *regexCharacter; #ifdef FEAT_LANGMAP langmap_init(); *************** *** 2985,2990 **** --- 2987,3016 ---- { /* First time count the NUL, otherwise count the ','. */ len = (int)STRLEN(p) + 3; + + /* Fix regex-warnings caused by temporary paths that have \( in them + e.g. c:\Dokumen~1\(rax)\temp */ + /* find all '\' and check the next sign */ + + backslash = vim_strchr(p, '\\'); + + while (backslash) + { + /* see if character after backslash is NUL (i.e. end of string) */ + if (backslash[1] == NUL) + break; + + /* check if next sign is potentially misleading regex character */ + regexCharacter = vim_strchr((char_u *)"()", backslash[1]); + if ( regexCharacter ) + /* if yes replace it by '.', the all matching regex sign */ + backslash[1] = '.'; + + /* finally find next backslash */ + backslash = vim_strchr(&backslash[1], '\\'); + } + + if (ga_grow(&ga, len) == OK) { if (ga.ga_len > 0)
PGP.sig
Description: Signierter Teil der Nachricht