chiark / gitweb /
str: Support new prefix-matching feature in str_match.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 13 Apr 2006 22:29:54 +0000 (23:29 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 13 Apr 2006 22:29:54 +0000 (23:29 +0100)
defs.pxi
str.pyx

index 2de0ab9..4b1ecde 100644 (file)
--- a/defs.pxi
+++ b/defs.pxi
@@ -157,9 +157,10 @@ cdef extern from 'mLib/sym.h':
 cdef extern from 'mLib/str.h':
   enum:
     STRF_QUOTE
+    STRF_PREFIX
   char *str_qword(char **pp, unsigned f)
   size_t str_qsplit(char *p, char **v, size_t c, char **rest, unsigned f)
-  int str_match(char *p, char *s)
+  int str_matchx(char *p, char *s, unsigned f)
   void str_sanitize(char *d, char *p, size_t sz)
 
 #----- Form-urlencoding functions -------------------------------------------
diff --git a/str.pyx b/str.pyx
index 7ec1ed4..b7d80e6 100644 (file)
--- a/str.pyx
+++ b/str.pyx
@@ -76,8 +76,11 @@ def split(char *p, int n = -1, quotep = False):
   xfree(op)
   return l, r
 
-def match(char *p, char *s):
-  return _tobool(str_match(p, s))
+def match(char *p, char *s, prefixp = False):
+  cdef unsigned f
+  if prefixp:
+    f = f | STRF_PREFIX
+  return _tobool(str_matchx(p, s, f))
 
 def sanitize(char *p, int n = -1):
   cdef char *buf