summaryrefslogtreecommitdiffstats
path: root/Modules/_sre.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* bug #416670Fredrik Lundh2001-07-031-16/+87
| | | | | added copy/deepcopy support to SRE (still not enabled, since it's not covered by the test suite)
* reapplied darryl gallion's minimizing repeat fix. I'm still not 100%Fredrik Lundh2001-07-021-1/+1
| | | | | sure about this one, but test #133283 now works even with the fix in place, and so does the test suite. we'll see what comes up...
* pythonware repository roundtrip (untabification)Fredrik Lundh2001-07-021-12/+13
|
* added martin's BIGCHARSET patch to SRE 2.1.1. martin reports 2xFredrik Lundh2001-07-021-0/+13
| | | | speedups for certain unicode character ranges.
* merged with pythonware's SRE 2.1.1 codebaseFredrik Lundh2001-07-021-2/+92
|
* SRE: made "copyright" string static, to avoid potential linkingFredrik Lundh2001-04-151-1/+8
| | | | conflicts.
* sre 2.1b2 update:Fredrik Lundh2001-03-221-16/+58
| | | | | | - take locale into account for word boundary anchors (#410271) - restored 2.0's *? behaviour (#233283, #408936 and others) - speed up re.sub/re.subn
* SF patch 404928: Support for next Cygwin gcc (2.95.2-8)Tim Peters2001-02-281-4/+1
|
* bumped SRE version number to 2.1. cleaned up and added 1.5.2Fredrik Lundh2001-01-161-25/+41
| | | | compatibility patches.
* fixed a memory leak in pattern cleanup (patch #103248 by cgw)Fredrik Lundh2001-01-161-2/+6
|
* added "magic" number to the _sre module, to avoid weird errors causedFredrik Lundh2001-01-151-1/+9
| | | | by compiler/engine mismatches
* -- don't use recursion for unbounded non-greedy repeatFredrik Lundh2001-01-141-2/+13
| | | | | | | | (bugs #115903, #115696) This is based on a patch by Darrel Gallion. I'm not 100% sure about this fix, but I haven't managed to come up with any test case it cannot handle...
* SRE fixes for 2.1 alpha:Fredrik Lundh2001-01-141-23/+33
| | | | | | | | | | -- added some more docstrings -- fixed typo in scanner class (#125531) -- the multiline flag (?m) should't affect the \Z operator (#127259) -- fixed non-greedy backtracking bug (#123769, #127259) -- added sre.DEBUG flag (currently dumps the parsed pattern structure) -- fixed a couple of glitches in groupdict (the #126587 memory leak had already been fixed by AMK)
* Fix bug 126587: matchobject.groupdict() leaks memory because of a missingAndrew M. Kuchling2000-12-221-0/+1
| | | | DECREF
* -- properly reset groups in findall (bug #117612)Fredrik Lundh2000-10-281-15/+18
| | | | | | | | -- fixed negative lookbehind to work correctly at the beginning of the target string (bug #117242) -- improved syntax check; you can no longer refer to a group inside itself (bug #110866)
* Accept keyword arguments for (most) pattern and match objectFredrik Lundh2000-10-031-31/+45
| | | | methods. Closes buglet #115845.
* Fixed negative lookahead/lookbehind. Closes bug #115618.Fredrik Lundh2000-10-031-4/+1
|
* Rationalize use of limits.h, moving the inclusion to Python.h.Fred Drake2000-09-261-6/+0
| | | | | | | | Add definitions of INT_MAX and LONG_MAX to pyport.h. Remove includes of limits.h and conditional definitions of INT_MAX and LONG_MAX elsewhere. This closes SourceForge patch #101659 and bug #115323.
* - fixed yet another gcc -pedantic warningFredrik Lundh2000-09-211-16/+47
| | | | | - added experimental "expand" method to match objects - don't use the buffer interface on unicode strings
* return -1 for undefined groups (as implemented in 1.5.2) instead ofFredrik Lundh2000-09-021-16/+4
| | | | None (as documented) from start/end/span. closes bug #113254
* oops. accidentally reintroduced a memory leak. put the bugfix back.Fredrik Lundh2000-08-271-3/+4
|
* don't mistake memory errors (including reaching the recursion limit)Fredrik Lundh2000-08-271-18/+24
| | | | | | | with success. also, check return values from the mark functions. this addresses (but doesn't really solve) bug #112693, and low-memory problems reported by jack jansen.
* pattern_findall(): Plug small memory leak discovered by Insure.Barry Warsaw2000-08-181-3/+3
| | | | | PyList_Append() always incref's the inserted item. Be sure to decref it regardless of whether the append succeeds or fails.