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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
/********************************************************************
* $Author: jgoerzen $
* $Revision: 1.17 $
* $Date: 2002/03/19 20:57:55 $
* $Source: /home/jgoerzen/tmp/gopher-umn/gopher/head/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.17 2002/03/19 20:57:55 jgoerzen
* Modified #warn -> #warning to use correct syntax.
*
* Revision 1.16 2002/03/19 20:37:28 jgoerzen
* Updated configure stuff with regcomp and regfree checks.
* Made Regex.h more robust with regcomp stuff.
*
* Revision 1.15 2002/03/19 20:07:16 jgoerzen
* GSgopherobj.c: Moved Regex.h include up.
*
* Regex.c, Regex.h: continuing full rewrites.
*
* Revision 1.14 2002/03/19 19:58:12 jgoerzen
* More updates. This is part of a major rewrite.
*
* Revision 1.13 2002/03/19 19:53:31 jgoerzen
* *** empty log message ***
*
* Revision 1.12 2002/03/19 18:07:42 jgoerzen
* Fixed regex stuff for Solaris -- I hope!
*
* Updated changelog.
*
* More notes in Platforms.
*
* 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"
/*****************
Basic POSIX support detection */
#ifdef HAVE_SYS_TYPES_H
/* POSIX and Linux regex.h implementations want sys/types.h */
#include <sys/types.h>
#endif
#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
#if defined(HAVE_REGCOMP) && defined(HAVE_REGFREE)
#define REGEX_POSIX
#endif
/*************
OK, handle the POSIX case. */
#ifdef REGEX_POSIX
/* Try including files until we get REG_EXTENDED. */
#ifndef REG_EXTENDED
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#ifndef REG_EXTENDED
#ifdef HAVE_REGEXP_H
#include <regexp.h>
#endif
#endif
#ifndef REG_EXTENDED
#warning REGEX_POSIX defined but REG_EXTENDED not found.
#endif
/* These are named posix_re_comp and then #defined to the original names
because MacOS X is nice enough to typedef re_comp and re_exec differently
in unistd.h. Eww. */
char *posix_re_comp(char *regex);
int posix_re_exec(char *string);
#define re_comp(a) (posix_re_comp(a))
#define re_exec(a) (posix_re_exec(a))
#else
/* ********** Try to figure out what else they have. */
#ifdef HAVE_RE_COMP
/* This generally means that they have re_comp themselves. Just
include it for them and leave it. */
#ifdef HAVE_RE_COMP_H
#include <re_comp.h>
#else
#include <unistd.h>
#endif /* HAVE_RE_COMP_H */
#else
#ifdef HAVE_REGEXP_H
/* This means SYSV... */
#define SYSVREGEX
#define REGEX_SYSV
# 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>
# endif /* REGEX_CODEIT */
/* Prototypes for Regex.c */
char *re_comp(char *expr);
int re_exec(char *string);
#else
#error "Unsupported or no regexp support."
#endif /* REGEX_SYSV */
#endif /* HAVE_RE_COMP */
#endif /* REGEX_POSIX */
#endif /* __GOPHER_REGEX_H__ */
|