Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9756

Modified Files:
        ChangeLog glob.c 
Log Message:
Improved globbing to support escapes, such that the literal asterisk symbol can 
be matched using \*

U glob.c
Index: glob.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/glob.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- glob.c      1 Jul 2009 11:11:36 -0000       1.2
+++ glob.c      25 Sep 2009 08:55:19 -0000      1.3
@@ -36,28 +36,50 @@
 {
        const char *haymem = NULL;
        const char *exprmem = NULL;
+       char escape = 0;
 
        /* probably need to implement this using libpcre once we get
         * advanced users, doing even more advanced things */
 
        while (*expr != '\0') {
+               if (*expr == '\\') {
+                       escape = !escape;
+                       if (escape) {
+                               expr++;
+                               continue; /* skip over escape */
+                       }
+               }
                switch (*expr) {
                        case '*':
-                               /* store expression position for retry lateron 
*/
-                               exprmem = expr;
-                               /* skip over haystack till the next char from 
expr */
-                               expr++;
-                               if (*expr == '\0')
-                                       /* this will always match the rest */
-                                       return(1);
-                               while (*haystack != '\0' && *haystack != *expr)
-                                       haystack++;
-                               /* store match position, for retry lateron */
-                               haymem = haystack + 1;
-                               if (*haystack == '\0')
-                                       /* couldn't find it, so no match  */
-                                       return(0);
-                       break;
+                               if (!escape) {
+                                       /* store expression position for retry 
lateron */
+                                       exprmem = expr;
+                                       /* skip over haystack till the next 
char from expr */
+                                       do {
+                                               expr++;
+                                               if (*expr == '\0') {
+                                                       /* this will always 
match the rest */
+                                                       return(1);
+                                               } else if (!escape && *expr == 
'*') {
+                                                       continue;
+                                               } else if (*expr == '\\') {
+                                                       escape = !escape;
+                                                       if (!escape)
+                                                               break;
+                                               } else {
+                                                       break;
+                                               }
+                                       } while(1);
+                                       while (*haystack != '\0' && *haystack 
!= *expr)
+                                               haystack++;
+                                       /* store match position, for retry 
lateron */
+                                       haymem = haystack + 1;
+                                       if (*haystack == '\0')
+                                               /* couldn't find it, so no 
match  */
+                                               return(0);
+                                       break;
+                               }
+                               /* do asterisk match if escaped */
                        default:
                                if (*expr != *haystack) {
                                        if (haymem != NULL) {
@@ -70,6 +92,7 @@
                }
                expr++;
                haystack++;
+               escape = 0;
        }
        return(*haystack == '\0');
 }

U ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/ChangeLog,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- ChangeLog   25 Sep 2009 08:20:39 -0000      1.27
+++ ChangeLog   25 Sep 2009 08:55:19 -0000      1.28
@@ -1,6 +1,10 @@
 # ChangeLog file for sql/src/backends/monet5
 # This file is updated with mchangelog (Gentoo echangelog bastard script)
 
+  25 Sep 2009; Fabian Groffen <[email protected]> glob.c:
+  Improved globbing to support escapes, such that the literal asterisk symbol
+  can be matched using \*
+
   25 Sep 2009; Fabian Groffen <[email protected]> merovingian_discoveryrunner.c,
   monetdb.1:
   Remote controllable merovingians now announce their controlport. These


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to