version 1.22, 2015/02/19 16:44:26 |
version 1.23, 2015/02/19 20:55:56 |
|
|
TEXICMD_APPENDIX, |
TEXICMD_APPENDIX, |
TEXICMD_APPENDIXSEC, |
TEXICMD_APPENDIXSEC, |
TEXICMD_APPENDIXSUBSEC, |
TEXICMD_APPENDIXSUBSEC, |
|
TEXICMD_APPENDIXSUBSUBSEC, |
TEXICMD_ASTERISK, |
TEXICMD_ASTERISK, |
TEXICMD_AT, |
TEXICMD_AT, |
TEXICMD_AUTHOR, |
TEXICMD_AUTHOR, |
|
|
TEXICMD_KEY, |
TEXICMD_KEY, |
TEXICMD_KINDEX, |
TEXICMD_KINDEX, |
TEXICMD_LATEX, |
TEXICMD_LATEX, |
|
TEXICMD_LOWERSECTIONS, |
TEXICMD_MATH, |
TEXICMD_MATH, |
TEXICMD_MENU, |
TEXICMD_MENU, |
TEXICMD_MULTITABLE, |
TEXICMD_MULTITABLE, |
|
|
TEXICMD_PARINDENT, |
TEXICMD_PARINDENT, |
TEXICMD_PRINTINDEX, |
TEXICMD_PRINTINDEX, |
TEXICMD_R, |
TEXICMD_R, |
|
TEXICMD_RAISESECTIONS, |
TEXICMD_REF, |
TEXICMD_REF, |
TEXICMD_RESULT, |
TEXICMD_RESULT, |
TEXICMD_SAMP, |
TEXICMD_SAMP, |
|
|
TEXICMD_STRONG, |
TEXICMD_STRONG, |
TEXICMD_SUBHEADING, |
TEXICMD_SUBHEADING, |
TEXICMD_SUBSECTION, |
TEXICMD_SUBSECTION, |
|
TEXICMD_SUBSUBSECTION, |
TEXICMD_SUBTITLE, |
TEXICMD_SUBTITLE, |
TEXICMD_SYNCODEINDEX, |
TEXICMD_SYNCODEINDEX, |
TEXICMD_T, |
TEXICMD_T, |
|
|
TEXICMD_UNNUMBERED, |
TEXICMD_UNNUMBERED, |
TEXICMD_UNNUMBEREDSEC, |
TEXICMD_UNNUMBEREDSEC, |
TEXICMD_UNNUMBEREDSUBSEC, |
TEXICMD_UNNUMBEREDSUBSEC, |
|
TEXICMD_UNNUMBEREDSUBSUBSEC, |
TEXICMD_UREF, |
TEXICMD_UREF, |
TEXICMD_URL, |
TEXICMD_URL, |
TEXICMD_VAR, |
TEXICMD_VAR, |
|
|
TEXICMD__MAX |
TEXICMD__MAX |
}; |
}; |
|
|
|
#define SECTSZ 4 |
|
static const char *const sects[SECTSZ] = { |
|
"Sh", |
|
"Ss", |
|
"Em", |
|
"No", |
|
}; |
|
|
/* |
/* |
* The file currently being parsed. |
* The file currently being parsed. |
* This keeps track of our location within that file. |
* This keeps track of our location within that file. |
|
|
size_t dirsz; /* number of texi directories */ |
size_t dirsz; /* number of texi directories */ |
char *title; /* title of document */ |
char *title; /* title of document */ |
char *subtitle; /* subtitle of document */ |
char *subtitle; /* subtitle of document */ |
|
int secoffs; /* see sectioner() */ |
/* |
/* |
* The following control what we output to the screen. |
* The following control what we output to the screen. |
* The complexity is required to accomodate for mdoc(7). |
* The complexity is required to accomodate for mdoc(7). |
Line 291 static void domultitable(struct texi *, enum texicmd, |
|
Line 305 static void domultitable(struct texi *, enum texicmd, |
|
static void doquotation(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void doquotation(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotable(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotable(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotop(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotop(struct texi *, enum texicmd, const char *, size_t, size_t *); |
|
static void dosecoffs(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosection(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosection(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosp(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosp(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosubsection(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosubsection(struct texi *, enum texicmd, const char *, size_t, size_t *); |
|
static void dosubsubsection(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosymbol(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dosymbol(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotab(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotab(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotitle(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dotitle(struct texi *, enum texicmd, const char *, size_t, size_t *); |
Line 308 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
Line 324 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
{ dosection, "appendix", 8 }, /* TEXICMD_APPENDIX */ |
{ dosection, "appendix", 8 }, /* TEXICMD_APPENDIX */ |
{ dosection, "appendixsec", 11 }, /* TEXICMD_APPENDIXSEC */ |
{ dosection, "appendixsec", 11 }, /* TEXICMD_APPENDIXSEC */ |
{ dosubsection, "appendixsubsec", 14 }, /* TEXICMD_APPENDIXSUBSEC */ |
{ dosubsection, "appendixsubsec", 14 }, /* TEXICMD_APPENDIXSUBSEC */ |
|
{ dosubsubsection, "appendixsubsubsec", 17 }, /* TEXICMD_APPENDIXSUBSUBSEC */ |
{ 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 */ |
Line 401 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
Line 418 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
{ dobracket, "key", 3 }, /* TEXICMD_KEY */ |
{ dobracket, "key", 3 }, /* TEXICMD_KEY */ |
{ doignline, "kindex", 6 }, /* TEXICMD_KINDEX */ |
{ doignline, "kindex", 6 }, /* TEXICMD_KINDEX */ |
{ dosymbol, "LaTeX", 5 }, /* TEXICMD_LATEX */ |
{ dosymbol, "LaTeX", 5 }, /* TEXICMD_LATEX */ |
|
{ dosecoffs, "lowersections", 13 }, /* TEXICMD_LOWERSECTIONS */ |
{ domath, "math", 4 }, /* TEXICMD_MATH */ |
{ domath, "math", 4 }, /* TEXICMD_MATH */ |
{ doignblock, "menu", 4 }, /* TEXICMD_MENU */ |
{ doignblock, "menu", 4 }, /* TEXICMD_MENU */ |
{ domultitable, "multitable", 10 }, /* TEXICMD_MULTITABLE */ |
{ domultitable, "multitable", 10 }, /* TEXICMD_MULTITABLE */ |
Line 416 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
Line 434 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
{ doignline, "paragraphindent", 14 }, /* TEXICMD_PARINDENT */ |
{ doignline, "paragraphindent", 14 }, /* TEXICMD_PARINDENT */ |
{ doignline, "printindex", 10 }, /* TEXICMD_PRINTINDEX */ |
{ doignline, "printindex", 10 }, /* TEXICMD_PRINTINDEX */ |
{ doinline, "r", 1 }, /* TEXICMD_R */ |
{ doinline, "r", 1 }, /* TEXICMD_R */ |
|
{ dosecoffs, "raisesections", 13 }, /* TEXICMD_RAISESECTIONS */ |
{ dobracket, "ref", 3 }, /* TEXICMD_REF */ |
{ dobracket, "ref", 3 }, /* TEXICMD_REF */ |
{ dosymbol, "result", 6 }, /* TEXICMD_RESULT */ |
{ dosymbol, "result", 6 }, /* TEXICMD_RESULT */ |
{ doinline, "samp", 4 }, /* TEXICMD_SAMP */ |
{ doinline, "samp", 4 }, /* TEXICMD_SAMP */ |
Line 439 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
Line 458 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
{ doinline, "strong", 6 }, /* TEXICMD_STRONG */ |
{ doinline, "strong", 6 }, /* TEXICMD_STRONG */ |
{ dosubsection, "subheading", 10 }, /* TEXICMD_SUBHEADING */ |
{ dosubsection, "subheading", 10 }, /* TEXICMD_SUBHEADING */ |
{ dosubsection, "subsection", 10 }, /* TEXICMD_SUBSECTION */ |
{ dosubsection, "subsection", 10 }, /* TEXICMD_SUBSECTION */ |
|
{ dosubsubsection, "subsubsection", 13 }, /* TEXICMD_SUBSUBSECTION */ |
{ doignline, "subtitle", 8 }, /* TEXICMD_SUBTITLE */ |
{ doignline, "subtitle", 8 }, /* TEXICMD_SUBTITLE */ |
{ doignline, "syncodeindex", 12 }, /* TEXICMD_SYNCODEINDEX */ |
{ doignline, "syncodeindex", 12 }, /* TEXICMD_SYNCODEINDEX */ |
{ doinline, "t", 1 }, /* TEXICMD_T */ |
{ doinline, "t", 1 }, /* TEXICMD_T */ |
Line 456 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
Line 476 static const struct texitok texitoks[TEXICMD__MAX] = { |
|
{ dosection, "unnumbered", 10 }, /* TEXICMD_UNNUMBERED */ |
{ dosection, "unnumbered", 10 }, /* TEXICMD_UNNUMBERED */ |
{ dosection, "unnumberedsec", 13 }, /* TEXICMD_UNNUMBEREDSEC */ |
{ dosection, "unnumberedsec", 13 }, /* TEXICMD_UNNUMBEREDSEC */ |
{ dosubsection, "unnumberedsubsec", 16 }, /* TEXICMD_UNNUMBEREDSUBSEC */ |
{ dosubsection, "unnumberedsubsec", 16 }, /* TEXICMD_UNNUMBEREDSUBSEC */ |
|
{ dosubsubsection, "unnumberedsubsubsec", 19 }, /* TEXICMD_UNNUMBEREDSUBSUBSEC */ |
{ dolink, "uref", 4 }, /* TEXICMD_UREF */ |
{ dolink, "uref", 4 }, /* TEXICMD_UREF */ |
{ dolink, "url", 3 }, /* TEXICMD_URL */ |
{ dolink, "url", 3 }, /* TEXICMD_URL */ |
{ doinline, "var", 3 }, /* TEXICMD_VAR */ |
{ doinline, "var", 3 }, /* TEXICMD_VAR */ |
Line 1801 doignargn(struct texi *p, enum texicmd cmd, |
|
Line 1822 doignargn(struct texi *p, enum texicmd cmd, |
|
p->ign--; |
p->ign--; |
} |
} |
|
|
|
/* |
|
* Sections can be made subsections and so on by way of the |
|
* @raiseections and @lowersections commands. |
|
* Perform this check here and return the actual section number adjusted |
|
* to the raise level. |
|
*/ |
|
static int |
|
sectioner(struct texi *p, int sec) |
|
{ |
|
|
|
if ((sec -= p->secoffs) < 0) { |
|
texiwarn(p, "section below minimum, clamping"); |
|
return(0); |
|
} else if (sec >= SECTSZ) { |
|
texiwarn(p, "section above maximum, clamping"); |
|
return(SECTSZ - 1); |
|
} |
|
return(sec); |
|
} |
|
|
static void |
static void |
|
dosubsubsection(struct texi *p, enum texicmd cmd, |
|
const char *buf, size_t sz, size_t *pos) |
|
{ |
|
int sec; |
|
|
|
sec = sectioner(p, 3); |
|
|
|
/* We don't have a subsubsubsection, so make one up. */ |
|
texivspace(p); |
|
teximacroopen(p, sects[sec]); |
|
parseeoln(p, buf, sz, pos); |
|
teximacroclose(p); |
|
texivspace(p); |
|
} |
|
|
|
static void |
dosubsection(struct texi *p, enum texicmd cmd, |
dosubsection(struct texi *p, enum texicmd cmd, |
const char *buf, size_t sz, size_t *pos) |
const char *buf, size_t sz, size_t *pos) |
{ |
{ |
|
int sec; |
|
|
|
sec = sectioner(p, 2); |
|
|
if (p->outmacro) |
if (p->outmacro) |
texierr(p, "\"Em\" in open line scope!?"); |
texierr(p, "\"%s\" in open line scope!?", sects[sec]); |
else if (p->literal) |
else if (p->literal) |
texierr(p, "\"Em\" in a literal scope!?"); |
texierr(p, "\"%s\" in a literal scope!?", sects[sec]); |
|
|
/* We don't have a subsubsection, so make one up. */ |
/* We don't have a subsubsection, so make one up. */ |
texivspace(p); |
texivspace(p); |
teximacroopen(p, "Em"); |
teximacroopen(p, sects[sec]); |
parseeoln(p, buf, sz, pos); |
parseeoln(p, buf, sz, pos); |
teximacroclose(p); |
teximacroclose(p); |
texivspace(p); |
texivspace(p); |
} |
} |
|
|
static void |
static void |
|
dosecoffs(struct texi *p, enum texicmd cmd, |
|
const char *buf, size_t sz, size_t *pos) |
|
{ |
|
|
|
if (TEXICMD_RAISESECTIONS == cmd) |
|
p->secoffs++; |
|
else |
|
p->secoffs--; |
|
} |
|
|
|
static void |
dosection(struct texi *p, enum texicmd cmd, |
dosection(struct texi *p, enum texicmd cmd, |
const char *buf, size_t sz, size_t *pos) |
const char *buf, size_t sz, size_t *pos) |
{ |
{ |
const char *blk; |
int sec; |
|
|
switch (cmd) { |
switch (cmd) { |
case (TEXICMD_APPENDIX): |
case (TEXICMD_APPENDIX): |
case (TEXICMD_CHAPTER): |
case (TEXICMD_CHAPTER): |
case (TEXICMD_TOP): |
case (TEXICMD_TOP): |
case (TEXICMD_UNNUMBERED): |
case (TEXICMD_UNNUMBERED): |
blk = "Sh"; |
sec = sectioner(p, 0); |
break; |
break; |
case (TEXICMD_APPENDIXSEC): |
case (TEXICMD_APPENDIXSEC): |
case (TEXICMD_HEADING): |
case (TEXICMD_HEADING): |
case (TEXICMD_SECTION): |
case (TEXICMD_SECTION): |
case (TEXICMD_UNNUMBEREDSEC): |
case (TEXICMD_UNNUMBEREDSEC): |
blk = "Ss"; |
sec = sectioner(p, 1); |
break; |
break; |
default: |
default: |
abort(); |
abort(); |
} |
} |
|
|
if (p->outmacro) |
if (p->outmacro) |
texierr(p, "%s in open line scope!?", blk); |
texierr(p, "\"%s\" in open line scope!?", sects[sec]); |
else if (p->literal) |
else if (p->literal) |
texierr(p, "%s in a literal scope!?", blk); |
texierr(p, "\"%s\" in a literal scope!?", sects[sec]); |
|
|
teximacroopen(p, blk); |
teximacroopen(p, sects[sec]); |
parseeoln(p, buf, sz, pos); |
parseeoln(p, buf, sz, pos); |
teximacroclose(p); |
teximacroclose(p); |
p->seenvs = 1; |
p->seenvs = 1; |