summaryrefslogtreecommitdiffstats
path: root/Modules/_sre.c
Commit message (Collapse)AuthorAgeFilesLines
* Fixing bug #1072259 in SRE.Gustavo Niemeyer2004-12-021-7/+10
|
* Add docstrings for regular expression objects and methods.Raymond Hettinger2004-09-241-8/+51
|
* Fixing bug #817234, which made SRE get into an infinite loop onGustavo Niemeyer2004-09-031-5/+3
| | | | | empty final matches with finditer(). New test cases included for this bug and for #581080.
* Moved SunPro warning suppression into pyport.h and out of individualNicholas Bastin2004-07-151-4/+0
| | | | modules and objects.
* Fixed end-of-loop code not reached warning when using SunPro CNicholas Bastin2004-06-171-0/+4
|
* Add weakref support to sockets and re pattern objects.Raymond Hettinger2004-05-311-1/+24
|
* - Fixing annoying warnings.Gustavo Niemeyer2004-02-141-7/+10
|
* Cleaning up recursive pieces left in the reorganization.Gustavo Niemeyer2003-12-131-119/+16
|
* Removing dead code.Gustavo Niemeyer2003-10-181-11/+0
|
* Implemented non-recursive SRE matching.Gustavo Niemeyer2003-10-171-439/+741
|
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-5/+5
| | | | | | * Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
* Fixing bug described in patch #756032, where SRE reads invalid dataGustavo Niemeyer2003-06-261-1/+1
| | | | due to a corrupted end pointer.
* Changes to sre.c after the application of patch #726869 have increasedAndrew MacIntyre2003-06-091-5/+11
| | | | | | | | | | | | | | | | | | stack usage on FreeBSD, requiring the recursion limit to be lowered further. Building with gcc 2.95 (the standard compiler on FreeBSD 4.x) is now also affected. The underlying issue is that FreeBSD's pthreads implementation has a hard-coded 1MB stack size for the initial (or "primary") thread, which can not be changed without rebuilding libc_r. Exhausting this stack results in a bus error. Building without pthreads (configure --without-threads), or linking with the port of the Linux pthreads library (aka Linuxthreads) instead of libc_r, avoids this limitation. On OS/2, only gcc 3.2 is affected and the stack size is controllable, so the special handling has been removed.
* Allow _sre.c to compile with Python 2.2Andrew M. Kuchling2003-04-301-0/+4
|
* - Included detailed documentation in _sre.c explaining how, when, and whyGustavo Niemeyer2003-04-271-17/+41
| | | | | | | | | | | | to use LASTMARK_SAVE()/LASTMARK_RESTORE(), based on the discussion in patch #712900. - Cleaned up LASTMARK_SAVE()/LASTMARK_RESTORE() usage, based on the established rules. - Moved the upper part of the just commited patch (relative to bug #725106) to outside the for() loop of BRANCH OP. There's no need to mark_save() in every loop iteration.
* Fix for part of the problem mentioned in #725149 by Greg Chapman.Gustavo Niemeyer2003-04-271-8/+10
| | | | | | | | | | | | | | | | | | | This problem is related to a wrong behavior from mark_save/restore(), which don't restore the mark_stack_base before restoring the marks. Greg's suggestion was to change the asserts, which happen to be the only recursive ops that can continue the loop, but the problem would happen to any operation with the same behavior. So, rather than hardcoding this into asserts, I have changed mark_save/restore() to always restore the stackbase before restoring the marks. Both solutions should fix these two cases, presented by Greg: >>> re.match('(a)(?:(?=(b)*)c)*', 'abb').groups() ('b', None) >>> re.match('(a)((?!(b)*))*', 'abb').groups() ('b', None, None) The rest of the bug and patch in #725149 must be discussed further.
* Applied patch #725106, by Greg Chapman, fixing capturing groupsGustavo Niemeyer2003-04-271-0/+10
| | | | | | | | | | | | | | | | | | | | within repeats of alternatives. The only change to the original patch was to convert the tests to the new test_re.py file. This patch fixes cases like: >>> re.match('((a)|b)*', 'abc').groups() ('b', '') Which is wrong (it's impossible to match the empty string), and incompatible with other regex systems, like the following examples show: % perl -e '"abc" =~ /^((a)|b)*/; print "$1 $2\n";' b a % echo "abc" | sed -r -e "s/^((a)|b)*/\1 \2|/" b a|c
* Applying patch #726869 by Andrew I MacIntyre, reducing in _sre.c theGustavo Niemeyer2003-04-271-0/+9
| | | | recursion limit for certain setups of FreeBSD and OS/2.
* Made MAX_UNTIL/MIN_UNTIL code more coherent about mark protection,Gustavo Niemeyer2003-04-221-4/+6
| | | | accordingly to further discussions with Greg Chapman in patch #712900.
* More work on bug #672491 and patch #712900.Gustavo Niemeyer2003-04-201-23/+38
| | | | | | | | | | | | | | | | I've applied a modified version of Greg Chapman's patch. I've included the fixes without introducing the reorganization mentioned, for the sake of stability. Also, the second fix mentioned in the patch don't fix the mentioned problem anymore, because of the change introduced by patch #720991 (by Greg as well). The new fix wasn't complicated though, and is included as well. As a note. It seems that there are other places that require the "protection" of LASTMARK_SAVE()/LASTMARK_RESTORE(), and are just waiting for someone to find how to break them. Particularly, I belive that every recursion of SRE_MATCH() should be protected by these macros. I won't do that right now since I'm not completely sure about this, and we don't have much time for testing until the next release.
* - Fixed bug #672491. This change restores the behavior of lastindex/lastgroupGustavo Niemeyer2003-04-201-5/+4
| | | | | | to be compliant with previous python versions, by backing out the changes made in revision 2.84 which affected this. The bugfix for backtracking is still maintained.
* Fully support 32-bit codes. Enable BIGCHARSET in UCS-4 builds.Martin v. Löwis2003-04-191-10/+42
|
* SF patch #720991 by Gary Herron:Guido van Rossum2003-04-141-0/+60
| | | | | | | A small fix for bug #545855 and Greg Chapman's addition of op code SRE_OP_MIN_REPEAT_ONE for eliminating recursion on simple uses of pattern '*?' on a long string.
* fix for SF #635398 (don't "downcast" return strings from unicode to ascii)Fredrik Lundh2002-11-221-21/+4
|
* Make private functions static so we don't pollute the namespaceNeal Norwitz2002-11-101-1/+2
|
* Fixed sre bug "[#581080] Provoking infinite scanner loops".Gustavo Niemeyer2002-11-071-4/+6
| | | | | | | | | | | | | | | | This bug happened because: 1) the scanner_search and scanner_match methods were not checking the buffer limits before increasing the current pointer; and 2) SRE_SEARCH was using "if (ptr == end)" as a loop break, instead of "if (ptr >= end)". * Modules/_sre.c (SRE_SEARCH): Check for "ptr >= end" to break loops, so that we don't hang forever if a pointer passing the buffer limit is used. (scanner_search,scanner_match): Don't increment the current pointer if we're going to pass the buffer limit. * Misc/NEWS Mention the fix.
* Fixed bug #470582, using a modified version of patch #527371,Gustavo Niemeyer2002-11-061-18/+19
| | | | | | | | | | | | | | | | | | | from Greg Chapman. * Modules/_sre.c (lastmark_restore): New function, implementing algorithm to restore a state to a given lastmark. In addition to the similar algorithm used in a few places of SRE_MATCH, restore lastindex when restoring lastmark. (SRE_MATCH): Replace lastmark inline restoring by lastmark_restore(), function. Also include it where missing. In SRE_OP_MARK, set lastindex only if i > lastmark. * Lib/test/re_tests.py * Lib/test/test_sre.py Included regression tests for the fixed bugs. * Misc/NEWS Mention fixes.
* Cray fixup as seen in bug #558153.Michael W. Hudson2002-07-311-2/+2
|
* Land Patch [ 566100 ] Rationalize DL_IMPORT and DL_EXPORT.Mark Hammond2002-07-191-2/+1
|
* staticforward bites the dust.Jeremy Hylton2002-07-171-3/+3
| | | | | | | | | | | | | | | The staticforward define was needed to support certain broken C compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the static keyword when it was used with a forward declaration of a static initialized structure. Standard C allows the forward declaration with static, and we've decided to stop catering to broken C compilers. (In fact, we expect that the compilers are all fixed eight years later.) I'm leaving staticforward and statichere defined in object.h as static. This is only for backwards compatibility with C extensions that might still use it. XXX I haven't updated the documentation.
* SF #561244 Micro optimizationsNeal Norwitz2002-06-131-4/+1
| | | | Convert loops to memset()s.
* Revert use of METH_OLDARGS (use 0) to support 1.5.2Neal Norwitz2002-03-311-2/+4
|
* Use symbolic METH_VARARGS/METH_OLDARGS instead of 1/0 for ml_flagsNeal Norwitz2002-03-311-5/+5
|
* bug #133283, #477728, #483789, #490573Fredrik Lundh2001-12-091-19/+11
| | | | | | | backed out of broken minimal repeat patch from July also fixed a couple of minor potential resource leaks in pattern_subx (Guido had already fixed the big one)
* Patch supplied by Burton Radons for his own SF bug #487390: ModifyingGuido van Rossum2001-12-081-3/+3
| | | | | | | | | | | | | type.__module__ behavior. This adds the module name and a dot in front of the type name in every type object initializer, except for built-in types (and those that already had this). Note that it touches lots of Mac modules -- I have no way to test these but the changes look right. Apologies if they're not. This also touches the weakref docs, which contains a sample type object initializer. It also touches the mmap test output, because the mmap type's repr is included in that output. It touches object.h to put the correct description in a comment.
* Fix for #489672 (Neil Norwitz): memory leak in test_sre.Guido van Rossum2001-12-071-1/+4
| | | | | | | | | (At least for the repeatable test case that Tim produced.) pattern_subx(): Add missing DECREF(filter) in both exit branches (normal and error return). Also fix a DECREF(args) that should certainly be a DECREF(match) -- because it's inside if (!args) and right after allocation of match.
* (experimental) "finditer" method/function. this works pretty muchFredrik Lundh2001-10-241-0/+28
| | | | | like findall, but returns an iterator (which returns match objects) instead of a list of strings/tuples.
* another major speedup: let sre.sub/subn check for escapes in theFredrik Lundh2001-10-221-30/+89
| | | | | template string, and don't call the template compiler if we can avoid it.
* sre.split should return the last segment, even if emptyFredrik Lundh2001-10-221-11/+10
| | | | (sorry, barry)
* fixed character set description in docstring (SRE uses PythonFredrik Lundh2001-10-211-96/+41
| | | | | | | | | | | | | | | | | strings, not C strings) removed USE_PYTHON defines, and related sre.py helpers skip calling the subx helper if the template is callable. interestingly enough, this means that def callback(m): return literal result = pattern.sub(callback, string) is much faster than result = pattern.sub(literal, string)
* sre.Scanner fixes (from Greg Chapman). also added a Scanner sanityFredrik Lundh2001-10-211-0/+17
| | | | | | check to the test suite. added a few missing exception checks in the _sre module
* rewrote the pattern.sub and pattern.subn methods in CFredrik Lundh2001-10-211-113/+306
| | | | | | | | | removed (conceptually flawed) getliteral helper; the new sub/subn code uses a faster code path for literal replacement strings, but doesn't (yet) look for literal patterns. added STATE_OFFSET macro, and use it to convert state.start/ptr to char indexes
* rewrote the pattern.split method in CFredrik Lundh2001-10-201-12/+136
| | | | also restored SRE Unicode support for 1.6/2.0/2.1
* SRE bug #441409:Fredrik Lundh2001-10-181-1/+3
| | | | | | | | compile should raise error for non-strings SRE bug #432570, 448951: reset group after failed match also bumped version number to 2.2.0
* fixed #449964: sre.sub raises an exception if the template contains aFredrik Lundh2001-09-181-12/+16
| | | | | | \g<x> group reference followed by a character escape (also restructured a few things on the way to fixing #449000)
* an SRE bugfix a day keeps Guido away...Fredrik Lundh2001-09-181-9/+14
| | | | | | | #462270: sub-tle difference between pre.sub and sre.sub. PRE ignored an empty match at the previous location, SRE didn't. also synced with Secret Labs "sreopen" codebase.
* Removed unreachable return to silence SGI compiler.Sjoerd Mullender2001-08-301-2/+1
|
* Patch #445762: Support --disable-unicodeMartin v. Löwis2001-08-171-1/+1
| | | | | | | | - Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
* init_sre(): Plug a little leak reported by Insure.Barry Warsaw2001-08-161-2/+5
|
* map re.sub() to string.replace(), when possibleFredrik Lundh2001-07-081-0/+23
|