PageRenderTime 71ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/opensource.apple.com/source/libarchive/libarchive-13.1/libarchive/doc/mdoc2man.awk

#
AWK | 353 lines | 337 code | 13 blank | 3 comment | 0 complexity | 238ee1ce5d0a04b696eca3fe2e01b7e7 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, AGPL-3.0, CC-BY-SA-3.0, MPL-2.0-no-copyleft-exception, MPL-2.0, JSON, 0BSD, LGPL-2.1, Apache-2.0, BSD-3-Clause, ISC, LGPL-2.0, WTFPL, MIT
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <title>mdoc2man.awk</title>
  6. <style type="text/css">
  7. .enscript-comment { font-style: italic; color: rgb(178,34,34); }
  8. .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
  9. .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
  10. .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
  11. .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
  12. .enscript-string { font-weight: bold; color: rgb(188,143,143); }
  13. .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
  14. .enscript-type { font-weight: bold; color: rgb(34,139,34); }
  15. .enscript-highlight { text-decoration: underline; color: 0; }
  16. </style>
  17. </head>
  18. <body id="top">
  19. <h1 style="margin:8px;" id="f1">mdoc2man.awk&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
  20. <hr/>
  21. <div></div>
  22. <pre>
  23. <span class="enscript-reference">#!/usr/bin/awk
  24. </span><span class="enscript-comment">#
  25. </span><span class="enscript-comment"># Copyright (c) 2003 Peter Stuge &lt;<a href="mailto:stuge-mdoc2man@cdy.org">stuge-mdoc2man@cdy.org</a>&gt;
  26. </span><span class="enscript-comment">#
  27. </span><span class="enscript-comment"># Permission to use, copy, modify, and distribute this software for any
  28. </span><span class="enscript-comment"># purpose with or without fee is hereby granted, provided that the above
  29. </span><span class="enscript-comment"># copyright notice and this permission notice appear in all copies.
  30. </span><span class="enscript-comment">#
  31. </span><span class="enscript-comment"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot; AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  32. </span><span class="enscript-comment"># WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  33. </span><span class="enscript-comment"># MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  34. </span><span class="enscript-comment"># ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  35. </span><span class="enscript-comment"># WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  36. </span><span class="enscript-comment"># ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  37. </span><span class="enscript-comment"># OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  38. </span>
  39. <span class="enscript-comment"># Dramatically overhauled by Tim Kientzle. This version almost
  40. </span><span class="enscript-comment"># handles library-style pages with Fn, Ft, etc commands. Still
  41. </span><span class="enscript-comment"># a lot of problems...
  42. </span>
  43. <span class="enscript-keyword">BEGIN</span> {
  44. displaylines = 0
  45. trailer = <span class="enscript-string">&quot;&quot;</span>
  46. out = <span class="enscript-string">&quot;&quot;</span>
  47. sep = <span class="enscript-string">&quot;&quot;</span>
  48. nextsep = <span class="enscript-string">&quot; &quot;</span>
  49. }
  50. <span class="enscript-comment"># Add a word with appropriate preceding whitespace
  51. </span><span class="enscript-comment"># Maintain a short queue of the expected upcoming word separators.
  52. </span><span class="enscript-keyword">function</span> add(str) {
  53. out=out sep str
  54. sep = nextsep
  55. nextsep = <span class="enscript-string">&quot; &quot;</span>
  56. }
  57. <span class="enscript-comment"># Add a word with no following whitespace
  58. </span><span class="enscript-comment"># Use for opening punctuation such as '('
  59. </span><span class="enscript-keyword">function</span> addopen(str) {
  60. add(str)
  61. sep = <span class="enscript-string">&quot;&quot;</span>
  62. }
  63. <span class="enscript-comment"># Add a word with no preceding whitespace
  64. </span><span class="enscript-comment"># Use for closing punctuation such as ')' or '.'
  65. </span><span class="enscript-keyword">function</span> addclose(str) {
  66. sep = <span class="enscript-string">&quot;&quot;</span>
  67. add(str)
  68. }
  69. <span class="enscript-comment"># Add a word with no space before or after
  70. </span><span class="enscript-comment"># Use for separating punctuation such as '='
  71. </span><span class="enscript-keyword">function</span> addpunct(str) {
  72. sep = <span class="enscript-string">&quot;&quot;</span>
  73. add(str)
  74. sep = <span class="enscript-string">&quot;&quot;</span>
  75. }
  76. <span class="enscript-comment"># Emit the current line so far
  77. </span><span class="enscript-keyword">function</span> endline() {
  78. addclose(trailer)
  79. trailer = <span class="enscript-string">&quot;&quot;</span>
  80. <span class="enscript-keyword">if</span>(<span class="enscript-keyword">length</span>(out) &gt; 0) {
  81. <span class="enscript-keyword">print</span> out
  82. out=<span class="enscript-string">&quot;&quot;</span>
  83. }
  84. <span class="enscript-keyword">if</span>(displaylines &gt; 0) {
  85. displaylines = displaylines - 1
  86. <span class="enscript-keyword">if</span> (displaylines == 0)
  87. dispend()
  88. }
  89. <span class="enscript-comment"># First word on next line has no preceding whitespace
  90. </span> sep = <span class="enscript-string">&quot;&quot;</span>
  91. }
  92. <span class="enscript-keyword">function</span> linecmd(cmd) {
  93. endline()
  94. add(cmd)
  95. endline()
  96. }
  97. <span class="enscript-keyword">function</span> breakline() {
  98. linecmd(<span class="enscript-string">&quot;.br&quot;</span>)
  99. }
  100. <span class="enscript-comment"># Start an indented display
  101. </span><span class="enscript-keyword">function</span> dispstart() {
  102. linecmd(<span class="enscript-string">&quot;.RS&quot;</span>)
  103. }
  104. <span class="enscript-comment"># End an indented display
  105. </span><span class="enscript-keyword">function</span> dispend() {
  106. linecmd(<span class="enscript-string">&quot;.RE&quot;</span>)
  107. }
  108. <span class="enscript-comment"># Collect rest of input line
  109. </span><span class="enscript-keyword">function</span> wtail() {
  110. retval=<span class="enscript-string">&quot;&quot;</span>
  111. <span class="enscript-keyword">while</span>(w&lt;nwords) {
  112. <span class="enscript-keyword">if</span>(<span class="enscript-keyword">length</span>(retval))
  113. retval=retval <span class="enscript-string">&quot; &quot;</span>
  114. retval=retval words[++w]
  115. }
  116. <span class="enscript-keyword">return</span> retval
  117. }
  118. ! /^\./ {
  119. out = $0
  120. endline()
  121. <span class="enscript-keyword">next</span>
  122. }
  123. /^\.\\<span class="enscript-string">&quot;/ { next }
  124. {
  125. sub(&quot;</span>^\\.<span class="enscript-string">&quot;,&quot;</span><span class="enscript-string">&quot;)
  126. nwords=split($0,words)
  127. # TODO: Instead of iterating 'w' over the array, have a separate
  128. # function that returns 'next word' and use that. This will allow
  129. # proper handling of double-quoted arguments as well.
  130. for(w=1;w&lt;=nwords;w++) {
  131. if(match(words[w],&quot;</span>^Li$<span class="enscript-string">&quot;)) { # Literal; rest of line is unformatted
  132. dispstart()
  133. displaylines = 1
  134. } else if(match(words[w],&quot;</span>^Dl$<span class="enscript-string">&quot;)) { # Display literal
  135. dispstart()
  136. displaylines = 1
  137. } else if(match(words[w],&quot;</span>^Bd$<span class="enscript-string">&quot;)) { # Begin display
  138. if(match(words[w+1],&quot;</span>-literal<span class="enscript-string">&quot;)) {
  139. dispstart()
  140. displaylines=10000
  141. w=nwords
  142. }
  143. } else if(match(words[w],&quot;</span>^Ed$<span class="enscript-string">&quot;)) { # End display
  144. displaylines = 0
  145. dispend()
  146. } else if(match(words[w],&quot;</span>^Ns$<span class="enscript-string">&quot;)) { # Suppress space after next word
  147. nextsep = &quot;</span><span class="enscript-string">&quot;
  148. } else if(match(words[w],&quot;</span>^No$<span class="enscript-string">&quot;)) { # Normal text
  149. add(words[++w])
  150. } else if(match(words[w],&quot;</span>^Dq$<span class="enscript-string">&quot;)) { # Quote
  151. addopen(&quot;</span>``<span class="enscript-string">&quot;)
  152. add(words[++w])
  153. while(w&lt;nwords&amp;&amp;!match(words[w+1],&quot;</span>^[\\.,]<span class="enscript-string">&quot;))
  154. add(words[++w])
  155. addclose(&quot;</span>''<span class="enscript-string">&quot;)
  156. } else if(match(words[w],&quot;</span>^Oo$<span class="enscript-string">&quot;)) {
  157. addopen(&quot;</span>[<span class="enscript-string">&quot;)
  158. } else if(match(words[w],&quot;</span>^Oc$<span class="enscript-string">&quot;)) {
  159. addclose(&quot;</span>]<span class="enscript-string">&quot;)
  160. } else if(match(words[w],&quot;</span>^Ao$<span class="enscript-string">&quot;)) {
  161. addopen(&quot;</span>&lt;<span class="enscript-string">&quot;)
  162. } else if(match(words[w],&quot;</span>^Ac$<span class="enscript-string">&quot;)) {
  163. addclose(&quot;</span>&gt;<span class="enscript-string">&quot;)
  164. } else if(match(words[w],&quot;</span>^Dd$<span class="enscript-string">&quot;)) {
  165. date=wtail()
  166. next
  167. } else if(match(words[w],&quot;</span>^Dt$<span class="enscript-string">&quot;)) {
  168. id=wtail()
  169. next
  170. } else if(match(words[w],&quot;</span>^Ox$<span class="enscript-string">&quot;)) {
  171. add(&quot;</span>OpenBSD<span class="enscript-string">&quot;)
  172. } else if(match(words[w],&quot;</span>^Fx$<span class="enscript-string">&quot;)) {
  173. add(&quot;</span>FreeBSD<span class="enscript-string">&quot;)
  174. } else if(match(words[w],&quot;</span>^Nx$<span class="enscript-string">&quot;)) {
  175. add(&quot;</span>NetBSD<span class="enscript-string">&quot;)
  176. } else if(match(words[w],&quot;</span>^St$<span class="enscript-string">&quot;)) {
  177. if (match(words[w+1], &quot;</span>^-p1003.1$<span class="enscript-string">&quot;)) {
  178. w++
  179. add(&quot;</span>IEEE Std 1003.1 (``POSIX.1'')<span class="enscript-string">&quot;)
  180. } else if(match(words[w+1], &quot;</span>^-p1003.1-96$<span class="enscript-string">&quot;)) {
  181. w++
  182. add(&quot;</span>ISO/IEC 9945-1:1996 (``POSIX.1'')<span class="enscript-string">&quot;)
  183. } else if(match(words[w+1], &quot;</span>^-p1003.1-88$<span class="enscript-string">&quot;)) {
  184. w++
  185. add(&quot;</span>IEEE Std 1003.1-1988 (``POSIX.1'')<span class="enscript-string">&quot;)
  186. } else if(match(words[w+1], &quot;</span>^-p1003.1-2001$<span class="enscript-string">&quot;)) {
  187. w++
  188. add(&quot;</span>IEEE Std 1003.1-2001 (``POSIX.1'')<span class="enscript-string">&quot;)
  189. } else if(match(words[w+1], &quot;</span>^-susv2$<span class="enscript-string">&quot;)) {
  190. w++
  191. add(&quot;</span>Version 2 of the Single UNIX Specification (``SUSv2'')<span class="enscript-string">&quot;)
  192. }
  193. } else if(match(words[w],&quot;</span>^Ex$<span class="enscript-string">&quot;)) {
  194. if (match(words[w+1], &quot;</span>^-std$<span class="enscript-string">&quot;)) {
  195. w++
  196. add(&quot;</span>The \\fB<span class="enscript-string">&quot; name &quot;</span>\\fP utility exits 0 on success, and &gt;0 <span class="enscript-keyword">if</span> an error occurs.<span class="enscript-string">&quot;)
  197. }
  198. } else if(match(words[w],&quot;</span>^Os$<span class="enscript-string">&quot;)) {
  199. add(&quot;</span>.TH <span class="enscript-string">&quot; id &quot;</span> \<span class="enscript-string">&quot;&quot;</span> date <span class="enscript-string">&quot;\&quot; \&quot;&quot;</span> wtail() <span class="enscript-string">&quot;\&quot;&quot;</span>)
  200. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Sh$&quot;</span>)) {
  201. add(<span class="enscript-string">&quot;.SH&quot;</span>)
  202. section=words[w+1]
  203. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Xr$&quot;</span>)) {
  204. add(<span class="enscript-string">&quot;\\fB&quot;</span> words[++w] <span class="enscript-string">&quot;\\fP(&quot;</span> words[++w] <span class="enscript-string">&quot;)&quot;</span> words[++w])
  205. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Nm$&quot;</span>)) {
  206. <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(section,<span class="enscript-string">&quot;SYNOPSIS&quot;</span>))
  207. breakline()
  208. <span class="enscript-keyword">if</span>(w&gt;1)
  209. n=name
  210. <span class="enscript-keyword">else</span> {
  211. n=words[++w]
  212. <span class="enscript-keyword">if</span>(!<span class="enscript-keyword">length</span>(name))
  213. name=n
  214. }
  215. <span class="enscript-keyword">if</span>(!<span class="enscript-keyword">length</span>(n))
  216. n=name
  217. add(<span class="enscript-string">&quot;\\fB&quot;</span> n <span class="enscript-string">&quot;\\fP&quot;</span>)
  218. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Nd$&quot;</span>)) {
  219. add(<span class="enscript-string">&quot;\\- &quot;</span> wtail())
  220. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Fl$&quot;</span>)) {
  221. add(<span class="enscript-string">&quot;\\fB\\-&quot;</span> words[++w] <span class="enscript-string">&quot;\\fP&quot;</span>)
  222. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Ar$&quot;</span>)) {
  223. addopen(<span class="enscript-string">&quot;\\fI&quot;</span>)
  224. <span class="enscript-keyword">if</span>(w==nwords)
  225. add(<span class="enscript-string">&quot;file ...\\fP&quot;</span>)
  226. <span class="enscript-keyword">else</span> {
  227. add(words[++w] <span class="enscript-string">&quot;\\fP&quot;</span>)
  228. <span class="enscript-keyword">while</span>(<span class="enscript-keyword">match</span>(words[w+1],<span class="enscript-string">&quot;^\\|$&quot;</span>))
  229. add(words[++w] <span class="enscript-string">&quot; \\fI&quot;</span> words[++w] <span class="enscript-string">&quot;\\fP&quot;</span>)
  230. }
  231. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Cm$&quot;</span>)) {
  232. add(<span class="enscript-string">&quot;\\fB&quot;</span> words[++w] <span class="enscript-string">&quot;\\fP&quot;</span>)
  233. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Op$&quot;</span>)) {
  234. addopen(<span class="enscript-string">&quot;[&quot;</span>)
  235. option=1
  236. trailer=<span class="enscript-string">&quot;]&quot;</span> trailer
  237. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Pp$&quot;</span>)) {
  238. endline()
  239. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^An$&quot;</span>)) {
  240. endline()
  241. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Ss$&quot;</span>)) {
  242. add(<span class="enscript-string">&quot;.SS&quot;</span>)
  243. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Ft$&quot;</span>)) {
  244. addopen(<span class="enscript-string">&quot;\\fI&quot;</span>)
  245. trailer = <span class="enscript-string">&quot;\\fP&quot;</span> trailer
  246. displaylines = 1
  247. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Fn$&quot;</span>)) {
  248. <span class="enscript-comment"># Using '.nh' to suppress hyphenation doesn't really work...
  249. </span> <span class="enscript-comment"># TODO: Fix this.
  250. </span> add(<span class="enscript-string">&quot;.nh&quot;</span>)
  251. endline()
  252. addopen(<span class="enscript-string">&quot;\\fB&quot;</span>)
  253. w++
  254. add(words[w])
  255. addclose(<span class="enscript-string">&quot;\\fP&quot;</span>)
  256. endline()
  257. add(<span class="enscript-string">&quot;.hy&quot;</span>)
  258. endline()
  259. addpunct(<span class="enscript-string">&quot;(&quot;</span>)
  260. <span class="enscript-comment"># This is broken; Fn should peek ahead and put each double-quoted
  261. </span> <span class="enscript-comment"># arg in .Ty and be smarter about following punct.
  262. </span> trailer = <span class="enscript-string">&quot;);&quot;</span> trailer
  263. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Va$&quot;</span>)) {
  264. w++
  265. add(<span class="enscript-string">&quot;\\fI&quot;</span> words[w] <span class="enscript-string">&quot;\\fP&quot;</span>)
  266. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^In$&quot;</span>)) {
  267. w++
  268. add(<span class="enscript-string">&quot;\\fB#include &lt;&quot;</span> words[w] <span class="enscript-string">&quot;&gt;\\fP&quot;</span>)
  269. breakline()
  270. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Pa$&quot;</span>)) {
  271. addopen(<span class="enscript-string">&quot;\\fI&quot;</span>)
  272. w++
  273. <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^\\.&quot;</span>))
  274. add(<span class="enscript-string">&quot;\\&amp;&quot;</span>)
  275. add(words[w] <span class="enscript-string">&quot;\\fP&quot;</span>)
  276. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Dv$&quot;</span>)) {
  277. add(<span class="enscript-string">&quot;.BR&quot;</span>)
  278. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Em|Ev$&quot;</span>)) {
  279. add(<span class="enscript-string">&quot;.IR&quot;</span>)
  280. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Pq$&quot;</span>)) {
  281. addopen(<span class="enscript-string">&quot;(&quot;</span>)
  282. trailer=<span class="enscript-string">&quot;)&quot;</span> trailer
  283. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Aq$&quot;</span>)) {
  284. addopen(<span class="enscript-string">&quot;&lt;&quot;</span>)
  285. trailer=<span class="enscript-string">&quot;&gt;&quot;</span> trailer
  286. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Brq$&quot;</span>)) {
  287. addopen(<span class="enscript-string">&quot;{&quot;</span>)
  288. trailer=<span class="enscript-string">&quot;}&quot;</span> trailer
  289. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^S[xy]$&quot;</span>)) {
  290. add(<span class="enscript-string">&quot;.B &quot;</span> wtail())
  291. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Ic$&quot;</span>)) {
  292. add(<span class="enscript-string">&quot;\\fB&quot;</span>)
  293. trailer=<span class="enscript-string">&quot;\\fP&quot;</span> trailer
  294. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^Bl$&quot;</span>)) {
  295. oldoptlist=optlist
  296. <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w+1],<span class="enscript-string">&quot;-bullet&quot;</span>))
  297. optlist=1
  298. <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w+1],<span class="enscript-string">&quot;-enum&quot;</span>)) {
  299. optlist=2
  300. enum=0
  301. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w+1],<span class="enscript-string">&quot;-tag&quot;</span>))
  302. optlist=3
  303. <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w+1],<span class="enscript-string">&quot;-item&quot;</span>))
  304. optlist=4
  305. <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w+1],<span class="enscript-string">&quot;-bullet&quot;</span>))
  306. optlist=1
  307. w=nwords
  308. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^El$&quot;</span>)) {
  309. optlist=oldoptlist
  310. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^It$&quot;</span>)&amp;&amp;optlist) {
  311. <span class="enscript-keyword">if</span>(optlist==1)
  312. add(<span class="enscript-string">&quot;.IP \\(bu&quot;</span>)
  313. <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(optlist==2)
  314. add(<span class="enscript-string">&quot;.IP &quot;</span> ++enum <span class="enscript-string">&quot;.&quot;</span>)
  315. <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(optlist==3) {
  316. add(<span class="enscript-string">&quot;.TP&quot;</span>)
  317. endline()
  318. <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w+1],<span class="enscript-string">&quot;^Pa$|^Ev$&quot;</span>)) {
  319. add(<span class="enscript-string">&quot;.B&quot;</span>)
  320. w++
  321. }
  322. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(optlist==4)
  323. add(<span class="enscript-string">&quot;.IP&quot;</span>)
  324. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^[=]$&quot;</span>)) {
  325. addpunct(words[w])
  326. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^[\[{(]$&quot;</span>)) {
  327. addopen(words[w])
  328. } <span class="enscript-keyword">else</span> <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(words[w],<span class="enscript-string">&quot;^[\\\])}.,;:]$&quot;</span>)) {
  329. addclose(words[w])
  330. } <span class="enscript-keyword">else</span> {
  331. add(words[w])
  332. }
  333. }
  334. <span class="enscript-keyword">if</span>(<span class="enscript-keyword">match</span>(out,<span class="enscript-string">&quot;^\\.[^a-zA-Z]&quot;</span>))
  335. <span class="enscript-keyword">sub</span>(<span class="enscript-string">&quot;^\\.&quot;</span>,<span class="enscript-string">&quot;&quot;</span>,out)
  336. endline()
  337. }
  338. </pre>
  339. <hr />
  340. </body></html>