From 74fb3039972db03a97852eb5ded0c618e7c60d79 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 17 Jul 1997 22:41:38 +0000 Subject: Jeffrey's latests --- Modules/reopmodule.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 125 insertions(+), 6 deletions(-) (limited to 'Modules/reopmodule.c') diff --git a/Modules/reopmodule.c b/Modules/reopmodule.c index 9b928f5bef..0817626d47 100644 --- a/Modules/reopmodule.c +++ b/Modules/reopmodule.c @@ -43,6 +43,13 @@ PERFORMANCE OF THIS SOFTWARE. static PyObject *ReopError; /* Exception */ +#define IGNORECASE 0x01 +#define MULTILINE 0x02 +#define DOTALL 0x04 +#define VERBOSE 0x08 + +static char *reop_casefold; + static PyObject * makeresult(regs, num_regs) struct re_registers *regs; @@ -90,6 +97,10 @@ reop_match(self, args) int flags, pos, result; struct re_pattern_buffer bufp; struct re_registers re_regs; + PyObject *modules = NULL; + PyObject *reopmodule = NULL; + PyObject *reopdict = NULL; + PyObject *casefold = NULL; if (!PyArg_Parse(args, "(s#iiis#is#i)", &(bufp.buffer), &(bufp.allocated), @@ -102,20 +113,44 @@ reop_match(self, args) /* XXX sanity-check the input data */ bufp.used=bufp.allocated; - bufp.translate=NULL; + if (flags & IGNORECASE) + { + if ((modules = PyImport_GetModuleDict()) == NULL) + return NULL; + + if ((reopmodule = PyDict_GetItemString(modules, + "reop")) == NULL) + return NULL; + + if ((reopdict = PyModule_GetDict(reopmodule)) == NULL) + return NULL; + + if ((casefold = PyDict_GetItemString(reopdict, + "casefold")) == NULL) + return NULL; + + bufp.translate = PyString_AsString(casefold); + } + else + bufp.translate=NULL; bufp.fastmap_accurate=1; bufp.can_be_null=can_be_null; bufp.uses_registers=1; bufp.anchor=anchor; - for(i=0; i