diff options
Diffstat (limited to 'otherlibs/str/regex-0.12')
-rw-r--r-- | otherlibs/str/regex-0.12/regex.c | 57 | ||||
-rw-r--r-- | otherlibs/str/regex-0.12/regex.h | 13 |
2 files changed, 51 insertions, 19 deletions
diff --git a/otherlibs/str/regex-0.12/regex.c b/otherlibs/str/regex-0.12/regex.c index 3798992d8..4bf2a76cd 100644 --- a/otherlibs/str/regex-0.12/regex.c +++ b/otherlibs/str/regex-0.12/regex.c @@ -17,7 +17,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Modified by Xavier.Leroy@inria.fr for integration in Objective Caml +*/ /* AIX requires this to be the first thing in the file. */ #if defined (_AIX) && !defined (REGEX_MALLOC) @@ -2263,7 +2266,7 @@ compile_range (p_ptr, pend, translate, syntax, b) change it ourselves. */ /* Xavier Leroy 14/10/1998: bumped from 2000 to 8000 because 2000 causes failures even with relatively simple patterns */ -int re_max_failures = 8000; +static int re_max_failures = 8000; typedef const unsigned char *fail_stack_elt_t; @@ -4648,7 +4651,37 @@ re_compile_pattern (pattern, length, bufp) return re_error_msg[(int) ret]; } + +/* Free dynamically allocated space used by PREG. */ + +void +re_free (preg) + struct re_pattern_buffer *preg; +{ + if (preg->buffer != NULL) + free (preg->buffer); + preg->buffer = NULL; + + preg->allocated = 0; + preg->used = 0; + + if (preg->fastmap != NULL) + free (preg->fastmap); + preg->fastmap = NULL; + preg->fastmap_accurate = 0; + + if (preg->translate != NULL) + free (preg->translate); + preg->translate = NULL; +} + + +/* XL: we don't need the BSD/POSIX emulation, and it causes name conflicts + with some C libraries. */ + +#if 0 + /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ @@ -4707,7 +4740,7 @@ re_exec (s) /* POSIX.2 functions. Don't define these for Emacs. */ -#ifndef emacs +#if !defined(emacs) && !defined(CAML) /* regcomp takes a regular expression as a string and compiles it. @@ -4931,24 +4964,12 @@ void regfree (preg) regex_t *preg; { - if (preg->buffer != NULL) - free (preg->buffer); - preg->buffer = NULL; - - preg->allocated = 0; - preg->used = 0; - - if (preg->fastmap != NULL) - free (preg->fastmap); - preg->fastmap = NULL; - preg->fastmap_accurate = 0; - - if (preg->translate != NULL) - free (preg->translate); - preg->translate = NULL; + re_free(preg); } #endif /* not emacs */ + +#endif /* 0 */ /* Local variables: diff --git a/otherlibs/str/regex-0.12/regex.h b/otherlibs/str/regex-0.12/regex.h index 69c3f44b6..884ba94ae 100644 --- a/otherlibs/str/regex-0.12/regex.h +++ b/otherlibs/str/regex-0.12/regex.h @@ -15,7 +15,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Modified by Xavier.Leroy@inria.fr for integration in Objective Caml +*/ #ifndef __REGEXP_LIBRARY_H__ #define __REGEXP_LIBRARY_H__ @@ -470,6 +473,12 @@ extern void re_set_registers _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, unsigned num_regs, regoff_t *starts, regoff_t *ends)); +/* XL: free the given BUFFER */ +extern void re_free _RE_ARGS ((struct re_pattern_buffer *buffer)); + +#if 0 +/* XL: we don't need BSD/POSIX compatibility */ + /* 4.2 bsd compatibility. */ extern char *re_comp _RE_ARGS ((const char *)); extern int re_exec _RE_ARGS ((const char *)); @@ -484,6 +493,8 @@ extern size_t regerror size_t errbuf_size)); extern void regfree _RE_ARGS ((regex_t *preg)); +#endif + #endif /* not __REGEXP_LIBRARY_H__ */ /* |