New versions straight from Jeffrey Ollie's web site

This commit is contained in:
Guido van Rossum 1997-07-10 14:31:32 +00:00
parent db9e20f418
commit db25f32849
3 changed files with 698 additions and 167 deletions

View file

@ -1,3 +1,7 @@
/*
* -*- mode: c-mode; c-file-style: python -*-
*/
#ifndef Py_REGEXPR_H
#define Py_REGEXPR_H
#ifdef __cplusplus
@ -5,22 +9,22 @@ extern "C" {
#endif
/*
* regexpr.h
*
* Author: Tatu Ylonen <ylo@ngs.fi>
*
* Copyright (c) 1991 Tatu Ylonen, Espoo, Finland
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies. This
* software is provided "as is" without express or implied warranty.
*
* Created: Thu Sep 26 17:15:36 1991 ylo
* Last modified: Mon Nov 4 15:49:46 1991 ylo
*/
regexpr.h
Author: Tatu Ylonen <ylo@ngs.fi>
Copyright (c) 1991 Tatu Ylonen, Espoo, Finland
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies. This
software is provided "as is" without express or implied warranty.
Created: Thu Sep 26 17:15:36 1991 ylo
Last modified: Mon Nov 4 15:49:46 1991 ylo
*/
/* $Id$ */
#ifndef REGEXPR_H
#define REGEXPR_H
@ -29,21 +33,22 @@ Last modified: Mon Nov 4 15:49:46 1991 ylo
typedef struct re_pattern_buffer
{
char *buffer; /* compiled pattern */
int allocated; /* allocated size of compiled pattern */
int used; /* actual length of compiled pattern */
char *fastmap; /* fastmap[ch] is true if ch can start pattern */
char *translate; /* translation to apply during compilation/matching */
char fastmap_accurate; /* true if fastmap is valid */
char can_be_null; /* true if can match empty string */
char uses_registers; /* registers are used and need to be initialized */
char anchor; /* anchor: 0=none 1=begline 2=begbuf */
char *buffer; /* compiled pattern */
int allocated; /* allocated size of compiled pattern */
int used; /* actual length of compiled pattern */
char *fastmap; /* fastmap[ch] is true if ch can start pattern */
char *translate; /* translation to apply during compilation/matching */
char fastmap_accurate; /* true if fastmap is valid */
char can_be_null; /* true if can match empty string */
char uses_registers; /* registers are used and need to be initialized */
int num_registers; /* number of registers used */
char anchor; /* anchor: 0=none 1=begline 2=begbuf */
} *regexp_t;
typedef struct re_registers
{
int start[RE_NREGS]; /* start offset of region */
int end[RE_NREGS]; /* end offset of region */
int start[RE_NREGS]; /* start offset of region */
int end[RE_NREGS]; /* end offset of region */
} *regexp_registers_t;
/* bit definitions for syntax */
@ -77,52 +82,53 @@ typedef struct re_registers
#ifdef HAVE_PROTOTYPES
extern int re_syntax;
/* This is the actual syntax mask. It was added so that Python
could do syntax-dependent munging of patterns before compilation. */
/* This is the actual syntax mask. It was added so that Python could do
* syntax-dependent munging of patterns before compilation. */
int re_set_syntax(int syntax);
/* This sets the syntax to use and returns the previous syntax. The
syntax is specified by a bit mask of the above defined bits. */
* syntax is specified by a bit mask of the above defined bits. */
char *re_compile_pattern(char *regex, int regex_size, regexp_t compiled);
/* This compiles the regexp (given in regex and length in regex_size).
This returns NULL if the regexp compiled successfully, and an error
message if an error was encountered. The buffer field must be
initialized to a memory area allocated by malloc (or to NULL) before
use, and the allocated field must be set to its length (or 0 if buffer is
NULL). Also, the translate field must be set to point to a valid
translation table, or NULL if it is not used. */
* This returns NULL if the regexp compiled successfully, and an error
* message if an error was encountered. The buffer field must be
* initialized to a memory area allocated by malloc (or to NULL) before
* use, and the allocated field must be set to its length (or 0 if
* buffer is NULL). Also, the translate field must be set to point to a
* valid translation table, or NULL if it is not used. */
int re_match(regexp_t compiled, char *string, int size, int pos,
regexp_registers_t old_regs);
/* This tries to match the regexp against the string. This returns the
length of the matched portion, or -1 if the pattern could not be
matched and -2 if an error (such as failure stack overflow) is
encountered. */
* length of the matched portion, or -1 if the pattern could not be
* matched and -2 if an error (such as failure stack overflow) is
* encountered. */
int re_search(regexp_t compiled, char *string, int size, int startpos,
int range, regexp_registers_t regs);
/* This rearches for a substring matching the regexp. This returns the first
index at which a match is found. range specifies at how many positions to
try matching; positive values indicate searching forwards, and negative
values indicate searching backwards. mstop specifies the offset beyond
which a match must not go. This returns -1 if no match is found, and
-2 if an error (such as failure stack overflow) is encountered. */
/* This rearches for a substring matching the regexp. This returns the
* first index at which a match is found. range specifies at how many
* positions to try matching; positive values indicate searching
* forwards, and negative values indicate searching backwards. mstop
* specifies the offset beyond which a match must not go. This returns
* -1 if no match is found, and -2 if an error (such as failure stack
* overflow) is encountered. */
void re_compile_fastmap(regexp_t compiled);
/* This computes the fastmap for the regexp. For this to have any effect,
the calling program must have initialized the fastmap field to point
to an array of 256 characters. */
* the calling program must have initialized the fastmap field to point
* to an array of 256 characters. */
char *re_comp(char *s);
/* BSD 4.2 regex library routine re_comp. This compiles the regexp into
an internal buffer. This returns NULL if the regexp was compiled
successfully, and an error message if there was an error. */
* an internal buffer. This returns NULL if the regexp was compiled
* successfully, and an error message if there was an error. */
int re_exec(char *s);
/* BSD 4.2 regexp library routine re_exec. This returns true if the string
matches the regular expression (that is, a matching part is found
anywhere in the string). */
/* BSD 4.2 regexp library routine re_exec. This returns true if the
* string matches the regular expression (that is, a matching part is
* found anywhere in the string). */
#else /* HAVE_PROTOTYPES */