Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Feb 1998 14:51:36 -0800 (PST)
From:      Chris Timmons <skynyrd@opus.cts.cwu.edu>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   detecting regexp implementations with gnu autoconf
Message-ID:  <Pine.BSF.3.96.980227142144.22907B-100000@opus.cts.cwu.edu>

next in thread | raw e-mail | index | archive | help

I'm making some adjustments to a program which currently uses (linux?) 
regular expression processing:

	#include <regexp.h>
	Call compile() then step()

A solaris machine I have uses:

     #include <regexpr.h>

     char *compile(char *instring, char *expbuf,
          const char *endbuf);

     int step(const char *string, const char *expbuf);


It looks like *BSD supports POSIX regular expressions:

       #include <sys/types.h>
       #include <regex.h>

       int      regcomp(regex_t *preg,       const char *pattern,
                 int cflags);

       int regexec(const regex_t *preg,       const char *string,
                 size_t nmatch, regmatch_t pmatch[], int eflags);

       size_t regerror(int errcode,          const regex_t *preg,
                 char *errbuf, size_t errbuf_size);

       void regfree(regex_t *preg);


What would the best way to dance around this in the application program?
I want to submit source changes to the maintainers which will allow the
program to compile and run on *BSD.  Right now the plan is to have
autoconf look for regex.h, regcomp(), regexc(), regerror() and regfree()
as the signature for the POSIX implementation.  Otherwise use compile()
and step() if they are present.  

#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP) \ 
    && defined(HAVE_REGEXEC) && defined(HAVE_REGERROR) \
    && defined(HAVE_REGFREE)
#define USE_POSIX_REGEX 1

#elif defined(HAVE_COMPILE) && defined(HAVE_STEP)
#define USE_SYSV_REGEX 1

#else
#error "Need either POSIX or SYSV (compile/step) regex support."

#endif


Suggestions?

-Chris


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980227142144.22907B-100000>