version 1.6, 2015/02/18 11:03:04 |
version 1.7, 2015/02/18 11:08:58 |
|
|
TEXICMD_AT, |
TEXICMD_AT, |
TEXICMD_AUTHOR, |
TEXICMD_AUTHOR, |
TEXICMD_BANG, |
TEXICMD_BANG, |
|
TEXICMD_BULLET, |
TEXICMD_BYE, |
TEXICMD_BYE, |
TEXICMD_CENTER, |
TEXICMD_CENTER, |
TEXICMD_CHAPTER, |
TEXICMD_CHAPTER, |
|
|
TEXICMD_PRINTINDEX, |
TEXICMD_PRINTINDEX, |
TEXICMD_REF, |
TEXICMD_REF, |
TEXICMD_SAMP, |
TEXICMD_SAMP, |
|
TEXICMD_SC, |
TEXICMD_SECTION, |
TEXICMD_SECTION, |
TEXICMD_SET, |
TEXICMD_SET, |
TEXICMD_SETCHAPNEWPAGE, |
TEXICMD_SETCHAPNEWPAGE, |
Line 236 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
Line 238 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
{ dosymbol, "@", 1 }, /* TEXICMD_AT */ |
{ dosymbol, "@", 1 }, /* TEXICMD_AT */ |
{ doignline, "author", 6 }, /* TEXICMD_AUTHOR */ |
{ doignline, "author", 6 }, /* TEXICMD_AUTHOR */ |
{ dosymbol, "!", 1 }, /* TEXICMD_BANG */ |
{ dosymbol, "!", 1 }, /* TEXICMD_BANG */ |
|
{ dosymbol, "bullet", 6 }, /* TEXICMD_BULLET */ |
{ dobye, "bye", 3 }, /* TEXICMD_BYE */ |
{ dobye, "bye", 3 }, /* TEXICMD_BYE */ |
{ doignline, "center", 5 }, /* TEXICMD_CENTER */ |
{ doignline, "center", 5 }, /* TEXICMD_CENTER */ |
{ dochapter, "chapter", 7 }, /* TEXICMD_CHAPTER */ |
{ dochapter, "chapter", 7 }, /* TEXICMD_CHAPTER */ |
Line 298 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
Line 301 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
{ doignline, "printindex", 10 }, /* TEXICMD_PRINTINDEX */ |
{ doignline, "printindex", 10 }, /* TEXICMD_PRINTINDEX */ |
{ dobracket, "ref", 3 }, /* TEXICMD_REF */ |
{ dobracket, "ref", 3 }, /* TEXICMD_REF */ |
{ doliteral, "samp", 4 }, /* TEXICMD_SAMP */ |
{ doliteral, "samp", 4 }, /* TEXICMD_SAMP */ |
|
{ dobracket, "sc", 2 }, /* TEXICMD_SC */ |
{ dosection, "section", 7 }, /* TEXICMD_SECTION */ |
{ dosection, "section", 7 }, /* TEXICMD_SECTION */ |
{ doignline, "set", 3 }, /* TEXICMD_SET */ |
{ doignline, "set", 3 }, /* TEXICMD_SET */ |
{ doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */ |
{ doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */ |
Line 656 texicmd(struct texi *p, const char *buf, |
|
Line 660 texicmd(struct texi *p, const char *buf, |
|
} |
} |
|
|
static void |
static void |
parseeof(struct texi *p, const char *buf, size_t sz) |
|
{ |
|
size_t pos = 0; |
|
enum texicmd cmd; |
|
size_t end; |
|
|
|
while ((pos = advancenext(p, buf, sz, &pos)) < sz) { |
|
switch (buf[pos]) { |
|
case ('}'): |
|
if (0 == p->ign) |
|
texiwarn(p, "unexpected \"}\""); |
|
advance(p, buf, &pos); |
|
continue; |
|
case ('{'): |
|
if (0 == p->ign) |
|
texiwarn(p, "unexpected \"{\""); |
|
advance(p, buf, &pos); |
|
continue; |
|
case ('@'): |
|
break; |
|
default: |
|
texiword(p, buf, sz, &pos); |
|
continue; |
|
} |
|
|
|
cmd = texicmd(p, buf, pos, sz, &end); |
|
advanceto(p, buf, &pos, end); |
|
if (TEXICMD__MAX == cmd) |
|
continue; |
|
if (NULL != texitoks[cmd].fp) |
|
(*texitoks[cmd].fp)(p, cmd, buf, sz, &pos); |
|
} |
|
} |
|
|
|
static void |
|
parsebracket(struct texi *p, const char *buf, size_t sz, size_t *pos) |
parsebracket(struct texi *p, const char *buf, size_t sz, size_t *pos) |
{ |
{ |
size_t end; |
size_t end; |
Line 810 parsesingle(struct texi *p, const char *buf, size_t sz |
|
Line 779 parsesingle(struct texi *p, const char *buf, size_t sz |
|
} |
} |
|
|
static void |
static void |
|
parseeof(struct texi *p, const char *buf, size_t sz) |
|
{ |
|
size_t pos; |
|
|
|
for (pos = 0; pos < sz; ) |
|
parsesingle(p, buf, sz, &pos); |
|
} |
|
|
|
static void |
parseto(struct texi *p, const char *buf, |
parseto(struct texi *p, const char *buf, |
size_t sz, size_t *pos, const char *endtoken) |
size_t sz, size_t *pos, const char *endtoken) |
{ |
{ |
Line 1039 doinclude(struct texi *p, enum texicmd cmd, |
|
Line 1017 doinclude(struct texi *p, enum texicmd cmd, |
|
for (i = 0; i < p->dirsz; i++) { |
for (i = 0; i < p->dirsz; i++) { |
rc = snprintf(path, sizeof(path), |
rc = snprintf(path, sizeof(path), |
"%s/%s", p->dirs[i], fname); |
"%s/%s", p->dirs[i], fname); |
texiwarn(p, "trying: %s", path); |
|
if (rc < 0) |
if (rc < 0) |
texierr(p, "couldn't format path"); |
texierr(p, "couldn't format path"); |
else if ((size_t)rc >= sizeof(path)) |
else if ((size_t)rc >= sizeof(path)) |
Line 1182 dosymbol(struct texi *p, enum texicmd cmd, |
|
Line 1159 dosymbol(struct texi *p, enum texicmd cmd, |
|
break; |
break; |
case (TEXICMD_BANG): |
case (TEXICMD_BANG): |
texiputchar(p, '!'); |
texiputchar(p, '!'); |
|
break; |
|
case (TEXICMD_BULLET): |
|
texiputchars(p, "\\(bu"); |
break; |
break; |
case (TEXICMD_COPYRIGHT): |
case (TEXICMD_COPYRIGHT): |
texiputchars(p, "\\(co"); |
texiputchars(p, "\\(co"); |