- int i, c;
- char mac[5];
-
- /* Comments and empties are quickly ignored. */
-
- if (0 == buf[1])
- return(1);
-
- if (' ' == buf[1]) {
- i = 2;
- while (buf[i] && ' ' == buf[i])
- i++;
- if (0 == buf[i])
- return(1);
- warnx("invalid syntax");
- return(0);
- }
-
- if (buf[1] && '\\' == buf[1])
- if (buf[2] && '\"' == buf[2])
- return(1);
-
- /* Copy the first word into a nil-terminated buffer. */
-
- for (i = 1; i < 5; i++) {
- if (0 == (mac[i - 1] = buf[i]))
- break;
- else if (' ' == buf[i])
- break;
- }
-
- mac[i - 1] = 0;
-
- if (i == 5 || i <= 1) {
- warnx("unknown macro: %s", mac);
- goto err;
- }
-
- if (MAN_MAX == (c = man_hash_find(m->htab, mac))) {
- warnx("unknown macro: %s", mac);
- goto err;
- }
-
- /* The macro is sane. Jump to the next word. */
-
- while (buf[i] && ' ' == buf[i])
- i++;
-
- /* Begin recursive parse sequence. */
-
- if ( ! (*man_macros[c].fp)(m, c, ln, 1, &i, buf))
- goto err;
-
- return(1);
-
-err: /* Error out. */