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

Andreas Jung andreas@zope.com
Wed, 14 Nov 2001 08:45:49 -0500


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

Modified Files:
	ZopeSplitter.c 
Log Message:
- unified indentations
- added encoding parameter to make pre-2.5 Data.fs installations happy because
  of adding the encoding parameter to the Splitter API


=== Zope/lib/python/Products/PluginIndexes/TextIndex/Splitter/ZopeSplitter/src/ZopeSplitter.c 1.3 => 1.4 === (548/648 lines abridged)
 #define UNLESS_ASSIGN(V,E) ASSIGN(V,E) UNLESS(V)
 
-typedef struct 
+typedef struct
 {
     PyObject_HEAD
     PyObject *text, *synstop;
     char *here, *end;
     int index;
-} Splitter;
- 
+}
+
+Splitter;
+
 static PyObject *next_word(Splitter *, char **, char **);
 
 static void
@@ -107,7 +109,7 @@
 }
 
 static void
-Splitter_dealloc(Splitter *self) 
+Splitter_dealloc(Splitter *self)
 {
     Py_XDECREF(self->text);
     Py_XDECREF(self->synstop);
@@ -120,15 +122,15 @@
     PyObject *res=0;
 
     Splitter_reset(self);
-    while(1)
-      {
-	UNLESS_ASSIGN(res,next_word(self,NULL,NULL)) return -1;
-	UNLESS(PyString_Check(res))
-	  {
-	    Py_DECREF(res);
-	    break;
-	  }
-      }
+
+    while(1) {
+        UNLESS_ASSIGN(res,next_word(self,NULL,NULL)) return -1;
+        UNLESS(PyString_Check(res)) {
+            Py_DECREF(res);
+            break;
+        }
+    }
+
     return self->index+1;

[-=- -=- -=- 548 lines omitted -=- -=- -=-]

+static struct PyMethodDef Splitter_module_methods[] =
+    {
+        { "ZopeSplitter", (PyCFunction)get_Splitter, METH_VARARGS|METH_KEYWORDS,
+            "ZopeSplitter(doc[,synstop]) -- Return a word splitter"
+        },
+
+        { NULL, NULL }
+    };
+
+static char Splitter_module_documentation[] =
+    "Parse source strings into sequences of words\n"
+    "\n"
+    "for use in an inverted index\n"
+    "\n"
+    "$Id$\n"
+    ;
 
 
 void
 initZopeSplitter(void)
 {
-  PyObject *m, *d;
-  char *rev="$Revision$";
-  
-  /* Create the module and add the functions */
-  m = Py_InitModule4("ZopeSplitter", Splitter_module_methods,
-                     Splitter_module_documentation,
-                     (PyObject*)NULL,PYTHON_API_VERSION);
-  
-  /* Add some symbolic constants to the module */
-  d = PyModule_GetDict(m);
-  PyDict_SetItemString(d, "__version__",
-		       PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
+    PyObject *m, *d;
+    char *rev="$Revision$";
+
+    /* Create the module and add the functions */
+    m = Py_InitModule4("ZopeSplitter", Splitter_module_methods,
+                       Splitter_module_documentation,
+                       (PyObject*)NULL,PYTHON_API_VERSION);
+
+    /* 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");
+    if (PyErr_Occurred())
+        Py_FatalError("can't initialize module Splitter");
 }