home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume16 / texi2roff < prev    next >
Text File  |  1988-11-14  |  54KB  |  1,636 lines

  1. Subject:  v16i085:  Convert GNU Texinfo files to nroff/troff files
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: Beverly Erlebacher <erlebach@turing.toronto.edu>
  6. Posting-number: Volume 16, Issue 85
  7. Archive-name: texi2roff
  8.  
  9. Here is texi2roff, a program to convert documents written using the
  10. Texinfo macro language for TeX to be printable with nroff and troff,
  11. using -ms, -me or -mm macros.  texi2roff is of use to people who want
  12. to read GNU project documentation but don't have TeX available.
  13. All Texinfo commands are supported to some extent, even if by carefully
  14. discarding them.
  15.  
  16.  
  17. Beverly Erlebacher            ..uunet!utai!utcsri!erlebach
  18. Computer Systems Research Institute      erlebach@csri.toronto.edu
  19. University of Toronto
  20. Toronto, Ontario CANADA
  21.  
  22. # More or less normal sort of shar file 
  23. echo unbundling file: texi2roff.1 1>&2
  24. sed -e 's/^X//' >texi2roff.1 <<'END_OF_texi2roff.1'
  25. X.TH TEXI2ROFF 1
  26. X.DA 31 Aug 88
  27. X.SH NAME
  28. Xtexi2roff \- convert Texinfo commands in documents 
  29. Xto nroff/troff commands.
  30. X.SH SYNOPSIS
  31. X.B texi2roff
  32. X.BR \-m {
  33. X.B e
  34. X|
  35. X.B m
  36. X|
  37. X.B s
  38. X}
  39. X.RB [ \-It
  40. X] [ file ... ]
  41. X.SH DESCRIPTION
  42. X.I texi2roff
  43. Xconverts documents which use the Texinfo macro language for TeX
  44. Xso they can be formatted by nroff or troff instead. 
  45. X.PP
  46. XThe named
  47. X.IR file s
  48. Xare read and processed in order. If no
  49. X.I file
  50. Xis given or if the
  51. X.I file
  52. Xis '\-'
  53. X.I texi2roff
  54. Xreads the standard input.
  55. X.PP
  56. XAll Texinfo commands are supported to some extent, even if by carefully
  57. Xdiscarding them. Since Texinfo allows the use of arbitrary TeX
  58. Xcommands provided the leading \e is replaced by @, some common
  59. XTeX commands not explicitly in Texinfo are supported as well.  To
  60. Xsee how various commands are handled examine the
  61. Xtranslation tables.  Any command whose type is DISCARD will
  62. Xdisappear with all contained text (unless the -t option is used).
  63. X.PP
  64. X.B \ef(CW
  65. Xand 
  66. X.B .ft\ CW
  67. Xare used to change to constant-width (typewriter-like) font.
  68. XIf this is not the standard at your site, run your
  69. X.I texi2roff
  70. Xoutput through sed or edit the translation tables.
  71. X.SH OPTIONS
  72. X.IP "\-m
  73. Xindicates which macro package you intend to 
  74. Xuse with nroff or troff.  Specify one of -me, -ms, or -mm.
  75. XIf your site has both -ms and -msnew macros, use -msnew 
  76. Xwith nroff/troff for better results.
  77. X.IP "\-I
  78. Xcauses Texinfo "Info file" menu and node contents and 'ifinfo' text
  79. Xto appear in the output.  Info files are a kind of 
  80. Xhypertext feature of Texinfo.  This material would not normally appear
  81. Xin a printed Texinfo document, but may contain interesting information
  82. Xor be useful when searching a document for a topic.
  83. X.IP "\-t
  84. X(transparent) prints contents of otherwise discarded commands,
  85. Xfor people who are afraid of missing something.  For best results
  86. Xwith the -t option, use -It.
  87. X.SH DIAGNOSTICS
  88. XErrors are reported giving file name and line number.
  89. X.PP
  90. XUnrecognized Texinfo commands may corrupt the program's command stack
  91. Xbecause it is hard to tell how to discard them when their closing 
  92. Xtokens are unknown. The program may guess
  93. Xwrong about which command is at fault when giving an 
  94. Xerror message for the closing token, but will generally
  95. Xrecover and translate the remainder of the document after such errors.
  96. X.SH HISTORY
  97. XWritten in February 1988 
  98. Xat the University of Toronto by Beverly Erlebacher
  99. X(erlebach@csri.toronto.edu). Current version (1.0a) released in
  100. XAugust 1988 by the same author.
  101. X.SH BUGS
  102. XAppendices will come out as unnumbered sections, instead of being
  103. X"numbered" with consecutive capital letters.
  104. XCross references are printed, but not with page numbers as Texinfo
  105. Xdoes. Indices and tables of contents are not generated.
  106. X.PP
  107. XSince \efP is a toggle, not a stack, nested Texinfo commands that
  108. Xgenerate nested font changes would not 'un-nest' correctly
  109. Xif it were used as a close
  110. Xto a font change.  The program needs a font stack. In the interim,
  111. Xit uses \efR, which causes less trouble than \efP.
  112. X.PP
  113. XThere are a number of differences in formatting details
  114. Xcompared to Texinfo. The -ms macros probably give the closest emulation.
  115. XIndentation is occasionally imperfect.
  116. X.PP
  117. XSince literal double quotes (") cause bizarre effects
  118. Xin macro arguments for -me macros, 
  119. X.I texi2roff
  120. Xreplaces them with \e(fm\e(fm (foot marks \(em \(fm\(fm)
  121. Xwhen the -me option is used.
  122. X.PP
  123. X.I texi2roff
  124. Xmay generate output which falls afoul of bugs 
  125. Xor strange features in nroff/troff.
  126. XThe program tries to avoid generating sequences that cause trouble.
  127. X.PP
  128. X"A program designed for inputs from people is
  129. Xusually stressed beyond the breaking point by computer-generated
  130. Xinputs." 
  131. X.PP
  132. X\&\(em Dennis Ritchie
  133. END_OF_texi2roff.1
  134. echo unbundling file: Readme 1>&2
  135. sed -e 's/^X//' >Readme <<'END_OF_Readme'
  136. Xtexi2roff - Texinfo to nroff/troff translator
  137. X
  138. XCopyright 1988  Beverly A. Erlebacher  (see copyright file)
  139. X
  140. XRaison d'etre:
  141. X-------------
  142. XI wrote texi2roff to help out Rayan Zachariassen, the author of
  143. XZMailer.  Rayan had prepared his documentation using Texinfo at the
  144. Xrequest of the GNU Project.  After he sent ZMailer to his alpha
  145. Xtesters, he got many complaints from people who did not have TeX
  146. Xinstalled and wanted documentation they could read or print with
  147. Xnroff/troff.
  148. X
  149. XIn the expectation that there are other people in the same plight
  150. Xwho would like to read documentation from the GNU project, I am
  151. Xposting texi2roff.
  152. X
  153. XPlease Note:
  154. X-----------
  155. Xtexi2roff translates Texinfo documents, *NOT* TeX documents. Not
  156. Xall GNU documentation uses Texinfo, although most of the recent
  157. Xmaterial does. A Texinfo document can be distinguished from a TeX
  158. Xdocument by the preponderance of commands starting with '@'. TeX
  159. Xcommands start with '\'.
  160. X
  161. Xnroff vs. troff
  162. X---------------
  163. XI tested this program almost exclusively with nroff, so I expect
  164. Xsome bugs in the troff oriented commands.  Please report bugs
  165. X(and fixes!).
  166. X
  167. XPortability:
  168. X-----------
  169. XI developed texi2roff on Sun 2's and 3's running Sun OS 3.n and 4.0
  170. Xand tested it on a Vax running 4.2BSD, a MIPS running 4.3BSD and an
  171. XHP-9000 running HP-UX.  There is a -DBSD directive in the program which
  172. Xonly controls which string header to #include and which of strchr() or
  173. Xindex() is used.  It is reported to work with Microport SVR2, Xenix
  174. XSystem III and several other environments. It even compiles with Turbo C
  175. Xand runs under MSDOS (SoftQuad (sq.com) sells nroff/troff for MSDOS). 
  176. XFor those using older C compilers, use -Dvoid=int.  
  177. X
  178. XThanks to Bob Webber (*not* the Bob Webber at Rutgers, this one is a
  179. Xmetallurgist), Peter Lee, Wolf Paul, Eric Christensen and Bill Mitchell
  180. Xfor testing this or an earlier version on a variety of machines, unix
  181. Xvariants and compilers.
  182. X
  183. XIn order to make the program more portable, I've added support for -me
  184. Xand -mm macros as well as the -ms macros it was developed with. 
  185. XUnfortunately, the -mm macros I have here are not the standard System V
  186. Xset. I would appreciate feedback on this - please report on any changes
  187. Xnecessary.
  188. X
  189. XDesign and Future Enhancements:
  190. X------------------------------
  191. XBy isolating all explicit command strings in the table header files,
  192. XI've made the program especially easy to modify and extend. Most
  193. Xcustomizations or refinements can (and should!) be made by twiddling
  194. Xthe strings in the tables.
  195. X
  196. XWhen modifying texi2roff, please respect the design, and keep all
  197. Xexplicit roff command strings in the table header files. Note
  198. Xthat the user's selection of macro package does not affect any code
  199. Xin translate.c. Please strive to keep the program table-driven.
  200. X
  201. XI use a mixture of macros and raw commands which is causing some of
  202. Xthe minor formatting problems.  Ideally, the program should have its
  203. Xown macro package.
  204. X
  205. XMore of the discarded commands could be implemented and some of the
  206. Xitems in the 'bugs' section of the manual page addressed.
  207. X
  208. XTexinfo is a moving target. I have provided crude support for some 
  209. Xfeatures that will not appear until release 19 of Gnuemacs, since
  210. XI dont have complete specs for them.  Most new commands can just be
  211. Xadded to the tables and the program will handle them.
  212. X
  213. XI feel robustness is very important so I have made every effort to
  214. Xdetect, report and recover gracefully from errors in the input.  As
  215. Xtexi2roff is more than an order of magnitude faster than nroff, there
  216. Xis no need to sacrifice other desirable attributes for speed.
  217. X
  218. X ...uunet!utai!utcsri!erlebach        erlebach@csri.toronto.edu
  219. X
  220. X    Beverly Erlebacher
  221. X    Computer Systems Research Institute
  222. X    10 King's College Road
  223. X    University of Toronto,
  224. X    Toronto, Ontario, Canada M5S 1A4
  225. X
  226. END_OF_Readme
  227. echo unbundling file: copyright 1>&2
  228. sed -e 's/^X//' >copyright <<'END_OF_copyright'
  229. XCopyright notice for texi2roff - Texinfo to nroff/troff translator:
  230. X
  231. X/*
  232. X * Copyright  1988 by  Beverly A. Erlebacher
  233. X * Written by Beverly A. Erlebacher.  Not derived from licensed software.
  234. X * This software is not subject to any license of the American Telephone
  235. X * and Telegraph Company or of the Regents of the University of California.
  236. X *
  237. X * Permission is granted to anyone to use this software for any purpose on
  238. X * any computer system, and to alter it and redistribute it freely, subject
  239. X * to the following restrictions:
  240. X *
  241. X * 1. The author is not responsible for the consequences of use of this
  242. X *    software, no matter how awful, even if they arise from flaws in it.
  243. X *
  244. X * 2. The origin of this software must not be misrepresented, either by
  245. X *    explicit claim or by omission.  Since few users ever read sources,
  246. X *    credits must appear in the documentation.
  247. X *
  248. X * 3. Altered versions must be plainly marked as such, and must not be
  249. X *    misrepresented as being the original software.  Since few users
  250. X *    ever read sources, credits must appear in the documentation.
  251. X *
  252. X * 4. This notice may not be removed or altered.
  253. X *
  254. X * 5. This release may be redistributed only in its original state:  existing
  255. X *    material (e.g. sources) may not be deleted, changes may not be made to
  256. X *    the originals, and new materials must be added as a supplementary
  257. X *    distribution rather than interspersed with the originals.
  258. X *
  259. X */
  260. X
  261. XBeverly Erlebacher
  262. XComputer Systems Research Institute
  263. X10 King's College Road
  264. XUniversity of Toronto,
  265. XToronto, Ontario, Canada M5S 1A4
  266. X
  267. X ...uunet!utai!utcsri!erlebach        erlebach@csri.toronto.edu
  268. X
  269. END_OF_copyright
  270. echo unbundling file: Makefile 1>&2
  271. sed -e 's/^X//' >Makefile <<'END_OF_Makefile'
  272. X
  273. X# Makefile for Texinfo to nroff/troff translator (texi2roff)
  274. X
  275. XCC = cc
  276. X
  277. X# Flags:
  278. X# -DBSD controls use of string(s).h and strchr/index only (not needed for Sun)
  279. X# use -Dvoid=int for System III and V7
  280. X
  281. XCFLAGS = -O
  282. X
  283. XOBJECTS = texi2roff.o table.o translate.o
  284. X
  285. Xtexi2roff: $(OBJECTS)
  286. X    $(CC) -o $@ $(CFLAGS) $(OBJECTS)
  287. X
  288. Xtexi2roff.o : texi2roff.h
  289. X
  290. Xtranslate.o : texi2roff.h
  291. X
  292. Xtable.o : texi2roff.h tablems.h tablemm.h tableme.h
  293. X
  294. Xclean:
  295. X    -rm -f *.o core errs
  296. X
  297. Xbundle:
  298. X    bundle texi2roff.1 Readme copyright Makefile  *.h *.c >bundled
  299. X    ls -l bundled
  300. END_OF_Makefile
  301. echo unbundling file: tableme.h 1>&2
  302. sed -e 's/^X//' >tableme.h <<'END_OF_tableme.h'
  303. X/*
  304. X * tableme.h - -me macros table and other explicit troff command strings
  305. X *         Release 1.0a    August 1988
  306. X *
  307. X * Copyright 1988  Beverly A.Erlebacher
  308. X * erlebach@csri.toronto.edu    ...uunet!utai!utcsri!erlebach
  309. X *
  310. X */
  311. X
  312. X/* 
  313. X * string to emit before the first input. this is the place to put troff
  314. X * commands controlling default point size, margin size, line length, etc.
  315. X */
  316. Xchar meinit[] = "";
  317. X
  318. X/*
  319. X * miscellaneous commands, described in texi2roff.h 
  320. X */
  321. Xstruct misccmds mecmds = { "\n.pp\n", "\n.ip\n", "", "", "\\(fm\\(fm"};
  322. X
  323. X/*
  324. X * patches for table entries for -I option 
  325. X */
  326. Xstruct tablerecd menodeentry = {
  327. X    "@node",    "\n", "\n.lp\n\\s8Node:", "\\s0\n.br\n", PARAGRAPH};
  328. X
  329. Xstruct tablerecd memenuentry = {
  330. X    "@menu",    "@end", "\n.(l I\n\\s8Menu: \n", "\\s0\n.)l\n", DISPLAY}; 
  331. X
  332. Xstruct tablerecd meifinfoentry = {
  333. X    "@ifinfo",    "@end", "\n", "\n", PARAGRAPH}; 
  334. X
  335. Xstruct tablerecd metable[] = {
  336. X    "@*",        "",    "\n.br\n",    "",        ESCAPED,
  337. X    "@.",        "",    "\\&.",        "",        ESCAPED,
  338. X    "@:",        "",    "",        "",        ESCAPED,
  339. X    "@@",        "",    "@",        "",        ESCAPED,
  340. X    "@TeX{",        "}",    "TeX",        "",        INPARA,
  341. X    "@appendix",    "\n",    "\n.bp\n.uh ",    "\n.br\n",    HEADING,
  342. X    "@appendixsec",    "\n",    "\n.uh ",     "\n.br\n",    HEADING,
  343. X    "@appendixsubsec",    "\n",    "\n.uh ",     "\n.br\n",    HEADING,
  344. X    "@appendixsubsubsec","\n",    "\n.uh ",     "\n.br\n",    HEADING,
  345. X    "@asis",        "\n",    "",        "",        PARAGRAPH,
  346. X    "@asis{",        "}",    "",        "",        INPARA,
  347. X    "@br",        "\n",    "\n.br\n.sp\n", "",        PARAGRAPH,
  348. X    "@bullet",        "\n",    "\\(bu",    "",        CHAR,
  349. X    "@bullet{",        "}",    "\\(bu",    "",        CHAR,
  350. X    "@bye",        "\n",    "",        "",        DISCARD,
  351. X    "@b{",        "}",    "\\fB",        "\\fR",        INPARA,
  352. X    "@c",        "\n",    "",        "",        DISCARD,
  353. X    "@center",        "\n",    "\n.ce\n",    "",        HEADING,
  354. X    "@chapter",        "\n",    "\n.bp\n.sh 1 ","\n.br\n",    HEADING,
  355. X    "@cindex",         "\n",    "",        "",        DISCARD,
  356. X    "@cite{",        "}",    "\\fI",        "\\fR",        INPARA,
  357. X    "@code{",        "}",    "\\fB",        "\\fR",        INPARA,
  358. X    "@comment",        "\n",    "",        "",        DISCARD,
  359. X    "@contents",    "\n",    "",        "",        DISCARD,
  360. X    "@copyright{",    "}",    "\\(co",    "",        CHAR,
  361. X    "@ctrl{",        "}",    "\\f(CW^",    "\\fR",        INPARA,
  362. X    "@dag",        "}{",    "\\(dg",    "",        CHAR,
  363. X    "@dag{",        "}",    "\\(dg",    "",        CHAR,
  364. X    "@ddag",        "}{",    "\\(dd",    "",        CHAR,
  365. X    "@ddag{",        "}",    "\\(dd",    "",        CHAR,
  366. X    "@deffn",        "@end", "\n.lp\n",    "",        HEADING,
  367. X    "@deffnx",          "\n",   "\n.br\n",    "\n.br\n",    HEADING,
  368. X    "@defspec",        "@end", "\n.lp\n",    "",        HEADING,
  369. X    "@defspecx",        "\n",   "\n.br\n",    "\n.br\n",    HEADING,
  370. X    "@defvar",        "@end", "\n.lp\n",    "",        HEADING,
  371. X    "@defvarx",         "\n",   "\n.br\n",    "\n.br\n",    HEADING,
  372. X    "@dfn{",        "}",    "\\fI",        "\\fR",        INPARA,
  373. X    "@display",        "@end", "\n.(l I\n",    "\n.)l\n",    DISPLAY,
  374. X    "@dots{",        "}",    "\\&...",    "",        INPARA,
  375. X    "@eject",        "\n",    "\n.bp\n",    "",        PARAGRAPH,
  376. X    "@emph{",        "}",    "\\fI",        "\\fR",        INPARA,
  377. X    "@end",        "\n",    "",        "\n.sp\n.in\n", END,
  378. X    "@enumerate",    "@end", "\n.(l L F\n.ba +5\n",
  379. X                    "\n.ba -5\n.)l\n",    ITEMIZING,
  380. X    "@example",        "@end", "\n.(l I\n.ft CW\n",
  381. X                    "\n.)l\n.ft R\n",    DISPLAY,
  382. X    "@file{",        "}",    "\\f(CW\\`",    "\\'\\fR",    INPARA,
  383. X    "@finalout",    "\n",    "",        "",        DISCARD,
  384. X    "@findex",         "\n",    "",        "",        DISCARD,
  385. X    "@footnote{",    "}",    "\n.(f \n",    "\n.)f\n",    FOOTNOTE,
  386. X    "@group",        "@end", "\n.(b\n",    "\n.)b\n",    PARAGRAPH,
  387. X    "@heading",        "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  388. X    "@headings",    "\n",    "",        "",        DISCARD,
  389. X    "@iappendix",    "\n",    "\n.bp\n.uh ",    "\n.br\n",    HEADING,
  390. X    "@iappendixsec",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  391. X    "@iappendixsubsec",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  392. X    "@ichapter",    "\n",    "\n.bp\n.uh ",    "\n.br\n",    HEADING,
  393. X    "@ifinfo",        "@end", "",        "",        DISCARD,
  394. X    "@iftex",        "@end", "",        "",        PARAGRAPH,
  395. X    "@ignore",        "@end", "",        "",        DISCARD,
  396. X    "@include",        "\n",    "",        "",        DISCARD,
  397. X    "@inforef{",    "}",    "See Info file ","",        PARAGRAPH,
  398. X    "@isection",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  399. X    "@isubsection",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  400. X    "@isubsubsection",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  401. X    "@item",        "\n",    "\n.ip ",    "\\ \n",    ITEM,
  402. X    "@itemize",        "@end", "\n.(l L F\n.ba +5\n",
  403. X                    "\n.ba -5\n.)l\n",    ITEMIZING,
  404. X    "@itemx",        "\n",    "\n.ip ",    "\\ \n",    ITEM,
  405. X    "@iunnumbered",    "\n",    "\n.bp\n.uh ",    "\n.br\n",    HEADING,
  406. X    "@iunnumberedsec",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  407. X    "@iunnumberedsubsec","\n",    "\n.uh ",    "\n.br\n",    HEADING,
  408. X    "@i{",        "}",    "\\fI",        "\\fR",        INPARA,
  409. X    "@kbd{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  410. X    "@key{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  411. X    "@kindex",         "\n",    "",        "",        DISCARD,
  412. X    "@majorheading",    "\n",    "\n.sp 4\n.uh ","\n.br\n",    HEADING,
  413. X    "@menu",        "@end", "",        "",        DISCARD, 
  414. X    "@minus{",        "}",    "\\-",        "",        CHAR,
  415. X    "@need",        "\n",    "",        "",        DISCARD,
  416. X    "@node",        "\n",    "",        "",        DISCARD,
  417. X    "@noindent",    "\n",    "\n.lp\n",    "",        PARAGRAPH,
  418. X    "@page",        "\n",    "\n.bp\n",    "",        PARAGRAPH,
  419. X    "@pindex",         "\n",    "",        "",        DISCARD,
  420. X    "@printindex",    "\n",    "",        "",        DISCARD,
  421. X    "@pxref{",        "}",    "see section  ","",        PARAGRAPH,
  422. X    "@quotation",    "@end", "\n.(q\n.nh\n", "\n.)q\n",    DISPLAY,
  423. X    "@r{",        "}",    "\\fR",        "\\fR",        INPARA,
  424. X    "@refill",        "\n",    "",        "",        DISCARD,
  425. X    "@samp{",        "}",    "\\f(CW\\`",    "\\'\\fR",    INPARA,
  426. X    "@section",        "\n",    "\n.sh 2 ",    "\n.br\n",    HEADING,
  427. X    "@setchapternewpage","\n",    "",        "",        DISCARD,
  428. X    "@setfilename",    "\n",    "",        "",        DISCARD,
  429. X    "@settitle",    "\n",    "\n.ds St ",
  430. X        "\n.oh '\\\\*(St''%'\n.eh '%''\\\\*(St'\n",    HEADING,
  431. X    "@smallbook",    "\n",    "",        "",        DISCARD,
  432. X    "@smallexample",    "@end", "\n.(l I\n.ft CW\n",
  433. X                    "\n.)l\n.ft R\n",    DISPLAY,
  434. X    "@sp",        "\n",    "\n.sp",    "\n",        PARAGRAPH,
  435. X    "@strong{",        "}",    "\\fB",        "\\fR",        INPARA,
  436. X    "@subheading",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  437. X    "@subsection",    "\n",    "\n.sh 3 ",    "\n.br\n",    HEADING,
  438. X    "@subsubheading",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  439. X    "@subsubsection",    "\n",    "\n.sh 4 ",    "\n.br\n",    HEADING,
  440. X    "@summarycontents", "\n",    "",        "",        DISCARD,
  441. X    "@synindex",    "\n",    "",        "",        DISCARD,
  442. X    "@t",        "\n",    "\t",        "",        CHAR,
  443. X    "@table",        "@end", "\n.(l L F\n.ba +5\n",
  444. X                    "\n.ba -5\n.)l\n",    ITEMIZING,
  445. X    "@tex",        "@end", "",        "",        DISCARD, 
  446. X    "@tindex",         "\n",    "",        "",        DISCARD,
  447. X    "@titlefont{",    "}",    "\n.sz +10\n.ce\n",
  448. X                        "\n.sz -10\n",    PARAGRAPH,
  449. X    "@titlepage",    "@end", "\n.tp\n",    "\n.bp\n",    PARAGRAPH,
  450. X    "@t{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  451. X    "@unnumbered",    "\n",    "\n.bp\n.uh ",    "\n.br\n",    HEADING,
  452. X    "@unnumberedsec",    "\n",    "\n.uh ",    "\n.br\n",    HEADING,
  453. X    "@unnumberedsubsec","\n",    "\n.uh ",    "\n.br\n",    HEADING,
  454. X    "@unnumberedsubsubsec","\n","\n.uh ",    "\n.br\n",    HEADING,
  455. X    "@var{",        "}",    "\\fI",        "\\fR",        INPARA,
  456. X    "@vfil",         "\n",    "",        "",        DISCARD,
  457. X    "@vindex",         "\n",    "",        "",        DISCARD,
  458. X    "@vskip",        "\n",    "",        "",        DISCARD,
  459. X    "@w{",        "}",    "\n\\! ",    "\n",        INPARA,
  460. X    "@xref{",        "}",    "See section ",    "",        PARAGRAPH,
  461. X    "@{",        "",    "{",        "",        ESCAPED,
  462. X    "@}",        "",    "}",        "",        ESCAPED
  463. X};
  464. X
  465. END_OF_tableme.h
  466. echo unbundling file: tablemm.h 1>&2
  467. sed -e 's/^X//' >tablemm.h <<'END_OF_tablemm.h'
  468. X/*
  469. X * tablemm.h - -mm macros table and other explicit troff command strings
  470. X *         Release 1.0a    August 1988
  471. X *
  472. X * Copyright 1988  Beverly A.Erlebacher
  473. X * erlebach@csri.toronto.edu    ...uunet!utai!utcsri!erlebach
  474. X *
  475. X */
  476. X
  477. X/* 
  478. X * string to emit before the first input. this is the place to put troff
  479. X * commands controlling default point size, margin size, line length, etc.
  480. X */
  481. Xchar mminit[] =  ".PH '''\n.SA 1\n";
  482. X
  483. X/*
  484. X * miscellaneous commands, described in texi2roff.h
  485. X */
  486. Xstruct misccmds mmcmds = { "\n.P 1\n", "\n.P 0\n", "", "", "\""};
  487. X
  488. X/*
  489. X * patches for table entries for -I option
  490. X */
  491. Xstruct tablerecd mmnodeentry = {
  492. X    "@node",    "\n", "\n.P 0\n\\s8Node:", "\\s0\n.br\n", PARAGRAPH};
  493. X
  494. Xstruct tablerecd mmmenuentry = {
  495. X    "@menu",    "@end", "\n.DS L\n\\s8Menu: \n", "\\s0\n.DE\n", DISPLAY}; 
  496. X
  497. Xstruct tablerecd mmifinfoentry = {
  498. X    "@ifinfo",    "@end", "\n", "\n", PARAGRAPH}; 
  499. X
  500. Xstruct tablerecd mmtable[] = {
  501. X    "@*",        "",    "\n.br\n",    "",        ESCAPED,
  502. X    "@.",        "",    "\\&.",        "",        ESCAPED,
  503. X    "@:",        "",    "",        "",        ESCAPED,
  504. X    "@@",        "",    "@",        "",        ESCAPED,
  505. X    "@TeX{",        "}",    "TeX",        "",        INPARA,
  506. X    "@appendix",    "\n",    "\n.bp\n.H ",    "\n.br\n",    HEADING,
  507. X    "@appendixsec",    "\n",    "\n.H ",    "\n.br\n",    HEADING,
  508. X    "@appendixsubsec",    "\n",    "\n.H ",    "\n.br\n",    HEADING,
  509. X    "@appendixsubsubsec","\n",    "\n.H ",    "\n.br\n",    HEADING,
  510. X    "@asis",        "\n",    "",        "",        PARAGRAPH,
  511. X    "@asis{",        "}",    "",        "",        INPARA,
  512. X    "@br",        "\n",    "\n.br\n.sp\n", "",        PARAGRAPH,
  513. X    "@bullet",        "\n",    "\\(bu",    "",        CHAR,
  514. X    "@bullet{",        "}",    "\\(bu",    "",        CHAR,
  515. X    "@bye",        "\n",    "",        "",        DISCARD,
  516. X    "@b{",        "}",    "\\fB",        "\\fR",        INPARA,
  517. X    "@c",        "\n",    "",        "",        DISCARD,
  518. X    "@center",        "\n",    "\n.ce\n",    "",        HEADING,
  519. X    "@chapter",        "\n",    "\n.bp\n.H 1 ", "\n.br\n",    HEADING,
  520. X    "@cindex",        "\n",    "",        "",        DISCARD,
  521. X    "@cite{",        "}",    "\\fI",        "\\fR",        INPARA,
  522. X    "@code{",        "}",    "\\fB",        "\\fR",        INPARA,
  523. X    "@comment",        "\n",    "",        "",        DISCARD,
  524. X    "@contents",    "\n",    "",        "",        DISCARD,
  525. X    "@copyright{",    "}",    "\\(co",    "",        CHAR,
  526. X    "@ctrl{",        "}",    "\\f(CW^",    "\\fR",        INPARA,
  527. X    "@dag",        "}{",    "\\(dg",    "",        CHAR,
  528. X    "@dag{",        "}",    "\\(dg",    "",        CHAR,
  529. X    "@ddag",        "}{",    "\\(dd",    "",        CHAR,
  530. X    "@ddag{",        "}",    "\\(dd",    "",        CHAR,
  531. X    "@deffn",        "@end", "\n\\&\n.br\n",    "",        HEADING,
  532. X    "@deffnx",        "\n",   "\n.br\n",    "\n.br\n",    HEADING,
  533. X    "@defspec",        "@end", "\n\\&\n.br\n",    "",        HEADING,
  534. X    "@defspecx",    "\n",   "\n.br\n",    "\n.br\n",    HEADING,
  535. X    "@defvar",        "@end", "\n\\&\n.br\n",    "",        HEADING,
  536. X    "@defvarx",        "\n",   "\n.br\n",    "\n.br\n",    HEADING,
  537. X    "@dfn{",        "}",    "\\fI",        "\\fR",        INPARA,
  538. X    "@display",        "@end", "\n.DS\n",    "\n.DE\n",    DISPLAY,
  539. X    "@dots{",        "}",    "\\&...",    "",        INPARA,
  540. X    "@eject",        "\n",    "\n.bp\n",    "",        PARAGRAPH,
  541. X    "@emph{",        "}",    "\\fI",        "\\fR",        INPARA,
  542. X    "@end",        "\n",    "",        "\n.sp\n.in\n", END,
  543. X    "@enumerate",    "@end", "\n.VL 5 0\n",    "\n.LE\n",    ITEMIZING,
  544. X    "@example",        "@end", "\n.DS 1\n.ft CW\n",
  545. X                    "\n.DE\n.ft R\n",    DISPLAY,
  546. X    "@file{",        "}",    "\\f(CW\\`",    "\\'\\fR",    INPARA,
  547. X    "@finalout",    "\n",    "",        "",        DISCARD,
  548. X    "@findex",        "\n",    "",        "",        DISCARD,
  549. X    "@footnote{",    "}",    "\n.FS \n",    "\n.FE\n",    FOOTNOTE,
  550. X    "@group",        "@end", "\n.DS L F\n",    "\n.DE\n",    PARAGRAPH,
  551. X    "@heading",        "\n",    "\n.sp 2\n.HU ","\n.br\n",    HEADING,
  552. X    "@headings",    "\n",    "",        "",        DISCARD,
  553. X    "@iappendix",    "\n",    "\n.bp\n.HU ",    "\n.br\n",    HEADING,
  554. X    "@iappendixsec",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  555. X    "@iappendixsubsec",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  556. X    "@ichapter",    "\n",    "\n.bp\n.HU ",    "\n.br\n",    HEADING,
  557. X    "@ifinfo",        "@end", "",        "",        DISCARD,
  558. X    "@iftex",        "@end", "",        "",        PARAGRAPH,
  559. X    "@ignore",        "@end", "",        "",        DISCARD,
  560. X    "@include",        "\n",    "",        "",        DISCARD,
  561. X    "@inforef{",    "}",    "See Info file ","",        PARAGRAPH,
  562. X    "@isection",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  563. X    "@isubsection",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  564. X    "@isubsubsection",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  565. X    "@item",        "\n",    "\n.LI ",    "\\ \n",    ITEM,
  566. X    "@itemize",        "@end", "\n.VL 5 0\n",    "\n.LE\n",    ITEMIZING,
  567. X    "@itemx",        "\n",    "\n.LI ",    "\\ \n",    ITEM,
  568. X    "@iunnumbered",    "\n",    "\n.bp\n.HU ",    "\n.br\n",    HEADING,
  569. X    "@iunnumberedsec",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  570. X    "@iunnumberedsubsec","\n",    "\n.HU ",    "\n.br\n",    HEADING,
  571. X    "@i{",        "}",    "\\fI",        "\\fR",        INPARA,
  572. X    "@kbd{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  573. X    "@key{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  574. X    "@kindex",        "\n",    "",        "",        DISCARD,
  575. X    "@majorheading",    "\n",    "\n.sp 4\n.HU ","\n.br\n",    HEADING,
  576. X    "@menu",        "@end", "",        "",        DISCARD, 
  577. X    "@minus{",        "}",    "\\-",        "",        CHAR,
  578. X    "@need",        "\n",    "",        "",        DISCARD,
  579. X    "@node",        "\n",    "",        "",        DISCARD,
  580. X    "@noindent",    "\n",    "\n.P 0\n",    "",        PARAGRAPH,
  581. X    "@page",        "\n",    "\n.bp\n",    "",        PARAGRAPH,
  582. X    "@pindex",        "\n",    "",        "",        DISCARD,
  583. X    "@printindex",    "\n",    "",        "",        DISCARD,
  584. X    "@pxref{",        "}",    "see section ",    "",        PARAGRAPH,
  585. X    "@quotation",    "@end", "\n.DS I F 5\n.nh\n", "\n.DE\n",DISPLAY,
  586. X    "@r{",        "}",    "\\fR",        "\\fR",        INPARA,
  587. X    "@refill",        "\n",    "",        "",        DISCARD,
  588. X    "@samp{",        "}",    "\\f(CW\\`",    "\\'\\fR",    INPARA,
  589. X    "@section",        "\n",    "\n.H 2 ",    "\n.br\n",    HEADING,
  590. X    "@setchapternewpage","\n",    "",        "",        DISCARD,
  591. X    "@setfilename",    "\n",    "",        "",        DISCARD,
  592. X    "@settitle",    "\n",    "\n.ds St ",
  593. X             "\n.OH '\\\\*(St''%'\n.EH '%''\\\\*(St'\n",HEADING,
  594. X    "@sp",        "\n",    "\n.sp",    "\n",        PARAGRAPH,
  595. X    "@smallbook",    "\n",    "",        "",        DISCARD,
  596. X    "@smallexample",    "@end", "\n.DS 1\n.ft CW\n",
  597. X                    "\n.DE\n.ft R\n",    DISPLAY,
  598. X    "@strong{",        "}",    "\\fB",        "\\fR",        INPARA,
  599. X    "@subheading",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  600. X    "@subsection",    "\n",    "\n.H 3 ",    "\n.br\n",    HEADING,
  601. X    "@subsubheading",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  602. X    "@subsubsection",    "\n",    "\n.H 4 ",    "\n.br\n",    HEADING,
  603. X    "@summarycontents", "\n",    "",        "",        DISCARD,
  604. X    "@synindex",    "\n",    "",        "",        DISCARD,
  605. X    "@t",        "\n",    "\t",        "",        CHAR,
  606. X    "@table",        "@end", "\n.VL 5 0\n",    "\n.LE\n",    ITEMIZING,
  607. X    "@tex",        "@end", "",        "",        DISCARD, 
  608. X    "@tindex",        "\n",    "",        "",        DISCARD,
  609. X    "@titlefont{",    "}",    "\n.ps +10\n.ce\n",
  610. X                         "\n.ps -10\n",    PARAGRAPH,
  611. X    "@titlepage",    "@end", "",        "\n.bp\n",    PARAGRAPH,
  612. X    "@t{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  613. X    "@unnumbered",    "\n",    "\n.bp\n.HU ",    "\n.br\n",    HEADING,
  614. X    "@unnumberedsec",    "\n",    "\n.HU ",    "\n.br\n",    HEADING,
  615. X    "@unnumberedsubsec","\n",    "\n.HU ",    "\n.br\n",    HEADING,
  616. X    "@unnumberedsubsubsec","\n","\n.HU ",    "\n.br\n",    HEADING,
  617. X    "@var{",        "}",    "\\fI",        "\\fR",        INPARA,
  618. X    "@vfil",        "\n",    "",        "",        DISCARD,
  619. X    "@vindex",        "\n",    "",        "",        DISCARD,
  620. X    "@vskip",        "\n",    "",        "",        DISCARD,
  621. X    "@w{",        "}",    "\n\\! ",    "\n",        INPARA,
  622. X    "@xref{",        "}",    "See section ",    "",        PARAGRAPH,
  623. X    "@{",        "",    "{",        "",        ESCAPED,
  624. X    "@}",        "",    "}",        "",        ESCAPED
  625. X};
  626. END_OF_tablemm.h
  627. echo unbundling file: tablems.h 1>&2
  628. sed -e 's/^X//' >tablems.h <<'END_OF_tablems.h'
  629. X/*
  630. X * tablems.h - -ms macros table and other explicit troff command strings
  631. X *         Release 1.0a    August 1988
  632. X *
  633. X * Copyright 1988  Beverly A.Erlebacher
  634. X * erlebach@csri.toronto.edu    ...uunet!utai!utcsri!erlebach
  635. X *
  636. X */
  637. X
  638. X/* 
  639. X * string to emit before the first input. this is the place to put troff
  640. X * commands controlling default point size, margin size, line length, etc.
  641. X */
  642. Xchar msinit[] = ".ND\n"; /* .ND suppresses date in footing */
  643. X
  644. X/*
  645. X * miscellaneous commands, described in texi2roff.h
  646. X */
  647. Xstruct misccmds mscmds = { "\n.PP\n", "\n.IP\n", "\n.RS\n", "\n.RE\n", "\""};
  648. X
  649. X/*
  650. X * patches for table entries for -I option
  651. X */
  652. Xstruct tablerecd msnodeentry = {
  653. X    "@node",    "\n", "\n.LP\n\\s8Node:", "\\s0\n.br\n", PARAGRAPH};
  654. X
  655. Xstruct tablerecd msmenuentry = {
  656. X    "@menu",    "@end", "\n.DS L\n\\s8Menu: \n", "\\s0\n.DE\n", DISPLAY}; 
  657. X
  658. Xstruct tablerecd msifinfoentry = {
  659. X    "@ifinfo",    "@end", "\n", "\n", PARAGRAPH}; 
  660. X
  661. Xstruct tablerecd mstable[] = {
  662. X    "@*",        "",    "\n.br\n",    "",        ESCAPED,
  663. X    "@.",        "",    "\\&.",        "",        ESCAPED,
  664. X    "@:",        "",    "",        "",        ESCAPED,
  665. X    "@@",        "",    "@",        "",        ESCAPED,
  666. X    "@TeX{",        "}",    "TeX",        "",        INPARA,
  667. X    "@appendix",    "\n",    "\n.bp\n.SH\n", "\n.br\n",    HEADING,
  668. X    "@appendixsec",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  669. X    "@appendixsubsec",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  670. X    "@appendixsubsubsec","\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  671. X    "@asis",        "\n",    "",        "",        PARAGRAPH,
  672. X    "@asis{",        "}",    "",        "",        INPARA,
  673. X    "@br",        "\n",    "\n.br\n.sp\n", "",        PARAGRAPH,
  674. X    "@bullet",        "\n",    "\\(bu",    "",        CHAR,
  675. X    "@bullet{",        "}",    "\\(bu",    "",        CHAR,
  676. X    "@bye",        "\n",    "",        "",        DISCARD,
  677. X    "@b{",        "}",    "\\fB",        "\\fR",        INPARA,
  678. X    "@c",        "\n",    "",        "",        DISCARD,
  679. X    "@center",        "\n",    "\n.ce\n",    "",        HEADING,
  680. X    "@chapter",        "\n",    "\n.bp\n.NH\n", "\n.br\n",    HEADING,
  681. X    "@cindex",        "\n",    "",        "",        DISCARD,
  682. X    "@cite{",        "}",    "\\fI",        "\\fR",        INPARA,
  683. X    "@code{",        "}",    "\\fB",        "\\fR",        INPARA,
  684. X    "@comment",        "\n",    "",        "",        DISCARD,
  685. X    "@contents",    "\n",    "",        "",        DISCARD,
  686. X    "@copyright{",    "}",    "\\(co",    "",        CHAR,
  687. X    "@ctrl{",        "}",    "\\f(CW^",    "\\fR",        INPARA,
  688. X    "@dag",        "}{",    "\\(dg",    "",        CHAR,
  689. X    "@dag{",        "}",    "\\(dg",    "",        CHAR,
  690. X    "@ddag",        "}{",    "\\(dd",    "",        CHAR,
  691. X    "@ddag{",        "}",    "\\(dd",    "",        CHAR,
  692. X    "@deffn",        "@end", "\n.LP\n",    "",        HEADING,
  693. X    "@deffnx",        "\n",     "\n.br\n",    "\n.br\n",    HEADING,
  694. X    "@defspec",        "@end", "\n.LP\n",    "",        HEADING,
  695. X    "@defspecx",    "\n",     "\n.br\n",    "\n.br\n",    HEADING,
  696. X    "@defvar",        "@end", "\n.LP\n",    "",        HEADING,
  697. X    "@defvarx",        "\n",     "\n.br\n",    "\n.br\n",    HEADING,
  698. X    "@dfn{",        "}",    "\\fI",        "\\fR",        INPARA,
  699. X    "@display",        "@end", "\n.DS\n",    "\n.DE\n",    DISPLAY,
  700. X    "@dots{",        "}",    "\\&...",    "",        INPARA,
  701. X    "@eject",        "\n",    "\n.bp\n",    "",        PARAGRAPH,
  702. X    "@emph{",        "}",    "\\fI",        "\\fR",        INPARA,
  703. X    "@end",        "\n",    "",        "\n.sp\n.in\n", END,
  704. X    "@enumerate",    "@end", "\n",        "\n",        ITEMIZING,
  705. X    "@example",        "@end", "\n.DS\n.ft CW\n",
  706. X                    "\n.DE\n.ft R\n",    DISPLAY,
  707. X    "@file{",        "}",    "\\f(CW\\`",    "\\'\\fR",    INPARA,
  708. X    "@finalout",    "\n",    "",        "",        DISCARD,
  709. X    "@findex",        "\n",    "",        "",        DISCARD,
  710. X    "@footnote{",    "}",    "\n.FS \n",    "\n.FE\n",    FOOTNOTE,
  711. X    "@group",        "@end", "\n.KS\n",    "\n.KE\n",    PARAGRAPH,
  712. X    "@heading",        "\n",    "\n.sp 2\n.SH\n","\n.br\n",    HEADING,
  713. X    "@headings",    "\n",    "",        "",        DISCARD,
  714. X    "@iappendix",    "\n",    "\n.bp\n.SH\n", "\n.br\n",    HEADING,
  715. X    "@iappendixsec",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  716. X    "@iappendixsubsec",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  717. X    "@ichapter",    "\n",    "\n.bp\n.SH\n", "\n.br\n",    HEADING,
  718. X    "@ifinfo",        "@end", "",        "",        DISCARD,
  719. X    "@iftex",        "@end", "",        "",        PARAGRAPH,
  720. X    "@ignore",        "@end", "",        "",        DISCARD,
  721. X    "@include",        "\n",    "",        "",        DISCARD,
  722. X    "@inforef{",    "}",    "See Info file ","",        PARAGRAPH,
  723. X    "@isection",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  724. X    "@isubsection",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  725. X    "@isubsubsection",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  726. X    "@item",        "\n",    "\n.IP ",    "\\ \n",    ITEM,
  727. X    "@itemize",        "@end", "\n",        "\n",        ITEMIZING,
  728. X    "@itemx",        "\n",    "\n.IP ",    "\\ \n",    ITEM,
  729. X    "@iunnumbered",    "\n",    "\n.bp\n.SH\n", "\n.br\n",    HEADING,
  730. X    "@iunnumberedsec",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  731. X    "@iunnumberedsubsec","\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  732. X    "@i{",        "}",    "\\fI",        "\\fR",        INPARA,
  733. X    "@kbd{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  734. X    "@key{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  735. X    "@kindex",        "\n",    "",        "",        DISCARD,
  736. X    "@majorheading",    "\n",    "\n.sp 4\n.SH\n","\n.br\n",    HEADING,
  737. X    "@menu",        "@end", "",        "",        DISCARD, 
  738. X    "@minus{",        "}",    "\\-",        "",        CHAR,
  739. X    "@need",        "\n",    "",        "",        DISCARD,
  740. X    "@node",        "\n",    "",        "",        DISCARD,
  741. X    "@noindent",    "\n",    "\n.LP\n",    "",        PARAGRAPH,
  742. X    "@page",        "\n",    "\n.bp\n",    "",        PARAGRAPH,
  743. X    "@pindex",        "\n",    "",        "",        DISCARD,
  744. X    "@printindex",    "\n",    "",        "",        DISCARD,
  745. X    "@pxref{",        "}",    "see section ",    "",        PARAGRAPH,
  746. X    "@quotation",    "@end", "\n.QP\n.nh\n", "\n.PP\n",    DISPLAY,
  747. X    "@r{",        "}",    "\\fR",        "\\fR",        INPARA,
  748. X    "@refill",        "\n",    "",        "",        DISCARD,
  749. X    "@samp{",        "}",    "\\f(CW\\`",    "\\'\\fR",    INPARA,
  750. X    "@section",        "\n",    "\n.NH 2\n",    "\n.br\n",    HEADING,
  751. X    "@setchapternewpage","\n",    "",        "",        DISCARD,
  752. X    "@setfilename",    "\n",    "",        "",        DISCARD,
  753. X    "@settitle",    "\n",    "\n.ds St ",
  754. X             "\n.OH '\\\\*(St''%'\n.EH '%''\\\\*(St'\n",HEADING,
  755. X    "@smallbook",    "\n",    "",        "",        DISCARD,
  756. X    "@smallexample",    "@end", "\n.DS\n.ft CW\n",
  757. X                    "\n.DE\n.ft R\n",    DISPLAY,
  758. X    "@sp",        "\n",    "\n.sp",    "\n",        PARAGRAPH,
  759. X    "@strong{",        "}",    "\\fB",        "\\fR",        INPARA,
  760. X    "@subheading",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  761. X    "@subsection",    "\n",    "\n.NH 3\n",    "\n.br\n",    HEADING,
  762. X    "@subsubheading",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  763. X    "@subsubsection",    "\n",    "\n.NH 4\n",    "\n.br\n",    HEADING,
  764. X    "@summarycontents", "\n",    "",        "",        DISCARD,
  765. X    "@synindex",    "\n",    "",        "",        DISCARD,
  766. X    "@t",        "\n",    "\t",        "",        CHAR,
  767. X    "@table",        "@end", "\n",        "\n",        ITEMIZING,
  768. X    "@tex",        "@end", "",        "",        DISCARD, 
  769. X    "@tindex",        "\n",    "",        "",        DISCARD,
  770. X    "@titlefont{",    "}",    "\n.ps +10\n.ce\n",
  771. X                         "\n.ps -10\n",    PARAGRAPH,
  772. X    "@titlepage",    "@end", "",        "\n.bp\n",    PARAGRAPH,
  773. X    "@t{",        "}",    "\\f(CW",    "\\fR",        INPARA,
  774. X    "@unnumbered",    "\n",    "\n.bp\n.SH\n", "\n.br\n",    HEADING,
  775. X    "@unnumberedsec",    "\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  776. X    "@unnumberedsubsec","\n",    "\n.SH\n",    "\n.br\n",    HEADING,
  777. X    "@unnumberedsubsubsec","\n","\n.SH\n",    "\n.br\n",    HEADING,
  778. X    "@var{",        "}",    "\\fI",        "\\fR",        INPARA,
  779. X    "@vfil",        "\n",    "",        "",        DISCARD,
  780. X    "@vindex",        "\n",    "",        "",        DISCARD,
  781. X    "@vskip",        "\n",    "",        "",        DISCARD,
  782. X    "@w{",        "}",    "\n\\! ",    "\n",        INPARA,
  783. X    "@xref{",        "}",    "See section ",    "",        PARAGRAPH,
  784. X    "@{",        "",    "{",        "",        ESCAPED,
  785. X    "@}",        "",    "}",        "",        ESCAPED
  786. X};
  787. END_OF_tablems.h
  788. echo unbundling file: texi2roff.h 1>&2
  789. sed -e 's/^X//' >texi2roff.h <<'END_OF_texi2roff.h'
  790. X/*
  791. X * texi2roff.h - header for Texinfo to nroff/troff translator texi2roff
  792. X *         Release 1.0a    August 1988
  793. X *
  794. X * Copyright 1988  Beverly A.Erlebacher
  795. X * erlebach@csri.toronto.edu    ...uunet!utai!utcsri!erlebach
  796. X *
  797. X */
  798. X
  799. X/* miscellaneous troff command strings in macro header files. */
  800. Xstruct misccmds {
  801. X    char * dfltpara;    /* emit when 2 consecutive newlines are detected */
  802. X            /* in the input and the indentation level is <= 1. */
  803. X    char * dfltipara;    /* same but for indentation level > 1.  */
  804. X    char * indentstart; /* emit to increase indent level for itemized list */
  805. X    char * indentend;    /* emit to decrease indent level for itemized list */
  806. X    char * dblquote    /* emit to get double quote in macro argument.     
  807. X             * although a literal " seems to work for -mm and 
  808. X             * -ms, -me chokes on it. if you have trouble with
  809. X             * -ms or -mm and ", use the -me string. if you
  810. X             * have SoftQuad's nroff/troff, you can use "\(dq"
  811. X             */
  812. X};
  813. X
  814. Xextern struct misccmds * cmds;
  815. X
  816. Xstruct tablerecd {
  817. X    char *  texstart;    /* starting token for a Texinfo command */
  818. X    char *  texend;    /* ending token for a Texinfo command */
  819. X    char *  trfstart;    /* troff commands to emit when texstart is found */
  820. X    char *  trfend;    /* troff commands to emit when texend is found */
  821. X    int        type;    /* kind of Texinfo command, as #defined below */
  822. X};
  823. X
  824. Xextern struct tablerecd * table;
  825. Xextern int tablesize;
  826. X
  827. X/* Texinfo command types */
  828. X
  829. X#define ESCAPED        0    /* special character (special to Texinfo) */
  830. X#define INPARA        1    /* in-paragraph command */
  831. X#define HEADING        2    /* chapter structuring command */
  832. X#define DISCARD        3    /* not supported - discard following text */
  833. X#define PARAGRAPH   4    /* applies to following paragraph */
  834. X#define ITEMIZING   5    /* starts itemized list */
  835. X#define ITEM        6    /* item in list */
  836. X#define END        7    /* end construct */
  837. X#define CHAR        8    /* really special char: dagger, bullet - scary, eh? */
  838. X#define    FOOTNOTE    9    /* footnote */
  839. X#define DISPLAY    10    /* text block of the kind called a 'display' */
  840. X/* nroff/troff macro packages supported */
  841. X#define NONE    0    /* dummy value for error detection */
  842. X#define MS    1
  843. X#define ME    2
  844. X#define MM    3
  845. X
  846. X/* useful confusion-reducing things */
  847. X#define STREQ(s,t) (*(s)==*(t) && strcmp(s, t)==0)
  848. X#define NO    0
  849. X#define YES    1
  850. END_OF_texi2roff.h
  851. echo unbundling file: table.c 1>&2
  852. sed -e 's/^X//' >table.c <<'END_OF_table.c'
  853. X/*
  854. X * table.c - set up translation tables for texi2roff
  855. X *         Release 1.0a    August 1988
  856. X *
  857. X * Copyright 1988  Beverly A.Erlebacher
  858. X * erlebach@csri.toronto.edu    ...uunet!utai!utcsri!erlebach
  859. X *
  860. X * When adding more commands: 
  861. X *
  862. X * - be sure that gettoken() can recognize not just the ending token
  863. X *   (texend) but also the end of the starting token (texstart) for
  864. X *   the command, if it doesnt already occur in a table.
  865. X *
  866. X * - keep the tables sorted
  867. X *
  868. X * - keep all troff output strings in the table macro header files
  869. X *
  870. X * - strive diligently to keep the program table-driven
  871. X */
  872. X
  873. X#include <stdio.h>    /* just to get NULL */
  874. X#include "texi2roff.h"
  875. X#include "tablems.h"
  876. X#include "tableme.h"
  877. X#include "tablemm.h"
  878. X
  879. Xstruct misccmds * cmds;
  880. Xstruct tablerecd * table;
  881. Xint tablesize;
  882. X
  883. Xvoid
  884. Xinitialize(macropkg, showInfo)
  885. Xint macropkg;
  886. Xint showInfo;
  887. X{
  888. X    extern void patchtable();
  889. X
  890. X    switch (macropkg) {
  891. X    case MS:
  892. X    table = mstable;
  893. X    tablesize = sizeof mstable;
  894. X    cmds = &mscmds;
  895. X    if (showInfo == YES)
  896. X        (void) patchtable( &msnodeentry, &msmenuentry, &msifinfoentry);
  897. X    puts(msinit);
  898. X    break;
  899. X    case MM:
  900. X    table = mmtable;
  901. X    tablesize = sizeof mmtable;
  902. X    cmds = &mmcmds;
  903. X    if (showInfo == YES)
  904. X      (void) patchtable( &mmnodeentry, &mmmenuentry, &mmifinfoentry);
  905. X    puts(mminit);
  906. X    break;
  907. X    case ME:
  908. X    table = metable;
  909. X    tablesize = sizeof metable;
  910. X    cmds = &mecmds;
  911. X    if (showInfo == YES)
  912. X       (void) patchtable( &menodeentry, &memenuentry, &meifinfoentry);
  913. X    puts( meinit);
  914. X    break;
  915. X    }
  916. X}
  917. X
  918. X/*
  919. X * real Texinfo has a sort of hypertext feature called Info files,
  920. X * using menus, nodes and 'ifinfo' sections. Although i can't simulate
  921. X * this here, and the material would not normally be printed by Texinfo,
  922. X * it could be useful to the user searching through a machine-readable
  923. X * manual. Specifying the -I option patches the table with alternative
  924. X * troff commands to display rather than discard this material.
  925. X */
  926. X
  927. Xvoid
  928. Xpatchtable(nodeentry, menuentry, ifinfoentry)
  929. Xstruct tablerecd * nodeentry;
  930. Xstruct tablerecd * menuentry;
  931. Xstruct tablerecd * ifinfoentry;
  932. X{
  933. X    struct tablerecd * tp;
  934. X    extern struct tablerecd * lookup();
  935. X
  936. X    /* not everybody has structure assignment */
  937. X    if ((tp = lookup("@menu")) != NULL) {
  938. X    tp->trfstart = menuentry->trfstart;
  939. X    tp->trfend = menuentry->trfend;
  940. X    tp->type = menuentry->type;
  941. X    }
  942. X    if ((tp = lookup("@node")) != NULL) {
  943. X    tp->trfstart = nodeentry->trfstart;
  944. X    tp->trfend = nodeentry->trfend;
  945. X    tp->type = nodeentry->type;
  946. X    }
  947. X    if ((tp = lookup("@ifinfo")) != NULL) {
  948. X    tp->trfstart = ifinfoentry->trfstart;
  949. X    tp->trfend = ifinfoentry->trfend;
  950. X    tp->type = ifinfoentry->type;
  951. X    }
  952. X}
  953. END_OF_table.c
  954. echo unbundling file: texi2roff.c 1>&2
  955. sed -e 's/^X//' >texi2roff.c <<'END_OF_texi2roff.c'
  956. X/*
  957. X * texi2roff.c - mainline for Texinfo to nroff/troff translator texi2roff
  958. X *         Release 1.0a     August 1988
  959. X *
  960. X * Copyright 1988 Beverly A.Erlebacher
  961. X * erlebach@csri.toronto.edu    ...uunet!utai!utcsri!erlebach
  962. X *
  963. X */
  964. X
  965. X#include <stdio.h>
  966. X#ifndef __TURBOC__
  967. X#include <sys/types.h>
  968. X#endif
  969. X#include <sys/stat.h>
  970. X#include "texi2roff.h"
  971. X
  972. Xchar *progname;
  973. Xint transparent = NO;    /* for -t flag */
  974. X
  975. X/*
  976. X * main - parse arguments, handle options
  977. X *    - initialize tables and other strings
  978. X *     - open files and pass them to process().
  979. X */
  980. Xmain(argc, argv)
  981. Xint argc;
  982. Xchar *argv[];
  983. X{
  984. X    int c, errflg = 0;
  985. X    FILE *in;
  986. X    char *inname;
  987. X    int macropkg = NONE;    /* user's choice of MS, ME or MM */
  988. X    int showInfo = NO;     /* for -I flag: whether to display Info file material*/
  989. X
  990. X    extern int optind;
  991. X    extern char *optarg;
  992. X    extern int process();
  993. X    extern void initialize();
  994. X
  995. X    progname = argv[0];
  996. X
  997. X    while ((c = getopt(argc, argv, "tIm:--")) != EOF)
  998. X    switch (c) {
  999. X      case 't':
  1000. X          transparent = YES;
  1001. X          break;
  1002. X    case 'I':
  1003. X        showInfo = YES;
  1004. X        break;
  1005. X    case 'm':
  1006. X        if (macropkg != NONE) {
  1007. X        errflg++;
  1008. X        } else {
  1009. X        switch ( (char) *optarg) {
  1010. X        case 's':
  1011. X            macropkg = MS;
  1012. X            break;
  1013. X        case 'm':
  1014. X            macropkg = MM;
  1015. X            break;
  1016. X        case 'e':
  1017. X            macropkg = ME;
  1018. X            break;
  1019. X        default:
  1020. X            errflg++;
  1021. X            break;
  1022. X        }
  1023. X        }
  1024. X        break;
  1025. X    case '?':
  1026. X        errflg++;
  1027. X        break;
  1028. X    }
  1029. X
  1030. X    if (macropkg == NONE) {
  1031. X    errflg++;
  1032. X    }
  1033. X    if (errflg) {
  1034. X    (void) fprintf(stderr, "Usage: %s [-It] -m{e|m|s} [file ... ]\n",
  1035. X                                progname);
  1036. X    exit(1);
  1037. X    }
  1038. X
  1039. X    (void) initialize(macropkg, showInfo);
  1040. X
  1041. X    if (optind >= argc) {
  1042. X    errflg += process(stdin, "stdin");
  1043. X    }
  1044. X    else
  1045. X    for (; optind < argc; optind++) {
  1046. X        if (STREQ(argv[optind], "-")) {
  1047. X        inname = "stdin";
  1048. X        in = stdin;
  1049. X        }
  1050. X        else {
  1051. X        if (( in = fopen(argv[optind], "r")) == NULL) {
  1052. X            fprintf(stderr,"%s : can't open file %s\n",
  1053. X                progname, argv[optind]);
  1054. X            continue;
  1055. X        }
  1056. X        inname = argv[optind];
  1057. X        }
  1058. X        errflg += process(in, inname);
  1059. X        if (in != stdin)
  1060. X        (void) fclose(in);
  1061. X    }
  1062. X    exit(errflg);
  1063. X}
  1064. X
  1065. X/*
  1066. X * process -  check opened files and pass them to translate().
  1067. X *       -  report on disastrous translation failures
  1068. X */
  1069. Xint
  1070. Xprocess(fp, filename)
  1071. X    FILE *fp;
  1072. X    char *filename;
  1073. X{
  1074. X    struct stat statbuf;
  1075. X    extern int translate(/* FILE *, char * */);
  1076. X
  1077. X    if (fstat(fileno(fp), &statbuf) != 0){
  1078. X    fprintf(stderr,"%s : can't fstat file %s\n", progname, filename);
  1079. X    return 1;
  1080. X    }
  1081. X    if ((statbuf.st_mode & S_IFMT)==S_IFDIR) {
  1082. X    (void) fprintf(stderr, "%s : %s is a directory\n", progname, filename);
  1083. X    return 1;
  1084. X    }
  1085. X    /* translate returns 0 (ok) or -1 (disaster). to recover from a 
  1086. X     * disaster and continue with next file would require fixing up the
  1087. X     * state in translate.c, and the document would likely be useless anyway,
  1088. X     * since it would have to be incredibly corrupted to blow stacks.
  1089. X     */
  1090. X    if (translate(fp, filename) < 0) {
  1091. X    (void) fprintf(stderr,
  1092. X        "%s: error while processing file %s, translation aborted\n",
  1093. X        progname, filename);
  1094. X    exit(1); 
  1095. X    }
  1096. X    return 0;
  1097. X}
  1098. END_OF_texi2roff.c
  1099. echo unbundling file: translate.c 1>&2
  1100. sed -e 's/^X//' >translate.c <<'END_OF_translate.c'
  1101. X/*
  1102. X * translate.c - main guts of Texinfo to nroff/troff translator texi2roff
  1103. X *          Release 1.0a     August 1988
  1104. X *
  1105. X * Copyright 1988 Beverly A.Erlebacher
  1106. X * erlebach@csri.toronto.edu    ...uunet!utai!utcsri!erlebach
  1107. X *
  1108. X */
  1109. X
  1110. X#include <stdio.h>
  1111. X#ifdef BSD
  1112. X#include <strings.h>
  1113. X#define strchr    index
  1114. X#else
  1115. X#include <string.h>
  1116. X#endif
  1117. X#include "texi2roff.h"
  1118. X
  1119. X#define MAXLINELEN  256
  1120. X#define ERROR        (-1)
  1121. X
  1122. Xextern int    transparent;        /* -t flag: dont discard things       */
  1123. Xint        linecount;
  1124. Xint        displaylevel = 0;    /* nesting level of 'display' text */
  1125. Xint        ilevel = 0;         /* nesting level of itemized lists */
  1126. Xint        inmacroarg = NO;    /* protect roff macro args flag */
  1127. Xchar            *filename;
  1128. Xchar         *p;            /* pointer into input buffer */
  1129. X
  1130. X/* forward references */
  1131. Xextern char * gettoken();
  1132. Xextern char * eatwhitespace();
  1133. Xextern struct tablerecd * lookup();
  1134. Xextern char * itemize();
  1135. Xextern char * doitem();
  1136. Xextern char * interpret();
  1137. X
  1138. X/*
  1139. X * errormsg - print error messages to stderr
  1140. X */
  1141. X
  1142. Xvoid
  1143. Xerrormsg( message, other)
  1144. X    char       *message;
  1145. X    char       *other;
  1146. X{
  1147. X    (void) fprintf(stderr, "%s line %d : %s%s\n",
  1148. X    filename, linecount, message, other);
  1149. X}
  1150. X
  1151. X/*
  1152. X * translate - translate one Texinfo file
  1153. X */
  1154. X
  1155. Xint 
  1156. Xtranslate(in, inname)
  1157. X    FILE       *in;
  1158. X    char       *inname;
  1159. X{
  1160. X    char        input[MAXLINELEN];
  1161. X    char        output[MAXLINELEN];
  1162. X    char        token[MAXLINELEN];
  1163. X    char        *c,*d,lastchar;
  1164. X
  1165. X    filename = inname;
  1166. X    linecount = 0;
  1167. X    lastchar = '\n';
  1168. X
  1169. X    while (fgets(input, MAXLINELEN, in) != NULL) {
  1170. X    ++linecount;
  1171. X    p = input;
  1172. X    *output = 0;
  1173. X    if (*p == '.')            /* protect leading '.' in input */
  1174. X        (void) strcpy(output, "\\&");
  1175. X    else if (*p == '\n') {
  1176. X        if (displaylevel > 0)
  1177. X        (void) strcat(output,"\\&\n");      /* protect newline */
  1178. X        else if (ilevel > 0)    /* indented paragraph */
  1179. X        (void) strcat(output, cmds->dfltipara);
  1180. X        else            /* default paragraph */
  1181. X        (void) strcat(output,cmds->dfltpara);
  1182. X    }
  1183. X    while (*p != '\0') {
  1184. X        p = gettoken(p, token);
  1185. X        p = interpret(token, output);
  1186. X        if (p == NULL)
  1187. X        return ERROR;
  1188. X    }
  1189. X
  1190. X    /*
  1191. X     * output, stripping surplus newlines when possible.
  1192. X     * ?roff may vanish lines w/leading '. also, empirically,
  1193. X     * often lines with leading \ . so emit zero-width char \& .
  1194. X     */
  1195. X    d = &lastchar;    /* character at end of previous output buffer */
  1196. X    for( c = output; *c != '\0'; d = c, ++c) {
  1197. X        if (*c != '\n' || *d != '\n') {
  1198. X        if ( *d == '\n' && (*c == '\\' || *c == '\''))
  1199. X            (void) fputs("\\&", stdout);
  1200. X        (void) putc(*c, stdout);
  1201. X        }
  1202. X    }
  1203. X    lastchar = *d;
  1204. X    }
  1205. X    return 0;
  1206. X}
  1207. X
  1208. X/*
  1209. X * PUSH - macro to push pointer to table entry onto command stack
  1210. X */
  1211. X
  1212. X#define MAXDEPTH    20
  1213. X
  1214. X#define PUSH(tptr)                            \
  1215. X    if (++stackptr == MAXDEPTH) {                    \
  1216. X    errormsg("stack overflow - commands nested too deeply", "");    \
  1217. X    return NULL;                            \
  1218. X    }                                    \
  1219. X    stack[stackptr] = tptr;
  1220. X
  1221. X/*
  1222. X * interpret - interprets and concatenates interpreted token onto outstring
  1223. X */
  1224. X
  1225. Xchar *
  1226. Xinterpret(token, outstring)
  1227. Xchar    *token;
  1228. Xchar    *outstring;
  1229. X{
  1230. X    static struct tablerecd *stack[MAXDEPTH];
  1231. X    static int        stackptr = 0; /* zeroth element is not used */
  1232. X    static int      discarding = NO;
  1233. X    static int        discardlevel = MAXDEPTH;
  1234. X    struct tablerecd *tptr;
  1235. X    char        *s, *cp, tempstr[MAXLINELEN];
  1236. X
  1237. X    s = p;
  1238. X    if (stackptr > 0 && STREQ(token, stack[stackptr]->texend)) {
  1239. X    /* have fetched closing token of current Texinfo command */
  1240. X    if (STREQ(token, "@end")) {/* WARNING! only works from translate() */
  1241. X        s = gettoken(eatwhitespace(s),tempstr);
  1242. X        if    (! STREQ(&(stack[stackptr]->texstart[1]), tempstr)) {
  1243. X        errormsg("probably @end for unrecognized Texinfo cmd @",
  1244. X                                tempstr);
  1245. X        return s;
  1246. X        }
  1247. X    }
  1248. X    if (!discarding)
  1249. X        (void) strcat(outstring, stack[stackptr]->trfend);
  1250. X
  1251. X    if (stack[stackptr]->type == DISPLAY)
  1252. X        --displaylevel;
  1253. X    else if (stack[stackptr]->type == ITEMIZING) {
  1254. X        --ilevel;
  1255. X        if (!discarding && ilevel > 0)
  1256. X        (void) strcat(outstring, cmds->indentend);
  1257. X    }
  1258. X
  1259. X    if (--stackptr < 0) {
  1260. X        errormsg("stack underflow", "");
  1261. X        return NULL;
  1262. X    }
  1263. X        if (discarding && stackptr < discardlevel) {
  1264. X        discarding = NO;
  1265. X        discardlevel = MAXDEPTH;
  1266. X        }
  1267. X    if (*token == '\n' || STREQ(token, "@end")) {
  1268. X        inmacroarg = NO;
  1269. X        return "";          /* flush rest of line if any */
  1270. X    }
  1271. X    } else if (*token != '@') {     /* ordinary piece of text */
  1272. X    if (!discarding)
  1273. X        (void) strcat(outstring, token);
  1274. X    if (*token == '\n') {
  1275. X        inmacroarg = NO;
  1276. X        return "";
  1277. X    }
  1278. X    } else {                /* start of Texinfo command */
  1279. X    if ((tptr = lookup(token)) == NULL) 
  1280. X        errormsg("unrecognized Texinfo command ", token);
  1281. X    else {
  1282. X        switch (tptr->type) {
  1283. X        case ESCAPED:
  1284. X        if (!discarding)
  1285. X            (void) strcat(outstring, tptr->trfstart);
  1286. X        break;
  1287. X        case DISPLAY:
  1288. X        ++displaylevel;
  1289. X        PUSH(tptr);
  1290. X        if (!discarding)
  1291. X            (void) strcat(outstring, tptr->trfstart);
  1292. X        break;
  1293. X        case HEADING:
  1294. X        /*
  1295. X         * not presently supporting  appendices (lettered
  1296. X         * rather than numbered     sections) they will come
  1297. X         * out as unnumbered for now
  1298. X         */
  1299. X        inmacroarg = YES;   /* protect ' and space in hdr macro args */
  1300. X        s = eatwhitespace(s);
  1301. X        /* fall through */
  1302. X        case CHAR:    /* may be some need to distinguish these 3 in future */
  1303. X        case INPARA:
  1304. X        case PARAGRAPH:
  1305. X        PUSH(tptr);
  1306. X        if (!discarding)
  1307. X            (void) strcat(outstring, tptr->trfstart);
  1308. X        break;
  1309. X        case DISCARD:
  1310. X        PUSH(tptr);
  1311. X        if (!discarding && !transparent) {
  1312. X            discarding = YES;
  1313. X            discardlevel = stackptr;
  1314. X        }
  1315. X        break;
  1316. X        case ITEMIZING:
  1317. X        if (!discarding) {
  1318. X            (void) strcat(outstring, tptr->trfstart);
  1319. X            if (ilevel > 0)
  1320. X            (void) strcat(outstring, cmds->indentstart);
  1321. X        }
  1322. X        PUSH(tptr);
  1323. X        ++ilevel;
  1324. X        s = itemize(s, token);
  1325. X        break;
  1326. X        case ITEM:
  1327. X        PUSH(tptr);
  1328. X        if (!discarding) {
  1329. X            (void) strcat(outstring, tptr->trfstart);
  1330. X            inmacroarg = YES;
  1331. X            s = doitem(s,tempstr);
  1332. X            inmacroarg = NO;
  1333. X            (void) strcat(outstring,tempstr);
  1334. X        }
  1335. X        break;
  1336. X        case END:
  1337. X        s = gettoken(eatwhitespace(s),tempstr);
  1338. X        errormsg("probably @end for unrecognized Texinfo cmd @",
  1339. X                            tempstr);
  1340. X        break;
  1341. X        case FOOTNOTE:
  1342. X        PUSH(tptr);
  1343. X        if (!discarding) {
  1344. X            s = gettoken(eatwhitespace(s),tempstr);
  1345. X            cp = outstring + strlen(outstring);
  1346. X            (void) interpret(tempstr, outstring);
  1347. X            (void) strcpy(tempstr, cp);
  1348. X            (void) strcat(outstring, tptr->trfstart);
  1349. X            /* replicate footnote mark */
  1350. X            (void) strcat(outstring, tempstr);
  1351. X        }
  1352. X        break;
  1353. X        default:
  1354. X        /* can't happen */
  1355. X        errormsg("ack ptui, what was that thing? ", token);
  1356. X        }
  1357. X    }
  1358. X    }
  1359. X    return s;
  1360. X}    
  1361. X
  1362. X/*
  1363. X * eatwhitespace - move input pointer to first char that isnt a blank or tab
  1364. X *    (note that newlines are *not* whitespace)
  1365. X */
  1366. X
  1367. Xchar           *
  1368. Xeatwhitespace(s)
  1369. X    register char       *s;
  1370. X{
  1371. X    while(*s == ' ' || *s == '\t')
  1372. X    ++s ;
  1373. X    return s;
  1374. X}
  1375. X
  1376. X
  1377. X/* 
  1378. X * strpbrk_like - returns pointer to the leftmost occurrence in str of any
  1379. X *    character in set. this function provided by rayan zachariassen.
  1380. X *     this isnt a full strpbrk(), it's just as much of one as is necessary
  1381. X *    here.  not everyone has a strpbrk() in their C library.
  1382. X*/
  1383. X
  1384. Xchar *
  1385. Xstrpbrk_like(str, set)
  1386. X    register char *str;
  1387. X    char *set;
  1388. X{
  1389. X    static int inited_set = 0;
  1390. X    static char set_vec[256] = { 0 };
  1391. X
  1392. X    if (!inited_set) {    /* we *know* it'll be the same every time... */
  1393. X    while (*set)
  1394. X         set_vec[(unsigned char)*set++] = 1;
  1395. X    inited_set = 1;
  1396. X    }
  1397. X    while (set_vec[*str] == 0)
  1398. X    if (!*str++)
  1399. X        return 0;
  1400. X    return str;
  1401. X}
  1402. X
  1403. X
  1404. X/*
  1405. X * gettoken - fetch next token from input buffer. leave the input pointer
  1406. X *    pointing to char after token.     may need to be modified when 
  1407. X *    new Texinfo commands are added which use different token boundaries.
  1408. X */
  1409. Xchar           *
  1410. Xgettoken(s, token)
  1411. X    char       *s;
  1412. X    char       *token;
  1413. X{
  1414. X    static char       endchars[] = " \n\t@{}:.*";
  1415. X    char       *q, *t;
  1416. X
  1417. X    q = s;
  1418. X    s = strpbrk_like(q, endchars);
  1419. X    if (s != q) {
  1420. X    switch (*s) {
  1421. X    case ' ':
  1422. X    case '\n':
  1423. X    case '\t':
  1424. X    case '@':
  1425. X    case '}':
  1426. X    case ':':
  1427. X    case '.':
  1428. X    case '*':
  1429. X        --s;
  1430. X        break;
  1431. X    case '{':
  1432. X        break;
  1433. X    }
  1434. X    } else {    /* *s == *q */
  1435. X    switch (*s) {
  1436. X    case ' ':
  1437. X    case '\n':
  1438. X    case '\t':
  1439. X    case '{':
  1440. X    case ':':
  1441. X    case '.':
  1442. X    case '*':
  1443. X        break;
  1444. X    case '}':
  1445. X        if (*(s+1) == '{') /* footnotes with daggers and dbl daggers!! */
  1446. X        ++s;
  1447. X        break;
  1448. X    case '@':
  1449. X        s = strpbrk_like(q + 1, endchars );
  1450. X        /* handles 2 char @ tokens: @{ @} @@ @: @. @* */
  1451. X        if ( strchr("{}@:.*", *s) == NULL
  1452. X            || (s > q+1 && (*s =='}' || *s == '@')))
  1453. X        --s;
  1454. X        break;
  1455. X    }
  1456. X    }
  1457. X    for (t = token; q <= s; ++q, ++t) {
  1458. X    switch (*q) {
  1459. X        case '\\' :         /* replace literal \ with \e */
  1460. X        *t = *q;
  1461. X            *++t = 'e';
  1462. X        break;
  1463. X        case ' '  :        /* protect spaces and ' in macro args */
  1464. X        case '\'' :    
  1465. X        if (inmacroarg == YES) {
  1466. X            *t = '\\';
  1467. X                *++t = *q;
  1468. X        } else
  1469. X            *t = *q;
  1470. X        break;
  1471. X        case '\"' :        /* try to avoid " trouble in macro args */
  1472. X        if (inmacroarg == YES) {
  1473. X            *t = 0;
  1474. X            (void) strcat(t,cmds->dblquote);
  1475. X            t += strlen(cmds->dblquote) - 1;
  1476. X        } else
  1477. X            *t = *q;
  1478. X        break;
  1479. X        default   :
  1480. X        *t = *q;
  1481. X        break;
  1482. X    }
  1483. X    }
  1484. X    *t = 0;
  1485. X    return ++s;
  1486. X}
  1487. X
  1488. X/*
  1489. X * lookup - find a Texinfo command starting token in the table
  1490. X */
  1491. X
  1492. Xstruct tablerecd *
  1493. Xlookup(token)
  1494. X    char       *token;
  1495. X{
  1496. X    register struct tablerecd *tptr;
  1497. X    struct tablerecd *endoftable = table + tablesize/sizeof table[0];
  1498. X
  1499. X    /* this could be a binary search, but even in a large document,
  1500. X     * commands are infrequent compared to non-command tokens.
  1501. X     * the program is fast enough and this works.
  1502. X     */
  1503. X
  1504. X    for (tptr = table; tptr < endoftable; ++tptr) {
  1505. X    if (STREQ(tptr->texstart, token))
  1506. X        return tptr;
  1507. X    }
  1508. X    return NULL;
  1509. X}
  1510. X
  1511. X/*
  1512. X * all the global data and code for handling itemized stuff is down here
  1513. X */
  1514. X
  1515. X#define MAXILEVEL    10
  1516. Xint icount[MAXILEVEL];
  1517. Xint what[MAXILEVEL];
  1518. Xchar item[MAXILEVEL][MAXLINELEN];
  1519. X
  1520. X#define ITEMIZE        0
  1521. X#define ENUMERATE   1
  1522. X#define TABLE        2
  1523. X#define APPLY        3
  1524. X
  1525. X/*
  1526. X * itemize - handle the itemizing start commands @enumerate, @itemize
  1527. X *    and @table
  1528. X */
  1529. X
  1530. Xchar * itemize(s, token)
  1531. Xchar * s;
  1532. Xchar * token;
  1533. X{
  1534. Xstruct tablerecd *i;
  1535. X
  1536. X    if (STREQ(token,"@itemize")) {
  1537. X    what[ilevel] = ITEMIZE;
  1538. X    s = gettoken(eatwhitespace(s),item[ilevel]);
  1539. X    if (item[ilevel][0] == '\n') { /* this is an error in the input */
  1540. X        --s;
  1541. X        (void) strcpy(item[ilevel],"-");
  1542. X        errormsg("missing itemizing argument ","");
  1543. X    } else {
  1544. X        if (item[ilevel][0] == '@') {
  1545. X        if ((i = lookup(item[ilevel])) != NULL) 
  1546. X            (void) strcpy(item[ilevel], i->trfstart);
  1547. X        else
  1548. X            errormsg("unrecognized itemizing argument ", item[ilevel]);
  1549. X        }
  1550. X        }
  1551. X    }
  1552. X
  1553. X    if (STREQ(token,"@enumerate")) {
  1554. X    what[ilevel] = ENUMERATE;
  1555. X    icount[ilevel] = 1;
  1556. X    } else if (STREQ(token,"@table")) {
  1557. X    what[ilevel] = TABLE;
  1558. X    s = gettoken(eatwhitespace(s),item[ilevel]);
  1559. X    if (item[ilevel][0] == '\n') {
  1560. X        item[ilevel][0] = '\0';  /* do nothing special */
  1561. X        --s;
  1562. X    } else {
  1563. X        if (item[ilevel][0] =='@'
  1564. X            && (((i = lookup(item[ilevel])) != NULL)
  1565. X            || ((i = lookup(strcat(item[ilevel],"{"))) != NULL)))
  1566. X        what[ilevel] = APPLY;
  1567. X        else
  1568. X        errormsg("unrecognized table itemizing argument ",item[ilevel]);
  1569. X    }
  1570. X    }
  1571. X
  1572. X    while (*s != '\n' && *s != '\0') 
  1573. X    ++s;  /* flush rest of line */
  1574. X    return s;
  1575. X}
  1576. X
  1577. X/*
  1578. X * doitem - handle @item and @itemx
  1579. X */
  1580. X
  1581. Xchar *
  1582. Xdoitem(s,tag)
  1583. Xchar * s;
  1584. Xchar * tag;
  1585. X{
  1586. X    char temp[MAXLINELEN], temp2[MAXLINELEN];
  1587. X    struct tablerecd *tp;
  1588. X
  1589. X    switch (what[ilevel]) {
  1590. X    case ITEMIZE:
  1591. X    (void) strcpy(tag, item[ilevel]);
  1592. X    break;
  1593. X    case ENUMERATE:
  1594. X    (void) sprintf(tag, "%d.", icount[ilevel]++);
  1595. X    break;
  1596. X    case TABLE:
  1597. X    *tag = '\0';
  1598. X    s = gettoken(eatwhitespace(s), temp);
  1599. X    if (*temp == '\n') {
  1600. X        *tag++ = '-';
  1601. X        errormsg("missing table item tag","");
  1602. X    }else {
  1603. X        while (temp[0] != '\n') {
  1604. X        (void) strcat(tag, temp);
  1605. X            s = gettoken(s, temp);
  1606. X        }
  1607. X    }
  1608. X    --s;
  1609. X    break;
  1610. X    case APPLY:
  1611. X    *tag = '\0';
  1612. X    temp2[0] = '\0';
  1613. X    s = gettoken(eatwhitespace(s), temp);
  1614. X    while (temp[0] != '\n') {
  1615. X        (void) interpret(temp, temp2);
  1616. X        s = gettoken(s, temp);
  1617. X    }
  1618. X    --s;
  1619. X    if ( (tp = lookup(item[ilevel])) != NULL ||
  1620. X        (tp = lookup(strcat(item[ilevel],"{"))) != NULL) {
  1621. X        (void) strcat(tag, tp->trfstart);
  1622. X        (void) strcat(tag, temp2);
  1623. X        (void) strcat(tag, tp->trfend);
  1624. X    } else { /* this is an error in the input */
  1625. X        (void) strcpy(tag,temp);
  1626. X        errormsg("error applying Texinfo command to table item tag ",temp);
  1627. X    }
  1628. X    break;
  1629. X    }
  1630. X    return s;
  1631. X}
  1632. END_OF_translate.c
  1633.  
  1634.