1/* 2 * regcomp and regexec - front ends to re_ routines 3 * 4 * Mostly for implementation of backward-compatibility kludges. Note that 5 * these routines exist ONLY in char versions. 6 * 7 * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. 8 * 9 * Development of this software was funded, in part, by Cray Research Inc., 10 * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics 11 * Corporation, none of whom are responsible for the results. The author 12 * thanks all of them. 13 * 14 * Redistribution and use in source and binary forms -- with or without 15 * modification -- are permitted for any purpose, provided that 16 * redistributions in source form retain this entire copyright notice and 17 * indicate the origin and nature of any modifications. 18 * 19 * I'd appreciate being given credit for this package in the documentation of 20 * software which uses it, but that is not a requirement. 21 * 22 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 24 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25 * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include "regguts.h" 35 36/* 37 - regcomp - compile regular expression 38 */ 39int 40regcomp( 41 regex_t *re, 42 CONST char *str, 43 int flags) 44{ 45 size_t len; 46 int f = flags; 47 48 if (f®_PEND) { 49 len = re->re_endp - str; 50 f &= ~REG_PEND; 51 } else { 52 len = strlen(str); 53 } 54 55 return re_comp(re, str, len, f); 56} 57 58/* 59 - regexec - execute regular expression 60 */ 61int 62regexec( 63 regex_t *re, 64 CONST char *str, 65 size_t nmatch, 66 regmatch_t pmatch[], 67 int flags) 68{ 69 CONST char *start; 70 size_t len; 71 int f = flags; 72 73 if (f & REG_STARTEND) { 74 start = str + pmatch[0].rm_so; 75 len = pmatch[0].rm_eo - pmatch[0].rm_so; 76 f &= ~REG_STARTEND; 77 } else { 78 start = str; 79 len = strlen(str); 80 } 81 82 return re_exec(re, start, len, nmatch, pmatch, f); 83} 84 85/* 86 * Local Variables: 87 * mode: c 88 * c-basic-offset: 4 89 * fill-column: 78 90 * End: 91 */ 92