regfronts.c

Go to the documentation of this file.
00001 /*
00002  * regcomp and regexec - front ends to re_ routines
00003  *
00004  * Mostly for implementation of backward-compatibility kludges. Note that
00005  * these routines exist ONLY in char versions.
00006  *
00007  * Copyright (c) 1998, 1999 Henry Spencer.  All rights reserved.
00008  *
00009  * Development of this software was funded, in part, by Cray Research Inc.,
00010  * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
00011  * Corporation, none of whom are responsible for the results.  The author
00012  * thanks all of them.
00013  *
00014  * Redistribution and use in source and binary forms -- with or without
00015  * modification -- are permitted for any purpose, provided that
00016  * redistributions in source form retain this entire copyright notice and
00017  * indicate the origin and nature of any modifications.
00018  *
00019  * I'd appreciate being given credit for this package in the documentation of
00020  * software which uses it, but that is not a requirement.
00021  *
00022  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
00023  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
00024  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
00025  * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00026  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00027  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00028  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00029  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00030  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00031  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032  */
00033 
00034 #include "regguts.h"
00035 
00036 /*
00037  - regcomp - compile regular expression
00038  */
00039 int
00040 regcomp(
00041     regex_t *re,
00042     CONST char *str,
00043     int flags)
00044 {
00045     size_t len;
00046     int f = flags;
00047 
00048     if (f&REG_PEND) {
00049         len = re->re_endp - str;
00050         f &= ~REG_PEND;
00051     } else {
00052         len = strlen(str);
00053     }
00054 
00055     return re_comp(re, str, len, f);
00056 }
00057 
00058 /*
00059  - regexec - execute regular expression
00060  */
00061 int
00062 regexec(
00063     regex_t *re,
00064     CONST char *str,
00065     size_t nmatch,
00066     regmatch_t pmatch[],
00067     int flags)
00068 {
00069     CONST char *start;
00070     size_t len;
00071     int f = flags;
00072 
00073     if (f & REG_STARTEND) {
00074         start = str + pmatch[0].rm_so;
00075         len = pmatch[0].rm_eo - pmatch[0].rm_so;
00076         f &= ~REG_STARTEND;
00077     } else {
00078         start = str;
00079         len = strlen(str);
00080     }
00081 
00082     return re_exec(re, start, len, nmatch, pmatch, f);
00083 }
00084 
00085 /*
00086  * Local Variables:
00087  * mode: c
00088  * c-basic-offset: 4
00089  * fill-column: 78
00090  * End:
00091  */



Generated on Wed Mar 12 12:18:10 2008 by  doxygen 1.5.1