From c3861078385ee8f546ae9d16d47b2f3447f3044d Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 8 Oct 1997 02:07:40 +0000 Subject: Checking in AMK's latest installement. (Two small changes to shup up gcc added.) --- Modules/pcremodule.c | 164 ++++++++++++++++----------------------------------- Modules/pypcre.c | 34 ++++++----- 2 files changed, 68 insertions(+), 130 deletions(-) diff --git a/Modules/pcremodule.c b/Modules/pcremodule.c index 7c4136a..d7615d1 100644 --- a/Modules/pcremodule.c +++ b/Modules/pcremodule.c @@ -222,7 +222,9 @@ PyPcre_compile(self, args) { PyMem_DEL(rv); if (!PyErr_Occurred()) - PyErr_SetObject(ErrorObject, Py_BuildValue("si", error, erroroffset)); + { + PyErr_SetObject(ErrorObject, Py_BuildValue("si", error, erroroffset)); + } return NULL; } rv->regex_extra=pcre_study(rv->regex, 0, &error); @@ -243,47 +245,57 @@ PyPcre_compile(self, args) } static PyObject * -PyPcre_expand_escape(self, args) - PyObject *self; - PyObject *args; +PyPcre_expand_escape(pattern, pattern_len, indexptr, typeptr) + unsigned char *pattern; + int pattern_len, *indexptr, *typeptr; { - unsigned char c, *pattern; - int index, pattern_len; - const int context=REPLACEMENT; - - if (!PyArg_ParseTuple(args, "s#i", &pattern, &pattern_len, &index)) - return NULL; + unsigned char c; + int index = *indexptr; + if (pattern_len<=index) { PyErr_SetString(ErrorObject, "escape ends too soon"); return NULL; } c=pattern[index]; index++; + *typeptr=CHAR; + switch (c) { case('t'): - return Py_BuildValue("ici", CHAR, (char)9, index); + *indexptr=index; + return Py_BuildValue("c", (char)9); break; case('n'): - return Py_BuildValue("ici", CHAR, (char)10, index); + *indexptr = index; + return Py_BuildValue("c", (char)10); break; case('v'): - return Py_BuildValue("ici", CHAR, (char)11, index); + *indexptr = index; + return Py_BuildValue("c", (char)11); break; case('r'): - return Py_BuildValue("ici", CHAR, (char)13, index); + *indexptr = index; + return Py_BuildValue("c", (char)13); break; case('f'): - return Py_BuildValue("ici", CHAR, (char)12, index); + *indexptr = index; + return Py_BuildValue("c", (char)12); break; case('a'): - return Py_BuildValue("ici", CHAR, (char)7, index); + *indexptr = index; + return Py_BuildValue("c", (char)7); break; + case('b'): + *indexptr=index; + return Py_BuildValue("c", (char)8); + break; + case('x'): { int end, length; unsigned char *string; - PyObject *v, *result; + PyObject *v; end=index; while (endoffset_top) free(md->offset_top); if (md->r1) free(md->r1); if (md->r2) free(md->r2); if (md->eptr) free(md->eptr); -if (md->ecode) free(md->ecode); +if (md->ecode) free(md->ecode); +return 0; } static int grow_stack(match_data *md) @@ -2987,7 +2989,7 @@ for (;;) int min, max, ctype; register int i; register int c; - BOOL minimize; + BOOL minimize = 0; /* Opening bracket. Check the alternative branches in turn, failing if none match. We have to set the start offset if required and there is space @@ -3000,7 +3002,7 @@ for (;;) if ((int)*ecode >= OP_BRA) { int number = (*ecode - OP_BRA) << 1; - int save_offset1, save_offset2; + int save_offset1 = 0, save_offset2 = 0; #ifdef DEBUG printf("start bracket %d\n", number/2); @@ -3858,7 +3860,7 @@ fail: if (md->point > save_stack_position) { /* If there are still points remaining on the stack, pop the next one off */ - int start, end, off_num; + int off_num; md->point--; offset_top = md->offset_top[md->point]; -- cgit v0.12