version 1.55, 2015/03/01 00:25:07 |
version 1.59, 2015/03/03 15:04:24 |
Line 94 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
Line 94 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
{ dosymbol, "*", 1 }, /* TEXICMD_ASTERISK */ |
{ dosymbol, "*", 1 }, /* TEXICMD_ASTERISK */ |
{ dosymbol, "@", 1 }, /* TEXICMD_AT */ |
{ dosymbol, "@", 1 }, /* TEXICMD_AT */ |
{ doignline, "author", 6 }, /* TEXICMD_AUTHOR */ |
{ doignline, "author", 6 }, /* TEXICMD_AUTHOR */ |
{ doinline, "b", 1 }, /* TEXICMD_BOLD */ |
{ doinline, "b", 1 }, /* TEXICMD_B */ |
|
{ dosymbol, "\\", 1 }, /* TEXICMD_BACKSLASH */ |
{ dosymbol, "!", 1 }, /* TEXICMD_BANG */ |
{ dosymbol, "!", 1 }, /* TEXICMD_BANG */ |
{ dosymbol, "bullet", 6 }, /* TEXICMD_BULLET */ |
{ dosymbol, "bullet", 6 }, /* TEXICMD_BULLET */ |
{ dobye, "bye", 3 }, /* TEXICMD_BYE */ |
{ dobye, "bye", 3 }, /* TEXICMD_BYE */ |
Line 268 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
Line 269 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
{ doaccent, "ringaccent", 10 }, /* TEXICMD_RINGACCENT */ |
{ doaccent, "ringaccent", 10 }, /* TEXICMD_RINGACCENT */ |
{ doinline, "samp", 4 }, /* TEXICMD_SAMP */ |
{ doinline, "samp", 4 }, /* TEXICMD_SAMP */ |
{ doinline, "sansserif", 9 }, /* TEXICMD_SANSSERIF */ |
{ doinline, "sansserif", 9 }, /* TEXICMD_SANSSERIF */ |
{ dobracket, "sc", 2 }, /* TEXICMD_SC */ |
{ doinline, "sc", 2 }, /* TEXICMD_SC */ |
{ dosection, "section", 7 }, /* TEXICMD_SECTION */ |
{ dosection, "section", 7 }, /* TEXICMD_SECTION */ |
{ dovalue, "set", 3 }, /* TEXICMD_SET */ |
{ dovalue, "set", 3 }, /* TEXICMD_SET */ |
{ doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */ |
{ doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */ |
Line 725 doinline(struct texi *p, enum texicmd cmd, size_t *pos |
|
Line 726 doinline(struct texi *p, enum texicmd cmd, size_t *pos |
|
} |
} |
|
|
if (NULL == macro || p->literal || TEXILIST_TABLE == p->list) { |
if (NULL == macro || p->literal || TEXILIST_TABLE == p->list) { |
|
if (TEXICMD_SC == cmd) |
|
p->uppercase++; |
parsebracket(p, pos, 0); |
parsebracket(p, pos, 0); |
|
if (TEXICMD_SC == cmd) |
|
p->uppercase--; |
return; |
return; |
} |
} |
|
|
|
/* |
|
* If we haven't seen any whitespace, then we don't want the |
|
* subsequent macro to insert any whitespace. |
|
*/ |
|
if (p->outmacro && 0 == p->seenws) { |
|
teximacroopen(p, "Ns"); |
|
teximacroclose(p); |
|
} |
|
|
teximacroopen(p, macro); |
teximacroopen(p, macro); |
p->seenws = 0; |
p->seenws = 0; |
|
if (TEXICMD_SC == cmd) |
|
p->uppercase++; |
parsebracket(p, pos, 0); |
parsebracket(p, pos, 0); |
|
if (TEXICMD_SC == cmd) |
|
p->uppercase--; |
texipunctuate(p, pos); |
texipunctuate(p, pos); |
teximacroclose(p); |
teximacroclose(p); |
} |
} |
|
|
dodisplay(struct texi *p, enum texicmd cmd, size_t *pos) |
dodisplay(struct texi *p, enum texicmd cmd, size_t *pos) |
{ |
{ |
|
|
|
advanceeoln(p, pos, 1); |
|
|
switch (cmd) { |
switch (cmd) { |
case (TEXICMD_FORMAT): |
case (TEXICMD_FORMAT): |
case (TEXICMD_SMALLFORMAT): |
case (TEXICMD_SMALLFORMAT): |
Line 953 dodisplay(struct texi *p, enum texicmd cmd, size_t *po |
|
Line 973 dodisplay(struct texi *p, enum texicmd cmd, size_t *po |
|
} |
} |
|
|
p->seenvs = 1; |
p->seenvs = 1; |
/* FIXME: ignore and parseeoln. */ |
|
advanceeoln(p, pos, 1); |
|
parseto(p, pos, texitoks[cmd].tok); |
parseto(p, pos, texitoks[cmd].tok); |
teximacro(p, "Ed"); |
teximacro(p, "Ed"); |
} |
} |
|
|
doexample(struct texi *p, enum texicmd cmd, size_t *pos) |
doexample(struct texi *p, enum texicmd cmd, size_t *pos) |
{ |
{ |
|
|
teximacro(p, "Bd -literal -offset indent"); |
|
/* FIXME: ignore and parseeoln. */ |
|
advanceeoln(p, pos, 1); |
advanceeoln(p, pos, 1); |
|
|
|
teximacro(p, "Bd -literal -offset indent"); |
p->literal++; |
p->literal++; |
parseto(p, pos, texitoks[cmd].tok); |
parseto(p, pos, texitoks[cmd].tok); |
p->literal--; |
p->literal--; |
Line 983 dobye(struct texi *p, enum texicmd cmd, size_t *pos) |
|
Line 1001 dobye(struct texi *p, enum texicmd cmd, size_t *pos) |
|
static void |
static void |
dotitle(struct texi *p, enum texicmd cmd, size_t *pos) |
dotitle(struct texi *p, enum texicmd cmd, size_t *pos) |
{ |
{ |
size_t start, end; |
size_t start; |
|
|
while (*pos < BUFSZ(p) && isws(BUF(p)[*pos])) |
while (*pos < BUFSZ(p) && isws(BUF(p)[*pos])) |
advance(p, pos); |
advance(p, pos); |
start = end = *pos; |
|
while (end < BUFSZ(p) && '\n' != BUF(p)[end]) |
/* We want to suck down the entire line, inclusive \n. */ |
end++; |
start = *pos; |
advanceeoln(p, pos, 1); |
while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) { |
|
if ('@' == BUF(p)[*pos]) |
|
advance(p, pos); |
|
advance(p, pos); |
|
} |
|
if (*pos < BUFSZ(p)) |
|
advance(p, pos); |
|
|
|
/* Copy this into a buffer. */ |
free(p->subtitle); |
free(p->subtitle); |
p->subtitle = malloc(end - start + 1); |
if (NULL == (p->subtitle = malloc(*pos - start + 1))) |
if (NULL == p->subtitle) |
|
texiabort(p, NULL); |
texiabort(p, NULL); |
memcpy(p->subtitle, &BUF(p)[start], end - start); |
memcpy(p->subtitle, &BUF(p)[start], *pos - start); |
p->subtitle[end - start] = '\0'; |
p->subtitle[*pos - start] = '\0'; |
} |
} |
|
|
static void |
static void |
Line 1189 dosymbol(struct texi *p, enum texicmd cmd, size_t *pos |
|
Line 1214 dosymbol(struct texi *p, enum texicmd cmd, size_t *pos |
|
case (TEXICMD_AT): |
case (TEXICMD_AT): |
texiputchar(p, '@'); |
texiputchar(p, '@'); |
break; |
break; |
|
case (TEXICMD_BACKSLASH): |
|
texiputchar(p, '\\'); |
|
break; |
case (TEXICMD_BANG): |
case (TEXICMD_BANG): |
texiputchar(p, '!'); |
texiputchar(p, '!'); |
break; |
break; |
Line 1410 dovalue(struct texi *p, enum texicmd cmd, size_t *pos) |
|
Line 1438 dovalue(struct texi *p, enum texicmd cmd, size_t *pos) |
|
texiputchar(p, ' '); |
texiputchar(p, ' '); |
p->seenws = 0; |
p->seenws = 0; |
if (NULL != (cp = valueblookup(p, pos))) |
if (NULL != (cp = valueblookup(p, pos))) |
texisplice(p, cp, strlen(cp), pos); |
texisplice(p, cp, strlen(cp), *pos); |
else |
else |
texiputchars(p, "{No value}"); |
texiputchars(p, "{No value}"); |
} else if (TEXICMD_IFCLEAR == cmd) { |
} else if (TEXICMD_IFCLEAR == cmd) { |
Line 1577 dosection(struct texi *p, enum texicmd cmd, size_t *po |
|
Line 1605 dosection(struct texi *p, enum texicmd cmd, size_t *po |
|
|
|
if (0 == sec && NULL != p->chapters) { |
if (0 == sec && NULL != p->chapters) { |
teximdocclose(p, 0); |
teximdocclose(p, 0); |
teximdocopen(p); |
teximdocopen(p, pos); |
} |
} |
|
|
teximacroopen(p, sects[sec]); |
teximacroopen(p, sects[sec]); |
Line 1594 dotop(struct texi *p, enum texicmd cmd, size_t *pos) |
|
Line 1622 dotop(struct texi *p, enum texicmd cmd, size_t *pos) |
|
texierr(p, "@top command while ignoring"); |
texierr(p, "@top command while ignoring"); |
|
|
if (NULL == p->chapters) |
if (NULL == p->chapters) |
teximdocopen(p); |
teximdocopen(p, pos); |
dosection(p, cmd, pos); |
dosection(p, cmd, pos); |
} |
} |
|
|
|
|
dosp(struct texi *p, enum texicmd cmd, size_t *pos) |
dosp(struct texi *p, enum texicmd cmd, size_t *pos) |
{ |
{ |
|
|
|
advanceeoln(p, pos, 1); |
if (p->literal) |
if (p->literal) |
texiputchar(p, '\n'); |
texiputchar(p, '\n'); |
else |
else |
texivspace(p); |
texivspace(p); |
/* FIXME: ignore and parseeoln. */ |
|
advanceeoln(p, pos, 1); |
|
} |
} |
|
|
static void |
static void |
Line 1679 domultitable(struct texi *p, enum texicmd cmd, size_t |
|
Line 1706 domultitable(struct texi *p, enum texicmd cmd, size_t |
|
|
|
/* Make sure we don't print anything when scanning. */ |
/* Make sure we don't print anything when scanning. */ |
p->ign++; |
p->ign++; |
if ('@' == BUF(p)[*pos]) { |
if (*pos < BUFSZ(p) && '@' == BUF(p)[*pos]) { |
/* |
/* |
* Look for @columnfractions. |
* Look for @columnfractions. |
* We ignore these, but we do use the number of |
* We ignore these, but we do use the number of |
Line 1731 dotable(struct texi *p, enum texicmd cmd, size_t *pos) |
|
Line 1758 dotable(struct texi *p, enum texicmd cmd, size_t *pos) |
|
{ |
{ |
enum texilist sv = p->list; |
enum texilist sv = p->list; |
|
|
|
advanceeoln(p, pos, 1); |
|
|
p->list = TEXILIST_ITEM; |
p->list = TEXILIST_ITEM; |
teximacro(p, "Bl -tag -width Ds"); |
teximacro(p, "Bl -tag -width Ds"); |
/* FIXME: ignore and parseeoln. */ |
|
advanceeoln(p, pos, 1); |
|
p->seenvs = 1; |
p->seenvs = 1; |
parseto(p, pos, texitoks[cmd].tok); |
parseto(p, pos, texitoks[cmd].tok); |
teximacro(p, "El"); |
teximacro(p, "El"); |
Line 1752 doend(struct texi *p, enum texicmd cmd, size_t *pos) |
|
Line 1779 doend(struct texi *p, enum texicmd cmd, size_t *pos) |
|
while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) |
while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) |
advance(p, pos); |
advance(p, pos); |
|
|
texiwarn(p, "unexpected \"end\": %.*s", (int)(*pos - start), &BUF(p)[start]); |
texiwarn(p, "unexpected \"end\": %.*s", |
|
(int)(*pos - start), &BUF(p)[start]); |
advanceeoln(p, pos, 1); |
advanceeoln(p, pos, 1); |
} |
} |
|
|
Line 1761 doenumerate(struct texi *p, enum texicmd cmd, size_t * |
|
Line 1789 doenumerate(struct texi *p, enum texicmd cmd, size_t * |
|
{ |
{ |
enum texilist sv = p->list; |
enum texilist sv = p->list; |
|
|
|
advanceeoln(p, pos, 1); |
|
|
p->list = TEXILIST_NOITEM; |
p->list = TEXILIST_NOITEM; |
teximacro(p, "Bl -enum"); |
teximacro(p, "Bl -enum"); |
p->seenvs = 1; |
p->seenvs = 1; |
/* FIXME: ignore and parseeoln. */ |
parseto(p, pos, texitoks[cmd].tok); |
advanceeoln(p, pos, 1); |
|
parseto(p, pos, "enumerate"); |
|
teximacro(p, "El"); |
teximacro(p, "El"); |
p->list = sv; |
p->list = sv; |
} |
} |
Line 1776 doitemize(struct texi *p, enum texicmd cmd, size_t *po |
|
Line 1804 doitemize(struct texi *p, enum texicmd cmd, size_t *po |
|
{ |
{ |
enum texilist sv = p->list; |
enum texilist sv = p->list; |
|
|
|
advanceeoln(p, pos, 1); |
|
|
p->list = TEXILIST_NOITEM; |
p->list = TEXILIST_NOITEM; |
teximacro(p, "Bl -bullet"); |
teximacro(p, "Bl -bullet"); |
p->seenvs = 1; |
p->seenvs = 1; |
/* FIXME: ignore and parseeoln. */ |
parseto(p, pos, texitoks[cmd].tok); |
advanceeoln(p, pos, 1); |
|
parseto(p, pos, "itemize"); |
|
teximacro(p, "El"); |
teximacro(p, "El"); |
p->list = sv; |
p->list = sv; |
} |
} |
|
|
doignline(struct texi *p, enum texicmd cmd, size_t *pos) |
doignline(struct texi *p, enum texicmd cmd, size_t *pos) |
{ |
{ |
|
|
/* FIXME: ignore and parseeoln. */ |
advanceeoln(p, pos, 1); |
advanceeoln(p, pos, 1); |
|
} |
} |
|
|
/* |
/* |
Line 1899 main(int argc, char *argv[]) |
|
Line 1926 main(int argc, char *argv[]) |
|
} |
} |
|
|
texiexit(&texi); |
texiexit(&texi); |
return(EXIT_FAILURE); |
exit(EXIT_SUCCESS); |
usage: |
usage: |
fprintf(stderr, "usage: %s [-Cdir] [-Idirs] [file]\n", progname); |
fprintf(stderr, "usage: %s [-Cdir] [-Idirs] [file]\n", progname); |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |