[Python-checkins] python/dist/src/Modules _sre.c,2.88,2.89 sre_constants.h,2.14,2.15
loewis@users.sourceforge.net
loewis@users.sourceforge.net
Sat, 19 Apr 2003 05:56:10 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv11938/Modules
Modified Files:
_sre.c sre_constants.h
Log Message:
Fully support 32-bit codes. Enable BIGCHARSET in UCS-4 builds.
Index: _sre.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v
retrieving revision 2.88
retrieving revision 2.89
diff -C2 -d -r2.88 -r2.89
*** _sre.c 14 Apr 2003 17:59:34 -0000 2.88
--- _sre.c 19 Apr 2003 12:56:07 -0000 2.89
***************
*** 21,24 ****
--- 21,25 ----
* 2001-12-07 fl fixed memory leak in sub/subn (Guido van Rossum)
* 2002-11-09 fl fixed empty sub/subn return type
+ * 2003-04-18 mvl fully support 4-byte codes
*
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
***************
*** 511,518 ****
case SRE_OP_CHARSET:
! /* <CHARSET> <bitmap> (16 bits per code word) */
! if (ch < 256 && (set[ch >> 4] & (1 << (ch & 15))))
! return ok;
! set += 16;
break;
--- 512,527 ----
case SRE_OP_CHARSET:
! if (sizeof(SRE_CODE) == 2) {
! /* <CHARSET> <bitmap> (16 bits per code word) */
! if (ch < 256 && (set[ch >> 4] & (1 << (ch & 15))))
! return ok;
! set += 16;
! }
! else {
! /* <CHARSET> <bitmap> (32 bits per code word) */
! if (ch < 256 && (set[ch >> 5] & (1 << (ch & 31))))
! return ok;
! set += 8;
! }
break;
***************
*** 522,530 ****
int count, block;
count = *(set++);
! block = ((unsigned char*)set)[ch >> 8];
! set += 128;
! if (set[block*16 + ((ch & 255)>>4)] & (1 << (ch & 15)))
! return ok;
! set += count*16;
break;
}
--- 531,553 ----
int count, block;
count = *(set++);
!
! if (sizeof(SRE_CODE) == 2) {
! block = ((unsigned char*)set)[ch >> 8];
! set += 128;
! if (set[block*16 + ((ch & 255)>>4)] & (1 << (ch & 15)))
! return ok;
! set += count*16;
! }
! else {
! if (ch < 65536)
! block = ((unsigned char*)set)[ch >> 8];
! else
! block = -1;
! set += 64;
! if (block >=0 &&
! (set[block*8 + ((ch & 255)>>5)] & (1 << (ch & 31))))
! return ok;
! set += count*8;
! }
break;
}
***************
*** 1372,1376 ****
for (i = 0; i < n; i++) {
PyObject *o = PyList_GET_ITEM(code, i);
! self->code[i] = (SRE_CODE) PyInt_AsLong(o);
}
--- 1395,1402 ----
for (i = 0; i < n; i++) {
PyObject *o = PyList_GET_ITEM(code, i);
! if (PyInt_Check(o))
! self->code[i] = (SRE_CODE) PyInt_AsLong(o);
! else
! self->code[i] = (SRE_CODE) PyLong_AsUnsignedLong(o);
}
***************
*** 3043,3046 ****
--- 3069,3078 ----
if (x) {
PyDict_SetItemString(d, "MAGIC", x);
+ Py_DECREF(x);
+ }
+
+ x = PyInt_FromLong(sizeof(SRE_CODE));
+ if (x) {
+ PyDict_SetItemString(d, "CODESIZE", x);
Py_DECREF(x);
}
Index: sre_constants.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v
retrieving revision 2.14
retrieving revision 2.15
diff -C2 -d -r2.14 -r2.15
*** sre_constants.h 14 Apr 2003 17:59:34 -0000 2.14
--- sre_constants.h 19 Apr 2003 12:56:08 -0000 2.15
***************
*** 12,16 ****
*/
! #define SRE_MAGIC 20010701
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
--- 12,16 ----
*/
! #define SRE_MAGIC 20030419
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1