version 1.17, 2015/02/28 00:03:20 |
version 1.19, 2015/02/28 13:16:44 |
Line 591 parseword(struct texi *p, size_t *pos, char extra) |
|
Line 591 parseword(struct texi *p, size_t *pos, char extra) |
|
* index after the command name. |
* index after the command name. |
*/ |
*/ |
enum texicmd |
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; |
size_t i, len, toksz; |
|
|
Line 719 parsearg(struct texi *p, size_t *pos, size_t num) |
|
Line 719 parsearg(struct texi *p, size_t *pos, size_t num) |
|
* This will stop in the event of EOF or if we're not at a bracket. |
* This will stop in the event of EOF or if we're not at a bracket. |
*/ |
*/ |
void |
void |
parsebracket(struct texi *p, size_t *pos) |
parsebracket(struct texi *p, size_t *pos, int dostack) |
{ |
{ |
size_t end, sv; |
size_t end, sv, stack; |
enum texicmd cmd; |
enum texicmd cmd; |
struct teximacro *macro; |
struct teximacro *macro; |
|
|
Line 732 parsebracket(struct texi *p, size_t *pos) |
|
Line 732 parsebracket(struct texi *p, size_t *pos) |
|
return; |
return; |
advance(p, pos); |
advance(p, pos); |
|
|
|
stack = 0; |
while ((*pos = advancenext(p, pos)) < BUFSZ(p)) { |
while ((*pos = advancenext(p, pos)) < BUFSZ(p)) { |
switch (BUF(p)[*pos]) { |
switch (BUF(p)[*pos]) { |
case ('}'): |
case ('}'): |
|
if (stack > 0) { |
|
stack--; |
|
advance(p, pos); |
|
texiputchar(p, '}'); |
|
continue; |
|
} |
advance(p, pos); |
advance(p, pos); |
return; |
return; |
case ('{'): |
case ('{'): |
|
if (dostack) { |
|
stack++; |
|
advance(p, pos); |
|
texiputchar(p, '{'); |
|
continue; |
|
} |
if (0 == p->ign) |
if (0 == p->ign) |
texiwarn(p, "unexpected \"{\""); |
texiwarn(p, "unexpected \"{\""); |
advance(p, pos); |
advance(p, pos); |
Line 814 parseeoln(struct texi *p, size_t *pos) |
|
Line 827 parseeoln(struct texi *p, size_t *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)); |
|
} |
|
|
|
/* |
* Parse a single word or command. |
* Parse a single word or command. |
* This will return immediately at the EOF. |
* This will return immediately at the EOF. |
*/ |
*/ |
Line 874 parselinearg(struct texi *p, size_t *pos) |
|
Line 904 parselinearg(struct texi *p, size_t *pos) |
|
} |
} |
|
|
if (*pos < BUFSZ(p) && '{' == BUF(p)[*pos]) |
if (*pos < BUFSZ(p) && '{' == BUF(p)[*pos]) |
parsebracket(p, pos); |
parsebracket(p, pos, 0); |
else if (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) |
else if (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) |
parsesingle(p, pos); |
parsesingle(p, pos); |
else |
else |