1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
/********************************************************************
* $Author: jgoerzen $
* $Revision: 1.11 $
* $Date: 2002/02/12 20:57:18 $
* $Source: /var/cvs/gopher/object/Regex.h,v $
* $State: Exp $
*
* Paul Lindner, University of Minnesota CIS.
*
* Copyright 1991, 1992 by the Regents of the University of Minnesota
* see the file "Copyright" in the distribution for conditions of use.
*********************************************************************
* MODULE: Regex.h
* Portable method of doing regular expressions
*********************************************************************
* Revision History:
* $Log: Regex.h,v $
* Revision 1.11 2002/02/12 20:57:18 jgoerzen
* Fixed an incorrect comment and added parens
*
* Revision 1.10 2002/02/12 20:50:21 jgoerzen
* Beginning of MacOS X (Darwin) support.
* Many modifications to Regex.[ch], see debian/changelog for details.
*
* Revision 1.9 2002/02/12 19:54:18 jgoerzen
* Updated with regex fixes
*
* Revision 1.8 2002/01/10 18:48:31 jgoerzen
* Fix for Linux
*
* Revision 1.7 2002/01/10 18:43:18 jgoerzen
* * Changes to work with Solaris:
* * configure.in: Now looks for strings.h and string.h
* * object/Regex.h: Now include re_comp.h if available.
* Include regex.h only if re_comp.h is unavailable.
* Define the SYSVREGEX stuff only if HAVE_RE_COMP_H is not defined
* * object/String.h: Include string.h and strings.h based on configure
* test.
*
* Revision 1.6 2002/01/08 18:28:02 jgoerzen
* * object/Regex.h: now conditionally includes sys/types.h for regex.h
*
* Revision 1.5 2002/01/08 17:36:14 jgoerzen
* Finally builds!
*
* Changes:
*
* * config.h.in: rebuilt by autoheader
*
* * configure: rebuilt by autoconf
*
* * configure.in:
* * Added REGEXLIBS test for NetBSD -- look for re_comp in -lcompat
* * Added checkes for term.h, re_comp.h, regex.h
*
* * gopher/ourutils.c, gopher/CURcurses.c: Use term.h check
*
* * gopher/Makefile.in, gopherd/Makefile.in, gophfilt/Makefile.in:
* * Use REGEXLIBS
*
* * gopher/globals.h, gopher/gopher.c: Remove sys_errlist
*
* * object/GSgopherobj.c: Removed <regex.h> #include, now use
* "Regex.h" that has proper regex determining logic
*
* * object/Regex.h: Moved regex.h include to here. Make it conditional
* based on configure test. Add conditional re_comp.h include.
*
* Revision 1.4 2001/02/26 21:22:08 jgoerzen
* Updated
*
* Revision 1.3 2001/01/17 21:48:05 jgoerzen
* Many fixes and tune-ups. Now compiles cleanly with -Wall -Werror!
*
* Revision 1.2 2000/12/20 01:19:20 jgoerzen
* Added patches from David Allen <s2mdalle@titan.vcu.edu>
*
* Revision 1.1.1.1 2000/08/19 00:28:56 jgoerzen
* Import from UMN Gopher 2.3.1 after GPLization
*
* Revision 3.7 1994/07/25 13:56:54 lindner
* First crack at POSIX regular expressions
*
* Revision 3.6 1994/07/21 17:29:13 lindner
* Fix typo
*
* Revision 3.5 1994/03/08 04:04:16 lindner
* add regex.h for NeXT systems
*
* Revision 3.4 1994/03/04 17:42:00 lindner
* Fix for SCO machines
*
* Revision 3.3 1994/02/20 16:24:02 lindner
* no message
*
* Revision 3.2 1993/10/27 18:50:38 lindner
* Support for more sysv platforms
*
* Revision 3.1 1993/10/19 20:48:26 lindner
* Portable versions of Regular expression routines for System V and BSD..
*
*
*********************************************************************/
#ifndef __GOPHER_REGEX_H__
#define __GOPHER_REGEX_H__
#include "config.h"
#if defined(USG) || defined(__svr4__) || defined(_AUX_SOURCE) || defined(hpux) || defined(irix) || defined(M_XENIX) || defined(SYSVREGEX)
#define REGEX_SYSV
#define SYSVREGEX
#endif
#ifdef HAVE_SYS_TYPES_H
/* regex.h on Linux needs sys/types.h */
#include <sys/types.h>
#endif
/* The following define tells glibc in Linux to pull in headers
for BSD compatibility regex support. */
#define _REGEX_RE_COMP
#ifdef HAVE_RE_COMP_H
#include <re_comp.h>
#else
#if defined(HAVE_REGEX_H) && !defined(REGEX_SYSV) && !defined(__APPLE__)
#include <regex.h>
#else
/*
#ifdef HAVE_REGEXP_H
#include <regexp.h>
#endif */
#endif
#endif
/*
* Posix Regular expressions routines
*/
#if defined(REGEX_POSIX)
# include "Malloc.h"
#ifdef HAVE_LIBGEN_H
# include <libgen.h>
#endif
# define re_comp(a) (REGEX_param=regcomp(a,NULL))
# define re_exec(a) regex(REGEX_param,a)
#ifndef __GOPHER_REGEX_C__
extern char *REGEX_param;
#endif
# undef REGEX_POSIX
# define REGEX_POSIX
#endif /* REGEX_POSIX */
#ifdef __APPLE__
#include "Malloc.h"
#include <regexp.h>
#define re_comp(a) (REGEX_param=regcomp(a))
#define re_exec(a) regexec(REGEX_param,a)
#ifndef __GOPHER_REGEX_C__
extern regexp *REGEX_param;
#endif
#endif /* __APPLE__*/
#define _REGEX_RE_COMP
#ifdef REGEX_SYSV
#ifndef HAVE_RE_COMP_H
# include "Malloc.h" /** For NULL **/
# ifdef REGEX_CODEIT
# define INIT register char *sp = instring;
# define GETC() (*sp++)
# define PEEKC() (*sp)
# define UNGETC(c) (--sp)
# define RETURN(c) return(NULL);
# define ERROR(c) return("error")
# include <regexp.h>
# define REGEX_SYSV
# endif /* REGEX_CODEIT */
/*** BSDize the puppy ***/
char *re_comp();
int re_exec();
#else
/** BSD regex.. **/
/* Or Linux... taken care of in the headers. */
#endif /* defined(....) */
#endif
#endif /* __GOPHER_REGEX_H__ */
|