Merge branch 'master' of git.sv.nongnu.org:/srv/git/nmh
[mmh] / sbr / fmt_compile.c
1
2 /*
3  * fmt_compile.c -- "compile" format strings for fmt_scan
4  *
5  * This code is Copyright (c) 2002, by the authors of nmh.  See the
6  * COPYRIGHT file in the root directory of the nmh distribution for
7  * complete copyright information.
8  */
9
10 #include <h/mh.h>
11 #include <h/addrsbr.h>
12 #include <h/tws.h>
13 #include <h/fmt_scan.h>
14 #include <h/fmt_compile.h>
15
16 #ifdef HAVE_SYS_TIME_H
17 # include <sys/time.h>
18 #endif
19 #include <time.h>
20
21 /*
22  * hash table for deciding if a component is "interesting"
23  */
24 struct comp *wantcomp[128];
25
26 static struct format *formatvec;        /* array to hold formats */
27 static struct format *next_fp;          /* next free format slot */
28 static struct format *fp;               /* current format slot   */
29 static struct comp *cm;                 /* most recent comp ref  */
30 static struct ftable *ftbl;             /* most recent func ref  */
31 static int ncomp;
32 static int infunction;                  /* function nesting cnt  */
33
34 extern struct mailname fmt_mnull;
35
36 /* ftable->type (argument type) */
37 #define TF_COMP    0        /* component expected                 */
38 #define TF_NUM     1        /* number expected                    */
39 #define TF_STR     2        /* string expected                    */
40 #define TF_EXPR    3        /* component or func. expected        */
41 #define TF_NONE    4        /* no argument                        */
42 #define TF_MYBOX   5        /* special - get current user's mbox  */
43 #define TF_NOW     6        /* special - get current unix time    */
44 #define TF_EXPR_SV 7        /* like expr but save current str reg */
45 #define TF_NOP     8        /* like expr but no result            */
46
47 /* ftable->flags */
48 /* NB that TFL_PUTS is also used to decide whether the test
49  * in a "%<(function)..." should be a string or numeric one.
50  */
51 #define TFL_PUTS   1        /* implicit putstr if top level */
52 #define TFL_PUTN   2        /* implicit putnum if top level */
53
54 struct ftable {
55     char *name;         /* function name                  */
56     char type;          /* argument type                  */
57     char f_type;        /* fmt type                       */
58     char extra;         /* arg. type dependent extra info */
59     char flags;
60 };
61
62 static struct ftable functable[] = {
63      { "nonzero",    TF_EXPR,   FT_V_NE,        FT_IF_V_NE,     0 },
64      { "zero",       TF_EXPR,   FT_V_EQ,        FT_IF_V_EQ,     0 },
65      { "eq",         TF_NUM,    FT_V_EQ,        FT_IF_V_EQ,     0 },
66      { "ne",         TF_NUM,    FT_V_NE,        FT_IF_V_NE,     0 },
67      { "gt",         TF_NUM,    FT_V_GT,        FT_IF_V_GT,     0 },
68      { "null",       TF_EXPR,   FT_S_NULL,      FT_IF_S_NULL,   0 },
69      { "nonnull",    TF_EXPR,   FT_S_NONNULL,   FT_IF_S,        0 },
70      { "match",      TF_STR,    FT_V_MATCH,     FT_IF_MATCH,    0 },
71      { "amatch",     TF_STR,    FT_V_AMATCH,    FT_IF_AMATCH,   0 },
72
73      { "putstr",     TF_EXPR,   FT_STR,         0,              0 },
74      { "putstrf",    TF_EXPR,   FT_STRF,        0,              0 },
75      { "putnum",     TF_EXPR,   FT_NUM,         0,              0 },
76      { "putnumf",    TF_EXPR,   FT_NUMF,        0,              0 },
77      { "putaddr",    TF_STR,    FT_PUTADDR,     0,              0 },
78      { "putlit",     TF_STR,    FT_STRLIT,      0,              0 },
79      { "void",       TF_NOP,    0,              0,              0 },
80
81      { "comp",       TF_COMP,   FT_LS_COMP,     0,              TFL_PUTS },
82      { "lit",        TF_STR,    FT_LS_LIT,      0,              TFL_PUTS },
83      { "getenv",     TF_STR,    FT_LS_GETENV,   0,              TFL_PUTS },
84      { "profile",    TF_STR,    FT_LS_CFIND,    0,              TFL_PUTS },
85      { "decodecomp", TF_COMP,   FT_LS_DECODECOMP, 0,            TFL_PUTS },
86      { "decode",     TF_EXPR,   FT_LS_DECODE,   0,              TFL_PUTS },
87      { "trim",       TF_EXPR,   FT_LS_TRIM,     0,              0 },
88      { "compval",    TF_COMP,   FT_LV_COMP,     0,              TFL_PUTN },
89      { "compflag",   TF_COMP,   FT_LV_COMPFLAG, 0,              TFL_PUTN },
90      { "num",        TF_NUM,    FT_LV_LIT,      0,              TFL_PUTN },
91      { "msg",        TF_NONE,   FT_LV_DAT,      0,              TFL_PUTN },
92      { "cur",        TF_NONE,   FT_LV_DAT,      1,              TFL_PUTN },
93      { "size",       TF_NONE,   FT_LV_DAT,      2,              TFL_PUTN },
94      { "width",      TF_NONE,   FT_LV_DAT,      3,              TFL_PUTN },
95      { "unseen",     TF_NONE,   FT_LV_DAT,      4,              TFL_PUTN },
96      { "dat",        TF_NUM,    FT_LV_DAT,      0,              TFL_PUTN },
97      { "strlen",     TF_NONE,   FT_LV_STRLEN,   0,              TFL_PUTN },
98      { "me",         TF_MYBOX,  FT_LS_LIT,      0,              TFL_PUTS },
99      { "plus",       TF_NUM,    FT_LV_PLUS_L,   0,              TFL_PUTN },
100      { "minus",      TF_NUM,    FT_LV_MINUS_L,  0,              TFL_PUTN },
101      { "divide",     TF_NUM,    FT_LV_DIVIDE_L, 0,              TFL_PUTN },
102      { "modulo",     TF_NUM,    FT_LV_MODULO_L, 0,              TFL_PUTN },
103      { "charleft",   TF_NONE,   FT_LV_CHAR_LEFT, 0,             TFL_PUTN },
104      { "timenow",    TF_NOW,    FT_LV_LIT,      0,              TFL_PUTN },
105
106      { "month",      TF_COMP,   FT_LS_MONTH,    FT_PARSEDATE,   TFL_PUTS },
107      { "lmonth",     TF_COMP,   FT_LS_LMONTH,   FT_PARSEDATE,   TFL_PUTS },
108      { "tzone",      TF_COMP,   FT_LS_ZONE,     FT_PARSEDATE,   TFL_PUTS },
109      { "day",        TF_COMP,   FT_LS_DAY,      FT_PARSEDATE,   TFL_PUTS },
110      { "weekday",    TF_COMP,   FT_LS_WEEKDAY,  FT_PARSEDATE,   TFL_PUTS },
111      { "tws",        TF_COMP,   FT_LS_822DATE,  FT_PARSEDATE,   TFL_PUTS },
112      { "sec",        TF_COMP,   FT_LV_SEC,      FT_PARSEDATE,   TFL_PUTN },
113      { "min",        TF_COMP,   FT_LV_MIN,      FT_PARSEDATE,   TFL_PUTN },
114      { "hour",       TF_COMP,   FT_LV_HOUR,     FT_PARSEDATE,   TFL_PUTN },
115      { "mday",       TF_COMP,   FT_LV_MDAY,     FT_PARSEDATE,   TFL_PUTN },
116      { "mon",        TF_COMP,   FT_LV_MON,      FT_PARSEDATE,   TFL_PUTN },
117      { "year",       TF_COMP,   FT_LV_YEAR,     FT_PARSEDATE,   TFL_PUTN },
118      { "yday",       TF_COMP,   FT_LV_YDAY,     FT_PARSEDATE,   TFL_PUTN },
119      { "wday",       TF_COMP,   FT_LV_WDAY,     FT_PARSEDATE,   TFL_PUTN },
120      { "zone",       TF_COMP,   FT_LV_ZONE,     FT_PARSEDATE,   TFL_PUTN },
121      { "clock",      TF_COMP,   FT_LV_CLOCK,    FT_PARSEDATE,   TFL_PUTN },
122      { "rclock",     TF_COMP,   FT_LV_RCLOCK,   FT_PARSEDATE,   TFL_PUTN },
123      { "sday",       TF_COMP,   FT_LV_DAYF,     FT_PARSEDATE,   TFL_PUTN },
124      { "szone",      TF_COMP,   FT_LV_ZONEF,    FT_PARSEDATE,   TFL_PUTN },
125      { "dst",        TF_COMP,   FT_LV_DST,      FT_PARSEDATE,   TFL_PUTN },
126      { "pretty",     TF_COMP,   FT_LS_PRETTY,   FT_PARSEDATE,   TFL_PUTS },
127      { "nodate",     TF_COMP,   FT_LV_COMPFLAG, FT_PARSEDATE,   TFL_PUTN },
128      { "date2local", TF_COMP,   FT_LOCALDATE,   FT_PARSEDATE,   0 },
129      { "date2gmt",   TF_COMP,   FT_GMTDATE,     FT_PARSEDATE,   0 },
130
131      { "pers",       TF_COMP,   FT_LS_PERS,     FT_PARSEADDR,   TFL_PUTS },
132      { "mbox",       TF_COMP,   FT_LS_MBOX,     FT_PARSEADDR,   TFL_PUTS },
133      { "host",       TF_COMP,   FT_LS_HOST,     FT_PARSEADDR,   TFL_PUTS },
134      { "path",       TF_COMP,   FT_LS_PATH,     FT_PARSEADDR,   TFL_PUTS },
135      { "gname",      TF_COMP,   FT_LS_GNAME,    FT_PARSEADDR,   TFL_PUTS },
136      { "note",       TF_COMP,   FT_LS_NOTE,     FT_PARSEADDR,   TFL_PUTS },
137      { "addr",       TF_COMP,   FT_LS_ADDR,     FT_PARSEADDR,   TFL_PUTS },
138      { "proper",     TF_COMP,   FT_LS_822ADDR,  FT_PARSEADDR,   TFL_PUTS },
139      { "type",       TF_COMP,   FT_LV_HOSTTYPE, FT_PARSEADDR,   TFL_PUTN },
140      { "ingrp",      TF_COMP,   FT_LV_INGRPF,   FT_PARSEADDR,   TFL_PUTN },
141      { "nohost",     TF_COMP,   FT_LV_NOHOSTF,  FT_PARSEADDR,   TFL_PUTN },
142      { "formataddr", TF_EXPR_SV,FT_FORMATADDR,  FT_FORMATADDR,  0 },
143      { "concataddr", TF_EXPR_SV,FT_CONCATADDR,  FT_FORMATADDR,  0 },
144      { "friendly",   TF_COMP,   FT_LS_FRIENDLY, FT_PARSEADDR,   TFL_PUTS },
145
146      { "mymbox",     TF_COMP,   FT_LV_COMPFLAG, FT_MYMBOX,      TFL_PUTN },
147      { "addtoseq",   TF_STR,    FT_ADDTOSEQ,    0,              0 },
148
149      { "unquote",   TF_EXPR,    FT_LS_UNQUOTE,  0,              TFL_PUTS},
150
151      { NULL,         0,         0,              0,              0 }
152 };
153
154 /* Add new component to the hash table */
155 #define NEWCOMP(cm,name) do { \
156         cm = ((struct comp *) calloc(1, sizeof (struct comp)));\
157         cm->c_name = name;\
158         ncomp++;\
159         i = CHASH(name);\
160         cm->c_next = wantcomp[i];\
161         wantcomp[i] = cm; \
162         } while (0)
163
164 #define NEWFMT (next_fp++)
165 #define NEW(type,fill,wid) do {\
166         fp=NEWFMT; fp->f_type=(type); fp->f_fill=(fill); fp->f_width=(wid); \
167         } while (0)
168
169 /* Add (possibly new) component to the hash table */
170 #define ADDC(name) do { \
171         FINDCOMP(cm, name);\
172         if (!cm) {\
173             NEWCOMP(cm,name);\
174         }\
175         fp->f_comp = cm; \
176         } while (0)
177
178 #define LV(type, value)         do { NEW(type,0,0); fp->f_value = (value); } while (0)
179 #define LS(type, str)           do { NEW(type,0,0); fp->f_text = (str); } while (0)
180
181 #define PUTCOMP(comp)           do { NEW(FT_COMP,0,0); ADDC(comp); } while (0)
182 #define PUTLIT(str)             do { NEW(FT_LIT,0,0); fp->f_text = (str); } while (0)
183 #define PUTC(c)                 do { NEW(FT_CHAR,0,0); fp->f_char = (c); } while (0)
184
185 static char *format_string;
186 static unsigned char *usr_fstring;      /* for CERROR */
187
188 #define CERROR(str) compile_error (str, cp)
189
190 /*
191  * external prototypes
192  */
193 extern char *getusername(void);
194
195 /*
196  * static prototypes
197  */
198 static struct ftable *lookup(char *);
199 static void compile_error(char *, char *);
200 static char *compile (char *);
201 static char *do_spec(char *);
202 static char *do_name(char *, int);
203 static char *do_func(char *);
204 static char *do_expr (char *, int);
205 static char *do_loop(char *);
206 static char *do_if(char *);
207
208
209 static struct ftable *
210 lookup(char *name)
211 {
212     register struct ftable *t = functable;
213     register char *nm;
214     register char c = *name;
215
216     while ((nm = t->name)) {
217         if (*nm == c && strcmp (nm, name) == 0)
218             return (ftbl = t);
219
220         t++;
221     }
222     return (struct ftable *) 0;
223 }
224
225
226 static void
227 compile_error(char *str, char *cp)
228 {
229     int i, errpos, errctx;
230
231     errpos = cp - format_string;
232     errctx = errpos > 20 ? 20 : errpos;
233     usr_fstring[errpos] = '\0';
234
235     for (i = errpos-errctx; i < errpos; i++) {
236 #ifdef LOCALE
237         if (iscntrl(usr_fstring[i]))
238 #else
239         if (usr_fstring[i] < 32)
240 #endif
241             usr_fstring[i] = '_';
242     }
243
244     advise(NULL, "\"%s\": format compile error - %s",
245            &usr_fstring[errpos-errctx], str);
246     adios (NULL, "%*s", errctx+1, "^");
247 }
248
249 /*
250  * Compile format string "fstring" into format list "fmt".
251  * Return the number of header components found in the format
252  * string.
253  */
254
255 int
256 fmt_compile(char *fstring, struct format **fmt)
257 {
258     register char *cp;
259     int i;
260
261     if (format_string)
262         free (format_string);
263     format_string = getcpy (fstring);
264     usr_fstring = fstring;
265
266     /* init the component hash table. */
267     for (i = 0; i < sizeof(wantcomp)/sizeof(wantcomp[0]); i++)
268         wantcomp[i] = 0;
269
270     memset((char *) &fmt_mnull, 0, sizeof(fmt_mnull));
271
272     /* it takes at least 4 char to generate one format so we
273      * allocate a worst-case format array using 1/4 the length
274      * of the format string.  We actually need twice this much
275      * to handle both pre-processing (e.g., address parsing) and
276      * normal processing.
277      */
278     i = strlen(fstring)/2 + 1;
279                 if (i==1) i++;
280     next_fp = formatvec = (struct format *)calloc ((size_t) i,
281                                                    sizeof(struct format));
282     if (next_fp == NULL)
283         adios (NULL, "unable to allocate format storage");
284
285     ncomp = 0;
286     infunction = 0;
287
288     cp = compile(format_string);
289     if (*cp) {
290         CERROR("extra '%>', '%|' or '%?'");
291     }
292     LV(FT_DONE, 0);             /* really done */
293     *fmt = formatvec;
294
295     return (ncomp);
296 }
297
298 static char *
299 compile (char *sp)
300 {
301     register char *cp = sp;
302     register int  c;
303
304     for (;;) {
305         sp = cp;
306         while ((c = *cp) && c != '%')
307             cp++;
308         *cp = 0;
309         switch (cp-sp) {
310         case 0:
311             break;
312         case 1:
313             PUTC(*sp);
314             break;
315         default:
316             PUTLIT(sp);
317             break;
318         }
319         if (c == 0)
320             return (cp);
321
322         switch (c = *++cp) {
323         case '%':
324             PUTC (*cp);
325             cp++;
326             break;
327
328         case '|':
329         case '>':
330         case '?':
331         case ']':
332             return (cp);
333
334         case '<':
335             cp = do_if(++cp);
336             break;
337
338         case '[':       /* ] */
339             cp = do_loop(++cp);
340             break;
341
342         case ';':       /* comment line */
343             cp++;
344             while ((c = *cp++) && c != '\n')
345                 continue;
346             break;
347
348         default:
349             cp = do_spec(cp);
350             break;
351         }
352     }
353 }
354
355
356 static char *
357 do_spec(char *sp)
358 {
359     register char *cp = sp;
360     register int c;
361 #ifndef lint
362     register int ljust = 0;
363 #endif  /* not lint */
364     register int wid = 0;
365     register char fill = ' ';
366
367     c = *cp++;
368     if (c == '-') {
369         ljust++;
370         c = *cp++;
371     }
372     if (c == '0') {
373         fill = c;
374         c = *cp++;
375     }
376     while (isdigit(c)) {
377         wid = wid*10 + (c - '0');
378         c = *cp++;
379     }
380     if (c == '{') {
381         cp = do_name(cp, 0);
382         if (! infunction)
383             fp->f_type = wid? FT_COMPF : FT_COMP;
384     }
385     else if (c == '(') {
386         cp = do_func(cp);
387         if (! infunction) {
388             if (ftbl->flags & TFL_PUTS) {
389                 LV( wid? FT_STRF : FT_STR, ftbl->extra);
390             }
391             else if (ftbl->flags & TFL_PUTN) {
392                 LV( wid? FT_NUMF : FT_NUM, ftbl->extra);
393             }
394         }
395     }
396     else {
397         CERROR("component or function name expected");
398     }
399     if (ljust)
400         wid = -wid;
401     fp->f_width = wid;
402     fp->f_fill = fill;
403
404     return (cp);
405 }
406
407 static char *
408 do_name(char *sp, int preprocess)
409 {
410     register char *cp = sp;
411     register int c;
412     register int i;
413     static int primed = 0;
414
415     while (isalnum(c = *cp++) || c == '-' || c == '_')
416         ;
417     if (c != '}') {
418         CERROR("'}' expected");
419     }
420     cp[-1] = '\0';
421     PUTCOMP(sp);
422     switch (preprocess) {
423
424     case FT_PARSEDATE:
425         if (cm->c_type & CT_ADDR) {
426             CERROR("component used as both date and address");
427         }
428         cm->c_tws = (struct tws *)
429             calloc((size_t) 1, sizeof(*cm->c_tws));
430         fp->f_type = preprocess;
431         PUTCOMP(sp);
432         cm->c_type |= CT_DATE;
433         break;
434
435     case FT_MYMBOX:
436         if (!primed) {
437             ismymbox ((struct mailname *) 0);
438             primed++;
439         }
440         /* fall through */
441     case FT_PARSEADDR:
442         if (cm->c_type & CT_DATE) {
443             CERROR("component used as both date and address");
444         }
445         cm->c_mn = &fmt_mnull;
446         fp->f_type = preprocess;
447         PUTCOMP(sp);
448         cm->c_type |= CT_ADDR;
449         break;
450
451     case FT_FORMATADDR:
452         if (cm->c_type & CT_DATE) {
453             CERROR("component used as both date and address");
454         }
455         cm->c_type |= CT_ADDR;
456         break;
457     }
458     return (cp);
459 }
460
461 static char *
462 do_func(char *sp)
463 {
464     register char *cp = sp;
465     register int c;
466     register struct ftable *t;
467     register int n;
468     int mflag;          /* minus sign in NUM */
469
470     infunction++;
471
472     while (isalnum(c = *cp++)) 
473         ;
474     if (c != '(' && c != '{' && c != ' ' && c != ')') {
475         CERROR("'(', '{', ' ' or ')' expected");
476     }
477     cp[-1] = '\0';
478     if ((t = lookup (sp)) == 0) {
479         CERROR("unknown function");
480     }
481     if (isspace(c))
482         c = *cp++;
483
484     switch (t->type) {
485
486     case TF_COMP:
487         if (c != '{') {
488             CERROR("component name expected");
489         }
490         cp = do_name(cp, t->extra);
491         fp->f_type = t->f_type;
492         c = *cp++;
493         break;
494
495     case TF_NUM:
496         if ((mflag = (c == '-')))
497             c = *cp++;
498         n = 0;
499         while (isdigit(c)) {
500             n = n*10 + (c - '0');
501             c = *cp++;
502         }
503         if (mflag)
504             n = (-n);
505         LV(t->f_type,n);
506         break;
507
508     case TF_STR:
509         sp = cp - 1;
510         while (c && c != ')')
511             c = *cp++;
512         cp[-1] = '\0';
513         LS(t->f_type,sp);
514         break;
515
516     case TF_NONE:
517         LV(t->f_type,t->extra);
518         break;
519
520     case TF_MYBOX:
521         LS(t->f_type, getusername());
522         break;
523
524     case TF_NOW:
525         LV(t->f_type, time((time_t *) 0));
526         break;
527
528     case TF_EXPR_SV:
529         LV(FT_SAVESTR, 0);
530         /* fall through */
531     case TF_EXPR:
532         *--cp = c;
533         cp = do_expr(cp, t->extra);
534         LV(t->f_type, 0);
535         c = *cp++;
536         ftbl = t;
537         break;
538
539     case TF_NOP:
540         *--cp = c;
541         cp = do_expr(cp, t->extra);
542         c = *cp++;
543         ftbl = t;
544         break;
545     }
546     if (c != ')') {
547         CERROR("')' expected");
548     }
549     --infunction;
550     return (cp);
551 }
552
553 static char *
554 do_expr (char *sp, int preprocess)
555 {
556     register char *cp = sp;
557     register int  c;
558
559     if ((c = *cp++) == '{') {
560         cp = do_name (cp, preprocess);
561         fp->f_type = FT_LS_COMP;
562     } else if (c == '(') {
563         cp = do_func (cp);
564     } else if (c == ')') {
565         return (--cp);
566     } else if (c == '%' && *cp == '<') {
567         cp = do_if (cp+1);
568     } else {
569         CERROR ("'(', '{', '%<' or ')' expected");
570     }
571     return (cp);
572 }
573
574 static char *
575 do_loop(char *sp)
576 {
577     register char *cp = sp;
578     struct format *floop;
579
580     floop = next_fp;
581     cp = compile (cp);
582     if (*cp++ != ']')
583         CERROR ("']' expected");
584
585     LV(FT_DONE, 1);             /* not yet done */
586     LV(FT_GOTO, 0);
587     fp->f_skip = floop - fp;    /* skip backwards */
588
589     return cp;
590 }
591
592 static char *
593 do_if(char *sp)
594 {
595     register char *cp = sp;
596     register struct format *fexpr,
597                            *fif = (struct format *)NULL;
598     register int c = '<';
599
600     for (;;) {
601         if (c == '<') {                 /* doing an IF */
602             if ((c = *cp++) == '{') /*}*/{
603                 cp = do_name(cp, 0);
604                 fp->f_type = FT_LS_COMP;
605                 LV (FT_IF_S, 0);
606             }
607             else if (c == '(') {
608                 cp = do_func(cp);
609                 /* see if we can merge the load and the "if" */
610                 if (ftbl->f_type >= IF_FUNCS)
611                     fp->f_type = ftbl->extra;
612                 else {
613                     /* Put out a string test or a value test depending
614                      * on what this function's return type is.
615                      */
616                     if (ftbl->flags & TFL_PUTS) {
617                         LV (FT_IF_S, 0);
618                     } else {
619                         LV (FT_IF_V_NE, 0);
620                     }
621                 }
622             }
623             else {
624                 CERROR("'(' or '{' expected");  /*}*/
625             }
626         }
627
628         fexpr = fp;                     /* loc of [ELS]IF */
629         cp = compile (cp);              /* compile IF TRUE stmts */
630         if (fif)
631             fif->f_skip = next_fp - fif;
632
633         if ((c = *cp++) == '|') {       /* the last ELSE */
634             LV(FT_GOTO, 0);
635             fif = fp;                   /* loc of GOTO */
636             fexpr->f_skip = next_fp - fexpr;
637
638             fexpr = (struct format *)NULL;/* no extra ENDIF */
639
640             cp = compile (cp);          /* compile ELSE stmts */
641             fif->f_skip = next_fp - fif;
642             c = *cp++;
643         }
644         else if (c == '?') {            /* another ELSIF */
645             LV(FT_GOTO, 0);
646             fif = fp;                   /* loc of GOTO */
647             fexpr->f_skip = next_fp - fexpr;
648
649             c = '<';                    /* impersonate an IF */
650             continue;
651         }
652         break;
653     }
654
655     if (c != '>') {
656         CERROR("'>' expected.");
657     }
658
659     if (fexpr)                          /* IF ... [ELSIF ...] ENDIF */
660         fexpr->f_skip = next_fp - fexpr;
661
662     return (cp);
663 }