[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src - ZopeSplitter.c:1.7

Andreas Jung andreas@digicool.com
Mon, 21 Jan 2002 14:28:56 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src
In directory cvs.zope.org:/tmp/cvs-serv17754/ZopeSplitter/src

Modified Files:
	ZopeSplitter.c 
Log Message:
introducing new 'casefolding' parameter


=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src/ZopeSplitter.c 1.6 => 1.7 ===
     int index_numbers;
     int max_len;
+    int casefolding;
 }
 
 Splitter;
@@ -170,7 +171,10 @@
             continue;
         }
 
-        c=tolower((unsigned char) *here);
+        if (self->casefolding) 
+            c = tolower((unsigned char) *here);
+        else
+            c = (unsigned char) *here;
 
         /* Check to see if this character is part of a word */
 
@@ -435,7 +439,7 @@
     SplitterType__doc__ /* Documentation string */
 };
 
-static char *splitter_args[]={"doc","synstop","encoding","singlechar","indexnumbers","maxlen",NULL};
+static char *splitter_args[]={"doc","synstop","encoding","singlechar","indexnumbers","maxlen","casefolding",NULL};
 
 
 static PyObject *
@@ -447,9 +451,17 @@
     int single_char = 0;
     int index_numbers = 0;
     int max_len= 64;
+    int casefolding = 1;
 
-    UNLESS(PyArg_ParseTupleAndKeywords(args,keywds,"O|Osiii",splitter_args, \
-                                       &doc,&synstop,&encoding,&single_char,&index_numbers,&max_len)) return NULL;
+    UNLESS(PyArg_ParseTupleAndKeywords(args,keywds,"O|Osiiii",splitter_args, \
+                                       &doc,
+                                       &synstop,
+                                       &encoding,
+                                       &single_char,
+                                       &index_numbers,
+                                       &max_len,
+                                       &casefolding
+                                    )) return NULL;
 
 
     if (index_numbers<0 || index_numbers>1) {
@@ -457,6 +469,11 @@
         return NULL;
     }
 
+    if (casefolding<0 || casefolding>1) {
+        PyErr_SetString(PyExc_ValueError,"casefolding must be 0 or 1");
+        return NULL;
+    }
+
     if (single_char<0 || single_char>1) {
         PyErr_SetString(PyExc_ValueError,"singlechar must be 0 or 1");
         return NULL;
@@ -486,6 +503,7 @@
     self->allow_single_chars = single_char;
     self->index_numbers      = index_numbers;
     self->max_len            = max_len;
+    self->casefolding        = casefolding;
 
     return (PyObject*)self;
 
@@ -498,7 +516,7 @@
 static struct PyMethodDef Splitter_module_methods[] =
     {
         { "ZopeSplitter", (PyCFunction)get_Splitter, METH_VARARGS|METH_KEYWORDS,
-            "ZopeSplitter(doc[,synstop][,encoding][,singlechar][,indexnumbers][,maxlen]) -- Return a word splitter"
+            "ZopeSplitter(doc[,synstop][,encoding][,singlechar][,indexnumbers][,maxlen][,casefolding]) -- Return a word splitter"
         },
 
         { NULL, NULL }