[Python-checkins] CVS: python/dist/src/Modules _sre.c,2.3,2.4 sre.h,2.2,2.3 sre_constants.h,2.2,2.3
Jeremy Hylton
python-dev@python.org
Thu, 1 Jun 2000 10:34:22 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv25984
Modified Files:
_sre.c sre.h sre_constants.h
Log Message:
Fredrik Lundh: here's the 96.6% version of SRE
Index: _sre.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v
retrieving revision 2.3
retrieving revision 2.4
diff -C2 -r2.3 -r2.4
*** _sre.c 2000/05/03 23:44:30 2.3
--- _sre.c 2000/06/01 17:34:20 2.4
***************
*** 2,11 ****
*
* Secret Labs' Regular Expression Engine
! * $Id: _sre.c,v 2.3 2000/05/03 23:44:30 guido Exp $
*
* simple regular expression matching engine
*
* partial history:
! * 99-10-24 fl created (bits and pieces from the template matcher)
* 99-11-13 fl added categories, branching, and more (0.2)
* 99-11-16 fl some tweaks to compile on non-Windows platforms
[...1449 lines suppressed...]
+ 0, /*tp_print*/
+ (getattrfunc)_cursor_getattr, /*tp_getattr*/
+ };
+
static PyMethodDef _functions[] = {
{"compile", _compile, 1},
***************
*** 1446,1450 ****
{
/* Patch object types */
! Pattern_Type.ob_type = Match_Type.ob_type = &PyType_Type;
Py_InitModule("_sre", _functions);
--- 1705,1710 ----
{
/* Patch object types */
! Pattern_Type.ob_type = Match_Type.ob_type =
! Cursor_Type.ob_type = &PyType_Type;
Py_InitModule("_sre", _functions);
Index: sre.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v
retrieving revision 2.2
retrieving revision 2.3
diff -C2 -r2.2 -r2.3
*** sre.h 2000/04/10 17:07:24 2.2
--- sre.h 2000/06/01 17:34:20 2.3
***************
*** 1,5 ****
/*
* Secret Labs' Regular Expression Engine
! * $Id: sre.h,v 2.2 2000/04/10 17:07:24 guido Exp $
*
* simple regular expression matching engine
--- 1,5 ----
/*
* Secret Labs' Regular Expression Engine
! * $Id: sre.h,v 2.3 2000/06/01 17:34:20 jhylton Exp $
*
* simple regular expression matching engine
***************
*** 15,29 ****
#include "sre_constants.h"
- /* Python objects */
-
typedef struct {
PyObject_HEAD
PyObject* code; /* link to the code string object */
- PyObject* pattern; /* link to the pattern source (or None) */
int groups;
PyObject* groupindex;
} PatternObject;
! #define PatternObject_GetCode(o) ((void*) PyString_AS_STRING((o)->code))
typedef struct {
--- 15,30 ----
#include "sre_constants.h"
typedef struct {
PyObject_HEAD
PyObject* code; /* link to the code string object */
int groups;
PyObject* groupindex;
+ /* compatibility */
+ PyObject* pattern; /* pattern source (or None) */
+ int flags; /* flags used when compiling pattern source */
} PatternObject;
! #define PatternObject_GetCode(o)\
! ((void*) PyString_AS_STRING(((PatternObject*)(o))->code))
typedef struct {
***************
*** 35,38 ****
} MatchObject;
! #endif
--- 36,62 ----
} MatchObject;
! typedef struct {
! /* string pointers */
! void* ptr; /* current position (also end of current slice) */
! void* beginning; /* start of original string */
! void* start; /* start of current slice */
! void* end; /* end of original string */
! /* character size */
! int charsize;
! /* registers */
! int marks;
! void* mark[64]; /* FIXME: <fl> should be dynamically allocated! */
! /* backtracking stack */
! void** stack;
! int stacksize;
! int stackbase;
! } SRE_STATE;
+ typedef struct {
+ PyObject_HEAD
+ PyObject* pattern;
+ PyObject* string;
+ SRE_STATE state;
+ } CursorObject;
+
+ #endif
Index: sre_constants.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v
retrieving revision 2.2
retrieving revision 2.3
diff -C2 -r2.2 -r2.3
*** sre_constants.h 2000/04/10 17:07:24 2.2
--- sre_constants.h 2000/06/01 17:34:20 2.3
***************
*** 1,3 ****
! /* generated by sre_constants.py */
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
--- 1,3 ----
! /* generated from sre_constants.py */
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
***************
*** 26,27 ****
--- 26,49 ----
#define SRE_OP_RANGE 24
#define SRE_OP_REPEAT 25
+ #define SRE_AT_BEGINNING 0
+ #define SRE_AT_BEGINNING_LINE 1
+ #define SRE_AT_BOUNDARY 2
+ #define SRE_AT_NON_BOUNDARY 3
+ #define SRE_AT_END 4
+ #define SRE_AT_END_LINE 5
+ #define SRE_CATEGORY_DIGIT 0
+ #define SRE_CATEGORY_NOT_DIGIT 1
+ #define SRE_CATEGORY_SPACE 2
+ #define SRE_CATEGORY_NOT_SPACE 3
+ #define SRE_CATEGORY_WORD 4
+ #define SRE_CATEGORY_NOT_WORD 5
+ #define SRE_CATEGORY_LINEBREAK 6
+ #define SRE_CATEGORY_NOT_LINEBREAK 7
+ #define SRE_CATEGORY_LOC_DIGIT 8
+ #define SRE_CATEGORY_LOC_NOT_DIGIT 9
+ #define SRE_CATEGORY_LOC_SPACE 10
+ #define SRE_CATEGORY_LOC_NOT_SPACE 11
+ #define SRE_CATEGORY_LOC_WORD 12
+ #define SRE_CATEGORY_LOC_NOT_WORD 13
+ #define SRE_CATEGORY_LOC_LINEBREAK 14
+ #define SRE_CATEGORY_LOC_NOT_LINEBREAK 15