[Python-checkins] CVS: python/dist/src/Modules _sre.c,2.53,2.54 sre_constants.h,2.11,2.12
Fredrik Lundh
effbot@users.sourceforge.net
Thu, 22 Mar 2001 07:50:12 -0800
- Previous message: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.136,1.137
- Next message: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.30,1.31 sre_compile.py,1.36,1.37 sre_parse.py,1.45,1.46 sre_constants.py,1.27,1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv29581/Modules
Modified Files:
_sre.c sre_constants.h
Log Message:
sre 2.1b2 update:
- take locale into account for word boundary anchors (#410271)
- restored 2.0's *? behaviour (#233283, #408936 and others)
- speed up re.sub/re.subn
Index: _sre.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -r2.53 -r2.54
*** _sre.c 2001/02/28 16:44:18 2.53
--- _sre.c 2001/03/22 15:50:09 2.54
***************
*** 25,30 ****
* 2000-12-21 fl fixed memory leak in groupdict
* 2001-01-02 fl properly reset pointer after failed assertion in MIN_UNTIL
! * 2001-01-15 fl avoid recursion for MIN_UTIL; fixed uppercase literal bug
* 2001-01-16 fl fixed memory leak in pattern destructor
*
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
--- 25,31 ----
* 2000-12-21 fl fixed memory leak in groupdict
* 2001-01-02 fl properly reset pointer after failed assertion in MIN_UNTIL
! * 2001-01-15 fl avoid recursion for MIN_UNTIL; fixed uppercase literal bug
* 2001-01-16 fl fixed memory leak in pattern destructor
+ * 2001-03-20 fl lots of fixes for 2.1b2
*
* Copyright (c) 1997-2001 by Secret Labs AB. All rights reserved.
***************
*** 41,45 ****
#ifndef SRE_RECURSIVE
! char copyright[] = " SRE 2.1 Copyright (c) 1997-2001 by Secret Labs AB ";
#include "Python.h"
--- 42,46 ----
#ifndef SRE_RECURSIVE
! char copyright[] = " SRE 2.1b2 Copyright (c) 1997-2001 by Secret Labs AB ";
#include "Python.h"
***************
*** 142,150 ****
120, 121, 122, 123, 124, 125, 126, 127 };
- static unsigned int sre_lower(unsigned int ch)
- {
- return ((ch) < 128 ? sre_char_lower[ch] : ch);
- }
-
#define SRE_IS_DIGIT(ch)\
((ch) < 128 ? (sre_char_info[(ch)] & SRE_DIGIT_MASK) : 0)
--- 143,146 ----
***************
*** 157,167 ****
#define SRE_IS_WORD(ch)\
((ch) < 128 ? (sre_char_info[(ch)] & SRE_WORD_MASK) : 0)
-
- /* locale-specific character predicates */
! static unsigned int sre_lower_locale(unsigned int ch)
{
! return ((ch) < 256 ? tolower((ch)) : ch);
}
#define SRE_LOC_IS_DIGIT(ch) ((ch) < 256 ? isdigit((ch)) : 0)
#define SRE_LOC_IS_SPACE(ch) ((ch) < 256 ? isspace((ch)) : 0)
--- 153,164 ----
#define SRE_IS_WORD(ch)\
((ch) < 128 ? (sre_char_info[(ch)] & SRE_WORD_MASK) : 0)
! static unsigned int sre_lower(unsigned int ch)
{
! return ((ch) < 128 ? sre_char_lower[ch] : ch);
}
+
+ /* locale-specific character predicates */
+
#define SRE_LOC_IS_DIGIT(ch) ((ch) < 256 ? isdigit((ch)) : 0)
#define SRE_LOC_IS_SPACE(ch) ((ch) < 256 ? isspace((ch)) : 0)
***************
*** 170,180 ****
#define SRE_LOC_IS_WORD(ch) (SRE_LOC_IS_ALNUM((ch)) || (ch) == '_')
/* unicode-specific character predicates */
#if defined(HAVE_UNICODE)
! static unsigned int sre_lower_unicode(unsigned int ch)
! {
! return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch));
! }
#define SRE_UNI_IS_DIGIT(ch) Py_UNICODE_ISDIGIT((Py_UNICODE)(ch))
#define SRE_UNI_IS_SPACE(ch) Py_UNICODE_ISSPACE((Py_UNICODE)(ch))
--- 167,179 ----
#define SRE_LOC_IS_WORD(ch) (SRE_LOC_IS_ALNUM((ch)) || (ch) == '_')
+ static unsigned int sre_lower_locale(unsigned int ch)
+ {
+ return ((ch) < 256 ? tolower((ch)) : ch);
+ }
+
/* unicode-specific character predicates */
#if defined(HAVE_UNICODE)
!
#define SRE_UNI_IS_DIGIT(ch) Py_UNICODE_ISDIGIT((Py_UNICODE)(ch))
#define SRE_UNI_IS_SPACE(ch) Py_UNICODE_ISSPACE((Py_UNICODE)(ch))
***************
*** 182,185 ****
--- 181,190 ----
#define SRE_UNI_IS_ALNUM(ch) Py_UNICODE_ISALNUM((Py_UNICODE)(ch))
#define SRE_UNI_IS_WORD(ch) (SRE_UNI_IS_ALNUM((ch)) || (ch) == '_')
+
+ static unsigned int sre_lower_unicode(unsigned int ch)
+ {
+ return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch));
+ }
+
#endif
***************
*** 419,422 ****
--- 424,463 ----
SRE_IS_WORD((int) ptr[0]) : 0;
return this == that;
+
+ case SRE_AT_LOC_BOUNDARY:
+ if (state->beginning == state->end)
+ return 0;
+ that = ((void*) ptr > state->beginning) ?
+ SRE_LOC_IS_WORD((int) ptr[-1]) : 0;
+ this = ((void*) ptr < state->end) ?
+ SRE_LOC_IS_WORD((int) ptr[0]) : 0;
+ return this != that;
+
+ case SRE_AT_LOC_NON_BOUNDARY:
+ if (state->beginning == state->end)
+ return 0;
+ that = ((void*) ptr > state->beginning) ?
+ SRE_LOC_IS_WORD((int) ptr[-1]) : 0;
+ this = ((void*) ptr < state->end) ?
+ SRE_LOC_IS_WORD((int) ptr[0]) : 0;
+ return this == that;
+
+ case SRE_AT_UNI_BOUNDARY:
+ if (state->beginning == state->end)
+ return 0;
+ that = ((void*) ptr > state->beginning) ?
+ SRE_UNI_IS_WORD((int) ptr[-1]) : 0;
+ this = ((void*) ptr < state->end) ?
+ SRE_UNI_IS_WORD((int) ptr[0]) : 0;
+ return this != that;
+
+ case SRE_AT_UNI_NON_BOUNDARY:
+ if (state->beginning == state->end)
+ return 0;
+ that = ((void*) ptr > state->beginning) ?
+ SRE_UNI_IS_WORD((int) ptr[-1]) : 0;
+ this = ((void*) ptr < state->end) ?
+ SRE_UNI_IS_WORD((int) ptr[0]) : 0;
+ return this == that;
}
***************
*** 1038,1042 ****
/* see if the tail matches */
state->repeat = rp->prev;
! if (rp->pattern[2] == 65535) {
/* unbounded repeat */
for (;;) {
--- 1079,1084 ----
/* see if the tail matches */
state->repeat = rp->prev;
! /* FIXME: the following fix doesn't always work (#133283) */
! if (0 && rp->pattern[2] == 65535) {
/* unbounded repeat */
for (;;) {
Index: sre_constants.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v
retrieving revision 2.11
retrieving revision 2.12
diff -C2 -r2.11 -r2.12
*** sre_constants.h 2001/01/15 12:46:09 2.11
--- sre_constants.h 2001/03/22 15:50:09 2.12
***************
*** 12,16 ****
*/
! #define SRE_MAGIC 20010115
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
--- 12,16 ----
*/
! #define SRE_MAGIC 20010320
#define SRE_OP_FAILURE 0
#define SRE_OP_SUCCESS 1
***************
*** 50,53 ****
--- 50,57 ----
#define SRE_AT_END_LINE 6
#define SRE_AT_END_STRING 7
+ #define SRE_AT_LOC_BOUNDARY 8
+ #define SRE_AT_LOC_NON_BOUNDARY 9
+ #define SRE_AT_UNI_BOUNDARY 10
+ #define SRE_AT_UNI_NON_BOUNDARY 11
#define SRE_CATEGORY_DIGIT 0
#define SRE_CATEGORY_NOT_DIGIT 1
- Previous message: [Python-checkins] CVS: python/dist/src/Misc NEWS,1.136,1.137
- Next message: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.30,1.31 sre_compile.py,1.36,1.37 sre_parse.py,1.45,1.46 sre_constants.py,1.27,1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]