=================================================================== RCS file: /cvs/texi2mdoc/util.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -p -r1.18 -r1.19 --- texi2mdoc/util.c 2015/02/28 08:41:59 1.18 +++ texi2mdoc/util.c 2015/02/28 13:16:44 1.19 @@ -1,4 +1,4 @@ -/* $Id: util.c,v 1.18 2015/02/28 08:41:59 kristaps Exp $ */ +/* $Id: util.c,v 1.19 2015/02/28 13:16:44 kristaps Exp $ */ /* * Copyright (c) 2015 Kristaps Dzonsons * @@ -591,7 +591,7 @@ parseword(struct texi *p, size_t *pos, char extra) * index after the command name. */ enum texicmd -texicmd(struct texi *p, size_t pos, size_t *end, struct teximacro **macro) +texicmd(const struct texi *p, size_t pos, size_t *end, struct teximacro **macro) { size_t i, len, toksz; @@ -824,6 +824,23 @@ parseeoln(struct texi *p, size_t *pos) if (*pos < BUFSZ(p) && '\n' == BUF(p)[*pos]) advance(p, pos); +} + +/* + * Peek to see if there's a command after subsequent whitespace. + * If so, return the macro identifier. + * This DOES NOT work with user-defined macros. + */ +enum texicmd +peekcmd(const struct texi *p, size_t pos) +{ + size_t end; + + while (pos < BUFSZ(p) && ismspace(BUF(p)[pos])) + pos++; + if (pos == BUFSZ(p) || '@' != BUF(p)[pos]) + return(TEXICMD__MAX); + return(texicmd(p, pos, &end, NULL)); } /*