/*
* picksbr.c -- routines to help pick along...
*
- * $Id$
- *
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
static int tcompile();
static struct nexus *parse();
-static struct nexus *exp1();
-static struct nexus *exp2();
-static struct nexus *exp3();
+static struct nexus *nexp1();
+static struct nexus *nexp2();
+static struct nexus *nexp3();
static struct nexus *newnexus();
static int ORaction();
register char *cp;
register struct nexus *n, *o;
- if ((n = exp1 ()) == NULL || (cp = nxtarg ()) == NULL)
+ if ((n = nexp1 ()) == NULL || (cp = nxtarg ()) == NULL)
return n;
if (*cp != '-') {
}
static struct nexus *
-exp1 (void)
+nexp1 (void)
{
register char *cp;
register struct nexus *n, *o;
- if ((n = exp2 ()) == NULL || (cp = nxtarg ()) == NULL)
+ if ((n = nexp2 ()) == NULL || (cp = nxtarg ()) == NULL)
return n;
if (*cp != '-') {
case PRAND:
o = newnexus (ANDaction);
o->n_L_child = n;
- if ((o->n_R_child = exp1 ()))
+ if ((o->n_R_child = nexp1 ()))
return o;
padvise (NULL, "missing conjunctive");
return NULL;
static struct nexus *
-exp2 (void)
+nexp2 (void)
{
register char *cp;
register struct nexus *n;
if (*cp != '-') {
prvarg ();
- return exp3 ();
+ return nexp3 ();
}
if (*++cp == '-')
case PRNOT:
n = newnexus (NOTaction);
- if ((n->n_L_child = exp3 ()))
+ if ((n->n_L_child = nexp3 ()))
return n;
padvise (NULL, "missing negation");
return NULL;
header: ;
default:
prvarg ();
- return exp3 ();
+ return nexp3 ();
}
}
static struct nexus *
-exp3 (void)
+nexp3 (void)
{
int i;
register char *cp, *dp;
padvise (NULL, "missing argument to %s", argp[-2]);
return NULL;
}
- return exp3 ();
+ return nexp3 ();
case PRAFTR:
case PRBEFR:
dasctime (&n->n_tws, TW_NULL));
return;
}
- fprintf (stderr, "UNKNOWN(0x%x)\n", (unsigned int) (*n->n_action));
+ fprintf (stderr, "UNKNOWN(0x%x)\n",
+ (unsigned int)(unsigned long) (*n->n_action));
}
{
register int c;
int cclcnt;
- register char *ep, *dp, *sp, *lastep = 0;
+ register unsigned char *ep, *dp, *sp, *lastep = 0;
dp = (ep = n->n_expbuf) + sizeof n->n_expbuf;
sp = astr;
case '[':
*ep++ = CCL;
*ep++ = 0;
- cclcnt = 1;
+ cclcnt = 0;
if ((c = *sp++) == '^') {
c = *sp++;
ep[-2] = NCCL;
goto cerror;
}
} while ((c = *sp++) != ']');
+ if (cclcnt > 255)
+ goto cerror;
lastep[1] = cclcnt;
continue;
static int
advance (char *alp, char *aep)
{
- register char *lp, *ep, *curlp;
+ register unsigned char *lp, *ep, *curlp;
- lp = alp;
- ep = aep;
+ lp = (unsigned char *)alp;
+ ep = (unsigned char *)aep;
for (;;)
switch (*ep++) {
case CCHR:
- if (*ep++ == *lp++ || ep[-1] == cc[(unsigned char)lp[-1]])
+ if (*ep++ == *lp++ || ep[-1] == cc[lp[-1]])
continue;
return 0;
case CCL:
if (cclass (ep, *lp++, 1)) {
- ep += *ep;
+ ep += *ep + 1;
continue;
}
return 0;
case NCCL:
if (cclass (ep, *lp++, 0)) {
- ep += *ep;
+ ep += *ep + 1;
continue;
}
return 0;
case CCHR | STAR:
curlp = lp;
- while (*lp++ == *ep || cc[(unsigned char)lp[-1]] == *ep)
+ while (*lp++ == *ep || cc[lp[-1]] == *ep)
continue;
ep++;
goto star;
curlp = lp;
while (cclass (ep, *lp++, ep[-1] == (CCL | STAR)))
continue;
- ep += *ep;
+ ep += *ep + 1;
goto star;
star:
static int
-cclass (char *aset, int ac, int af)
+cclass (unsigned char *aset, int ac, int af)
{
- register int n;
- register char c,
- *set;
+ register unsigned int n;
+ register unsigned char c, *set;
set = aset;
if ((c = ac) == 0)
return (0);
n = *set++;
- while (--n)
- if (*set++ == c || set[-1] == cc[(unsigned char)c])
+ while (n--)
+ if (*set++ == c || set[-1] == cc[c])
return (af);
return (!af);