- fixed another split problem

(those semantics are weird...)

- got rid of $Id$'s (for the moment, at least).  in other
  words, there should be no more "empty" checkins.

- internal: some minor cleanups.
This commit is contained in:
Fredrik Lundh 2000-06-29 18:03:25 +00:00
parent 34a96371c3
commit 8094611eb8
6 changed files with 22 additions and 15 deletions

View File

@ -1,6 +1,5 @@
# #
# Secret Labs' Regular Expression Engine # Secret Labs' Regular Expression Engine
# $Id$
# #
# re-compatible interface for the sre matching engine # re-compatible interface for the sre matching engine
# #
@ -135,13 +134,14 @@ def _split(pattern, string, maxsplit=0):
if not m: if not m:
break break
b, e = m.span() b, e = m.span()
if e == i: if b == e:
if i >= len(string):
break
continue continue
append(string[i:b]) append(string[i:b])
if g and b != e: if g and b != e:
extend(m.groups()) extend(m.groups())
i = e i = e
n = n + 1 n = n + 1
if i < len(string):
append(string[i:]) append(string[i:])
return s return s

View File

@ -1,6 +1,5 @@
# #
# Secret Labs' Regular Expression Engine # Secret Labs' Regular Expression Engine
# $Id$
# #
# convert template to internal format # convert template to internal format
# #

View File

@ -1,6 +1,5 @@
# #
# Secret Labs' Regular Expression Engine # Secret Labs' Regular Expression Engine
# $Id$
# #
# various symbols used by the regular expression engine. # various symbols used by the regular expression engine.
# run this script to update the _sre include files! # run this script to update the _sre include files!

View File

@ -1,6 +1,5 @@
# #
# Secret Labs' Regular Expression Engine # Secret Labs' Regular Expression Engine
# $Id$
# #
# convert re-style regular expression to sre pattern # convert re-style regular expression to sre pattern
# #

View File

@ -1,7 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*- /* -*- Mode: C; tab-width: 4 -*-
* *
* Secret Labs' Regular Expression Engine * Secret Labs' Regular Expression Engine
* $Id$
* *
* regular expression matching engine * regular expression matching engine
* *
@ -31,7 +30,7 @@
#ifndef SRE_RECURSIVE #ifndef SRE_RECURSIVE
static char static char
copyright[] = " SRE 0.9.1 Copyright (c) 1997-2000 by Secret Labs AB "; copyright[] = " SRE 0.9.2 Copyright (c) 1997-2000 by Secret Labs AB ";
#include "Python.h" #include "Python.h"
@ -56,7 +55,7 @@ copyright[] = " SRE 0.9.1 Copyright (c) 1997-2000 by Secret Labs AB ";
#define HAVE_UNICODE #define HAVE_UNICODE
#endif #endif
#if defined(WIN32) /* FIXME: <fl> don't assume Windows == MSVC */ #if defined(_MSC_VER)
#pragma optimize("agtw", on) /* doesn't seem to make much difference... */ #pragma optimize("agtw", on) /* doesn't seem to make much difference... */
/* fastest possible local call under MSVC */ /* fastest possible local call under MSVC */
#define LOCAL(type) static __inline type __fastcall #define LOCAL(type) static __inline type __fastcall
@ -298,16 +297,21 @@ SRE_AT(SRE_STATE* state, SRE_CHAR* ptr, SRE_CODE at)
int this, that; int this, that;
switch (at) { switch (at) {
case SRE_AT_BEGINNING: case SRE_AT_BEGINNING:
return ((void*) ptr == state->beginning); return ((void*) ptr == state->beginning);
case SRE_AT_BEGINNING_LINE: case SRE_AT_BEGINNING_LINE:
return ((void*) ptr == state->beginning || return ((void*) ptr == state->beginning ||
SRE_IS_LINEBREAK((int) ptr[-1])); SRE_IS_LINEBREAK((int) ptr[-1]));
case SRE_AT_END: case SRE_AT_END:
return ((void*) ptr == state->end); return ((void*) ptr == state->end);
case SRE_AT_END_LINE: case SRE_AT_END_LINE:
return ((void*) ptr == state->end || return ((void*) ptr == state->end ||
SRE_IS_LINEBREAK((int) ptr[0])); SRE_IS_LINEBREAK((int) ptr[0]));
case SRE_AT_BOUNDARY: case SRE_AT_BOUNDARY:
if (state->beginning == state->end) if (state->beginning == state->end)
return 0; return 0;
@ -316,6 +320,7 @@ SRE_AT(SRE_STATE* state, SRE_CHAR* ptr, SRE_CODE at)
this = ((void*) ptr < state->end) ? this = ((void*) ptr < state->end) ?
SRE_IS_WORD((int) ptr[0]) : 0; SRE_IS_WORD((int) ptr[0]) : 0;
return this != that; return this != that;
case SRE_AT_NON_BOUNDARY: case SRE_AT_NON_BOUNDARY:
if (state->beginning == state->end) if (state->beginning == state->end)
return 0; return 0;
@ -365,7 +370,8 @@ SRE_MEMBER(SRE_CODE* set, SRE_CHAR ch)
break; break;
default: default:
/* FIXME: internal error */ /* internal error -- there's not much we can do about it
here, so let's just pretend it didn't match... */
return 0; return 0;
} }
} }
@ -910,14 +916,19 @@ SRE_SEARCH(SRE_STATE* state, SRE_CODE* pattern)
SRE_CHAR* ptr = state->start; SRE_CHAR* ptr = state->start;
SRE_CHAR* end = state->end; SRE_CHAR* end = state->end;
int status = 0; int status = 0;
int prefix_len = 0;
SRE_CODE* prefix = NULL;
if (pattern[0] == SRE_OP_INFO) { if (pattern[0] == SRE_OP_INFO) {
/* don't look too far */ /* args: <skip> <min> <max> <prefix> <prefix data...> */
end -= pattern[2]; end -= pattern[2];
prefix_len = pattern[4];
prefix = pattern + 5;
pattern += pattern[1]; pattern += pattern[1];
/* FIXME: add support for fast scan */
} }
/* if (prefix_len > 0) ... */
if (pattern[0] == SRE_OP_LITERAL) { if (pattern[0] == SRE_OP_LITERAL) {
/* pattern starts with a literal */ /* pattern starts with a literal */
SRE_CHAR chr = (SRE_CHAR) pattern[1]; SRE_CHAR chr = (SRE_CHAR) pattern[1];

View File

@ -1,8 +1,7 @@
/* /*
* Secret Labs' Regular Expression Engine * Secret Labs' Regular Expression Engine
* $Id$
* *
* simple regular expression matching engine * regular expression matching engine
* *
* Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved.
* *