Am 26.02.2007 um 00:22 schrieb Basti Grembowietz:

Am 25.02.2007 um 17:42 schrieb Bram Moolenaar:

...
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 it
is a list of patterns and "\(" is a regexp item.

We better make sure that when there are special things in $TEMP they are
escaped when put in 'backupskip'.  So that $TEMP is taken literally.
That is in set_init_1(), around line 3000. Perhaps you can make a patch
for that?
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 '.'

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.

Regards,
Basti

Now I also fixed my fix =) Replacing the character in the directory-string directly by '.' resulted in an escaped '\.' . I now use '?', this will be translated to '.'.

By the way, I noted that in my situation the matching of p_bsk sometimes does not help because of Windows abbrevfiated filenames ("C:\Dokum~1\..."). For example when saving directly using the full name of the file ("C:\Dokumente und Einstellungen\..."). But this is another
issue, my patch works great for me.

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)

Attachment: PGP.sig
Description: Signierter Teil der Nachricht

Reply via email to