On Sun, Aug 19, 2007 at 09:11:41PM +0200, Bram Moolenaar wrote: > Good catch with "]". By itself it's not recognized, only the matching > "[" is. > > How about making a bit cleaner: You are overwriting the string and > restoring the character in four places. If we make a > vim_isfilec_or_wc() function that could be simplified a lot. You can > safely assume that a wildcard char is not multi-byte. Thus putting > the byte in a two-byte buffer and then invoking mch_has_wildcard() > should be OK.
Thanks for the feedback. The patch worked but it was kind of messy. It illustrated quite well that comments starts to appear when the code no longer speaks for itself. I have attached a cleaner patch. Martin
Index: src/proto/charset.pro
===================================================================
RCS file: /cvsroot/vim/vim7/src/proto/charset.pro,v
retrieving revision 1.12
diff -c -r1.12 charset.pro
*** src/proto/charset.pro 5 May 2007 17:21:32 -0000 1.12
--- src/proto/charset.pro 19 Aug 2007 19:58:42 -0000
***************
*** 21,26 ****
--- 21,27 ----
int vim_iswordp __ARGS((char_u *p));
int vim_iswordc_buf __ARGS((char_u *p, buf_T *buf));
int vim_isfilec __ARGS((int c));
+ int vim_isfilec_or_wc __ARGS((int c));
int vim_isprintc __ARGS((int c));
int vim_isprintc_strict __ARGS((int c));
int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
Index: src/charset.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/charset.c,v
retrieving revision 1.26
diff -c -r1.26 charset.c
*** src/charset.c 15 Aug 2007 18:41:26 -0000 1.26
--- src/charset.c 19 Aug 2007 19:58:43 -0000
***************
*** 932,937 ****
--- 932,954 ----
}
/*
+ * return TRUE if 'c' is a valid file-name character or a wildcard character
+ * Assume characters above 0x100 are valid (multi-byte).
+ * Explicitly interpret ']' as a wildcard character as mch_has_wildcard("]")
+ * returns false.
+ */
+ int
+ vim_isfilec_or_wc(c)
+ int c;
+ {
+ char_u buf[2];
+
+ buf[0] = (char_u)c;
+ buf[1] = NUL;
+ return vim_isfilec(c) || c == ']' || mch_has_wildcard(buf);
+ }
+
+ /*
* return TRUE if 'c' is a printable character
* Assume characters above 0x100 are printable (multi-byte), except for
* Unicode.
Index: src/ex_docmd.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/ex_docmd.c,v
retrieving revision 1.131
diff -c -r1.131 ex_docmd.c
*** src/ex_docmd.c 18 Aug 2007 15:47:10 -0000 1.131
--- src/ex_docmd.c 19 Aug 2007 19:58:46 -0000
***************
*** 3311,3319 ****
in_quote = !in_quote;
}
#ifdef SPACE_IN_FILENAME
! else if (!vim_isfilec(c) && (!(ea.argt & NOSPC) || usefilter))
#else
! else if (!vim_isfilec(c))
#endif
{
while (*p != NUL)
--- 3311,3320 ----
in_quote = !in_quote;
}
#ifdef SPACE_IN_FILENAME
! else if (!vim_isfilec_or_wc(c)
! && (!(ea.argt & NOSPC) || usefilter))
#else
! else if (!vim_isfilec_or_wc(c))
#endif
{
while (*p != NUL)
***************
*** 3324,3330 ****
else
#endif
c = *p;
! if (c == '`' || vim_isfilec(c))
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
--- 3325,3331 ----
else
#endif
c = *p;
! if (c == '`' || vim_isfilec_or_wc(c))
break;
#ifdef FEAT_MBYTE
if (has_mbyte)
signature.asc
Description: Digital signature
