/*
* Copyright (c) 2005, 2008 Sun Microsystems, Inc. All Rights Reserved.
* Use is subject to license terms.
*
* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
* All Rights Reserved
*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Code moved from regexp.h */
#include "apr.h"
#include "apr_lib.h"
#ifdef APR_HAVE_LIMITS_H
#include <limits.h>
#endif
#include <stdlib.h>
#endif
#include "libsed.h"
#include "regexp.h"
#include "sed.h"
#define SEDCOMPILE_ERROR(c) { \
regerrno = c; \
goto out; \
}
static int _advance(char *, char *, step_vars_storage *);
{
}
/*
*/
{
switch(err) {
case 0:
/* No error */
break;
case 11:
break;
case 16:
break;
case 25:
break;
case 36:
break;
case 41:
break;
case 42:
break;
case 43:
break;
case 44:
break;
case 45:
break;
case 46:
break;
case 49:
break;
case 50:
break;
default:
break;
}
return (0);
}
{
int c;
char *lastep;
int cclcnt;
int closed;
int neg;
int lc;
int i, cflg;
int regerrno = 0;
lastep = 0;
if (c == '\n') {
UNGETC(c);
}
goto out;
}
if (c == '^')
else
UNGETC(c);
while (1) {
SEDCOMPILE_ERROR(50);
c = GETC();
if (c == eof) {
SEDCOMPILE_ERROR(42);
goto out;
}
switch (c) {
case '.':
continue;
case '\n':
SEDCOMPILE_ERROR(36);
goto out;
case '*':
goto defchar;
continue;
case '$':
goto defchar;
continue;
case '[':
SEDCOMPILE_ERROR(50);
lc = 0;
for (i = 0; i < 16; i++)
ep[i] = 0;
neg = 0;
if ((c = GETC()) == '^') {
neg = 1;
c = GETC();
}
iflag = 1;
do {
c &= 0377;
if (c == '\0' || c == '\n')
SEDCOMPILE_ERROR(49);
if ((c & 0200) && iflag) {
iflag = 0;
SEDCOMPILE_ERROR(50);
for (i = 16; i < 32; i++)
ep[i] = 0;
}
if (c == '-' && lc != 0) {
if ((c = GETC()) == ']') {
PLACE('-');
break;
}
if ((c & 0200) && iflag) {
iflag = 0;
SEDCOMPILE_ERROR(50);
for (i = 16; i < 32; i++)
ep[i] = 0;
}
while (lc < c) {
lc++;
}
}
lc = c;
PLACE(c);
} while ((c = GETC()) != ']');
if (iflag)
iflag = 16;
else
iflag = 32;
if (neg) {
if (iflag == 32) {
cclcnt++)
ep[0] &= 0376;
} else {
/* make nulls match so test fails */
ep[0] |= 01;
}
}
continue;
case '\\':
switch (c = GETC()) {
case '(':
SEDCOMPILE_ERROR(43);
continue;
case ')':
SEDCOMPILE_ERROR(42);
closed++;
continue;
case '{':
if (lastep == (char *) 0)
goto defchar;
cflg = 0;
nlim:
c = GETC();
i = 0;
do {
if ('0' <= c && c <= '9')
i = 10 * i + c - '0';
else
SEDCOMPILE_ERROR(16);
if (i >= 255)
SEDCOMPILE_ERROR(11);
*ep++ = i;
if (c == ',') {
if (cflg++)
SEDCOMPILE_ERROR(44);
if ((c = GETC()) == '\\')
*ep++ = (char) 255;
else {
UNGETC(c);
goto nlim;
/* get 2'nd number */
}
}
if (GETC() != '}')
SEDCOMPILE_ERROR(45);
if (!cflg) /* one number */
*ep++ = i;
SEDCOMPILE_ERROR(46);
continue;
case '\n':
SEDCOMPILE_ERROR(36);
case 'n':
c = '\n';
goto defchar;
default:
if (c >= '1' && c <= '9') {
if ((c -= '1') >= closed)
SEDCOMPILE_ERROR(25);
*ep++ = c;
continue;
}
}
/* Drop through to default to use \ to turn off special chars */
default:
*ep++ = c;
}
}
out:
if (regerrno) {
return (char*) NULL;
}
/* XXX : Basant : what extra */
/* int reglength = (int)(ep - expbuf); */
return ep;
}
{
int c;
if (circf) {
}
/* fast check for first character */
c = p2[1];
do {
if (*p1 != c)
continue;
return (1);
}
} while (*p1++);
return (0);
}
/* regular algorithm */
do {
return (1);
}
} while (*p1++);
return (0);
}
{
char *curlp;
int c;
char *bbeg;
char neg;
int ct;
while (1) {
neg = 0;
switch (*ep++) {
case CCHR:
continue;
return (0);
case CDOT:
if (*lp++)
continue;
return (0);
case CDOL:
if (*lp == 0)
continue;
return (0);
case CCEOF:
return (1);
case CXCL:
c = (unsigned char)*lp++;
if (ISTHERE(c)) {
ep += 32;
continue;
}
return (0);
case NCCL:
neg = 1;
case CCL:
c = *lp++;
ep += 16;
continue;
}
return (0);
case CBRA:
ep++;
continue;
case CKET:
ep++;
continue;
c = *ep++;
if (*lp++ != c)
return (0);
if (*lp++ != c)
break;
lp++;
ep += 2;
goto star;
if (*lp++ == '\0')
return (0);
if (*lp++ == '\0')
break;
lp++;
ep += 2;
goto star;
c = (unsigned char)*lp++;
if (!ISTHERE(c))
return (0);
}
c = (unsigned char)*lp++;
if (!ISTHERE(c))
break;
}
lp++;
goto star;
neg = 1;
c = *lp++;
return (0);
}
c = *lp++;
break;
}
lp++;
goto star;
case CBACK:
ep++;
continue;
}
return (0);
ep++;
return (1);
}
return (0);
while (*lp++);
goto star;
ep++;
goto star;
do {
c = (unsigned char)*lp++;
} while (ISTHERE(c));
ep += 32;
goto star;
neg = 1;
do {
c = *lp++;
ep += 16;
goto star;
star:
do {
break;
return (1);
return (0);
}
}
}
{
}