From 007f372a86653605d72852e22dcd423d0276786c Mon Sep 17 00:00:00 2001 From: ru Date: Wed, 18 Jun 2003 13:01:08 +0000 Subject: Removed files not present in v4.6 import. --- contrib/texinfo/COPYING.DOC | 397 -------------------------------------------- 1 file changed, 397 deletions(-) delete mode 100644 contrib/texinfo/COPYING.DOC (limited to 'contrib/texinfo') diff --git a/contrib/texinfo/COPYING.DOC b/contrib/texinfo/COPYING.DOC deleted file mode 100644 index 32a6b2f..0000000 --- a/contrib/texinfo/COPYING.DOC +++ /dev/null @@ -1,397 +0,0 @@ - GNU Free Documentation License - Version 1.2, November 2002 - - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document "free" in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The "Document", below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as "you". You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section "Entitled XYZ" means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as "Acknowledgements", -"Dedications", "Endorsements", or "History".) To "Preserve the Title" -of such a section when you modify the Document means that it remains a -section "Entitled XYZ" according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section Entitled "History", Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section to be Entitled "Endorsements" - or to conflict in title with any Invariant Section. -O. Preserve any Warranty Disclaimers. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled "History" -in the various original documents, forming one section Entitled -"History"; likewise combine any sections Entitled "Acknowledgements", -and any sections Entitled "Dedications". You must delete all sections -Entitled "Endorsements". - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an "aggregate" if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warrany Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled "Acknowledgements", -"Dedications", or "History", the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. -- cgit v1.1 From 212fa58b27874a1ac997e85e3f696ffad810e44c Mon Sep 17 00:00:00 2001 From: ru Date: Mon, 23 May 2005 10:46:22 +0000 Subject: Import of stripped down GNU texinfo 4.8 --- contrib/texinfo/AUTHORS | 13 +- contrib/texinfo/ChangeLog | 14597 ++++++++------------------------ contrib/texinfo/ChangeLog.46 | 12516 +++++++++++++++++++++++++++ contrib/texinfo/INSTALL | 26 +- contrib/texinfo/INTRODUCTION | 2 +- contrib/texinfo/NEWS | 108 +- contrib/texinfo/README | 7 +- contrib/texinfo/README.dev | 44 + contrib/texinfo/TODO | 135 +- contrib/texinfo/config.h.in | 92 +- contrib/texinfo/doc/README | 2 +- contrib/texinfo/doc/info-stnd.texi | 81 +- contrib/texinfo/doc/info.1 | 28 +- contrib/texinfo/doc/info.5 | 2 +- contrib/texinfo/doc/info.texi | 369 +- contrib/texinfo/doc/infokey.1 | 41 + contrib/texinfo/doc/install-info.1 | 20 +- contrib/texinfo/doc/makeinfo.1 | 35 +- contrib/texinfo/doc/texindex.1 | 10 +- contrib/texinfo/doc/texinfo.5 | 2 +- contrib/texinfo/doc/texinfo.txi | 8507 +++++++++++-------- contrib/texinfo/doc/version-stnd.texi | 8 +- contrib/texinfo/doc/version.texi | 8 +- contrib/texinfo/info/README | 2 +- contrib/texinfo/info/dir.c | 28 +- contrib/texinfo/info/display.c | 115 +- contrib/texinfo/info/display.h | 19 +- contrib/texinfo/info/doc.c | 224 +- contrib/texinfo/info/doc.h | 32 +- contrib/texinfo/info/dribble.c | 11 +- contrib/texinfo/info/dribble.h | 8 +- contrib/texinfo/info/echo-area.c | 155 +- contrib/texinfo/info/echo-area.h | 53 +- contrib/texinfo/info/filesys.c | 85 +- contrib/texinfo/info/filesys.h | 28 +- contrib/texinfo/info/footnotes.c | 25 +- contrib/texinfo/info/footnotes.h | 6 +- contrib/texinfo/info/funs.h | 224 +- contrib/texinfo/info/gc.c | 13 +- contrib/texinfo/info/gc.h | 8 +- contrib/texinfo/info/indices.c | 83 +- contrib/texinfo/info/indices.h | 19 +- contrib/texinfo/info/info-utils.c | 197 +- contrib/texinfo/info/info-utils.h | 41 +- contrib/texinfo/info/info.c | 100 +- contrib/texinfo/info/info.h | 20 +- contrib/texinfo/info/infodoc.c | 161 +- contrib/texinfo/info/infokey.c | 160 +- contrib/texinfo/info/infokey.h | 2 +- contrib/texinfo/info/infomap.c | 154 +- contrib/texinfo/info/infomap.h | 13 +- contrib/texinfo/info/key.c | 4 +- contrib/texinfo/info/m-x.c | 21 +- contrib/texinfo/info/man.c | 83 +- contrib/texinfo/info/man.h | 18 +- contrib/texinfo/info/nodemenu.c | 38 +- contrib/texinfo/info/nodes.c | 155 +- contrib/texinfo/info/nodes.h | 17 +- contrib/texinfo/info/search.c | 108 +- contrib/texinfo/info/search.h | 30 +- contrib/texinfo/info/session.c | 649 +- contrib/texinfo/info/session.h | 193 +- contrib/texinfo/info/signals.c | 62 +- contrib/texinfo/info/signals.h | 11 +- contrib/texinfo/info/termdep.h | 2 +- contrib/texinfo/info/terminal.c | 67 +- contrib/texinfo/info/terminal.h | 40 +- contrib/texinfo/info/tilde.c | 26 +- contrib/texinfo/info/tilde.h | 12 +- contrib/texinfo/info/variables.c | 20 +- contrib/texinfo/info/variables.h | 11 +- contrib/texinfo/info/window.c | 132 +- contrib/texinfo/info/window.h | 82 +- contrib/texinfo/lib/README | 2 +- contrib/texinfo/lib/gettext.h | 17 +- contrib/texinfo/lib/substring.c | 10 +- contrib/texinfo/lib/system.h | 93 +- contrib/texinfo/lib/xalloc.h | 103 +- contrib/texinfo/lib/xexit.c | 7 +- contrib/texinfo/lib/xmalloc.c | 41 +- contrib/texinfo/lib/xstrdup.c | 13 +- contrib/texinfo/makeinfo/README | 2 +- contrib/texinfo/makeinfo/cmds.c | 1012 ++- contrib/texinfo/makeinfo/cmds.h | 168 +- contrib/texinfo/makeinfo/defun.c | 396 +- contrib/texinfo/makeinfo/defun.h | 6 +- contrib/texinfo/makeinfo/files.c | 407 +- contrib/texinfo/makeinfo/files.h | 45 +- contrib/texinfo/makeinfo/float.c | 430 + contrib/texinfo/makeinfo/float.h | 56 + contrib/texinfo/makeinfo/footnote.c | 58 +- contrib/texinfo/makeinfo/footnote.h | 13 +- contrib/texinfo/makeinfo/html.c | 591 +- contrib/texinfo/makeinfo/html.h | 32 +- contrib/texinfo/makeinfo/index.c | 432 +- contrib/texinfo/makeinfo/index.h | 65 +- contrib/texinfo/makeinfo/insertion.c | 1076 ++- contrib/texinfo/makeinfo/insertion.h | 46 +- contrib/texinfo/makeinfo/lang.c | 393 +- contrib/texinfo/makeinfo/lang.h | 66 +- contrib/texinfo/makeinfo/macro.c | 146 +- contrib/texinfo/makeinfo/macro.h | 38 +- contrib/texinfo/makeinfo/makeinfo.c | 1705 ++-- contrib/texinfo/makeinfo/makeinfo.h | 116 +- contrib/texinfo/makeinfo/multi.c | 513 +- contrib/texinfo/makeinfo/multi.h | 28 + contrib/texinfo/makeinfo/node.c | 334 +- contrib/texinfo/makeinfo/node.h | 28 +- contrib/texinfo/makeinfo/sectioning.c | 406 +- contrib/texinfo/makeinfo/sectioning.h | 61 +- contrib/texinfo/makeinfo/toc.c | 286 +- contrib/texinfo/makeinfo/toc.h | 17 +- contrib/texinfo/makeinfo/xml.c | 1915 +++-- contrib/texinfo/makeinfo/xml.h | 113 +- contrib/texinfo/makeinfo/xref.c | 620 ++ contrib/texinfo/makeinfo/xref.h | 30 + contrib/texinfo/util/README | 2 +- contrib/texinfo/util/install-info.c | 295 +- contrib/texinfo/util/texindex.c | 241 +- 119 files changed, 31792 insertions(+), 21102 deletions(-) create mode 100644 contrib/texinfo/ChangeLog.46 create mode 100644 contrib/texinfo/README.dev create mode 100644 contrib/texinfo/doc/infokey.1 create mode 100644 contrib/texinfo/makeinfo/float.c create mode 100644 contrib/texinfo/makeinfo/float.h create mode 100644 contrib/texinfo/makeinfo/multi.h create mode 100644 contrib/texinfo/makeinfo/xref.c create mode 100644 contrib/texinfo/makeinfo/xref.h (limited to 'contrib/texinfo') diff --git a/contrib/texinfo/AUTHORS b/contrib/texinfo/AUTHORS index 1c5bfad..ce8ee85 100644 --- a/contrib/texinfo/AUTHORS +++ b/contrib/texinfo/AUTHORS @@ -1,26 +1,31 @@ -$Id: AUTHORS,v 1.5 2003/05/08 00:51:55 karl Exp $ +$Id: AUTHORS,v 1.10 2004/04/11 17:56:45 karl Exp $ Texinfo authors. + Copyright (C) 2003 Free Software Foundation, Inc. + Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. Akim Demaille texi2dvi. +Alper Ersoy makeinfo: enhancements in all files, especially + html-, xml-, and docbook-related. Andreas Schwab texinfo.tex, configure.ac, most makeinfo files. Bob Chassell texinfo.tex, original texinfo.txi. Brian Fox all makeinfo/* and info/* files, info-stnd.texi. Dave Love original makeinfo/html.[ch]. Eli Zaretskii all files. Karl Berry all files. +Karl Heinz Marbaise original makeinfo language support, most files. Noah Friedman original texi2dvi. Paul Rubin original makeinfo/multi.c. Philippe Martin original makeinfo xml/docbook output. Richard Stallman original texinfo.tex, install-info.c, texindex.c, texinfo.txi. -Zack Weinberg texinfo.tex (@macro implementation). +Zack Weinberg texinfo.tex: @macro implementation. See http://www.iro.umontreal.ca/contrib/po/HTML/team-LL.html for the translation teams for a given language LL. -Many files included in Texinfo distribution are copied from other -locations. See util/srclist*. +Many files included in the Texinfo distribution are copied from other +locations, no author information is given for those. See util/srclist*. diff --git a/contrib/texinfo/ChangeLog b/contrib/texinfo/ChangeLog index fbbaff6..7c53a09 100644 --- a/contrib/texinfo/ChangeLog +++ b/contrib/texinfo/ChangeLog @@ -1,12504 +1,4999 @@ -2003-06-10 - - * version 4.6. - -2003-06-04 - - * config.sub: update from gnulib. - -2003-06-03 - - * mkinstalldirs: update from gnulib. - -2003-06-02 Akim Demaille +2004-12-31 Karl Berry - * util/texi2dvi (tex_envvars): New. - Use it to forward -I directories to BIBINPUTS and BSTINPUTS, in - addition of INDEXSTYLE and TEXINPUTS. + * Version 4.8. -2003-06-02 +2004-12-21 Karl Berry - * makeinfo/html.c (html_output_head): don't output the , to - avoid having mozilla put up a document navigation bar when - we don't have anything else to support it yet. Report from: - Per Bothner. - * makeinfo/makeinfo.c: no need to declare add_link or - add_escaped_anchor_name, since they are not used. + * pretest version 4.7.94. - * doc/texinfo.txi (Contents): recommend @contents at the beginning - more strongly. Suggestions from Kevin Ryde. + * makeinfo/xref.c: doc fix. -2003-06-01 +2004-12-20 Karl Berry - * makeinfo/macro.c (apply): make \\ expand to \ even if the macro - has no arguments. Report from: Jesper Harder , - 31 May 2003 02:56:20 +0200. + * makeinfo/html.c (cm_node) : need old-style names in the normal + (not no_headers) html case, too, of course. + (add_html_names): canon_white the new name, too. -2003-05-31 +2004-12-19 Karl Berry - * util/dir-example (C++ libraries): new category, suggested by Bruno. + * pretest version 4.7.93. -2003-05-29 + * automake 1.9.4. - * configure.ac: pretest version 4.5.93. + * makeinfo/xml.c (try_docbook_image): new fn. + (xml_insert_docbook_image): call it, trying additional formats + pdf, svg, etc. + * makeinfo/makeinfo.c (cm_image): check for gif too. + http://www.gnu.org/philosophy/gif.html says: + "we can and will include support for displaying GIF files in GNU + software." Leaving it undocumented, though. + Based on patch from Jens Elkner, 18 Dec 2004 01:56:28 +0100. -2003-05-29 gettextize +2004-12-19 Torsten Bronger - * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.12.1. + * util/texinfo.dtd: define most entities, add . -2003-05-26 +2004-12-17 Juan M. Guerrero - * util/texi2dvi: spurious \ in tex_args assignment. + * djgpp/config.bat: remove files like coXXXXXX.tmp created + in the top_srcdir by the gl_FUNC_MKSTEMP test. - * doc/texinfo.txi (Contents): trim excess words. +2004-12-15 Karl Berry -2003-05-25 + * pretest version 4.7.92. - * util/texi2dvi: extra quotes for the tex_args assignment in - --batch mode. + * util/texinfo.dtd: merge with makeinfo/texinfo.dtd. + * makeinfo/texinfo.dtd, makeinfo/texinfo.xsl: remove. -2003-05-19 +2004-12-15 Stepan Kasal - * lib/xexit.c: translate fflush error messages, add newlines - (report from Jim Meyering). - * util/{texindex.c,install-info.c}, - * makeinfo/makeinfo.c, - * info/info.c: use xexit again, with redundant return to avoid - warnings. + * Makefile.am (EXTRA_DIST): Removed po/Makevars.template, sorry. -2003-05-18 +2004-12-15 Juan M. Guerrero - * lib/xexit.c (xexit): fputs not fprintf, so we get newline; - translate the messages, too. Report from Jim Meyering. + * djgpp/config.sed: adjust for new autoconf. + * makeinfo/node.c (enumerate_filename): make dos_file_names const + instead of static, since it may involve a fn call to pathconf. - * util/dir-example: move gcc/automake entries. +2004-12-15 Karl Berry - * pretest version 4.5.92. + * Makefile.am (EXTRA_DIST): include ChangeLog.46, README.dev, + and po/Makevars.template. From Stepan. - * update to automake 1.7.5. +2004-12-14 Karl Berry - * makeinfo/html.c (append_char): forgot to increment length, duh. - Report from: "Torsten Bronger" , - 18 May 2003 14:36:23 +0200. + * doc/texinfo.txi (inforef): try to explain possible uses more + thoroughly. + From: Luc Teirlinck, 13 Dec 2004 21:45:58 -0600. -2003-05-17 + * doc/texinfo.txi (pxref): more explanation. + * doc/info-stnd.texi (Basic Windows): put pxref in parens. + help-texinfo mail from adl, 13 Dec 2004 17:07:50 +0100. - * makeinfo/makeinfo.c (defining_copying): new fn. - (add_char): call it, when testing if we should - call html_output_head. - Report from: Torsten Bronger , - 17 May 2003 22:10:42 +0200. +2004-12-13 Andreas Schwab - * configure.ac: pretest version 4.5.91. + * info/echo-area.c (DECLARE_INFO_COMMAND): Add intermediate cast + to avoid warning. + * info/infokey.c (compile): Likewise. + * info/session.c (forward_move_node_structure): Likewise. + (DECLARE_INFO_COMMAND): Likewise. -2003-05-16 + * makeinfo/makeinfo.c (init_paragraph): Don't use free_and_clear + to avoid strict aliasing issue. - * makeinfo/index.c (sort_index): don't deref NULL. Report from Jan. + * makeinfo/cmds.c (cm_center): Avoid strict aliasing issue. -2003-05-13 +2004-12-13 Karl Berry - * makeinfo/html.c (append_char): appease sgi compiler. - * makeinfo/html.c (insert_html_tag): remove spurious arg to pop_tag, - From: ezra peisach , 13 - May 2003 12:13:40 -0400. + * doc/texinfo.txi (HTML Cross-reference Command Expansion): add + @euro{} -> U+20AC. texinfo-pretest mail from Patrice, + 12 Dec 2004 23:49:50 +0100. - Fix a few GCC warnings, reported by Jim Meyering: +2004-12-12 Karl Berry - * info/nodes.c: parenthesize assignment used as truth value. - * info/nodemenu.c (format_node_info): strcpy instead of sprintf, - since there's no format. - * makeinfo/makeinfo.c (isolate_nodename): remove spurious decl. - * makeinfo/xml.c (xml_insert_indexterm): declare as void. - * info/key.c: initialize with 0,0 at end. - * info/infokey.c (main): return instead of xexit, and remove - unused variable. - * makeinfo/html.c (init_buffer): forgot to return buf. - * info/info.c (remember_info_program_name): remove spurious - declaration. - - * makeinfo/sectioning.c, - * info/infomap.c: remove unused variables. - - * makeinfo/makeinfo.c (insert_toplevel_subdirectory), - * info/man.c, - * info/infodoc.c (info_find_or_create_help_window): parenthesize - && within ||. - * info/display.c (display_update_one_window): initialize rep to - NULL, parenthesize && within ||. - - * util/install-info.c, - * info/info.c (main), - * info/makedoc.c (main): return instead of xexit. + * doc/texinfo.txi (makeinfo options): don't be so suggestive about + skipping xref validation. + emacs-devel mail from: Luc Teirlinck, 12 Dec 2004 13:02:11 -0600. -2003-05-13 Akim Demaille +2004-12-08 Karl Berry - * util/texi2dvi (get_xref_files): Pass --file-line-error-style - to TeX when supported. + * pretest version 4.7.91. -2003-05-12 + * info/echo-area.c, info/infokey.c, info/session.c: omit useless + casts to intptr_t, since we're just casting to (void *) next. + intptr_t is not defined with gcc 3.04 on Tru64 Unix V5.1 + (This whole vararg stuff needs to be redone correctly.) + Report from: Svend Tollak Munkejord (via te) + 8 Dec 2004 17:15:17 +0100. - * configure.ac: pretest version 4.5.90. + * doc/texinfo.txi (ref): rewrite last two redundant paragraphs. - * Makefile.am (EXTRA_DIST): add onceonly.m4. +2004-12-07 Karl Berry - * makeinfo/tests/accentenc: must discard stderr since we expect - two errors in this case. + * doc/texinfo.txi (Macro Details): document @c kludge in macro + definitions to work around some newline problems. (From Werner.) - * makeinfo/makeinfo.c (main): new option --css-include. - (usage): add to --help message. - * makeinfo/makeinfo.h (css_include): new global. - * makeinfo/html.c (append_char, process_css_file): new fns - implementing it. - (html_output_head): call it. - * doc/texinfo.txi (HTML CSS): new node describing it. - Also split up the Generating HTML node into subnodes. +2004-12-05 Karl Berry - * config.{guess,sub}: update from gnulib. + * makeinfo/html.c (add_escaped_anchor_name): prefix g_t if the + nodename begins with a nonletter. Ugh. + * doc/texinfo.txi (HTML Xref Node Name Expansion): document this. + http://ff0.org/pipermail/texinfo-pretest/2004-December/000210.html + + * doc/texinfo.txi (HTML Xref 8-bit Character Expansion): define + behavior for Unicode code points above 0xfff. -2003-05-10 + * makeinfo/makeinfo.c (reader_loop): didn't make it into + HTML 4, remove it. Sigh. + texinfo-pretest mail from wl, 05 Dec 2004 23:39:05 +0100. - * makeinfo/index.c (sort_index): allocate the sorted index in new - memory, and set the original index to that, to avoid problems with - @printindex being called twice on the same index. - (cm_printindex): do not free the returned index. - Report from: Dumas Patrice , 9 May 2003 - 15:12:21 +0200. +2004-12-02 Karl Berry -2003-05-09 + * configure.ac (install-warnings): simplify default case. From te. - * makeinfo/defun.c (cm_defun): issue error message without extra - x's. Report from: Dumas Patrice , 9 May - 2003 17:24:25 +0200. +2004-12-01 Karl Berry -2003-05-07 Akim Demaille + * pretest version 4.7.90. - * util/texi2dvi (textra_cmd): New. - (textra): Escape escapes from sed's evaluation. - Use them to support additional TeX/LaTeX commands. - Support --command as a synonym for --texinfo. + * util/texi2dvi (recode): new option, off by default. + Unconditionally calling recode seems problematic, when there + hasn't been a release for years and its Texinfo support is less than + perfect. -2003-05-06 +2004-11-30 Karl Berry - * util/dir-example: finish getting rid of GNU packages. + * doc/texinfo.txi (Quotations and Examples): @quotation does not + reduce interparagraph spacing. + + * makeinfo/node.c (cm_node) : do not bother calling + add_html_nodes in the split case, the filename is wrong. -2003-05-04 +2004-11-29 Karl Berry - * doc/texinfo.tex (\itemizey): if no arg to @itemize, default to - @bullet. Fix from: Stepan Kasal 2 May 2003 - 09:32:11 +0200, report from: Jesper Harder . + Support for writing using the old-style node name + to HTML name conversion, to keep the gcc folks happy. + * makeinfo/node.c (add_html_names): new routine, factoring out + common code (plus new code) from cm_node. + (cm_node) : call it. + * makeinfo/makeinfo.h (OLD_HTML_SAFE, OLD_URL_SAFE_CHAR): + (re)define these. + * makeinfo/html.c (add_escaped_anchor_name): take new argument to + optionally output the old-style conversion. + (add_anchor_name): change call. + * index.c: change calls. + * makeinfo/html.h (add_escaped_anchor_name): change decl. -2003-04-30 +2004-11-26 Karl Berry - * makeinfo/.gdbinit: no colon on local variables. + * makeinfo/makeinfo.c (reader_loop): allow after — - * doc/texinfo.txi (documentencoding): Document new Info output feature. - makeinfo/lang.h (encoding_type): rename `ecname' member to `encname'. - makeinfo/html.c, lang.c: change usage. - makeinfo/lang.c (cm_documentencoding): fix typo in warning. - makeinfo/makeinfo.h (SPLIT_SIZE_THRESHOLD): remove. - (info_trailer): declare. - makeinfo/makeinfo.c (info_trailer): new fn to generate Local - Variables: section if --enable-encoding and - @documentencoding are given. - (convert_from_loaded_file): call it. - * makeinfo/node.c (split_file): write trailer into each split - file. Also, simply split files if file size is less than - --split-size, removing SPLIT_SIZE_THRESHOLD. - - * doc/texinfo.tex: remove trailing whitespace. - -2003-04-29 - - * makeinfo/node.c (cm_anchor): normalize_node_name so that an - anchor named "TOP" or "top" or whatever is not allowed. Report - from: Dumas Patrice , 29 Apr 2003 18:56:51 - +0200. +2004-11-25 Karl Berry -2003-04-28 + * doc/texinfo.txi (Fonts): document new command @sansserif. + * doc/texinfo.tex (\sansserif): new command. + * makeinfo/cmds.h (cm_sansserif): new cmd. + * makeinfo/cmds.c (cm_sansserif): new cmd. + (command_table): add it. + * makeinfo/texinfo.dtd (Inline.fonts): add it; also slanted. + * makeinfo/xml.h (SANSSERIF, SLANTED): define these new elements. + * makeinfo/xml.c (texinfoml_element_list): add them. + From: Frank Küster, 21 Oct 2004 23:27:33 +0200, Debian bug#277754. - * makeinfo/makeinfo.c: whitespace cleanup. + * doc/texinfo.txi (Quotations and Examples, end titlepage): state + that there must be only one space between the @end and its + argument. Report from: christoph.sobotka, 26 Oct 2004 22:04:03 +0200. - * doc/texinfo.tex (\doprintindex): don't \kern-\parindent, it makes - the first index entry stick out to the left. - Report from: Jesper Harder , - 28 Apr 2003 03:10:36 +0200. +2004-11-22 Karl Berry - From Akim Demaille : - * makeinfo/makeinfo.c (cm_value): Warn for undefined flags. + * doc/texinfo.txi (euro): new node, documenting new command, + @euro{}, for the Euro currency symbol. + * doc/texinfo.tex (\euro): new command, along with \eurofont to + support it. The following extra font support is also related to + supporting @euro{}: + (\bfstylename): define this. + (\textnominalsize .. \ssecnominalsize): new macros. + (\textfonts .. \ssecfonts): define \curfontsize. + * makeinfo/cmds.c (command_table): add euro. + * makeinfo/lang.c (cm_special_char): handle euro. + (iso8859_15_map): new global. -2003-04-27 +2004-11-18 Stepan Kasal - * doc/texinfo.tex (\footnote, \smartitalicx): use \ptexslash - for italic correction instead of \/, since we've redefined \/ now. - Report from: Jesper Harder , 27 Apr 2003 - 23:30:29 +0200. + * doc/texinfo.tex (\ptexnewwrite): Save \newwrite. + (\newwrite): Call it. - * util/dir-example (mailutils): more from Wojciech Polak. - (autoconf): align/edit/sort entries. +2004-11-17 Karl Berry -2003-04-26 + * configure.ac (install-warnings): new --enable option, requested + by te. - * doc/texinfo.txi (Image Syntax): second and following @image args - optional. Report from: Max Techter , 26 Apr 2003 - 15:50:02 +0200. +2004-11-11 Karl Berry - * util/dir-example (anubis): request from Wojciech Polak. + * texinfo.dtd (metainformation): add documentdescription. + (documentdescription): define. + * xml.h (DOCUMENTDESCRIPTION): new value for xml_element. + * xml.c (texinfoml_element_list): define documentdescription. + (docbook_element_list): likewise, but don't know how to handle it. + * cmds.c (cm_documentdescription): insert opening xml tag. + * insertion.c (end_insertion): insert closing xml tag. -2003-04-25 + * makeinfo/makeinfo.c (insert_string): declare const char * arg. + * makeinfo/makeinfo.h: likewise. + Report from: Vincent Lefevre, 20 Oct 2004 15:40:39 +0200, + noting a spurious after . - * makeinfo/defun.c (defun_internal): whitespace needed in docbook - output for deftype*. From: José Fonseca - , 25 Apr 2003 13:07:13 +0100. +2004-11-08 Karl Berry -2003-04-21 + * doc/texinfo.tex (\pdfmakeoutlines): in the first run through the + toc, define \thischapnum...\thissubsecnum as 0, rather than \empty. + This is so \expnumber doesn't end up trying to expand + \csname sec\empty\endcsname, i.e., \sec, which is the secant function. + Report from: Oliver Beck, help-texinfo, 8 Nov 2004 08:05:55 +0100. - * doc/texinfo.tex (\dofirstparagraphindent): forgot to rename the - \...word's. - (\suppressfirstparagraphindent): forgot to rename - to \dosuppress... Reported by Simon. +2004-11-07 Karl Berry -2003-04-20 + * makeinfo/makeinfo.c (main) [LC_MESSAGES]: #ifdef the setlocale + using LC_MESSAGES. From te, 6 Nov 2004 23:36:10 +0100. - * Installed changes from Simon for suppressing indentation on the - first paragraph after section headings, and for new @indent command: +2004-11-06 Karl Berry - 2003-04-12 Simon Law - * doc/texinfo.tex (\firstparagraphindent): implement suppression - of the indentation of the first paragraph. - (\dofirstparagraphindent): for parsing arguments. - (\suppressfirstparagraphindent): suppress, or don't suppress. - (\dosuppressfirstparagraphindent): the actual gobbling of indentation. - (\footnote): Compensate for the hanging-indent side-effect. - (\numhead, \apphead, \unnmhead): call \dosuppress... - * makeinfo/cmds.c (command_table): add "firstparagraphindent" - (as cm_firstparagraphindent) - (set_firstparagraphindent, cm_firstparagraphindent): implement - @firstparagraphindent parsing of options. - * makeinfo/makeinfo.h: declare "do_first_par_indent". - * makeinfo/sectioning.c (sectioning_underscore): suppress - indentation if requested. - * doc/texinfo.txi: document it. + * lib/Makefile.am (libtxi_a_SOURCES): add strdup.h. + Report from: Thomas Esser , + 6 Nov 2004 18:11:51 +0100. - * doc/texinfo.tex (\indent): override \indent primitive to - clear \everypar. - (\ptexindent): for saving/restoring \indent in @tex. - (\footnote): Neutralise the effect of @indent - within a footnote. - * makeinfo/cmds.c (command_table): add "indent" (as cm_indent). - (cm_indent): un-inhibit_paragraph_indentation. - * doc/texinfo.txi: document it. +2004-11-01 Karl Berry - * doc/texinfo.txi (Conventions): remove spurious extra vertical space - from bulleted itemize which starts with a quote. + * makeinfo/xref.c (cm_xref): don't include the external file name + in the HTML output, since it's pretty traditional not to + distinguish internal and external links in HTML, and it disturbs + the flow of reading. + From: Han-Wen Nienhuys , 31 Oct 2004 00:13:36 +0200. + (For lilypond.) - * makeinfo/cmds.c (command_table): fix @novalidate definition. +2004-10-31 Karl Berry + * doc/texinfo.tex (\setmultitablespacing): just let \multistrut be + the same as \strut. Its previous computation was wrong. + See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. - * Installed changes from Jan for @image support in Info format: +2004-10-22 Stepan Kasal - 2003-04-14 Jan Nieuwenhuizen - * info/display.c (display_update_one_window): Skip new style - image tag/cookie. + * info/Makefile.am (generated_sources): Add dependencies defining + a total order on the files, to prevent race conditions with + parallel make. + Move the code about generated sources to the end of the file. - 2003-04-09 Jan Nieuwenhuizen - * makeinfo/makeinfo.c (cm_image): Write ^@^H[image ...^@^H] tag. +2004-10-20 Stepan Kasal + * info/Makefile.am (doc.c, key.c, funs.h): Don't distribute them. + of these three files. + (ginfo_SOURCES, nodist_ginfo_SOURCES): Move files. + (infokey_SOURCES, nodist_infokey_SOURCES): Likewise. + (DISTCLEANFILES): Include generated_sources. - * makeinfo/html.c (html_output_head): use \n"); - } - - add_word ("\n\n"); - - if (title && !html_title_written && titlepage_cmd_present) - { - add_word_args ("

%s

\n", html_title); - html_title_written = 1; - } -} - - /* Append CHAR to BUFFER, (re)allocating as necessary. We don't handle null characters. */ @@ -139,9 +38,8 @@ typedef struct char *buffer; } buffer_type; - static buffer_type * -init_buffer () +init_buffer (void) { buffer_type *buf = xmalloc (sizeof (buffer_type)); buf->length = 0; @@ -151,11 +49,8 @@ init_buffer () return buf; } - static void -append_char (buf, c) - buffer_type *buf; - int c; +append_char (buffer_type *buf, int c) { buf->length++; if (buf->length >= buf->size) @@ -167,17 +62,15 @@ append_char (buf, c) buf->buffer[buf->length] = 0; } - /* Read the cascading style-sheet file FILENAME. Write out any @import commands, which must come first, by the definition of css. If the file contains any actual css code following the @imports, return it; else return NULL. */ - static char * -process_css_file (filename) - char *filename; +process_css_file (char *filename) { - int c, lastchar; + int c; + int lastchar = 0; FILE *f; buffer_type *import_text = init_buffer (); buffer_type *inline_text = init_buffer (); @@ -185,6 +78,8 @@ process_css_file (filename) enum { null_state, comment_state, import_state, inline_state } state = null_state, prev_state; + prev_state = null_state; + /* read from stdin if `-' is the filename. */ f = STREQ (filename, "-") ? stdin : fopen (filename, "r"); if (!f) @@ -204,12 +99,22 @@ process_css_file (filename) { case null_state: /* between things */ if (c == '@') - { - /* If there's some other @command, just call it an - import, it's all the same to us. So don't bother - looking for the `import'. */ - append_char (import_text, c); - state = import_state; + { /* Only @import and @charset should switch into + import_state, other @-commands, such as @media, should + put us into inline_state. I don't think any other css + @-commands start with `i' or `c', although of course + this will break when such a command is defined. */ + int nextchar = getc (f); + if (nextchar == 'i' || nextchar == 'c') + { + append_char (import_text, c); + state = import_state; + } + else + { + ungetc (nextchar, f); /* wasn't an @import */ + state = inline_state; + } } else if (c == '/') { /* possible start of a comment */ @@ -277,23 +182,176 @@ process_css_file (filename) /* We're wasting the buffer struct memory, but so what. */ return inline_text->buffer; } + +HSTACK *htmlstack = NULL; + +/* See html.h. */ +int html_output_head_p = 0; +int html_title_written = 0; + +void +html_output_head (void) +{ + static const char *html_title = NULL; + char *encoding; + + if (html_output_head_p) + return; + html_output_head_p = 1; + + encoding = current_document_encoding (); + + /* The should not have markup, so use text_expansion. */ + if (!html_title) + html_title = escape_string (title ? + text_expansion (title) : (char *) _("Untitled")); + + /* Make sure this is the very first string of the output document. */ + output_paragraph_offset = 0; + + add_html_block_elt_args ("<html lang=\"%s\">\n<head>\n", + language_table[language_code].abbrev); + + /* When splitting, add current node's name to title if it's available and not + Top. */ + if (splitting && current_node && !STREQ (current_node, "Top")) + add_word_args ("<title>%s - %s\n", + escape_string (xstrdup (current_node)), html_title); + else + add_word_args ("%s\n", html_title); + + add_word ("\n"); + + if (!document_description) + document_description = html_title; + + add_word_args ("\n", + document_description); + add_word_args ("\n", + VERSION); + + /* Navigation bar links. */ + if (!splitting) + add_word ("\n"); + else if (tag_table) + { + /* Always put a top link. */ + add_word ("\n"); + + /* We already have a top link, avoid duplication. */ + if (tag_table->up && !STREQ (tag_table->up, "Top")) + add_link (tag_table->up, "rel=\"up\""); + + if (tag_table->prev) + add_link (tag_table->prev, "rel=\"prev\""); + + if (tag_table->next) + add_link (tag_table->next, "rel=\"next\""); + + /* fixxme: Look for a way to put links to various indices in the + document. Also possible candidates to be added here are First and + Last links. */ + } + else + { + /* We are splitting, but we neither have a tag_table. So this must be + index.html. So put a link to Top. */ + add_word ("\n"); + } + + add_word ("\n"); + + if (copying_text) + { /* It is not ideal that we include the html markup here within + , so we use text_expansion. */ + insert_string ("\n"); + } + + /* Put the style definitions in a comment for the sake of browsers + that don't support \n"); + } + + add_word ("\n\n"); + + if (title && !html_title_written && titlepage_cmd_present) + { + add_word_args ("

%s

\n", html_title); + html_title_written = 1; + } + + free (encoding); +} /* Escape HTML special characters in the string if necessary, returning a pointer to a possibly newly-allocated one. */ char * -escape_string (string) - char * string; +escape_string (char *string) { - int i=0, newlen=0; - char * newstring; + char *newstring; + int i = 0, newlen = 0; do { /* Find how much to allocate. */ switch (string[i]) { + case '"': + newlen += 6; /* `"' */ + break; case '&': newlen += 5; /* `&' */ break; @@ -315,6 +373,10 @@ escape_string (string) { switch (string[i]) { + case '"': + strcpy (newstring, """); + newstring += 6; + break; case '&': strcpy (newstring, "&"); newstring += 5; @@ -336,24 +398,22 @@ escape_string (string) free (string); return newstring - newlen; } - - /* Save current tag. */ -void -push_tag (tag) - char *tag; +static void +push_tag (char *tag, char *attribs) { HSTACK *newstack = xmalloc (sizeof (HSTACK)); newstack->tag = tag; + newstack->attribs = xstrdup (attribs); newstack->next = htmlstack; htmlstack = newstack; } /* Get last tag. */ -void -pop_tag () +static void +pop_tag (void) { HSTACK *tos = htmlstack; @@ -363,77 +423,162 @@ pop_tag () return; } + free (htmlstack->attribs); + htmlstack = htmlstack->next; free (tos); } +/* Check if tag is an empty or a whitespace only element. + If so, remove it, keeping whitespace intact. */ +int +rollback_empty_tag (char *tag) +{ + int check_position = output_paragraph_offset; + int taglen = strlen (tag); + int rollback_happened = 0; + char *contents = ""; + char *contents_canon_white = ""; + + /* If output_paragraph is empty, we cannot rollback :-\ */ + if (output_paragraph_offset <= 0) + return 0; + + /* Find the end of the previous tag. */ + while (output_paragraph[check_position-1] != '>' && check_position > 0) + check_position--; + + /* Save stuff between tag's end to output_paragraph's end. */ + if (check_position != output_paragraph_offset) + { + contents = xmalloc (output_paragraph_offset - check_position + 1); + memcpy (contents, output_paragraph + check_position, + output_paragraph_offset - check_position); + + contents[output_paragraph_offset - check_position] = '\0'; + + contents_canon_white = xstrdup (contents); + canon_white (contents_canon_white); + } + + /* Find the start of the previous tag. */ + while (output_paragraph[check_position-1] != '<' && check_position > 0) + check_position--; + + /* Check to see if this is the tag. */ + if (strncmp ((char *) output_paragraph + check_position, tag, taglen) == 0 + && (whitespace (output_paragraph[check_position + taglen]) + || output_paragraph[check_position + taglen] == '>')) + { + if (!contents_canon_white || !*contents_canon_white) + { + /* Empty content after whitespace removal, so roll it back. */ + output_paragraph_offset = check_position - 1; + rollback_happened = 1; + + /* Original contents may not be empty (whitespace.) */ + if (contents && *contents) + { + insert_string (contents); + free (contents); + } + } + } + + return rollback_happened; +} + /* Open or close TAG according to START_OR_END. */ void -insert_html_tag (start_or_end, tag) +#if defined (VA_FPRINTF) && __STDC__ +insert_html_tag_with_attribute (int start_or_end, char *tag, char *format, ...) +#else +insert_html_tag_with_attribute (start_or_end, tag, format, va_alist) int start_or_end; char *tag; + char *format; + va_dcl +#endif { char *old_tag = NULL; + char *old_attribs = NULL; + char formatted_attribs[2000]; /* xx no fixed limits */ int do_return = 0; - - if (!paragraph_is_open && (start_or_end == START)) - { - /* Need to compensate for the

we are about to insert, or - else cm_xxx functions that call us will get wrong text - between START and END. */ - adjust_braces_following (output_paragraph_offset, 3); - add_word ("

"); - } + extern int in_html_elt; if (start_or_end != START) pop_tag (); if (htmlstack) - old_tag = htmlstack->tag; + { + old_tag = htmlstack->tag; + old_attribs = htmlstack->attribs; + } + + if (format) + { +#ifdef VA_SPRINTF + va_list ap; +#endif + + VA_START (ap, format); +#ifdef VA_SPRINTF + VA_SPRINTF (formatted_attribs, format, ap); +#else + sprintf (formatted_attribs, format, a1, a2, a3, a4, a5, a6, a7, a8); +#endif + va_end (ap); + } + else + formatted_attribs[0] = '\0'; + /* Exception: can nest multiple spans. */ if (htmlstack - && (strcmp (htmlstack->tag, tag) == 0)) + && STREQ (htmlstack->tag, tag) + && !(STREQ (tag, "span") && STREQ (old_attribs, formatted_attribs))) do_return = 1; if (start_or_end == START) - push_tag (tag); + push_tag (tag, formatted_attribs); if (do_return) return; + in_html_elt++; + /* texinfo.tex doesn't support more than one font attribute at the same time. */ - if ((start_or_end == START) && old_tag && *old_tag) - { - add_word ("'); - } + if ((start_or_end == START) && old_tag && *old_tag + && !rollback_empty_tag (old_tag)) + add_word_args ("", old_tag); if (*tag) { - add_char ('<'); - if (start_or_end != START) - add_char ('/'); - add_word (tag); - add_char ('>'); + if (start_or_end == START) + add_word_args (format ? "<%s %s>" : "<%s>", tag, formatted_attribs); + else if (!rollback_empty_tag (tag)) + /* Insert close tag only if we didn't rollback, + in which case the opening tag is removed. */ + add_word_args ("", tag); } if ((start_or_end != START) && old_tag && *old_tag) - { - add_char ('<'); - add_word (old_tag); - add_char ('>'); - } -} + add_word_args (strlen (old_attribs) > 0 ? "<%s %s>" : "<%s>", + old_tag, old_attribs); + in_html_elt--; +} +void +insert_html_tag (int start_or_end, char *tag) +{ + insert_html_tag_with_attribute (start_or_end, tag, NULL); +} /* Output an HTML to the filename for NODE, including the other string as extra attributes. */ void -add_link (nodename, attributes) - char *nodename, *attributes; +add_link (char *nodename, char *attributes) { if (nodename) { @@ -441,39 +586,64 @@ add_link (nodename, attributes) add_word_args ("%s", attributes); add_word_args (" href=\""); add_anchor_name (nodename, 1); - add_word ("\">\n"); + add_word_args ("\" title=\"%s\">\n", nodename); } } /* Output NAME with characters escaped as appropriate for an anchor - name, i.e., escape URL special characters as %. */ + name, i.e., escape URL special characters with our _00hh convention + if OLD is zero. (See the manual for details on the new scheme.) + + If OLD is nonzero, generate the node name with the 4.6-and-earlier + convention of %hh (and more special characters output as-is, notably + - and *). This is only so that external references to old names can + still work with HTML generated by the new makeinfo; the gcc folks + needed this. Our own HTML does not refer to these names. */ + void -add_escaped_anchor_name (name) - char *name; +add_escaped_anchor_name (char *name, int old) { + canon_white (name); + + if (!old && !strchr ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", + *name)) + { /* XHTML does not allow anything but an ASCII letter to start an + identifier. Therefore kludge in this constant string if we + have a nonletter. */ + add_word ("g_t"); + } + for (; *name; name++) { - if (*name == '&') - add_word ("&"); - else if (! URL_SAFE_CHAR (*name)) + if (cr_or_whitespace (*name)) + add_char ('-'); + + else if (!old && !URL_SAFE_CHAR (*name)) /* Cast so characters with the high bit set are treated as >128, for example o-umlaut should be 246, not -10. */ + add_word_args ("_00%x", (unsigned char) *name); + + else if (old && !URL_SAFE_CHAR (*name) && !OLD_URL_SAFE_CHAR (*name)) + /* Different output convention, but still cast as above. */ add_word_args ("%%%x", (unsigned char) *name); + else add_char (*name); } } /* Insert the text for the name of a reference in an HTML anchor - appropriate for NODENAME. If HREF is nonzero, it will be - appropriate for a href= attribute, rather than name= i.e., including - the `#' if it's an internal reference. */ + appropriate for NODENAME. + + If HREF is zero, generate text for name= in the new node name + conversion convention. + If HREF is negative, generate text for name= in the old convention. + If HREF is positive, generate the name for an href= attribute, i.e., + including the `#' if it's an internal reference. */ void -add_anchor_name (nodename, href) - char *nodename; - int href; +add_anchor_name (char *nodename, int href) { - if (href) + if (href > 0) { if (splitting) add_url_name (nodename, href); @@ -486,38 +656,52 @@ add_anchor_name (nodename, href) if (strcasecmp (nodename, "(dir)") == 0) /* Strip the parens, but keep the original letter-case. */ add_word_args ("%.3s", nodename + 1); + else if (strcasecmp (nodename, "top") == 0) + add_word ("Top"); else - add_escaped_anchor_name (nodename); + add_escaped_anchor_name (nodename, href < 0); } /* Insert the text for the name of a reference in an HTML url, aprropriate for NODENAME */ void -add_url_name (nodename, href) - char *nodename; - int href; +add_url_name (char *nodename, int href) { add_nodename_to_filename (nodename, href); } -/* Only allow [-0-9a-zA-Z_.] when nodifying filenames. This may - result in filename clashes; e.g., +/* Convert non [A-Za-z0-9] to _00xx, where xx means the hexadecimal + representation of the ASCII character. Also convert spaces and + newlines to dashes. */ +static void +fix_filename (char *filename) +{ + int i; + int len = strlen (filename); + char *oldname = xstrdup (filename); - @node Foo ],,, - @node Foo [,,, + *filename = '\0'; - both map to Foo--.html. If that happens, cm_node will put all - the nodes whose file names clash on the same file. */ -void -fix_filename (filename) - char *filename; -{ - char *p; - for (p = filename; *p; p++) + for (i = 0; i < len; i++) { - if (!(isalnum (*p) || strchr ("-._", *p))) - *p = '-'; + if (cr_or_whitespace (oldname[i])) + strcat (filename, "-"); + else if (URL_SAFE_CHAR (oldname[i])) + strncat (filename, (char *) oldname + i, 1); + else + { + char *hexchar = xmalloc (6 * sizeof (char)); + sprintf (hexchar, "_00%x", (unsigned char) oldname[i]); + strcat (filename, hexchar); + free (hexchar); + } + + /* Check if we are nearing boundaries. */ + if (strlen (filename) >= PATH_MAX - 20) + break; } + + free (oldname); } /* As we can't look-up a (forward-referenced) nodes' html filename @@ -525,9 +709,7 @@ fix_filename (filename) nodenames are unique, and generate the html filename from the nodename, that's always known. */ static char * -nodename_to_filename_1 (nodename, href) - char *nodename; - int href; +nodename_to_filename_1 (char *nodename, int href) { char *p; char *filename; @@ -623,9 +805,7 @@ nodename_to_filename_1 (nodename, href) /* If necessary, ie, if current filename != filename of node, output the node name. */ void -add_nodename_to_filename (nodename, href) - char *nodename; - int href; +add_nodename_to_filename (char *nodename, int href) { /* for now, don't check: always output filename */ char *filename = nodename_to_filename_1 (nodename, href); @@ -634,8 +814,7 @@ add_nodename_to_filename (nodename, href) } char * -nodename_to_filename (nodename) - char *nodename; +nodename_to_filename (char *nodename) { /* The callers of nodename_to_filename use the result to produce . */ @@ -34,24 +35,31 @@ extern int html_output_head_p; extern int html_title_written; /* Perform the output. */ -extern void html_output_head (); +extern void html_output_head (void); /* Escape &<>. */ -extern char *escape_string (/* char * */); +extern char *escape_string (char *); /* Open or close TAG according to START_OR_END. */ -extern void insert_html_tag (/* int start_or_end, char *tag */); +extern void insert_html_tag (int start_or_end, char *tag); /* Output HTML to NODE, plus extra ATTRIBUTES. */ -extern void add_link (/* char *node, char *attributes */); +extern void add_link (char *nodename, char *attributes); -/* Escape URL-special characters as %xy. */ -extern void add_escaped_anchor_name (/* char *name */); +/* Escape URL-special characters. */ +extern void add_escaped_anchor_name (char *name, int old); /* See html.c. */ -extern void add_anchor_name (/* nodename, href */); -extern void add_url_name ( /* nodename, href */ ); -extern char* nodename_to_filename ( /* nodename */ ); -extern void add_nodename_to_filename ( /*nodename, href */ ); +extern void add_anchor_name (char *nodename, int href); +extern void add_url_name (char *nodename, int href); +extern void add_nodename_to_filename (char *nodename, int href); +extern char *nodename_to_filename (char *nodename); +extern int rollback_empty_tag (char *tag); + +#if defined (VA_FPRINTF) && __STDC__ +extern void insert_html_tag_with_attribute (int start_or_end, char *tag, char *format, ...); +#else +extern void insert_html_tag_with_attribute (); +#endif #endif /* !HTML_H */ diff --git a/contrib/texinfo/makeinfo/index.c b/contrib/texinfo/makeinfo/index.c index ab6a53c..710e8b6 100644 --- a/contrib/texinfo/makeinfo/index.c +++ b/contrib/texinfo/makeinfo/index.c @@ -1,7 +1,8 @@ /* index.c -- indexing for Texinfo. - $Id: index.c,v 1.8 2003/05/16 23:52:40 karl Exp $ + $Id: index.c,v 1.17 2004/11/30 02:03:23 karl Exp $ - Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, + Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,59 +19,16 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "system.h" +#include "files.h" +#include "footnote.h" +#include "html.h" #include "index.h" #include "lang.h" #include "macro.h" +#include "sectioning.h" #include "toc.h" #include "xml.h" -/* An index element... */ -typedef struct index_elt -{ - struct index_elt *next; - char *entry; /* The index entry itself, after expansion. */ - char *entry_text; /* The original, non-expanded entry text. */ - char *node; /* The node from whence it came. */ - int code; /* Nonzero means add `@code{...}' when - printing this element. */ - int defining_line; /* Line number where this entry was written. */ - char *defining_file; /* Source file for defining_line. */ -} INDEX_ELT; - - -/* A list of short-names for each index. - There are two indices into the the_indices array. - * read_index is the index that points to the list of index - entries that we will find if we ask for the list of entries for - this name. - * write_index is the index that points to the list of index entries - that we will add new entries to. - - Initially, read_index and write_index are the same, but the - @syncodeindex and @synindex commands can change the list we add - entries to. - - For example, after the commands - @cindex foo - @defindex ii - @synindex cp ii - @cindex bar - - the cp index will contain the entry `foo', and the new ii - index will contain the entry `bar'. This is consistent with the - way texinfo.tex handles the same situation. - - In addition, for each index, it is remembered whether that index is - a code index or not. Code indices have @code{} inserted around the - first word when they are printed with printindex. */ -typedef struct -{ - char *name; - int read_index; /* index entries for `name' */ - int write_index; /* store index entries here, @synindex can change it */ - int code; -} INDEX_ALIST; - INDEX_ALIST **name_index_alist = NULL; /* An array of pointers. Each one is for a different index. The @@ -81,18 +39,24 @@ INDEX_ELT **the_indices = NULL; /* The number of defined indices. */ int defined_indices = 0; +/* This is the order of the index. */ +int index_counter = 0; + /* Stuff for defining commands on the fly. */ COMMAND **user_command_array = NULL; int user_command_array_len = 0; /* How to compare index entries for sorting. May be set to strcoll. */ -int (*index_compare_fn) () = strcasecmp; +int (*index_compare_fn) (const char *a, const char *b) = strcasecmp; + +/* Function to compare index entries for sorting. (Calls + `index_compare_fn' above.) */ +int index_element_compare (const void *element1, const void *element2); /* Find which element in the known list of indices has this name. Returns -1 if NAME isn't found. */ static int -find_index_offset (name) - char *name; +find_index_offset (char *name) { int i; for (i = 0; i < defined_indices; i++) @@ -103,9 +67,8 @@ find_index_offset (name) /* Return a pointer to the entry of (name . index) for this name. Return NULL if the index doesn't exist. */ -INDEX_ALIST * -find_index (name) - char *name; +static INDEX_ALIST * +find_index (char *name) { int offset = find_index_offset (name); if (offset > -1) @@ -116,11 +79,8 @@ find_index (name) /* User-defined commands, which happens only from user-defined indexes. Used to initialize the builtin indices, too. */ -void -define_user_command (name, proc, needs_braces_p) - char *name; - COMMAND_FUNCTION *proc; - int needs_braces_p; +static void +define_user_command (char *name, COMMAND_FUNCTION (*proc), int needs_braces_p) { int slot = user_command_array_len; user_command_array_len++; @@ -139,8 +99,7 @@ define_user_command (name, proc, needs_braces_p) /* Please release me, let me go... */ static void -free_index (index) - INDEX_ELT *index; +free_index (INDEX_ELT *index) { INDEX_ELT *temp; @@ -159,8 +118,7 @@ free_index (index) /* Flush an index by name. This will delete the list of entries that would be written by a @printindex command for this index. */ static void -undefindex (name) - char *name; +undefindex (char *name) { int i; int which = find_index_offset (name); @@ -180,11 +138,9 @@ undefindex (name) name_index_alist[which] = NULL; } -/* Add the arguments to the current index command to the index NAME. - html fixxme generate specific html anchor */ +/* Add the arguments to the current index command to the index NAME. */ static void -index_add_arg (name) - char *name; +index_add_arg (char *name) { int which; char *index_entry; @@ -216,17 +172,57 @@ index_add_arg (name) else { INDEX_ELT *new = xmalloc (sizeof (INDEX_ELT)); + + index_counter++; + + /* Get output line number updated before doing anything. */ + if (!html && !xml) + flush_output (); + new->next = the_indices[which]; - new->entry_text = index_entry; new->entry = NULL; - new->node = current_node ? current_node : xstrdup (""); + new->entry_text = index_entry; + /* Since footnotes are handled at the very end of the document, + node name in the non-split HTML outputs always show the last + node. We artificially make it ``Footnotes''. */ + if (html && !splitting && already_outputting_pending_notes) + new->node = xstrdup (_("Footnotes")); + else + new->node = current_node ? current_node : xstrdup (""); + if (!html && !xml && no_headers) + { + new->section = current_sectioning_number (); + if (strlen (new->section) == 0) + new->section_name = current_sectioning_name (); + else + new->section_name = ""; + } + else + { + new->section = NULL; + new->section_name = NULL; + } new->code = tem->code; new->defining_line = line_number - 1; + new->output_line = no_headers ? output_line_number : node_line_number; /* We need to make a copy since input_filename may point to something that goes away, for example, inside a macro. (see the findexerr test). */ new->defining_file = xstrdup (input_filename); + + if (html && splitting) + { + if (current_output_filename && *current_output_filename) + new->output_file = filename_part (current_output_filename); + else + new->output_file = xstrdup (""); + } + else + new->output_file = NULL; + + new->entry_number = index_counter; the_indices[which] = new; + #if 0 /* The index breaks if there are colons in the entry. -- This is true, but it's too painful to force changing index @@ -238,14 +234,36 @@ index_add_arg (name) warning (_("Info cannot handle `:' in index entry `%s'"), new->entry_text); #endif + + if (html) + { + /* Anchor. */ + int removed_empty_elt = 0; + + /* We must put the anchor outside the

and
    blocks. */ + if (rollback_empty_tag ("dl")) + removed_empty_elt = 1; + else if (rollback_empty_tag ("ul")) + removed_empty_elt = 2; + + add_word ("", index_counter); + + if (removed_empty_elt == 1) + add_html_block_elt_args ("\n
    "); + else if (removed_empty_elt == 2) + add_html_block_elt_args ("\n
      "); + } } + if (xml) xml_insert_indexterm (index_entry, name); } /* The function which user defined index commands call. */ static void -gen_index () +gen_index (void) { char *name = xstrdup (command); if (strlen (name) >= strlen ("index")) @@ -257,9 +275,7 @@ gen_index () /* Define an index known as NAME. We assign the slot number. If CODE is nonzero, make this a code index. */ static void -defindex (name, code) - char *name; - int code; +defindex (char *name, int code) { int i, slot; @@ -299,9 +315,7 @@ defindex (name, code) /* Define an index NAME, implicitly @code if CODE is nonzero. */ static void -top_defindex (name, code) - char *name; - int code; +top_defindex (char *name, int code) { char *temp; @@ -314,7 +328,7 @@ top_defindex (name, code) /* Set up predefined indices. */ void -init_indices () +init_indices (void) { int i; @@ -364,9 +378,8 @@ init_indices () /* Given an index name, return the offset in the_indices of this index, or -1 if there is no such index. */ -int -translate_index (name) - char *name; +static int +translate_index (char *name) { INDEX_ALIST *which = find_index (name); @@ -378,8 +391,7 @@ translate_index (name) /* Return the index list which belongs to NAME. */ INDEX_ELT * -index_list (name) - char *name; +index_list (char *name) { int which = translate_index (name); if (which < 0) @@ -390,8 +402,7 @@ index_list (name) /* Define a new index command. Arg is name of index. */ static void -gen_defindex (code) - int code; +gen_defindex (int code) { char *name; get_rest_of_line (0, &name); @@ -413,13 +424,13 @@ gen_defindex (code) } void -cm_defindex () +cm_defindex (void) { gen_defindex (0); } void -cm_defcodeindex () +cm_defcodeindex (void) { gen_defindex (1); } @@ -428,7 +439,7 @@ cm_defcodeindex () Make the first one be a synonym for the second one, i.e. make the first one have the same index as the second one. */ void -cm_synindex () +cm_synindex (void) { int source, target; char *abbrev1, *abbrev2; @@ -446,8 +457,11 @@ cm_synindex () } else { - name_index_alist[target]->write_index - = name_index_alist[source]->write_index; + if (xml && !docbook) + xml_synindex (abbrev1, abbrev2); + else + name_index_alist[target]->write_index + = name_index_alist[source]->write_index; } free (abbrev1); @@ -455,53 +469,53 @@ cm_synindex () } void -cm_pindex () /* Pinhead index. */ +cm_pindex (void) /* Pinhead index. */ { index_add_arg ("pg"); } void -cm_vindex () /* Variable index. */ +cm_vindex (void) /* Variable index. */ { index_add_arg ("vr"); } void -cm_kindex () /* Key index. */ +cm_kindex (void) /* Key index. */ { index_add_arg ("ky"); } void -cm_cindex () /* Concept index. */ +cm_cindex (void) /* Concept index. */ { index_add_arg ("cp"); } void -cm_findex () /* Function index. */ +cm_findex (void) /* Function index. */ { index_add_arg ("fn"); } void -cm_tindex () /* Data Type index. */ +cm_tindex (void) /* Data Type index. */ { index_add_arg ("tp"); } int -index_element_compare (element1, element2) - INDEX_ELT **element1, **element2; +index_element_compare (const void *element1, const void *element2) { - return index_compare_fn ((*element1)->entry, (*element2)->entry); + INDEX_ELT **elt1 = (INDEX_ELT **) element1; + INDEX_ELT **elt2 = (INDEX_ELT **) element2; + + return index_compare_fn ((*elt1)->entry, (*elt2)->entry); } /* Force all index entries to be unique. */ -void -make_index_entries_unique (array, count) - INDEX_ELT **array; - int count; +static void +make_index_entries_unique (INDEX_ELT **array, int count) { int i, j; INDEX_ELT **copy; @@ -560,9 +574,8 @@ make_index_entries_unique (array, count) /* Sort the index passed in INDEX, returning an array of pointers to elements. The array is terminated with a NULL pointer. */ -INDEX_ELT ** -sort_index (index) - INDEX_ELT *index; +static INDEX_ELT ** +sort_index (INDEX_ELT *index) { INDEX_ELT **array; INDEX_ELT *temp; @@ -641,38 +654,95 @@ sort_index (index) return array; } +static void +insert_index_output_line_no (int line_number, int output_line_number_len) +{ + int last_column; + int str_size = output_line_number_len + strlen (_("(line )")) + + sizeof (NULL); + char *out_line_no_str = (char *) xmalloc (str_size + 1); + + /* Do not translate ``(line NNN)'' below for !no_headers case (Info output), + because it's something like the ``* Menu'' strings. For plaintext output + it should be translated though. */ + sprintf (out_line_no_str, + no_headers ? _("(line %*d)") : "(line %*d)", + output_line_number_len, line_number); + + { + int i = output_paragraph_offset; + while (0 < i && output_paragraph[i-1] != '\n') + i--; + last_column = output_paragraph_offset - i; + } + + if (last_column + strlen (out_line_no_str) > fill_column) + { + insert ('\n'); + last_column = 0; + } + + while (last_column + strlen (out_line_no_str) < fill_column) + { + insert (' '); + last_column++; + } + + insert_string (out_line_no_str); + insert ('\n'); + + free (out_line_no_str); +} + /* Nonzero means that we are in the middle of printing an index. */ int printing_index = 0; /* Takes one arg, a short name of an index to print. Outputs a menu of the sorted elements of the index. */ void -cm_printindex () +cm_printindex (void) { + char *index_name; + get_rest_of_line (0, &index_name); + + /* get_rest_of_line increments the line number by one, + so to make warnings/errors point to the correct line, + we decrement the line_number again. */ + if (!handling_delayed_writes) + line_number--; + if (xml && !docbook) { - char *index_name; - get_rest_of_line (0, &index_name); xml_insert_element (PRINTINDEX, START); insert_string (index_name); xml_insert_element (PRINTINDEX, END); } + else if (!handling_delayed_writes) + { + int command_len = sizeof ("@ ") + strlen (command) + strlen (index_name); + char *index_command = xmalloc (command_len + 1); + + close_paragraph (); + if (docbook) + xml_begin_index (); + + sprintf (index_command, "@%s %s", command, index_name); + register_delayed_write (index_command); + free (index_command); + } else { int item; INDEX_ELT *index; INDEX_ELT *last_index = 0; INDEX_ELT **array; - char *index_name; unsigned line_length; char *line; int saved_inhibit_paragraph_indentation = inhibit_paragraph_indentation; int saved_filling_enabled = filling_enabled; int saved_line_number = line_number; char *saved_input_filename = input_filename; - - close_paragraph (); - get_rest_of_line (0, &index_name); + unsigned output_line_number_len; index = index_list (index_name); if (index == (INDEX_ELT *)-1) @@ -696,9 +766,17 @@ cm_printindex () xml_sort_index = 0; close_paragraph (); if (html) - add_word_args ("
        ", index_name); + add_html_block_elt_args ("
          ", + index_name); else if (!no_headers && !docbook) - add_word ("* Menu:\n\n"); + { /* Info. Add magic cookie for info readers (to treat this + menu differently), and the usual start-of-menu. */ + add_char ('\0'); + add_word ("\010[index"); + add_char ('\0'); + add_word ("\010]\n"); + add_word ("* Menu:\n\n"); + } me_inhibit_expansion++; @@ -706,11 +784,29 @@ cm_printindex () line_length = 100; line = xmalloc (line_length); + { + char *max_output_line_number = (char *) xmalloc (25 * sizeof (char)); + + if (no_headers) + sprintf (max_output_line_number, "%d", output_line_number); + else + { + INDEX_ELT *tmp_entry = index; + unsigned tmp = 0; + for (tmp_entry = index; tmp_entry; tmp_entry = tmp_entry->next) + tmp = tmp_entry->output_line > tmp ? tmp_entry->output_line : tmp; + sprintf (max_output_line_number, "%d", tmp); + } + + output_line_number_len = strlen (max_output_line_number); + free (max_output_line_number); + } + for (item = 0; (index = array[item]); item++) { /* A pathological document might have an index entry outside of any node. Don't crash; try using the section name instead. */ - const char *index_node = index->node; + char *index_node = index->node; line_number = index->defining_line; input_filename = index->defining_file; @@ -723,44 +819,39 @@ cm_printindex () line_error (_("Entry for index `%s' outside of any node"), index_name); if (html || !no_headers) - index_node = _("(outside of any node)"); + index_node = (char *) _("(outside of any node)"); } if (html) - /* fixme: html: we should use specific index anchors pointing - to the actual location of the indexed position (but then we - have to find something to wrap the anchor around). */ { - if (last_index - && STREQ (last_index->entry_text, index->entry_text)) - add_word (", "); /* Don't repeat the previous entry. */ - else - { - /* In the HTML case, the expanded index entry is not - good for us, since it was expanded for non-HTML mode - inside sort_index. So we need to HTML-escape and - expand the original entry text here. */ - char *escaped_entry = xstrdup (index->entry_text); - char *expanded_entry; - - /* expansion() doesn't HTML-escape the argument, so need - to do it separately. */ - escaped_entry = escape_string (escaped_entry); - expanded_entry = expansion (escaped_entry, index->code); - add_word_args ("\n
        • %s: ", expanded_entry); - free (escaped_entry); - free (expanded_entry); - } + /* For HTML, we need to expand and HTML-escape the + original entry text, at the same time. Consider + @cindex J@"urgen. We want Jüurgen. We can't + expand and then escape since we'll end up with + J&uuml;rgen. We can't escape and then expand + because then `expansion' will see J@"urgen, and + @"urgen is not a command. */ + char *html_entry = + maybe_escaped_expansion (index->entry_text, index->code, 1); + + add_html_block_elt_args ("\n
        • output_file) ? index->output_file : ""); + add_escaped_anchor_name (index->entry_text, 0); + add_word_args ("-%d\">%s: ", index->entry_number, + html_entry); + free (html_entry); + add_word ("node && *index->node) { - /* Make sure any non-macros in the node name are expanded. */ + /* Ensure any non-macros in the node name are expanded. */ char *expanded_index; in_fixed_width_font++; expanded_index = expansion (index_node, 0); in_fixed_width_font--; add_anchor_name (expanded_index, 1); + expanded_index = escape_string (expanded_index); add_word_args ("\">%s", expanded_index); free (expanded_index); } @@ -773,6 +864,8 @@ cm_printindex () /* If we use the section instead of the (missing) node, then index_node already includes all we need except the #. */ add_word_args ("#%s", index_node); + + add_html_block_elt ("
        • "); } else if (xml && docbook) { @@ -806,7 +899,9 @@ cm_printindex () insert_string (line); /* Make sure any non-macros in the node name are expanded. */ in_fixed_width_font++; - execute_string ("%s.\n", index_node); + execute_string ("%s. ", index_node); + insert_index_output_line_no (index->output_line, + output_line_number_len); in_fixed_width_font--; } else @@ -815,40 +910,27 @@ cm_printindex () there's little sense in referring to them in the index. Instead, output the number or name of the section that corresponds to that node. */ - char *section_name = toc_find_section_of_node (index_node); - - sprintf (line, "%-*s ", number_sections ? 50 : 1, index->entry); + sprintf (line, "%-*s ", number_sections ? 46 : 1, index->entry); line[strlen (index->entry)] = ':'; insert_string (line); - if (section_name) - { - int idx = 0; - unsigned ref_len = strlen (section_name) + 30; - - if (ref_len > line_length) - { - line_length = ref_len; - line = xrealloc (line, line_length); - } - - if (number_sections) - { - while (section_name[idx] - && (isdigit (section_name[idx]) - || (idx && section_name[idx] == '.'))) - idx++; - } - if (idx) - sprintf (line, " See %.*s.\n", idx, section_name); - else - sprintf (line, "\n See ``%s''.\n", section_name); - insert_string (line); + + if (strlen (index->section) > 0) + { /* We got your number. */ + insert_string ((char *) _("See ")); + insert_string (index->section); } else - { - insert_string (" "); /* force a blank */ - execute_string ("See node %s.\n", index_node); + { /* Sigh, index in an @unnumbered. :-\ */ + insert_string ("\n "); + insert_string ((char *) _("See ")); + insert_string ("``"); + insert_string (expansion (index->section_name, 0)); + insert_string ("''"); } + + insert_string (". "); + insert_index_output_line_no (index->output_line, + output_line_number_len); } } @@ -859,7 +941,6 @@ cm_printindex () } free (line); - free (index_name); me_inhibit_expansion--; printing_index = 0; @@ -871,8 +952,13 @@ cm_printindex () line_number = saved_line_number; if (html) - add_word ("
        "); + add_html_block_elt ("
      "); else if (xml && docbook) xml_end_index (); } + + free (index_name); + /* Re-increment the line number, because get_rest_of_line + left us looking at the next line after the command. */ + line_number++; } diff --git a/contrib/texinfo/makeinfo/index.h b/contrib/texinfo/makeinfo/index.h index 3279a24..3ff723d 100644 --- a/contrib/texinfo/makeinfo/index.h +++ b/contrib/texinfo/makeinfo/index.h @@ -1,5 +1,5 @@ /* index.h -- declarations for index.c. - $Id: index.h,v 1.1 2002/08/25 23:38:38 karl Exp $ + $Id: index.h,v 1.2 2004/04/11 17:56:47 karl Exp $ Copyright (C) 1998, 99 Free Software Foundation, Inc. @@ -27,10 +27,67 @@ extern COMMAND **user_command_array; extern int user_command_array_len; +/* An index element... */ +typedef struct index_elt +{ + struct index_elt *next; + char *entry; /* The index entry itself, after expansion. */ + char *entry_text; /* The original, non-expanded entry text. */ + char *node; /* The node from whence it came. */ + char *section; /* Current section number we are in, */ + char *section_name; /* ... and its title. */ + int code; /* Nonzero means add `@code{...}' when + printing this element. */ + int defining_line; /* Line number where this entry was written. */ + int output_line; /* And line number where it is in the output. */ + char *defining_file; /* Source file for defining_line. */ + char *output_file; /* Output file for output_line. */ + int entry_number; /* Entry number. */ +} INDEX_ELT; + + +/* A list of short-names for each index. + There are two indices into the the_indices array. + * read_index is the index that points to the list of index + entries that we will find if we ask for the list of entries for + this name. + * write_index is the index that points to the list of index entries + that we will add new entries to. + + Initially, read_index and write_index are the same, but the + @syncodeindex and @synindex commands can change the list we add + entries to. + + For example, after the commands + @cindex foo + @defindex ii + @synindex cp ii + @cindex bar + + the cp index will contain the entry `foo', and the new ii + index will contain the entry `bar'. This is consistent with the + way texinfo.tex handles the same situation. + + In addition, for each index, it is remembered whether that index is + a code index or not. Code indices have @code{} inserted around the + first word when they are printed with printindex. */ +typedef struct +{ + char *name; + int read_index; /* index entries for `name' */ + int write_index; /* store index entries here, @synindex can change it */ + int code; +} INDEX_ALIST; + +extern INDEX_ALIST **name_index_alist; + /* Initialize all indices. */ -extern void init_indices (); +extern void init_indices (void); + +extern int defined_indices; +extern int printing_index; +extern int index_counter; -/* Function to compare index entries for sorting. */ -extern int (*index_compare_fn) (); +INDEX_ELT *index_list (char *name); #endif /* !INDEX_H */ diff --git a/contrib/texinfo/makeinfo/insertion.c b/contrib/texinfo/makeinfo/insertion.c index 95c0be2..05a2044 100644 --- a/contrib/texinfo/makeinfo/insertion.c +++ b/contrib/texinfo/makeinfo/insertion.c @@ -1,7 +1,7 @@ /* insertion.c -- insertions for Texinfo. - $Id: insertion.c,v 1.21 2003/04/01 14:34:18 karl Exp $ + $Id: insertion.c,v 1.55 2004/11/11 18:34:28 karl Exp $ - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -21,25 +21,29 @@ #include "system.h" #include "cmds.h" #include "defun.h" +#include "float.h" +#include "html.h" #include "insertion.h" #include "macro.h" #include "makeinfo.h" +#include "multi.h" #include "xml.h" /* Must match list in insertion.h. */ static char *insertion_type_names[] = { "cartouche", "copying", "defcv", "deffn", "defivar", "defmac", - "defmethod", "defop", "defopt", "defspec", "deftp", "deftypefn", - "deftypefun", "deftypeivar", "deftypemethod", "deftypeop", - "deftypevar", "deftypevr", "defun", "defvar", "defvr", "detailmenu", - "direntry", "display", "documentdescription", "enumerate", "example", - "flushleft", "flushright", "format", "ftable", "group", "ifclear", - "ifhtml", "ifinfo", "ifnothtml", "ifnotinfo", "ifnotplaintext", "ifnottex", "ifnotxml", - "ifplaintext", "ifset", "iftex", "ifxml", "itemize", "lisp", "menu", - "multitable", "quotation", "rawhtml", "rawtex", "smalldisplay", - "smallexample", "smallformat", "smalllisp", "verbatim", "table", - "tex", "vtable", "bad_type" + "defmethod", "defop", "defopt", "defspec", "deftp", "deftypecv", + "deftypefn", "deftypefun", "deftypeivar", "deftypemethod", + "deftypeop", "deftypevar", "deftypevr", "defun", "defvar", "defvr", + "detailmenu", "direntry", "display", "documentdescription", + "enumerate", "example", "float", "flushleft", "flushright", "format", + "ftable", "group", "ifclear", "ifdocbook", "ifhtml", "ifinfo", + "ifnotdocbook", "ifnothtml", "ifnotinfo", "ifnotplaintext", "ifnottex", + "ifnotxml", "ifplaintext", "ifset", "iftex", "ifxml", "itemize", "lisp", + "menu", "multitable", "quotation", "rawdocbook", "rawhtml", "rawtex", + "rawxml", "smalldisplay", "smallexample", "smallformat", "smalllisp", + "verbatim", "table", "tex", "vtable", "titlepage", "bad_type" }; /* All nested environments. */ @@ -62,19 +66,29 @@ int in_menu = 0; Used for menu and itemize. */ int in_paragraph = 0; -static const char dl_tag[] = "
      \n"; -extern void cm_insert_copying (); +/* Since an insertion is already in the stack before we reach the switch + statement, we cannot use is_in_insertion_of_type (always returns true.) Also + making it return the level found, and comparing it with the current level is + no use, due to the order of stack. */ +static int float_active = 0; +/* Unsetting escape_html blindly causes text inside @html/etc. to be escaped if + used within a rmacro. */ +static int raw_output_block = 0; + +/* Non-zero if a
      element has a
      element in it. We use this when + deciding whether to insert a
      or not. */ +static int html_deflist_has_term = 0; void -init_insertion_stack () +init_insertion_stack (void) { insertion_stack = NULL; } /* Return the type of the current insertion. */ static enum insertion_type -current_insertion_type () +current_insertion_type (void) { return insertion_level ? insertion_stack->insertion : bad_type; } @@ -82,7 +96,7 @@ current_insertion_type () /* Return the string which is the function to wrap around items, or NULL if we're not in an environment where @item is ok. */ static char * -current_item_function () +current_item_function (void) { int done = 0; INSERTION_ELT *elt = insertion_stack; @@ -106,7 +120,9 @@ current_item_function () case ifset: case iftex: case ifxml: + case rawdocbook: case rawhtml: + case rawxml: case rawtex: case tex: case cartouche: @@ -126,8 +142,8 @@ current_item_function () change it to "@ ", since "@" by itself is not a command. This makes "@ ", "@\t", and "@\n" all the same, but their default meanings are the same anyway, and let's not worry about supporting redefining them. */ -char * -get_item_function () +static char * +get_item_function (void) { char *item_function; char *item_loc; @@ -161,10 +177,8 @@ get_item_function () } /* Push the state of the current insertion on the stack. */ -void -push_insertion (type, item_function) - enum insertion_type type; - char *item_function; +static void +push_insertion (enum insertion_type type, char *item_function) { INSERTION_ELT *new = xmalloc (sizeof (INSERTION_ELT)); @@ -184,7 +198,7 @@ push_insertion (type, item_function) /* Pop the value on top of the insertion stack into the global variables. */ void -pop_insertion () +pop_insertion (void) { INSERTION_ELT *temp = insertion_stack; @@ -204,12 +218,22 @@ pop_insertion () /* Return a pointer to the print name of this enumerated type. */ -const char * -insertion_type_pname (type) - enum insertion_type type; +static const char * +insertion_type_pname (enum insertion_type type) { if ((int) type < (int) bad_type) - return insertion_type_names[(int) type]; + { + if (type == rawdocbook) + return "docbook"; + else if (type == rawhtml) + return "html"; + else if (type == rawxml) + return "xml"; + else if (type == rawtex) + return "tex"; + else + return insertion_type_names[(int) type]; + } else return _("Broken-Type in insertion_type_pname"); } @@ -217,18 +241,19 @@ insertion_type_pname (type) /* Return the insertion_type associated with NAME. If the type is not one of the known ones, return BAD_TYPE. */ enum insertion_type -find_type_from_name (name) - char *name; +find_type_from_name (char *name) { int index = 0; while (index < (int) bad_type) { if (STREQ (name, insertion_type_names[index])) return (enum insertion_type) index; + if (index == rawdocbook && STREQ (name, "docbook")) + return rawdocbook; if (index == rawhtml && STREQ (name, "html")) return rawhtml; - if (index == rawhtml && STREQ (name, "xml")) - return rawhtml; + if (index == rawxml && STREQ (name, "xml")) + return rawxml; if (index == rawtex && STREQ (name, "tex")) return rawtex; index++; @@ -236,9 +261,29 @@ find_type_from_name (name) return bad_type; } +/* Simple function to query insertion_stack to see if we are inside a given + insertion type. */ int -defun_insertion (type) - enum insertion_type type; +is_in_insertion_of_type (int type) +{ + INSERTION_ELT *temp = insertion_stack; + + if (!insertion_level) + return 0; + + while (temp) + { + if (temp->insertion == type) + return 1; + temp = temp->next; + } + + return 0; +} + + +static int +defun_insertion (enum insertion_type type) { return 0 || (type == defcv) @@ -250,6 +295,7 @@ defun_insertion (type) || (type == defopt) || (type == defspec) || (type == deftp) + || (type == deftypecv) || (type == deftypefn) || (type == deftypefun) || (type == deftypeivar) @@ -280,9 +326,8 @@ int current_enumval = 1; int current_enumtype = ENUM_DIGITS; char *enumeration_arg = NULL; -void -start_enumerating (at, type) - int at, type; +static void +start_enumerating (int at, int type) { if ((enumstack_offset + 1) == max_stack_depth) { @@ -296,8 +341,8 @@ start_enumerating (at, type) current_enumtype = type; } -void -stop_enumerating () +static void +stop_enumerating (void) { --enumstack_offset; if (enumstack_offset < 0) @@ -308,8 +353,8 @@ stop_enumerating () } /* Place a letter or digits into the output stream. */ -void -enumerate_item () +static void +enumerate_item (void) { char temp[10]; @@ -331,7 +376,7 @@ enumerate_item () } static void -enum_html () +enum_html (void) { char type; int start; @@ -352,12 +397,12 @@ enum_html () start = *enumeration_arg - 'a' + 1; } - add_word_args ("
        \n", type, start); + add_html_block_elt_args ("
          \n", type, start); } /* Conditionally parse based on the current command name. */ void -command_name_condition () +command_name_condition (void) { char *discarder = xmalloc (8 + strlen (command)); @@ -372,8 +417,7 @@ command_name_condition () commands is done. A huge switch statement handles the various setups, and generic code is on both sides. */ void -begin_insertion (type) - enum insertion_type type; +begin_insertion (enum insertion_type type) { int no_discard = 0; @@ -405,10 +449,11 @@ begin_insertion (type) if (xml) xml_insert_element (MENU, START); + else + in_fixed_width_font++; next_menu_item_number = 1; in_menu++; - in_fixed_width_font++; no_discard++; break; @@ -424,7 +469,14 @@ begin_insertion (type) no_discard++; } - in_fixed_width_font++; + if (xml) + { + xml_insert_element (DETAILMENU, START); + skip_whitespace_and_newlines(); + } + else + in_fixed_width_font++; + in_detailmenu++; break; @@ -455,32 +507,15 @@ begin_insertion (type) break; case copying: - { /* Save the copying text away for @insertcopying, typically used on the back of the @titlepage (for TeX) and the Top node (for info/html). */ - char *text; - int start_of_end; - int save_paragraph_indentation; - + if (input_text[input_text_offset] != '\n') discard_until ("\n"); /* ignore remainder of @copying line */ - start_of_end = get_until ("\n@end copying", &text); - - /* include all the output-format-specific markup. */ - if (docbook) - { - save_paragraph_indentation = inhibit_paragraph_indentation; - inhibit_paragraph_indentation = 1; - } - copying_text = full_expansion (text, 0); - free (text); - - if (docbook) - inhibit_paragraph_indentation = save_paragraph_indentation; - - input_text_offset = start_of_end; /* go back to the @end to match */ - } - + + input_text_offset = get_until ("\n@end copying", ©ing_text); + canon_white (copying_text); + /* For info, output the copying text right away, so it will end up in the header of the Info file, before the first node, and thus get copied automatically to all the split files. For xml, also @@ -495,25 +530,21 @@ begin_insertion (type) xml_insert_element (BOOKINFO, START); xml_in_bookinfo = 1; } - if (!xml_in_abstract) - { - xml_insert_element (ABSTRACT, START); - xml_in_abstract = 1; - } + xml_insert_element (LEGALNOTICE, START); } + if (!html && !no_headers) cm_insert_copying (); - if (docbook && xml_in_abstract) - { - xml_insert_element (ABSTRACT, END); - xml_in_abstract = 0; - } + + if (docbook) + xml_insert_element (LEGALNOTICE, END); + break; - + case quotation: /* @quotation does filling (@display doesn't). */ if (html) - add_word ("
          \n"); + add_html_block_elt ("
          \n"); else { /* with close_single_paragraph, we get no blank line above @@ -524,32 +555,39 @@ begin_insertion (type) inhibit_paragraph_indentation = 1; } current_indent += default_indentation_increment; + if (xml) + xml_insert_quotation (insertion_stack->item_function, START); + else if (strlen(insertion_stack->item_function)) + execute_string ("@b{%s:} ", insertion_stack->item_function); break; - case display: - case smalldisplay: case example: case smallexample: case lisp: case smalllisp: + in_fixed_width_font++; + /* fall through */ + + /* Like @example but no fixed width font. */ + case display: + case smalldisplay: /* Like @display but without indentation. */ case smallformat: case format: close_single_paragraph (); inhibit_paragraph_indentation = 1; - in_fixed_width_font++; filling_enabled = 0; last_char_was_newline = 0; if (html) - /* Kludge alert: if
           is followed by a newline, IE3
          -           renders an extra blank line before the pre-formatted block.
          -           Other browsers seem to not mind one way or the other.  */
          -        add_word_args ("
          ", command);
          +        /* Kludge alert: if 
           is followed by a newline, IE3,
          +           mozilla, maybe others render an extra blank line before the
          +           pre-formatted block.  So don't output a newline.  */
          +        add_html_block_elt_args ("
          ", command);
           
                 if (type != format && type != smallformat)
                   {
          -          current_indent += default_indentation_increment;
          +          current_indent += example_indentation_increment;
                     if (html)
                       {
                         /* Since we didn't put \n after 
          , we need to insert
          @@ -559,7 +597,6 @@ begin_insertion (type)
                           add_char (' ');
                       }
                   }
          -
                 break;
           
               case multitable:
          @@ -599,14 +636,26 @@ begin_insertion (type)
                   {
                     if (type == itemize)
                       {
          -              add_word ("
            \n"); + add_html_block_elt ("
              \n"); in_paragraph = 0; } else - add_word (dl_tag); + { /* We are just starting, so this
              + has no
              children yet. */ + html_deflist_has_term = 0; + add_html_block_elt ("
              \n"); + } } if (xml) xml_begin_table (type, insertion_stack->item_function); + + while (input_text[input_text_offset] == '\n' + && input_text[input_text_offset+1] == '\n') + { + line_number++; + input_text_offset++; + } + break; case enumerate: @@ -636,7 +685,7 @@ begin_insertion (type) start_enumerating (*enumeration_arg, ENUM_ALPHA); break; - /* @group does nothing special in makeinfo. */ + /* @group produces no output in info. */ case group: /* Only close the paragraph if we are not inside of an @example-like environment. */ @@ -658,15 +707,157 @@ begin_insertion (type) case cartouche: if (html) - add_word ("
              \n"); + add_html_block_elt ("

              \n"); if (in_menu) no_discard++; break; + case floatenv: + /* Cannot nest floats, so complain. */ + if (float_active) + { + line_error (_("%cfloat environments cannot be nested"), COMMAND_PREFIX); + pop_insertion (); + break; + } + + float_active++; + + { /* Collect data about this float. */ + /* Example: @float [FLOATTYPE][,XREFLABEL][,POSITION] */ + char floattype[200] = ""; + char xreflabel[200] = ""; + char position[200] = ""; + char *text; + char *caption; + char *shortcaption; + int start_of_end; + int save_line_number = line_number; + int save_input_text_offset = input_text_offset; + int i; + + if (strlen (insertion_stack->item_function) > 0) + { + int i = 0, t = 0, c = 0; + while (insertion_stack->item_function[i]) + { + if (insertion_stack->item_function[i] == ',') + { + switch (t) + { + case 0: + floattype[c] = '\0'; + break; + case 1: + xreflabel[c] = '\0'; + break; + case 2: + position[c] = '\0'; + break; + } + c = 0; + t++; + i++; + continue; + } + + switch (t) + { + case 0: + floattype[c] = insertion_stack->item_function[i]; + break; + case 1: + xreflabel[c] = insertion_stack->item_function[i]; + break; + case 2: + position[c] = insertion_stack->item_function[i]; + break; + } + c++; + i++; + } + } + + skip_whitespace_and_newlines (); + + start_of_end = get_until ("\n@end float", &text); + + /* Get also the @caption. */ + i = search_forward_until_pos ("\n@caption{", + save_input_text_offset, start_of_end); + if (i > -1) + { + input_text_offset = i + sizeof ("\n@caption{") - 1; + get_until_in_braces ("\n@end float", &caption); + input_text_offset = save_input_text_offset; + } + else + caption = ""; + + /* ... and the @shortcaption. */ + i = search_forward_until_pos ("\n@shortcaption{", + save_input_text_offset, start_of_end); + if (i > -1) + { + input_text_offset = i + sizeof ("\n@shortcaption{") - 1; + get_until_in_braces ("\n@end float", &shortcaption); + input_text_offset = save_input_text_offset; + } + else + shortcaption = ""; + + canon_white (xreflabel); + canon_white (floattype); + canon_white (position); + canon_white (caption); + canon_white (shortcaption); + + add_new_float (xstrdup (xreflabel), + xstrdup (caption), xstrdup (shortcaption), + xstrdup (floattype), xstrdup (position)); + + /* Move to the start of the @float so the contents get processed as + usual. */ + input_text_offset = save_input_text_offset; + line_number = save_line_number; + } + + if (html) + add_html_block_elt ("
              \n"); + else if (docbook) + xml_insert_element (FLOAT, START); + else if (xml) + { + xml_insert_element_with_attribute (FLOAT, START, + "name=\"%s\"", current_float_id ()); + + xml_insert_element (FLOATTYPE, START); + execute_string ("%s", current_float_type ()); + xml_insert_element (FLOATTYPE, END); + + xml_insert_element (FLOATPOS, START); + execute_string ("%s", current_float_position ()); + xml_insert_element (FLOATPOS, END); + } + else + { /* Info */ + close_single_paragraph (); + inhibit_paragraph_indentation = 1; + } + + /* Anchor now. Note that XML documents get their + anchors with tag. */ + if ((!xml || docbook) && strlen (current_float_id ()) > 0) + execute_string ("@anchor{%s}", current_float_id ()); + + break; + /* Insertions that are no-ops in info, but do something in TeX. */ case ifclear: + case ifdocbook: case ifhtml: case ifinfo: + case ifnotdocbook: case ifnothtml: case ifnotinfo: case ifnotplaintext: @@ -681,8 +872,25 @@ begin_insertion (type) no_discard++; break; + case rawdocbook: case rawhtml: - escape_html = 0; + case rawxml: + raw_output_block++; + + if (raw_output_block > 0) + { + xml_no_para = 1; + escape_html = 0; + xml_keep_space++; + } + + { + /* Some deuglification for improved readability. */ + extern int xml_in_para; + if (xml && !xml_in_para && xml_indentation_increment > 0) + add_char ('\n'); + } + break; case defcv: @@ -694,6 +902,7 @@ begin_insertion (type) case defopt: case defspec: case deftp: + case deftypecv: case deftypefn: case deftypefun: case deftypeivar: @@ -708,6 +917,8 @@ begin_insertion (type) filling_enabled = indented_fill = 1; current_indent += default_indentation_increment; no_indent = 0; + if (xml) + xml_begin_definition (); break; case flushleft: @@ -715,7 +926,7 @@ begin_insertion (type) inhibit_paragraph_indentation = 1; filling_enabled = indented_fill = no_indent = 0; if (html) - add_word ("
              "); + add_html_block_elt ("
              "); break; case flushright: @@ -724,12 +935,15 @@ begin_insertion (type) inhibit_paragraph_indentation = 1; force_flush_right++; if (html) - add_word ("
              "); + add_html_block_elt ("
              "); + break; + + case titlepage: + xml_insert_element (TITLEPAGE, START); break; default: line_error ("begin_insertion internal error: type=%d", type); - } if (!no_discard) @@ -740,11 +954,10 @@ begin_insertion (type) `bad_type', TYPE gets translated to match the value currently on top of the stack. Otherwise, if TYPE doesn't match the top of the insertion stack, give error. */ -void -end_insertion (type) - enum insertion_type type; +static void +end_insertion (int type) { - enum insertion_type temp_type; + int temp_type; if (!insertion_level) return; @@ -771,23 +984,28 @@ end_insertion (type) case ifinfo: case documentdescription: break; - case copying: - xml_insert_element (COPYING, END); - break; case quotation: - xml_insert_element (QUOTATION, END); + xml_insert_quotation ("", END); break; case example: xml_insert_element (EXAMPLE, END); + if (docbook && current_insertion_type () == floatenv) + xml_insert_element (FLOATEXAMPLE, END); break; case smallexample: xml_insert_element (SMALLEXAMPLE, END); + if (docbook && current_insertion_type () == floatenv) + xml_insert_element (FLOATEXAMPLE, END); break; case lisp: xml_insert_element (LISP, END); + if (docbook && current_insertion_type () == floatenv) + xml_insert_element (FLOATEXAMPLE, END); break; case smalllisp: xml_insert_element (SMALLLISP, END); + if (docbook && current_insertion_type () == floatenv) + xml_insert_element (FLOATEXAMPLE, END); break; case cartouche: xml_insert_element (CARTOUCHE, END); @@ -817,21 +1035,28 @@ end_insertion (type) xml_end_table (type); break; case enumerate: - xml_end_enumerate (type); + xml_end_enumerate (); break; case group: xml_insert_element (GROUP, END); break; + case titlepage: + xml_insert_element (TITLEPAGE, END); + break; } } switch (type) { /* Insertions which have no effect on paragraph formatting. */ case copying: - case documentdescription: + line_number--; + break; + case ifclear: + case ifdocbook: case ifinfo: case ifhtml: + case ifnotdocbook: case ifnothtml: case ifnotinfo: case ifnotplaintext: @@ -842,13 +1067,29 @@ end_insertion (type) case iftex: case ifxml: case rawtex: + case titlepage: break; + case rawdocbook: case rawhtml: - escape_html = 1; + case rawxml: + raw_output_block--; + + if (raw_output_block <= 0) + { + xml_no_para = 0; + escape_html = 1; + xml_keep_space--; + } + + if ((xml || html) && output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; break; case detailmenu: + if (xml) + xml_insert_element (DETAILMENU, END); + in_detailmenu--; /* No longer hacking menus. */ if (!in_menu) { @@ -862,11 +1103,17 @@ end_insertion (type) close_insertion_paragraph (); break; + case documentdescription: + if (xml) + insert_string (document_description); + xml_insert_element (DOCUMENTDESCRIPTION, END); + break; + case menu: in_menu--; /* No longer hacking menus. */ if (html && !no_headers) - add_word ("\n"); - else if (!no_headers) + add_html_block_elt ("\n"); + else if (!no_headers && !xml) close_insertion_paragraph (); break; @@ -879,23 +1126,76 @@ end_insertion (type) close_insertion_paragraph (); current_indent -= default_indentation_increment; if (html) - add_word ("\n"); + add_html_block_elt ("\n"); break; case flushleft: if (html) - add_word ("
              \n"); + add_html_block_elt ("
              \n"); close_insertion_paragraph (); break; case cartouche: if (html) - add_word ("
              \n"); + add_html_block_elt ("

              \n"); close_insertion_paragraph (); break; case group: - close_insertion_paragraph (); + if (!xml || docbook) + close_insertion_paragraph (); + break; + + case floatenv: + if (xml) + xml_insert_element (FLOAT, END); + else + { + if (html) + add_html_block_elt ("

              "); + else + close_paragraph (); + + no_indent = 1; + + /* Legend: + 1) @float Foo,lbl & no caption: Foo 1.1 + 2) @float Foo & no caption: Foo + 3) @float ,lbl & no caption: 1.1 + 4) @float & no caption: */ + + if (!xml && !html) + indent (current_indent); + + if (strlen (current_float_type ())) + execute_string ("%s", current_float_type ()); + + if (strlen (current_float_id ()) > 0) + { + if (strlen (current_float_type ()) > 0) + add_char (' '); + + add_word (current_float_number ()); + } + + if (strlen (current_float_title ()) > 0) + { + if (strlen (current_float_type ()) > 0 + || strlen (current_float_id ()) > 0) + insert_string (": "); + + execute_string ("%s", current_float_title ()); + } + + /* Indent the following paragraph. */ + inhibit_paragraph_indentation = 0; + + if (html) + add_word ("

              \n"); + else + close_paragraph (); + } + float_active--; break; case format: @@ -909,15 +1209,30 @@ end_insertion (type) case quotation: /* @format and @smallformat are the only fixed_width insertion without a change in indentation. */ - if (type != format && type != smallformat) + if (type != format && type != smallformat && type != quotation) + current_indent -= example_indentation_increment; + else if (type == quotation) current_indent -= default_indentation_increment; if (html) - add_word (type == quotation ? "
          \n" : "\n"); + { /* The complex code in close_paragraph that kills whitespace + does not function here, since we've inserted non-whitespace + (the ) before it. The indentation already got + inserted at the end of the last example line, so we have to + delete it, or browsers wind up showing an extra blank line. */ + kill_self_indent (default_indentation_increment); + add_html_block_elt (type == quotation + ? "
          \n" : "\n"); + } /* The ending of one of these insertions always marks the - start of a new paragraph. */ - close_insertion_paragraph (); + start of a new paragraph, except for the XML output. */ + if (!xml || docbook) + close_insertion_paragraph (); + + /* closes paragraph without messing with

          . */ + if (html && type != quotation) + paragraph_is_open = 0; break; case table: @@ -925,28 +1240,28 @@ end_insertion (type) case vtable: current_indent -= default_indentation_increment; if (html) - add_word ("
      \n"); + add_html_block_elt ("
      \n"); close_insertion_paragraph (); break; case itemize: current_indent -= default_indentation_increment; if (html) - add_word ("
    \n"); + add_html_block_elt ("
\n"); close_insertion_paragraph (); break; case flushright: force_flush_right--; if (html) - add_word ("\n"); + add_html_block_elt ("\n"); close_insertion_paragraph (); break; /* Handle the @defun insertions with this default clause. */ default: { - enum insertion_type base_type; + int base_type; if (type < defcv || type > defvr) line_error ("end_insertion internal error: type=%d", type); @@ -957,6 +1272,7 @@ end_insertion (type) case deffn: case defvr: case deftp: + case deftypecv: case deftypefn: case deftypevr: case defcv: @@ -965,8 +1281,16 @@ end_insertion (type) case deftypeop: case deftypeivar: if (html) - /* close the tables which has been opened in defun.c */ - add_word ("\n\n"); + { + if (paragraph_is_open) + add_html_block_elt ("

"); + /* close the div and blockquote which has been opened in defun.c */ + if (!rollback_empty_tag ("blockquote")) + add_html_block_elt (""); + add_html_block_elt ("\n"); + } + if (xml) + xml_end_definition (); break; } /* switch (base_type)... */ @@ -991,8 +1315,7 @@ end_insertion (type) @if... conditionals, otherwise not. This is because conditionals can cross node boundaries. Always happens with the @top node, for example. */ void -discard_insertions (specials_ok) - int specials_ok; +discard_insertions (int specials_ok) { int real_line_number = line_number; while (insertion_stack) @@ -1000,7 +1323,9 @@ discard_insertions (specials_ok) if (specials_ok && ((ifclear <= insertion_stack->insertion && insertion_stack->insertion <= iftex) + || insertion_stack->insertion == rawdocbook || insertion_stack->insertion == rawhtml + || insertion_stack->insertion == rawxml || insertion_stack->insertion == rawtex)) break; else @@ -1020,71 +1345,125 @@ discard_insertions (specials_ok) /* Insertion (environment) commands. */ void -cm_quotation () +cm_quotation (void) { - if (xml) - xml_insert_element (QUOTATION, START); + /* We start the blockquote element in the insertion. */ begin_insertion (quotation); } void -cm_example () +cm_example (void) { + if (docbook && current_insertion_type () == floatenv) + xml_begin_docbook_float (FLOATEXAMPLE); + if (xml) - xml_insert_element (EXAMPLE, START); + { + /* Rollback previous newlines. These occur between + and . */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + + xml_insert_element (EXAMPLE, START); + + /* Make sure example text is starting on a new line + for improved readability. */ + if (docbook) + add_char ('\n'); + } + begin_insertion (example); } void -cm_smallexample () +cm_smallexample (void) { + if (docbook && current_insertion_type () == floatenv) + xml_begin_docbook_float (FLOATEXAMPLE); + if (xml) - xml_insert_element (SMALLEXAMPLE, START); + { + /* See cm_example comments about newlines. */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + xml_insert_element (SMALLEXAMPLE, START); + if (docbook) + add_char ('\n'); + } + begin_insertion (smallexample); } void -cm_lisp () +cm_lisp (void) { + if (docbook && current_insertion_type () == floatenv) + xml_begin_docbook_float (FLOATEXAMPLE); + if (xml) - xml_insert_element (LISP, START); + { + /* See cm_example comments about newlines. */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + xml_insert_element (LISP, START); + if (docbook) + add_char ('\n'); + } + begin_insertion (lisp); } void -cm_smalllisp () +cm_smalllisp (void) { + if (docbook && current_insertion_type () == floatenv) + xml_begin_docbook_float (FLOATEXAMPLE); + if (xml) - xml_insert_element (SMALLLISP, START); + { + /* See cm_example comments about newlines. */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + xml_insert_element (SMALLLISP, START); + if (docbook) + add_char ('\n'); + } + begin_insertion (smalllisp); } void -cm_cartouche () +cm_cartouche (void) { + if (docbook && current_insertion_type () == floatenv) + xml_begin_docbook_float (CARTOUCHE); + if (xml) xml_insert_element (CARTOUCHE, START); begin_insertion (cartouche); } void -cm_copying () +cm_copying (void) { - if (xml) - xml_insert_element (COPYING, START); begin_insertion (copying); } /* Not an insertion, despite the name, but it goes with cm_copying. */ void -cm_insert_copying () +cm_insert_copying (void) { - if (copying_text) - { /* insert_string rather than add_word because we've already done - full expansion on copying_text when we saved it. */ - insert_string (copying_text); - insert ('\n'); - + if (!copying_text) + { + warning ("@copying not used before %s", command); + return; + } + + execute_string ("%s", copying_text); + + if (!xml && !html) + { + add_word ("\n\n"); /* Update output_position so that the node positions in the tag tables will take account of the copying text. */ flush_output (); @@ -1092,7 +1471,7 @@ cm_insert_copying () } void -cm_format () +cm_format (void) { if (xml) { @@ -1102,56 +1481,94 @@ cm_format () xml_in_abstract = 1; } else - xml_insert_element (FORMAT, START); + { + /* See cm_example comments about newlines. */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + xml_insert_element (FORMAT, START); + if (docbook) + add_char ('\n'); + } } begin_insertion (format); } void -cm_smallformat () +cm_smallformat (void) { if (xml) - xml_insert_element (SMALLFORMAT, START); + { + /* See cm_example comments about newlines. */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + xml_insert_element (SMALLFORMAT, START); + if (docbook) + add_char ('\n'); + } + begin_insertion (smallformat); } void -cm_display () +cm_display (void) { if (xml) - xml_insert_element (DISPLAY, START); + { + /* See cm_example comments about newlines. */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + xml_insert_element (DISPLAY, START); + if (docbook) + add_char ('\n'); + } + begin_insertion (display); } void -cm_smalldisplay () +cm_smalldisplay (void) { if (xml) - xml_insert_element (SMALLDISPLAY, START); + { + /* See cm_example comments about newlines. */ + if (output_paragraph[output_paragraph_offset-1] == '\n') + output_paragraph_offset--; + xml_insert_element (SMALLDISPLAY, START); + if (docbook) + add_char ('\n'); + } + begin_insertion (smalldisplay); } void -cm_direntry () +cm_direntry (void) { - if (html || xml) + if (html || xml || no_headers) command_name_condition (); else begin_insertion (direntry); } void -cm_documentdescription () +cm_documentdescription (void) { - if (html || xml) + if (html) begin_insertion (documentdescription); + + else if (xml) + { + xml_insert_element (DOCUMENTDESCRIPTION, START); + begin_insertion (documentdescription); + } + else command_name_condition (); } void -cm_itemize () +cm_itemize (void) { begin_insertion (itemize); } @@ -1159,9 +1576,7 @@ cm_itemize () /* Start an enumeration insertion of type TYPE. If the user supplied no argument on the line, then use DEFAULT_STRING as the initial string. */ static void -do_enumeration (type, default_string) - int type; - char *default_string; +do_enumeration (int type, char *default_string) { get_until_in_line (0, ".", &enumeration_arg); canon_white (enumeration_arg); @@ -1188,7 +1603,7 @@ do_enumeration (type, default_string) } void -cm_enumerate () +cm_enumerate (void) { do_enumeration (enumerate, "1"); } @@ -1202,15 +1617,16 @@ cm_enumerate () verbatim environment may be encapsulated in an @example environment, for example. */ void -handle_verbatim_environment (find_end_verbatim) - int find_end_verbatim; +handle_verbatim_environment (int find_end_verbatim) { int character; int seen_end = 0; int save_filling_enabled = filling_enabled; int save_inhibit_paragraph_indentation = inhibit_paragraph_indentation; + int save_escape_html = escape_html; - close_single_paragraph (); + if (!insertion_stack) + close_single_paragraph (); /* no blank lines if not at outer level */ inhibit_paragraph_indentation = 1; filling_enabled = 0; in_fixed_width_font++; @@ -1222,7 +1638,22 @@ handle_verbatim_environment (find_end_verbatim) */ if (html) - add_word ("
");
+    { /* If inside @example, we'll be preceded by the indentation
+         already.  Browsers will ignore those spaces because we're about
+         to start another 
 (don't ask me).  So, wipe them out for
+         cleanliness, and re-insert.  */
+      int i;
+      kill_self_indent (default_indentation_increment);
+      add_html_block_elt ("
");
+      for (i = current_indent; i > 0; i--)
+        add_char (' ');
+    }
+  else if (xml)
+    {
+      xml_insert_element (VERBATIM, START);
+      escape_html = 0;
+      add_word (" sizeof (END_VERBATIM))
           && !strncmp (&input_text[input_text_offset+1], END_VERBATIM,
@@ -1257,7 +1687,16 @@ handle_verbatim_environment (find_end_verbatim)
     warning (_("end of file inside verbatim block"));
 
   if (html)
-    add_word ("
"); + { /* See comments in example case above. */ + kill_self_indent (default_indentation_increment); + add_word ("
"); + } + else if (xml) + { + add_word ("]]>"); + xml_insert_element (VERBATIM, END); + escape_html = save_escape_html; + } in_fixed_width_font--; filling_enabled = save_filling_enabled; @@ -1265,53 +1704,89 @@ handle_verbatim_environment (find_end_verbatim) } void -cm_verbatim () +cm_verbatim (void) { handle_verbatim_environment (1); } void -cm_table () +cm_table (void) { begin_insertion (table); } void -cm_multitable () +cm_multitable (void) { begin_insertion (multitable); /* @@ */ } void -cm_ftable () +cm_ftable (void) { begin_insertion (ftable); } void -cm_vtable () +cm_vtable (void) { begin_insertion (vtable); } void -cm_group () +cm_group (void) { begin_insertion (group); } /* Insert raw HTML (no escaping of `<' etc.). */ void -cm_html () +cm_html (int arg) { - if (process_html || process_xml) + if (process_html) begin_insertion (rawhtml); else command_name_condition (); } void -cm_ifhtml () +cm_xml (int arg) +{ + if (process_xml) + begin_insertion (rawxml); + else + command_name_condition (); +} + +void +cm_docbook (int arg) +{ + if (process_docbook) + begin_insertion (rawdocbook); + else + command_name_condition (); +} + +void +cm_ifdocbook (void) +{ + if (process_docbook) + begin_insertion (ifdocbook); + else + command_name_condition (); +} + +void +cm_ifnotdocbook (void) +{ + if (!process_docbook) + begin_insertion (ifnotdocbook); + else + command_name_condition (); +} + +void +cm_ifhtml (void) { if (process_html) begin_insertion (ifhtml); @@ -1320,7 +1795,7 @@ cm_ifhtml () } void -cm_ifnothtml () +cm_ifnothtml (void) { if (!process_html) begin_insertion (ifnothtml); @@ -1330,7 +1805,7 @@ cm_ifnothtml () void -cm_ifinfo () +cm_ifinfo (void) { if (process_info) begin_insertion (ifinfo); @@ -1339,7 +1814,7 @@ cm_ifinfo () } void -cm_ifnotinfo () +cm_ifnotinfo (void) { if (!process_info) begin_insertion (ifnotinfo); @@ -1349,7 +1824,7 @@ cm_ifnotinfo () void -cm_ifplaintext () +cm_ifplaintext (void) { if (process_plaintext) begin_insertion (ifplaintext); @@ -1358,7 +1833,7 @@ cm_ifplaintext () } void -cm_ifnotplaintext () +cm_ifnotplaintext (void) { if (!process_plaintext) begin_insertion (ifnotplaintext); @@ -1368,7 +1843,7 @@ cm_ifnotplaintext () void -cm_tex () +cm_tex (void) { if (process_tex) begin_insertion (rawtex); @@ -1377,7 +1852,7 @@ cm_tex () } void -cm_iftex () +cm_iftex (void) { if (process_tex) begin_insertion (iftex); @@ -1386,7 +1861,7 @@ cm_iftex () } void -cm_ifnottex () +cm_ifnottex (void) { if (!process_tex) begin_insertion (ifnottex); @@ -1395,7 +1870,7 @@ cm_ifnottex () } void -cm_ifxml () +cm_ifxml (void) { if (process_xml) begin_insertion (ifxml); @@ -1404,7 +1879,7 @@ cm_ifxml () } void -cm_ifnotxml () +cm_ifnotxml (void) { if (!process_xml) begin_insertion (ifnotxml); @@ -1413,9 +1888,47 @@ cm_ifnotxml () } +/* Generic xrefable block with a caption. */ +void +cm_float (void) +{ + begin_insertion (floatenv); +} + +void +cm_caption (int arg) +{ + char *temp; + + /* This is a no_op command for most formats, as we handle it during @float + insertion. For XML though, we handle it here to keep document structure + as close as possible, to the Texinfo source. */ + + /* Everything is already handled at START. */ + if (arg == END) + return; + + /* Check if it's mislocated. */ + if (current_insertion_type () != floatenv) + line_error (_("@%s not meaningful outside `@float' environment"), command); + + get_until_in_braces ("\n@end float", &temp); + + if (xml) + { + int elt = STREQ (command, "shortcaption") ? SHORTCAPTION : CAPTION; + xml_insert_element (elt, START); + if (!docbook) + execute_string ("%s", temp); + xml_insert_element (elt, END); + } + + free (temp); +} + /* Begin an insertion where the lines are not filled or indented. */ void -cm_flushleft () +cm_flushleft (void) { begin_insertion (flushleft); } @@ -1423,15 +1936,15 @@ cm_flushleft () /* Begin an insertion where the lines are not filled, and each line is forced to the right-hand side of the page. */ void -cm_flushright () +cm_flushright (void) { begin_insertion (flushright); } void -cm_menu () +cm_menu (void) { - if (current_node == NULL) + if (current_node == NULL && !macro_expansion_output_stream) { warning (_("@menu seen before first @node, creating `Top' node")); warning (_("perhaps your @top node should be wrapped in @ifnottex rather than @ifinfo?")); @@ -1442,22 +1955,108 @@ cm_menu () } void -cm_detailmenu () +cm_detailmenu (void) { - if (current_node == NULL) + if (current_node == NULL && !macro_expansion_output_stream) { /* Problems anyway, @detailmenu should always be inside @menu. */ warning (_("@detailmenu seen before first node, creating `Top' node")); execute_string ("@node top\n@top Top\n"); } begin_insertion (detailmenu); } + +/* Title page commands. */ + +void +cm_titlepage (void) +{ + titlepage_cmd_present = 1; + if (xml && !docbook) + begin_insertion (titlepage); + else + command_name_condition (); +} + +void +cm_author (void) +{ + char *rest; + get_rest_of_line (1, &rest); + + if (is_in_insertion_of_type (quotation)) + { + if (html) + add_word_args ("— %s", rest); + else if (docbook) + { + /* FIXME Ideally, we should use an attribution element, + but they are supposed to be at the start of quotation + blocks. So to avoid looking ahead mess, let's just + use mdash like HTML for now. */ + xml_insert_entity ("mdash"); + add_word (rest); + } + else if (xml) + { + xml_insert_element (AUTHOR, START); + add_word (rest); + xml_insert_element (AUTHOR, END); + } + else + add_word_args ("-- %s", rest); + } + else if (is_in_insertion_of_type (titlepage)) + { + if (xml && !docbook) + { + xml_insert_element (AUTHOR, START); + add_word (rest); + xml_insert_element (AUTHOR, END); + } + } + else + line_error (_("@%s not meaningful outside `@titlepage' and `@quotation' environments"), + command); + + free (rest); +} + +void +cm_titlepage_cmds (void) +{ + char *rest; + + get_rest_of_line (1, &rest); + + if (!is_in_insertion_of_type (titlepage)) + line_error (_("@%s not meaningful outside `@titlepage' environment"), + command); + + if (xml && !docbook) + { + int elt = 0; + + if (STREQ (command, "title")) + elt = BOOKTITLE; + else if (STREQ (command, "subtitle")) + elt = BOOKSUBTITLE; + + xml_insert_element (elt, START); + add_word (rest); + xml_insert_element (elt, END); + } + + free (rest); +} /* End existing insertion block. */ void -cm_end () +cm_end (void) { char *temp; - enum insertion_type type; + int type; + + get_rest_of_line (0, &temp); if (!insertion_level) { @@ -1465,8 +2064,6 @@ cm_end () return; } - get_rest_of_line (0, &temp); - if (temp[0] == 0) line_error (_("`%c%s' needs something after it"), COMMAND_PREFIX, command); @@ -1474,8 +2071,8 @@ cm_end () if (type == bad_type) { - line_error (_("Bad argument to `%s', `%s', using `%s'"), - command, temp, insertion_type_pname (current_insertion_type ())); + line_error (_("Bad argument `%s' to `@%s', using `%s'"), + temp, command, insertion_type_pname (current_insertion_type ())); } if (xml && type == menu) /* fixme */ { @@ -1490,9 +2087,8 @@ cm_end () static int itemx_flag = 0; /* Return whether CMD takes a brace-delimited {arg}. */ -/*static */int -command_needs_braces (cmd) - char *cmd; +int +command_needs_braces (char *cmd) { int i; for (i = 0; command_table[i].name; i++) @@ -1506,7 +2102,7 @@ command_needs_braces (cmd) void -cm_item () +cm_item (void) { char *rest_of_line, *item_func; @@ -1548,7 +2144,9 @@ cm_item () case ifset: case iftex: case ifxml: + case rawdocbook: case rawhtml: + case rawxml: case rawtex: case tex: case cartouche: @@ -1585,14 +2183,7 @@ cm_item () else { if (html) - { - if (in_paragraph) - { - add_word ("

"); - in_paragraph = 0; - } - add_word ("
  • "); - } + add_html_block_elt ("
  • "); else if (xml) xml_begin_item (); else @@ -1646,17 +2237,11 @@ cm_item () case ftable: case vtable: if (html) - { - static int last_html_output_position = 0; - - /* If nothing has been output since the last
    , + { /* If nothing has been output since the last
    , remove the empty
    element. Some browsers render an extra empty line for
    , which makes @itemx conversion look ugly. */ - if (last_html_output_position == output_position - && strncmp ((char *) output_paragraph, "
    ", - output_paragraph_offset) == 0) - output_paragraph_offset = 0; + rollback_empty_tag ("dd"); /* Force the browser to render one blank line before each new @item in a table. But don't do that if @@ -1666,14 +2251,14 @@ cm_item () Note that there are some browsers which ignore
    in this context, but I cannot find any way to force them all render exactly one blank line. */ - if (!itemx_flag - && ((output_paragraph_offset < sizeof (dl_tag) + 1) - || strncmp ((char *) output_paragraph - + output_paragraph_offset - sizeof (dl_tag) + 1, - dl_tag, sizeof (dl_tag) - 1) != 0)) - add_word ("
    "); + if (!itemx_flag && html_deflist_has_term) + add_html_block_elt ("
    "); + + /* We are about to insert a
    , so this
    has a term. + Feel free to insert a
    next time. :) */ + html_deflist_has_term = 1; - add_word ("
    "); + add_html_block_elt ("
    "); if (item_func && *item_func) execute_string ("%s{%s}", item_func, rest_of_line); else @@ -1684,15 +2269,19 @@ cm_item () if (current_insertion_type () == vtable) execute_string ("%cvindex %s\n", COMMAND_PREFIX, rest_of_line); - /* Make sure output_position is updated, so we could - remember it. */ - close_single_paragraph (); - last_html_output_position = output_position; - add_word ("
    "); + + add_html_block_elt ("
    "); } else if (xml) /* && docbook)*/ /* 05-08 */ { xml_begin_table_item (); + + if (!docbook && current_insertion_type () == ftable) + execute_string ("%cfindex %s\n", COMMAND_PREFIX, rest_of_line); + + if (!docbook && current_insertion_type () == vtable) + execute_string ("%cvindex %s\n", COMMAND_PREFIX, rest_of_line); + if (item_func && *item_func) execute_string ("%s{%s}", item_func, rest_of_line); else @@ -1770,9 +2359,18 @@ cm_item () } void -cm_itemx () +cm_itemx (void) { itemx_flag++; cm_item (); itemx_flag--; } + +int headitem_flag = 0; + +void +cm_headitem (void) +{ + headitem_flag = 1; + cm_item (); +} diff --git a/contrib/texinfo/makeinfo/insertion.h b/contrib/texinfo/makeinfo/insertion.h index 17916e7..ace5571 100644 --- a/contrib/texinfo/makeinfo/insertion.h +++ b/contrib/texinfo/makeinfo/insertion.h @@ -1,7 +1,7 @@ /* insertion.h -- declarations for insertion.c. - $Id: insertion.h,v 1.2 2002/09/29 19:15:20 karl Exp $ + $Id: insertion.h,v 1.10 2004/04/11 17:56:47 karl Exp $ - Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,14 +24,15 @@ enum insertion_type { cartouche, copying, defcv, deffn, defivar, defmac, defmethod, defop, - defopt, defspec, deftp, deftypefn, deftypefun, deftypeivar, + defopt, defspec, deftp, deftypecv, deftypefn, deftypefun, deftypeivar, deftypemethod, deftypeop, deftypevar, deftypevr, defun, defvar, defvr, detailmenu, direntry, display, documentdescription, enumerate, - example, flushleft, flushright, format, ftable, group, ifclear, - ifhtml, ifinfo, ifnothtml, ifnotinfo, ifnotplaintext, ifnottex, ifnotxml, - ifplaintext, ifset, iftex, ifxml, itemize, lisp, menu, multitable, quotation, - rawhtml, rawtex, smalldisplay, smallexample, smallformat, smalllisp, - verbatim, table, tex, vtable, bad_type + example, floatenv, flushleft, flushright, format, ftable, group, + ifclear, ifdocbook, ifhtml, ifinfo, ifnotdocbook, ifnothtml, ifnotinfo, + ifnotplaintext, ifnottex, ifnotxml, ifplaintext, ifset, iftex, ifxml, + itemize, lisp, menu, multitable, quotation, rawdocbook, rawhtml, rawtex, + rawxml, smalldisplay, smallexample, smallformat, smalllisp, verbatim, + table, tex, vtable, titlepage, bad_type }; typedef struct istack_elt @@ -42,12 +43,11 @@ typedef struct istack_elt int line_number; int filling_enabled; int indented_fill; - enum insertion_type insertion; + int insertion; int inhibited; int in_fixed_width_font; } INSERTION_ELT; - extern int insertion_level; extern INSERTION_ELT *insertion_stack; extern int in_menu; @@ -55,10 +55,24 @@ extern int in_detailmenu; extern int had_menu_commentary; extern int in_paragraph; -extern void command_name_condition (); -extern void cm_ifhtml (), cm_ifnothtml(), cm_html (); -extern void cm_ifinfo (), cm_ifnotinfo (); -extern void cm_ifplaintext (), cm_ifnotplaintext(); -extern void cm_iftex (), cm_ifnottex (), cm_tex (); -extern void cm_ifxml (), cm_ifnotxml (); +extern int headitem_flag; +extern int after_headitem; + +extern void init_insertion_stack (void); +extern void command_name_condition (void); +extern void cm_ifdocbook (void), cm_ifnotdocbook(void), cm_docbook (int arg); +extern void cm_ifhtml (void), cm_ifnothtml(void), cm_html (int arg); +extern void cm_ifinfo (void), cm_ifnotinfo (void); +extern void cm_ifplaintext (void), cm_ifnotplaintext(void); +extern void cm_iftex (void), cm_ifnottex (void), cm_tex (void); +extern void cm_ifxml (void), cm_ifnotxml (void), cm_xml (int arg); +extern void handle_verbatim_environment (int find_end_verbatim); +extern void begin_insertion (enum insertion_type type); +extern void pop_insertion (void); +extern void discard_insertions (int specials_ok); + +extern int is_in_insertion_of_type (int type); +extern int command_needs_braces (char *cmd); + +extern enum insertion_type find_type_from_name (char *name); #endif /* !INSERTION_H */ diff --git a/contrib/texinfo/makeinfo/lang.c b/contrib/texinfo/makeinfo/lang.c index 2938196..c72e8db 100644 --- a/contrib/texinfo/makeinfo/lang.c +++ b/contrib/texinfo/makeinfo/lang.c @@ -1,7 +1,8 @@ /* lang.c -- language-dependent support. - $Id: lang.c,v 1.8 2003/05/01 00:05:27 karl Exp $ + $Id: lang.c,v 1.14 2004/11/22 23:57:33 karl Exp $ - Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +22,7 @@ #include "system.h" #include "cmds.h" +#include "files.h" #include "lang.h" #include "makeinfo.h" #include "xml.h" @@ -31,6 +33,9 @@ encoding_code_type document_encoding_code = no_encoding; /* Current language code; default is English. */ language_code_type language_code = en; +/* By default, unsupported encoding is an empty string. */ +char *unknown_encoding = NULL; + static iso_map_type us_ascii_map [] = {{NULL, 0, 0}}; /* ASCII map is trivial */ /* Translation table between HTML and ISO Codes. The last item is @@ -137,6 +142,126 @@ static iso_map_type iso8859_1_map [] = { { NULL, 0, 0 } }; + +/* ISO 8859-15, also known as Latin 9, differs from Latin 1 in only a + few positions. http://www.cs.tut.fi/~jkorpela/latin9.html has a good + explanation and listing, summarized here. The names are abbreviated + from the official Unicode names, to fit in a decent line length. + + code position + dec oct hex latin1 latin1 name latin9 latin9 name + + 164 0244 0xA4 U+00A4 currency symbol U+20AC euro sign + 166 0246 0xA6 U+00A6 broken bar U+0160 S with caron + 168 0250 0xA8 U+00A8 diaeresis U+0161 s with caron + 180 0264 0xB4 U+00B4 acute accent U+017D Z with caron + 184 0270 0xB8 U+00B8 cedilla U+017E z with caron + 188 0274 0xBC U+00BC fraction 1/4 U+0152 ligature OE + 189 0275 0xBD U+00BD fraction 1/2 U+0153 ligature oe + 190 0276 0xBE U+00BE fraction 3/4 U+0178 Y with diaeresis +*/ + +static iso_map_type iso8859_15_map [] = { + { "nbsp", 0xA0, 0x00A0 }, + { "iexcl", 0xA1, 0x00A1 }, + { "cent", 0xA2, 0x00A2 }, + { "pound", 0xA3, 0x00A3 }, + { "euro", 0xA4, 0x20AC }, + { "yen", 0xA5, 0x00A5 }, + { "Scaron", 0xA6, 0x0160 }, + { "sect", 0xA7, 0x00A7 }, + { "scaron", 0xA8, 0x0161 }, + { "copy", 0xA9, 0x00A9 }, + { "ordf", 0xAA, 0x00AA }, + { "laquo", 0xAB, 0x00AB }, + { "not", 0xAC, 0x00AC }, + { "shy", 0xAD, 0x00AD }, + { "reg", 0xAE, 0x00AE }, + { "hibar", 0xAF, 0x00AF }, + { "deg", 0xB0, 0x00B0 }, + { "plusmn", 0xB1, 0x00B1 }, + { "sup2", 0xB2, 0x00B2 }, + { "sup3", 0xB3, 0x00B3 }, + { "Zcaron", 0xB4, 0x017D }, + { "micro", 0xB5, 0x00B5 }, + { "para", 0xB6, 0x00B6 }, + { "middot", 0xB7, 0x00B7 }, + { "zcaron", 0xB8, 0x017E }, + { "sup1", 0xB9, 0x00B9 }, + { "ordm", 0xBA, 0x00BA }, + { "raquo", 0xBB, 0x00BB }, + { "OElig", 0xBC, 0x0152 }, + { "oelig", 0xBD, 0x0153 }, + { "Yuml", 0xBE, 0x0178 }, + { "iquest", 0xBF, 0x00BF }, + { "Agrave", 0xC0, 0x00C0 }, + { "Aacute", 0xC1, 0x00C1 }, + { "Acirc", 0xC2, 0x00C2 }, + { "Atilde", 0xC3, 0x00C3 }, + { "Auml", 0xC4, 0x00C4 }, + { "Aring", 0xC5, 0x00C5 }, + { "AElig", 0xC6, 0x00C6 }, + { "Ccedil", 0xC7, 0x00C7 }, + { "Ccedil", 0xC7, 0x00C7 }, + { "Egrave", 0xC8, 0x00C8 }, + { "Eacute", 0xC9, 0x00C9 }, + { "Ecirc", 0xCA, 0x00CA }, + { "Euml", 0xCB, 0x00CB }, + { "Igrave", 0xCC, 0x00CC }, + { "Iacute", 0xCD, 0x00CD }, + { "Icirc", 0xCE, 0x00CE }, + { "Iuml", 0xCF, 0x00CF }, + { "ETH", 0xD0, 0x00D0 }, + { "Ntilde", 0xD1, 0x00D1 }, + { "Ograve", 0xD2, 0x00D2 }, + { "Oacute", 0xD3, 0x00D3 }, + { "Ocirc", 0xD4, 0x00D4 }, + { "Otilde", 0xD5, 0x00D5 }, + { "Ouml", 0xD6, 0x00D6 }, + { "times", 0xD7, 0x00D7 }, + { "Oslash", 0xD8, 0x00D8 }, + { "Ugrave", 0xD9, 0x00D9 }, + { "Uacute", 0xDA, 0x00DA }, + { "Ucirc", 0xDB, 0x00DB }, + { "Uuml", 0xDC, 0x00DC }, + { "Yacute", 0xDD, 0x00DD }, + { "THORN", 0xDE, 0x00DE }, + { "szlig", 0xDF, 0x00DF }, + { "agrave", 0xE0, 0x00E0 }, + { "aacute", 0xE1, 0x00E1 }, + { "acirc", 0xE2, 0x00E2 }, + { "atilde", 0xE3, 0x00E3 }, + { "auml", 0xE4, 0x00E4 }, + { "aring", 0xE5, 0x00E5 }, + { "aelig", 0xE6, 0x00E6 }, + { "ccedil", 0xE7, 0x00E7 }, + { "egrave", 0xE8, 0x00E8 }, + { "eacute", 0xE9, 0x00E9 }, + { "ecirc", 0xEA, 0x00EA }, + { "euml", 0xEB, 0x00EB }, + { "igrave", 0xEC, 0x00EC }, + { "iacute", 0xED, 0x00ED }, + { "icirc", 0xEE, 0x00EE }, + { "iuml", 0xEF, 0x00EF }, + { "eth", 0xF0, 0x00F0 }, + { "ntilde", 0xF1, 0x00F1 }, + { "ograve", 0xF2, 0x00F2 }, + { "oacute", 0xF3, 0x00F3 }, + { "ocirc", 0xF4, 0x00F4 }, + { "otilde", 0xF5, 0x00F5 }, + { "ouml", 0xF6, 0x00F6 }, + { "divide", 0xF7, 0x00F7 }, + { "oslash", 0xF8, 0x00F8 }, + { "ugrave", 0xF9, 0x00F9 }, + { "uacute", 0xFA, 0x00FA }, + { "ucirc", 0xFB, 0x00FB }, + { "uuml", 0xFC, 0x00FC }, + { "yacute", 0xFD, 0x00FD }, + { "thorn", 0xFE, 0x00FE }, + { "yuml", 0xFF, 0x00FF }, + { NULL, 0, 0 } +}; + /* Date: Mon, 31 Mar 2003 00:19:28 +0200 @@ -262,21 +387,21 @@ static iso_map_type iso8859_2_map [] = { encoding_type encoding_table[] = { { no_encoding, "(no encoding)", NULL }, { US_ASCII, "US-ASCII", us_ascii_map }, - { ISO_8859_1, "ISO-8859-1", (iso_map_type *) iso8859_1_map }, - { ISO_8859_2, "ISO-8859-2", (iso_map_type *) iso8859_2_map }, - { ISO_8859_3, "ISO-8859-3", NULL }, - { ISO_8859_4, "ISO-8859-4", NULL }, - { ISO_8859_5, "ISO-8859-5", NULL }, - { ISO_8859_6, "ISO-8859-6", NULL }, - { ISO_8859_7, "ISO-8859-7", NULL }, - { ISO_8859_8, "ISO-8859-8", NULL }, - { ISO_8859_9, "ISO-8859-9", NULL }, - { ISO_8859_10, "ISO-8859-10", NULL }, - { ISO_8859_11, "ISO-8859-11", NULL }, - { ISO_8859_12, "ISO-8859-12", NULL }, - { ISO_8859_13, "ISO-8859-13", NULL }, - { ISO_8859_14, "ISO-8859-14", NULL }, - { ISO_8859_15, "ISO-8859-15", NULL }, + { ISO_8859_1, "iso-8859-1", (iso_map_type *) iso8859_1_map }, + { ISO_8859_2, "iso-8859-2", (iso_map_type *) iso8859_2_map }, + { ISO_8859_3, "iso-8859-3", NULL }, + { ISO_8859_4, "iso-8859-4", NULL }, + { ISO_8859_5, "iso-8859-5", NULL }, + { ISO_8859_6, "iso-8859-6", NULL }, + { ISO_8859_7, "iso-8859-7", NULL }, + { ISO_8859_8, "iso-8859-8", NULL }, + { ISO_8859_9, "iso-8859-9", NULL }, + { ISO_8859_10, "iso-8859-10", NULL }, + { ISO_8859_11, "iso-8859-11", NULL }, + { ISO_8859_12, "iso-8859-12", NULL }, + { ISO_8859_13, "iso-8859-13", NULL }, + { ISO_8859_14, "iso-8859-14", NULL }, + { ISO_8859_15, "iso-8859-15", (iso_map_type *) iso8859_15_map }, { last_encoding_code, NULL, NULL } }; @@ -423,13 +548,16 @@ language_type language_table[] = { { zu, "zu", "Zulu" }, { last_language_code, NULL, NULL } }; - - /* @documentlanguage. Maybe we'll do something useful with this in the future. For now, we just recognize it. */ + +/* XML documents can make use of this data. Unfortunately, it clashes with + the structure currently used. So instead of enclosing content into + a language block, we just output an empty element. Anyways, a stream based + parser can make good use of it. */ void -cm_documentlanguage () +cm_documentlanguage (void) { language_code_type c; char *lang_arg; @@ -451,6 +579,12 @@ cm_documentlanguage () if (c == last_language_code) warning (_("%s is not a valid ISO 639 language code"), lang_arg); + if (xml && !docbook) + { + xml_insert_element_with_attribute (DOCUMENTLANGUAGE, START, "xml:lang=\"%s\"", lang_arg); + xml_insert_element (DOCUMENTLANGUAGE, END); + } + free (lang_arg); } @@ -460,8 +594,7 @@ cm_documentlanguage () its equivalent. */ static int -cm_search_iso_map (html) - char *html; +cm_search_iso_map (char *html) { int i; iso_map_type *iso = encoding_table[document_encoding_code].isotab; @@ -483,43 +616,88 @@ cm_search_iso_map (html) /* @documentencoding. Set the translation table. */ void -cm_documentencoding () +cm_documentencoding (void) { - encoding_code_type enc; - char *enc_arg; - - get_rest_of_line (1, &enc_arg); - - /* See if we have this encoding. */ - for (enc = no_encoding+1; enc != last_encoding_code; enc++) + if (!handling_delayed_writes) { - if (strcasecmp (enc_arg, encoding_table[enc].encname) == 0) + encoding_code_type enc; + char *enc_arg; + + /* This is ugly and probably needs to apply to other commands' + argument parsing as well. When we're doing @documentencoding, + we're generally in the frontmatter of the document, and so the. + expansion in html/xml/docbook would generally be the empty string. + (Because those modes wait until the first normal text of the + document to start outputting.) The result would thus be a warning + "unrecognized encoding name `'". Sigh. */ + int save_html = html; + int save_xml = xml; + + html = 0; + xml = 0; + get_rest_of_line (1, &enc_arg); + html = save_html; + xml = save_xml; + + /* See if we have this encoding. */ + for (enc = no_encoding+1; enc != last_encoding_code; enc++) { - document_encoding_code = enc; - break; + if (strcasecmp (enc_arg, encoding_table[enc].encname) == 0) + { + document_encoding_code = enc; + break; + } + } + + /* If we didn't find this code, complain. */ + if (enc == last_encoding_code) + { + warning (_("unrecognized encoding name `%s'"), enc_arg); + /* Let the previous one go. */ + if (unknown_encoding && *unknown_encoding) + free (unknown_encoding); + unknown_encoding = xstrdup (enc_arg); } + + else if (encoding_table[document_encoding_code].isotab == NULL) + warning (_("sorry, encoding `%s' not supported"), enc_arg); + + free (enc_arg); } + else if (xml) + { + char *encoding = current_document_encoding (); - /* If we didn't find this code, complain. */ - if (enc == last_encoding_code) - warning (_("unrecognized encoding name `%s'"), enc_arg); + if (encoding && *encoding) + { + insert_string (" encoding=\""); + insert_string (encoding); + insert_string ("\""); + } - else if (encoding_table[document_encoding_code].isotab == NULL) - warning (_("sorry, encoding `%s' not supported"), enc_arg); + free (encoding); + } +} - free (enc_arg); +char * +current_document_encoding (void) +{ + if (document_encoding_code != no_encoding) + return xstrdup (encoding_table[document_encoding_code].encname); + else if (unknown_encoding && *unknown_encoding) + return xstrdup (unknown_encoding); + else + return xstrdup (""); } -/* If html or xml output, add HTML_STR to the output. If not html and +/* If html or xml output, add &HTML_STR; to the output. If not html and the user requested encoded output, add the real 8-bit character corresponding to HTML_STR from the translation tables. Otherwise, add INFO_STR. */ -void -add_encoded_char (html_str, info_str) - char *html_str; - char *info_str; +static void +add_encoded_char (char *html_str, char *info_str) { if (html) add_word_args ("&%s;", html_str); @@ -547,13 +725,8 @@ add_encoded_char (html_str, info_str) /* Output an accent for HTML or XML. */ static void -cm_accent_generic_html (arg, start, end, html_supported, single, - html_solo_standalone, html_solo) - int arg, start, end; - char *html_supported; - int single; - int html_solo_standalone; - char *html_solo; +cm_accent_generic_html (int arg, int start, int end, char *html_supported, + int single, int html_solo_standalone, char *html_solo) { static int valid_html_accent; /* yikes */ @@ -569,20 +742,39 @@ cm_accent_generic_html (arg, start, end, html_supported, single, escape_html = saved_escape_html; } else - { - valid_html_accent = 0; - if (html_solo_standalone) - { /* No special HTML support, so produce standalone char. */ - if (xml) - xml_insert_entity (html_solo); + { /* @dotless{i} is not listed in html_supported but HTML entities + starting with `i' can be used, such as î. */ + int save_input_text_offset = input_text_offset; + char *accent_contents; + + get_until_in_braces ("\n", &accent_contents); + canon_white (accent_contents); + + if (strstr (accent_contents, "@dotless{i")) + { + add_word_args ("&%c", accent_contents[9]); + valid_html_accent = 1; + } + else + { + /* Search for @dotless{} wasn't successful, so rewind. */ + input_text_offset = save_input_text_offset; + valid_html_accent = 0; + if (html_solo_standalone) + { /* No special HTML support, so produce standalone char. */ + if (xml) + xml_insert_entity (html_solo); + else + add_word_args ("&%s;", html_solo); + } else - add_word_args ("&%s;", html_solo); - } - else - /* If the html_solo does not exist as standalone character - (namely ˆ ` ˜), then we use - the single character version instead. */ - add_char (single); + /* If the html_solo does not exist as standalone character + (namely ˆ ` ˜), then we use + the single character version instead. */ + add_char (single); + } + + free (accent_contents); } } else if (arg == END) @@ -598,10 +790,8 @@ cm_accent_generic_html (arg, start, end, html_supported, single, static void -cm_accent_generic_no_headers (arg, start, end, single, html_solo) - int arg, start, end; - int single; - char *html_solo; +cm_accent_generic_no_headers (int arg, int start, int end, int single, + char *html_solo) { if (arg == END) { @@ -628,8 +818,11 @@ cm_accent_generic_no_headers (arg, start, end, single, html_solo) { /* If we didn't find a translation for this character, put the single instead. E.g., &Xuml; does not exist so X¨ should be produced. */ - warning (_("%s is an invalid ISO code, using %c"), - buffer, single); + /* When the below warning is issued, an author has nothing + wrong in their document, let alone anything ``fixable'' + on their side. So it is commented out for now. */ + /* warning (_("%s is an invalid ISO code, using %c"), + buffer, single); */ add_char (single); } @@ -644,8 +837,7 @@ cm_accent_generic_no_headers (arg, start, end, single, html_solo) special HTML support. */ void -cm_accent (arg) - int arg; +cm_accent (int arg) { int old_escape_html = escape_html; escape_html = 0; @@ -687,14 +879,14 @@ cm_accent (arg) exists as valid standalone character in HTML, e.g., ¨. */ static void -cm_accent_generic (arg, start, end, html_supported, single, - html_solo_standalone, html_solo) - int arg, start, end; - char *html_supported; - int single; - int html_solo_standalone; - char *html_solo; +cm_accent_generic (int arg, int start, int end, char *html_supported, + int single, int html_solo_standalone, char *html_solo) { + /* Accentuating space characters makes no sense, so issue a warning. */ + if (arg == START && isspace (input_text[input_text_offset])) + warning ("Accent command `@%s' must not be followed by whitespace", + command); + if (html || xml) cm_accent_generic_html (arg, start, end, html_supported, single, html_solo_standalone, html_solo); @@ -712,43 +904,37 @@ cm_accent_generic (arg, start, end, html_supported, single, } void -cm_accent_umlaut (arg, start, end) - int arg, start, end; +cm_accent_umlaut (int arg, int start, int end) { cm_accent_generic (arg, start, end, "aouAOUEeIiy", '"', 1, "uml"); } void -cm_accent_acute (arg, start, end) - int arg, start, end; +cm_accent_acute (int arg, int start, int end) { cm_accent_generic (arg, start, end, "AEIOUYaeiouy", '\'', 1, "acute"); } void -cm_accent_cedilla (arg, start, end) - int arg, start, end; +cm_accent_cedilla (int arg, int start, int end) { cm_accent_generic (arg, start, end, "Cc", ',', 1, "cedil"); } void -cm_accent_hat (arg, start, end) - int arg, start, end; +cm_accent_hat (int arg, int start, int end) { cm_accent_generic (arg, start, end, "AEIOUaeiou", '^', 0, "circ"); } void -cm_accent_grave (arg, start, end) - int arg, start, end; +cm_accent_grave (int arg, int start, int end) { cm_accent_generic (arg, start, end, "AEIOUaeiou", '`', 0, "grave"); } void -cm_accent_tilde (arg, start, end) - int arg, start, end; +cm_accent_tilde (int arg, int start, int end) { cm_accent_generic (arg, start, end, "ANOano", '~', 0, "tilde"); } @@ -757,7 +943,7 @@ cm_accent_tilde (arg, start, end) /* Non-English letters/characters that don't insert themselves. */ void -cm_special_char (arg) +cm_special_char (int arg) { int old_escape_html = escape_html; escape_html = 0; @@ -769,27 +955,35 @@ cm_special_char (arg) && command[1] == 0) { /* Lslash lslash Oslash oslash. Lslash and lslash aren't supported in HTML. */ - if ((html || xml) && command[0] == 'O') + if (command[0] == 'O') add_encoded_char ("Oslash", "/O"); - else if ((html || xml) && command[0] == 'o') + else if (command[0] == 'o') add_encoded_char ("oslash", "/o"); else add_word_args ("/%c", command[0]); } else if (strcmp (command, "exclamdown") == 0) add_encoded_char ("iexcl", "!"); - else if (strcmp (command, "pounds") == 0) - add_encoded_char ("pound" , "#"); else if (strcmp (command, "questiondown") == 0) add_encoded_char ("iquest", "?"); + else if (strcmp (command, "euro") == 0) + /* http://www.cs.tut.fi/~jkorpela/html/euro.html suggests that + € degrades best in old browsers. */ + add_encoded_char ("euro", "Euro "); + else if (strcmp (command, "pounds") == 0) + add_encoded_char ("pound" , "#"); + else if (strcmp (command, "ordf") == 0) + add_encoded_char ("ordf" , "a"); + else if (strcmp (command, "ordm") == 0) + add_encoded_char ("ordm" , "o"); else if (strcmp (command, "AE") == 0) add_encoded_char ("AElig", command); else if (strcmp (command, "ae") == 0) add_encoded_char ("aelig", command); else if (strcmp (command, "OE") == 0) - add_encoded_char ("#140", command); + add_encoded_char ("OElig", command); else if (strcmp (command, "oe") == 0) - add_encoded_char ("#156", command); + add_encoded_char ("oelig", command); else if (strcmp (command, "AA") == 0) add_encoded_char ("Aring", command); else if (strcmp (command, "aa") == 0) @@ -804,8 +998,7 @@ cm_special_char (arg) /* Dotless i or j. */ void -cm_dotless (arg, start, end) - int arg, start, end; +cm_dotless (int arg, int start, int end) { if (arg == END) { diff --git a/contrib/texinfo/makeinfo/lang.h b/contrib/texinfo/makeinfo/lang.h index a1e9489..b231455 100644 --- a/contrib/texinfo/makeinfo/lang.h +++ b/contrib/texinfo/makeinfo/lang.h @@ -1,5 +1,5 @@ /* lang.h -- declarations for language codes etc. - $Id: lang.h,v 1.4 2003/05/01 00:05:27 karl Exp $ + $Id: lang.h,v 1.6 2004/04/11 17:56:47 karl Exp $ Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. @@ -73,34 +73,35 @@ extern language_type language_table[]; -/* The document encoding. This is usefull if we working e.g. - * with german Texinfo so we can produce correct german umlaut - * while creating output (--no-headers ASCII like). - */ +/* The document encoding. This is useful to produce true 8-bit + characters according to the @documentencoding. */ + typedef enum { - no_encoding, - US_ASCII, - ISO_8859_1, - ISO_8859_2, - ISO_8859_3, /* this and none of the rest are supported. */ - ISO_8859_4, - ISO_8859_5, - ISO_8859_6, - ISO_8859_7, - ISO_8859_8, - ISO_8859_9, - ISO_8859_10, - ISO_8859_11, - ISO_8859_12, - ISO_8859_13, - ISO_8859_14, - ISO_8859_15, - last_encoding_code + no_encoding, + US_ASCII, + ISO_8859_1, + ISO_8859_2, + ISO_8859_3, /* this and none of the rest are supported. */ + ISO_8859_4, + ISO_8859_5, + ISO_8859_6, + ISO_8859_7, + ISO_8859_8, + ISO_8859_9, + ISO_8859_10, + ISO_8859_11, + ISO_8859_12, + ISO_8859_13, + ISO_8859_14, + ISO_8859_15, + last_encoding_code } encoding_code_type; /* The current document encoding, or null if not set. */ extern encoding_code_type document_encoding_code; +/* If an encoding is not supported, just keep it as a string. */ +extern char *unknown_encoding; /* Maps an HTML abbreviation to ISO and Unicode codes for a given code. */ @@ -118,7 +119,8 @@ typedef struct typedef struct { encoding_code_type ec; /* document encoding type (see above enum) */ - char *encname; /* encoding name like "ISO-8859-1", valid in Emacs */ + char *encname; /* encoding name like "iso-8859-1", valid in + HTML and Emacs */ iso_map_type *isotab; /* address of ISO translation table */ } encoding_type; @@ -127,12 +129,20 @@ extern encoding_type encoding_table[]; /* The commands. */ -extern void cm_documentlanguage (), cm_documentencoding (); +extern void cm_documentlanguage (void), + cm_documentencoding (void); /* Accents, other non-English characters. */ -void cm_accent (), cm_special_char (), cm_dotless (); +void cm_accent (int arg), cm_special_char (int arg), + cm_dotless (int arg, int start, int end); + +extern void cm_accent_umlaut (int arg, int start, int end), + cm_accent_acute (int arg, int start, int end), + cm_accent_cedilla (int arg, int start, int end), + cm_accent_hat (int arg, int start, int end), + cm_accent_grave (int arg, int start, int end), + cm_accent_tilde (int arg, int start, int end); -extern void cm_accent_umlaut (), cm_accent_acute (), cm_accent_cedilla (), - cm_accent_hat (), cm_accent_grave (), cm_accent_tilde (); +extern char *current_document_encoding (void); #endif /* not LANG_H */ diff --git a/contrib/texinfo/makeinfo/macro.c b/contrib/texinfo/makeinfo/macro.c index ef33a53..65ac0da 100644 --- a/contrib/texinfo/makeinfo/macro.c +++ b/contrib/texinfo/makeinfo/macro.c @@ -1,5 +1,5 @@ /* macro.c -- user-defined macros for Texinfo. - $Id: macro.c,v 1.2 2003/06/01 23:41:23 karl Exp $ + $Id: macro.c,v 1.6 2004/04/11 17:56:47 karl Exp $ Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc. @@ -19,6 +19,7 @@ #include "system.h" #include "cmds.h" +#include "files.h" #include "macro.h" #include "makeinfo.h" #include "insertion.h" @@ -54,8 +55,7 @@ int macro_list_size = 0; /* Number of slots in total. */ /* Return the length of the array in ARRAY. */ int -array_len (array) - char **array; +array_len (char **array) { int i = 0; @@ -66,8 +66,7 @@ array_len (array) } void -free_array (array) - char **array; +free_array (char **array) { if (array) { @@ -81,8 +80,7 @@ free_array (array) /* Return the macro definition of NAME or NULL if NAME is not defined. */ MACRO_DEF * -find_macro (name) - char *name; +find_macro (char *name) { int i; MACRO_DEF *def; @@ -101,13 +99,9 @@ find_macro (name) and SOURCE_LINENO is the line number within that file. If a macro already exists with NAME, then a warning is produced, and that previous definition is overwritten. */ -void -add_macro (name, arglist, body, source_file, source_lineno, flags) - char *name; - char **arglist; - char *body; - char *source_file; - int source_lineno, flags; +static void +add_macro (char *name, char **arglist, char *body, char *source_file, + int source_lineno, int flags) { MACRO_DEF *def; @@ -163,8 +157,7 @@ add_macro (name, arglist, body, source_file, source_lineno, flags) char ** -get_brace_args (quote_single) - int quote_single; +get_brace_args (int quote_single) { char **arglist, *word; int arglist_index, arglist_size; @@ -243,9 +236,8 @@ get_brace_args (quote_single) return arglist; } -char ** -get_macro_args (def) - MACRO_DEF *def; +static char ** +get_macro_args (MACRO_DEF *def) { int i; char *word; @@ -298,9 +290,8 @@ get_macro_args (def) /* Substitute actual parameters for named parameters in body. The named parameters which appear in BODY must by surrounded reverse slashes, as in \foo\. */ -char * -apply (named, actuals, body) - char **named, **actuals, *body; +static char * +apply (char **named, char **actuals, char *body) { int i; int new_body_index, new_body_size; @@ -391,8 +382,7 @@ apply (named, actuals, body) /* Expand macro passed in DEF, a pointer to a MACRO_DEF, and return its expansion as a string. */ char * -expand_macro (def) - MACRO_DEF *def; +expand_macro (MACRO_DEF *def) { char **arglist; int num_args; @@ -422,8 +412,7 @@ expand_macro (def) /* Execute the macro passed in DEF, a pointer to a MACRO_DEF. */ void -execute_macro (def) - MACRO_DEF *def; +execute_macro (MACRO_DEF *def) { char *execution_string; int start_line = line_number, end_line; @@ -444,7 +433,8 @@ execute_macro (def) end_line = line_number; line_number = start_line; - if (macro_expansion_output_stream && !executing_string && !me_inhibit_expansion) + if (macro_expansion_output_stream + && !executing_string && !me_inhibit_expansion) { remember_itext (input_text, input_text_offset); me_execute_string (execution_string); @@ -462,21 +452,17 @@ execute_macro (def) set the ME_RECURSE flag. MACTYPE is either "macro" or "rmacro", and tells us what the matching @end should be. */ static void -define_macro (mactype, recursive) - char *mactype; - int recursive; +define_macro (char *mactype, int recursive) { - int i; - char *name, **arglist, *body, *line, *last_end; - int body_size, body_index; + int i, start; + char *name, *line; + char *last_end = NULL; + char *body = NULL; + char **arglist = NULL; + int body_size = 0, body_index = 0; int depth = 1; - int defining_line = line_number; int flags = 0; - - arglist = NULL; - body = NULL; - body_size = 0; - body_index = 0; + int defining_line = line_number; if (macro_expansion_output_stream && !executing_string) me_append_before_this_command (); @@ -485,15 +471,13 @@ define_macro (mactype, recursive) /* Get the name of the macro. This is the set of characters which are not whitespace and are not `{' immediately following the @macro. */ + start = input_text_offset; { - int start = input_text_offset; int len; - for (i = start; - (i < input_text_length) && - (input_text[i] != '{') && - (!cr_or_whitespace (input_text[i])); - i++); + for (i = start; i < input_text_length && input_text[i] != '{' + && !cr_or_whitespace (input_text[i]); + i++) ; len = i - start; name = xmalloc (1 + len); @@ -653,7 +637,7 @@ define_macro (mactype, recursive) depth--; last_end = "macro"; } - if (*line == COMMAND_PREFIX && strncmp (line + 1, "end rmacro", 9) == 0) + if (*line == COMMAND_PREFIX && strncmp (line + 1, "end rmacro", 10) == 0) { depth--; last_end = "rmacro"; @@ -697,17 +681,32 @@ define_macro (mactype, recursive) add_macro (name, arglist, body, input_filename, defining_line, flags); if (macro_expansion_output_stream && !executing_string) - remember_itext (input_text, input_text_offset); + { + /* Remember text for future expansions. */ + remember_itext (input_text, input_text_offset); + + /* Bizarrely, output the @macro itself. This is so texinfo.tex + will have a chance to read it when texi2dvi calls makeinfo -E. + The problem is that we don't really expand macros in all + contexts; a @table's @item is one. And a fix is not obvious to + me, since it appears virtually identical to any other internal + expansion. Just setting a variable in cm_item caused other + strange expansion problems. */ + write_region_to_macro_output ("@", 0, 1); + write_region_to_macro_output (mactype, 0, strlen (mactype)); + write_region_to_macro_output (" ", 0, 1); + write_region_to_macro_output (input_text, start, input_text_offset); + } } void -cm_macro () +cm_macro (void) { define_macro ("macro", 0); } void -cm_rmacro () +cm_rmacro (void) { define_macro ("rmacro", 1); } @@ -717,8 +716,7 @@ cm_rmacro () returned. */ static MACRO_DEF * -delete_macro (name) - char *name; +delete_macro (char *name) { int i; MACRO_DEF *def; @@ -737,7 +735,7 @@ delete_macro (name) } void -cm_unmacro () +cm_unmacro (void) { int i; char *line, *name; @@ -785,9 +783,7 @@ cm_unmacro () /* Set the value of POINTER's offset to OFFSET. */ ITEXT * -remember_itext (pointer, offset) - char *pointer; - int offset; +remember_itext (char *pointer, int offset) { int i; ITEXT *itext = NULL; @@ -841,8 +837,7 @@ remember_itext (pointer, offset) /* Forget the input text associated with POINTER. */ void -forget_itext (pointer) - char *pointer; +forget_itext (char *pointer) { int i; @@ -858,7 +853,7 @@ forget_itext (pointer) /* Append the text which appeared in input_text from the last offset to the character just before the command that we are currently executing. */ void -me_append_before_this_command () +me_append_before_this_command (void) { int i; @@ -870,8 +865,7 @@ me_append_before_this_command () /* Similar to execute_string, but only takes a single string argument, and remembers the input text location, etc. */ void -me_execute_string (execution_string) - char *execution_string; +me_execute_string (char *execution_string) { int saved_escape_html = escape_html; int saved_in_paragraph = in_paragraph; @@ -903,8 +897,7 @@ me_execute_string (execution_string) when we need to produce macro-expanded output for input which leaves no traces in the Info output. */ void -me_execute_string_keep_state (execution_string, append_string) - char *execution_string, *append_string; +me_execute_string_keep_state (char *execution_string, char *append_string) { int op_orig, opcol_orig, popen_orig; int fill_orig, newline_orig, indent_orig, meta_pos_orig; @@ -934,8 +927,7 @@ me_execute_string_keep_state (execution_string, append_string) /* Append the text which appears in input_text from the last offset to the current OFFSET. */ void -append_to_expansion_output (offset) - int offset; +append_to_expansion_output (int offset) { int i; ITEXT *itext = NULL; @@ -959,9 +951,7 @@ append_to_expansion_output (offset) /* Only write this input text iff it appears in our itext list. */ void -maybe_write_itext (pointer, offset) - char *pointer; - int offset; +maybe_write_itext (char *pointer, int offset) { int i; ITEXT *itext = NULL; @@ -981,9 +971,7 @@ maybe_write_itext (pointer, offset) } void -write_region_to_macro_output (string, start, end) - char *string; - int start, end; +write_region_to_macro_output (char *string, int start, int end) { if (macro_expansion_output_stream) fwrite (string + start, 1, end - start, macro_expansion_output_stream); @@ -1000,14 +988,15 @@ typedef struct alias_struct static alias_type *aliases; -/* @alias */ +/* @alias aname = cmdname */ + void -cm_alias () +cm_alias (void) { alias_type *a = xmalloc (sizeof (alias_type)); skip_whitespace (); - get_until_in_line (1, "=", &(a->alias)); + get_until_in_line (0, "=", &(a->alias)); canon_white (a->alias); discard_until ("="); @@ -1020,8 +1009,7 @@ cm_alias () /* Perform an alias expansion. Called from read_command. */ char * -alias_expand (tok) - char *tok; +alias_expand (char *tok) { alias_type *findit = aliases; @@ -1062,7 +1050,7 @@ static enclosure_stack_type *enclosure_stack; /* @definfoenclose */ void -cm_definfoenclose () +cm_definfoenclose (void) { enclosure_type *e = xmalloc (sizeof (enclosure_type)); @@ -1081,8 +1069,7 @@ cm_definfoenclose () return 1. Else return 0. */ int -enclosure_command (tok) - char *tok; +enclosure_command (char *tok) { enclosure_type *findit = enclosures; @@ -1104,8 +1091,7 @@ enclosure_command (tok) /* actually perform the enclosure expansion */ void -enclosure_expand (arg, start, end) - int arg, start, end; +enclosure_expand (int arg, int start, int end) { if (arg == START) add_word (enclosure_stack->current->before); diff --git a/contrib/texinfo/makeinfo/macro.h b/contrib/texinfo/makeinfo/macro.h index 5161084..fbc0e59 100644 --- a/contrib/texinfo/makeinfo/macro.h +++ b/contrib/texinfo/makeinfo/macro.h @@ -1,5 +1,5 @@ /* macro.h -- declarations for macro.c. - $Id: macro.h,v 1.1 2002/08/25 23:38:38 karl Exp $ + $Id: macro.h,v 1.2 2004/04/11 17:56:47 karl Exp $ Copyright (C) 1998, 99 Free Software Foundation, Inc. @@ -48,24 +48,30 @@ typedef struct { #define ME_RECURSE 0x01 #define ME_QUOTE_ARG 0x02 -extern void execute_macro (); -extern MACRO_DEF *find_macro (); -extern char *expand_macro (); +extern void execute_macro (MACRO_DEF *def); +extern MACRO_DEF *find_macro (char *name); +extern char *expand_macro (MACRO_DEF *def); -extern ITEXT *remember_itext (); -extern void forget_itext (); -extern void maybe_write_itext (); -extern void write_region_to_macro_output (); -extern void append_to_expansion_output (); -extern void me_append_before_this_command (); -extern void me_execute_string (); +extern ITEXT *remember_itext (char *pointer, int offset); +extern void forget_itext (char *pointer); +extern void maybe_write_itext (char *pointer, int offset); +extern void write_region_to_macro_output (char *string, int start, int end); +extern void append_to_expansion_output (int offset); +extern void me_append_before_this_command (void); +extern void me_execute_string (char *execution_string); +extern void me_execute_string_keep_state (char *execution_string, + char *append_string); -extern char *alias_expand (); -extern int enclosure_command (); -extern void enclosure_expand (); +extern char *alias_expand (char *tok); +extern int enclosure_command (char *tok); +extern void enclosure_expand (int arg, int start, int end); /* The @commands. */ -extern void cm_macro (), cm_rmacro (), cm_unmacro (); -extern void cm_alias (), cm_definfoenclose (); +extern void cm_macro (void), cm_rmacro (void), cm_unmacro (void); +extern void cm_alias (void), cm_definfoenclose (void); + +extern int array_len (char **array); +extern void free_array (char **array); +extern char **get_brace_args (int quote_single); #endif /* not MACRO_H */ diff --git a/contrib/texinfo/makeinfo/makeinfo.c b/contrib/texinfo/makeinfo/makeinfo.c index a5e63fc..22ed4c4 100644 --- a/contrib/texinfo/makeinfo/makeinfo.c +++ b/contrib/texinfo/makeinfo/makeinfo.c @@ -1,8 +1,8 @@ /* makeinfo -- convert Texinfo source into other formats. - $Id: makeinfo.c,v 1.34 2003/06/02 12:32:29 karl Exp $ + $Id: makeinfo.c,v 1.74 2004/12/19 17:15:42 karl Exp $ Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Makeinfo was authored by Brian Fox (bfox@ai.mit.edu). */ + Original author of makeinfo: Brian Fox (bfox@ai.mit.edu). */ #include "system.h" #include "getopt.h" @@ -27,6 +27,7 @@ #include "makeinfo.h" #include "cmds.h" #include "files.h" +#include "float.h" #include "footnote.h" #include "html.h" #include "index.h" @@ -34,6 +35,7 @@ #include "lang.h" #include "macro.h" #include "node.h" +#include "sectioning.h" #include "toc.h" #include "xml.h" @@ -69,10 +71,6 @@ char *output_filename = NULL; char *command_output_filename = NULL; static char *save_command_output_filename = NULL; -/* Flags which control initial output string for xrefs. */ -int px_ref_flag = 0; -int ref_flag = 0; - #define INITIAL_PARAGRAPH_SPACE 5000 int paragraph_buffer_len = INITIAL_PARAGRAPH_SPACE; @@ -135,9 +133,16 @@ int do_justification = 0; /* Nonzero means don't replace whitespace with   in HTML mode. */ int in_html_elt = 0; +/* Nonzero means we are inserting a block level HTML element that must not be + enclosed in a

    , such as

      ,
        and . */ +int in_html_block_level_elt = 0; + /* True when expanding a macro definition. */ static int executing_macro = 0; +/* True when we are inside a
      1. block of a menu. */ +static int in_menu_item = 0; + typedef struct brace_element { struct brace_element *next; @@ -149,64 +154,44 @@ typedef struct brace_element BRACE_ELEMENT *brace_stack = NULL; -extern void do_multitable (), end_multitable (); - -void push_node_filename (), pop_node_filename (); -void remember_error (); -void convert_from_stream (), convert_from_file (), convert_from_loaded_file (); -void init_internals (), init_paragraph (), init_brace_stack (); -void init_insertion_stack (), init_indices (); -void init_tag_table (), write_tag_table (), write_tag_table_internal (); -void validate_file (), validate_other_references (), split_file (); -void free_node_references (), handle_variable (); -void handle_variable_internal (); -void normalize_node_name (); -void add_anchor_name (); -void free_node_node_references (), remember_node_node_reference (); - -char **get_brace_args (); -int array_len (); -void free_array (); -static int end_of_sentence_p (); -void reader_loop (); -void remember_brace (), remember_brace_1 (); -void pop_and_call_brace (), discard_braces (); -void add_word (), add_char (), insert (), flush_output (); -void insert_string (); -void close_paragraph (); -void ignore_blank_line (); -void do_flush_right_indentation (), discard_insertions (); -void start_paragraph (), indent (); -void inhibit_output_flushing (), uninhibit_output_flushing (); -int set_paragraph_indent (); -int self_delimiting (), search_forward (); -int multitable_item (), number_of_node (); - -void me_execute_string_keep_state (); -void maybe_update_execution_strings (); - -extern char *escape_string (); -extern void insert_html_tag (); -extern void sectioning_html (); - -#if defined (VA_FPRINTF) && __STDC__ -/* Unfortunately we must use prototypes if we are to use . */ -void add_word_args (const char *, ...); -void execute_string (char *, ...); -#else -void add_word_args (); -void execute_string (); -#endif /* no prototypes */ +static void convert_from_file (char *name); +static void convert_from_loaded_file (char *name); +static void convert_from_stream (FILE *stream, char *name); +static void do_flush_right_indentation (void); +static void handle_variable (int action); +static void handle_variable_internal (int action, char *name); +static void init_brace_stack (void); +static void init_internals (void); +static void pop_and_call_brace (void); +static void remember_brace (COMMAND_FUNCTION (*proc)); +static int end_of_sentence_p (void); + +void maybe_update_execution_strings (char **text, unsigned int new_len); /* Error handling. */ /* Number of errors encountered. */ int errors_printed = 0; +/* Remember that an error has been printed. If more than + max_error_level have been printed, then exit the program. */ +static void +remember_error (void) +{ + errors_printed++; + if (max_error_level && (errors_printed > max_error_level)) + { + fprintf (stderr, _("Too many errors! Gave up.\n")); + flush_file_stack (); + if (errors_printed - max_error_level < 2) + cm_bye (); + xexit (1); + } +} + /* Print the last error gotten from the file system. */ int -fs_error (filename) - char *filename; +fs_error (char *filename) { remember_error (); perror (filename); @@ -329,24 +314,9 @@ warning (format, va_alist) } -/* Remember that an error has been printed. If more than - max_error_level have been printed, then exit the program. */ -void -remember_error () -{ - errors_printed++; - if (max_error_level && (errors_printed > max_error_level)) - { - fprintf (stderr, _("Too many errors! Gave up.\n")); - flush_file_stack (); - cm_bye (); - xexit (1); - } -} - /* The other side of a malformed expression. */ -void -misplaced_brace () +static void +misplaced_brace (void) { line_error (_("Misplaced %c"), '}'); } @@ -355,7 +325,7 @@ misplaced_brace () /* Display the version info of this invocation of Makeinfo. */ static void -print_version_info () +print_version_info (void) { printf ("makeinfo (GNU %s) %s\n", PACKAGE, VERSION); } @@ -364,8 +334,7 @@ print_version_info () Otherwise, just say to use --help for more info. Then exit with EXIT_VALUE. */ static void -usage (exit_value) - int exit_value; +usage (int exit_value) { if (exit_value != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), progname); @@ -389,14 +358,15 @@ General options:\n\ -v, --verbose explain what is being done.\n\ --version display version information and exit.\n"), max_error_level, reference_warning_limit); - puts ("\n"); + puts (""); /* xgettext: no-wrap */ puts (_("\ Output format selection (default is to produce Info):\n\ - --docbook output DocBook XML rather than Info.\n\ + --docbook output Docbook XML rather than Info.\n\ --html output HTML rather than Info.\n\ --xml output Texinfo XML rather than Info.\n\ + --plaintext output plain text rather than Info.\n\ ")); puts (_("\ @@ -428,7 +398,7 @@ Options for Info and plain text:\n\ --split-size=NUM split Info files at size NUM (default %d).\n"), fill_column, paragraph_start_indent, DEFAULT_SPLIT_SIZE); - puts ("\n"); + puts (""); puts (_("\ Options for HTML:\n\ @@ -436,6 +406,13 @@ Options for HTML:\n\ read stdin if FILE is -.\n\ ")); + printf (_("\ +Options for XML and Docbook:\n\ + --output-indent=VAL indent XML elements by VAL spaces (default %d).\n\ + If VAL is 0, ignorable whitespace is dropped.\n\ +"), xml_indentation_increment); + puts (""); + puts (_("\ Input file options:\n\ --commands-in-node-names allow @ commands in node names.\n\ @@ -447,16 +424,21 @@ Input file options:\n\ puts (_("\ Conditional processing in input:\n\ + --ifdocbook process @ifdocbook and @docbook even if\n\ + not generating Docbook.\n\ --ifhtml process @ifhtml and @html even if not generating HTML.\n\ --ifinfo process @ifinfo even if not generating Info.\n\ --ifplaintext process @ifplaintext even if not generating plain text.\n\ --iftex process @iftex and @tex; implies --no-split.\n\ --ifxml process @ifxml and @xml.\n\ + --no-ifdocbook do not process @ifdocbook and @docbook text.\n\ --no-ifhtml do not process @ifhtml and @html text.\n\ --no-ifinfo do not process @ifinfo text.\n\ --no-ifplaintext do not process @ifplaintext text.\n\ --no-iftex do not process @iftex and @tex text.\n\ --no-ifxml do not process @ifxml and @xml text.\n\ +\n\ + Also, for the --no-ifFORMAT options, do process @ifnotFORMAT text.\n\ ")); puts (_("\ @@ -502,6 +484,7 @@ struct option long_options[] = { "force", 0, &force, 1 }, { "help", 0, 0, 'h' }, { "html", 0, 0, 'w' }, + { "ifdocbook", 0, &process_docbook, 1 }, { "ifhtml", 0, &process_html, 1 }, { "ifinfo", 0, &process_info, 1 }, { "ifplaintext", 0, &process_plaintext, 1 }, @@ -509,6 +492,7 @@ struct option long_options[] = { "ifxml", 0, &process_xml, 1 }, { "macro-expand", 1, 0, 'E' }, { "no-headers", 0, &no_headers, 1 }, + { "no-ifdocbook", 0, &process_docbook, 0 }, { "no-ifhtml", 0, &process_html, 0 }, { "no-ifinfo", 0, &process_info, 0 }, { "no-ifplaintext", 0, &process_plaintext, 0 }, @@ -523,7 +507,9 @@ struct option long_options[] = { "number-footnotes", 0, &number_footnotes, 1 }, { "number-sections", 0, &number_sections, 1 }, { "output", 1, 0, 'o' }, + { "output-indent", 1, 0, 'i' }, { "paragraph-indent", 1, 0, 'p' }, + { "plaintext", 0, 0, 't' }, { "reference-limit", 1, 0, 'r' }, { "split-size", 1, 0, 'S'}, { "verbose", 0, &verbose_mode, 1 }, @@ -532,14 +518,24 @@ struct option long_options[] = {NULL, 0, NULL, 0} }; +/* We use handle_variable_internal for -D and -U, and it depends on + execute_string, which depends on input_filename, which is not defined + while we are handling options. :-\ So we save these defines in this + struct, and handle them later. */ +typedef struct command_line_define +{ + struct command_line_define *next; + int action; + char *define; +} COMMAND_LINE_DEFINE; + +static COMMAND_LINE_DEFINE *command_line_defines = NULL; + /* For each file mentioned in the command line, process it, turning Texinfo commands into wonderfully formatted output text. */ int -main (argc, argv) - int argc; - char **argv; +main (int argc, char **argv) { - extern int errors_printed; int c, ind; int reading_from_stdin = 0; @@ -547,17 +543,69 @@ main (argc, argv) /* Do not use LC_ALL, because LC_NUMERIC screws up the scanf parsing of the argument to @multicolumn. */ setlocale (LC_TIME, ""); +#ifdef LC_MESSAGES /* ultrix */ setlocale (LC_MESSAGES, ""); +#endif setlocale (LC_CTYPE, ""); setlocale (LC_COLLATE, ""); #endif +#ifdef ENABLE_NLS /* Set the text message domain. */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); +#endif + + /* If TEXINFO_OUTPUT_FORMAT envvar is set, use it to set default output. + Can be overridden with one of the output options. */ + if (getenv ("TEXINFO_OUTPUT_FORMAT") != NULL) + { + if (STREQ (getenv ("TEXINFO_OUTPUT_FORMAT"), "docbook")) + { + splitting = 0; + html = 0; + docbook = 1; + xml = 1; + process_docbook = 1; + } + else if (STREQ (getenv ("TEXINFO_OUTPUT_FORMAT"), "html")) + { + html = 1; + docbook = 0; + xml = 0; + process_html = 1; + } + else if (STREQ (getenv ("TEXINFO_OUTPUT_FORMAT"), "info")) + { + html = 0; + docbook = 0; + xml = 0; + } + else if (STREQ (getenv ("TEXINFO_OUTPUT_FORMAT"), "plaintext")) + { + splitting = 0; + no_headers = 1; + html = 0; + docbook = 0; + xml = 0; + process_plaintext = 1; + } + else if (STREQ (getenv ("TEXINFO_OUTPUT_FORMAT"), "xml")) + { + splitting = 0; + html = 0; + docbook = 0; + xml = 1; + process_xml = 1; + } + else + fprintf (stderr, + _("%s: Ignoring unrecognized TEXINFO_OUTPUT_FORMAT value `%s'.\n"), + progname, getenv ("TEXINFO_OUTPUT_FORMAT")); + } /* Parse argument flags from the input line. */ - while ((c = getopt_long (argc, argv, "D:de:E:f:hI:o:p:P:r:s:U:vV:wx", + while ((c = getopt_long (argc, argv, "D:de:E:f:hI:i:o:p:P:r:s:t:U:vV:wx", long_options, &ind)) != EOF) { if (c == 0 && long_options[ind].flag == 0) @@ -572,13 +620,24 @@ main (argc, argv) case 'D': case 'U': /* User specified variable to set or clear. */ - handle_variable_internal ((c == 'D') ? SET : CLEAR, optarg); + if (xml && !docbook) + { + COMMAND_LINE_DEFINE *new = xmalloc (sizeof (COMMAND_LINE_DEFINE)); + new->action = (c == 'D') ? SET : CLEAR; + new->define = xstrdup (optarg); + new->next = command_line_defines; + command_line_defines = new; + } + else + handle_variable_internal ((c == 'D' ? SET : CLEAR), optarg); break; case 'd': /* --docbook */ splitting = 0; xml = 1; docbook = 1; + html = 0; + process_docbook = 1; break; case 'e': /* --error-limit */ @@ -586,7 +645,7 @@ main (argc, argv) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), - "--error-limit", progname, optarg); + progname, "--error-limit", optarg); usage (1); } break; @@ -598,10 +657,13 @@ main (argc, argv) macro_expansion_output_stream = strcmp (optarg, "-") == 0 ? stdout : fopen (optarg, "w"); if (!macro_expansion_output_stream) - error (_("Couldn't open macro expansion output `%s'"), optarg); + error (_("%s: could not open macro expansion output `%s'"), + progname, optarg); } else - error (_("Cannot specify more than one macro expansion output")); + fprintf (stderr, + _("%s: ignoring second macro expansion output `%s'.\n"), + progname, optarg); break; case 'f': /* --fill-column */ @@ -609,7 +671,7 @@ main (argc, argv) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), - "--fill-column", progname, optarg); + progname, "--fill-column", optarg); usage (1); } break; @@ -620,14 +682,17 @@ main (argc, argv) case 'I': /* Append user-specified dir to include file path. */ - if (!include_files_path) - include_files_path = xstrdup ("."); - - include_files_path = (char *) - xrealloc (include_files_path, - 2 + strlen (include_files_path) + strlen (optarg)); - strcat (include_files_path, PATH_SEP); - strcat (include_files_path, optarg); + append_to_include_path (optarg); + break; + + case 'i': + if (sscanf (optarg, "%d", &xml_indentation_increment) != 1) + { + fprintf (stderr, + _("%s: %s arg must be numeric, not `%s'.\n"), + progname, "--output-indent", optarg); + usage (1); + } break; case 'o': /* --output */ @@ -647,23 +712,7 @@ main (argc, argv) case 'P': /* Prepend user-specified include dir to include path. */ - if (!include_files_path) - { - include_files_path = xstrdup (optarg); - include_files_path = xrealloc (include_files_path, - strlen (include_files_path) + 3); /* 3 for ":.\0" */ - strcat (strcat (include_files_path, PATH_SEP), "."); - } - else - { - char *tmp = xstrdup (include_files_path); - include_files_path = xrealloc (include_files_path, - strlen (include_files_path) + strlen (optarg) + 2); /* 2 for ":\0" */ - strcpy (include_files_path, optarg); - strcat (include_files_path, ":"); - strcat (include_files_path, tmp); - free (tmp); - } + prepend_to_include_path (optarg); break; case 'r': /* --reference-limit */ @@ -671,7 +720,7 @@ main (argc, argv) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), - "--reference-limit", progname, optarg); + progname, "--reference-limit", optarg); usage (1); } break; @@ -680,7 +729,7 @@ main (argc, argv) if (set_footnote_style (optarg) < 0) { fprintf (stderr, - _("%s: --footnote-style arg must be `separate' or `end', not `%s'.\n"), + _("%s: --footnote-style arg must be `separate' or `end', not `%s'.\n"), progname, optarg); usage (1); } @@ -692,11 +741,20 @@ main (argc, argv) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), - "--split-size", progname, optarg); + progname, "--split-size", optarg); usage (1); } break; + case 't': /* --plaintext */ + splitting = 0; + no_headers = 1; + html = 0; + docbook = 0; + xml = 0; + process_plaintext = 1; + break; + case 'v': verbose_mode++; break; @@ -704,21 +762,24 @@ main (argc, argv) case 'V': /* --version */ print_version_info (); puts (""); - printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\ -There is NO warranty. You may redistribute this software\n\ + puts ("Copyright (C) 2004 Free Software Foundation, Inc."); + printf (_("There is NO warranty. You may redistribute this software\n\ under the terms of the GNU General Public License.\n\ -For more information about these matters, see the files named COPYING.\n"), - "2003"); +For more information about these matters, see the files named COPYING.\n")); xexit (0); break; case 'w': /* --html */ + xml = 0; + docbook = 0; html = 1; process_html = 1; break; case 'x': /* --xml */ splitting = 0; + html = 0; + docbook = 0; xml = 1; process_xml = 1; break; @@ -729,6 +790,9 @@ For more information about these matters, see the files named COPYING.\n"), } } + if (macro_expansion_output_stream) + validating = 0; + if (!validating) expensive_validation = 0; @@ -746,6 +810,10 @@ For more information about these matters, see the files named COPYING.\n"), if (no_headers) { + /* If the user did not specify an output file, use stdout. */ + if (!command_output_filename) + command_output_filename = xstrdup ("-"); + if (html && splitting && !STREQ (command_output_filename, "-")) { /* --no-headers --no-split --html indicates confusion. */ fprintf (stderr, @@ -756,10 +824,6 @@ For more information about these matters, see the files named COPYING.\n"), /* --no-headers implies --no-split. */ splitting = 0; - - /* If the user did not specify an output file, use stdout. */ - if (!command_output_filename) - command_output_filename = xstrdup ("-"); } if (process_info == -1) @@ -790,7 +854,6 @@ For more information about these matters, see the files named COPYING.\n"), xexit (errors_printed ? 2 : 0); return 0; /* Avoid bogus warnings. */ } - /* Hacking tokens and strings. */ @@ -808,8 +871,8 @@ For more information about these matters, see the files named COPYING.\n"), && (c) != '^' \ ) -char * -read_token () +static char * +read_token (void) { int i, character; char *result; @@ -841,8 +904,7 @@ read_token () /* Return nonzero if CHARACTER is self-delimiting. */ int -self_delimiting (character) - int character; +self_delimiting (int character) { /* @; and @\ are not Texinfo commands, but they are listed here anyway. I don't know why. --karl, 10aug96. */ @@ -851,35 +913,35 @@ self_delimiting (character) /* Clear whitespace from the front and end of string. */ void -canon_white (string) - char *string; +canon_white (char *string) { - int len = strlen (string); - int x; + char *p = string; + unsigned len; - if (!len) + if (!*p) return; - for (x = 0; x < len; x++) + do { - if (!cr_or_whitespace (string[x])) - { - strcpy (string, string + x); - break; - } + if (!cr_or_whitespace (*p)) + break; + ++p; } - len = strlen (string); - if (len) - len--; - while (len > -1 && cr_or_whitespace (string[len])) - len--; - string[len + 1] = 0; + while (*p); + + len = strlen (p); + while (len && cr_or_whitespace (p[len-1])) + --len; + + if (p != string) + memmove (string, p, len); + + string[len] = 0; } /* Bash STRING, replacing all whitespace with just one space. */ void -fix_whitespace (string) - char *string; +fix_whitespace (char *string) { char *temp = xmalloc (strlen (string) + 1); int string_index = 0; @@ -909,8 +971,7 @@ fix_whitespace (string) /* Discard text until the desired string is found. The string is included in the discarded text. */ void -discard_until (string) - char *string; +discard_until (char *string) { int temp = search_forward (string, input_text_offset); @@ -924,18 +985,26 @@ discard_until (string) if (temp < 0) { - input_text_offset = input_text_length - strlen (string); - + /* not found, move current position to end of string */ + input_text_offset = input_text_length; if (strcmp (string, "\n") != 0) - { - line_error (_("Expected `%s'"), string); + { /* Give a more descriptive feedback, if we are looking for ``@end '' + during macro execution. That means someone used a multiline + command as an argument to, say, @section ... style commands. */ + char *end_block = xmalloc (8); + sprintf (end_block, "\n%cend ", COMMAND_PREFIX); + if (executing_string && strstr (string, end_block)) + line_error (_("Multiline command %c%s used improperly"), + COMMAND_PREFIX, command); + else + line_error (_("Expected `%s'"), string); + free (end_block); return; } } else - input_text_offset = temp; - - input_text_offset += strlen (string); + /* found, move current position to after the found string */ + input_text_offset = temp + strlen (string); } /* Read characters from the file until we are at MATCH. @@ -943,8 +1012,7 @@ discard_until (string) On exit input_text_offset is after the match string. Return the offset where the string starts. */ int -get_until (match, string) - char *match, **string; +get_until (char *match, char **string) { int len, current_point, x, new_point, tem; @@ -977,8 +1045,7 @@ get_until (match, string) /* Replace input_text[FROM .. TO] with its expansion. */ void -replace_with_expansion (from, to) - int from, *to; +replace_with_expansion (int from, int *to) { char *xp; unsigned xp_len, new_len; @@ -1054,9 +1121,7 @@ replace_with_expansion (from, to) expand the text before looking for MATCH for those cases where MATCH might be produced by some macro. */ void -get_until_in_line (expand, match, string) - int expand; - char *match, **string; +get_until_in_line (int expand, char *match, char **string) { int real_bottom = input_text_length; int limit = search_forward ("\n", input_text_offset); @@ -1088,9 +1153,7 @@ get_until_in_line (expand, match, string) } void -get_rest_of_line (expand, string) - int expand; - char **string; +get_rest_of_line (int expand, char **string) { xml_no_para ++; if (expand) @@ -1121,7 +1184,7 @@ get_rest_of_line (expand, string) /* Backup the input pointer to the previous character, keeping track of the current line number. */ void -backup_input_pointer () +backup_input_pointer (void) { if (input_text_offset) { @@ -1134,8 +1197,7 @@ backup_input_pointer () /* Read characters from the file until we are at MATCH or closing brace. Place the characters read into STRING. */ void -get_until_in_braces (match, string) - char *match, **string; +get_until_in_braces (char *match, char **string) { char *temp; int i, brace = 0; @@ -1192,8 +1254,8 @@ static char *suffixes[] = { NULL }; -void -initialize_conversion () +static void +initialize_conversion (void) { init_tag_table (); init_indices (); @@ -1207,16 +1269,11 @@ initialize_conversion () output_position = 0; } -typedef struct generic_list { - struct generic_list *next; -} GENERIC_LIST; - /* Reverse the chain of structures in LIST. Output the new head of the chain. You should always assign the output value of this function to something, or you will lose the chain. */ GENERIC_LIST * -reverse_list (list) - GENERIC_LIST *list; +reverse_list (GENERIC_LIST *list) { GENERIC_LIST *next; GENERIC_LIST *prev = NULL; @@ -1237,10 +1294,8 @@ reverse_list (list) /* Convert the Texinfo file coming from the open stream STREAM. Assume the source of the stream is named NAME. */ -void -convert_from_stream (stream, name) - FILE *stream; - char *name; +static void +convert_from_stream (FILE *stream, char *name) { char *buffer = NULL; int buffer_offset = 0, buffer_size = 0; @@ -1287,13 +1342,15 @@ convert_from_stream (stream, name) convert_from_loaded_file (name); } -void -convert_from_file (name) - char *name; +static void +convert_from_file (char *name) { int i; char *filename = xmalloc (strlen (name) + 50); + /* Prepend file directory to the search path, so relative links work. */ + prepend_to_include_path (pathname_part (name)); + initialize_conversion (); /* Try to load the file specified by NAME, concatenated with our @@ -1304,7 +1361,7 @@ convert_from_file (name) strcpy (filename, name); strcat (filename, suffixes[i]); - if (find_and_load (filename)) + if (find_and_load (filename, 1)) break; if (!suffixes[i][0] && strrchr (filename, '.')) @@ -1325,6 +1382,38 @@ convert_from_file (name) input_filename = filename; convert_from_loaded_file (name); + + /* Pop the prepended path, so multiple filenames in the + command line do not screw each others include paths. */ + pop_path_from_include_path (); +} + +static int +create_html_directory (char *dir, int can_remove_file) +{ + struct stat st; + + /* Already exists. */ + if (stat (dir, &st) == 0) + { + /* And it's a directory, so silently reuse it. */ + if (S_ISDIR (st.st_mode)) + return 1; + /* Not a directory, so move it out of the way if we are allowed. */ + else if (can_remove_file) + { + if (unlink (dir) != 0) + return 0; + } + else + return 0; + } + + if (mkdir (dir, 0777) == 0) + /* Success! */ + return 1; + else + return 0; } /* Given OUTPUT_FILENAME == ``/foo/bar/baz.html'', return @@ -1339,13 +1428,11 @@ convert_from_file (name) foo.whatever unchanged. */ static char * -insert_toplevel_subdirectory (output_filename) - char *output_filename; +insert_toplevel_subdirectory (char *output_filename) { static const char index_name[] = "index.html"; char *dir, *subdir, *base, *basename, *p; char buf[PATH_MAX]; - struct stat st; const int index_len = sizeof (index_name) - 1; strcpy (buf, output_filename); @@ -1375,41 +1462,34 @@ insert_toplevel_subdirectory (output_filename) if (strlen (dir)) strcat (output_filename, "/"); strcat (output_filename, subdir); - if ((mkdir (output_filename, 0777) == -1 && errno != EEXIST) - /* output_filename might exist, but be a non-directory. */ - || (stat (output_filename, &st) == 0 && !S_ISDIR (st.st_mode))) - { /* that failed, try subdir name with .html */ + + /* First try, do not remove existing file. */ + if (!create_html_directory (output_filename, 0)) + { + /* That failed, try subdir name with .html. + Remove it if it exists. */ strcpy (output_filename, dir); if (strlen (dir)) strcat (output_filename, "/"); strcat (output_filename, basename); - if (mkdir (output_filename, 0777) == -1) - { - const char *errmsg = strerror (errno); - if ((errno == EEXIST -#ifdef __MSDOS__ - || errno == EACCES -#endif - ) - && (stat (output_filename, &st) == 0 && !S_ISDIR (st.st_mode))) - errmsg = _("File exists, but is not a directory"); + if (!create_html_directory (output_filename, 1)) + { + /* Last try failed too :-\ */ line_error (_("Can't create directory `%s': %s"), - output_filename, errmsg); + output_filename, strerror (errno)); xexit (1); } - strcat (output_filename, "/"); } - else if (strlen (subdir)) - strcat (output_filename, "/"); + + strcat (output_filename, "/"); strcat (output_filename, index_name); return output_filename; } /* FIXME: this is way too hairy */ -void -convert_from_loaded_file (name) - char *name; +static void +convert_from_loaded_file (char *name) { char *real_output_filename = NULL; @@ -1476,8 +1556,6 @@ convert_from_loaded_file (name) if (!command_output_filename) { get_until ("\n", &output_filename); /* read rest of line */ - if (xml && !docbook) - xml_begin_document (output_filename); if (html || xml) { /* Change any extension to .html or .xml. */ char *html_name, *directory_part, *basename_part, *temp; @@ -1553,6 +1631,9 @@ convert_from_loaded_file (name) set_current_output_filename (real_output_filename); + if (xml && !docbook) + xml_begin_document (filename_part (output_filename)); + if (verbose_mode) printf (_("Making %s file `%s' from `%s'.\n"), no_headers ? "text" @@ -1593,6 +1674,19 @@ convert_from_loaded_file (name) output_filename, VERSION, input_filename); close_paragraph (); + + if (xml && !docbook) + { + /* Just before the real main loop, let's handle the defines. */ + COMMAND_LINE_DEFINE *temp; + + for (temp = command_line_defines; temp; temp = temp->next) + { + handle_variable_internal (temp->action, temp->define); + free(temp->define); + } + } + reader_loop (); if (xml) xml_end_document (); @@ -1611,7 +1705,8 @@ finished: && FILENAME_CMP (macro_expansion_filename, NULL_DEVICE) != 0 && FILENAME_CMP (macro_expansion_filename, ALSO_NULL_DEVICE) != 0) { - fprintf (stderr, _("%s: Removing macro output file `%s' due to errors; use --force to preserve.\n"), + fprintf (stderr, +_("%s: Removing macro output file `%s' due to errors; use --force to preserve.\n"), progname, macro_expansion_filename); if (unlink (macro_expansion_filename) < 0) perror (macro_expansion_filename); @@ -1621,15 +1716,10 @@ finished: if (output_stream) { output_pending_notes (); - if (tag_table) - { - tag_table = (TAG_ENTRY *) reverse_list (tag_table); - if (!no_headers && !html) - write_tag_table (); - } if (html) { + no_indent = 1; start_paragraph (); add_word ("\n"); close_paragraph (); @@ -1638,14 +1728,19 @@ finished: /* maybe we want local variables in info output. */ { char *trailer = info_trailer (); - if (trailer) + if (!xml && !docbook && trailer) { + if (html) + insert_string ("\n"); } } - flush_output (); /* in case there was no @bye */ + /* Write stuff makeinfo generates after @bye, ie. info_trailer. */ + flush_output (); if (output_stream != stdout) fclose (output_stream); @@ -1654,19 +1749,28 @@ finished: if (validating) validate_file (tag_table); - /* If we need to output the table of contents, do it now. */ - if (contents_filename || shortcontents_filename) - toc_update (); + handle_delayed_writes (); + + if (tag_table) + { + tag_table = (TAG_ENTRY *) reverse_list ((GENERIC_LIST *) tag_table); + if (!no_headers && !html && !STREQ (current_output_filename, "-")) + write_tag_table (real_output_filename); + } if (splitting && !html && (!errors_printed || force)) - split_file (real_output_filename, split_size); + { + clean_old_split_files (real_output_filename); + split_file (real_output_filename, split_size); + } else if (errors_printed && !force && strcmp (real_output_filename, "-") != 0 && FILENAME_CMP (real_output_filename, NULL_DEVICE) != 0 && FILENAME_CMP (real_output_filename, ALSO_NULL_DEVICE) != 0) { /* If there were errors, and no --force, remove the output. */ - fprintf (stderr, _("%s: Removing output file `%s' due to errors; use --force to preserve.\n"), + fprintf (stderr, + _("%s: Removing output file `%s' due to errors; use --force to preserve.\n"), progname, real_output_filename); if (unlink (real_output_filename) < 0) perror (real_output_filename); @@ -1674,33 +1778,35 @@ finished: } free (real_output_filename); } - - -/* If enable_encoding and document_encoding are both set, return a Local - Variables section (as a malloc-ed string) so that Emacs' locale - features can work. Else return NULL. */ - +/* If enable_encoding is set and @documentencoding is used, return a + Local Variables section (as a malloc-ed string) so that Emacs' + locale features can work. Else return NULL. */ char * -info_trailer () +info_trailer (void) { - if (!enable_encoding || document_encoding_code <= US_ASCII) + char *encoding; + + if (!enable_encoding) return NULL; - { -#define LV_FMT "\n\037\nLocal Variables:\ncoding: %s\nEnd:\n" - char *enc_name = encoding_table[document_encoding_code].encname; - char *lv = xmalloc (sizeof (LV_FMT) + strlen (enc_name)); - sprintf (lv, LV_FMT, enc_name); - return lv; - } -} + encoding = current_document_encoding (); + if (encoding && *encoding) + { +#define LV_FMT "\n\037\nLocal Variables:\ncoding: %s\nEnd:\n" + char *lv = xmalloc (sizeof (LV_FMT) + strlen (encoding)); + sprintf (lv, LV_FMT, encoding); + free (encoding); + return lv; + } + free (encoding); + return NULL; +} void -free_and_clear (pointer) - char **pointer; +free_and_clear (char **pointer) { if (*pointer) { @@ -1710,8 +1816,8 @@ free_and_clear (pointer) } /* Initialize some state. */ -void -init_internals () +static void +init_internals (void) { free_and_clear (&output_filename); free_and_clear (&command); @@ -1731,9 +1837,9 @@ init_internals () } void -init_paragraph () +init_paragraph (void) { - free_and_clear (&output_paragraph); + free (output_paragraph); output_paragraph = xmalloc (paragraph_buffer_len); output_paragraph[0] = 0; output_paragraph_offset = 0; @@ -1747,7 +1853,7 @@ init_paragraph () menu line. */ static void -handle_menu_entry () +handle_menu_entry (void) { char *tem; @@ -1773,23 +1879,21 @@ handle_menu_entry () if (had_menu_commentary) { - add_word ("