ConvertTexi.dpr 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  1. {
  2. TIGCC Documentation Tools
  3. Copyright (C) 2002-2004 Sebastian Reichelt
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. }
  16. program ConvertTexi;
  17. uses
  18. Windows,
  19. SysUtils,
  20. Classes,
  21. UtilsDos,
  22. UtilsWin,
  23. HelpSystemMasterUnit in '..\HelpSystemMasterUnit.pas';
  24. function GetSecID(Ref: string): string;
  25. begin
  26. Ref := StringReplace (Ref, #13#10, ' ', [rfReplaceAll]);
  27. Ref := StringReplace (Ref, #13, ' ', [rfReplaceAll]);
  28. Ref := StringReplace (Ref, #10, ' ', [rfReplaceAll]);
  29. Ref := StringReplace (Ref, ',, ', ',,', [rfReplaceAll]);
  30. if Ref = 'Invoking GCC,,GCC Command Options' then
  31. Result := 'comopts/comopts'
  32. else if (Ref = 'Overall Options,,Options Controlling the Kind of Output') or (Ref = 'Overall Options,,Options Controlling the Kind of Output, gcc.info, Using GNU CC') then
  33. Result := 'comopts/SEC4'
  34. else if Ref = 'C Dialect Options,,Options Controlling C Dialect' then
  35. Result := 'comopts/SEC6'
  36. else if Ref = 'Warning Options,,Options to Request or Suppress Warnings' then
  37. Result := 'comopts/SEC8'
  38. else if (Ref = 'Debugging Options,,Options for Debugging Your Program or GCC') or (Ref = 'Debugging Options,,Options for Debugging Your Program or @command{gcc}') then
  39. Result := 'comopts/SEC9'
  40. else if Ref = 'Optimize Options,,Options That Control Optimization' then
  41. Result := 'comopts/SEC10'
  42. else if Ref = 'Preprocessor Options,,Options Controlling the Preprocessor' then
  43. Result := 'comopts/SEC11'
  44. else if Ref = 'Assembler Options,,Passing Options to the Assembler' then
  45. Result := 'comopts/SEC12'
  46. else if Ref = 'Directory Options,,Options for Directory Search' then
  47. Result := 'comopts/SEC14'
  48. else if Ref = 'Spec Files,,Specifying subprocesses and the switches to pass to them' then
  49. Result := 'comopts/SEC15'
  50. else if Ref = 'M680x0 Options,,M680x0 Options' then
  51. Result := 'comopts/SEC16'
  52. else if Ref = 'Code Gen Options,,Options for Code Generation Conventions' then
  53. Result := 'comopts/SEC44'
  54. else if Ref = 'Environment Variables,,Environment Variables Affecting GCC' then
  55. Result := 'comopts/SEC45'
  56. else if Ref = 'CPP Overview' then
  57. Result := 'cpp/SEC2'
  58. else if Ref = 'Initial processing' then
  59. Result := 'cpp/SEC3'
  60. else if Ref = 'Tokenization' then
  61. Result := 'cpp/SEC3a'
  62. else if Ref = 'The preprocessing language' then
  63. Result := 'cpp/SEC3b'
  64. else if Ref = 'Header Files' then
  65. Result := 'cpp/SEC4'
  66. else if Ref = 'Include Syntax' then
  67. Result := 'cpp/SEC6'
  68. else if Ref = 'Include Operation' then
  69. Result := 'cpp/SEC7'
  70. else if Ref = 'Once-Only Headers' then
  71. Result := 'cpp/SEC8'
  72. else if Ref = 'Computed Includes' then
  73. Result := 'cpp/SEC8a'
  74. else if Ref = 'Wrapper Headers' then
  75. Result := 'cpp/SEC9'
  76. else if Ref = 'System Headers' then
  77. Result := 'cpp/SEC9a'
  78. else if Ref = 'Macros' then
  79. Result := 'cpp/SEC10'
  80. else if Ref = 'Object-like Macros' then
  81. Result := 'cpp/SEC11'
  82. else if Ref = 'Function-like Macros' then
  83. Result := 'cpp/SEC12'
  84. else if Ref = 'Macro Arguments' then
  85. Result := 'cpp/SEC12a'
  86. else if Ref = 'Variadic Macros' then
  87. Result := 'cpp/SEC13'
  88. else if Ref = 'Predefined Macros' then
  89. Result := 'cpp/SEC14'
  90. else if Ref = 'Standard Predefined Macros' then
  91. Result := 'cpp/SEC15'
  92. else if Ref = 'Common Predefined Macros' then
  93. Result := 'cpp/SEC15a'
  94. else if Ref = 'System-specific Predefined Macros' then
  95. Result := 'cpp/SEC16'
  96. else if Ref = 'Stringification' then
  97. Result := 'cpp/SEC17'
  98. else if Ref = 'Concatenation' then
  99. Result := 'cpp/SEC18'
  100. else if Ref = 'Undefining and Redefining Macros' then
  101. Result := 'cpp/SEC19'
  102. else if Ref = 'Directives Within Macro Arguments' then
  103. Result := 'cpp/SEC20'
  104. else if Ref = 'Macro Pitfalls' then
  105. Result := 'cpp/SEC22'
  106. else if Ref = 'Misnesting' then
  107. Result := 'cpp/SEC23'
  108. else if Ref = 'Operator Precedence Problems' then
  109. Result := 'cpp/SEC24'
  110. else if Ref = 'Swallowing the Semicolon' then
  111. Result := 'cpp/SEC25'
  112. else if Ref = 'Duplication of Side Effects' then
  113. Result := 'cpp/SEC26'
  114. else if Ref = 'Self-Referential Macros' then
  115. Result := 'cpp/SEC27'
  116. else if Ref = 'Argument Prescan' then
  117. Result := 'cpp/SEC28'
  118. else if Ref = 'Newlines in Arguments' then
  119. Result := 'cpp/SEC30'
  120. else if Ref = 'Conditionals' then
  121. Result := 'cpp/SEC31'
  122. else if Ref = 'Conditional Uses' then
  123. Result := 'cpp/SEC32'
  124. else if Ref = 'Conditional Syntax' then
  125. Result := 'cpp/SEC33'
  126. else if Ref = 'If' then
  127. Result := 'cpp/SEC34'
  128. else if Ref = 'Else' then
  129. Result := 'cpp/SEC35'
  130. else if Ref = 'Elif' then
  131. Result := 'cpp/SEC36'
  132. else if Ref = 'Deleted Code' then
  133. Result := 'cpp/SEC37'
  134. else if Ref = 'Ifdef' then
  135. Result := 'cpp/SEC38'
  136. else if Ref = 'Defined' then
  137. Result := 'cpp/SEC38a'
  138. else if Ref = 'Assertions' then
  139. Result := 'cpp/SEC39'
  140. else if Ref = 'Diagnostics' then
  141. Result := 'cpp/SEC40'
  142. else if Ref = 'Line Control' then
  143. Result := 'cpp/SEC41'
  144. else if Ref = 'Pragmas' then
  145. Result := 'cpp/SEC46'
  146. else if Ref = 'Other Directives' then
  147. Result := 'cpp/SEC42'
  148. else if Ref = 'Preprocessor Output' then
  149. Result := 'cpp/SEC43'
  150. else if Ref = 'Traditional Mode' then
  151. Result := 'cpp/SEC70'
  152. else if Ref = 'Traditional lexical analysis' then
  153. Result := 'cpp/SEC71'
  154. else if Ref = 'Traditional macros' then
  155. Result := 'cpp/SEC72'
  156. else if Ref = 'Traditional miscellany' then
  157. Result := 'cpp/SEC73'
  158. else if Ref = 'Traditional warnings' then
  159. Result := 'cpp/SEC74'
  160. else if Ref = 'Implementation Details' then
  161. Result := 'cpp/SEC80'
  162. else if Ref = 'Implementation-defined behavior' then
  163. Result := 'cpp/SEC81'
  164. else if Ref = 'Implementation limits' then
  165. Result := 'cpp/SEC82'
  166. else if Ref = 'Obsolete Features' then
  167. Result := 'cpp/SEC83'
  168. else if Ref = 'Obsolete once-only headers' then
  169. Result := 'cpp/SEC84'
  170. else if Ref = 'Miscellaneous obsolete features' then
  171. Result := 'cpp/SEC85'
  172. else if Ref = 'Differences from previous versions' then
  173. Result := 'cpp/SEC86'
  174. else if Ref = 'Invocation' then
  175. Result := 'cpp/SEC44'
  176. else if Ref = 'Environment Variables' then
  177. Result := 'cpp/SEC45'
  178. else if Ref = 'C Extensions' then
  179. Result := 'gnuexts/gnuexts'
  180. else if Ref = 'Statement Exprs' then
  181. Result := 'gnuexts/SEC63'
  182. else if Ref = 'Local Labels' then
  183. Result := 'gnuexts/SEC64'
  184. else if Ref = 'Labels as Values' then
  185. Result := 'gnuexts/SEC65'
  186. else if Ref = 'Nested Functions' then
  187. Result := 'gnuexts/SEC66'
  188. else if Ref = 'Constructing Calls' then
  189. Result := 'gnuexts/SEC67'
  190. else if Ref = 'Naming Types' then
  191. Result := 'gnuexts/SEC68'
  192. else if Ref = 'Typeof' then
  193. Result := 'gnuexts/SEC69'
  194. else if Ref = 'Lvalues' then
  195. Result := 'gnuexts/SEC70'
  196. else if Ref = 'Conditional Extensions' then
  197. Result := 'gnuexts/SEC71'
  198. else if Ref = 'Long Long' then
  199. Result := 'gnuexts/SEC72'
  200. else if Ref = 'Complex' then
  201. Result := 'gnuexts/SEC73'
  202. else if Ref = 'Hex Floats' then
  203. Result := 'gnuexts/SEC74'
  204. else if Ref = 'Zero Length' then
  205. Result := 'gnuexts/SEC75'
  206. else if Ref = 'Variable Length' then
  207. Result := 'gnuexts/SEC76'
  208. else if Ref = 'Variadic Macro Extensions' then
  209. Result := 'gnuexts/SEC77'
  210. else if Ref = 'Subscripting' then
  211. Result := 'gnuexts/SEC78'
  212. else if Ref = 'Pointer Arith' then
  213. Result := 'gnuexts/SEC79'
  214. else if Ref = 'Initializers' then
  215. Result := 'gnuexts/SEC80'
  216. else if Ref = 'Compound Literals' then
  217. Result := 'gnuexts/SEC81'
  218. else if Ref = 'Designated Inits' then
  219. Result := 'gnuexts/SEC82'
  220. else if Ref = 'Case Ranges' then
  221. Result := 'gnuexts/SEC83'
  222. else if Ref = 'Cast to Union' then
  223. Result := 'gnuexts/SEC84'
  224. else if Ref = 'Function Attributes' then
  225. Result := 'gnuexts/SEC85'
  226. else if Ref = 'Attribute Syntax' then
  227. Result := 'gnuexts/SEC85a'
  228. else if Ref = 'Function Prototypes' then
  229. Result := 'gnuexts/SEC86'
  230. else if Ref = 'C++ Comments' then
  231. Result := 'gnuexts/SEC87'
  232. else if Ref = 'Dollar Signs' then
  233. Result := 'gnuexts/SEC88'
  234. else if Ref = 'Character Escapes' then
  235. Result := 'gnuexts/SEC89'
  236. else if Ref = 'Alignment' then
  237. Result := 'gnuexts/SEC90'
  238. else if Ref = 'Variable Attributes' then
  239. Result := 'gnuexts/SEC91'
  240. else if Ref = 'Type Attributes' then
  241. Result := 'gnuexts/SEC92'
  242. else if Ref = 'Inline' then
  243. Result := 'gnuexts/SEC93'
  244. else if Ref = 'Extended Asm,,Assembler Instructions with C Expression Operands' then
  245. Result := 'gnuexts/SEC94'
  246. else if Ref = 'Asm Labels' then
  247. Result := 'gnuexts/SEC96'
  248. else if Ref = 'Explicit Reg Vars' then
  249. Result := 'gnuexts/SEC97'
  250. else if Ref = 'Global Reg Vars' then
  251. Result := 'gnuexts/SEC98'
  252. else if Ref = 'Local Reg Vars' then
  253. Result := 'gnuexts/SEC99'
  254. else if Ref = 'Alternate Keywords' then
  255. Result := 'gnuexts/SEC100'
  256. else if Ref = 'Incomplete Enums' then
  257. Result := 'gnuexts/SEC101'
  258. else if Ref = 'Function Names' then
  259. Result := 'gnuexts/SEC102'
  260. else if Ref = 'Return Address' then
  261. Result := 'gnuexts/SEC103'
  262. else if Ref = 'Other Builtins' then
  263. Result := 'gnuexts/SEC104'
  264. else if Ref = 'Escaped Newlines' then
  265. Result := 'gnuexts/SEC105'
  266. else if Ref = 'Multi-line Strings' then
  267. Result := 'gnuexts/SEC106'
  268. else if Ref = 'Mixed Declarations' then
  269. Result := 'gnuexts/SEC107'
  270. else if Ref = 'Unnamed Fields' then
  271. Result := 'gnuexts/SEC108'
  272. else if Ref = 'Volatiles' then
  273. Result := 'gnuexts/SEC109'
  274. else if Ref = 'Empty Structures' then
  275. Result := 'gnuexts/SEC111'
  276. else if Ref = 'Acknowledgements,,GNU Assembler Acknowledgements' then
  277. Result := 'gnuasm/acknowledge'
  278. else if Ref = 'Command Line,,Command Line' then
  279. Result := 'gnuasm/SEC9'
  280. else if (Ref = 'Invoking,,Command-Line Options') or (Ref = 'Invoking,,Comand-Line Options') then
  281. Result := 'gnuasm/SEC10'
  282. else if Ref = 'Overview,,Overview' then
  283. Result := 'gnuasm/SEC11'
  284. else if Ref = 'M68K-Opts,,M680x0 Options' then
  285. Result := 'gnuasm/SEC12'
  286. else if Ref = 'a,,Enable Listings: @option{-a[cdhlns]}' then
  287. Result := 'gnuasm/SEC13'
  288. else if Ref = 'listing,,Configuring listing output: @option{--listing}' then
  289. Result := 'gnuasm/SEC14'
  290. else if Ref = 'o,,Name the Object File: @option{-o}' then
  291. Result := 'gnuasm/SEC15'
  292. else if Ref = 'W,,Control Warnings: @option{-W}, @option{--warn}, @option{--no-warn}, @option{--fatal-warnings}' then
  293. Result := 'gnuasm/SEC16'
  294. else if Ref = 'R,,Join Data and Text Sections: @option{-R}' then
  295. Result := 'gnuasm/SEC17'
  296. else if Ref = 'L,,Include Local Labels: @option{-L}' then
  297. Result := 'gnuasm/SEC18'
  298. else if Ref = 'traditional-format,,Compatible Output: @option{--traditional-format}' then
  299. Result := 'gnuasm/SEC19'
  300. else if Ref = 'M,,Assemble in MRI Compatibility Mode: @option{-M}' then
  301. Result := 'gnuasm/SEC19a'
  302. else if Ref = 'Input Files,,Input Files' then
  303. Result := 'gnuasm/SEC21'
  304. else if Ref = 'Input Files,,Filenames and Line-numbers' then
  305. Result := 'gnuasm/SEC22'
  306. else if Ref = 'Object,,Output (Object) File' then
  307. Result := 'gnuasm/SEC23'
  308. else if Ref = 'Errors,,Error and Warning Messages' then
  309. Result := 'gnuasm/SEC24'
  310. else if Ref = 'Syntax,,Syntax' then
  311. Result := 'gnuasm/SEC25'
  312. else if Ref = 'Preprocessing,,Preprocessing' then
  313. Result := 'gnuasm/SEC26'
  314. else if Ref = 'Whitespace,,Whitespace' then
  315. Result := 'gnuasm/SEC27'
  316. else if Ref = 'Comments,,Comments' then
  317. Result := 'gnuasm/SEC28'
  318. else if Ref = 'Symbol Intro,,Symbols' then
  319. Result := 'gnuasm/SEC29'
  320. else if Ref = 'Statements,,Statements' then
  321. Result := 'gnuasm/SEC30'
  322. else if Ref = 'Constants,,Constants' then
  323. Result := 'gnuasm/SEC31'
  324. else if Ref = 'Characters,,Character Constants' then
  325. Result := 'gnuasm/SEC32'
  326. else if (Ref = 'Strings,,Strings') or (Ref = 'Strings') then
  327. Result := 'gnuasm/SEC33'
  328. else if Ref = 'Chars,,Characters' then
  329. Result := 'gnuasm/SEC34'
  330. else if Ref = 'Numbers,,Number Constants' then
  331. Result := 'gnuasm/SEC35'
  332. else if Ref = 'Integers,,Integers' then
  333. Result := 'gnuasm/SEC36'
  334. else if Ref = 'Bignums,,Bignums' then
  335. Result := 'gnuasm/SEC37'
  336. else if Ref = 'Flonums,,Flonums' then
  337. Result := 'gnuasm/SEC38'
  338. else if Ref = 'M68K-Syntax,,Syntax' then
  339. Result := 'gnuasm/SEC216'
  340. else if Ref = 'M68K-Moto-Syntax,,Motorola Syntax' then
  341. Result := 'gnuasm/SEC217'
  342. else if Ref = 'M68K-Branch,,Branch Improvement' then
  343. Result := 'gnuasm/SEC221'
  344. else if Ref = 'M68K-Chars,,Special Characters' then
  345. Result := 'gnuasm/SEC222'
  346. else if (Ref = 'Sections,,Sections and Relocation') or (Ref = 'Secs Background,,Background') then
  347. Result := 'gnuasm/SEC39'
  348. else if Ref = 'Ld Sections,,Linker Sections' then
  349. Result := 'gnuasm/SEC41'
  350. else if Ref = 'As Sections,,Assembler Internal Sections' then
  351. Result := 'gnuasm/SEC42'
  352. else if Ref = 'Sub-Sections,,Sub-Sections' then
  353. Result := 'gnuasm/SEC43'
  354. else if Ref = 'bss,,bss Section' then
  355. Result := 'gnuasm/SEC44'
  356. else if (Ref = 'Symbols,,Symbols') or (Ref = 'Symbols') then
  357. Result := 'gnuasm/SEC45'
  358. else if Ref = 'Labels,,Labels' then
  359. Result := 'gnuasm/SEC46'
  360. else if Ref = 'Setting Symbols,,Giving Symbols Other Values' then
  361. Result := 'gnuasm/SEC47'
  362. else if (Ref = 'Symbol Names') or (Ref = 'Symbol Names,,Symbol Names') then
  363. Result := 'gnuasm/SEC48'
  364. else if Ref = 'Symbol Names,,Local Symbol Names' then
  365. Result := 'gnuasm/SEC48L'
  366. else if Ref = 'Symbol Names,,Dollar Local Labels' then
  367. Result := 'gnuasm/SEC48LD'
  368. else if Ref = 'Dot,,The Special Dot Symbol' then
  369. Result := 'gnuasm/SEC49'
  370. else if (Ref = 'Symbol Attributes') or (Ref = 'Symbol Attributes,,Symbol Attributes') then
  371. Result := 'gnuasm/SEC50'
  372. else if Ref = 'Symbol Value,,Value' then
  373. Result := 'gnuasm/SEC51'
  374. else if Ref = 'Symbol Type,,Type' then
  375. Result := 'gnuasm/SEC52'
  376. else if Ref = 'COFF Symbols,,Symbol Attributes for COFF' then
  377. Result := 'gnuasm/SEC56'
  378. else if Ref = 'COFF Symbols,,Primary Attributes' then
  379. Result := 'gnuasm/SEC57'
  380. else if Ref = 'COFF Symbols,,Auxiliary Attributes' then
  381. Result := 'gnuasm/SEC58'
  382. else if (Ref = 'Expressions') or (Ref = 'Expressions,,Expressions') then
  383. Result := 'gnuasm/SEC60'
  384. else if Ref = 'Empty Exprs,,Empty Expressions' then
  385. Result := 'gnuasm/SEC61'
  386. else if Ref = 'Integer Exprs,,Integer Expressions' then
  387. Result := 'gnuasm/SEC62'
  388. else if Ref = 'Arguments,,Arguments' then
  389. Result := 'gnuasm/SEC63'
  390. else if Ref = 'Operators,,Operators' then
  391. Result := 'gnuasm/SEC64'
  392. else if (Ref = 'Prefix Ops,,Prefix Operator') or (Ref = 'Prefix Ops,,Prefix Operators') then
  393. Result := 'gnuasm/SEC65'
  394. else if (Ref = 'Infix Ops,,Infix Operator') or (Ref = 'Infix Ops,,Infix Operators') then
  395. Result := 'gnuasm/SEC66'
  396. else if Ref = 'Pseudo Ops,,Assembler Directives' then
  397. Result := 'gnuasm/SEC67'
  398. else if Pos ('.abort', Ref) > 0 then
  399. Result := 'gnuasm/SEC68'
  400. else if Pos ('.ABORT', Ref) > 0 then
  401. Result := 'gnuasm/SEC69'
  402. else if Pos ('.align', Ref) > 0 then
  403. Result := 'gnuasm/SEC70'
  404. else if Pos ('.app-file', Ref) > 0 then
  405. Result := 'gnuasm/SEC71'
  406. else if Pos ('.ascii', Ref) > 0 then
  407. Result := 'gnuasm/SEC72'
  408. else if Pos ('.asciz', Ref) > 0 then
  409. Result := 'gnuasm/SEC73'
  410. else if Pos ('.balign', Ref) > 0 then
  411. Result := 'gnuasm/SEC74'
  412. else if Pos ('.byte', Ref) > 0 then
  413. Result := 'gnuasm/SEC75'
  414. else if Pos ('.comm', Ref) > 0 then
  415. Result := 'gnuasm/SEC76'
  416. else if Pos ('.data', Ref) > 0 then
  417. Result := 'gnuasm/SEC77'
  418. else if Pos ('.def', Ref) > 0 then
  419. Result := 'gnuasm/SEC78'
  420. else if Pos ('.desc', Ref) > 0 then
  421. Result := 'gnuasm/SEC79'
  422. else if Pos ('.dim', Ref) > 0 then
  423. Result := 'gnuasm/SEC80'
  424. else if Pos ('.double', Ref) > 0 then
  425. Result := 'gnuasm/SEC81'
  426. else if Pos ('.eject', Ref) > 0 then
  427. Result := 'gnuasm/SEC82'
  428. else if Pos ('.elseif', Ref) > 0 then
  429. Result := 'gnuasm/SEC83IF'
  430. else if Pos ('.else', Ref) > 0 then
  431. Result := 'gnuasm/SEC83'
  432. else if Pos ('.endef', Ref) > 0 then
  433. Result := 'gnuasm/SEC84'
  434. else if Pos ('.endif', Ref) > 0 then
  435. Result := 'gnuasm/SEC84IF'
  436. else if Pos ('.endfunc', Ref) > 0 then
  437. Result := 'gnuasm/SEC84FUNC'
  438. else if Pos ('.endm', Ref) > 0 then
  439. Result := 'gnuasm/SEC84M'
  440. else if Pos ('.endr', Ref) > 0 then
  441. Result := 'gnuasm/SEC84R'
  442. else if Pos ('.end', Ref) > 0 then
  443. Result := 'gnuasm/SEC83b'
  444. else if Pos ('.equiv', Ref) > 0 then
  445. Result := 'gnuasm/SEC87'
  446. else if Pos ('.equ', Ref) > 0 then
  447. Result := 'gnuasm/SEC86'
  448. else if Pos ('.err', Ref) > 0 then
  449. Result := 'gnuasm/SEC88'
  450. else if Pos ('.even', Ref) > 0 then
  451. Result := 'gnuasm/SEC70E'
  452. else if Pos ('.exitm', Ref) > 0 then
  453. Result := 'gnuasm/SEC85'
  454. else if Pos ('.extern', Ref) > 0 then
  455. Result := 'gnuasm/SEC89'
  456. else if Pos ('.fail', Ref) > 0 then
  457. Result := 'gnuasm/SEC89a'
  458. else if Pos ('.file', Ref) > 0 then
  459. Result := 'gnuasm/SEC90'
  460. else if Pos ('.fill', Ref) > 0 then
  461. Result := 'gnuasm/SEC91'
  462. else if Pos ('.float', Ref) > 0 then
  463. Result := 'gnuasm/SEC92'
  464. else if Pos ('.func', Ref) > 0 then
  465. Result := 'gnuasm/SEC92a'
  466. else if (Pos ('.globl', Ref) > 0) or (Pos ('.global', Ref) > 0) then
  467. Result := 'gnuasm/SEC93'
  468. else if Pos ('.hword', Ref) > 0 then
  469. Result := 'gnuasm/SEC94'
  470. else if Pos ('.ident', Ref) > 0 then
  471. Result := 'gnuasm/SEC95'
  472. else if Pos ('.ifdef', Ref) > 0 then
  473. Result := 'gnuasm/SEC96D'
  474. else if Pos ('.ifndef', Ref) > 0 then
  475. Result := 'gnuasm/SEC96N'
  476. else if Pos ('.ifnotdef', Ref) > 0 then
  477. Result := 'gnuasm/SEC96ND'
  478. else if (Pos ('.if ', Ref) > 0) or (Pos ('.if}', Ref) > 0) then
  479. Result := 'gnuasm/SEC96'
  480. else if Pos ('.incbin', Ref) > 0 then
  481. Result := 'gnuasm/SEC97B'
  482. else if Pos ('.include', Ref) > 0 then
  483. Result := 'gnuasm/SEC97'
  484. else if Pos ('.int', Ref) > 0 then
  485. Result := 'gnuasm/SEC98'
  486. else if Pos ('.irpc', Ref) > 0 then
  487. Result := 'gnuasm/SEC100'
  488. else if Pos ('.irp', Ref) > 0 then
  489. Result := 'gnuasm/SEC99'
  490. else if Pos ('.lcomm', Ref) > 0 then
  491. Result := 'gnuasm/SEC101'
  492. else if Pos ('.lflags', Ref) > 0 then
  493. Result := 'gnuasm/SEC102'
  494. else if Pos ('.line', Ref) > 0 then
  495. Result := 'gnuasm/SEC103'
  496. else if Pos ('.ln', Ref) > 0 then
  497. Result := 'gnuasm/SEC105'
  498. else if Pos ('.list', Ref) > 0 then
  499. Result := 'gnuasm/SEC107'
  500. else if Pos ('.long', Ref) > 0 then
  501. Result := 'gnuasm/SEC108'
  502. else if Pos ('.macro', Ref) > 0 then
  503. Result := 'gnuasm/SEC109'
  504. else if Pos ('.mri', Ref) > 0 then
  505. Result := 'gnuasm/SEC106'
  506. else if Pos ('.nolist', Ref) > 0 then
  507. Result := 'gnuasm/SEC110'
  508. else if Pos ('.octa', Ref) > 0 then
  509. Result := 'gnuasm/SEC111'
  510. else if Pos ('.org', Ref) > 0 then
  511. Result := 'gnuasm/SEC112'
  512. else if Pos ('.p2align[wl]', Ref) > 0 then
  513. Result := 'gnuasm/SEC113'
  514. else if Pos ('.print', Ref) > 0 then
  515. Result := 'gnuasm/SEC113a'
  516. else if Pos ('.psize', Ref) > 0 then
  517. Result := 'gnuasm/SEC114'
  518. else if Pos ('.purgem', Ref) > 0 then
  519. Result := 'gnuasm/SEC114a'
  520. else if Pos ('.quad', Ref) > 0 then
  521. Result := 'gnuasm/SEC115'
  522. else if Pos ('.rept', Ref) > 0 then
  523. Result := 'gnuasm/SEC116'
  524. else if Pos ('.sbttl', Ref) > 0 then
  525. Result := 'gnuasm/SEC117'
  526. else if Pos ('.scl', Ref) > 0 then
  527. Result := 'gnuasm/SEC118'
  528. else if Ref = 'Section,,COFF Version' then
  529. Result := 'gnuasm/SEC119'
  530. else if Pos ('.set', Ref) > 0 then
  531. Result := 'gnuasm/SEC120'
  532. else if Pos ('.short', Ref) > 0 then
  533. Result := 'gnuasm/SEC121'
  534. else if Pos ('.single', Ref) > 0 then
  535. Result := 'gnuasm/SEC122'
  536. else if Ref = 'Size,,COFF Version' then
  537. Result := 'gnuasm/SEC123'
  538. else if Pos ('.sleb128', Ref) > 0 then
  539. Result := 'gnuasm/SEC124'
  540. else if Pos ('.skip', Ref) > 0 then
  541. Result := 'gnuasm/SEC125'
  542. else if Pos ('.space', Ref) > 0 then
  543. Result := 'gnuasm/SEC126'
  544. else if Pos ('.stabd', Ref) > 0 then
  545. Result := 'gnuasm/SEC127'
  546. else if Pos ('.stabn', Ref) > 0 then
  547. Result := 'gnuasm/SEC127N'
  548. else if Pos ('.stabs', Ref) > 0 then
  549. Result := 'gnuasm/SEC127S'
  550. else if Pos ('.string', Ref) > 0 then
  551. Result := 'gnuasm/SEC128'
  552. else if Pos ('.struct', Ref) > 0 then
  553. Result := 'gnuasm/SEC128a'
  554. else if Pos ('.symver', Ref) > 0 then
  555. Result := 'gnuasm/SEC129'
  556. else if Pos ('.tag', Ref) > 0 then
  557. Result := 'gnuasm/SEC130'
  558. else if Pos ('.text', Ref) > 0 then
  559. Result := 'gnuasm/SEC131'
  560. else if Pos ('.title', Ref) > 0 then
  561. Result := 'gnuasm/SEC132'
  562. else if Ref = 'Type,,COFF Version' then
  563. Result := 'gnuasm/SEC133'
  564. else if Pos ('.uleb128', Ref) > 0 then
  565. Result := 'gnuasm/SEC134'
  566. else if Pos ('.val', Ref) > 0 then
  567. Result := 'gnuasm/SEC135'
  568. else if Pos ('.vtable_entry', Ref) > 0 then
  569. Result := 'gnuasm/SEC135a'
  570. else if Pos ('.word', Ref) > 0 then
  571. Result := 'gnuasm/SEC136'
  572. else if Ref = 'Bug Criteria,,Have You Found a Bug?' then
  573. Result := 'Bug Criteria,,Have You Found a Bug'
  574. else
  575. Result := StringReplace (Ref, '/', '_', [rfReplaceAll]);
  576. if Pos (':', Result) > 0 then
  577. Delete (Result, Pos (':', Result), Length (Result));
  578. end;
  579. procedure PreProcessSource(var Source: string);
  580. begin
  581. Source := StringReplace (Source, '@value{AS}', 'as', [rfReplaceAll]);
  582. Source := StringReplace (Source, '@value{LD}', 'ld', [rfReplaceAll]);
  583. Source := StringReplace (Source, '@value{GCC}', 'gcc', [rfReplaceAll]);
  584. Source := StringReplace (Source, '@value{CPP}', 'cpp', [rfReplaceAll]);
  585. Source := StringReplace (Source, '''''', '"', [rfReplaceAll]);
  586. Source := StringReplace (Source, '``', '"', [rfReplaceAll]);
  587. Source := StringReplace (Source, '´´', '"', [rfReplaceAll]);
  588. end;
  589. procedure PostProcessDest(var Dest: string);
  590. var
  591. P,
  592. I: Integer;
  593. begin
  594. Dest := StringReplace (Dest, '<BR><BR>'#13#10'<BR><BR>', '<BR><BR>', [rfReplaceAll]);
  595. Dest := StringReplace (Dest, #13#10#13#10'<BR><BR>', #13#10'<BR><BR>', [rfReplaceAll]);
  596. Dest := StringReplace (Dest, '<BR><BR>'#13#10#13#10, '<BR><BR>'#13#10, [rfReplaceAll]);
  597. Dest := StringReplace (Dest, '<LI>'#13#10'</LI>'#13#10, '', [rfReplaceAll]);
  598. Dest := StringReplace (Dest, '<LI>'#13#10'<BR><BR>', '<LI>', [rfReplaceAll]);
  599. Dest := StringReplace (Dest, '<BR><BR>'#13#10'</LI>'#13#10'</UL>', '</LI>'#13#10'</UL>', [rfReplaceAll]);
  600. Dest := StringReplace (Dest, '<BR><BR>'#13#10'</LI>'#13#10'</OL>', '</LI>'#13#10'</OL>', [rfReplaceAll]);
  601. Dest := StringReplace (Dest, '<BR><BR>'#13#10'<PRE>', '<PRE>', [rfReplaceAll]);
  602. Dest := StringReplace (Dest, '<BR><BR>'#13#10'</PRE>', '</PRE>', [rfReplaceAll]);
  603. Dest := StringReplace (Dest, '</PRE>'#13#10'<BR><BR>', '</PRE>', [rfReplaceAll]);
  604. Dest := StringReplace (Dest, #13#10#13#10'</PRE>', #13#10'</PRE>', [rfReplaceAll]);
  605. Dest := StringReplace (Dest, '<BR><BR>'#13#10'<UL', '<UL', [rfReplaceAll]);
  606. Dest := StringReplace (Dest, '</UL>'#13#10'<BR><BR>', '</UL>', [rfReplaceAll]);
  607. Dest := StringReplace (Dest, '<BR><BR>'#13#10'<OL', '<OL', [rfReplaceAll]);
  608. Dest := StringReplace (Dest, '</OL>'#13#10'<BR><BR>', '</OL>', [rfReplaceAll]);
  609. Dest := StringReplace (Dest, '<BR><BR>'#13#10'<DL', '<DL', [rfReplaceAll]);
  610. Dest := StringReplace (Dest, '</DL>'#13#10'<BR><BR>', '</DL>', [rfReplaceAll]);
  611. Dest := StringReplace (Dest, '<BR><BR>'#13#10'</DL>', '</DL>', [rfReplaceAll]);
  612. Dest := StringReplace (Dest, '<DD><DT>', '<BR>', [rfReplaceAll]);
  613. P := Pos ('</CODE></A>', Dest);
  614. while P > 0 do begin
  615. Dest [P + 2] := 'A';
  616. Dest [P + 3] := '>';
  617. Dest [P + 4] := '<';
  618. Dest [P + 5] := '/';
  619. Dest [P + 6] := 'C';
  620. Dest [P + 7] := 'O';
  621. Dest [P + 8] := 'D';
  622. Dest [P + 9] := 'E';
  623. I := P - 1;
  624. while (I > 0) and (Copy (Dest, I, Length ('<CODE>')) <> '<CODE>') do
  625. Dec (I);
  626. if I > 0 then begin
  627. Delete (Dest, I, Length ('<CODE>'));
  628. Dec (I);
  629. while (I > 0) and (Dest [I] <> '<') do
  630. Dec (I);
  631. if I > 0 then
  632. Insert ('<CODE>', Dest, I);
  633. end;
  634. P := Pos ('</CODE></A>', Dest);
  635. end;
  636. Dest := StringReplace (Dest, '. ', '. ', [rfReplaceAll]);
  637. end;
  638. function CountChars(Ch: Char; S: string): Integer;
  639. var
  640. I: Integer;
  641. begin
  642. Result := 0;
  643. for I := 1 to Length (S) do
  644. if S [I] = Ch then
  645. Inc (Result);
  646. end;
  647. type
  648. TListType = (ltNone, ltNormal, ltColumns, ltFiles);
  649. var
  650. FullContents,
  651. NewContents,
  652. CurFile,
  653. CurNode,
  654. CurSection,
  655. CurSectionTitle,
  656. CurSubFile: string;
  657. P,
  658. SecStart,
  659. PreFormatted,
  660. SCase,
  661. CodeFormat: Integer;
  662. InsertedSeeAlso: Boolean = False;
  663. procedure ProcessSecID(var SecID: string);
  664. begin
  665. if (SecID = 'Overview') and (CurFile = 'cpp') then
  666. SecID := 'CPP Overview'
  667. else if (SecID = 'Conditionals') and (CurFile = 'gnuexts') then
  668. SecID := 'Conditional Extensions'
  669. else if (SecID = 'Variadic Macros') and (CurFile = 'gnuexts') then
  670. SecID := 'Variadic Macro Extensions'
  671. else if (SecID = 'Pragmas') and (CurFile = 'gnuexts') then
  672. SecID := 'Pragma Extensions'
  673. else if (SecID = 'Acknowledgements,,Acknowledgements') and (CurFile = 'gnuasm') then
  674. SecID := 'Acknowledgements,,GNU Assembler Acknowledgements';
  675. end;
  676. function GetLinkTo(Ref: string): string;
  677. begin
  678. ProcessSecID (Ref);
  679. Result := GetSecID (Ref);
  680. if StartsWith (CurFile + '/', Result, True, 1, True) then
  681. Result := '$$LINK(' + Result + ')'
  682. else
  683. Result := '$$INFOLINK(' + Result + ')';
  684. end;
  685. procedure FinishSection;
  686. var
  687. I: Integer;
  688. SecID,
  689. TempContents,
  690. S: string;
  691. begin
  692. SecID := CurNode;
  693. if (Length (CurSection) > 0) and (((CurFile <> 'cpp') and (CurFile <> 'gnuexts')) or (SecID = 'Extended Asm')) then
  694. SecID := SecID + ',,' + CurSection;
  695. ProcessSecID (SecID);
  696. SecID := GetSecID (SecID);
  697. if Length (CurSubFile) > 0 then
  698. SecID := SecID + '_' + StringReplace (CurSubFile, '/', ' and ', [rfReplaceAll]);
  699. TempContents := Copy (NewContents, SecStart, Length (NewContents));
  700. PostProcessDest (TempContents);
  701. TrimHTMLWhiteSpace (TempContents);
  702. if (Pos ('@code', CurSectionTitle) > 0) and (Pos ('.', CurSectionTitle) > 0) then begin
  703. Delete (CurSectionTitle, 1, Pos ('.', CurSectionTitle) - 1);
  704. for I := 3 to Length (CurSectionTitle) do
  705. if not (CurSectionTitle [I] in ['A'..'Z', 'a'..'z', '_', '.', '0'..'9', '[', ']']) then begin
  706. Delete (CurSectionTitle, I, Length (CurSectionTitle));
  707. Break;
  708. end;
  709. end;
  710. if Length (TempContents) > 0 then begin
  711. if Length (CurSubFile) > 0 then
  712. S := CurSubFile
  713. else
  714. S := CurSectionTitle;
  715. WriteFile (SecID + '.hss', '[Main]'#13#10'Title=' + S + #13#10#13#10'[Top]'#13#10 + TempContents + #13#10);
  716. end;
  717. SecStart := Length (NewContents) + 1;
  718. end;
  719. procedure StartSeeAlso;
  720. var
  721. I: Integer;
  722. begin
  723. I := Length (NewContents);
  724. while (I > 0) and (NewContents [I] in [#13, #10, ' ', #9]) do
  725. Dec (I);
  726. InsertedSeeAlso := True;
  727. if (I <= 0) or (NewContents [I] in ['.', '>']) then
  728. NewContents := NewContents + 'See '
  729. else if (NewContents [I] in [',', ';', ':', '(', '[', '{']) then
  730. NewContents := NewContents + 'see '
  731. else
  732. InsertedSeeAlso := False;
  733. end;
  734. procedure EndSeeAlso;
  735. begin
  736. if InsertedSeeAlso and (P <= Length (FullContents)) and (FullContents [P] = ',') then
  737. Inc (P);
  738. InsertedSeeAlso := False;
  739. end;
  740. procedure ConvertFromP(ListType: TListType = ltNone);
  741. var
  742. I,
  743. J: Integer;
  744. Tag,
  745. Parameters,
  746. Quotes,
  747. S: string;
  748. begin
  749. while P <= Length (FullContents) do begin
  750. if FullContents [P] = '}' then begin
  751. Inc (P);
  752. Break;
  753. end else if FullContents [P] = '{' then begin
  754. Inc (P);
  755. ConvertFromP (ListType);
  756. end else if FullContents [P] = #13 then begin
  757. while (Length (NewContents) > 0) and (NewContents [Length (NewContents)] = ' ') do
  758. Delete (NewContents, Length (NewContents), 1);
  759. if PreFormatted > 0 then begin
  760. NewContents := NewContents + #13#10;
  761. Inc (P);
  762. end else begin
  763. if (Copy (FullContents, P, 2) = #13#13) or (Copy (FullContents, P, 4) = #13#10#13#10) or (((Copy (FullContents, P, 2) = #13'@') or (Copy (FullContents, P, 3) = #13#10'@')) and (Pos ('{', Copy (FullContents, P, 25)) <= 0) and (Pos ('if', Copy (FullContents, P, 25)) <= 0)) then begin
  764. if Copy (NewContents, Length (NewContents) - 9, 10) <> '<BR><BR>'#13#10 then
  765. NewContents := NewContents + #13#10'<BR><BR>'#13#10;
  766. while (P <= Length (FullContents)) and (FullContents [P] in [#13, #10]) do
  767. Inc (P);
  768. end else begin
  769. if Copy (NewContents, Length (NewContents) - 1, 2) <> #13#10 then
  770. NewContents := NewContents + #13#10;
  771. Inc (P);
  772. end;
  773. end;
  774. end else if FullContents [P] = '@' then begin
  775. Inc (P);
  776. if P <= Length (FullContents) then begin
  777. if FullContents [P] in ['A'..'Z', 'a'..'z', '0'..'9'] then begin
  778. Tag := '';
  779. Parameters := '';
  780. Quotes := '';
  781. while (P <= Length (FullContents)) and (not (FullContents [P] in [#13, #10, ' ', '{'])) do begin
  782. Tag := Tag + FullContents [P];
  783. Inc (P);
  784. end;
  785. if (P <= Length (FullContents)) and (FullContents [P] = '{') then begin
  786. Inc (P);
  787. if (Tag = 'w')
  788. or (Tag = 'r')
  789. or (Tag = 'gccoptlist')
  790. or (Tag = 'key')
  791. or (Tag = 'value')
  792. or (Tag = 'copyrightnotice')
  793. or (Tag = 'covertexts')
  794. or (Tag = 'acronym')
  795. then
  796. Tag := ''
  797. else if (Tag = 'sc') then
  798. else if (Tag = 'anchor') then begin
  799. Tag := '';
  800. while (P <= Length (FullContents)) and (not (FullContents [P] in ['@', '{', '}'])) do
  801. Inc (P);
  802. end else if Tag = 'copyright' then begin
  803. Tag := '';
  804. NewContents := NewContents + '(c)';
  805. end else if Tag = 'TeX' then begin
  806. Tag := '';
  807. NewContents := NewContents + 'TeX';
  808. end else if Tag = 'equiv' then begin
  809. Tag := '';
  810. NewContents := NewContents + '&lt;=&gt;';
  811. end else if Tag = 'expansion' then begin
  812. Tag := '';
  813. NewContents := NewContents + 'expands to';
  814. end else if Tag = 'error' then begin
  815. Tag := '';
  816. NewContents := NewContents + 'Error:';
  817. end else if Tag = 'minus' then begin
  818. Tag := '';
  819. NewContents := NewContents + '<FONT FACE="Courier New">-</FONT>';
  820. end else if (Tag = 'dots') then begin
  821. Tag := '';
  822. NewContents := NewContents + '...';
  823. end else if (Tag = 'code') or (Tag = 'samp') or (Tag = 'command') or (Tag = 'file') or (Tag = 'math') or (Tag = 'env') or (Tag = 'kbd') or (Tag = 't') then begin
  824. if (Length (FullContents) >= P + 2) and (FullContents [P] = '-') and ((FullContents [P + 1] in ['A'..'Z', 'a'..'z', '0'..'9']) or ((FullContents [P + 1] = '-') and (FullContents [P + 2] in ['A'..'Z', 'a'..'z', '0'..'9']))) then begin
  825. Tag := 'B';
  826. Quotes := '''';
  827. end else
  828. Tag := 'CODE';
  829. end else if (Tag = 'strong') or (Tag = 'b') then
  830. Tag := 'B'
  831. else if (Tag = 'emph') or (Tag = 'var') or (Tag = 'i') then
  832. Tag := 'I'
  833. else if (Tag = 'dfn') then
  834. Tag := 'U'
  835. else if (Tag = 'option') then begin
  836. Tag := 'B';
  837. Quotes := '''';
  838. end else if (Tag = 'cite') then begin
  839. Tag := '';
  840. Quotes := '"';
  841. end else if (Tag = 'ref') or (Tag = 'xref') or (Tag = 'pxref') then begin
  842. Tag := 'A';
  843. I := Pos ('}', Copy (FullContents, P, 255));
  844. if I > 0 then begin
  845. while CountChars ('{', Copy (FullContents, P, I - 1)) > CountChars ('}', Copy (FullContents, P, I - 1)) do
  846. Inc (I);
  847. Parameters := 'HREF="' + GetLinkTo (Copy (FullContents, P, I - 1)) + '"';
  848. if ((Pos (',,', Copy (FullContents, P, 255)) > 0) or (Pos (','#13',', Copy (FullContents, P, 255)) > 0) or (Pos (','#13#10',', Copy (FullContents, P, 255)) > 0)) and (Pos ('{', Copy (FullContents, P, Pos (',', Copy (FullContents, P, 255)))) <= 0) then begin
  849. Delete (FullContents, P, Pos (',', Copy (FullContents, P, 255)));
  850. Delete (FullContents, P, Pos (',', Copy (FullContents, P, 255)));
  851. while FullContents [P] in [' ', #9, #13, #10] do
  852. Delete (FullContents, P, 1);
  853. end;
  854. StartSeeAlso;
  855. end;
  856. end else if (Tag = 'uref') then begin
  857. Tag := 'A';
  858. I := Pos ('}', Copy (FullContents, P, 255));
  859. if I > 0 then begin
  860. Parameters := 'HREF="' + Copy (FullContents, P, I - 1) + '"';
  861. StartSeeAlso;
  862. end;
  863. end else if (Tag = 'email') then begin
  864. Tag := 'A';
  865. I := Pos ('}', Copy (FullContents, P, 255));
  866. if I > 0 then
  867. Parameters := 'HREF="mailto:' + StringReplace (Copy (FullContents, P, I - 1), '@@', '@', []) + '"';
  868. end else if (Tag = 'footnote') then begin
  869. Tag := '';
  870. Quotes := '(';
  871. NewContents := NewContents + ' ';
  872. end else
  873. raise ESubStrNotFound.CreateFmt ('Unsupported style "%s"', [Tag]);
  874. if (Length (Tag) > 0) and (Tag <> 'sc') then begin
  875. NewContents := NewContents + '<' + Tag;
  876. if Length (Parameters) > 0 then
  877. NewContents := NewContents + ' ' + Parameters;
  878. NewContents := NewContents + '>' + Quotes;
  879. end;
  880. if Tag = 'sc' then
  881. Inc (SCase)
  882. else if Tag = 'CODE' then
  883. Inc (CodeFormat);
  884. ConvertFromP (ListType);
  885. if Tag = 'sc' then
  886. Dec (SCase)
  887. else if Tag = 'CODE' then
  888. Dec (CodeFormat);
  889. if Quotes = '(' then
  890. Quotes := ')';
  891. if (Length (Tag) > 0) and (Tag <> 'sc') then
  892. NewContents := NewContents + Quotes + '</' + Tag + '>';
  893. if Tag = 'A' then
  894. EndSeeAlso;
  895. end else begin
  896. while (P <= Length (FullContents)) and (FullContents [P] = ' ') do
  897. Inc (P);
  898. if Tag <> 'center' then begin
  899. while (P <= Length (FullContents)) and (not (FullContents [P] in [#13, #10])) do begin
  900. Parameters := Parameters + FullContents [P];
  901. Inc (P);
  902. end;
  903. while (P <= Length (FullContents)) and (FullContents [P] in [#13, #10]) do
  904. Inc (P);
  905. TrimWhiteSpace (Parameters);
  906. if (Tag = 'end') then begin
  907. Dec (P);
  908. if FullContents [P] = #10 then
  909. Dec (P);
  910. Break
  911. end else if (Tag = 'c')
  912. or (Tag = 'comment')
  913. or (Tag = 'set')
  914. or (Tag = 'setfilename')
  915. or (Tag = 'settitle')
  916. or (Tag = 'title')
  917. or (Tag = 'subtitle')
  918. or (Tag = 'cindex')
  919. or (Tag = 'kindex')
  920. or (Tag = 'opindex')
  921. or (Tag = 'findex')
  922. or (Tag = 'gol')
  923. or (Tag = 'noindent')
  924. or (Tag = 'need')
  925. or (Tag = 'page')
  926. or (Tag = 'setchapternewpage')
  927. or (Tag = 'finalout')
  928. or (Tag = 'printindex')
  929. or (Tag = 'syncodeindex')
  930. or (Tag = 'sp')
  931. or (Tag = 'author')
  932. or (Tag = 'vskip')
  933. or (Tag = 'top')
  934. or (Tag = 'refill')
  935. or (Tag = 'lowersections')
  936. or (Tag = 'raisesections')
  937. or (Tag = 'unnumbered')
  938. or (Tag = 'unnumberedsec')
  939. or (Tag = 'contents')
  940. or (Tag = 'defcodeindex')
  941. or (Tag = 'dircategory')
  942. or (Tag = 'tab')
  943. or (Tag = 'bye')
  944. or (Tag = 'insertcopying')
  945. then
  946. else if (Tag = 'node') then begin
  947. if not ((Parameters = 'Ln') and (CurNode = 'Line')) then begin
  948. FinishSection;
  949. CurNode := Parameters;
  950. CurSection := '';
  951. CurSectionTitle := Parameters;
  952. end;
  953. end else if (Tag = 'section') or (Tag = 'subsection') or (Tag = 'subsubsection') or (Tag = 'subheading') or (Tag = 'chapter') then begin
  954. if not ((CurNode = 'Line') and (Pos ('.ln', Parameters) > 0)) then begin
  955. FinishSection;
  956. CurSection := Parameters;
  957. CurSectionTitle := Parameters;
  958. end;
  959. end else if (Tag = 'ignore')
  960. or (Tag = 'tex')
  961. or (Tag = 'menu')
  962. or (Tag = 'direntry')
  963. or (Tag = 'copying')
  964. or ((Tag = 'ifset') and ((Parameters <> 'M68K') and (Parameters <> 'M680X0') and (Parameters <> 'COFF') and (Parameters <> 'W16') and (Parameters <> 'have-stabs') and (Parameters <> 'cppmanual')))
  965. then begin
  966. I := Length (NewContents) + 1;
  967. ConvertFromP (ListType);
  968. Delete (NewContents, I, Length (NewContents));
  969. end else if (Tag = 'group')
  970. or (Tag = 'ifset')
  971. or (Tag = 'ifclear')
  972. or (Tag = 'ifinfo')
  973. or (Tag = 'iftex')
  974. or (Tag = 'ifnottex')
  975. or (Tag = 'ifhtml')
  976. or (Tag = 'ifnothtml')
  977. or (Tag = 'macro')
  978. or (Tag = 'titlepage')
  979. or (Tag = 'quotation')
  980. or (Tag = 'display')
  981. or (Tag = 'detailmenu')
  982. or (Tag = 'html')
  983. then
  984. ConvertFromP (ListType)
  985. else if (Tag = 'example')
  986. or (Tag = 'smallexample')
  987. or (Tag = 'multitable')
  988. or (Tag = 'format')
  989. then begin
  990. NewContents := NewContents + '<PRE>';
  991. Inc (PreFormatted);
  992. ConvertFromP (ListType);
  993. Dec (PreFormatted);
  994. NewContents := NewContents + '</PRE>';
  995. end else if (Tag = 'table') or (Tag = 'ftable') or (Tag = 'vtable') then begin
  996. if CurFile = 'gnuexts' then begin
  997. S := NewContents;
  998. I := SecStart;
  999. SecStart := Length (NewContents) + 1;
  1000. ConvertFromP (ltFiles);
  1001. FinishSection;
  1002. CurSubFile := '';
  1003. SecStart := I;
  1004. NewContents := S;
  1005. end else begin
  1006. if ListType = ltColumns then
  1007. NewContents := NewContents + '<BR><BR>';
  1008. NewContents := NewContents + '<DL>'#13#10;
  1009. ConvertFromP (ltColumns);
  1010. NewContents := NewContents + '</DL>';
  1011. if ListType = ltColumns then
  1012. NewContents := NewContents + '<BR>';
  1013. end;
  1014. end else if (Tag = 'itemize') then begin
  1015. NewContents := NewContents + '<UL>'#13#10'<LI>'#13#10;
  1016. ConvertFromP (ltNormal);
  1017. NewContents := NewContents + '</LI>'#13#10'</UL>';
  1018. end else if (Tag = 'enumerate') then begin
  1019. NewContents := NewContents + '<OL';
  1020. if Length (Parameters) > 0 then begin
  1021. if Parameters [1] in ['0'..'9'] then
  1022. NewContents := NewContents + ' START="' + Parameters + '"'
  1023. else
  1024. NewContents := NewContents + ' TYPE="' + Parameters + '"';
  1025. end;
  1026. NewContents := NewContents + '>'#13#10'<LI>'#13#10;
  1027. ConvertFromP (ltNormal);
  1028. NewContents := NewContents + '</LI>'#13#10'</OL>';
  1029. end else if (Tag = 'item') or (Tag = 'itemx') then begin
  1030. case ListType of
  1031. ltNormal: begin
  1032. NewContents := NewContents + '</LI>'#13#10'<LI>'#13#10;
  1033. Insert (Parameters + #13#10, FullContents, P);
  1034. end;
  1035. ltColumns: begin
  1036. Parameters := HTMLize (Parameters);
  1037. I := Pos ('@', Parameters);
  1038. while I > 0 do begin
  1039. Delete (Parameters, I, 1);
  1040. if (Length (Parameters) >= I) and (Parameters [I] in ['A'..'Z', 'a'..'z']) then begin
  1041. if StartsWith ('var{', Parameters, True, I, True) then begin
  1042. J := Pos ('}', Copy (Parameters, I, Length (Parameters)));
  1043. if J > 0 then begin
  1044. Delete (Parameters, I + J - 1, 1);
  1045. Insert ('</I>', Parameters, I + J - 1);
  1046. Insert ('<I>', Parameters, I);
  1047. end;
  1048. end else begin
  1049. while (Length (Parameters) >= I) and (Parameters [I] <> '{') do
  1050. Delete (Parameters, I, 1);
  1051. if Length (Parameters) >= I then
  1052. Delete (Parameters, I, 1);
  1053. J := Pos ('}', Copy (Parameters, I, Length (Parameters)));
  1054. if J > 0 then
  1055. Delete (Parameters, I + J - 1, 1);
  1056. end;
  1057. end;
  1058. I := Pos ('@', Parameters);
  1059. end;
  1060. NewContents := NewContents + '<DT><B>' + Parameters + '</B>'#13#10'<DD>';
  1061. end;
  1062. ltFiles: begin
  1063. if P > SecStart + 5 then begin
  1064. if Length (CurSubFile) > 0 then
  1065. FinishSection;
  1066. CurSubFile := Parameters;
  1067. if Pos ('__builtin_', CurSubFile) > 0 then
  1068. Delete (CurSubFile, 1, Pos ('__builtin_', CurSubFile) - 1);
  1069. if Pos (' ', CurSubFile) > 0 then
  1070. Delete (CurSubFile, Pos (' ', CurSubFile), Length (CurSubFile));
  1071. end;
  1072. end else
  1073. Insert (Parameters, FullContents, P);
  1074. end;
  1075. end else if (Tag = 'exdent') then
  1076. Insert (Parameters, FullContents, P)
  1077. else if (Tag = 'deftypefn') then begin
  1078. S := NewContents;
  1079. I := SecStart;
  1080. SecStart := Length (NewContents) + 1;
  1081. CurSubFile := Parameters;
  1082. if Pos ('__builtin_', CurSubFile) > 0 then
  1083. Delete (CurSubFile, 1, Pos ('__builtin_', CurSubFile) - 1);
  1084. if Pos (' ', CurSubFile) > 0 then
  1085. Delete (CurSubFile, Pos (' ', CurSubFile), Length (CurSubFile));
  1086. ConvertFromP;
  1087. FinishSection;
  1088. CurSubFile := '';
  1089. SecStart := I;
  1090. NewContents := S;
  1091. end else if (Tag = 'include') then begin
  1092. if FileExists (Parameters) or ((Parameters <> 'asconfig.texi') and (Parameters <> 'md.texi') and (Copy (Parameters, 1, 2) <> 'c-')) then begin
  1093. S := LoadFile (Parameters);
  1094. PreProcessSource (S);
  1095. Insert (S, FullContents, P);
  1096. end;
  1097. end else
  1098. raise ESubStrNotFound.CreateFmt ('Unsupported command "%s"', [Tag]);
  1099. end;
  1100. end;
  1101. end else begin
  1102. if FullContents [P] <> ':' then
  1103. NewContents := NewContents + HTMLizeChar (FullContents [P]);
  1104. Inc (P);
  1105. end;
  1106. end;
  1107. end else begin
  1108. if FullContents [P] <> #10 then begin
  1109. if FullContents [P] in [' ', #13, #9] then begin
  1110. if ((Copy (NewContents, Length (NewContents) - 1, 2) = 'eg') or (Copy (NewContents, Length (NewContents) - 1, 2) = 'ie')) and (Length (NewContents) > 2) and (NewContents [Length (NewContents) - 2] in [' ', #13, #9, '(', '[', '{']) then begin
  1111. Insert ('.', NewContents, Length (NewContents));
  1112. NewContents := NewContents + '.';
  1113. end;
  1114. end;
  1115. if SCase > 0 then
  1116. NewContents := NewContents + HTMLizeChar (UpCase (FullContents [P]))
  1117. else if FullContents [P] in ['´', '`'] then
  1118. NewContents := NewContents + ''''
  1119. else if (FullContents [P] in ['-']) and (Copy (NewContents, Length (NewContents) - 1, 2) = '--') then begin
  1120. NewContents := NewContents + ' ';
  1121. NewContents [Length (NewContents) - 2] := ' ';
  1122. end else if (FullContents [P] = ' ') and (CodeFormat > 0) then
  1123. NewContents := NewContents + '&nbsp;'
  1124. else
  1125. NewContents := NewContents + HTMLizeChar (FullContents [P]);
  1126. end;
  1127. Inc (P);
  1128. end;
  1129. end;
  1130. end;
  1131. begin
  1132. if Pos ('invoke', ParamStr (1)) > 0 then
  1133. CurFile := 'comopts'
  1134. else if Pos ('as', ParamStr (1)) > 0 then
  1135. CurFile := 'gnuasm'
  1136. else if Pos ('cpp', ParamStr (1)) > 0 then
  1137. CurFile := 'cpp'
  1138. else if Pos ('extend', ParamStr (1)) > 0 then
  1139. CurFile := 'gnuexts'
  1140. else
  1141. CurFile := WithoutExt (ParamStr (1));
  1142. FullContents := LoadFile (ParamStr (1));
  1143. PreProcessSource (FullContents);
  1144. NewContents := '<HTML><BODY>'#13#10;
  1145. try
  1146. CurNode := CurFile;
  1147. CurSection := '';
  1148. CurSectionTitle := '';
  1149. CurSubFile := '';
  1150. P := 1;
  1151. SecStart := Length (NewContents) + 1;
  1152. PreFormatted := 0;
  1153. SCase := 0;
  1154. CodeFormat := 0;
  1155. ConvertFromP;
  1156. if P <= Length (FullContents) then
  1157. raise ESubStrNotFound.Create ('Unexpected closing bracket');
  1158. FinishSection;
  1159. finally
  1160. NewContents := NewContents + #13#10'</BODY></HTML>';
  1161. PostProcessDest (NewContents);
  1162. WriteFile (ChangeFileExt (ParamStr (1), '.html'), NewContents);
  1163. end;
  1164. end.