=================================================================== RCS file: /cvs/texi2mdoc/main.c,v retrieving revision 1.57 retrieving revision 1.60 diff -u -p -r1.57 -r1.60 --- texi2mdoc/main.c 2015/03/01 16:57:39 1.57 +++ texi2mdoc/main.c 2015/03/05 08:18:56 1.60 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.57 2015/03/01 16:57:39 kristaps Exp $ */ +/* $Id: main.c,v 1.60 2015/03/05 08:18:56 kristaps Exp $ */ /* * Copyright (c) 2015 Kristaps Dzonsons * @@ -94,7 +94,8 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { dosymbol, "*", 1 }, /* TEXICMD_ASTERISK */ { dosymbol, "@", 1 }, /* TEXICMD_AT */ { doignline, "author", 6 }, /* TEXICMD_AUTHOR */ - { doinline, "b", 1 }, /* TEXICMD_BOLD */ + { doinline, "b", 1 }, /* TEXICMD_B */ + { dosymbol, "\\", 1 }, /* TEXICMD_BACKSLASH */ { dosymbol, "!", 1 }, /* TEXICMD_BANG */ { dosymbol, "bullet", 6 }, /* TEXICMD_BULLET */ { dobye, "bye", 3 }, /* TEXICMD_BYE */ @@ -268,7 +269,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doaccent, "ringaccent", 10 }, /* TEXICMD_RINGACCENT */ { doinline, "samp", 4 }, /* TEXICMD_SAMP */ { doinline, "sansserif", 9 }, /* TEXICMD_SANSSERIF */ - { dobracket, "sc", 2 }, /* TEXICMD_SC */ + { doinline, "sc", 2 }, /* TEXICMD_SC */ { dosection, "section", 7 }, /* TEXICMD_SECTION */ { dovalue, "set", 3 }, /* TEXICMD_SET */ { doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */ @@ -341,6 +342,12 @@ static const struct texitok __texitoks[TEXICMD__MAX] = const struct texitok *const texitoks = __texitoks; +/* + * Texinfo has lots of indexes. + * You can add new ones in a variety of ways. + * We maintain an array of all of these index names (usually a few + * letters) and pass unknown commands through the array list. + */ static void dodefindex(struct texi *p, enum texicmd cmd, size_t *pos) { @@ -349,7 +356,6 @@ dodefindex(struct texi *p, enum texicmd cmd, size_t *p while (*pos < BUFSZ(p) && isws(BUF(p)[*pos])) advance(p, pos); - start = end = *pos; while (end < BUFSZ(p) && ! ismspace(BUF(p)[end])) end++; @@ -357,18 +363,21 @@ dodefindex(struct texi *p, enum texicmd cmd, size_t *p if (start == end) { advanceeoln(p, pos, 1); return; - } else if (NULL == (cp = malloc(end - start + 1))) + } + + if (NULL == (cp = malloc(end - start + 1))) texiabort(p, NULL); - memcpy(cp, &BUF(p)[start], end - start); cp[end - start] = '\0'; + /* FIXME: use reallocarray(). */ p->indexs = realloc(p->indexs, sizeof(char *) * (p->indexsz + 1)); - if (NULL == p->indexs) texiabort(p, NULL); p->indexs[p->indexsz++] = cp; + + advanceeoln(p, pos, 1); } static void @@ -725,13 +734,30 @@ doinline(struct texi *p, enum texicmd cmd, size_t *pos } if (NULL == macro || p->literal || TEXILIST_TABLE == p->list) { + if (TEXICMD_SC == cmd) + p->uppercase++; parsebracket(p, pos, 0); + if (TEXICMD_SC == cmd) + p->uppercase--; 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); p->seenws = 0; + if (TEXICMD_SC == cmd) + p->uppercase++; parsebracket(p, pos, 0); + if (TEXICMD_SC == cmd) + p->uppercase--; texipunctuate(p, pos); teximacroclose(p); } @@ -1195,6 +1221,9 @@ dosymbol(struct texi *p, enum texicmd cmd, size_t *pos break; case (TEXICMD_AT): texiputchar(p, '@'); + break; + case (TEXICMD_BACKSLASH): + texiputchar(p, '\\'); break; case (TEXICMD_BANG): texiputchar(p, '!');