- case PRAFTR:
- case PRBEFR:
- if (!(cp = nxtarg ())) {/* allow -xyz arguments */
- padvise (NULL, "missing argument to %s", argp[-2]);
- return NULL;
- }
- n = newnexus (TWSaction);
- n->n_datef = datesw;
- if (!tcompile (cp, &n->n_tws, n->n_after = i == PRAFTR)) {
- padvise (NULL, "unable to parse %s %s", argp[-2], cp);
- return NULL;
- }
- return n;
- }
+ if (*++cp == '-') {
+ dp = ++cp;
+ goto header;
+ }
+ switch (i = smatch(cp, parswit)) {
+ case AMBIGSW:
+ ambigsw(cp, parswit);
+ talked++;
+ return NULL;
+ case UNKWNSW:
+ fprintf(stderr, "-%s unknown\n", cp);
+ talked++;
+ return NULL;
+
+ case PRLBR:
+ if ((n = parse()) == NULL) {
+ padvise(NULL, "missing group");
+ return NULL;
+ }
+ if ((cp = nxtarg()) == NULL) {
+ padvise(NULL, "missing -rbrace");
+ return NULL;
+ }
+ if (*cp++ == '-' && smatch(cp, parswit) == PRRBR)
+ return n;
+ padvise(NULL, "%s unexpected", --cp);
+ return NULL;
+
+ default:
+ prvarg();
+ return NULL;
+
+ case PRCC:
+ case PRDATE:
+ case PRFROM:
+ case PRTO:
+ case PRSUBJ:
+ strncpy(temp, parswit[i].sw, sizeof(temp));
+ temp[sizeof(temp) - 1] = '\0';
+ dp = *brkstring(temp, " ", NULL);
+header: ;
+ if (!(cp = nxtarg())) { /* allow -xyz arguments */
+ padvise(NULL, "missing argument to %s",
+ argp[-2]);
+ return NULL;
+ }
+ n = newnexus(GREPaction);
+ n->n_header = 1;
+ snprintf(buffer, sizeof(buffer), "^%s[ \t]*:.*%s",
+ dp, cp);
+ dp = buffer;
+ goto pattern;
+
+ case PRSRCH:
+ n = newnexus(GREPaction);
+ n->n_header = 0;
+ if (!(cp = nxtarg())) { /* allow -xyz arguments */
+ padvise(NULL, "missing argument to %s",
+ argp[-2]);
+ return NULL;
+ }
+ dp = cp;
+pattern: ;
+ if (!gcompile(n, dp)) {
+ padvise(NULL, "pattern error in %s %s",
+ argp[-2], cp);
+ return NULL;
+ }
+ n->n_patbuf = getcpy(dp);
+ return n;
+
+ case PROTHR:
+ padvise(NULL, "internal error!");
+ return NULL;
+
+ case PRDATF:
+ if (!(datesw = nxtarg()) || *datesw == '-') {
+ padvise(NULL, "missing argument to %s",
+ argp[-2]);
+ return NULL;
+ }
+ return nexp3();
+
+ case PRAFTR:
+ case PRBEFR:
+ if (!(cp = nxtarg())) { /* allow -xyz arguments */
+ padvise(NULL, "missing argument to %s",
+ argp[-2]);
+ return NULL;
+ }
+ n = newnexus(TWSaction);
+ n->n_datef = datesw;
+ if (!tcompile(cp, &n->n_tws, n->n_after =
+ i == PRAFTR)) {
+ padvise(NULL, "unable to parse %s %s",
+ argp[-2], cp);
+ return NULL;
+ }
+ return n;
+ }