Loading ...
Sorry, an error occurred while loading the content.
 

Re: Regular expression warning E54 when saving arbitrary files (backslash-issue) including FIX

Expand Messages
  • Basti Grembowietz
    ... 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
    Message 1 of 7 , Feb 26, 2007
      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
    • Bram Moolenaar
      ... Looks a bit complicated and doesn t work for all magic characters. How about using vim_strsave_escaped()? -- hundred-and-one symptoms of being an internet
      Message 2 of 7 , Feb 27, 2007
        Basti Grembowietz wrote:

        > >> 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.

        Looks a bit complicated and doesn't work for all magic characters. How
        about using vim_strsave_escaped()?

        --
        hundred-and-one symptoms of being an internet addict:
        203. You're an active member of more than 20 newsgroups.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
      Your message has been successfully submitted and would be delivered to recipients shortly.