[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src - ZopeSplitter.c:1.2.10.6
Andreas Jung
andreas@zope.com
Thu, 11 Oct 2001 08:54:12 -0400
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src
In directory cvs.zope.org:/tmp/cvs-serv4474/src
Modified Files:
Tag: ajung-unicode
ZopeSplitter.c
Log Message:
fixed problem with string encoded != ascii
=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src/ZopeSplitter.c 1.2.10.5 => 1.2.10.6 ===
int start=0;
-#ifdef DEBUG
- puts("before List_New");
- fflush(stdout);
-#endif
-
self->list = PyList_New(0);
-#ifdef DEBUG
- puts("after List_New");
- fflush(stdout);
-#endif
-
-
do {
register Py_UNICODE ch;
@@ -276,7 +265,7 @@
}
static PyObject *
-get_Splitter(PyObject *modinfo, PyObject *args)
+get_Splitter(PyObject *modinfo, PyObject *args,PyObject *keywds)
{
Splitter *self;
PyObject *doc, *unicodedoc,*synstop=NULL;
@@ -291,19 +280,14 @@
#endif
if (PyString_Check(doc)) {
+ // This sux a bit. The default encoding should be ascii or latin1.
+ // But there must be better support to pass an optional encoding parameter
+
+ unicodedoc = PyUnicode_FromEncodedObject(doc,"latin1","strict");
+ if (! unicodedoc) goto err;
-#ifdef DEBUG
- puts("got a string object");
- fflush(stdout);
-#endif
- unicodedoc = PyUnicode_FromObject(doc);
} else if( PyUnicode_Check(doc)) {
-#ifdef DEBUG
- puts("got a unicode object");
- fflush(stdout);
-
-#endif
unicodedoc = doc;
} else {
PyErr_SetString(PyExc_TypeError, "first argument is neither string nor unicode.");
@@ -313,20 +297,9 @@
if (synstop) {
self->synstop = synstop;
Py_INCREF(synstop);
- } else {
- self->synstop=NULL;
- }
-
-#ifdef DEBUG
- puts("before splitUnicodeString");
- PyObject_Print(unicodedoc,stdout,0);
-#endif
+ } else self->synstop=NULL;
splitUnicodeString(self,(PyUnicodeObject *)unicodedoc);
-
-#ifdef DEBUG
- puts("after splitUnicodeString");
-#endif
return (PyObject*)self;