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

Andreas Jung andreas@digicool.com
Mon, 8 Apr 2002 14:00:55 -0400


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

Modified Files:
      Tag: Zope-2_5-branch
	ISO_8859_1_Splitter.c 
Log Message:
Splitter were broken when the casefolding default parameter has
been overwritten.


=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ISO_8859_1_Splitter/src/ISO_8859_1_Splitter.c 1.6.4.3 => 1.6.4.4 ===
     int index_numbers;
     int max_len;
+    int casefolding;
 }
 
 Splitter;
@@ -251,7 +252,10 @@
             continue;
         }
 
-        c=mytolower(*here);
+        if (self->casefolding)
+            c=mytolower(*here);
+        else
+            c = (*here);
 
         /* Check to see if this character is part of a word */
 
@@ -490,7 +494,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 *
 get_Splitter(PyObject *modinfo, PyObject *args,PyObject *keywds)
@@ -501,8 +505,9 @@
     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) {
@@ -510,6 +515,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;
@@ -521,7 +531,6 @@
     }
 
 
-
     UNLESS(self = PyObject_NEW(Splitter, &SplitterType)) return NULL;
 
     if(synstop) {
@@ -539,6 +548,7 @@
     self->allow_single_chars    = single_char;
     self->index_numbers         = index_numbers;
     self->max_len               = max_len;
+    self->casefolding           = casefolding;
 
     self->index = -1;
 
@@ -553,7 +563,7 @@
 static struct PyMethodDef Splitter_module_methods[] =
     {
         { "ISO_8859_1_Splitter", (PyCFunction)get_Splitter, METH_VARARGS|METH_KEYWORDS,
-          "ISO_8859_1_Splitter(doc[,synstop][,encoding][,singlechar][,indexnumbers][,maxlen]) -- Return a word splitter"
+          "ISO_8859_1_Splitter(doc[,synstop][,encoding][,singlechar][,indexnumbers][,maxlen][,casefolding]) -- Return a word splitter"
         },
 
         { NULL, NULL }