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

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


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

Modified Files:
      Tag: ajung-textindexng-branch
	ISO_8859_1_Splitter.c 
Log Message:
introducing new casefolding parameter


=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ISO_8859_1_Splitter/src/ISO_8859_1_Splitter.c 1.5.10.2 => 1.5.10.3 ===
     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 }
@@ -577,16 +587,18 @@
 
     /* Create the module and add the functions */
     initSplitterTrtabs();
+    if (PyErr_Occurred()) Py_FatalError("can't initialize module Splitter 1");
     m = Py_InitModule4("ISO_8859_1_Splitter", Splitter_module_methods,
                        Splitter_module_documentation,
                        (PyObject*)NULL,PYTHON_API_VERSION);
+    if (PyErr_Occurred()) Py_FatalError("can't initialize module Splitter 2");
 
     /* Add some symbolic constants to the module */
     d = PyModule_GetDict(m);
+    if (PyErr_Occurred()) Py_FatalError("can't initialize module Splitter 3");
     PyDict_SetItemString(d, "__version__",
                          PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
+    if (PyErr_Occurred()) Py_FatalError("can't initialize module Splitter 4");
 
-    if (PyErr_Occurred())
-        Py_FatalError("can't initialize module Splitter");
 }