[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src - ZopeSplitter.c:1.6.4.1
Andreas Jung
andreas@digicool.com
Mon, 8 Apr 2002 14:00:25 -0400
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src
In directory cvs.zope.org:/tmp/cvs-serv25599/ZopeSplitter/src
Modified Files:
Tag: Zope-2_5-branch
ZopeSplitter.c
Log Message:
Splitter were broken when the casefolding default parameter has
been overwritten.
=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src/ZopeSplitter.c 1.6 => 1.6.4.1 ===
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 }
@@ -517,7 +535,6 @@
initZopeSplitter(void)
{
PyObject *m, *d;
- char *rev="$Revision$";
/* Create the module and add the functions */
m = Py_InitModule4("ZopeSplitter", Splitter_module_methods,
@@ -526,8 +543,6 @@
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
- PyDict_SetItemString(d, "__version__",
- PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
if (PyErr_Occurred())
Py_FatalError("can't initialize module Splitter");