X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/5dd6771b28c257af405d7248639ed0e3bcdce38b..a1067dea91a4cb3fc71b0b33271d2c7c9c8a2d7a:/sbr/mf.c diff --git a/sbr/mf.c b/sbr/mf.c index fd92e369..37fcf7b9 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -16,7 +16,6 @@ * static prototypes */ static char *getcpy (char *); -static void compress (char *, unsigned char *); static int isat (char *); static int parse_address (void); static int phrase (char *); @@ -55,14 +54,16 @@ isfrom(char *string) int -lequal (unsigned char *a, unsigned char *b) +lequal (char *a, char *b) { for (; *a; a++, b++) if (*b == 0) return FALSE; else { - char c1 = islower (*a) ? toupper (*a) : *a; - char c2 = islower (*b) ? toupper (*b) : *b; + char c1 = islower ((unsigned char) *a) ? + toupper ((unsigned char) *a) : *a; + char c2 = islower ((unsigned char) *b) ? + toupper ((unsigned char) *b) : *b; if (c1 != c2) return FALSE; } @@ -71,158 +72,6 @@ lequal (unsigned char *a, unsigned char *b) } -/* - * seekadrx() is tricky. We want to cover both UUCP-style and ARPA-style - * addresses, so for each list of addresses we see if we can find some - * character to give us a hint. - */ - - -#define CHKADR 0 /* undertermined address style */ -#define UNIXDR 1 /* UNIX-style address */ -#define ARPADR 2 /* ARPAnet-style address */ - - -static char *punctuators = ";<>.()[]"; -static char *vp = NULL; -static char *tp = NULL; - -static struct adrx adrxs1; - - -struct adrx * -seekadrx (char *addrs) -{ - static int state = CHKADR; - register char *cp; - register struct adrx *adrxp; - - if (state == CHKADR) - for (state = UNIXDR, cp = addrs; *cp; cp++) - if (strchr(punctuators, *cp)) { - state = ARPADR; - break; - } - - switch (state) { - case UNIXDR: - adrxp = uucpadrx (addrs); - break; - - case ARPADR: - default: - adrxp = getadrx (addrs); - break; - } - - if (adrxp == NULL) - state = CHKADR; - - return adrxp; -} - - -/* - * uucpadrx() implements a partial UUCP-style address parser. It's based - * on the UUCP notion that addresses are separated by spaces or commas. - */ - - -struct adrx * -uucpadrx (char *addrs) -{ - register unsigned char *cp, *wp, *xp, *yp; - register char *zp; - register struct adrx *adrxp = &adrxs1; - - if (vp == NULL) { - vp = tp = getcpy (addrs); - compress (addrs, vp); - } - else - if (tp == NULL) { - free (vp); - vp = NULL; - return NULL; - } - - for (cp = tp; isspace (*cp); cp++) - continue; - if (*cp == 0) { - free (vp); - vp = tp = NULL; - return NULL; - } - - if ((wp = strchr(cp, ',')) == NULL) { - if ((wp = strchr(cp, ' ')) != NULL) { - xp = wp; - while (isspace (*xp)) - xp++; - if (*xp != 0 && isat (--xp)) { - yp = xp + 4; - while (isspace (*yp)) - yp++; - if (*yp != 0) { - if ((zp = strchr(yp, ' ')) != NULL) - *zp = 0, tp = ++zp; - else - tp = NULL; - } - else - *wp = 0, tp = ++wp; - } - else - *wp = 0, tp = ++wp; - } - else - tp = NULL; - } - else - *wp = 0, tp = ++wp; - - if (adrxp->text) - free (adrxp->text); - adrxp->text = getcpy (cp); - adrxp->mbox = cp; - adrxp->host = adrxp->path = NULL; - if ((wp = strrchr(cp, '@')) != NULL) { - *wp++ = 0; - adrxp->host = *wp ? wp : NULL; - } - else - for (wp = cp + strlen (cp) - 4; wp >= cp; wp--) - if (isat (wp)) { - *wp++ = 0; - adrxp->host = wp + 3; - } - - adrxp->pers = adrxp->grp = adrxp->note = adrxp->err = NULL; - adrxp->ingrp = 0; - - return adrxp; -} - - -static void -compress (char *fp, unsigned char *tp) -{ - register char c; - register unsigned char *cp; - - for (c = ' ', cp = tp; (*tp = *fp++) != 0;) - if (isspace (*tp)) { - if (c != ' ') - *tp++ = c = ' '; - } - else - c = *tp++; - - if (c == ' ' && cp < tp) - *--tp = 0; -} - - static int isat (char *p) { @@ -333,8 +182,8 @@ static int ingrp = 0; static int last_lex = LX_END; static char *dp = NULL; -static unsigned char *cp = NULL; -static unsigned char *ap = NULL; +static char *cp = NULL; +static char *ap = NULL; static char *pers = NULL; static char *mbox = NULL; static char *host = NULL; @@ -416,7 +265,7 @@ getadrx (char *addrs) } break; } - while (isspace (*ap)) + while (isspace ((unsigned char) *ap)) ap++; if (cp) sprintf (adr, "%.*s", (int)(cp - ap), ap); @@ -759,8 +608,7 @@ my_lex (char *buffer) { /* buffer should be at least BUFSIZ bytes long */ int i, gotat = 0; - register unsigned char c; - register char *bp; + char c, *bp; /* Add C to the buffer bp. After use of this macro *bp is guaranteed to be within the buffer. */ #define ADDCHR(C) do { *bp++ = (C); if ((bp - buffer) == (BUFSIZ-1)) goto my_lex_buffull; } while (0) @@ -772,7 +620,7 @@ my_lex (char *buffer) gotat = isat (cp); c = *cp++; - while (isspace (c)) + while (isspace ((unsigned char) c)) c = *cp++; if (c == 0) { cp = NULL; @@ -862,7 +710,7 @@ my_lex (char *buffer) if (c == special[i].lx_chr) return (last_lex = special[i].lx_val); - if (iscntrl (c)) + if (iscntrl ((unsigned char) c)) return (last_lex = LX_ERR); for (;;) { @@ -871,7 +719,7 @@ my_lex (char *buffer) for (i = 0; special[i].lx_chr != 0; i++) if (c == special[i].lx_chr) goto got_atom; - if (iscntrl (c) || isspace (c)) + if (iscntrl ((unsigned char) c) || isspace ((unsigned char) c)) break; ADDCHR(c); }