diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /dviware/mdvi |
Initial commit
Diffstat (limited to 'dviware/mdvi')
145 files changed, 37795 insertions, 0 deletions
diff --git a/dviware/mdvi/ABOUT-NLS b/dviware/mdvi/ABOUT-NLS new file mode 100644 index 0000000000..28d38c76fd --- /dev/null +++ b/dviware/mdvi/ABOUT-NLS @@ -0,0 +1,226 @@ +Notes on the Free Translation Project +************************************* + + Free software is going international! The Free Translation Project +is a way to get maintainers of free software, translators, and users all +together, so that will gradually become able to speak many languages. +A few packages already provide translations for their messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do *not* +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work at translations should contact the appropriate team. + + When reporting bugs in the `intl/' directory or bugs which may be +related to internationalization, you should tell about the version of +`gettext' which is used. The information can be found in the +`intl/VERSION' file, in internationalized packages. + +One advise in advance +===================== + + If you want to exploit the full power of internationalization, you +should configure it using + + ./configure --with-included-gettext + +to force usage of internationalizing routines provided within this +package, despite the existence of internationalizing capabilities in the +operating system where this package is being installed. So far, only +the `gettext' implementation in the GNU C library version 2 provides as +many features (such as locale alias or message inheritance) as the +implementation here. It is also not possible to offer this additional +functionality on top of a `catgets' implementation. Future versions of +GNU `gettext' will very likely convey even more functionality. So it +might be a good idea to change to GNU `gettext' as soon as possible. + + So you need not provide this option if you are using GNU libc 2 or +you have installed a recent copy of the GNU gettext package with the +included `libintl'. + +INSTALL Matters +=============== + + Some packages are "localizable" when properly installed; the +programs they contain can be made to speak your own native language. +Most such packages use GNU `gettext'. Other packages have their own +ways to internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system provides +usable `catgets' (if using this is selected by the installer) or +`gettext' functions. If neither is available, the GNU `gettext' own +library will be used. This library is wholly contained within this +package, usually in the `intl/' subdirectory, so prior installation of +the GNU `gettext' package is *not* required. Installers may use +special options at configuration time for changing the default +behaviour. The commands: + + ./configure --with-included-gettext + ./configure --with-catgets + ./configure --disable-nls + +will respectively bypass any pre-existing `catgets' or `gettext' to use +the internationalizing routines provided within this package, enable +the use of the `catgets' functions (if found on the locale system), or +else, *totally* disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl.a' file and +will decide to use this. This might be not what is desirable. You +should use the more recent version of the GNU `gettext' library. I.e. +if the file `intl/VERSION' shows that the library which comes with this +package is more recent, you should use + + ./configure --with-included-gettext + +to prevent auto-detection. + + By default the configuration process will not test for the `catgets' +function and therefore they will not be used. The reasons are already +given above: the emulation on top of `catgets' cannot provide all the +extensions provided by the GNU `gettext' library. If you nevertheless +want to use the `catgets' functions use + + ./configure --with-catgets + +to enable the test for `catgets' (this causes no harm if `catgets' is +not available on your system). If you really select this option we +would like to hear about the reasons because we cannot think of any +good one ourself. + + Internationalized packages have usually many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +Using This Package +================== + + As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +ISO 639 `LL' two-letter code prior to using the programs in the +package. For example, let's suppose that you speak German. At the +shell prompt, merely execute `setenv LANG de' (in `csh'), +`export LANG; LANG=de' (in `sh') or `export LANG=de' (in `bash'). This +can be done from your `.login' or `.profile' file, once and for all. + + An operating system might already offer message localization for +many of its programs, while other programs have been installed locally +with the full capabilities of GNU `gettext'. Just using `gettext' +extended syntax for `LANG' would break proper localization of already +available operating system programs. In this case, users should set +both `LANGUAGE' and `LANG' variables in their environment, as programs +using GNU `gettext' give preference to `LANGUAGE'. For example, some +Swedish users would rather read translations in German than English for +when Swedish is not available. This is easily accomplished by setting +`LANGUAGE' to `sv:de' while leaving `LANG' to `sv'. + +Translating Teams +================= + + For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list, courtesy of Linux +International. You may reach your translation team at the address +`LL@li.org', replacing LL by the two-letter ISO 639 code for your +language. Language codes are *not* the same as the country codes given +in ISO 3166. The following translation teams exist, as of December +1997: + + Chinese `zh', Czech `cs', Danish `da', Dutch `nl', English `en', + Esperanto `eo', Finnish `fi', French `fr', German `de', Hungarian + `hu', Irish `ga', Italian `it', Indonesian `id', Japanese `ja', + Korean `ko', Latin `la', Norwegian `no', Persian `fa', Polish + `pl', Portuguese `pt', Russian `ru', Slovenian `sl', Spanish `es', + Swedish `sv', and Turkish `tr'. + +For example, you may reach the Chinese translation team by writing to +`zh@li.org'. + + If you'd like to volunteer to *work* at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is *not* the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request@li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +*actively* in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `translation@iro.umontreal.ca' to reach the +coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skill are praised more than +programming skill, here. + +Available Packages +================== + + Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of December +1997. The matrix shows, in regard of each package, for which languages +PO files have been submitted to translation coordination. + + Ready PO files cs da de en es fi fr it ja ko nl no pl pt ru sl sv + .----------------------------------------------------. + bash | [] [] [] | 3 + bison | [] [] [] | 3 + clisp | [] [] [] [] | 4 + cpio | [] [] [] [] [] [] | 6 + diffutils | [] [] [] [] [] | 5 + enscript | [] [] [] [] [] [] | 6 + fileutils | [] [] [] [] [] [] [] [] [] [] | 10 + findutils | [] [] [] [] [] [] [] [] [] | 9 + flex | [] [] [] [] | 4 + gcal | [] [] [] [] [] | 5 + gettext | [] [] [] [] [] [] [] [] [] [] [] | 12 + grep | [] [] [] [] [] [] [] [] [] [] | 10 + hello | [] [] [] [] [] [] [] [] [] [] [] | 11 + id-utils | [] [] [] | 3 + indent | [] [] [] [] [] | 5 + libc | [] [] [] [] [] [] [] | 7 + m4 | [] [] [] [] [] [] | 6 + make | [] [] [] [] [] [] | 6 + music | [] [] | 2 + ptx | [] [] [] [] [] [] [] [] | 8 + recode | [] [] [] [] [] [] [] [] [] | 9 + sh-utils | [] [] [] [] [] [] [] [] | 8 + sharutils | [] [] [] [] [] [] | 6 + tar | [] [] [] [] [] [] [] [] [] [] [] | 11 + texinfo | [] [] [] | 3 + textutils | [] [] [] [] [] [] [] [] [] | 9 + wdiff | [] [] [] [] [] [] [] [] | 8 + `----------------------------------------------------' + 17 languages cs da de en es fi fr it ja ko nl no pl pt ru sl sv + 27 packages 6 4 25 1 18 1 26 2 1 12 20 9 19 7 4 7 17 179 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If December 1997 seems to be old, you may fetch a more recent copy +of this `ABOUT-NLS' file on most GNU archive sites. + diff --git a/dviware/mdvi/BUGS b/dviware/mdvi/BUGS new file mode 100644 index 0000000000..57dd3ddee1 --- /dev/null +++ b/dviware/mdvi/BUGS @@ -0,0 +1,12 @@ + +Numbers between parentheses are the version of MDVI in which the bug was +detected or introduced. + +(0.1) Rules are misaligned when not in `portrait' orientation (see any DVI + file with large square root signs). +(0.1) Page origin is wrong after rotation (use arrow keys to correct). +(0.2) Some glyphs don't appear on the screen the first time a page is + displayed. Redisplaying the page corrects this. +(0.2) X11 interface has problems synchronizing page rotations with the X + server. The problem is clearly visible on a slow connection. + FIXED 3/15/2001 -ag diff --git a/dviware/mdvi/COPYING b/dviware/mdvi/COPYING new file mode 100644 index 0000000000..568f0738f3 --- /dev/null +++ b/dviware/mdvi/COPYING @@ -0,0 +1,37 @@ + +MDVI is free software, distributed under the terms of the GNU General Public +License. See the file `LICENSE' for details. + +The AFM parser is (C) Adobe Systems Incorporated. See the top part of the +files `parseAFM.c' and `parseAFM.h' for the terms under which they can be +distributed. + +Some portions of MDVI (currently, only three functions in `bitmap.c') +contain code adapted from xdvi, which has these licensing terms: + +/*========================================================================*\ + +Copyright (c) 1990-1999 Paul Vojta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +PAUL VOJTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +NOTE: + xdvi is based on prior work, as noted in the modification history + in xdvi.c. + +\*========================================================================*/ diff --git a/dviware/mdvi/Changes b/dviware/mdvi/Changes new file mode 100644 index 0000000000..d6e2edd117 --- /dev/null +++ b/dviware/mdvi/Changes @@ -0,0 +1,133 @@ + +2/8/2001: + * First working versions of pkview and tfmview. + * switched to autoconf, removed `machdeps.*'. +2/9/2001: + * Now pkview supports GF fonts. + * bitmap.c: bitmap_set_row(): rewritten to be more efficient and + save redundant calculations. Now there is a much more efficient + set of functions: bitmap_paint_bits()/bitmap_clear_bits(). + * another theft from xdvi: gamma correction. +2/11/2001: + * First DVI file rendered correctly! +2/14/2001: + * Added support for virtual fonts (my test files look exactly the + same before and after dvicopy, which is not true for xdvi!). + * Improved rulers (but they still have problems -- e.g. they need to + bee erased before scrolling the window or changing the page). + * kpathsea is no longer optional. +2/21/2001: + * Compiles without warnings with SUN's cc compiler! (although initially + it did not link, it was not mdvi's fault: my kpathsea requires -lgcc. + Anyway, ar x libgcc.a _eprintf.o did the trick). + * Rules look a bit better now, but still not perfect. Incorporated + many things from dvips. + * Added mdvi_configure() + * Added mdvi_reload() + * Added independent horizontal and vertical resolutions (and + shrinking factors!). + * Now one can change any setting on the fly, and the program + recomputes everything, reloads fonts, unloads unnecessary ones, etc. +2/22/2001: + * Added all sorts of orientations (even seemingly useless ones). Now + pages are correctly rendered in portrait, landscape, seascape, etc. + It was surprising how easy it was to implement this. +2/23/2001: + * Released 0.1 on sourceforge. +2/25/2001: + * Fixed: empty glyphs crashed the reader. + * Added more US paper types (actually, new aliases for old ones). + * Added functions to query paper types in different classes (ISO, + US). + * Added the function mdvi_sort_pages() and --sort-pages option to + mdvi. + * Added a quite powerful page selection mechanism, and the + --page-ranges option to mdvi. +2/26/2001: + * Lost of changes to make part of MDVI a stand-alone library. + * New file setup.c that implements `application' contexts. +2/28/2001: + * Added generic support for specials, based on a prefix and a + regular expression. Specials can be added and removed at run-time. + * Added support for TkDVI's layers, as a test of the \special code. + * Added support for TFM "fonts", used when nothing else is available. + * Made MDVI more robust to missing fonts. + * Now the file is reloaded automatically if modified behind our back. + * Changed `specials' code to avoid duplicating strings so much. + * Fixed: rule alignment, again (was placing rule at (hh,vv-height) + instead of (hh,vv-height+1)). +3/1/2001: + * Started working on EPSF specials. Now mdvi draws bounding boxes + correctly. Still a lot of work ahead. + * Added `associations', so now arbitrary data can be added to a DVI + context and associated with a key. This will be used for specials. +3/5/2001: + * Improved the TFM reader to get bounding boxes for missing glyphs. + * TFM reading code rewritten from scratch again to support loading + of TFM data in a generic object. Also added caching of TFM data. + * Started working on support for Type 1 PostScript fonts, using + T1lib as rasterizer. I need to understand the PostScript units to + make the output correct, but the basic machinery works. +3/6/2001: + * Finished the Type1 support code. Looks great. + * Added debugging masks a-la dvips. + * Implemented DviFontInfo, now fonts can be added in a much more + generic way. + * Implemented bitmap shriking with T1lib, for non-antialiased glyphs. + Looks great! (well, at least MUCH better than for bitmapped fonts). + * Added batch mode (-z and --batch), which will be useful for + profiling. + * Fixed: was not refreshing the DviFontChar pointer in + t1_font_get_glyph/load_one_glyph after loading the font file (which + may change the character array in the font). + * Passed a `correctness' test: processes texbook.dvi in batch mode + with ElectricFence without crashing! + * font.c: Moved glyph transformation code from load_one_glyph() into + a separate funtcion font_transform_glyph(), used by + t1_font_shrink_glyph(). + * Fixed: was trying to load glyphs for virtual fonts. Now if a font + type does not declare a glyph loading function, load_one_glyph() + does nothing. + * config/endian.m4: new macro to detect the target byte order +3/7/2001: + * Added scaling for bitmapped fonts. Now all fonts look fine when the + horizontal and vertical resolutions differ. + * Actually, the previous entry is a lie: it works as expected for + scalable fonts (Type1/TrueType), but not so well for bitmapped + fonts. +3/12/2001: + * encoding.c: New file, to process dvips font maps and encodings. + * Added support for TrueType fonts with the FreeType 1.x library. + * Added two fields to DviFontChar: `missing' and `loaded' + * Added builtin support for AFM files, with Adobe's `parseAFM' + package, the same one used by T1lib. + * New functions get_font_metrics()/free_font_metrics() to get + metrics data for a font. The data may come from TFM or AFM files, + and is always returned in raw (unscaled) TFM units. This makes it + possible to share font metrics data between several fonts. These + functions implement this feature. +3/13/2001: + * tfmfile.c: Added support for OFMs (levels 0 and 1). + * fontsrch.c: Started working on font priority classes. + * New font search mechanism mostly working. Now MDVI supports the + following font formats: PK, GF, VF, OVF, Type1, TrueType, TFM, + OFM-0, OFM-1, AFM. +3/15/2001: + * Started switching to gettext for messages. Still a lot of work + ahead in this area. + * config/nls.mk.in: new fragment to be used by `po' directories. + * config/intl.m4: files with macros from `gettext' + * fontmap.c: added support for Ghostscript's font maps. +3/16/2001: + * tfmfile.c: fixed ofm_load_file, which was failing in some cases + because of wrong checksums. This shows just how unstable Omega is at + this time. Most of my .ofm files do not comply with the format + specs. MDVI can try to check for this and load the file anyway. Not + sure if this is the right thing to do, though. +3/19/2001: + * configure: added checks for a `texmf' tree. + * configure: --with-freetype is now --with-truetype-fonts + * configure: now a summary of the configuration is printed at the end + * Makefile: now data files and `mdvi.conf' are installed properly + * separated the library from the viewer, moved headers to their own + directory, etc. diff --git a/dviware/mdvi/LICENSE b/dviware/mdvi/LICENSE new file mode 100644 index 0000000000..d60c31a97a --- /dev/null +++ b/dviware/mdvi/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public 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. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/dviware/mdvi/MD5SUMS b/dviware/mdvi/MD5SUMS new file mode 100644 index 0000000000..bd7a2017a9 --- /dev/null +++ b/dviware/mdvi/MD5SUMS @@ -0,0 +1,144 @@ +3aa31738209266abcaf3431371c8f6fc ./Makefile.in +4e86c3a6628286f947917437879256c4 ./configure.in +777ff2757cdf904980c0da5006b71f07 ./config.h.in +791c49f9615c24b572c3682c4f7ea0b3 ./version.h.in +95cb4d76d2e1fc6f9fed0dd8e2c8e044 ./configure +66ead5a2695e7c299343ef41bc674cb7 ./config/CVS/Root +68476f2e6a295557ea4e2271e4925ca4 ./config/CVS/Repository +0e78ec6ae7db46988b40f72b8aba06d7 ./config/CVS/Entries +0777a9a58c88595c88794c7e2c0a3e5a ./config/FRONTENDS +d3b5080e5b6efa4c83c08189b03d4169 ./config/VERSION +cea6321f875dfff89c3173a5ebf9dd06 ./config/acconfig.h +e0d1a0e075e6f0623d7a7fe9ac840b8b ./config/aclocal.m4 +70174108ce02966f4d67227e81b62604 ./config/config.mk.in +af0274889e32f3fa9fb4308766d0c1c0 ./config/depend.mk +9574d5cea4e6b02c3fcc6a2916b5d54f ./config/dist.mk +92bb749665329b0273425e2d68adcfbe ./config/endian.m4 +5afe8eb5573965dfb58378e4e46f3813 ./config/install-sh +d798969d689c4e0d91b6d1ede3f79be1 ./config/intl.m4 +793162b51a6888523b14da2bc3b0c8d7 ./config/libopts.m4 +d789ae83a35e981f092a062551533ebb ./config/mkinstalldirs +ca4eef30d5b9bbcb1a4dea685138e7e0 ./config/nls.mk.in +9d65c8f23f0e3b5da2429196ce77596d ./config/targets.mk +dfa0c3afe2a3db8a32b4bc98d7555947 ./config/texmf.m4 +b67747993169bb76735d8598da87d80b ./config/with.m4 +d6431a3ee29f58c76d934209d7655336 ./README +12a634e6b054115ccc1f0548063cf659 ./COPYING +94d55d512a9ba36caa9b7df079bae19f ./LICENSE +4d28bb3381891f2b08c4d79676027767 ./NOTES +62801ee107eaf566e10e92aa07b16773 ./BUGS +ef11564ccd2881c65a06c9b0d6f7deec ./ABOUT-NLS +66aadafaba6515638190daf590ecc388 ./WARNING +8e7d80b6c3df176822f25875e7c1b5f5 ./Changes +86865e74c10b92edca402ba203a5d633 ./mdvi.conf +32fe754688834d3f54275993ab02bf6f ./data/8r.enc +30ff49e492b907e17b0adfe35cf44cd0 ./data/cmex.enc +da2e4f1e81781be2aa89308dc9543c0c ./data/cminch.enc +a2cee67a821c858e798e570132b2269e ./data/cmitext.enc +ad9bbdad9528014a31153d878d12470d ./data/cmittext.enc +7ca1b6c4fafe7a30b01b8217a576a1a2 ./data/cmmi.enc +9f062e11ab73c3522e030942034ff625 ./data/cmsy.enc +8e6629f8e47fcaea5f805c8eecf114ac ./data/cmtex.enc +d1b26fc3c45aae22b3244f6a576f4f55 ./data/cmtext.enc +e2e4d929dabff8448e1e9bd79db77c9c ./data/cmtextf.enc +01e982f0fc1c98e61146f200af043a21 ./data/cmttext.enc +c01b7da14bca881dc533993bddc2196e ./data/cork.enc +d40160549e2f67f0a819f2aeae2da4ab ./data/texnansi.enc +a44fec80afb4797ae0515d4750845f62 ./data/cm.map +a8df3902202571d58c99f688cb52bcc7 ./data/8a.enc +babc0ffcecdf429b85bb2628ed49f82f ./data/ad.enc +612cc38dda218d282d316c9c1abb660d ./data/asex.enc +7c934574050c0a7045b6197ca934fff9 ./data/asexp.enc +eff3dbbebc4bedd1c84d82dfac92ae24 ./data/dc.enc +7cf8112c2297fd81c8a56c4ff11a6d46 ./data/dvips.enc +7a76ac2c099e4bfdef074daa90efc450 ./data/EC.enc +b3db76e10e9fee76390edc5173c656c8 ./data/extex.enc +1f86279fe11d0bcb9aae3ed570b83258 ./data/funky.enc +fd382e0559d4f02c3b2a4c9ffc6b9e47 ./data/texmext.enc +0c058a6370ee4d80751512b03ef9e472 ./data/texmital.enc +17f8cba37cf65877f389d7a43fc63536 ./data/texmsym.enc +db72e22d311d0f5db3304750036ffcdd ./data/xl2.enc +66bc0111aaf2f6194a9f4a5e314860af ./data/xt2.enc +5ed7b9d5a5d4822b5bd903f769496603 ./data/omega.map +2319c3f22a6c7a6a305b9b01e3586944 ./data/psfonts.map +6b87723795683cdcfd846c2d8d60cb3e ./data/cmttf.map +2bb9e37af81f819a505fd626abc83c6d ./x11/dvi.c +35982458db8d5697f87ea5d4ec65b753 ./x11/dvidraw.c +e39e4015219df78d5bf84714c55ea77f ./x11/x11.c +d614a61b92dd8bd8fd4b350327d0d673 ./x11/x11.h +7e6bf9258d303b26894232e1b4587bf8 ./x11/Makefile.in +ceb9533a18bcec26f3df8a81fcdadd32 ./support/getopt.c +f186ef13539854f0e04d1e8a192037e2 ./support/getopt1.c +cf9d59999dd73cff9a0a00a1d70bfbd9 ./support/getopt.h +8f5fbc465d7aad836abe92a96985496d ./support/Makefile.in +b8d284a4a8b9f8f2d759618fa51a63b2 ./lib/common.c +d9447cb1387cda4c0e6d3906078feef4 ./lib/util.c +b60850d72d3bfd85991b64e87de63222 ./lib/pk.c +907089ed175e0bcc1ea86ba6fd1dbcab ./lib/gf.c +35d9de4cd92f4b1597205ac1f976b438 ./lib/vf.c +edf86080adf7779446177d684aa1c095 ./lib/bitmap.c +62d586f61c374cb9847dd830b4718a26 ./lib/font.c +0ded8748767994f04eb8c505298ec60b ./lib/list.c +d834fdae7af146a0619f559dc67c6e94 ./lib/dviread.c +168a0051144a304781b1c39f71d5973a ./lib/paper.c +2c5d5a71226f3189fc5946da8eac5ca1 ./lib/pagesel.c +037b0c3b0977eb89050f074ab55d43c8 ./lib/setup.c +da9bd109ea4229294cfcaf80a4aaea60 ./lib/special.c +5087f6f7592c177f85a7f7dde80d4c30 ./lib/tfm.c +f0cabf82c4afa8367237b8f59ee19e83 ./lib/sp-epsf.c +937f73b78bb728030dfecbc4f2453dc4 ./lib/dvimisc.c +187064295a477853e9d4fe4a24dddd2a ./lib/hash.c +e6eb127cea75339c22a8cbf0c27022b9 ./lib/assoc.c +dad8d4b5a88b2696a8f6ab1e4187e6e6 ./lib/tfmfile.c +cbf3ac4b85cad6135de7f1a087378cb7 ./lib/t1.c +8f599f0fdca9fa6298aeec2f2a7e4204 ./lib/tt.c +d228acf6b60948271f472052a358436a ./lib/fontmap.c +45e43e7bc150e314d28c6803c0c6888c ./lib/afmparse.c +94dc13b7e15db96d0092e6ca2d1db492 ./lib/fontsrch.c +62f3527a602b9211dc003c6add505e29 ./lib/files.c +5721706802e1caf3d500b2595dcdf817 ./lib/Makefile.in +1733ce72ede934e73eebf52b3edf254f ./lib/afmparse.h +66ead5a2695e7c299343ef41bc674cb7 ./lib/po/CVS/Root +cb58e218512ac89b0943ae7ce8ad430a ./lib/po/CVS/Repository +d117b7d6feb88ea92612618b1d77927a ./lib/po/CVS/Entries +271992473e68562ee2f5e3f1207054d1 ./lib/po/Makefile +993bed40b7b5dff9c5c1930cacab9735 ./lib/po/Makefile.in +667a6a654bdaa675f2c5c5e2522492d2 ./lib/po/cat-id-tbl.c +e25c8d9efb07e81227c26d72c041a2b1 ./lib/po/es.gmo +cc92202b7df4d941882ba9034b299f27 ./lib/po/es.po +d370c54200542647aece9d3478962d91 ./lib/po/mdvi.pot +1ded054093de910d9786c62bc4fe8cc6 ./lib/po/stamp-cat-id +66ead5a2695e7c299343ef41bc674cb7 ./include/CVS/Root +1daeaac52bf665a37a43574fc7f4fbb7 ./include/CVS/Repository +a5146427d6419a59805daa5ce8345582 ./include/CVS/Entries +c584bcffbc5d054c9c8ea29abb0324dc ./include/bitmap.h +432beb42af478c029671eb6cec3f5cb7 ./include/common.h +298102e05060cd8955769cd511adb2ae ./include/defaults.h +94fc90f392ffd03a72e43e1e9936e341 ./include/dviopcodes.h +e98a4935bddde005fbae89017f2485df ./include/fontmap.h +90ad13b923362693af38c7cd11d7eba8 ./include/mdvi.h +1bf260eb303b4c4120196db38bf9845a ./include/private.h +b24dadc4f6515df83b5fcc5c782bd29f ./include/sysdeps.h +1c8847d1090caf9d9ed7be8ef2b27742 ./intl/ChangeLog +8db747ab5bed6a057050609643889682 ./intl/Makefile.in +88c9303406b57aeed1f313b827c28e3a ./intl/linux-msg.sed +606344532ffc07b36812c0d04acb1f38 ./intl/po2tbl.sed.in +0be261721efcbc3f04680d99e149f18a ./intl/xopen-msg.sed +c46b419b2ebd68930fcb8491fae2bd32 ./intl/gettext.h +2fcb82a7def25bcd2549a394af4cc67d ./intl/gettextP.h +b23eb0ee50448b24ec0b942ff382da10 ./intl/hash-string.h +cbb38948ae7c116ea7aa981874709e73 ./intl/libgettext.h +eea45725e2601ab7dd122a20871ecf76 ./intl/loadinfo.h +0d0f701f3de2b7d66164cd9dfc174378 ./intl/bindtextdom.c +cc8f13a4eca50e459ace9fc8dd63febc ./intl/dcgettext.c +4ef4d731f96a4c2a4901fa03a97abc60 ./intl/dgettext.c +07fdb4d82208430fdcf4e9c57799b742 ./intl/gettext.c +a3604c7c8eb409eb8e9e385096fa099b ./intl/finddomain.c +2cb45953ee0685f05d4eecf3e5decaec ./intl/loadmsgcat.c +432350d759a37ec39245d656d83e27cc ./intl/localealias.c +9f197f8e4cafdfa82382882bbe04694f ./intl/textdomain.c +dca9627004c526250d47351899faf37f ./intl/l10nflist.c +930994e607ac485929753d7caddcb584 ./intl/explodename.c +93e4ab4b2eba5d2b8a36e1b2380190c5 ./intl/intl-compat.c +caa3581b00edb0a7d3811a24a3e46c5c ./intl/cat-compat.c +f9e8b00ce31b1d86e5be53c0c6a78a71 ./intl/VERSION diff --git a/dviware/mdvi/Makefile.in b/dviware/mdvi/Makefile.in new file mode 100644 index 0000000000..e86ce15413 --- /dev/null +++ b/dviware/mdvi/Makefile.in @@ -0,0 +1,120 @@ + +srcdir = @srcdir@ +VPATH = @srcdir@ + +include ./config.mk + +distdir = $(PACKAGE)-$(VERSION) +ALL_FRONTENDS = @ALL_FRONTENDS@ + +FRONTENDS = @FRONTENDS@ +SUBDIRS = @INTLSUB@ support lib $(FRONTENDS) +MDVIMAPDIR = @MDVIMAPDIR@ +MKTEXLSR = @MKTEXLSR@ +POST_INSTALL = @POST_INSTALL@ +POST_UNINSTALL = $(POST_INSTALL) + +OTHERFILES = README TODO COPYING LICENSE NOTES BUGS \ + ABOUT-NLS WARNING Changes + +ACFILES = Makefile.in configure.in config.h.in version.h.in \ + configure config + +DISTFILES = $(ACFILES) $(OTHERFILES) mdvi.conf data +DISTDIRS = $(ALL_FRONTENDS) support lib intl + +.PHONY: all $(SUBDIRS) $(ALL_FRONTENDS) +all: $(SUBDIRS) + +$(SUBDIRS): + if test -d "$@"; then $(MAKE) -C $@; else :; fi +$(ALL_FRONTENDS): @INTLSUB@ support lib + +.PHONY: _dummy +_dummy $(INTLDEPS): + $(MAKE) -C intl all + +.PHONY: install-data install-bin install-recurse install +install: all install-data install-bin install-recurse + $(POST_INSTALL) +install-bin: +install-data: + $(MKINSTALLDIRS) $(MDVIMAPDIR) + $(INSTALL_DATA) $(srcdir)/mdvi.conf $(MDVIMAPDIR)/mdvi.conf + @cd $(srcdir)/data; for i in *; do \ + echo "$(INSTALL_DATA) $$i $(MDVIMAPDIR)/$$i"; \ + $(INSTALL_DATA) $$i $(MDVIMAPDIR)/$$i; \ + done +install-recurse: + @list="$(SUBDIRS)"; for i in $$list; do \ + if test -d "$$i"; then $(MAKE) -C $$i install; else :; fi; \ + done + +.PHONY: uninstall uninstall-data uninstall-bin uninstall-recurse uninstall +uninstall: uninstall-recurse uninstall-bin uninstall-data + $(POST_UNINSTALL) +uninstall-bin: +uninstall-data: + @cd data; for i in *; do \ + $(RM) $(MDVIMAPDIR)/$$i; \ + done + $(RM) $(MDVIMAPDIR)/mdvi.conf + -rmdir $(MDVIMAPDIR) +uninstall-recurse: + @list="$(SUBDIRS)"; for i in $$list; do \ + if test -d "$$i"; then $(MAKE) -C $$i uninstall; else :; fi; \ + done + +.PHONY: dist +dist: distdir $(distdir)/MD5SUMS + @echo "Creating tarball $(distdir).tar.gz..." + $(TAR) zcfoh $(distdir).tar.gz $(distdir) || exit 1 + cp $(distdir)/MD5SUMS $(distdir).sum + rm -rf $(distdir) + +# Creates a tarball, unpacks it, configures it, builds it in a VPATH +# configuration, installs it, and cleans up if everything went well. +# Otherwise, the output generated when building is saevd in the file +# distcheck.log for post-mortem examination. +# +CONFOPTS = \ + --with-type1-fonts \ + --with-truetype-fonts \ + --with-freetype-headers=/usr/local/include/freetype1 + +.PHONY: distcheck +distcheck: dist + @echo "Checking $(distdir).tar.gz for completeness" + $(TAR) zxf $(distdir).tar.gz || exit 1 + -@top=`pwd`; rm -rf distcheck; mkdir distcheck; \ + cd distcheck; inst=`pwd`/INSTALL=; mkdir BUILD=; cd BUILD=; \ + rm -f $$top/distcheck.log; \ + echo "Testing distribution (building output saved in \`distcheck.log')"; \ + echo "running ../../$(distdir)/configure $(CONFOPTS) \ + --prefix=$$inst" --with-texmf="$$inst/texmf"; \ + ../../$(distdir)/configure $(CONFOPTS) \ + --prefix=$$inst --with-texmf="$$inst/texmf" \ + >>$$top/distcheck.log 2>&1 || exit 1; \ + echo "running $(MAKE) all"; \ + $(MAKE) all >>$$top/distcheck.log 2>&1 || exit 1; \ + echo "running $(MAKE) install"; \ + $(MAKE) install >>$$top/distcheck.log 2>&1 || exit 1; \ + cd .. && echo success > SUCCESS + @if test -f distcheck/SUCCESS; then \ + echo "$(distdir) ready for distribution"; \ + else \ + echo "$(distdir) does not build and install yet -- check log"; \ + fi + rm -rf distcheck $(distdir) + +.PHONY: snapshot +snapshot: + $(MAKE) distdir=$(PACKAGE)-`date +"%Y%m%d"` dist + +include $(FRAGDIR)/dist.mk + +CLEANABLE += core +DISTCLEANABLE += config.mk nls.mk config.log config.cache \ + config.status config.h version.h Makefile + +include $(FRAGDIR)/targets.mk diff --git a/dviware/mdvi/NOTES b/dviware/mdvi/NOTES new file mode 100644 index 0000000000..49e5892f3f --- /dev/null +++ b/dviware/mdvi/NOTES @@ -0,0 +1,46 @@ + +Changes since 0.1 + +Bugs fixed: (CRASH means that the bug caused MDVI to dump core). + + - CRASH: empty glyphs were not skipped as they should + - viewing origin was not set properly (was being set before + receiving ConfigureNotify events). + - ruler text was not always visible + - rules were misplaced by one pixel vertically + +New features: + - Building process (i.e. Makefile and autoconf files) rewritten from + scratch. Better support for parallel builds and cross compilation. + - Added a page selection mechanism to process only certain pages in a DVI + file. New option --page-ranges (-r) to mdvi. + - Added --sort-pages to sort pages according to TeX or DVI numbers. + - Added generic support for \specials, and support for TkDVI's layers, as + a test. + - MDVI tries harder to find fonts and if it fails it uses metrics files + (see below for supported formats) to draw the bounding box of missing + glyphs. + - The bounding box of included EPS files is displayed correctly (if they + are not rotated). + - Added support for dvips' color specials, but output is not too pretty + because MDVI still does not support transparency. + - MDVI now handles fonts in a generic way, which makes it easier to add + support for new font types. + - (viewer) Added `batch' mode for MDVI, useful for generating all the + fonts required by a DVI file, diagnose font-related problems, or + profiling. In this mode, MDVI runs without an interactive interface. + - Added support for Type1 fonts, using t1lib. + - Added support for TrueType fonts, using FreeType 1.x. + - Added support for TFM, OFM-0, OFM-1 and AFM font metrics files, and a + generic mechanism to request metric information for a font. + - Added support for PostScript font maps and encoding vectors, using the + configuration files of dvips or pdftex. MDVI can also read the font maps + of Ghostscript, and use it to locate additional fonts. Glyph metrics are + transformed correctly (at the price of some loss in precision) for + slanted and/or extended fonts. + - Added support for internationalization. Now MDVI only needs translators. + - Added support for Ghostscript font maps, so MDVI can use its fonts + and metric files. + - (viewer) Now font support is completely configurable from the command + line (i.e. what font formats to use, and in what order to try them). + - MDVI is on its way to become a standalone library (independent of X). diff --git a/dviware/mdvi/README b/dviware/mdvi/README new file mode 100644 index 0000000000..80991fceed --- /dev/null +++ b/dviware/mdvi/README @@ -0,0 +1,241 @@ + +This is MDVI, a free DVI previewer. + +MDVI is distributed under the terms of the GNU General Public License. See +the file `COPYING' for details. + +MDVI is currently is in its early stages of development, and needs much more +work before being considered ready for general use. Although it is quite +usable, it lacks key features that any self-respecting DVI previewer must +include. See the file `TODO' for details. + +Requirements +============ + + - An ANSI C compiler (tested with gcc and Sun's cc). + - X11 (no toolkits, just Xlib). + - kpathsea. Any version should do, but I use 3.3.3. If you want to use + TrueType fonts, you need at least version 3.2. + - GNU Make, any version (ftp://ftp.gnu.org/pub/make) + - To use Type 1 fonts, you also need the T1lib library. Get it from + ftp://ftp.neuroinformatik.ruhr-uni-bochum.de/pub/software/t1lib/ + - To use TrueType fonts, you need the FreeType library. MDVI currently + supports only versions 1.x (tested with 1.3) of FreeType. A port to + FreeType 2.x should be completed soon. Get 1.x from + http://freetype.sourceforge.net + +You can get all the necessary libraries from MDVI's anonymous FTP site, at +ftp://mdvi.sourceforge.net/pub/mdvi. The files you'll find there are: + + kpathsea-3.3.3.tar.gz + A stripped down version of the web2c-7.3.3 package that contains + the kpathsea library only. Use this if your TeX distribution does + not use kpathsea to locate files. + t1lib-1.0.1.tar.gz + The T1lib library, required to support Type1 PostScript fonts. + freetype-1.3.tar.gz + The FreeType library. + tex-ttf-fonts.tar.gz + TrueType fonts for use with TeX. These fonts are free, originally + obtained from ftp://ftp.tug.org. + dvips-config.tar.gz, pdftex-config.tar.gz + Fontmap files + +Why use MDVI? +============= + +Although MDVI is far from complete, it already has some unique features. +Namely: + + - A clean, minimal, but efficient interface. No buttons, no distractions. + - Rendering of pages in 8 different orientations. + - Independent horizontal and vertical scaling factors and resolutions + implemented for all font formats. MDVI can closely match the final + printed output as produced by dvips or other printer drivers. + - Ability to partially read a DVI file, including a powerful mechanism to + select the pages that are actually processed, based on either DVI page + numbers, TeX \counters, or both. + - Several ways of sorting pages, which is nice when viewing LaTeX + documents that have a table of contents. Sorting pages up by TeX number, + the table of contents comes up as the first page. + - Modular design, with a clear division between device-independent code to + process DVI files and the actual rendering of glyphs. Adding support for + a new font format is a trivial task. + - Ability to change all rendering parameters on the fly (including + resolutions). + - Can process DVI files in `batch mode' without a user interface. Useful + for detecting font-related problems (and to generate all the fonts + needed by a DVI file without actually displaying it). + - Fully customizable via environment variables and `texmf.cnf' - no need + for yet another configuration file to maintain. + - Support for fonts in PK, GF, VF and OVF formats. + - Support for Type1 PostScript fonts, metric files, fontmaps and + encodings. MDVI can use the same configuration files and fonts used by + dvips/pdftex. + - Experimental support for TrueType fonts via FreeType 1.x, using + PostScript fontmaps and encoding files. + - Builtin support for font metrics in TFM, AFM, OFM0 and OFM1 formats. If + a font is missing but a metrics file can be found, MDVI can display a + box with the right dimensions in its place, or simply ignore the + characters from that font. + - Extensible: Support for new fonts and \specials can be added at run-time + through an extremely simple API. + - Font support completely configurable at run-time, via environment + variables and/or command line options. + +The most important omissions in MDVI: + + - Support for X resource files. + - Rendering of PostScript specials (but EPS bounding boxes are displayed + correctly, unless they are rotated). + - Transparent glyphs. Currently MDVI uses a cheap trick to simulate + transparent glyphs, which consists in drawing with a GXand function. + This will NOT work in many common X visuals, and even when it does it + still does not yield correct results when the background color is not + white. + - Zooming. This effect can still be achieved by changing the resolution or + the shrinking factor inside the viewer. See the description of keyboard + commands at the end. + - It's slower than it could be. + +These will be improved in the future, but for now the priority is robustness +and correctness. + +Building +======== + +First make sure you have all the required tools and libraries, described +above, and that they are properly installed. + +If you plan to use Type1 and/or TrueType fonts, you also need to have the +configuration files used by dvips or pdftex installed in kpathsea's texmf +tree. More precisely, you need the PostScript font maps and encoding vector +files. + +If your TeX distribution does not use kpathsea, you'll have to install that +library independently. It's not hard at all, and it's worth the effort. + +If the kpathsea library is in a standard place, you can just type + + $ ./configure + $ make + $ make install + +If the `configure' script fails, or if you want to enable additional +features of MDVI, you can use the following options: + + --with-kpathsea-headers=DIRECTORY + --with-kpathsea-library=DIRECTORY + Use these to tell the configure script where to look for kpathsea + + --with-type1-fonts + --with-t1lib-headers=DIRECTORY + --with-t1lib-library=DIRECTORY + The option --with-type1-fonts enables support for Type1 fonts. Notice + that support for these fonts is not enabled by default. The other two + options tell `configure' where to find t1lib's headers and the + library itselg. + + --with-freetype + --with-freetype-headers=DIRECTORY + --with-freetype-library=DIRECTORY + The option --with-freetype enables support for TrueType fonts. Notice + that support for these fonts is not enabled by default. The other two + options tell `configure' where to find FreeType's headers and the + library itself. + + --disable-nls + If you don't want MDVI to support languages other than english. + +Note: I have had problems during the final link against the kpathsea +library on Solaris if the library was compiled with gcc, and MDVI is +compiled with Sun's cc. To solve the problem, just use the commands + + $ ar x `gcc --print-libgcc-file-name` _eprintf.o + +and add `_eprintf.o' to KPSE_LIBS in the Makefile. Then the link should be +successful. It shouldn't be hard to make `configure' detect this, but I +don't think it's worth it. If you do, let me know. + +Fonts +===== + +To use Type1/TrueType fonts, MDVI needs PostScript fontmaps. These are +usually distributed with dvips and pdftex, but you can get them separately +from MDVI's ftp site (see above). Please notice that you need to have a +correct fontmap entry for *each* font you want to use, or the output will be +incorrect. + +Using MDVI +========== + +MDVI's UI is a bit primitive by today's standards, but it is easy to learn +and powerful. It is driven exclusively with the keyboard, although some +functionality is bound to the mouse. All the parameters that affect the +reading and rendering of DVI files can be specified in the command line, and +also via environment variables. To see a list of these variables, run mdvi +with the `--info' option. + +Keyboard commands +----------------- + +Although some of this commands may be considered rather exotic, to say the +least, they exist mostly to test the basic DVI interpreter and the rendering +engine. + +Keyboard commands without arguments: + + PageUp/PageDown go to previous/next page + Control+PageUp go to the first page + Control+PageDown go to the last page + Up/Down/Left/Right scroll the window in the given direction + (the movement rate can be reduced by holding + the Shift key while pressing the direction + key, and further reduced by holding the + Control key). + Control+Fn save the displayed page number + Fn restore a saved page number + q quits MDVI + b switches between human and TeX's eyes + a toggles glyph antialiasing + l redraws the page + L reloads the DVI file from disk + R rotates the page clockwise by 90 degrees + r rotates the page counter-clockwise + F flips the page vertically + f flips the page horizontally + ? displays a summary of keyboard commands on + standard output (sorry, but this is all the + online help available at this point). + +Keyboard commands that accept a numeric argument: + +The argument is typed before pressing the specified key. You will not see +it, but it'll be there. Some commands accept negative or even +floating point numbers. + + Command Description Neg Pos Floats + p go to current page + ARG yes yes truncated + j jump to page number ARG (last+ARG if negative) yes yes truncated + t jump to TeX's page number ARG yes yes truncated + d change resolution no yes truncated + m change magnification no yes yes + x change horizontal shrinking ratio no yes truncated + y change vertical shrinking ratio no yes truncated + n change pixel density (for bitmap shrinking) no yes truncated + g change gamma correction (for antialiased glyphs) no yes yes + +where `truncated' means that all the decimal digits are dropped. Be advised +that changing the resolution or the magnification may take some time, +because fonts may need to be recreated by kpathsea. Also, not all fonts +support arbitrary resolutions (Type1 and TrueType fonts do, as far as I +know), and kpathsea may fail with a message saying that it is not able to +guess the MF mode from the specified resolution. Using the --mfmode option +might help. + +Mouse usage +----------- + + Button 1 displays a ruler that can be moved around the page + Button 1 + Shift displays a horizontal ruler only + Button 1 + Control displays a vertical ruler only diff --git a/dviware/mdvi/WARNING b/dviware/mdvi/WARNING new file mode 100644 index 0000000000..e12560d729 --- /dev/null +++ b/dviware/mdvi/WARNING @@ -0,0 +1,15 @@ + +MDVI's development state is still alpha, which means it could crash +miserably, display obscene pictures instead of Math text, infest your dog +with fleas, and/or bring chaos and destruction into your otherwise happy and +relaxed life. This does not mean that MDVI is utterly useless. It should +display DVI files correctly, and if you don't use the more experimental +features (like Type1 and TrueType fonts), things should go smoothly. + +It is almost certain that you will find problems and bugs. If you do, please +consider reporting what you find or making suggestions for improvements at +MDVI's SourceForge webpage (http://www.sourceforge.net/projects/mdvi). + +The interface still needs a lot of work, but most of the development is +currently concentrated on MDVI's guts, which you don't see on the +screen. diff --git a/dviware/mdvi/config.h.in b/dviware/mdvi/config.h.in new file mode 100644 index 0000000000..c59ed4412e --- /dev/null +++ b/dviware/mdvi/config.h.in @@ -0,0 +1,220 @@ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Don't change these */ +#undef PACKAGE +#undef VERSION + +/* You can edit anything below this point */ + +/* Define if using alloca.c. */ +#undef C_ALLOCA + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +#undef CRAY_STACKSEG_END + +/* Define if you have alloca, as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +#undef HAVE_ALLOCA_H + +/* Define if you don't have vprintf but do have _doprnt. */ +#undef HAVE_DOPRNT + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the vprintf function. */ +#undef HAVE_VPRINTF + +/* Define as __inline if that's what the C compiler calls it. */ +#undef inline + +/* Define to `long' if <sys/types.h> doesn't define. */ +#undef off_t + +/* Define if you need to in order for stat and other things to work. */ +#undef _POSIX_SOURCE + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +#undef size_t + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +#undef STACK_DIRECTION + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* Disable to avoid using NLS */ +#undef ENABLE_NLS + +/* Disable if you don't have the gettext function */ +#undef HAVE_GETTEXT + +/* Disable if you don't have the catgets function */ +#undef HAVE_CATGETS + +/* Disable if you don't have the catgets function */ +#undef HAVE_STPCPY + +/* Disable if you don't have the catgets function */ +#undef HAVE_LC_MESSAGES + +/* The number of bytes in a int. */ +#undef SIZEOF_INT + +/* The number of bytes in a long. */ +#undef SIZEOF_LONG + +/* The number of bytes in a short. */ +#undef SIZEOF_SHORT + +/* The number of bytes in a void *. */ +#undef SIZEOF_VOID_P + +/* Define if you have the __argz_count function. */ +#undef HAVE___ARGZ_COUNT + +/* Define if you have the __argz_next function. */ +#undef HAVE___ARGZ_NEXT + +/* Define if you have the __argz_stringify function. */ +#undef HAVE___ARGZ_STRINGIFY + +/* Define if you have the dcgettext function. */ +#undef HAVE_DCGETTEXT + +/* Define if you have the getcwd function. */ +#undef HAVE_GETCWD + +/* Define if you have the getopt function. */ +#undef HAVE_GETOPT + +/* Define if you have the getopt_long function. */ +#undef HAVE_GETOPT_LONG + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#undef HAVE_MEMCPY + +/* Define if you have the munmap function. */ +#undef HAVE_MUNMAP + +/* Define if you have the putenv function. */ +#undef HAVE_PUTENV + +/* Define if you have the regexec function. */ +#undef HAVE_REGEXEC + +/* Define if you have the setenv function. */ +#undef HAVE_SETENV + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the stpcpy function. */ +#undef HAVE_STPCPY + +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + +/* Define if you have the strchr function. */ +#undef HAVE_STRCHR + +/* Define if you have the strdup function. */ +#undef HAVE_STRDUP + +/* Define if you have the <argz.h> header file. */ +#undef HAVE_ARGZ_H + +/* Define if you have the <fcntl.h> header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the <limits.h> header file. */ +#undef HAVE_LIMITS_H + +/* Define if you have the <locale.h> header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the <malloc.h> header file. */ +#undef HAVE_MALLOC_H + +/* Define if you have the <nl_types.h> header file. */ +#undef HAVE_NL_TYPES_H + +/* Define if you have the <regex.h> header file. */ +#undef HAVE_REGEX_H + +/* Define if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the <sys/param.h> header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the i library (-li). */ +#undef HAVE_LIBI + +/* Define if you have the m library (-lm). */ +#undef HAVE_LIBM + +/* Name of this package (don't change) */ +#undef PACKAGE + +/* Version of this package (don't change) */ +#undef VERSION + +/* Define if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define to the full path of an existing texmf tree */ +#undef TEXMFTOP + +/* Define if you are using a web2c-based TeX distribution */ +#undef TEXMF_IS_WEB2C + +/* Define to use POSIX regular expressions to match TeX \specials */ +#undef WITH_REGEX_SPECIALS + +/* Define to simulate transparent glyphs on white backgrounds */ +#undef CHEAP_X_TRICK + +/* Define to add support for AFM files */ +#undef WITH_AFM_FILES + +/* Define to add support for Omega-specific file formats */ +#undef WITH_OMEGA + +/* Define to add support for TrueType fonts */ +#undef WITH_TRUETYPE_FONTS + +/* Define to add support for Type1 fonts */ +#undef WITH_TYPE1_FONTS + +/* Version of T1lib used to build MDVI */ +#undef T1LIB_VERSION + +/* Version of kpathsea used to build MDVI */ +#undef KPSE_VERSION + diff --git a/dviware/mdvi/config/CVS/Entries b/dviware/mdvi/config/CVS/Entries new file mode 100644 index 0000000000..26a11e72e8 --- /dev/null +++ b/dviware/mdvi/config/CVS/Entries @@ -0,0 +1,17 @@ +/FRONTENDS/1.1.1.1/Tue Mar 20 09:25:41 2001// +/VERSION/1.1.1.1/Tue Mar 20 09:25:40 2001// +/acconfig.h/1.1.1.1/Tue Mar 20 09:25:41 2001// +/aclocal.m4/1.1.1.1/Tue Mar 20 09:25:39 2001// +/config.mk.in/1.1.1.1/Tue Mar 20 09:25:39 2001// +/depend.mk/1.1.1.1/Tue Mar 20 09:25:40 2001// +/dist.mk/1.1.1.1/Tue Mar 20 09:25:39 2001// +/endian.m4/1.1.1.1/Tue Mar 20 09:25:41 2001// +/install-sh/1.1.1.1/Tue Mar 20 09:25:40 2001// +/intl.m4/1.1.1.1/Tue Mar 20 09:25:39 2001// +/libopts.m4/1.1.1.1/Tue Mar 20 09:25:40 2001// +/mkinstalldirs/1.1.1.1/Tue Mar 20 09:25:40 2001// +/nls.mk.in/1.1.1.1/Tue Mar 20 09:25:40 2001// +/targets.mk/1.1.1.1/Tue Mar 20 09:25:39 2001// +/texmf.m4/1.1.1.1/Tue Mar 20 09:25:41 2001// +/with.m4/1.1.1.1/Tue Mar 20 09:25:41 2001// +D diff --git a/dviware/mdvi/config/CVS/Repository b/dviware/mdvi/config/CVS/Repository new file mode 100644 index 0000000000..66228fa8da --- /dev/null +++ b/dviware/mdvi/config/CVS/Repository @@ -0,0 +1 @@ +mdvi/config diff --git a/dviware/mdvi/config/CVS/Root b/dviware/mdvi/config/CVS/Root new file mode 100644 index 0000000000..164e86eed7 --- /dev/null +++ b/dviware/mdvi/config/CVS/Root @@ -0,0 +1 @@ +agiacom@cvs.mdvi.sourceforge.net:/cvsroot/mdvi diff --git a/dviware/mdvi/config/FRONTENDS b/dviware/mdvi/config/FRONTENDS new file mode 100644 index 0000000000..4d4642d4d6 --- /dev/null +++ b/dviware/mdvi/config/FRONTENDS @@ -0,0 +1,2 @@ +# This file lists all the frontends that are distributed with MDVI. +ALL_FRONTENDS=x11 diff --git a/dviware/mdvi/config/VERSION b/dviware/mdvi/config/VERSION new file mode 100644 index 0000000000..b1c4c8cce5 --- /dev/null +++ b/dviware/mdvi/config/VERSION @@ -0,0 +1,9 @@ +# +# This is the only place where the version numbers are stored, and this file +# is ONLY read by shell scripts. +# +PACKAGE=mdvi +MAJOR=0 +MINOR=2 +PATCH= +VERSION=${MAJOR}.${MINOR}${PATCH} diff --git a/dviware/mdvi/config/acconfig.h b/dviware/mdvi/config/acconfig.h new file mode 100644 index 0000000000..b5b829c89a --- /dev/null +++ b/dviware/mdvi/config/acconfig.h @@ -0,0 +1,24 @@ + +/* Don't change these */ +#undef PACKAGE +#undef VERSION + +/* You can edit anything below this point */ +@TOP@ + +/* Disable to avoid using NLS */ +#undef ENABLE_NLS + +/* Disable if you don't have the gettext function */ +#undef HAVE_GETTEXT + +/* Disable if you don't have the catgets function */ +#undef HAVE_CATGETS + +/* Disable if you don't have the catgets function */ +#undef HAVE_STPCPY + +/* Disable if you don't have the catgets function */ +#undef HAVE_LC_MESSAGES + +@BOTTOM@ diff --git a/dviware/mdvi/config/aclocal.m4 b/dviware/mdvi/config/aclocal.m4 new file mode 100644 index 0000000000..78b0f3d56d --- /dev/null +++ b/dviware/mdvi/config/aclocal.m4 @@ -0,0 +1,5 @@ +builtin(include,libopts.m4) +builtin(include,endian.m4) +builtin(include,with.m4) +builtin(include,intl.m4) +builtin(include,texmf.m4) diff --git a/dviware/mdvi/config/config.mk.in b/dviware/mdvi/config/config.mk.in new file mode 100644 index 0000000000..54781e654d --- /dev/null +++ b/dviware/mdvi/config/config.mk.in @@ -0,0 +1,87 @@ +# @configure_input@ + +PACKAGE = @PACKAGE@ +MAJOR = @MAJOR@ +MINOR = @MINOR@ +PATCH = @PATCH@ +VERSION = @VERSION@ + +############################################# +# Directories + +TOPDIR = @TOPDIR@ +TOPSRCDIR = @TOPSRCDIR@ +CONFIGDIR = $(TOPDIR)/config +CONFIGSRCDIR = $(TOPSRCDIR)/config +FRAGDIR = $(CONFIGSRCDIR) +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +datadir = @datadir@ +localedir = $(datadir)/locale + +# gettext uses this +top_builddir = $(TOPDIR) + +############################################ +# Programs + +@SET_MAKE@ +SHELL = @SHELL@ +CC = @CC@ +TAR = tar +MAKELIB = ar rcs +MD5SUM = @MD5SUM@ +MAKEDEP = $(CC) -MM -MG +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +MKINSTALLDIRS = $(SHELL) $(CONFIGSRCDIR)/mkinstalldirs + +############################################ +# Compiler options + +# Compiler options +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +DEFS = @DEFS@ +CPPFLAGS= @CPPFLAGS@ + +# Default flags for dependencies +DEPCFLAGS = $(CFLAGS) $(CPPFLAGS) + +# Out `support' library +SUPPORTLIB = @SUPPORTLIB@ +SUPPORTHDR = @SUPPORTHDR@ + +# Options to compile kpathsea sources +KPSE_CFLAGS = @KPATHSEA_CFLAGS@ +# Options to link against the kpathsea library +KPSE_LIBS = @KPATHSEA_LDFLAGS@ @KPATHSEA_LIBS@ + +# Options to compile t1lib sources +T1LIB_CFLAGS = @T1LIB_CFLAGS@ +T1LIB_LIBS = @T1LIB_LDFLAGS@ @T1LIB_LIBS@ + +# Options to compile FreeType sources +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LDFLAGS@ @FREETYPE_LIBS@ + +# Options to compile X sources +X_CFLAGS = @X_CFLAGS@ +# Options to link against the X libraries +X_LIBS = @X_LIBS@ @X11LIB@ @X_EXTRA_LIBS@ + +# Options for i18n +INTLDEPS = @INTLDEPS@ +INTLLIBS = @INTLLIBS@ +INTLCFLAGS_yes = -I$(top_builddir)/intl + +# Libraries we need +LIBS = @LIBS@ + +# Additional compiler flags +ADDCFLAGS = $(INTLCFLAGS_@USE_INCLUDED_LIBINTL@) $(SUPPORTHDR) + +# Additional libraries +ADDLIBS = $(INTLLIBS) $(SUPPORTLIB) diff --git a/dviware/mdvi/config/depend.mk b/dviware/mdvi/config/depend.mk new file mode 100644 index 0000000000..6560f74d8e --- /dev/null +++ b/dviware/mdvi/config/depend.mk @@ -0,0 +1,13 @@ + +DISTCLEANABLE += $(DEPSOURCES:.c=.d) + +.SUFFIXES: .d + +.c.d: + @echo "Updating dependencies for $<" + @set -e; $(MAKEDEP) $(DEPCFLAGS) $< | \ + sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; + +ifeq ($(subst clean,,$(MAKECMDGOALS)),$(MAKECMDGOALS)) +-include $(DEPSOURCES:.c=.d) +endif diff --git a/dviware/mdvi/config/dist.mk b/dviware/mdvi/config/dist.mk new file mode 100644 index 0000000000..a8758c5753 --- /dev/null +++ b/dviware/mdvi/config/dist.mk @@ -0,0 +1,36 @@ + +.PHONY: distdir +distdir: + @echo "Distributing into $(distdir)" + @rm -rf $(distdir) + @mkdir $(distdir) + @list="$(DISTFILES)"; for i in $$list; do \ + if test -d $(srcdir)/$$i; then \ + echo "cp -pr $(srcdir)/$$i $(distdir)/$$i"; \ + cp -pr $(srcdir)/$$i $(distdir)/$$i; \ + else \ + echo "cp -p $(srcdir)/$$i $(distdir)/$$i"; \ + cp -p $(srcdir)/$$i $(distdir)/$$i; \ + fi; \ + done + @list="$(DISTDIRS)"; for i in $$list; do \ + if test -n "$$i" -a "$$i" != .; then \ + test -d $(distdir)/$$i || mkdir $(distdir)/$$i || exit 1; \ + $(MAKE) -C $$i $(DISTMAKEFLAGS) distdir=../$(distdir)/$$i distdir; \ + fi; \ + done + @list="$(NODISTFILES)"; for i in $$list; do \ + echo "rm -f $(distdir)/$$i"; \ + rm -f $(distdir)/$$i; \ + done + +$(distdir)/MD5SUMS: + @echo "Computing MD5 sums..." + -@if test -x "$(MD5SUM)"; then \ + (cd $(distdir); find . -type f -exec $(MD5SUM) {} \; > /tmp/MD5SUM$$$$); \ + if test -s /tmp/MD5SUM$$$$; then \ + mv -f /tmp/MD5SUM$$$$ $(distdir)/MD5SUMS; \ + else \ + rm -f /tmp/MD5SUM$$$$; \ + fi; \ + fi diff --git a/dviware/mdvi/config/endian.m4 b/dviware/mdvi/config/endian.m4 new file mode 100644 index 0000000000..9130a993ea --- /dev/null +++ b/dviware/mdvi/config/endian.m4 @@ -0,0 +1,87 @@ +dnl +dnl Checks for the byte order of the target machine, allowing the user +dnl to specify it on the command line if cross compiling +dnl This macro defines the same symbols as AC_C_BIGENDIAN +dnl +AC_DEFUN(AC_CHECK_BYTE_ORDER, [ + dnl we need to know if we're cross compiling + AC_REQUIRE([AC_PROG_CC]) + AC_ARG_WITH(target-byte-order, + [ --with-target-byte-order=ORDER + set target byte order, if cross-compiling + (ORDER is one of lsb, msb, auto)], + byteorder="$withval", byteorder=auto) +case "$byteorder" in + lsb|msb) + if test "$cross_compiling" = no; then + AC_MSG_WARN([you should force the byte order only when cross-compiling]) + fi + ;; + auto) + if test "$cross_compiling" = yes; then + AC_MSG_ERROR([specify the target byte order --with-target-byte-order]) + fi + ;; + *) + AC_MSG_WARN([unknown byte order \`$byteorder', set to \`auto']) + byteorder=auto + ;; +esac +AC_MSG_CHECKING([for target byte order]) +if test "$byteorder" = auto; then +AC_CACHE_VAL(ac_cv_byteorder, [ + AC_TRY_RUN([#include <stdio.h> +#include <sys/types.h> +#include <sys/param.h> +main(){ +#if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) + FILE *f; + f = fopen("conftestval", "w"); + if(!f) exit(1); +#if BYTE_ORDER == LITTLE_ENDIAN + fprintf(f, "lsb\n"); + exit(0); +#endif +#if BYTE_ORDER == BIG_ENDIAN + fprintf(f, "msb\n"); + exit(0); +#endif +#else + exit(1); +#endif +}], ac_cv_byteorder=`cat conftestval`, +[AC_TRY_RUN([#include <stdio.h> +main() { + union { + long l; + char c[sizeof(long)]; + } u; + FILE *f; + f = fopen("conftestval", "w"); + u.l = 1; + if(u.c[0] == 1) fprintf(f, "lsb\n"); + else if(u.c[sizeof(long)-1] == 1) fprintf(f, "msb\n"); + else fprintf(f, "unknown\n"); + exit(0); +}], ac_cv_byteorder=`cat conftestval`, ac_cv_byteorder=unknown, + ac_cv_byteorder=unknown)], ac_cv_byteorder=unknown) +]) dnl end of AC_CACHE_VAL +byteorder="$ac_cv_byteorder" +fi + +dnl Now examine what happened +case "$byteorder" in + lsb) AC_MSG_RESULT([little endian]) ;; + msb) + AC_MSG_RESULT([big endian]) + AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, 1, + [Define if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX).]) + ;; + *) + AC_MSG_RESULT(unknown) + AC_MSG_WARN([unable to guess the byte order of this machine]) + AC_MSG_ERROR([specify the target byte order with --with-target-byte-order]) + ;; +esac +]) diff --git a/dviware/mdvi/config/install-sh b/dviware/mdvi/config/install-sh new file mode 100644 index 0000000000..e9de23842d --- /dev/null +++ b/dviware/mdvi/config/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/dviware/mdvi/config/intl.m4 b/dviware/mdvi/config/intl.m4 new file mode 100644 index 0000000000..afbc713e2c --- /dev/null +++ b/dviware/mdvi/config/intl.m4 @@ -0,0 +1,355 @@ +# Macro to add for using GNU gettext. +# Ulrich Drepper <drepper@cygnus.com>, 1995. +# +# This file can be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU Public License +# but which still want to provide support for the GNU gettext functionality. +# Please note that the actual code is *not* freely available. + +# serial 5 + +AC_DEFUN(AM_WITH_NLS, + [AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE(nls, + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT($USE_NLS) + AC_SUBST(USE_NLS) + + USE_INCLUDED_LIBINTL=no + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + AC_DEFINE(ENABLE_NLS) + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH(included-gettext, + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If gettext or catgets are available (in this order) we + dnl use this. Else we have to fall back to GNU NLS library. + dnl catgets is only used if permitted by option --with-catgets. + nls_cv_header_intl= + nls_cv_header_libgt= + CATOBJEXT=NONE + + AC_CHECK_HEADER(libintl.h, + [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc, + [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")], + gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)]) + + if test "$gt_cv_func_gettext_libc" != "yes"; then + AC_CHECK_LIB(intl, bindtextdomain, + [AC_CACHE_CHECK([for gettext in libintl], + gt_cv_func_gettext_libintl, + [AC_CHECK_LIB(intl, gettext, + gt_cv_func_gettext_libintl=yes, + gt_cv_func_gettext_libintl=no)], + gt_cv_func_gettext_libintl=no)]) + fi + + if test "$gt_cv_func_gettext_libc" = "yes" \ + || test "$gt_cv_func_gettext_libintl" = "yes"; then + AC_DEFINE(HAVE_GETTEXT) + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl + if test "$MSGFMT" != "no"; then + AC_CHECK_FUNCS(dcgettext) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; + return _nl_msg_cat_cntr], + [CATOBJEXT=.gmo + DATADIRNAME=share], + [CATOBJEXT=.mo + DATADIRNAME=lib]) + INSTOBJEXT=.mo + fi + fi + ]) + + if test "$CATOBJEXT" = "NONE"; then + AC_MSG_CHECKING([whether catgets can be used]) + AC_ARG_WITH(catgets, + [ --with-catgets use catgets functions if available], + nls_cv_use_catgets=$withval, nls_cv_use_catgets=no) + AC_MSG_RESULT($nls_cv_use_catgets) + + if test "$nls_cv_use_catgets" = "yes"; then + dnl No gettext in C library. Try catgets next. + AC_CHECK_LIB(i, main) + AC_CHECK_FUNC(catgets, + [AC_DEFINE(HAVE_CATGETS) + INTLOBJS="\$(CATOBJS)" + AC_PATH_PROG(GENCAT, gencat, no)dnl + if test "$GENCAT" != "no"; then + AC_PATH_PROG(GMSGFMT, gmsgfmt, no) + if test "$GMSGFMT" = "no"; then + AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no) + fi + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + USE_INCLUDED_LIBINTL=yes + CATOBJEXT=.cat + INSTOBJEXT=.cat + DATADIRNAME=lib + INTLDEPS='$(top_builddir)/intl/libintl.a' + INTLLIBS=$INTLDEPS + LIBS=`echo $LIBS | sed -e 's/-lintl//'` + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi]) + fi + fi + + if test "$CATOBJEXT" = "NONE"; then + dnl Neither gettext nor catgets in included in the C library. + dnl Fall back on GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + INTLOBJS="\$(GETTOBJS)" + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + AC_SUBST(MSGFMT) + USE_INCLUDED_LIBINTL=yes + CATOBJEXT=.gmo + INSTOBJEXT=.mo + DATADIRNAME=share + INTLDEPS='$(top_builddir)/intl/libintl.a' + INTLLIBS=$INTLDEPS + LIBS=`echo $LIBS | sed -e 's/-lintl//'` + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi + + dnl Test whether we really found GNU xgettext. + if test "$XGETTEXT" != ":"; then + dnl If it is no GNU xgettext we define it as : so that the + dnl Makefiles still can work. + if $XGETTEXT --omit-header /dev/null 2> /dev/null; then + : ; + else + AC_MSG_RESULT( + [found xgettext program is not GNU xgettext; ignore it]) + XGETTEXT=":" + fi + fi + + # We need to process the po/ directory. + POSUB=po + else + DATADIRNAME=share + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi + AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl) +# AC_OUTPUT_COMMANDS( +# [case "$CONFIG_FILES" in *po/Makefile.in*) +# sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile +# esac]) + + dnl These rules are solely for the distribution goal. While doing this + dnl we only have to keep exactly one list of the available catalogs + dnl in configure.in. + for lang in $ALL_LINGUAS; do + GMOFILES="$GMOFILES $lang.gmo" + POFILES="$POFILES $lang.po" + done + + dnl Make all variables we use known to autoconf. + AC_SUBST(USE_INCLUDED_LIBINTL) + AC_SUBST(CATALOGS) + AC_SUBST(CATOBJEXT) + AC_SUBST(DATADIRNAME) + AC_SUBST(GMOFILES) + AC_SUBST(INSTOBJEXT) + AC_SUBST(INTLDEPS) + AC_SUBST(INTLLIBS) + AC_SUBST(INTLOBJS) + AC_SUBST(POFILES) + AC_SUBST(POSUB) + ]) + +AC_DEFUN(AM_GNU_GETTEXT, + [AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_PROG_RANLIB])dnl + AC_REQUIRE([AC_ISC_POSIX])dnl + AC_REQUIRE([AC_HEADER_STDC])dnl + AC_REQUIRE([AC_C_CONST])dnl + AC_REQUIRE([AC_C_INLINE])dnl + AC_REQUIRE([AC_TYPE_OFF_T])dnl + AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([AC_FUNC_ALLOCA])dnl + AC_REQUIRE([AC_FUNC_MMAP])dnl + + AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \ +unistd.h sys/param.h]) + AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \ +strdup __argz_count __argz_stringify __argz_next]) + + if test "${ac_cv_func_stpcpy+set}" != "set"; then + AC_CHECK_FUNCS(stpcpy) + fi + if test "${ac_cv_func_stpcpy}" = "yes"; then + AC_DEFINE(HAVE_STPCPY) + fi + + AM_LC_MESSAGES + AM_WITH_NLS + + if test "x$CATOBJEXT" != "x"; then + if test "x$ALL_LINGUAS" = "x"; then + LINGUAS= + else + AC_MSG_CHECKING(for catalogs to be installed) + NEW_LINGUAS= + for lang in ${LINGUAS=$ALL_LINGUAS}; do + case "$ALL_LINGUAS" in + *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; + esac + done + LINGUAS=$NEW_LINGUAS + AC_MSG_RESULT($LINGUAS) + fi + + dnl Construct list of names of catalog files to be constructed. + if test -n "$LINGUAS"; then + for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done + fi + fi + + dnl The reference to <locale.h> in the installed <libintl.h> file + dnl must be resolved because we cannot expect the users of this + dnl to define HAVE_LOCALE_H. + if test $ac_cv_header_locale_h = yes; then + INCLUDE_LOCALE_H="#include <locale.h>" + else + INCLUDE_LOCALE_H="\ +/* The system does not provide the header <locale.h>. Take care yourself. */" + fi + AC_SUBST(INCLUDE_LOCALE_H) + + dnl Determine which catalog format we have (if any is needed) + dnl For now we know about two different formats: + dnl Linux libc-5 and the normal X/Open format + test -d intl || mkdir intl + if test "$CATOBJEXT" = ".cat"; then + AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen) + + dnl Transform the SED scripts while copying because some dumb SEDs + dnl cannot handle comments. + sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed + fi + dnl po2tbl.sed is always needed. + sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ + $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed + + dnl In the intl/Makefile.in we have a special dependency which makes + dnl only sense for gettext. We comment this out for non-gettext + dnl packages. + if test "$PACKAGE" = "gettext"; then + GT_NO="#NO#" + GT_YES= + else + GT_NO= + GT_YES="#YES#" + fi + AC_SUBST(GT_NO) + AC_SUBST(GT_YES) + + dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly + dnl find the mkinstalldirs script in another subdir but ($top_srcdir). + dnl Try to locate is. + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + AC_SUBST(MKINSTALLDIRS) + + dnl *** For now the libtool support in intl/Makefile is not for real. + l= + AC_SUBST(l) + + dnl Generate list of files to be processed by xgettext which will + dnl be included in po/Makefile. +# test -d po || mkdir po +# if test "x$srcdir" != "x."; then +# if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then +# posrcprefix="$srcdir/" +# else +# posrcprefix="../$srcdir/" +# fi +# else +# posrcprefix="../" +# fi +# rm -f po/POTFILES +# sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ +# < $srcdir/po/POTFILES.in > po/POTFILES + ]) + +AC_DEFUN(AM_LC_MESSAGES, + [if test $ac_cv_header_locale_h = yes; then + AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, + [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], + am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) + if test $am_cv_val_LC_MESSAGES = yes; then + AC_DEFINE(HAVE_LC_MESSAGES) + fi + fi]) + +dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, +dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN(AM_PATH_PROG_WITH_TEST, +[# Extract the first word of "$2", so it can be a program name with args. +set dummy $2; ac_word=[$]2 +AC_MSG_CHECKING([for $ac_word]) +AC_CACHE_VAL(ac_cv_path_$1, +[case "[$]$1" in + /*) + ac_cv_path_$1="[$]$1" # Let the user override the test with a path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in ifelse([$5], , $PATH, [$5]); do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if [$3]; then + ac_cv_path_$1="$ac_dir/$ac_word" + break + fi + fi + done + IFS="$ac_save_ifs" +dnl If no 4th arg is given, leave the cache variable unset, +dnl so AC_PATH_PROGS will keep looking. +ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +])dnl + ;; +esac])dnl +$1="$ac_cv_path_$1" +if test -n "[$]$1"; then + AC_MSG_RESULT([$]$1) +else + AC_MSG_RESULT(no) +fi +AC_SUBST($1)dnl +]) diff --git a/dviware/mdvi/config/libopts.m4 b/dviware/mdvi/config/libopts.m4 new file mode 100644 index 0000000000..08fbc225ab --- /dev/null +++ b/dviware/mdvi/config/libopts.m4 @@ -0,0 +1,90 @@ +dnl Requires the `AC_ARG_WITHX' macros from with.m4 +dnl +dnl AC_CHECK_LIBOPTIONS(SHORTNAME, NAME, HEADERS, FUNCTION) +dnl SHORTNAME=name used for sh variables and such +dnl NAME="official" name of the library, used for -l +dnl +AC_DEFUN(AC_CHECK_LIBOPTIONS, [ + define([LIB], translit($1,[a-z-],[A-Z_])) + define([NAME], translit($1,[A-Z],[a-z])) +AC_ARG_WITHX(NAME[-headers], [location of the $1 headers], + [case "$withval" in + yes) AC_MSG_WARN([no value specified for [--with-]NAME[-headers]] ;; + no) NAME[_headers]= ;; + *) NAME[_headers]=$withval ;; + esac], ,[=DIR]) +AC_ARG_WITHX(NAME[-library], [location of the $1 library], + [case "$withval" in + yes) AC_MSG_WARN([no value specified for [--with-]NAME[-library]] ;; + no) NAME[_library]= ;; + *) NAME[_library]=$withval ;; + esac], ,[=DIR]) + AC_SUBST(LIB[_CFLAGS]) + AC_SUBST(LIB[_LDFLAGS]) + AC_SUBST(LIB[_LIBS]) + LIB[_CFLAGS]= + LIB[_LDFLAGS]= + [have_]NAME[_headers]=no + [have_]NAME[_library]=no +[#] Check for $2 headers + AC_MSG_CHECKING([for $2 headers]) + OCF=$CFLAGS; + TMPCFLAGS= + [#] If we were given PATH/lib, try PATH/include + if test -z "[$]NAME[_headers]"; then + test -n "[$]NAME[_library]" && NAME[_headers]=[$]NAME[_library]/../include + fi + test -n "[$]NAME[_headers]" && TMPCFLAGS="-I[$]NAME[_headers]" + CFLAGS="$OCF $TMPCFLAGS" + AC_TRY_COMPILE([$3], [$4], + [[have_]NAME[_headers]=yes; LIB[_CFLAGS]=$TMPCFLAGS], + [if test -n "[$]NAME[_headers]"; then + TMPCFLAGS="-I[$]NAME[_headers]/.." + CFLAGS="$OCF $TMPCFLAGS" + AC_TRY_COMPILE([$3], [$4], + [[have_]NAME[_headers]=yes; LIB[_CFLAGS]=$TMPCFLAGS], + [[have_]NAME[_headers]=no; LIB[_CFLAGS]=]) + fi]) + AC_MSG_RESULT([$have_]NAME[_headers]) +[#] Check for the $2 library + AC_MSG_CHECKING([for the $2 library]) + OLD=$LDFLAGS; OLI=$LIBS + TMPLDFLAGS= + [#] If we were given PATH/include, try PATH/lib + if test -z "[$]NAME[_library]"; then + test -n "[$]NAME[_headers]" && NAME[_library]=[$]NAME[_headers]/../lib + fi + test -n "[$]NAME[_library]" && TMPLDFLAGS="-L[$]NAME[_library]" + LDFLAGS="$OLD $TMPLDFLAGS" + LIBS="$LIBS -l$2" + AC_TRY_LINK([$3], [$4], + [[have_]NAME[_library]=yes; LIB[_LDFLAGS]=$TMPLDFLAGS], + [[have_]NAME[_library]=no; LIB[_LDFLAGS]=]) + AC_MSG_RESULT([$have_]NAME[_library]) + if test "[$have_]NAME[_headers]" = yes -a "[$have_]NAME[_library]" = yes; then + LIB[_LIBS]="-l$2" + fi +undefine([LIB]) + TMPCFLAGS= + TMPLDFLAGS= +[#] Restore things + CFLAGS=$OCF + LDFLAGS=$OLD + LIBS=$OLI +]) +AC_DEFUN(AC_SAVE_FLAGS, [ +ac_mdvi_CFLAGS="$CFLAGS" +ac_mdvi_LDFLAGS="$LDFLAGS" +ac_mdvi_LIBS="$LIBS" +]) +AC_DEFUN(AC_RESTORE_FLAGS, [ +CFLAGS="$ac_mdvi_CFLAGS" +LDFLAGS="$ac_mdvi_LDFLAGS" +LIBS="$ac_mdvi_LIBS" +]) +AC_DEFUN(AC_CHANGE_FLAGS, [ +AC_SAVE_FLAGS +ifelse([$1], , ,CFLAGS="$CFLAGS $1") +ifelse([$2], , ,LDFLAGS="$LDFLAGS $2") +ifelse([$3], , ,LIBS="$3 $LIBS") +]) diff --git a/dviware/mdvi/config/mkinstalldirs b/dviware/mdvi/config/mkinstalldirs new file mode 100644 index 0000000000..d0f178257a --- /dev/null +++ b/dviware/mdvi/config/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman <friedman@prep.ai.mit.edu> +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1.1.1 2001/03/20 09:25:40 agiacom Exp $ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/dviware/mdvi/config/nls.mk.in b/dviware/mdvi/config/nls.mk.in new file mode 100644 index 0000000000..d69e1535a4 --- /dev/null +++ b/dviware/mdvi/config/nls.mk.in @@ -0,0 +1,213 @@ +########################################################################### +# +# This makefile fragment deals with generation and installation of message +# catalogs. It is a modified version of the Makefile.in.in distributed with +# GNU gettext (taken from version 0.10.35). It was modified to be used when +# distributing a package that contains several sub-packages and libraries, +# each with their own message catalogs, and each with support for different +# languages. +# +# Packages can have different directories or share the same one. This +# fragment assumes that the catalogs are in a `po' subdirectory of the +# source directory, but if this is not the case, set the `SOURCEDIR' +# directory to point to the sources. +# +# To use this, create a Makefile that looks like the following: +# +# --cut-here-- +# include <top directory>/config/config.mk +# +# LINGUAS = <set of languages supported by this package> +# +# # These are optional (see below) +# PACKAGE = <package name> +# +# POT_SOURCES = <base name of source files needing translation in `..'> +# POT_OTHER = <full name of other source files> +# +# include <top directory>/config/nls.mk +# --cut-here-- +# +# That's it. You may omit the PACKAGE variable if you have a file +# `package-info' in the source directory +# +########################################################################### + +ifndef SOURCEDIR +SOURCEDIR = .. +endif + +ifndef PACKAGE +include $(SOURCEDIR)/package-info +endif + +ifndef LOCALEDIR +ifeq "@LOCALEDIR@" "" +LOCALEDIR = $(prefix)/locale +else +LOCALEDIR = @LOCALEDIR@ +endif +endif + +GNU_LOCALEDIR = $(prefix)/share/locale + +srcdir = @srcdir@ +top_srcdir = @TOPSRCDIR@ + +# Programs +GENCAT = @GENCAT@ +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +MSGMERGE = msgmerge + +SOURCES = cat-id-tbl.c +POFILES = @POFILES@ +GMOFILES = @GMOFILES@ + +# Files for distribution +# DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \ +# stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES) + +POTFILES = $(addprefix $(SOURCEDIR)/, $(POT_SOURCES)) $(POT_OTHER) + +CATOBJEXT = @CATOBJEXT@ +INSTOBJEXT = @INSTOBJEXT@ + +CLEANABLE += core core.* *.pox $(PACKAGE).po *.old.po cat-id-tbl.tmp *.o +DISTCLEANABLE += *.mo *.msg *.cat *.cat.m +MAINCLEANABLE += $(GMOFILES) + +CATALOGS := $(addsuffix $(CATOBJEXT), $(LINGUAS)) + +.SUFFIXES: .po .pox .gmo .mo .msg .cat + +.po.pox: $(PACKAGE).pot + # $(MAKE) $(PACKAGE).pot + $(MSGMERGE) $< $(PACKAGE).pot -o $*.pox + +.po.mo: + $(MSGFMT) -o $@ $< + +.po.gmo: + file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \ + && rm -f $$file && $(GMSGFMT) -o $$file $< + +.po.cat: + sed -f $(top_srcdir)/intl/po2msg.sed < $< > $*.msg \ + && rm -f $@ && $(GENCAT) $@ $*.msg + +.PHONY: all all-yes all-no +all: all-@USE_NLS@ + +all-yes: cat-id-tbl.c $(CATALOGS) +all-no: + +$(PACKAGE).pot: $(POTFILES) + @echo "Extracting messages from sources" + @$(XGETTEXT) --default-domain=$(PACKAGE) \ + --add-comments --keyword=_ --keyword=_G $(POTFILES) \ + && test ! -f $(PACKAGE).po \ + || ( rm -f $(srcdir)/$(PACKAGE).pot \ + && mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot ) + +$(srcdir)/cat-id-tbl.c: stamp-cat-id; @: +$(srcdir)/stamp-cat-id: $(PACKAGE).pot + @rm -f cat-id-tbl.tmp + @sed -f $(top_srcdir)/intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \ + | sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp + @if cmp -s cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; then \ + rm cat-id-tbl.tmp; \ + else \ + echo cat-id-tbl.c changed; \ + rm -f $(srcdir)/cat-id-tbl.c; \ + mv cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; \ + fi + @cd $(srcdir) && rm -f stamp-cat-id && echo timestamp > stamp-cat-id + +.PHONY: install install-exec install-data install-data-yes install-data-no +install: install-exec install-data +install-exec: +install-data: install-data-@USE_NLS@ +install-data-no: all +install-data-yes: all + @catalogs="$(CATALOGS)"; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + case "$$cat" in \ + *.gmo) destdir=$(GNU_LOCALEDIR);; \ + *) destdir=$(LOCALEDIR);; \ + esac; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + dir=$$destdir/$$lang/LC_MESSAGES; \ + $(MKINSTALLDIRS) $$dir; \ + if test -r $$cat; then \ + $(INSTALL_DATA) $$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \ + echo "installing $$cat as $$dir/$(PACKAGE)$(INSTOBJEXT)"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \ + echo "installing $(srcdir)/$$cat as" \ + "$$dir/$(PACKAGE)$(INSTOBJEXT)"; \ + fi; \ + if test -r $$cat.m; then \ + $(INSTALL_DATA) $$cat.m $$dir/$(PACKAGE)$(INSTOBJEXT).m; \ + echo "installing $$cat.m as $$dir/$(PACKAGE)$(INSTOBJEXT).m"; \ + else \ + if test -r $(srcdir)/$$cat.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$cat.m \ + $$dir/$(PACKAGE)$(INSTOBJEXT).m; \ + echo "installing $(srcdir)/$$cat as" \ + "$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \ + else \ + true; \ + fi; \ + fi; \ + done + +.PHONY: uninstall +uninstall: + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + rm -f $(LOCALEDIR)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \ + rm -f $(LOCALEDIR)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \ + rm -f $(GNU_LOCALEDIR)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \ + rm -f $(GNU_LOCALEDIR)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \ + done + +.PHONY: check +check: all + +cat-id-tbl.o: $(top_srcdir)/intl/libgettext.h + +.PHONY: update-po +update-po: Makefile $(PACKAGE).pot + cd $(srcdir); \ + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + mv $$lang.po $$lang.old.po; \ + echo "$$lang:"; \ + if $(MSGMERGE) $$lang.old.po $(PACKAGE).pot -o $$lang.po; then \ + rm -f $$lang.old.po; \ + else \ + echo "msgmerge for $$cat failed!"; \ + rm -f $$lang.po; \ + mv $$lang.old.po $$lang.po; \ + fi; \ + done + +ifdef SUBDIR +Makefile: Makefile.in + @cd $(TOPSRCDIR) && \ + CONFIG_FILES=$(SUBDIR)/po/$@ CONFIG_HEADERS= \ + ./config.status +endif + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: + +include $(FRAGDIR)/targets.mk diff --git a/dviware/mdvi/config/targets.mk b/dviware/mdvi/config/targets.mk new file mode 100644 index 0000000000..a9c07b5bf7 --- /dev/null +++ b/dviware/mdvi/config/targets.mk @@ -0,0 +1,28 @@ + +.PHONY: clean-local +clean-local: + $(RM) $(CLEANABLE) + +.PHONY: clean-subdirs +clean-subdirs: + @list="$(SUBDIRS)"; for i in $$list; do \ + $(MAKE) -C $$i clean; \ + done + +.PHONY: clean +clean: clean-subdirs clean-local + +.PHONY: distclean-local +distclean-local: clean-local + $(RM) $(DISTCLEANABLE) + +.PHONY: distclean-subdirs +distclean-subdirs: + @list="$(SUBDIRS)"; for i in $$list; do \ + if test -d "$$i"; then \ + $(MAKE) -C $$i distclean; \ + else :; fi; \ + done + +.PHONY: distclean realclean +distclean realclean: distclean-subdirs distclean-local diff --git a/dviware/mdvi/config/texmf.m4 b/dviware/mdvi/config/texmf.m4 new file mode 100644 index 0000000000..571633a1a3 --- /dev/null +++ b/dviware/mdvi/config/texmf.m4 @@ -0,0 +1,55 @@ +AC_DEFUN(AC_CHECK_TEXMF, [ +AC_ARG_WITHX(texmf, + [path to an existing texmf tree (\$TEXMFLOCAL)], + [case "$withval" in + yes|no) texmf= ;; + *) texmf="$withval" ;; + esac], , [=DIR]) +AC_PATH_PROG(KPSEWHICH, kpsewhich) +if test -z "$texmf"; then + AC_MSG_CHECKING([for a texmf tree]) + # If user did not specify something, try it ourselves + AC_CACHE_VAL(ac_cv_texmf_tree, [ + if test -x "$KPSEWHICH"; then + ac_cv_texmf_tree=`$KPSEWHICH --expand-var='$TEXMFLOCAL'` + if test -z "$ac_cv_texmf_tree"; then + ac_cv_texmf_tree=`$KPSEWHICH --expand-var='$TEXMFMAIN'` + fi + fi + if test -z "$ac_cv_texmf_tree"; then + # try some common paths + for i in /usr/share/texmf /usr/local/share/texmf; do + if test -d $$i; then + ac_cv_texmf_tree=$$i + break + fi + done + fi + ]) + AC_MSG_RESULT("$ac_cv_texmf_tree") + texmf="$ac_cv_texmf_tree" +else + ac_cv_texmf_tree="$texmf" +fi +if test -n "$texmf"; then + AC_DEFINE_UNQUOTED(TEXMFTOP, "$texmf", + [Define to the full path of an existing texmf tree]) + AC_MSG_CHECKING([for texmf.cnf]) + if test -x "$KPSEWHICH"; then + texmfcnf=`$KPSEWHICH --format=web2c texmf.cnf` + fi + if test -z "$texmfcnf"; then + texmfcnf="$texmf/web2c/texmf.cnf" + fi + if test -f $texmfcnf; then + AC_MSG_RESULT(yes) + AC_DEFINE_UNQUOTED(TEXMF_IS_WEB2C, 1, + [Define if you are using a web2c-based TeX distribution]) + texmf_is_web2c=yes + else + AC_MSG_RESULT(no) + texmf_is_web2c=no + fi +fi +AC_SUBST(texmf) +]) diff --git a/dviware/mdvi/config/with.m4 b/dviware/mdvi/config/with.m4 new file mode 100644 index 0000000000..a822135dde --- /dev/null +++ b/dviware/mdvi/config/with.m4 @@ -0,0 +1,65 @@ +dnl +dnl AC_ARG_WITHX, AC_ARG_WITHOUTX, AC_ARG_ENABLEX, AC_ARG_DISABLEX +dnl +dnl These macros behave just as AC_ARG_WITH and AC_ARG_ENABLE, except +dnl that they make sure the --help descriptions will be aligned properly +dnl +AC_DEFUN(AC_ARG_WITHX, +[AC_ARG_WITH([$1], + ifelse(builtin(eval, len([$1$5])<17),1, + builtin(format, [[ --with-]%-17s%s], [$1$5], [$2]), + [ --with-$1$5 + $2]), [$3], [$4])]) +AC_DEFUN(AC_ARG_WITHOUTX, +[AC_ARG_WITH([$1], + ifelse(builtin(eval, len([$1$5])<14),1, + builtin(format, [ [--without-]%-14s%s], [$1$5], [$2]), + [ --without-$1$5 + $2]), [$3], [$4])]) +AC_DEFUN(AC_ARG_ENABLEX, +[AC_ARG_ENABLE([$1], + ifelse(builtin(eval, len([$1$5])<15),1, + builtin(format, [ [--enable-]%-15s%s], [$1$5], [$2]), + [ --enable-$1$5 + $2]), [$3], [$4])]) +AC_DEFUN(AC_ARG_DISABLEX, +[AC_ARG_ENABLE([$1], + ifelse(builtin(eval, len([$1$5])<14),1, + builtin(format, [ [--disable-]%-14s%s], [$1$5], [$2]), + [ --disable-$1$5 + $2]), [$3], [$4])]) +dnl +dnl AC_ARG_WITH_BOOL(name, default, description) +dnl +AC_DEFUN(AC_ARG_WITH_BOOL, [ + define([VAR],[with_]translit($1,-,_)) + ifelse([$2], [yes], + [AC_ARG_WITHOUTX([$1], [$3], + [case "$withval" in + yes|no) ;; + *) VAR=yes ;; + esac], VAR=yes)], + [AC_ARG_WITHX([$1], [$3], + [case "$withval" in + yes|no) ;; + *) VAR=no ;; + esac], VAR=no)]dnl + ) + undefine([VAR]) +]) +AC_DEFUN(AC_ARG_ENABLE_BOOL, [ + define([VAR],[enable_]translit($1,-,_)) + ifelse([$2], [yes], + [AC_ARG_DISABLEX([$1], [$3], + [case "$enableval" in + yes|no) ;; + *) VAR=yes ;; + esac], VAR=yes)], + [AC_ARG_ENABLEX([$1], [$3], + [case "$enableval" in + yes|no) ;; + *) VAR=no ;; + esac], VAR=no)]dnl + ) + undefine([VAR]) +]) diff --git a/dviware/mdvi/configure b/dviware/mdvi/configure new file mode 100644 index 0000000000..374f742be6 --- /dev/null +++ b/dviware/mdvi/configure @@ -0,0 +1,6113 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --disable-nls do not use Native Language Support" +ac_help="$ac_help + --with-included-gettext use the GNU gettext library included here" +ac_help="$ac_help + --with-catgets use catgets functions if available" +ac_help="$ac_help + --with-x use the X Window System" +ac_help="$ac_help + --with-target-byte-order=ORDER + set target byte order, if cross-compiling + (ORDER is one of lsb, msb, auto)" +ac_help="$ac_help + --disable-regex-specials + disable regular expressions in \\special handlers" +ac_help="$ac_help + --without-omega disable Omega-specific file formats" +ac_help="$ac_help + --with-type1-fonts add support for type1 fonts (requires t1lib)" +ac_help="$ac_help + --with-truetype-fonts add support for TrueType fonts (required Freetype 1.x)" +ac_help="$ac_help + --disable-cheap-trick disable cheap X transparency trick" +ac_help="$ac_help + --disable-afm-files disable support for AFM metric files" +ac_help="$ac_help + --with-frontends=LIST frontends to compile (only \`x11' for now)" +ac_help="$ac_help + --with-texmf=DIR path to an existing texmf tree (\$TEXMFLOCAL)" +ac_help="$ac_help + --with-freetype-headers=DIR + location of the FreeType headers" +ac_help="$ac_help + --with-freetype-library=DIR + location of the FreeType library" +ac_help="$ac_help + --with-t1lib-headers=DIR + location of the t1lib headers" +ac_help="$ac_help + --with-t1lib-library=DIR + location of the t1lib library" +ac_help="$ac_help + --with-kpathsea-headers=DIR + location of the kpathsea headers" +ac_help="$ac_help + --with-kpathsea-library=DIR + location of the kpathsea library" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=./config/VERSION + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + +ac_aux_dir= +for ac_dir in ./config $srcdir/./config; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in ./config $srcdir/./config" 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + + +. $srcdir/config/VERSION +cat >> confdefs.h <<EOF +#define PACKAGE "$PACKAGE" +EOF + +cat >> confdefs.h <<EOF +#define VERSION "$VERSION" +EOF + + + + + + + +TOPDIR=`pwd` +TOPSRCDIR=`cd $srcdir && pwd` + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:616: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:646: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:697: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:729: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 740 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:771: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:776: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:785: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:804: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:847: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:900: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Extract the first word of "md5sum", so it can be a program name with args. +set dummy md5sum; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:929: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MD5SUM'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MD5SUM" in + /*) + ac_cv_path_MD5SUM="$MD5SUM" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_MD5SUM="$MD5SUM" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_MD5SUM="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MD5SUM" && ac_cv_path_MD5SUM=":" + ;; +esac +fi +MD5SUM="$ac_cv_path_MD5SUM" +if test -n "$MD5SUM"; then + echo "$ac_t""$MD5SUM" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + +ALL_LINGUAS="es" + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:967: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 982 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:988: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 999 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext <<EOF +#line 1016 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1022: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1049: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 +echo "configure:1077: checking for POSIXized ISC" >&5 +if test -d /etc/conf/kconfig.d && + grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 +then + echo "$ac_t""yes" 1>&6 + ISC=yes # If later tests want to check for ISC. + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + if test "$GCC" = yes; then + CC="$CC -posix" + else + CC="$CC -Xp" + fi +else + echo "$ac_t""no" 1>&6 + ISC= +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1098: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1103 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1111: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1128 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1146 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext <<EOF +#line 1167 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1178: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:1202: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1207 "configure" +#include "confdefs.h" + +int main() { + +/* Ultrix mips cc rejects this. */ +typedef int charset[2]; const charset x; +/* SunOS 4.1.1 cc rejects this. */ +char const *const *ccp; +char **p; +/* NEC SVR4.0.2 mips cc rejects this. */ +struct point {int x, y;}; +static struct point const zero = {0,0}; +/* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in an arm + of an if-expression whose if-part is not a constant expression */ +const char *g = "string"; +ccp = &g + (g ? g-g : 0); +/* HPUX 7.0 cc rejects these. */ +++ccp; +p = (char**) ccp; +ccp = (char const *const *) p; +{ /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; +} +{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; +} +{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; +} +{ /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1256: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:1277: checking for inline" >&5 +if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat > conftest.$ac_ext <<EOF +#line 1284 "configure" +#include "confdefs.h" + +int main() { +} $ac_kw foo() { +; return 0; } +EOF +if { (eval echo configure:1291: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_inline=$ac_kw; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done + +fi + +echo "$ac_t""$ac_cv_c_inline" 1>&6 +case "$ac_cv_c_inline" in + inline | yes) ;; + no) cat >> confdefs.h <<\EOF +#define inline +EOF + ;; + *) cat >> confdefs.h <<EOF +#define inline $ac_cv_c_inline +EOF + ;; +esac + +echo $ac_n "checking for off_t""... $ac_c" 1>&6 +echo "configure:1317: checking for off_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1322 "configure" +#include "confdefs.h" +#include <sys/types.h> +#if STDC_HEADERS +#include <stdlib.h> +#include <stddef.h> +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_off_t=yes +else + rm -rf conftest* + ac_cv_type_off_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_off_t" 1>&6 +if test $ac_cv_type_off_t = no; then + cat >> confdefs.h <<\EOF +#define off_t long +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:1350: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1355 "configure" +#include "confdefs.h" +#include <sys/types.h> +#if STDC_HEADERS +#include <stdlib.h> +#include <stddef.h> +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 +echo "configure:1385: checking for working alloca.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1390 "configure" +#include "confdefs.h" +#include <alloca.h> +int main() { +char *p = alloca(2 * sizeof(int)); +; return 0; } +EOF +if { (eval echo configure:1397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_header_alloca_h=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_alloca_h=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_alloca_h" 1>&6 +if test $ac_cv_header_alloca_h = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA_H 1 +EOF + +fi + +echo $ac_n "checking for alloca""... $ac_c" 1>&6 +echo "configure:1418: checking for alloca" >&5 +if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1423 "configure" +#include "confdefs.h" + +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef _MSC_VER +# include <malloc.h> +# define alloca _alloca +# else +# if HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +int main() { +char *p = (char *) alloca(1); +; return 0; } +EOF +if { (eval echo configure:1451: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_func_alloca_works=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_func_alloca_works=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_func_alloca_works" 1>&6 +if test $ac_cv_func_alloca_works = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA 1 +EOF + +fi + +if test $ac_cv_func_alloca_works = no; then + # The SVR3 libPW and SVR4 libucb both contain incompatible functions + # that cause trouble. Some versions do not even contain alloca or + # contain a buggy version. If you still want to use their alloca, + # use ar to extract alloca.o from them instead of compiling alloca.c. + ALLOCA=alloca.${ac_objext} + cat >> confdefs.h <<\EOF +#define C_ALLOCA 1 +EOF + + +echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 +echo "configure:1483: checking whether alloca needs Cray hooks" >&5 +if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1488 "configure" +#include "confdefs.h" +#if defined(CRAY) && ! defined(CRAY2) +webecray +#else +wenotbecray +#endif + +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "webecray" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_os_cray=yes +else + rm -rf conftest* + ac_cv_os_cray=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_os_cray" 1>&6 +if test $ac_cv_os_cray = yes; then +for ac_func in _getb67 GETB67 getb67; do + echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1513: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1518 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1541: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<EOF +#define CRAY_STACKSEG_END $ac_func +EOF + + break +else + echo "$ac_t""no" 1>&6 +fi + +done +fi + +echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 +echo "configure:1568: checking stack direction for C alloca" >&5 +if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_stack_direction=0 +else + cat > conftest.$ac_ext <<EOF +#line 1576 "configure" +#include "confdefs.h" +find_stack_direction () +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; +} +main () +{ + exit (find_stack_direction() < 0); +} +EOF +if { (eval echo configure:1595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_c_stack_direction=1 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_c_stack_direction=-1 +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_c_stack_direction" 1>&6 +cat >> confdefs.h <<EOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +EOF + +fi + +for ac_hdr in unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1620: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1625 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1630: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in getpagesize +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1659: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1664 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1687: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +echo $ac_n "checking for working mmap""... $ac_c" 1>&6 +echo "configure:1712: checking for working mmap" >&5 +if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_mmap_fixed_mapped=no +else + cat > conftest.$ac_ext <<EOF +#line 1720 "configure" +#include "confdefs.h" + +/* Thanks to Mike Haertel and Jim Avera for this test. + Here is a matrix of mmap possibilities: + mmap private not fixed + mmap private fixed at somewhere currently unmapped + mmap private fixed at somewhere already mapped + mmap shared not fixed + mmap shared fixed at somewhere currently unmapped + mmap shared fixed at somewhere already mapped + For private mappings, we should verify that changes cannot be read() + back from the file, nor mmap's back from the file at a different + address. (There have been systems where private was not correctly + implemented like the infamous i386 svr4.0, and systems where the + VM page cache was not coherent with the filesystem buffer cache + like early versions of FreeBSD and possibly contemporary NetBSD.) + For shared mappings, we should conversely verify that changes get + propogated back to all the places they're supposed to be. + + Grep wants private fixed already mapped. + The main things grep needs to know about mmap are: + * does it exist and is it safe to write into the mmap'd area + * how to use it (BSD variants) */ +#include <sys/types.h> +#include <fcntl.h> +#include <sys/mman.h> + +/* This mess was copied from the GNU getpagesize.h. */ +#ifndef HAVE_GETPAGESIZE +# ifdef HAVE_UNISTD_H +# include <unistd.h> +# endif + +/* Assume that all systems that can run configure have sys/param.h. */ +# ifndef HAVE_SYS_PARAM_H +# define HAVE_SYS_PARAM_H 1 +# endif + +# ifdef _SC_PAGESIZE +# define getpagesize() sysconf(_SC_PAGESIZE) +# else /* no _SC_PAGESIZE */ +# ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else /* no EXEC_PAGESIZE */ +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* no CLSIZE */ +# else /* no NBPG */ +# ifdef NBPC +# define getpagesize() NBPC +# else /* no NBPC */ +# ifdef PAGESIZE +# define getpagesize() PAGESIZE +# endif /* PAGESIZE */ +# endif /* no NBPC */ +# endif /* no NBPG */ +# endif /* no EXEC_PAGESIZE */ +# else /* no HAVE_SYS_PARAM_H */ +# define getpagesize() 8192 /* punt totally */ +# endif /* no HAVE_SYS_PARAM_H */ +# endif /* no _SC_PAGESIZE */ + +#endif /* no HAVE_GETPAGESIZE */ + +#ifdef __cplusplus +extern "C" { void *malloc(unsigned); } +#else +char *malloc(); +#endif + +int +main() +{ + char *data, *data2, *data3; + int i, pagesize; + int fd; + + pagesize = getpagesize(); + + /* + * First, make a file with some known garbage in it. + */ + data = malloc(pagesize); + if (!data) + exit(1); + for (i = 0; i < pagesize; ++i) + *(data + i) = rand(); + umask(0); + fd = creat("conftestmmap", 0600); + if (fd < 0) + exit(1); + if (write(fd, data, pagesize) != pagesize) + exit(1); + close(fd); + + /* + * Next, try to mmap the file at a fixed address which + * already has something else allocated at it. If we can, + * also make sure that we see the same garbage. + */ + fd = open("conftestmmap", O_RDWR); + if (fd < 0) + exit(1); + data2 = malloc(2 * pagesize); + if (!data2) + exit(1); + data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); + if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + exit(1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + exit(1); + + /* + * Finally, make sure that changes to the mapped area + * do not percolate back to the file as seen by read(). + * (This is a bug on some variants of i386 svr4.0.) + */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = malloc(pagesize); + if (!data3) + exit(1); + if (read(fd, data3, pagesize) != pagesize) + exit(1); + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + exit(1); + close(fd); + unlink("conftestmmap"); + exit(0); +} + +EOF +if { (eval echo configure:1860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_func_mmap_fixed_mapped=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_mmap_fixed_mapped=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6 +if test $ac_cv_func_mmap_fixed_mapped = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_MMAP 1 +EOF + +fi + + + for ac_hdr in argz.h limits.h locale.h nl_types.h malloc.h string.h \ +unistd.h sys/param.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1888: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1893 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1898: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + for ac_func in getcwd munmap putenv setenv setlocale strchr strcasecmp \ +strdup __argz_count __argz_stringify __argz_next +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1928: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1933 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + + if test "${ac_cv_func_stpcpy+set}" != "set"; then + for ac_func in stpcpy +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1985: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1990 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + fi + if test "${ac_cv_func_stpcpy}" = "yes"; then + cat >> confdefs.h <<\EOF +#define HAVE_STPCPY 1 +EOF + + fi + + if test $ac_cv_header_locale_h = yes; then + echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 +echo "configure:2047: checking for LC_MESSAGES" >&5 +if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2052 "configure" +#include "confdefs.h" +#include <locale.h> +int main() { +return LC_MESSAGES +; return 0; } +EOF +if { (eval echo configure:2059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + am_cv_val_LC_MESSAGES=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + am_cv_val_LC_MESSAGES=no +fi +rm -f conftest* +fi + +echo "$ac_t""$am_cv_val_LC_MESSAGES" 1>&6 + if test $am_cv_val_LC_MESSAGES = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_LC_MESSAGES 1 +EOF + + fi + fi + echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 +echo "configure:2080: checking whether NLS is requested" >&5 + # Check whether --enable-nls or --disable-nls was given. +if test "${enable_nls+set}" = set; then + enableval="$enable_nls" + USE_NLS=$enableval +else + USE_NLS=yes +fi + + echo "$ac_t""$USE_NLS" 1>&6 + + + USE_INCLUDED_LIBINTL=no + + if test "$USE_NLS" = "yes"; then + cat >> confdefs.h <<\EOF +#define ENABLE_NLS 1 +EOF + + echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 +echo "configure:2100: checking whether included gettext is requested" >&5 + # Check whether --with-included-gettext or --without-included-gettext was given. +if test "${with_included_gettext+set}" = set; then + withval="$with_included_gettext" + nls_cv_force_use_gnu_gettext=$withval +else + nls_cv_force_use_gnu_gettext=no +fi + + echo "$ac_t""$nls_cv_force_use_gnu_gettext" 1>&6 + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + nls_cv_header_intl= + nls_cv_header_libgt= + CATOBJEXT=NONE + + ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for libintl.h""... $ac_c" 1>&6 +echo "configure:2119: checking for libintl.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2124 "configure" +#include "confdefs.h" +#include <libintl.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2129: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6 +echo "configure:2146: checking for gettext in libc" >&5 +if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2151 "configure" +#include "confdefs.h" +#include <libintl.h> +int main() { +return (int) gettext ("") +; return 0; } +EOF +if { (eval echo configure:2158: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + gt_cv_func_gettext_libc=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + gt_cv_func_gettext_libc=no +fi +rm -f conftest* +fi + +echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6 + + if test "$gt_cv_func_gettext_libc" != "yes"; then + echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6 +echo "configure:2174: checking for bindtextdomain in -lintl" >&5 +ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lintl $LIBS" +cat > conftest.$ac_ext <<EOF +#line 2182 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char bindtextdomain(); + +int main() { +bindtextdomain() +; return 0; } +EOF +if { (eval echo configure:2193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6 +echo "configure:2209: checking for gettext in libintl" >&5 +if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo $ac_n "checking for gettext in -lintl""... $ac_c" 1>&6 +echo "configure:2214: checking for gettext in -lintl" >&5 +ac_lib_var=`echo intl'_'gettext | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lintl $LIBS" +cat > conftest.$ac_ext <<EOF +#line 2222 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gettext(); + +int main() { +gettext() +; return 0; } +EOF +if { (eval echo configure:2233: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + gt_cv_func_gettext_libintl=yes +else + echo "$ac_t""no" 1>&6 +gt_cv_func_gettext_libintl=no +fi + +fi + +echo "$ac_t""$gt_cv_func_gettext_libintl" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + fi + + if test "$gt_cv_func_gettext_libc" = "yes" \ + || test "$gt_cv_func_gettext_libintl" = "yes"; then + cat >> confdefs.h <<\EOF +#define HAVE_GETTEXT 1 +EOF + + # Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2272: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MSGFMT" in + /*) + ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then + ac_cv_path_MSGFMT="$ac_dir/$ac_word" + break + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="no" + ;; +esac +fi +MSGFMT="$ac_cv_path_MSGFMT" +if test -n "$MSGFMT"; then + echo "$ac_t""$MSGFMT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + if test "$MSGFMT" != "no"; then + for ac_func in dcgettext +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:2306: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2311 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + # Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2361: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$GMSGFMT" in + /*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_GMSGFMT="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" + ;; +esac +fi +GMSGFMT="$ac_cv_path_GMSGFMT" +if test -n "$GMSGFMT"; then + echo "$ac_t""$GMSGFMT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + # Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2397: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$XGETTEXT" in + /*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then + ac_cv_path_XGETTEXT="$ac_dir/$ac_word" + break + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" + ;; +esac +fi +XGETTEXT="$ac_cv_path_XGETTEXT" +if test -n "$XGETTEXT"; then + echo "$ac_t""$XGETTEXT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + cat > conftest.$ac_ext <<EOF +#line 2429 "configure" +#include "confdefs.h" + +int main() { +extern int _nl_msg_cat_cntr; + return _nl_msg_cat_cntr +; return 0; } +EOF +if { (eval echo configure:2437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + CATOBJEXT=.gmo + DATADIRNAME=share +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CATOBJEXT=.mo + DATADIRNAME=lib +fi +rm -f conftest* + INSTOBJEXT=.mo + fi + fi + +else + echo "$ac_t""no" 1>&6 +fi + + + if test "$CATOBJEXT" = "NONE"; then + echo $ac_n "checking whether catgets can be used""... $ac_c" 1>&6 +echo "configure:2460: checking whether catgets can be used" >&5 + # Check whether --with-catgets or --without-catgets was given. +if test "${with_catgets+set}" = set; then + withval="$with_catgets" + nls_cv_use_catgets=$withval +else + nls_cv_use_catgets=no +fi + + echo "$ac_t""$nls_cv_use_catgets" 1>&6 + + if test "$nls_cv_use_catgets" = "yes"; then + echo $ac_n "checking for main in -li""... $ac_c" 1>&6 +echo "configure:2473: checking for main in -li" >&5 +ac_lib_var=`echo i'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-li $LIBS" +cat > conftest.$ac_ext <<EOF +#line 2481 "configure" +#include "confdefs.h" + +int main() { +main() +; return 0; } +EOF +if { (eval echo configure:2488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo i | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <<EOF +#define $ac_tr_lib 1 +EOF + + LIBS="-li $LIBS" + +else + echo "$ac_t""no" 1>&6 +fi + + echo $ac_n "checking for catgets""... $ac_c" 1>&6 +echo "configure:2516: checking for catgets" >&5 +if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2521 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char catgets(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char catgets(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_catgets) || defined (__stub___catgets) +choke me +#else +catgets(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_catgets=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_catgets=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'catgets`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_CATGETS 1 +EOF + + INTLOBJS="\$(CATOBJS)" + # Extract the first word of "gencat", so it can be a program name with args. +set dummy gencat; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2566: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_GENCAT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$GENCAT" in + /*) + ac_cv_path_GENCAT="$GENCAT" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_GENCAT="$GENCAT" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_GENCAT="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_GENCAT" && ac_cv_path_GENCAT="no" + ;; +esac +fi +GENCAT="$ac_cv_path_GENCAT" +if test -n "$GENCAT"; then + echo "$ac_t""$GENCAT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + if test "$GENCAT" != "no"; then + # Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2602: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$GMSGFMT" in + /*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_GMSGFMT="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="no" + ;; +esac +fi +GMSGFMT="$ac_cv_path_GMSGFMT" +if test -n "$GMSGFMT"; then + echo "$ac_t""$GMSGFMT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test "$GMSGFMT" = "no"; then + # Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2639: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$GMSGFMT" in + /*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then + ac_cv_path_GMSGFMT="$ac_dir/$ac_word" + break + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="no" + ;; +esac +fi +GMSGFMT="$ac_cv_path_GMSGFMT" +if test -n "$GMSGFMT"; then + echo "$ac_t""$GMSGFMT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + fi + # Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2674: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$XGETTEXT" in + /*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then + ac_cv_path_XGETTEXT="$ac_dir/$ac_word" + break + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" + ;; +esac +fi +XGETTEXT="$ac_cv_path_XGETTEXT" +if test -n "$XGETTEXT"; then + echo "$ac_t""$XGETTEXT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + USE_INCLUDED_LIBINTL=yes + CATOBJEXT=.cat + INSTOBJEXT=.cat + DATADIRNAME=lib + INTLDEPS='$(top_builddir)/intl/libintl.a' + INTLLIBS=$INTLDEPS + LIBS=`echo $LIBS | sed -e 's/-lintl//'` + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi +else + echo "$ac_t""no" 1>&6 +fi + + fi + fi + + if test "$CATOBJEXT" = "NONE"; then + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + INTLOBJS="\$(GETTOBJS)" + # Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2732: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MSGFMT" in + /*) + ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then + ac_cv_path_MSGFMT="$ac_dir/$ac_word" + break + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="msgfmt" + ;; +esac +fi +MSGFMT="$ac_cv_path_MSGFMT" +if test -n "$MSGFMT"; then + echo "$ac_t""$MSGFMT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + # Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2766: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$GMSGFMT" in + /*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_GMSGFMT="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" + ;; +esac +fi +GMSGFMT="$ac_cv_path_GMSGFMT" +if test -n "$GMSGFMT"; then + echo "$ac_t""$GMSGFMT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + # Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:2802: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$XGETTEXT" in + /*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then + ac_cv_path_XGETTEXT="$ac_dir/$ac_word" + break + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" + ;; +esac +fi +XGETTEXT="$ac_cv_path_XGETTEXT" +if test -n "$XGETTEXT"; then + echo "$ac_t""$XGETTEXT" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + USE_INCLUDED_LIBINTL=yes + CATOBJEXT=.gmo + INSTOBJEXT=.mo + DATADIRNAME=share + INTLDEPS='$(top_builddir)/intl/libintl.a' + INTLLIBS=$INTLDEPS + LIBS=`echo $LIBS | sed -e 's/-lintl//'` + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi + + if test "$XGETTEXT" != ":"; then + if $XGETTEXT --omit-header /dev/null 2> /dev/null; then + : ; + else + echo "$ac_t""found xgettext program is not GNU xgettext; ignore it" 1>&6 + XGETTEXT=":" + fi + fi + + # We need to process the po/ directory. + POSUB=po + else + DATADIRNAME=share + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi + +# AC_OUTPUT_COMMANDS( +# [case "$CONFIG_FILES" in *po/Makefile.in*) +# sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile +# esac]) + + for lang in $ALL_LINGUAS; do + GMOFILES="$GMOFILES $lang.gmo" + POFILES="$POFILES $lang.po" + done + + + + + + + + + + + + + + + if test "x$CATOBJEXT" != "x"; then + if test "x$ALL_LINGUAS" = "x"; then + LINGUAS= + else + echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6 +echo "configure:2890: checking for catalogs to be installed" >&5 + NEW_LINGUAS= + for lang in ${LINGUAS=$ALL_LINGUAS}; do + case "$ALL_LINGUAS" in + *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; + esac + done + LINGUAS=$NEW_LINGUAS + echo "$ac_t""$LINGUAS" 1>&6 + fi + + if test -n "$LINGUAS"; then + for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done + fi + fi + + if test $ac_cv_header_locale_h = yes; then + INCLUDE_LOCALE_H="#include <locale.h>" + else + INCLUDE_LOCALE_H="\ +/* The system does not provide the header <locale.h>. Take care yourself. */" + fi + + + test -d intl || mkdir intl + if test "$CATOBJEXT" = ".cat"; then + ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6 +echo "configure:2918: checking for linux/version.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 2923 "configure" +#include "confdefs.h" +#include <linux/version.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + msgformat=linux +else + echo "$ac_t""no" 1>&6 +msgformat=xopen +fi + + + sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed + fi + sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ + $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed + + if test "$PACKAGE" = "gettext"; then + GT_NO="#NO#" + GT_YES= + else + GT_NO= + GT_YES="#YES#" + fi + + + + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + + + l= + + + # test -d po || mkdir po +# if test "x$srcdir" != "x."; then +# if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then +# posrcprefix="$srcdir/" +# else +# posrcprefix="../$srcdir/" +# fi +# else +# posrcprefix="../" +# fi +# rm -f po/POTFILES +# sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ +# < $srcdir/po/POTFILES.in > po/POTFILES + + +echo $ac_n "checking for floor in -lm""... $ac_c" 1>&6 +echo "configure:2994: checking for floor in -lm" >&5 +ac_lib_var=`echo m'_'floor | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lm $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3002 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char floor(); + +int main() { +floor() +; return 0; } +EOF +if { (eval echo configure:3013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <<EOF +#define $ac_tr_lib 1 +EOF + + LIBS="-lm $LIBS" + +else + echo "$ac_t""no" 1>&6 +fi + + +# If we find X, set shell vars x_includes and x_libraries to the +# paths, otherwise set no_x=yes. +# Uses ac_ vars as temps to allow command line to override cache and checks. +# --without-x overrides everything else, but does not touch the cache. +echo $ac_n "checking for X""... $ac_c" 1>&6 +echo "configure:3046: checking for X" >&5 + +# Check whether --with-x or --without-x was given. +if test "${with_x+set}" = set; then + withval="$with_x" + : +fi + +# $have_x is `yes', `no', `disabled', or empty when we do not yet know. +if test "x$with_x" = xno; then + # The user explicitly disabled X. + have_x=disabled +else + if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then + # Both variables are already set. + have_x=yes + else +if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # One or both of the vars are not set, and there is no cached value. +ac_x_includes=NO ac_x_libraries=NO +rm -fr conftestdir +if mkdir conftestdir; then + cd conftestdir + # Make sure to not put "make" in the Imakefile rules, since we grep it out. + cat > Imakefile <<'EOF' +acfindx: + @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' +EOF + if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + for ac_extension in a so sl; do + if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && + test -f $ac_im_libdir/libX11.$ac_extension; then + ac_im_usrlibdir=$ac_im_libdir; break + fi + done + # Screen out bogus values from the imake configuration. They are + # bogus both because they are the default anyway, and because + # using them would break gcc on systems where it needs fixed includes. + case "$ac_im_incroot" in + /usr/include) ;; + *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; + esac + case "$ac_im_usrlibdir" in + /usr/lib | /lib) ;; + *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; + esac + fi + cd .. + rm -fr conftestdir +fi + +if test "$ac_x_includes" = NO; then + # Guess where to find include files, by looking for this one X11 .h file. + test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h + + # First, try using that file with no special directory specified. +cat > conftest.$ac_ext <<EOF +#line 3108 "configure" +#include "confdefs.h" +#include <$x_direct_test_include> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:3113: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + # We can compile using X headers with no special include directory. +ac_x_includes= +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + # Look for the header file in a standard set of common directories. +# Check X11 before X11Rn because it is often a symlink to the current release. + for ac_dir in \ + /usr/X11/include \ + /usr/X11R6/include \ + /usr/X11R5/include \ + /usr/X11R4/include \ + \ + /usr/include/X11 \ + /usr/include/X11R6 \ + /usr/include/X11R5 \ + /usr/include/X11R4 \ + \ + /usr/local/X11/include \ + /usr/local/X11R6/include \ + /usr/local/X11R5/include \ + /usr/local/X11R4/include \ + \ + /usr/local/include/X11 \ + /usr/local/include/X11R6 \ + /usr/local/include/X11R5 \ + /usr/local/include/X11R4 \ + \ + /usr/X386/include \ + /usr/x386/include \ + /usr/XFree86/include/X11 \ + \ + /usr/include \ + /usr/local/include \ + /usr/unsupported/include \ + /usr/athena/include \ + /usr/local/x11r5/include \ + /usr/lpp/Xamples/include \ + \ + /usr/openwin/include \ + /usr/openwin/share/include \ + ; \ + do + if test -r "$ac_dir/$x_direct_test_include"; then + ac_x_includes=$ac_dir + break + fi + done +fi +rm -f conftest* +fi # $ac_x_includes = NO + +if test "$ac_x_libraries" = NO; then + # Check for the libraries. + + test -z "$x_direct_test_library" && x_direct_test_library=Xt + test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc + + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS="$LIBS" + LIBS="-l$x_direct_test_library $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3182 "configure" +#include "confdefs.h" + +int main() { +${x_direct_test_function}() +; return 0; } +EOF +if { (eval echo configure:3189: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + LIBS="$ac_save_LIBS" +# We can link X programs with no special library path. +ac_x_libraries= +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + LIBS="$ac_save_LIBS" +# First see if replacing the include by lib works. +# Check X11 before X11Rn because it is often a symlink to the current release. +for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ + /usr/X11/lib \ + /usr/X11R6/lib \ + /usr/X11R5/lib \ + /usr/X11R4/lib \ + \ + /usr/lib/X11 \ + /usr/lib/X11R6 \ + /usr/lib/X11R5 \ + /usr/lib/X11R4 \ + \ + /usr/local/X11/lib \ + /usr/local/X11R6/lib \ + /usr/local/X11R5/lib \ + /usr/local/X11R4/lib \ + \ + /usr/local/lib/X11 \ + /usr/local/lib/X11R6 \ + /usr/local/lib/X11R5 \ + /usr/local/lib/X11R4 \ + \ + /usr/X386/lib \ + /usr/x386/lib \ + /usr/XFree86/lib/X11 \ + \ + /usr/lib \ + /usr/local/lib \ + /usr/unsupported/lib \ + /usr/athena/lib \ + /usr/local/x11r5/lib \ + /usr/lpp/Xamples/lib \ + /lib/usr/lib/X11 \ + \ + /usr/openwin/lib \ + /usr/openwin/share/lib \ + ; \ +do + for ac_extension in a so sl; do + if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi +rm -f conftest* +fi # $ac_x_libraries = NO + +if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then + # Didn't find X anywhere. Cache the known absence of X. + ac_cv_have_x="have_x=no" +else + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" +fi +fi + fi + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + echo "$ac_t""$have_x" 1>&6 + no_x=yes +else + # If each of the values was on the command line, it overrides each guess. + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + # Update the cache value to reflect the command line values. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$x_includes ac_x_libraries=$x_libraries" + echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 +fi + +if test "$no_x" = yes; then + # Not all programs may use this symbol, but it does not hurt to define it. + cat >> confdefs.h <<\EOF +#define X_DISPLAY_MISSING 1 +EOF + + X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= +else + if test -n "$x_includes"; then + X_CFLAGS="$X_CFLAGS -I$x_includes" + fi + + # It would also be nice to do this for all -L options, not just this one. + if test -n "$x_libraries"; then + X_LIBS="$X_LIBS -L$x_libraries" + # For Solaris; some versions of Sun CC require a space after -R and + # others require no space. Words are not sufficient . . . . + case "`(uname -sr) 2>/dev/null`" in + "SunOS 5"*) + echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 +echo "configure:3295: checking whether -R must be followed by a space" >&5 + ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" + cat > conftest.$ac_ext <<EOF +#line 3298 "configure" +#include "confdefs.h" + +int main() { + +; return 0; } +EOF +if { (eval echo configure:3305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_R_nospace=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_R_nospace=no +fi +rm -f conftest* + if test $ac_R_nospace = yes; then + echo "$ac_t""no" 1>&6 + X_LIBS="$X_LIBS -R$x_libraries" + else + LIBS="$ac_xsave_LIBS -R $x_libraries" + cat > conftest.$ac_ext <<EOF +#line 3321 "configure" +#include "confdefs.h" + +int main() { + +; return 0; } +EOF +if { (eval echo configure:3328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_R_space=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_R_space=no +fi +rm -f conftest* + if test $ac_R_space = yes; then + echo "$ac_t""yes" 1>&6 + X_LIBS="$X_LIBS -R $x_libraries" + else + echo "$ac_t""neither works" 1>&6 + fi + fi + LIBS="$ac_xsave_LIBS" + esac + fi + + # Check for system-dependent libraries X programs must link with. + # Do this before checking for the system-independent R6 libraries + # (-lICE), since we may need -lsocket or whatever for X linking. + + if test "$ISC" = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" + else + # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And karl@cs.umb.edu says + # the Alpha needs dnet_stub (dnet does not exist). + echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 +echo "configure:3360: checking for dnet_ntoa in -ldnet" >&5 +ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldnet $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3368 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dnet_ntoa(); + +int main() { +dnet_ntoa() +; return 0; } +EOF +if { (eval echo configure:3379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_lib_dnet_dnet_ntoa = no; then + echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 +echo "configure:3401: checking for dnet_ntoa in -ldnet_stub" >&5 +ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldnet_stub $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3409 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dnet_ntoa(); + +int main() { +dnet_ntoa() +; return 0; } +EOF +if { (eval echo configure:3420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) + # needs -lnsl. + # The nsl library prevents programs from opening the X display + # on Irix 5.2, according to dickey@clark.net. + echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 +echo "configure:3449: checking for gethostbyname" >&5 +if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 3454 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char gethostbyname(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) +choke me +#else +gethostbyname(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3477: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_gethostbyname=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_gethostbyname=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_gethostbyname = no; then + echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 +echo "configure:3498: checking for gethostbyname in -lnsl" >&5 +ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lnsl $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3506 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname(); + +int main() { +gethostbyname() +; return 0; } +EOF +if { (eval echo configure:3517: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # lieder@skyler.mavd.honeywell.com says without -lsocket, + # socket/setsockopt and other routines are undefined under SCO ODT + # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary + # on later versions), says simon@lia.di.epfl.ch: it contains + # gethostby* variants that don't use the nameserver (or something). + # -lsocket must be given before -lnsl if both are needed. + # We assume that if connect needs -lnsl, so does gethostbyname. + echo $ac_n "checking for connect""... $ac_c" 1>&6 +echo "configure:3547: checking for connect" >&5 +if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 3552 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char connect(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char connect(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_connect) || defined (__stub___connect) +choke me +#else +connect(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_connect=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_connect=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_connect = no; then + echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 +echo "configure:3596: checking for connect in -lsocket" >&5 +ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsocket $X_EXTRA_LIBS $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3604 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char connect(); + +int main() { +connect() +; return 0; } +EOF +if { (eval echo configure:3615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. + echo $ac_n "checking for remove""... $ac_c" 1>&6 +echo "configure:3639: checking for remove" >&5 +if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 3644 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char remove(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char remove(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_remove) || defined (__stub___remove) +choke me +#else +remove(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_remove=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_remove=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_remove = no; then + echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 +echo "configure:3688: checking for remove in -lposix" >&5 +ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lposix $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3696 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char remove(); + +int main() { +remove() +; return 0; } +EOF +if { (eval echo configure:3707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. + echo $ac_n "checking for shmat""... $ac_c" 1>&6 +echo "configure:3731: checking for shmat" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 3736 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shmat(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shmat(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shmat) || defined (__stub___shmat) +choke me +#else +shmat(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3759: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shmat=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shmat=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_shmat = no; then + echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 +echo "configure:3780: checking for shmat in -lipc" >&5 +ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lipc $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3788 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shmat(); + +int main() { +shmat() +; return 0; } +EOF +if { (eval echo configure:3799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" +else + echo "$ac_t""no" 1>&6 +fi + + fi + fi + + # Check for libraries that X11R6 Xt/Xaw programs need. + ac_save_LDFLAGS="$LDFLAGS" + test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" + # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to + # check for ICE first), but we must link in the order -lSM -lICE or + # we get undefined symbols. So assume we have SM if we have ICE. + # These have to be linked with before -lX11, unlike the other + # libraries we check for below, so use a different variable. + # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. + echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 +echo "configure:3832: checking for IceConnectionNumber in -lICE" >&5 +ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lICE $X_EXTRA_LIBS $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3840 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char IceConnectionNumber(); + +int main() { +IceConnectionNumber() +; return 0; } +EOF +if { (eval echo configure:3851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" +else + echo "$ac_t""no" 1>&6 +fi + + LDFLAGS="$ac_save_LDFLAGS" + +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:3876: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 3881 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:3889: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 3906 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 3924 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext <<EOF +#line 3945 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:3956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +for ac_hdr in strings.h fcntl.h unistd.h locale.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:3983: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 3988 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:3993: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:4020: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4025 "configure" +#include "confdefs.h" + +int main() { + +/* Ultrix mips cc rejects this. */ +typedef int charset[2]; const charset x; +/* SunOS 4.1.1 cc rejects this. */ +char const *const *ccp; +char **p; +/* NEC SVR4.0.2 mips cc rejects this. */ +struct point {int x, y;}; +static struct point const zero = {0,0}; +/* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in an arm + of an if-expression whose if-part is not a constant expression */ +const char *g = "string"; +ccp = &g + (g ? g-g : 0); +/* HPUX 7.0 cc rejects these. */ +++ccp; +p = (char**) ccp; +ccp = (char const *const *) p; +{ /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; +} +{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; +} +{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; +} +{ /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:4074: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:4095: checking for inline" >&5 +if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat > conftest.$ac_ext <<EOF +#line 4102 "configure" +#include "confdefs.h" + +int main() { +} $ac_kw foo() { +; return 0; } +EOF +if { (eval echo configure:4109: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_inline=$ac_kw; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done + +fi + +echo "$ac_t""$ac_cv_c_inline" 1>&6 +case "$ac_cv_c_inline" in + inline | yes) ;; + no) cat >> confdefs.h <<\EOF +#define inline +EOF + ;; + *) cat >> confdefs.h <<EOF +#define inline $ac_cv_c_inline +EOF + ;; +esac + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:4135: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4140 "configure" +#include "confdefs.h" +#include <sys/types.h> +#if STDC_HEADERS +#include <stdlib.h> +#include <stddef.h> +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + +echo $ac_n "checking size of long""... $ac_c" 1>&6 +echo "configure:4168: checking size of long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_sizeof_long=4 +else + cat > conftest.$ac_ext <<EOF +#line 4176 "configure" +#include "confdefs.h" +#include <stdio.h> +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long)); + exit(0); +} +EOF +if { (eval echo configure:4187: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_long" 1>&6 +cat >> confdefs.h <<EOF +#define SIZEOF_LONG $ac_cv_sizeof_long +EOF + + +echo $ac_n "checking size of int""... $ac_c" 1>&6 +echo "configure:4207: checking size of int" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_sizeof_int=4 +else + cat > conftest.$ac_ext <<EOF +#line 4215 "configure" +#include "confdefs.h" +#include <stdio.h> +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(int)); + exit(0); +} +EOF +if { (eval echo configure:4226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_int=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_int=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_int" 1>&6 +cat >> confdefs.h <<EOF +#define SIZEOF_INT $ac_cv_sizeof_int +EOF + + +echo $ac_n "checking size of short""... $ac_c" 1>&6 +echo "configure:4246: checking size of short" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_sizeof_short=2 +else + cat > conftest.$ac_ext <<EOF +#line 4254 "configure" +#include "confdefs.h" +#include <stdio.h> +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(short)); + exit(0); +} +EOF +if { (eval echo configure:4265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_short=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_short=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_short" 1>&6 +cat >> confdefs.h <<EOF +#define SIZEOF_SHORT $ac_cv_sizeof_short +EOF + + +echo $ac_n "checking size of void *""... $ac_c" 1>&6 +echo "configure:4285: checking size of void *" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_void_p'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_sizeof_void_p=4 +else + cat > conftest.$ac_ext <<EOF +#line 4293 "configure" +#include "confdefs.h" +#include <stdio.h> +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(void *)); + exit(0); +} +EOF +if { (eval echo configure:4304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_void_p=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_void_p=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_void_p" 1>&6 +cat >> confdefs.h <<EOF +#define SIZEOF_VOID_P $ac_cv_sizeof_void_p +EOF + + + + + # Check whether --with-target-byte-order or --without-target-byte-order was given. +if test "${with_target_byte_order+set}" = set; then + withval="$with_target_byte_order" + byteorder="$withval" +else + byteorder=auto +fi + +case "$byteorder" in + lsb|msb) + if test "$cross_compiling" = no; then + echo "configure: warning: you should force the byte order only when cross-compiling" 1>&2 + fi + ;; + auto) + if test "$cross_compiling" = yes; then + { echo "configure: error: specify the target byte order --with-target-byte-order" 1>&2; exit 1; } + fi + ;; + *) + echo "configure: warning: unknown byte order \`$byteorder', set to \`auto'" 1>&2 + byteorder=auto + ;; +esac +echo $ac_n "checking for target byte order""... $ac_c" 1>&6 +echo "configure:4350: checking for target byte order" >&5 +if test "$byteorder" = auto; then +if eval "test \"`echo '$''{'ac_cv_byteorder'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + if test "$cross_compiling" = yes; then + ac_cv_byteorder=unknown +else + cat > conftest.$ac_ext <<EOF +#line 4360 "configure" +#include "confdefs.h" +#include <stdio.h> +#include <sys/types.h> +#include <sys/param.h> +main(){ +#if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) + FILE *f; + f = fopen("conftestval", "w"); + if(!f) exit(1); +#if BYTE_ORDER == LITTLE_ENDIAN + fprintf(f, "lsb\n"); + exit(0); +#endif +#if BYTE_ORDER == BIG_ENDIAN + fprintf(f, "msb\n"); + exit(0); +#endif +#else + exit(1); +#endif +} +EOF +if { (eval echo configure:4383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_byteorder=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + if test "$cross_compiling" = yes; then + ac_cv_byteorder=unknown +else + cat > conftest.$ac_ext <<EOF +#line 4394 "configure" +#include "confdefs.h" +#include <stdio.h> +main() { + union { + long l; + char c[sizeof(long)]; + } u; + FILE *f; + f = fopen("conftestval", "w"); + u.l = 1; + if(u.c[0] == 1) fprintf(f, "lsb\n"); + else if(u.c[sizeof(long)-1] == 1) fprintf(f, "msb\n"); + else fprintf(f, "unknown\n"); + exit(0); +} +EOF +if { (eval echo configure:4411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_byteorder=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_byteorder=unknown +fi +rm -fr conftest* +fi + +fi +rm -fr conftest* +fi + + +fi + byteorder="$ac_cv_byteorder" +fi + +case "$byteorder" in + lsb) echo "$ac_t""little endian" 1>&6 ;; + msb) + echo "$ac_t""big endian" 1>&6 + cat >> confdefs.h <<EOF +#define WORDS_BIGENDIAN 1 +EOF + + ;; + *) + echo "$ac_t""unknown" 1>&6 + echo "configure: warning: unable to guess the byte order of this machine" 1>&2 + { echo "configure: error: specify the target byte order with --with-target-byte-order" 1>&2; exit 1; } + ;; +esac + + +echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 +echo "configure:4450: checking for 8-bit clean memcmp" >&5 +if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_memcmp_clean=no +else + cat > conftest.$ac_ext <<EOF +#line 4458 "configure" +#include "confdefs.h" + +main() +{ + char c0 = 0x40, c1 = 0x80, c2 = 0x81; + exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1); +} + +EOF +if { (eval echo configure:4468: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_func_memcmp_clean=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_memcmp_clean=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 +test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" + +echo $ac_n "checking for vprintf""... $ac_c" 1>&6 +echo "configure:4486: checking for vprintf" >&5 +if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4491 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char vprintf(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char vprintf(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_vprintf) || defined (__stub___vprintf) +choke me +#else +vprintf(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_vprintf=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_vprintf=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'vprintf`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_VPRINTF 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +if test "$ac_cv_func_vprintf" != yes; then +echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 +echo "configure:4538: checking for _doprnt" >&5 +if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4543 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char _doprnt(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char _doprnt(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub__doprnt) || defined (__stub____doprnt) +choke me +#else +_doprnt(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func__doprnt=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func__doprnt=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'_doprnt`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_DOPRNT 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +fi + +for ac_func in strchr memcpy getopt getopt_long +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4593: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4598 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4621: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + + + + # Check whether --enable-regex-specials or --disable-regex-specials was given. +if test "${enable_regex_specials+set}" = set; then + enableval="$enable_regex_specials" + case "$enableval" in + yes|no) ;; + *) enable_regex_specials=yes ;; + esac +else + enable_regex_specials=yes +fi + + + + + + # Check whether --with-omega or --without-omega was given. +if test "${with_omega+set}" = set; then + withval="$with_omega" + case "$withval" in + yes|no) ;; + *) with_omega=yes ;; + esac +else + with_omega=yes +fi + + + + + + # Check whether --with-type1-fonts or --without-type1-fonts was given. +if test "${with_type1_fonts+set}" = set; then + withval="$with_type1_fonts" + case "$withval" in + yes|no) ;; + *) with_type1_fonts=no ;; + esac +else + with_type1_fonts=no +fi + + + + + + # Check whether --with-truetype-fonts or --without-truetype-fonts was given. +if test "${with_truetype_fonts+set}" = set; then + withval="$with_truetype_fonts" + case "$withval" in + yes|no) ;; + *) with_truetype_fonts=no ;; + esac +else + with_truetype_fonts=no +fi + + + + + + # Check whether --enable-cheap-trick or --disable-cheap-trick was given. +if test "${enable_cheap_trick+set}" = set; then + enableval="$enable_cheap_trick" + case "$enableval" in + yes|no) ;; + *) enable_cheap_trick=yes ;; + esac +else + enable_cheap_trick=yes +fi + + + + + + # Check whether --enable-afm-files or --disable-afm-files was given. +if test "${enable_afm_files+set}" = set; then + enableval="$enable_afm_files" + case "$enableval" in + yes|no) ;; + *) enable_afm_files=yes ;; + esac +else + enable_afm_files=yes +fi + + + +# Check whether --with-frontends or --without-frontends was given. +if test "${with_frontends+set}" = set; then + withval="$with_frontends" + : +fi + + +# Check whether --with-texmf or --without-texmf was given. +if test "${with_texmf+set}" = set; then + withval="$with_texmf" + case "$withval" in + yes|no) texmf= ;; + *) texmf="$withval" ;; + esac +fi + +# Extract the first word of "kpsewhich", so it can be a program name with args. +set dummy kpsewhich; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:4755: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_KPSEWHICH'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$KPSEWHICH" in + /*) + ac_cv_path_KPSEWHICH="$KPSEWHICH" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_KPSEWHICH="$KPSEWHICH" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_KPSEWHICH="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +KPSEWHICH="$ac_cv_path_KPSEWHICH" +if test -n "$KPSEWHICH"; then + echo "$ac_t""$KPSEWHICH" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$texmf"; then + echo $ac_n "checking for a texmf tree""... $ac_c" 1>&6 +echo "configure:4789: checking for a texmf tree" >&5 + # If user did not specify something, try it ourselves + if eval "test \"`echo '$''{'ac_cv_texmf_tree'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + if test -x "$KPSEWHICH"; then + ac_cv_texmf_tree=`$KPSEWHICH --expand-var='$TEXMFLOCAL'` + if test -z "$ac_cv_texmf_tree"; then + ac_cv_texmf_tree=`$KPSEWHICH --expand-var='$TEXMFMAIN'` + fi + fi + if test -z "$ac_cv_texmf_tree"; then + # try some common paths + for i in /usr/share/texmf /usr/local/share/texmf; do + if test -d $$i; then + ac_cv_texmf_tree=$$i + break + fi + done + fi + +fi + + echo "$ac_t"""$ac_cv_texmf_tree"" 1>&6 + texmf="$ac_cv_texmf_tree" +else + ac_cv_texmf_tree="$texmf" +fi +if test -n "$texmf"; then + cat >> confdefs.h <<EOF +#define TEXMFTOP "$texmf" +EOF + + echo $ac_n "checking for texmf.cnf""... $ac_c" 1>&6 +echo "configure:4824: checking for texmf.cnf" >&5 + if test -x "$KPSEWHICH"; then + texmfcnf=`$KPSEWHICH --format=web2c texmf.cnf` + fi + if test -z "$texmfcnf"; then + texmfcnf="$texmf/web2c/texmf.cnf" + fi + if test -f $texmfcnf; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<EOF +#define TEXMF_IS_WEB2C 1 +EOF + + texmf_is_web2c=yes + else + echo "$ac_t""no" 1>&6 + texmf_is_web2c=no + fi +fi + + + + +if test "$ac_cv_func_getopt" = no; then + LIBOBJS="$LIBOBJS getopt.o" +fi +if test "$ac_cv_func_getopt_long" = no; then + LIBOBJS="$LIBOBJS getopt1.o" +fi + +if test -n "$LIBOBJS"; then + SUPPORTLIB='$(TOPDIR)/support/support.a' + SUPPORTHDR='-I$(TOPDIR)/support' +fi + + + +if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLSUB=intl +fi + + +if test "$enable_regex_specials" = yes; then + for ac_hdr in regex.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:4871: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4876 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:4881: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + for ac_func in regexec +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:4910: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4915 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:4938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + if test "$ac_cv_func_regexec" = no; then + echo "configure: warning: support for POSIX regular expressions disabled" 1>&2 + enable_regex_specials=no + else + cat >> confdefs.h <<\EOF +#define WITH_REGEX_SPECIALS 1 +EOF + + fi +fi + +if test "$texmf_is_web2c" = yes; then + # Extract the first word of "mktexlsr", so it can be a program name with args. +set dummy mktexlsr; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:4977: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MKTEXLSR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MKTEXLSR" in + /*) + ac_cv_path_MKTEXLSR="$MKTEXLSR" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_MKTEXLSR="$MKTEXLSR" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_MKTEXLSR="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MKTEXLSR" && ac_cv_path_MKTEXLSR=":" + ;; +esac +fi +MKTEXLSR="$ac_cv_path_MKTEXLSR" +if test -n "$MKTEXLSR"; then + echo "$ac_t""$MKTEXLSR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + MDVIMAPDIR="$texmf/mdvi" + POST_INSTALL='echo "Updating ls-R database..."; $(MKTEXLSR)' +else + echo "configure: warning: \ +kpathsea does not seem to be installed properly. +Continue at your own risk" 1>&2 + MDVIMAPDIR='${datadir}/mdvi' + POST_INSTALL=: +fi + + + + +# Check front ends +. $srcdir/config/FRONTENDS +echo $ac_n "checking which frontends to compile""... $ac_c" 1>&6 +echo "configure:5026: checking which frontends to compile" >&5 +case "$with_frontends" in + yes) user_frontends="$ALL_FRONTENDS" ;; + no) user_frontends= ;; + *) user_frontends=`echo $with_frontends | sed -e 's/,/ /g'` ;; +esac +FRONTENDS= +DISABLED= +for i in $user_frontends; do + if echo "$ALL_FRONTENDS" | grep $i >/dev/null 2>&1; then + # Don't add it more than once + FRONTENDS="`echo $FRONTENDS | sed -e 's/[ \t]*'$i'[ \t]*//'` $i" + else + DISABLED="$DISABLED + $i" + fi +done +user_frontends= +echo "$ac_t""$FRONTENDS" 1>&6 + + +if test -n "$DISABLED"; then + echo "configure: warning: \ +The following unknown frontends have been disabled: $DISABLED" 1>&2 +fi + +if test "$enable_cheap_trick" = yes; then + cat >> confdefs.h <<\EOF +#define CHEAP_X_TRICK 1 +EOF + +fi + +if test "$enable_afm_files" = yes; then + cat >> confdefs.h <<\EOF +#define WITH_AFM_FILES 1 +EOF + +fi + +if test "$with_omega" = yes; then + cat >> confdefs.h <<\EOF +#define WITH_OMEGA 1 +EOF + +fi + +if test "$with_truetype_fonts" = yes; then + + + +# Check whether --with-freetype-headers or --without-freetype-headers was given. +if test "${with_freetype_headers+set}" = set; then + withval="$with_freetype_headers" + case "$withval" in + yes) echo "configure: warning: no value specified for --with-freetype-headers ;; + no" 1>&2 freetype_headers= ;; + *) freetype_headers=$withval ;; + esac +fi + +# Check whether --with-freetype-library or --without-freetype-library was given. +if test "${with_freetype_library+set}" = set; then + withval="$with_freetype_library" + case "$withval" in + yes) echo "configure: warning: no value specified for --with-freetype-library ;; + no" 1>&2 freetype_library= ;; + *) freetype_library=$withval ;; + esac +fi + + + + + FREETYPE_CFLAGS= + FREETYPE_LDFLAGS= + have_freetype_headers=no + have_freetype_library=no +# Check for ttf headers + echo $ac_n "checking for ttf headers""... $ac_c" 1>&6 +echo "configure:5106: checking for ttf headers" >&5 + OCF=$CFLAGS; + TMPCFLAGS= + # If we were given PATH/lib, try PATH/include + if test -z "$freetype_headers"; then + test -n "$freetype_library" && freetype_headers=$freetype_library/../include + fi + test -n "$freetype_headers" && TMPCFLAGS="-I$freetype_headers" + CFLAGS="$OCF $TMPCFLAGS" + cat > conftest.$ac_ext <<EOF +#line 5116 "configure" +#include "confdefs.h" +#include <freetype.h> +int main() { +TT_Init_FreeType(0) +; return 0; } +EOF +if { (eval echo configure:5123: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + have_freetype_headers=yes; FREETYPE_CFLAGS=$TMPCFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + if test -n "$freetype_headers"; then + TMPCFLAGS="-I$freetype_headers/.." + CFLAGS="$OCF $TMPCFLAGS" + cat > conftest.$ac_ext <<EOF +#line 5134 "configure" +#include "confdefs.h" +#include <freetype.h> +int main() { +TT_Init_FreeType(0) +; return 0; } +EOF +if { (eval echo configure:5141: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + have_freetype_headers=yes; FREETYPE_CFLAGS=$TMPCFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + have_freetype_headers=no; FREETYPE_CFLAGS= +fi +rm -f conftest* + fi +fi +rm -f conftest* + echo "$ac_t""$have_freetype_headers" 1>&6 +# Check for the ttf library + echo $ac_n "checking for the ttf library""... $ac_c" 1>&6 +echo "configure:5157: checking for the ttf library" >&5 + OLD=$LDFLAGS; OLI=$LIBS + TMPLDFLAGS= + # If we were given PATH/include, try PATH/lib + if test -z "$freetype_library"; then + test -n "$freetype_headers" && freetype_library=$freetype_headers/../lib + fi + test -n "$freetype_library" && TMPLDFLAGS="-L$freetype_library" + LDFLAGS="$OLD $TMPLDFLAGS" + LIBS="$LIBS -lttf" + cat > conftest.$ac_ext <<EOF +#line 5168 "configure" +#include "confdefs.h" +#include <freetype.h> +int main() { +TT_Init_FreeType(0) +; return 0; } +EOF +if { (eval echo configure:5175: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + have_freetype_library=yes; FREETYPE_LDFLAGS=$TMPLDFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + have_freetype_library=no; FREETYPE_LDFLAGS= +fi +rm -f conftest* + echo "$ac_t""$have_freetype_library" 1>&6 + if test "$have_freetype_headers" = yes -a "$have_freetype_library" = yes; then + FREETYPE_LIBS="-lttf" + fi + + TMPCFLAGS= + TMPLDFLAGS= +# Restore things + CFLAGS=$OCF + LDFLAGS=$OLD + LIBS=$OLI + +fi + +if test "$with_truetype_fonts" = yes; then + case "${have_freetype_headers}-${have_freetype_library}" in + yes-yes) + FREETYPE_LIBS="$FRETYPE_LDFLAGS $FREETYPE_LIBS" + cat >> confdefs.h <<\EOF +#define WITH_TRUETYPE_FONTS 1 +EOF + + ;; + *) echo "configure: warning: TrueType font support disabled" 1>&2 + with_truetype_fonts=no + ;; + esac +fi + +if test "$with_type1_fonts" = yes; then + + + +# Check whether --with-t1lib-headers or --without-t1lib-headers was given. +if test "${with_t1lib_headers+set}" = set; then + withval="$with_t1lib_headers" + case "$withval" in + yes) echo "configure: warning: no value specified for --with-t1lib-headers ;; + no" 1>&2 t1lib_headers= ;; + *) t1lib_headers=$withval ;; + esac +fi + +# Check whether --with-t1lib-library or --without-t1lib-library was given. +if test "${with_t1lib_library+set}" = set; then + withval="$with_t1lib_library" + case "$withval" in + yes) echo "configure: warning: no value specified for --with-t1lib-library ;; + no" 1>&2 t1lib_library= ;; + *) t1lib_library=$withval ;; + esac +fi + + + + + T1LIB_CFLAGS= + T1LIB_LDFLAGS= + have_t1lib_headers=no + have_t1lib_library=no +# Check for t1 headers + echo $ac_n "checking for t1 headers""... $ac_c" 1>&6 +echo "configure:5247: checking for t1 headers" >&5 + OCF=$CFLAGS; + TMPCFLAGS= + # If we were given PATH/lib, try PATH/include + if test -z "$t1lib_headers"; then + test -n "$t1lib_library" && t1lib_headers=$t1lib_library/../include + fi + test -n "$t1lib_headers" && TMPCFLAGS="-I$t1lib_headers" + CFLAGS="$OCF $TMPCFLAGS" + cat > conftest.$ac_ext <<EOF +#line 5257 "configure" +#include "confdefs.h" +#include <t1lib.h> +int main() { +T1_InitLib(0) +; return 0; } +EOF +if { (eval echo configure:5264: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + have_t1lib_headers=yes; T1LIB_CFLAGS=$TMPCFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + if test -n "$t1lib_headers"; then + TMPCFLAGS="-I$t1lib_headers/.." + CFLAGS="$OCF $TMPCFLAGS" + cat > conftest.$ac_ext <<EOF +#line 5275 "configure" +#include "confdefs.h" +#include <t1lib.h> +int main() { +T1_InitLib(0) +; return 0; } +EOF +if { (eval echo configure:5282: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + have_t1lib_headers=yes; T1LIB_CFLAGS=$TMPCFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + have_t1lib_headers=no; T1LIB_CFLAGS= +fi +rm -f conftest* + fi +fi +rm -f conftest* + echo "$ac_t""$have_t1lib_headers" 1>&6 +# Check for the t1 library + echo $ac_n "checking for the t1 library""... $ac_c" 1>&6 +echo "configure:5298: checking for the t1 library" >&5 + OLD=$LDFLAGS; OLI=$LIBS + TMPLDFLAGS= + # If we were given PATH/include, try PATH/lib + if test -z "$t1lib_library"; then + test -n "$t1lib_headers" && t1lib_library=$t1lib_headers/../lib + fi + test -n "$t1lib_library" && TMPLDFLAGS="-L$t1lib_library" + LDFLAGS="$OLD $TMPLDFLAGS" + LIBS="$LIBS -lt1" + cat > conftest.$ac_ext <<EOF +#line 5309 "configure" +#include "confdefs.h" +#include <t1lib.h> +int main() { +T1_InitLib(0) +; return 0; } +EOF +if { (eval echo configure:5316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + have_t1lib_library=yes; T1LIB_LDFLAGS=$TMPLDFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + have_t1lib_library=no; T1LIB_LDFLAGS= +fi +rm -f conftest* + echo "$ac_t""$have_t1lib_library" 1>&6 + if test "$have_t1lib_headers" = yes -a "$have_t1lib_library" = yes; then + T1LIB_LIBS="-lt1" + fi + + TMPCFLAGS= + TMPLDFLAGS= +# Restore things + CFLAGS=$OCF + LDFLAGS=$OLD + LIBS=$OLI + + case "${have_t1lib_headers}-${have_t1lib_library}" in + yes-yes) + echo $ac_n "checking if we can compile a trivial t1lib program""... $ac_c" 1>&6 +echo "configure:5341: checking if we can compile a trivial t1lib program" >&5 + + +ac_mdvi_CFLAGS="$CFLAGS" +ac_mdvi_LDFLAGS="$LDFLAGS" +ac_mdvi_LIBS="$LIBS" + +CFLAGS="$CFLAGS $T1LIB_CFLAGS" +LDFLAGS="$LDFLAGS $T1LIB_LDFLAGS" +LIBS="-lt1 $LIBS" + + if test "$cross_compiling" = yes; then + t1version=unknown +else + cat > conftest.$ac_ext <<EOF +#line 5356 "configure" +#include "confdefs.h" +#include <stdio.h> + #include <t1lib.h> + int main() { + FILE *f; + f = fopen("conftestval", "w"); + if(!f) exit(1); + fprintf(f, "%s\n", T1_GetLibIdent()); + fclose(f); + exit(0); + } +EOF +if { (eval echo configure:5369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + t1version=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + t1version= +fi +rm -fr conftest* +fi + + +CFLAGS="$ac_mdvi_CFLAGS" +LDFLAGS="$ac_mdvi_LDFLAGS" +LIBS="$ac_mdvi_LIBS" + + if test -z "$t1version"; then + echo "$ac_t""no" 1>&6 + else + echo "$ac_t""yes" 1>&6 + fi + if test -z "$t1version"; then + echo "configure: warning: Type1 font support disabled" 1>&2 + with_type1_fonts=no + else + cat >> confdefs.h <<\EOF +#define WITH_TYPE1_FONTS 1 +EOF + + cat >> confdefs.h <<EOF +#define T1LIB_VERSION "$t1version" +EOF + + fi + ;; + *) echo "configure: warning: Type1 font support disabled" 1>&2 + with_type1_fonts=no + ;; + esac +fi + + + + +# Check whether --with-kpathsea-headers or --without-kpathsea-headers was given. +if test "${with_kpathsea_headers+set}" = set; then + withval="$with_kpathsea_headers" + case "$withval" in + yes) echo "configure: warning: no value specified for --with-kpathsea-headers ;; + no" 1>&2 kpathsea_headers= ;; + *) kpathsea_headers=$withval ;; + esac +fi + +# Check whether --with-kpathsea-library or --without-kpathsea-library was given. +if test "${with_kpathsea_library+set}" = set; then + withval="$with_kpathsea_library" + case "$withval" in + yes) echo "configure: warning: no value specified for --with-kpathsea-library ;; + no" 1>&2 kpathsea_library= ;; + *) kpathsea_library=$withval ;; + esac +fi + + + + + KPATHSEA_CFLAGS= + KPATHSEA_LDFLAGS= + have_kpathsea_headers=no + have_kpathsea_library=no +# Check for kpathsea headers + echo $ac_n "checking for kpathsea headers""... $ac_c" 1>&6 +echo "configure:5443: checking for kpathsea headers" >&5 + OCF=$CFLAGS; + TMPCFLAGS= + # If we were given PATH/lib, try PATH/include + if test -z "$kpathsea_headers"; then + test -n "$kpathsea_library" && kpathsea_headers=$kpathsea_library/../include + fi + test -n "$kpathsea_headers" && TMPCFLAGS="-I$kpathsea_headers" + CFLAGS="$OCF $TMPCFLAGS" + cat > conftest.$ac_ext <<EOF +#line 5453 "configure" +#include "confdefs.h" +#include <stdio.h> + #include <kpathsea/progname.h> +int main() { +kpse_set_program_name("conftest", "conftest") +; return 0; } +EOF +if { (eval echo configure:5461: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + have_kpathsea_headers=yes; KPATHSEA_CFLAGS=$TMPCFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + if test -n "$kpathsea_headers"; then + TMPCFLAGS="-I$kpathsea_headers/.." + CFLAGS="$OCF $TMPCFLAGS" + cat > conftest.$ac_ext <<EOF +#line 5472 "configure" +#include "confdefs.h" +#include <stdio.h> + #include <kpathsea/progname.h> +int main() { +kpse_set_program_name("conftest", "conftest") +; return 0; } +EOF +if { (eval echo configure:5480: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + have_kpathsea_headers=yes; KPATHSEA_CFLAGS=$TMPCFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + have_kpathsea_headers=no; KPATHSEA_CFLAGS= +fi +rm -f conftest* + fi +fi +rm -f conftest* + echo "$ac_t""$have_kpathsea_headers" 1>&6 +# Check for the kpathsea library + echo $ac_n "checking for the kpathsea library""... $ac_c" 1>&6 +echo "configure:5496: checking for the kpathsea library" >&5 + OLD=$LDFLAGS; OLI=$LIBS + TMPLDFLAGS= + # If we were given PATH/include, try PATH/lib + if test -z "$kpathsea_library"; then + test -n "$kpathsea_headers" && kpathsea_library=$kpathsea_headers/../lib + fi + test -n "$kpathsea_library" && TMPLDFLAGS="-L$kpathsea_library" + LDFLAGS="$OLD $TMPLDFLAGS" + LIBS="$LIBS -lkpathsea" + cat > conftest.$ac_ext <<EOF +#line 5507 "configure" +#include "confdefs.h" +#include <stdio.h> + #include <kpathsea/progname.h> +int main() { +kpse_set_program_name("conftest", "conftest") +; return 0; } +EOF +if { (eval echo configure:5515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + have_kpathsea_library=yes; KPATHSEA_LDFLAGS=$TMPLDFLAGS +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + have_kpathsea_library=no; KPATHSEA_LDFLAGS= +fi +rm -f conftest* + echo "$ac_t""$have_kpathsea_library" 1>&6 + if test "$have_kpathsea_headers" = yes -a "$have_kpathsea_library" = yes; then + KPATHSEA_LIBS="-lkpathsea" + fi + + TMPCFLAGS= + TMPLDFLAGS= +# Restore things + CFLAGS=$OCF + LDFLAGS=$OLD + LIBS=$OLI + + +if test "$have_kpathsea_headers" = no -o "$have_kpathsea_library" = no; then + { echo "configure: error: I could not find the kpathsea library on this system. +This library is required to build this package. Please install it and use +the --with-kpathsea-headers and --with-kpathsea-library options to tell +configure the location of its header files and the library itself." 1>&2; exit 1; } + exit 1 +fi + +echo $ac_n "checking if we can compile a trivial kpathsea program""... $ac_c" 1>&6 +echo "configure:5547: checking if we can compile a trivial kpathsea program" >&5 + + +ac_mdvi_CFLAGS="$CFLAGS" +ac_mdvi_LDFLAGS="$LDFLAGS" +ac_mdvi_LIBS="$LIBS" + +CFLAGS="$CFLAGS $KPATHSEA_CFLAGS" +LDFLAGS="$LDFLAGS $KPATHSEA_LDFLAGS" +LIBS="-lkpathsea $LIBS" + +if test "$cross_compiling" = yes; then + kpseversion=unknown +else + cat > conftest.$ac_ext <<EOF +#line 5562 "configure" +#include "confdefs.h" +#include <stdio.h> + #include <kpathsea/c-auto.h> + extern char *kpathsea_version_string; + int main() { + FILE *f; + f = fopen("conftestval", "w"); + if(!f) exit(1); + fprintf(f, "%s\n", kpathsea_version_string); + fclose(f); + exit(0); + } +EOF +if { (eval echo configure:5576: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + kpseversion=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + kpseversion= +fi +rm -fr conftest* +fi + + +CFLAGS="$ac_mdvi_CFLAGS" +LDFLAGS="$ac_mdvi_LDFLAGS" +LIBS="$ac_mdvi_LIBS" + +if test -z "$kpseversion"; then + echo "$ac_t""no" 1>&6 +else + echo "$ac_t""yes" 1>&6 +fi +if test -z "$kpseversion"; then + { echo "configure: error: Could not compile a simple kpathsea program -- check your installation" 1>&2; exit 1; } +fi +cat >> confdefs.h <<EOF +#define KPSE_VERSION "$kpseversion" +EOF + + +if test "$no_x" = yes; then + X11LIB= +else + X11LIB=-lX11 +fi + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile \ + lib/Makefile \ + lib/po/Makefile \ + support/Makefile \ + x11/Makefile \ + version.h \ + config.mk:config/config.mk.in \ + nls.mk:config/nls.mk.in \ + intl/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@PACKAGE@%$PACKAGE%g +s%@MAJOR@%$MAJOR%g +s%@MINOR@%$MINOR%g +s%@PATCH@%$PATCH%g +s%@VERSION@%$VERSION%g +s%@TOPDIR@%$TOPDIR%g +s%@TOPSRCDIR@%$TOPSRCDIR%g +s%@CC@%$CC%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@SET_MAKE@%$SET_MAKE%g +s%@MD5SUM@%$MD5SUM%g +s%@RANLIB@%$RANLIB%g +s%@CPP@%$CPP%g +s%@ALLOCA@%$ALLOCA%g +s%@USE_NLS@%$USE_NLS%g +s%@MSGFMT@%$MSGFMT%g +s%@GMSGFMT@%$GMSGFMT%g +s%@XGETTEXT@%$XGETTEXT%g +s%@GENCAT@%$GENCAT%g +s%@USE_INCLUDED_LIBINTL@%$USE_INCLUDED_LIBINTL%g +s%@CATALOGS@%$CATALOGS%g +s%@CATOBJEXT@%$CATOBJEXT%g +s%@DATADIRNAME@%$DATADIRNAME%g +s%@GMOFILES@%$GMOFILES%g +s%@INSTOBJEXT@%$INSTOBJEXT%g +s%@INTLDEPS@%$INTLDEPS%g +s%@INTLLIBS@%$INTLLIBS%g +s%@INTLOBJS@%$INTLOBJS%g +s%@POFILES@%$POFILES%g +s%@POSUB@%$POSUB%g +s%@INCLUDE_LOCALE_H@%$INCLUDE_LOCALE_H%g +s%@GT_NO@%$GT_NO%g +s%@GT_YES@%$GT_YES%g +s%@MKINSTALLDIRS@%$MKINSTALLDIRS%g +s%@l@%$l%g +s%@X_CFLAGS@%$X_CFLAGS%g +s%@X_PRE_LIBS@%$X_PRE_LIBS%g +s%@X_LIBS@%$X_LIBS%g +s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g +s%@LIBOBJS@%$LIBOBJS%g +s%@KPSEWHICH@%$KPSEWHICH%g +s%@texmf@%$texmf%g +s%@SUPPORTLIB@%$SUPPORTLIB%g +s%@SUPPORTHDR@%$SUPPORTHDR%g +s%@INTLSUB@%$INTLSUB%g +s%@MKTEXLSR@%$MKTEXLSR%g +s%@MDVIMAPDIR@%$MDVIMAPDIR%g +s%@POST_INSTALL@%$POST_INSTALL%g +s%@ALL_FRONTENDS@%$ALL_FRONTENDS%g +s%@FRONTENDS@%$FRONTENDS%g +s%@FREETYPE_CFLAGS@%$FREETYPE_CFLAGS%g +s%@FREETYPE_LDFLAGS@%$FREETYPE_LDFLAGS%g +s%@FREETYPE_LIBS@%$FREETYPE_LIBS%g +s%@T1LIB_CFLAGS@%$T1LIB_CFLAGS%g +s%@T1LIB_LDFLAGS@%$T1LIB_LDFLAGS%g +s%@T1LIB_LIBS@%$T1LIB_LIBS%g +s%@KPATHSEA_CFLAGS@%$KPATHSEA_CFLAGS%g +s%@KPATHSEA_LDFLAGS@%$KPATHSEA_LDFLAGS%g +s%@KPATHSEA_LIBS@%$KPATHSEA_LIBS%g +s%@X11LIB@%$X11LIB%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"Makefile \ + lib/Makefile \ + lib/po/Makefile \ + support/Makefile \ + x11/Makefile \ + version.h \ + config.mk:config/config.mk.in \ + nls.mk:config/nls.mk.in \ + intl/Makefile"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <<EOF + CONFIG_HEADERS="config.h" +EOF +cat >> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF + +cat >> $CONFIG_STATUS <<EOF +ac_sources="$nls_cv_header_libgt" +ac_dests="$nls_cv_header_intl" +EOF + +cat >> $CONFIG_STATUS <<\EOF +srcdir=$ac_given_srcdir +while test -n "$ac_sources"; do + set $ac_dests; ac_dest=$1; shift; ac_dests=$* + set $ac_sources; ac_source=$1; shift; ac_sources=$* + + echo "linking $srcdir/$ac_source to $ac_dest" + + if test ! -r $srcdir/$ac_source; then + { echo "configure: error: $srcdir/$ac_source: File not found" 1>&2; exit 1; } + fi + rm -f $ac_dest + + # Make relative symlinks. + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dest_dir=`echo $ac_dest|sed 's%/[^/][^/]*$%%'` + if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then + # The dest file is in a subdirectory. + test ! -d "$ac_dest_dir" && mkdir "$ac_dest_dir" + ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dest_dir_suffix. + ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dest_dir_suffix= ac_dots= + fi + + case "$srcdir" in + [/$]*) ac_rel_source="$srcdir/$ac_source" ;; + *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;; + esac + + # Make a symlink if possible; otherwise try a hard link. + if ln -s $ac_rel_source $ac_dest 2>/dev/null || + ln $srcdir/$ac_source $ac_dest; then : + else + { echo "configure: error: can not link $ac_dest to $srcdir/$ac_source" 1>&2; exit 1; } + fi +done +EOF +cat >> $CONFIG_STATUS <<EOF + +EOF +cat >> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + + +if test -z "$FRONTENDS"; then + FRONTENDS="NONE!" +fi + +cat <<EOF + +Selected options: + + Support for Type1 fonts : $with_type1_fonts + Support for TrueType fonts : $with_truetype_fonts + Support for Omega-specific formats : $with_omega + Support for AFM files : $enable_afm_files + Support for internationalization : $USE_NLS + Apply regular expressions to specials: $enable_regex_specials + + Frontends that will be compiled: + $FRONTENDS + Installation directories (prefix is \`$prefix'): + Programs : $bindir + Fontmaps and encodings : $MDVIMAPDIR + +To change these parameters, edit the files \`config.h' and \`config.mk' +You may also want to edit \`include/defaults.h' and the Makefiles. +Otherwise, just type \`make'. + +EOF diff --git a/dviware/mdvi/configure.in b/dviware/mdvi/configure.in new file mode 100644 index 0000000000..9d6d5a4b8f --- /dev/null +++ b/dviware/mdvi/configure.in @@ -0,0 +1,350 @@ +dnl +dnl Copyright (C) 2000, Matias Atria +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl + +AC_INIT(./config/VERSION) +AC_CONFIG_AUX_DIR(./config) +AC_CONFIG_HEADER(config.h) + +. $srcdir/config/VERSION +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", + [Name of this package (don't change)]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", + [Version of this package (don't change)]) +AC_SUBST(PACKAGE) +AC_SUBST(MAJOR) +AC_SUBST(MINOR) +AC_SUBST(PATCH) +AC_SUBST(VERSION) + +TOPDIR=`pwd` +TOPSRCDIR=`cd $srcdir && pwd` +AC_SUBST(TOPDIR) +AC_SUBST(TOPSRCDIR) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PATH_PROG(MD5SUM, md5sum, :) +AC_SUBST(MD5SUM) + +ALL_LINGUAS="es" + +AM_GNU_GETTEXT + +dnl Checks for libraries. +AC_CHECK_LIB(m, floor) + +dnl Checks for header files. +AC_PATH_XTRA +AC_HEADER_STDC +AC_CHECK_HEADERS(strings.h fcntl.h unistd.h locale.h) +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIZE_T +AC_CHECK_SIZEOF(long, 4) +AC_CHECK_SIZEOF(int, 4) +AC_CHECK_SIZEOF(short, 2) +AC_CHECK_SIZEOF(void *, 4) +AC_CHECK_BYTE_ORDER + +dnl Checks for library functions. +AC_FUNC_MEMCMP +AC_FUNC_VPRINTF +AC_CHECK_FUNCS(strchr memcpy getopt getopt_long) + +AC_ARG_ENABLE_BOOL(regex-specials, yes, + [disable regular expressions in \\special handlers]) +AC_ARG_WITH_BOOL(omega, yes, + [disable Omega-specific file formats]) +AC_ARG_WITH_BOOL(type1-fonts, no, + [add support for type1 fonts (requires t1lib)]) +AC_ARG_WITH_BOOL(truetype-fonts, no, + [add support for TrueType fonts (required Freetype 1.x)]) +AC_ARG_ENABLE_BOOL(cheap-trick, yes, + [disable cheap X transparency trick]) +AC_ARG_ENABLE_BOOL(afm-files, yes, + [disable support for AFM metric files]) +AC_ARG_WITHX(frontends, + [frontends to compile (only \`x11' for now)], , , [=LIST]) +AC_CHECK_TEXMF + +dnl################################################################# +dnl Now examine the --with and --enable options +dnl################################################################# + +if test "$ac_cv_func_getopt" = no; then + LIBOBJS="$LIBOBJS getopt.o" +fi +if test "$ac_cv_func_getopt_long" = no; then + LIBOBJS="$LIBOBJS getopt1.o" +fi + +if test -n "$LIBOBJS"; then + SUPPORTLIB='$(TOPDIR)/support/support.a' + SUPPORTHDR='-I$(TOPDIR)/support' +fi +AC_SUBST(SUPPORTLIB) +AC_SUBST(SUPPORTHDR) + +if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLSUB=intl +fi +AC_SUBST(INTLSUB) + +if test "$enable_regex_specials" = yes; then + AC_CHECK_HEADERS(regex.h) + AC_CHECK_FUNCS(regexec) + if test "$ac_cv_func_regexec" = no; then + AC_MSG_WARN([support for POSIX regular expressions disabled]) + enable_regex_specials=no + else + AC_DEFINE(WITH_REGEX_SPECIALS, 1, + [Define to use POSIX regular expressions to match TeX \\specials]) + fi +fi + +if test "$texmf_is_web2c" = yes; then + AC_PATH_PROG(MKTEXLSR, mktexlsr, :) + MDVIMAPDIR="$texmf/mdvi" + POST_INSTALL='echo "Updating ls-R database..."; $(MKTEXLSR)' +else + AC_MSG_WARN([\ +kpathsea does not seem to be installed properly. +Continue at your own risk]) + MDVIMAPDIR='${datadir}/mdvi' + POST_INSTALL=: +fi +AC_SUBST(MDVIMAPDIR) +AC_SUBST(MKTEXLSR) +AC_SUBST(POST_INSTALL) + +# Check front ends +. $srcdir/config/FRONTENDS +AC_MSG_CHECKING([which frontends to compile]) +case "$with_frontends" in + yes) user_frontends="$ALL_FRONTENDS" ;; + no) user_frontends= ;; + *) user_frontends=`echo $with_frontends | sed -e 's/,/ /g'` ;; +esac +FRONTENDS= +DISABLED= +for i in $user_frontends; do + if echo "$ALL_FRONTENDS" | grep $i >/dev/null 2>&1; then + # Don't add it more than once + FRONTENDS="`echo $FRONTENDS | sed -e 's/[[ \t]]*'$i'[[ \t]]*//'` $i" + else + DISABLED="$DISABLED + $i" + fi +done +user_frontends= +AC_MSG_RESULT($FRONTENDS) +AC_SUBST(ALL_FRONTENDS) +AC_SUBST(FRONTENDS) +if test -n "$DISABLED"; then + AC_MSG_WARN([\ +The following unknown frontends have been disabled: $DISABLED]) +fi + +if test "$enable_cheap_trick" = yes; then + AC_DEFINE(CHEAP_X_TRICK, 1, + [Define to simulate transparent glyphs on white backgrounds]) +fi + +if test "$enable_afm_files" = yes; then + AC_DEFINE(WITH_AFM_FILES, 1, + [Define to add support for AFM files]) +fi + +if test "$with_omega" = yes; then + AC_DEFINE(WITH_OMEGA, 1, + [Define to add support for Omega-specific file formats]) +fi + +if test "$with_truetype_fonts" = yes; then + AC_CHECK_LIBOPTIONS(FreeType, ttf, + [#include <freetype.h>], [TT_Init_FreeType(0)]) +dnl This code is for freetype 2.x +dnl +dnl We only use the freetype-config script if the user did not specify +dnl the location of the headers or the library itself. +dnl if test -z "$with_freetype_headers" -a -z "$with_freetype_library"; then +dnl if test "$cross_compiling" = yes; then +dnl AC_MSG_WARN([\ +dnl You must use --with-freetype-headers and --with-freetype-library +dnl when cross-compiling. I will pretend that you said --without-freetype]) +dnl have_freetype_library=no +dnl FREETYPE_LDFLAGS="$FREETYPE_LDFLAGS $FREETYPE_LIBS" +dnl FREETYPE_LIBS= +dnl else +dnl AC_PATH_PROG(FREETYPE, freetype-config, no) +dnl if test "$ac_cv_prog_freetype_config" = no; then +dnl have_freetype_library=no +dnl FREETYPE_CFLAGS= +dnl FREETYEP_LDFLAGS= +dnl else +dnl FREETYPE_CFLAGS=`$FREETYPE --cflags` +dnl FREETYPE_LDFLAGS=`$FREETYPE --libs` +dnl AC_MSG_CHECKING([if the FreeType configuration works]) +dnl AC_CHANGE_FLAGS([$FREETYPE_CFLAGS], [$FREETYPE_LDFLAGS]) +dnl AC_TRY_COMPILE([#include <freetype/freetype.h>], +dnl [FT_Init_FreeType(0)], +dnl [have_freetype_headers=yes; have_freetype_library=yes], +dnl [have_freetype_library=no]) +dnl AC_RESTORE_FLAGS +dnl AC_MSG_RESULT($have_freetype_library) +dnl fi +dnl fi +dnl fi +fi + +if test "$with_truetype_fonts" = yes; then + case "${have_freetype_headers}-${have_freetype_library}" in + yes-yes) + FREETYPE_LIBS="$FRETYPE_LDFLAGS $FREETYPE_LIBS" + AC_DEFINE(WITH_TRUETYPE_FONTS, 1, + [Define to add support for TrueType fonts]) + ;; + *) AC_MSG_WARN([TrueType font support disabled]) + with_truetype_fonts=no + ;; + esac +fi + +if test "$with_type1_fonts" = yes; then + AC_CHECK_LIBOPTIONS(t1lib, t1, [#include <t1lib.h>], [T1_InitLib(0)]) + case "${have_t1lib_headers}-${have_t1lib_library}" in + yes-yes) + AC_MSG_CHECKING([if we can compile a trivial t1lib program]) + AC_CHANGE_FLAGS([$T1LIB_CFLAGS], [$T1LIB_LDFLAGS], [-lt1]) + AC_TRY_RUN([#include <stdio.h> + #include <t1lib.h> + int main() { + FILE *f; + f = fopen("conftestval", "w"); + if(!f) exit(1); + fprintf(f, "%s\n", T1_GetLibIdent()); + fclose(f); + exit(0); + }], t1version=`cat conftestval`, t1version=, t1version=unknown) + AC_RESTORE_FLAGS + if test -z "$t1version"; then + AC_MSG_RESULT(no) + else + AC_MSG_RESULT(yes) + fi + if test -z "$t1version"; then + AC_MSG_WARN([Type1 font support disabled]) + with_type1_fonts=no + else + AC_DEFINE(WITH_TYPE1_FONTS, 1, + [Define to add support for Type1 fonts]) + AC_DEFINE_UNQUOTED(T1LIB_VERSION, "$t1version", + [Version of T1lib used to build MDVI]) + fi + ;; + [*]) AC_MSG_WARN([Type1 font support disabled]) + with_type1_fonts=no + ;; + esac +fi + +AC_CHECK_LIBOPTIONS(kpathsea, kpathsea, + [#include <stdio.h> + #include <kpathsea/progname.h>], + [kpse_set_program_name("conftest", "conftest")]) + +if test "$have_kpathsea_headers" = no -o "$have_kpathsea_library" = no; then + AC_MSG_ERROR([I could not find the kpathsea library on this system. +This library is required to build this package. Please install it and use +the --with-kpathsea-headers and --with-kpathsea-library options to tell +configure the location of its header files and the library itself.]) + exit 1 +fi + +AC_MSG_CHECKING([if we can compile a trivial kpathsea program]) +AC_CHANGE_FLAGS([$KPATHSEA_CFLAGS], [$KPATHSEA_LDFLAGS], [-lkpathsea]) +AC_TRY_RUN([#include <stdio.h> + #include <kpathsea/c-auto.h> + extern char *kpathsea_version_string; + int main() { + FILE *f; + f = fopen("conftestval", "w"); + if(!f) exit(1); + fprintf(f, "%s\n", kpathsea_version_string); + fclose(f); + exit(0); + }], kpseversion=`cat conftestval`, kpseversion=, kpseversion=unknown) +AC_RESTORE_FLAGS +if test -z "$kpseversion"; then + AC_MSG_RESULT(no) +else + AC_MSG_RESULT(yes) +fi +if test -z "$kpseversion"; then + AC_MSG_ERROR([Could not compile a simple kpathsea program -- check your installation]) +fi +AC_DEFINE_UNQUOTED(KPSE_VERSION, "$kpseversion", + [Version of kpathsea used to build MDVI]) + +dnl if X is disabled, let the makefile know +if test "$no_x" = yes; then + X11LIB= +else + X11LIB=-lX11 +fi +AC_SUBST(X11LIB) + +AC_OUTPUT(Makefile \ + lib/Makefile \ + lib/po/Makefile \ + support/Makefile \ + x11/Makefile \ + version.h \ + config.mk:config/config.mk.in \ + nls.mk:config/nls.mk.in \ + intl/Makefile) + +if test -z "$FRONTENDS"; then + FRONTENDS="NONE!" +fi + +cat <<EOF + +Selected options: + + Support for Type1 fonts : $with_type1_fonts + Support for TrueType fonts : $with_truetype_fonts + Support for Omega-specific formats : $with_omega + Support for AFM files : $enable_afm_files + Support for internationalization : $USE_NLS + Apply regular expressions to specials: $enable_regex_specials + + Frontends that will be compiled: + $FRONTENDS + Installation directories (prefix is \`$prefix'): + Programs : $bindir + Fontmaps and encodings : $MDVIMAPDIR + +To change these parameters, edit the files \`config.h' and \`config.mk' +You may also want to edit \`include/defaults.h' and the Makefiles. +Otherwise, just type \`make'. + +EOF diff --git a/dviware/mdvi/data/8a.enc b/dviware/mdvi/data/8a.enc new file mode 100644 index 0000000000..b1b118c5ec --- /dev/null +++ b/dviware/mdvi/data/8a.enc @@ -0,0 +1,269 @@ +% @@psencodingfile@{ +% author = "Adobe", +% version = "1.0", +% date = "22 June 1996", +% filename = "8a.enc", +% email = "kb@@mail.tug.org", +% address = "135 Center Hill Rd. // Plymouth, MA 02360", +% codetable = "ISO/ASCII", +% checksum = "269 317 2399", +% docstring = "Adobe StandardEncoding as an afm2tfm/dvips .enc file." +% @} +/StandardEncoding [ +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/space +/exclam +/quotedbl +/numbersign +/dollar +/percent +/ampersand +/quoteright +/parenleft +/parenright +/asterisk +/plus +/comma +/hyphen +/period +/slash +/zero +/one +/two +/three +/four +/five +/six +/seven +/eight +/nine +/colon +/semicolon +/less +/equal +/greater +/question +/at +/A +/B +/C +/D +/E +/F +/G +/H +/I +/J +/K +/L +/M +/N +/O +/P +/Q +/R +/S +/T +/U +/V +/W +/X +/Y +/Z +/bracketleft +/backslash +/bracketright +/asciicircum +/underscore +/quoteleft +/a +/b +/c +/d +/e +/f +/g +/h +/i +/j +/k +/l +/m +/n +/o +/p +/q +/r +/s +/t +/u +/v +/w +/x +/y +/z +/braceleft +/bar +/braceright +/asciitilde +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/exclamdown +/cent +/sterling +/fraction +/yen +/florin +/section +/currency +/quotesingle +/quotedblleft +/guillemotleft +/guilsinglleft +/guilsinglright +/fi +/fl +/.notdef +/endash +/dagger +/daggerdbl +/periodcentered +/.notdef +/paragraph +/bullet +/quotesinglbase +/quotedblbase +/quotedblright +/guillemotright +/ellipsis +/perthousand +/.notdef +/questiondown +/.notdef +/grave +/acute +/circumflex +/tilde +/macron +/breve +/dotaccent +/dieresis +/.notdef +/ring +/cedilla +/.notdef +/hungarumlaut +/ogonek +/caron +/emdash +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/AE +/.notdef +/ordfeminine +/.notdef +/.notdef +/.notdef +/.notdef +/Lslash +/Oslash +/OE +/ordmasculine +/.notdef +/.notdef +/.notdef +/.notdef +/.notdef +/ae +/.notdef +/.notdef +/.notdef +/dotlessi +/.notdef +/.notdef +/lslash +/oslash +/oe +/germandbls +/.notdef +/.notdef +/.notdef +/.notdef +] def diff --git a/dviware/mdvi/data/8r.enc b/dviware/mdvi/data/8r.enc new file mode 100644 index 0000000000..4b400156c0 --- /dev/null +++ b/dviware/mdvi/data/8r.enc @@ -0,0 +1,119 @@ +% @@psencodingfile@{ +% author = "S. Rahtz, P. MacKay, Alan Jeffrey, B. Horn, K. Berry", +% version = "0.6", +% date = "22 June 1996", +% filename = "8r.enc", +% email = "kb@@mail.tug.org", +% address = "135 Center Hill Rd. // Plymouth, MA 02360", +% codetable = "ISO/ASCII", +% checksum = "119 662 4424", +% docstring = "Encoding for TrueType or Type 1 fonts to be used with TeX." +% @} +% +% Idea is to have all the characters normally included in Type 1 fonts +% available for typesetting. This is effectively the characters in Adobe +% Standard Encoding + ISO Latin 1 + extra characters from Lucida. +% +% Character code assignments were made as follows: +% +% (1) the Windows ANSI characters are almost all in their Windows ANSI +% positions, because some Windows users cannot easily reencode the +% fonts, and it makes no difference on other systems. The only Windows +% ANSI characters not available are those that make no sense for +% typesetting -- rubout (127 decimal), nobreakspace (160), softhyphen +% (173). quotesingle and grave are moved just because it's such an +% irritation not having them in TeX positions. +% +% (2) Remaining characters are assigned arbitrarily to the lower part +% of the range, avoiding 0, 10 and 13 in case we meet dumb software. +% +% (3) Y&Y Lucida Bright includes some extra text characters; in the +% hopes that other PostScript fonts, perhaps created for public +% consumption, will include them, they are included starting at 0x12. +% +% (4) Remaining positions left undefined are for use in (hopefully) +% upward-compatible revisions, if someday more characters are generally +% available. +% +% (5) hyphen appears twice for compatibility with both ASCII and Windows. +% +/TeXBase1Encoding [ +% 0x00 (encoded characters from Adobe Standard not in Windows 3.1) + /.notdef /dotaccent /fi /fl + /fraction /hungarumlaut /Lslash /lslash + /ogonek /ring /.notdef + /breve /minus /.notdef +% These are the only two remaining unencoded characters, so may as +% well include them. + /Zcaron /zcaron +% 0x10 + /caron /dotlessi +% (unusual TeX characters available in, e.g., Lucida Bright) + /dotlessj /ff /ffi /ffl + /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef + % very contentious; it's so painful not having quoteleft and quoteright + % at 96 and 145 that we move the things normally found there down to here. + /grave /quotesingle +% 0x20 (ASCII begins) + /space /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quoteright + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% 0x30 + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question +% 0x40 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O +% 0x50 + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% 0x60 + /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o +% 0x70 + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /asciitilde + /.notdef % rubout; ASCII ends +% 0x80 + /.notdef /.notdef /quotesinglbase /florin + /quotedblbase /ellipsis /dagger /daggerdbl + /circumflex /perthousand /Scaron /guilsinglleft + /OE /.notdef /.notdef /.notdef +% 0x90 + /.notdef /.notdef /.notdef /quotedblleft + /quotedblright /bullet /endash /emdash + /tilde /trademark /scaron /guilsinglright + /oe /.notdef /.notdef /Ydieresis +% 0xA0 + /.notdef % nobreakspace + /exclamdown /cent /sterling + /currency /yen /brokenbar /section + /dieresis /copyright /ordfeminine /guillemotleft + /logicalnot + /hyphen % Y&Y (also at 45); Windows' softhyphen + /registered + /macron +% 0xD0 + /degree /plusminus /twosuperior /threesuperior + /acute /mu /paragraph /periodcentered + /cedilla /onesuperior /ordmasculine /guillemotright + /onequarter /onehalf /threequarters /questiondown +% 0xC0 + /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /Iacute /Icircumflex /Idieresis +% 0xD0 + /Eth /Ntilde /Ograve /Oacute + /Ocircumflex /Otilde /Odieresis /multiply + /Oslash /Ugrave /Uacute /Ucircumflex + /Udieresis /Yacute /Thorn /germandbls +% 0xE0 + /agrave /aacute /acircumflex /atilde + /adieresis /aring /ae /ccedilla + /egrave /eacute /ecircumflex /edieresis + /igrave /iacute /icircumflex /idieresis +% 0xF0 + /eth /ntilde /ograve /oacute + /ocircumflex /otilde /odieresis /divide + /oslash /ugrave /uacute /ucircumflex + /udieresis /yacute /thorn /ydieresis +] def diff --git a/dviware/mdvi/data/EC.enc b/dviware/mdvi/data/EC.enc new file mode 100644 index 0000000000..f092a34a2f --- /dev/null +++ b/dviware/mdvi/data/EC.enc @@ -0,0 +1,82 @@ +% +% This is the EC encoding. +% +% These are the ligs and kerns in addition to those found in the +% AFM file. (The only ligs in the Times-Roman.afm file are the +% fi and fl ligatures.) +% +% LIGKERN space l =: lslash ; space L =: Lslash ; +% LIGKERN question quoteleft =: questiondown ; exclam quoteleft =: exclamdown ; +% LIGKERN hyphen hyphen =: endash ; endash hyphen =: emdash ; +% LIGKERN quoteleft quoteleft =: quotedblleft ; +% LIGKERN quoteright quoteright =: quotedblright ; +% +% We blow away kerns to and from spaces (TeX doesn't have a +% space) and also remove any kerns from the numbers (although +% the only kern pair that mentions a number in Times-Roman.afm +% is one one.) +% +% LIGKERN space {} * ; * {} space ; zero {} * ; * {} zero ; +% LIGKERN one {} * ; * {} one ; two {} * ; * {} two ; +% LIGKERN three {} * ; * {} three ; four {} * ; * {} four ; +% LIGKERN five {} * ; * {} five ; six {} * ; * {} six ; +% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ; +% LIGKERN nine {} * ; * {} nine ; +% LIGKERN comma comma =: quotedblbase ; less less =: guillemotleft ; +% LIGKERN greater greater =: guillemotright ; +% +/ECEncoding [ % now 256 chars follow +% 0x00 + /grave /acute /circumflex /tilde /dieresis /hungarumlaut /ring /caron + /breve /macron /dotaccent /cedilla + /ogonek /quotesinglbase /guilsinglleft /guilsinglright +% 0x10 + /quotedblleft /quotedblright /quotedblbase /guillemotleft + /guillemotright /endash /emdash /cwm + /zeroinferior /dotlessi /dotlessj /ff /fi /fl /ffi /ffl +% 0x20 + /visualspace /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quoteright + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% 0x30 + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question +% 0x40 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O +% 0x50 + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% 0x60 + /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o +% 0x70 + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /asciitilde /hyphen +% 0x80 + /Abreve /Aogonek /Cacute /Ccaron /Dcaron /Ecaron /Eogonek /Gbreve + /Lacute /Lcaron /Lslash /Nacute /Ncaron /Ng /Ohungarumlaut /Racute +% 0x90 + /Rcaron /Sacute /Scaron /Scedilla + /Tcaron /Tcedilla /Uhungarumlaut /Uring + /Ydieresis /Zacute /Zcaron /Zdotaccent /IJ /Idotaccent /dbar /section +% 0xA0 + /abreve /aogonek /cacute /ccaron /dcaron /ecaron /eogonek /gbreve + /lacute /lcaron /lslash /nacute /ncaron /ng /ohungarumlaut /racute +% 0xB0 + /rcaron /sacute /scaron /scedilla + /tquoteright /tcedilla /uhungarumlaut /uring + /ldot /zacute /zcaron /zdotaccent /ij /exclamdown /questiondown /sterling +% 0xC0 + /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /Iacute /Icircumflex /Idieresis +% 0xD0 + /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /OE + /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /Germandbls +% 0xE0 + /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla + /egrave /eacute /ecircumflex /edieresis + /igrave /iacute /icircumflex /idieresis +% 0xF0 + /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /oe + /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls +] def diff --git a/dviware/mdvi/data/ad.enc b/dviware/mdvi/data/ad.enc new file mode 100644 index 0000000000..97b71ac708 --- /dev/null +++ b/dviware/mdvi/data/ad.enc @@ -0,0 +1,67 @@ +%% Name is "ad.enc". +%% This draft file is for DEMO version +%% It is used as "Base Vector" + +/AdobeEncoding [ + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + +%% 040 + /space /exclam /quotedbl /numbersign /dollar /percent /ampersand + /quoteright /parenleft /parenright /asterisk /plus /comma /hyphen + /period /slash + +%% 060 + /zero /one /two /three /four /five /six /seven /eight /nine /colon + /semicolon /less /equal /greater /question + +%% 0100 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O + +%% 0120 + /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash + /bracketright /asciicircum /underscore + +%% 0140 + /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o + +%% 0160 + /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef + +%% 0240 + /.notdef /exclamdown /cent /sterling /fraction /yen /florin /section + /currency /quotesingle /quotedblleft /guillemotleft /guilsinglleft + /guilsinglright /fi /fl + +%% 0260 + /.notdef /endash /dagger /daggerdbl /periodcentered /.notdef + /paragraph /bullet /quotesinglbase /quotedblbase /quotedblright + /guillemotright /ellipsis /perthousand /.notdef /questiondown + /.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent + /dieresis /.notdef /ring /cedilla /.notdef + /hungarumlaut /ogonek /caron + +%% 0320 + /emdash /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + +%% 0340 + /.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef + +%% 0350 + /Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef + +%% 0360 + /.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef + +%% 0370 + /lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/asex.enc b/dviware/mdvi/data/asex.enc new file mode 100644 index 0000000000..f0abd28a75 --- /dev/null +++ b/dviware/mdvi/data/asex.enc @@ -0,0 +1,120 @@ +% This is ASEX encoding. (file ASEX.enc) +% +% Adobe Standard Encoding Extended. +% +% Creator: Pierre A. MacKay mackay@cs.washington.edu +% Creation Date: Thu Aug 31 08:56:22 PDT 1993 +% +% This is an input coding file for creation of a "raw font". +% It can, for esample be used with Radical Eye Software's +% afm2tfm. Use with the -p flag. This same encoding can also be +% used with ps2pk to create a complete set of bitmapped +% simplex characters. +% +% The {\em sole} purpose of this file is to ensure that all {\em simplex} +% characters in the font are made available in the raw TFM. Therefore +% there are no ligatures or any other refinements. The raw TFM +% file contains no ligatures or kernings---nothing but character +% metrics. We retain Adobe Standard encoding for all mapped +% characters in the AFM file, and extend the list by adding +% the unmapped simple characters into the empty code positions +% from O 200 to O 240. It is assumed that the output coding used +% for the TeX tfm will be different from this ( -t flag in afm2tfm ). +% +% The extended part of this encoding is consistent with the general +% run of text fonts from Adobe, BitStream, DTC, Linotype, Monotype, +% URW and probably others as well. For SuperFont characters, see below. +% In a library of over 300 text fonts, I have found no variants. The only +% variant in display fonts is the occasional absence of lowercase. +% +% Jan Michael Rynnings has pointed out that a few very carefully designed +% fonts, e. g. Adobe Garamond and Adobe Caslon, may treat all the accented +% characters as simplex glyphs (must make for a large pfa file), and that +% this input encoding would not recognize such refinements. True---but +% such fonts will be a tiny minority, and can be dealt with by +% special encoding files. A couple of tests indicate that it makes +% no perceptible difference whether you use composites formed from +% the CC recipes in the AFM file or call the characters out directly +% from the PFA file. There seems no reason, therefore, to fill the +% raw font with characters that are clearly identified as composites +% in the AFM file. +% +% Usage: +% afm2tfm <FontName>.afm -p ASEX.enc -t <output>.enc -v <vplname> <rawname> +% +/ASEXEncoding [ % now 256 chars follow +% +% The following will replace the characters from 0 to 32 in the raw encoding +% if you have access to a SuperFont. There is reason to hope that this +% set will be as stable as the unmapped set in current text fonts +% If you don't have a SuperFont, and have to create any of these as a +% composite, precede the name with a dot, as is done here for +% Scedilla and scedilla. The change in name keeps afm2tfm from thinking +% that the character already exists when it comes to evaluate the output +% (-t flag) encoding. +% +% 0x00 + /Aogonek /Eogonek /Iogonek /Kafii9170 /Lafii9170 /Lcaron /Nafii9170 /Rafii9170 + /Safii9170 /.Scedilla /Tafii9170 /Uogonek /.notdef /.notdef /.notdef /.notdef +% 0x10 + /aogonek /eogonek /iogonek /kafii9170 /lafii9170 /lcaron /nafii9170 /rafii9170 + /safii9170 /.scedilla /tafii9170 /uogonek /.notdef /.notdef /.notdef /.notdef +% 0x20 % Keep the space, for use as \boundarychar (Give it zero width in vpl) + /space /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quoteright + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% 0x30 + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question +% 0x40 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O +% 0x50 + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% 0x60 + /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o +% 0x70 + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /asciitilde /.notdef +% +% This is the Extension to Adobe Standard Encoding +% +% In as many of the next 32 positions as necessary, include +% all the unmapped simple (non-composite) characters. The +% inclusion of Ccedilla and ccedilla is problematic. These are +% composites in some schemes, simple in others. Best to +% assume they are simplex. Characters are entered in alphabetical order +% by name. If you need to create your own composite for Ccedilla +% ccedilla or Eth, precede the name with a dot as indicated above. +% +% 0x80 + /Ccedilla /Eth /Thorn /brokenbar /ccedilla /copyright /degree /divide + /eth /logicalnot /minus /mu /multiply /onehalf /onequarter /onesuperior +% 0x90 + /plusminus /registered /thorn /threequarters + /threesuperior /trademark /twosuperior /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +% From here on the order is again Adobe Standard Encoding +% +% 0xA0 + /.notdef /exclamdown /cent /sterling /fraction /yen /florin /section + /currency /quotesingle /quotedblleft /guillemotleft + /guilsinglleft /guilsinglright /fi /fl +% 0xB0 + /.notdef /endash /dagger /daggerdbl /periodcentered /.notdef /paragraph /bullet + /quotesinglbase /quotedblbase /quotedblright /guillemotright + /ellipsis /perthousand /.notdef /questiondown +% 0xC0 + /.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent + /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron +% 0xD0 + /emdash /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% 0xE0 + /.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef + /Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef +% 0xF0 + /.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef + /lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/asexp.enc b/dviware/mdvi/data/asexp.enc new file mode 100644 index 0000000000..0e76927935 --- /dev/null +++ b/dviware/mdvi/data/asexp.enc @@ -0,0 +1,84 @@ +% Date: Tue, 19 Jul 1994 07:11:11 -0700 +% From: mackay@cs.washington.edu (Pierre MacKay) +% To: kb@cs.umb.edu, alanje@cogs.susx.ac.uk, mackay@cs.washington.edu, +% Sebastian.Rahtz@cl.cam.ac.uk, unixtex@u.washington.edu +% Subject: ASEXP +% +% Since the expert font encoding vector is apparently left +% alone even by Windows, here is the version I have been using. +% +% This is ASEXP encoding, for the Monotype Expert character set. +% In Baskerville only the Roman Regular has all the characters. +% It seems to be the same as what Adobe uses---who knows? +% +/ASEXPEncoding [ % now 256 chars follow +% 0x00 + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% 0x10 + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% 0x20 % The independent accent slash doesn't exist + /.notdef /exclamsmall /Hungarumlautsmall /.notdef + /dollaroldstyle /dollarsuperior /ampersandsmall /Acutesmall + /parenleftsuperior /parenrightsuperior /twodotenleader /onedotenleader + /comma /hyphen /period /fraction +% 0x30 + /zerooldstyle /oneoldstyle /twooldstyle /threeoldstyle + /fouroldstyle /fiveoldstyle /sixoldstyle /sevenoldstyle + /eightoldstyle /nineoldstyle /colon /semicolon + /commasuperior /threequartersemdash /periodsuperior /questionsmall +% 0x40 + /.notdef /asuperior /bsuperior /centsuperior + /dsuperior /esuperior /.notdef /.notdef + /.notdef /isuperior /.notdef /.notdef + /lsuperior /msuperior /nsuperior /osuperior +% 0x50 + /.notdef /.notdef /rsuperior /ssuperior + /tsuperior /.notdef /ff /fi + /fl /ffi /ffl /parenleftinferior + /.notdef /parenrightinferior /Circumflexsmall /hyphensuperior +% 0x60 + /Gravesmall /Asmall /Bsmall /Csmall /Dsmall /Esmall /Fsmall /Gsmall + /Hsmall /Ismall /Jsmall /Ksmall /Lsmall /Msmall /Nsmall /Osmall +% 0X70 + /Psmall /Qsmall /Rsmall /Ssmall /Tsmall /Usmall /Vsmall /Wsmall + /Xsmall /Ysmall /Zsmall /colonmonetary + /onefitted /rupiah /Tildesmall /.notdef +% 0x80 + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% 0x90 + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% 0xA0 + /.notdef /exclamdownsmall /centoldstyle /Lslashsmall + /.notdef /.notdef /Scaronsmall /Zcaronsmall + /Dieresissmall /Brevesmall /Caronsmall /.notdef + /Dotaccentsmall /.notdef /.notdef /Macronsmall +% 0xB0 + /.notdef /.notdef /figuredash /hypheninferior + /.notdef /.notdef /Ogoneksmall /Ringsmall + /Cedillasmall /.notdef /.notdef /.notdef + /onequarter /onehalf /threequarters /questiondownsmall +% 0xC0 + /oneeighth /threeeighths /fiveeighths /seveneighths + /onethird /twothirds /.notdef /.notdef + /zerosuperior /onesuperior /twosuperior /threesuperior + /foursuperior /fivesuperior /sixsuperior /sevensuperior +% 0xD0 + /eightsuperior /ninesuperior /zeroinferior /oneinferior + /twoinferior /threeinferior /fourinferior /fiveinferior + /sixinferior /seveninferior /eightinferior /nineinferior + /centinferior /dollarinferior /periodinferior /commainferior +% 0xE0 + /Agravesmall /Aacutesmall /Acircumflexsmall /Atildesmall + /Adieresissmall /Aringsmall /AEsmall /Ccedillasmall + /Egravesmall /Eacutesmall /Ecircumflexsmall /Edieresissmall + /Igravesmall /Iacutesmall /Icircumflexsmall /Idieresissmall +% 0xF0 + /Ethsmall /Ntildesmall /Ogravesmall /Oacutesmall + /Ocircumflexsmall /Otildesmall /Odieresissmall /OEsmall + /Oslashsmall /Ugravesmall /Uacutesmall /Ucircumflexsmall + /Udieresissmall /Yacutesmall /Thornsmall /Ydieresissmall +] def diff --git a/dviware/mdvi/data/cm.map b/dviware/mdvi/data/cm.map new file mode 100644 index 0000000000..1fb3acef32 --- /dev/null +++ b/dviware/mdvi/data/cm.map @@ -0,0 +1,80 @@ +cmb10 CMB10 <cmb10.pfb <cmtext.enc +cmbsy10 CMBSY10 <cmbsy10.pfb <cmsy.enc +cmbsy6 CMBSY6 <cmbsy6.pfb <cmsy.enc +cmbsy7 CMBSY7 <cmbsy7.pfb <cmsy.enc +cmbsy8 CMBSY8 <cmbsy8.pfb <cmsy.enc +cmbsy9 CMBSY9 <cmbsy9.pfb <cmsy.enc +cmbx10 CMBX10 <cmbx10.pfb <cmtext.enc +cmbx12 CMBX12 <cmbx12.pfb <cmtext.enc +cmbx5 CMBX5 <cmbx5.pfb <cmtext.enc +cmbx6 CMBX6 <cmbx6.pfb <cmtext.enc +cmbx7 CMBX7 <cmbx7.pfb <cmtext.enc +cmbx8 CMBX8 <cmbx8.pfb <cmtext.enc +cmbx9 CMBX9 <cmbx9.pfb <cmtext.enc +cmbxsl10 CMBXSL10 <cmbxsl10.pfb <cmtext.enc +cmbxti10 CMBXTI10 <cmbxti10.pfb <cmitext.enc +cmcsc10 CMCSC10 <cmcsc10.pfb <cmtextf.enc +cmdunh10 CMDUNH10 <cmdunh10.pfb <cmtext.enc +cmex10 CMEX10 <cmex10.pfb <cmex.enc +cmff10 CMFF10 <cmff10.pfb <cmtext.enc +cmfi10 CMFI10 <cmfi10.pfb <cmitext.enc +cmfib8 CMFIB8 <cmfib8.pfb <cmtext.enc +cminch CMINCH <cminch.pfb <cminch.enc +cmitt10 CMITT10 <cmitt10.pfb <cmittext.enc +cmmi10 CMMI10 <cmmi10.pfb <cmmi.enc +cmmi12 CMMI12 <cmmi12.pfb <cmmi.enc +cmmi5 CMMI5 <cmmi5.pfb <cmmi.enc +cmmi6 CMMI6 <cmmi6.pfb <cmmi.enc +cmmi7 CMMI7 <cmmi7.pfb <cmmi.enc +cmmi8 CMMI8 <cmmi8.pfb <cmmi.enc +cmmi9 CMMI9 <cmmi9.pfb <cmmi.enc +cmmib10 CMMIB10 <cmmib10.pfb <cmmi.enc +cmr10 CMR10 <cmr10.pfb <cmtext.enc +%cmr10 CMR10 <cmr10.pfb <cmtext.enc +cmr12 CMR12 <cmr12.pfb <cmtext.enc +cmr17 CMR17 <cmr17.pfb <cmtext.enc +cmr5 CMR5 <cmr5.pfb <cmtextf.enc +cmr6 CMR6 <cmr6.pfb <cmtext.enc +cmr7 CMR7 <cmr7.pfb <cmtext.enc +cmr8 CMR8 <cmr8.pfb <cmtext.enc +cmr9 CMR9 <cmr9.pfb <cmtext.enc +cmsl10 CMSL10 <cmsl10.pfb <cmtext.enc +cmsl12 CMSL12 <cmsl12.pfb <cmtext.enc +cmsl8 CMSL8 <cmsl8.pfb <cmtext.enc +cmsl9 CMSL9 <cmsl9.pfb <cmtext.enc +cmsltt10 CMSLTT10 <cmsltt10.pfb <cmttext.enc +cmss10 CMSS10 <cmss10.pfb <cmtext.enc +cmss12 CMSS12 <cmss12.pfb <cmtext.enc +cmss17 CMSS17 <cmss17.pfb <cmtext.enc +cmss8 CMSS8 <cmss8.pfb <cmtext.enc +cmss9 CMSS9 <cmss9.pfb <cmtext.enc +cmssbx10 CMSSBX10 <cmssbx10.pfb <cmtext.enc +cmssdc10 CMSSDC10 <cmssdc10.pfb <cmtext.enc +cmssi10 CMSSI10 <cmssi10.pfb <cmtext.enc +cmssi12 CMSSI12 <cmssi12.pfb <cmtext.enc +cmssi17 CMSSI17 <cmssi17.pfb <cmtext.enc +cmssi8 CMSSI8 <cmssi8.pfb <cmtext.enc +cmssi9 CMSSI9 <cmssi9.pfb <cmtext.enc +cmssq8 CMSSQ8 <cmssq8.pfb <cmtext.enc +cmssqi8 CMSSQI8 <cmssqi8.pfb <cmtext.enc +cmsy10 CMSY10 <cmsy10.pfb <cmsy.enc +cmsy5 CMSY5 <cmsy5.pfb <cmsy.enc +cmsy6 CMSY6 <cmsy6.pfb <cmsy.enc +cmsy7 CMSY7 <cmsy7.pfb <cmsy.enc +cmsy8 CMSY8 <cmsy8.pfb <cmsy.enc +cmsy9 CMSY9 <cmsy9.pfb <cmsy.enc +cmtcsc10 CMTCSC10 <cmtcsc10.pfb <cmttext.enc +cmtex10 CMTEX10 <cmtex10.pfb <cmtex.enc +cmtex8 CMTEX8 <cmtex8.pfb <cmtex.enc +cmtex9 CMTEX9 <cmtex9.pfb <cmtex.enc +cmti10 CMTI10 <cmti10.pfb <cmitext.enc +cmti12 CMTI12 <cmti12.pfb <cmitext.enc +cmti7 CMTI7 <cmti7.pfb <cmitext.enc +cmti8 CMTI8 <cmti8.pfb <cmitext.enc +cmti9 CMTI9 <cmti9.pfb <cmitext.enc +cmtt10 CMTT10 <cmtt10.pfb <cmttext.enc +cmtt12 CMTT12 <cmtt12.pfb <cmttext.enc +cmtt8 CMTT8 <cmtt8.pfb <cmttext.enc +cmtt9 CMTT9 <cmtt9.pfb <cmttext.enc +cmu10 CMU10 <cmu10.pfb <cmitext.enc +cmvtt10 CMVTT10 <cmvtt10.pfb <cmtext.enc diff --git a/dviware/mdvi/data/cmex.enc b/dviware/mdvi/data/cmex.enc new file mode 100644 index 0000000000..c0238bea0a --- /dev/null +++ b/dviware/mdvi/data/cmex.enc @@ -0,0 +1,86 @@ +% TeX math extension +% +/TeXMathExtensionEncoding [ +% +/parenleftbig /parenrightbig /bracketleftbig /bracketrightbig /floorleftbig +/floorrightbig /ceilingleftbig /ceilingrightbig +% +/braceleftbig /bracerightbig /angbracketleftbig /angbracketrightbig +/vextendsingle /vextenddouble /slashbig /backslashbig +% +/parenleftBig /parenrightBig /parenleftbigg /parenrightbigg +/bracketleftbigg /bracketrightbigg /floorleftbigg /floorrightbigg +% +/ceilingleftbigg /ceilingrightbigg /braceleftbigg /bracerightbigg +/angbracketleftbigg /angbracketrightbigg /slashbigg /backslashbigg +% +/parenleftBigg /parenrightBigg /bracketleftBigg /bracketrightBigg +/floorleftBigg /floorrightBigg /ceilingleftBigg /ceilingrightBigg +% +/braceleftBigg /bracerightBigg /angbracketleftBigg /angbracketrightBigg +/slashBigg /backslashBigg /slashBig /backslashBig +% +/parenlefttp /parenrighttp /bracketlefttp /bracketrighttp /bracketleftbt +/bracketrightbt /bracketleftex /bracketrightex +% +/bracelefttp /bracerighttp /braceleftbt /bracerightbt /braceleftmid +/bracerightmid /braceex /arrowvertex +% +/parenleftbt /parenrightbt /parenleftex /parenrightex /angbracketleftBig +/angbracketrightBig /unionsqtext /unionsqdisplay +% +/contintegraltext /contintegraldisplay /circledottext /circledotdisplay +/circleplustext /circleplusdisplay /circlemultiplytext +/circlemultiplydisplay +% +/summationtext /producttext /integraltext /uniontext /intersectiontext +/unionmultitext /logicalandtext /logicalortext +% +/summationdisplay /productdisplay /integraldisplay /uniondisplay +/intersectiondisplay /unionmultidisplay /logicalanddisplay +/logicalordisplay +% +/coproducttext /coproductdisplay /hatwide /hatwider /hatwidest /tildewide +/tildewider /tildewidest +% +/bracketleftBig /bracketrightBig /floorleftBig /floorrightBig +/ceilingleftBig /ceilingrightBig /braceleftBig /bracerightBig +% +/radicalbig /radicalBig /radicalbigg /radicalBigg /radicalbt /radicalvertex +/radicaltp /arrowvertexdbl +% +/arrowtp /arrowbt /bracehtipdownleft /bracehtipdownright /bracehtipupleft +/bracehtipupright /arrowdbltp /arrowdblbt +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cminch.enc b/dviware/mdvi/data/cminch.enc new file mode 100644 index 0000000000..df131bbc86 --- /dev/null +++ b/dviware/mdvi/data/cminch.enc @@ -0,0 +1,68 @@ +% TeX CM inch +% +/TeXInchEncoding [ +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/zero /one /two /three /four /five /six /seven +% +/eight /nine /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cmitext.enc b/dviware/mdvi/data/cmitext.enc new file mode 100644 index 0000000000..2fc5f5f5c8 --- /dev/null +++ b/dviware/mdvi/data/cmitext.enc @@ -0,0 +1,70 @@ +% TeX italic text (this vector is the same as "TeX text" because of +% the mistake in BaKoMa font -- see file enc-note) +% +/TeXItalicTextEncoding [ +% +/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon +% +/Phi /Psi /Omega /ff /fi /fl /ffi /ffl +% +/dotlessi /dotlessj /grave /acute /caron /breve /macron /ring +% +/cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash +% +/polishlcross /exclam /quotedblright /numbersign /dollar /percent +/ampersand /quoteright +% +/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% +/zero /one /two /three /four /five /six /seven +% +/eight /nine /colon /semicolon /exclamdown /equal /questiondown /question +% +/at /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /bracketleft /quotedblleft /bracketright /circumflex /dotaccent +% +/quoteleft /a /b /c /d /e /f /g +% +/h /i /j /k /l /m /n /o +% +/p /q /r /s /t /u /v /w +% +/x /y /z /endash /emdash /hungarumlaut /tilde /dieresis +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cmittext.enc b/dviware/mdvi/data/cmittext.enc new file mode 100644 index 0000000000..464036743d --- /dev/null +++ b/dviware/mdvi/data/cmittext.enc @@ -0,0 +1,70 @@ +% TeX italic typewriter text (this vectror is the same as "TeX typewriter text" +% bacause of a mistake in BaKoMa fonts -- see enc-note) +% +/TeXItalicTypewriterTextEncoding [ +% +/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon +% +/Phi /Psi /Omega /arrowup /arrowdown /quotesingle /exclamdown /questiondown +% +/dotlessi /dotlessj /grave /acute /caron /breve /macron /ring +% +/cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash +% +/visiblespace /exclam /quotedbl /numbersign /dollar /percent /ampersand +/quoteright +% +/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% +/zero /one /two /three /four /five /six /seven +% +/eight /nine /colon /semicolon /less /equal /greater /question +% +/at /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% +/quoteleft /a /b /c /d /e /f /g +% +/h /i /j /k /l /m /n /o +% +/p /q /r /s /t /u /v /w +% +/x /y /z /braceleft /bar /braceright /asciitilde /dieresis +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cmmi.enc b/dviware/mdvi/data/cmmi.enc new file mode 100644 index 0000000000..0a46a4c985 --- /dev/null +++ b/dviware/mdvi/data/cmmi.enc @@ -0,0 +1,70 @@ +% TeX math italic +% +/TeXMathItalicEncoding [ +% +/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon +% +/Phi /Psi /Omega /alpha /beta /gamma /delta /epsilon1 +% +/zeta /eta /theta /iota /kappa /lambda /mu /nu +% +/xi /pi /rho /sigma /tau /upsilon /phi /chi +% +/psi /omega /epsilon /theta1 /pi1 /rho1 /sigma1 /phi1 +% +/arrowlefttophalf /arrowleftbothalf /arrowrighttophalf /arrowrightbothalf +/arrowhookleft /arrowhookright /triangleright /triangleleft +% +/zerooldstyle /oneoldstyle /twooldstyle /threeoldstyle /fouroldstyle +/fiveoldstyle /sixoldstyle /sevenoldstyle +% +/eightoldstyle /nineoldstyle /period /comma /less /slash /greater /star +% +/partialdiff /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /flat /natural /sharp /slurbelow /slurabove +% +/lscript /a /b /c /d /e /f /g +% +/h /i /j /k /l /m /n /o +% +/p /q /r /s /t /u /v /w +% +/x /y /z /dotlessi /dotlessj /weierstrass /vector /tie +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cmsy.enc b/dviware/mdvi/data/cmsy.enc new file mode 100644 index 0000000000..c919b6ce94 --- /dev/null +++ b/dviware/mdvi/data/cmsy.enc @@ -0,0 +1,79 @@ +% TeX math symbols +% +/TeXMathSymbolsEncoding [ +% +/minus /periodcentered /multiply /asteriskmath /divide /diamondmath +/plusminus /minusplus +% +/circleplus /circleminus /circlemultiply /circledivide /circledot +/circlecopyrt /openbullet /bullet +% +/equivasymptotic /equivalence /reflexsubset /reflexsuperset /lessequal +/greaterequal /precedesequal /followsequal +% +/similar /approxequal /propersubset /propersuperset /lessmuch /greatermuch +/precedes /follows +% +/arrowleft /arrowright /arrowup /arrowdown /arrowboth /arrownortheast +/arrowsoutheast /similarequal +% +/arrowdblleft /arrowdblright /arrowdblup /arrowdbldown /arrowdblboth +/arrownorthwest /arrowsouthwest /proportional +% +/prime /infinity /element /owner /triangle /triangleinv /negationslash +/mapsto +% +/universal /existential /logicalnot /emptyset /Rfractur /Ifractur +/latticetop /perpendicular +% +/aleph /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /union /intersection /unionmulti /logicaland /logicalor +% +/turnstileleft /turnstileright /floorleft /floorright /ceilingleft +/ceilingright /braceleft /braceright +% +/angbracketleft /angbracketright /bar /bardbl /arrowbothv /arrowdblbothv +/backslash /wreathproduct +% +/radical /coproduct /nabla /integral /unionsq /intersectionsq +/subsetsqequal /supersetsqequal +% +/section /dagger /daggerdbl /paragraph /club /diamond /heart /spade +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cmtex.enc b/dviware/mdvi/data/cmtex.enc new file mode 100644 index 0000000000..ebdb6a43db --- /dev/null +++ b/dviware/mdvi/data/cmtex.enc @@ -0,0 +1,71 @@ +% TeX extended ASCII (this vector is the same as "TeX text without f-ligatures" +% because of the mistake in BaKoMa font -- see enc-note file) +% +/TeXTextWithoutLigEncoding [ +% +/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon +% +/Phi /Psi /Omega /arrowup /arrowdown /quotesingle /exclamdown /questiondown +% +/dotlessi /dotlessj /grave /acute /caron /breve /macron /ring +% +/cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash +% +/suppress /exclam /quotedbl /numbersign /dollar /percent /ampersand +/quoteright +% +/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% +/zero /one /two /three /four /five /six /seven +% +/eight /nine /colon /semicolon /less /equal /greater /question +% +/at /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% +/quoteleft /a /b /c /d /e /f /g +% +/h /i /j /k /l /m /n /o +% +/p /q /r /s /t /u /v /w +% +/x /y /z /braceleft /bar /braceright /asciitilde /dieresis +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def + diff --git a/dviware/mdvi/data/cmtext.enc b/dviware/mdvi/data/cmtext.enc new file mode 100644 index 0000000000..f519430e43 --- /dev/null +++ b/dviware/mdvi/data/cmtext.enc @@ -0,0 +1,70 @@ +% TeX text +% +/TeXTextEncoding [ +% +/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon +% +/Phi /Psi /Omega /ff /fi /fl /ffi /ffl +% +/dotlessi /dotlessj /grave /acute /caron /breve /macron /ring +% +/cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash +% +/polishlcross /exclam /quotedblright /numbersign /dollar /percent +/ampersand /quoteright +% +/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% +/zero /one /two /three /four /five /six /seven +% +/eight /nine /colon /semicolon /exclamdown /equal /questiondown /question +% +/at /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /bracketleft /quotedblleft /bracketright /circumflex /dotaccent +% +/quoteleft /a /b /c /d /e /f /g +% +/h /i /j /k /l /m /n /o +% +/p /q /r /s /t /u /v /w +% +/x /y /z /endash /emdash /hungarumlaut /tilde /dieresis +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def + diff --git a/dviware/mdvi/data/cmtextf.enc b/dviware/mdvi/data/cmtextf.enc new file mode 100644 index 0000000000..cff6a0c65b --- /dev/null +++ b/dviware/mdvi/data/cmtextf.enc @@ -0,0 +1,69 @@ +% TeX text without f-ligatures +% +/TeXTextWithoutLigEncoding [ +% +/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon +% +/Phi /Psi /Omega /arrowup /arrowdown /quotesingle /exclamdown /questiondown +% +/dotlessi /dotlessj /grave /acute /caron /breve /macron /ring +% +/cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash +% +/suppress /exclam /quotedblright /numbersign /dollar /percent /ampersand +/quoteright +% +/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% +/zero /one /two /three /four /five /six /seven +% +/eight /nine /colon /semicolon /less /equal /greater /question +% +/at /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /bracketleft /quotedblleft /bracketright /circumflex /dotaccent +% +/quoteleft /a /b /c /d /e /f /g +% +/h /i /j /k /l /m /n /o +% +/p /q /r /s /t /u /v /w +% +/x /y /z /endash /emdash /hungarumlaut /tilde /dieresis +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cmttext.enc b/dviware/mdvi/data/cmttext.enc new file mode 100644 index 0000000000..d36bf3fd03 --- /dev/null +++ b/dviware/mdvi/data/cmttext.enc @@ -0,0 +1,69 @@ +% TeX typewriter text +% +/TeXTypewriterTextEncoding [ +% +/Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma /Upsilon +% +/Phi /Psi /Omega /arrowup /arrowdown /quotesingle /exclamdown /questiondown +% +/dotlessi /dotlessj /grave /acute /caron /breve /macron /ring +% +/cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash +% +/visiblespace /exclam /quotedbl /numbersign /dollar /percent /ampersand +/quoteright +% +/parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% +/zero /one /two /three /four /five /six /seven +% +/eight /nine /colon /semicolon /less /equal /greater /question +% +/at /A /B /C /D /E /F /G +% +/H /I /J /K /L /M /N /O +% +/P /Q /R /S /T /U /V /W +% +/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% +/quoteleft /a /b /c /d /e /f /g +% +/h /i /j /k /l /m /n /o +% +/p /q /r /s /t /u /v /w +% +/x /y /z /braceleft /bar /braceright /asciitilde /dieresis +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/cmttf.map b/dviware/mdvi/data/cmttf.map new file mode 100644 index 0000000000..a0f7bae0ef --- /dev/null +++ b/dviware/mdvi/data/cmttf.map @@ -0,0 +1,80 @@ +cmb10 cmb10 <cmb10.ttf <[cmtext.enc +cmbsy10 cmbsy10 <cmbsy10.ttf cmsy.enc +cmbsy6 cmbsy6 <cmbsy6.ttf cmsy.enc +cmbsy7 cmbsy7 <cmbsy7.ttf cmsy.enc +cmbsy8 cmbsy8 <cmbsy8.ttf cmsy.enc +cmbsy9 cmbsy9 <cmbsy9.ttf cmsy.enc +cmbx10 cmbx10 <cmbx10.ttf cmtext.enc +cmbx12 cmbx12 <cmbx12.ttf cmtext.enc +cmbx5 cmbx5 <cmbx5.ttf cmtext.enc +cmbx6 cmbx6 <cmbx6.ttf cmtext.enc +cmbx7 cmbx7 <cmbx7.ttf cmtext.enc +cmbx8 cmbx8 <cmbx8.ttf cmtext.enc +cmbx9 cmbx9 <cmbx9.ttf cmtext.enc +cmbxsl10 cmbxsl10 <cmbxsl10.ttf cmtext.enc +cmbxti10 cmbxti10 <cmbxti10.ttf cmitext.enc +cmcsc10 cmcsc10 <cmcsc10.ttf cmtextf.enc +cmdunh10 cmdunh10 <cmdunh10.ttf cmtext.enc +cmex10 cmex10 <cmex10.ttf cmex.enc +cmff10 cmff10 <cmff10.ttf cmtext.enc +cmfi10 cmfi10 <cmfi10.ttf cmitext.enc +cmfib8 cmfib8 <cmfib8.ttf cmtext.enc +cminch cminch <cminch.ttf cminch.enc +cmitt10 cmitt10 <cmitt10.ttf cmittext.enc +cmmi10 cmmi10 <cmmi10.ttf cmmi.enc +cmmi12 cmmi12 <cmmi12.ttf cmmi.enc +cmmi5 cmmi5 <cmmi5.ttf cmmi.enc +cmmi6 cmmi6 <cmmi6.ttf cmmi.enc +cmmi7 cmmi7 <cmmi7.ttf cmmi.enc +cmmi8 cmmi8 <cmmi8.ttf cmmi.enc +cmmi9 cmmi9 <cmmi9.ttf cmmi.enc +cmmib10 cmmib10 <cmmib10.ttf cmmi.enc +cmr10 cmr10 <cmr10.ttf cmtext.enc +%cmr10 cmr10 <cmr10.ttf cmtext.enc +cmr12 cmr12 <cmr12.ttf cmtext.enc +cmr17 cmr17 <cmr17.ttf cmtext.enc +cmr5 cmr5 <cmr5.ttf cmtextf.enc +cmr6 cmr6 <cmr6.ttf cmtext.enc +cmr7 cmr7 <cmr7.ttf cmtext.enc +cmr8 cmr8 <cmr8.ttf cmtext.enc +cmr9 cmr9 <cmr9.ttf cmtext.enc +cmsl10 cmsl10 <cmsl10.ttf cmtext.enc +cmsl12 cmsl12 <cmsl12.ttf cmtext.enc +cmsl8 cmsl8 <cmsl8.ttf cmtext.enc +cmsl9 cmsl9 <cmsl9.ttf cmtext.enc +cmsltt10 cmsltt10 <cmsltt10.ttf cmttext.enc +cmss10 cmss10 <cmss10.ttf cmtext.enc +cmss12 cmss12 <cmss12.ttf cmtext.enc +cmss17 cmss17 <cmss17.ttf cmtext.enc +cmss8 cmss8 <cmss8.ttf cmtext.enc +cmss9 cmss9 <cmss9.ttf cmtext.enc +cmssbx10 cmssbx10 <cmssbx10.ttf cmtext.enc +cmssdc10 cmssdc10 <cmssdc10.ttf cmtext.enc +cmssi10 cmssi10 <cmssi10.ttf cmtext.enc +cmssi12 cmssi12 <cmssi12.ttf cmtext.enc +cmssi17 cmssi17 <cmssi17.ttf cmtext.enc +cmssi8 cmssi8 <cmssi8.ttf cmtext.enc +cmssi9 cmssi9 <cmssi9.ttf cmtext.enc +cmssq8 cmssq8 <cmssq8.ttf cmtext.enc +cmssqi8 cmssqi8 <cmssqi8.ttf cmtext.enc +cmsy10 cmsy10 <cmsy10.ttf cmsy.enc +cmsy5 cmsy5 <cmsy5.ttf cmsy.enc +cmsy6 cmsy6 <cmsy6.ttf cmsy.enc +cmsy7 cmsy7 <cmsy7.ttf cmsy.enc +cmsy8 cmsy8 <cmsy8.ttf cmsy.enc +cmsy9 cmsy9 <cmsy9.ttf cmsy.enc +cmtcsc10 cmtcsc10 <cmtcsc10.ttf cmttext.enc +cmtex10 cmtex10 <cmtex10.ttf cmtex.enc +cmtex8 cmtex8 <cmtex8.ttf cmtex.enc +cmtex9 cmtex9 <cmtex9.ttf cmtex.enc +cmti10 cmti10 <cmti10.ttf cmitext.enc +cmti12 cmti12 <cmti12.ttf cmitext.enc +cmti7 cmti7 <cmti7.ttf cmitext.enc +cmti8 cmti8 <cmti8.ttf cmitext.enc +cmti9 cmti9 <cmti9.ttf cmitext.enc +cmtt10 cmtt10 <cmtt10.ttf cmttext.enc +cmtt12 cmtt12 <cmtt12.ttf cmttext.enc +cmtt8 cmtt8 <cmtt8.ttf cmttext.enc +cmtt9 cmtt9 <cmtt9.ttf cmttext.enc +cmu10 cmu10 <cmu10.ttf cmitext.enc +cmvtt10 cmvtt10 <cmvtt10.ttf cmtext.enc diff --git a/dviware/mdvi/data/cork.enc b/dviware/mdvi/data/cork.enc new file mode 100644 index 0000000000..2c7cbc2576 --- /dev/null +++ b/dviware/mdvi/data/cork.enc @@ -0,0 +1,85 @@ +% This is the Cork encoding, aka EC, Cork, aka TeX Latin 1, as +% described in TTN 1(4), December 1992, and TUGboat 11(4), November +% 1990, page 514. EC is the name of the Computer Modern-based fonts in +% this encoding. NFSS and Fontinst know it by `T1'. +% +% These are the ligs and kerns in addition to those found in the +% AFM file. (The only ligs in the Times-Roman.afm file are the +% fi and fl ligatures.) +% +% LIGKERN space l =: lslash ; space L =: Lslash ; +% LIGKERN question quoteleft =: questiondown ; exclam quoteleft =: exclamdown ; +% LIGKERN hyphen hyphen =: endash ; endash hyphen =: emdash ; +% LIGKERN quoteleft quoteleft =: quotedblleft ; +% LIGKERN quoteright quoteright =: quotedblright ; +% +% We blow away kerns to and from spaces (TeX doesn't have a +% space) and also remove any kerns from the numbers (although +% the only kern pair that mentions a number in Times-Roman.afm +% is one one.) +% +% LIGKERN space {} * ; * {} space ; zero {} * ; * {} zero ; +% LIGKERN one {} * ; * {} one ; two {} * ; * {} two ; +% LIGKERN three {} * ; * {} three ; four {} * ; * {} four ; +% LIGKERN five {} * ; * {} five ; six {} * ; * {} six ; +% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ; +% LIGKERN nine {} * ; * {} nine ; +% LIGKERN comma comma =: quotedblbase ; less less =: guillemotleft ; +% LIGKERN greater greater =: guillemotright ; +% +/CorkEncoding [ % now 256 chars follow +% 0x00 + /grave /acute /circumflex /tilde /dieresis /hungarumlaut /ring /caron + /breve /macron /dotaccent /cedilla + /ogonek /quotesinglbase /guilsinglleft /guilsinglright +% 0x10 + /quotedblleft /quotedblright /quotedblbase /guillemotleft + /guillemotright /endash /emdash /compworkmark + /perthousandzero /dotlessi /dotlessj /ff /fi /fl /ffi /ffl +% 0x20 + /visualspace /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quoteright + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% 0x30 + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question +% 0x40 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O +% 0x50 + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% 0x60 + /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o +% 0x70 + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /asciitilde /hyphen +% 0x80 + /Abreve /Aogonek /Cacute /Ccaron /Dcaron /Ecaron /Eogonek /Gbreve + /Lacute /Lcaron /Lslash /Nacute /Ncaron /Ng /Ohungarumlaut /Racute +% 0x90 + /Rcaron /Sacute /Scaron /Scedilla + /Tcaron /Tcedilla /Uhungarumlaut /Uring + /Ydieresis /Zacute /Zcaron /Zdotaccent /IJ /Idotaccent /dbar /section +% 0xA0 + /abreve /aogonek /cacute /ccaron /dcaron /ecaron /eogonek /gbreve + /lacute /lcaron /lslash /nacute /ncaron /ng /ohungarumlaut /racute +% 0xB0 + /rcaron /sacute /scaron /scedilla + /tquoteright /tcedilla /uhungarumlaut /uring + /ydieresis /zacute /zcaron /zdotaccent + /ij /exclamdown /questiondown /sterling +% 0xC0 + /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /Iacute /Icircumflex /Idieresis +% 0xD0 + /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /OE + /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /Germandbls +% 0xE0 + /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla + /egrave /eacute /ecircumflex /edieresis + /igrave /iacute /icircumflex /idieresis +% 0xF0 + /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /oe + /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls +] def diff --git a/dviware/mdvi/data/dc.enc b/dviware/mdvi/data/dc.enc new file mode 100644 index 0000000000..4d23e0bb03 --- /dev/null +++ b/dviware/mdvi/data/dc.enc @@ -0,0 +1,80 @@ +% +% This is the DC encoding. +% +% These are the ligs and kerns in addition to those found in the +% AFM file. (The only ligs in the Times-Roman.afm file are the +% fi and fl ligatures.) +% +% LIGKERN space l =: lslash ; space L =: Lslash ; +% LIGKERN question quoteleft =: questiondown ; exclam quoteleft =: exclamdown ; +% LIGKERN hyphen hyphen =: endash ; endash hyphen =: emdash ; +% LIGKERN quoteleft quoteleft =: quotedblleft ; +% LIGKERN quoteright quoteright =: quotedblright ; +% +% We blow away kerns to and from spaces (TeX doesn't have a +% space) and also remove any kerns from the numbers (although +% the only kern pair that mentions a number in Times-Roman.afm +% is one one.) +% +% LIGKERN space {} * ; * {} space ; zero {} * ; * {} zero ; +% LIGKERN one {} * ; * {} one ; two {} * ; * {} two ; +% LIGKERN three {} * ; * {} three ; four {} * ; * {} four ; +% LIGKERN five {} * ; * {} five ; six {} * ; * {} six ; +% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ; +% LIGKERN nine {} * ; * {} nine ; +% LIGKERN comma comma =: quotedblbase ; less less =: guillemotleft ; +% LIGKERN greater greater =: guillemotright ; +% +/DCEncoding [ % now 256 chars follow +% 0x00 + /grave /acute /circumflex /tilde /dieresis /hungarumlaut /ring /caron + /breve /macron /dotaccent /cedilla + /ogonek /quotesinglbase /guilsinglleft /guilsinglright +% 0x10 + /quotedblleft /quotedblright /quotedblbase /guillemotleft + /guillemotright /endash /emdash /.notdef + /zeroinferior /dotlessi /dotlessj /ff /fi /fl /ffi /ffl +% 0x20 + /.notdef /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quoteright + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash +% 0x30 + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question +% 0x40 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O +% 0x50 + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% 0x60 + /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o +% 0x70 + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /asciitilde /hyphen +% 0x80 + /Abreve /Aogonek /Cacute /Ccaron /Dcaron /Ecaron /Eogonek /Gbreve + /Lacute /Lcaron /Lslash /Nacute /Ncaron /Ng /Ohungarumlaut /Racute +% 0x90 + /Rcaron /Sacute /Scaron /Scedilla /Tcaron /Tcedilla /Uhungarumlaut /Uring + /Ldot /Zacute /Zcaron /Zdotaccent /IJ /Idotaccent /dbar /section +% 0xA0 + /abreve /aogonek /cacute /ccaron /dcaron /ecaron /eogonek /gbreve + /lacute /lcaron /lslash /nacute /ncaron /ng /ohungarumlaut /racute +% 0xB0 + /rcaron /sacute /scaron /scedilla /tcaron /tcedilla /uhungarumlaut /uring + /ldot /zacute /zcaron /zdotaccent /ij /exclamdown /questiondown /sterling +% 0xC0 + /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /Iacute /Icircumflex /Idieresis +% 0xD0 + /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /OE + /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /SS +% 0xE0 + /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla + /egrave /eacute /ecircumflex /edieresis + /igrave /iacute /icircumflex /idieresis +% 0xF0 + /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /oe + /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls +] def diff --git a/dviware/mdvi/data/dvips.enc b/dviware/mdvi/data/dvips.enc new file mode 100644 index 0000000000..ea451ff106 --- /dev/null +++ b/dviware/mdvi/data/dvips.enc @@ -0,0 +1,75 @@ +% @@psencodingfile@{ +% author = "T. Rokicki, K. Berry", +% version = "2.0", +% date = "22 June 1996", +% filename = "dvips.enc", +% email = "kb@@mail.tug.org", +% address = "135 Center Hill Rd. // Plymouth, MA 02360", +% codetable = "ISO/ASCII", +% checksum = "75 515 3715", +% docstring = "An encoding for PostScript fonts to be used with TeX." +% @} +% +% This is almost the default encoding produced by the afm2tfm program +% that comes with the dvips distribution, when it is applied to a +% StandardEncoding PostScript font. The positions of the accented +% characters (which afm2tfm assigned more or less randomly in the +% previous set of fonts) have been held fixed. +% +% It is almost upward-compatible with TeX text. (The primary exceptions +% are dotaccent and hungarumlaut.) Some of the ligatures are also in +% different positions, but this is not important, since ligature +% positions are defined in the TFM file, not by macros. +% +% The character positions were assigned in this order: +% 1) non-composite characters in the afm2tfm encoding (except dotlessj +% was included in its plain TeX position); +% 2) available characters in the Cork (EC) encoding; +% 3) remaining composite characters in the base encoding (starting at +% position 130 decimal). We don't include all the other base +% characters because that changes the height/depth/width tables in +% the TFM files (because more characters mean more distinct values). +% +% We leave the initial positions open for the Greek letters in Times-Roman. +% +/DvipsEncoding [ + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef + /.notdef /quotesingle /exclamdown /questiondown + /dotlessi /dotlessj /grave /acute /caron /breve /macron /ring + /cedilla /germandbls /ae /oe /oslash /AE /OE /Oslash + /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question + /at /A /B /C /D /E /F /G + /H /I /J /K /L /M /N /O + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /circumflex /underscore + /quoteleft /a /b /c /d /e /f /g + /h /i /j /k /l /m /n /o + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /tilde /dieresis + /asciicircum /asciitilde /Ccedilla /Iacute + /Icircumflex /atilde /edieresis /egrave + /scaron /zcaron /Eth /ff /ffi /ffl /.notdef /.notdef + /.notdef /.notdef /Scaron /.notdef /.notdef /.notdef /.notdef /.notdef + /Ydieresis /.notdef /Zcaron /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /cent /sterling /fraction /yen /florin /section + /currency /copyright /quotedblleft /guillemotleft + /guilsinglleft /guilsinglright /fi /fl + /degree /endash /dagger /daggerdbl /periodcentered /.notdef /paragraph /bullet + /quotesinglbase /quotedblbase /quotedblright /guillemotright + /ellipsis /perthousand /.notdef /.notdef + /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /.notdef /dotaccent + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /hungarumlaut /ogonek /Idieresis + /emdash /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /.notdef + /.notdef /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /.notdef + /agrave /aacute /acircumflex /ordfeminine + /adieresis /aring /.notdef /ccedilla + /Lslash /eacute /ecircumflex /ordmasculine + /igrave /iacute /icircumflex /idieresis + /.notdef /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /.notdef + /lslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis +] def diff --git a/dviware/mdvi/data/extex.enc b/dviware/mdvi/data/extex.enc new file mode 100644 index 0000000000..e67970b5a1 --- /dev/null +++ b/dviware/mdvi/data/extex.enc @@ -0,0 +1,79 @@ +% +% This is the extended TeX encoding. +% +% These are the ligs and kerns in addition to those found in the +% AFM file. (The only ligs in the Times-Roman.afm file are the +% fi and fl ligatures.) +% +% LIGKERN space l =: lslash ; space L =: Lslash ; +% LIGKERN question quoteleft =: questiondown ; exclam quoteleft =: exclamdown ; +% LIGKERN hyphen hyphen =: endash ; endash hyphen =: emdash ; +% LIGKERN quoteleft quoteleft =: quotedblleft ; +% LIGKERN quoteright quoteright =: quotedblright ; +% +% We blow away kerns to and from spaces (TeX doesn't have a +% space) and also remove any kerns from the numbers (although +% the only kern pair that mentions a number in Times-Roman.afm +% is one one.) +% +% LIGKERN space {} * ; * {} space ; zero {} * ; * {} zero ; +% LIGKERN one {} * ; * {} one ; two {} * ; * {} two ; +% LIGKERN three {} * ; * {} three ; four {} * ; * {} four ; +% LIGKERN five {} * ; * {} five ; six {} * ; * {} six ; +% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ; +% LIGKERN nine {} * ; * {} nine ; +% LIGKERN comma comma =: quotedblbase ; less less =: guillemotleft ; +% LIGKERN greater greater =: guillemotright ; +% +/ExtendedTeXEncoding [ % now 256 chars follow +% 0x00 + /grave /acute /circumflex /tilde /dieresis /hungarumlaut /ring /caron + /breve /macron /dotaccent /cedilla + /ogonek /quotesinglbase /guilsinglleft /guilsinglright +% 0x10 + /quotedblleft /quotedblright /quotedblbase /guillemotleft + /guillemotright /endash /emdash /cwm + /zeroinferior /dotlessi /dotlessj /ff /fi /fl /ffi /ffl +% 0x20 + /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright + /parenleft /parenright /asterisk /plus /comma /minus /period /slash +% 0x30 + /zero /one /two /three /four /five /six /seven + /eight /nine /colon /semicolon /less /equal /greater /question +% 0x40 + /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O +% 0x50 + /P /Q /R /S /T /U /V /W + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +% 0x60 + /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o +% 0x70 + /p /q /r /s /t /u /v /w + /x /y /z /braceleft /bar /braceright /asciitilde /hyphen +% 0x80 + /Abreve /Aogonek /Cacute /Ccaron /Dcaron /Ecaron /Eogonek /Gbreve + /Lacute /Lcaron /Lslash /Nacute /Ncaron /Eng /Ohungarumlaut /Racute +% 0x90 + /Rcaron /Sacute /Scaron /Scedilla /Tcaron /Tcedilla /Uhungarumlaut /Uring + /Ydieresis /Zacute /Zcaron /Zdot /IJ /Idot /dstroke /paragraph +% 0xA0 + /abreve /aogonek /cacute /ccaron /dcaron /ecaron /eogonek /gbreve + /lacute /lcaron /lslash /nacute /ncaron /eng /ohungarumlaut /racute +% 0xB0 + /rcaron /sacute /scaron /scedilla /tcaron /tcedilla /uhungarumlaut /uring + /ydieresis /zacute /zcaron /zdot /ij /exclamdown /questiondown /sterling +% 0xC0 + /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla + /Egrave /Eacute /Ecircumflex /Edieresis + /Igrave /Iacute /Icircumflex /Idieresis +% 0xD0 + /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /OE + /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /Germandbls +% 0xE0 + /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla + /egrave /eacute /ecircumflex /edieresis + /igrave /iacute /icircumflex /idieresis +% 0xF0 + /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /oe + /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls +] def diff --git a/dviware/mdvi/data/funky.enc b/dviware/mdvi/data/funky.enc new file mode 100644 index 0000000000..84f9798cc3 --- /dev/null +++ b/dviware/mdvi/data/funky.enc @@ -0,0 +1,81 @@ +% +% This is our funky encoding. Not for the weak. +% +% LIGKERN || A =:| A ; || = 46 ; a {} b ; +% +/FunkyEncoding [ + /Gamma /Delta /Theta /Lambda /Xi /Pi /Sigma + /Upsilon /Phi /Psi /Omega /arrowup /arrowdown /quotesingle + /exclamdown /questiondown /dotlessi /dotlessj /grave /acute + /caron /breve /macron /ring /cedilla /germandbls /ae /oe + /oslash /AE /OE /Oslash /space /exclam /quotedbl /numbersign + /dollar /percent /ampersand /quoteright /parenleft /parenright + /asterisk /plus /comma /hyphen /period /slash /zero /one + /two /three /four /five /six /seven /eight /nine /colon + /semicolon /less /equal /greater /question /at + /E /C /D /F /I /G /H /J /O /K /L /M /N /P /U /Q /R /S /T /V /Y /W /X /Z /A /B + /bracketleft /backslash /bracketright /circumflex /underscore /quoteleft + /e /c /d /f /i /g /h /j /o /k /l /m /n /p /u /q /r /s /t /v /y /w /x /z /a /b + /braceleft /bar /braceright /tilde /dieresis % 128 chars + /T /T /T /T /T /T /T /T /T /T + /o /o /o /o /o /o /o /o /o /o + /two /two /two /two /two % 153 chars, 103 more to go + /fi /ff /ffi /ffl % if they exist + /some /characters /that /dont /exist + /. /. /. /. /. /. /. /. /. /. /. /. /. /. /. /. /. /. /. /. % 182 so far + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + /.notdef /.notdef % that's 128. + ] def +% +% Let's be able to add mod 9 automatically with the kerns. +% +% LIGKERN zero zero =: zero ; zero one =: one ; zero two =: two ; +% LIGKERN zero three =: three ; zero four =: four ; zero five =: five ; +% LIGKERN zero six =: six ; zero seven =: seven ; zero eight =: eight ; +% LIGKERN zero nine =: zero ; one zero =: one ; one one =: two ; +% LIGKERN one two =: three ; one three =: four ; one four =: five ; +% LIGKERN one five =: six ; one six =: seven ; one seven =: eight ; +% LIGKERN one eight =: zero ; one nine =: one ; two zero =: two ; +% LIGKERN two one =: three ; two two =: four ; two three =: five ; +% LIGKERN two four =: six ; two five =: seven ; two six =: eight ; +% LIGKERN two seven =: zero ; two eight =: one ; two nine =: two ; +% LIGKERN three zero =: three ; three one =: four ; three two =: five ; +% LIGKERN three three =: six ; three four =: seven ; three five =: eight ; +% LIGKERN three six =: zero ; three seven =: one ; three eight =: two ; +% LIGKERN three nine =: three ; four zero =: four ; four one =: five ; +% LIGKERN four two =: six ; four three =: seven ; four four =: eight ; +% LIGKERN four five =: zero ; four six =: one ; four seven =: two ; +% LIGKERN four eight =: three ; four nine =: four ; five zero =: five ; +% LIGKERN five one =: six ; five two =: seven ; five three =: eight ; +% LIGKERN five four =: zero ; five five =: one ; five six =: two ; +% LIGKERN five seven =: three ; five eight =: four ; five nine =: five ; +% LIGKERN six zero =: six ; six one =: seven ; six two =: eight ; +% LIGKERN six three =: zero ; six four =: one ; six five =: two ; +% LIGKERN six six =: three ; six seven =: four ; six eight =: five ; +% LIGKERN six nine =: six ; seven zero =: seven ; seven one =: eight ; +% LIGKERN seven two =: zero ; seven three =: one ; seven four =: two ; +% LIGKERN seven five =: three ; seven six =: four ; seven seven =: five ; +% LIGKERN seven eight =: six ; seven nine =: seven ; eight zero =: eight ; +% LIGKERN eight one =: zero ; eight two =: one ; eight three =: two ; +% LIGKERN eight four =: three ; eight five =: four ; eight six =: five ; +% LIGKERN eight seven =: six ; eight eight =: seven ; eight nine =: eight ; +% LIGKERN nine zero =: zero ; nine one =: one ; nine two =: two ; +% LIGKERN nine three =: three ; nine four =: four ; nine five =: five ; +% LIGKERN nine six =: six ; nine seven =: seven ; nine eight =: eight ; +% LIGKERN nine nine =: zero ; ten zero =: one ; ten one =: two ; +% LIGKERN ten two =: three ; ten three =: four ; ten four =: five ; +% LIGKERN ten five =: six ; ten six =: seven ; ten seven =: eight ; +% LIGKERN zero || |=: emdash ; one || |=: emdash ; two || |=: emdash ; +% LIGKERN three || |=: emdash ; four || |=: emdash ; five || |=: emdash ; +% LIGKERN six || |=: emdash ; seven || |=: emdash ; eight || |=: emdash ; +% LIGKERN nine || |=: emdash ; || nine =: zero ; +% LIGKERN z || |=:> z ; q o |=:|> emdash ; plus plus |=: exclam ; +% LIGKERN slash slash =:| backslash ; q || =: Q ; || q =: Q ; diff --git a/dviware/mdvi/data/omega.map b/dviware/mdvi/data/omega.map new file mode 100644 index 0000000000..996996b321 --- /dev/null +++ b/dviware/mdvi/data/omega.map @@ -0,0 +1,25 @@ +omsea1 OmegaSerifArabicOne <omsea1.pfb +omsea1b OmegaSerifArabicOne-Bold <omsea1b.pfb +omsea2 OmegaSerifArabicTwo <omsea2.pfb +omsea2b OmegaSerifArabicTwo-Bold <omsea2b.pfb +omsea3 OmegaSerifArabicThree <omsea3.pfb +omsea3b OmegaSerifArabicThree-Bold <omsea3b.pfb +omseco OmegaSerifCommon <omseco.pfb +omsecob OmegaSerifCommon-Bold <omsecob.pfb +omsecobi OmegaSerifCommon-BoldItalic <omsecobi.pfb +omsecoi OmegaSerifCommon-Italic <omsecoi.pfb +omsecx OmegaSerifCyrillicExtended <omsecx.pfb +omsecy OmegaSerifCyrillic <omsecy.pfb +omsegr OmegaSerifGreek <omsegr.pfb +omsegrb OmegaSerifGreek-Bold <omsegrb.pfb +omsegrbi OmegaSerifGreek-BoldItalic <omsegrbi.pfb +omsegri OmegaSerifGreek-Italic <omsegri.pfb +omseha OmegaSerifArmenian <omseha.pfb +omsehe OmegaSerifHebrew <omsehe.pfb +omseip OmegaSerifIPA <omseip.pfb +omsela OmegaSerifLatin <omsela.pfb +omselab OmegaSerifLatin-Bold <omselab.pfb +omselabi OmegaSerifLatin-BoldItalic <omselabi.pfb +omselai OmegaSerifLatin-Italic <omselai.pfb +omseti OmegaSerifTifinagh <omseti.pfb +omssti OmegaSansTifinagh <omssti.pfb diff --git a/dviware/mdvi/data/psfonts.map b/dviware/mdvi/data/psfonts.map new file mode 100644 index 0000000000..d82c521370 --- /dev/null +++ b/dviware/mdvi/data/psfonts.map @@ -0,0 +1,84 @@ +bchb8r CharterBT-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc <bchb8a.pfb +bchbi8r CharterBT-BoldItalic " TeXBase1Encoding ReEncodeFont " <8r.enc <bchbi8a.pfb +bchbo8r CharterBT-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <bchb8a.pfb +bchr8r CharterBT-Roman " TeXBase1Encoding ReEncodeFont " <8r.enc <bchr8a.pfb +bchri8r CharterBT-Italic " TeXBase1Encoding ReEncodeFont " <8r.enc <bchri8a.pfb +bchro8r CharterBT-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <bchr8a.pfb +pagd8r AvantGarde-Demi " TeXBase1Encoding ReEncodeFont " <8r.enc +pagdo8r AvantGarde-DemiOblique " TeXBase1Encoding ReEncodeFont " <8r.enc +pagk8r AvantGarde-Book " TeXBase1Encoding ReEncodeFont " <8r.enc +pagko8r AvantGarde-BookOblique " TeXBase1Encoding ReEncodeFont " <8r.enc +pbkd8r Bookman-Demi " TeXBase1Encoding ReEncodeFont " <8r.enc +pbkdi8r Bookman-DemiItalic " TeXBase1Encoding ReEncodeFont " <8r.enc +pbkdo8r Bookman-Demi " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +pbkl8r Bookman-Light " TeXBase1Encoding ReEncodeFont " <8r.enc +pbkli8r Bookman-LightItalic " TeXBase1Encoding ReEncodeFont " <8r.enc +pbklo8r Bookman-Light " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +pcrb8r Courier-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc +pcrbo8r Courier-BoldOblique " TeXBase1Encoding ReEncodeFont " <8r.enc +pcrr8r Courier " TeXBase1Encoding ReEncodeFont " <8r.enc +pcrr8rn Courier " .85 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +pcrro8r Courier-Oblique " TeXBase1Encoding ReEncodeFont " <8r.enc +phvb8r Helvetica-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc +phvb8rn Helvetica-Narrow-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc +phvbo8r Helvetica-BoldOblique " TeXBase1Encoding ReEncodeFont " <8r.enc +phvbo8rn Helvetica-Narrow-BoldOblique " TeXBase1Encoding ReEncodeFont " <8r.enc +phvbon8r Helvetica-BoldOblique " .82 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +phvbrn8r Helvetica-Bold " .82 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +phvr8r Helvetica " TeXBase1Encoding ReEncodeFont " <8r.enc +phvr8rn Helvetica-Narrow " TeXBase1Encoding ReEncodeFont " <8r.enc +phvro8r Helvetica-Oblique " TeXBase1Encoding ReEncodeFont " <8r.enc +phvro8rn Helvetica-Narrow-Oblique " TeXBase1Encoding ReEncodeFont " <8r.enc +phvron8r Helvetica-Oblique " .82 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +phvrrn8r Helvetica " .82 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +pncb8r NewCenturySchlbk-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc +pncbi8r NewCenturySchlbk-BoldItalic " TeXBase1Encoding ReEncodeFont " <8r.enc +pncbo8r NewCenturySchlbk-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +pncr8r NewCenturySchlbk-Roman " TeXBase1Encoding ReEncodeFont " <8r.enc +pncri8r NewCenturySchlbk-Italic " TeXBase1Encoding ReEncodeFont " <8r.enc +pncro8r NewCenturySchlbk-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +pplb8r Palatino-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc +pplbi8r Palatino-BoldItalic " TeXBase1Encoding ReEncodeFont " <8r.enc +pplbo8r Palatino-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +pplbu8r Palatino-BoldItalic " -.1763 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +pplr8r Palatino-Roman " TeXBase1Encoding ReEncodeFont " <8r.enc +pplri8r Palatino-Italic " TeXBase1Encoding ReEncodeFont " <8r.enc +pplro8r Palatino-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +pplrre8r Palatino-Roman " 1.2 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +pplrrn8r Palatino-Roman " .82 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +pplru8r Palatino-Italic " -.1763 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +psyr Symbol +psyro Symbol " .167 SlantFont " +ptmb8r Times-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc +ptmbi8r Times-BoldItalic " TeXBase1Encoding ReEncodeFont " <8r.enc +ptmbo8r Times-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +ptmr8r Times-Roman " TeXBase1Encoding ReEncodeFont " <8r.enc +ptmri8r Times-Italic " TeXBase1Encoding ReEncodeFont " <8r.enc +ptmro8r Times-Roman " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc +ptmrre8r Times-Roman " 1.2 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +ptmrrn8r Times-Roman " .82 ExtendFont TeXBase1Encoding ReEncodeFont " <8r.enc +putb8r Utopia-Bold " TeXBase1Encoding ReEncodeFont " <8r.enc <putb8a.pfb +putbi8r Utopia-BoldItalic " TeXBase1Encoding ReEncodeFont " <8r.enc <putbi8a.pfb +putbo8r Utopia-Bold " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <putb8a.pfb +putr8r Utopia-Regular " TeXBase1Encoding ReEncodeFont " <8r.enc <putr8a.pfb +putri8r Utopia-Italic " TeXBase1Encoding ReEncodeFont " <8r.enc <putri8a.pfb +putro8r Utopia-Regular " .167 SlantFont TeXBase1Encoding ReEncodeFont " <8r.enc <putr8a.pfb +pzcmi8r ZapfChancery-MediumItalic " TeXBase1Encoding ReEncodeFont " <8r.enc +pzdr ZapfDingbats +xyatip10 XYATIP10 <<xyatip10.pfb +xybsql10 XYBSQL10 <<xybsql10.pfb +xybtip10 XYBTIP10 <<xybtip10.pfb +xycirc10 XYCIRC10 <<xycirc10.pfb +xycmat10 XYCMAT10 <<xycmat10.pfb +xycmat11 XYCMAT10 <<xycmat10.pfb "1.1 ExtendFont" +xycmat12 XYCMAT10 <<xycmat10.pfb "1.2 ExtendFont" +xycmbt10 XYCMBT10 <<xycmbt10.pfb +xycmbt11 XYCMBT10 <<xycmbt10.pfb "1.1 ExtendFont" +xycmbt12 XYCMBT10 <<xycmbt10.pfb "1.2 ExtendFont" +xydash10 XYDASH10 <<xydash10.pfb +xyeuat10 XYEUAT10 <<xyeuat10.pfb +xyeuat11 XYEUAT10 <<xyeuat10.pfb "1.1 ExtendFont" +xyeuat12 XYEUAT10 <<xyeuat10.pfb "1.2 ExtendFont" +xyeubt10 XYEUBT10 <<xyeubt10.pfb +xyeubt11 XYEUBT10 <<xyeubt10.pfb "1.1 ExtendFont" +xyeubt12 XYEUBT10 <<xyeubt10.pfb "1.2 ExtendFont" diff --git a/dviware/mdvi/data/texmext.enc b/dviware/mdvi/data/texmext.enc new file mode 100644 index 0000000000..ef84ebbf9c --- /dev/null +++ b/dviware/mdvi/data/texmext.enc @@ -0,0 +1,184 @@ +% TeX math extension encoding. +% No ligatures or kerns. +% +/TeXMathExtensionEncoding [ % now 256 chars follow + +% 0x0 +/parenleftbig +/parenrightbig +/bracketleftbig +/bracketrightbig +/floorleftbig +/floorrightbig +/ceilingleftbig +/ceilingrightbig + +% 0x8 +/braceleftbig +/bracerightbig +/angbracketleftbig +/angbracketrightbig +/vextendsingle +/vextenddouble +/slashbig +/backslashbig + +% 0x10 +/parenleftBig +/parenrightBig +/parenleftbigg +/parenrightbigg +/bracketleftbigg +/bracketrightbigg +/floorleftbigg +/floorrightbigg + +% 0x18 +/ceilingleftbigg +/ceilingrightbigg +/braceleftbigg +/bracerightbigg +/angbracketleftbigg +/angbracketrightbigg +/slashbigg +/backslashbigg + +% 0x20 +/parenleftBigg +/parenrightBigg +/bracketleftBigg +/bracketrightBigg +/floorleftBigg +/floorrightBigg +/ceilingleftBigg +/ceilingrightBigg + +% 0x28 +/braceleftBigg +/bracerightBigg +/angbracketleftBigg +/angbracketrightBigg +/slashBigg +/backslashBigg +/slashBig +/backslashBig + +% 0x30 +/parenlefttp +/parenrighttp +/bracketlefttp +/bracketrighttp +/bracketleftbt +/bracketrightbt +/bracketleftex +/bracketrightex + +% 0x38 +/bracelefttp +/bracerighttp +/braceleftbt +/bracerightbt +/braceleftmid +/bracerightmid +/braceex +/arrowvertex + +% 0x40 +/parenleftbt +/parenrightbt +/parenleftex +/parenrightex +/angbracketleftBig +/angbracketrightBig +/unionsqtext +/unionsqdisplay + +% 0x48 +/contintegraltext +/contintegraldisplay +/circledottext +/circledotdisplay +/circleplustext +/circleplusdisplay +/circlemultiplytext +/circlemultiplydisplay + +% 0x50 +/summationtext +/producttext +/integraltext +/uniontext +/intersectiontext +/unionmultitext +/logicalandtext +/logicalortext + +% 0x58 +/summationdisplay +/productdisplay +/integraldisplay +/uniondisplay +/intersectiondisplay +/unionmultidisplay +/logicalanddisplay +/logicalordisplay + +% 0x60 +/coproducttext +/coproductdisplay +/hatwide +/hatwider +/hatwidest +/tildewide +/tildewider +/tildewidest + +% 0x68 +/bracketleftBig +/bracketrightBig +/floorleftBig +/floorrightBig +/ceilingleftBig +/ceilingrightBig +/braceleftBig +/bracerightBig + +% 0x70 +/radicalbig +/radicalBig +/radicalbigg +/radicalBigg +/radicalbt +/radicalvertex +/radicaltp +/arrowvertexdbl + +% 0x78 +/arrowtp +/arrowbt +/bracehtipdownleft +/bracehtipdownright +/bracehtipupleft +/bracehtipupright +/arrowdbltp +/arrowdblbt + +% Have to have 128 .notdef's now to fill things out. +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/texmital.enc b/dviware/mdvi/data/texmital.enc new file mode 100644 index 0000000000..35453d8906 --- /dev/null +++ b/dviware/mdvi/data/texmital.enc @@ -0,0 +1,183 @@ +% TeX math italic encoding. +% No ligatures or kerns. +% +/TeXMathItalicEncoding [ % now 256 chars follow +% 0x0 +/Gamma +/Delta +/Theta +/Lambda +/Xi +/Pi +/Sigma +/Upsilon + +% 0x8 +/Phi +/Psi +/Omega +/alpha +/beta +/gamma +/delta +/epsilon1 + +% 0x10 +/zeta +/eta +/theta +/iota +/kappa +/lambda +/mu +/nu + +% 0x18 +/xi +/pi +/rho +/sigma +/tau +/upsilon +/phi +/chi + +% 0x20 +/psi +/omega +/epsilon +/theta1 +/pi1 +/rho1 +/sigma1 +/phi1 + +% 0x28 +/arrowlefttophalf +/arrowleftbothalf +/arrowrighttophalf +/arrowrightbothalf +/arrowhookleft +/arrowhookright +/triangleright +/triangleleft + +% 0x30 +/zerooldstyle +/oneoldstyle +/twooldstyle +/threeoldstyle +/fouroldstyle +/fiveoldstyle +/sixoldstyle +/sevenoldstyle + +% 0x38 +/eightoldstyle +/nineoldstyle +/period +/comma +/less +/slash +/greater +/star + +% 0x40 +/partialdiff +/A +/B +/C +/D +/E +/F +/G + +% 0x48 +/H +/I +/J +/K +/L +/M +/N +/O + +% 0x50 +/P +/Q +/R +/S +/T +/U +/V +/W + +% 0x58 +/X +/Y +/Z +/flat +/natural +/sharp +/slurbelow +/slurabove + +% 0x60 +/lscript +/a +/b +/c +/d +/e +/f +/g + +% 0x68 +/h +/i +/j +/k +/l +/m +/n +/o + +% 0x70 +/p +/q +/r +/s +/t +/u +/v +/w + +% 0x78 +/x +/y +/z +/dotlessi +/dotlessj +/weierstrass +/vector +/tie + +% Have to have 128 .notdef's now to fill things out. +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/texmsym.enc b/dviware/mdvi/data/texmsym.enc new file mode 100644 index 0000000000..26fe7cd6c3 --- /dev/null +++ b/dviware/mdvi/data/texmsym.enc @@ -0,0 +1,183 @@ +% TeX math symbols encoding. +% No ligatures or kerns. +% +/TeXMathSymbolEncoding [ % now 256 chars follow +% 0x0 +/minus +/periodcentered +/multiply +/asteriskmath +/divide +/diamondmath +/plusminus +/minusplus + +% 0x8 +/circleplus +/circleminus +/circlemultiply +/circledivide +/circledot +/circlecopyrt +/openbullet +/bullet + +% 0x10 +/equivasymptotic +/equivalence +/reflexsubset +/reflexsuperset +/lessequal +/greaterequal +/precedesequal +/followsequal + +% 0x18 +/similar +/approxequal +/propersubset +/propersuperset +/lessmuch +/greatermuch +/precedes +/follows + +% 0x20 +/arrowleft +/arrowright +/arrowup +/arrowdown +/arrowboth +/arrownortheast +/arrowsoutheast +/similarequal + +% 0x28 +/arrowdblleft +/arrowdblright +/arrowdblup +/arrowdbldown +/arrowdblboth +/arrownorthwest +/arrowsouthwest +/proportional + +% 0x30 +/prime +/infinity +/element +/owner +/triangle +/triangleinv +/negationslash +/mapsto + +% 0x38 +/universal +/existential +/logicalnot +/emptyset +/Rfractur +/Ifractur +/latticetop +/perpendicular + +% 0x40 +/aleph +/A +/B +/C +/D +/E +/F +/G + +% 0x48 +/H +/I +/J +/K +/L +/M +/N +/O + +% 0x50 +/P +/Q +/R +/S +/T +/U +/V +/W + +% 0x58 +/X +/Y +/Z +/union +/intersection +/unionmulti +/logicaland +/logicalor + +% 0x60 +/turnstileleft +/turnstileright +/floorleft +/floorright +/ceilingleft +/ceilingright +/braceleft +/braceright + +% 0x68 +/angbracketleft +/angbracketright +/bar +/bardbl +/arrowbothv +/arrowdblbothv +/backslash +/wreathproduct + +% 0x70 +/radical +/coproduct +/nabla +/integral +/unionsq +/intersectionsq +/subsetsqequal +/supersetsqequal + +% 0x78 +/section +/dagger +/daggerdbl +/paragraph +/club +/diamond +/heart +/spade + +% Have to have 128 .notdef's now to fill things out. +% +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef +] def diff --git a/dviware/mdvi/data/texnansi.enc b/dviware/mdvi/data/texnansi.enc new file mode 100644 index 0000000000..f04715707e --- /dev/null +++ b/dviware/mdvi/data/texnansi.enc @@ -0,0 +1,314 @@ +% @psencodingfile{ +% author = "Y&Y, Inc.", +% version = "1.1", +% date = "1 December 1996", +% filename = "texnansi.enc", +% email = "help@YandY.com", +% address = "45 Walden Street // Concord, MA 01742, USA", +% codetable = "ISO/ASCII", +% checksum = "xx", +% docstring = "Encoding for fonts in Adobe Type 1 format for use with TeX." +% } +% +% The idea is to have all 228 characters normally included in Type 1 text +% fonts (plus a few more) available for typesetting. This is effectively +% the character set in Adobe Standard Encoding, ISO Latin 1, plus a few more. +% +% Character code assignments were made as follows: +% +% (1) The character layout largely matches `ASCII' in the 32 -- 126 range, +% except for `circumflex' in 94 and `tilde' in 126, to match `TeX text' +% (`asciicircumflex' and `asciitilde' appear in 158 and 142 instead). +% +% (2) The character layout matches `Windows ANSI' in almost all places, +% except for `quoteright' in 39 and `quoteleft' in 96 to match ASCII +% (`quotesingle' and `grave' appear in 129 and 18 instead). +% +% (3) The character layout matches `TeX typewriter' used by CM text fonts +% in most places (except for discordant positions such as hungarumlaut +% (instead of braceright), dotaccent (instead of underscore) etc. +% +% (4) Remaining characters are assigned arbitrarily to the `control character' +% range (0 -- 31), avoiding 0, 9, 10 and 13 in case we meet dumb software +% - similarly one should really avoid 127 and 128 if possible. +% In addition, the 8 open slots in Windows ANSI between 128 and 159 are used. +% +% (5) Y&Y Lucida Bright includes some extra ligatures and such; ff, ffi, ffl, +% and `dotlessj,' these are included 11 -- 15, and 17. +% +% (6) Hyphen appears both at 45 and 173 for compatibility with both ASCII +% and Windows ANSI. +% +% (7) It doesn't really matter where ligatures appear (both real, such as ffi, +% and pseudo such as ---) since these should not be accessed directly, only +% via ligature information in the TFM file. +% +% SAMPLE USAGE (in `psfonts.map' file for DVIPS): +% +% lbr LucidaBright "TeXnANSIEncoding ReEncodeFont" <texnansi.enc <lbr.pfb +% +% This tells DVIPS that the font called `lbr' in TeX has PostScript +% FontName `LucidaBright.' It also asks DVIPS to expand the file `lbr.pfb' +% into PFA form, to include the attached `texnansi.enc' encoding vector, +% and to then actually reencode the font based on that encoding vector. +% +% Revised 1996 June 1 by adding second position for `fl' to avoid Acrobat bug. +% Revised 1996 June 1 by adding second position for `fraction' for same reason. +% +Encoding=TeXnANSIEncoding +.notdef % 0 +uni20AC % 1 +.notdef % 2 +.notdef % 3 +fraction % 4 +dotaccent % 5 +hungarumlaut % 6 +ogonek % 7 +fl % 8 +.notdef % /fraction % 9 not used (see 4), backward compatability only +cwm % 10 not used, except boundary char internally maybe +ff % 11 +fi % 12 +.notdef % fl % 13 not used (see 8), backward compatability only +ffi % 14 +ffl % 15 +dotlessi % 16 +dotlessj % 17 +grave % 18 +acute % 19 +caron % 20 +breve % 21 +macron % 22 +ring % 23 +cedilla % 24 +germandbls % 25 +ae % 26 +oe % 27 +oslash % 28 +AE % 29 +OE % 30 +Oslash % 31 +space % 32 % /suppress in TeX text +exclam % 33 +quotedbl % 34 % /quotedblright in TeX text +numbersign % 35 +dollar % 36 +percent % 37 +ampersand % 38 +quoteright % 39 % /quotesingle in ANSI +parenleft % 40 +parenright % 41 +asterisk % 42 +plus % 43 +comma % 44 +hyphen % 45 +period % 46 +slash % 47 +zero % 48 +one % 49 +two % 50 +three % 51 +four % 52 +five % 53 +six % 54 +seven % 55 +eight % 56 +nine % 57 +colon % 58 +semicolon % 59 +less % 60 % /exclamdown in TeX text +equal % 61 +greater % 62 % /questiondown in TeX text +question % 63 +at % 64 +A % 65 +B % 66 +C % 67 +D % 68 +E % 69 +F % 70 +G % 71 +H % 72 +I % 73 +J % 74 +K % 75 +L % 76 +M % 77 +N % 78 +O % 79 +P % 80 +Q % 81 +R % 82 +S % 83 +T % 84 +U % 85 +V % 86 +W % 87 +X % 88 +Y % 89 +Z % 90 +bracketleft % 91 +backslash % 92 % /quotedblleft in TeX text +bracketright % 93 +circumflex % 94 % /asciicircum in ASCII +underscore % 95 % /dotaccent in TeX text +quoteleft % 96 % /grave accent in ANSI +a % 97 +b % 98 +c % 99 +d % 100 +e % 101 +f % 102 +g % 103 +h % 104 +i % 105 +j % 106 +k % 107 +l % 108 +m % 109 +n % 110 +o % 111 +p % 112 +q % 113 +r % 114 +s % 115 +t % 116 +u % 117 +v % 118 +w % 119 +x % 120 +y % 121 +z % 122 +braceleft % 123 % /endash in TeX text +bar % 124 % /emdash in TeX test +braceright % 125 % /hungarumlaut in TeX text +tilde % 126 % /asciitilde in ASCII +dieresis % 127 not used (see 168), use higher up instead +/Lslash % 128 this position is unfortunate, but now too late to fix +quotesingle % 129 +/quotesinglbase % 130 +florin % 131 +quotedblbase % 132 +ellipsis % 133 +dagger % 134 +daggerdbl % 135 +circumflex % 136 +perthousand % 137 +Scaron % 138 +guilsinglleft % 139 +OE % 140 +Zcaron % 141 +asciicircum % 142 +minus % 143 +lslash % 144 +quoteleft % 145 +quoteright % 146 +quotedblleft % 147 +quotedblright % 148 +bullet % 149 +endash % 150 +emdash % 151 +tilde % 152 +trademark % 153 +scaron % 154 +guilsinglright % 155 +oe % 156 +zcaron % 157 +asciitilde % 158 +Ydieresis % 159 +nbspace % 160 % /space (no break space) +exclamdown % 161 +cent % 162 +sterling % 163 +currency % 164 +yen % 165 +brokenbar % 166 +section % 167 +dieresis % 168 +copyright % 169 +ordfeminine % 170 +guillemotleft % 171 +logicalnot % 172 +sfthyphen % 173 % /hyphen (hanging hyphen) +registered % 174 +macron % 175 +degree % 176 +plusminus % 177 +twosuperior % 178 +threesuperior % 179 +acute % 180 +mu % 181 +paragraph % 182 +periodcentered %183 +cedilla % 184 +onesuperior % 185 +ordmasculine % 186 +guillemotright %187 +onequarter % 188 +onehalf % 189 +threequarters % 190 +questiondown % 191 +Agrave % 192 +Aacute % 193 +Acircumflex % 194 +Atilde % 195 +Adieresis % 196 +Aring % 197 +AE % 198 +Ccedilla % 199 +Egrave % 200 +Eacute % 201 +Ecircumflex % 202 +Edieresis % 203 +Igrave % 204 +Iacute % 205 +Icircumflex % 206 +Idieresis % 207 +Eth % 208 +Ntilde % 209 +Ograve % 210 +Oacute % 211 +Ocircumflex % 212 +Otilde % 213 +Odieresis % 214 +multiply % 215 % OE in T1 +Oslash % 216 +Ugrave % 217 +Uacute % 218 +Ucircumflex % 219 +Udieresis % 220 +Yacute % 221 +Thorn % 222 +germandbls % 223 % SS in T1 +agrave % 224 +aacute % 225 +acircumflex % 226 +atilde % 227 +adieresis % 228 +aring % 229 +ae % 230 +ccedilla % 231 +egrave % 232 +eacute % 233 +ecircumflex % 234 +edieresis % 235 +igrave % 236 +iacute % 237 +icircumflex % 238 +idieresis % 239 +eth % 240 +ntilde % 241 +ograve % 242 +oacute % 243 +ocircumflex % 244 +otilde % 245 +odieresis % 246 +divide % 247 % oe in T1 +oslash % 248 +ugrave % 249 +uacute % 250 +ucircumflex % 251 +udieresis % 252 +yacute % 253 +thorn % 254 +ydieresis % 255 % germandbls in T1 diff --git a/dviware/mdvi/data/xl2.enc b/dviware/mdvi/data/xl2.enc new file mode 100644 index 0000000000..6e603ea099 --- /dev/null +++ b/dviware/mdvi/data/xl2.enc @@ -0,0 +1,316 @@ +% Date: Thu, 25 May 1995 19:00:36 +0200 (MET DST) +% From: Petr Sojka <sojka@daeron.ics.muni.cz> +% +% some of our (CSTUG- czech TeX Users Group) users want to support +% 8bit font coding such that: +% -- lower 7bit is exactly OT1 (but with differences imposed +% by DEK -- e.g. layout of cmr is different from cmtt) +% -- upper part is taken from ISO-Latin 2 (iso 8859-2), +% but some of empty positions are filled with useful characters +% usually available in type-1 font (permill sign etc.) +/XL2encoding [ +%%%%% '000 = "00 + /Gamma + /Delta + /Theta + /Lambda + /Xi + /Pi + /Sigma + /Upsilon +%%%%% '010 = "08 + /Phi + /Psi + /Omega + /ff + /fi + /fl + /ffi + /ffl +%%%%% '020 = "10 + /dotlessi + /dotlessj + /grave + /acute + /caron + /breve + /macron + /ring +%%%%% '030 = "18 + /cedilla + /germandbls + /ae + /oe + /oslash + /AE + /OE + /Oslash +%%%%% '040 = "20 + /.notdef + /exclam + /quotedblright + /numbersign + /dollar + /percent + /ampersand + /quoteright +%%%%% '050 = "28 + /parenleft + /parenright + /asterisk + /plus + /comma + /hyphen + /period + /slash +%%%%% '060 = "30 + /zero + /one + /two + /three + /four + /five + /six + /seven +%%%%% '070 = "38 + /eight + /nine + /colon + /semicolon + /exclamdown + /equal + /questiondown + /question +%%%%% '100 = "40 + /at + /A + /B + /C + /D + /E + /F + /G +%%%%% '110 = "48 + /H + /I + /J + /K + /L + /M + /N + /O +%%%%% '120 = "50 + /P + /Q + /R + /S + /T + /U + /V + /W +%%%%% '130 = "58 + /X + /Y + /Z + /bracketleft + /quotedblleft + /bracketright + /circumflex + /dotaccent +%%%%% '140 = "60 + /quoteleft + /a + /b + /c + /d + /e + /f + /g +%%%%% '150 = "68 + /h + /i + /j + /k + /l + /m + /n + /o +%%%%% '160 = "70 + /p + /q + /r + /s + /t + /u + /v + /w +%%%%% '170 = "78 + /x + /y + /z + /endash + /emdash + /hungarumlaut + /tilde + /dieresis +%%%%% '200 = "80 + /ellipsis + /dagger + /daggerdbl + /bullet + /sterling + /paragraph + /.notdef + /.notdef +%%%%% '210 = "88 + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /perthousand + /.notdef + /.notdef +%%%%% '220 = "90 + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef +%%%%% '230 = "98 + /Agrave + /.notdef + /.notdef + /.notdef + /hyphen + /ogonek + /guillemotleft + /guillemotright +%%%%% '240 = "A0 + /.notdef + /Aogonek + /breve + /Lslash + /currency + /Lcaron + /Sacute + /section +%%%%% '250 = "A8 + /dieresis + /Scaron + /Scedilla + /Tcaron + /Zacute + /.notdef + /Zcaron + /Zdotaccent +%%%%% '260 = "B0 + /ring + /aogonek + /cedilla + /lslash + /acute + /lcaron + /sacute + /caron +%%%%% '270 = "B8 + /agrave + /scaron + /scedilla + /tcaron + /zacute + /hungarumlaut + /zcaron + /zdotaccent +%%%%% '300 = "C0 + /Racute + /Aacute + /Acircumflex + /Abreve + /Adieresis + /Lacute + /Cacute + /Ccedilla +%%%%% '310 = "C8 + /Ccaron + /Eacute + /Eogonek + /Edieresis + /Ecaron + /Iacute + /Icircumflex + /Dcaron +%%%%% '320 = "D0 + /Eth + /Nacute + /Ncaron + /Oacute + /Ocircumflex + /Ohungarumlaut + /Odieresis + /multiply +%%%%% '330 = "D8 + /Rcaron + /Uring + /Uacute + /Uhungarumlaut + /Udieresis + /Yacute + /Togonek + /germandbls +%%%%% '340 = "E0 + /racute + /aacute + /acircumflex + /abreve + /adieresis + /lacute + /cacute + /ccedilla +%%%%% '350 = "E8 + /ccaron + /eacute + /eogonek + /edieresis + /ecaron + /iacute + /icircumflex + /dcaron +%%%%% '360 = "F0 + /eth + /nacute + /ncaron + /oacute + /ocircumflex + /ohungarumlaut + /odieresis + /divide +%%%%% '370 = "F8 + /rcaron + /uring + /uacute + /uhungarumlaut + /udieresis + /yacute + /quotedblbase + /quotedblleft +] def + +% LIGKERN hyphen hyphen =: endash ; endash hyphen =: emdash ; +% LIGKERN quoteleft quoteleft =: quotedblleft ; +% LIGKERN quoteright quoteright =: quotedblright ; +% LIGKERN exclamdown exclamdown =: guillemotleft ; +% frenchdblquotes +% LIGKERN questiondown questiondown =: guillemotright ; +% csquoteleft +% LIGKERN comma comma =: quotedblbase ; +% LIGKERN space {} * ; * {} space ; zero {} * ; * {} zero ; +% LIGKERN one {} * ; * {} one ; two {} * ; * {} two ; +% LIGKERN three {} * ; * {} three ; four {} * ; * {} four ; +% LIGKERN five {} * ; * {} five ; six {} * ; * {} six ; +% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ; +% LIGKERN nine {} * ; * {} nine ; +% LIGKERN question {} quoteleft ; exclam {} quoteleft ; diff --git a/dviware/mdvi/data/xt2.enc b/dviware/mdvi/data/xt2.enc new file mode 100644 index 0000000000..d2725cda6f --- /dev/null +++ b/dviware/mdvi/data/xt2.enc @@ -0,0 +1,307 @@ +% This is the typewriter version of xl2. +/XT2encoding [ +%%%%% '000 = "00 + /Gamma + /Delta + /Theta + /Lambda + /Xi + /Pi + /Sigma + /Upsilon +%%%%% '010 = "08 + /Phi + /Psi + /Omega + /arrowup + /arrowdown + /qoutesingle + /exclamdown + /questiondown +%%%%% '020 = "10 + /dotlessi + /dotlessj + /grave + /acute + /caron + /breve + /macron + /ring +%%%%% '030 = "18 + /cedilla + /germandbls + /ae + /oe + /oslash + /AE + /OE + /Oslash +%%%%% '040 = "20 + /.notdef + /exclam + /quotedblright + /numbersign + /dollar + /percent + /ampersand + /quoteright +%%%%% '050 = "28 + /parenleft + /parenright + /asterisk + /plus + /comma + /hyphen + /period + /slash +%%%%% '060 = "30 + /zero + /one + /two + /three + /four + /five + /six + /seven +%%%%% '070 = "38 + /eight + /nine + /colon + /semicolon + /less + /equal + /greater + /question +%%%%% '100 = "40 + /at + /A + /B + /C + /D + /E + /F + /G +%%%%% '110 = "48 + /H + /I + /J + /K + /L + /M + /N + /O +%%%%% '120 = "50 + /P + /Q + /R + /S + /T + /U + /V + /W +%%%%% '130 = "58 + /X + /Y + /Z + /bracketleft + /backslash + /bracketright + /circumflex + /underscore +%%%%% '140 = "60 + /quoteleft + /a + /b + /c + /d + /e + /f + /g +%%%%% '150 = "68 + /h + /i + /j + /k + /l + /m + /n + /o +%%%%% '160 = "70 + /p + /q + /r + /s + /t + /u + /v + /w +%%%%% '170 = "78 + /x + /y + /z + /braceleft + /bar + /braceright + /tilde + /dieresis +%%%%% '200 = "80 + /ellipsis + /dagger + /daggerdbl + /bullet + /sterling + /paragraph + /.notdef + /.notdef +%%%%% '210 = "88 + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /perthousand + /.notdef + /.notdef +%%%%% '220 = "90 + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef + /.notdef +%%%%% '230 = "98 + /Agrave + /.notdef + /.notdef + /.notdef + /hyphen + /ogonek + /guillemotleft + /guillemotright +%%%%% '240 = "A0 + /.notdef + /Aogonek + /breve + /Lslash + /currency + /Lcaron + /Sacute + /section +%%%%% '250 = "A8 + /dieresis + /Scaron + /Scedilla + /Tcaron + /Zacute + /.notdef + /Zcaron + /Zdotaccent +%%%%% '260 = "B0 + /ring + /aogonek + /cedilla + /lslash + /acute + /lcaron + /sacute + /caron +%%%%% '270 = "B8 + /agrave + /scaron + /scedilla + /tcaron + /zacute + /hungarumlaut + /zcaron + /zdotaccent +%%%%% '300 = "C0 + /Racute + /Aacute + /Acircumflex + /Abreve + /Adieresis + /Lacute + /Cacute + /Ccedilla +%%%%% '310 = "C8 + /Ccaron + /Eacute + /Eogonek + /Edieresis + /Ecaron + /Iacute + /Icircumflex + /Dcaron +%%%%% '320 = "D0 + /Eth + /Nacute + /Ncaron + /Oacute + /Ocircumflex + /Ohungarumlaut + /Odieresis + /multiply +%%%%% '330 = "D8 + /Rcaron + /Uring + /Uacute + /Uhungarumlaut + /Udieresis + /Yacute + /Togonek + /germandbls +%%%%% '340 = "E0 + /racute + /aacute + /acircumflex + /abreve + /adieresis + /lacute + /cacute + /ccedilla +%%%%% '350 = "E8 + /ccaron + /eacute + /eogonek + /edieresis + /ecaron + /iacute + /icircumflex + /dcaron +%%%%% '360 = "F0 + /eth + /nacute + /ncaron + /oacute + /ocircumflex + /ohungarumlaut + /odieresis + /divide +%%%%% '370 = "F8 + /rcaron + /uring + /uacute + /uhungarumlaut + /udieresis + /yacute + /quotedblbase + /quotedblleft +] def + +% LIGKERN quoteleft quoteleft =: quotedblleft ; +% LIGKERN quoteright quoteright =: quotedblright ; +% LIGKERN exclamdown exclamdown =: guillemotleft ; +% frenchdblquotes +% LIGKERN questiondown questiondown =: guillemotright ; +% csquoteleft +% LIGKERN comma comma =: quotedblbase ; +% LIGKERN space {} * ; * {} space ; zero {} * ; * {} zero ; +% LIGKERN one {} * ; * {} one ; two {} * ; * {} two ; +% LIGKERN three {} * ; * {} three ; four {} * ; * {} four ; +% LIGKERN five {} * ; * {} five ; six {} * ; * {} six ; +% LIGKERN seven {} * ; * {} seven ; eight {} * ; * {} eight ; +% LIGKERN nine {} * ; * {} nine ; +% LIGKERN question {} quoteleft ; exclam {} quoteleft ; +% LIGKERN f {} f ; f {} i ; f {} l ; diff --git a/dviware/mdvi/include/CVS/Entries b/dviware/mdvi/include/CVS/Entries new file mode 100644 index 0000000000..f0d8adc4b6 --- /dev/null +++ b/dviware/mdvi/include/CVS/Entries @@ -0,0 +1,9 @@ +/bitmap.h/1.1.1.1/Tue Mar 20 09:25:34 2001// +/common.h/1.1.1.1/Tue Mar 20 09:25:34 2001// +/defaults.h/1.1.1.1/Tue Mar 20 09:25:35 2001// +/dviopcodes.h/1.1.1.1/Tue Mar 20 09:25:35 2001// +/fontmap.h/1.1.1.1/Tue Mar 20 09:25:35 2001// +/mdvi.h/1.1.1.1/Tue Mar 20 09:25:37 2001// +/private.h/1.1.1.1/Tue Mar 20 09:25:33 2001// +/sysdeps.h/1.1.1.1/Tue Mar 20 09:25:37 2001// +D diff --git a/dviware/mdvi/include/CVS/Repository b/dviware/mdvi/include/CVS/Repository new file mode 100644 index 0000000000..4d7fd951c0 --- /dev/null +++ b/dviware/mdvi/include/CVS/Repository @@ -0,0 +1 @@ +mdvi/include diff --git a/dviware/mdvi/include/CVS/Root b/dviware/mdvi/include/CVS/Root new file mode 100644 index 0000000000..164e86eed7 --- /dev/null +++ b/dviware/mdvi/include/CVS/Root @@ -0,0 +1 @@ +agiacom@cvs.mdvi.sourceforge.net:/cvsroot/mdvi diff --git a/dviware/mdvi/include/bitmap.h b/dviware/mdvi/include/bitmap.h new file mode 100644 index 0000000000..4d5f23ace9 --- /dev/null +++ b/dviware/mdvi/include/bitmap.h @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _BITMAP_H +#define _BITMAP_H 1 + +#include "sysdeps.h" + +/* Structures and functions to manipulate bitmaps */ + +/* bitmap unit (as in X's docs) */ +typedef Uint32 BmUnit; + +/* size (in bytes) of a bitmap atom */ +#define BITMAP_BYTES 4 + +/* size (in bits) of a bitmap atom */ +#define BITMAP_BITS (BITMAP_BYTES << 3) + +typedef struct { + int width; + int height; + int stride; + BmUnit *data; +} BITMAP; + +#define BM_BYTES_PER_LINE(b) \ + (ROUND((b)->width, BITMAP_BITS) * BITMAP_BYTES) +#define BM_WIDTH(b) (((BITMAP *)(b))->width) +#define BM_HEIGHT(b) (((BITMAP *)(b))->height) + +#define BMBIT(n) ((BmUnit)1 << (n)) + +/* Macros to manipulate individual pixels in a bitmap + * (they are slow, don't use them) + */ + +#define bm_offset(b,o) (BmUnit *)((Uchar *)(b) + (o)) + +#define __bm_unit_ptr(b,x,y) \ + bm_offset((b)->data, (y) * (b)->stride + \ + ((x) / BITMAP_BITS) * BITMAP_BYTES) + +#define __bm_unit(b,x,y) __bm_unit_ptr((b), (x), (y))[0] + +#define BM_GETPIXEL(b,x,y) __bm_unit((b), (x), (y)) +#define BM_SETPIXEL(b,x,y) (__bm_unit((b), (x), (y)) |= FIRSTMASKAT(x)) +#define BM_CLRPIXEL(b,x,y) (__bm_unit((b), (x), (y)) &= ~FIRSTMASKAT(x)) + +/* + * These macros are used to access pixels in a bitmap. They are supposed + * to be used like this: + */ +#if 0 + BmUnit *row, mask; + + mask = FIRSTMASK; + + /* position `unit' at coordinates (column_number, row_number) */ + unit = (BmUnit *)((char *)bitmap->data + row_number * bitmap->stride + + (column_number / BITMAP_BITS); + /* loop over all pixels IN THE SAME ROW */ + for(i = 0; i < number_of_pixels; i++) { + /* to test if a pixel is set */ + if(*unit & mask) { + /* yes, it is, do something with it */ + } + /* to set/clear a pixel */ + if(painting) + *unit |= mask; /* now you see it */ + else + *unit &= ~mask; /* now you don't */ + /* move to next pixel */ + if(mask == LASTMASK) { + unit++; + UPDATEMASK(mask); + } + } +/* end of sample code */ +#endif + +/* bitmaps are stored in native byte order */ +#ifdef WORD_BIG_ENDIAN +#define FIRSTSHIFT (BITMAP_BITS - 1) +#define LASTSHIFT 0 +#define NEXTMASK(m) ((m) >>= 1) +#define PREVMASK(m) ((m) <<= 1) +#define FIRSTSHIFTAT(c) (BITMAP_BITS - ((c) % BITMAP_BITS) - 1) +#else +#define FIRSTSHIFT 0 +#define LASTSHIFT (BITMAP_BITS - 1) +#define NEXTMASK(m) ((m) <<= 1) +#define PREVMASK(m) ((m) >>= 1) +#define FIRSTSHIFTAT(c) ((c) % BITMAP_BITS) +#endif + +#define FIRSTMASK BMBIT(FIRSTSHIFT) +#define FIRSTMASKAT(c) BMBIT(FIRSTSHIFTAT(c)) +#define LASTMASK BMBIT(LASTSHIFT) + +extern BITMAP *bitmap_alloc __PROTO((int, int)); +extern BITMAP *bitmap_alloc_raw __PROTO((int, int)); +extern void bitmap_destroy __PROTO((BITMAP *)); + +/* + * set_row(bm, row, col, count, state): + * sets `count' pixels to state `onoff', starting from pixel + * at position (col, row). All pixels must lie in the same + * row. + */ +extern void bitmap_set_col __PROTO((BITMAP *, int, int, int, int)); +extern void bitmap_set_row __PROTO((BITMAP *, int, int, int, int)); + +extern void bitmap_paint_bits __PROTO((BmUnit *, int, int)); +extern void bitmap_clear_bits __PROTO((BmUnit *, int, int)); + +extern BITMAP *bitmap_copy __PROTO((BITMAP *)); +extern void bitmap_flip_horizontally __PROTO((BITMAP *)); +extern void bitmap_flip_vertically __PROTO((BITMAP *)); +extern void bitmap_flip_diagonally __PROTO((BITMAP *)); +extern void bitmap_rotate_clockwise __PROTO((BITMAP *)); +extern void bitmap_rotate_counter_clockwise __PROTO((BITMAP *)); +extern void bitmap_flip_rotate_clockwise __PROTO((BITMAP *)); +extern void bitmap_flip_rotate_counter_clockwise __PROTO((BITMAP *)); +extern BITMAP *bitmap_convert_lsb8 __PROTO((Uchar *, int, int)); +extern BITMAP *bitmap_convert_msb8 __PROTO((Uchar *, int, int)); + +#include <stdio.h> +extern void bitmap_print __PROTO((FILE *, BITMAP *)); + +#endif /* _BITMAP_H */ diff --git a/dviware/mdvi/include/common.h b/dviware/mdvi/include/common.h new file mode 100644 index 0000000000..67130feb75 --- /dev/null +++ b/dviware/mdvi/include/common.h @@ -0,0 +1,289 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _MDVI_COMMON_H +#define _MDVI_COMMON_H 1 + +#include <stdio.h> +#include <sys/types.h> +#include <math.h> + +#include "sysdeps.h" + +#if STDC_HEADERS +# include <string.h> +#endif + +#if !defined(STDC_HEADERS) || defined(__STRICT_ANSI__) +# ifndef HAVE_STRCHR +# define strchr index +# define strrchr rindex +# endif +# ifndef HAVE_MEMCPY +# define memcpy(a,b,n) bcopy((b), (a), (n)) +# define memmove(a,b,n) bcopy((b), (a), (n)) +# endif +#endif + +#ifdef HAVE_MEMCPY +#define memzero(a,n) memset((a), 0, (n)) +#else +#define memzero(a,n) bzero((a), (n)) +#endif + +typedef struct _List { + struct _List *next; + struct _List *prev; +} List; +#define LIST(x) ((List *)(x)) + +typedef struct { + char *data; + size_t size; + size_t length; +} Buffer; + +typedef struct { + List *head; + List *tail; + int count; +} ListHead; +#define MDVI_EMPTY_LIST_HEAD {NULL, NULL, 0} + +typedef struct { + char *data; + size_t size; + size_t length; +} Dstring; + +/* Functions to read numbers from streams and memory */ + +#define fgetbyte(p) ((unsigned)getc(p)) + +extern char *program_name; + +extern Ulong fugetn __PROTO((FILE *, size_t)); +extern long fsgetn __PROTO((FILE *, size_t)); +extern Ulong mugetn __PROTO((const Uchar *, size_t)); +extern long msgetn __PROTO((const Uchar *, size_t)); + +/* To read from a stream (fu: unsigned, fs: signed) */ +#define fuget4(p) fugetn((p), 4) +#define fuget3(p) fugetn((p), 3) +#define fuget2(p) fugetn((p), 2) +#define fuget1(p) fgetbyte(p) +#define fsget4(p) fsgetn((p), 4) +#define fsget3(p) fsgetn((p), 3) +#define fsget2(p) fsgetn((p), 2) +#define fsget1(p) fsgetn((p), 1) + +/* To read from memory (mu: unsigned, ms: signed) */ +#define MUGETN(p,n) ((p) += (n), mugetn((p)-(n), (n))) +#define MSGETN(p,n) ((p) += (n), msgetn((p)-(n), (n))) +#define muget4(p) MUGETN((p), 4) +#define muget3(p) MUGETN((p), 3) +#define muget2(p) MUGETN((p), 2) +#define muget1(p) MUGETN((p), 1) +#define msget4(p) MSGETN((p), 4) +#define msget3(p) MSGETN((p), 3) +#define msget2(p) MSGETN((p), 2) +#define msget1(p) MSGETN((p), 1) + +#define ROUND(x,y) (((x) + (y) - 1) / (y)) +#define FROUND(x) (int)((x) + 0.5) +#define SFROUND(x) (int)((x) >= 0 ? floor((x) + 0.5) : ceil((x) + 0.5)) + +#define Max(a,b) (((a) > (b)) ? (a) : (b)) +#define Min(a,b) (((a) < (b)) ? (a) : (b)) + +/* make 2byte number from 2 8bit quantities */ +#define HALFWORD(a,b) ((((a) << 8) & 0xf) | (b)) +#define FULLWORD(a,b,c,d) \ + ((((Int8)(a) << 24) & 0xff000000) | \ + (((Uint8)(b) << 16) & 0x00ff0000) | \ + (((Uint8)(c) << 8) & 0x0000ff00) | \ + ((Uint8)(d) & 0xff)) + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#define SWAPINT(a,b) \ + ({ int _s = a; a = b; b = _s; }) +#else +#define SWAPINT(a,b) do { int _s = a; a = b; b = _s; } while(0) +#endif + +#define STREQ(a,b) (strcmp((a), (b)) == 0) +#define STRNEQ(a,b,n) (strncmp((a), (b), (n)) == 0) +#define STRCEQ(a,b) (strcasecmp((a), (b)) == 0) +#define STRNCEQ(a,b,n) (strncasecmp((a), (b), (n)) == 0) + +extern char *read_string __PROTO((FILE *, int, char *, size_t)); +extern size_t read_bcpl __PROTO((FILE *, char *, size_t, size_t)); +extern char *read_alloc_bcpl __PROTO((FILE *, size_t, size_t *)); + +/* miscellaneous */ + +extern void message __PROTO((const char *, ...)); +extern void crash __PROTO((const char *, ...)); +extern void fatal __PROTO((const char *, ...)); +extern void error __PROTO((const char *, ...)); +extern void warning __PROTO((const char *, ...)); +extern int unit2pix __PROTO((int, const char *)); +extern double unit2pix_factor __PROTO((const char *)); + +#define LOG_NONE -1 +#define LOG_INFO 0 +#define LOG_WARN 1 +#define LOG_ERROR 2 +#define LOG_DEBUG 3 + +#define DBG_OPCODE (1 << 0) +#define DBG_FONTS (1 << 1) +#define DBG_FILES (1 << 2) +#define DBG_DVI (1 << 3) +#define DBG_PARAMS (1 << 4) +#define DBG_SPECIAL (1 << 5) +#define DBG_DEVICE (1 << 6) +#define DBG_GLYPHS (1 << 7) +#define DBG_BITMAPS (1 << 8) +#define DBG_PATHS (1 << 9) +#define DBG_SEARCH (1 << 10) +#define DBG_VARS (1 << 11) +#define DBG_BITMAP_OPS (1 << 12) +#define DBG_BITMAP_DATA (1 << 13) +#define DBG_TYPE1 (1 << 14) +#define DBG_TT (1 << 15) +#define DBG_FT2 (1 << 16) +#define DBG_FMAP (1 << 17) + +#define DBG_SILENT (1 << 31) + +#ifdef NODEBUG +#define DEBUGGING(x) 0 +#else +#define DEBUGGING(x) (_mdvi_debug_mask & DBG_##x) +#endif + +#ifndef NODEBUG +extern Uint32 _mdvi_debug_mask; +extern void __debug __PROTO((int, const char *, ...)); +#define DEBUG(x) __debug x +#define ASSERT(x) do { \ + if(!(x)) crash("%s:%d: Assertion %s failed\n", \ + __FILE__, __LINE__, #x); \ + } while(0) +#define ASSERT_VALUE(x,y) do { \ + if((x) != (y)) \ + crash("%s:%d: Assertion failed (%d = %s != %s)\n", \ + __FILE__, __LINE__, (x), #x, #x); \ + } while(0) +#else +#define DEBUG(x) do { } while(0) +#define ASSERT(x) do { } while(0) +#define ASSERT_VALUE(x,y) do { } while(0) +#endif + +#define set_debug_mask(m) (_mdvi_debug_mask = (Uint32)(m)) +#define add_debug_mask(m) (_mdvi_debug_mask |= (Uint32)(m)) +#define get_debug_mask() _mdvi_debug_mask + +/* memory allocation */ + +extern void xfree __PROTO((void *)); +extern void *xmalloc __PROTO((size_t)); +extern void *xrealloc __PROTO((void *, size_t)); +extern void *xcalloc __PROTO((size_t, size_t)); +extern char *xstrncpy __PROTO((char *, const char *, size_t)); +extern char *xstrdup __PROTO((const char *)); +extern char *xstrndup __PROTO((const char *, size_t)); +extern void *xmemdup __PROTO((const void *, size_t)); + +/* macros to make memory allocation nicer */ +#define xalloc(t) (t *)xmalloc(sizeof(t)) +#define xnalloc(t,n) (t *)xcalloc((n), sizeof(t)) +#define xresize(p,t,n) (t *)xrealloc((p), (n) * sizeof(t)) + +extern int get_number __PROTO((const char *, long *)); +/* return paper dimensions (in cm) */ +extern int paper_dimensions __PROTO((const char *, double *, double *)); + +extern char *xstradd __PROTO((char *, size_t *, size_t, const char *, size_t)); + +extern Ulong get_mtime __PROTO((int)); + +/* lists */ +extern void listh_init __PROTO((ListHead *)); +extern void listh_prepend __PROTO((ListHead *, List *)); +extern void listh_append __PROTO((ListHead *, List *)); +extern void listh_add_before __PROTO((ListHead *, List *, List *)); +extern void listh_add_after __PROTO((ListHead *, List *, List *)); +extern void listh_remove __PROTO((ListHead *, List *)); +extern void listh_concat __PROTO((ListHead *, ListHead *)); +extern void listh_catcon __PROTO((ListHead *, ListHead *)); + +extern void buff_init __PROTO((Buffer *)); +extern size_t buff_add __PROTO((Buffer *, const char *, size_t)); +extern char *buff_gets __PROTO((Buffer *, size_t *)); +extern void buff_free __PROTO((Buffer *)); + +extern char *getword __PROTO((char *, const char *, char **)); +extern char *getstring __PROTO((char *, const char *, char **)); + +extern void dstring_init __PROTO((Dstring *)); +extern int dstring_new __PROTO((Dstring *, const char *, int)); +extern int dstring_append __PROTO((Dstring *, const char *, int)); +extern int dstring_copy __PROTO((Dstring *, int, const char *, int)); +extern int dstring_insert __PROTO((Dstring *, int, const char *, int)); +extern void dstring_reset __PROTO((Dstring *)); + +#define dstring_length(d) ((d)->length) +#define dstring_strcat(d,s) dstring_append((d), (s), -1) + +extern char *dgets __PROTO((Dstring *, FILE *)); +extern int file_readable __PROTO((const char *)); +extern int file_exists __PROTO((const char *)); +extern char *find_in_path __PROTO((const char *path, const char *file)); +extern const char *file_basename __PROTO((const char *)); +extern const char *file_extension __PROTO((const char *)); +extern char *read_into_core __PROTO((const char *, size_t *)); + +/* + * Miscellaneous macros + */ + +#define LIST_FOREACH(ptr, type, list) \ + for(ptr = (type *)(list)->head; ptr; ptr = (ptr)->next) + +#define Size(x) (sizeof(x) / sizeof((x)[0])) + +/* multiply a fix_word by a 32bit number */ +#define B0(x) ((x) & 0xff) +#define B1(x) B0((x) >> 8) +#define B2(x) B0((x) >> 16) +#define B3(x) B0((x) >> 24) +#define __tfm_mul(z,t) \ + (((((B0(t) * (z)) >> 8) + (B1(t) * (z))) >> 8) + B2(t) * (z)) +#define TFMSCALE(z,t,a,b) \ + ((B3(t) == 255) ? \ + __tfm_mul((z), (t)) / (b) - (a) : \ + __tfm_mul((z), (t)) / (b)) +#define TFMPREPARE(x,z,a,b) do { \ + a = 16; z = (x); \ + while(z > 040000000L) { z >>= 1; a <<= 1; } \ + b = 256 / a; a *= z; \ + } while(0) + +#endif /* _MDVI_COMMON_H */ diff --git a/dviware/mdvi/include/defaults.h b/dviware/mdvi/include/defaults.h new file mode 100644 index 0000000000..46ce6ce4a7 --- /dev/null +++ b/dviware/mdvi/include/defaults.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _MDVI_DEFAULTS_H +#define _MDVI_DEFAULTS_H 1 + +/* resolution */ +#define MDVI_DPI 600 +#define MDVI_VDPI MDVI_DPI + +/* horizontal margins */ +#define MDVI_HMARGIN "1in" + +/* vertical margins */ +#define MDVI_VMARGIN "1in" + +/* rulers */ +#define MDVI_HRUNITS "1in" +#define MDVI_VRUNITS "1in" + +/* paper */ +#define MDVI_PAPERNAME "letter" + +/* magnification */ +#define MDVI_MAGNIFICATION 1.0 + +/* fallback font */ +#define MDVI_FALLBACK_FONT "cmr10" + +/* metafont mode */ +#define MDVI_MFMODE NULL + +/* default shrinking factor */ +#define MDVI_DEFAULT_SHRINKING -1 /* based on resolution */ + +/* default pixel density */ +#define MDVI_DEFAULT_DENSITY 50 + +/* default gamma correction */ +#define MDVI_DEFAULT_GAMMA 1.0 + +/* default window geometry */ +#define MDVI_GEOMETRY NULL + +/* default orientation */ +#define MDVI_ORIENTATION "tblr" + +/* colors */ +#define MDVI_FOREGROUND "black" +#define MDVI_BACKGROUND "white" + +/* flags */ +#define MDVI_DEFAULT_FLAGS MDVI_ANTIALIASED + +#define MDVI_DEFAULT_CONFIG "mdvi.conf" + +#endif /* _MDVI_DEAFAULTS_H */ diff --git a/dviware/mdvi/include/dviopcodes.h b/dviware/mdvi/include/dviopcodes.h new file mode 100644 index 0000000000..f99af05ea2 --- /dev/null +++ b/dviware/mdvi/include/dviopcodes.h @@ -0,0 +1,72 @@ +#ifndef _MDVI_DVIOPCODES_H +#define _MDVI_DVIOPCODES_H 1 + +#define DVI_SET_CHAR0 0 +#define DVI_SET_CHAR1 1 +#define DVI_SET_CHAR_MAX 127 +#define DVI_SET1 128 +#define DVI_SET2 129 +#define DVI_SET3 130 +#define DVI_SET4 131 +#define DVI_SET_RULE 132 +#define DVI_PUT1 133 +#define DVI_PUT2 134 +#define DVI_PUT3 135 +#define DVI_PUT4 136 +#define DVI_PUT_RULE 137 +#define DVI_NOOP 138 +#define DVI_BOP 139 +#define DVI_EOP 140 +#define DVI_PUSH 141 +#define DVI_POP 142 +#define DVI_RIGHT1 143 +#define DVI_RIGHT2 144 +#define DVI_RIGHT3 145 +#define DVI_RIGHT4 146 +#define DVI_W0 147 +#define DVI_W1 148 +#define DVI_W2 149 +#define DVI_W3 150 +#define DVI_W4 151 +#define DVI_X0 152 +#define DVI_X1 153 +#define DVI_X2 154 +#define DVI_X3 155 +#define DVI_X4 156 +#define DVI_DOWN1 157 +#define DVI_DOWN2 158 +#define DVI_DOWN3 159 +#define DVI_DOWN4 160 +#define DVI_Y0 161 +#define DVI_Y1 162 +#define DVI_Y2 163 +#define DVI_Y3 164 +#define DVI_Y4 165 +#define DVI_Z0 166 +#define DVI_Z1 167 +#define DVI_Z2 168 +#define DVI_Z3 169 +#define DVI_Z4 170 +#define DVI_FNT_NUM0 171 +#define DVI_FNT_NUM1 172 +#define DVI_FNT_NUM_MAX 234 +#define DVI_FNT1 235 +#define DVI_FNT2 236 +#define DVI_FNT3 237 +#define DVI_FNT4 238 +#define DVI_XXX1 239 +#define DVI_XXX2 240 +#define DVI_XXX3 241 +#define DVI_XXX4 242 +#define DVI_FNT_DEF1 243 +#define DVI_FNT_DEF2 244 +#define DVI_FNT_DEF3 245 +#define DVI_FNT_DEF4 246 +#define DVI_PRE 247 +#define DVI_POST 248 +#define DVI_POST_POST 249 + +#define DVI_ID 2 +#define DVI_TRAILER 223 + +#endif /* _MDVI_DVIOPCODES_H */ diff --git a/dviware/mdvi/include/fontmap.h b/dviware/mdvi/include/fontmap.h new file mode 100644 index 0000000000..0a901ec3a6 --- /dev/null +++ b/dviware/mdvi/include/fontmap.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _MDVI_FONTMAP_H +#define _MDVI_FONTMAP_H 1 + +typedef struct _DviFontMapEnt DviFontMapEnt; +typedef struct _DviEncoding DviEncoding; + +typedef struct { + const char *psname; + const char *encoding; + const char *fontfile; + const char *fullfile; + const char *fmfile; + int fmtype; + long extend; + long slant; +} DviFontMapInfo; + +struct _DviEncoding { + DviEncoding *next; + DviEncoding *prev; + char *private; + char *filename; + char *name; + char **vector; /* table with exactly 256 strings */ + int links; + long offset; + DviHashTable nametab; +}; + +struct _DviFontMapEnt { + DviFontMapEnt *next; + DviFontMapEnt *prev; + char *private; + char *fontname; + char *psname; + char *encoding; + char *encfile; + char *fontfile; + char *fullfile; + long extend; + long slant; +}; + +#define MDVI_FMAP_SLANT(x) ((double)(x)->slant / 10000.0) +#define MDVI_FMAP_EXTEND(x) ((double)(x)->extend / 10000.0) + +extern DviEncoding *mdvi_request_encoding __PROTO((const char *)); +extern void mdvi_release_encoding __PROTO((DviEncoding *, int)); +extern int mdvi_encode_glyph __PROTO((DviEncoding *, const char *)); +extern DviFontMapEnt *mdvi_load_fontmap __PROTO((const char *)); +extern void mdvi_install_fontmap __PROTO((DviFontMapEnt *)); +extern int mdvi_load_fontmaps __PROTO((void)); +extern int mdvi_query_fontmap __PROTO((DviFontMapInfo *, const char *)); +extern void mdvi_flush_encodings __PROTO((void)); +extern void mdvi_flush_fontmaps __PROTO((void)); + +extern int mdvi_add_fontmap_file __PROTO((const char *, const char *)); + +/* PS font maps */ +extern int mdvi_ps_read_fontmap __PROTO((const char *)); +extern char *mdvi_ps_find_font __PROTO((const char *)); +extern TFMInfo *mdvi_ps_get_metrics __PROTO((const char *)); +extern void mdvi_ps_flush_fonts __PROTO((void)); + +#endif /* _MDVI_FONTMAP_H */ diff --git a/dviware/mdvi/include/mdvi.h b/dviware/mdvi/include/mdvi.h new file mode 100644 index 0000000000..8b16da9f5e --- /dev/null +++ b/dviware/mdvi/include/mdvi.h @@ -0,0 +1,767 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _MDVI_DVI_H +#define _MDVI_DVI_H 1 + +#include <stdio.h> +#include <sys/types.h> +#include <math.h> + +#include "sysdeps.h" +#include "bitmap.h" +#include "common.h" +#include "defaults.h" +#include "dviopcodes.h" + +typedef struct _DviGlyph DviGlyph; +typedef struct _DviDevice DviDevice; +typedef struct _DviFontChar DviFontChar; +typedef struct _DviFontRef DviFontRef; +typedef struct _DviFontInfo DviFontInfo; +typedef struct _DviFont DviFont; +typedef struct _DviState DviState; +typedef struct _DviPaper DviPaper; +typedef struct _DviPaperSpec DviPaperSpec; +typedef struct _DviPageSpec *DviPageSpec; +typedef struct _DviParams DviParams; +typedef struct _DviBuffer DviBuffer; +typedef struct _DviContext DviContext; +typedef struct _DviRange DviRange; +typedef struct _DviAppConfig DviAppConfig; +typedef struct _DviColorPair DviColorPair; +typedef struct _DviHashBucket DviHashBucket; +typedef struct _DviHashTable DviHashTable; +typedef struct _DviConfValue DviConfValue; +typedef struct _DviSection DviSection; +typedef struct _DviConfig DviConfig; +typedef struct _TFMChar TFMChar; +typedef struct _TFMInfo TFMInfo; +typedef struct _DviFontSearch DviFontSearch; +/* this is an opaque type */ +typedef struct _DviFontClass DviFontClass; + +typedef void (*DviFreeFunc) __PROTO((void *)); +typedef void (*DviFree2Func) __PROTO((void *, void *)); + +typedef Ulong DviColor; + +#ifdef TRUE +#undef TRUE +#endif +#ifdef FALSE +#undef FALSE +#endif + +typedef enum { + FALSE = 0, + TRUE = 1 +} DviBool; + +/* + * information about a page: + * pagenum[0] = offset to BOP + * pagenum[1], ..., pagenum[10] = TeX \counters + */ +typedef long PageNum[11]; + +/* this structure contains the platform-specific information + * required to interpret a DVI file */ + +typedef void (*DviGlyphDraw) __PROTO((DviContext *context, + DviFontChar *glyph, + int x, int y)); + +typedef void (*DviRuleDraw) __PROTO((DviContext *context, + int x, int y, + Uint width, Uint height, int fill)); + +typedef int (*DviColorScale) __PROTO((void *device_data, + Ulong *pixels, + int npixels, + Ulong foreground, + Ulong background, + double gamma, + int density)); +typedef void *(*DviCreateImage) __PROTO((void *device_data, + Uint width, + Uint height, + Uint bpp)); +typedef void (*DviFreeImage) __PROTO((void *image)); +typedef void (*DviPutPixel) __PROTO((void *image, int x, int y, Ulong color)); +typedef void (*DviDevDestroy) __PROTO((void *data)); +typedef void (*DviRefresh) __PROTO((DviContext *dvi, void *device_data)); +typedef void (*DviSetColor) __PROTO((void *device_data, Ulong, Ulong)); + +struct _DviDevice { + DviGlyphDraw draw_glyph; + DviRuleDraw draw_rule; + DviColorScale alloc_colors; + DviCreateImage create_image; + DviFreeImage free_image; + DviPutPixel put_pixel; + DviDevDestroy dev_destroy; + DviRefresh refresh; + DviSetColor set_color; + void * device_data; +}; + +/* + * Hash tables + */ + +typedef Uchar *DviHashKey; +#define MDVI_KEY(x) ((DviHashKey)(x)) + +typedef Ulong (*DviHashFunc) __PROTO((DviHashKey key)); +typedef int (*DviHashComp) __PROTO((DviHashKey key1, DviHashKey key2)); +typedef void (*DviHashFree) __PROTO((DviHashKey key, void *data)); + + +struct _DviHashTable { + DviHashBucket **buckets; + int nbucks; + int nkeys; + DviHashFunc hash_func; + DviHashComp hash_comp; + DviHashFree hash_free; +}; +#define MDVI_EMPTY_HASH_TABLE {NULL, 0, 0, NULL, NULL, NULL} + +/* + * Fonts + */ + +#include "fontmap.h" + +struct _TFMChar { + Int32 present; + Int32 advance; /* advance */ + Int32 height; /* ascent */ + Int32 depth; /* descent */ + Int32 left; /* leftSideBearing */ + Int32 right; /* rightSideBearing */ +}; + +struct _TFMInfo { + int type; /* DviFontAFM, DviFontTFM, DviFontOFM */ + Uint32 checksum; + Uint32 design; + int loc; + int hic; + char coding[64]; + char family[64]; + TFMChar *chars; +}; + +struct _DviGlyph { + short x, y; /* origin */ + Uint w, h; /* dimensions */ + void *data; /* bitmap or XImage */ +}; + +typedef void (*DviFontShrinkFunc) + __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); +typedef int (*DviFontLoadFunc) __PROTO((DviParams *, DviFont *)); +typedef int (*DviFontGetGlyphFunc) __PROTO((DviParams *, DviFont *, int)); +typedef void (*DviFontFreeFunc) __PROTO((DviFont *)); +typedef void (*DviFontResetFunc) __PROTO((DviFont *)); +typedef char *(*DviFontLookupFunc) __PROTO((const char *, Ushort *, Ushort *)); +typedef int (*DviFontEncodeFunc) __PROTO((DviParams *, DviFont *, DviEncoding *)); + +struct _DviFontInfo { + char *name; /* human-readable format identifying string */ + int scalable; /* does it support scaling natively? */ + DviFontLoadFunc load; + DviFontGetGlyphFunc getglyph; + DviFontShrinkFunc shrink0; + DviFontShrinkFunc shrink1; + DviFontFreeFunc freedata; + DviFontResetFunc reset; + DviFontLookupFunc lookup; + int kpse_type; + void * private; +}; + +struct _DviFontChar { + Uint32 offset; + Int16 code; /* format-dependent, not used by MDVI */ + Int16 width; + Int16 height; + Int16 x; + Int16 y; + Int32 tfmwidth; + Ushort flags; +#ifdef __STRICT_ANSI__ + Ushort loaded; + Ushort missing; +#else + Ushort loaded : 1, + missing : 1; +#endif + Ulong fg; + Ulong bg; + BITMAP *glyph_data; + /* data for shrunk bitimaps */ + DviGlyph glyph; + DviGlyph shrunk; + DviGlyph grey; +}; + +struct _DviFontRef { + DviFontRef *next; + DviFont *ref; + Int32 fontid; +}; + +typedef enum { + DviFontAny = -1, + DviFontPK = 0, + DviFontGF = 1, + DviFontVF = 2, + DviFontTFM = 3, + DviFontT1 = 4, + DviFontTT = 5, + DviFontAFM = 6, + DviFontOFM = 7 +} DviFontType; + +struct _DviFontSearch { + int id; + Ushort hdpi; + Ushort vdpi; + Ushort actual_hdpi; + Ushort actual_vdpi; + const char *wanted_name; + const char *actual_name; + DviFontClass *curr; + DviFontInfo *info; +}; + +/* this is a kludge, I know */ +#define ISVIRTUAL(font) ((font)->search.info->getglyph == NULL) +#define SEARCH_DONE(s) ((s).id < 0) +#define SEARCH_INIT(s, name, h, v) do { \ + (s).id = 0; \ + (s).curr = NULL; \ + (s).hdpi = (h); \ + (s).vdpi = (v); \ + (s).wanted_name = (name); \ + (s).actual_name = NULL; \ + } while(0) + +struct _DviFont { + DviFont *next; + DviFont *prev; + int type; + Int32 checksum; + int hdpi; + int vdpi; + Int32 scale; + Int32 design; + FILE *in; + char *fontname; + char *filename; + int links; + int loc; + int hic; + Uint flags; + DviFontSearch search; + DviFontChar *chars; + DviFontRef *subfonts; + void *private; +}; + +/* + * Dvi context + */ + +typedef enum { + MDVI_PAPER_CLASS_ISO, + MDVI_PAPER_CLASS_US, + MDVI_PAPER_CLASS_ANY, + MDVI_PAPER_CLASS_CUSTOM +} DviPaperClass; + +struct _DviPaper { + DviPaperClass pclass; + const char *name; + double inches_wide; + double inches_tall; +}; + +struct _DviPaperSpec { + const char *name; + const char *width; + const char *height; +}; + +typedef enum { + MDVI_ORIENT_TBLR = 0, /* top to bottom, left to right */ + MDVI_ORIENT_TBRL = 1, /* top to bottom, right to left */ + MDVI_ORIENT_BTLR = 2, /* bottom to top, left to right */ + MDVI_ORIENT_BTRL = 3, /* bottom to top, right to left */ + MDVI_ORIENT_RP90 = 4, /* rotated +90 degrees (counter-clockwise) */ + MDVI_ORIENT_RM90 = 5, /* rotated -90 degrees (clockwise) */ + MDVI_ORIENT_IRP90 = 6, /* flip horizontally, then rotate by +90 */ + MDVI_ORIENT_IRM90 = 7 /* rotate by -90, then flip horizontally */ +} DviOrientation; + +typedef enum { + MDVI_PAGE_SORT_UP, /* up, using \counter0 */ + MDVI_PAGE_SORT_DOWN, /* down, using \counter0 */ + MDVI_PAGE_SORT_RANDOM, /* randomly */ + MDVI_PAGE_SORT_DVI_UP, /* up, by location in DVI file */ + MDVI_PAGE_SORT_DVI_DOWN, /* down, by location in DVI file */ + MDVI_PAGE_SORT_NONE /* don't sort */ +} DviPageSort; + +struct _DviParams { + double mag; /* magnification */ + double conv; /* horizontal DVI -> pixel */ + double vconv; /* vertical DVI -> pixel */ + double tfm_conv; /* TFM -> DVI */ + double gamma; /* gamma correction factor */ + Uint dpi; /* horizontal resolution */ + Uint vdpi; /* vertical resolution */ + int hshrink; /* horizontal shrinking factor */ + int vshrink; /* vertical shrinking factor */ + Uint density; /* pixel density */ + Uint flags; /* flags (see MDVI_PARAM macros) */ + int hdrift; /* max. horizontal drift */ + int vdrift; /* max. vertical drift */ + int vsmallsp; /* small vertical space */ + int thinsp; /* small horizontal space */ + int layer; /* visible layer (for layered DVI files) */ + Ulong fg; /* foreground color */ + Ulong bg; /* background color */ + DviOrientation orientation; /* page orientation */ + int base_x; + int base_y; + Ulong *pixels; /* colors used for antialiasing */ + int npixels; /* number of entries in `pixels' */ +}; + +typedef enum { + MDVI_PARAM_LAST = 0, + MDVI_SET_DPI = 1, + MDVI_SET_XDPI = 2, + MDVI_SET_YDPI = 3, + MDVI_SET_SHRINK = 4, + MDVI_SET_XSHRINK = 5, + MDVI_SET_YSHRINK = 6, + MDVI_SET_GAMMA = 7, + MDVI_SET_DENSITY = 8, + MDVI_SET_MAGNIFICATION = 9, + MDVI_SET_DRIFT = 10, + MDVI_SET_HDRIFT = 11, + MDVI_SET_VDRIFT = 12, + MDVI_SET_ORIENTATION = 13, + MDVI_SET_FOREGROUND = 14, + MDVI_SET_BACKGROUND = 15 +} DviParamCode; + +struct _DviBuffer { + Uchar *data; + size_t size; /* allocated size */ + size_t length; /* amount of data buffered */ + size_t pos; /* current position in buffer */ + int frozen; /* can we free this data? */ +}; + +/* DVI registers */ +struct _DviState { + int h; + int v; + int hh; + int vv; + int w; + int x; + int y; + int z; +}; + +struct _DviColorPair { + Ulong fg; + Ulong bg; +}; + +struct _DviContext { + char *filename; /* name of the DVI file */ + FILE *in; /* from here we read */ + char *fileid; /* from preamble */ + char *fallback_font; /* fallback font to use if one is not found */ + int npages; /* number of pages */ + int currpage; /* currrent page (0 based) */ + int depth; /* recursion depth */ + DviBuffer buffer; /* input buffer */ + DviParams params; /* parameters */ + DviPaper paper; /* paper type */ + Int32 num; /* numerator */ + Int32 den; /* denominator */ + DviFontRef *fonts; /* fonts used in this file */ + DviFontRef **fontmap; /* for faster id lookups */ + DviFontRef *currfont; /* current font */ + int nfonts; /* # of fonts used in this job */ + Int32 dvimag; /* original magnification */ + double dviconv; /* unshrunk scaling factor */ + double dvivconv; /* unshrunk scaling factor (vertical) */ + int dvi_page_w; /* unscaled page width */ + int dvi_page_h; /* unscaled page height */ + Ulong modtime; /* file modification time */ + PageNum *pagemap; /* page table */ + DviState pos; /* registers */ + DviPageSpec *pagesel; /* page selection data */ + int curr_layer; /* current layer */ + DviState *stack; /* DVI stack */ + int stacksize; /* stack depth */ + int stacktop; /* stack pointer */ + DviDevice device; /* device-specific routines */ + Ulong curr_fg; /* rendering color */ + Ulong curr_bg; + DviColorPair *color_stack; + DviHashTable assoc; + int color_top; + int color_size; + DviFontRef *(*findref) __PROTO((DviContext *, Int32)); + void *user_data; /* client data attached to this context */ +}; + +typedef enum { + MDVI_RANGE_BOUNDED, /* range is finite */ + MDVI_RANGE_LOWER, /* range has a lower bound */ + MDVI_RANGE_UPPER, /* range has an upper bound */ + MDVI_RANGE_UNBOUNDED /* range has no bounds at all */ +} DviRangeType; + +struct _DviRange { + DviRangeType type; /* one of the above */ + int from; /* lower bound */ + int to; /* upper bound */ + int step; /* step */ +}; + +struct _DviAppConfig { + char *program; + char *fallback_font; + char *fgcolor; + char *bgcolor; + char *mfmode; + char *hrule_units; + char *vrule_units; + char *hmargin; + char *vmargin; + char *page_ranges; + char *fontspec; + char *fontunspec; + DviPaper paper; + DviPageSort page_sort; + DviParams params; + int first_page; + int use_tex_page; +}; + +/* in-memory configuration files */ +struct _DviConfValue { + DviConfValue *next; + char *key; + char *value; +}; + +struct _DviSection { + DviSection *next; + char *name; + long offset; + DviConfValue *keys; + DviHashTable table; +}; + +struct _DviConfig { + char *filename; + char *core; + DviSection *sections; + DviHashTable sectable; +}; + + + +typedef void (*DviSpecialHandler) + __PROTO((DviContext *dvi, const char *prefix, const char *arg)); + +#define RANGE_HAS_LOWER(x) \ + ((x) == MDVI_RANGE_BOUNDED || (x) == MDVI_RANGE_LOWER) +#define RANGE_HAS_UPPER(x) \ + ((x) == MDVI_RANGE_BOUNDED || (x) == MDVI_RANGE_UPPER) + +/* + * Macros and prototypes + */ + +#define MDVI_PARAM_ANTIALIASED 1 +#define MDVI_PARAM_MONO 2 +#define MDVI_PARAM_CHARBOXES 4 +#define MDVI_PARAM_SHOWUNDEF 8 +#define MDVI_PARAM_DELAYFONTS 16 + +/* + * The FALLBACK priority class is reserved for font formats that + * contain no glyph information and are to be used as a last + * resort (e.g. TFM, AFM) + */ +#define MDVI_FONTPRIO_FALLBACK -3 +#define MDVI_FONTPRIO_LOWEST -2 +#define MDVI_FONTPRIO_LOW -1 +#define MDVI_FONTPRIO_NORMAL 0 +#define MDVI_FONTPRIO_HIGH 1 +#define MDVI_FONTPRIO_HIGHEST 2 + +#define MDVI_FONT_ENCODED (1 << 0) + +#define MDVI_GLYPH_EMPTY ((void *)1) +/* does the glyph have a non-empty bitmap/image? */ +#define MDVI_GLYPH_NONEMPTY(x) ((x) && (x) != MDVI_GLYPH_EMPTY) +/* has the glyph been loaded from disk? */ +#define MDVI_GLYPH_UNSET(x) ((x) == NULL) +/* do we have only a bounding box for this glyph? */ +#define MDVI_GLYPH_ISEMPTY(x) ((x) == MDVI_GLYPH_EMPTY) + +#define MDVI_ENABLED(d,x) ((d)->params.flags & (x)) +#define MDVI_DISABLED(d,x) !MDVI_ENABLED((d), (x)) + +#define MDVI_LASTPAGE(d) ((d)->npages - 1) +#define MDVI_NPAGES(d) (d)->npages +#define MDVI_VALIDPAGE(d,p) ((p) >= 0 && (p) <= MDVI_LASTPAGE(d)) +#define MDVI_FLAGS(d) (d)->params.flags +#define MDVI_SHRINK_FROM_DPI(d) Max(1, (d) / 75) +#define MDVI_CURRFG(d) (d)->curr_fg +#define MDVI_CURRBG(d) (d)->curr_bg + +#define pixel_round(d,v) (int)((d)->params.conv * (v) + 0.5) +#define vpixel_round(d,v) (int)((d)->params.vconv * (v) + 0.5) +#define rule_round(d,v) (int)((d)->params.conv * (v) + 0.99999) /*9999999)*/ +#define vrule_round(d,v) (int)((d)->params.vconv * (v) + 0.99999) + +extern int mdvi_reload __PROTO((DviContext *, DviParams *)); +extern void mdvi_setpage __PROTO((DviContext *, int)); +extern int mdvi_dopage __PROTO((DviContext *, int)); +extern void mdvi_shrink_glyph __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); +extern void mdvi_shrink_box __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); +extern void mdvi_shrink_glyph_grey __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); +extern int mdvi_find_tex_page __PROTO((DviContext *, int)); +extern int mdvi_configure __PROTO((DviContext *, DviParamCode, ...)); + +extern int get_tfm_chars __PROTO((DviParams *, DviFont *, TFMInfo *, int)); +extern int tfm_load_file __PROTO((const char *, TFMInfo *)); +extern int afm_load_file __PROTO((const char *, TFMInfo *)); +extern TFMInfo *get_font_metrics __PROTO((const char *, int, const char *)); +extern char *lookup_font_metrics __PROTO((const char *, int *)); +extern void free_font_metrics __PROTO((TFMInfo *)); +extern void flush_font_metrics __PROTO((void)); + +#define get_metrics(name) get_font_metrics((name), DviFontAny, NULL) + +extern void mdvi_sort_pages __PROTO((DviContext *, DviPageSort)); +extern int mdvi_get_paper_size __PROTO((const char *, DviPaper *)); +extern DviPaperSpec* mdvi_get_paper_specs __PROTO((DviPaperClass)); +extern void mdvi_free_paper_specs __PROTO((DviPaperSpec *)); + +/* Associations */ +extern int mdvi_assoc_put + __PROTO((DviContext *, char *, void *, DviFree2Func)); +extern void * mdvi_assoc_get __PROTO((DviContext *, char *)); +extern void * mdvi_assoc_del __PROTO((DviContext *, char *)); +extern void mdvi_assoc_free __PROTO((DviContext *, char *)); +extern void mdvi_assoc_flush __PROTO((DviContext *)); + +extern int mdvi_check_config __PROTO((DviAppConfig *)); +extern void mdvi_init_kpathsea __PROTO((const char *, const char *, const char *, int)); +extern DviAppConfig *mdvi_init_app __PROTO((const char *, const char *)); + +extern DviContext* mdvi_init_context __PROTO((DviParams *, DviPageSpec *, const char *)); +extern void mdvi_destroy_context __PROTO((DviContext *)); + +/* helper macros that call mdvi_configure() */ +#define mdvi_config_one(d,x,y) mdvi_configure((d), (x), (y), MDVI_PARAM_LAST) +#define mdvi_set_dpi(d,x) mdvi_config_one((d), MDVI_SET_DPI, (x)) +#define mdvi_set_xdpi(d,x) mdvi_config_one((d), MDVI_SET_XDPI, (x)) +#define mdvi_set_ydpi(d,x) mdvi_config_one((d), MDVI_SET_YDPI, (x)) +#define mdvi_set_hshrink(d,h) mdvi_config_one((d), MDVI_SET_XSHRINK, (h)) +#define mdvi_set_vshrink(d,h) mdvi_config_one((d), MDVI_SET_YSHRINK, (h)) +#define mdvi_set_gamma(d,g) mdvi_config_one((d), MDVI_SET_GAMMA, (g)) +#define mdvi_set_density(d,x) mdvi_config_one((d), MDVI_SET_DENSITY, (x)) +#define mdvi_set_drift(d,x) mdvi_config_one((d), MDVI_SET_DRIFT, (x)) +#define mdvi_set_hdrift(d,h) mdvi_config_one((d), MDVI_SET_HDRIFT, (h)) +#define mdvi_set_vdrift(d,v) mdvi_config_one((d), MDVI_SET_VDRIFT, (v)) +#define mdvi_set_mag(d,m) \ + mdvi_config_one((d), MDVI_SET_MAGNIFICATION, (m)) +#define mdvi_set_foreground(d,x) \ + mdvi_config_one((d), MDVI_SET_FOREGROUND, (x)) +#define mdvi_set_background(d,x) \ + mdvi_config_one((d), MDVI_SET_BACKGROUND, (x)) +#define mdvi_set_orientation(d,x) \ + mdvi_config_one((d), MDVI_SET_ORIENTATION, (x)) +#define mdvi_set_shrink(d,h,v) \ + mdvi_configure((d), MDVI_SET_XSHRINK, (h), \ + MDVI_SET_YSHRINK, (v), MDVI_PARAM_LAST) + +extern DviRange* mdvi_parse_range __PROTO((const char *, DviRange *, int *, char **)); +extern DviPageSpec* mdvi_parse_page_spec __PROTO((const char *)); +extern void mdvi_free_page_spec __PROTO((DviPageSpec *)); +extern int mdvi_in_range __PROTO((DviRange *, int, int)); +extern int mdvi_range_length __PROTO((DviRange *, int)); +extern int mdvi_page_selected __PROTO((DviPageSpec *, PageNum, int)); + +/* Color support */ +extern void mdvi_set_color __PROTO((DviContext *, Ulong, Ulong)); +extern void mdvi_push_color __PROTO((DviContext *, Ulong, Ulong)); +extern void mdvi_pop_color __PROTO((DviContext *)); +extern void mdvi_reset_color __PROTO((DviContext *)); + +/* Specials */ +extern int mdvi_register_special __PROTO(( + const char *label, + const char *prefix, + const char *regex, + DviSpecialHandler handler, + int replace)); +extern int mdvi_unregister_special __PROTO((const char *prefix)); +extern int mdvi_do_special __PROTO((DviContext *dvi, char *dvi_special)); +extern void mdvi_flush_specials __PROTO((void)); + +/* Fonts */ + +#define MDVI_FONTSEL_BITMAP (1 << 0) +#define MDVI_FONTSEL_GREY (1 << 1) +#define MDVI_FONTSEL_GLYPH (1 << 2) + +#define FONTCHAR(font, code) \ + (((code) < font->loc || (code) > font->hic || !(font)->chars) ? \ + NULL : &font->chars[(code) - (font)->loc]) +#define FONT_GLYPH_COUNT(font) ((font)->hic - (font)->loc + 1) + +#define glyph_present(x) ((x) && (x)->offset) + +/* create a reference to a font */ +extern DviFontRef *font_reference __PROTO((DviParams *params, + Int32 dvi_id, + const char *font_name, + Int32 checksum, + int xdpi, + int ydpi, + Int32 scale_factor)); + +/* drop a reference to a font */ +extern void font_drop_one __PROTO((DviFontRef *)); + +/* drop a chain of references */ +extern void font_drop_chain __PROTO((DviFontRef *)); + +/* destroy selected information for a glyph */ +extern void font_reset_one_glyph __PROTO((DviDevice *, DviFontChar *, int)); + +/* destroy selected information for all glyphs in a font */ +extern void font_reset_font_glyphs __PROTO((DviDevice *, DviFont *, int)); + +/* same for a chain of font references */ +extern void font_reset_chain_glyphs __PROTO((DviDevice *, DviFontRef *, int)); + +extern void font_finish_definitions __PROTO((DviContext *)); + +/* lookup an id # in a reference chain */ +extern DviFontRef* font_find_flat __PROTO((DviContext *, Int32)); +extern DviFontRef* font_find_mapped __PROTO((DviContext *, Int32)); + +/* called to reopen (or rewind) a font file */ +extern int font_reopen __PROTO((DviFont *)); + +/* reads a glyph from a font, and makes all necessary transformations */ +extern DviFontChar* font_get_glyph __PROTO((DviContext *, DviFont *, int)); + +/* transform a glyph according to the given orientation */ +extern void font_transform_glyph __PROTO((DviOrientation, DviGlyph *)); + +/* destroy all fonts that are not being used, returns number of fonts freed */ +extern int font_free_unused __PROTO((DviDevice *)); + +#define font_free_glyph(dev, font, code) \ + font_reset_one_glyph((dev), \ + FONTCHAR((font), (code)), MDVI_FONTSEL_GLYPH) + +extern int mdvi_encode_font __PROTO((DviParams *, DviFont *)); + +/* Hash tables */ +#define MDVI_HASH_REPLACE 0 +#define MDVI_HASH_UNIQUE 1 +#define MDVI_HASH_UNCHECKED 2 + +extern void mdvi_hash_init __PROTO((DviHashTable *)); +extern void mdvi_hash_create __PROTO((DviHashTable *, int)); +extern int mdvi_hash_add __PROTO((DviHashTable *, DviHashKey, void *, int)); +extern int mdvi_hash_destroy_key __PROTO((DviHashTable *, DviHashKey)); +extern void mdvi_hash_reset __PROTO((DviHashTable *, int)); +extern void *mdvi_hash_lookup __PROTO((DviHashTable *, DviHashKey)); +extern void *mdvi_hash_remove __PROTO((DviHashTable *, DviHashKey)); +extern void *mdvi_hash_remove_ptr __PROTO((DviHashTable *, DviHashKey)); + +#define mdvi_hash_flush(h) mdvi_hash_reset((h), 1) +#define mdvi_hash_destroy(h) mdvi_hash_reset((h), 0) + +/* font lookup functions */ +extern int mdvi_register_font_type __PROTO((DviFontInfo *, int)); +extern char **mdvi_list_font_class __PROTO((int)); +extern int mdvi_get_font_classes __PROTO((void)); +extern int mdvi_unregister_font_type __PROTO((const char *, int)); +extern char *mdvi_lookup_font __PROTO((DviFontSearch *)); +extern DviFont *mdvi_add_font __PROTO((const char *, Int32, int, int, Int32)); +extern int mdvi_font_retry __PROTO((DviParams *, DviFont *)); + +/* configuration files */ +extern DviConfig *mdvi_read_config __PROTO((const char *)); +extern DviSection *mdvi_find_section __PROTO((DviConfig *, const char *)); +extern int mdvi_destroy_section __PROTO((DviConfig *, DviSection *)); +extern void mdvi_destroy_config __PROTO((DviConfig *)); + +/* Miscellaneous */ + +extern DviOrientation mdvi_get_orientation __PROTO((const char *)); +extern int mdvi_get_integer __PROTO((const char *, long *)); +extern int mdvi_get_float __PROTO((const char *, double *)); +extern long mdvi_get_integer_env __PROTO((const char *, long)); +extern double mdvi_get_float_env __PROTO((const char *, double)); +extern char* mdvi_get_string_env __PROTO((const char *, char *)); +extern void mdvi_get_params_env __PROTO((DviParams *)); + +extern int mdvi_set_logfile __PROTO((const char *)); +extern int mdvi_set_logstream __PROTO((FILE *)); +extern int mdvi_set_loglevel __PROTO((int)); + +#define mdvi_stop_logging(x) mdvi_set_logstream(NULL) + +extern int mdvi_get_pagesort __PROTO((const char *)); +extern int mdvi_get_debugmask __PROTO((const char *)); +extern DviOrientation mdvi_getorient __PROTO((const char *)); +extern int mdvi_getint __PROTO((const char *, long *)); +extern int mdvi_getfloat __PROTO((const char *, double *)); +extern int mdvi_getenv_int __PROTO((const char *, int)); +extern double mdvi_getenv_float __PROTO((const char *, double)); +extern char* mdvi_getenv_string __PROTO((const char *, char *)); + +/* this will check the environment and then `texmf.cnf' for + * the given name changed to lowercase, and `_' changed to `-' */ +extern char* mdvi_getenv __PROTO((const char *)); + +#endif /* _MDVI_DVI_H */ diff --git a/dviware/mdvi/include/private.h b/dviware/mdvi/include/private.h new file mode 100644 index 0000000000..261a91172e --- /dev/null +++ b/dviware/mdvi/include/private.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _MDVI_PRIVATE_H +#define _MDVI_PRIVATE_H 1 + +#define HAVE_PROTOTYPES 1 +#include <kpathsea/debug.h> +#include <kpathsea/tex-file.h> +#include <kpathsea/tex-glyph.h> +#include <kpathsea/cnf.h> +#include <kpathsea/proginit.h> +#include <kpathsea/progname.h> + +#define ISSP(p) (*(p) == ' ' || *(p) == '\t') +#define SKIPSP(p) while(ISSP(p)) p++ +#define SKIPNSP(p) while(*(p) && !ISSP(p)) p++ + +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) gettext(x) +#define _G(x) x +#else +#define _(x) x +#define _G(x) x +#endif /* ENABLE_NLS */ + +#if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2 +#define _BREAKPOINT() do { __asm__ __volatile__ ("int $03"); } while(0) +#elif defined (__alpha__) && defined (__GNUC__) && __GNUC__ >= 2 +#define _BREAKPOINT() do { __asm__ __volatile__ ("bpt"); } while(0) +#else /* !__i386__ && !__alpha__ */ +#define _BREAKPOINT() +#endif /* __i386__ */ + +#endif /* _MDVI_PRIVATE_H */ diff --git a/dviware/mdvi/include/sysdeps.h b/dviware/mdvi/include/sysdeps.h new file mode 100644 index 0000000000..a59f7e1033 --- /dev/null +++ b/dviware/mdvi/include/sysdeps.h @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _SYSDEP_H +#define _SYSDEP_H 1 + +/* + * The purpose of this file is to define symbols that describe the + * system-dependent features we use. Namely, byte order, native integer + * types of various sizes, and safe pointer<->integer conversion. + */ + +#include "config.h" + +#ifdef WORDS_BIGENDIAN +#define WORD_BIG_ENDIAN 1 +#else +#define WORD_LITTLE_ENDIAN 1 +#endif + +typedef unsigned long Ulong; +typedef unsigned int Uint; +typedef unsigned short Ushort; +typedef unsigned char Uchar; + +/* this one's easy */ +typedef unsigned char Uint8; +typedef char Int8; + +/* define a datatype for 32bit integers (either int or long) */ +#if SIZEOF_LONG == 4 +typedef unsigned long Uint32; +typedef long Int32; +#else /* SIZEOF_LONG != 4 */ +#if SIZEOF_INT == 4 +typedef unsigned int Uint32; +typedef int Int32; +#else /* SIZEOF_INT != 4 */ +#ifdef __cplusplus +#include "No.appropriate.32bit.native.type.found.Fix.sysdeps.h" +#else +#error No appropriate 32bit native type found. Fix sysdeps.h +#endif /* ! __cplusplus */ +#endif /* SIZEOF_INT != 4 */ +#endif /* SIZEOF_LONG != 4 */ + +/* now 16bit integers (one of long, int or short) */ +#if SIZEOF_SHORT == 2 +typedef unsigned short Uint16; +typedef short Int16; +#else /* SIZEOF_SHORT != 2 */ +#if SIZEOF_INT == 2 +typedef unsigned int Uint16; +typedef short Int16; +#else /* SIZEOF_INT != 2 */ +#ifdef __cplusplus +#include "No.appropriate.16bit.native.type.found.Fix.sysdeps.h" +#else +#error No appropriate 16bit native type found. Fix sysdeps.h +#endif /* ! __cplusplus */ +#endif /* SIZEOF_INT != 2 */ +#endif /* SIZEOF_SHORT != 2 */ + +/* + * An integer type to convert to and from pointers safely. All we do here is + * look for an integer type with the same size as a pointer. + */ +#if SIZEOF_LONG == SIZEOF_VOID_P +typedef unsigned long UINT; +typedef long INT; +#else +#if SIZEOF_INT == SIZEOF_VOID_P +typedef unsigned int UINT; +typedef int INT; +#else +#if SIZEOF_SHORT == SIZEOF_VOID_P +typedef unsigned short UINT; +typedef short INT; +#else +#ifdef __cplusplus +#include "No.native.pointer-compatible.integer.type.found.Fix.sysdeps.h" +#else +#error No native pointer-compatible integer type found. Fix sysdeps.h +#endif +#endif +#endif +#endif + +/* nice, uh? */ +typedef void *Pointer; + +/* macros to do the safe pointer <-> integer conversions */ +#define Ptr2Int(x) ((INT)((Pointer)(x))) +#define Int2Ptr(x) ((Pointer)((INT)(x))) + +#ifdef _NO_PROTO +#define __PROTO(x) () +#else +#define __PROTO(x) x +#endif + +#ifdef WITH_REGEX_SPECIALS +/* if we don't have regexec(), there's no point in this */ +#ifndef HAVE_REGEXEC +#undef WITH_REGEX_SPECIALS +#endif +#endif + +#ifdef WITH_TYPE1_FONTS +/* if we don't have the t1lib library, undefine this */ +#ifndef T1LIB_VERSION +#undef WITH_TYPE1_FONTS +#endif +#endif + +#endif /* _SYSDEP_H */ diff --git a/dviware/mdvi/intl/ChangeLog b/dviware/mdvi/intl/ChangeLog new file mode 100644 index 0000000000..198950159d --- /dev/null +++ b/dviware/mdvi/intl/ChangeLog @@ -0,0 +1,1086 @@ +1998-04-29 Ulrich Drepper <drepper@cygnus.com> + + * intl/localealias.c (read_alias_file): Use unsigned char for + local variables. Remove unused variable tp. + * intl/l10nflist.c (_nl_normalize_codeset): Use unsigned char * + for type of codeset. For loosing Solaris systems. + * intl/loadinfo.h: Adapt prototype of _nl_normalize_codeset. + * intl/bindtextdom.c (BINDTEXTDOMAIN): Don't define local variable + len if not needed. + Patches by Jim Meyering. + +1998-04-28 Ulrich Drepper <drepper@cygnus.com> + + * loadmsgcat.c (_nl_load_domain): Don't assign the element use_mmap if + mmap is not supported. + + * hash-string.h: Don't include <values.h>. + +1998-04-27 Ulrich Drepper <drepper@cygnus.com> + + * textdomain.c: Use strdup is available. + + * localealias.c: Define HAVE_MEMPCPY so that we can use this + function. Define and use semapahores to protect modfication of + global objects when compiling for glibc. Add code to allow + freeing alias table. + + * l10nflist.c: Don't assume stpcpy not being a macro. + + * gettextP.h: Define internal_function macri if not already done. + Use glibc byte-swap macros instead of defining SWAP when compiled + for glibc. + (struct loaded_domain): Add elements to allow unloading. + + * Makefile.in (distclean): Don't remove libintl.h here. + + * bindtextdomain.c: Carry over changes from glibc. Use strdup if + available. + + * dcgettext.c: Don't assume stpcpy not being a macro. Mark internal + functions. Add memory freeing code for glibc. + + * dgettext.c: Update copyright. + + * explodename.c: Include stdlib.h and string.h only if they exist. + Use strings.h eventually. + + * finddomain.c: Mark internal functions. Use strdup if available. + Add memory freeing code for glibc. + +1997-10-10 20:00 Ulrich Drepper <drepper@cygnus.com> + + * libgettext.h: Fix dummy textdomain and bindtextdomain macros. + They should return reasonable values. + Reported by Tom Tromey <tromey@cygnus.com>. + +1997-09-16 03:33 Ulrich Drepper <drepper@cygnus.com> + + * libgettext.h: Define PARAMS also to `args' if __cplusplus is defined. + * intlh.inst.in: Likewise. + Reported by Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>. + + * libintl.glibc: Update from current glibc version. + +1997-09-06 02:10 Ulrich Drepper <drepper@cygnus.com> + + * intlh.inst.in: Reformat copyright. + +1997-08-19 15:22 Ulrich Drepper <drepper@cygnus.com> + + * dcgettext.c (DCGETTEXT): Remove wrong comment. + +1997-08-16 00:13 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in (install-data): Don't change directory to install. + +1997-08-01 14:30 Ulrich Drepper <drepper@cygnus.com> + + * cat-compat.c: Fix copyright. + + * localealias.c: Don't define strchr unless !HAVE_STRCHR. + + * loadmsgcat.c: Update copyright. Fix typos. + + * l10nflist.c: Don't define strchr unless !HAVE_STRCHR. + (_nl_make_l10nflist): Handle sponsor and revision correctly. + + * gettext.c: Update copyright. + * gettext.h: Likewise. + * hash-string.h: Likewise. + + * finddomain.c: Remoave dead code. Define strchr only if + !HAVE_STRCHR. + + * explodename.c: Include <sys/types.h>. + + * explodename.c: Reformat copyright text. + (_nl_explode_name): Fix typo. + + * dcgettext.c: Define and use __set_errno. + (guess_category_value): Don't use setlocale if HAVE_LC_MESSAGES is + not defined. + + * bindtextdom.c: Pretty printing. + +1997-05-01 02:25 Ulrich Drepper <drepper@cygnus.com> + + * dcgettext.c (guess_category_value): Don't depend on + HAVE_LC_MESSAGES. We don't need the macro here. + Patch by Bruno Haible <haible@ilog.fr>. + + * cat-compat.c (textdomain): DoN't refer to HAVE_SETLOCALE_NULL + macro. Instead use HAVE_LOCALE_NULL and define it when using + glibc, as in dcgettext.c. + Patch by Bruno Haible <haible@ilog.fr>. + + * Makefile.in (CPPFLAGS): New variable. Reported by Franc,ois + Pinard. + +Mon Mar 10 06:51:17 1997 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in: Implement handling of libtool. + + * gettextP.h: Change data structures for use of generic lowlevel + i18n file handling. + +Wed Dec 4 20:21:18 1996 Ulrich Drepper <drepper@cygnus.com> + + * textdomain.c: Put parentheses around arguments of memcpy macro + definition. + * localealias.c: Likewise. + * l10nflist.c: Likewise. + * finddomain.c: Likewise. + * bindtextdom.c: Likewise. + Reported by Thomas Esken. + +Mon Nov 25 22:57:51 1996 Ulrich Drepper <drepper@cygnus.com> + + * textdomain.c: Move definition of `memcpy` macro to right + position. + +Fri Nov 22 04:01:58 1996 Ulrich Drepper <drepper@cygnus.com> + + * finddomain.c [!HAVE_STRING_H && !_LIBC]: Define memcpy using + bcopy if not already defined. Reported by Thomas Esken. + * bindtextdom.c: Likewise. + * l10nflist.c: Likewise. + * localealias.c: Likewise. + * textdomain.c: Likewise. + +Tue Oct 29 11:10:27 1996 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in (libdir): Change to use exec_prefix instead of + prefix. Reported by Knut-HåvardAksnes <etokna@eto.ericsson.se>. + +Sat Aug 31 03:07:09 1996 Ulrich Drepper <drepper@cygnus.com> + + * l10nflist.c (_nl_normalize_codeset): We convert to lower case, + so don't prepend uppercase `ISO' for only numeric arg. + +Fri Jul 19 00:15:46 1996 Ulrich Drepper <drepper@cygnus.com> + + * l10nflist.c: Move inclusion of argz.h, ctype.h, stdlib.h after + definition of _GNU_SOURCE. Patch by Roland McGrath. + + * Makefile.in (uninstall): Fix another bug with `for' loop and + empty arguments. Patch by Jim Meyering. Correct name os + uninstalled files: no intl- prefix anymore. + + * Makefile.in (install-data): Again work around shells which + cannot handle mpty for list. Reported by Jim Meyering. + +Sat Jul 13 18:11:35 1996 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in (install): Split goal. Now depend on install-exec + and install-data. + (install-exec, install-data): New goals. Created from former + install goal. + Reported by Karl Berry. + +Sat Jun 22 04:58:14 1996 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in (MKINSTALLDIRS): New variable. Path to + mkinstalldirs script. + (install): use MKINSTALLDIRS variable or if the script is not present + try to find it in the $top_scrdir). + +Wed Jun 19 02:56:56 1996 Ulrich Drepper <drepper@cygnus.com> + + * l10nflist.c: Linux libc *partly* includes the argz_* functions. + Grr. Work around by renaming the static version and use macros + for renaming. + +Tue Jun 18 20:11:17 1996 Ulrich Drepper <drepper@cygnus.com> + + * l10nflist.c: Correct presence test macros of __argz_* functions. + + * l10nflist.c: Include <argz.h> based on test of it instead when + __argz_* functions are available. + Reported by Andreas Schwab. + +Thu Jun 13 15:17:44 1996 Ulrich Drepper <drepper@cygnus.com> + + * explodename.c, l10nflist.c: Define NULL for dumb systems. + +Tue Jun 11 17:05:13 1996 Ulrich Drepper <drepper@cygnus.com> + + * intlh.inst.in, libgettext.h (dcgettext): Rename local variable + result to __result to prevent name clash. + + * l10nflist.c, localealias.c, dcgettext.c: Define _GNU_SOURCE to + get prototype for stpcpy and strcasecmp. + + * intlh.inst.in, libgettext.h: Move declaration of + `_nl_msg_cat_cntr' outside __extension__ block to prevent warning + from gcc's -Wnested-extern option. + +Fri Jun 7 01:58:00 1996 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in (install): Remove comment. + +Thu Jun 6 17:28:17 1996 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in (install): Work around for another Buglix stupidity. + Always use an `else' close for `if's. Reported by Nelson Beebe. + + * Makefile.in (intlh.inst): Correct typo in phony rule. + Reported by Nelson Beebe. + +Thu Jun 6 01:49:52 1996 Ulrich Drepper <drepper@cygnus.com> + + * dcgettext.c (read_alias_file): Rename variable alloca_list to + block_list as the macro calls assume. + Patch by Eric Backus. + + * localealias.c [!HAVE_ALLOCA]: Define alloca as macro using + malloc. + (read_alias_file): Rename varriabe alloca_list to block_list as the + macro calls assume. + Patch by Eric Backus. + + * l10nflist.c: Correct conditional for <argz.h> inclusion. + Reported by Roland McGrath. + + * Makefile.in (all): Depend on all-@USE_INCLUDED_LIBINTL@, not + all-@USE_NLS@. + + * Makefile.in (install): intlh.inst comes from local dir, not + $(srcdir). + + * Makefile.in (intlh.inst): Special handling of this goal. If + used in gettext, this is really a rul to construct this file. If + used in any other package it is defined as a .PHONY rule with + empty body. + + * finddomain.c: Extract locale file information handling into + l10nfile.c. Rename local stpcpy__ function to stpcpy. + + * dcgettext.c (stpcpy): Add local definition. + + * l10nflist.c: Solve some portability problems. Patches partly by + Thomas Esken. Add local definition of stpcpy. + +Tue Jun 4 02:47:49 1996 Ulrich Drepper <drepper@cygnus.com> + + * intlh.inst.in: Don't depend including <locale.h> on + HAVE_LOCALE_H. Instead configure must rewrite this fiile + depending on the result of the configure run. + + * Makefile.in (install): libintl.inst is now called intlh.inst. + Add rules for updating intlh.inst from intlh.inst.in. + + * libintl.inst: Renamed to intlh.inst.in. + + * localealias.c, dcgettext.c [__GNUC__]: Define HAVE_ALLOCA to 1 + because gcc has __buitlin_alloca. + Reported by Roland McGrath. + +Mon Jun 3 00:32:16 1996 Ulrich Drepper <drepper@cygnus.com> + + * Makefile.in (installcheck): New goal to fulfill needs of + automake's distcheck. + + * Makefile.in (install): Reorder commands so that VERSION is + found. + + * Makefile.in (gettextsrcdir): Now use subdirectory intl/ in + @datadir@/gettext. + (COMSRCS): Add l10nfile.c. + (OBJECTS): Add l10nfile.o. + (DISTFILES): Rename to DISTFILE.normal. Remove $(DISTFILES.common). + (DISTFILE.gettext): Remove $(DISTFILES.common). + (all-gettext): Remove goal. + (install): If $(PACKAGE) = gettext install, otherwose do nothing. No + package but gettext itself should install libintl.h + headers. + (dist): Extend goal to work for gettext, too. + (dist-gettext): Remove goal. + + * dcgettext.c [!HAVE_ALLOCA]: Define macro alloca by using malloc. + +Sun Jun 2 17:33:06 1996 Ulrich Drepper <drepper@cygnus.com> + + * loadmsgcat.c (_nl_load_domain): Parameter is now comes from + find_l10nfile. + +Sat Jun 1 02:23:03 1996 Ulrich Drepper <drepper@cygnus.com> + + * l10nflist.c (__argz_next): Add definition. + + * dcgettext.c [!HAVE_ALLOCA]: Add code for handling missing alloca + code. Use new l10nfile handling. + + * localealias.c [!HAVE_ALLOCA]: Add code for handling missing + alloca code. + + * l10nflist.c: Initial revision. + +Tue Apr 2 18:51:18 1996 Ulrich Drepper <drepper@myware> + + * Makefile.in (all-gettext): New goal. Same as all-yes. + +Thu Mar 28 23:01:22 1996 Karl Eichwalder <ke@ke.central.de> + + * Makefile.in (gettextsrcdir): Define using @datadir@. + +Tue Mar 26 12:39:14 1996 Ulrich Drepper <drepper@myware> + + * finddomain.c: Include <ctype.h>. Reported by Roland McGrath. + +Sat Mar 23 02:00:35 1996 Ulrich Drepper <drepper@myware> + + * finddomain.c (stpcpy): Rename to stpcpy__ to prevent clashing + with external declaration. + +Sat Mar 2 00:47:09 1996 Ulrich Drepper <drepper@myware> + + * Makefile.in (all-no): Rename from all_no. + +Sat Feb 17 00:25:59 1996 Ulrich Drepper <drepper@myware> + + * gettextP.h [loaded_domain]: Array `successor' must now contain up + to 63 elements (because of codeset name normalization). + + * finddomain.c: Implement codeset name normalization. + +Thu Feb 15 04:39:09 1996 Ulrich Drepper <drepper@myware> + + * Makefile.in (all): Define to `all-@USE_NLS@'. + (all-yes, all_no): New goals. `all-no' is noop, `all-yes' + is former all. + +Mon Jan 15 21:46:01 1996 Howard Gayle <howard@hal.com> + + * localealias.c (alias_compare): Increment string pointers in loop + of strcasecmp replacement. + +Fri Dec 29 21:16:34 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (install-src): Who commented this goal out ? :-) + +Fri Dec 29 15:08:16 1995 Ulrich Drepper <drepper@myware> + + * dcgettext.c (DCGETTEXT): Save `errno'. Failing system calls + should not effect it because a missing catalog is no error. + Reported by Harald K<o:>nig <koenig@tat.physik.uni-tuebingen.de>. + +Tue Dec 19 22:09:13 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (Makefile): Explicitly use $(SHELL) for running + shell scripts. + +Fri Dec 15 17:34:59 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * Makefile.in (install-src): Only install library and header when + we use the own implementation. Don't do it when using the + system's gettext or catgets functions. + + * dcgettext.c (find_msg): Must not swap domain->hash_size here. + +Sat Dec 9 16:24:37 1995 Ulrich Drepper <drepper@myware> + + * localealias.c, libintl.inst, libgettext.h, hash-string.h, + gettextP.h, finddomain.c, dcgettext.c, cat-compat.c: + Use PARAMS instead of __P. Suggested by Roland McGrath. + +Tue Dec 5 11:39:14 1995 Larry Schwimmer <rosebud@cyclone.stanford.edu> + + * libgettext.h: Use `#if !defined (_LIBINTL_H)' instead of `#if + !_LIBINTL_H' because Solaris defines _LIBINTL_H as empty. + +Mon Dec 4 15:42:07 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (install-src): + Install libintl.inst instead of libintl.h.install. + +Sat Dec 2 22:51:38 1995 Marcus Daniels <marcus@sysc.pdx.edu> + + * cat-compat.c (textdomain): + Reverse order in which files are tried you load. First + try local file, when this failed absolute path. + +Wed Nov 29 02:03:53 1995 Nelson H. F. Beebe <beebe@math.utah.edu> + + * cat-compat.c (bindtextdomain): Add missing { }. + +Sun Nov 26 18:21:41 1995 Ulrich Drepper <drepper@myware> + + * libintl.inst: Add missing __P definition. Reported by Nelson Beebe. + + * Makefile.in: + Add dummy `all' and `dvi' goals. Reported by Tom Tromey. + +Sat Nov 25 16:12:01 1995 Franc,ois Pinard <pinard@iro.umontreal.ca> + + * hash-string.h: Capitalize arguments of macros. + +Sat Nov 25 12:01:36 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (DISTFILES): Prevent files names longer than 13 + characters. libintl.h.glibc->libintl.glibc, + libintl.h.install->libintl.inst. Reported by Joshua R. Poulson. + +Sat Nov 25 11:31:12 1995 Eric Backus <ericb@lsid.hp.com> + + * dcgettext.c: Fix bug in preprocessor conditionals. + +Sat Nov 25 02:35:27 1995 Nelson H. F. Beebe <beebe@math.utah.edu> + + * libgettext.h: Solaris cc does not understand + #if !SYMBOL1 && !SYMBOL2. Sad but true. + +Thu Nov 23 16:22:14 1995 Ulrich Drepper <drepper@myware> + + * hash-string.h (hash_string): + Fix for machine with >32 bit `unsigned long's. + + * dcgettext.c (DCGETTEXT): + Fix horrible bug in loop for alternative translation. + +Thu Nov 23 01:45:29 1995 Ulrich Drepper <drepper@myware> + + * po2tbl.sed.in, linux-msg.sed, xopen-msg.sed: + Some further simplifications in message number generation. + +Mon Nov 20 21:08:43 1995 Ulrich Drepper <drepper@myware> + + * libintl.h.glibc: Use __const instead of const in prototypes. + + * Makefile.in (install-src): + Install libintl.h.install instead of libintl.h. This + is a stripped-down version. Suggested by Peter Miller. + + * libintl.h.install, libintl.h.glibc: Initial revision. + + * localealias.c (_nl_expand_alias, read_alias_file): + Protect prototypes in type casts by __P. + +Tue Nov 14 16:43:58 1995 Ulrich Drepper <drepper@myware> + + * hash-string.h: Correct prototype for hash_string. + +Sun Nov 12 12:42:30 1995 Ulrich Drepper <drepper@myware> + + * hash-string.h (hash_string): Add prototype. + + * gettextP.h: Fix copyright. + (SWAP): Add prototype. + +Wed Nov 8 22:56:33 1995 Ulrich Drepper <drepper@myware> + + * localealias.c (read_alias_file): Forgot sizeof. + Avoid calling *printf function. This introduces a big overhead. + Patch by Roland McGrath. + +Tue Nov 7 14:21:08 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c, cat-compat.c: Wrong indentation in #if for stpcpy. + + * finddomain.c (stpcpy): + Define substitution function local. The macro was to flaky. + + * cat-compat.c: Fix typo. + + * xopen-msg.sed, linux-msg.sed: + While bringing message number to right place only accept digits. + + * linux-msg.sed, xopen-msg.sed: Now that the counter does not have + leading 0s we don't need to remove them. Reported by Marcus + Daniels. + + * Makefile.in (../po/cat-id-tbl.o): Use $(top_srdir) in + dependency. Reported by Marcus Daniels. + + * cat-compat.c: (stpcpy) [!_LIBC && !HAVE_STPCPY]: Define replacement. + Generally cleanup using #if instead of #ifndef. + + * Makefile.in: Correct typos in comment. By Franc,ois Pinard. + +Mon Nov 6 00:27:02 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (install-src): Don't install libintl.h and libintl.a + if we use an available gettext implementation. + +Sun Nov 5 22:02:08 1995 Ulrich Drepper <drepper@myware> + + * libgettext.h: Fix typo: HAVE_CATGETTS -> HAVE_CATGETS. Reported + by Franc,ois Pinard. + + * libgettext.h: Use #if instead of #ifdef/#ifndef. + + * finddomain.c: + Comments describing what has to be done should start with FIXME. + +Sun Nov 5 19:38:01 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (DISTFILES): Split. Use DISTFILES with normal meaning. + DISTFILES.common names the files common to both dist goals. + DISTFILES.gettext are the files only distributed in GNU gettext. + +Sun Nov 5 17:32:54 1995 Ulrich Drepper <drepper@myware> + + * dcgettext.c (DCGETTEXT): Correct searching in derived locales. + This was necessary since a change in _nl_find_msg several weeks + ago. I really don't know this is still not fixed. + +Sun Nov 5 12:43:12 1995 Ulrich Drepper <drepper@myware> + + * loadmsgcat.c (_nl_load_domain): Test for FILENAME == NULL. This + might mark a special condition. + + * finddomain.c (make_entry_rec): Don't make illegal entry as decided. + + * Makefile.in (dist): Suppress error message when ln failed. + Get files from $(srcdir) explicitly. + + * libgettext.h (gettext_const): Rename to gettext_noop. + +Fri Nov 3 07:36:50 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c (make_entry_rec): + Protect against wrong locale names by testing mask. + + * libgettext.h (gettext_const): Add macro definition. + Capitalize macro arguments. + +Thu Nov 2 23:15:51 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c (_nl_find_domain): + Test for pointer != NULL before accessing value. + Reported by Tom Tromey. + + * gettext.c (NULL): + Define as (void*)0 instad of 0. Reported by Franc,ois Pinard. + +Mon Oct 30 21:28:52 1995 Ulrich Drepper <drepper@myware> + + * po2tbl.sed.in: Serious typo bug fixed by Jim Meyering. + +Sat Oct 28 23:20:47 1995 Ulrich Drepper <drepper@myware> + + * libgettext.h: Disable dcgettext optimization for Solaris 2.3. + + * localealias.c (alias_compare): + Peter Miller reported that tolower in some systems is + even dumber than I thought. Protect call by `isupper'. + +Fri Oct 27 22:22:51 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (libdir, includedir): New variables. + (install-src): Install libintl.a and libintl.h in correct dirs. + +Fri Oct 27 22:07:29 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (SOURCES): Fix typo: intrl.compat.c -> intl-compat.c. + + * po2tbl.sed.in: Patch for buggy SEDs by Christian von Roques. + + * localealias.c: + Fix typo and superflous test. Reported by Christian von Roques. + +Fri Oct 6 11:52:05 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c (_nl_find_domain): + Correct some remainder from the pre-CEN syntax. Now + we don't have a constant number of successors anymore. + +Wed Sep 27 21:41:13 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (DISTFILES): Add libintl.h.glibc. + + * Makefile.in (dist-libc): Add goal for packing sources for glibc. + (COMSRCS, COMHDRS): Splitted to separate sources shared with glibc. + + * loadmsgcat.c: Forget to continue #if line. + + * localealias.c: + [_LIBC]: Rename strcasecmp to __strcasecmp to keep ANSI C name + space clean. + + * dcgettext.c, finddomain.c: Better comment to last change. + + * loadmsgcat.c: + [_LIBC]: Rename fstat, open, close, read, mmap, and munmap to + __fstat, __open, __close, __read, __mmap, and __munmap resp + to keep ANSI C name space clean. + + * finddomain.c: + [_LIBC]: Rename stpcpy to __stpcpy to keep ANSI C name space clean. + + * dcgettext.c: + [_LIBC]: Rename getced and stpcpy to __getcwd and __stpcpy resp to + keep ANSI C name space clean. + + * libgettext.h: + Include sys/types.h for those old SysV systems out there. + Reported by Francesco Potorti`. + + * loadmsgcat.c (use_mmap): Define if compiled for glibc. + + * bindtextdom.c: Include all those standard headers + unconditionally if _LIBC is defined. + + * finddomain.c: Fix 2 times defiend -> defined. + + * textdomain.c: Include libintl.h instead of libgettext.h when + compiling for glibc. Include all those standard headers + unconditionally if _LIBC is defined. + + * localealias.c, loadmsgcat.c: Prepare to be compiled in glibc. + + * gettext.c: + Include libintl.h instead of libgettext.h when compiling for glibc. + Get NULL from stddef.h if we compile for glibc. + + * finddomain.c: Include libintl.h instead of libgettext.h when + compiling for glibc. Include all those standard headers + unconditionally if _LIBC is defined. + + * dcgettext.c: Include all those standard headers unconditionally + if _LIBC is defined. + + * dgettext.c: If compiled in glibc include libintl.h instead of + libgettext.h. + (locale.h): Don't rely on HAVE_LOCALE_H when compiling for glibc. + + * dcgettext.c: If compiled in glibc include libintl.h instead of + libgettext.h. + (getcwd): Don't rely on HAVE_GETCWD when compiling for glibc. + + * bindtextdom.c: + If compiled in glibc include libintl.h instead of libgettext.h. + +Mon Sep 25 22:23:06 1995 Ulrich Drepper <drepper@myware> + + * localealias.c (_nl_expand_alias): Don't call bsearch if NMAP <= 0. + Reported by Marcus Daniels. + + * cat-compat.c (bindtextdomain): + String used in putenv must not be recycled. + Reported by Marcus Daniels. + + * libgettext.h (__USE_GNU_GETTEXT): + Additional symbol to signal that we use GNU gettext + library. + + * cat-compat.c (bindtextdomain): + Fix bug with the strange stpcpy replacement. + Reported by Nelson Beebe. + +Sat Sep 23 08:23:51 1995 Ulrich Drepper <drepper@myware> + + * cat-compat.c: Include <string.h> for stpcpy prototype. + + * localealias.c (read_alias_file): + While expand strdup code temporary variable `cp' hided + higher level variable with same name. Rename to `tp'. + + * textdomain.c (textdomain): + Avoid warning by using temporary variable in strdup code. + + * finddomain.c (_nl_find_domain): Remove unused variable `application'. + +Thu Sep 21 15:51:44 1995 Ulrich Drepper <drepper@myware> + + * localealias.c (alias_compare): + Use strcasecmp() only if available. Else use + implementation in place. + + * intl-compat.c: + Wrapper functions now call *__ functions instead of __*. + + * libgettext.h: Declare prototypes for *__ functions instead for __*. + + * cat-compat.c, loadmsgcat.c: + Don't use xmalloc, xstrdup, and stpcpy. These functions are not part + of the standard libc and so prevent libintl.a from being used + standalone. + + * bindtextdom.c: + Don't use xmalloc, xstrdup, and stpcpy. These functions are not part + of the standard libc and so prevent libintl.a from being used + standalone. + Rename to bindtextdomain__ if not used in GNU C Library. + + * dgettext.c: + Rename function to dgettext__ if not used in GNU C Library. + + * gettext.c: + Don't use xmalloc, xstrdup, and stpcpy. These functions are not part + of the standard libc and so prevent libintl.a from being used + standalone. + Functions now called gettext__ if not used in GNU C Library. + + * dcgettext.c, localealias.c, textdomain.c, finddomain.c: + Don't use xmalloc, xstrdup, and stpcpy. These functions are not part + of the standard libc and so prevent libintl.a from being used + standalone. + +Sun Sep 17 23:14:49 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c: Correct some bugs in handling of CEN standard + locale definitions. + +Thu Sep 7 01:49:28 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c: Implement CEN syntax. + + * gettextP.h (loaded_domain): Extend number of successors to 31. + +Sat Aug 19 19:25:29 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (aliaspath): Remove path to X11 locale dir. + + * Makefile.in: Make install-src depend on install. This helps + gettext to install the sources and other packages can use the + install goal. + +Sat Aug 19 15:19:33 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (uninstall): Remove stuff installed by install-src. + +Tue Aug 15 13:13:53 1995 Ulrich Drepper <drepper@myware> + + * VERSION.in: Initial revision. + + * Makefile.in (DISTFILES): + Add VERSION file. This is not necessary for gettext, but + for other packages using this library. + +Tue Aug 15 06:16:44 1995 Ulrich Drepper <drepper@myware> + + * gettextP.h (_nl_find_domain): + New prototype after changing search strategy. + + * finddomain.c (_nl_find_domain): + We now try only to find a specified catalog. Fall back to other + catalogs listed in the locale list is now done in __dcgettext. + + * dcgettext.c (__dcgettext): + Now we provide message fall back even to different languages. + I.e. if a message is not available in one language all the other + in the locale list a tried. Formerly fall back was only possible + within one language. Implemented by moving one loop from + _nl_find_domain to here. + +Mon Aug 14 23:45:50 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (gettextsrcdir): + Directory where source of GNU gettext library are made + available. + (INSTALL, INSTALL_DATA): Programs used for installing sources. + (gettext-src): New. Rule to install GNU gettext sources for use in + gettextize shell script. + +Sun Aug 13 14:40:48 1995 Ulrich Drepper <drepper@myware> + + * loadmsgcat.c (_nl_load_domain): + Use mmap for loading only when munmap function is + also available. + + * Makefile.in (install): Depend on `all' goal. + +Wed Aug 9 11:04:33 1995 Ulrich Drepper <drepper@myware> + + * localealias.c (read_alias_file): + Do not overwrite '\n' when terminating alias value string. + + * localealias.c (read_alias_file): + Handle long lines. Ignore the rest not fitting in + the buffer after the initial `fgets' call. + +Wed Aug 9 00:54:29 1995 Ulrich Drepper <drepper@myware> + + * gettextP.h (_nl_load_domain): + Add prototype, replacing prototype for _nl_load_msg_cat. + + * finddomain.c (_nl_find_domain): + Remove unneeded variable filename and filename_len. + (expand_alias): Remove prototype because functions does not + exist anymore. + + * localealias.c (read_alias_file): + Change type of fname_len parameter to int. + (xmalloc): Add prototype. + + * loadmsgcat.c: Better prototypes for xmalloc. + +Tue Aug 8 22:30:39 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c (_nl_find_domain): + Allow alias name to be constructed from the four components. + + * Makefile.in (aliaspath): New variable. Set to preliminary value. + (SOURCES): Add localealias.c. + (OBJECTS): Add localealias.o. + + * gettextP.h: Add prototype for _nl_expand_alias. + + * finddomain.c: Aliasing handled in intl/localealias.c. + + * localealias.c: Aliasing for locale names. + + * bindtextdom.c: Better prototypes for xmalloc and xstrdup. + +Mon Aug 7 23:47:42 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (DISTFILES): gettext.perl is now found in misc/. + + * cat-compat.c (bindtextdomain): + Correct implementation. dirname parameter was not used. + Reported by Marcus Daniels. + + * gettextP.h (loaded_domain): + New fields `successor' and `decided' for oo, lazy + message handling implementation. + + * dcgettext.c: + Adopt for oo, lazy message handliing. + Now we can inherit translations from less specific locales. + (find_msg): New function. + + * loadmsgcat.c, finddomain.c: + Complete rewrite. Implement oo, lazy message handling :-). + We now have an additional environment variable `LANGUAGE' with + a higher priority than LC_ALL for the LC_MESSAGE locale. + Here we can set a colon separated list of specifications each + of the form `language[_territory[.codeset]][@modifier]'. + +Sat Aug 5 09:55:42 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c (unistd.h): + Include to get _PC_PATH_MAX defined on system having it. + +Fri Aug 4 22:42:00 1995 Ulrich Drepper <drepper@myware> + + * finddomain.c (stpcpy): Include prototype. + + * Makefile.in (dist): Remove `copying instead' message. + +Wed Aug 2 18:52:03 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (ID, TAGS): Do not use $^. + +Tue Aug 1 20:07:11 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (TAGS, ID): Use $^ as command argument. + (TAGS): Give etags -o option t write to current directory, + not $(srcdir). + (ID): Use $(srcdir) instead os $(top_srcdir)/src. + (distclean): Remove ID. + +Sun Jul 30 11:51:46 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (gnulocaledir): + New variable, always using share/ for data directory. + (DEFS): Add GNULOCALEDIR, used in finddomain.c. + + * finddomain.c (_nl_default_dirname): + Set to GNULOCALEDIR, because it always has to point + to the directory where GNU gettext Library writes it to. + + * intl-compat.c (textdomain, bindtextdomain): + Undefine macros before function definition. + +Sat Jul 22 01:10:02 1995 Ulrich Drepper <drepper@myware> + + * libgettext.h (_LIBINTL_H): + Protect definition in case where this file is included as + libgettext.h on Solaris machines. Add comment about this. + +Wed Jul 19 02:36:42 1995 Ulrich Drepper <drepper@myware> + + * intl-compat.c (textdomain): Correct typo. + +Wed Jul 19 01:51:35 1995 Ulrich Drepper <drepper@myware> + + * dcgettext.c (dcgettext): Function now called __dcgettext. + + * dgettext.c (dgettext): Now called __dgettext and calls + __dcgettext. + + * gettext.c (gettext): + Function now called __gettext and calls __dgettext. + + * textdomain.c (textdomain): Function now called __textdomain. + + * bindtextdom.c (bindtextdomain): Function now called + __bindtextdomain. + + * intl-compat.c: Initial revision. + + * Makefile.in (SOURCES): Add intl-compat.c. + (OBJECTS): We always compile the GNU gettext library functions. + OBJECTS contains all objects but cat-compat.o, ../po/cat-if-tbl.o, + and intl-compat.o. + (GETTOBJS): Contains now only intl-compat.o. + + * libgettext.h: + Re-include protection matches dualistic character of libgettext.h. + For all functions in GNU gettext library define __ counter part. + + * finddomain.c (strchr): Define as index if not found in C library. + (_nl_find_domain): For relative paths paste / in between. + +Tue Jul 18 16:37:45 1995 Ulrich Drepper <drepper@myware> + + * loadmsgcat.c, finddomain.c: Add inclusion of sys/types.h. + + * xopen-msg.sed: Fix bug with `msgstr ""' lines. + A little bit better comments. + +Tue Jul 18 01:18:27 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in: + po-mode.el, makelinks, combine-sh are now found in ../misc. + + * po-mode.el, makelinks, combine-sh, elisp-comp: + Moved to ../misc/. + + * libgettext.h, gettextP.h, gettext.h: Uniform test for __STDC__. + +Sun Jul 16 22:33:02 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (INSTALL, INSTALL_DATA): New variables. + (install-data, uninstall): Install/uninstall .elc file. + + * po-mode.el (Installation comment): + Add .pox as possible extension of .po files. + +Sun Jul 16 13:23:27 1995 Ulrich Drepper <drepper@myware> + + * elisp-comp: Complete new version by Franc,ois: This does not + fail when not compiling in the source directory. + +Sun Jul 16 00:12:17 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (../po/cat-id-tbl.o): + Use $(MAKE) instead of make for recursive make. + + * Makefile.in (.el.elc): Use $(SHELL) instead of /bin/sh. + (install-exec): Add missing dummy goal. + (install-data, uninstall): @ in multi-line shell command at + beginning, not in front of echo. Reported by Eric Backus. + +Sat Jul 15 00:21:28 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (DISTFILES): + Rename libgettext.perl to gettext.perl to fit in 14 chars + file systems. + + * gettext.perl: + Rename to gettext.perl to fit in 14 chars file systems. + +Thu Jul 13 23:17:20 1995 Ulrich Drepper <drepper@myware> + + * cat-compat.c: If !STDC_HEADERS try to include malloc.h. + +Thu Jul 13 20:55:02 1995 Ulrich Drepper <drepper@myware> + + * po2tbl.sed.in: Pretty printing. + + * linux-msg.sed, xopen-msg.sed: + Correct bugs with handling substitute flags in branches. + + * hash-string.h (hash_string): + Old K&R compilers don't under stand `unsigned char'. + + * gettext.h (nls_uint32): + Some old K&R compilers (eg HP) don't understand `unsigned int'. + + * cat-compat.c (msg_to_cat_id): De-ANSI-fy prototypes. + +Thu Jul 13 01:34:33 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (ELCFILES): New variable. + (DISTFILES): Add elisp-comp. + Add implicit rule for .el -> .elc compilation. + (install-data): install $ELCFILES + (clean): renamed po-to-tbl and po-to-msg to po2tbl and po2msg resp. + + * elisp-comp: Initial revision + +Wed Jul 12 16:14:52 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in: + cat-id-tbl.c is now found in po/. This enables us to use an identical + intl/ directory in all packages. + + * dcgettext.c (dcgettext): hashing does not work for table size <= 2. + + * textdomain.c: fix typo (#if def -> #if defined) + +Tue Jul 11 18:44:43 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in (stamp-cat-id): use top_srcdir to address source files + (DISTFILES,distclean): move tupdate.perl to src/ + + * po-to-tbl.sed.in: + add additional jump to clear change flag to recognize multiline strings + +Tue Jul 11 01:32:50 1995 Ulrich Drepper <drepper@myware> + + * textdomain.c: Protect inclusion of stdlib.h and string.h. + + * loadmsgcat.c: Protect inclusion of stdlib.h. + + * libgettext.h: Protect inclusion of locale.h. + Allow use in C++ programs. + Define NULL is not happened already. + + * Makefile.in (DISTFILES): ship po-to-tbl.sed.in instead of + po-to-tbl.sed. + (distclean): remove po-to-tbl.sed and tupdate.perl. + + * tupdate.perl.in: Substitute Perl path even in exec line. + Don't include entries without translation from old .po file. + +Tue Jul 4 00:41:51 1995 Ulrich Drepper <drepper@myware> + + * tupdate.perl.in: use "Updated: " in msgid "". + + * cat-compat.c: Fix typo (LOCALDIR -> LOCALEDIR). + Define getenv if !__STDC__. + + * bindtextdom.c: Protect stdlib.h and string.h inclusion. + Define free if !__STDC__. + + * finddomain.c: Change DEF_MSG_DOM_DIR to LOCALEDIR. + Define free if !__STDC__. + + * cat-compat.c: Change DEF_MSG_DOM_DIR to LOCALEDIR. + +Mon Jul 3 23:56:30 1995 Ulrich Drepper <drepper@myware> + + * Makefile.in: Use LOCALEDIR instead of DEF_MSG_DOM_DIR. + Remove unneeded $(srcdir) from Makefile.in dependency. + + * makelinks: Add copyright and short description. + + * po-mode.el: Last version for 0.7. + + * tupdate.perl.in: Fix die message. + + * dcgettext.c: Protect include of string.h. + + * gettext.c: Protect include of stdlib.h and further tries to get NULL. + + * finddomain.c: Some corrections in includes. + + * Makefile.in (INCLUDES): Prune list correct path to Makefile.in. + + * po-to-tbl.sed: Adopt for new .po file format. + + * linux-msg.sed, xopen-msg.sed: Adopt for new .po file format. + +Sun Jul 2 23:55:03 1995 Ulrich Drepper <drepper@myware> + + * tupdate.perl.in: Complete rewrite for new .po file format. + +Sun Jul 2 02:06:50 1995 Ulrich Drepper <drepper@myware> + + * First official release. This directory contains all the code + needed to internationalize own packages. It provides functions + which allow to use the X/Open catgets function with an interface + like the Uniforum gettext function. For system which does not + have neither of those a complete implementation is provided. diff --git a/dviware/mdvi/intl/Makefile.in b/dviware/mdvi/intl/Makefile.in new file mode 100644 index 0000000000..e3f47623af --- /dev/null +++ b/dviware/mdvi/intl/Makefile.in @@ -0,0 +1,104 @@ +# Makefile for directory with message catalog handling in GNU NLS Utilities. +# Copyright (C) 1995, 1996, 1997 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +include ../config.mk + +srcdir = @srcdir@ +VPATH = @srcdir@ + +includedir = $(prefix)/include +datadir = $(prefix)/@DATADIRNAME@ +gnulocaledir = $(localedir) +aliaspath = $(localedir):. +subdir = intl + +l = @l@ + +AR = ar +LIBTOOL = @LIBTOOL@ +RANLIB = @RANLIB@ + +DEFS = -DLOCALEDIR=\"$(localedir)\" -DGNULOCALEDIR=\"$(gnulocaledir)\" \ +-DLOCALE_ALIAS_PATH=\"$(aliaspath)\" @DEFS@ + +COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) + +HEADERS = $(COMHDRS) libgettext.h loadinfo.h +COMHDRS = gettext.h gettextP.h hash-string.h +SOURCES = $(COMSRCS) intl-compat.c cat-compat.c +COMSRCS = bindtextdom.c dcgettext.c dgettext.c gettext.c \ +finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c \ +explodename.c +OBJECTS = @INTLOBJS@ bindtextdom.$lo dcgettext.$lo dgettext.$lo gettext.$lo \ +finddomain.$lo loadmsgcat.$lo localealias.$lo textdomain.$lo l10nflist.$lo \ +explodename.$lo +CATOBJS = cat-compat.$lo ../po/cat-id-tbl.$lo +GETTOBJS = intl-compat.$lo +DISTFILES.common = ChangeLog Makefile.in linux-msg.sed po2tbl.sed.in \ +xopen-msg.sed $(HEADERS) $(SOURCES) +DISTFILES.normal = VERSION + +DISTFILES = $(DISTFILES.common) $(DISTFILES.normal) +DISTDIRS = + +.SUFFIXES: +.SUFFIXES: .c .o .lo +.c.o: + $(COMPILE) $< +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) $< + +INCLUDES = -I.. -I. -I$(TOPSRCDIR)/intl +CLEANABLE += *.a *.o *.lo core core.* +DISTCLEANABLE += Makefile libintl.h ID TAGS po2msg.sed po2tbl.sed + +all: all-@USE_INCLUDED_LIBINTL@ + +all-yes: libintl.$la +all-no: + +libintl.a: $(OBJECTS) + rm -f $@ + $(AR) cru $@ $(OBJECTS) + $(RANLIB) $@ + +libintl.la: $(OBJECTS) + $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJECTS) \ + -version-info 1:0 -rpath $(libdir) + +../po/cat-id-tbl.$lo: ../po/cat-id-tbl.c $(TOPSRCDIR)/po/$(PACKAGE).pot + cd ../po && $(MAKE) cat-id-tbl.$lo + +check: +install: +installcheck: +uninstall: + +$(OBJECTS): ../config.h libgettext.h +bindtextdom.$lo finddomain.$lo loadmsgcat.$lo: gettextP.h gettext.h loadinfo.h +dcgettext.$lo: gettextP.h gettext.h hash-string.h loadinfo.h + +Makefile: Makefile.in ../config.status + cd .. \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: + +include $(FRAGDIR)/dist.mk +include $(FRAGDIR)/targets.mk diff --git a/dviware/mdvi/intl/VERSION b/dviware/mdvi/intl/VERSION new file mode 100644 index 0000000000..ee66b0612b --- /dev/null +++ b/dviware/mdvi/intl/VERSION @@ -0,0 +1 @@ +GNU gettext library from gettext-0.10.35 diff --git a/dviware/mdvi/intl/bindtextdom.c b/dviware/mdvi/intl/bindtextdom.c new file mode 100644 index 0000000000..d9c3f349e0 --- /dev/null +++ b/dviware/mdvi/intl/bindtextdom.c @@ -0,0 +1,203 @@ +/* Implementation of the bindtextdomain(3) function + Copyright (C) 1995, 1996, 1997, 1998 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#else +# ifdef HAVE_MALLOC_H +# include <malloc.h> +# else +void free (); +# endif +#endif + +#if defined HAVE_STRING_H || defined _LIBC +# include <string.h> +#else +# include <strings.h> +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif +#endif + +#ifdef _LIBC +# include <libintl.h> +#else +# include "libgettext.h" +#endif +#include "gettext.h" +#include "gettextP.h" + +/* @@ end of prolog @@ */ + +/* Contains the default location of the message catalogs. */ +extern const char _nl_default_dirname[]; + +/* List with bindings of specific domains. */ +extern struct binding *_nl_domain_bindings; + + +/* Names for the libintl functions are a problem. They must not clash + with existing names and they should follow ANSI C. But this source + code is also used in GNU C Library where the names have a __ + prefix. So we have to make a difference here. */ +#ifdef _LIBC +# define BINDTEXTDOMAIN __bindtextdomain +# ifndef strdup +# define strdup(str) __strdup (str) +# endif +#else +# define BINDTEXTDOMAIN bindtextdomain__ +#endif + +/* Specify that the DOMAINNAME message catalog will be found + in DIRNAME rather than in the system locale data base. */ +char * +BINDTEXTDOMAIN (domainname, dirname) + const char *domainname; + const char *dirname; +{ + struct binding *binding; + + /* Some sanity checks. */ + if (domainname == NULL || domainname[0] == '\0') + return NULL; + + for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) + { + int compare = strcmp (domainname, binding->domainname); + if (compare == 0) + /* We found it! */ + break; + if (compare < 0) + { + /* It is not in the list. */ + binding = NULL; + break; + } + } + + if (dirname == NULL) + /* The current binding has be to returned. */ + return binding == NULL ? (char *) _nl_default_dirname : binding->dirname; + + if (binding != NULL) + { + /* The domain is already bound. If the new value and the old + one are equal we simply do nothing. Otherwise replace the + old binding. */ + if (strcmp (dirname, binding->dirname) != 0) + { + char *new_dirname; + + if (strcmp (dirname, _nl_default_dirname) == 0) + new_dirname = (char *) _nl_default_dirname; + else + { +#if defined _LIBC || defined HAVE_STRDUP + new_dirname = strdup (dirname); + if (new_dirname == NULL) + return NULL; +#else + size_t len = strlen (dirname) + 1; + new_dirname = (char *) malloc (len); + if (new_dirname == NULL) + return NULL; + + memcpy (new_dirname, dirname, len); +#endif + } + + if (binding->dirname != _nl_default_dirname) + free (binding->dirname); + + binding->dirname = new_dirname; + } + } + else + { + /* We have to create a new binding. */ +#if !defined _LIBC && !defined HAVE_STRDUP + size_t len; +#endif + struct binding *new_binding = + (struct binding *) malloc (sizeof (*new_binding)); + + if (new_binding == NULL) + return NULL; + +#if defined _LIBC || defined HAVE_STRDUP + new_binding->domainname = strdup (domainname); + if (new_binding->domainname == NULL) + return NULL; +#else + len = strlen (domainname) + 1; + new_binding->domainname = (char *) malloc (len); + if (new_binding->domainname == NULL) + return NULL; + memcpy (new_binding->domainname, domainname, len); +#endif + + if (strcmp (dirname, _nl_default_dirname) == 0) + new_binding->dirname = (char *) _nl_default_dirname; + else + { +#if defined _LIBC || defined HAVE_STRDUP + new_binding->dirname = strdup (dirname); + if (new_binding->dirname == NULL) + return NULL; +#else + len = strlen (dirname) + 1; + new_binding->dirname = (char *) malloc (len); + if (new_binding->dirname == NULL) + return NULL; + memcpy (new_binding->dirname, dirname, len); +#endif + } + + /* Now enqueue it. */ + if (_nl_domain_bindings == NULL + || strcmp (domainname, _nl_domain_bindings->domainname) < 0) + { + new_binding->next = _nl_domain_bindings; + _nl_domain_bindings = new_binding; + } + else + { + binding = _nl_domain_bindings; + while (binding->next != NULL + && strcmp (domainname, binding->next->domainname) > 0) + binding = binding->next; + + new_binding->next = binding->next; + binding->next = new_binding; + } + + binding = new_binding; + } + + return binding->dirname; +} + +#ifdef _LIBC +/* Alias for function name in GNU C Library. */ +weak_alias (__bindtextdomain, bindtextdomain); +#endif diff --git a/dviware/mdvi/intl/cat-compat.c b/dviware/mdvi/intl/cat-compat.c new file mode 100644 index 0000000000..867d901b8f --- /dev/null +++ b/dviware/mdvi/intl/cat-compat.c @@ -0,0 +1,262 @@ +/* Compatibility code for gettext-using-catgets interface. + Copyright (C) 1995, 1997 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> + +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <string.h> +#else +char *getenv (); +# ifdef HAVE_MALLOC_H +# include <malloc.h> +# endif +#endif + +#ifdef HAVE_NL_TYPES_H +# include <nl_types.h> +#endif + +#include "libgettext.h" + +/* @@ end of prolog @@ */ + +/* XPG3 defines the result of `setlocale (category, NULL)' as: + ``Directs `setlocale()' to query `category' and return the current + setting of `local'.'' + However it does not specify the exact format. And even worse: POSIX + defines this not at all. So we can use this feature only on selected + system (e.g. those using GNU C Library). */ +#ifdef _LIBC +# define HAVE_LOCALE_NULL +#endif + +/* The catalog descriptor. */ +static nl_catd catalog = (nl_catd) -1; + +/* Name of the default catalog. */ +static const char default_catalog_name[] = "messages"; + +/* Name of currently used catalog. */ +static const char *catalog_name = default_catalog_name; + +/* Get ID for given string. If not found return -1. */ +static int msg_to_cat_id PARAMS ((const char *msg)); + +/* Substitution for systems lacking this function in their C library. */ +#if !_LIBC && !HAVE_STPCPY +static char *stpcpy PARAMS ((char *dest, const char *src)); +#endif + + +/* Set currently used domain/catalog. */ +char * +textdomain (domainname) + const char *domainname; +{ + nl_catd new_catalog; + char *new_name; + size_t new_name_len; + char *lang; + +#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES \ + && defined HAVE_LOCALE_NULL + lang = setlocale (LC_MESSAGES, NULL); +#else + lang = getenv ("LC_ALL"); + if (lang == NULL || lang[0] == '\0') + { + lang = getenv ("LC_MESSAGES"); + if (lang == NULL || lang[0] == '\0') + lang = getenv ("LANG"); + } +#endif + if (lang == NULL || lang[0] == '\0') + lang = "C"; + + /* See whether name of currently used domain is asked. */ + if (domainname == NULL) + return (char *) catalog_name; + + if (domainname[0] == '\0') + domainname = default_catalog_name; + + /* Compute length of added path element. */ + new_name_len = sizeof (LOCALEDIR) - 1 + 1 + strlen (lang) + + sizeof ("/LC_MESSAGES/") - 1 + sizeof (PACKAGE) - 1 + + sizeof (".cat"); + + new_name = (char *) malloc (new_name_len); + if (new_name == NULL) + return NULL; + + strcpy (new_name, PACKAGE); + new_catalog = catopen (new_name, 0); + + if (new_catalog == (nl_catd) -1) + { + /* NLSPATH search didn't work, try absolute path */ + sprintf (new_name, "%s/%s/LC_MESSAGES/%s.cat", LOCALEDIR, lang, + PACKAGE); + new_catalog = catopen (new_name, 0); + + if (new_catalog == (nl_catd) -1) + { + free (new_name); + return (char *) catalog_name; + } + } + + /* Close old catalog. */ + if (catalog != (nl_catd) -1) + catclose (catalog); + if (catalog_name != default_catalog_name) + free ((char *) catalog_name); + + catalog = new_catalog; + catalog_name = new_name; + + return (char *) catalog_name; +} + +char * +bindtextdomain (domainname, dirname) + const char *domainname; + const char *dirname; +{ +#if HAVE_SETENV || HAVE_PUTENV + char *old_val, *new_val, *cp; + size_t new_val_len; + + /* This does not make much sense here but to be compatible do it. */ + if (domainname == NULL) + return NULL; + + /* Compute length of added path element. If we use setenv we don't need + the first byts for NLSPATH=, but why complicate the code for this + peanuts. */ + new_val_len = sizeof ("NLSPATH=") - 1 + strlen (dirname) + + sizeof ("/%L/LC_MESSAGES/%N.cat"); + + old_val = getenv ("NLSPATH"); + if (old_val == NULL || old_val[0] == '\0') + { + old_val = NULL; + new_val_len += 1 + sizeof (LOCALEDIR) - 1 + + sizeof ("/%L/LC_MESSAGES/%N.cat"); + } + else + new_val_len += strlen (old_val); + + new_val = (char *) malloc (new_val_len); + if (new_val == NULL) + return NULL; + +# if HAVE_SETENV + cp = new_val; +# else + cp = stpcpy (new_val, "NLSPATH="); +# endif + + cp = stpcpy (cp, dirname); + cp = stpcpy (cp, "/%L/LC_MESSAGES/%N.cat:"); + + if (old_val == NULL) + { +# if __STDC__ + stpcpy (cp, LOCALEDIR "/%L/LC_MESSAGES/%N.cat"); +# else + + cp = stpcpy (cp, LOCALEDIR); + stpcpy (cp, "/%L/LC_MESSAGES/%N.cat"); +# endif + } + else + stpcpy (cp, old_val); + +# if HAVE_SETENV + setenv ("NLSPATH", new_val, 1); + free (new_val); +# else + putenv (new_val); + /* Do *not* free the environment entry we just entered. It is used + from now on. */ +# endif + +#endif + + return (char *) domainname; +} + +#undef gettext +char * +gettext (msg) + const char *msg; +{ + int msgid; + + if (msg == NULL || catalog == (nl_catd) -1) + return (char *) msg; + + /* Get the message from the catalog. We always use set number 1. + The message ID is computed by the function `msg_to_cat_id' + which works on the table generated by `po-to-tbl'. */ + msgid = msg_to_cat_id (msg); + if (msgid == -1) + return (char *) msg; + + return catgets (catalog, 1, msgid, (char *) msg); +} + +/* Look through the table `_msg_tbl' which has `_msg_tbl_length' entries + for the one equal to msg. If it is found return the ID. In case when + the string is not found return -1. */ +static int +msg_to_cat_id (msg) + const char *msg; +{ + int cnt; + + for (cnt = 0; cnt < _msg_tbl_length; ++cnt) + if (strcmp (msg, _msg_tbl[cnt]._msg) == 0) + return _msg_tbl[cnt]._msg_number; + + return -1; +} + + +/* @@ begin of epilog @@ */ + +/* We don't want libintl.a to depend on any other library. So we + avoid the non-standard function stpcpy. In GNU C Library this + function is available, though. Also allow the symbol HAVE_STPCPY + to be defined. */ +#if !_LIBC && !HAVE_STPCPY +static char * +stpcpy (dest, src) + char *dest; + const char *src; +{ + while ((*dest++ = *src++) != '\0') + /* Do nothing. */ ; + return dest - 1; +} +#endif diff --git a/dviware/mdvi/intl/dcgettext.c b/dviware/mdvi/intl/dcgettext.c new file mode 100644 index 0000000000..c4c7a2c7d1 --- /dev/null +++ b/dviware/mdvi/intl/dcgettext.c @@ -0,0 +1,624 @@ +/* Implementation of the dcgettext(3) function. + Copyright (C) 1995, 1996, 1997, 1998 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <sys/types.h> + +#ifdef __GNUC__ +# define alloca __builtin_alloca +# define HAVE_ALLOCA 1 +#else +# if defined HAVE_ALLOCA_H || defined _LIBC +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca +char *alloca (); +# endif +# endif +# endif +#endif + +#include <errno.h> +#ifndef errno +extern int errno; +#endif +#ifndef __set_errno +# define __set_errno(val) errno = (val) +#endif + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#else +char *getenv (); +# ifdef HAVE_MALLOC_H +# include <malloc.h> +# else +void free (); +# endif +#endif + +#if defined HAVE_STRING_H || defined _LIBC +# ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +# endif +# include <string.h> +#else +# include <strings.h> +#endif +#if !HAVE_STRCHR && !defined _LIBC +# ifndef strchr +# define strchr index +# endif +#endif + +#if defined HAVE_UNISTD_H || defined _LIBC +# include <unistd.h> +#endif + +#include "gettext.h" +#include "gettextP.h" +#ifdef _LIBC +# include <libintl.h> +#else +# include "libgettext.h" +#endif +#include "hash-string.h" + +/* @@ end of prolog @@ */ + +#ifdef _LIBC +/* Rename the non ANSI C functions. This is required by the standard + because some ANSI C functions will require linking with this object + file and the name space must not be polluted. */ +# define getcwd __getcwd +# ifndef stpcpy +# define stpcpy __stpcpy +# endif +#else +# if !defined HAVE_GETCWD +char *getwd (); +# define getcwd(buf, max) getwd (buf) +# else +char *getcwd (); +# endif +# ifndef HAVE_STPCPY +static char *stpcpy PARAMS ((char *dest, const char *src)); +# endif +#endif + +/* Amount to increase buffer size by in each try. */ +#define PATH_INCR 32 + +/* The following is from pathmax.h. */ +/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define + PATH_MAX but might cause redefinition warnings when sys/param.h is + later included (as on MORE/BSD 4.3). */ +#if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__)) +# include <limits.h> +#endif + +#ifndef _POSIX_PATH_MAX +# define _POSIX_PATH_MAX 255 +#endif + +#if !defined(PATH_MAX) && defined(_PC_PATH_MAX) +# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX)) +#endif + +/* Don't include sys/param.h if it already has been. */ +#if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN) +# include <sys/param.h> +#endif + +#if !defined(PATH_MAX) && defined(MAXPATHLEN) +# define PATH_MAX MAXPATHLEN +#endif + +#ifndef PATH_MAX +# define PATH_MAX _POSIX_PATH_MAX +#endif + +/* XPG3 defines the result of `setlocale (category, NULL)' as: + ``Directs `setlocale()' to query `category' and return the current + setting of `local'.'' + However it does not specify the exact format. And even worse: POSIX + defines this not at all. So we can use this feature only on selected + system (e.g. those using GNU C Library). */ +#ifdef _LIBC +# define HAVE_LOCALE_NULL +#endif + +/* Name of the default domain used for gettext(3) prior any call to + textdomain(3). The default value for this is "messages". */ +const char _nl_default_default_domain[] = "messages"; + +/* Value used as the default domain for gettext(3). */ +const char *_nl_current_default_domain = _nl_default_default_domain; + +/* Contains the default location of the message catalogs. */ +const char _nl_default_dirname[] = GNULOCALEDIR; + +/* List with bindings of specific domains created by bindtextdomain() + calls. */ +struct binding *_nl_domain_bindings; + +/* Prototypes for local functions. */ +static char *find_msg PARAMS ((struct loaded_l10nfile *domain_file, + const char *msgid)) internal_function; +static const char *category_to_name PARAMS ((int category)) internal_function; +static const char *guess_category_value PARAMS ((int category, + const char *categoryname)) + internal_function; + + +/* For those loosing systems which don't have `alloca' we have to add + some additional code emulating it. */ +#ifdef HAVE_ALLOCA +/* Nothing has to be done. */ +# define ADD_BLOCK(list, address) /* nothing */ +# define FREE_BLOCKS(list) /* nothing */ +#else +struct block_list +{ + void *address; + struct block_list *next; +}; +# define ADD_BLOCK(list, addr) \ + do { \ + struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \ + /* If we cannot get a free block we cannot add the new element to \ + the list. */ \ + if (newp != NULL) { \ + newp->address = (addr); \ + newp->next = (list); \ + (list) = newp; \ + } \ + } while (0) +# define FREE_BLOCKS(list) \ + do { \ + while (list != NULL) { \ + struct block_list *old = list; \ + list = list->next; \ + free (old); \ + } \ + } while (0) +# undef alloca +# define alloca(size) (malloc (size)) +#endif /* have alloca */ + + +/* Names for the libintl functions are a problem. They must not clash + with existing names and they should follow ANSI C. But this source + code is also used in GNU C Library where the names have a __ + prefix. So we have to make a difference here. */ +#ifdef _LIBC +# define DCGETTEXT __dcgettext +#else +# define DCGETTEXT dcgettext__ +#endif + +/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY + locale. */ +char * +DCGETTEXT (domainname, msgid, category) + const char *domainname; + const char *msgid; + int category; +{ +#ifndef HAVE_ALLOCA + struct block_list *block_list = NULL; +#endif + struct loaded_l10nfile *domain; + struct binding *binding; + const char *categoryname; + const char *categoryvalue; + char *dirname, *xdomainname; + char *single_locale; + char *retval; + int saved_errno = errno; + + /* If no real MSGID is given return NULL. */ + if (msgid == NULL) + return NULL; + + /* If DOMAINNAME is NULL, we are interested in the default domain. If + CATEGORY is not LC_MESSAGES this might not make much sense but the + defintion left this undefined. */ + if (domainname == NULL) + domainname = _nl_current_default_domain; + + /* First find matching binding. */ + for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) + { + int compare = strcmp (domainname, binding->domainname); + if (compare == 0) + /* We found it! */ + break; + if (compare < 0) + { + /* It is not in the list. */ + binding = NULL; + break; + } + } + + if (binding == NULL) + dirname = (char *) _nl_default_dirname; + else if (binding->dirname[0] == '/') + dirname = binding->dirname; + else + { + /* We have a relative path. Make it absolute now. */ + size_t dirname_len = strlen (binding->dirname) + 1; + size_t path_max; + char *ret; + + path_max = (unsigned) PATH_MAX; + path_max += 2; /* The getcwd docs say to do this. */ + + dirname = (char *) alloca (path_max + dirname_len); + ADD_BLOCK (block_list, dirname); + + __set_errno (0); + while ((ret = getcwd (dirname, path_max)) == NULL && errno == ERANGE) + { + path_max += PATH_INCR; + dirname = (char *) alloca (path_max + dirname_len); + ADD_BLOCK (block_list, dirname); + __set_errno (0); + } + + if (ret == NULL) + { + /* We cannot get the current working directory. Don't signal an + error but simply return the default string. */ + FREE_BLOCKS (block_list); + __set_errno (saved_errno); + return (char *) msgid; + } + + stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname); + } + + /* Now determine the symbolic name of CATEGORY and its value. */ + categoryname = category_to_name (category); + categoryvalue = guess_category_value (category, categoryname); + + xdomainname = (char *) alloca (strlen (categoryname) + + strlen (domainname) + 5); + ADD_BLOCK (block_list, xdomainname); + + stpcpy (stpcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"), + domainname), + ".mo"); + + /* Creating working area. */ + single_locale = (char *) alloca (strlen (categoryvalue) + 1); + ADD_BLOCK (block_list, single_locale); + + + /* Search for the given string. This is a loop because we perhaps + got an ordered list of languages to consider for th translation. */ + while (1) + { + /* Make CATEGORYVALUE point to the next element of the list. */ + while (categoryvalue[0] != '\0' && categoryvalue[0] == ':') + ++categoryvalue; + if (categoryvalue[0] == '\0') + { + /* The whole contents of CATEGORYVALUE has been searched but + no valid entry has been found. We solve this situation + by implicitly appending a "C" entry, i.e. no translation + will take place. */ + single_locale[0] = 'C'; + single_locale[1] = '\0'; + } + else + { + char *cp = single_locale; + while (categoryvalue[0] != '\0' && categoryvalue[0] != ':') + *cp++ = *categoryvalue++; + *cp = '\0'; + } + + /* If the current locale value is C (or POSIX) we don't load a + domain. Return the MSGID. */ + if (strcmp (single_locale, "C") == 0 + || strcmp (single_locale, "POSIX") == 0) + { + FREE_BLOCKS (block_list); + __set_errno (saved_errno); + return (char *) msgid; + } + + + /* Find structure describing the message catalog matching the + DOMAINNAME and CATEGORY. */ + domain = _nl_find_domain (dirname, single_locale, xdomainname); + + if (domain != NULL) + { + retval = find_msg (domain, msgid); + + if (retval == NULL) + { + int cnt; + + for (cnt = 0; domain->successor[cnt] != NULL; ++cnt) + { + retval = find_msg (domain->successor[cnt], msgid); + + if (retval != NULL) + break; + } + } + + if (retval != NULL) + { + FREE_BLOCKS (block_list); + __set_errno (saved_errno); + return retval; + } + } + } + /* NOTREACHED */ +} + +#ifdef _LIBC +/* Alias for function name in GNU C Library. */ +weak_alias (__dcgettext, dcgettext); +#endif + + +static char * +internal_function +find_msg (domain_file, msgid) + struct loaded_l10nfile *domain_file; + const char *msgid; +{ + size_t top, act, bottom; + struct loaded_domain *domain; + + if (domain_file->decided == 0) + _nl_load_domain (domain_file); + + if (domain_file->data == NULL) + return NULL; + + domain = (struct loaded_domain *) domain_file->data; + + /* Locate the MSGID and its translation. */ + if (domain->hash_size > 2 && domain->hash_tab != NULL) + { + /* Use the hashing table. */ + nls_uint32 len = strlen (msgid); + nls_uint32 hash_val = hash_string (msgid); + nls_uint32 idx = hash_val % domain->hash_size; + nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2)); + nls_uint32 nstr = W (domain->must_swap, domain->hash_tab[idx]); + + if (nstr == 0) + /* Hash table entry is empty. */ + return NULL; + + if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len + && strcmp (msgid, + domain->data + W (domain->must_swap, + domain->orig_tab[nstr - 1].offset)) == 0) + return (char *) domain->data + W (domain->must_swap, + domain->trans_tab[nstr - 1].offset); + + while (1) + { + if (idx >= domain->hash_size - incr) + idx -= domain->hash_size - incr; + else + idx += incr; + + nstr = W (domain->must_swap, domain->hash_tab[idx]); + if (nstr == 0) + /* Hash table entry is empty. */ + return NULL; + + if (W (domain->must_swap, domain->orig_tab[nstr - 1].length) == len + && strcmp (msgid, + domain->data + W (domain->must_swap, + domain->orig_tab[nstr - 1].offset)) + == 0) + return (char *) domain->data + + W (domain->must_swap, domain->trans_tab[nstr - 1].offset); + } + /* NOTREACHED */ + } + + /* Now we try the default method: binary search in the sorted + array of messages. */ + bottom = 0; + top = domain->nstrings; + while (bottom < top) + { + int cmp_val; + + act = (bottom + top) / 2; + cmp_val = strcmp (msgid, domain->data + + W (domain->must_swap, + domain->orig_tab[act].offset)); + if (cmp_val < 0) + top = act; + else if (cmp_val > 0) + bottom = act + 1; + else + break; + } + + /* If an translation is found return this. */ + return bottom >= top ? NULL : (char *) domain->data + + W (domain->must_swap, + domain->trans_tab[act].offset); +} + + +/* Return string representation of locale CATEGORY. */ +static const char * +internal_function +category_to_name (category) + int category; +{ + const char *retval; + + switch (category) + { +#ifdef LC_COLLATE + case LC_COLLATE: + retval = "LC_COLLATE"; + break; +#endif +#ifdef LC_CTYPE + case LC_CTYPE: + retval = "LC_CTYPE"; + break; +#endif +#ifdef LC_MONETARY + case LC_MONETARY: + retval = "LC_MONETARY"; + break; +#endif +#ifdef LC_NUMERIC + case LC_NUMERIC: + retval = "LC_NUMERIC"; + break; +#endif +#ifdef LC_TIME + case LC_TIME: + retval = "LC_TIME"; + break; +#endif +#ifdef LC_MESSAGES + case LC_MESSAGES: + retval = "LC_MESSAGES"; + break; +#endif +#ifdef LC_RESPONSE + case LC_RESPONSE: + retval = "LC_RESPONSE"; + break; +#endif +#ifdef LC_ALL + case LC_ALL: + /* This might not make sense but is perhaps better than any other + value. */ + retval = "LC_ALL"; + break; +#endif + default: + /* If you have a better idea for a default value let me know. */ + retval = "LC_XXX"; + } + + return retval; +} + +/* Guess value of current locale from value of the environment variables. */ +static const char * +internal_function +guess_category_value (category, categoryname) + int category; + const char *categoryname; +{ + const char *retval; + + /* The highest priority value is the `LANGUAGE' environment + variable. This is a GNU extension. */ + retval = getenv ("LANGUAGE"); + if (retval != NULL && retval[0] != '\0') + return retval; + + /* `LANGUAGE' is not set. So we have to proceed with the POSIX + methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some + systems this can be done by the `setlocale' function itself. */ +#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL + return setlocale (category, NULL); +#else + /* Setting of LC_ALL overwrites all other. */ + retval = getenv ("LC_ALL"); + if (retval != NULL && retval[0] != '\0') + return retval; + + /* Next comes the name of the desired category. */ + retval = getenv (categoryname); + if (retval != NULL && retval[0] != '\0') + return retval; + + /* Last possibility is the LANG environment variable. */ + retval = getenv ("LANG"); + if (retval != NULL && retval[0] != '\0') + return retval; + + /* We use C as the default domain. POSIX says this is implementation + defined. */ + return "C"; +#endif +} + +/* @@ begin of epilog @@ */ + +/* We don't want libintl.a to depend on any other library. So we + avoid the non-standard function stpcpy. In GNU C Library this + function is available, though. Also allow the symbol HAVE_STPCPY + to be defined. */ +#if !_LIBC && !HAVE_STPCPY +static char * +stpcpy (dest, src) + char *dest; + const char *src; +{ + while ((*dest++ = *src++) != '\0') + /* Do nothing. */ ; + return dest - 1; +} +#endif + + +#ifdef _LIBC +/* If we want to free all resources we have to do some work at + program's end. */ +static void __attribute__ ((unused)) +free_mem (void) +{ + struct binding *runp; + + for (runp = _nl_domain_bindings; runp != NULL; runp = runp->next) + { + free (runp->domainname); + if (runp->dirname != _nl_default_dirname) + /* Yes, this is a pointer comparison. */ + free (runp->dirname); + } + + if (_nl_current_default_domain != _nl_default_default_domain) + /* Yes, again a pointer comparison. */ + free ((char *) _nl_current_default_domain); +} + +text_set_element (__libc_subfreeres, free_mem); +#endif diff --git a/dviware/mdvi/intl/dgettext.c b/dviware/mdvi/intl/dgettext.c new file mode 100644 index 0000000000..0510c2b071 --- /dev/null +++ b/dviware/mdvi/intl/dgettext.c @@ -0,0 +1,59 @@ +/* Implementation of the dgettext(3) function + Copyright (C) 1995, 1996, 1997 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if defined HAVE_LOCALE_H || defined _LIBC +# include <locale.h> +#endif + +#ifdef _LIBC +# include <libintl.h> +#else +# include "libgettext.h" +#endif + +/* @@ end of prolog @@ */ + +/* Names for the libintl functions are a problem. They must not clash + with existing names and they should follow ANSI C. But this source + code is also used in GNU C Library where the names have a __ + prefix. So we have to make a difference here. */ +#ifdef _LIBC +# define DGETTEXT __dgettext +# define DCGETTEXT __dcgettext +#else +# define DGETTEXT dgettext__ +# define DCGETTEXT dcgettext__ +#endif + +/* Look up MSGID in the DOMAINNAME message catalog of the current + LC_MESSAGES locale. */ +char * +DGETTEXT (domainname, msgid) + const char *domainname; + const char *msgid; +{ + return DCGETTEXT (domainname, msgid, LC_MESSAGES); +} + +#ifdef _LIBC +/* Alias for function name in GNU C Library. */ +weak_alias (__dgettext, dgettext); +#endif diff --git a/dviware/mdvi/intl/explodename.c b/dviware/mdvi/intl/explodename.c new file mode 100644 index 0000000000..8066dc2996 --- /dev/null +++ b/dviware/mdvi/intl/explodename.c @@ -0,0 +1,188 @@ +/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#endif + +#if defined HAVE_STRING_H || defined _LIBC +# include <string.h> +#else +# include <strings.h> +#endif +#include <sys/types.h> + +#include "loadinfo.h" + +/* On some strange systems still no definition of NULL is found. Sigh! */ +#ifndef NULL +# if defined __STDC__ && __STDC__ +# define NULL ((void *) 0) +# else +# define NULL 0 +# endif +#endif + +/* @@ end of prolog @@ */ + +int +_nl_explode_name (name, language, modifier, territory, codeset, + normalized_codeset, special, sponsor, revision) + char *name; + const char **language; + const char **modifier; + const char **territory; + const char **codeset; + const char **normalized_codeset; + const char **special; + const char **sponsor; + const char **revision; +{ + enum { undecided, xpg, cen } syntax; + char *cp; + int mask; + + *modifier = NULL; + *territory = NULL; + *codeset = NULL; + *normalized_codeset = NULL; + *special = NULL; + *sponsor = NULL; + *revision = NULL; + + /* Now we determine the single parts of the locale name. First + look for the language. Termination symbols are `_' and `@' if + we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */ + mask = 0; + syntax = undecided; + *language = cp = name; + while (cp[0] != '\0' && cp[0] != '_' && cp[0] != '@' + && cp[0] != '+' && cp[0] != ',') + ++cp; + + if (*language == cp) + /* This does not make sense: language has to be specified. Use + this entry as it is without exploding. Perhaps it is an alias. */ + cp = strchr (*language, '\0'); + else if (cp[0] == '_') + { + /* Next is the territory. */ + cp[0] = '\0'; + *territory = ++cp; + + while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@' + && cp[0] != '+' && cp[0] != ',' && cp[0] != '_') + ++cp; + + mask |= TERRITORY; + + if (cp[0] == '.') + { + /* Next is the codeset. */ + syntax = xpg; + cp[0] = '\0'; + *codeset = ++cp; + + while (cp[0] != '\0' && cp[0] != '@') + ++cp; + + mask |= XPG_CODESET; + + if (*codeset != cp && (*codeset)[0] != '\0') + { + *normalized_codeset = _nl_normalize_codeset (*codeset, + cp - *codeset); + if (strcmp (*codeset, *normalized_codeset) == 0) + free ((char *) *normalized_codeset); + else + mask |= XPG_NORM_CODESET; + } + } + } + + if (cp[0] == '@' || (syntax != xpg && cp[0] == '+')) + { + /* Next is the modifier. */ + syntax = cp[0] == '@' ? xpg : cen; + cp[0] = '\0'; + *modifier = ++cp; + + while (syntax == cen && cp[0] != '\0' && cp[0] != '+' + && cp[0] != ',' && cp[0] != '_') + ++cp; + + mask |= XPG_MODIFIER | CEN_AUDIENCE; + } + + if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_')) + { + syntax = cen; + + if (cp[0] == '+') + { + /* Next is special application (CEN syntax). */ + cp[0] = '\0'; + *special = ++cp; + + while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_') + ++cp; + + mask |= CEN_SPECIAL; + } + + if (cp[0] == ',') + { + /* Next is sponsor (CEN syntax). */ + cp[0] = '\0'; + *sponsor = ++cp; + + while (cp[0] != '\0' && cp[0] != '_') + ++cp; + + mask |= CEN_SPONSOR; + } + + if (cp[0] == '_') + { + /* Next is revision (CEN syntax). */ + cp[0] = '\0'; + *revision = ++cp; + + mask |= CEN_REVISION; + } + } + + /* For CEN syntax values it might be important to have the + separator character in the file name, not for XPG syntax. */ + if (syntax == xpg) + { + if (*territory != NULL && (*territory)[0] == '\0') + mask &= ~TERRITORY; + + if (*codeset != NULL && (*codeset)[0] == '\0') + mask &= ~XPG_CODESET; + + if (*modifier != NULL && (*modifier)[0] == '\0') + mask &= ~XPG_MODIFIER; + } + + return mask; +} diff --git a/dviware/mdvi/intl/finddomain.c b/dviware/mdvi/intl/finddomain.c new file mode 100644 index 0000000000..81ea29bf4e --- /dev/null +++ b/dviware/mdvi/intl/finddomain.c @@ -0,0 +1,216 @@ +/* Handle list of needed message catalogs + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <ctype.h> +#include <errno.h> +#include <stdio.h> +#include <sys/types.h> + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#else +# ifdef HAVE_MALLOC_H +# include <malloc.h> +# else +void free (); +# endif +#endif + +#if defined HAVE_STRING_H || defined _LIBC +# include <string.h> +#else +# include <strings.h> +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif +#endif +#if !HAVE_STRCHR && !defined _LIBC +# ifndef strchr +# define strchr index +# endif +#endif + +#if defined HAVE_UNISTD_H || defined _LIBC +# include <unistd.h> +#endif + +#include "gettext.h" +#include "gettextP.h" +#ifdef _LIBC +# include <libintl.h> +#else +# include "libgettext.h" +#endif + +/* @@ end of prolog @@ */ +/* List of already loaded domains. */ +static struct loaded_l10nfile *_nl_loaded_domains; + + +/* Return a data structure describing the message catalog described by + the DOMAINNAME and CATEGORY parameters with respect to the currently + established bindings. */ +struct loaded_l10nfile * +internal_function +_nl_find_domain (dirname, locale, domainname) + const char *dirname; + char *locale; + const char *domainname; +{ + struct loaded_l10nfile *retval; + const char *language; + const char *modifier; + const char *territory; + const char *codeset; + const char *normalized_codeset; + const char *special; + const char *sponsor; + const char *revision; + const char *alias_value; + int mask; + + /* LOCALE can consist of up to four recognized parts for the XPG syntax: + + language[_territory[.codeset]][@modifier] + + and six parts for the CEN syntax: + + language[_territory][+audience][+special][,[sponsor][_revision]] + + Beside the first part all of them are allowed to be missing. If + the full specified locale is not found, the less specific one are + looked for. The various parts will be stripped off according to + the following order: + (1) revision + (2) sponsor + (3) special + (4) codeset + (5) normalized codeset + (6) territory + (7) audience/modifier + */ + + /* If we have already tested for this locale entry there has to + be one data set in the list of loaded domains. */ + retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, + strlen (dirname) + 1, 0, locale, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, domainname, 0); + if (retval != NULL) + { + /* We know something about this locale. */ + int cnt; + + if (retval->decided == 0) + _nl_load_domain (retval); + + if (retval->data != NULL) + return retval; + + for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) + { + if (retval->successor[cnt]->decided == 0) + _nl_load_domain (retval->successor[cnt]); + + if (retval->successor[cnt]->data != NULL) + break; + } + return cnt >= 0 ? retval : NULL; + /* NOTREACHED */ + } + + /* See whether the locale value is an alias. If yes its value + *overwrites* the alias name. No test for the original value is + done. */ + alias_value = _nl_expand_alias (locale); + if (alias_value != NULL) + { +#if defined _LIBC || defined HAVE_STRDUP + locale = strdup (alias_value); + if (locale == NULL) + return NULL; +#else + size_t len = strlen (alias_value) + 1; + locale = (char *) malloc (len); + if (locale == NULL) + return NULL; + + memcpy (locale, alias_value, len); +#endif + } + + /* Now we determine the single parts of the locale name. First + look for the language. Termination symbols are `_' and `@' if + we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */ + mask = _nl_explode_name (locale, &language, &modifier, &territory, + &codeset, &normalized_codeset, &special, + &sponsor, &revision); + + /* Create all possible locale entries which might be interested in + generalization. */ + retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, + strlen (dirname) + 1, mask, language, territory, + codeset, normalized_codeset, modifier, special, + sponsor, revision, domainname, 1); + if (retval == NULL) + /* This means we are out of core. */ + return NULL; + + if (retval->decided == 0) + _nl_load_domain (retval); + if (retval->data == NULL) + { + int cnt; + for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) + { + if (retval->successor[cnt]->decided == 0) + _nl_load_domain (retval->successor[cnt]); + if (retval->successor[cnt]->data != NULL) + break; + } + } + + /* The room for an alias was dynamically allocated. Free it now. */ + if (alias_value != NULL) + free (locale); + + return retval; +} + + +#ifdef _LIBC +static void __attribute__ ((unused)) +free_mem (void) +{ + struct loaded_l10nfile *runp = _nl_loaded_domains; + + while (runp != NULL) + { + struct loaded_l10nfile *here = runp; + if (runp->data != NULL) + _nl_unload_domain ((struct loaded_domain *) runp->data); + runp = runp->next; + free (here); + } +} + +text_set_element (__libc_subfreeres, free_mem); +#endif diff --git a/dviware/mdvi/intl/gettext.c b/dviware/mdvi/intl/gettext.c new file mode 100644 index 0000000000..d929f98d68 --- /dev/null +++ b/dviware/mdvi/intl/gettext.c @@ -0,0 +1,70 @@ +/* Implementation of gettext(3) function. + Copyright (C) 1995, 1997 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef _LIBC +# define __need_NULL +# include <stddef.h> +#else +# ifdef STDC_HEADERS +# include <stdlib.h> /* Just for NULL. */ +# else +# ifdef HAVE_STRING_H +# include <string.h> +# else +# define NULL ((void *) 0) +# endif +# endif +#endif + +#ifdef _LIBC +# include <libintl.h> +#else +# include "libgettext.h" +#endif + +/* @@ end of prolog @@ */ + +/* Names for the libintl functions are a problem. They must not clash + with existing names and they should follow ANSI C. But this source + code is also used in GNU C Library where the names have a __ + prefix. So we have to make a difference here. */ +#ifdef _LIBC +# define GETTEXT __gettext +# define DGETTEXT __dgettext +#else +# define GETTEXT gettext__ +# define DGETTEXT dgettext__ +#endif + +/* Look up MSGID in the current default message catalog for the current + LC_MESSAGES locale. If not found, returns MSGID itself (the default + text). */ +char * +GETTEXT (msgid) + const char *msgid; +{ + return DGETTEXT (NULL, msgid); +} + +#ifdef _LIBC +/* Alias for function name in GNU C Library. */ +weak_alias (__gettext, gettext); +#endif diff --git a/dviware/mdvi/intl/gettext.h b/dviware/mdvi/intl/gettext.h new file mode 100644 index 0000000000..3cd23d7d6a --- /dev/null +++ b/dviware/mdvi/intl/gettext.h @@ -0,0 +1,105 @@ +/* Internal header for GNU gettext internationalization functions. + Copyright (C) 1995, 1997 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _GETTEXT_H +#define _GETTEXT_H 1 + +#include <stdio.h> + +#if HAVE_LIMITS_H || _LIBC +# include <limits.h> +#endif + +/* @@ end of prolog @@ */ + +/* The magic number of the GNU message catalog format. */ +#define _MAGIC 0x950412de +#define _MAGIC_SWAPPED 0xde120495 + +/* Revision number of the currently used .mo (binary) file format. */ +#define MO_REVISION_NUMBER 0 + +/* The following contortions are an attempt to use the C preprocessor + to determine an unsigned integral type that is 32 bits wide. An + alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but + doing that would require that the configure script compile and *run* + the resulting executable. Locally running cross-compiled executables + is usually not possible. */ + +#if __STDC__ +# define UINT_MAX_32_BITS 4294967295U +#else +# define UINT_MAX_32_BITS 0xFFFFFFFF +#endif + +/* If UINT_MAX isn't defined, assume it's a 32-bit type. + This should be valid for all systems GNU cares about because + that doesn't include 16-bit systems, and only modern systems + (that certainly have <limits.h>) have 64+-bit integral types. */ + +#ifndef UINT_MAX +# define UINT_MAX UINT_MAX_32_BITS +#endif + +#if UINT_MAX == UINT_MAX_32_BITS +typedef unsigned nls_uint32; +#else +# if USHRT_MAX == UINT_MAX_32_BITS +typedef unsigned short nls_uint32; +# else +# if ULONG_MAX == UINT_MAX_32_BITS +typedef unsigned long nls_uint32; +# else + /* The following line is intended to throw an error. Using #error is + not portable enough. */ + "Cannot determine unsigned 32-bit data type." +# endif +# endif +#endif + + +/* Header for binary .mo file format. */ +struct mo_file_header +{ + /* The magic number. */ + nls_uint32 magic; + /* The revision number of the file format. */ + nls_uint32 revision; + /* The number of strings pairs. */ + nls_uint32 nstrings; + /* Offset of table with start offsets of original strings. */ + nls_uint32 orig_tab_offset; + /* Offset of table with start offsets of translation strings. */ + nls_uint32 trans_tab_offset; + /* Size of hashing table. */ + nls_uint32 hash_tab_size; + /* Offset of first hashing entry. */ + nls_uint32 hash_tab_offset; +}; + +struct string_desc +{ + /* Length of addressed string. */ + nls_uint32 length; + /* Offset of string in file. */ + nls_uint32 offset; +}; + +/* @@ begin of epilog @@ */ + +#endif /* gettext.h */ diff --git a/dviware/mdvi/intl/gettextP.h b/dviware/mdvi/intl/gettextP.h new file mode 100644 index 0000000000..00c5203197 --- /dev/null +++ b/dviware/mdvi/intl/gettextP.h @@ -0,0 +1,89 @@ +/* Header describing internals of gettext library + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _GETTEXTP_H +#define _GETTEXTP_H + +#include "loadinfo.h" + +/* @@ end of prolog @@ */ + +#ifndef PARAMS +# if __STDC__ +# define PARAMS(args) args +# else +# define PARAMS(args) () +# endif +#endif + +#ifndef internal_function +# define internal_function +#endif + +#ifndef W +# define W(flag, data) ((flag) ? SWAP (data) : (data)) +#endif + + +#ifdef _LIBC +# include <byteswap.h> +# define SWAP(i) bswap_32 (i) +#else +static nls_uint32 SWAP PARAMS ((nls_uint32 i)); + +static inline nls_uint32 +SWAP (i) + nls_uint32 i; +{ + return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24); +} +#endif + + +struct loaded_domain +{ + const char *data; + int use_mmap; + size_t mmap_size; + int must_swap; + nls_uint32 nstrings; + struct string_desc *orig_tab; + struct string_desc *trans_tab; + nls_uint32 hash_size; + nls_uint32 *hash_tab; +}; + +struct binding +{ + struct binding *next; + char *domainname; + char *dirname; +}; + +struct loaded_l10nfile *_nl_find_domain PARAMS ((const char *__dirname, + char *__locale, + const char *__domainname)) + internal_function; +void _nl_load_domain PARAMS ((struct loaded_l10nfile *__domain)) + internal_function; +void _nl_unload_domain PARAMS ((struct loaded_domain *__domain)) + internal_function; + +/* @@ begin of epilog @@ */ + +#endif /* gettextP.h */ diff --git a/dviware/mdvi/intl/hash-string.h b/dviware/mdvi/intl/hash-string.h new file mode 100644 index 0000000000..cacb38e479 --- /dev/null +++ b/dviware/mdvi/intl/hash-string.h @@ -0,0 +1,59 @@ +/* Implements a string hashing function. + Copyright (C) 1995, 1997 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* @@ end of prolog @@ */ + +#ifndef PARAMS +# if __STDC__ +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +/* We assume to have `unsigned long int' value with at least 32 bits. */ +#define HASHWORDBITS 32 + + +/* Defines the so called `hashpjw' function by P.J. Weinberger + [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools, + 1986, 1987 Bell Telephone Laboratories, Inc.] */ +static unsigned long hash_string PARAMS ((const char *__str_param)); + +static inline unsigned long +hash_string (str_param) + const char *str_param; +{ + unsigned long int hval, g; + const char *str = str_param; + + /* Compute the hash value for the given string. */ + hval = 0; + while (*str != '\0') + { + hval <<= 4; + hval += (unsigned long) *str++; + g = hval & ((unsigned long) 0xf << (HASHWORDBITS - 4)); + if (g != 0) + { + hval ^= g >> (HASHWORDBITS - 8); + hval ^= g; + } + } + return hval; +} diff --git a/dviware/mdvi/intl/intl-compat.c b/dviware/mdvi/intl/intl-compat.c new file mode 100644 index 0000000000..503efa0fa9 --- /dev/null +++ b/dviware/mdvi/intl/intl-compat.c @@ -0,0 +1,76 @@ +/* intl-compat.c - Stub functions to call gettext functions from GNU gettext + Library. + Copyright (C) 1995 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 +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "libgettext.h" + +/* @@ end of prolog @@ */ + + +#undef gettext +#undef dgettext +#undef dcgettext +#undef textdomain +#undef bindtextdomain + + +char * +bindtextdomain (domainname, dirname) + const char *domainname; + const char *dirname; +{ + return bindtextdomain__ (domainname, dirname); +} + + +char * +dcgettext (domainname, msgid, category) + const char *domainname; + const char *msgid; + int category; +{ + return dcgettext__ (domainname, msgid, category); +} + + +char * +dgettext (domainname, msgid) + const char *domainname; + const char *msgid; +{ + return dgettext__ (domainname, msgid); +} + + +char * +gettext (msgid) + const char *msgid; +{ + return gettext__ (msgid); +} + + +char * +textdomain (domainname) + const char *domainname; +{ + return textdomain__ (domainname); +} diff --git a/dviware/mdvi/intl/l10nflist.c b/dviware/mdvi/intl/l10nflist.c new file mode 100644 index 0000000000..9c7dc18360 --- /dev/null +++ b/dviware/mdvi/intl/l10nflist.c @@ -0,0 +1,411 @@ +/* Handle list of needed message catalogs + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + + +#if defined HAVE_STRING_H || defined _LIBC +# ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +# endif +# include <string.h> +#else +# include <strings.h> +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif +#endif +#if !HAVE_STRCHR && !defined _LIBC +# ifndef strchr +# define strchr index +# endif +#endif + +#if defined _LIBC || defined HAVE_ARGZ_H +# include <argz.h> +#endif +#include <ctype.h> +#include <sys/types.h> + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#endif + +#include "loadinfo.h" + +/* On some strange systems still no definition of NULL is found. Sigh! */ +#ifndef NULL +# if defined __STDC__ && __STDC__ +# define NULL ((void *) 0) +# else +# define NULL 0 +# endif +#endif + +/* @@ end of prolog @@ */ + +#ifdef _LIBC +/* Rename the non ANSI C functions. This is required by the standard + because some ANSI C functions will require linking with this object + file and the name space must not be polluted. */ +# ifndef stpcpy +# define stpcpy(dest, src) __stpcpy(dest, src) +# endif +#else +# ifndef HAVE_STPCPY +static char *stpcpy PARAMS ((char *dest, const char *src)); +# endif +#endif + +/* Define function which are usually not available. */ + +#if !defined _LIBC && !defined HAVE___ARGZ_COUNT +/* Returns the number of strings in ARGZ. */ +static size_t argz_count__ PARAMS ((const char *argz, size_t len)); + +static size_t +argz_count__ (argz, len) + const char *argz; + size_t len; +{ + size_t count = 0; + while (len > 0) + { + size_t part_len = strlen (argz); + argz += part_len + 1; + len -= part_len + 1; + count++; + } + return count; +} +# undef __argz_count +# define __argz_count(argz, len) argz_count__ (argz, len) +#endif /* !_LIBC && !HAVE___ARGZ_COUNT */ + +#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY +/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's + except the last into the character SEP. */ +static void argz_stringify__ PARAMS ((char *argz, size_t len, int sep)); + +static void +argz_stringify__ (argz, len, sep) + char *argz; + size_t len; + int sep; +{ + while (len > 0) + { + size_t part_len = strlen (argz); + argz += part_len; + len -= part_len + 1; + if (len > 0) + *argz++ = sep; + } +} +# undef __argz_stringify +# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep) +#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */ + +#if !defined _LIBC && !defined HAVE___ARGZ_NEXT +static char *argz_next__ PARAMS ((char *argz, size_t argz_len, + const char *entry)); + +static char * +argz_next__ (argz, argz_len, entry) + char *argz; + size_t argz_len; + const char *entry; +{ + if (entry) + { + if (entry < argz + argz_len) + entry = strchr (entry, '\0') + 1; + + return entry >= argz + argz_len ? NULL : (char *) entry; + } + else + if (argz_len > 0) + return argz; + else + return 0; +} +# undef __argz_next +# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry) +#endif /* !_LIBC && !HAVE___ARGZ_NEXT */ + + +/* Return number of bits set in X. */ +static int pop PARAMS ((int x)); + +static inline int +pop (x) + int x; +{ + /* We assume that no more than 16 bits are used. */ + x = ((x & ~0x5555) >> 1) + (x & 0x5555); + x = ((x & ~0x3333) >> 2) + (x & 0x3333); + x = ((x >> 4) + x) & 0x0f0f; + x = ((x >> 8) + x) & 0xff; + + return x; +} + + +struct loaded_l10nfile * +_nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language, + territory, codeset, normalized_codeset, modifier, special, + sponsor, revision, filename, do_allocate) + struct loaded_l10nfile **l10nfile_list; + const char *dirlist; + size_t dirlist_len; + int mask; + const char *language; + const char *territory; + const char *codeset; + const char *normalized_codeset; + const char *modifier; + const char *special; + const char *sponsor; + const char *revision; + const char *filename; + int do_allocate; +{ + char *abs_filename; + struct loaded_l10nfile *last = NULL; + struct loaded_l10nfile *retval; + char *cp; + size_t entries; + int cnt; + + /* Allocate room for the full file name. */ + abs_filename = (char *) malloc (dirlist_len + + strlen (language) + + ((mask & TERRITORY) != 0 + ? strlen (territory) + 1 : 0) + + ((mask & XPG_CODESET) != 0 + ? strlen (codeset) + 1 : 0) + + ((mask & XPG_NORM_CODESET) != 0 + ? strlen (normalized_codeset) + 1 : 0) + + (((mask & XPG_MODIFIER) != 0 + || (mask & CEN_AUDIENCE) != 0) + ? strlen (modifier) + 1 : 0) + + ((mask & CEN_SPECIAL) != 0 + ? strlen (special) + 1 : 0) + + (((mask & CEN_SPONSOR) != 0 + || (mask & CEN_REVISION) != 0) + ? (1 + ((mask & CEN_SPONSOR) != 0 + ? strlen (sponsor) + 1 : 0) + + ((mask & CEN_REVISION) != 0 + ? strlen (revision) + 1 : 0)) : 0) + + 1 + strlen (filename) + 1); + + if (abs_filename == NULL) + return NULL; + + retval = NULL; + last = NULL; + + /* Construct file name. */ + memcpy (abs_filename, dirlist, dirlist_len); + __argz_stringify (abs_filename, dirlist_len, ':'); + cp = abs_filename + (dirlist_len - 1); + *cp++ = '/'; + cp = stpcpy (cp, language); + + if ((mask & TERRITORY) != 0) + { + *cp++ = '_'; + cp = stpcpy (cp, territory); + } + if ((mask & XPG_CODESET) != 0) + { + *cp++ = '.'; + cp = stpcpy (cp, codeset); + } + if ((mask & XPG_NORM_CODESET) != 0) + { + *cp++ = '.'; + cp = stpcpy (cp, normalized_codeset); + } + if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0) + { + /* This component can be part of both syntaces but has different + leading characters. For CEN we use `+', else `@'. */ + *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@'; + cp = stpcpy (cp, modifier); + } + if ((mask & CEN_SPECIAL) != 0) + { + *cp++ = '+'; + cp = stpcpy (cp, special); + } + if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0) + { + *cp++ = ','; + if ((mask & CEN_SPONSOR) != 0) + cp = stpcpy (cp, sponsor); + if ((mask & CEN_REVISION) != 0) + { + *cp++ = '_'; + cp = stpcpy (cp, revision); + } + } + + *cp++ = '/'; + stpcpy (cp, filename); + + /* Look in list of already loaded domains whether it is already + available. */ + last = NULL; + for (retval = *l10nfile_list; retval != NULL; retval = retval->next) + if (retval->filename != NULL) + { + int compare = strcmp (retval->filename, abs_filename); + if (compare == 0) + /* We found it! */ + break; + if (compare < 0) + { + /* It's not in the list. */ + retval = NULL; + break; + } + + last = retval; + } + + if (retval != NULL || do_allocate == 0) + { + free (abs_filename); + return retval; + } + + retval = (struct loaded_l10nfile *) + malloc (sizeof (*retval) + (__argz_count (dirlist, dirlist_len) + * (1 << pop (mask)) + * sizeof (struct loaded_l10nfile *))); + if (retval == NULL) + return NULL; + + retval->filename = abs_filename; + retval->decided = (__argz_count (dirlist, dirlist_len) != 1 + || ((mask & XPG_CODESET) != 0 + && (mask & XPG_NORM_CODESET) != 0)); + retval->data = NULL; + + if (last == NULL) + { + retval->next = *l10nfile_list; + *l10nfile_list = retval; + } + else + { + retval->next = last->next; + last->next = retval; + } + + entries = 0; + /* If the DIRLIST is a real list the RETVAL entry corresponds not to + a real file. So we have to use the DIRLIST separation mechanism + of the inner loop. */ + cnt = __argz_count (dirlist, dirlist_len) == 1 ? mask - 1 : mask; + for (; cnt >= 0; --cnt) + if ((cnt & ~mask) == 0 + && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0) + && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0)) + { + /* Iterate over all elements of the DIRLIST. */ + char *dir = NULL; + + while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir)) + != NULL) + retval->successor[entries++] + = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt, + language, territory, codeset, + normalized_codeset, modifier, special, + sponsor, revision, filename, 1); + } + retval->successor[entries] = NULL; + + return retval; +} + +/* Normalize codeset name. There is no standard for the codeset + names. Normalization allows the user to use any of the common + names. */ +const char * +_nl_normalize_codeset (codeset, name_len) + const unsigned char *codeset; + size_t name_len; +{ + int len = 0; + int only_digit = 1; + char *retval; + char *wp; + size_t cnt; + + for (cnt = 0; cnt < name_len; ++cnt) + if (isalnum (codeset[cnt])) + { + ++len; + + if (isalpha (codeset[cnt])) + only_digit = 0; + } + + retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1); + + if (retval != NULL) + { + if (only_digit) + wp = stpcpy (retval, "iso"); + else + wp = retval; + + for (cnt = 0; cnt < name_len; ++cnt) + if (isalpha (codeset[cnt])) + *wp++ = tolower (codeset[cnt]); + else if (isdigit (codeset[cnt])) + *wp++ = codeset[cnt]; + + *wp = '\0'; + } + + return (const char *) retval; +} + + +/* @@ begin of epilog @@ */ + +/* We don't want libintl.a to depend on any other library. So we + avoid the non-standard function stpcpy. In GNU C Library this + function is available, though. Also allow the symbol HAVE_STPCPY + to be defined. */ +#if !_LIBC && !HAVE_STPCPY +static char * +stpcpy (dest, src) + char *dest; + const char *src; +{ + while ((*dest++ = *src++) != '\0') + /* Do nothing. */ ; + return dest - 1; +} +#endif diff --git a/dviware/mdvi/intl/libgettext.h b/dviware/mdvi/intl/libgettext.h new file mode 100644 index 0000000000..3a92960ae3 --- /dev/null +++ b/dviware/mdvi/intl/libgettext.h @@ -0,0 +1,182 @@ +/* Message catalogs for internationalization. + Copyright (C) 1995, 1996, 1997, 1998 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Because on some systems (e.g. Solaris) we sometimes have to include + the systems libintl.h as well as this file we have more complex + include protection above. But the systems header might perhaps also + define _LIBINTL_H and therefore we have to protect the definition here. */ + +#if !defined _LIBINTL_H || !defined _LIBGETTEXT_H +#ifndef _LIBINTL_H +# define _LIBINTL_H 1 +#endif +#define _LIBGETTEXT_H 1 + +/* We define an additional symbol to signal that we use the GNU + implementation of gettext. */ +#define __USE_GNU_GETTEXT 1 + +#include <sys/types.h> + +#if HAVE_LOCALE_H +# include <locale.h> +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* @@ end of prolog @@ */ + +#ifndef PARAMS +# if __STDC__ || defined __cplusplus +# define PARAMS(args) args +# else +# define PARAMS(args) () +# endif +#endif + +#ifndef NULL +# if !defined __cplusplus || defined __GNUC__ +# define NULL ((void *) 0) +# else +# define NULL (0) +# endif +#endif + +#if !HAVE_LC_MESSAGES +/* This value determines the behaviour of the gettext() and dgettext() + function. But some system does not have this defined. Define it + to a default value. */ +# define LC_MESSAGES (-1) +#endif + + +/* Declarations for gettext-using-catgets interface. Derived from + Jim Meyering's libintl.h. */ +struct _msg_ent +{ + const char *_msg; + int _msg_number; +}; + + +#if HAVE_CATGETS +/* These two variables are defined in the automatically by po-to-tbl.sed + generated file `cat-id-tbl.c'. */ +extern const struct _msg_ent _msg_tbl[]; +extern int _msg_tbl_length; +#endif + + +/* For automatical extraction of messages sometimes no real + translation is needed. Instead the string itself is the result. */ +#define gettext_noop(Str) (Str) + +/* Look up MSGID in the current default message catalog for the current + LC_MESSAGES locale. If not found, returns MSGID itself (the default + text). */ +extern char *gettext PARAMS ((const char *__msgid)); +extern char *gettext__ PARAMS ((const char *__msgid)); + +/* Look up MSGID in the DOMAINNAME message catalog for the current + LC_MESSAGES locale. */ +extern char *dgettext PARAMS ((const char *__domainname, const char *__msgid)); +extern char *dgettext__ PARAMS ((const char *__domainname, + const char *__msgid)); + +/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY + locale. */ +extern char *dcgettext PARAMS ((const char *__domainname, const char *__msgid, + int __category)); +extern char *dcgettext__ PARAMS ((const char *__domainname, + const char *__msgid, int __category)); + + +/* Set the current default message catalog to DOMAINNAME. + If DOMAINNAME is null, return the current default. + If DOMAINNAME is "", reset to the default of "messages". */ +extern char *textdomain PARAMS ((const char *__domainname)); +extern char *textdomain__ PARAMS ((const char *__domainname)); + +/* Specify that the DOMAINNAME message catalog will be found + in DIRNAME rather than in the system locale data base. */ +extern char *bindtextdomain PARAMS ((const char *__domainname, + const char *__dirname)); +extern char *bindtextdomain__ PARAMS ((const char *__domainname, + const char *__dirname)); + +#if ENABLE_NLS + +/* Solaris 2.3 has the gettext function but dcgettext is missing. + So we omit this optimization for Solaris 2.3. BTW, Solaris 2.4 + has dcgettext. */ +# if !HAVE_CATGETS && (!HAVE_GETTEXT || HAVE_DCGETTEXT) + +# define gettext(Msgid) \ + dgettext (NULL, Msgid) + +# define dgettext(Domainname, Msgid) \ + dcgettext (Domainname, Msgid, LC_MESSAGES) + +# if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ >= 7 +/* This global variable is defined in loadmsgcat.c. We need a sign, + whether a new catalog was loaded, which can be associated with all + translations. */ +extern int _nl_msg_cat_cntr; + +# define dcgettext(Domainname, Msgid, Category) \ + (__extension__ \ + ({ \ + char *__result; \ + if (__builtin_constant_p (Msgid)) \ + { \ + static char *__translation__; \ + static int __catalog_counter__; \ + if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \ + { \ + __translation__ = \ + dcgettext__ (Domainname, Msgid, Category); \ + __catalog_counter__ = _nl_msg_cat_cntr; \ + } \ + __result = __translation__; \ + } \ + else \ + __result = dcgettext__ (Domainname, Msgid, Category); \ + __result; \ + })) +# endif +# endif + +#else + +# define gettext(Msgid) (Msgid) +# define dgettext(Domainname, Msgid) (Msgid) +# define dcgettext(Domainname, Msgid, Category) (Msgid) +# define textdomain(Domainname) ((char *) Domainname) +# define bindtextdomain(Domainname, Dirname) ((char *) Dirname) + +#endif + +/* @@ begin of epilog @@ */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dviware/mdvi/intl/linux-msg.sed b/dviware/mdvi/intl/linux-msg.sed new file mode 100644 index 0000000000..5918e720a9 --- /dev/null +++ b/dviware/mdvi/intl/linux-msg.sed @@ -0,0 +1,100 @@ +# po2msg.sed - Convert Uniforum style .po file to Linux style .msg file +# Copyright (C) 1995 Free Software Foundation, Inc. +# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. +# +# 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# +# The first directive in the .msg should be the definition of the +# message set number. We use always set number 1. +# +1 { + i\ +$set 1 # Automatically created by po2msg.sed + h + s/.*/0/ + x +} +# +# Mitch's old catalog format does not allow comments. +# +# We copy the original message as a comment into the .msg file. +# +/^msgid/ { + s/msgid[ ]*"// +# +# This does not work now with the new format. +# /"$/! { +# s/\\$// +# s/$/ ... (more lines following)"/ +# } + x +# The following nice solution is by +# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de> + td +# Increment a decimal number in pattern space. +# First hide trailing `9' digits. + :d + s/9\(_*\)$/_\1/ + td +# Assure at least one digit is available. + s/^\(_*\)$/0\1/ +# Increment the last digit. + s/8\(_*\)$/9\1/ + s/7\(_*\)$/8\1/ + s/6\(_*\)$/7\1/ + s/5\(_*\)$/6\1/ + s/4\(_*\)$/5\1/ + s/3\(_*\)$/4\1/ + s/2\(_*\)$/3\1/ + s/1\(_*\)$/2\1/ + s/0\(_*\)$/1\1/ +# Convert the hidden `9' digits to `0's. + s/_/0/g + x + G + s/\(.*\)"\n\([0-9]*\)/$ #\2 Original Message:(\1)/p +} +# +# The .msg file contains, other then the .po file, only the translations +# but each given a unique ID. Starting from 1 and incrementing by 1 for +# each message we assign them to the messages. +# It is important that the .po file used to generate the cat-id-tbl.c file +# (with po-to-tbl) is the same as the one used here. (At least the order +# of declarations must not be changed.) +# +/^msgstr/ { + s/msgstr[ ]*"\(.*\)"/# \1/ +# Clear substitution flag. + tb +# Append the next line. + :b + N +# Look whether second part is continuation line. + s/\(.*\n\)"\(.*\)"/\1\2/ +# Yes, then branch. + ta + P + D +# Note that D includes a jump to the start!! +# We found a continuation line. But before printing insert '\'. + :a + s/\(.*\)\(\n.*\)/\1\\\2/ + P +# We cannot use D here. + s/.*\n\(.*\)/\1/ + tb +} +d diff --git a/dviware/mdvi/intl/loadinfo.h b/dviware/mdvi/intl/loadinfo.h new file mode 100644 index 0000000000..f4ebf6d811 --- /dev/null +++ b/dviware/mdvi/intl/loadinfo.h @@ -0,0 +1,76 @@ +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef PARAMS +# if __STDC__ +# define PARAMS(args) args +# else +# define PARAMS(args) () +# endif +#endif + +/* Encoding of locale name parts. */ +#define CEN_REVISION 1 +#define CEN_SPONSOR 2 +#define CEN_SPECIAL 4 +#define XPG_NORM_CODESET 8 +#define XPG_CODESET 16 +#define TERRITORY 32 +#define CEN_AUDIENCE 64 +#define XPG_MODIFIER 128 + +#define CEN_SPECIFIC (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE) +#define XPG_SPECIFIC (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER) + + +struct loaded_l10nfile +{ + const char *filename; + int decided; + + const void *data; + + struct loaded_l10nfile *next; + struct loaded_l10nfile *successor[1]; +}; + + +extern const char *_nl_normalize_codeset PARAMS ((const unsigned char *codeset, + size_t name_len)); + +extern struct loaded_l10nfile * +_nl_make_l10nflist PARAMS ((struct loaded_l10nfile **l10nfile_list, + const char *dirlist, size_t dirlist_len, int mask, + const char *language, const char *territory, + const char *codeset, + const char *normalized_codeset, + const char *modifier, const char *special, + const char *sponsor, const char *revision, + const char *filename, int do_allocate)); + + +extern const char *_nl_expand_alias PARAMS ((const char *name)); + +extern int _nl_explode_name PARAMS ((char *name, const char **language, + const char **modifier, + const char **territory, + const char **codeset, + const char **normalized_codeset, + const char **special, + const char **sponsor, + const char **revision)); diff --git a/dviware/mdvi/intl/loadmsgcat.c b/dviware/mdvi/intl/loadmsgcat.c new file mode 100644 index 0000000000..515892dfb8 --- /dev/null +++ b/dviware/mdvi/intl/loadmsgcat.c @@ -0,0 +1,222 @@ +/* Load needed message catalogs. + Copyright (C) 1995, 1996, 1997, 1998 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#endif + +#if defined HAVE_UNISTD_H || defined _LIBC +# include <unistd.h> +#endif + +#if (defined HAVE_MMAP && defined HAVE_MUNMAP) || defined _LIBC +# include <sys/mman.h> +#endif + +#include "gettext.h" +#include "gettextP.h" + +/* @@ end of prolog @@ */ + +#ifdef _LIBC +/* Rename the non ISO C functions. This is required by the standard + because some ISO C functions will require linking with this object + file and the name space must not be polluted. */ +# define open __open +# define close __close +# define read __read +# define mmap __mmap +# define munmap __munmap +#endif + +/* We need a sign, whether a new catalog was loaded, which can be associated + with all translations. This is important if the translations are + cached by one of GCC's features. */ +int _nl_msg_cat_cntr = 0; + + +/* Load the message catalogs specified by FILENAME. If it is no valid + message catalog do nothing. */ +void +internal_function +_nl_load_domain (domain_file) + struct loaded_l10nfile *domain_file; +{ + int fd; + size_t size; + struct stat st; + struct mo_file_header *data = (struct mo_file_header *) -1; +#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ + || defined _LIBC + int use_mmap = 0; +#endif + struct loaded_domain *domain; + + domain_file->decided = 1; + domain_file->data = NULL; + + /* If the record does not represent a valid locale the FILENAME + might be NULL. This can happen when according to the given + specification the locale file name is different for XPG and CEN + syntax. */ + if (domain_file->filename == NULL) + return; + + /* Try to open the addressed file. */ + fd = open (domain_file->filename, O_RDONLY); + if (fd == -1) + return; + + /* We must know about the size of the file. */ + if (fstat (fd, &st) != 0 + || (size = (size_t) st.st_size) != st.st_size + || size < sizeof (struct mo_file_header)) + { + /* Something went wrong. */ + close (fd); + return; + } + +#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ + || defined _LIBC + /* Now we are ready to load the file. If mmap() is available we try + this first. If not available or it failed we try to load it. */ + data = (struct mo_file_header *) mmap (NULL, size, PROT_READ, + MAP_PRIVATE, fd, 0); + + if (data != (struct mo_file_header *) -1) + { + /* mmap() call was successful. */ + close (fd); + use_mmap = 1; + } +#endif + + /* If the data is not yet available (i.e. mmap'ed) we try to load + it manually. */ + if (data == (struct mo_file_header *) -1) + { + size_t to_read; + char *read_ptr; + + data = (struct mo_file_header *) malloc (size); + if (data == NULL) + return; + + to_read = size; + read_ptr = (char *) data; + do + { + long int nb = (long int) read (fd, read_ptr, to_read); + if (nb == -1) + { + close (fd); + return; + } + + read_ptr += nb; + to_read -= nb; + } + while (to_read > 0); + + close (fd); + } + + /* Using the magic number we can test whether it really is a message + catalog file. */ + if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED) + { + /* The magic number is wrong: not a message catalog file. */ +#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ + || defined _LIBC + if (use_mmap) + munmap ((caddr_t) data, size); + else +#endif + free (data); + return; + } + + domain_file->data + = (struct loaded_domain *) malloc (sizeof (struct loaded_domain)); + if (domain_file->data == NULL) + return; + + domain = (struct loaded_domain *) domain_file->data; + domain->data = (char *) data; +#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ + || defined _LIBC + domain->use_mmap = use_mmap; +#endif + domain->mmap_size = size; + domain->must_swap = data->magic != _MAGIC; + + /* Fill in the information about the available tables. */ + switch (W (domain->must_swap, data->revision)) + { + case 0: + domain->nstrings = W (domain->must_swap, data->nstrings); + domain->orig_tab = (struct string_desc *) + ((char *) data + W (domain->must_swap, data->orig_tab_offset)); + domain->trans_tab = (struct string_desc *) + ((char *) data + W (domain->must_swap, data->trans_tab_offset)); + domain->hash_size = W (domain->must_swap, data->hash_tab_size); + domain->hash_tab = (nls_uint32 *) + ((char *) data + W (domain->must_swap, data->hash_tab_offset)); + break; + default: + /* This is an illegal revision. */ +#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \ + || defined _LIBC + if (use_mmap) + munmap ((caddr_t) data, size); + else +#endif + free (data); + free (domain); + domain_file->data = NULL; + return; + } + + /* Show that one domain is changed. This might make some cached + translations invalid. */ + ++_nl_msg_cat_cntr; +} + + +#ifdef _LIBC +void +internal_function +_nl_unload_domain (domain) + struct loaded_domain *domain; +{ + if (domain->use_mmap) + munmap ((caddr_t) domain->data, domain->mmap_size); + else + free ((void *) domain->data); + + free (domain); +} +#endif diff --git a/dviware/mdvi/intl/localealias.c b/dviware/mdvi/intl/localealias.c new file mode 100644 index 0000000000..bca555a610 --- /dev/null +++ b/dviware/mdvi/intl/localealias.c @@ -0,0 +1,424 @@ +/* Handle aliases for locale names. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <ctype.h> +#include <stdio.h> +#include <sys/types.h> + +#ifdef __GNUC__ +# define alloca __builtin_alloca +# define HAVE_ALLOCA 1 +#else +# if defined HAVE_ALLOCA_H || defined _LIBC +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca +char *alloca (); +# endif +# endif +# endif +#endif + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#else +char *getenv (); +# ifdef HAVE_MALLOC_H +# include <malloc.h> +# else +void free (); +# endif +#endif + +#if defined HAVE_STRING_H || defined _LIBC +# ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +# endif +# include <string.h> +#else +# include <strings.h> +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif +#endif +#if !HAVE_STRCHR && !defined _LIBC +# ifndef strchr +# define strchr index +# endif +#endif + +#include "gettext.h" +#include "gettextP.h" + +/* @@ end of prolog @@ */ + +#ifdef _LIBC +/* Rename the non ANSI C functions. This is required by the standard + because some ANSI C functions will require linking with this object + file and the name space must not be polluted. */ +# define strcasecmp __strcasecmp + +# define mempcpy __mempcpy +# define HAVE_MEMPCPY 1 + +/* We need locking here since we can be called from different places. */ +# include <bits/libc-lock.h> + +__libc_lock_define_initialized (static, lock); +#endif + + +/* For those loosing systems which don't have `alloca' we have to add + some additional code emulating it. */ +#ifdef HAVE_ALLOCA +/* Nothing has to be done. */ +# define ADD_BLOCK(list, address) /* nothing */ +# define FREE_BLOCKS(list) /* nothing */ +#else +struct block_list +{ + void *address; + struct block_list *next; +}; +# define ADD_BLOCK(list, addr) \ + do { \ + struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \ + /* If we cannot get a free block we cannot add the new element to \ + the list. */ \ + if (newp != NULL) { \ + newp->address = (addr); \ + newp->next = (list); \ + (list) = newp; \ + } \ + } while (0) +# define FREE_BLOCKS(list) \ + do { \ + while (list != NULL) { \ + struct block_list *old = list; \ + list = list->next; \ + free (old); \ + } \ + } while (0) +# undef alloca +# define alloca(size) (malloc (size)) +#endif /* have alloca */ + + +struct alias_map +{ + const char *alias; + const char *value; +}; + + +static char *string_space = NULL; +static size_t string_space_act = 0; +static size_t string_space_max = 0; +static struct alias_map *map; +static size_t nmap = 0; +static size_t maxmap = 0; + + +/* Prototypes for local functions. */ +static size_t read_alias_file PARAMS ((const char *fname, int fname_len)) + internal_function; +static void extend_alias_table PARAMS ((void)); +static int alias_compare PARAMS ((const struct alias_map *map1, + const struct alias_map *map2)); + + +const char * +_nl_expand_alias (name) + const char *name; +{ + static const char *locale_alias_path = LOCALE_ALIAS_PATH; + struct alias_map *retval; + const char *result = NULL; + size_t added; + +#ifdef _LIBC + __libc_lock_lock (lock); +#endif + + do + { + struct alias_map item; + + item.alias = name; + + if (nmap > 0) + retval = (struct alias_map *) bsearch (&item, map, nmap, + sizeof (struct alias_map), + (int (*) PARAMS ((const void *, + const void *)) + ) alias_compare); + else + retval = NULL; + + /* We really found an alias. Return the value. */ + if (retval != NULL) + { + result = retval->value; + break; + } + + /* Perhaps we can find another alias file. */ + added = 0; + while (added == 0 && locale_alias_path[0] != '\0') + { + const char *start; + + while (locale_alias_path[0] == ':') + ++locale_alias_path; + start = locale_alias_path; + + while (locale_alias_path[0] != '\0' && locale_alias_path[0] != ':') + ++locale_alias_path; + + if (start < locale_alias_path) + added = read_alias_file (start, locale_alias_path - start); + } + } + while (added != 0); + +#ifdef _LIBC + __libc_lock_unlock (lock); +#endif + + return result; +} + + +static size_t +internal_function +read_alias_file (fname, fname_len) + const char *fname; + int fname_len; +{ +#ifndef HAVE_ALLOCA + struct block_list *block_list = NULL; +#endif + FILE *fp; + char *full_fname; + size_t added; + static const char aliasfile[] = "/locale.alias"; + + full_fname = (char *) alloca (fname_len + sizeof aliasfile); + ADD_BLOCK (block_list, full_fname); +#ifdef HAVE_MEMPCPY + mempcpy (mempcpy (full_fname, fname, fname_len), + aliasfile, sizeof aliasfile); +#else + memcpy (full_fname, fname, fname_len); + memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile); +#endif + + fp = fopen (full_fname, "r"); + if (fp == NULL) + { + FREE_BLOCKS (block_list); + return 0; + } + + added = 0; + while (!feof (fp)) + { + /* It is a reasonable approach to use a fix buffer here because + a) we are only interested in the first two fields + b) these fields must be usable as file names and so must not + be that long + */ + unsigned char buf[BUFSIZ]; + unsigned char *alias; + unsigned char *value; + unsigned char *cp; + + if (fgets (buf, sizeof buf, fp) == NULL) + /* EOF reached. */ + break; + + /* Possibly not the whole line fits into the buffer. Ignore + the rest of the line. */ + if (strchr (buf, '\n') == NULL) + { + char altbuf[BUFSIZ]; + do + if (fgets (altbuf, sizeof altbuf, fp) == NULL) + /* Make sure the inner loop will be left. The outer loop + will exit at the `feof' test. */ + break; + while (strchr (altbuf, '\n') == NULL); + } + + cp = buf; + /* Ignore leading white space. */ + while (isspace (cp[0])) + ++cp; + + /* A leading '#' signals a comment line. */ + if (cp[0] != '\0' && cp[0] != '#') + { + alias = cp++; + while (cp[0] != '\0' && !isspace (cp[0])) + ++cp; + /* Terminate alias name. */ + if (cp[0] != '\0') + *cp++ = '\0'; + + /* Now look for the beginning of the value. */ + while (isspace (cp[0])) + ++cp; + + if (cp[0] != '\0') + { + size_t alias_len; + size_t value_len; + + value = cp++; + while (cp[0] != '\0' && !isspace (cp[0])) + ++cp; + /* Terminate value. */ + if (cp[0] == '\n') + { + /* This has to be done to make the following test + for the end of line possible. We are looking for + the terminating '\n' which do not overwrite here. */ + *cp++ = '\0'; + *cp = '\n'; + } + else if (cp[0] != '\0') + *cp++ = '\0'; + + if (nmap >= maxmap) + extend_alias_table (); + + alias_len = strlen (alias) + 1; + value_len = strlen (value) + 1; + + if (string_space_act + alias_len + value_len > string_space_max) + { + /* Increase size of memory pool. */ + size_t new_size = (string_space_max + + (alias_len + value_len > 1024 + ? alias_len + value_len : 1024)); + char *new_pool = (char *) realloc (string_space, new_size); + if (new_pool == NULL) + { + FREE_BLOCKS (block_list); + return added; + } + string_space = new_pool; + string_space_max = new_size; + } + + map[nmap].alias = memcpy (&string_space[string_space_act], + alias, alias_len); + string_space_act += alias_len; + + map[nmap].value = memcpy (&string_space[string_space_act], + value, value_len); + string_space_act += value_len; + + ++nmap; + ++added; + } + } + } + + /* Should we test for ferror()? I think we have to silently ignore + errors. --drepper */ + fclose (fp); + + if (added > 0) + qsort (map, nmap, sizeof (struct alias_map), + (int (*) PARAMS ((const void *, const void *))) alias_compare); + + FREE_BLOCKS (block_list); + return added; +} + + +static void +extend_alias_table () +{ + size_t new_size; + struct alias_map *new_map; + + new_size = maxmap == 0 ? 100 : 2 * maxmap; + new_map = (struct alias_map *) realloc (map, (new_size + * sizeof (struct alias_map))); + if (new_map == NULL) + /* Simply don't extend: we don't have any more core. */ + return; + + map = new_map; + maxmap = new_size; +} + + +#ifdef _LIBC +static void __attribute__ ((unused)) +free_mem (void) +{ + if (string_space != NULL) + free (string_space); + if (map != NULL) + free (map); +} +text_set_element (__libc_subfreeres, free_mem); +#endif + + +static int +alias_compare (map1, map2) + const struct alias_map *map1; + const struct alias_map *map2; +{ +#if defined _LIBC || defined HAVE_STRCASECMP + return strcasecmp (map1->alias, map2->alias); +#else + const unsigned char *p1 = (const unsigned char *) map1->alias; + const unsigned char *p2 = (const unsigned char *) map2->alias; + unsigned char c1, c2; + + if (p1 == p2) + return 0; + + do + { + /* I know this seems to be odd but the tolower() function in + some systems libc cannot handle nonalpha characters. */ + c1 = isupper (*p1) ? tolower (*p1) : *p1; + c2 = isupper (*p2) ? tolower (*p2) : *p2; + if (c1 == '\0') + break; + ++p1; + ++p2; + } + while (c1 == c2); + + return c1 - c2; +#endif +} diff --git a/dviware/mdvi/intl/po2tbl.sed.in b/dviware/mdvi/intl/po2tbl.sed.in new file mode 100644 index 0000000000..b3bcca4d73 --- /dev/null +++ b/dviware/mdvi/intl/po2tbl.sed.in @@ -0,0 +1,102 @@ +# po2tbl.sed - Convert Uniforum style .po file to lookup table for catgets +# Copyright (C) 1995 Free Software Foundation, Inc. +# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. +# +# 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +1 { + i\ +/* Automatically generated by po2tbl.sed from @PACKAGE NAME@.pot. */\ +\ +#if HAVE_CONFIG_H\ +# include <config.h>\ +#endif\ +\ +#include "libgettext.h"\ +\ +const struct _msg_ent _msg_tbl[] = { + h + s/.*/0/ + x +} +# +# Write msgid entries in C array form. +# +/^msgid/ { + s/msgid[ ]*\(".*"\)/ {\1/ + tb +# Append the next line + :b + N +# Look whether second part is continuation line. + s/\(.*\)"\(\n\)"\(.*"\)/\1\2\3/ +# Yes, then branch. + ta +# Because we assume that the input file correctly formed the line +# just read cannot be again be a msgid line. So it's safe to ignore +# it. + s/\(.*\)\n.*/\1/ + bc +# We found a continuation line. But before printing insert '\'. + :a + s/\(.*\)\(\n.*\)/\1\\\2/ + P +# We cannot use D here. + s/.*\n\(.*\)/\1/ +# Some buggy seds do not clear the `successful substitution since last ``t''' +# flag on `N', so we do a `t' here to clear it. + tb +# Not reached + :c + x +# The following nice solution is by +# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de> + td +# Increment a decimal number in pattern space. +# First hide trailing `9' digits. + :d + s/9\(_*\)$/_\1/ + td +# Assure at least one digit is available. + s/^\(_*\)$/0\1/ +# Increment the last digit. + s/8\(_*\)$/9\1/ + s/7\(_*\)$/8\1/ + s/6\(_*\)$/7\1/ + s/5\(_*\)$/6\1/ + s/4\(_*\)$/5\1/ + s/3\(_*\)$/4\1/ + s/2\(_*\)$/3\1/ + s/1\(_*\)$/2\1/ + s/0\(_*\)$/1\1/ +# Convert the hidden `9' digits to `0's. + s/_/0/g + x + G + s/\(.*\)\n\([0-9]*\)/\1, \2},/ + s/\(.*\)"$/\1/ + p +} +# +# Last line. +# +$ { + i\ +};\ + + g + s/0*\(.*\)/int _msg_tbl_length = \1;/p +} +d diff --git a/dviware/mdvi/intl/textdomain.c b/dviware/mdvi/intl/textdomain.c new file mode 100644 index 0000000000..88557460f3 --- /dev/null +++ b/dviware/mdvi/intl/textdomain.c @@ -0,0 +1,108 @@ +/* Implementation of the textdomain(3) function. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. + + 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 + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if defined STDC_HEADERS || defined _LIBC +# include <stdlib.h> +#endif + +#if defined STDC_HEADERS || defined HAVE_STRING_H || defined _LIBC +# include <string.h> +#else +# include <strings.h> +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif +#endif + +#ifdef _LIBC +# include <libintl.h> +#else +# include "libgettext.h" +#endif + +/* @@ end of prolog @@ */ + +/* Name of the default text domain. */ +extern const char _nl_default_default_domain[]; + +/* Default text domain in which entries for gettext(3) are to be found. */ +extern const char *_nl_current_default_domain; + + +/* Names for the libintl functions are a problem. They must not clash + with existing names and they should follow ANSI C. But this source + code is also used in GNU C Library where the names have a __ + prefix. So we have to make a difference here. */ +#ifdef _LIBC +# define TEXTDOMAIN __textdomain +# ifndef strdup +# define strdup(str) __strdup (str) +# endif +#else +# define TEXTDOMAIN textdomain__ +#endif + +/* Set the current default message catalog to DOMAINNAME. + If DOMAINNAME is null, return the current default. + If DOMAINNAME is "", reset to the default of "messages". */ +char * +TEXTDOMAIN (domainname) + const char *domainname; +{ + char *old; + + /* A NULL pointer requests the current setting. */ + if (domainname == NULL) + return (char *) _nl_current_default_domain; + + old = (char *) _nl_current_default_domain; + + /* If domain name is the null string set to default domain "messages". */ + if (domainname[0] == '\0' + || strcmp (domainname, _nl_default_default_domain) == 0) + _nl_current_default_domain = _nl_default_default_domain; + else + { + /* If the following malloc fails `_nl_current_default_domain' + will be NULL. This value will be returned and so signals we + are out of core. */ +#if defined _LIBC || defined HAVE_STRDUP + _nl_current_default_domain = strdup (domainname); +#else + size_t len = strlen (domainname) + 1; + char *cp = (char *) malloc (len); + if (cp != NULL) + memcpy (cp, domainname, len); + _nl_current_default_domain = cp; +#endif + } + + if (old != _nl_default_default_domain) + free (old); + + return (char *) _nl_current_default_domain; +} + +#ifdef _LIBC +/* Alias for function name in GNU C Library. */ +weak_alias (__textdomain, textdomain); +#endif diff --git a/dviware/mdvi/intl/xopen-msg.sed b/dviware/mdvi/intl/xopen-msg.sed new file mode 100644 index 0000000000..b19c0bbd0e --- /dev/null +++ b/dviware/mdvi/intl/xopen-msg.sed @@ -0,0 +1,104 @@ +# po2msg.sed - Convert Uniforum style .po file to X/Open style .msg file +# Copyright (C) 1995 Free Software Foundation, Inc. +# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. +# +# 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# +# The first directive in the .msg should be the definition of the +# message set number. We use always set number 1. +# +1 { + i\ +$set 1 # Automatically created by po2msg.sed + h + s/.*/0/ + x +} +# +# We copy all comments into the .msg file. Perhaps they can help. +# +/^#/ s/^#[ ]*/$ /p +# +# We copy the original message as a comment into the .msg file. +# +/^msgid/ { +# Does not work now +# /"$/! { +# s/\\$// +# s/$/ ... (more lines following)"/ +# } + s/^msgid[ ]*"\(.*\)"$/$ Original Message: \1/ + p +} +# +# The .msg file contains, other then the .po file, only the translations +# but each given a unique ID. Starting from 1 and incrementing by 1 for +# each message we assign them to the messages. +# It is important that the .po file used to generate the cat-id-tbl.c file +# (with po-to-tbl) is the same as the one used here. (At least the order +# of declarations must not be changed.) +# +/^msgstr/ { + s/msgstr[ ]*"\(.*\)"/\1/ + x +# The following nice solution is by +# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de> + td +# Increment a decimal number in pattern space. +# First hide trailing `9' digits. + :d + s/9\(_*\)$/_\1/ + td +# Assure at least one digit is available. + s/^\(_*\)$/0\1/ +# Increment the last digit. + s/8\(_*\)$/9\1/ + s/7\(_*\)$/8\1/ + s/6\(_*\)$/7\1/ + s/5\(_*\)$/6\1/ + s/4\(_*\)$/5\1/ + s/3\(_*\)$/4\1/ + s/2\(_*\)$/3\1/ + s/1\(_*\)$/2\1/ + s/0\(_*\)$/1\1/ +# Convert the hidden `9' digits to `0's. + s/_/0/g + x +# Bring the line in the format `<number> <message>' + G + s/^[^\n]*$/& / + s/\(.*\)\n\([0-9]*\)/\2 \1/ +# Clear flag from last substitution. + tb +# Append the next line. + :b + N +# Look whether second part is a continuation line. + s/\(.*\n\)"\(.*\)"/\1\2/ +# Yes, then branch. + ta + P + D +# Note that `D' includes a jump to the start!! +# We found a continuation line. But before printing insert '\'. + :a + s/\(.*\)\(\n.*\)/\1\\\2/ + P +# We cannot use the sed command `D' here + s/.*\n\(.*\)/\1/ + tb +} +d diff --git a/dviware/mdvi/lib/Makefile.in b/dviware/mdvi/lib/Makefile.in new file mode 100644 index 0000000000..9ad27f3d91 --- /dev/null +++ b/dviware/mdvi/lib/Makefile.in @@ -0,0 +1,66 @@ + +srcdir = @srcdir@ +VPATH = @srcdir@ + +include ../config.mk + +SUBDIRS = po + +LOCAL_CFLAGS = $(KPSE_CFLAGS) -I$(srcdir) -I.. -I$(srcdir)/../include +ALL_CFLAGS = $(CFLAGS) $(ADDCFLAGS) $(CPPFLAGS) $(LOCAL_CFLAGS) + +OBJS = common.o util.o pk.o gf.o vf.o bitmap.o font.o list.o \ + dviread.o paper.o pagesel.o setup.o special.o tfm.o sp-epsf.o \ + dvimisc.o hash.o assoc.o tfmfile.o t1.o tt.o fontmap.o \ + afmparse.o fontsrch.o files.o +SOURCES = common.c util.c pk.c gf.c vf.c bitmap.c font.c list.c \ + dviread.c paper.c pagesel.c setup.c special.c tfm.c sp-epsf.c \ + dvimisc.c hash.c assoc.c tfmfile.c t1.c tt.c fontmap.c \ + afmparse.c fontsrch.c files.c +HEADERS = bitmap.h common.h defaults.h dviopcodes.h fontmap.h mdvi.h sysdeps.h + +ALL_SOURCES = $(SOURCES) +ALL_HEADERS = $(addprefix $(srcdir)/../include/, $(HEADERS)) +OTHERFILES = Makefile.in afmparse.h + +# Dedendency files depend on these +DEPSOURCES = $(SOURCES) +DEPCFLAGS = $(LOCAL_CFLAGS) $(T1LIB_CFLAGS) $(FREETYPE_CFLAGS) + +# Files we distribute +DISTFILES = $(ALL_SOURCES) ../include $(OTHERFILES) po + +# Files that we clean on the `clean' and `distclean' targets resp. +CLEANABLE += $(OBJS) $(MDVILIB) +DISTCLEANABLE += Makefile + +# The main target of this Makefile +MDVILIB = mdvi.a + +.PHONY: all $(SUBDIRS) +all: $(MDVILIB) $(SUBDIRS) + +$(SUBDIRS): + if test -d "$@"; then $(MAKE) -C $@; else :; fi + +.PHONY: install uninstall +install: +uninstall: + +$(MDVILIB): $(OBJS) + $(MAKELIB) $@ $(OBJS) + +.SUFFIXES: +.SUFFIXES: .c .o + +.c.o: + $(CC) $(ALL_CFLAGS) -c $< + +t1.o: t1.c + $(CC) $(ALL_CFLAGS) $(T1LIB_CFLAGS) -c $< +tt.o: tt.c + $(CC) $(ALL_CFLAGS) $(FREETYPE_CFLAGS) -c $< + +include $(FRAGDIR)/dist.mk +include $(FRAGDIR)/targets.mk +include $(FRAGDIR)/depend.mk diff --git a/dviware/mdvi/lib/afmparse.c b/dviware/mdvi/lib/afmparse.c new file mode 100644 index 0000000000..5b8ac68090 --- /dev/null +++ b/dviware/mdvi/lib/afmparse.c @@ -0,0 +1,1302 @@ +/* + * (C) 1988, 1989, 1990 by Adobe Systems Incorporated. All rights reserved. + * + * This file may be freely copied and redistributed as long as: + * 1) This entire notice continues to be included in the file, + * 2) If the file has been modified in any way, a notice of such + * modification is conspicuously indicated. + * + * PostScript, Display PostScript, and Adobe are registered trademarks of + * Adobe Systems Incorporated. + * + * ************************************************************************ + * THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT + * NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS + * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR + * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY + * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, + * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * ************************************************************************ + */ + +/* + * modified for MDVI: + * - some names changed to avoid conflicts with T1lib + * - changed to ANSI C prototypes, as used by MDVI + * mal - 3/01 + */ + +/* parseAFM.c + * + * This file is used in conjuction with the parseAFM.h header file. + * This file contains several procedures that are used to parse AFM + * files. It is intended to work with an application program that needs + * font metric information. The program can be used as is by making a + * procedure call to "parseFile" (passing in the expected parameters) + * and having it fill in a data structure with the data from the + * AFM file, or an application developer may wish to customize this + * code. + * + * There is also a file, parseAFMclient.c, that is a sample application + * showing how to call the "parseFile" procedure and how to use the data + * after "parseFile" has returned. + * + * Please read the comments in parseAFM.h and parseAFMclient.c. + * + * History: + * original: DSM Thu Oct 20 17:39:59 PDT 1988 + * modified: DSM Mon Jul 3 14:17:50 PDT 1989 + * - added 'storageProblem' return code + * - fixed bug of not allocating extra byte for string duplication + * - fixed typos + * modified: DSM Tue Apr 3 11:18:34 PDT 1990 + * - added free(ident) at end of parseFile routine + * modified: DSM Tue Jun 19 10:16:29 PDT 1990 + * - changed (width == 250) to (width = 250) in initializeArray + */ + +#include "sysdeps.h" + +#ifdef WITH_AFM_FILES + +#include <stdlib.h> /* added for MDVI */ +#include <string.h> /* added for MDVI */ + +#include <stdio.h> +#include <errno.h> +#include <sys/file.h> +#include <math.h> +#include "afmparse.h" +#undef VERSION + +#define lineterm EOL /* line terminating character */ +#define normalEOF 1 /* return code from parsing routines used only */ + /* in this module */ +#define Space "space" /* used in string comparison to look for the width */ + /* of the space character to init the widths array */ +#define False "false" /* used in string comparison to check the value of */ + /* boolean keys (e.g. IsFixedPitch) */ + +#define MATCH(A,B) (strncmp((A),(B), MAX_NAME) == 0) + + + +/*************************** GLOBALS ***********************/ + +static char *ident = NULL; /* storage buffer for keywords */ + + +/* "shorts" for fast case statement + * The values of each of these enumerated items correspond to an entry in the + * table of strings defined below. Therefore, if you add a new string as + * new keyword into the keyStrings table, you must also add a corresponding + * parseKey AND it MUST be in the same position! + * + * IMPORTANT: since the sorting algorithm is a binary search, the strings of + * keywords must be placed in lexicographical order, below. [Therefore, the + * enumerated items are not necessarily in lexicographical order, depending + * on the name chosen. BUT, they must be placed in the same position as the + * corresponding key string.] The NOPE shall remain in the last position, + * since it does not correspond to any key string, and it is used in the + * "recognize" procedure to calculate how many possible keys there are. + */ + +enum parseKey { + ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, COMMENT, + DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES, + ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN, + FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME, ISFIXEDPITCH, + ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME, + NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES, + STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS, + STARTTRACKKERN, TRACKKERN, UNDERLINEPOSITION, + UNDERLINETHICKNESS, VERSION, XYWIDTH, XWIDTH, WEIGHT, XHEIGHT, + NOPE } ; + +/* keywords for the system: + * This a table of all of the current strings that are vaild AFM keys. + * Each entry can be referenced by the appropriate parseKey value (an + * enumerated data type defined above). If you add a new keyword here, + * a corresponding parseKey MUST be added to the enumerated data type + * defined above, AND it MUST be added in the same position as the + * string is in this table. + * + * IMPORTANT: since the sorting algorithm is a binary search, the keywords + * must be placed in lexicographical order. And, NULL should remain at the + * end. + */ + +static char *keyStrings[] = { + "Ascender", "B", "C", "CC", "CapHeight", "Comment", + "Descender", "EncodingScheme", "EndCharMetrics", "EndComposites", + "EndFontMetrics", "EndKernData", "EndKernPairs", "EndTrackKern", + "FamilyName", "FontBBox", "FontName", "FullName", "IsFixedPitch", + "ItalicAngle", "KP", "KPX", "L", "N", + "Notice", "PCC", "StartCharMetrics", "StartComposites", + "StartFontMetrics", "StartKernData", "StartKernPairs", + "StartTrackKern", "TrackKern", "UnderlinePosition", + "UnderlineThickness", "Version", "W", "WX", "Weight", "XHeight", + NULL }; + +/*************************** PARSING ROUTINES **************/ + +/*************************** token *************************/ + +/* A "AFM File Conventions" tokenizer. That means that it will + * return the next token delimited by white space. See also + * the `linetoken' routine, which does a similar thing but + * reads all tokens until the next end-of-line. + */ + +static char *token(FILE *stream) +{ + int ch, idx; + + /* skip over white space */ + while ((ch = fgetc(stream)) == ' ' || ch == lineterm || + ch == ',' || ch == '\t' || ch == ';'); + + idx = 0; + while (ch != EOF && ch != ' ' && ch != lineterm + && ch != '\t' && ch != ':' && ch != ';') + { + ident[idx++] = ch; + ch = fgetc(stream); + } /* while */ + + if (ch == EOF && idx < 1) return ((char *)NULL); + if (idx >= 1 && ch != ':' ) ungetc(ch, stream); + if (idx < 1 ) ident[idx++] = ch; /* single-character token */ + ident[idx] = 0; + + return(ident); /* returns pointer to the token */ + +} /* token */ + + +/*************************** linetoken *************************/ + +/* "linetoken" will get read all tokens until the EOL character from + * the given stream. This is used to get any arguments that can be + * more than one word (like Comment lines and FullName). + */ + +static char *linetoken(FILE *stream) +{ + int ch, idx; + + while ((ch = fgetc(stream)) == ' ' || ch == '\t' ); + + idx = 0; + while (ch != EOF && ch != lineterm) + { + ident[idx++] = ch; + ch = fgetc(stream); + } /* while */ + + ungetc(ch, stream); + ident[idx] = 0; + + return(ident); /* returns pointer to the token */ + +} /* linetoken */ + + +/*************************** recognize *************************/ + +/* This function tries to match a string to a known list of + * valid AFM entries (check the keyStrings array above). + * "ident" contains everything from white space through the + * next space, tab, or ":" character. + * + * The algorithm is a standard Knuth binary search. + */ + +static enum parseKey recognize(char *ident) +{ + int lower = 0, upper = (int) NOPE, midpoint, cmpvalue; + BOOL found = FALSE; + + while ((upper >= lower) && !found) + { + midpoint = (lower + upper)/2; + if (keyStrings[midpoint] == NULL) break; + cmpvalue = strncmp(ident, keyStrings[midpoint], MAX_NAME); + if (cmpvalue == 0) found = TRUE; + else if (cmpvalue < 0) upper = midpoint - 1; + else lower = midpoint + 1; + } /* while */ + + if (found) return (enum parseKey) midpoint; + else return NOPE; + +} /* recognize */ + + +/************************* parseGlobals *****************************/ + +/* This function is called by "parseFile". It will parse the AFM File + * up to the "StartCharMetrics" keyword, which essentially marks the + * end of the Global Font Information and the beginning of the character + * metrics information. + * + * If the caller of "parseFile" specified that it wanted the Global + * Font Information (as defined by the "AFM File Specification" + * document), then that information will be stored in the returned + * data structure. + * + * Any Global Font Information entries that are not found in a + * given file, will have the usual default initialization value + * for its type (i.e. entries of type int will be 0, etc). + * + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by + * parseFile to determine if there is more file to parse. + */ + +static BOOL parseGlobals(FILE *fp, GlobalFontInfo *gfi) +{ + BOOL cont = TRUE, save = (gfi != NULL); + int error = ok; + register char *keyword; + + while (cont) + { + keyword = token(fp); + + if (keyword == NULL) + /* Have reached an early and unexpected EOF. */ + /* Set flag and stop parsing */ + { + error = earlyEOF; + break; /* get out of loop */ + } + if (!save) + /* get tokens until the end of the Global Font info section */ + /* without saving any of the data */ + switch (recognize(keyword)) + { + case STARTCHARMETRICS: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + default: + break; + } /* switch */ + else + /* otherwise parse entire global font info section, */ + /* saving the data */ + switch(recognize(keyword)) + { + case STARTFONTMETRICS: + keyword = token(fp); + gfi->afmVersion = (char *) malloc(strlen(keyword) + 1); + strcpy(gfi->afmVersion, keyword); + break; + case COMMENT: + keyword = linetoken(fp); + break; + case FONTNAME: + keyword = token(fp); + gfi->fontName = (char *) malloc(strlen(keyword) + 1); + strcpy(gfi->fontName, keyword); + break; + case ENCODINGSCHEME: + keyword = token(fp); + gfi->encodingScheme = (char *) + malloc(strlen(keyword) + 1); + strcpy(gfi->encodingScheme, keyword); + break; + case FULLNAME: + keyword = linetoken(fp); + gfi->fullName = (char *) malloc(strlen(keyword) + 1); + strcpy(gfi->fullName, keyword); + break; + case FAMILYNAME: + keyword = linetoken(fp); + gfi->familyName = (char *) malloc(strlen(keyword) + 1); + strcpy(gfi->familyName, keyword); + break; + case WEIGHT: + keyword = token(fp); + gfi->weight = (char *) malloc(strlen(keyword) + 1); + strcpy(gfi->weight, keyword); + break; + case ITALICANGLE: + keyword = token(fp); + gfi->italicAngle = atof(keyword); + if (errno == ERANGE) error = parseError; + break; + case ISFIXEDPITCH: + keyword = token(fp); + if (MATCH(keyword, False)) + gfi->isFixedPitch = 0; + else + gfi->isFixedPitch = 1; + break; + case UNDERLINEPOSITION: + keyword = token(fp); + gfi->underlinePosition = atoi(keyword); + break; + case UNDERLINETHICKNESS: + keyword = token(fp); + gfi->underlineThickness = atoi(keyword); + break; + case VERSION: + keyword = token(fp); + gfi->version = (char *) malloc(strlen(keyword) + 1); + strcpy(gfi->version, keyword); + break; + case NOTICE: + keyword = linetoken(fp); + gfi->notice = (char *) malloc(strlen(keyword) + 1); + strcpy(gfi->notice, keyword); + break; + case FONTBBOX: + keyword = token(fp); + gfi->fontBBox.llx = atoi(keyword); + keyword = token(fp); + gfi->fontBBox.lly = atoi(keyword); + keyword = token(fp); + gfi->fontBBox.urx = atoi(keyword); + keyword = token(fp); + gfi->fontBBox.ury = atoi(keyword); + break; + case CAPHEIGHT: + keyword = token(fp); + gfi->capHeight = atoi(keyword); + break; + case XHEIGHT: + keyword = token(fp); + gfi->xHeight = atoi(keyword); + break; + case DESCENDER: + keyword = token(fp); + gfi->descender = atoi(keyword); + break; + case ASCENDER: + keyword = token(fp); + gfi->ascender = atoi(keyword); + break; + case STARTCHARMETRICS: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + case NOPE: + default: + error = parseError; + break; + } /* switch */ + } /* while */ + + return(error); + +} /* parseGlobals */ + + + +#if 0 /* this function does not seem to be used anywhere */ +/************************* initializeArray ************************/ + +/* Unmapped character codes are (at Adobe Systems) assigned the + * width of the space character (if one exists) else they get the + * value of 250 ems. This function initializes all entries in the + * char widths array to have this value. Then any mapped character + * codes will be replaced with the width of the appropriate character + * when parsing the character metric section. + + * This function parses the Character Metrics Section looking + * for a space character (by comparing character names). If found, + * the width of the space character will be used to initialize the + * values in the array of character widths. + * + * Before returning, the position of the read/write pointer of the + * file is reset to be where it was upon entering this function. + */ + +static int initializeArray(FILE *fp, int *cwi) +{ + BOOL cont = TRUE, found = FALSE; + long opos = ftell(fp); + int code = 0, width = 0, i = 0, error = 0; + register char *keyword; + + while (cont) + { + keyword = token(fp); + if (keyword == NULL) + { + error = earlyEOF; + break; /* get out of loop */ + } + switch(recognize(keyword)) + { + case COMMENT: + keyword = linetoken(fp); + break; + case CODE: + code = atoi(token(fp)); + break; + case XWIDTH: + width = atoi(token(fp)); + break; + case CHARNAME: + keyword = token(fp); + if (MATCH(keyword, Space)) + { + cont = FALSE; + found = TRUE; + } + break; + case ENDCHARMETRICS: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + case NOPE: + default: + error = parseError; + break; + } /* switch */ + } /* while */ + + if (!found) + width = 250; + + for (i = 0; i < 256; ++i) + cwi[i] = width; + + fseek(fp, opos, 0); + + return(error); + +} /* initializeArray */ +#endif /* unused */ + +/************************* parseCharWidths **************************/ + +/* This function is called by "parseFile". It will parse the AFM File + * up to the "EndCharMetrics" keyword. It will save the character + * width info (as opposed to all of the character metric information) + * if requested by the caller of parseFile. Otherwise, it will just + * parse through the section without saving any information. + * + * If data is to be saved, parseCharWidths is passed in a pointer + * to an array of widths that has already been initialized by the + * standard value for unmapped character codes. This function parses + * the Character Metrics section only storing the width information + * for the encoded characters into the array using the character code + * as the index into that array. + * + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by + * parseFile to determine if there is more file to parse. + */ + +static int parseCharWidths(FILE *fp, int *cwi) +{ + BOOL cont = TRUE, save = (cwi != NULL); + int pos = 0, error = ok; + register char *keyword; + + while (cont) + { + keyword = token(fp); + /* Have reached an early and unexpected EOF. */ + /* Set flag and stop parsing */ + if (keyword == NULL) + { + error = earlyEOF; + break; /* get out of loop */ + } + if (!save) + /* get tokens until the end of the Char Metrics section without */ + /* saving any of the data*/ + switch (recognize(keyword)) + { + case ENDCHARMETRICS: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + default: + break; + } /* switch */ + else + /* otherwise parse entire char metrics section, saving */ + /* only the char x-width info */ + switch(recognize(keyword)) + { + case COMMENT: + keyword = linetoken(fp); + break; + case CODE: + keyword = token(fp); + pos = atoi(keyword); + break; + case XYWIDTH: + /* PROBLEM: Should be no Y-WIDTH when doing "quick & dirty" */ + keyword = token(fp); keyword = token(fp); /* eat values */ + error = parseError; + break; + case XWIDTH: + keyword = token(fp); + if (pos >= 0) /* ignore unmapped chars */ + cwi[pos] = atoi(keyword); + break; + case ENDCHARMETRICS: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + case CHARNAME: /* eat values (so doesn't cause parseError) */ + keyword = token(fp); + break; + case CHARBBOX: + keyword = token(fp); keyword = token(fp); + keyword = token(fp); keyword = token(fp); + break; + case LIGATURE: + keyword = token(fp); keyword = token(fp); + break; + case NOPE: + default: + error = parseError; + break; + } /* switch */ + } /* while */ + + return(error); + +} /* parseCharWidths */ + + +/************************* parseCharMetrics ************************/ + +/* This function is called by parseFile if the caller of parseFile + * requested that all character metric information be saved + * (as opposed to only the character width information). + * + * parseCharMetrics is passed in a pointer to an array of records + * to hold information on a per character basis. This function + * parses the Character Metrics section storing all character + * metric information for the ALL characters (mapped and unmapped) + * into the array. + * + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by + * parseFile to determine if there is more file to parse. + */ + +static int parseCharMetrics(FILE *fp, FontInfo *fi) +{ + BOOL cont = TRUE, firstTime = TRUE; + int error = ok, count = 0; + register CharMetricInfo *temp = fi->cmi; + register char *keyword; + + while (cont) + { + keyword = token(fp); + if (keyword == NULL) + { + error = earlyEOF; + break; /* get out of loop */ + } + switch(recognize(keyword)) + { + case COMMENT: + keyword = linetoken(fp); + break; + case CODE: + if (count < fi->numOfChars) + { + if (firstTime) firstTime = FALSE; + else temp++; + temp->code = atoi(token(fp)); + count++; + } + else + { + error = parseError; + cont = FALSE; + } + break; + case XYWIDTH: + temp->wx = atoi(token(fp)); + temp->wy = atoi(token(fp)); + break; + case XWIDTH: + temp->wx = atoi(token(fp)); + break; + case CHARNAME: + keyword = token(fp); + temp->name = (char *) malloc(strlen(keyword) + 1); + strcpy(temp->name, keyword); + break; + case CHARBBOX: + temp->charBBox.llx = atoi(token(fp)); + temp->charBBox.lly = atoi(token(fp)); + temp->charBBox.urx = atoi(token(fp)); + temp->charBBox.ury = atoi(token(fp)); + break; + case LIGATURE: { + Ligature **tail = &(temp->ligs); + Ligature *node = *tail; + + if (*tail != NULL) + { + while (node->next != NULL) + node = node->next; + tail = &(node->next); + } + + *tail = (Ligature *) calloc(1, sizeof(Ligature)); + keyword = token(fp); + (*tail)->succ = (char *) malloc(strlen(keyword) + 1); + strcpy((*tail)->succ, keyword); + keyword = token(fp); + (*tail)->lig = (char *) malloc(strlen(keyword) + 1); + strcpy((*tail)->lig, keyword); + break; } + case ENDCHARMETRICS: + cont = FALSE;; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + case NOPE: + default: + error = parseError; + break; + } /* switch */ + } /* while */ + + if ((error == ok) && (count != fi->numOfChars)) + error = parseError; + + return(error); + +} /* parseCharMetrics */ + + + +/************************* parseTrackKernData ***********************/ + +/* This function is called by "parseFile". It will parse the AFM File + * up to the "EndTrackKern" or "EndKernData" keywords. It will save the + * track kerning data if requested by the caller of parseFile. + * + * parseTrackKernData is passed in a pointer to the FontInfo record. + * If data is to be saved, the FontInfo record will already contain + * a valid pointer to storage for the track kerning data. + * + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by + * parseFile to determine if there is more file to parse. + */ + +static int parseTrackKernData(FILE *fp, FontInfo *fi) +{ + BOOL cont = TRUE, save = (fi->tkd != NULL); + int pos = 0, error = ok, tcount = 0; + register char *keyword; + + while (cont) + { + keyword = token(fp); + + if (keyword == NULL) + { + error = earlyEOF; + break; /* get out of loop */ + } + if (!save) + /* get tokens until the end of the Track Kerning Data */ + /* section without saving any of the data */ + switch(recognize(keyword)) + { + case ENDTRACKKERN: + case ENDKERNDATA: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + default: + break; + } /* switch */ + else + /* otherwise parse entire Track Kerning Data section, */ + /* saving the data */ + switch(recognize(keyword)) + { + case COMMENT: + keyword = linetoken(fp); + break; + case TRACKKERN: + if (tcount < fi->numOfTracks) + { + keyword = token(fp); + fi->tkd[pos].degree = atoi(keyword); + keyword = token(fp); + fi->tkd[pos].minPtSize = atof(keyword); + if (errno == ERANGE) error = parseError; + keyword = token(fp); + fi->tkd[pos].minKernAmt = atof(keyword); + if (errno == ERANGE) error = parseError; + keyword = token(fp); + fi->tkd[pos].maxPtSize = atof(keyword); + if (errno == ERANGE) error = parseError; + keyword = token(fp); + fi->tkd[pos++].maxKernAmt = atof(keyword); + if (errno == ERANGE) error = parseError; + tcount++; + } + else + { + error = parseError; + cont = FALSE; + } + break; + case ENDTRACKKERN: + case ENDKERNDATA: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + case NOPE: + default: + error = parseError; + break; + } /* switch */ + } /* while */ + + if (error == ok && tcount != fi->numOfTracks) + error = parseError; + + return(error); + +} /* parseTrackKernData */ + + +/************************* parsePairKernData ************************/ + +/* This function is called by "parseFile". It will parse the AFM File + * up to the "EndKernPairs" or "EndKernData" keywords. It will save + * the pair kerning data if requested by the caller of parseFile. + * + * parsePairKernData is passed in a pointer to the FontInfo record. + * If data is to be saved, the FontInfo record will already contain + * a valid pointer to storage for the pair kerning data. + * + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by + * parseFile to determine if there is more file to parse. + */ + +static int parsePairKernData(FILE *fp, FontInfo *fi) +{ + BOOL cont = TRUE, save = (fi->pkd != NULL); + int pos = 0, error = ok, pcount = 0; + register char *keyword; + + while (cont) + { + keyword = token(fp); + + if (keyword == NULL) + { + error = earlyEOF; + break; /* get out of loop */ + } + if (!save) + /* get tokens until the end of the Pair Kerning Data */ + /* section without saving any of the data */ + switch(recognize(keyword)) + { + case ENDKERNPAIRS: + case ENDKERNDATA: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + default: + break; + } /* switch */ + else + /* otherwise parse entire Pair Kerning Data section, */ + /* saving the data */ + switch(recognize(keyword)) + { + case COMMENT: + keyword = linetoken(fp); + break; + case KERNPAIR: + if (pcount < fi->numOfPairs) + { + keyword = token(fp); + fi->pkd[pos].name1 = (char *) + malloc(strlen(keyword) + 1); + strcpy(fi->pkd[pos].name1, keyword); + keyword = token(fp); + fi->pkd[pos].name2 = (char *) + malloc(strlen(keyword) + 1); + strcpy(fi->pkd[pos].name2, keyword); + keyword = token(fp); + fi->pkd[pos].xamt = atoi(keyword); + keyword = token(fp); + fi->pkd[pos++].yamt = atoi(keyword); + pcount++; + } + else + { + error = parseError; + cont = FALSE; + } + break; + case KERNPAIRXAMT: + if (pcount < fi->numOfPairs) + { + keyword = token(fp); + fi->pkd[pos].name1 = (char *) + malloc(strlen(keyword) + 1); + strcpy(fi->pkd[pos].name1, keyword); + keyword = token(fp); + fi->pkd[pos].name2 = (char *) + malloc(strlen(keyword) + 1); + strcpy(fi->pkd[pos].name2, keyword); + keyword = token(fp); + fi->pkd[pos++].xamt = atoi(keyword); + pcount++; + } + else + { + error = parseError; + cont = FALSE; + } + break; + case ENDKERNPAIRS: + case ENDKERNDATA: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + case NOPE: + default: + error = parseError; + break; + } /* switch */ + } /* while */ + + if (error == ok && pcount != fi->numOfPairs) + error = parseError; + + return(error); + +} /* parsePairKernData */ + + +/************************* parseCompCharData **************************/ + +/* This function is called by "parseFile". It will parse the AFM File + * up to the "EndComposites" keyword. It will save the composite + * character data if requested by the caller of parseFile. + * + * parseCompCharData is passed in a pointer to the FontInfo record, and + * a boolean representing if the data should be saved. + * + * This function will create the appropriate amount of storage for + * the composite character data and store a pointer to the storage + * in the FontInfo record. + * + * This function returns an error code specifying whether there was + * a premature EOF or a parsing error. This return value is used by + * parseFile to determine if there is more file to parse. + */ + +static int parseCompCharData(FILE *fp, FontInfo *fi) +{ + BOOL cont = TRUE, firstTime = TRUE, save = (fi->ccd != NULL); + int pos = 0, j = 0, error = ok, ccount = 0, pcount = 0; + register char *keyword; + + while (cont) + { + keyword = token(fp); + if (keyword == NULL) + /* Have reached an early and unexpected EOF. */ + /* Set flag and stop parsing */ + { + error = earlyEOF; + break; /* get out of loop */ + } + if (ccount > fi->numOfComps) + { + error = parseError; + break; /* get out of loop */ + } + if (!save) + /* get tokens until the end of the Composite Character info */ + /* section without saving any of the data */ + switch(recognize(keyword)) + { + case ENDCOMPOSITES: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + default: + break; + } /* switch */ + else + /* otherwise parse entire Composite Character info section, */ + /* saving the data */ + switch(recognize(keyword)) + { + case COMMENT: + keyword = linetoken(fp); + break; + case COMPCHAR: + if (ccount < fi->numOfComps) + { + keyword = token(fp); + if (pcount != fi->ccd[pos].numOfPieces) + error = parseError; + pcount = 0; + if (firstTime) firstTime = FALSE; + else pos++; + fi->ccd[pos].ccName = (char *) + malloc(strlen(keyword) + 1); + strcpy(fi->ccd[pos].ccName, keyword); + keyword = token(fp); + fi->ccd[pos].numOfPieces = atoi(keyword); + fi->ccd[pos].pieces = (Pcc *) + calloc(fi->ccd[pos].numOfPieces, sizeof(Pcc)); + j = 0; + ccount++; + } + else + { + error = parseError; + cont = FALSE; + } + break; + case COMPCHARPIECE: + if (pcount < fi->ccd[pos].numOfPieces) + { + keyword = token(fp); + fi->ccd[pos].pieces[j].pccName = (char *) + malloc(strlen(keyword) + 1); + strcpy(fi->ccd[pos].pieces[j].pccName, keyword); + keyword = token(fp); + fi->ccd[pos].pieces[j].deltax = atoi(keyword); + keyword = token(fp); + fi->ccd[pos].pieces[j++].deltay = atoi(keyword); + pcount++; + } + else + error = parseError; + break; + case ENDCOMPOSITES: + cont = FALSE; + break; + case ENDFONTMETRICS: + cont = FALSE; + error = normalEOF; + break; + case NOPE: + default: + error = parseError; + break; + } /* switch */ + } /* while */ + + if (error == ok && ccount != fi->numOfComps) + error = parseError; + + return(error); + +} /* parseCompCharData */ + + + + +/*************************** 'PUBLIC' FUNCTION ********************/ + + +/*************************** parseFile *****************************/ + +/* parseFile is the only 'public' procedure available. It is called + * from an application wishing to get information from an AFM file. + * The caller of this function is responsible for locating and opening + * an AFM file and handling all errors associated with that task. + * + * parseFile expects 3 parameters: a vaild file pointer, a pointer + * to a (FontInfo *) variable (for which storage will be allocated and + * the data requested filled in), and a mask specifying which + * data from the AFM File should be saved in the FontInfo structure. + * + * The file will be parsed and the requested data will be stored in + * a record of type FontInfo (refer to ParseAFM.h). + * + * parseFile returns an error code as defined in parseAFM.h. + * + * The position of the read/write pointer associated with the file + * pointer upon return of this function is undefined. + */ + +extern int afm_parse_file(FILE *fp, FontInfo **fi, FLAGS flags) +{ + + int code = ok; /* return code from each of the parsing routines */ + int error = ok; /* used as the return code from this function */ + + register char *keyword; /* used to store a token */ + + + /* storage data for the global variable ident */ + ident = (char *) calloc(MAX_NAME, sizeof(char)); + if (ident == NULL) {error = storageProblem; return(error);} + + (*fi) = (FontInfo *) calloc(1, sizeof(FontInfo)); + if ((*fi) == NULL) {error = storageProblem; return(error);} + + if (flags & P_G) + { + (*fi)->gfi = (GlobalFontInfo *) calloc(1, sizeof(GlobalFontInfo)); + if ((*fi)->gfi == NULL) {error = storageProblem; return(error);} + } + + /* The AFM File begins with Global Font Information. This section */ + /* will be parsed whether or not information should be saved. */ + code = parseGlobals(fp, (*fi)->gfi); + + if (code < 0) error = code; + + /* The Global Font Information is followed by the Character Metrics */ + /* section. Which procedure is used to parse this section depends on */ + /* how much information should be saved. If all of the metrics info */ + /* is wanted, parseCharMetrics is called. If only the character widths */ + /* is wanted, parseCharWidths is called. parseCharWidths will also */ + /* be called in the case that no character data is to be saved, just */ + /* to parse through the section. */ + + if ((code != normalEOF) && (code != earlyEOF)) + { + (*fi)->numOfChars = atoi(token(fp)); + if (flags & (P_M ^ P_W)) + { + (*fi)->cmi = (CharMetricInfo *) + calloc((*fi)->numOfChars, sizeof(CharMetricInfo)); + if ((*fi)->cmi == NULL) {error = storageProblem; return(error);} + code = parseCharMetrics(fp, *fi); + } + else + { + if (flags & P_W) + { + (*fi)->cwi = (int *) calloc(256, sizeof(int)); + if ((*fi)->cwi == NULL) + { + error = storageProblem; + return(error); + } + } + /* parse section regardless */ + code = parseCharWidths(fp, (*fi)->cwi); + } /* else */ + } /* if */ + + if ((error != earlyEOF) && (code < 0)) error = code; + + /* The remaining sections of the AFM are optional. This code will */ + /* look at the next keyword in the file to determine what section */ + /* is next, and then allocate the appropriate amount of storage */ + /* for the data (if the data is to be saved) and call the */ + /* appropriate parsing routine to parse the section. */ + + while ((code != normalEOF) && (code != earlyEOF)) + { + keyword = token(fp); + if (keyword == NULL) + /* Have reached an early and unexpected EOF. */ + /* Set flag and stop parsing */ + { + code = earlyEOF; + break; /* get out of loop */ + } + switch(recognize(keyword)) + { + case STARTKERNDATA: + break; + case ENDKERNDATA: + break; + case STARTTRACKKERN: + keyword = token(fp); + if (flags & P_T) + { + (*fi)->numOfTracks = atoi(keyword); + (*fi)->tkd = (TrackKernData *) + calloc((*fi)->numOfTracks, sizeof(TrackKernData)); + if ((*fi)->tkd == NULL) + { + error = storageProblem; + return(error); + } + } /* if */ + code = parseTrackKernData(fp, *fi); + break; + case STARTKERNPAIRS: + keyword = token(fp); + if (flags & P_P) + { + (*fi)->numOfPairs = atoi(keyword); + (*fi)->pkd = (PairKernData *) + calloc((*fi)->numOfPairs, sizeof(PairKernData)); + if ((*fi)->pkd == NULL) + { + error = storageProblem; + return(error); + } + } /* if */ + code = parsePairKernData(fp, *fi); + break; + case STARTCOMPOSITES: + keyword = token(fp); + if (flags & P_C) + { + (*fi)->numOfComps = atoi(keyword); + (*fi)->ccd = (CompCharData *) + calloc((*fi)->numOfComps, sizeof(CompCharData)); + if ((*fi)->ccd == NULL) + { + error = storageProblem; + return(error); + } + } /* if */ + code = parseCompCharData(fp, *fi); + break; + case ENDFONTMETRICS: + code = normalEOF; + break; + case NOPE: + default: + code = parseError; + break; + } /* switch */ + + if ((error != earlyEOF) && (code < 0)) error = code; + + } /* while */ + + if ((error != earlyEOF) && (code < 0)) error = code; + + if (ident != NULL) { free(ident); ident = NULL; } + + return(error); + +} /* parseFile */ + +/* added for MDVI: this function was copied from `parseAFMclient.c' */ + +void afm_free_fontinfo(FontInfo *fi) +{ + if (fi != NULL) + { + if (fi->gfi != NULL) + { + free(fi->gfi->afmVersion); fi->gfi->afmVersion = NULL; + free(fi->gfi->fontName); fi->gfi->fontName = NULL; + free(fi->gfi->fullName); fi->gfi->fullName = NULL; + free(fi->gfi->familyName); fi->gfi->familyName = NULL; + free(fi->gfi->weight); fi->gfi->weight = NULL; + free(fi->gfi->version); fi->gfi->version = NULL; + free(fi->gfi->notice); fi->gfi->notice = NULL; + free(fi->gfi->encodingScheme); fi->gfi->encodingScheme = NULL; + free(fi->gfi); fi->gfi = NULL; + } + + if (fi->cwi != NULL) + { free(fi->cwi); fi->cwi = NULL; } + + if (fi->cmi != NULL) + { + int i = 0; + CharMetricInfo *temp = fi->cmi; + Ligature *node = temp->ligs; + + for (i = 0; i < fi->numOfChars; ++i) + { + for (node = temp->ligs; node != NULL; node = node->next) + { + free(node->succ); node->succ = NULL; + free(node->lig); node->lig = NULL; + } + + free(temp->name); temp->name = NULL; + temp++; + } + + free(fi->cmi); fi->cmi = NULL; + } + + if (fi->tkd != NULL) + { free(fi->tkd); fi->tkd = NULL; } + + if (fi->pkd != NULL) + { + free(fi->pkd->name1); fi->pkd->name1 = NULL; + free(fi->pkd->name2); fi->pkd->name2 = NULL; + free(fi->pkd); fi->pkd = NULL; + } + + if (fi->ccd != NULL) + { + int i = 0, j = 0; + CompCharData *ccd = fi->ccd; + + for (i = 0; i < fi->numOfComps; ++i) + { + for (j = 0; j < ccd[i].numOfPieces; ++j) + { + free(ccd[i].pieces[j].pccName); + ccd[i].pieces[j].pccName = NULL; + } + + free(ccd[i].ccName); ccd[i].ccName = NULL; + } + + free(fi->ccd); fi->ccd = NULL; + } + + free(fi); + + } /* if */ + +} /* afm_free_fontinfo */ + +#endif /* WITH_AFM_FILES */ diff --git a/dviware/mdvi/lib/afmparse.h b/dviware/mdvi/lib/afmparse.h new file mode 100644 index 0000000000..6cce780cdf --- /dev/null +++ b/dviware/mdvi/lib/afmparse.h @@ -0,0 +1,307 @@ +/* modified for MDVI -- some names changed to avoid conflicts with T1lib */ +/* + * (C) 1988, 1989 by Adobe Systems Incorporated. All rights reserved. + * + * This file may be freely copied and redistributed as long as: + * 1) This entire notice continues to be included in the file, + * 2) If the file has been modified in any way, a notice of such + * modification is conspicuously indicated. + * + * PostScript, Display PostScript, and Adobe are registered trademarks of + * Adobe Systems Incorporated. + * + * ************************************************************************ + * THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO CHANGE WITHOUT + * NOTICE, AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY ADOBE SYSTEMS + * INCORPORATED. ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY OR + * LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO WARRANTY OF ANY + * KIND (EXPRESS, IMPLIED OR STATUTORY) WITH RESPECT TO THIS INFORMATION, + * AND EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * ************************************************************************ + */ + +/* ParseAFM.h + * + * This header file is used in conjuction with the parseAFM.c file. + * Together these files provide the functionality to parse Adobe Font + * Metrics files and store the information in predefined data structures. + * It is intended to work with an application program that needs font metric + * information. The program can be used as is by making a procedure call to + * parse an AFM file and have the data stored, or an application developer + * may wish to customize the code. + * + * This header file defines the data structures used as well as the key + * strings that are currently recognized by this version of the AFM parser. + * This program is based on the document "Adobe Font Metrics Files, + * Specification Version 2.0". + * + * AFM files are separated into distinct sections of different data. Because + * of this, the parseAFM program can parse a specified file to only save + * certain sections of information based on the application's needs. A record + * containing the requested information will be returned to the application. + * + * AFM files are divided into five sections of data: + * 1) The Global Font Information + * 2) The Character Metrics Information + * 3) The Track Kerning Data + * 4) The Pair-Wise Kerning Data + * 5) The Composite Character Data + * + * Basically, the application can request any of these sections independent + * of what other sections are requested. In addition, in recognizing that + * many applications will want ONLY the x-width of characters and not all + * of the other character metrics information, there is a way to receive + * only the width information so as not to pay the storage cost for the + * unwanted data. An application should never request both the + * "quick and dirty" char metrics (widths only) and the Character Metrics + * Information since the Character Metrics Information will contain all + * of the character widths as well. + * + * There is a procedure in parseAFM.c, called parseFile, that can be + * called from any application wishing to get information from the AFM File. + * This procedure expects 3 parameters: a vaild file descriptor, a pointer + * to a (FontInfo *) variable (for which space will be allocated and then + * will be filled in with the data requested), and a mask specifying + * which data from the AFM File should be saved in the FontInfo structure. + * + * The flags that can be used to set the appropriate mask are defined below. + * In addition, several commonly used masks have already been defined. + * + * History: + * original: DSM Thu Oct 20 17:39:59 PDT 1988 + * modified: DSM Mon Jul 3 14:17:50 PDT 1989 + * - added 'storageProblem' return code + * - fixed typos + */ +#ifndef _MDVI_PARSEAFM_H +#define _MDVI_PARSEAFM_H 1 + +#include "sysdeps.h" + +#include <stdio.h> + +/* your basic constants */ +#define TRUE 1 +#define FALSE 0 +#define EOL '\n' /* end-of-line indicator */ +#define MAX_NAME 4096 /* max length for identifiers */ +#define BOOL int +#define FLAGS int + +/* Flags that can be AND'ed together to specify exactly what + * information from the AFM file should be saved. */ +#define P_G 0x01 /* 0000 0001 */ /* Global Font Info */ +#define P_W 0x02 /* 0000 0010 */ /* Character Widths ONLY */ +#define P_M 0x06 /* 0000 0110 */ /* All Char Metric Info */ +#define P_P 0x08 /* 0000 1000 */ /* Pair Kerning Info */ +#define P_T 0x10 /* 0001 0000 */ /* Track Kerning Info */ +#define P_C 0x20 /* 0010 0000 */ /* Composite Char Info */ + +/* Commonly used flags */ +#define P_GW (P_G | P_W) +#define P_GM (P_G | P_M) +#define P_GMP (P_G | P_M | P_P) +#define P_GMK (P_G | P_M | P_P | P_T) +#define P_ALL (P_G | P_M | P_P | P_T | P_C) + +/* Possible return codes from the parseFile procedure. + * + * ok means there were no problems parsing the file. + * + * parseError means that there was some kind of parsing error, but the + * parser went on. This could include problems like the count for any given + * section does not add up to how many entries there actually were, or + * there was a key that was not recognized. The return record may contain + * vaild data or it may not. + * + * earlyEOF means that an End of File was encountered before expected. This + * may mean that the AFM file had been truncated, or improperly formed. + * + * storageProblem means that there were problems allocating storage for + * the data structures that would have contained the AFM data. + */ +#define ok 0 +#define parseError -1 +#define earlyEOF -2 +#define storageProblem -3 + +/************************* TYPES *********************************/ +/* Below are all of the data structure definitions. These structures + * try to map as closely as possible to grouping and naming of data + * in the AFM Files. + */ + +/* Bounding box definition. Used for the Font BBox as well as the + * Character BBox. + */ +typedef struct +{ + int llx; /* lower left x-position */ + int lly; /* lower left y-position */ + int urx; /* upper right x-position */ + int ury; /* upper right y-position */ +} BBox; + +/* Global Font information. + * The key that each field is associated with is in comments. For an + * explanation about each key and its value please refer to the AFM + * documentation (full title & version given above). + */ +typedef struct +{ + char *afmVersion; /* key: StartFontMetrics */ + char *fontName; /* key: FontName */ + char *fullName; /* key: FullName */ + char *familyName; /* key: FamilyName */ + char *weight; /* key: Weight */ + float italicAngle; /* key: ItalicAngle */ + BOOL isFixedPitch; /* key: IsFixedPitch */ + BBox fontBBox; /* key: FontBBox */ + int underlinePosition; /* key: UnderlinePosition */ + int underlineThickness; /* key: UnderlineThickness */ + char *version; /* key: Version */ + char *notice; /* key: Notice */ + char *encodingScheme; /* key: EncodingScheme */ + int capHeight; /* key: CapHeight */ + int xHeight; /* key: XHeight */ + int ascender; /* key: Ascender */ + int descender; /* key: Descender */ +} GlobalFontInfo; + +/* Ligature definition is a linked list since any character can have + * any number of ligatures. + */ +typedef struct _t_ligature +{ + char *succ, *lig; + struct _t_ligature *next; +} Ligature; + +/* Character Metric Information. This structure is used only if ALL + * character metric information is requested. If only the character + * widths is requested, then only an array of the character x-widths + * is returned. + * + * The key that each field is associated with is in comments. For an + * explanation about each key and its value please refer to the + * Character Metrics section of the AFM documentation (full title + * & version given above). + */ +typedef struct +{ + int code, /* key: C */ + wx, /* key: WX */ + wy; /* together wx and wy are associated with key: W */ + char *name; /* key: N */ + BBox charBBox; /* key: B */ + Ligature *ligs; /* key: L (linked list; not a fixed number of Ls */ +} CharMetricInfo; + +/* Track kerning data structure. + * The fields of this record are the five values associated with every + * TrackKern entry. + * + * For an explanation about each value please refer to the + * Track Kerning section of the AFM documentation (full title + * & version given above). + */ +typedef struct +{ + int degree; + float minPtSize, + minKernAmt, + maxPtSize, + maxKernAmt; +} TrackKernData; + +/* Pair Kerning data structure. + * The fields of this record are the four values associated with every + * KP entry. For KPX entries, the yamt will be zero. + * + * For an explanation about each value please refer to the + * Pair Kerning section of the AFM documentation (full title + * & version given above). + */ +typedef struct +{ + char *name1; + char *name2; + int xamt, + yamt; +} PairKernData; + +/* PCC is a piece of a composite character. This is a sub structure of a + * compCharData described below. + * These fields will be filled in with the values from the key PCC. + * + * For an explanation about each key and its value please refer to the + * Composite Character section of the AFM documentation (full title + * & version given above). + */ +typedef struct +{ + char *pccName; + int deltax, + deltay; +} Pcc; + +/* Composite Character Information data structure. + * The fields ccName and numOfPieces are filled with the values associated + * with the key CC. The field pieces points to an array (size = numOfPieces) + * of information about each of the parts of the composite character. That + * array is filled in with the values from the key PCC. + * + * For an explanation about each key and its value please refer to the + * Composite Character section of the AFM documentation (full title + * & version given above). + */ +typedef struct +{ + char *ccName; + int numOfPieces; + Pcc *pieces; +} CompCharData; + +/* FontInfo + * Record type containing pointers to all of the other data + * structures containing information about a font. + * A a record of this type is filled with data by the + * parseFile function. + */ +typedef struct +{ + GlobalFontInfo *gfi; /* ptr to a GlobalFontInfo record */ + int *cwi; /* ptr to 256 element array of just char widths */ + int numOfChars; /* number of entries in char metrics array */ + CharMetricInfo *cmi; /* ptr to char metrics array */ + int numOfTracks; /* number to entries in track kerning array */ + TrackKernData *tkd; /* ptr to track kerning array */ + int numOfPairs; /* number to entries in pair kerning array */ + PairKernData *pkd; /* ptr to pair kerning array */ + int numOfComps; /* number to entries in comp char array */ + CompCharData *ccd; /* ptr to comp char array */ +} FontInfo; + +/************************* PROCEDURES ****************************/ + +/* Call this procedure to do the grunt work of parsing an AFM file. + * + * "fp" should be a valid file pointer to an AFM file. + * + * "fi" is a pointer to a pointer to a FontInfo record sturcture + * (defined above). Storage for the FontInfo structure will be + * allocated in parseFile and the structure will be filled in + * with the requested data from the AFM File. + * + * "flags" is a mask with bits set representing what data should + * be saved. Defined above are valid flags that can be used to set + * the mask, as well as a few commonly used masks. + * + * The possible return codes from parseFile are defined above. + */ + +extern int afm_parse_file __PROTO((FILE *, FontInfo **, FLAGS)); +extern void afm_free_fontinfo __PROTO((FontInfo *)); + +#endif /* _MDVI_PARSEAFM_H */ diff --git a/dviware/mdvi/lib/assoc.c b/dviware/mdvi/lib/assoc.c new file mode 100644 index 0000000000..472f8bd9fe --- /dev/null +++ b/dviware/mdvi/lib/assoc.c @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "mdvi.h" + +typedef struct { + void *data; + DviFree2Func free_func; +} DviAssoc; + +#define MDVI_ASSOC_SIZE 31 + +static void assoc_free(DviHashKey key, void *ptr) +{ + DviAssoc *assoc = (DviAssoc *)ptr; + + DEBUG((4, "Destroying association `%s'\n", (char *)key)); + if(assoc->free_func) + assoc->free_func(key, assoc->data); + xfree(assoc); +} + +int mdvi_assoc_put(DviContext *dvi, char *key, void *data, DviFree2Func f) +{ + DviAssoc *assoc; + int ok; + + if(dvi->assoc.buckets == NULL) { + mdvi_hash_create(&dvi->assoc, MDVI_ASSOC_SIZE); + dvi->assoc.hash_free = assoc_free; + } + assoc = xalloc(DviAssoc); + assoc->data = data; + assoc->free_func = f; + + ok = mdvi_hash_add(&dvi->assoc, MDVI_KEY(key), + assoc, MDVI_HASH_UNIQUE); + if(ok < 0) { + xfree(assoc); + return -1; + } + return 0; +} + +void *mdvi_assoc_get(DviContext *dvi, char *key) +{ + DviAssoc *assoc; + + if(dvi->assoc.buckets == NULL) + return NULL; + assoc = (DviAssoc *)mdvi_hash_lookup(&dvi->assoc, MDVI_KEY(key)); + return assoc ? assoc->data : NULL; +} + +void *mdvi_assoc_del(DviContext *dvi, char *key) +{ + DviAssoc *assoc; + void *ptr; + + if(dvi->assoc.buckets == NULL) + return NULL; + assoc = mdvi_hash_remove(&dvi->assoc, MDVI_KEY(key)); + if(assoc == NULL) + return NULL; + ptr = assoc->data; + xfree(assoc); + return ptr; +} + +void mdvi_assoc_free(DviContext *dvi, char *key) +{ + if(dvi->assoc.buckets) { + /* this will call `assoc_free' */ + mdvi_hash_destroy_key(&dvi->assoc, MDVI_KEY(key)); + } +} + +void mdvi_assoc_flush(DviContext *dvi) +{ + if(dvi->assoc.buckets) + mdvi_hash_reset(&dvi->assoc, 0); +} diff --git a/dviware/mdvi/lib/bitmap.c b/dviware/mdvi/lib/bitmap.c new file mode 100644 index 0000000000..2d9d0e978f --- /dev/null +++ b/dviware/mdvi/lib/bitmap.c @@ -0,0 +1,1111 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Bitmap manipulation routines */ + +#include <stdlib.h> + +#include "mdvi.h" + +/* bit_masks[n] contains a BmUnit with `n' contiguous bits */ + +static BmUnit bit_masks[] = { + 0x0, 0x1, 0x3, 0x7, + 0xf, 0x1f, 0x3f, 0x7f, + 0xff, +#if BITMAP_BYTES > 1 + 0x1ff, 0x3ff, 0x7ff, + 0xfff, 0x1fff, 0x3fff, 0x7fff, + 0xffff, +#if BITMAP_BYTES > 2 + 0x1ffff, 0x3ffff, 0x7ffff, + 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, + 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, + 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, + 0xffffffff +#endif /* BITMAP_BYTES > 2 */ +#endif /* BITMAP_BYTES > 1 */ +}; + +#ifndef NODEBUG +#define SHOW_OP_DATA (DEBUGGING(BITMAP_OPS) && DEBUGGING(BITMAP_DATA)) +#endif + +/* cache for color tables, to avoid creating them for every glyph */ +typedef struct { + Ulong fg; + Ulong bg; + Uint nlevels; + Ulong *pixels; + int density; + double gamma; + Uint hits; +} ColorCache; + +/* + * Some useful macros to manipulate bitmap data + * SEGMENT(m,n) = bit mask for a segment of `m' contiguous bits + * starting at column `n'. These macros assume that + * m + n <= BITMAP_BITS, 0 <= m, n. + */ +#ifdef WORD_BIG_ENDIAN +#define SEGMENT(m,n) (bit_masks[m] << (BITMAP_BITS - (m) - (n))) +#else +#define SEGMENT(m,n) (bit_masks[m] << (n)) +#endif + +/* sampling and shrinking routines shamelessly stolen from xdvi */ + +static int sample_count[] = { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 +}; + +/* bit_swap[j] = j with all bits inverted (i.e. msb -> lsb) */ +static Uchar bit_swap[] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; + +#define CCSIZE 256 +static ColorCache color_cache[CCSIZE]; +static int cc_entries; + +#define GAMMA_DIFF 0.005 + +/* create a color table */ +Ulong *get_color_table(DviDevice *dev, + int nlevels, Ulong fg, Ulong bg, double gamma, int density) +{ + ColorCache *cc, *tofree; + int lohits; + Ulong *pixels; + int status; + + lohits = color_cache[0].hits; + tofree = &color_cache[0]; + /* look in the cache and see if we have one that matches this request */ + for(cc = &color_cache[0]; cc < &color_cache[cc_entries]; cc++) { + if(cc->hits < lohits) { + lohits = cc->hits; + tofree = cc; + } + if(cc->fg == fg && cc->bg == bg && cc->density == density && + cc->nlevels == nlevels && fabs(cc->gamma - gamma) <= GAMMA_DIFF) + break; + } + + if(cc < &color_cache[cc_entries]) { + cc->hits++; + return cc->pixels; + } + + DEBUG((DBG_DEVICE, "Adding color table to cache (fg=%lu, bg=%lu, n=%d)\n", + fg, bg, nlevels)); + + /* no entry was found in the cache, create a new one */ + if(cc_entries < CCSIZE) { + cc = &color_cache[cc_entries++]; + cc->pixels = NULL; + } else { + cc = tofree; + xfree(cc->pixels); + } + pixels = xnalloc(Ulong, nlevels); + status = dev->alloc_colors(dev->device_data, + pixels, nlevels, fg, bg, gamma, density); + if(status < 0) { + xfree(pixels); + return NULL; + } + cc->fg = fg; + cc->bg = bg; + cc->gamma = gamma; + cc->density = density; + cc->nlevels = nlevels; + cc->pixels = pixels; + cc->hits = 1; + return pixels; +} + +void flush_color_table(void) +{ + ColorCache *cc; + + for(cc = &color_cache[0]; cc < &color_cache[cc_entries]; cc++) + xfree(cc->pixels); + cc_entries = 0; +} + +/* + * next we have three bitmap functions to convert bitmaps in LSB bit order + * with 8, 16 and 32 bits per unit, to our internal format. The differences + * are minimal, but writing a generic function to handle all unit sizes is + * hopelessly slow. + */ + +BITMAP *bitmap_convert_lsb8(Uchar *bits, int w, int h) +{ + BITMAP *bm; + int i; + Uchar *unit; + register Uchar *curr; + Uchar *end; + int bytes; + + DEBUG((DBG_BITMAP_OPS, "convert LSB %dx%d@8 -> bitmap\n", w, h)); + + bm = bitmap_alloc_raw(w, h); + + /* this is the number of bytes in the original bitmap */ + bytes = ROUND(w, 8); + unit = (Uchar *)bm->data; + end = unit + bm->stride; + curr = bits; + /* we try to do this as fast as we can */ + for(i = 0; i < h; i++) { +#ifdef WORD_LITTLE_ENDIAN + memcpy(unit, curr, bytes); + curr += bytes; +#else + int j; + + for(j = 0; j < bytes; curr++, j++) + unit[j] = bit_swap[*curr]; +#endif + memzero(unit + bytes, bm->stride - bytes); + unit += bm->stride; + } + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); + return bm; +} + +BITMAP *bitmap_convert_msb8(Uchar *data, int w, int h) +{ + BITMAP *bm; + Uchar *unit; + Uchar *curr; + int i; + int bytes; + + bm = bitmap_alloc(w, h); + bytes = ROUND(w, 8); + unit = (Uchar *)bm->data; + curr = data; + for(i = 0; i < h; i++) { +#ifdef WORD_LITTLE_ENDIAN + int j; + + for(j = 0; j < bytes; curr++, j++) + unit[j] = bit_swap[*curr]; +#else + memcpy(unit, curr, bytes); + curr += bytes; +#endif + memzero(unit + bytes, bm->stride - bytes); + unit += bm->stride; + } + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); + return bm; +} + + +BITMAP *bitmap_copy(BITMAP *bm) +{ + BITMAP *nb = bitmap_alloc(bm->width, bm->height); + + DEBUG((DBG_BITMAP_OPS, "copy %dx%d\n", bm->width, bm->height)); + memcpy(nb->data, bm->data, bm->height * bm->stride); + return nb; +} + +BITMAP *bitmap_alloc(int w, int h) +{ + BITMAP *bm; + + bm = xalloc(BITMAP); + bm->width = w; + bm->height = h; + bm->stride = BM_BYTES_PER_LINE(bm); + if(h && bm->stride) + bm->data = (BmUnit *)xcalloc(h, bm->stride); + else + bm->data = NULL; + + return bm; +} + +BITMAP *bitmap_alloc_raw(int w, int h) +{ + BITMAP *bm; + + bm = xalloc(BITMAP); + bm->width = w; + bm->height = h; + bm->stride = BM_BYTES_PER_LINE(bm); + if(h && bm->stride) + bm->data = (BmUnit *)xmalloc(h * bm->stride); + else + bm->data = NULL; + + return bm; +} + +void bitmap_destroy(BITMAP *bm) +{ + if(bm->data) + free(bm->data); + free(bm); +} + +void bitmap_print(FILE *out, BITMAP *bm) +{ + int i, j; + BmUnit *a, mask; + static const char labels[] = { + '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' + }; + int sub; + + a = bm->data; + fprintf(out, " "); + if(bm->width > 10) { + putchar('0'); + sub = 0; + for(j = 2; j <= bm->width; j++) + if((j %10) == 0) { + if((j % 100) == 0) { + fprintf(out, "*"); + sub += 100; + } else + fprintf(out, "%d", (j - sub)/10); + } else + putc(' ', out); + fprintf(out, "\n "); + } + for(j = 0; j < bm->width; j++) + putc(labels[j % 10], out); + putchar('\n'); + for(i = 0; i < bm->height; i++) { + mask = FIRSTMASK; + a = (BmUnit *)((char *)bm->data + i * bm->stride); + fprintf(out, "%3d ", i+1); + for(j = 0; j < bm->width; j++) { + if(*a & mask) + putc('#', out); + else + putc('.', out); + if(mask == LASTMASK) { + a++; + mask = FIRSTMASK; + } else + NEXTMASK(mask); + } + putchar('\n'); + } +} + +void bitmap_set_col(BITMAP *bm, int row, int col, int count, int state) +{ + BmUnit *ptr; + BmUnit mask; + + ptr = __bm_unit_ptr(bm, col, row); + mask = FIRSTMASKAT(col); + + while(count-- > 0) { + if(state) + *ptr |= mask; + else + *ptr &= ~mask; + /* move to next row */ + ptr = bm_offset(ptr, bm->stride); + } +} + +/* + * to use this function you should first make sure that + * there is room for `count' bits in the scanline + * + * A general-purpose (but not very efficient) function to paint `n' pixels + * on a bitmap, starting at position (x, y) would be: + * + * bitmap_paint_bits(__bm_unit_ptr(bitmap, x, y), x % BITMAP_BITS, n) + * + */ +void bitmap_paint_bits(BmUnit *ptr, int n, int count) +{ + /* paint the head */ + if(n + count > BITMAP_BITS) { + *ptr |= SEGMENT(BITMAP_BITS - n, n); + count -= BITMAP_BITS - n; + ptr++; + } else { + *ptr |= SEGMENT(count, n); + return; + } + + /* paint the middle */ + for(; count >= BITMAP_BITS; count -= BITMAP_BITS) + *ptr++ = bit_masks[BITMAP_BITS]; + + /* paint the tail */ + if(count > 0) + *ptr |= SEGMENT(count, 0); +} + +/* + * same as paint_bits but clears pixels instead of painting them. Written + * as a separate function for efficiency reasons. + */ +void bitmap_clear_bits(BmUnit *ptr, int n, int count) +{ + if(n + count > BITMAP_BITS) { + *ptr &= ~SEGMENT(BITMAP_BITS - n, n); + count -= BITMAP_BITS; + ptr++; + } else { + *ptr &= ~SEGMENT(count, n); + return; + } + + for(; count >= BITMAP_BITS; count -= BITMAP_BITS) + *ptr++ = 0; + + if(count > 0) + *ptr &= ~SEGMENT(count, 0); +} + +/* the general function to paint rows. Still used by the PK reader, but that + * will change soon (The GF reader already uses bitmap_paint_bits()). + */ +void bitmap_set_row(BITMAP *bm, int row, int col, int count, int state) +{ + BmUnit *ptr; + + ptr = __bm_unit_ptr(bm, col, row); + if(state) + bitmap_paint_bits(ptr, col & (BITMAP_BITS-1), count); + else + bitmap_clear_bits(ptr, col & (BITMAP_BITS-1), count); +} + +/* + * Now several `flipping' operations + */ + +void bitmap_flip_horizontally(BITMAP *bm) +{ + BITMAP nb; + BmUnit *fptr, *tptr; + BmUnit fmask, tmask; + int w, h; + + nb.width = bm->width; + nb.height = bm->height; + nb.stride = bm->stride; + nb.data = xcalloc(bm->height, bm->stride); + + fptr = bm->data; + tptr = __bm_unit_ptr(&nb, nb.width-1, 0); + for(h = 0; h < bm->height; h++) { + BmUnit *fline, *tline; + + fline = fptr; + tline = tptr; + fmask = FIRSTMASK; + tmask = FIRSTMASKAT(nb.width-1); + for(w = 0; w < bm->width; w++) { + if(*fline & fmask) + *tline |= tmask; + if(fmask == LASTMASK) { + fmask = FIRSTMASK; + fline++; + } else + NEXTMASK(fmask); + if(tmask == FIRSTMASK) { + tmask = LASTMASK; + tline--; + } else + PREVMASK(tmask); + } + fptr = bm_offset(fptr, bm->stride); + tptr = bm_offset(tptr, bm->stride); + } + DEBUG((DBG_BITMAP_OPS, "flip_horizontally (%d,%d) -> (%d,%d)\n", + bm->width, bm->height, nb.width, nb.height)); + xfree(bm->data); + bm->data = nb.data; + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); +} + +void bitmap_flip_vertically(BITMAP *bm) +{ + BITMAP nb; + BmUnit *fptr, *tptr; + BmUnit fmask; + int w, h; + + nb.width = bm->width; + nb.height = bm->height; + nb.stride = bm->stride; + nb.data = xcalloc(bm->height, bm->stride); + + fptr = bm->data; + tptr = __bm_unit_ptr(&nb, 0, nb.height-1); + for(h = 0; h < bm->height; h++) { + BmUnit *fline, *tline; + + fline = fptr; + tline = tptr; + fmask = FIRSTMASK; + for(w = 0; w < bm->width; w++) { + if(*fline & fmask) + *tline |= fmask; + if(fmask == LASTMASK) { + fmask = FIRSTMASK; + fline++; + tline++; + } else + NEXTMASK(fmask); + } + fptr = bm_offset(fptr, bm->stride); + tptr = (BmUnit *)((char *)tptr - bm->stride); + } + DEBUG((DBG_BITMAP_OPS, "flip_vertically (%d,%d) -> (%d,%d)\n", + bm->width, bm->height, nb.width, nb.height)); + xfree(bm->data); + bm->data = nb.data; + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); +} + +void bitmap_flip_diagonally(BITMAP *bm) +{ + BITMAP nb; + BmUnit *fptr, *tptr; + BmUnit fmask, tmask; + int w, h; + + nb.width = bm->width; + nb.height = bm->height; + nb.stride = bm->stride; + nb.data = xcalloc(bm->height, bm->stride); + + fptr = bm->data; + tptr = __bm_unit_ptr(&nb, nb.width-1, nb.height-1); + for(h = 0; h < bm->height; h++) { + BmUnit *fline, *tline; + + fline = fptr; + tline = tptr; + fmask = FIRSTMASK; + tmask = FIRSTMASKAT(nb.width-1); + for(w = 0; w < bm->width; w++) { + if(*fline & fmask) + *tline |= tmask; + if(fmask == LASTMASK) { + fmask = FIRSTMASK; + fline++; + } else + NEXTMASK(fmask); + if(tmask == FIRSTMASK) { + tmask = LASTMASK; + tline--; + } else + PREVMASK(tmask); + } + fptr = bm_offset(fptr, bm->stride); + tptr = bm_offset(tptr, -nb.stride); + } + DEBUG((DBG_BITMAP_OPS, "flip_diagonally (%d,%d) -> (%d,%d)\n", + bm->width, bm->height, nb.width, nb.height)); + xfree(bm->data); + bm->data = nb.data; + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); +} + +void bitmap_rotate_clockwise(BITMAP *bm) +{ + BITMAP nb; + BmUnit *fptr, *tptr; + BmUnit fmask, tmask; + int w, h; + + nb.width = bm->height; + nb.height = bm->width; + nb.stride = BM_BYTES_PER_LINE(&nb); + nb.data = xcalloc(nb.height, nb.stride); + + fptr = bm->data; + tptr = __bm_unit_ptr(&nb, nb.width - 1, 0); + + tmask = FIRSTMASKAT(nb.width-1); + for(h = 0; h < bm->height; h++) { + BmUnit *fline, *tline; + + fmask = FIRSTMASK; + fline = fptr; + tline = tptr; + for(w = 0; w < bm->width; w++) { + if(*fline & fmask) + *tline |= tmask; + if(fmask == LASTMASK) { + fmask = FIRSTMASK; + fline++; + } else + NEXTMASK(fmask); + /* go to next row */ + tline = bm_offset(tline, nb.stride); + } + fptr = bm_offset(fptr, bm->stride); + if(tmask == FIRSTMASK) { + tmask = LASTMASK; + tptr--; + } else + PREVMASK(tmask); + } + + DEBUG((DBG_BITMAP_OPS, "rotate_clockwise (%d,%d) -> (%d,%d)\n", + bm->width, bm->height, nb.width, nb.height)); + xfree(bm->data); + bm->data = nb.data; + bm->width = nb.width; + bm->height = nb.height; + bm->stride = nb.stride; + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); +} + +void bitmap_rotate_counter_clockwise(BITMAP *bm) +{ + BITMAP nb; + BmUnit *fptr, *tptr; + BmUnit fmask, tmask; + int w, h; + + nb.width = bm->height; + nb.height = bm->width; + nb.stride = BM_BYTES_PER_LINE(&nb); + nb.data = xcalloc(nb.height, nb.stride); + + fptr = bm->data; + tptr = __bm_unit_ptr(&nb, 0, nb.height - 1); + + tmask = FIRSTMASK; + for(h = 0; h < bm->height; h++) { + BmUnit *fline, *tline; + + fmask = FIRSTMASK; + fline = fptr; + tline = tptr; + for(w = 0; w < bm->width; w++) { + if(*fline & fmask) + *tline |= tmask; + if(fmask == LASTMASK) { + fmask = FIRSTMASK; + fline++; + } else + NEXTMASK(fmask); + /* go to previous row */ + tline = bm_offset(tline, -nb.stride); + } + fptr = bm_offset(fptr, bm->stride); + if(tmask == LASTMASK) { + tmask = FIRSTMASK; + tptr++; + } else + NEXTMASK(tmask); + } + + DEBUG((DBG_BITMAP_OPS, "rotate_counter_clockwise (%d,%d) -> (%d,%d)\n", + bm->width, bm->height, nb.width, nb.height)); + xfree(bm->data); + bm->data = nb.data; + bm->width = nb.width; + bm->height = nb.height; + bm->stride = nb.stride; + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); +} + +void bitmap_flip_rotate_clockwise(BITMAP *bm) +{ + BITMAP nb; + BmUnit *fptr, *tptr; + BmUnit fmask, tmask; + int w, h; + + nb.width = bm->height; + nb.height = bm->width; + nb.stride = BM_BYTES_PER_LINE(&nb); + nb.data = xcalloc(nb.height, nb.stride); + + fptr = bm->data; + tptr = __bm_unit_ptr(&nb, nb.width-1, nb.height-1); + + tmask = FIRSTMASKAT(nb.width-1); + for(h = 0; h < bm->height; h++) { + BmUnit *fline, *tline; + + fmask = FIRSTMASK; + fline = fptr; + tline = tptr; + for(w = 0; w < bm->width; w++) { + if(*fline & fmask) + *tline |= tmask; + if(fmask == LASTMASK) { + fmask = FIRSTMASK; + fline++; + } else + NEXTMASK(fmask); + /* go to previous line */ + tline = bm_offset(tline, -nb.stride); + } + fptr = bm_offset(fptr, bm->stride); + if(tmask == FIRSTMASK) { + tmask = LASTMASK; + tptr--; + } else + PREVMASK(tmask); + } + DEBUG((DBG_BITMAP_OPS, "flip_rotate_clockwise (%d,%d) -> (%d,%d)\n", + bm->width, bm->height, nb.width, nb.height)); + xfree(bm->data); + bm->data = nb.data; + bm->width = nb.width; + bm->height = nb.height; + bm->stride = nb.stride; + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); +} + +void bitmap_flip_rotate_counter_clockwise(BITMAP *bm) +{ + BITMAP nb; + BmUnit *fptr, *tptr; + BmUnit fmask, tmask; + int w, h; + + nb.width = bm->height; + nb.height = bm->width; + nb.stride = BM_BYTES_PER_LINE(&nb); + nb.data = xcalloc(nb.height, nb.stride); + + fptr = bm->data; + tptr = nb.data; + tmask = FIRSTMASK; + + for(h = 0; h < bm->height; h++) { + BmUnit *fline, *tline; + + fmask = FIRSTMASK; + fline = fptr; + tline = tptr; + for(w = 0; w < bm->width; w++) { + if(*fline & fmask) + *tline |= tmask; + if(fmask == LASTMASK) { + fmask = FIRSTMASK; + fline++; + } else + NEXTMASK(fmask); + /* go to next line */ + tline = bm_offset(tline, nb.stride); + } + fptr = bm_offset(fptr, bm->stride); + if(tmask == LASTMASK) { + tmask = FIRSTMASK; + tptr++; + } else + NEXTMASK(tmask); + } + + DEBUG((DBG_BITMAP_OPS, "flip_rotate_counter_clockwise (%d,%d) -> (%d,%d)\n", + bm->width, bm->height, nb.width, nb.height)); + xfree(bm->data); + bm->data = nb.data; + bm->width = nb.width; + bm->height = nb.height; + bm->stride = nb.stride; + if(SHOW_OP_DATA) + bitmap_print(stderr, bm); +} + +#if 0 +void bitmap_transform(BITMAP *map, DviOrientation orient) +{ + switch(orient) { + case MDVI_ORIENT_TBLR: + break; + case MDVI_ORIENT_TBRL: + bitmap_flip_horizontally(map); + break; + case MDVI_ORIENT_BTLR: + bitmap_flip_vertically(map); + break; + case MDVI_ORIENT_BTRL: + bitmap_flip_diagonally(map); + break; + case MDVI_ORIENT_RP90: + bitmap_rotate_counter_clockwise(map); + break; + case MDVI_ORIENT_RM90: + bitmap_rotate_clockwise(map); + break; + case MDVI_ORIENT_IRP90: + bitmap_flip_rotate_counter_clockwise(map); + break; + case MDVI_ORIENT_IRM90: + bitmap_flip_rotate_clockwise(map); + break; + } +} +#endif + +/* + * Count the number of non-zero bits in a box of dimensions w x h, starting + * at column `step' in row `data'. + * + * Shamelessly stolen from xdvi. + */ +static int do_sample(BmUnit *data, int stride, int step, int w, int h) +{ + BmUnit *ptr, *end, *cp; + int shift, n; + int bits_left; + int wid; + + ptr = data + step / BITMAP_BITS; + end = bm_offset(data, h * stride); + shift = FIRSTSHIFTAT(step); + bits_left = w; + n = 0; + while(bits_left) { +#ifndef WORD_BIG_ENDIAN + wid = BITMAP_BITS - shift; +#else + wid = shift; +#endif + if(wid > bits_left) + wid = bits_left; + if(wid > 8) + wid = 8; +#ifdef WORD_BIG_ENDIAN + shift -= wid; +#endif + for(cp = ptr; cp < end; cp = bm_offset(cp, stride)) + n += sample_count[(*cp >> shift) & bit_masks[wid]]; +#ifndef WORD_BIG_ENDIAN + shift += wid; +#endif +#ifdef WORD_BIG_ENDIAN + if(shift == 0) { + shift = BITMAP_BITS; + ptr++; + } +#else + if(shift == BITMAP_BITS) { + shift = 0; + ptr++; + } +#endif + bits_left -= wid; + } + return n; +} + +void mdvi_shrink_box(DviContext *dvi, DviFont *font, + DviFontChar *pk, DviGlyph *dest) +{ + int x, y, z; + DviGlyph *glyph; + int hs, vs; + + hs = dvi->params.hshrink; + vs = dvi->params.vshrink; + glyph = &pk->glyph; + + x = (int)glyph->x / hs; + if((int)glyph->x - x * hs > 0) + x++; + dest->w = x + ROUND((int)glyph->w - glyph->x, hs); + + z = (int)glyph->y + 1; + y = z / vs; + if(z - y * vs <= 0) + y--; + dest->h = y + ROUND((int)glyph->h - z, vs) + 1; + dest->x = x; + dest->y = glyph->y / vs; + dest->data = MDVI_GLYPH_EMPTY; + DEBUG((DBG_BITMAPS, "shrink_box: (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n", + glyph->w, glyph->h, glyph->x, glyph->y, + dest->w, dest->h, dest->x, dest->y)); +} + +void mdvi_shrink_glyph(DviContext *dvi, DviFont *font, + DviFontChar *pk, DviGlyph *dest) +{ + int rows_left, rows, init_cols; + int cols_left, cols; + BmUnit *old_ptr, *new_ptr; + BITMAP *oldmap, *newmap; + BmUnit m, *cp; + DviGlyph *glyph; + int sample, min_sample; + int old_stride; + int new_stride; + int x, y; + int w, h; + int hs, vs; + + hs = dvi->params.hshrink; + vs = dvi->params.vshrink; + + min_sample = vs * hs * dvi->params.density / 100; + + glyph = &pk->glyph; + oldmap = (BITMAP *)glyph->data; + + x = (int)glyph->x / hs; + init_cols = (int)glyph->x - x * hs; + if(init_cols <= 0) + init_cols += hs; + else + x++; + w = x + ROUND((int)glyph->w - glyph->x, hs); + + cols = (int)glyph->y + 1; + y = cols / vs; + rows = cols - y * vs; + if(rows <= 0) { + rows += vs; + y--; + } + h = y + ROUND((int)glyph->h - cols, vs) + 1; + + /* create the new glyph */ + newmap = bitmap_alloc(w, h); + dest->data = newmap; + dest->x = x; + dest->y = glyph->y / vs; + dest->w = w; + dest->h = h; + + old_ptr = oldmap->data; + old_stride = oldmap->stride; + new_ptr = newmap->data; + new_stride = newmap->stride; + rows_left = glyph->h; + + while(rows_left) { + if(rows > rows_left) + rows = rows_left; + cols_left = glyph->w; + m = FIRSTMASK; + cp = new_ptr; + cols = init_cols; + while(cols_left > 0) { + if(cols > cols_left) + cols = cols_left; + sample = do_sample(old_ptr, old_stride, + glyph->w - cols_left, cols, rows); + if(sample >= min_sample) + *cp |= m; + if(m == LASTMASK) { + m = FIRSTMASK; + cp++; + } else + NEXTMASK(m); + cols_left -= cols; + cols = hs; + } + new_ptr = bm_offset(new_ptr, new_stride); + old_ptr = bm_offset(old_ptr, rows * old_stride); + rows_left -= rows; + rows = vs; + } + DEBUG((DBG_BITMAPS, "shrink_glyph: (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n", + glyph->w, glyph->h, glyph->x, glyph->y, + dest->w, dest->h, dest->x, dest->y)); + if(DEBUGGING(BITMAP_DATA)) + bitmap_print(stderr, newmap); +} + +void mdvi_shrink_glyph_grey(DviContext *dvi, DviFont *font, + DviFontChar *pk, DviGlyph *dest) +{ + int rows_left, rows; + int cols_left, cols, init_cols; + long sampleval, samplemax; + BmUnit *old_ptr; + void *image; + int w, h; + int x, y; + DviGlyph *glyph; + BITMAP *map; + Ulong *pixels; + int npixels; + Ulong colortab[2]; + int hs, vs; + DviDevice *dev; + + hs = dvi->params.hshrink; + vs = dvi->params.vshrink; + dev = &dvi->device; + + glyph = &pk->glyph; + map = (BITMAP *)glyph->data; + + x = (int)glyph->x / hs; + init_cols = (int)glyph->x - x * hs; + if(init_cols <= 0) + init_cols += hs; + else + x++; + w = x + ROUND((int)glyph->w - glyph->x, hs); + + cols = (int)glyph->y + 1; + y = cols / vs; + rows = cols - y * vs; + if(rows <= 0) { + rows += vs; + y--; + } + h = y + ROUND((int)glyph->h - cols, vs) + 1; + ASSERT(w && h); + + /* before touching anything, do this */ + image = dev->create_image(dev->device_data, w, h, BITMAP_BITS); + if(image == NULL) { + mdvi_shrink_glyph(dvi, font, pk, dest); + return; + } + + /* save these colors */ + pk->fg = MDVI_CURRFG(dvi); + pk->bg = MDVI_CURRBG(dvi); + + samplemax = vs * hs; + npixels = samplemax + 1; + pixels = get_color_table(&dvi->device, npixels, pk->fg, pk->bg, + dvi->params.gamma, dvi->params.density); + if(pixels == NULL) { + npixels = 2; + colortab[0] = pk->fg; + colortab[1] = pk->bg; + pixels = &colortab[0]; + } + + /* setup the new glyph */ + dest->data = image; + dest->x = x; + dest->y = glyph->y / vs; + dest->w = w; + dest->h = h; + + y = 0; + old_ptr = map->data; + rows_left = glyph->h; + + while(rows_left && y < h) { + x = 0; + if(rows > rows_left) + rows = rows_left; + cols_left = glyph->w; + cols = init_cols; + while(cols_left && x < w) { + if(cols > cols_left) + cols = cols_left; + sampleval = do_sample(old_ptr, map->stride, + glyph->w - cols_left, cols, rows); + /* scale the sample value by the number of grey levels */ + if(npixels - 1 != samplemax) + sampleval = ((npixels-1) * sampleval) / samplemax; + ASSERT(sampleval < npixels); + dev->put_pixel(image, x, y, pixels[sampleval]); + cols_left -= cols; + cols = hs; + x++; + } + for(; x < w; x++) + dev->put_pixel(image, x, y, pixels[0]); + old_ptr = bm_offset(old_ptr, rows * map->stride); + rows_left -= rows; + rows = vs; + y++; + } + + for(; y < h; y++) { + for(x = 0; x < w; x++) + dev->put_pixel(image, x, y, pixels[0]); + } + DEBUG((DBG_BITMAPS, "shrink_glyph_grey: (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n", + glyph->w, glyph->h, glyph->x, glyph->y, + dest->w, dest->h, dest->x, dest->y)); +} + diff --git a/dviware/mdvi/lib/common.c b/dviware/mdvi/lib/common.c new file mode 100644 index 0000000000..24b30da537 --- /dev/null +++ b/dviware/mdvi/lib/common.c @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> +#include <string.h> + +#include "common.h" + +long fsgetn(FILE *p, size_t n) +{ + long v; + + v = fgetbyte(p); + if(v & 0x80) + v -= 0x100; + while(--n > 0) + v = (v << 8) | fgetbyte(p); + return v; +} + +Ulong fugetn(FILE *p, size_t n) +{ + Ulong v; + + v = fgetbyte(p); + while(--n > 0) + v = (v << 8) | fgetbyte(p); + return v; +} + +long msgetn(const Uchar *p, size_t n) +{ + long v = (long)*p++; + + if(v & 0x80) + v -= 0x100; + while(--n > 0) + v = (v << 8) | *p++; + return v; +} + +Ulong mugetn(const Uchar *p, size_t n) +{ + Ulong v = (Ulong)*p++; + + while(--n > 0) + v = (v << 8) | *p++; + return v; +} + +char *read_string(FILE *in, int s, char *buffer, size_t len) +{ + int n; + char *str; + + n = fugetn(in, s ? s : 1); + if((str = buffer) == NULL || n + 1 > len) + str = xmalloc(n + 1); + if(fread(str, 1, n, in) != n) { + if(str != buffer) xfree(str); + return NULL; + } + str[n] = 0; + return str; +} + +size_t read_bcpl(FILE *in, char *buffer, size_t maxlen, size_t wanted) +{ + size_t i; + + i = (int)fuget1(in); + if(maxlen && i > maxlen) + i = maxlen; + if(fread(buffer, i, 1, in) != 1) + return -1; + buffer[i] = '\0'; + while(wanted-- > i) + (void)fgetc(in); + return i; +} + +char *read_alloc_bcpl(FILE *in, size_t maxlen, size_t *size) +{ + size_t i; + char *buffer; + + i = (size_t)fuget1(in); + if(maxlen && i > maxlen) + i = maxlen; + buffer = (char *)malloc(i + 1); + if(buffer == NULL) + return NULL; + if(fread(buffer, i, 1, in) != 1) { + free(buffer); + return NULL; + } + buffer[i] = '\0'; + if(size) *size = i; + return buffer; +} + +/* stolen from dvips */ +Int32 scaled_width(Int32 fix, int scale) +{ + Int32 al, bl; + + if(fix < 0) + return -scaled_width(-fix, scale); + if(scale < 0) + return -scaled_width(fix, -scale); + al = fix & 32767; + bl = scale & 32767; + al >>= 15; + bl >>= 15; + + return (((al*bl / 32768) + fix*bl + al*scale) / 32 + + fix * scale / 1024); +} + +/* buffers */ + +void buff_free(Buffer *buf) +{ + if(buf->data) + xfree(buf->data); + buff_init(buf); +} + +void buff_init(Buffer *buf) +{ + buf->data = NULL; + buf->size = 0; + buf->length = 0; +} + +size_t buff_add(Buffer *buf, const char *data, size_t len) +{ + if(!len && data) + len = strlen(data); + if(buf->length + len + 1 > buf->size) { + buf->size = buf->length + len + 256; + buf->data = xrealloc(buf->data, buf->size); + } + memcpy(buf->data + buf->length, data, len); + buf->length += len; + return buf->length; +} + +char *buff_gets(Buffer *buf, size_t *length) +{ + char *ptr; + char *ret; + size_t len; + + ptr = strchr(buf->data, '\n'); + if(ptr == NULL) + return NULL; + ptr++; /* include newline */ + len = ptr - buf->data; + ret = xmalloc(len + 1); + if(len > 0) { + memcpy(ret, buf->data, len); + memmove(buf->data, buf->data + len, buf->length - len); + buf->length -= len; + } + ret[len] = 0; + if(length) *length = len; + return ret; +} + diff --git a/dviware/mdvi/lib/dvimisc.c b/dviware/mdvi/lib/dvimisc.c new file mode 100644 index 0000000000..5dbacfbf01 --- /dev/null +++ b/dviware/mdvi/lib/dvimisc.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "mdvi.h" + +void mdvi_set_color(DviContext *dvi, Ulong fg, Ulong bg) +{ + if(dvi->curr_fg != fg || dvi->curr_bg != bg) { + DEBUG((DBG_DEVICE, "setting color to (%lu,%lu)\n", fg, bg)); + if(dvi->device.set_color) + dvi->device.set_color(dvi->device.device_data, fg, bg); + dvi->curr_fg = fg; + dvi->curr_bg = bg; + } +} + +void mdvi_push_color(DviContext *dvi, Ulong fg, Ulong bg) +{ + if(dvi->color_top == dvi->color_size) { + dvi->color_size += 32; + dvi->color_stack = xrealloc(dvi->color_stack, + dvi->color_size * sizeof(DviColorPair)); + } + dvi->color_stack[dvi->color_top].fg = dvi->curr_fg; + dvi->color_stack[dvi->color_top].bg = dvi->curr_bg; + dvi->color_top++; + mdvi_set_color(dvi, fg, bg); +} + +void mdvi_pop_color(DviContext *dvi) +{ + Ulong fg, bg; + + if(dvi->color_top == 0) + return; + dvi->color_top--; + fg = dvi->color_stack[dvi->color_top].fg; + bg = dvi->color_stack[dvi->color_top].bg; + mdvi_set_color(dvi, fg, bg); +} + +void mdvi_reset_color(DviContext *dvi) +{ + dvi->color_top = 0; + mdvi_set_color(dvi, dvi->params.fg, dvi->params.bg); +} + diff --git a/dviware/mdvi/lib/dviread.c b/dviware/mdvi/lib/dviread.c new file mode 100644 index 0000000000..1b8db1369f --- /dev/null +++ b/dviware/mdvi/lib/dviread.c @@ -0,0 +1,1548 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <math.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> + +#include "mdvi.h" +#include "private.h" + +typedef int (*DviCommand) __PROTO((DviContext *, int)); + +#define DVICMDDEF(x) static int x __PROTO((DviContext *, int)) + +DVICMDDEF(set_char); +DVICMDDEF(set_rule); +DVICMDDEF(no_op); +DVICMDDEF(push); +DVICMDDEF(pop); +DVICMDDEF(move_right); +DVICMDDEF(move_down); +DVICMDDEF(move_w); +DVICMDDEF(move_x); +DVICMDDEF(move_y); +DVICMDDEF(move_z); +DVICMDDEF(sel_font); +DVICMDDEF(sel_fontn); +DVICMDDEF(special); +DVICMDDEF(def_font); +DVICMDDEF(undefined); +DVICMDDEF(unexpected); + +static const DviCommand dvi_commands[] = { + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, + set_char, set_char, set_char, set_char, /* 0 - 127 */ + set_char, set_char, set_char, set_char, /* 128 - 131 */ + set_rule, /* 132 */ + set_char, set_char, set_char, set_char, /* 133 - 136 */ + set_rule, /* 137 */ + no_op, /* 138 */ + unexpected, /* 139 (BOP) */ + unexpected, /* 140 (EOP) */ + push, /* 141 */ + pop, /* 142 */ + move_right, move_right, move_right, move_right, /* 143 - 146 */ + move_w, move_w, move_w, move_w, move_w, /* 147 - 151 */ + move_x, move_x, move_x, move_x, move_x, /* 152 - 156 */ + move_down, move_down, move_down, move_down, /* 157 - 160 */ + move_y, move_y, move_y, move_y, move_y, /* 161 - 165 */ + move_z, move_z, move_z, move_z, move_z, /* 166 - 170 */ + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, + sel_font, sel_font, sel_font, sel_font, /* 171 - 234 */ + sel_fontn, sel_fontn, sel_fontn, sel_fontn, /* 235 - 238 */ + special, special, special, special, /* 239 - 242 */ + def_font, def_font, def_font, def_font, /* 243 - 246 */ + unexpected, /* 247 (PRE) */ + unexpected, /* 248 (POST) */ + unexpected, /* 249 (POST_POST) */ + undefined, undefined, undefined, + undefined, undefined, undefined /* 250 - 255 */ +}; + +#define DVI_BUFLEN 4096 + +static void dummy_draw_glyph(DviContext *dvi, DviFontChar *ch, int x, int y) +{ +} + +static void dummy_draw_rule(DviContext *dvi, int x, int y, Uint w, Uint h, int f) +{ +} + +static int dummy_alloc_colors(void *a, Ulong *b, int c, Ulong d, Ulong e, double f, int g) +{ + return -1; +} + +static void *dummy_create_image(void *a, Uint b, Uint c, Uint d) +{ + return NULL; +} + +static void dummy_free_image(void *a) +{ +} + +static void dummy_dev_destroy(void *a) +{ +} + +static void dummy_dev_putpixel(void *a, int x, int y, Ulong c) +{ +} + +static void dummy_dev_refresh(DviContext *a, void *b) +{ +} + +static void dummy_dev_set_color(void *a, Ulong b, Ulong c) +{ +} + +/* functions to report errors */ +static void dvierr(DviContext *dvi, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + fprintf(stderr, "%s[%d]: Error: ", + dvi->filename, dvi->currpage); + vfprintf(stderr, format, ap); + va_end(ap); +} + +static void dviwarn(DviContext *dvi, const char *format, ...) +{ + va_list ap; + + fprintf(stderr, "%s[%d]: Warning: ", + dvi->filename, dvi->currpage); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); +} + +#define NEEDBYTES(d,n) \ + ((d)->buffer.pos + (n) > (d)->buffer.length) + +static int get_bytes(DviContext *dvi, size_t n) +{ + /* + * caller wants to read `n' bytes from dvi->buffer + dvi->pos. + * Make sure there is enough data to satisfy the request + */ + if(NEEDBYTES(dvi, n)) { + size_t required; + int newlen; + + if(dvi->buffer.frozen || dvi->in == NULL || feof(dvi->in)) { + /* this is EOF */ + dviwarn(dvi, _("unexpected EOF\n")); + return -1; + } + /* get more data */ + if(dvi->buffer.data == NULL) { + /* first allocation */ + dvi->buffer.size = Max(DVI_BUFLEN, n); + dvi->buffer.data = (Uchar *)xmalloc(dvi->buffer.size); + dvi->buffer.length = 0; + dvi->buffer.frozen = 0; + } else if(dvi->buffer.pos < dvi->buffer.length) { + /* move whatever we want to keep */ + dvi->buffer.length -= dvi->buffer.pos; + memmove(dvi->buffer.data, + dvi->buffer.data + dvi->buffer.pos, + dvi->buffer.length); + } else { + /* we can discard all the data in this buffer */ + dvi->buffer.length = 0; + } + + required = n - dvi->buffer.length; + if(required > dvi->buffer.size - dvi->buffer.length) { + /* need to allocate more memory */ + dvi->buffer.size = dvi->buffer.length + required + 128; + dvi->buffer.data = (Uchar *)xresize(dvi->buffer.data, + char, dvi->buffer.size); + } + /* now read into the buffer */ + newlen = fread(dvi->buffer.data + dvi->buffer.length, + 1, dvi->buffer.size - dvi->buffer.length, dvi->in); + if(newlen == -1) { + error("%s: %s\n", dvi->filename, strerror(errno)); + return -1; + } + dvi->buffer.length += newlen; + dvi->buffer.pos = 0; + } + return 0; +} + +/* only relative forward seeks are supported by this function */ +static int dskip(DviContext *dvi, long offset) +{ + ASSERT(offset > 0); + + if(NEEDBYTES(dvi, offset) && get_bytes(dvi, offset) == -1) + return -1; + dvi->buffer.pos += offset; + return 0; +} + +/* DVI I/O functions (note: here `n' must be <= 4) */ +static long dsgetn(DviContext *dvi, size_t n) +{ + long val; + + if(NEEDBYTES(dvi, n) && get_bytes(dvi, n) == -1) + return -1; + val = msgetn(dvi->buffer.data + dvi->buffer.pos, n); + dvi->buffer.pos += n; + return val; +} + +static int dread(DviContext *dvi, char *buffer, size_t len) +{ + if(NEEDBYTES(dvi, len) && get_bytes(dvi, len) == -1) + return -1; + memcpy(buffer, dvi->buffer.data + dvi->buffer.pos, len); + dvi->buffer.pos += len; + return 0; +} + +static long dugetn(DviContext *dvi, size_t n) +{ + long val; + + if(NEEDBYTES(dvi, n) && get_bytes(dvi, n) == -1) + return -1; + val = mugetn(dvi->buffer.data + dvi->buffer.pos, n); + dvi->buffer.pos += n; + return val; +} + +static long dtell(DviContext *dvi) +{ + return dvi->depth ? + dvi->buffer.pos : + ftell(dvi->in) - dvi->buffer.length + dvi->buffer.pos; +} + +static void dreset(DviContext *dvi) +{ + if(!dvi->buffer.frozen && dvi->buffer.data) + xfree(dvi->buffer.data); + dvi->buffer.data = NULL; + dvi->buffer.size = 0; + dvi->buffer.length = 0; + dvi->buffer.pos = 0; +} + +#define dsget1(d) dsgetn((d), 1) +#define dsget2(d) dsgetn((d), 2) +#define dsget3(d) dsgetn((d), 3) +#define dsget4(d) dsgetn((d), 4) +#define duget1(d) dugetn((d), 1) +#define duget2(d) dugetn((d), 2) +#define duget3(d) dugetn((d), 3) +#define duget4(d) dugetn((d), 4) + +#ifndef NODEBUG +static void dviprint(DviContext *dvi, const char *command, int sub, const char *fmt, ...) +{ + int i; + va_list ap; + + printf("%s: ", dvi->filename); + for(i = 0; i < dvi->depth; i++) + printf(" "); + printf("%4lu: %s", dtell(dvi), command); + if(sub >= 0) printf("%d", sub); + if(*fmt) printf(": "); + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} +#define SHOWCMD(x) \ + if(_mdvi_debug_mask & DBG_OPCODE) do { dviprint x; } while(0) +#else +#define SHOWCMD(x) do { } while(0) +#endif + +int mdvi_find_tex_page(DviContext *dvi, int tex_page) +{ + int i; + + for(i = 0; i < dvi->npages; i++) + if(dvi->pagemap[i][1] == tex_page) + return i; + return -1; +} + +/* page sorting functions */ +static int sort_up(const void *p1, const void *p2) +{ + return ((long *)p1)[1] - ((long *)p2)[1]; +} +static int sort_down(const void *p1, const void *p2) +{ + return ((long *)p2)[1] - ((long *)p1)[1]; +} +static int sort_random(const void *p1, const void *p2) +{ + return (random() % 1) ? -1 : 1; +} +static int sort_dvi_up(const void *p1, const void *p2) +{ + return ((long *)p1)[0] - ((long *)p2)[0]; +} +static int sort_dvi_down(const void *p1, const void *p2) +{ + return ((long *)p1)[0] - ((long *)p2)[0]; +} + +void mdvi_sort_pages(DviContext *dvi, DviPageSort type) +{ + int (*sortfunc) __PROTO((const void *, const void *)); + + switch(type) { + case MDVI_PAGE_SORT_UP: + sortfunc = sort_up; + break; + case MDVI_PAGE_SORT_DOWN: + sortfunc = sort_down; + break; + case MDVI_PAGE_SORT_RANDOM: + sortfunc = sort_random; + break; + case MDVI_PAGE_SORT_DVI_UP: + sortfunc = sort_dvi_up; + break; + case MDVI_PAGE_SORT_DVI_DOWN: + sortfunc = sort_dvi_down; + break; + case MDVI_PAGE_SORT_NONE: + default: + sortfunc = NULL; + break; + } + + if(sortfunc) + qsort(dvi->pagemap, dvi->npages, sizeof(PageNum), sortfunc); +} + +static DviFontRef *define_font(DviContext *dvi, int op) +{ + Int32 arg; + Int32 scale; + Int32 dsize; + Int32 checksum; + int hdpi; + int vdpi; + int n; + char *name; + DviFontRef *ref; + + arg = dugetn(dvi, op - DVI_FNT_DEF1 + 1); + checksum = duget4(dvi); + scale = duget4(dvi); + dsize = duget4(dvi); + hdpi = FROUND(dvi->params.mag * dvi->params.dpi * scale / dsize); + vdpi = FROUND(dvi->params.mag * dvi->params.vdpi * scale / dsize); + n = duget1(dvi) + duget1(dvi); + name = xmalloc(n + 1); + dread(dvi, name, n); + name[n] = 0; + DEBUG((DBG_FONTS, "requesting font %d = `%s' at %.1fpt (%dx%d dpi)\n", + arg, name, (double)scale / (dvi->params.tfm_conv * 0x100000), + hdpi, vdpi)); + ref = font_reference(&dvi->params, arg, name, checksum, hdpi, vdpi, scale); + if(ref == NULL) { + error(_("could not load font `%s'\n"), name); + xfree(name); + return NULL; + } + xfree(name); + return ref; +} + +static char *opendvi(const char *name) +{ + int len; + char *file; + + len = strlen(name); + /* if file ends with .dvi and it exists, that's it */ + if(len >= 4 && STREQ(name+len-4, ".dvi")) { + DEBUG((DBG_DVI|DBG_FILES, "opendvi: Trying `%s'\n", name)); + if(access(name, R_OK) == 0) + return xstrdup(name); + } + + /* try appending .dvi */ + file = xmalloc(len + 5); + strcpy(file, name); + strcpy(file+len, ".dvi"); + DEBUG((DBG_DVI|DBG_FILES, "opendvi: Trying `%s'\n", file)); + if(access(file, R_OK) == 0) + return file; + /* try the given name */ + file[len] = 0; + DEBUG((DBG_DVI|DBG_FILES, "opendvi: Trying `%s'\n", file)); + if(access(file, R_OK) == 0) + return file; + xfree(file); + return NULL; +} + +int mdvi_reload(DviContext *dvi, DviParams *np) +{ + DviContext *newdvi; + DviParams *pars; + + /* close our file */ + if(dvi->in) { + fclose(dvi->in); + dvi->in = NULL; + } + + pars = np ? np : &dvi->params; + DEBUG((DBG_DVI, "%s: reloading\n", dvi->filename)); + + /* load it again */ + newdvi = mdvi_init_context(pars, dvi->pagesel, dvi->filename); + if(newdvi == NULL) { + warning(_("could not reload `%s'\n"), dvi->filename); + return -1; + } + + /* drop all our font references */ + font_drop_chain(dvi->fonts); + /* destroy our font map */ + if(dvi->fontmap) + xfree(dvi->fontmap); + dvi->currfont = NULL; + + /* and use the ones we just loaded */ + dvi->fonts = newdvi->fonts; + dvi->fontmap = newdvi->fontmap; + dvi->nfonts = newdvi->nfonts; + + /* copy the new information */ + dvi->params = newdvi->params; + dvi->num = newdvi->num; + dvi->den = newdvi->den; + dvi->dvimag = newdvi->dvimag; + dvi->dviconv = newdvi->dviconv; + dvi->dvivconv = newdvi->dvivconv; + dvi->modtime = newdvi->modtime; + + if(dvi->fileid) xfree(dvi->fileid); + dvi->fileid = newdvi->fileid; + + dvi->dvi_page_w = newdvi->dvi_page_w; + dvi->dvi_page_h = newdvi->dvi_page_h; + + xfree(dvi->pagemap); + dvi->pagemap = newdvi->pagemap; + dvi->npages = newdvi->npages; + if(dvi->currpage > dvi->npages-1) + dvi->currpage = 0; + + xfree(dvi->stack); + dvi->stack = newdvi->stack; + dvi->stacksize = newdvi->stacksize; + + /* remove fonts that are not being used anymore */ + font_free_unused(&dvi->device); + + xfree(newdvi->filename); + xfree(newdvi); + + DEBUG((DBG_DVI, "%s: reload successful\n", dvi->filename)); + if(dvi->device.refresh) + dvi->device.refresh(dvi, dvi->device.device_data); + + return 0; +} + +/* function to change parameters ia DVI context + * The DVI context is modified ONLY if this function is successful */ +int mdvi_configure(DviContext *dvi, DviParamCode option, ...) +{ + va_list ap; + int reset_all; + int reset_font; + DviParams np; + + va_start(ap, option); + + reset_font = 0; + reset_all = 0; + np = dvi->params; /* structure copy */ + while(option != MDVI_PARAM_LAST) { + switch(option) { + case MDVI_SET_DPI: + np.dpi = np.vdpi = va_arg(ap, Uint); + reset_all = 1; + break; + case MDVI_SET_XDPI: + np.dpi = va_arg(ap, Uint); + reset_all = 1; + break; + case MDVI_SET_YDPI: + np.vdpi = va_arg(ap, Uint); + break; + case MDVI_SET_SHRINK: + np.hshrink = np.vshrink = va_arg(ap, Uint); + reset_font = MDVI_FONTSEL_GREY|MDVI_FONTSEL_BITMAP; + break; + case MDVI_SET_XSHRINK: + np.hshrink = va_arg(ap, Uint); + reset_font = MDVI_FONTSEL_GREY|MDVI_FONTSEL_BITMAP; + break; + case MDVI_SET_YSHRINK: + np.vshrink = va_arg(ap, Uint); + reset_font = MDVI_FONTSEL_GREY|MDVI_FONTSEL_BITMAP; + break; + case MDVI_SET_ORIENTATION: + np.orientation = va_arg(ap, DviOrientation); + reset_font = MDVI_FONTSEL_GLYPH; + break; + case MDVI_SET_GAMMA: + np.gamma = va_arg(ap, double); + if(np.pixels) { + xfree(np.pixels); + np.pixels = 0; + np.npixels = 0; + } + reset_font = MDVI_FONTSEL_GREY; + break; + case MDVI_SET_DENSITY: + np.density = va_arg(ap, Uint); + reset_font = MDVI_FONTSEL_BITMAP; + break; + case MDVI_SET_MAGNIFICATION: + np.mag = va_arg(ap, double); + reset_all = 1; + break; + case MDVI_SET_DRIFT: + np.hdrift = np.vdrift = va_arg(ap, int); + break; + case MDVI_SET_HDRIFT: + np.hdrift = va_arg(ap, int); + break; + case MDVI_SET_VDRIFT: + np.vdrift = va_arg(ap, int); + break; + case MDVI_SET_FOREGROUND: + np.fg = va_arg(ap, Ulong); + reset_font = MDVI_FONTSEL_GREY; + break; + case MDVI_SET_BACKGROUND: + np.bg = va_arg(ap, Ulong); + reset_font = MDVI_FONTSEL_GREY; + break; + default: + break; + } + option = va_arg(ap, DviParamCode); + } + va_end(ap); + + /* check that all values make sense */ + if(np.dpi <= 0 || np.vdpi <= 0) + return -1; + if(np.mag <= 0.0) + return -1; + if(np.density < 0) + return -1; + if(np.hshrink < 1 || np.vshrink < 1) + return -1; + if(np.hdrift < 0 || np.vdrift < 0) + return -1; + if(np.fg == np.bg) + return -1; + + /* + * If the dpi or the magnification change, we basically have to reload + * the DVI file again from scratch. + */ + + if(reset_all) + return (mdvi_reload(dvi, &np) == 0); + + if(np.hshrink != dvi->params.hshrink) { + np.conv = dvi->dviconv; + if(np.hshrink) + np.conv /= np.hshrink; + } + if(np.vshrink != dvi->params.vshrink) { + np.vconv = dvi->dvivconv; + if(np.vshrink) + np.vconv /= np.vshrink; + } + + if(reset_font) { + font_reset_chain_glyphs(&dvi->device, dvi->fonts, reset_font); + } + dvi->params = np; + if((reset_font & MDVI_FONTSEL_GLYPH) && dvi->device.refresh) { + dvi->device.refresh(dvi, dvi->device.device_data); + return 0; + } + + return 1; +} +/* + * Read the initial data from the DVI file. If something is wrong with the + * file, we just spit out an error message and refuse to load the file, + * without giving any details. This makes sense because DVI files are ok + * 99.99% of the time, and dvitype(1) can be used to check the other 0.01%. + */ +DviContext *mdvi_init_context(DviParams *par, DviPageSpec *spec, const char *file) +{ + FILE *p; + Int32 arg; + int op; + long offset; + int n; + DviContext *dvi; + char *filename; + int pagecount; + + /* + * 1. Open the file and initialize the DVI context + */ + + filename = opendvi(file); + if(filename == NULL) { + perror(file); + return NULL; + } + p = fopen(filename, "r"); + if(p == NULL) { + perror(file); + xfree(filename); + return NULL; + } + dvi = xalloc(DviContext); + memzero(dvi, sizeof(DviContext)); + dvi->pagemap = NULL; + dvi->filename = filename; + dvi->stack = NULL; + dvi->modtime = get_mtime(fileno(p)); + dvi->buffer.data = NULL; + dvi->pagesel = spec; + dvi->in = p; /* now we can use the dget*() functions */ + + /* + * 2. Read the preamble, extract scaling information, and + * setup the DVI parameters. + */ + + if(fuget1(p) != DVI_PRE) + goto bad_dvi; + if((arg = fuget1(p)) != DVI_ID) { + error(_("%s: unsupported DVI format (version %u)\n"), + file, arg); + goto error; /* jump to the end of this routine, + * where we handle errors */ + } + /* get dimensions */ + dvi->num = fuget4(p); + dvi->den = fuget4(p); + dvi->dvimag = fuget4(p); + + /* check that these numbers make sense */ + if(!dvi->num || !dvi->den || !dvi->dvimag) + goto bad_dvi; + + dvi->params.mag = + (par->mag > 0 ? par->mag : (double)dvi->dvimag / 1000.0); + dvi->params.hdrift = par->hdrift; + dvi->params.vdrift = par->vdrift; + dvi->params.dpi = par->dpi ? par->dpi : MDVI_DPI; + dvi->params.vdpi = par->vdpi ? par->vdpi : par->dpi; + dvi->params.hshrink = par->hshrink; + dvi->params.vshrink = par->vshrink; + dvi->params.density = par->density; + dvi->params.gamma = par->gamma; + dvi->params.conv = (double)dvi->num / dvi->den; + dvi->params.conv *= (dvi->params.dpi / 254000.0) * dvi->params.mag; + dvi->params.vconv = (double)dvi->num / dvi->den; + dvi->params.vconv *= (dvi->params.vdpi / 254000.0) * dvi->params.mag; + dvi->params.tfm_conv = (25400000.0 / dvi->num) * + ((double)dvi->den / 473628672) / 16.0; + dvi->params.flags = par->flags; + dvi->params.orientation = par->orientation; + dvi->params.fg = par->fg; + dvi->params.bg = par->bg; + dvi->params.pixels = NULL; + dvi->params.npixels = 0; + + /* initialize colors */ + dvi->curr_fg = par->fg; + dvi->curr_bg = par->bg; + dvi->color_stack = NULL; + dvi->color_top = 0; + dvi->color_size = 0; + + /* pixel conversion factors */ + dvi->dviconv = dvi->params.conv; + dvi->dvivconv = dvi->params.vconv; + if(dvi->params.hshrink) + dvi->params.conv /= dvi->params.hshrink; + if(dvi->params.vshrink) + dvi->params.vconv /= dvi->params.vshrink; + + /* get the comment from the preamble */ + n = fuget1(p); + dvi->fileid = xmalloc(n + 1); + fread(dvi->fileid, 1, n, p); + dvi->fileid[n] = 0; + DEBUG((DBG_DVI, "%s: %s\n", filename, dvi->fileid)); + + /* + * 3. Read postamble, extract page information (number of + * pages, dimensions) and stack depth. + */ + + /* jump to the end of the file */ + if(fseek(p, (long)-1, SEEK_END) == -1) + goto error; + for(n = 0; (op = fuget1(p)) == DVI_TRAILER; n++) + if(fseek(p, (long)-2, SEEK_CUR) < 0) + break; + if(op != arg || n < 4) + goto bad_dvi; + /* get the pointer to postamble */ + fseek(p, (long)-5, SEEK_CUR); + arg = fuget4(p); + /* jump to it */ + fseek(p, (long)arg, SEEK_SET); + if(fuget1(p) != DVI_POST) + goto bad_dvi; + offset = fuget4(p); + if(dvi->num != fuget4(p) || dvi->den != fuget4(p) || + dvi->dvimag != fuget4(p)) + goto bad_dvi; + dvi->dvi_page_h = fuget4(p); + dvi->dvi_page_w = fuget4(p); + dvi->stacksize = fuget2(p); + dvi->npages = fuget2(p); + DEBUG((DBG_DVI, "%s: from postamble: stack depth %d, %d page%s\n", + filename, dvi->stacksize, dvi->npages, dvi->npages > 1 ? "s" : "")); + + /* + * 4. Process font definitions. + */ + + /* process font definitions */ + dvi->nfonts = 0; + dvi->fontmap = NULL; + /* + * CAREFUL: here we need to use the dvi->buffer, but it might leave the + * the file cursor in the wrong position after reading fonts (because of + * buffering). It's ok, though, because after the font definitions we read + * the page offsets, and we fseek() to the relevant part of the file with + * SEEK_SET. Nothing is read after the page offsets. + */ + while((op = duget1(dvi)) != DVI_POST_POST) { + DviFontRef *ref; + + if(op == DVI_NOOP) + continue; + else if(op < DVI_FNT_DEF1 || op > DVI_FNT_DEF4) + goto error; + ref = define_font(dvi, op); + if(ref == NULL) + goto error; + ref->next = dvi->fonts; + dvi->fonts = ref; + dvi->nfonts++; + } + /* we don't need the buffer anymore */ + dreset(dvi); + + if(op != DVI_POST_POST) + goto bad_dvi; + font_finish_definitions(dvi); + DEBUG((DBG_DVI, "%s: %d font%s required by this job\n", + filename, dvi->nfonts, dvi->nfonts > 1 ? "s" : "")); + dvi->findref = font_find_mapped; + + /* + * 5. Build the page map. + */ + + dvi->pagemap = xnalloc(PageNum, dvi->npages); + memzero(dvi->pagemap, sizeof(PageNum) * dvi->npages); + + n = dvi->npages - 1; + pagecount = n; + while(offset != -1) { + int i; + PageNum page; + + fseek(p, offset, SEEK_SET); + op = fuget1(p); + if(op != DVI_BOP || n < 0) + goto bad_dvi; + for(i = 1; i <= 10; i++) + page[i] = fsget4(p); + page[0] = offset; + offset = (long)fuget4(p); + /* check if the page is selected */ + if(spec && mdvi_page_selected(spec, page, n) == 0) { + DEBUG((DBG_DVI, "Page %d (%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld.%ld) ignored by request\n", + n, page[1], page[2], page[3], page[4], page[5], + page[6], page[7], page[8], page[9], page[10])); + } else { + memcpy(&dvi->pagemap[pagecount], page, sizeof(PageNum)); + pagecount--; + } + n--; + } + pagecount++; + if(pagecount >= dvi->npages) { + error(_("no pages selected\n")); + goto error; + } + if(pagecount) { + DEBUG((DBG_DVI, "%d of %d pages selected\n", + dvi->npages - pagecount, dvi->npages)); + dvi->npages -= pagecount; + memmove(dvi->pagemap, &dvi->pagemap[pagecount], + dvi->npages * sizeof(PageNum)); + } + + /* + * 6. Setup stack, initialize device functions + */ + + dvi->curr_layer = 0; + dvi->stack = xnalloc(DviState, dvi->stacksize + 8); + + dvi->device.draw_glyph = dummy_draw_glyph; + dvi->device.draw_rule = dummy_draw_rule; + dvi->device.alloc_colors = dummy_alloc_colors; + dvi->device.create_image = dummy_create_image; + dvi->device.free_image = dummy_free_image; + dvi->device.dev_destroy = dummy_dev_destroy; + dvi->device.put_pixel = dummy_dev_putpixel; + dvi->device.refresh = dummy_dev_refresh; + dvi->device.set_color = dummy_dev_set_color; + dvi->device.device_data = NULL; + + /* initialize associations */ + mdvi_hash_init(&dvi->assoc); + + DEBUG((DBG_DVI, "%s read successfully\n", filename)); + return dvi; + +bad_dvi: + error(_("%s: File corrupted, or not a DVI file\n"), file); +error: + /* if we came from the font definitions, this will be non-trivial */ + dreset(dvi); + mdvi_destroy_context(dvi); + return NULL; +} + +void mdvi_destroy_context(DviContext *dvi) +{ + if(dvi->device.dev_destroy) + dvi->device.dev_destroy(dvi->device.device_data); + /* release all fonts */ + if(dvi->fonts) { + font_drop_chain(dvi->fonts); + font_free_unused(&dvi->device); + } + if(dvi->fontmap) + xfree(dvi->fontmap); + if(dvi->filename) + xfree(dvi->filename); + if(dvi->stack) + xfree(dvi->stack); + if(dvi->pagemap) + xfree(dvi->pagemap); + if(dvi->fileid) + xfree(dvi->fileid); + if(dvi->in) + fclose(dvi->in); + if(dvi->buffer.data && !dvi->buffer.frozen) + xfree(dvi->buffer.data); + if(dvi->color_stack) + xfree(dvi->color_stack); + mdvi_assoc_flush(dvi); + + xfree(dvi); +} + +void mdvi_setpage(DviContext *dvi, int pageno) +{ + if(pageno < 0) + pageno = 0; + if(pageno > dvi->npages-1) + pageno = dvi->npages - 1; + dvi->currpage = pageno; +} + +int mdvi_run_macro(DviContext *dvi, Uchar *macro, size_t len) +{ + DviFontRef *curr, *fonts; + DviBuffer saved_buffer; + FILE *saved_file; + int opcode; + int oldtop; + + dvi->depth++; + push(dvi, DVI_PUSH); + dvi->pos.w = 0; + dvi->pos.x = 0; + dvi->pos.y = 0; + dvi->pos.z = 0; + + /* save our state */ + curr = dvi->currfont; + fonts = dvi->fonts; + saved_buffer = dvi->buffer; + saved_file = dvi->in; + dvi->currfont = curr->ref->subfonts; + dvi->fonts = curr->ref->subfonts; + dvi->buffer.data = macro; + dvi->buffer.pos = 0; + dvi->buffer.length = len; + dvi->buffer.frozen = 1; + dvi->in = NULL; + oldtop = dvi->stacktop; + + /* execute commands */ + while((opcode = duget1(dvi)) != DVI_EOP) { + if(dvi_commands[opcode](dvi, opcode) < 0) + break; + } + if(opcode != DVI_EOP) + dviwarn(dvi, _("%s: vf macro had errors\n"), + curr->ref->fontname); + if(dvi->stacktop != oldtop) + dviwarn(dvi, _("%s: stack not empty after vf macro\n"), + curr->ref->fontname); + + /* restore things */ + pop(dvi, DVI_POP); + dvi->currfont = curr; + dvi->fonts = fonts; + dvi->buffer = saved_buffer; + dvi->in = saved_file; + dvi->depth--; + + return (opcode != DVI_EOP ? -1 : 0); +} + +int mdvi_dopage(DviContext *dvi, int pageno) +{ + int op; + int ppi; + int reloaded = 0; + +again: + if(dvi->in == NULL) { + /* try reopening the file */ + dvi->in = fopen(dvi->filename, "r"); + if(dvi->in == NULL) { + warning(_("%s: could not reopen file (%s)\n"), + dvi->filename, + strerror(errno)); + return -1; + } + DEBUG((DBG_FILES, "reopen(%s) -> Ok\n", dvi->filename)); + } + + /* check if we need to reload the file */ + if(!reloaded && get_mtime(fileno(dvi->in)) > dvi->modtime) { + mdvi_reload(dvi, &dvi->params); + /* we have to reopen the file, again */ + reloaded = 1; + goto again; + } + + if(pageno < 0 || pageno > dvi->npages-1) { + error(_("%s: page %d out of range\n"), + dvi->filename, pageno); + return -1; + } + + fseek(dvi->in, (long)dvi->pagemap[pageno][0], SEEK_SET); + if((op = fuget1(dvi->in)) != DVI_BOP) { + error(_("%s: bad offset at page %d\n"), + dvi->filename, pageno+1); + return -1; + } + + /* skip bop */ + fseek(dvi->in, (long)44, SEEK_CUR); + + /* reset state */ + dvi->currfont = NULL; + memzero(&dvi->pos, sizeof(DviState)); + dvi->stacktop = 0; + dvi->currpage = pageno; + dvi->curr_layer = 0; + + if(dvi->buffer.data && !dvi->buffer.frozen) + xfree(dvi->buffer.data); + + /* reset our buffer */ + dvi->buffer.data = NULL; + dvi->buffer.length = 0; + dvi->buffer.pos = 0; + dvi->buffer.frozen = 0; + +#if 0 /* make colors survive page breaks */ + /* reset color stack */ + mdvi_reset_color(dvi); +#endif + + /* set max horizontal and vertical drift (from dvips) */ + if(dvi->params.hdrift < 0) { + ppi = dvi->params.dpi / dvi->params.hshrink; /* shrunk pixels per inch */ + if(ppi < 600) + dvi->params.hdrift = ppi / 100; + else if(ppi < 1200) + dvi->params.hdrift = ppi / 200; + else + dvi->params.hdrift = ppi / 400; + } + if(dvi->params.vdrift < 0) { + ppi = dvi->params.vdpi / dvi->params.vshrink; /* shrunk pixels per inch */ + if(ppi < 600) + dvi->params.vdrift = ppi / 100; + else if(ppi < 1200) + dvi->params.vdrift = ppi / 200; + else + dvi->params.vdrift = ppi / 400; + } + + dvi->params.thinsp = FROUND(0.025 * dvi->params.dpi / dvi->params.conv); + dvi->params.vsmallsp = FROUND(0.025 * dvi->params.vdpi / dvi->params.vconv); + + /* execute all the commands in the page */ + while((op = duget1(dvi)) != DVI_EOP) { + if(dvi_commands[op](dvi, op) < 0) + break; + } + + fflush(stdout); + fflush(stderr); + if(op != DVI_EOP) + return -1; + if(dvi->stacktop) + dviwarn(dvi, _("stack not empty at end of page\n")); + return 0; +} + +static int inline move_vertical(DviContext *dvi, int amount) +{ + int rvv; + + dvi->pos.v += amount; + rvv = vpixel_round(dvi, dvi->pos.v); + if(!dvi->params.vdrift) + return rvv; + if(amount > dvi->params.vsmallsp || amount <= -dvi->params.vsmallsp) + return rvv; + else { + int newvv; + + newvv = dvi->pos.vv + vpixel_round(dvi, amount); + if(rvv - newvv > dvi->params.vdrift) + return rvv - dvi->params.vdrift; + else if(newvv - rvv > dvi->params.vdrift) + return rvv + dvi->params.vdrift; + else + return newvv; + } +} + +static int inline move_horizontal(DviContext *dvi, int amount) +{ + int rhh; + + dvi->pos.h += amount; + rhh = pixel_round(dvi, dvi->pos.h); + if(!dvi->params.hdrift) + return rhh; + else if(amount > dvi->params.thinsp || amount <= -6 * dvi->params.thinsp) + return rhh; + else { + int newhh; + + newhh = dvi->pos.hh + pixel_round(dvi, amount); + if(rhh - newhh > dvi->params.hdrift) + return rhh - dvi->params.hdrift; + else if(newhh - rhh > dvi->params.hdrift) + return rhh + dvi->params.hdrift; + else + return newhh; + } +} + +static void inline fix_after_horizontal(DviContext *dvi) +{ + int rhh; + + rhh = pixel_round(dvi, dvi->pos.h); + if(!dvi->params.hdrift) + dvi->pos.hh = rhh; + else if(rhh - dvi->pos.hh > dvi->params.hdrift) + dvi->pos.hh = rhh - dvi->params.hdrift; + else if(dvi->pos.hh - rhh > dvi->params.hdrift) + dvi->pos.hh = rhh + dvi->params.hdrift; +} + +/* commands */ + +#define DBGSUM(a,b,c) \ + (a), (b) > 0 ? '+' : '-', \ + (b) > 0 ? (b) : -(b), (c) + +/* + * The only commands that actually draw something are: + * set_char, set_rule + */ + +static void draw_box(DviContext *dvi, DviFontChar *ch) +{ + DviGlyph *glyph = NULL; + int x, y, w, h; + + if(!MDVI_GLYPH_UNSET(ch->shrunk.data)) + glyph = &ch->shrunk; + else if(!MDVI_GLYPH_UNSET(ch->grey.data)) + glyph = &ch->grey; + else if(!MDVI_GLYPH_UNSET(ch->glyph.data)) + glyph = &ch->glyph; + if(glyph == NULL) + return; + x = glyph->x; + y = glyph->y; + w = glyph->w; + h = glyph->h; + /* this is bad -- we have to undo the orientation */ + switch(dvi->params.orientation) { + case MDVI_ORIENT_TBLR: + break; + case MDVI_ORIENT_TBRL: + x = w - x; + break; + case MDVI_ORIENT_BTLR: + y = h - y; + break; + case MDVI_ORIENT_BTRL: + x = w - x; + y = h - y; + break; + case MDVI_ORIENT_RP90: + SWAPINT(w, h); + SWAPINT(x, y); + x = w - x; + break; + case MDVI_ORIENT_RM90: + SWAPINT(w, h); + SWAPINT(x, y); + y = h - y; + break; + case MDVI_ORIENT_IRP90: + SWAPINT(w, h); + SWAPINT(x, y); + break; + case MDVI_ORIENT_IRM90: + SWAPINT(w, h); + SWAPINT(x, y); + x = w - x; + y = h - y; + break; + } + + dvi->device.draw_rule(dvi, + dvi->pos.hh - x, dvi->pos.vv - y, w, h, 1); +} + +int set_char(DviContext *dvi, int opcode) +{ + int num; + int h; + int hh; + DviFontChar *ch; + DviFont *font; + + if(opcode < 128) + num = opcode; + else + num = dugetn(dvi, opcode - DVI_SET1 + 1); + if(dvi->currfont == NULL) { + dvierr(dvi, _("no default font set yet\n")); + return -1; + } + font = dvi->currfont->ref; + ch = font_get_glyph(dvi, font, num); + if(ch == NULL || ch->missing) { + /* try to display something anyway */ + ch = FONTCHAR(font, num); + if(!glyph_present(ch)) { + dviwarn(dvi, + _("requested character %d does not exist in `%s'\n"), + num, font->fontname); + return 0; + } + draw_box(dvi, ch); + } else if(dvi->curr_layer <= dvi->params.layer) { + if(ISVIRTUAL(font)) + mdvi_run_macro(dvi, (Uchar *)font->private + + ch->offset, ch->width); + else if(ch->width && ch->height) + dvi->device.draw_glyph(dvi, ch, + dvi->pos.hh, dvi->pos.vv); + } + if(opcode >= DVI_PUT1 && opcode <= DVI_PUT4) { + SHOWCMD((dvi, "putchar", opcode - DVI_PUT1 + 1, + "char %d (%s)\n", + num, dvi->currfont->ref->fontname)); + } else { + h = dvi->pos.h + ch->tfmwidth; + hh = dvi->pos.hh + pixel_round(dvi, ch->tfmwidth); + SHOWCMD((dvi, "setchar", num, "(%d,%d) h:=%d%c%d=%d, hh:=%d (%s)\n", + dvi->pos.hh, dvi->pos.vv, + DBGSUM(dvi->pos.h, ch->tfmwidth, h), hh, + font->fontname)); + dvi->pos.h = h; + dvi->pos.hh = hh; + fix_after_horizontal(dvi); + } + + return 0; +} + +int set_rule(DviContext *dvi, int opcode) +{ + Int32 a, b; + int h, w; + + a = dsget4(dvi); + b = dsget4(dvi); w = rule_round(dvi, b); + if(a > 0 && b > 0) { + h = vrule_round(dvi, a); + SHOWCMD((dvi, opcode == DVI_SET_RULE ? "setrule" : "putrule", -1, + "width %d, height %d (%dx%d pixels)\n", + b, a, w, h)); + /* the `draw' functions expect the origin to be at the top left + * corner of the rule, not the bottom left, as in DVI files */ + if(dvi->curr_layer <= dvi->params.layer) + dvi->device.draw_rule(dvi, + dvi->pos.hh, dvi->pos.vv - h + 1, w, h, 1); + } else { + SHOWCMD((dvi, opcode == DVI_SET_RULE ? "setrule" : "putrule", -1, + "(moving left only, by %d)\n", b)); + } + + if(opcode == DVI_SET_RULE) { + dvi->pos.h += b; + dvi->pos.hh += w; + fix_after_horizontal(dvi); + } + return 0; +} + +int no_op(DviContext *dvi, int opcode) +{ + SHOWCMD((dvi, "noop", -1, "")); + return 0; +} + +int push(DviContext *dvi, int opcode) +{ + if(dvi->stacktop == dvi->stacksize) { + if(!dvi->depth) + dviwarn(dvi, _("enlarging stack\n")); + dvi->stacksize += 8; + dvi->stack = xresize(dvi->stack, + DviState, dvi->stacksize); + } + memcpy(&dvi->stack[dvi->stacktop], &dvi->pos, sizeof(DviState)); + SHOWCMD((dvi, "push", -1, + "level %d: (h=%d,v=%d,w=%d,x=%d,y=%d,z=%d,hh=%d,vv=%d)\n", + dvi->stacktop, + dvi->pos.h, dvi->pos.v, dvi->pos.w, dvi->pos.x, + dvi->pos.y, dvi->pos.z, dvi->pos.hh, dvi->pos.vv)); + dvi->stacktop++; + return 0; +} + +int pop(DviContext *dvi, int opcode) +{ + if(dvi->stacktop == 0) { + dvierr(dvi, _("stack underflow\n")); + return -1; + } + memcpy(&dvi->pos, &dvi->stack[dvi->stacktop-1], sizeof(DviState)); + SHOWCMD((dvi, "pop", -1, + "level %d: (h=%d,v=%d,w=%d,x=%d,y=%d,z=%d,hh=%d,vv=%d)\n", + dvi->stacktop, + dvi->pos.h, dvi->pos.v, dvi->pos.w, dvi->pos.x, + dvi->pos.y, dvi->pos.z, dvi->pos.hh, dvi->pos.vv)); + dvi->stacktop--; + return 0; +} + +int move_right(DviContext *dvi, int opcode) +{ + Int32 arg; + int h, hh; + + arg = dsgetn(dvi, opcode - DVI_RIGHT1 + 1); + h = dvi->pos.h; + hh = move_horizontal(dvi, arg); + SHOWCMD((dvi, "right", opcode - DVI_RIGHT1 + 1, + "%d h:=%d%c%d=%d, hh:=%d\n", + arg, DBGSUM(h, arg, dvi->pos.h), hh)); + dvi->pos.hh = hh; + return 0; +} + +int move_down(DviContext *dvi, int opcode) +{ + Int32 arg; + int v, vv; + + arg = dsgetn(dvi, opcode - DVI_DOWN1 + 1); + v = dvi->pos.v; + vv = move_vertical(dvi, arg); + SHOWCMD((dvi, "down", opcode - DVI_DOWN1 + 1, + "%d v:=%d%c%d=%d, vv:=%d\n", + arg, DBGSUM(v, arg, dvi->pos.v), vv)); + dvi->pos.vv = vv; + return 0; +} + +int move_w(DviContext *dvi, int opcode) +{ + int h, hh; + + if(opcode != DVI_W0) + dvi->pos.w = dsgetn(dvi, opcode - DVI_W0); + h = dvi->pos.h; + hh = move_horizontal(dvi, dvi->pos.w); + SHOWCMD((dvi, "w", opcode - DVI_W0, + "%d h:=%d%c%d=%d, hh:=%d\n", + dvi->pos.w, DBGSUM(h, dvi->pos.w, dvi->pos.h), hh)); + dvi->pos.hh = hh; + return 0; +} + +int move_x(DviContext *dvi, int opcode) +{ + int h, hh; + + if(opcode != DVI_X0) + dvi->pos.x = dsgetn(dvi, opcode - DVI_X0); + h = dvi->pos.h; + hh = move_horizontal(dvi, dvi->pos.x); + SHOWCMD((dvi, "x", opcode - DVI_X0, + "%d h:=%d%c%d=%d, hh:=%d\n", + dvi->pos.x, DBGSUM(h, dvi->pos.x, dvi->pos.h), hh)); + dvi->pos.hh = hh; + return 0; +} + +int move_y(DviContext *dvi, int opcode) +{ + int v, vv; + + if(opcode != DVI_Y0) + dvi->pos.y = dsgetn(dvi, opcode - DVI_Y0); + v = dvi->pos.v; + vv = move_vertical(dvi, dvi->pos.y); + SHOWCMD((dvi, "y", opcode - DVI_Y0, + "%d h:=%d%c%d=%d, hh:=%d\n", + dvi->pos.y, DBGSUM(v, dvi->pos.y, dvi->pos.v), vv)); + dvi->pos.vv = vv; + return 0; +} + +int move_z(DviContext *dvi, int opcode) +{ + int v, vv; + + if(opcode != DVI_Z0) + dvi->pos.z = dsgetn(dvi, opcode - DVI_Z0); + v = dvi->pos.v; + vv = move_vertical(dvi, dvi->pos.z); + SHOWCMD((dvi, "z", opcode - DVI_Z0, + "%d h:=%d%c%d=%d, hh:=%d\n", + dvi->pos.z, DBGSUM(v, dvi->pos.z, dvi->pos.v), vv)); + dvi->pos.vv = vv; + return 0; +} + +int sel_font(DviContext *dvi, int opcode) +{ + DviFontRef *ref; + int ndx; + + ndx = opcode - DVI_FNT_NUM0; + if(dvi->depth) + ref = font_find_flat(dvi, ndx); + else + ref = dvi->findref(dvi, ndx); + if(ref == NULL) { + dvierr(dvi, _("font %d is not defined\n"), + opcode - DVI_FNT_NUM0); + return -1; + } + SHOWCMD((dvi, "fntnum", opcode - DVI_FNT_NUM0, + "current font is %s\n", + ref->ref->fontname)); + dvi->currfont = ref; + return 0; +} + +int sel_fontn(DviContext *dvi, int opcode) +{ + Int32 arg; + DviFontRef *ref; + + arg = dugetn(dvi, opcode - DVI_FNT1 + 1); + if(dvi->depth) + ref = font_find_flat(dvi, arg); + else + ref = dvi->findref(dvi, arg); + if(ref == NULL) { + dvierr(dvi, _("font %d is not defined\n"), arg); + return -1; + } + SHOWCMD((dvi, "fnt", opcode - DVI_FNT1 + 1, + "current font is %s (id %d)\n", + ref->ref->fontname, arg)); + dvi->currfont = ref; + return 0; +} + +int special(DviContext *dvi, int opcode) +{ + char *s; + Int32 arg; + + arg = dugetn(dvi, opcode - DVI_XXX1 + 1); + s = xmalloc(arg + 1); + dread(dvi, s, arg); + s[arg] = 0; + mdvi_do_special(dvi, s); + SHOWCMD((dvi, "XXXX", opcode - DVI_XXX1 + 1, + "[%s]", s)); + xfree(s); + return 0; +} + +int def_font(DviContext *dvi, int opcode) +{ + DviFontRef *ref; + Int32 arg; + + arg = dugetn(dvi, opcode - DVI_FNT_DEF1 + 1); + if(dvi->depth) + ref = font_find_flat(dvi, arg); + else + ref = dvi->findref(dvi, arg); + /* skip the rest */ + dskip(dvi, 12); + dskip(dvi, duget1(dvi) + duget1(dvi)); + if(ref == NULL) { + dvierr(dvi, _("font %d is not defined in postamble\n"), arg); + return -1; + } + SHOWCMD((dvi, "fntdef", opcode - DVI_FNT_DEF1 + 1, + "%d -> %s (%d links)\n", + ref->fontid, ref->ref->fontname, + ref->ref->links)); + return 0; +} + +int unexpected(DviContext *dvi, int opcode) +{ + dvierr(dvi, _("unexpected opcode %d\n"), opcode); + return -1; +} + +int undefined(DviContext *dvi, int opcode) +{ + dvierr(dvi, _("undefined opcode %d\n"), opcode); + return -1; +} + diff --git a/dviware/mdvi/lib/files.c b/dviware/mdvi/lib/files.c new file mode 100644 index 0000000000..d3dbcfedc1 --- /dev/null +++ b/dviware/mdvi/lib/files.c @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> + +#include "common.h" + +char *dgets(Dstring *dstr, FILE *in) +{ + char buffer[256]; + + dstr->length = 0; + if(feof(in)) + return NULL; + while(fgets(buffer, 256, in) != NULL) { + int len = strlen(buffer); + + if(buffer[len-1] == '\n') { + dstring_append(dstr, buffer, len - 1); + break; + } + dstring_append(dstr, buffer, len); + } + if(dstr->data) + dstr->data[dstr->length] = 0; + return dstr->data; +} + +/* some simple helper functions to manipulate file names */ + +const char *file_basename(const char *filename) +{ + const char *ptr = strrchr(filename, '/'); + + return (ptr ? ptr + 1 : filename); +} + +const char *file_extension(const char *filename) +{ + const char *ptr = strchr(file_basename(filename), '.'); + + return (ptr ? ptr + 1 : NULL); +} + +int file_readable(const char *filename) +{ + int status = (access(filename, R_OK) == 0); + + DEBUG((DBG_FILES, "file_redable(%s) -> %s\n", + filename, status ? "Yes" : "No")); + return status; +} + +int file_exists(const char *filename) +{ + int status = (access(filename, F_OK) == 0); + + DEBUG((DBG_FILES, "file_exists(%s) -> %s\n", + filename, status ? "Yes" : "No")); + return status; +} + +static char *xstrchre(const char *string, int c) +{ + const char *ptr; + + for(ptr = string; *ptr && *ptr != c; ptr++); + return (char *)ptr; +} + +char *find_in_path(const char *filename, const char *path) +{ + const char *p, *q; + char *try; + int len; + + /* if the file is readable as given, return it */ + if(file_readable(filename)) + return xstrdup(filename); + + /* worst case scenario */ + try = xmalloc(strlen(path) + strlen(filename) + 2); + try[0] = 0; + + for(p = path; *p; p = q) { + q = xstrchre(p, ':'); + len = q - p; + xstrncpy(try, p, len); + try[len] = '/'; + strcpy(try + len + 1, filename); + if(file_readable(try)) + break; + if(*q) q++; + } + + if(*p) + return try; + else { + xfree(try); + return NULL; + } +} + +char *read_into_core(const char *file, size_t *size) +{ + FILE *in; + struct stat st; + char *ptr; + + in = fopen(file, "r"); + if(in == NULL) + return NULL; + if(fstat(fileno(in), &st) < 0) { + /* I don't think this is possible, but who knows */ + fclose(in); + return NULL; + } + if(st.st_size == 0) { + warning("%s: file is empty\n", file); + fclose(in); + return NULL; + } + ptr = xmalloc(st.st_size + 1); + if(fread(ptr, st.st_size, 1, in) != 1) { + fclose(in); + xfree(ptr); + return NULL; + } + fclose(in); + ptr[st.st_size] = 0; + if(size) *size = st.st_size; + return ptr; +} diff --git a/dviware/mdvi/lib/font.c b/dviware/mdvi/lib/font.c new file mode 100644 index 0000000000..63fed3eb88 --- /dev/null +++ b/dviware/mdvi/lib/font.c @@ -0,0 +1,542 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> + +#include "mdvi.h" +#include "private.h" + +static ListHead fontlist; + +extern char *_mdvi_fallback_font; + +extern void vf_free_macros(DviFont *); + +#define finfo search.info +#define TYPENAME(font) \ + ((font)->finfo ? (font)->finfo->name : "none") + +void font_print(void) +{ + DviFont *font; + + message("Fonts registered (%d):\n", fontlist.count); + LIST_FOREACH(font, DviFont, &fontlist) { + message("%s: %dx%ddpi, scaled %.2f of %.2fpt, type `%s' at %p\n", + font->fontname, font->hdpi, font->vdpi, + (double)font->scale / 1048576, + (double)font->design / 1048576, + font->search.id < 0 ? "unknown" : font->search.info->name, + font); + message(" %sloaded, filename: %s\n", + font->chars ? "" : "not ", font->filename); + if(font->links) { + message(" in use (%d links), %d glyphs [%d, %d]\n", + font->links, FONT_GLYPH_COUNT(font), + font->loc, font->hic); + if(font->subfonts) { + DviFontRef *ref; + + message(" subfonts:\n"); + for(ref = font->subfonts; ref; ref = ref->next) { + message(" %s (id %d) at %p\n", + ref->ref->fontname, + ref->fontid, ref->ref); + } + } + } else + message(" not used\n"); + } +} + +int font_reopen(DviFont *font) +{ + if(font->in) + fseek(font->in, (long)0, SEEK_SET); + else if((font->in = fopen(font->filename, "r")) == NULL) { + DEBUG((DBG_FILES, "reopen(%s) -> Error\n", font->filename)); + return -1; + } + DEBUG((DBG_FILES, "reopen(%s) -> Ok.\n", font->filename)); + return 0; +} + +/* used from context: params and device */ +static int load_font_file(DviParams *params, DviFont *font) +{ + int status; + + if(SEARCH_DONE(font->search)) + return -1; + if(font->in == NULL && font_reopen(font) < 0) + return -1; + DEBUG((DBG_FONTS, "%s: loading %s font from `%s'\n", + font->fontname, + font->finfo->name, font->filename)); + do { + status = font->finfo->load(params, font); + } while(status < 0 && mdvi_font_retry(params, font) == 0); + if(status < 0) + return -1; + if(font->in) { + fclose(font->in); + font->in = NULL; + } + DEBUG((DBG_FONTS, "reload_font(%s) -> %s\n", + font->fontname, status < 0 ? "Error" : "Ok")); + return 0; +} + +void font_drop_one(DviFontRef *ref) +{ + DviFont *font; + + font = ref->ref; + xfree(ref); + /* drop all children */ + for(ref = font->subfonts; ref; ref = ref->next) { + /* just adjust the reference counts */ + ref->ref->links--; + } + if(--font->links == 0) { + /* + * this font doesn't have any more references, but + * we still keep it around in case a virtual font + * requests it. + */ + if(font->in) { + fclose(font->in); + font->in = NULL; + } + if(LIST(font) != fontlist.tail) { + /* move it to the end of the list */ + listh_remove(&fontlist, LIST(font)); + listh_append(&fontlist, LIST(font)); + } + } + DEBUG((DBG_FONTS, "%s: reference dropped, %d more left\n", + font->fontname, font->links)); +} + +void font_drop_chain(DviFontRef *head) +{ + DviFontRef *ptr; + + for(; (ptr = head); ) { + head = ptr->next; + font_drop_one(ptr); + } +} + +int font_free_unused(DviDevice *dev) +{ + DviFont *font, *next; + int count = 0; + + DEBUG((DBG_FONTS, "destroying unused fonts\n")); + for(font = (DviFont *)fontlist.head; font; font = next) { + DviFontRef *ref; + + next = font->next; + if(font->links) + continue; + count++; + DEBUG((DBG_FONTS, "removing unused %s font `%s'\n", + TYPENAME(font), font->fontname)); + listh_remove(&fontlist, LIST(font)); + if(font->in) + fclose(font->in); + /* get rid of subfonts (but can't use `drop_chain' here) */ + for(; (ref = font->subfonts); ) { + font->subfonts = ref->next; + xfree(ref); + } + /* remove this font */ + font_reset_font_glyphs(dev, font, MDVI_FONTSEL_GLYPH); + /* let the font destroy its private data */ + if(font->finfo->freedata) + font->finfo->freedata(font); + /* destroy characters */ + if(font->chars) + xfree(font->chars); + xfree(font->fontname); + xfree(font->filename); + xfree(font); + } + DEBUG((DBG_FONTS, "%d unused fonts removed\n", count)); + return count; +} + +/* used from context: params and device */ +DviFontRef * +font_reference( + DviParams *params, /* rendering parameters */ + Int32 id, /* external id number */ + const char *name, /* font name */ + Int32 sum, /* checksum (from DVI of VF) */ + int hdpi, /* resolution */ + int vdpi, + Int32 scale) /* scaling factor (from DVI or VF) */ +{ + DviFont *font; + DviFontRef *ref; + + /* see if there is a font with the same characteristics */ + for(font = (DviFont *)fontlist.head; font; font = font->next) { + if(strcmp(name, font->fontname) == 0 + && (!sum || !font->checksum || font->checksum == sum) + && font->hdpi == hdpi + && font->vdpi == vdpi + && font->scale == scale) + break; + } + /* try to load the font */ + if(font == NULL) { + font = mdvi_add_font(name, sum, hdpi, vdpi, scale); + if(font == NULL) + return NULL; + listh_append(&fontlist, LIST(font)); + } + if(!font->links && !font->chars && load_font_file(params, font) < 0) { + DEBUG((DBG_FONTS, "font_reference(%s) -> Error\n", name)); + return NULL; + } + ref = xalloc(DviFontRef); + ref->ref = font; + font->links++; + ref->fontid = id; + + if(LIST(font) != fontlist.head) { + listh_remove(&fontlist, LIST(font)); + listh_prepend(&fontlist, LIST(font)); + } + + DEBUG((DBG_FONTS, "font_reference(%s) -> %d links\n", + font->fontname, font->links)); + return ref; +} + +void font_transform_glyph(DviOrientation orient, DviGlyph *g) +{ + BITMAP *map; + int x, y; + + map = (BITMAP *)g->data; + if(MDVI_GLYPH_ISEMPTY(map)) + map = NULL; + + /* put the glyph in the right orientation */ + switch(orient) { + case MDVI_ORIENT_TBLR: + break; + case MDVI_ORIENT_TBRL: + g->x = g->w - g->x; + if(map) bitmap_flip_horizontally(map); + break; + case MDVI_ORIENT_BTLR: + g->y = g->h - g->y; + if(map) bitmap_flip_vertically(map); + break; + case MDVI_ORIENT_BTRL: + g->x = g->w - g->x; + g->y = g->h - g->y; + if(map) bitmap_flip_diagonally(map); + break; + case MDVI_ORIENT_RP90: + if(map) bitmap_rotate_counter_clockwise(map); + y = g->y; + x = g->w - g->x; + g->x = y; + g->y = x; + SWAPINT(g->w, g->h); + break; + case MDVI_ORIENT_RM90: + if(map) bitmap_rotate_clockwise(map); + y = g->h - g->y; + x = g->x; + g->x = y; + g->y = x; + SWAPINT(g->w, g->h); + break; + case MDVI_ORIENT_IRP90: + if(map) bitmap_flip_rotate_counter_clockwise(map); + y = g->y; + x = g->x; + g->x = y; + g->y = x; + SWAPINT(g->w, g->h); + break; + case MDVI_ORIENT_IRM90: + if(map) bitmap_flip_rotate_clockwise(map); + y = g->h - g->y; + x = g->w - g->x; + g->x = y; + g->y = x; + SWAPINT(g->w, g->h); + break; + } +} + +static int load_one_glyph(DviContext *dvi, DviFont *font, int code) +{ + BITMAP *map; + DviFontChar *ch; + int status; + +#ifndef NODEBUG + ch = FONTCHAR(font, code); + DEBUG((DBG_GLYPHS, "loading glyph code %d in %s (at %u)\n", + code, font->fontname, ch->offset)); +#endif + if(font->finfo->getglyph == NULL) { + /* font type does not need to load glyphs (e.g. vf) */ + return 0; + } + + status = font->finfo->getglyph(&dvi->params, font, code); + if(status < 0) + return -1; + /* get the glyph again (font->chars may have changed) */ + ch = FONTCHAR(font, code); +#ifndef NODEBUG + map = (BITMAP *)ch->glyph.data; + if(DEBUGGING(BITMAP_DATA)) { + DEBUG((DBG_BITMAP_DATA, + "%s: new %s bitmap for character %d:\n", + font->fontname, TYPENAME(font), code)); + if(MDVI_GLYPH_ISEMPTY(map)) + DEBUG((DBG_BITMAP_DATA, "blank bitmap\n")); + else + bitmap_print(stderr, map); + } +#endif + /* check if we have to scale it */ + if(!font->finfo->scalable && font->hdpi != font->vdpi) { + int hs, vs, d; + + /* we scale it ourselves */ + d = Max(font->hdpi, font->vdpi); + hs = d / font->hdpi; + vs = d / font->vdpi; + if(ch->width && ch->height && (hs > 1 || vs > 1)) { + int h, v; + DviGlyph glyph; + + DEBUG((DBG_FONTS, + "%s: scaling glyph %d to resolution %dx%d\n", + font->fontname, code, font->hdpi, font->vdpi)); + h = dvi->params.hshrink; + v = dvi->params.vshrink; + d = dvi->params.density; + dvi->params.hshrink = hs; + dvi->params.vshrink = vs; + dvi->params.density = 50; + /* shrink it */ + font->finfo->shrink0(dvi, font, ch, &glyph); + /* restore parameters */ + dvi->params.hshrink = h; + dvi->params.vshrink = v; + dvi->params.density = d; + /* update glyph data */ + if(!MDVI_GLYPH_ISEMPTY(ch->glyph.data)) + bitmap_destroy((BITMAP *)ch->glyph.data); + ch->glyph.data = glyph.data; + ch->glyph.x = glyph.x; + ch->glyph.y = glyph.y; + ch->glyph.w = glyph.w; + ch->glyph.h = glyph.h; + } + + } + font_transform_glyph(dvi->params.orientation, &ch->glyph); + + return 0; +} + +DviFontChar *font_get_glyph(DviContext *dvi, DviFont *font, int code) +{ + DviFontChar *ch; + +again: + /* if we have not loaded the font yet, do so now */ + if(!font->chars && load_font_file(&dvi->params, font) < 0) + return NULL; + + /* get the unscaled glyph, maybe loading it from disk */ + ch = FONTCHAR(font, code); + if(!ch || !glyph_present(ch)) + return NULL; + if(!ch->loaded && load_one_glyph(dvi, font, code) == -1) { + if(font->chars == NULL) { + /* we need to try another font class */ + goto again; + } + return NULL; + } + /* yes, we have to do this again */ + ch = FONTCHAR(font, code); + + /* Got the glyph. If we also have the right scaled glyph, do no more */ + if(!ch->width || !ch->height || + font->finfo->getglyph == NULL || + (dvi->params.hshrink == 1 && dvi->params.vshrink == 1)) + return ch; + + /* If the glyph is empty, we just need to shrink the box */ + if(ch->missing || MDVI_GLYPH_ISEMPTY(ch->glyph.data)) { + if(MDVI_GLYPH_UNSET(ch->shrunk.data)) + mdvi_shrink_box(dvi, font, ch, &ch->shrunk); + return ch; + } else if(MDVI_ENABLED(dvi, MDVI_PARAM_ANTIALIASED)) { + if(ch->grey.data && + ch->fg == dvi->curr_fg && + ch->bg == dvi->curr_bg) + return ch; + if(ch->grey.data) { + if(dvi->device.free_image) + dvi->device.free_image(ch->grey.data); + ch->grey.data = NULL; + } + font->finfo->shrink1(dvi, font, ch, &ch->grey); + } else if(!ch->shrunk.data) + font->finfo->shrink0(dvi, font, ch, &ch->shrunk); + + return ch; +} + +void font_reset_one_glyph(DviDevice *dev, DviFontChar *ch, int what) +{ + if(!glyph_present(ch)) + return; + if(what & MDVI_FONTSEL_BITMAP) { + if(MDVI_GLYPH_NONEMPTY(ch->shrunk.data)) + bitmap_destroy((BITMAP *)ch->shrunk.data); + ch->shrunk.data = NULL; + } + if(what & MDVI_FONTSEL_GREY) { + if(MDVI_GLYPH_NONEMPTY(ch->grey.data)) { + if(dev->free_image) + dev->free_image(ch->grey.data); + } + ch->grey.data = NULL; + } + if(what & MDVI_FONTSEL_GLYPH) { + if(MDVI_GLYPH_NONEMPTY(ch->glyph.data)) + bitmap_destroy((BITMAP *)ch->glyph.data); + ch->glyph.data = NULL; + ch->loaded = 0; + } +} + +void font_reset_font_glyphs(DviDevice *dev, DviFont *font, int what) +{ + int i; + DviFontChar *ch; + + if(what & MDVI_FONTSEL_GLYPH) + what |= MDVI_FONTSEL_BITMAP|MDVI_FONTSEL_GREY; + if(font->subfonts) { + DviFontRef *ref; + + for(ref = font->subfonts; ref; ref = ref->next) + font_reset_font_glyphs(dev, ref->ref, what); + } + if(font->in) { + DEBUG((DBG_FILES, "close(%s)\n", font->filename)); + fclose(font->in); + font->in = NULL; + } + if(font->finfo->getglyph == NULL) + return; + DEBUG((DBG_FONTS, "resetting glyphs in font `%s'\n", font->fontname)); + for(ch = font->chars, i = font->loc; i <= font->hic; ch++, i++) { + if(glyph_present(ch)) + font_reset_one_glyph(dev, ch, what); + } + if((what & MDVI_FONTSEL_GLYPH) && font->finfo->reset) + font->finfo->reset(font); +} + +void font_reset_chain_glyphs(DviDevice *dev, DviFontRef *head, int what) +{ + DviFontRef *ref; + + for(ref = head; ref; ref = ref->next) + font_reset_font_glyphs(dev, ref->ref, what); +} + +static int compare_refs(const void *p1, const void *p2) +{ + return ((*(DviFontRef **)p1)->fontid - (*(DviFontRef **)p2)->fontid); +} + +void font_finish_definitions(DviContext *dvi) +{ + int count; + DviFontRef **map, *ref; + + /* first get rid of unused fonts */ + font_free_unused(&dvi->device); + + if(dvi->fonts == NULL) { + warning(_("%s: no fonts defined\n"), dvi->filename); + return; + } + map = xnalloc(DviFontRef *, dvi->nfonts); + for(count = 0, ref = dvi->fonts; ref; ref = ref->next) + map[count++] = ref; + /* sort the array by font id */ + qsort(map, dvi->nfonts, sizeof(DviFontRef *), compare_refs); + dvi->fontmap = map; +} + +DviFontRef *font_find_flat(DviContext *dvi, Int32 id) +{ + DviFontRef *ref; + + for(ref = dvi->fonts; ref; ref = ref->next) + if(ref->fontid == id) + break; + return ref; +} + +DviFontRef *font_find_mapped(DviContext *dvi, Int32 id) +{ + int lo, hi, n; + DviFontRef **map; + + /* do a binary search */ + lo = 0; hi = dvi->nfonts; + map = dvi->fontmap; + while(lo < hi) { + int sign; + + n = (hi + lo) >> 1; + sign = (map[n]->fontid - id); + if(sign == 0) + break; + else if(sign < 0) + lo = n; + else + hi = n; + } + if(lo >= hi) + return NULL; + return map[n]; +} + diff --git a/dviware/mdvi/lib/fontmap.c b/dviware/mdvi/lib/fontmap.c new file mode 100644 index 0000000000..8b60a05d8a --- /dev/null +++ b/dviware/mdvi/lib/fontmap.c @@ -0,0 +1,1169 @@ +/* encoding.c - functions to manipulate encodings and fontmaps */ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <sys/stat.h> + +#include "mdvi.h" +#include "private.h" + +#include <kpathsea/expand.h> +#include <kpathsea/pathsearch.h> + +typedef struct _DviFontMap DviFontMap; + +struct _DviFontMap { + ListHead entries; + DviHashTable fonts; +}; + +typedef struct _PSFontMap { + struct _PSFontMap *next; + struct _PSFontMap *prev; + char *psname; + char *mapname; + char *fullname; +} PSFontMap; + +/* these variables control PS font maps */ +static char *pslibdir = NULL; /* path where we look for PS font maps */ +static char *psfontdir = NULL; /* PS font search path */ +static int psinitialized = 0; /* did we expand the path already? */ + +static ListHead psfonts = MDVI_EMPTY_LIST_HEAD; +static DviHashTable pstable = MDVI_EMPTY_HASH_TABLE; + +static ListHead fontmaps; +static DviHashTable maptable; +static int fontmaps_loaded = 0; + +#define MAP_HASH_SIZE 57 +#define ENC_HASH_SIZE 31 +#define PSMAP_HASH_SIZE 57 + +/* this hash table should be big enough to + * hold (ideally) one glyph name per bucket */ +#define ENCNAME_HASH_SIZE 131 /* most TeX fonts have 128 glyphs */ + +static ListHead encodings = MDVI_EMPTY_LIST_HEAD; +static DviEncoding *tex_text_encoding = NULL; +static DviEncoding *default_encoding = NULL; + +/* we keep two hash tables for encodings: one for their base files (e.g. + * "8r.enc"), and another one for their names (e.g. "TeXBase1Encoding") */ +static DviHashTable enctable = MDVI_EMPTY_HASH_TABLE; +static DviHashTable enctable_file = MDVI_EMPTY_HASH_TABLE; + +/* the TeX text encoding, from dvips */ +static char *tex_text_vector[256] = { + "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi", "Sigma", "Upsilon", + "Phi", "Psi", "Omega", "arrowup", "arrowdown", "quotesingle", + "exclamdown", "questiondown", "dotlessi", "dotlessj", "grave", + "acute", "caron", "breve", "macron", "ring", "cedilla", + "germandbls", "ae", "oe", "oslash", "AE", "OE", "Oslash", "space", + "exclam", "quotedbl", "numbersign", "dollar", "percent", + "ampersand", "quoteright", "parenleft", "parenright", "asterisk", + "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", + "three", "four", "five", "six", "seven", "eight", "nine", "colon", + "semicolon", "less", "equal", "greater", "question", "at", "A", "B", + "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", + "bracketleft", "backslash", "bracketright", "circumflex", + "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", + "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", + "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "tilde", + "dieresis", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static void ps_init_default_paths __PROTO((void)); + +/* + * What we do here is allocate one block large enough to hold the entire + * file (these files are small) minus the leading comments. This is much + * better than allocating up to 256 tiny strings per encoding vector. */ +static int read_encoding(DviEncoding *enc) +{ + FILE *in; + int curr; + char *line; + char *name; + char *next; + struct stat st; + + ASSERT(enc->private == NULL); + + in = fopen(enc->filename, "r"); + if(in == NULL) { + DEBUG((DBG_FMAP, "%s: could not read `%s' (%s)\n", + enc->name, enc->filename, strerror(errno))); + return -1; + } + if(fstat(fileno(in), &st) < 0) { + /* should not happen */ + fclose(in); + return -1; + } + st.st_size -= enc->offset; + + /* this will be one big string */ + enc->private = (char *)malloc(st.st_size + 1); + /* setup the hash table */ + mdvi_hash_create(&enc->nametab, ENCNAME_HASH_SIZE); + /* setup the encoding vector */ + enc->vector = (char **)xmalloc(256 * sizeof(char *)); + + /* jump to the beginning of the interesting part */ + fseek(in, enc->offset, SEEK_SET); + /* and read everything */ + if(fread(enc->private, st.st_size, 1, in) != 1) { + fclose(in); + xfree(enc->private); + enc->private = NULL; + return -1; + } + /* we don't need this anymore */ + fclose(in); + curr = 0; + + next = name = NULL; + DEBUG((DBG_FMAP, "%s: reading encoding vector\n", enc->name)); + for(line = enc->private; *line && curr < 256; line = next) { + SKIPSP(line); + if(*line == ']') { + line++; SKIPSP(line); + if(STRNEQ(line, "def", 3)) + break; + } + name = getword(line, " \t\n", &next); + if(name == NULL) + break; + /* next > line */ + if(*name < ' ') + continue; + if(*name == '%') { + while(*next && *next != '\n') + next++; + if(*next) next++; /* skip \n */ + continue; + } + + /* got a name */ + if(*next) *next++ = 0; + + if(*name == '/') + name++; + enc->vector[curr] = name; + /* add it to the hash table */ + if(!STREQ(name, ".notdef")) { + mdvi_hash_add(&enc->nametab, MDVI_KEY(name), + Int2Ptr(curr + 1), MDVI_HASH_REPLACE); + } + curr++; + } + if(curr == 0) { + mdvi_hash_reset(&enc->nametab, 0); + xfree(enc->private); + xfree(enc); + return -1; + } + while(curr < 256) + enc->vector[curr++] = NULL; + return 0; +} + +static DviEncoding *find_encoding(const char *name) +{ + return (DviEncoding *)(encodings.count ? + mdvi_hash_lookup(&enctable, MDVI_KEY(name)) : NULL); +} + +static void destroy_encoding(DviEncoding *enc) +{ + if(enc == default_encoding) { + default_encoding = tex_text_encoding; + /* now we use reference counts again */ + mdvi_release_encoding(enc, 1); + } + if(enc != tex_text_encoding) { + mdvi_hash_reset(&enc->nametab, 0); + if(enc->private) { + xfree(enc->private); + xfree(enc->vector); + } + if(enc->name) + xfree(enc->name); + if(enc->filename) + xfree(enc->filename); + xfree(enc); + } +} + +/* this is used for the `enctable_file' hash table */ +static void file_hash_free(DviHashKey key, void *data) +{ + xfree(key); +} + +static DviEncoding *register_encoding(const char *basefile, int replace) +{ + DviEncoding *enc; + FILE *in; + char *filename; + char *name; + Dstring input; + char *line; + long offset; + + DEBUG((DBG_FMAP, "register_encoding(%s)\n", basefile)); + + if(encodings.count) { + enc = mdvi_hash_lookup(&enctable_file, MDVI_KEY(basefile)); + if(enc != NULL) { + DEBUG((DBG_FMAP, "%s: already there\n", basefile)); + return enc; /* no error */ + } + } + + /* try our own files first */ + filename = kpse_find_file(basefile, + kpse_program_text_format, 0); + + /* then try the system-wide ones */ + if(filename == NULL) + filename = kpse_find_file(basefile, + kpse_tex_ps_header_format, 0); + if(filename == NULL) + filename = kpse_find_file(basefile, + kpse_dvips_config_format, 0); + + /* finally try the given name */ + if(filename == NULL) + filename = xstrdup(basefile); + + in = fopen(filename, "r"); + if(in == NULL) { + xfree(filename); + return NULL; + } + + /* just lookup the name of the encoding */ + name = NULL; + dstring_init(&input); + while((line = dgets(&input, in)) != NULL) { + if(STRNEQ(line, "Encoding=", 9)) { + name = getword(line + 9, " \t", &line); + if(*line) *line++ = 0; + break; + } else if(*line == '/') { + char *label = getword(line + 1, " \t", &line); + if(*line) { + *line++ = 0; + SKIPSP(line); + if(*line == '[') { + *line = 0; + name = label; + break; + } + } + } + } + offset = ftell(in); + fclose(in); + if(name == NULL || *name == 0) { + DEBUG((DBG_FMAP, + "%s: could not determine name of encoding\n", + basefile)); + xfree(filename); + return NULL; + } + + /* check if the encoding is already there */ + enc = find_encoding(name); + if(enc == tex_text_encoding) { + /* A special case: if the vector we found is the static one, + * allow the user to override it with an external file */ + listh_remove(&encodings, LIST(enc)); + mdvi_hash_remove(&enctable, MDVI_KEY(enc->name)); + if(enc == default_encoding) + default_encoding = NULL; + } else if(enc) { + /* if the encoding is being used, refuse to remove it */ + if(enc->links) { + xfree(filename); + dstring_reset(&input); + return NULL; + } + if(replace) { + mdvi_hash_remove(&enctable, MDVI_KEY(name)); + mdvi_hash_remove(&enctable_file, MDVI_KEY(basefile)); + listh_remove(&encodings, LIST(enc)); + if(enc == default_encoding) { + default_encoding = NULL; + mdvi_release_encoding(enc, 1); + } + DEBUG((DBG_FMAP, "%s: overriding encoding\n", name)); + destroy_encoding(enc); + } else { + xfree(filename); + dstring_reset(&input); + return enc; /* no error */ + } + } + enc = xalloc(DviEncoding); + enc->name = xstrdup(name); + enc->filename = filename; + enc->links = 0; + enc->offset = offset; + enc->private = NULL; + enc->vector = NULL; + mdvi_hash_init(&enc->nametab); + dstring_reset(&input); + if(default_encoding == NULL) + default_encoding = enc; + mdvi_hash_add(&enctable, MDVI_KEY(enc->name), + enc, MDVI_HASH_UNCHECKED); + mdvi_hash_add(&enctable_file, MDVI_KEY(xstrdup(basefile)), + enc, MDVI_HASH_REPLACE); + listh_prepend(&encodings, LIST(enc)); + DEBUG((DBG_FMAP, "%s: encoding `%s' registered\n", + basefile, enc->name)); + return enc; +} + +DviEncoding *mdvi_request_encoding(const char *name) +{ + DviEncoding *enc = find_encoding(name); + + if(enc == NULL) { + DEBUG((DBG_FMAP, "%s: encoding not found, returning default `%s'\n", + name, default_encoding->name)); + return default_encoding; + } + /* we don't keep reference counts for this */ + if(enc == tex_text_encoding) + return enc; + if(!enc->private && read_encoding(enc) < 0) + return NULL; + enc->links++; + + /* if the hash table is empty, rebuild it */ + if(enc->nametab.nkeys == 0) { + int i; + + DEBUG((DBG_FMAP, "%s: rehashing\n", enc->name)); + for(i = 0; i < 256; i++) { + if(enc->vector[i] == NULL) + continue; + mdvi_hash_add(&enc->nametab, + MDVI_KEY(enc->vector[i]), + (DviHashKey)Int2Ptr(i), + MDVI_HASH_REPLACE); + } + } + return enc; +} + +void mdvi_release_encoding(DviEncoding *enc, int should_free) +{ + /* ignore our static encoding */ + if(enc == tex_text_encoding) + return; + if(!enc->links || --enc->links > 0 || !should_free) + return; + DEBUG((DBG_FMAP, "%s: resetting encoding vector\n", enc->name)); + mdvi_hash_reset(&enc->nametab, 1); /* we'll reuse it */ +} + +int mdvi_encode_glyph(DviEncoding *enc, const char *name) +{ + void *data; + + data = mdvi_hash_lookup(&enc->nametab, MDVI_KEY(name)); + if(data == NULL) + return -1; + /* we added +1 to the hashed index just to distinguish + * a failed lookup from a zero index. Adjust it now. */ + return (Ptr2Int(data) - 1); +} + +/**************** + * Fontmaps * + ****************/ + +static void parse_spec(DviFontMapEnt *ent, char *spec) +{ + char *arg, *command; + + /* this is a ridiculously simple parser, and recognizes only + * things of the form <argument> <command>. Of these, only + * command=SlantFont, ExtendFont and ReEncodeFont are handled */ + while(*spec) { + arg = getword(spec, " \t", &spec); + if(*spec) *spec++ = 0; + command = getword(spec, " \t", &spec); + if(*spec) *spec++ = 0; + if(!arg || !command) + continue; + if(STREQ(command, "SlantFont")) { + double x = 10000 * strtod(arg, 0); + + /* SFROUND evaluates arguments twice */ + ent->slant = SFROUND(x); + } else if(STREQ(command, "ExtendFont")) { + double x = 10000 * strtod(arg, 0); + + ent->extend = SFROUND(x); + } else if(STREQ(command, "ReEncodeFont")) { + if(ent->encoding) + xfree(ent->encoding); + ent->encoding = xstrdup(arg); + } + } +} + +#if 0 +static void print_ent(DviFontMapEnt *ent) +{ + printf("Entry for `%s':\n", ent->fontname); + printf(" PS name: %s\n", ent->psname ? ent->psname : "(none)"); + printf(" Encoding: %s\n", ent->encoding ? ent->encoding : "(default)"); + printf(" EncFile: %s\n", ent->encfile ? ent->encfile : "(none)"); + printf(" FontFile: %s\n", ent->fontfile ? ent->fontfile : "(same)"); + printf(" Extend: %ld\n", ent->extend); + printf(" Slant: %ld\n", ent->slant); +} +#endif + +DviFontMapEnt *mdvi_load_fontmap(const char *file) +{ + char *ptr; + FILE *in; + int lineno = 1; + Dstring input; + ListHead list; + DviFontMapEnt *ent; + DviEncoding *last_encoding; + char *last_encfile; + + ptr = kpse_find_file(file, kpse_program_text_format, 0); + if(ptr == NULL) + ptr = kpse_find_file(file, kpse_tex_ps_header_format, 0); + if(ptr == NULL) + ptr = kpse_find_file(file, kpse_dvips_config_format, 0); + if(ptr == NULL) + in = fopen(file, "r"); + else { + in = fopen(ptr, "r"); + xfree(ptr); + } + if(in == NULL) + return NULL; + + ent = NULL; + listh_init(&list); + dstring_init(&input); + last_encoding = NULL; + last_encfile = NULL; + + while((ptr = dgets(&input, in)) != NULL) { + char *font_file; + char *tex_name; + char *ps_name; + char *vec_name; + int is_encoding; + DviEncoding *enc; + + lineno++; + SKIPSP(ptr); + + /* we skip what dvips does */ + if(*ptr <= ' ' || *ptr == '*' || *ptr == '#' || + *ptr == ';' || *ptr == '%') + continue; + + font_file = NULL; + tex_name = NULL; + ps_name = NULL; + vec_name = NULL; + is_encoding = 0; + + if(ent == NULL) { + ent = xalloc(DviFontMapEnt); + ent->encoding = NULL; + ent->slant = 0; + ent->extend = 0; + } + while(*ptr) { + char *hdr_name = NULL; + + while(*ptr && *ptr <= ' ') + ptr++; + if(*ptr == 0) + break; + if(*ptr == '"') { + char *str; + + str = getstring(ptr, " \t", &ptr); + if(*ptr) *ptr++ = 0; + parse_spec(ent, str); + continue; + } else if(*ptr == '<') { + ptr++; + if(*ptr == '<') + ptr++; + else if(*ptr == '[') { + is_encoding = 1; + ptr++; + } + SKIPSP(ptr); + hdr_name = ptr; + } else if(!tex_name) + tex_name = ptr; + else if(!ps_name) + ps_name = ptr; + else + hdr_name = ptr; + + /* get next word */ + getword(ptr, " \t", &ptr); + if(*ptr) *ptr++ = 0; + + if(hdr_name) { + const char *ext = file_extension(hdr_name); + + if(is_encoding || (ext && STRCEQ(ext, "enc"))) + vec_name = hdr_name; + else + font_file = hdr_name; + } + } + + if(tex_name == NULL) + continue; + ent->fontname = xstrdup(tex_name); + ent->psname = ps_name ? xstrdup(ps_name) : NULL; + ent->fontfile = font_file ? xstrdup(font_file) : NULL; + ent->encfile = vec_name ? xstrdup(vec_name) : NULL; + ent->fullfile = NULL; + enc = NULL; /* we don't have this yet */ + + /* if we have an encoding file, register it */ + if(ent->encfile) { + /* register_encoding is smart enough not to load the + * same file twice */ + if(!last_encfile || !STREQ(last_encfile, ent->encfile)) { + last_encfile = ent->encfile; + last_encoding = register_encoding(ent->encfile, 1); + } + enc = last_encoding; + } + if(ent->encfile && enc){ + if(ent->encoding && !STREQ(ent->encoding, enc->name)) { + warning( + _("%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n"), + file, lineno); + } else if(!ent->encoding) + ent->encoding = xstrdup(enc->name); + } + + /* add it to the list */ + /*print_ent(ent);*/ + listh_append(&list, LIST(ent)); + ent = NULL; + } + dstring_reset(&input); + fclose(in); + + return (DviFontMapEnt *)list.head; +} + +static void free_ent(DviFontMapEnt *ent) +{ + ASSERT(ent->fontname != NULL); + xfree(ent->fontname); + if(ent->psname) + xfree(ent->psname); + if(ent->fontfile) + xfree(ent->fontfile); + if(ent->encoding) + xfree(ent->encoding); + if(ent->encfile) + xfree(ent->encfile); + if(ent->fullfile) + xfree(ent->fullfile); + xfree(ent); +} + +void mdvi_install_fontmap(DviFontMapEnt *head) +{ + DviFontMapEnt *ent, *next; + + for(ent = head; ent; ent = next) { + /* add all the entries, overriding old ones */ + DviFontMapEnt *old; + + old = (DviFontMapEnt *) + mdvi_hash_remove(&maptable, MDVI_KEY(ent->fontname)); + if(old != NULL) { + DEBUG((DBG_FMAP, "%s: overriding fontmap entry\n", + old->fontname)); + listh_remove(&fontmaps, LIST(old)); + free_ent(old); + } + next = ent->next; + mdvi_hash_add(&maptable, MDVI_KEY(ent->fontname), + ent, MDVI_HASH_UNCHECKED); + listh_append(&fontmaps, LIST(ent)); + } +} + +static void init_static_encoding() +{ + DviEncoding *encoding; + int i; + + DEBUG((DBG_FMAP, "installing static TeX text encoding\n")); + encoding = xalloc(DviEncoding); + encoding->private = ""; + encoding->filename = ""; + encoding->name = "TeXTextEncoding"; + encoding->vector = tex_text_vector; + encoding->links = 1; + encoding->offset = 0; + mdvi_hash_create(&encoding->nametab, ENCNAME_HASH_SIZE); + for(i = 0; i < 256; i++) { + if(encoding->vector[i]) { + mdvi_hash_add(&encoding->nametab, + MDVI_KEY(encoding->vector[i]), + (DviHashKey)Int2Ptr(i), + MDVI_HASH_UNCHECKED); + } + } + ASSERT_VALUE(encodings.count, 0); + mdvi_hash_create(&enctable, ENC_HASH_SIZE); + mdvi_hash_create(&enctable_file, ENC_HASH_SIZE); + enctable_file.hash_free = file_hash_free; + mdvi_hash_add(&enctable, MDVI_KEY(encoding->name), + encoding, MDVI_HASH_UNCHECKED); + listh_prepend(&encodings, LIST(encoding)); + tex_text_encoding = encoding; + default_encoding = tex_text_encoding; +} + +int mdvi_set_default_encoding(const char *name) +{ + DviEncoding *enc, *old; + + enc = find_encoding(name); + if(enc == NULL) + return -1; + if(enc == default_encoding) + return 0; + /* this will read it from file if necessary, + * but it can fail if the file is corrupted */ + enc = mdvi_request_encoding(name); + if(enc == NULL) + return -1; + old = default_encoding; + default_encoding = enc; + if(old != tex_text_encoding) + mdvi_release_encoding(old, 1); + return 0; +} + +int mdvi_init_fontmaps(void) +{ + char *file; + char *line; + FILE *in; + Dstring input; + int count = 0; + char *config; + + if(fontmaps_loaded) + return 0; + /* we will only try this once */ + fontmaps_loaded = 1; + + DEBUG((DBG_FMAP, "reading fontmaps\n")); + + /* make sure the static encoding is there */ + init_static_encoding(); + + /* create the fontmap hash table */ + mdvi_hash_create(&maptable, MAP_HASH_SIZE); + + /* get the name of our configuration file */ + config = kpse_cnf_get("mdvi-config"); + if(config == NULL) + config = MDVI_DEFAULT_CONFIG; + /* let's ask kpathsea for the file first */ + file = kpse_find_file(config, kpse_program_text_format, 0); + if(file == NULL) + in = fopen(config, "r"); + else { + in = fopen(file, "r"); + xfree(file); + } + if(in == NULL) + return -1; + dstring_init(&input); + while((line = dgets(&input, in)) != NULL) { + char *arg; + + SKIPSP(line); + if(*line < ' ' || *line == '#' || *line == '%') + continue; + if(STRNEQ(line, "fontmap", 7)) { + DviFontMapEnt *ent; + + arg = getstring(line + 7, " \t", &line); *line = 0; + DEBUG((DBG_FMAP, "%s: loading fontmap\n", arg)); + ent = mdvi_load_fontmap(arg); + if(ent == NULL) + warning(_("%s: could not load fontmap\n"), arg); + else { + DEBUG((DBG_FMAP, + "%s: installing fontmap\n", arg)); + mdvi_install_fontmap(ent); + count++; + } + } else if(STRNEQ(line, "encoding", 8)) { + arg = getstring(line + 8, " \t", &line); *line = 0; + if(arg && *arg) + register_encoding(arg, 1); + } else if(STRNEQ(line, "default-encoding", 16)) { + arg = getstring(line + 16, " \t", &line); *line = 0; + if(mdvi_set_default_encoding(arg) < 0) + warning(_("%s: could not set as default encoding\n"), + arg); + } else if(STRNEQ(line, "psfontpath", 10)) { + arg = getstring(line + 11, " \t", &line); *line = 0; + if(!psinitialized) + ps_init_default_paths(); + if(psfontdir) + xfree(psfontdir); + psfontdir = kpse_path_expand(arg); + } else if(STRNEQ(line, "pslibpath", 9)) { + arg = getstring(line + 10, " \t", &line); *line = 0; + if(!psinitialized) + ps_init_default_paths(); + if(pslibdir) + xfree(pslibdir); + pslibdir = kpse_path_expand(arg); + } else if(STRNEQ(line, "psfontmap", 9)) { + arg = getstring(line + 9, " \t", &line); *line = 0; + if(mdvi_ps_read_fontmap(arg) < 0) + warning("%s: %s: could not read PS fontmap\n", + config, arg); + } + } + fclose(in); + dstring_reset(&input); + fontmaps_loaded = 1; + DEBUG((DBG_FMAP, "%d files installed, %d fontmaps\n", + count, fontmaps.count)); + return count; +} + +int mdvi_query_fontmap(DviFontMapInfo *info, const char *fontname) +{ + DviFontMapEnt *ent; + + if(!fontmaps_loaded && mdvi_init_fontmaps() < 0) + return -1; + ent = (DviFontMapEnt *)mdvi_hash_lookup(&maptable, MDVI_KEY(fontname)); + + if(ent == NULL) + return -1; + info->psname = ent->psname; + info->encoding = ent->encoding; + info->fontfile = ent->fontfile; + info->extend = ent->extend; + info->slant = ent->slant; + info->fullfile = ent->fullfile; + + return 0; +} + +int mdvi_add_fontmap_file(const char *name, const char *fullpath) +{ + DviFontMapEnt *ent; + + if(!fontmaps_loaded && mdvi_init_fontmaps() < 0) + return -1; + ent = (DviFontMapEnt *)mdvi_hash_lookup(&maptable, MDVI_KEY(name)); + if(ent == NULL) + return -1; + if(ent->fullfile) + xfree(ent->fullfile); + ent->fullfile = xstrdup(fullpath); + return 0; +} + + +void mdvi_flush_encodings(void) +{ + DviEncoding *enc; + + if(enctable.nbucks == 0) + return; + + DEBUG((DBG_FMAP, "flushing %d encodings\n", encodings.count)); + /* asked to remove all encodings */ + for(; (enc = (DviEncoding *)encodings.head); ) { + encodings.head = LIST(enc->next); + if((enc != tex_text_encoding && enc->links) || enc->links > 1) { + warning(_("encoding vector `%s' is in use\n"), + enc->name); + } + destroy_encoding(enc); + } + /* destroy the static encoding */ + if(tex_text_encoding->nametab.buckets) + mdvi_hash_reset(&tex_text_encoding->nametab, 0); + mdvi_hash_reset(&enctable, 0); + mdvi_hash_reset(&enctable_file, 0); +} + +void mdvi_flush_fontmaps(void) +{ + DviFontMapEnt *ent; + + if(!fontmaps_loaded) + return; + + DEBUG((DBG_FMAP, "flushing %d fontmaps\n", fontmaps.count)); + for(; (ent = (DviFontMapEnt *)fontmaps.head); ) { + fontmaps.head = LIST(ent->next); + free_ent(ent); + } + mdvi_hash_reset(&maptable, 0); + fontmaps_loaded = 0; +} + +/* reading of PS fontmaps */ + +void ps_init_default_paths(void) +{ + char *kppath = mdvi_getenv("MDVI_PS_LIBPATH"); + char *kfpath = mdvi_getenv("MDVI_PS_FONTPATH"); + + ASSERT(psinitialized == 0); + if(kppath == NULL) + kppath = getenv("GS_LIB"); + if(kfpath == NULL) + kfpath = getenv("GS_FONTPATH"); + if(kppath != NULL) + pslibdir = kpse_path_expand(kppath); + if(kfpath != NULL) + psfontdir = kpse_path_expand(kfpath); + listh_init(&psfonts); + mdvi_hash_create(&pstable, PSMAP_HASH_SIZE); + psinitialized = 1; +} + +int mdvi_ps_read_fontmap(const char *name) +{ + char *fullname; + FILE *in; + Dstring dstr; + char *line; + int count = 0; + + if(!psinitialized) + ps_init_default_paths(); + if(pslibdir) + fullname = kpse_path_search(pslibdir, name, 1); + else + fullname = (char *)name; + in = fopen(fullname, "r"); + if(in == NULL) { + if(fullname != name) + xfree(fullname); + return -1; + } + dstring_init(&dstr); + + while((line = dgets(&dstr, in)) != NULL) { + char *name; + char *mapname; + const char *ext; + PSFontMap *ps; + + SKIPSP(line); + /* we're looking for lines of the form + * /FONT-NAME (fontfile) + * /FONT-NAME /FONT-ALIAS + */ + if(*line != '/') + continue; + name = getword(line + 1, " \t", &line); + if(*line) *line++ = 0; + mapname = getword(line, " \t", &line); + if(*line) *line++ = 0; + + if(!name || !mapname || !*name) + continue; + if(*mapname == '(') { + char *end; + + mapname++; + for(end = mapname; *end && *end != ')'; end++); + *end = 0; + } + if(!*mapname) + continue; + /* dont add `.gsf' fonts, which require a full blown + * PostScript interpreter */ + ext = file_extension(mapname); + if(ext && STREQ(ext, "gsf")) { + DEBUG((DBG_FMAP, "(ps) %s: font `%s' ignored\n", + name, mapname)); + continue; + } + ps = (PSFontMap *)mdvi_hash_lookup(&pstable, MDVI_KEY(name)); + if(ps != NULL) { + if(STREQ(ps->mapname, mapname)) + continue; + DEBUG((DBG_FMAP, + "(ps) replacing font `%s' (%s) by `%s'\n", + name, ps->mapname, mapname)); + xfree(ps->mapname); + ps->mapname = xstrdup(mapname); + if(ps->fullname) { + xfree(ps->fullname); + ps->fullname = NULL; + } + } else { + DEBUG((DBG_FMAP, "(ps) adding font `%s' as `%s'\n", + name, mapname)); + ps = xalloc(PSFontMap); + ps->psname = xstrdup(name); + ps->mapname = xstrdup(mapname); + ps->fullname = NULL; + listh_append(&psfonts, LIST(ps)); + mdvi_hash_add(&pstable, MDVI_KEY(ps->psname), + ps, MDVI_HASH_UNCHECKED); + count++; + } + } + fclose(in); + dstring_reset(&dstr); + + DEBUG((DBG_FMAP, "(ps) %s: %d PostScript fonts registered\n", + fullname, count)); + return 0; +} + +void mdvi_ps_flush_fonts(void) +{ + PSFontMap *map; + + if(!psinitialized) + return; + DEBUG((DBG_FMAP, "(ps) flushing PS font map (%d) entries\n", + psfonts.count)); + mdvi_hash_reset(&pstable, 0); + for(; (map = (PSFontMap *)psfonts.head); ) { + psfonts.head = LIST(map->next); + xfree(map->psname); + xfree(map->mapname); + if(map->fullname) + xfree(map->fullname); + xfree(map); + } + listh_init(&psfonts); + if(pslibdir) { + xfree(pslibdir); + pslibdir = NULL; + } + if(psfontdir) { + xfree(psfontdir); + psfontdir = NULL; + } + psinitialized = 0; +} + +char *mdvi_ps_find_font(const char *psname) +{ + PSFontMap *map, *smap; + char *filename; + int recursion_limit = 32; + + DEBUG((DBG_FMAP, "(ps) resolving PS font `%s'\n", psname)); + if(!psinitialized) + return NULL; + map = (PSFontMap *)mdvi_hash_lookup(&pstable, MDVI_KEY(psname)); + if(map == NULL) + return NULL; + if(map->fullname) + return xstrdup(map->fullname); + + /* is it an alias? */ + smap = map; + while(recursion_limit-- > 0 && smap && *smap->mapname == '/') + smap = (PSFontMap *)mdvi_hash_lookup(&pstable, + MDVI_KEY(smap->mapname + 1)); + if(smap == NULL) { + if(recursion_limit == 0) + DEBUG((DBG_FMAP, + "(ps) %s: possible loop in PS font map\n", + psname)); + return NULL; + } + + if(psfontdir) + filename = kpse_path_search(psfontdir, smap->mapname, 1); + else if(file_exists(map->mapname)) + filename = xstrdup(map->mapname); + else + filename = NULL; + if(filename) + map->fullname = xstrdup(filename); + + return filename; +} + +/* + * To get metric info for a font, we proceed as follows: + * - We try to find NAME.<tfm,ofm,afm>. + * - We query the fontmap for NAME. + * - We get back a PSNAME, and use to find the file in the PS font map. + * - We get the PSFONT file name, replace its extension by "afm" and + * lookup the file in GS's font search path. + * - We finally read the data, transform it as specified in our font map, + * and return it to the caller. The new data is left in the font metrics + * cache, so the next time it will be found at the first step (when we look + * up NAME.afm). + * + * The name `_ps_' in this function is not meant to imply that it can be + * used for Type1 fonts only. It should be usable for TrueType fonts as well. + * + * The returned metric info is subjected to the same caching mechanism as + * all the other metric data, as returned by get_font_metrics(). One should + * not modify the returned data at all, and it should be disposed with + * free_font_metrics(). + */ +TFMInfo *mdvi_ps_get_metrics(const char *fontname) +{ + TFMInfo *info; + DviFontMapInfo map; + char buffer[64]; /* to avoid mallocs */ + char *psfont; + char *basefile; + char *afmfile; + char *ext; + int baselen; + int nc; + TFMChar *ch; + double efactor; + double sfactor; + + DEBUG((DBG_FMAP, "(ps) %s: looking for metric data\n", fontname)); + info = get_font_metrics(fontname, DviFontAny, NULL); + if(info != NULL) + return info; + + /* query the fontmap */ + if(mdvi_query_fontmap(&map, fontname) < 0 || !map.psname) + return NULL; + + /* get the PS font */ + psfont = mdvi_ps_find_font(map.psname); + if(psfont == NULL) + return NULL; + DEBUG((DBG_FMAP, "(ps) %s: found as PS font `%s'\n", + fontname, psfont)); + /* replace its extension */ + basefile = strrchr(psfont, '/'); + if(basefile == NULL) + basefile = psfont; + baselen = strlen(basefile); + ext = strrchr(basefile, '.'); + if(ext != NULL) + *ext = 0; + if(baselen + 4 < 64) + afmfile = &buffer[0]; + else + afmfile = xmalloc(baselen + 5); + strcpy(afmfile, basefile); + strcpy(afmfile + baselen, ".afm"); + /* we don't need this anymore */ + xfree(psfont); + DEBUG((DBG_FMAP, "(ps) %s: looking for `%s'\n", + fontname, afmfile)); + /* lookup the file */ + psfont = kpse_path_search(psfontdir, afmfile, 1); + /* don't need this anymore */ + if(afmfile != &buffer[0]) + xfree(afmfile); + if(psfont != NULL) { + info = get_font_metrics(fontname, DviFontAFM, psfont); + xfree(psfont); + } else + info = NULL; + if(info == NULL || (!map.extend && !map.slant)) + return info; + + /* + * transform the data as prescribed -- keep in mind that `info' + * points to CACHED data, so we're modifying the metric cache + * in place. + */ + +#define DROUND(x) ((x) >= 0 ? floor((x) + 0.5) : ceil((x) - 0.5)) +#define TRANSFORM(x,y) DROUND(efactor * (x) + sfactor * (y)) + + efactor = (double)map.extend / 10000.0; + sfactor = (double)map.slant / 10000.0; + DEBUG((DBG_FMAP, "(ps) %s: applying extend=%f, slant=%f\n", + efactor, sfactor)); + + nc = info->hic - info->loc + 1; + for(ch = info->chars; ch < info->chars + nc; ch++) { + /* the AFM bounding box is: + * wx = ch->advance + * llx = ch->left + * lly = -ch->depth + * urx = ch->right + * ury = ch->height + * what we do here is transform wx, llx, and urx by + * newX = efactor * oldX + sfactor * oldY + * where for `wx' oldY = 0. Also, these numbers are all in + * TFM units (i.e. TFM's fix-words, which is just the actual + * number times 2^20, no need to do anything to it). + */ + if(ch->present) { + ch->advance = TRANSFORM(ch->advance, 0); + ch->left = TRANSFORM(ch->left, -ch->depth); + ch->right = TRANSFORM(ch->right, ch->height); + } + } + + return info; +} diff --git a/dviware/mdvi/lib/fontsrch.c b/dviware/mdvi/lib/fontsrch.c new file mode 100644 index 0000000000..f7d4a45a9b --- /dev/null +++ b/dviware/mdvi/lib/fontsrch.c @@ -0,0 +1,370 @@ +/* fontsearch.c -- implements the font lookup mechanism in MDVI */ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * How this works: + * Fonts are divided into MAX_CLASS priority classes. The first + * MAX_CLASS-1 ones correspond to `real' fonts (pk, gf, vf, type1, truetype, + * etc). The last one corresponds to `metric' fonts that are used as a last + * resort (tfm, afm, ofm, ...). When a font is looked up, it is tried in a + * `high' priority class (0 being the highest priority). The priority is + * lowered until it reaches MAX_CLASS-1. Then the whole thing is repeated + * for the fallback font. When the search reaches MAX_CLASS-1, we lookup the + * original font, and then the fallback font. The search can be done + * incrementally, with several calls to mdvi_lookup_font(). If this function + * is called again to continue a search, the function assumes the previous + * font it returned was not valid, and it goes on to the next step. + * + * Reason for this: + * Some font types are quite expensive to load (e.g. Type1), so loading + * them is deferred until the last possible moment. This means that a font that + * was supposed to exist may have to be discarded. Until now, MDVI had no ability to + * "resume" a search, so in this case it would have produced an error, regardless + * of whether the offending font existed in other formats. + * Also, given the large number of font types supported by MDVI, some mechanism + * was necessary to bring some order into the chaos. + * + * This mechanism fixes these two problems. For the first one, a search can + * be "resumed" and all the font formats tried for the missing font, and + * again for the fallback font (see above). As for the second, the + * hierarchical division in classes gives a lot of flexibility in how the + * fonts are configured. + */ + +#include "mdvi.h" + +#define HAVE_PROTOTYPES 1 +#include <kpathsea/tex-file.h> +#include <kpathsea/tex-glyph.h> + +struct _DviFontClass { + DviFontClass *next; + DviFontClass *prev; + DviFontInfo info; + int links; + int id; +}; + +extern char *_mdvi_fallback_font; + +/* this leaves classes 0 and 1 for `real' fonts */ +#define MAX_CLASS 3 +static ListHead font_classes[MAX_CLASS]; +static int initialized = 0; + +static void init_font_classes(void) +{ + int i; + + for(i = 0; i < MAX_CLASS; i++) + listh_init(&font_classes[i]); + initialized = 1; +} + +int mdvi_get_font_classes(void) +{ + return (MAX_CLASS - 2); +} + +char **mdvi_list_font_class(int klass) +{ + char **list; + int i, n; + DviFontClass *fc; + + if(klass == -1) + klass = MAX_CLASS-1; + if(klass < 0 || klass >= MAX_CLASS) + return NULL; + n = font_classes[klass].count; + list = xnalloc(char *, n + 1); + fc = (DviFontClass *)font_classes[klass].head; + for(i = 0; i < n; fc = fc->next, i++) { + list[i] = xstrdup(fc->info.name); + } + list[i] = NULL; + return list; +} + +int mdvi_register_font_type(DviFontInfo *info, int klass) +{ + DviFontClass *fc; + + if(klass == -1) + klass = MAX_CLASS-1; + if(klass < 0 || klass >= MAX_CLASS) + return -1; + if(!initialized) + init_font_classes(); + fc = xalloc(struct _DviFontClass); + fc->links = 0; + fc->id = klass; + fc->info.name = xstrdup(info->name); + fc->info.scalable = info->scalable; + fc->info.load = info->load; + fc->info.getglyph = info->getglyph; + fc->info.shrink0 = info->shrink0; + fc->info.shrink1 = info->shrink1; + fc->info.freedata = info->freedata; + fc->info.reset = info->reset; + fc->info.lookup = info->lookup; + fc->info.kpse_type = info->kpse_type; + listh_append(&font_classes[klass], LIST(fc)); + return 0; +} + +int mdvi_unregister_font_type(const char *name, int klass) +{ + DviFontClass *fc; + int k; + + if(klass == -1) + klass = MAX_CLASS - 1; + + if(klass >= 0 && klass < MAX_CLASS) { + k = klass; + LIST_FOREACH(fc, DviFontClass, &font_classes[k]) { + if(STREQ(fc->info.name, name)) + break; + } + } else if(klass < 0) { + for(k = 0; k < MAX_CLASS; k++) { + LIST_FOREACH(fc, DviFontClass, &font_classes[k]) { + if(STREQ(fc->info.name, name)) + break; + } + if(fc) break; + } + } else + return -1; + + if(fc == NULL || fc->links) + return -1; + /* remove it */ + listh_remove(&font_classes[k], LIST(fc)); + + /* and destroy it */ + xfree(fc->info.name); + xfree(fc); + return 0; +} + +static char *lookup_font(DviFontClass *ptr, const char *name, Ushort *h, Ushort *v) +{ + char *filename; + + /* + * If the font type registered a function to do the lookup, use that. + * Otherwise we use kpathsea. + */ + if(ptr->info.lookup) + filename = ptr->info.lookup(name, h, v); + else if(ptr->info.kpse_type <= kpse_any_glyph_format) { + kpse_glyph_file_type type; + + filename = kpse_find_glyph(name, Max(*h, *v), + ptr->info.kpse_type, &type); + /* if kpathsea returned a fallback font, reject it */ + if(filename && type.source == kpse_glyph_source_fallback) { + xfree(filename); + filename = NULL; + } else if(filename) + *h = *v = type.dpi; + } else + filename = kpse_find_file(name, ptr->info.kpse_type, 1); + return filename; +} + +/* + * Class MAX_CLASS-1 is special: it consists of `metric' fonts that should + * be tried as a last resort + */ +char *mdvi_lookup_font(DviFontSearch *search) +{ + int kid; + int k; + DviFontClass *ptr; + DviFontClass *last; + char *filename = NULL; + const char *name; + Ushort hdpi, vdpi; + + if(search->id < 0) + return NULL; + + if(search->curr == NULL) { + /* this is the initial search */ + name = search->wanted_name; + hdpi = search->hdpi; + vdpi = search->vdpi; + kid = 0; + last = NULL; + } else { + name = search->actual_name; + hdpi = search->actual_hdpi; + vdpi = search->actual_vdpi; + kid = search->id; + last = search->curr; + } + + ptr = NULL; +again: + /* try all classes except MAX_CLASS-1 */ + for(k = kid; !filename && k < MAX_CLASS-1; k++) { + if(last == NULL) + ptr = (DviFontClass *)font_classes[k].head; + else + ptr = last->next; + while(ptr) { + DEBUG((DBG_FONTS, "%d: trying `%s' at (%d,%d)dpi as `%s'\n", + k, name, hdpi, vdpi, ptr->info.name)); + /* lookup the font in this class */ + filename = lookup_font(ptr, name, &hdpi, &vdpi); + if(filename) + break; + ptr = ptr->next; + } + last = NULL; + } + if(filename != NULL) { + search->id = k-1; + search->curr = ptr; + search->actual_name = name; + search->actual_hdpi = hdpi; + search->actual_vdpi = vdpi; + search->info = &ptr->info; + ptr->links++; + return filename; + } + + if(kid < MAX_CLASS - 1 && !STREQ(name, _mdvi_fallback_font)) { + warning("font `%s' at %dx%d not found, trying `%s' instead\n", + name, hdpi, vdpi, _mdvi_fallback_font); + name = _mdvi_fallback_font; + kid = 0; + goto again; + } + + /* we tried the fallback font, and all the `real' classes. Let's + * try the `metric' class now */ + name = search->wanted_name; + hdpi = search->hdpi; + vdpi = search->vdpi; + if(kid == MAX_CLASS-1) { + /* we were looking into this class from the beginning */ + if(last == NULL) { + /* no more fonts to try */ + return NULL; + } + ptr = last->next; + } else { + warning("font `%s' not found, trying metric files instead\n", + name); + ptr = (DviFontClass *)font_classes[MAX_CLASS-1].head; + } + +metrics: + while(ptr) { + DEBUG((DBG_FONTS, "metric: trying `%s' at (%d,%d)dpi as `%s'\n", + name, hdpi, vdpi, ptr->info.name)); + filename = lookup_font(ptr, name, &hdpi, &vdpi); + if(filename) + break; + ptr = ptr->next; + } + if(filename != NULL) { + if(STREQ(name, _mdvi_fallback_font)) + search->id = MAX_CLASS; + else + search->id = MAX_CLASS - 1; + search->curr = ptr; + search->actual_name = name; + search->actual_hdpi = hdpi; + search->actual_vdpi = vdpi; + search->info = &ptr->info; + ptr->links++; + return filename; + } + if(!STREQ(name, _mdvi_fallback_font)) { + warning("metric file for `%s' not found, trying `%s' instead\n", + name, _mdvi_fallback_font); + name = _mdvi_fallback_font; + ptr = (DviFontClass *)font_classes[MAX_CLASS-1].head; + goto metrics; + } + + search->id = -1; + search->actual_name = NULL; + + /* tough luck, nothing found */ + return NULL; +} + +/* called by `font_reference' to do the initial lookup */ +DviFont *mdvi_add_font(const char *name, Int32 sum, + int hdpi, int vdpi, Int32 scale) +{ + DviFont *font; + + font = xalloc(DviFont); + font->fontname = xstrdup(name); + SEARCH_INIT(font->search, font->fontname, hdpi, vdpi); + font->filename = mdvi_lookup_font(&font->search); + if(font->filename == NULL) { + /* this answer is final */ + xfree(font->fontname); + xfree(font); + return NULL; + } + font->hdpi = font->search.actual_hdpi; + font->vdpi = font->search.actual_vdpi; + font->scale = scale; + font->design = 0; + font->checksum = sum; + font->type = 0; + font->links = 0; + font->loc = 0; + font->hic = 0; + font->in = NULL; + font->chars = NULL; + font->subfonts = NULL; + + return font; +} + +int mdvi_font_retry(DviParams *params, DviFont *font) +{ + /* try the search again */ + char *filename; + + ASSERT(font->search.curr != NULL); + /* we won't be using this class anymore */ + font->search.curr->links--; + + filename = mdvi_lookup_font(&font->search); + if(filename == NULL) + return -1; + xfree(font->filename); + font->filename = filename; + /* copy the new information */ + font->hdpi = font->search.actual_hdpi; + font->vdpi = font->search.actual_vdpi; + + return 0; +} diff --git a/dviware/mdvi/lib/gf.c b/dviware/mdvi/lib/gf.c new file mode 100644 index 0000000000..459e428ece --- /dev/null +++ b/dviware/mdvi/lib/gf.c @@ -0,0 +1,394 @@ +/* gf.c - GF font support */ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* functions to read GF fonts */ + +#include <string.h> +#include "common.h" +#include "mdvi.h" +#include "private.h" + +/* opcodes */ + +#define GF_PAINT0 0 +#define GF_PAINT1 64 +#define GF_PAINT2 65 +#define GF_PAINT3 66 +#define GF_BOC 67 +#define GF_BOC1 68 +#define GF_EOC 69 +#define GF_SKIP0 70 +#define GF_SKIP1 71 +#define GF_SKIP2 72 +#define GF_SKIP3 73 +#define GF_NEW_ROW_0 74 +#define GF_NEW_ROW_1 75 +#define GF_NEW_ROW_MAX 238 +#define GF_XXX1 239 +#define GF_XXX2 240 +#define GF_XXX3 241 +#define GF_XXX4 242 +#define GF_YYY 243 +#define GF_NOOP 244 +#define GF_LOC 245 +#define GF_LOC0 246 +#define GF_PRE 247 +#define GF_POST 248 +#define GF_POST_POST 249 + +#define GF_ID 131 +#define GF_TRAILER 223 + +#define BLACK 1 +#define WHITE 0 + +static int gf_load_font __PROTO((DviParams *, DviFont *)); +static int gf_font_get_glyph __PROTO((DviParams *, DviFont *, int)); + +/* only symbol exported by this file */ +DviFontInfo gf_font_info = { + "GF", + 0, /* scaling not supported natively */ + gf_load_font, + gf_font_get_glyph, + mdvi_shrink_glyph, + mdvi_shrink_glyph_grey, + NULL, /* free */ + NULL, /* reset */ + NULL, /* lookup */ + kpse_gf_format, + NULL +}; + +static int gf_read_bitmap(FILE *p, DviFontChar *ch) +{ + int op; + int min_n, max_n; + int min_m, max_m; + int paint_switch; + int x, y; + int bpl; + Int32 par; + BmUnit *line; + BITMAP *map; + + fseek(p, (long)ch->offset, SEEK_SET); + op = fuget1(p); + if(op == GF_BOC) { + /* skip character code */ + fuget4(p); + /* skip pointer */ + fuget4(p); + min_m = fsget4(p); + max_m = fsget4(p); + min_n = fsget4(p); + max_n = fsget4(p); + } else if(op == GF_BOC1) { + /* skip character code */ + fuget1(p); + min_m = fuget1(p); /* this is max_m - min_m */ + max_m = fuget1(p); + min_n = fuget1(p); /* this is max_n - min_n */ + max_n = fuget1(p); + min_m = max_m - min_m; + min_n = max_n - min_n; + } else { + error(_("GF: invalid opcode %d in character %d\n"), + op, ch->code); + return -1; + } + + ch->x = -min_m; + ch->y = max_n; + ch->width = max_m - min_m + 1; + ch->height = max_n - min_n + 1; + map = bitmap_alloc(ch->width, ch->height); + + ch->glyph.data = map; + ch->glyph.x = ch->x; + ch->glyph.y = ch->y; + ch->glyph.w = ch->width; + ch->glyph.h = ch->height; + +#define COLOR(x) ((x) ? "BLACK" : "WHITE") + + paint_switch = WHITE; + x = y = 0; + line = map->data; + bpl = map->stride; + DEBUG((DBG_BITMAPS, "(gf) reading character %d\n", ch->code)); + while((op = fuget1(p)) != GF_EOC) { + Int32 n; + + if(feof(p)) + break; + if(op == GF_PAINT0) { + DEBUG((DBG_BITMAPS, "(gf) Paint0 %s -> %s\n", + COLOR(paint_switch), COLOR(!paint_switch))); + paint_switch = !paint_switch; + } else if(op <= GF_PAINT3) { + if(op < GF_PAINT1) + par = op; + else + par = fugetn(p, op - GF_PAINT1 + 1); + if(y >= ch->height || x + par >= ch->width) + goto toobig; + /* paint everything between columns x and x + par - 1 */ + DEBUG((DBG_BITMAPS, "(gf) Paint %d %s from (%d,%d)\n", + par, COLOR(paint_switch), x, y)); + if(paint_switch == BLACK) + bitmap_paint_bits(line + (x / BITMAP_BITS), + x % BITMAP_BITS, par); + paint_switch = !paint_switch; + x += par; + } else if(op >= GF_NEW_ROW_0 && op <= GF_NEW_ROW_MAX) { + y++; + line = bm_offset(line, bpl); + x = op - GF_NEW_ROW_0; + paint_switch = BLACK; + DEBUG((DBG_BITMAPS, "(gf) new_row_%d\n", x)); + } else switch(op) { + case GF_SKIP0: + y++; + line = bm_offset(line, bpl); + x = 0; + paint_switch = WHITE; + DEBUG((DBG_BITMAPS, "(gf) skip_0\n")); + break; + case GF_SKIP1: + case GF_SKIP2: + case GF_SKIP3: + par = fugetn(p, op - GF_SKIP1 + 1); + y += par + 1; + line = bm_offset(line, (par + 1) * bpl); + x = 0; + paint_switch = WHITE; + DEBUG((DBG_BITMAPS, "(gf) skip_%d\n", op - GF_SKIP1)); + break; + case GF_XXX1: + case GF_XXX2: + case GF_XXX3: + case GF_XXX4: { +#ifndef NODEBUG + char *s; + + s = read_string(p, op - GF_XXX1 + 1, NULL, 0); + DEBUG((DBG_SPECIAL, "(gf) Character %d: Special \"%s\"\n", + ch->code, s)); + xfree(s); +#else + n = fugetn(p, op - GF_XXX1 + 1); + fseek(p, (long)n, SEEK_CUR); +#endif + break; + } + case GF_YYY: + n = fuget4(p); + DEBUG((DBG_SPECIAL, "(gf) Character %d: MF special %u\n", + ch->code, n)); + break; + case GF_NOOP: + DEBUG((DBG_BITMAPS, "(gf) no_op\n")); + break; + default: + error(_("(gf) Character %d: invalid opcode %d\n"), + ch->code, op); + goto error; + } + /* chech that we're still inside the bitmap */ + if(x > ch->width || y > ch->height) + goto toobig; + DEBUG((DBG_BITMAPS, "(gf) curr_loc @ (%d,%d)\n", x, y)); + } + + if(op != GF_EOC) + goto error; + DEBUG((DBG_BITMAPS, "(gf) end of character %d\n", ch->code)); + return 0; + +toobig: + error(_("(gf) character %d has an incorrect bounding box\n"), + ch->code); +error: + bitmap_destroy(map); + ch->glyph.data = NULL; + return -1; +} + +static int gf_load_font(DviParams *unused, DviFont *font) +{ + int i; + int n; + int loc; + int hic; + FILE *p; + Int32 word; + int op; + long alpha, beta, z; +#ifndef NODEBUG + char s[256]; +#endif + + p = font->in; + + /* check preamble */ + loc = fuget1(p); hic = fuget1(p); + if(loc != GF_PRE || hic != GF_ID) + goto badgf; + loc = fuget1(p); +#ifndef NODEBUG + for(i = 0; i < loc; i++) + s[i] = fuget1(p); + s[i] = 0; + DEBUG((DBG_FONTS, "(gf) %s: %s\n", font->fontname, s)); +#else + fseek(p, (long)loc, SEEK_CUR); +#endif + /* now read character locators in postamble */ + if(fseek(p, (long)-1, SEEK_END) == -1) + return -1; + + n = 0; + while((op = fuget1(p)) == GF_TRAILER) { + if(fseek(p, (long)-2, SEEK_CUR) < 0) + break; + n++; + } + if(op != GF_ID || n < 4) + goto badgf; + /* get the pointer to the postamble */ + fseek(p, (long)-5, SEEK_CUR); + op = fuget4(p); + /* jump to it */ + fseek(p, (long)op, SEEK_SET); + if(fuget1(p) != GF_POST) + goto badgf; + /* skip pointer to last EOC */ + fuget4(p); + /* get the design size */ + font->design = fuget4(p); + /* the checksum */ + word = fuget4(p); + if(word && font->checksum && font->checksum != word) { + warning(_("%s: bad checksum (expected %u, found %u)\n"), + font->fontname, font->checksum, word); + } else if(!font->checksum) + font->checksum = word; + /* skip pixels per point ratio */ + fuget4(p); + fuget4(p); + font->chars = xnalloc(DviFontChar, 256); + for(loc = 0; loc < 256; loc++) + font->chars[loc].offset = 0; + /* skip glyph "bounding box" */ + fseek(p, (long)16, SEEK_CUR); + loc = 256; + hic = -1; + TFMPREPARE(font->scale, z, alpha, beta); + while((op = fuget1(p)) != GF_POST_POST) { + DviFontChar *ch; + int cc; + + /* get the character code */ + cc = fuget1(p); + if(cc < loc) + loc = cc; + if(cc > hic) + hic = cc; + ch = &font->chars[cc]; + switch(op) { + case GF_LOC: + fsget4(p); /* skip dx */ + fsget4(p); /* skip dy */ + break; + case GF_LOC0: + fuget1(p); /* skip dx */ + /* dy assumed 0 */ + break; + default: + error(_("%s: junk in postamble\n"), font->fontname); + goto error; + } + ch->code = cc; + ch->tfmwidth = fuget4(p); + ch->tfmwidth = TFMSCALE(ch->tfmwidth, z, alpha, beta); + ch->offset = fuget4(p); + if(ch->offset == -1) + ch->offset = 0; + /* initialize the rest of the glyph information */ + ch->x = 0; + ch->y = 0; + ch->width = 0; + ch->height = 0; + ch->glyph.data = NULL; + ch->shrunk.data = NULL; + ch->grey.data = NULL; + ch->flags = 0; + ch->loaded = 0; + } + + if(op != GF_POST_POST) + goto badgf; + + if(loc > 0 || hic < 255) { + /* shrink to optimal size */ + memmove(font->chars, font->chars + loc, + (hic - loc + 1) * sizeof(DviFontChar)); + font->chars = xresize(font->chars, + DviFontChar, hic - loc + 1); + } + font->loc = loc; + font->hic = hic; + + return 0; + +badgf: + error(_("%s: File corrupted, or not a GF file\n"), font->fontname); +error: + if(font->chars) { + xfree(font->chars); + font->chars = NULL; + } + font->loc = font->hic = 0; + return -1; +} + +static int gf_font_get_glyph(DviParams *params, DviFont *font, int code) +{ + DviFontChar *ch; + + if(code < font->loc || code > font->hic || !font->chars) + return -1; + ch = &font->chars[code - font->loc]; + + if(!ch->loaded) { + if(ch->offset == 0) + return -1; + DEBUG((DBG_GLYPHS, "(gf) %s: loading GF glyph for character %d\n", + font->fontname, code)); + if(font->in == NULL && font_reopen(font) < 0) + return -1; + if(fseek(font->in, ch->offset, SEEK_SET) == -1) + return -1; + if(gf_read_bitmap(font->in, ch) < 0) + return -1; + ch->loaded = 1; + } + return 0; +} diff --git a/dviware/mdvi/lib/hash.c b/dviware/mdvi/lib/hash.c new file mode 100644 index 0000000000..5487bed59d --- /dev/null +++ b/dviware/mdvi/lib/hash.c @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "mdvi.h" + +/* simple hash tables for MDVI */ + + +struct _DviHashBucket { + DviHashBucket *next; + DviHashKey key; + Ulong hvalue; + void *data; +}; + +static Ulong hash_string(DviHashKey key) +{ + Uchar *p; + Ulong h, g; + + for(h = 0, p = (Uchar *)key; *p; p++) { + h = (h << 4UL) + *p; + if((g = h & 0xf0000000L) != 0) { + h ^= (g >> 24UL); + h ^= g; + } + } + + return h; +} + +static int hash_compare(DviHashKey k1, DviHashKey k2) +{ + return strcmp((char *)k1, (char *)k2); +} + +void mdvi_hash_init(DviHashTable *hash) +{ + hash->buckets = NULL; + hash->nbucks = 0; + hash->nkeys = 0; + hash->hash_func = NULL; + hash->hash_comp = NULL; + hash->hash_free = NULL; +} + +void mdvi_hash_create(DviHashTable *hash, int size) +{ + int i; + + hash->nbucks = size; + hash->buckets = xnalloc(DviHashBucket *, size); + for(i = 0; i < size; i++) + hash->buckets[i] = NULL; + hash->hash_func = hash_string; + hash->hash_comp = hash_compare; + hash->hash_free = NULL; + hash->nkeys = 0; +} + +static DviHashBucket *hash_find(DviHashTable *hash, DviHashKey key) +{ + Ulong hval; + DviHashBucket *buck; + + hval = (hash->hash_func(key) % hash->nbucks); + + for(buck = hash->buckets[hval]; buck; buck = buck->next) + if(hash->hash_comp(buck->key, key) == 0) + break; + return buck; +} + +/* Neither keys nor data are duplicated */ +int mdvi_hash_add(DviHashTable *hash, DviHashKey key, void *data, int rep) +{ + DviHashBucket *buck = NULL; + Ulong hval; + + if(rep != MDVI_HASH_UNCHECKED) { + buck = hash_find(hash, key); + if(buck != NULL) { + if(buck->data == data) + return 0; + if(rep == MDVI_HASH_UNIQUE) + return -1; + if(hash->hash_free != NULL) + hash->hash_free(buck->key, buck->data); + } + } + if(buck == NULL) { + buck = xalloc(DviHashBucket); + buck->hvalue = hash->hash_func(key); + hval = (buck->hvalue % hash->nbucks); + buck->next = hash->buckets[hval]; + hash->buckets[hval] = buck; + hash->nkeys++; + } + + /* save key and data */ + buck->key = key; + buck->data = data; + + return 0; +} + +void *mdvi_hash_lookup(DviHashTable *hash, DviHashKey key) +{ + DviHashBucket *buck = hash_find(hash, key); + + return buck ? buck->data : NULL; +} + +static DviHashBucket *hash_remove(DviHashTable *hash, DviHashKey key) +{ + DviHashBucket *buck, *last; + Ulong hval; + + hval = hash->hash_func(key); + hval %= hash->nbucks; + + for(last = NULL, buck = hash->buckets[hval]; buck; buck = buck->next) { + if(hash->hash_comp(buck->key, key) == 0) + break; + last = buck; + } + if(buck == NULL) + return NULL; + if(last) + last->next = buck->next; + else + hash->buckets[hval] = buck->next; + hash->nkeys--; + return buck; +} + +void *mdvi_hash_remove(DviHashTable *hash, DviHashKey key) +{ + DviHashBucket *buck = hash_remove(hash, key); + void *data = NULL; + + if(buck) { + data = buck->data; + xfree(buck); + } + return data; +} + +void *mdvi_hash_remove_ptr(DviHashTable *hash, DviHashKey key) +{ + DviHashBucket *buck, *last; + Ulong hval; + void *ptr; + + hval = hash->hash_func(key); + hval %= hash->nbucks; + + for(last = NULL, buck = hash->buckets[hval]; buck; buck = buck->next) { + if(buck->key == key) + break; + last = buck; + } + if(buck == NULL) + return NULL; + if(last) + last->next = buck->next; + else + hash->buckets[hval] = buck->next; + hash->nkeys--; + /* destroy the bucket */ + ptr = buck->data; + xfree(buck); + return ptr; +} + +int mdvi_hash_destroy_key(DviHashTable *hash, DviHashKey key) +{ + DviHashBucket *buck = hash_remove(hash, key); + + if(buck == NULL) + return -1; + if(hash->hash_free) + hash->hash_free(buck->key, buck->data); + xfree(buck); + return 0; +} + +void mdvi_hash_reset(DviHashTable *hash, int reuse) +{ + int i; + DviHashBucket *buck; + + /* remove all keys in the hash table */ + for(i = 0; i < hash->nbucks; i++) { + for(; (buck = hash->buckets[i]); ) { + hash->buckets[i] = buck->next; + if(hash->hash_free) + hash->hash_free(buck->key, buck->data); + xfree(buck); + } + } + hash->nkeys = 0; + if(!reuse && hash->buckets) { + xfree(hash->buckets); + hash->buckets = NULL; + hash->nbucks = 0; + } /* otherwise, it is left empty, ready to be reused */ +} diff --git a/dviware/mdvi/lib/list.c b/dviware/mdvi/lib/list.c new file mode 100644 index 0000000000..c434e2b197 --- /dev/null +++ b/dviware/mdvi/lib/list.c @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "common.h" + +void listh_init(ListHead *head) +{ + head->head = head->tail = NULL; + head->count = 0; +} + +void listh_prepend(ListHead *head, List *list) +{ + list->prev = NULL; + list->next = head->head; + if(head->head) + head->head->prev = list; + head->head = list; + if(!head->tail) + head->tail = list; + head->count++; +} + +void listh_append(ListHead *head, List *list) +{ + list->next = NULL; + list->prev = head->tail; + if(head->tail) + head->tail->next = list; + else + head->head = list; + head->tail = list; + head->count++; +} + +void listh_add_before(ListHead *head, List *at, List *list) +{ + if(at == head->head || head->head == NULL) + listh_prepend(head, list); + else { + list->next = at; + list->prev = at->prev; + at->prev = list; + head->count++; + } +} + +void listh_add_after(ListHead *head, List *at, List *list) +{ + if(at == head->tail || !head->tail) + listh_append(head, list); + else { + list->prev = at; + list->next = at->next; + at->next = list; + head->count++; + } +} + +void listh_remove(ListHead *head, List *list) +{ + if(list == head->head) { + head->head = list->next; + if(head->head) + head->head->prev = NULL; + } else if(list == head->tail) { + head->tail = list->prev; + if(head->tail) + head->tail->next = NULL; + } else { + list->next->prev = list->prev; + list->prev->next = list->next; + } + if(--head->count == 0) + head->head = head->tail = NULL; +} + +void listh_concat(ListHead *h1, ListHead *h2) +{ + if(h2->head == NULL) + ; /* do nothing */ + else if(h1->tail == NULL) + h1->head = h2->head; + else { + h1->tail->next = h2->head; + h2->head->prev = h1->tail; + } + h1->tail = h2->tail; + h1->count += h2->count; +} + +void listh_catcon(ListHead *h1, ListHead *h2) +{ + if(h2->head == NULL) + ; /* do nothing */ + else if(h1->head == NULL) + h1->tail = h2->tail; + else { + h1->head->prev = h2->tail; + h2->tail->next = h1->head; + } + h1->head = h2->head; + h1->count += h2->count; +} diff --git a/dviware/mdvi/lib/pagesel.c b/dviware/mdvi/lib/pagesel.c new file mode 100644 index 0000000000..7fc610a468 --- /dev/null +++ b/dviware/mdvi/lib/pagesel.c @@ -0,0 +1,490 @@ +/* pagesel.c -- Page selection mechanism */ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include <limits.h> + +#include "mdvi.h" +#include "private.h" + +char *program_name = "page"; + +struct _DviPageSpec { + DviRange *ranges; + int nranges; +}; + +DviRange *mdvi_parse_range(const char *format, DviRange *limit, int *nitems, char **endptr) +{ + int quoted; + int size; + int curr; + int done; + int lower; + int upper; + int type; + char * cp; + char * copy; + char * text; + DviRange one; + DviRange *range; + + quoted = (*format == '{'); + if(quoted) format++; + + size = 0; + curr = 0; + range = NULL; + copy = xstrdup(format); + done = 0; + lower = 0; + upper = 0; + type = MDVI_RANGE_UNBOUNDED; + + if(limit) { + switch(limit->type) { + case MDVI_RANGE_BOUNDED: + lower = limit->from; + upper = limit->to; + break; + case MDVI_RANGE_UPPER: + lower = INT_MIN; + upper = limit->to; + break; + case MDVI_RANGE_LOWER: + lower = limit->from; + upper = INT_MAX; + break; + case MDVI_RANGE_UNBOUNDED: + lower = INT_MIN; + upper = INT_MAX; + break; + } + type = limit->type; + } else { + lower = INT_MIN; + upper = INT_MAX; + type = MDVI_RANGE_UNBOUNDED; + } + one.type = type; + one.from = lower; + one.to = upper; + one.step = 1; + for(cp = text = copy; !done; cp++) { + char *p; + int f, t, s; + int ch; + int this_type; + int lower_given = 0; + int upper_given = 0; + + if(*cp == 0 || *cp == '.' || (*cp == '}' && quoted)) + done = 1; + else if(*cp != ',') + continue; + + if(text == cp) + continue; + ch = *cp; + *cp = 0; + f = lower; + t = upper; + s = 1; + + p = strchr(text, ':'); + if(p) *p++ = 0; + if(*text) { + lower_given = 1; + f = strtol(text, NULL, 0); + } + if(p == NULL) { + if(lower_given) { + upper_given = 1; + t = f; s = 1; + } + goto finish; + } + text = p; + p = strchr(text, ':'); + if(p) *p++ = 0; + if(*text) { + upper_given = 1; + t = strtol(text, NULL, 0); + } + if(p == NULL) + goto finish; + text = p; + if(*text) + s = strtol(text, NULL, 0); +finish: + if(lower_given && upper_given) + this_type = MDVI_RANGE_BOUNDED; + else if(lower_given) { + if(!RANGE_HAS_UPPER(type)) + this_type = MDVI_RANGE_LOWER; + else + this_type = MDVI_RANGE_BOUNDED; + t = upper; + } else if(upper_given) { + if(RANGE_HAS_UPPER(one.type)) { + one.to++; + this_type = MDVI_RANGE_BOUNDED; + } else { + one.to = lower; + if(!RANGE_HAS_LOWER(type)) + this_type = MDVI_RANGE_UPPER; + else + this_type = MDVI_RANGE_BOUNDED; + } + f = one.to; + } else { + this_type = type; + f = lower; + t = upper; + } + one.type = this_type; + one.to = t; + one.from = f; + one.step = s; + + if(curr == size) { + size += 8; + range = xrealloc(range, size * sizeof(DviRange)); + } + memcpy(&range[curr++], &one, sizeof(DviRange)); + *cp = ch; + text = cp + 1; + } + if(done) + cp--; + if(quoted && *cp == '}') + cp++; + if(endptr) + *endptr = (char *)format + (cp - copy); + if(curr && curr < size) + range = xrealloc(range, curr * sizeof(DviRange)); + *nitems = curr; + xfree(copy); + return range; +} + +DviPageSpec *mdvi_parse_page_spec(const char *format) +{ + /* + * a page specification looks like this: + * '{'RANGE_SPEC'}' for a DVI spec + * '{'RANGE_SPEC'}' '.' ... for a TeX spec + */ + DviPageSpec *spec; + DviRange *range; + int count; + int i; + char *ptr; + + spec = xnalloc(struct _DviPageSpec *, 11); + for(i = 0; i < 11; i++) + spec[i] = NULL; + + /* check what kind of spec we're parsing */ + if(*format != '*') { + range = mdvi_parse_range(format, NULL, &count, &ptr); + if(ptr == format) { + if(range) xfree(range); + error(_("invalid page specification `%s'\n"), format); + return NULL; + } + } else + range = NULL; + + if(*format == 'D' || *format == 'd' || *ptr != '.') + i = 0; + else + i = 1; + + if(range) { + spec[i] = xalloc(struct _DviPageSpec); + spec[i]->ranges = range; + spec[i]->nranges = count; + } else + spec[i] = NULL; + + if(*ptr != '.') { + if(*ptr) + warning(_("garbage after DVI page specification ignored\n")); + return spec; + } + + for(i++; *ptr == '.' && i <= 10; i++) { + ptr++; + if(*ptr == '*') { + ptr++; + range = NULL; + } else { + char *end; + + range = mdvi_parse_range(ptr, NULL, &count, &end); + if(end == ptr) { + if(range) xfree(range); + range = NULL; + } else + ptr = end; + } + if(range != NULL) { + spec[i] = xalloc(struct _DviPageSpec); + spec[i]->ranges = range; + spec[i]->nranges = count; + } else + spec[i] = NULL; + } + + if(i > 10) + warning(_("more than 10 counters in page specification\n")); + else if(*ptr) + warning(_("garbage after TeX page specification ignored\n")); + + return spec; +} + +/* returns non-zero if the given page is included by `spec' */ +int mdvi_page_selected(DviPageSpec *spec, PageNum page, int dvipage) +{ + int i; + int not_found; + + if(spec == NULL) + return 1; + if(spec[0]) { + not_found = mdvi_in_range(spec[0]->ranges, + spec[0]->nranges, dvipage); + if(not_found < 0) + return 0; + } + for(i = 1; i <= 10; i++) { + if(spec[i] == NULL) + continue; + not_found = mdvi_in_range(spec[i]->ranges, + spec[i]->nranges, (int)page[i]); + if(not_found < 0) + return 0; + } + return 1; +} + +void mdvi_free_page_spec(DviPageSpec *spec) +{ + int i; + + for(i = 0; i < 11; i++) + if(spec[i]) { + xfree(spec[i]->ranges); + xfree(spec[i]); + } + xfree(spec); +} + +int mdvi_in_range(DviRange *range, int nitems, int value) +{ + DviRange *r; + + for(r = range; r < range + nitems; r++) { + int cond; + + switch(r->type) { + case MDVI_RANGE_BOUNDED: + if(value == r->from) + return (r - range); + if(r->step < 0) + cond = (value <= r->from) && (value >= r->to); + else + cond = (value <= r->to) && (value >= r->from); + if(cond && ((value - r->from) % r->step) == 0) + return (r - range); + break; + case MDVI_RANGE_LOWER: + if(value == r->from) + return (r - range); + if(r->step < 0) + cond = (value < r->from); + else + cond = (value > r->from); + if(cond && ((value - r->from) % r->step) == 0) + return (r - range); + break; + case MDVI_RANGE_UPPER: + if(value == r->to) + return (r - range); + if(r->step < 0) + cond = (value > r->to); + else + cond = (value < r->to); + if(cond && ((value - r->to) % r->step) == 0) + return (r - range); + break; + case MDVI_RANGE_UNBOUNDED: + if((value % r->step) == 0) + return (r - range); + break; + } + } + return -1; +} + +int mdvi_range_length(DviRange *range, int nitems) +{ + int count = 0; + DviRange *r; + + for(r = range; r < range + nitems; r++) { + int n; + + if(r->type != MDVI_RANGE_BOUNDED) + return -2; + n = (r->to - r->from) / r->step; + if(n < 0) + n = 0; + count += n + 1; + } + return count; +} + +#ifdef TEST + +void print_range(DviRange *range) +{ + switch(range->type) { + case MDVI_RANGE_BOUNDED: + printf("From %d to %d, step %d\n", + range->from, range->to, range->step); + break; + case MDVI_RANGE_LOWER: + printf("From %d, step %d\n", + range->from, range->step); + break; + case MDVI_RANGE_UPPER: + printf("From %d, step -%d\n", + range->to, range->step); + break; + case MDVI_RANGE_UNBOUNDED: + printf("From 0, step %d and %d\n", + range->step, -range->step); + break; + } +} + +int main() +{ +#if 0 + char buf[256]; + DviRange limit; + + limit.from = 0; + limit.to = 100; + limit.step = 2; + limit.type = MDVI_RANGE_UNBOUNDED; + while(1) { + DviRange *range; + char *end; + int count; + int i; + + printf("Range> "); fflush(stdout); + if(fgets(buf, 256, stdin) == NULL) + break; + if(buf[strlen(buf)-1] == '\n') + buf[strlen(buf)-1] = 0; + if(buf[0] == 0) + continue; + end = NULL; + range = mdvi_parse_range(buf, &limit, &count, &end); + if(range == NULL) { + printf("range is empty\n"); + continue; + } + + for(i = 0; i < count; i++) { + printf("Range %d (%d elements):\n", + i, mdvi_range_length(&range[i], 1)); + print_range(&range[i]); + } + if(end && *end) + printf("Tail: [%s]\n", end); + printf("range has %d elements\n", + mdvi_range_length(range, count)); +#if 1 + while(1) { + int v; + + printf("Value: "); fflush(stdout); + if(fgets(buf, 256, stdin) == NULL) + break; + if(buf[strlen(buf)-1] == '\n') + buf[strlen(buf)-1] = 0; + if(buf[0] == 0) + break; + v = atoi(buf); + i = mdvi_in_range(range, count, v); + if(i == -1) + printf("%d not in range\n", v); + else { + printf("%d in range: ", v); + print_range(&range[i]); + } + } +#endif + if(range) xfree(range); + } +#else + DviPageSpec *spec; + char buf[256]; + + while(1) { + printf("Spec> "); fflush(stdout); + if(fgets(buf, 256, stdin) == NULL) + break; + if(buf[strlen(buf)-1] == '\n') + buf[strlen(buf)-1] = 0; + if(buf[0] == 0) + continue; + spec = mdvi_parse_page_spec(buf); + if(spec == NULL) + printf("no spec parsed\n"); + else { + int i; + + printf("spec = "); + for(i = 0; i < 11; i++) { + printf("Counter %d:\n", i); + if(spec[i]) { + int k; + + for(k = 0; k < spec[i]->nranges; k++) + print_range(&spec[i]->ranges[k]); + } else + printf("\t*\n"); + } + mdvi_free_page_spec(spec); + } + } +#endif + exit(0); + +} +#endif /* TEST */ diff --git a/dviware/mdvi/lib/paper.c b/dviware/mdvi/lib/paper.c new file mode 100644 index 0000000000..b98f5e09d7 --- /dev/null +++ b/dviware/mdvi/lib/paper.c @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <string.h> + +#include "common.h" +#include "mdvi.h" +#include "private.h" + +static const DviPaperSpec papers[] = { + {"ISO", 0, 0}, + {"4A0", "1682mm", "2378mm"}, + {"2A0", "1189mm", "1682mm"}, + {"A0", "841mm", "1189mm"}, + {"A1", "594mm", "841mm"}, + {"A2", "420mm", "594mm"}, + {"A3", "297mm", "420mm"}, + {"A4", "210mm", "297mm"}, + {"A5", "148mm", "210mm"}, + {"A6", "105mm", "148mm"}, + {"A7", "74mm", "105mm"}, + {"A8", "52mm", "74mm"}, + {"A9", "37mm", "52mm"}, + {"A10", "26mm", "37mm"}, + {"B0", "1000mm", "1414mm"}, + {"B1", "707mm", "1000mm"}, + {"B2", "500mm", "707mm"}, + {"B3", "353mm", "500mm"}, + {"B4", "250mm", "353mm"}, + {"B5", "176mm", "250mm"}, + {"B6", "125mm", "176mm"}, + {"B7", "88mm", "125mm"}, + {"B8", "62mm", "88mm"}, + {"B9", "44mm", "62mm"}, + {"B10", "31mm", "44mm"}, + {"C0", "917mm", "1297mm"}, + {"C1", "648mm", "917mm"}, + {"C2", "458mm", "648mm"}, + {"C3", "324mm", "458mm"}, + {"C4", "229mm", "324mm"}, + {"C5", "162mm", "229mm"}, + {"C6", "114mm", "162mm"}, + {"C7", "81mm", "114mm"}, + {"C8", "57mm", "81mm"}, + {"C9", "40mm", "57mm"}, + {"C10", "28mm", "40mm"}, + {"US", 0, 0}, + {"archA", "9in", "12in"}, + {"archB", "12in", "18in"}, + {"archC", "18in", "24in"}, + {"archD", "24in", "36in"}, + {"archE", "36in", "48in"}, + {"executive", "7.5in", "10in"}, + {"flsa", "8.5in", "13in"}, + {"flse", "8.5in", "13in"}, + {"halfletter", "5.5in", "8.5in"}, + {"letter", "8.5in", "11in"}, + {"legal", "8.5in", "14in"}, + {"ledger", "17in", "11in"}, + {"note", "7.5in", "10in"}, + {"tabloid", "11in", "17in"}, + {"statement", "5.5in", "8.5in"}, + {0, 0, 0} +}; + +static DviPaperClass str2class(const char *name) +{ + if(STRCEQ(name, "ISO")) + return MDVI_PAPER_CLASS_ISO; + else if(STRCEQ(name, "US")) + return MDVI_PAPER_CLASS_US; + return MDVI_PAPER_CLASS_CUSTOM; +} + +int mdvi_get_paper_size(const char *name, DviPaper *paper) +{ + const DviPaperSpec *sp; + double a, b; + char c, d, e, f; + char buf[32]; + + paper->pclass = MDVI_PAPER_CLASS_CUSTOM; + if(sscanf(name, "%lfx%lf%c%c", &a, &b, &c, &d) == 4) { + sprintf(buf, "%12.16f%c%c", a, c, d); + paper->inches_wide = unit2pix_factor(buf); + sprintf(buf, "%12.16f%c%c", b, c, d); + paper->inches_tall = unit2pix_factor(buf); + paper->name = _("custom"); + return 0; + } else if(sscanf(name, "%lf%c%c,%lf%c%c", &a, &c, &d, &b, &e, &f) == 6) { + sprintf(buf, "%12.16f%c%c", a, c, d); + paper->inches_wide = unit2pix_factor(buf); + sprintf(buf, "%12.16f%c%c", b, e, f); + paper->inches_tall = unit2pix_factor(buf); + paper->name = _("custom"); + return 0; + } + + for(sp = &papers[0]; sp->name; sp++) { + if(!sp->width || !sp->height) { + paper->pclass = str2class(sp->name); + continue; + } + if(strcasecmp(sp->name, name) == 0) { + paper->inches_wide = unit2pix_factor(sp->width); + paper->inches_tall = unit2pix_factor(sp->height); + paper->name = sp->name; + return 0; + } + } + return -1; +} + +DviPaperSpec *mdvi_get_paper_specs(DviPaperClass pclass) +{ + int i; + int first, count; + DviPaperSpec *spec, *ptr; + + first = -1; + count = 0; + if(pclass == MDVI_PAPER_CLASS_ANY || + pclass == MDVI_PAPER_CLASS_CUSTOM) { + first = 0; + count = (sizeof(papers) / sizeof(papers[0])) - 3; + } else for(i = 0; papers[i].name; i++) { + if(papers[i].width == NULL) { + if(str2class(papers[i].name) == pclass) + first = i; + else if(first >= 0) + break; + } else if(first >= 0) + count++; + } + ptr = spec = xnalloc(DviPaperSpec, count + 1); + for(i = first; papers[i].name&& count > 0; i++) { + if(papers[i].width) { + ptr->name = papers[i].name; + ptr->width = papers[i].width; + ptr->height = papers[i].height; + ptr++; + count--; + } + } + ptr->name = NULL; + ptr->width = NULL; + ptr->height = NULL; + + return spec; +} + +void mdvi_free_paper_specs(DviPaperSpec *spec) +{ + xfree(spec); +} diff --git a/dviware/mdvi/lib/pk.c b/dviware/mdvi/lib/pk.c new file mode 100644 index 0000000000..7c1d13a29e --- /dev/null +++ b/dviware/mdvi/lib/pk.c @@ -0,0 +1,569 @@ + +/* Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * History: + * + * 11/3/2000: + * - First working version + * 11/4/2000: + * - FIXED: entirely white/black rows were missed. + * 11/8/2000: + * - TESTED: Glyphs are rendered correctly in different byte orders. + * - Made bitmap code much more efficient and compact. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <math.h> + +#include "mdvi.h" +#include "private.h" + +#define PK_ID 89 +#define PK_CMD_START 240 +#define PK_X1 240 +#define PK_X2 241 +#define PK_X3 242 +#define PK_X4 243 +#define PK_Y 244 +#define PK_POST 245 +#define PK_NOOP 246 +#define PK_PRE 247 + +#define PK_DYN_F(x) (((x) >> 4) & 0xf) +#define PK_PACKED(x) (PK_DYN_F(x) != 14) + +static int pk_load_font __PROTO((DviParams *, DviFont *)); +static int pk_font_get_glyph __PROTO((DviParams *, DviFont *, int)); + +static int pk_auto_generate = 1; /* this is ON by default */ + +typedef struct { + char currbyte; + char nybpos; + int dyn_f; +} pkread; + +static char *pk_lookup __PROTO((const char *, Ushort *, Ushort *)); +static char *pk_lookupn __PROTO((const char *, Ushort *, Ushort *)); + +/* only symbols exported by this file */ +DviFontInfo pk_font_info = { + "PK", + 0, /* scaling not supported natively */ + pk_load_font, + pk_font_get_glyph, + mdvi_shrink_glyph, + mdvi_shrink_glyph_grey, + NULL, /* free */ + NULL, /* reset */ + pk_lookup, /* lookup */ + kpse_pk_format, + NULL +}; + +DviFontInfo pkn_font_info = { + "PKN", + 0, /* scaling not supported natively */ + pk_load_font, + pk_font_get_glyph, + mdvi_shrink_glyph, + mdvi_shrink_glyph_grey, + NULL, /* free */ + NULL, /* reset */ + pk_lookupn, /* lookup */ + kpse_pk_format, + NULL +}; + +static char *pk_lookup(const char *name, Ushort *hdpi, Ushort *vdpi) +{ + kpse_glyph_file_type type; + char *filename; + + if(pk_auto_generate == 0) { + kpse_set_program_enabled(kpse_pk_format, 1, kpse_src_cmdline); + pk_auto_generate = 1; + } + filename = kpse_find_glyph(name, Max(*hdpi, *vdpi), + kpse_pk_format, &type); + if(filename && type.source == kpse_glyph_source_fallback) { + xfree(filename); + filename = NULL; + } else if(filename) { + *hdpi = *vdpi = type.dpi; + } + return filename; +} + +static char *pk_lookupn(const char *name, Ushort *hdpi, Ushort *vdpi) +{ + kpse_glyph_file_type type; + char *filename; + + if(pk_auto_generate) { + kpse_set_program_enabled(kpse_pk_format, 0, kpse_src_cmdline); + pk_auto_generate = 0; + } + filename = kpse_find_glyph(name, Max(*hdpi, *vdpi), + kpse_pk_format, &type); + if(filename && type.source == kpse_glyph_source_fallback) { + xfree(filename); + filename = NULL; + } else if(filename) { + *hdpi = *vdpi = type.dpi; + } + return filename; +} + +static inline int pk_get_nyb(FILE *p, pkread *pk) +{ + unsigned t; + int nb; + char c; + + t = c = pk->currbyte; + nb = pk->nybpos; + + switch(nb) { + case 0: + c = pk->currbyte = fuget1(p); + t = (c >> 4); + break; + case 1: + t = c; + break; + } + pk->nybpos = !nb; + return (t & 0xf); +} + +/* + * this is a bit cumbersome because we have to pass around + * the `pkread' data... + */ +static int pk_packed_num(FILE *p, pkread *pkr, int *repeat) +{ + int i, j; + int dyn_f = pkr->dyn_f; + + i = pk_get_nyb(p, pkr); + if(i == 0) { + do { + j = pk_get_nyb(p, pkr); + i++; + } while(j == 0); + while(i-- > 0) + j = (j << 4) + pk_get_nyb(p, pkr); + return (j - 15 + ((13 - dyn_f) << 4) + + dyn_f); + } else if(i <= dyn_f) + return i; + else if(i < 14) + return ((i - dyn_f - 1) << 4) + + pk_get_nyb(p, pkr) + dyn_f + 1; + else { + *repeat = 1; + if(i == 14) + *repeat = pk_packed_num(p, pkr, repeat); + return pk_packed_num(p, pkr, repeat); + } +} + +#define ROUND(x,y) (((x) + (y) - 1) / (y)) + +static BITMAP *get_bitmap(FILE *p, int w, int h, int flags) +{ + int i, j; + BmUnit *ptr; + BITMAP *bm; + int bitpos; + int currch; + + flags = 0; /* shut up that compiler */ + bitpos = -1; + if((bm = bitmap_alloc(w, h)) == NULL) + return NULL; + DEBUG((DBG_BITMAPS, "get_bitmap(%d,%d,%d): reading raw bitmap\n", + w, h, flags)); + ptr = bm->data; + currch = 0; + for(i = 0; i < h; i++) { + BmUnit mask; + + mask = FIRSTMASK; + for(j = 0; j < w; j++) { + if(bitpos < 0) { + currch = fuget1(p); + bitpos = 7; + } + if(currch & (1 << bitpos)) + *ptr |= mask; + bitpos--; + if(mask == LASTMASK) { + ptr++; + mask = FIRSTMASK; + } else + NEXTMASK(mask); + } + ptr = bm_offset(ptr, bm->stride); + } + return bm; +} + +static BITMAP *get_packed(FILE *p, int w, int h, int flags) +{ + int inrow, count; + int row; + BITMAP *bm; + int repeat_count; + int paint; + pkread pkr; + + pkr.nybpos = 0; + pkr.currbyte = 0; + pkr.dyn_f = PK_DYN_F(flags); + paint = !!(flags & 0x8); + + repeat_count = 0; + row = 0; + inrow = w; + if((bm = bitmap_alloc(w, h)) == NULL) + return NULL; + DEBUG((DBG_BITMAPS, "get_packed(%d,%d,%d): reading packed glyph\n", + w, h, flags)); + while(row < h) { + int i = 0; + + count = pk_packed_num(p, &pkr, &i); + if(i > 0) { + if(repeat_count) + fprintf(stderr, "second repeat count for this row (had %d and got %d)\n", + repeat_count, i); + repeat_count = i; + } + + if(count >= inrow) { + Uchar *r, *t; + BmUnit *a, mask; + + /* first finish current row */ + if(paint) + bitmap_set_row(bm, row, w - inrow, inrow, paint); + /* now copy it as many times as required */ + r = (Uchar *)bm->data + row * bm->stride; + while(repeat_count-- > 0) { + t = r + bm->stride; + /* copy entire lines */ + memcpy(t, r, bm->stride); + r = t; + row++; + } + repeat_count = 0; + /* count first row we drew */ + row++; + /* update run count */ + count -= inrow; + /* now r points to the beginning of the last row we finished */ + if(paint) + mask = ~((BmUnit)0); + else + mask = 0; + /* goto next row */ + a = (BmUnit *)(r + bm->stride); + /* deal with entirely with/black rows */ + while(count >= w) { + /* count number of atoms in a row */ + i = ROUND(w, BITMAP_BITS); + while(i-- > 0) + *a++ = mask; + count -= w; + row++; + } + inrow = w; + } + if(count > 0) + bitmap_set_row(bm, row, w - inrow, count, paint); + inrow -= count; + paint = !paint; + } + if(row != h || inrow != w) { + error(_("Bad PK file: More bits than required\n")); + bitmap_destroy(bm); + return NULL; + } + return bm; +} + +static BITMAP *get_char(FILE *p, int w, int h, int flags) +{ + /* check if dyn_f == 14 */ + if(((flags >> 4) & 0xf) == 14) + return get_bitmap(p, w, h, flags); + else + return get_packed(p, w, h, flags); +} + +/* supports any number of characters in a font */ +static int pk_load_font(DviParams *unused, DviFont *font) +{ + int i; + int flag_byte; + int loc, hic, maxch; + Int32 checksum; + FILE *p; +#ifndef NODEBUG + char s[256]; +#endif + long alpha, beta, z; + + font->chars = xnalloc(DviFontChar, 256); + p = font->in; + memzero(font->chars, 256 * sizeof(DviFontChar)); + for(i = 0; i < 256; i++) + font->chars[i].offset = 0; + + /* check the preamble */ + loc = fuget1(p); hic = fuget1(p); + if(loc != PK_PRE || hic != PK_ID) + goto badpk; + i = fuget1(p); +#ifndef NODEBUG + for(loc = 0; loc < i; loc++) + s[loc] = fuget1(p); + s[loc] = 0; + DEBUG((DBG_FONTS, "(pk) %s: %s\n", font->fontname, s)); +#else + fseek(in, (long)i, SEEK_CUR); +#endif + /* get the design size */ + font->design = fuget4(p); + /* get the checksum */ + checksum = fuget4(p); + if(checksum && font->checksum && font->checksum != checksum) { + warning(_("%s: checksum mismatch (expected %u, got %u)\n"), + font->fontname, font->checksum, checksum); + } else if(!font->checksum) + font->checksum = checksum; + /* skip pixel per point ratios */ + fuget4(p); + fuget4(p); + if(feof(p)) + goto badpk; + + /* now start reading the font */ + loc = 256; hic = -1; maxch = 256; + + /* initialize alpha and beta for TFM width computation */ + TFMPREPARE(font->scale, z, alpha, beta); + + while((flag_byte = fuget1(p)) != PK_POST) { + if(feof(p)) + break; + if(flag_byte >= PK_CMD_START) { + switch(flag_byte) { + case PK_X1: + case PK_X2: + case PK_X3: + case PK_X4: { +#ifndef NODEBUG + char *t; + int n; + + i = fugetn(p, flag_byte - PK_X1 + 1); + if(i < 256) + t = &s[0]; + else + t = xmalloc(i + 1); + for(n = 0; n < i; n++) + t[n] = fuget1(p); + t[n] = 0; + DEBUG((DBG_SPECIAL, "(pk) %s: Special \"%s\"\n", + font->fontname, t)); + if(t != &s[0]) + xfree(t); +#else + i = fugetn(p, flag_byte - PK_X1 + 1); + while(i-- > 0) + fuget1(p); +#endif + break; + } + case PK_Y: + i = fuget4(p); + DEBUG((DBG_SPECIAL, "(pk) %s: MF special %u\n", + font->fontname, (unsigned)i)); + break; + case PK_POST: + case PK_NOOP: + break; + case PK_PRE: + error(_("%s: unexpected preamble\n"), font->fontname); + goto error; + } + } else { + int pl; + int cc; + int w, h; + int x, y; + int offset; + long tfm; + + switch(flag_byte & 0x7) { + case 7: + pl = fuget4(p); + cc = fuget4(p); + offset = ftell(p) + pl; + tfm = fuget4(p); + fsget4(p); /* skip dx */ + fsget4(p); /* skip dy */ + w = fuget4(p); + h = fuget4(p); + x = fsget4(p); + y = fsget4(p); + break; + case 4: + case 5: + case 6: + pl = (flag_byte % 4) * 65536 + fuget2(p); + cc = fuget1(p); + offset = ftell(p) + pl; + tfm = fuget3(p); + fsget2(p); /* skip dx */ + /* dy assumed 0 */ + w = fuget2(p); + h = fuget2(p); + x = fsget2(p); + y = fsget2(p); + break; + default: + pl = (flag_byte % 4) * 256 + fuget1(p); + cc = fuget1(p); + offset = ftell(p) + pl; + tfm = fuget3(p); + fsget1(p); /* skip dx */ + /* dy assumed 0 */ + w = fuget1(p); + h = fuget1(p); + x = fsget1(p); + y = fsget1(p); + } + if(feof(p)) + break; + if(cc < loc) + loc = cc; + if(cc > hic) + hic = cc; + if(cc > maxch) { + font->chars = xresize(font->chars, + DviFontChar, cc + 16); + for(i = maxch; i < cc + 16; i++) + font->chars[i].offset = 0; + maxch = cc + 16; + } + font->chars[cc].code = cc; + font->chars[cc].flags = flag_byte; + font->chars[cc].offset = ftell(p); + font->chars[cc].width = w; + font->chars[cc].height = h; + font->chars[cc].glyph.data = NULL; + font->chars[cc].x = x; + font->chars[cc].y = y; + font->chars[cc].glyph.x = x; + font->chars[cc].glyph.y = y; + font->chars[cc].glyph.w = w; + font->chars[cc].glyph.h = h; + font->chars[cc].grey.data = NULL; + font->chars[cc].shrunk.data = NULL; + font->chars[cc].tfmwidth = TFMSCALE(z, tfm, alpha, beta); + font->chars[cc].loaded = 0; + fseek(p, (long)offset, SEEK_SET); + } + } + if(flag_byte != PK_POST) { + error(_("%s: unexpected end of file (no postamble)\n"), + font->fontname); + goto error; + } + while((flag_byte = fuget1(p)) != EOF) { + if(flag_byte != PK_NOOP) { + error(_("invalid PK file! (junk in postamble)\n")); + goto error; + } + } + + /* resize font char data */ + if(loc > 0 || hic < maxch-1) { + memmove(font->chars, font->chars + loc, + (hic - loc + 1) * sizeof(DviFontChar)); + font->chars = xresize(font->chars, + DviFontChar, hic - loc + 1); + } + font->loc = loc; + font->hic = hic; + return 0; + +badpk: + error(_("%s: File corrupted, or not a PK file\n"), font->fontname); +error: + xfree(font->chars); + font->chars = NULL; + font->loc = font->hic = 0; + return -1; +} + +static int pk_font_get_glyph(DviParams *params, DviFont *font, int code) +{ + DviFontChar *ch; + + if((ch = FONTCHAR(font, code)) == NULL) + return -1; + + if(ch->offset == 0) + return -1; + DEBUG((DBG_GLYPHS, "(pk) loading glyph for character %d (%dx%d) in font `%s'\n", + code, ch->width, ch->height, font->fontname)); + if(font->in == NULL && font_reopen(font) < 0) + return -1; + if(!ch->width || !ch->height) { + /* this happens for ` ' (ASCII 32) in some fonts */ + ch->glyph.x = ch->x; + ch->glyph.y = ch->y; + ch->glyph.w = ch->width; + ch->glyph.h = ch->height; + ch->glyph.data = NULL; + return 0; + } + if(fseek(font->in, ch->offset, SEEK_SET) == -1) + return -1; + ch->glyph.data = get_char(font->in, + ch->width, ch->height, ch->flags); + if(ch->glyph.data) { + /* restore original settings */ + ch->glyph.x = ch->x; + ch->glyph.y = ch->y; + ch->glyph.w = ch->width; + ch->glyph.h = ch->height; + } else + return -1; + ch->loaded = 1; + return 0; +} diff --git a/dviware/mdvi/lib/po/CVS/Entries b/dviware/mdvi/lib/po/CVS/Entries new file mode 100644 index 0000000000..e6aca75262 --- /dev/null +++ b/dviware/mdvi/lib/po/CVS/Entries @@ -0,0 +1,7 @@ +/Makefile.in/1.1.1.1/Tue Mar 20 09:25:29 2001// +/cat-id-tbl.c/1.1.1.1/Tue Mar 20 09:25:30 2001// +/es.gmo/1.1.1.1/Tue Mar 20 09:25:29 2001// +/es.po/1.1.1.1/Tue Mar 20 09:25:29 2001// +/mdvi.pot/1.1.1.1/Tue Mar 20 09:25:29 2001// +/stamp-cat-id/1.1.1.1/Tue Mar 20 09:25:29 2001// +D diff --git a/dviware/mdvi/lib/po/CVS/Repository b/dviware/mdvi/lib/po/CVS/Repository new file mode 100644 index 0000000000..fe4f6751df --- /dev/null +++ b/dviware/mdvi/lib/po/CVS/Repository @@ -0,0 +1 @@ +mdvi/lib/po diff --git a/dviware/mdvi/lib/po/CVS/Root b/dviware/mdvi/lib/po/CVS/Root new file mode 100644 index 0000000000..164e86eed7 --- /dev/null +++ b/dviware/mdvi/lib/po/CVS/Root @@ -0,0 +1 @@ +agiacom@cvs.mdvi.sourceforge.net:/cvsroot/mdvi diff --git a/dviware/mdvi/lib/po/Makefile b/dviware/mdvi/lib/po/Makefile new file mode 100644 index 0000000000..429a2f036d --- /dev/null +++ b/dviware/mdvi/lib/po/Makefile @@ -0,0 +1,18 @@ +# Generated automatically from Makefile.in by configure. + +srcdir = . + +include ../../config.mk + +PACKAGE = mdvi +SUBDIR = lib +LINGUAS = es + +POT_SOURCES = afmparse.c assoc.c bitmap.c common.c dvimisc.c dviread.c \ + files.c font.c fontmap.c fontsrch.c gf.c hash.c list.c pagesel.c \ + paper.c pk.c setup.c sp-epsf.c special.c t1.c tfm.c tfmfile.c \ + util.c vf.c + +DISTCLEANABLE += Makefile + +include $(TOPDIR)/nls.mk diff --git a/dviware/mdvi/lib/po/Makefile.in b/dviware/mdvi/lib/po/Makefile.in new file mode 100644 index 0000000000..f603e41efa --- /dev/null +++ b/dviware/mdvi/lib/po/Makefile.in @@ -0,0 +1,18 @@ + +srcdir = @srcdir@ +VPATH = @srcdir@ + +include ../../config.mk + +PACKAGE = mdvi +SUBDIR = lib +LINGUAS = es + +POT_SOURCES = afmparse.c assoc.c bitmap.c common.c dvimisc.c dviread.c \ + files.c font.c fontmap.c fontsrch.c gf.c hash.c list.c pagesel.c \ + paper.c pk.c setup.c sp-epsf.c special.c t1.c tfm.c tfmfile.c \ + util.c vf.c + +DISTCLEANABLE += Makefile + +include $(TOPDIR)/nls.mk diff --git a/dviware/mdvi/lib/po/cat-id-tbl.c b/dviware/mdvi/lib/po/cat-id-tbl.c new file mode 100644 index 0000000000..31167514c7 --- /dev/null +++ b/dviware/mdvi/lib/po/cat-id-tbl.c @@ -0,0 +1,103 @@ +/* Automatically generated by po2tbl.sed from mdvi.pot. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include "libgettext.h" + +const struct _msg_ent _msg_tbl[] = { + {"", 1}, + {"unexpected EOF\n", 2}, + {"could not load font `%s'\n", 3}, + {"could not reload `%s'\n", 4}, + {"%s: unsupported DVI format (version %u)\n", 5}, + {"no pages selected\n", 6}, + {"%s: File corrupted, or not a DVI file\n", 7}, + {"%s: vf macro had errors\n", 8}, + {"%s: stack not empty after vf macro\n", 9}, + {"%s: could not reopen file (%s)\n", 10}, + {"%s: page %d out of range\n", 11}, + {"%s: bad offset at page %d\n", 12}, + {"stack not empty at end of page\n", 13}, + {"no default font set yet\n", 14}, + {"requested character %d does not exist in `%s'\n", 15}, + {"enlarging stack\n", 16}, + {"stack underflow\n", 17}, + {"font %d is not defined\n", 18}, + {"font %d is not defined in postamble\n", 19}, + {"unexpected opcode %d\n", 20}, + {"undefined opcode %d\n", 21}, + {"%s: no fonts defined\n", 22}, + {"%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n", 23}, + {"%s: could not load fontmap\n", 24}, + {"%s: could not set as default encoding\n", 25}, + {"encoding vector `%s' is in use\n", 26}, + {"GF: invalid opcode %d in character %d\n", 27}, + {"(gf) Character %d: invalid opcode %d\n", 28}, + {"(gf) character %d has an incorrect bounding box\n", 29}, + {"%s: bad checksum (expected %u, found %u)\n", 30}, + {"%s: junk in postamble\n", 31}, + {"%s: File corrupted, or not a GF file\n", 32}, + {"invalid page specification `%s'\n", 33}, + {"garbage after DVI page specification ignored\n", 34}, + {"more than 10 counters in page specification\n", 35}, + {"garbage after TeX page specification ignored\n", 36}, + {"custom", 37}, + {"Bad PK file: More bits than required\n", 38}, + {"%s: checksum mismatch (expected %u, got %u)\n", 39}, + {"%s: unexpected preamble\n", 40}, + {"%s: unexpected end of file (no postamble)\n", 41}, + {"invalid PK file! (junk in postamble)\n", 42}, + {"%s: File corrupted, or not a PK file\n", 43}, + {"unknown orientation `%s'\n", 44}, + {"variable %s should be an integer\n", 45}, + {"variable %s should be a floating-point number\n", 46}, + {"%s: unknown paper `%s', using %s\n", 47}, + {"DPI must be a positive integer\n", 48}, + {"magnification must be a positive number\n", 49}, + {"pixel density must be between 0 and 100\n", 50}, + {"no fallback font specified, using `%s'\n", 51}, + {"%s: malformed value for key `%s'\n", 52}, + {"%s: unknown key `%s' ignored\n", 53}, + {"%s: no argument for key `%s', using defaults\n", 54}, + {"%s: argument `%s' ignored for key `%s'\n", 55}, + {"%s: tried to pop top level layer\n", 56}, + {"(t1) failed to reset device resolution\n", 57}, + {"%s: could not encode font\n", 58}, + {"(t1) unsupported bitmap pad size %d\n", 59}, + {"%s: Checksum mismatch (got %u, expected %u)\n", 60}, + {"%s: Error reading AFM data\n", 61}, + {"Warning: TFM file `%s' has suspicious size\n", 62}, + {"%s: font coding scheme truncated to 40 bytes\n", 63}, + {"%s: File corrupted, or not a TFM file\n", 64}, + {"Ooops!", 65}, + {"Aieeeee!!", 66}, + {"Ouch!", 67}, + {"Houston, we have a problem", 68}, + {"3.. 2.. 1.. BOOM!", 69}, + {"I'm history", 70}, + {"I'm going down", 71}, + {"I smell a rat", 72}, + {"Crashing", 73}, + {"%s: Error: ", 74}, + {"Error", 75}, + {"%s: Warning: ", 76}, + {"Warning", 77}, + {"%s: Fatal: ", 78}, + {"Fatal", 79}, + {"out of memory allocating %u bytes\n", 80}, + {"attempted to reallocate with zero size\n", 81}, + {"failed to reallocate %u bytes\n", 82}, + {"attempted to callocate 0 members\n", 83}, + {"attempted to callocate %u members with size 0\n", 84}, + {"failed to allocate %ux%u bytes\n", 85}, + {"attempted to free NULL pointer\n", 86}, + {"%s: Checksum mismatch (expected %u, got %u)\n", 87}, + {"(vf) %s: could not load font `%s'\n", 88}, + {"(vf) %s: character %d redefined\n", 89}, + {"(vf) %s: no postamble\n", 90}, + {"%s: File corrupted, or not a VF file.\n", 91}, +}; + +int _msg_tbl_length = 91; diff --git a/dviware/mdvi/lib/po/es.gmo b/dviware/mdvi/lib/po/es.gmo Binary files differnew file mode 100644 index 0000000000..3184e74625 --- /dev/null +++ b/dviware/mdvi/lib/po/es.gmo diff --git a/dviware/mdvi/lib/po/es.po b/dviware/mdvi/lib/po/es.po new file mode 100644 index 0000000000..bff94ad8c4 --- /dev/null +++ b/dviware/mdvi/lib/po/es.po @@ -0,0 +1,595 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: mdvi 0.2\n" +"POT-Creation-Date: 2001-03-19 04:03-0500\n" +"PO-Revision-Date: 2001-03-13 04:20-0500\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: ENCODING\n" + +#. this is EOF +#: ../dviread.c:205 +msgid "unexpected EOF\n" +msgstr "fin de archivo inesperado\n" + +#: ../dviread.c:426 +#, c-format +msgid "could not load font `%s'\n" +msgstr "no pude cargar la fuente `%s'\n" + +#: ../dviread.c:480 +#, c-format +msgid "could not reload `%s'\n" +msgstr "no pude releer `%s'\n" + +#: ../dviread.c:712 +#, c-format +msgid "%s: unsupported DVI format (version %u)\n" +msgstr "%s: formato DVI desconocido (version %u)\n" + +#: ../dviread.c:874 +msgid "no pages selected\n" +msgstr "ninguna pagina seleccionada\n" + +#: ../dviread.c:910 +#, c-format +msgid "%s: File corrupted, or not a DVI file\n" +msgstr "%s: Archivo no valido, o no es un DVI\n" + +#: ../dviread.c:992 +#, c-format +msgid "%s: vf macro had errors\n" +msgstr "%s: errores en la macro vf\n" + +#: ../dviread.c:995 +#, c-format +msgid "%s: stack not empty after vf macro\n" +msgstr "%s: pila no vacia despues de macro vf\n" + +#: ../dviread.c:1020 +#, c-format +msgid "%s: could not reopen file (%s)\n" +msgstr "%s: no pude reabrir el archivo (%s)\n" + +#: ../dviread.c:1037 +#, c-format +msgid "%s: page %d out of range\n" +msgstr "%s: la pagina %d no existe\n" + +#: ../dviread.c:1044 +#, c-format +msgid "%s: bad offset at page %d\n" +msgstr "%s: puntero no valido en la pagina %d\n" + +#: ../dviread.c:1107 +msgid "stack not empty at end of page\n" +msgstr "pila no vacial al termino de pagina\n" + +#: ../dviread.c:1251 +msgid "no default font set yet\n" +msgstr "no hay una fuente seleccionada\n" + +#: ../dviread.c:1261 +#, c-format +msgid "requested character %d does not exist in `%s'\n" +msgstr "el caracter requerido %d no existe en `%s'\n" + +#: ../dviread.c:1333 +msgid "enlarging stack\n" +msgstr "aumentando el espacio de pila\n" + +#: ../dviread.c:1351 +msgid "stack underflow\n" +msgstr "desdoblamiento de pila\n" + +#: ../dviread.c:1465 ../dviread.c:1487 +#, c-format +msgid "font %d is not defined\n" +msgstr "la fuente %d no esta definida\n" + +#: ../dviread.c:1527 +#, c-format +msgid "font %d is not defined in postamble\n" +msgstr "la fuente %d no fue definida en postambulo\n" + +#: ../dviread.c:1539 +#, c-format +msgid "unexpected opcode %d\n" +msgstr "codigo %d inesperado\n" + +#: ../dviread.c:1545 +#, c-format +msgid "undefined opcode %d\n" +msgstr "codigo %d no definido\n" + +#: ../fontmap.c:579 +#, c-format +msgid "%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n" +msgstr "%s: %d: [%s] el codigo `%s' no corresponde al vector `%s'\n" + +#: ../fontmap.c:740 +#, c-format +msgid "%s: could not load fontmap\n" +msgstr "%s: no pude cargar el mapa de fuentes\n" + +#: ../fontmap.c:754 +#, c-format +msgid "%s: could not set as default encoding\n" +msgstr "%s: no pude fijar el codigo predeterminado\n" + +#: ../fontmap.c:833 +#, c-format +msgid "encoding vector `%s' is in use\n" +msgstr "el vector de codigo `%s' esta siendo usado\n" + +#: ../font.c:497 +#, c-format +msgid "%s: no fonts defined\n" +msgstr "%s: ninguna fuente definidas\n" + +#: ../gf.c:111 +#, c-format +msgid "GF: invalid opcode %d in character %d\n" +msgstr "GF: codigo %d no valido en caracter %d\n" + +#: ../gf.c:209 +#, c-format +msgid "(gf) Character %d: invalid opcode %d\n" +msgstr "(gf) caracter %d: codigo %d no valido\n" + +#: ../gf.c:225 +#, c-format +msgid "(gf) character %d has an incorrect bounding box\n" +msgstr "(gf) caracter %d tiene una caja minima incorrecta\n" + +#: ../gf.c:288 +#, c-format +msgid "%s: bad checksum (expected %u, found %u)\n" +msgstr "%s: sumas de verificacion no concuerdan (%u != %u)\n" + +#: ../gf.c:324 +#, c-format +msgid "%s: junk in postamble\n" +msgstr "%s: basura en postambulo\n" + +#: ../gf.c:361 +#, c-format +msgid "%s: File corrupted, or not a GF file\n" +msgstr "%s: Archivo no valido, o no es un GF\n" + +#: ../pagesel.c:211 +#, c-format +msgid "invalid page specification `%s'\n" +msgstr "la especificacion de pagina `%s' no es valida\n" + +#: ../pagesel.c:231 +msgid "garbage after DVI page specification ignored\n" +msgstr "basura al final de especificacion de pagina DVI ignorada\n" + +#: ../pagesel.c:259 +msgid "more than 10 counters in page specification\n" +msgstr "mas de 10 contadores in especificacion de pagina\n" + +#: ../pagesel.c:261 +msgid "garbage after TeX page specification ignored\n" +msgstr "basura al final de especificacion de pagina TeX ignorada\n" + +#: ../paper.c:103 ../paper.c:110 +msgid "custom" +msgstr "usuario" + +#: ../pk.c:249 +msgid "Bad PK file: More bits than required\n" +msgstr "Archivo PK no valido: mas bits de los necesarios\n" + +#: ../pk.c:302 +#, c-format +msgid "%s: checksum mismatch (expected %u, got %u)\n" +msgstr "%s: sumas de verificacion no concuerdan (%u != %u)\n" + +#: ../pk.c:359 +#, c-format +msgid "%s: unexpected preamble\n" +msgstr "%s: preambulo inseperado\n" + +#: ../pk.c:442 +#, c-format +msgid "%s: unexpected end of file (no postamble)\n" +msgstr "%s: fin de archivo inesperado (falta postambulo)\n" + +#: ../pk.c:448 +msgid "invalid PK file! (junk in postamble)\n" +msgstr "archivo PK no valido (basura en postambulo)\n" + +#: ../pk.c:465 +#, c-format +msgid "%s: File corrupted, or not a PK file\n" +msgstr "%s: Archivo no valido, o no es un PK\n" + +#: ../setup.c:138 +#, c-format +msgid "unknown orientation `%s'\n" +msgstr "orientacion `%s' desconocida\n" + +#: ../setup.c:198 +#, c-format +msgid "variable %s should be an integer\n" +msgstr "la variable `%s' debe ser un entero\n" + +#: ../setup.c:231 +#, c-format +msgid "variable %s should be a floating-point number\n" +msgstr "la variable `%s' debe ser un numero decimal\n" + +#: ../setup.c:293 +#, c-format +msgid "%s: unknown paper `%s', using %s\n" +msgstr "%s: papel `%s' desconocido, usando %s\n" + +#: ../setup.c:300 +msgid "DPI must be a positive integer\n" +msgstr "DPI debe ser un entero positivo\n" + +#: ../setup.c:310 +msgid "magnification must be a positive number\n" +msgstr "la magnificacion debe ser positiva\n" + +#: ../setup.c:314 +msgid "pixel density must be between 0 and 100\n" +msgstr "la densidad de pixeles debe ser >= 0 y <= 100\n" + +#: ../setup.c:324 +#, c-format +msgid "no fallback font specified, using `%s'\n" +msgstr "no hay fuente predeterminada definida, usando `%s'\n" + +#: ../special.c:242 +#, c-format +msgid "%s: tried to pop top level layer\n" +msgstr "%s: `layer pop' sin push\n" + +#: ../sp-epsf.c:148 +#, c-format +msgid "%s: malformed value for key `%s'\n" +msgstr "%s: el valor para la clave `%s' no es valido\n" + +#: ../sp-epsf.c:159 +#, c-format +msgid "%s: unknown key `%s' ignored\n" +msgstr "%s: clave `%s' desconocida, ignorada\n" + +#: ../sp-epsf.c:164 +#, c-format +msgid "%s: no argument for key `%s', using defaults\n" +msgstr "%s: falta argumento para clave `%s', usando valor predeterminado\n" + +#: ../sp-epsf.c:168 +#, c-format +msgid "%s: argument `%s' ignored for key `%s'\n" +msgstr "%s: argumento `%s' ignorado para la clave `%s'\n" + +#: ../t1.c:181 +msgid "(t1) failed to reset device resolution\n" +msgstr "(t1) no pude fijar la resolucion\n" + +#: ../t1.c:209 +#, c-format +msgid "%s: could not encode font\n" +msgstr "%s: no pude codificar la fuente\n" + +#: ../t1.c:447 +#, c-format +msgid "(t1) unsupported bitmap pad size %d\n" +msgstr "(t1) unsupported bitmap pad size %d\n" + +#: ../tfm.c:174 +#, c-format +msgid "%s: Checksum mismatch (got %u, expected %u)\n" +msgstr "%s: sumas de verificacion no concuerdan (%u != %u)\n" + +#: ../tfmfile.c:88 +#, c-format +msgid "%s: Error reading AFM data\n" +msgstr "%s: Error leyendo informacion AFM\n" + +#: ../tfmfile.c:178 +#, c-format +msgid "Warning: TFM file `%s' has suspicious size\n" +msgstr "Atencion: archivo TFM `%s' tiene taman~o sospechoso\n" + +#: ../tfmfile.c:228 ../tfmfile.c:509 +#, c-format +msgid "%s: font coding scheme truncated to 40 bytes\n" +msgstr "%s: esquema de codigo truncado a 40 bytes\n" + +#: ../tfmfile.c:288 ../tfmfile.c:588 +#, c-format +msgid "%s: File corrupted, or not a TFM file\n" +msgstr "%s: Archivo no valido, o no es un TFM\n" + +#: ../tt.c:132 +#, c-format +msgid "(tt) %s: could not load face: %s\n" +msgstr "(tt) %s: no pude cargar la fuente: %s\n" + +#: ../tt.c:140 +#, c-format +msgid "(tt) %s: could not create face: %s\n" +msgstr "(tt) %s: no pude crear la fuente: %s\n" + +#: ../tt.c:149 +#, c-format +msgid "(tt) %s: could not create glyph: %s\n" +msgstr "(tt) %s: no pude crear un glifo: %s\n" + +#: ../tt.c:182 +#, c-format +msgid "(tt) %s: no acceptable map found, using #0\n" +msgstr "(tt) %s: ninguna tabla de mapeo aceptable, usando #0\n" + +#: ../tt.c:195 +#, c-format +msgid "(tt) %s: could not set resolution: %s\n" +msgstr "(tt) %s: no pude fijar la resolucion: %s\n" + +#: ../tt.c:202 +#, c-format +msgid "(tt) %s: could not set point size: %s\n" +msgstr "(tt) %s: no pude fijar el taman~o de la fuente: %s\n" + +#: ../tt.c:221 +#, c-format +msgid "(tt) %s: could not load PS name table\n" +msgstr "(tt) %s: no pude cargar la tabla de nombres PS\n" + +#: ../tt.c:246 +#, c-format +msgid "%s: no encoding vector found, expect bad output\n" +msgstr "" +"%s: no hay vector de codigos para esta fuente, la imagen puede ser " +"incorrecta\n" + +#: ../tt.c:306 +#, fuzzy, c-format +msgid "(tt) %s: no font metric data\n" +msgstr "(tt) %s: no hay informacion metrica\n" + +#: ../util.c:32 +msgid "Ooops!" +msgstr "Oooops!" + +#: ../util.c:33 +msgid "Aieeeee!!" +msgstr "Aaaargh!!" + +#: ../util.c:34 +msgid "Ouch!" +msgstr "Ayy!" + +#: ../util.c:35 +msgid "Houston, we have a problem" +msgstr "Hay olor a muerto" + +#: ../util.c:36 +msgid "3.. 2.. 1.. BOOM!" +msgstr "Adios mundo cruel" + +#: ../util.c:37 +msgid "I'm history" +msgstr "Estoy frito" + +#: ../util.c:38 +msgid "I'm going down" +msgstr "" + +#: ../util.c:39 +msgid "I smell a rat" +msgstr "" + +#: ../util.c:144 +#, fuzzy +msgid "Crashing" +msgstr "Abortando: " + +#: ../util.c:154 +#, c-format +msgid "%s: Error: " +msgstr "%s: Error: " + +#: ../util.c:161 +#, fuzzy +msgid "Error" +msgstr "Error: " + +#: ../util.c:170 +#, c-format +msgid "%s: Warning: " +msgstr "%s: Atencion: " + +#: ../util.c:177 +#, fuzzy +msgid "Warning" +msgstr "Atencion: " + +#: ../util.c:186 +#, c-format +msgid "%s: Fatal: " +msgstr "%s: Fatal: " + +#: ../util.c:193 +#, fuzzy +msgid "Fatal" +msgstr "Fatal: " + +#: ../util.c:207 +#, c-format +msgid "out of memory allocating %u bytes\n" +msgstr "se acabo la memoria al requerir %u bytes\n" + +#: ../util.c:217 +msgid "attempted to reallocate with zero size\n" +msgstr "intento de realloc() a taman~o cero\n" + +# FALTA +#: ../util.c:220 +#, c-format +msgid "failed to reallocate %u bytes\n" +msgstr "failed to reallocate %u bytes\n" + +#: ../util.c:229 +msgid "attempted to callocate 0 members\n" +msgstr "intento de calloc() 0 miembros\n" + +#: ../util.c:231 +#, c-format +msgid "attempted to callocate %u members with size 0\n" +msgstr "intento de calloc() %u miembros de taman~o 0\n" + +#: ../util.c:235 +#, c-format +msgid "failed to allocate %ux%u bytes\n" +msgstr "se acabo la memoria al requerir %ux%u bytes\n" + +#: ../util.c:243 +msgid "attempted to free NULL pointer\n" +msgstr "intento de liberar puntero nulo\n" + +#: ../vf.c:79 +#, c-format +msgid "%s: Checksum mismatch (expected %u, got %u)\n" +msgstr "%s: sumas de verificacion no concuerdan (%u != %u)\n" + +#: ../vf.c:127 +#, c-format +msgid "(vf) %s: could not load font `%s'\n" +msgstr "(vf) %s: no pude cargar la fuente `%s'\n" + +#: ../vf.c:177 +#, c-format +msgid "(vf) %s: character %d redefined\n" +msgstr "(vf) %s: caracter %d redefinido\n" + +#: ../vf.c:200 +#, c-format +msgid "(vf) %s: no postamble\n" +msgstr "(vf) %s: falta postambulo\n" + +#: ../vf.c:226 +#, c-format +msgid "%s: File corrupted, or not a VF file.\n" +msgstr "%s: Archivo no valido, o no es un VF\n" + +#~ msgid "ISO paper types" +#~ msgstr "Tipos de papel ISO" + +#~ msgid "US paper types" +#~ msgstr "Tipos de papel US" + +#~ msgid "%s: I don't know about that\n" +#~ msgstr "%s: No se que nada se\n" + +#~ msgid "resolution must be a positive integer\n" +#~ msgstr "la resolucion debe ser positiva\n" + +#~ msgid "Known topics\n" +#~ msgstr "Topicos conocidos\n" + +#~ msgid "magnification must be positive\n" +#~ msgstr "la magnificacion debe ser positiva\n" + +#~ msgid "page number must be a positive integer\n" +#~ msgstr "el numero de pagina debe ser un entero positivo\n" + +#~ msgid "shrinking factor must be a non-negative number\n" +#~ msgstr "el factor de escala debe ser un entero no negativo, o -1\n" + +#~ msgid "unknown sorting type `%s'\n" +#~ msgstr "tipo de ordenamiento `%s' desconocido\n" + +#~ msgid "pixel density must be a non-negative number\n" +#~ msgstr "la densidad de pixeles debe ser no negativa\n" + +#~ msgid "pixel density should be less than 100\n" +#~ msgstr "la densidad de pixeles debe ser <= 100\n" + +#~ msgid "tex-page must be an integer\n" +#~ msgstr "tex-page debe ser un entero\n" + +#, fuzzy +#~ msgid "%s: no DVI file specified\n" +#~ msgstr "%s: ninguna fuente definidas\n" + +#, fuzzy +#~ msgid "Try `%s --help' for more information\n" +#~ msgstr "Ver `%s --help' para mas detalles\n" + +#~ msgid "Selected starting page out of range, showing first page instead\n" +#~ msgstr "La pagina seleccionada no existe, voy a mostrar la primera\n" + +#~ msgid "%s: magnification must be positive\n" +#~ msgstr "%s: la magnificacion debe ser positiva\n" + +#~ msgid "%s: no font metrics file, font ignored\n" +#~ msgstr "%s: no hay informacion metrica, fuente ignorada\n" + +#~ msgid "connection to X server failed\n" +#~ msgstr "no pude conectarme a un servidor X\n" + +#~ msgid "%s: could not find display font `%s'\n" +#~ msgstr "%s: no pude cargar la fuente de pantalla `%s'\n" + +#~ msgid "invalid color name `%s', using black\n" +#~ msgstr "el color `%s' no existe, usando negro\n" + +#~ msgid "failed to allocate color `%s', using black\n" +#~ msgstr "no pude crear el color `%s', usando negro\n" + +#~ msgid "could not find a TFM file for the fallback font `%s'\n" +#~ msgstr "no pude encontrar un TFM para la fuente predeterminada `%s'\n" + +#~ msgid "TFM file for font `%s' not fount, trying `%s'\n" +#~ msgstr "Archivo TFM no existe para la fuente `%s', tratando `%s'\n" + +#~ msgid "font `%s' not found\n" +#~ msgstr "la fuente `%s' no existe\n" + +#~ msgid "fallback font `%s' not found, trying TFM\n" +#~ msgstr "la fuente predeterminada `%s' no existe, tratando TFM\n" + +#~ msgid "font `%s' at %ddpi not found, trying `%s' at %ddpi instead\n" +#~ msgstr "" +#~ "la fuente `%s' a %ddpi no existe, tratando `%s' a %ddpi en su lugar\n" + +#~ msgid "font `%s' at %ddpi not found, trying TFM\n" +#~ msgstr "la fuente `%s' a %ddpi no existe, tratando TFM\n" + +#~ msgid "font `%s' at %ddpi not found. Using `%s' at %ddpi instead\n" +#~ msgstr "la fuente `%s' a %ddpi no existe. Usando `%s' a %ddpi en su lugar\n" + +#~ msgid "%s: unsuported format %d\n" +#~ msgstr "%s: formato %d desconocido\n" + +#~ msgid "could not initialize graphics output\n" +#~ msgstr "no pude iniciar el sistema grafico\n" + +#~ msgid "(ft) %s: could not load face: %s\n" +#~ msgstr "(ft) %s: no pude cargar la fuente: %s\n" + +#~ msgid "(ft) %s: could not create face\n" +#~ msgstr "(ft) %s: no pude crear la fuente\n" + +#~ msgid "encoding vectors not supported for TrueType fonts\n" +#~ msgstr "vectores de codigo ignorados para fuentes TrueType\n" + +#~ msgid "(ft) %s: could not set face size to %dpt\n" +#~ msgstr "(ft) %s: no pude fijar el tamano de la fuente a %dpt\n" + +#~ msgid "(ft) %s: no font metrics data\n" +#~ msgstr "(ft) %s: no hay informacion metrica para esta fuente\n" diff --git a/dviware/mdvi/lib/po/mdvi.pot b/dviware/mdvi/lib/po/mdvi.pot new file mode 100644 index 0000000000..cafa33a43f --- /dev/null +++ b/dviware/mdvi/lib/po/mdvi.pot @@ -0,0 +1,435 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2001-03-20 03:32-0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: ENCODING\n" + +#. this is EOF +#: ../dviread.c:205 +msgid "unexpected EOF\n" +msgstr "" + +#: ../dviread.c:426 +#, c-format +msgid "could not load font `%s'\n" +msgstr "" + +#: ../dviread.c:480 +#, c-format +msgid "could not reload `%s'\n" +msgstr "" + +#: ../dviread.c:712 +#, c-format +msgid "%s: unsupported DVI format (version %u)\n" +msgstr "" + +#: ../dviread.c:874 +msgid "no pages selected\n" +msgstr "" + +#: ../dviread.c:910 +#, c-format +msgid "%s: File corrupted, or not a DVI file\n" +msgstr "" + +#: ../dviread.c:992 +#, c-format +msgid "%s: vf macro had errors\n" +msgstr "" + +#: ../dviread.c:995 +#, c-format +msgid "%s: stack not empty after vf macro\n" +msgstr "" + +#: ../dviread.c:1020 +#, c-format +msgid "%s: could not reopen file (%s)\n" +msgstr "" + +#: ../dviread.c:1037 +#, c-format +msgid "%s: page %d out of range\n" +msgstr "" + +#: ../dviread.c:1044 +#, c-format +msgid "%s: bad offset at page %d\n" +msgstr "" + +#: ../dviread.c:1107 +msgid "stack not empty at end of page\n" +msgstr "" + +#: ../dviread.c:1251 +msgid "no default font set yet\n" +msgstr "" + +#: ../dviread.c:1261 +#, c-format +msgid "requested character %d does not exist in `%s'\n" +msgstr "" + +#: ../dviread.c:1333 +msgid "enlarging stack\n" +msgstr "" + +#: ../dviread.c:1351 +msgid "stack underflow\n" +msgstr "" + +#: ../dviread.c:1465 ../dviread.c:1487 +#, c-format +msgid "font %d is not defined\n" +msgstr "" + +#: ../dviread.c:1527 +#, c-format +msgid "font %d is not defined in postamble\n" +msgstr "" + +#: ../dviread.c:1539 +#, c-format +msgid "unexpected opcode %d\n" +msgstr "" + +#: ../dviread.c:1545 +#, c-format +msgid "undefined opcode %d\n" +msgstr "" + +#: ../font.c:497 +#, c-format +msgid "%s: no fonts defined\n" +msgstr "" + +#: ../fontmap.c:587 +#, c-format +msgid "%s: %d: [%s] requested encoding `%s' does not match vector `%s'\n" +msgstr "" + +#: ../fontmap.c:748 +#, c-format +msgid "%s: could not load fontmap\n" +msgstr "" + +#: ../fontmap.c:762 +#, c-format +msgid "%s: could not set as default encoding\n" +msgstr "" + +#: ../fontmap.c:841 +#, c-format +msgid "encoding vector `%s' is in use\n" +msgstr "" + +#: ../gf.c:112 +#, c-format +msgid "GF: invalid opcode %d in character %d\n" +msgstr "" + +#: ../gf.c:210 +#, c-format +msgid "(gf) Character %d: invalid opcode %d\n" +msgstr "" + +#: ../gf.c:226 +#, c-format +msgid "(gf) character %d has an incorrect bounding box\n" +msgstr "" + +#: ../gf.c:289 +#, c-format +msgid "%s: bad checksum (expected %u, found %u)\n" +msgstr "" + +#: ../gf.c:325 +#, c-format +msgid "%s: junk in postamble\n" +msgstr "" + +#: ../gf.c:362 +#, c-format +msgid "%s: File corrupted, or not a GF file\n" +msgstr "" + +#: ../pagesel.c:211 +#, c-format +msgid "invalid page specification `%s'\n" +msgstr "" + +#: ../pagesel.c:231 +msgid "garbage after DVI page specification ignored\n" +msgstr "" + +#: ../pagesel.c:259 +msgid "more than 10 counters in page specification\n" +msgstr "" + +#: ../pagesel.c:261 +msgid "garbage after TeX page specification ignored\n" +msgstr "" + +#: ../paper.c:103 ../paper.c:110 +msgid "custom" +msgstr "" + +#: ../pk.c:309 +msgid "Bad PK file: More bits than required\n" +msgstr "" + +#: ../pk.c:362 +#, c-format +msgid "%s: checksum mismatch (expected %u, got %u)\n" +msgstr "" + +#: ../pk.c:419 +#, c-format +msgid "%s: unexpected preamble\n" +msgstr "" + +#: ../pk.c:502 +#, c-format +msgid "%s: unexpected end of file (no postamble)\n" +msgstr "" + +#: ../pk.c:508 +msgid "invalid PK file! (junk in postamble)\n" +msgstr "" + +#: ../pk.c:525 +#, c-format +msgid "%s: File corrupted, or not a PK file\n" +msgstr "" + +#: ../setup.c:138 +#, c-format +msgid "unknown orientation `%s'\n" +msgstr "" + +#: ../setup.c:198 +#, c-format +msgid "variable %s should be an integer\n" +msgstr "" + +#: ../setup.c:231 +#, c-format +msgid "variable %s should be a floating-point number\n" +msgstr "" + +#: ../setup.c:295 +#, c-format +msgid "%s: unknown paper `%s', using %s\n" +msgstr "" + +#: ../setup.c:302 +msgid "DPI must be a positive integer\n" +msgstr "" + +#: ../setup.c:312 +msgid "magnification must be a positive number\n" +msgstr "" + +#: ../setup.c:316 +msgid "pixel density must be between 0 and 100\n" +msgstr "" + +#: ../setup.c:326 +#, c-format +msgid "no fallback font specified, using `%s'\n" +msgstr "" + +#: ../sp-epsf.c:148 +#, c-format +msgid "%s: malformed value for key `%s'\n" +msgstr "" + +#: ../sp-epsf.c:159 +#, c-format +msgid "%s: unknown key `%s' ignored\n" +msgstr "" + +#: ../sp-epsf.c:164 +#, c-format +msgid "%s: no argument for key `%s', using defaults\n" +msgstr "" + +#: ../sp-epsf.c:168 +#, c-format +msgid "%s: argument `%s' ignored for key `%s'\n" +msgstr "" + +#: ../special.c:242 +#, c-format +msgid "%s: tried to pop top level layer\n" +msgstr "" + +#: ../t1.c:182 +msgid "(t1) failed to reset device resolution\n" +msgstr "" + +#: ../t1.c:210 +#, c-format +msgid "%s: could not encode font\n" +msgstr "" + +#: ../t1.c:448 +#, c-format +msgid "(t1) unsupported bitmap pad size %d\n" +msgstr "" + +#: ../tfm.c:177 +#, c-format +msgid "%s: Checksum mismatch (got %u, expected %u)\n" +msgstr "" + +#: ../tfmfile.c:88 +#, c-format +msgid "%s: Error reading AFM data\n" +msgstr "" + +#: ../tfmfile.c:178 +#, c-format +msgid "Warning: TFM file `%s' has suspicious size\n" +msgstr "" + +#: ../tfmfile.c:228 ../tfmfile.c:509 +#, c-format +msgid "%s: font coding scheme truncated to 40 bytes\n" +msgstr "" + +#: ../tfmfile.c:288 ../tfmfile.c:588 +#, c-format +msgid "%s: File corrupted, or not a TFM file\n" +msgstr "" + +#: ../util.c:32 +msgid "Ooops!" +msgstr "" + +#: ../util.c:33 +msgid "Aieeeee!!" +msgstr "" + +#: ../util.c:34 +msgid "Ouch!" +msgstr "" + +#: ../util.c:35 +msgid "Houston, we have a problem" +msgstr "" + +#: ../util.c:36 +msgid "3.. 2.. 1.. BOOM!" +msgstr "" + +#: ../util.c:37 +msgid "I'm history" +msgstr "" + +#: ../util.c:38 +msgid "I'm going down" +msgstr "" + +#: ../util.c:39 +msgid "I smell a rat" +msgstr "" + +#: ../util.c:144 +msgid "Crashing" +msgstr "" + +#: ../util.c:154 +#, c-format +msgid "%s: Error: " +msgstr "" + +#: ../util.c:161 +msgid "Error" +msgstr "" + +#: ../util.c:170 +#, c-format +msgid "%s: Warning: " +msgstr "" + +#: ../util.c:177 +msgid "Warning" +msgstr "" + +#: ../util.c:186 +#, c-format +msgid "%s: Fatal: " +msgstr "" + +#: ../util.c:193 +msgid "Fatal" +msgstr "" + +#: ../util.c:207 +#, c-format +msgid "out of memory allocating %u bytes\n" +msgstr "" + +#: ../util.c:217 +msgid "attempted to reallocate with zero size\n" +msgstr "" + +#: ../util.c:220 +#, c-format +msgid "failed to reallocate %u bytes\n" +msgstr "" + +#: ../util.c:229 +msgid "attempted to callocate 0 members\n" +msgstr "" + +#: ../util.c:231 +#, c-format +msgid "attempted to callocate %u members with size 0\n" +msgstr "" + +#: ../util.c:235 +#, c-format +msgid "failed to allocate %ux%u bytes\n" +msgstr "" + +#: ../util.c:243 +msgid "attempted to free NULL pointer\n" +msgstr "" + +#: ../vf.c:81 +#, c-format +msgid "%s: Checksum mismatch (expected %u, got %u)\n" +msgstr "" + +#: ../vf.c:129 +#, c-format +msgid "(vf) %s: could not load font `%s'\n" +msgstr "" + +#: ../vf.c:179 +#, c-format +msgid "(vf) %s: character %d redefined\n" +msgstr "" + +#: ../vf.c:202 +#, c-format +msgid "(vf) %s: no postamble\n" +msgstr "" + +#: ../vf.c:228 +#, c-format +msgid "%s: File corrupted, or not a VF file.\n" +msgstr "" diff --git a/dviware/mdvi/lib/po/stamp-cat-id b/dviware/mdvi/lib/po/stamp-cat-id new file mode 100644 index 0000000000..9788f70238 --- /dev/null +++ b/dviware/mdvi/lib/po/stamp-cat-id @@ -0,0 +1 @@ +timestamp diff --git a/dviware/mdvi/lib/setup.c b/dviware/mdvi/lib/setup.c new file mode 100644 index 0000000000..c2436d8727 --- /dev/null +++ b/dviware/mdvi/lib/setup.c @@ -0,0 +1,381 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <ctype.h> + +#include "mdvi.h" +#include "private.h" + +char *_mdvi_fallback_font = NULL; + +int mdvi_get_pagesort(const char *spec) +{ + if(STRCEQ(spec, "up")) + return MDVI_PAGE_SORT_UP; + else if(STRCEQ(spec, "down")) + return MDVI_PAGE_SORT_DOWN; + else if(STRCEQ(spec, "random")) + return MDVI_PAGE_SORT_RANDOM; + else if(STRCEQ(spec, "dviup")) + return MDVI_PAGE_SORT_DVI_UP; + else if(STRCEQ(spec, "dvidown")) + return MDVI_PAGE_SORT_DVI_DOWN; + else if(STRCEQ(spec, "none")) + return MDVI_PAGE_SORT_NONE; + return -1; +} + +int mdvi_get_debugmask(const char *spec) +{ + const char *ptr, *text; + static char *masks[] = { + "opcodes", "fonts", + "files", "dvi", + "params", "special", + "device", "glyphs", + "bitmaps", "paths", + "search", "vars", + "bitops", "bitdata", + "type1", "tt", + "ft2", "fontmaps" + }; + int done = 0; + int mask = 0; + int i; + + for(ptr = text = spec; !done; ptr++) { + int len; + + if(*ptr && *ptr != '|' && *ptr != ',') + continue; + if(*ptr == 0) + done = 1; + len = ptr - text; + if(len == 0) + continue; + for(i = 0; masks[i]; i++) { + if(STRNEQ(masks[i], text, len)) { + mask |= (1 << i); + break; + } + } + if(!masks[i] && STRNEQ(text, "silent", len)) + mask |= DBG_SILENT; + text = ptr + 1; + } + return mask; +} + +DviOrientation mdvi_getorient(const char *s) +{ + if(STRCEQ(s, "TBLR") || + STRCEQ(s, "Portrait") || + STRCEQ(s, "TopLeft") || + STRCEQ(s, "top-left") || + STRCEQ(s, "tl")) + return MDVI_ORIENT_TBLR; + + if(STRCEQ(s, "TBRL") || + STRCEQ(s, "TopRight") || + STRCEQ(s, "top-right") || + STRCEQ(s, "tr")) + return MDVI_ORIENT_TBRL; + + if(STRCEQ(s, "BTLR") || + STRCEQ(s, "BottomLeft") || + STRCEQ(s, "bottom-left") || + STRCEQ(s, "bl")) + return MDVI_ORIENT_BTLR; + + if(STRCEQ(s, "BTRL") || + STRCEQ(s, "BottomRight") || + STRCEQ(s, "bottom-right") || + STRCEQ(s, "br")) + return MDVI_ORIENT_BTRL; + + if(STRCEQ(s, "RM90") || + STRCEQ(s, "Landscape") || + STRCEQ(s, "rotated-clockwise") || + STRCEQ(s, "rcw")) + return MDVI_ORIENT_RM90; + + if(STRCEQ(s, "RP90") || + STRCEQ(s, "Seascape") || + STRCEQ(s, "rotated-counter-clockwise") || + STRCEQ(s, "rccw")) + return MDVI_ORIENT_RP90; + + if(STRCEQ(s, "IRP90") || + STRCEQ(s, "FlipSeascape") || + STRCEQ(s, "flipped-seascape") || + STRCEQ(s, "frccw")) + return MDVI_ORIENT_IRP90; + + if(STRCEQ(s, "IRM90") || + STRCEQ(s, "FlipLandscape") || + STRCEQ(s, "flipped-landscape") || + STRCEQ(s, "frcw")) + return MDVI_ORIENT_IRM90; + + warning(_("unknown orientation `%s'\n"), s); + return MDVI_ORIENT_TBLR; +} + +/* + * this will try $NAME, and then `NAME' in texmf.cnf, with + * letters converted to lowercase, and _ replaced by - + * (so MDVI_HDRIFT -> mdvi-hdrift) + */ +char *mdvi_getenv(const char *name) +{ + static char kname[64]; + const char *ptr; + int i; + + if((ptr = getenv(name)) != NULL) + return (char *)ptr; + for(i = 0, ptr = name; *ptr; i++, ptr++) + kname[i] = (*ptr == '_' ? '-' : tolower(*ptr)); + kname[i] = 0; + return kpse_cnf_get(kname); +} + +int mdvi_getint(const char *name, long *value) +{ + long x; + char *end; + + errno = 0; + x = strtol(name, &end, 0); + if(errno || *end) + return -1; + if(value) *value = x; + return 0; +} + +int mdvi_getfloat(const char *name, double *value) +{ + long x; + char *end; + + errno = 0; + x = strtod(name, &end); + if(errno || *end) + return -1; + if(value) *value = x; + return 0; +} + +int mdvi_getenv_int(const char *name, int dflt) +{ + char *var = mdvi_getenv(name); + long x; + + if(var == NULL) { + DEBUG((DBG_VARS, "getenv_int: %s -> (nil)\n", + name)); + return dflt; + } + if(mdvi_getint(var, &x) == -1) { + warning(_("variable %s should be an integer\n"), name); + x = dflt; + } + DEBUG((DBG_VARS, "getenv_int: $%s -> %ld (\"%s\")\n", + name, x, var)); + return (int)x; +} + +char *mdvi_getenv_string(const char *name, char *dflt) +{ + char *var = mdvi_getenv(name); + + if(var == NULL) { + DEBUG((DBG_VARS, "getenv_string: %s -> (nil)\n", + name)); + return dflt; + } + DEBUG((DBG_VARS, "getenv_string: $%s -> \"%s\"\n", + name, var)); + return var; +} + +double mdvi_getenv_double(const char *name, double dflt) +{ + char *var = mdvi_getenv(name); + double x; + + if(var == NULL) { + DEBUG((DBG_VARS, "getenv_double: %s -> (nil)\n", + name)); + return dflt; + } + if(mdvi_getfloat(var, &x) == -1) { + warning(_("variable %s should be a floating-point number\n"), + name); + x = dflt; + } + DEBUG((DBG_VARS, "getenv_double: $%s -> %g (\"%s\")\n", + name, x, var)); + return x; +} + +DviAppConfig *mdvi_init_app(const char *program, const char *progid) +{ + DviAppConfig *app; + char *value; + + /* get kpathsea going -- we need it here */ + kpse_set_program_name(program, progid); + + app = xalloc(DviAppConfig); + + app->program = (char *)program; + value = strrchr(app->program, '/'); + if(value) + app->program = value + 1; + + /* get defaults from the environment */ + app->params.dpi = mdvi_getenv_int("MDVI_DPI", MDVI_DPI); + app->params.vdpi = mdvi_getenv_int("MDVI_VDPI", MDVI_VDPI); + app->params.mag = mdvi_getenv_double("MDVI_MAGNIFICATION", MDVI_MAGNIFICATION); + app->params.density = mdvi_getenv_int("MDVI_PIXEL_DENSITY", MDVI_DEFAULT_DENSITY); + app->params.gamma = mdvi_getenv_double("MDVI_GAMMA", MDVI_DEFAULT_GAMMA); + app->params.flags = MDVI_PARAM_ANTIALIASED; + app->params.hdrift = mdvi_getenv_int("MDVI_HDRIFT", -1); + app->params.vdrift = mdvi_getenv_int("MDVI_VDRIFT", -1); + app->params.hshrink = mdvi_getenv_int("MDVI_HSHRINK", -1); + app->params.vshrink = mdvi_getenv_int("MDVI_VSHRINK", -1); + value = mdvi_getenv_string("MDVI_ORIENTATION", MDVI_ORIENTATION); + app->params.orientation = mdvi_getorient(value); + app->fontspec = mdvi_getenv_string("MDVI_FONTSPEC", NULL); + app->fontunspec = mdvi_getenv_string("MDVI_FONTOMIT", NULL); + app->fgcolor = mdvi_getenv_string("MDVI_FOREGROUND", MDVI_FOREGROUND); + app->bgcolor = mdvi_getenv_string("MDVI_BACKGROUND", MDVI_BACKGROUND); + app->hmargin = mdvi_getenv_string("MDVI_HMARGIN", MDVI_HMARGIN); + app->vmargin = mdvi_getenv_string("MDVI_VMARGIN", MDVI_VMARGIN); + app->hrule_units = mdvi_getenv_string("MDVI_HRUNIT", MDVI_HRUNITS); + app->vrule_units = mdvi_getenv_string("MDVI_VRUNIT", MDVI_VRUNITS); + app->paper.name = mdvi_getenv_string("MDVI_PAPER", MDVI_PAPERNAME); + app->fallback_font = mdvi_getenv_string("MDVI_FALLBACK_FONT", MDVI_FALLBACK_FONT); + app->mfmode = mdvi_getenv_string("MDVI_MFMODE", MDVI_MFMODE); + app->page_sort = MDVI_PAGE_SORT_NONE; + app->page_ranges = NULL; + + if(app->params.hshrink == -1 && app->params.vshrink == -1) { + app->params.hshrink = + app->params.vshrink = mdvi_getenv_int("MDVI_SHRINKING", + MDVI_DEFAULT_SHRINKING); + } + return app; +} + +int mdvi_check_config(DviAppConfig *app) +{ + /* Check all the values */ + + if(mdvi_get_paper_size(app->paper.name, &app->paper) == -1) { + warning(_("%s: unknown paper `%s', using %s\n"), + app->program, app->paper.name, + MDVI_PAPERNAME); + mdvi_get_paper_size(MDVI_PAPERNAME, &app->paper); + } + + if(app->params.dpi == (Uint)-1) { + error(_("DPI must be a positive integer\n")); + return -1; + } + if(app->params.vdpi == (Uint)-1) + app->params.vdpi = app->params.dpi; + if(app->params.hshrink == -1) + app->params.hshrink = MDVI_SHRINK_FROM_DPI(app->params.dpi); + if(app->params.vshrink == -1) + app->params.vshrink = MDVI_SHRINK_FROM_DPI(app->params.dpi); + if(app->params.mag <= 0) { + error(_("magnification must be a positive number\n")); + return -1; + } + if(app->params.density < 0 || app->params.density > 100) { + warning(_("pixel density must be between 0 and 100\n")); + app->params.density = (app->params.density < 0) ? 0 : 100; + } + if(app->fgcolor == NULL) + app->fgcolor = "black"; + if(app->bgcolor == NULL) + app->bgcolor = "white"; + + /* we must have a fallback font */ + if(app->fallback_font == NULL) { + warning(_("no fallback font specified, using `%s'\n"), + MDVI_FALLBACK_FONT); + app->fallback_font = MDVI_FALLBACK_FONT; + } + + /* finish initializing kpathsea */ + kpse_init_prog(app->program, app->params.dpi, + app->mfmode, NULL); + kpse_set_program_enabled(kpse_any_glyph_format, 1, kpse_src_compile); + kpse_set_program_enabled(kpse_pk_format, 1, kpse_src_compile); + kpse_set_program_enabled(kpse_tfm_format, 1, kpse_src_compile); + kpse_set_program_enabled(kpse_ofm_format, 1, kpse_src_compile); + if(_mdvi_debug_mask & DBG_PATHS) + KPSE_DEBUG_SET(KPSE_DEBUG_PATHS); + if(_mdvi_debug_mask & DBG_VARS) + KPSE_DEBUG_SET(KPSE_DEBUG_VARS); + if(_mdvi_debug_mask & DBG_SEARCH) + KPSE_DEBUG_SET(KPSE_DEBUG_SEARCH); + + return 0; +} + +void mdvi_init_kpathsea(const char *program, + const char *mfmode, const char *font, int dpi) +{ + const char *p; + + + p = strrchr(program, '/'); + p = (p ? p + 1 : program); + kpse_set_program_name(program, p); + kpse_init_prog(p, dpi, mfmode, font); + kpse_set_program_enabled(kpse_any_glyph_format, + 1, kpse_src_compile); + kpse_set_program_enabled(kpse_pk_format, + 1, kpse_src_compile); + kpse_set_program_enabled(kpse_tfm_format, + 1, kpse_src_compile); + kpse_set_program_enabled(kpse_ofm_format, + 1, kpse_src_compile); +} + +void mdvi_set_fallback_font(const char *name) +{ + if(_mdvi_fallback_font) { + xfree(_mdvi_fallback_font); + _mdvi_fallback_font = NULL; + } + if(name) + _mdvi_fallback_font = xstrdup(name); +} + +char *mdvi_get_fallback_font(void) +{ + return _mdvi_fallback_font ? xstrdup(_mdvi_fallback_font) : NULL; +} diff --git a/dviware/mdvi/lib/sp-epsf.c b/dviware/mdvi/lib/sp-epsf.c new file mode 100644 index 0000000000..52fed74c82 --- /dev/null +++ b/dviware/mdvi/lib/sp-epsf.c @@ -0,0 +1,255 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* postscript specials */ + +#include <stdlib.h> +#include <string.h> + +#include "mdvi.h" +#include "private.h" + +typedef struct { + double ox; + double oy; + double bw; + double bh; + double angle; +} EpsfBox; + +#define LLX 0 +#define LLY 1 +#define URX 2 +#define URY 3 +#define RWI 4 +#define RHI 5 +#define HOFF 6 +#define VOFF 7 +#define HSIZE 8 +#define VSIZE 9 +#define HSCALE 10 +#define VSCALE 11 +#define ANGLE 12 +#define CLIP 13 + +/* Note: the given strings are modified in place */ +static char *parse_epsf_special(EpsfBox *box, char **ret, + char *prefix, char *arg) +{ + static struct { + char *name; + int has_arg; + char *value; + } keys[] = { + {"llx", 1, "0"}, + {"lly", 1, "0"}, + {"urx", 1, "0"}, + {"ury", 1, "0"}, + {"rwi", 1, "0"}, + {"rhi", 1, "0"}, + {"hoffset", 1, "0"}, + {"voffset", 1, "0"}, + {"hsize", 1, "612"}, + {"vsize", 1, "792"}, + {"hscale", 1, "100"}, + {"vscale", 1, "100"}, + {"angle", 1, "0"}, + {"clip", 0, "0"} + }; +#define NKEYS (sizeof(keys) / sizeof(keys[0])) + char *ptr; + char *filename; + int quoted; + double value[NKEYS]; + Uchar present[NKEYS]; + Buffer buffer; + char *name; + int i; + double originx; + double originy; + double hsize; + double vsize; + double hscale; + double vscale; + + /* this special has the form + * ["]file.ps["] [key=valye]* + */ + + /* scan the filename */ + while(*arg == ' ' || *arg == '\t') + arg++; + + /* make a copy of the string */ + ptr = arg; + + if(*ptr == '"') + for(name = ++ptr; *ptr && *ptr != '"'; ptr++); + else + for(name = ptr; *ptr && *ptr != ' ' && *ptr != '\t'; ptr++); + if(ptr == name) + return NULL; + *ptr++ = 0; + filename = name; + + /* reset values to defaults */ + for(i = 0; i < NKEYS; i++) { + value[i] = atof(keys[i].value); + present[i] = 0; + } + + buff_init(&buffer); + buff_add(&buffer, "@beginspecial ", 0); + + quoted = 0; + while(*ptr) { + const char *keyname; + char *val; + char *p; + + while(*ptr == ' ' || *ptr == '\t') + ptr++; + keyname = ptr; + + /* get the whole key=value pair */ + for(; *ptr && *ptr != ' ' && *ptr != '\t'; ptr++); + + if(*ptr) *ptr++ = 0; + /* now we shouldn't touch `ptr' anymore */ + + /* now work on this pair */ + p = strchr(keyname, '='); + if(p == NULL) + val = NULL; + else { + *p++ = 0; + if(*p == '"') { + val = ++p; + /* skip until closing quote */ + while(*p && *p != '"') + p++; + if(*p != '"') + warning( + _("%s: malformed value for key `%s'\n"), + filename, keyname); + } else + val = p; + } + + /* lookup the key */ + for(i = 0; i < NKEYS; i++) + if(STRCEQ(keys[i].name, keyname)) + break; + if(i == NKEYS) { + warning(_("%s: unknown key `%s' ignored\n"), + filename, keyname); + continue; + } + if(keys[i].has_arg && val == NULL) { + warning(_("%s: no argument for key `%s', using defaults\n"), + filename, keyname); + val = keys[i].value; + } else if(!keys[i].has_arg && val) { + warning(_("%s: argument `%s' ignored for key `%s'\n"), + filename, val, keyname); + val = NULL; + } + if(val) + value[i] = atof(val); + + /* put the argument */ + buff_add(&buffer, val, 0); + buff_add(&buffer, " @", 2); + buff_add(&buffer, keyname, 0); + buff_add(&buffer, " ", 1); + + /* remember that this option was given */ + present[i] = 0xff; + } + buff_add(&buffer, " @setspecial", 0); + + /* now compute the bounding box (code comes from dvips) */ + originx = 0; + originy = 0; + hscale = 1; + vscale = 1; + hsize = 0; + vsize = 0; + + if(present[HSIZE]) + hsize = value[HSIZE]; + if(present[VSIZE]) + vsize = value[VSIZE]; + if(present[HOFF]) + originx = value[HOFF]; + if(present[VOFF]) + originy = value[VOFF]; + if(present[HSCALE]) + hscale = value[HSCALE] / 100.0; + if(present[VSCALE]) + vscale = value[VSCALE] / 100.0; + if(present[URX] && present[LLX]) + hsize = value[URX] - value[LLX]; + if(present[URY] && present[LLY]) + vsize = value[URY] - value[LLY]; + if(present[RWI] || present[RHI]) { + if(present[RWI] && !present[RHI]) + hscale = vscale = value[RWI] / (10.0 * hsize); + else if(present[RHI] && !present[RWI]) + hscale = vscale = value[RHI] / (10.0 * vsize); + else { + hscale = value[RWI] / (10.0 * hsize); + vscale = value[RHI] / (10.0 * vsize); + } + } + + box->ox = originx; + box->oy = originy; + box->bw = hsize * hscale; + box->bh = vsize * vscale; + box->angle = value[ANGLE]; + + *ret = buffer.data; + + return filename; +} + +void epsf_special(DviContext *dvi, char *prefix, char *arg) +{ + char *file; + char *special; + EpsfBox box; + int x, y; + int w, h; + double xf, vf; + + file = parse_epsf_special(&box, &special, prefix, arg); + if(file != NULL) + xfree(special); + /* + * draw the bounding box. Notice that it is in PostScript units, + * so we have to convert it into pixels + */ + xf = dvi->params.dpi * dvi->params.mag / (72.0 * dvi->params.hshrink); + vf = dvi->params.vdpi * dvi->params.mag / (72.0 * dvi->params.vshrink); + x = FROUND(box.ox * xf); + y = FROUND(box.oy * vf); + w = FROUND(box.bw * xf); + h = FROUND(box.bh * vf); + dvi->device.draw_rule(dvi, dvi->pos.hh + x, dvi->pos.vv + y - h + 1, w, h, 0); +} diff --git a/dviware/mdvi/lib/special.c b/dviware/mdvi/lib/special.c new file mode 100644 index 0000000000..7188bd8ed5 --- /dev/null +++ b/dviware/mdvi/lib/special.c @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <ctype.h> +#include <string.h> + +#include "mdvi.h" +#include "private.h" + +#if defined(WITH_REGEX_SPECIALS) && defined(HAVE_REGEX_H) +#include <regex.h> +#endif + +typedef struct _DviSpecial { + struct _DviSpecial *next; + struct _DviSpecial *prev; + char *label; + char *prefix; + size_t plen; +#ifdef WITH_REGEX_SPECIALS + regex_t reg; + int has_reg; +#endif + DviSpecialHandler handler; +} DviSpecial; + +static ListHead specials = {NULL, NULL, 0}; + +#define SPECIAL(x) \ + void x __PROTO((DviContext *, const char *, const char *)) + +static SPECIAL(sp_layer); +extern SPECIAL(epsf_special); +extern SPECIAL(do_color_special); + +static struct { + char *label; + char *prefix; + char *regex; + DviSpecialHandler handler; +} builtins[] = { + {"Layers", "layer", NULL, sp_layer}, + {"EPSF", "psfile", NULL, epsf_special} +}; +#define NSPECIALS (sizeof(builtins) / sizeof(builtins[0])) +static int registered_builtins = 0; + +static void register_builtin_specials(void) +{ + int i; + + ASSERT(registered_builtins == 0); + for(i = 0; i < NSPECIALS; i++) + mdvi_register_special( + builtins[i].label, + builtins[i].prefix, + builtins[i].regex, + builtins[i].handler, + 1 /* replace if exists */); + registered_builtins = 1; +} + +static DviSpecial *find_special_prefix(const char *prefix) +{ + DviSpecial *sp; + + /* should have a hash table here, but I'm so lazy */ + for(sp = (DviSpecial *)specials.head; sp; sp = sp->next) { + if(STRCEQ(sp->prefix, prefix)) + break; + } + return sp; +} + +int mdvi_register_special(const char *label, const char *prefix, + const char *regex, DviSpecialHandler handler, int replace) +{ + DviSpecial *sp; + int newsp = 0; + + if(!registered_builtins) + register_builtin_specials(); + + sp = find_special_prefix(prefix); + if(sp == NULL) { + sp = xalloc(DviSpecial); + sp->prefix = xstrdup(prefix); + newsp = 1; + } else if(!replace) + return -1; + else { + xfree(sp->label); + sp->label = NULL; + } + +#ifdef WITH_REGEX_SPECIALS + if(!newsp && sp->has_reg) { + regfree(&sp->reg); + sp->has_reg = 0; + } + if(regex && regcomp(&sp->reg, regex, REG_NOSUB) != 0) { + if(newsp) { + xfree(sp->prefix); + xfree(sp); + } + return -1; + } + sp->has_reg = (regex != NULL); +#endif + sp->handler = handler; + sp->label = xstrdup(label); + sp->plen = strlen(prefix); + if(newsp) + listh_prepend(&specials, LIST(sp)); + DEBUG((DBG_SPECIAL, + "New \\special handler `%s' with prefix `%s'\n", + label, prefix)); + return 0; +} + +int mdvi_unregister_special(const char *prefix) +{ + DviSpecial *sp; + + sp = find_special_prefix(prefix); + if(sp == NULL) + return -1; + xfree(sp->prefix); +#ifdef WITH_REGEX_SPECIALS + if(sp->has_reg) + regfree(&sp->reg); +#endif + listh_remove(&specials, LIST(sp)); + xfree(sp); + return 0; +} + +#define IS_PREFIX_DELIMITER(x) (strchr(" \t\n:=", (x)) != NULL) + +int mdvi_do_special(DviContext *dvi, char *string) +{ + char *prefix; + char *ptr; + DviSpecial *sp; + + if(!registered_builtins) { + } + + if(!string || !*string) + return 0; + + /* skip leading spaces */ + while(*string && isspace(*string)) + string++; + + DEBUG((DBG_SPECIAL, "Looking for a handler for `%s'\n", string)); + + /* now try to find a match */ + ptr = string; + for(sp = (DviSpecial *)specials.head; sp; sp = sp->next) { +#ifdef WITH_REGEX_SPECIALS + if(sp->has_reg && !regexec(&sp->reg, ptr, 0, 0, 0)) + break; +#endif + /* check the prefix */ + if(STRNCEQ(sp->prefix, ptr, sp->plen)) { + ptr += sp->plen; + break; + } + } + + if(sp == NULL) { + DEBUG((DBG_SPECIAL, "None found\n")); + return -1; + } + + /* extract the prefix */ + if(ptr == string) { + prefix = NULL; + DEBUG((DBG_SPECIAL, + "REGEX match with `%s' (arg `%s')\n", + sp->label, ptr)); + } else { + if(*ptr) *ptr++ = 0; + prefix = string; + DEBUG((DBG_SPECIAL, + "PREFIX match with `%s' (prefix `%s', arg `%s')\n", + sp->label, prefix, ptr)); + } + + /* invoke the handler */ + sp->handler(dvi, prefix, ptr); + + return 0; +} + +void mdvi_flush_specials(void) +{ + DviSpecial *sp, *list; + + + for(list = (DviSpecial *)specials.head; (sp = list); ) { + list = sp->next; + if(sp->prefix) xfree(sp->prefix); + if(sp->label) xfree(sp->label); +#ifdef WITH_REGEX_SPECIALS + if(sp->has_reg) + regfree(&sp->reg); +#endif + xfree(sp); + } + specials.head = NULL; + specials.tail = NULL; + specials.count = 0; +} + +/* some builtin specials */ + +void sp_layer(DviContext *dvi, const char *prefix, const char *arg) +{ + if(STREQ("push", arg)) + dvi->curr_layer++; + else if(STREQ("pop", arg)) { + if(dvi->curr_layer) + dvi->curr_layer--; + else + warning(_("%s: tried to pop top level layer\n"), + dvi->filename); + } else if(STREQ("reset", arg)) + dvi->curr_layer = 0; + DEBUG((DBG_SPECIAL, "Layer level: %d\n", dvi->curr_layer)); +} + diff --git a/dviware/mdvi/lib/t1.c b/dviware/mdvi/lib/t1.c new file mode 100644 index 0000000000..bc2900b204 --- /dev/null +++ b/dviware/mdvi/lib/t1.c @@ -0,0 +1,634 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Type1 font support for MDVI + * + * We use T1lib only as a rasterizer, not to draw glyphs. + */ + +#include "mdvi.h" + +#ifdef WITH_TYPE1_FONTS + +#include <stdio.h> +#include <t1lib.h> +#include "private.h" + +static int t1lib_initialized = 0; + +typedef struct t1info { + struct t1info *next; + struct t1info *prev; + char *fontname; /* (short) name of this font */ + int t1id; /* T1lib's id for this font */ + int hasmetrics; /* have we processed this font? */ + TFMInfo *tfminfo; /* TFM data is shared */ + DviFontMapInfo mapinfo; + DviEncoding *encoding; +} T1Info; + +static void t1_font_remove __PROTO((T1Info *)); +static int t1_load_font __PROTO((DviParams *, DviFont *)); +static int t1_font_get_glyph __PROTO((DviParams *, DviFont *, int)); +static void t1_font_shrink_glyph + __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); +static void t1_free_data __PROTO((DviFont *)); +static void t1_reset_font __PROTO((DviFont *)); +static char *t1_lookup_font __PROTO((const char *, Ushort *, Ushort *)); + +/* only symbol exported by this file */ +DviFontInfo t1_font_info = { + "Type1", + 1, /* scaling supported by format */ + t1_load_font, + t1_font_get_glyph, + t1_font_shrink_glyph, + mdvi_shrink_glyph_grey, + t1_free_data, + t1_reset_font, + t1_lookup_font, /* lookup */ + kpse_type1_format, + NULL +}; + +/* this seems good enough for most DVI files */ +#define T1_HASH_SIZE 31 + +/* If these parameters change, we must delete all size information + * in all fonts, and reset the device resolutions in T1lib */ +static int t1lib_xdpi = -1; +static int t1lib_ydpi = -1; + +static ListHead t1fonts = {NULL, NULL, 0}; +static DviHashTable t1hash; + +/* Type1 fonts need their own `lookup' function. Here is how it works: + * First we try to find the font by its given name. If that fails, we + * query the font maps. A typical font map entry may contain the line + * + * ptmr8rn Times-Roman ".82 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc <ptmr + * + * which means: If you're looking for the font `ptmr8rn' load `Times-Roman' + * which is in `ptmr' instead, and extend it by 0.82 points, then reencode + * it with the vector TeXBase1Encoding from the file `8r.enc'. This will + * fail if the entry looks like this: + * + * ptmr8rn Times-Roman ".82 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc + * + * because to deal with this we would need to be able to locate the font file + * for the `Times-Roman' font ourselves, and that's beyond the scope of mdvi. + * But hey, we tried hard. + */ +char *t1_lookup_font(const char *name, Ushort *hdpi, Ushort *vdpi) +{ + char *filename; + char *newname; + const char *ext; + DviFontMapInfo info; + + DEBUG((DBG_TYPE1, "(t1) looking for `%s'\n", name)); + + /* first let's try the font we were asked for */ + filename = kpse_find_file(name, kpse_type1_format, 1); + if(filename != NULL) { + /* we got it */ + return filename; + } + + DEBUG((DBG_TYPE1, "(t1) %s: not found, querying font maps\n", name)); + /* now query the fontmap */ + if(mdvi_query_fontmap(&info, name) < 0) { + /* it's not there either */ + return NULL; + } + + /* check what we got */ + if(info.fullfile) { + DEBUG((DBG_TYPE1, "(t1) %s: found `%s' (cached)\n", + name, info.fullfile)); + /* this is a cached lookup */ + return xstrdup(info.fullfile); + } + + /* no file associated to this font? */ + if(info.fontfile == NULL) + return info.psname ? mdvi_ps_find_font(info.psname) : NULL; + + /* let's extract the extension */ + ext = file_extension(info.fontfile); + if(ext && !STREQ(ext, "pfa") && !STREQ(ext, "pfb")) { + DEBUG((DBG_TYPE1, + "(t1) %s: associated name `%s' is not Type1\n", + name, info.fontfile)); + /* it's not a Type1 font */ + return NULL; + } + + /* get the `base' name */ + if(ext) { + newname = xstrdup(name); + newname[ext - info.fontfile - 1] = 0; + } else + newname = (char *)name; /* we don't modify this */ + + /* look it up */ + DEBUG((DBG_TYPE1, "(t1) looking for `%s' on behalf of `%s'\n", + newname, name)); + filename = kpse_find_file(newname, kpse_type1_format, 1); + + /* we don't need this anymore */ + if(newname != name) + xfree(newname); + if(filename == NULL) { + DEBUG((DBG_TYPE1, "(t1) %s: not found\n", name)); + return NULL; + } + + DEBUG((DBG_TYPE1, "(t1) %s: found as `%s'\n", name, filename)); + /* got it! let's remember this */ + mdvi_add_fontmap_file(name, filename); + return filename; +} + +static void t1_reset_resolution(int xdpi, int ydpi) +{ + int i; + int nfonts; + + DEBUG((DBG_TYPE1, "(t1) resetting device resolution (current: (%d,%d))\n", + t1lib_xdpi, t1lib_ydpi)); + + nfonts = T1_Get_no_fonts(); + for(i = 0; i < nfonts; i++) + T1_DeleteAllSizes(i); + /* reset device resolutions */ + if(T1_SetDeviceResolutions((float)xdpi, (float)ydpi) < 0) + warning(_("(t1) failed to reset device resolution\n")); + else + DEBUG((DBG_TYPE1, + "(t1) reset successful, new resolution is (%d, %d)\n", + xdpi, ydpi)); + t1lib_xdpi = xdpi; + t1lib_ydpi = ydpi; +} + +static void t1_reset_font(DviFont *font) +{ + T1Info *info = (T1Info *)font->private; + + if(info == NULL) + return; + DEBUG((DBG_FONTS, "(t1) resetting font `%s'\n", font->fontname)); + /* just mark the font as not having metric info. It will be reset + * automatically later */ + info->hasmetrics = 0; +} + +static void t1_transform_font(T1Info *info) +{ + if(!info->hasmetrics && info->encoding != NULL) { + DEBUG((DBG_TYPE1, "(t1) %s: encoding with vector `%s'\n", + info->fontname, info->encoding->name)); + T1_DeleteAllSizes(info->t1id); + if(T1_ReencodeFont(info->t1id, info->encoding->vector) < 0) + warning(_("%s: could not encode font\n"), info->fontname); + } + if(info->mapinfo.slant) { + DEBUG((DBG_TYPE1, "(t1) %s: slanting by %.3f\n", + info->fontname, + MDVI_FMAP_SLANT(&info->mapinfo))); + T1_SlantFont(info->t1id, + MDVI_FMAP_SLANT(&info->mapinfo)); + } + if(info->mapinfo.extend) { + DEBUG((DBG_TYPE1, "(t1) %s: extending by %.3f\n", + info->fontname, + MDVI_FMAP_EXTEND(&info->mapinfo))); + T1_ExtendFont(info->t1id, + MDVI_FMAP_EXTEND(&info->mapinfo)); + } +} + +/* if this function is called, we really need this font */ +static int t1_really_load_font(DviParams *params, DviFont *font, T1Info *info) +{ + int i; + T1Info *old; + int t1id; + int copied; + int status; + + DEBUG((DBG_TYPE1, "(t1) really_load_font(%s)\n", info->fontname)); + + /* if the parameters changed, reset T1lib */ + if(t1lib_xdpi != params->dpi || t1lib_ydpi != params->vdpi) + t1_reset_resolution(params->dpi, params->vdpi); + + /* if we already have a T1lib id, do nothing */ + if(info->t1id != -1) { + info->hasmetrics = 1; + /* apply slant and extend again */ + t1_transform_font(info); + return 0; + } + + /* before we even attempt to load the font, make sure we have metric + * data for it */ + info->tfminfo = mdvi_ps_get_metrics(info->fontname); + if(info->tfminfo == NULL) { + DEBUG((DBG_FONTS, + "(t1) %s: no metric data, font ignored\n", + info->fontname)); + goto t1_error; + } + /* fix this */ + font->design = info->tfminfo->design; + + /* check if we have a font with this name (maybe at a different size) */ + old = (T1Info *)mdvi_hash_lookup(&t1hash, info->fontname); + if(old == info) { + /* let's avoid confusion */ + old = NULL; + } + if(old && old->t1id != -1) { + /* let's take advantage of T1lib's font sharing */ + t1id = T1_CopyFont(old->t1id); + DEBUG((DBG_TYPE1, "(t1) %s -> %d (CopyFont)\n", + info->fontname, t1id)); + copied = 1; + } else { + t1id = T1_AddFont(font->filename); + DEBUG((DBG_TYPE1, "(t1) %s -> %d (AddFont)\n", + info->fontname, t1id)); + copied = 0; + } + if(t1id < 0) + goto t1_error; + info->t1id = t1id; + + /* + * a minor optimization: If the old font in the hash table has + * not been loaded yet, replace it by this one, so we can use + * CopyFont later. + */ + if(old && old->t1id == -1) { + DEBUG((DBG_TYPE1, "(t1) font `%s' exchanged in hash table\n", + info->fontname)); + mdvi_hash_remove(&t1hash, old->fontname); + mdvi_hash_add(&t1hash, info->fontname, + info, MDVI_HASH_UNCHECKED); + } + + /* now let T1lib load it */ + if(!copied && T1_LoadFont(info->t1id) < 0) { + DEBUG((DBG_TYPE1, "(t1) T1_LoadFont(%d) failed with error %d\n", + info->t1id, T1_errno)); + goto t1_error; + } + DEBUG((DBG_TYPE1, "(t1) T1_LoadFont(%d) -> Ok\n", info->t1id)); + + /* get information from the fontmap */ + status = mdvi_query_fontmap(&info->mapinfo, info->fontname); + if(!status && info->mapinfo.encoding) + info->encoding = mdvi_request_encoding(info->mapinfo.encoding); + t1_transform_font(info); + + i = info->tfminfo->hic - info->tfminfo->loc + 1; + if(i != font->hic - font->loc + 1) { + /* reset to optimal size */ + font->chars = xrealloc(font->chars, i * sizeof(DviFontChar)); + } + + /* get the scaled characters metrics */ + get_tfm_chars(params, font, info->tfminfo, 0); + info->hasmetrics = 1; + + DEBUG((DBG_TYPE1, "(t1) font `%s' really-loaded\n", info->fontname)); + return 0; + +t1_error: + /* some error does not allows us to use this font. We need to reset + * the font structure, so the font system can try to read this + * font in a different class */ + + /* first destroy the private data */ + t1_font_remove(info); + /* now reset all chars -- this is the important part */ + xfree(font->chars); + font->chars = NULL; + font->loc = font->hic = 0; + return -1; +} + +static int init_t1lib(DviParams *params) +{ + int t1flags; + +#ifdef WORD_LITTLE_ENDIAN + /* try making T1lib use bitmaps in our format, but if this + * fails we'll convert the bitmap ourselves */ + T1_SetBitmapPad(BITMAP_BITS); +#endif + T1_SetDeviceResolutions((float)params->dpi, (float)params->vdpi); + t1flags = IGNORE_CONFIGFILE|IGNORE_FONTDATABASE|T1_NO_AFM; + if(DEBUGGING(TYPE1)) + t1flags |= LOGFILE; + if(T1_InitLib(t1flags) == NULL) + return (t1lib_initialized = -1); + if(DEBUGGING(TYPE1)) { + DEBUG((DBG_TYPE1, "T1lib debugging output saved in t1lib.log\n")); + T1_SetLogLevel(T1LOG_DEBUG); + } + /* initialize our hash table, but don't allocate memory for it + * until we use it */ + mdvi_hash_init(&t1hash); + DEBUG((DBG_TYPE1, "(t1) t1lib %s initialized -- resolution is (%d, %d), pad is %d bits\n", + T1_GetLibIdent(), params->dpi, params->vdpi, T1_GetBitmapPad())); + t1lib_initialized = 1; + t1lib_xdpi = params->dpi; + t1lib_ydpi = params->vdpi; + return 0; +} + +static int t1_load_font(DviParams *params, DviFont *font) +{ + T1Info *info; + int i; + + if(t1lib_initialized < 0) + return -1; + else if(t1lib_initialized == 0 && init_t1lib(params) < 0) + return -1; + + if(font->in != NULL) { + /* we don't need this */ + fclose(font->in); + font->in = NULL; + } + + info = xalloc(T1Info); + + /* + * mark the font as `unregistered' with T1lib. It will + * be added when we actually use it + */ + info->t1id = -1; + + /* add the font to our list */ + info->fontname = font->fontname; + info->hasmetrics = 0; + info->encoding = NULL; + info->mapinfo.psname = NULL; + info->mapinfo.encoding = NULL; + info->mapinfo.fontfile = NULL; + info->mapinfo.extend = 0; + info->mapinfo.slant = 0; + info->encoding = NULL; + + /* create the hash table if we have not done so yet */ + if(t1hash.nbucks == 0) + mdvi_hash_create(&t1hash, T1_HASH_SIZE); + mdvi_hash_add(&t1hash, info->fontname, info, MDVI_HASH_UNIQUE); + listh_append(&t1fonts, LIST(info)); + + font->private = info; + + /* reset everything */ + font->chars = xnalloc(DviFontChar, 256); + font->loc = 0; + font->hic = 255; + for(i = 0; i < 256; i++) { + font->chars[i].code = i; + font->chars[i].offset = 1; + font->chars[i].loaded = 0; + font->chars[i].glyph.data = NULL; + font->chars[i].shrunk.data = NULL; + font->chars[i].grey.data = NULL; + } + + return 0; +} + +#define GLYPH_WIDTH(g) \ + ((g)->metrics.rightSideBearing - (g)->metrics.leftSideBearing) +#define GLYPH_HEIGHT(g) \ + ((g)->metrics.ascent - (g)->metrics.descent) + +static inline BITMAP *t1_glyph_bitmap(GLYPH *glyph) +{ + BITMAP *bm; + int w, h; + + w = GLYPH_WIDTH(glyph); + h = GLYPH_HEIGHT(glyph); + + if(!w || !h) + return MDVI_GLYPH_EMPTY; + switch(glyph->bpp << 3) { + case 8: + bm = bitmap_convert_lsb8(glyph->bits, w, h); + break; + default: + warning(_("(t1) unsupported bitmap pad size %d\n"), + glyph->bpp); + bm = MDVI_GLYPH_EMPTY; + break; + } + return bm; +} + +static void t1_font_shrink_glyph(DviContext *dvi, DviFont *font, DviFontChar *ch, DviGlyph *dest) +{ + double size; + GLYPH *glyph; + T1Info *info; + T1_TMATRIX matrix; + + info = (T1Info *)font->private; + ASSERT(info != NULL); + + DEBUG((DBG_TYPE1, "(t1) shrinking glyph for character %d in `%s' (%d,%d)\n", + ch->code, font->fontname, ch->width, ch->height)); + size = (double)font->scale / (dvi->params.tfm_conv * 0x100000); + size = 72.0 * size / 72.27; + matrix.cxx = 1.0/(double)dvi->params.hshrink; + matrix.cyy = 1.0/(double)dvi->params.vshrink; + matrix.cxy = 0.0; + matrix.cyx = 0.0; + glyph = T1_SetChar(info->t1id, ch->code, (float)size, &matrix); + + dest->data = t1_glyph_bitmap(glyph); + dest->x = -glyph->metrics.leftSideBearing; + dest->y = glyph->metrics.ascent; + dest->w = GLYPH_WIDTH(glyph); + dest->h = GLYPH_HEIGHT(glyph); + +#ifndef NODEBUG + if(DEBUGGING(BITMAP_DATA)) { + DEBUG((DBG_BITMAP_DATA, + "(t1) %s: t1_shrink_glyph(%d): (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n", + ch->glyph.w, ch->glyph.h, ch->glyph.x, ch->glyph.y, + dest->w, dest->h, dest->x, dest->y)); + bitmap_print(stderr, (BITMAP *)dest->data); + } +#endif + /* transform the glyph - we could do this with t1lib, but we do + * it ourselves for now */ + font_transform_glyph(dvi->params.orientation, dest); +} + +static int t1_font_get_glyph(DviParams *params, DviFont *font, int code) +{ + T1Info *info = (T1Info *)font->private; + GLYPH *glyph; + DviFontChar *ch; + double size; + T1_TMATRIX matrix; + int dpi; + + ASSERT(info != NULL); + if(!info->hasmetrics && t1_really_load_font(params, font, info) < 0) + return -1; + ch = FONTCHAR(font, code); + if(!ch || !glyph_present(ch)) + return -1; + ch->loaded = 1; + if(!ch->width || !ch->height) { + ch->glyph.x = ch->x; + ch->glyph.y = ch->y; + ch->glyph.w = ch->width; + ch->glyph.h = ch->height; + ch->glyph.data = NULL; + return 0; + } + + /* load the glyph with T1lib (this is done only once for each glyph) */ + + /* get size in TeX points (tfm_conv includes dpi and magnification) */ + size = (double)font->scale / (params->tfm_conv * 0x100000); + /* and transform into PostScript points */ + size = 72.0 * size / 72.27; + + dpi = Max(font->hdpi, font->vdpi); + /* we don't want the glyph to be cached twice (once by us, another by + * T1lib), so we use an identity matrix to tell T1lib not to keep the + * glyph around */ + matrix.cxx = (double)font->hdpi / dpi; + matrix.cyy = (double)font->vdpi / dpi; + matrix.cxy = matrix.cyx = 0.0; + glyph = T1_SetChar(info->t1id, ch->code, (float)size, &matrix); + if(glyph == NULL) { + ch->glyph.x = ch->x; + ch->glyph.y = ch->y; + ch->glyph.w = ch->width; + ch->glyph.h = ch->height; + ch->glyph.data = NULL; + ch->missing = 1; + return 0; + } + /* and make it a bitmap */ + ch->glyph.data = t1_glyph_bitmap(glyph); + ch->glyph.x = -glyph->metrics.leftSideBearing; + ch->glyph.y = glyph->metrics.ascent; + ch->glyph.w = GLYPH_WIDTH(glyph); + ch->glyph.h = GLYPH_HEIGHT(glyph); + + /* let's also fix the glyph's origin + * (which is not contained in the TFM) */ + ch->x = ch->glyph.x; + ch->y = ch->glyph.y; + /* let's fix these too */ + ch->width = ch->glyph.w; + ch->height = ch->glyph.h; + + return 0; +} + +static void t1_font_remove(T1Info *info) +{ + T1Info *old; + + /* first remove it from our list */ + listh_remove(&t1fonts, LIST(info)); + + /* it it's in the hash table, we may need to replace this by another font */ + old = (T1Info *)mdvi_hash_lookup(&t1hash, info->fontname); + if(old == info) { + mdvi_hash_remove(&t1hash, info->fontname); + /* go through the list and see if there is another + * font with this name */ + for(old = (T1Info *)t1fonts.head; old; old = old->next) + if(STREQ(old->fontname, info->fontname)) + break; + if(old != NULL) + mdvi_hash_add(&t1hash, old->fontname, old, + MDVI_HASH_UNCHECKED); + } + /* release our encoding vector */ + if(info->encoding) { + DEBUG((DBG_TYPE1, "(t1) %s: releasing vector `%s'\n", + info->fontname, info->encoding->name)); + mdvi_release_encoding(info->encoding, 1); + } + + /* now get rid of it */ + if(info->t1id != -1) { + DEBUG((DBG_TYPE1, "(t1) %s: T1_DeleteFont(%d)\n", + info->fontname, info->t1id)); + T1_DeleteFont(info->t1id); + } else + DEBUG((DBG_TYPE1, "(t1) %s: not loaded yet, DeleteFont skipped\n", + info->fontname)); + + if(info->tfminfo) + free_font_metrics(info->tfminfo); + /*xfree(info->fontname);*/ + xfree(info); +} + +static void t1_free_data(DviFont *font) +{ + /* called after all the glyphs are destroyed */ + + if(font->private == NULL) { + /* this is perfectly normal, it just means the font has + * not been requested by MDVI yet */ + return; + } + + /* destroy this data */ + + t1_font_remove((T1Info *)font->private); + font->private = NULL; + + /* + * if this is the last T1 font, reset the T1 library + * It is important that we do this, because this is will be called + * when the resolution or the magnification changes. + */ + if(t1fonts.count == 0) { + DEBUG((DBG_TYPE1, "(t1) last font removed -- closing T1lib\n")); + T1_CloseLib(); + t1lib_initialized = 0; + t1lib_xdpi = -1; + t1lib_ydpi = -1; + } +} + +#endif /* WITH_TYPE1_FONTS */ diff --git a/dviware/mdvi/lib/tfm.c b/dviware/mdvi/lib/tfm.c new file mode 100644 index 0000000000..6cc82abf1d --- /dev/null +++ b/dviware/mdvi/lib/tfm.c @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "mdvi.h" +#include "private.h" + +static int tfm_load_font __PROTO((DviParams *, DviFont *)); +static int tfm_font_get_glyph __PROTO((DviParams *, DviFont *, int)); + +DviFontInfo tfm_font_info = { + "TFM", + 0, /* scaling not supported by format */ + tfm_load_font, + tfm_font_get_glyph, + mdvi_shrink_box, + mdvi_shrink_box, + NULL, /* free */ + NULL, /* reset */ + NULL, /* lookup */ + kpse_tfm_format, + NULL +}; + +DviFontInfo ofm_font_info = { + "OFM", + 0, /* scaling not supported by format */ + tfm_load_font, + tfm_font_get_glyph, + mdvi_shrink_box, + mdvi_shrink_box, + NULL, /* free */ + NULL, /* reset */ + NULL, /* lookup */ + kpse_ofm_format, + NULL +}; + +DviFontInfo afm_font_info = { + "AFM", + 0, /* scaling not supported by format */ + tfm_load_font, + tfm_font_get_glyph, + mdvi_shrink_box, + mdvi_shrink_box, + NULL, /* free */ + NULL, /* reset */ + NULL, /* lookup */ + kpse_afm_format, + NULL +}; + +#define TYPENAME(font) \ + ((font)->search.info ? (font)->search.info : "none") + +/* + * Although it does not seem that way, this conversion is independent of the + * shrinking factors, within roundoff (that's because `conv' and `vconv' + * have already been scaled by hshrink and vshrink, repsectively). We + * should really use `dviconv' and `dvivconv', but I'm not so sure those + * should be moved to the DviParams structure. + */ +#define XCONV(x) FROUND(params->conv * (x) * params->hshrink) +#define YCONV(y) FROUND(params->vconv * (y) * params->vshrink) + +/* this is used quite often in several places, so I made it standalone */ +int get_tfm_chars(DviParams *params, DviFont *font, TFMInfo *info, int loaded) +{ + Int32 z, alpha, beta; + int n; + DviFontChar *ch; + TFMChar *ptr; + + n = info->hic - info->loc + 1; + if(n != FONT_GLYPH_COUNT(font)) { + font->chars = xrealloc(font->chars, + n * sizeof(DviFontChar)); + } + font->loc = info->loc; + font->hic = info->hic; + ch = font->chars; + ptr = info->chars; + + /* Prepare z, alpha and beta for TFM width computation */ + TFMPREPARE(font->scale, z, alpha, beta); + + /* get the character metrics */ + for(n = info->loc; n <= info->hic; ch++, ptr++, n++) { + int a, b, c, d; + + ch->offset = ptr->present; + if(ch->offset == 0) + continue; + /* this is what we came here for */ + ch->tfmwidth = TFMSCALE(z, ptr->advance, alpha, beta); + /* scale all other TFM units (so they are in DVI units) */ + a = TFMSCALE(z, ptr->left, alpha, beta); + b = TFMSCALE(z, ptr->right, alpha, beta); + c = TFMSCALE(z, ptr->height, alpha, beta); + d = TFMSCALE(z, ptr->depth, alpha, beta); + + /* now convert to unscaled pixels */ + ch->width = XCONV(b - a); + ch->height = YCONV(c - d); + if(ch->height < 0) ch->height = -ch->height; + ch->x = XCONV(a); + ch->y = YCONV(c); + /* + * the offset is not used, but we might as well set it to + * something meaningful (and it MUST be non-zero) + */ + ch->flags = 0; + ch->code = n; + ch->glyph.data = NULL; + ch->grey.data = NULL; + ch->shrunk.data = NULL; + ch->loaded = loaded; + } + + return 0; +} + +/* + * We use this function as a last resort to find the character widths in a + * font The DVI rendering code can correctly skip over a glyph if it knows + * its TFM width, which is what we try to find here. + */ +static int tfm_load_font(DviParams *params, DviFont *font) +{ + TFMInfo *tfm; + int type; + + switch(font->search.info->kpse_type) { + case kpse_tfm_format: + type = DviFontTFM; + break; + case kpse_afm_format: + type = DviFontAFM; + break; + case kpse_ofm_format: + type = DviFontOFM; + break; + default: + return -1; + } + + /* we don't need this */ + if(font->in) { + fclose(font->in); + font->in = NULL; + } + tfm = get_font_metrics(font->fontname, type, font->filename); + if(tfm == NULL) + return -1; + + if(tfm->checksum && font->checksum && tfm->checksum != font->checksum) { + warning(_("%s: Checksum mismatch (got %u, expected %u)\n"), + font->fontname, (unsigned)tfm->checksum, + (unsigned)font->checksum); + } + font->checksum = tfm->checksum; + font->design = tfm->design; + font->loc = 0; + font->hic = 0; + font->chars = NULL; + get_tfm_chars(params, font, tfm, 1); + + /* free everything */ + free_font_metrics(tfm); + + return 0; +} + +static int tfm_font_get_glyph(DviParams *params, DviFont *font, int code) +{ + DviFontChar *ch; + + ch = FONTCHAR(font, code); + if(!glyph_present(ch)) + return -1; + ch->glyph.x = ch->x; + ch->glyph.y = ch->y; + ch->glyph.w = ch->width; + ch->glyph.h = ch->height; + /* + * This has two purposes: (1) avoid unnecessary calls to this function, + * and (2) detect when the glyph data for a TFM font is actually used + * (we'll get a SEGV). Any occurrence of that is a bug. + */ + ch->glyph.data = MDVI_GLYPH_EMPTY; + + return 0; +} diff --git a/dviware/mdvi/lib/tfmfile.c b/dviware/mdvi/lib/tfmfile.c new file mode 100644 index 0000000000..b91e931668 --- /dev/null +++ b/dviware/mdvi/lib/tfmfile.c @@ -0,0 +1,744 @@ +/* tfmfile.c -- readers for TFM, AFM, OTFM-0 and OTFM-1 files */ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> /* tex-file.h needs this */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "mdvi.h" +#include "private.h" + +#ifdef WITH_AFM_FILES +#undef TRUE +#undef FALSE +#include "afmparse.h" +#endif + +typedef struct tfmpool { + struct tfmpool *next; + struct tfmpool *prev; + char *short_name; + int links; + TFMInfo tfminfo; +} TFMPool; + +static ListHead tfmpool = {NULL, NULL, 0}; +static DviHashTable tfmhash; + +#define TFM_HASH_SIZE 31 + +#ifdef WORD_LITTLE_ENDIAN +static inline void swap_array(Uint32 *ptr, int n) +{ + Uint32 i; + + while(n-- > 0) { + i = *ptr; + *ptr++ = ((i & 0xff000000) >> 24) + | ((i & 0x00ff0000) >> 8) + | ((i & 0x0000ff00) << 8) + | ((i & 0x000000ff) << 24); + } +} +#endif + +#ifdef WITH_AFM_FILES + +/* reading of AFM files */ +/* macro to convert between AFM and TFM units */ +#define AFM2TFM(x) FROUND((double)(x) * 0x100000 / 1000) +int afm_load_file(const char *filename, TFMInfo *info) +{ + /* the information we want is: + * - tfmwidth + * - width and heights + * - character origins + */ + FontInfo *fi = NULL; + int status; + CharMetricInfo *cm; + FILE *in; + + in = fopen(filename, "r"); + if(in == NULL) + return -1; + status = afm_parse_file(in, &fi, P_GM); + fclose(in); + + if(status != ok) { + error(_("%s: Error reading AFM data\n"), filename); + return -1; + } + + /* aim high */ + info->chars = xnalloc(TFMChar, 256); + info->loc = 256; + info->hic = 0; + info->design = 0xa00000; /* fake -- 10pt */ + info->checksum = 0; /* no checksum */ + info->type = DviFontAFM; + xstrncpy(info->coding, fi->gfi->encodingScheme, 63); + xstrncpy(info->family, fi->gfi->familyName, 63); + + /* now get the data */ + for(cm = fi->cmi; cm < fi->cmi + fi->numOfChars; cm++) { + int code; + TFMChar *ch; + + code = cm->code; + if(code < 0 || code > 255) + continue; /* ignore it */ + ch = &info->chars[code]; + ch->present = 1; + if(code < info->loc) + info->loc = code; + if(code > info->hic) + info->hic = code; + ch->advance = AFM2TFM(cm->wx); + /* this is the `leftSideBearing' */ + ch->left = AFM2TFM(cm->charBBox.llx); + /* this is the height (ascent - descent) -- the sign is to follow + * TeX conventions, as opposed to Adobe's ones */ + ch->depth = -AFM2TFM(cm->charBBox.lly); + /* this is the width (rightSideBearing - leftSideBearing) */ + ch->right = AFM2TFM(cm->charBBox.urx); + /* this is the `ascent' */ + ch->height = AFM2TFM(cm->charBBox.ury); + } + + /* we don't need this anymore */ + afm_free_fontinfo(fi); + + /* optimize storage */ + if(info->loc > 0 || info->hic < 256) { + memmove(&info->chars[0], + &info->chars[info->loc], + (info->hic - info->loc + 1) * sizeof(TFMChar)); + info->chars = xrealloc(info->chars, + (info->hic - info->loc + 1) * sizeof(TFMChar)); + } + + /* we're done */ + return 0; +} + +#endif /* WITH_AFM_FILES */ + +int tfm_load_file(const char *filename, TFMInfo *info) +{ + int lf, lh, bc, ec, nw, nh, nd, ne; + int i, n; + Uchar *tfm; + Uchar *ptr; + struct stat st; + int size; + FILE *in; + Int32 *cb; + Int32 *charinfo; + Int32 *widths; + Int32 *heights; + Int32 *depths; + Uint32 checksum; + + in = fopen(filename, "r"); + if(in == NULL) + return -1; + tfm = NULL; + + DEBUG((DBG_FONTS, "(mt) reading TFM file `%s'\n", + filename)); + /* We read the entire TFM file into core */ + if(fstat(fileno(in), &st) < 0) + return -1; + if(st.st_size == 0) + goto bad_tfm; + + /* allocate a word-aligned buffer to hold the file */ + size = 4 * ROUND(st.st_size, 4); + if(size != st.st_size) + warning(_("Warning: TFM file `%s' has suspicious size\n"), + filename); + tfm = (Uchar *)xmalloc(size); + if(fread(tfm, st.st_size, 1, in) != 1) + goto error; + /* we don't need this anymore */ + fclose(in); + in = NULL; + + /* not a checksum, but serves a similar purpose */ + checksum = 0; + + ptr = tfm; + /* get the counters */ + lf = muget2(ptr); + lh = muget2(ptr); checksum += 6 + lh; + bc = muget2(ptr); + ec = muget2(ptr); checksum += ec - bc + 1; + nw = muget2(ptr); checksum += nw; + nh = muget2(ptr); checksum += nh; + nd = muget2(ptr); checksum += nd; + checksum += muget2(ptr); /* skip italics correction count */ + checksum += muget2(ptr); /* skip lig/kern table size */ + checksum += muget2(ptr); /* skip kern table size */ + ne = muget2(ptr); checksum += ne; + checksum += muget2(ptr); /* skip # of font parameters */ + + size = ec - bc + 1; + cb = (Int32 *)tfm; cb += 6 + lh; + charinfo = cb; cb += size; + widths = cb; cb += nw; + heights = cb; cb += nh; + depths = cb; + + if(widths[0] || heights[0] || depths[0] || + checksum != lf || bc - 1 > ec || ec > 255 || ne > 256) + goto bad_tfm; + + /* from this point on, no error checking is done */ + + /* now we're at the header */ + /* get the checksum */ + info->checksum = muget4(ptr); + /* get the design size */ + info->design = muget4(ptr); + /* get the coding scheme */ + if(lh > 2) { + /* get the coding scheme */ + i = n = msget1(ptr); + if(n < 0 || n > 39) { + warning(_("%s: font coding scheme truncated to 40 bytes\n"), + filename); + n = 39; + } + memcpy(info->coding, ptr, n); + info->coding[n] = 0; + ptr += i; + } else + strcpy(info->coding, "FontSpecific"); + /* get the font family */ + if(lh > 12) { + n = msget1(ptr); + if(n > 0) { + i = Max(n, 63); + memcpy(info->family, ptr, i); + info->family[i] = 0; + } else + strcpy(info->family, "unspecified"); + ptr += n; + } + /* now we don't read from `ptr' anymore */ + + info->loc = bc; + info->hic = ec; + info->type = DviFontTFM; + + /* allocate characters */ + info->chars = xnalloc(TFMChar, size); + + +#ifdef WORD_LITTLE_ENDIAN + /* byte-swap the three arrays at once (they are consecutive in memory) */ + swap_array((Uint32 *)widths, nw + nh + nd); +#endif + + /* get the relevant data */ + ptr = (Uchar *)charinfo; + for(i = bc; i <= ec; ptr += 3, i++) { + int ndx; + + ndx = (int)*ptr; ptr++; + info->chars[i-bc].advance = widths[ndx]; + /* TFM files lack this information */ + info->chars[i-bc].left = 0; + info->chars[i-bc].right = widths[ndx]; + info->chars[i-bc].present = (ndx != 0); + if(ndx) { + ndx = ((*ptr >> 4) & 0xf); + info->chars[i-bc].height = heights[ndx]; + ndx = (*ptr & 0xf); + info->chars[i-bc].depth = depths[ndx]; + } + } + + /* free everything */ + xfree(tfm); + + return 0; + +bad_tfm: + error(_("%s: File corrupted, or not a TFM file\n"), filename); +error: + if(tfm) xfree(tfm); + if(in) fclose(in); + return -1; +} + +static int ofm1_load_file(FILE *in, TFMInfo *info) +{ + int lf, lh, bc, ec, nw, nh, nd; + int nco, ncw, npc; + int i; + int n; + int size; + Int32 *tfm; + Int32 *widths; + Int32 *heights; + Int32 *depths; + TFMChar *tch; + TFMChar *end; + + lf = fuget4(in); + lh = fuget4(in); + bc = fuget4(in); + ec = fuget4(in); + nw = fuget4(in); + nh = fuget4(in); + nd = fuget4(in); + fuget4(in); /* italics */ + fuget4(in); /* lig-kern */ + fuget4(in); /* kern */ + fuget4(in); /* extensible recipe */ + fuget4(in); /* parameters */ + fuget4(in); /* direction */ + nco = fuget4(in); + ncw = fuget4(in); + npc = fuget4(in); + + /* get the checksum */ + info->checksum = fuget4(in); + /* the design size */ + info->design = fuget4(in); + /* get the coding scheme */ + if(lh > 2) { + /* get the coding scheme */ + i = n = fsget1(in); + if(n < 0 || n > 39) + n = 39; + fread(info->coding, 39, 1, in); + info->coding[n] = 0; + } else + strcpy(info->coding, "FontSpecific"); + /* get the font family */ + if(lh > 12) { + n = fsget1(in); + if(n > 0) { + i = Max(n, 63); + fread(info->family, i, 1, in); + info->family[i] = 0; + } else + strcpy(info->family, "unspecified"); + } + tfm = NULL; + + /* jump to the beginning of the char-info table */ + fseek(in, 4L*nco, SEEK_SET); + + size = ec - bc + 1; + info->loc = bc; + info->hic = ec; + info->chars = xnalloc(TFMChar, size); + end = info->chars + size; + + for(tch = info->chars, i = 0; i < ncw; i++) { + TFMChar ch; + int nr; + + /* in the characters we store the actual indices */ + ch.advance = fuget2(in); + ch.height = fuget1(in); + ch.depth = fuget1(in); + /* skip 2nd word */ + fuget4(in); + /* get # of repeats */ + nr = fuget2(in); + /* skip parameters */ + fseek(in, (long)npc * 2, SEEK_CUR); + /* if npc is odd, skip padding */ + if(npc & 1) fuget2(in); + + /* now repeat the character */ + while(nr-- >= 0 && tch < end) + memcpy(tch++, &ch, sizeof(TFMChar)); + if(tch == end) + goto bad_tfm; + } + + /* I wish we were done, but we aren't */ + + /* get the widths, heights and depths */ + size = nw + nh + nd; + tfm = xnalloc(Int32, size); + /* read them in one sweep */ + if(fread(tfm, 4, size, in) != size) { + xfree(tfm); + goto bad_tfm; + } + + /* byte-swap things if necessary */ +#ifdef WORD_LITTLE_ENDIAN + swap_array((Uint32 *)tfm, size); +#endif + widths = tfm; + heights = widths + nw; + depths = heights + nh; + + if(widths[0] || heights[0] || depths[0]) + goto bad_tfm; + + /* now fix the characters */ + size = ec - bc + 1; + for(tch = info->chars; tch < end; tch++) { + tch->present = (tch->advance != 0); + tch->advance = widths[tch->advance]; + tch->height = heights[tch->height]; + tch->depth = depths[tch->depth]; + tch->left = 0; + tch->right = tch->advance; + } + + /* NOW we're done */ + xfree(tfm); + return 0; + +bad_tfm: + if(tfm) xfree(tfm); + return -1; +} + +/* we don't read OFM files into memory, because they can potentially be large */ +int ofm_load_file(const char *filename, TFMInfo *info) +{ + int lf, lh, bc, ec, nw, nh, nd; + int i, n; + Int32 *tfm; + Uchar *ptr; + int size; + FILE *in; + Int32 *cb; + Int32 *charinfo; + Int32 *widths; + Int32 *heights; + Int32 *depths; + Uint32 checksum; + int olevel; + int nwords; + + in = fopen(filename, "r"); + if(in == NULL) + return -1; + + /* not a checksum, but serves a similar purpose */ + checksum = 0; + + /* get the counters */ + /* get file level */ + olevel = fsget2(in); + if(olevel != 0) + goto bad_tfm; + olevel = fsget2(in); + if(olevel != 0) { + DEBUG((DBG_FONTS, "(mt) reading Level-1 OFM file `%s'\n", + filename)); + /* we handle level-1 files separately */ + if(ofm1_load_file(in, info) < 0) + goto bad_tfm; + return 0; + } + + DEBUG((DBG_FONTS, "(mt) reading Level-0 OFM file `%s'\n", filename)); + nwords = 14; + lf = fuget4(in); checksum = nwords; + lh = fuget4(in); checksum += lh; + bc = fuget4(in); + ec = fuget4(in); checksum += 2 * (ec - bc + 1); + nw = fuget4(in); checksum += nw; + nh = fuget4(in); checksum += nh; + nd = fuget4(in); checksum += nd; + checksum += fuget4(in); /* skip italics correction count */ + checksum += 2*fuget4(in); /* skip lig/kern table size */ + checksum += fuget4(in); /* skip kern table size */ + checksum += 2*fuget4(in); /* skip extensible recipe count */ + checksum += fuget4(in); /* skip # of font parameters */ + + /* I have found several .ofm files that seem to have the + * font-direction word missing, so we try to detect that here */ + if(checksum == lf + 1) { + DEBUG((DBG_FONTS, "(mt) font direction missing in `%s'\n", + filename)); + checksum--; + nwords--; + } else { + /* skip font direction */ + fuget4(in); + } + + if(checksum != lf || bc > ec + 1 || ec > 65535) + goto bad_tfm; + + /* now we're at the header */ + + /* get the checksum */ + info->checksum = fuget4(in); + /* get the design size */ + info->design = fuget4(in); + + /* get the coding scheme */ + if(lh > 2) { + /* get the coding scheme */ + i = n = fsget1(in); + if(n < 0 || n > 39) { + warning(_("%s: font coding scheme truncated to 40 bytes\n"), + filename); + n = 39; + } + fread(info->coding, 39, 1, in); + info->coding[n] = 0; + ptr += i; + } else + strcpy(info->coding, "FontSpecific"); + /* get the font family */ + if(lh > 12) { + n = fsget1(in); + if(n > 0) { + i = Max(n, 63); + fread(info->family, i, 1, in); + info->family[i] = 0; + } else + strcpy(info->family, "unspecified"); + } + + /* now skip anything else in the header */ + fseek(in, 4L*(nwords + lh), SEEK_SET); + /* and read everything at once */ + size = 2*(ec - bc + 1) + nw + nh + nd; + tfm = xnalloc(Int32, size * sizeof(Int32)); + if(fread(tfm, 4, size, in) != size) { + xfree(tfm); + goto bad_tfm; + } + /* byte-swap all the tables at once */ +#ifdef WORD_LITTLE_ENDIAN + swap_array((Uint32 *)tfm, size); +#endif + cb = tfm; + charinfo = cb; cb += 2*(ec - bc + 1); + widths = cb; cb += nw; + heights = cb; cb += nh; + depths = cb; + + if(widths[0] || heights[0] || depths[0]) { + xfree(tfm); + goto bad_tfm; + } + + /* from this point on, no error checking is done */ + + /* we don't need this anymore */ + fclose(in); + + /* now we don't read from `ptr' anymore */ + + info->loc = bc; + info->hic = ec; + info->type = DviFontTFM; + + /* allocate characters */ + info->chars = xnalloc(TFMChar, size); + + /* get the relevant data */ + ptr = (Uchar *)charinfo; + for(i = bc; i <= ec; ptr += 4, i++) { + int ndx; + + ndx = muget2(ptr); + info->chars[i-bc].advance = widths[ndx]; + /* TFM files lack this information */ + info->chars[i-bc].left = 0; + info->chars[i-bc].right = widths[ndx]; + info->chars[i-bc].present = (ndx != 0); + ndx = muget1(ptr); + info->chars[i-bc].height = heights[ndx]; + ndx = muget1(ptr); + info->chars[i-bc].depth = depths[ndx]; + } + + xfree(tfm); + return 0; + +bad_tfm: + error(_("%s: File corrupted, or not a TFM file\n"), filename); + fclose(in); + return -1; +} + +char *lookup_font_metrics(const char *name, int *type) +{ + char *file; + + switch(*type) { +#ifndef WITH_AFM_FILES + case DviFontAny: +#endif + case DviFontTFM: + file = kpse_find_tfm(name); + break; + case DviFontOFM: { + file = kpse_find_ofm(name); + /* we may have gotten a TFM back */ + if(file != NULL) { + const char *ext = file_extension(file); + if(ext && STREQ(ext, "tfm")) + *type = DviFontTFM; + } + break; + } +#ifdef WITH_AFM_FILES + case DviFontAFM: + file = kpse_find_file(name, kpse_afm_format, 0); + break; + case DviFontAny: + file = kpse_find_file(name, kpse_afm_format, 0); + *type = DviFontAFM; + if(file == NULL) { + file = kpse_find_tfm(name); + *type = DviFontTFM; + } + break; +#endif + default: + return NULL; + } + + return file; +} + +/* + * The next two functions are just wrappers for the font metric loaders, + * and use the pool of TFM data + */ + +/* this is how we interpret arguments: + * - if filename is NULL, we look for files of the given type, + * unless type is DviFontAny, in which case we try all the + * types we know of. + * - if filename is not NULL, we look at `type' to decide + * how to read the file. If type is DviFontAny, we just + * return an error. + */ +TFMInfo *get_font_metrics(const char *short_name, int type, const char *filename) +{ + TFMPool *tfm = NULL; + int status; + char *file; + + if(tfmpool.count) { + tfm = (TFMPool *)mdvi_hash_lookup(&tfmhash, + MDVI_KEY(short_name)); + if(tfm != NULL) { + DEBUG((DBG_FONTS, "(mt) reusing metric file `%s' (%d links)\n", + short_name, tfm->links)); + tfm->links++; + return &tfm->tfminfo; + } + } + + file = filename ? (char *)filename : lookup_font_metrics(short_name, &type); + if(file == NULL) + return NULL; + + tfm = xalloc(TFMPool); + DEBUG((DBG_FONTS, "(mt) loading font metric data from `%s'\n", file, file)); + switch(type) { + case DviFontTFM: + status = tfm_load_file(file, &tfm->tfminfo); + break; + case DviFontOFM: + status = ofm_load_file(file, &tfm->tfminfo); + break; +#ifdef WITH_AFM_FILES + case DviFontAFM: + status = afm_load_file(file, &tfm->tfminfo); + break; +#endif + default: + status = -1; + break; + } + if(file != filename) + xfree(file); + if(status < 0) { + xfree(tfm); + return NULL; + } + tfm->short_name = xstrdup(short_name); + + /* add it to the pool */ + if(tfmpool.count == 0) + mdvi_hash_create(&tfmhash, TFM_HASH_SIZE); + mdvi_hash_add(&tfmhash, MDVI_KEY(tfm->short_name), + tfm, MDVI_HASH_UNCHECKED); + listh_prepend(&tfmpool, LIST(tfm)); + tfm->links = 1; + + return &tfm->tfminfo; +} + +void free_font_metrics(TFMInfo *info) +{ + TFMPool *tfm; + + if(tfmpool.count == 0) + return; + /* get the entry -- can't use the hash table for this, because + * we don't have the short name */ + for(tfm = (TFMPool *)tfmpool.head; tfm; tfm = tfm->next) + if(info == &tfm->tfminfo) + break; + if(tfm == NULL) + return; + if(--tfm->links > 0) { + DEBUG((DBG_FONTS, "(mt) %s not removed, still in use\n", + tfm->short_name)); + return; + } + mdvi_hash_remove_ptr(&tfmhash, MDVI_KEY(tfm->short_name)); + + DEBUG((DBG_FONTS, "(mt) removing unused TFM data for `%s'\n", tfm->short_name)); + listh_remove(&tfmpool, LIST(tfm)); + xfree(tfm->short_name); + xfree(tfm->tfminfo.chars); + xfree(tfm); +} + +void flush_font_metrics(void) +{ + TFMPool *ptr; + + for(; (ptr = (TFMPool *)tfmpool.head); ) { + tfmpool.head = LIST(ptr->next); + + xfree(ptr->short_name); + xfree(ptr->tfminfo.chars); + xfree(ptr); + } + mdvi_hash_reset(&tfmhash, 0); +} diff --git a/dviware/mdvi/lib/tt.c b/dviware/mdvi/lib/tt.c new file mode 100644 index 0000000000..d04d33d7b3 --- /dev/null +++ b/dviware/mdvi/lib/tt.c @@ -0,0 +1,494 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "mdvi.h" + +#ifdef WITH_TRUETYPE_FONTS + +#include <string.h> +#include <freetype.h> +#include <ftxpost.h> +#include <ftxerr18.h> + +#include "private.h" + +static TT_Engine tt_handle; +static int initialized = 0; + +typedef struct ftinfo { + struct ftinfo *next; + struct ftinfo *prev; + char *fontname; + char *fmfname; + TT_Face face; + TT_Instance instance; + TT_Glyph glyph; + int hasmetrics; + int loaded; + int fmftype; + TFMInfo *tfminfo; + DviFontMapInfo mapinfo; + DviEncoding *encoding; +} FTInfo; + +static int tt_load_font __PROTO((DviParams *, DviFont *)); +static int tt_font_get_glyph __PROTO((DviParams *, DviFont *, int)); +static void tt_free_data __PROTO((DviFont *)); +static void tt_reset_font __PROTO((DviFont *)); +static void tt_shrink_glyph + __PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *)); +static void tt_font_remove __PROTO((FTInfo *)); + +DviFontInfo tt_font_info = { + "TT", + 0, + tt_load_font, + tt_font_get_glyph, + tt_shrink_glyph, + mdvi_shrink_glyph_grey, + tt_free_data, /* free */ + tt_reset_font, /* reset */ + NULL, /* lookup */ + kpse_truetype_format, + NULL +}; + +#define FT_HASH_SIZE 31 + +static ListHead ttfonts = {NULL, NULL, 0}; + +static int init_freetype(void) +{ + TT_Error code; + + ASSERT(initialized == 0); + code = TT_Init_FreeType(&tt_handle); + if(code) { + DEBUG((DBG_TT, "(tt) Init_Freetype: error %d\n", code)); + return -1; + } + code = TT_Init_Post_Extension(tt_handle); + if(code) { + TT_Done_FreeType(tt_handle); + return -1; + } + /* we're on */ + initialized = 1; + return 0; +} + +static void tt_encode_font(DviFont *font, FTInfo *info) +{ + TT_Face_Properties prop; + int i; + + if(TT_Get_Face_Properties(info->face, &prop)) + return; + + for(i = 0; i < prop.num_Glyphs; i++) { + char *string; + int ndx; + + if(TT_Get_PS_Name(info->face, i, &string)) + continue; + ndx = mdvi_encode_glyph(info->encoding, string); + if(ndx < font->loc || ndx > font->hic) + continue; + font->chars[ndx - font->loc].code = i; + } +} + +static int tt_really_load_font(DviParams *params, DviFont *font, FTInfo *info) +{ + DviFontChar *ch; + TFMChar *ptr; + Int32 z, alpha, beta; + int i; + FTInfo *old; + TT_Error status; + double point_size; + static int warned = 0; + TT_CharMap cmap; + TT_Face_Properties props; + int map_found; + + DEBUG((DBG_TT, "(tt) really_load_font(%s)\n", info->fontname)); + + /* get the point size */ + point_size = (double)font->scale / (params->tfm_conv * 0x100000); + point_size = 72.0 * point_size / 72.27; + if(info->loaded) { + /* just reset the size info */ + TT_Set_Instance_Resolutions(info->instance, + params->dpi, params->vdpi); + TT_Set_Instance_CharSize(info->instance, FROUND(point_size * 64)); + /* FIXME: should extend/slant again */ + info->hasmetrics = 1; + return 0; + } + + /* load the face */ + DEBUG((DBG_TT, "(tt) loading new face `%s'\n", + info->fontname)); + status = TT_Open_Face(tt_handle, font->filename, &info->face); + if(status) { + warning(_("(tt) %s: could not load face: %s\n"), + info->fontname, TT_ErrToString18(status)); + return -1; + } + + /* create a new instance of this face */ + status = TT_New_Instance(info->face, &info->instance); + if(status) { + warning(_("(tt) %s: could not create face: %s\n"), + info->fontname, TT_ErrToString18(status)); + TT_Close_Face(info->face); + return -1; + } + + /* create a glyph */ + status = TT_New_Glyph(info->face, &info->glyph); + if(status) { + warning(_("(tt) %s: could not create glyph: %s\n"), + info->fontname, TT_ErrToString18(status)); + goto tt_error; + } + + /* + * We'll try to find a Unicode charmap. It's not that important that we + * actually find one, especially if the fontmap files are installed + * properly, but it's good to have some predefined behaviour + */ + TT_Get_Face_Properties(info->face, &props); + + map_found = -1; + for(i = 0; map_found < 0 && i < props.num_CharMaps; i++) { + TT_UShort pid, eid; + + TT_Get_CharMap_ID(info->face, i, &pid, &eid); + switch(pid) { + case TT_PLATFORM_APPLE_UNICODE: + map_found = i; + break; + case TT_PLATFORM_ISO: + if(eid == TT_ISO_ID_7BIT_ASCII || + eid == TT_ISO_ID_8859_1) + map_found = 1; + break; + case TT_PLATFORM_MICROSOFT: + if(eid == TT_MS_ID_UNICODE_CS) + map_found = 1; + break; + } + } + if(map_found < 0) { + warning(_("(tt) %s: no acceptable map found, using #0\n"), + info->fontname); + map_found = 0; + } + DEBUG((DBG_TT, "(tt) %s: using charmap #%d\n", + info->fontname, map_found)); + TT_Get_CharMap(info->face, map_found, &cmap); + + DEBUG((DBG_TT, "(tt) %s: Set_Char_Size(%.2f, %d, %d)\n", + font->fontname, point_size, font->hdpi, font->vdpi)); + status = TT_Set_Instance_Resolutions(info->instance, + params->dpi, params->vdpi); + if(status) { + error(_("(tt) %s: could not set resolution: %s\n"), + info->fontname, TT_ErrToString18(status)); + goto tt_error; + } + status = TT_Set_Instance_CharSize(info->instance, + FROUND(point_size * 64)); + if(status) { + error(_("(tt) %s: could not set point size: %s\n"), + info->fontname, TT_ErrToString18(status)); + goto tt_error; + } + + /* after this point we don't fail */ + + /* get information from the fontmap */ + status = mdvi_query_fontmap(&info->mapinfo, info->fontname); + if(!status && info->mapinfo.encoding) + info->encoding = mdvi_request_encoding(info->mapinfo.encoding); + else + info->encoding = NULL; + + if(info->encoding != NULL) { + TT_Post post; + + status = TT_Load_PS_Names(info->face, &post); + if(status) { + warning(_("(tt) %s: could not load PS name table\n"), + info->fontname); + mdvi_release_encoding(info->encoding, 0); + info->encoding = NULL; + } + } + + /* get the metrics. If this fails, it's not fatal, but certainly bad */ + info->tfminfo = get_font_metrics(info->fontname, + info->fmftype, info->fmfname); + + if(info->tfminfo == NULL) { + warning("(tt) %s: no metrics data, font ignored\n", + info->fontname); + goto tt_error; + } + /* fix this */ + font->design = info->tfminfo->design; + + /* get the scaled character metrics */ + get_tfm_chars(params, font, info->tfminfo, 0); + + if(info->encoding) + tt_encode_font(font, info); + else { + warning(_("%s: no encoding vector found, expect bad output\n"), + info->fontname); + /* this is better than nothing */ + for(i = font->loc; i <= font->hic; i++) + font->chars[i - font->loc].code = TT_Char_Index(cmap, i); + } + + info->loaded = 1; + info->hasmetrics = 1; + return 0; + +tt_error: + tt_font_remove(info); + xfree(font->chars); + font->chars = NULL; + font->loc = font->hic = 0; + return -1; +} + +static int tt_load_font(DviParams *params, DviFont *font) +{ + int i; + FTInfo *info; + + if(!initialized && init_freetype() < 0) + return -1; + + if(font->in != NULL) { + fclose(font->in); + font->in = NULL; + } + + info = xalloc(FTInfo); + + memzero(info, sizeof(FTInfo)); + info->fmftype = DviFontAny; /* any metrics type will do */ + info->fmfname = lookup_font_metrics(font->fontname, &info->fmftype); + info->fontname = font->fontname; + info->hasmetrics = 0; + info->loaded = 0; + + /* these will be obtained from the fontmaps */ + info->mapinfo.psname = NULL; + info->mapinfo.encoding = NULL; + info->mapinfo.fontfile = NULL; + info->mapinfo.extend = 0; + info->mapinfo.slant = 0; + + /* initialize these */ + font->chars = xnalloc(DviFontChar, 256); + font->loc = 0; + font->hic = 255; + for(i = 0; i < 256; i++) { + font->chars[i].offset = 1; + font->chars[i].glyph.data = NULL; + font->chars[i].shrunk.data = NULL; + font->chars[i].grey.data = NULL; + } + + if(info->fmfname == NULL) + warning(_("(tt) %s: no font metric data\n"), font->fontname); + + listh_append(&ttfonts, LIST(info)); + font->private = info; + + return 0; +} + +static int tt_get_bitmap(DviParams *params, DviFont *font, + int code, double xscale, double yscale, DviGlyph *glyph) +{ + TT_Outline outline; + TT_Raster_Map raster; + TT_BBox bbox; + TT_Glyph_Metrics metrics; + TT_Matrix mat; + FTInfo *info; + int error; + int have_outline = 0; + int w, h; + + info = (FTInfo *)font->private; + if(info == NULL) + return -1; + + error = TT_Load_Glyph(info->instance, info->glyph, + code, TTLOAD_DEFAULT); + if(error) goto tt_error; + error = TT_Get_Glyph_Outline(info->glyph, &outline); + if(error) goto tt_error; + have_outline = 1; + mat.xx = FROUND(xscale * 65536); + mat.yy = FROUND(yscale * 65536); + mat.yx = 0; + mat.xy = 0; + TT_Transform_Outline(&outline, &mat); + error = TT_Get_Outline_BBox(&outline, &bbox); + if(error) goto tt_error; + bbox.xMin &= -64; + bbox.yMin &= -64; + bbox.xMax = (bbox.xMax + 63) & -64; + bbox.yMax = (bbox.yMax + 63) & -64; + w = (bbox.xMax - bbox.xMin) / 64; + h = (bbox.yMax - bbox.yMin) / 64; + + glyph->w = w; + glyph->h = h; + glyph->x = -bbox.xMin / 64; + glyph->y = bbox.yMax / 64; + if(!w || !h) + goto tt_error; + raster.rows = h; + raster.width = w; + raster.cols = ROUND(w, 8); + raster.size = h * raster.cols; + raster.flow = TT_Flow_Down; + raster.bitmap = xcalloc(h, raster.cols); + + TT_Translate_Outline(&outline, -bbox.xMin, -bbox.yMin); + TT_Get_Outline_Bitmap(tt_handle, &outline, &raster); + glyph->data = bitmap_convert_msb8(raster.bitmap, w, h); + TT_Done_Outline(&outline); + xfree(raster.bitmap); + + return 0; +tt_error: + if(have_outline) + TT_Done_Outline(&outline); + return -1; +} + +static int tt_font_get_glyph(DviParams *params, DviFont *font, int code) +{ + FTInfo *info = (FTInfo *)font->private; + DviFontChar *ch; + int error; + double xs, ys; + int dpi; + + ASSERT(info != NULL); + if(!info->hasmetrics && tt_really_load_font(params, font, info) < 0) + return -1; + ch = FONTCHAR(font, code); + if(!ch || !glyph_present(ch)) + return -1; + ch->loaded = 1; + if(!ch->width || !ch->height) + goto blank; + if(ch->code == 0) { + ch->glyph.data = NULL; + goto missing; + } + /* get the glyph */ + dpi = Max(font->hdpi, font->vdpi); + error = tt_get_bitmap(params, font, ch->code, + (double)font->hdpi / dpi, + (double)font->vdpi / dpi, + &ch->glyph); + if(error) + goto missing; + ch->x = ch->glyph.x; + ch->y = ch->glyph.y; + + return 0; + +missing: + ch->glyph.data = MDVI_GLYPH_EMPTY; + ch->missing = 1; +blank: + ch->glyph.w = ch->width; + ch->glyph.h = ch->height; + ch->glyph.x = ch->x; + ch->glyph.y = ch->y; + return 0; +} + +static void tt_shrink_glyph(DviContext *dvi, DviFont *font, DviFontChar *ch, DviGlyph *dest) +{ + tt_get_bitmap(&dvi->params, font, + ch->code, + (double)font->hdpi / (dvi->params.dpi * dvi->params.hshrink), + (double)font->vdpi / (dvi->params.vdpi * dvi->params.vshrink), + dest); + /* transform the glyph for the current orientation */ + font_transform_glyph(dvi->params.orientation, dest); +} + +static void tt_reset_font(DviFont *font) +{ + FTInfo *info = (FTInfo *)font->private; + + if(info == NULL) + return; + info->hasmetrics = 0; +} + +static void tt_font_remove(FTInfo *info) +{ + FTInfo *old; + + if(info->loaded) { + /* all fonts in the hash table have called TT_Open_Face */ + TT_Done_Instance(info->instance); + TT_Close_Face(info->face); + } + listh_remove(&ttfonts, LIST(info)); + /* release our encodings */ + if(info->encoding) + mdvi_release_encoding(info->encoding, 1); + /* and destroy the font */ + if(info->tfminfo) + free_font_metrics(info->tfminfo); + if(info->fmfname) + xfree(info->fmfname); + xfree(info); +} + +static void tt_free_data(DviFont *font) +{ + if(font->private == NULL) + return; + + tt_font_remove((FTInfo *)font->private); + if(initialized && ttfonts.count == 0) { + DEBUG((DBG_TT, "(tt) last font removed -- closing FreeType\n")); + TT_Done_FreeType(tt_handle); + initialized = 0; + } +} + +#endif /* WITH_TRUETYPE_FONTS */ diff --git a/dviware/mdvi/lib/util.c b/dviware/mdvi/lib/util.c new file mode 100644 index 0000000000..34ba3fa1b9 --- /dev/null +++ b/dviware/mdvi/lib/util.c @@ -0,0 +1,504 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <time.h> +#include <sys/stat.h> +#include <errno.h> +#include <unistd.h> + +#include "common.h" +#include "private.h" + +static char *const messages[] = { + _G("Ooops!"), + _G("Aieeeee!!"), + _G("Ouch!"), + _G("Houston, we have a problem"), + _G("3.. 2.. 1.. BOOM!"), + _G("I'm history"), + _G("I'm going down"), + _G("I smell a rat") +}; +#define NMSGS (sizeof(messages) / sizeof(char *)) + +static FILE *logfile = NULL; +static int _mdvi_log_level; + +static void vputlog(int level, const char *head, const char *format, va_list ap) +{ + if(logfile != NULL && _mdvi_log_level >= level) { + if(head != NULL) + fprintf(logfile, "%s: ", head); + vfprintf(logfile, format, ap); + } +} + +int mdvi_set_logfile(const char *filename) +{ + FILE *f = NULL; + + if(filename && (f = fopen(filename, "w")) == NULL) + return -1; + if(logfile != NULL && !isatty(fileno(logfile))) { + fclose(logfile); + logfile = NULL; + } + if(filename) + logfile = f; + return 0; +} + +int mdvi_set_logstream(FILE *file) +{ + if(logfile && !isatty(fileno(logfile))) { + fclose(logfile); + logfile = NULL; + } + logfile = file; + return 0; +} + +int mdvi_set_loglevel(int level) +{ + int old = _mdvi_log_level; + + _mdvi_log_level = level; + return old; +} + +#ifndef NODEBUG +Uint32 _mdvi_debug_mask = 0; + +void __debug(int mask, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + if(_mdvi_debug_mask & mask) { + if(!DEBUGGING(SILENT)) { + fprintf(stderr, "Debug: "); + vfprintf(stderr, format, ap); + fflush(stderr); + } +#ifndef __GNUC__ + /* let's be portable */ + va_end(ap); + va_start(ap, format); +#endif + vputlog(LOG_DEBUG, "Debug", format, ap); + } + va_end(ap); +} +#endif + +void message(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + if(_mdvi_log_level >= LOG_INFO) { + fprintf(stderr, "%s: ", program_name); + vfprintf(stderr, format, ap); +#ifndef __GNUC__ + va_end(ap); + va_start(ap, format); +#endif + } + vputlog(LOG_INFO, NULL, format, ap); + va_end(ap); +} + +void crash(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + fprintf(stderr, "%s: %s: ", + program_name, + gettext(messages[(int)time(NULL) % NMSGS])); + vfprintf(stderr, format, ap); +#ifndef __GNUC__ + /* let's be portable */ + va_end(ap); + va_start(ap, format); +#endif + vputlog(LOG_ERROR, _("Crashing"), format, ap); + va_end(ap); + abort(); +} + +void error(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + fprintf(stderr, _("%s: Error: "), program_name); + vfprintf(stderr, format, ap); +#ifndef __GNUC__ + /* let's be portable */ + va_end(ap); + va_start(ap, format); +#endif + vputlog(LOG_ERROR, _("Error"), format, ap); + va_end(ap); +} + +void warning(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + fprintf(stderr, _("%s: Warning: "), program_name); + vfprintf(stderr, format, ap); +#ifndef __GNUC__ + /* let's be portable */ + va_end(ap); + va_start(ap, format); +#endif + vputlog(LOG_WARN, _("Warning"), format, ap); + va_end(ap); +} + +void fatal(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + fprintf(stderr, _("%s: Fatal: "), program_name); + vfprintf(stderr, format, ap); +#ifndef __GNUC__ + /* let's be portable */ + va_end(ap); + va_start(ap, format); +#endif + vputlog(LOG_ERROR, _("Fatal"), format, ap); + va_end(ap); +#ifndef NODEBUG + abort(); +#else + exit(EXIT_FAILURE); +#endif +} + +void *xmalloc(size_t nelems) +{ + void *ptr = malloc(nelems); + + if(ptr == NULL) + fatal(_("out of memory allocating %u bytes\n"), + (unsigned)nelems); + return ptr; +} + +void *xrealloc(void *data, size_t newsize) +{ + void *ptr; + + if(newsize == 0) + crash(_("attempted to reallocate with zero size\n")); + ptr = realloc(data, newsize); + if(ptr == NULL) + fatal(_("failed to reallocate %u bytes\n"), (unsigned)newsize); + return ptr; +} + +void *xcalloc(size_t nmemb, size_t size) +{ + void *ptr; + + if(nmemb == 0) + crash(_("attempted to callocate 0 members\n")); + if(size == 0) + crash(_("attempted to callocate %u members with size 0\n"), + (unsigned)nmemb); + ptr = calloc(nmemb, size); + if(ptr == 0) + fatal(_("failed to allocate %ux%u bytes\n"), + (unsigned)nmemb, (unsigned)size); + return ptr; +} + +void xfree(void *ptr) +{ + if(ptr == NULL) + crash(_("attempted to free NULL pointer\n")); + free(ptr); +} + +char *xstrdup(const char *string) +{ + int length; + char *ptr; + + length = strlen(string) + 1; + ptr = (char *)xmalloc(length); + memcpy(ptr, string, length); + return ptr; +} + +/* `to' should have room for length+1 bytes */ +char *xstrncpy(char *to, const char *from, size_t length) +{ + strncpy(to, from, length); + to[length] = '\0'; + return to; +} + +char *xstrndup(const char *string, size_t length) +{ + int n; + char *ptr; + + n = strlen(string); + if(n > length) + n = length; + ptr = (char *)xmalloc(n + 1); + memcpy(ptr, string, n); + return ptr; +} + +void *xmemdup(const void *data, size_t length) +{ + void *ptr = xmalloc(length); + + memcpy(ptr, data, length); + return ptr; +} + +double unit2pix_factor(const char *spec) +{ + double val; + double factor; + const char *p, *q; + static const char *units = "incmmmmtptpcddccspbpftydcs"; + + val = 0.0; + + for(p = spec; *p >= '0' && *p <= '9'; p++) + val = 10.0 * val + (double)(*p - '0'); + if(*p == '.') { + p++; + factor = 0.1; + while(*p && *p >= '0' && *p <= '9') { + val += (*p++ - '0') * factor; + factor = factor * 0.1; + } + } + factor = 1.0; + for(q = units; *q; q += 2) { + if(p[0] == q[0] && p[1] == q[1]) + break; + } + switch((int)(q - units)) { + /*in*/ case 0: factor = 1.0; break; + /*cm*/ case 2: factor = 1.0 / 2.54; break; + /*mm*/ case 4: factor = 1.0 / 25.4; break; + /*mt*/ case 6: factor = 1.0 / 0.0254; break; + /*pt*/ case 8: factor = 1.0 / 72.27; break; + /*pc*/ case 10: factor = 12.0 / 72.27; break; + /*dd*/ case 12: factor = (1238.0 / 1157.0) / 72.27; break; + /*cc*/ case 14: factor = 12 * (1238.0 / 1157.0) / 72.27; break; + /*sp*/ case 16: factor = 1.0 / (72.27 * 65536); break; + /*bp*/ case 18: factor = 1.0 / 72.0; break; + /*ft*/ case 20: factor = 12.0; break; + /*yd*/ case 22: factor = 36.0; break; + /*cs*/ case 24: factor = 1.0 / 72000.0; break; + default: factor = 1.0; + } + return factor * val; +} + +int unit2pix(int dpi, const char *spec) +{ + double factor = unit2pix_factor(spec); + + return (int)(factor * dpi + 0.5); +} + +Ulong get_mtime(int fd) +{ + struct stat st; + + if(fstat(fd, &st) == 0) + return (Ulong)st.st_mtime; + return 0; +} + +char *xstradd(char *dest, size_t *size, size_t n, const char *src, size_t m) +{ + if(m == 0) + m = strlen(src); + if(n + m >= *size) { + dest = xrealloc(dest, n + m + 1); + *size = n + m + 1; + } + memcpy(dest + n, src, m); + dest[n + m] = 0; + return dest; +} + +int get_number(const char *string, long *val) +{ + long x; + char *end; + + errno = 0; + x = strtol(string, &end, 10); + if(errno || *end) + return -1; + *val = x; + return 0; +} + +char *getword(char *string, const char *delim, char **end) +{ + char *ptr; + char *word; + + /* skip leading delimiters */ + for(ptr = string; *ptr && strchr(delim, *ptr); ptr++); + + if(*ptr == 0) + return NULL; + word = ptr++; + /* skip non-delimiters */ + while(*ptr && !strchr(delim, *ptr)) + ptr++; + *end = (char *)ptr; + return word; +} + +char *getstring(char *string, const char *delim, char **end) +{ + char *ptr; + char *word; + int quoted = 0; + + /* skip leading delimiters */ + for(ptr = string; *ptr && strchr(delim, *ptr); ptr++); + + if(ptr == NULL) + return NULL; + quoted = (*ptr == '"'); + if(quoted) + for(word = ++ptr; *ptr && *ptr != '"'; ptr++); + else + for(word = ptr; *ptr && !strchr(delim, *ptr); ptr++); + *end = (char *)ptr; + return word; +} + +static long pow2(size_t n) +{ + long x = 8; /* don't bother allocating less than this */ + + while(x < n) + x <<= 1L; + return x; +} + +void dstring_init(Dstring *dstr) +{ + dstr->data = NULL; + dstr->size = 0; + dstr->length = 0; +} + +int dstring_append(Dstring *dstr, const char *string, int len) +{ + if(len < 0) + len = strlen(string); + if(len) { + if(dstr->length + len >= dstr->size) { + dstr->size = pow2(dstr->length + len + 1); + dstr->data = xrealloc(dstr->data, dstr->size); + } + memcpy(dstr->data + dstr->length, string, len); + dstr->length += len; + dstr->data[dstr->length] = 0; + } else if(dstr->size == 0) { + ASSERT(dstr->data == NULL); + dstr->size = 8; + dstr->data = xmalloc(8); + dstr->data[0] = 0; + } + + return dstr->length; +} + +int dstring_copy(Dstring *dstr, int pos, const char *string, int len) +{ + ASSERT(pos >= 0); + if(len < 0) + len = strlen(string); + if(len) { + if(pos + len >= dstr->length) { + dstr->length = pos; + return dstring_append(dstr, string, len); + } + memcpy(dstr->data + pos, string, len); + } + return dstr->length; +} + +int dstring_insert(Dstring *dstr, int pos, const char *string, int len) +{ + ASSERT(pos >= 0); + if(pos == dstr->length) + return dstring_append(dstr, string, len); + if(len < 0) + len = strlen(string); + if(len) { + if(dstr->length + len >= dstr->size) { + dstr->size = pow2(dstr->length + len + 1); + dstr->data = xrealloc(dstr->data, dstr->size); + } + /* make room */ + memmove(dstr->data + pos, dstr->data + pos + len, len); + /* now copy */ + memcpy(dstr->data + pos, string, len); + dstr->length += len; + dstr->data[dstr->length] = 0; + } + return dstr->length; +} + +int dstring_new(Dstring *dstr, const char *string, int len) +{ + if(len < 0) + len = strlen(string); + if(len) { + dstr->size = pow2(len + 1); + dstr->data = xmalloc(dstr->size * len); + memcpy(dstr->data, string, len); + } else + dstring_init(dstr); + return dstr->length; +} + +void dstring_reset(Dstring *dstr) +{ + if(dstr->data) + xfree(dstr->data); + dstring_init(dstr); +} + diff --git a/dviware/mdvi/lib/vf.c b/dviware/mdvi/lib/vf.c new file mode 100644 index 0000000000..86185f3662 --- /dev/null +++ b/dviware/mdvi/lib/vf.c @@ -0,0 +1,240 @@ +/* vf.c -- VF font support */ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <string.h> + +#include "mdvi.h" +#include "private.h" + +static int vf_load_font __PROTO((DviParams *, DviFont *)); +static void vf_free_macros __PROTO((DviFont *)); + +/* only symbol exported by this file */ +DviFontInfo vf_font_info = { + "VF", + 1, /* virtual fonts scale just fine */ + vf_load_font, + NULL, /* get_glyph */ + NULL, /* shrink0 */ + NULL, /* shrink1 */ + vf_free_macros, + NULL, /* reset */ + NULL, /* lookup */ + kpse_vf_format, + NULL +}; + +DviFontInfo ovf_font_info = { + "OVF", + 1, /* virtual fonts scale just fine */ + vf_load_font, + NULL, /* get_glyph */ + NULL, /* shrink0 */ + NULL, /* shrink1 */ + vf_free_macros, + NULL, /* reset */ + NULL, /* lookup */ + kpse_ovf_format, + NULL +}; + +static int vf_load_font(DviParams *params, DviFont *font) +{ + FILE *p; + Uchar *macros; + int msize; + int mlen; + Int32 checksum; + long alpha, beta, z; + int op; + int i; + int nchars; + int loc, hic; + DviFontRef *last; + + macros = NULL; + msize = mlen = 0; + p = font->in; + + if(fuget1(p) != 247 || fuget1(p) != 202) + goto badvf; + mlen = fuget1(p); + fseek(p, (long)mlen, SEEK_CUR); + checksum = fuget4(p); + if(checksum && font->checksum && checksum != font->checksum) { + warning(_("%s: Checksum mismatch (expected %u, got %u)\n"), + font->fontname, font->checksum, checksum); + } else if(!font->checksum) + font->checksum = checksum; + font->design = fuget4(p); + + /* read all the fonts in the preamble */ + last = NULL; + + /* initialize alpha, beta and z for TFM width computation */ + TFMPREPARE(font->scale, z, alpha, beta); + + op = fuget1(p); + while(op >= DVI_FNT_DEF1 && op <= DVI_FNT_DEF4) { + DviFontRef *ref; + Int32 scale, design; + Uint32 checksum; + int id; + int n; + int hdpi; + int vdpi; + char *name; + + /* process fnt_def commands */ + + id = fugetn(p, op - DVI_FNT_DEF1 + 1); + checksum = fuget4(p); + scale = fuget4(p); + design = fuget4(p); + + /* scale this font according to our parent's scale */ + scale = TFMSCALE(scale, z, alpha, beta); + design = FROUND(params->tfm_conv * design); + + /* compute the resolution */ + hdpi = FROUND(params->mag * params->dpi * scale / design); + vdpi = FROUND(params->mag * params->vdpi * scale / design); + n = fuget1(p) + fuget1(p); + name = xmalloc(n + 1); + fread(name, 1, n, p); + name[n] = 0; + DEBUG((DBG_FONTS, "(vf) %s: defined font `%s' at %.1fpt (%dx%d dpi)\n", + font->fontname, name, + (double)scale / (params->tfm_conv * 0x100000), hdpi, vdpi)); + + /* get the font */ + ref = font_reference(params, id, name, checksum, hdpi, vdpi, scale); + if(ref == NULL) { + error(_("(vf) %s: could not load font `%s'\n"), + font->fontname, name); + goto error; + } + xfree(name); + if(last == NULL) + font->subfonts = last = ref; + else + last->next = ref; + ref->next = NULL; + op = fuget1(p); + } + + if(op >= DVI_FNT_DEF1 && op <= DVI_FNT_DEF4) + goto error; + + /* This function correctly reads both .vf and .ovf files */ + + font->chars = xnalloc(DviFontChar, 256); + for(i = 0; i < 256; i++) + font->chars[i].offset = 0; + nchars = 256; + loc = -1; hic = -1; + /* now read the characters themselves */ + while(op <= 242) { + int pl; + Int32 cc; + Int32 tfm; + + if(op == 242) { + pl = fuget4(p); + cc = fuget4(p); + tfm = fuget4(p); + } else { + pl = op; + cc = fuget1(p); + tfm = fuget3(p); + } + if(loc < 0 || cc < loc) + loc = cc; + if(hic < 0 || cc > hic) + hic = cc; + if(cc >= nchars) { + font->chars = xresize(font->chars, + DviFontChar, cc + 16); + for(i = nchars; i < cc + 16; i++) + font->chars[i].offset = 0; + nchars = cc + 16; + } + if(font->chars[cc].offset) { + error(_("(vf) %s: character %d redefined\n"), + font->fontname, cc); + goto error; + } + + DEBUG((DBG_GLYPHS, "(vf) %s: defined character %d (macro length %d)\n", + font->fontname, cc, pl)); + font->chars[cc].width = pl + 1; + font->chars[cc].code = cc; + font->chars[cc].tfmwidth = TFMSCALE(tfm, z, alpha, beta); + font->chars[cc].offset = mlen; + font->chars[cc].loaded = 1; + if(mlen + pl + 1 > msize) { + msize = mlen + pl + 256; + macros = xresize(macros, Uchar, msize); + } + if(pl && fread(macros + mlen, 1, pl, p) != pl) + break; + macros[mlen+pl] = DVI_EOP; + mlen += pl + 1; + op = fuget1(p); + } + if(op != 248) { + error(_("(vf) %s: no postamble\n"), font->fontname); + goto error; + } + + /* make macro memory just big enough */ + if(msize > mlen) { + macros = xresize(macros, Uchar, mlen); + msize = mlen; + } + + DEBUG((DBG_FONTS|DBG_GLYPHS, + "(vf) %s: macros use %d bytes\n", font->fontname, msize)); + + if(loc > 0 || hic < nchars-1) { + memmove(font->chars, font->chars + loc, + (hic - loc + 1) * sizeof(DviFontChar)); + font->chars = xresize(font->chars, + DviFontChar, hic - loc + 1); + } + font->loc = loc; + font->hic = hic; + font->private = macros; + + return 0; + +badvf: + error(_("%s: File corrupted, or not a VF file.\n"), font->fontname); +error: + if(font->chars) + xfree(font->chars); + if(macros) + xfree(macros); + return -1; +} + +static void vf_free_macros(DviFont *font) +{ + xfree(font->private); +} diff --git a/dviware/mdvi/mdvi.conf b/dviware/mdvi/mdvi.conf new file mode 100644 index 0000000000..0a3f23f0ee --- /dev/null +++ b/dviware/mdvi/mdvi.conf @@ -0,0 +1,10 @@ + +encoding "texnansi.enc" +fontmap "psfonts.map" +fontmap "xdvifont.map" +fontmap "cm.map" + +# These beast is independent of our font maps +psfontpath "/usr/local/share/ghostscript/fonts" +pslibpath "/usr/local/share/ghostscript/6.50/lib" +psfontmap "Fontmap.GS" diff --git a/dviware/mdvi/support/Makefile.in b/dviware/mdvi/support/Makefile.in new file mode 100644 index 0000000000..729e400b18 --- /dev/null +++ b/dviware/mdvi/support/Makefile.in @@ -0,0 +1,30 @@ + +srcdir = @srcdir@ +VPATH = @srcdir@ + +include ../config.mk + +OBJS = @LIBOBJS@ +SOURCES = $(OBJS:.o=.c) + +ALL_SOURCES = getopt.c getopt1.c +ALL_HEADERS = getopt.h + +OTHERFILES = Makefile.in +DISTFILES = $(ALL_SOURCES) $(ALL_HEADERS) $(OTHERFILES) + +.PHONY: all +all: @SUPPORTLIB@ + +support.a: $(OBJS) + $(MAKELIB) $@ $(OBJS) + +.PHONY: install uninstall +install: +uninstall: + +CLEANABLE += $(OBJS) support.a +DISTCLEANABLE += Makefile + +include $(FRAGDIR)/dist.mk +include $(FRAGDIR)/targets.mk diff --git a/dviware/mdvi/support/getopt.c b/dviware/mdvi/support/getopt.c new file mode 100644 index 0000000000..81b2d9b7bc --- /dev/null +++ b/dviware/mdvi/support/getopt.c @@ -0,0 +1,732 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 + Free Software Foundation, Inc. + +This file is part of the libiberty library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. + Ditto for AIX 3.2 and <stdlib.h>. */ +#ifndef _NO_PROTO +#define _NO_PROTO +#endif + +/* slightly edited for use in VB */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +extern char *getenv(); + +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include <stdio.h> + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ +/* Many versions of the Linux C library include older, broken versions + of these routines, which will break the linker's command-line + parsing. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) || defined (__linux__) + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = NULL; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* XXX 1003.2 says this must be 1 before any call. */ +int optind = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return EOF with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +#include <string.h> +#define my_index strchr +#else + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +static char *my_index (const char *str, int chr) +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +#ifndef __STDC__ +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +#endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void exchange (char **argv) +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +static const char *_getopt_initialize (const char *optstring) +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind = 1; + + nextchar = NULL; + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (getenv ("POSIXLY_CORRECT") != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns `EOF'. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal ( + int argc, + char *const *argv, + const char *optstring, + const struct option *longopts, + int *longind, + int long_only) +{ + optarg = NULL; + + if (optind == 0) + optstring = _getopt_initialize (optstring); + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc + && (argv[optind][0] != '-' || argv[optind][1] == '\0')) + optind++; + last_nonopt = optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return EOF; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) + { + if (ordering == REQUIRE_ORDER) + return EOF; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((int)(nameend - nextchar) == (int)strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, "%s: option `%s' is ambiguous\n", + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + } + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, "%s: unrecognized option `--%s'\n", + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, "%s: unrecognized option `%c%s'\n", + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); + } + optopt = c; + return '?'; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: option requires an argument -- %c\n", + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int getopt (int argc, char *const *argv, const char *optstring) +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* _LIBC or not __GNU_LIBRARY__. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == EOF) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/dviware/mdvi/support/getopt.h b/dviware/mdvi/support/getopt.h new file mode 100644 index 0000000000..abf9153832 --- /dev/null +++ b/dviware/mdvi/support/getopt.h @@ -0,0 +1,129 @@ +/* Declarations for getopt. + Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +#if __STDC__ + const char *name; +#else + char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +#if __STDC__ +#if defined(__GNU_LIBRARY__) +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int argc, char *const *argv, const char *shortopts); +#else /* not __GNU_LIBRARY__ */ +extern int getopt (); +#endif /* not __GNU_LIBRARY__ */ +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* not __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GETOPT_H */ diff --git a/dviware/mdvi/support/getopt1.c b/dviware/mdvi/support/getopt1.c new file mode 100644 index 0000000000..d6da3305d3 --- /dev/null +++ b/dviware/mdvi/support/getopt1.c @@ -0,0 +1,190 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#if defined (emacs) || defined (CONFIG_BROKETS) +/* We use <config.h> instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include <config.h> +#else +#include "config.h" +#endif +#endif + +#include "getopt.h" + +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include <stdio.h> + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ +/* Many versions of the Linux C library include older, broken versions + of these routines, which will break the linker's command-line + parsing. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) || defined (__linux__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include <stdlib.h> +#else +char *getenv (); +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long ( + int argc, + char *const *argv, + const char *options, + const struct option *long_options, + int *opt_index) +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only ( + int argc, + char *const *argv, + const char *options, + const struct option *long_options, + int *opt_index) +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); +} + + +#endif /* _LIBC or not __GNU_LIBRARY__. */ + +#ifdef TEST + +#include <stdio.h> + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == EOF) + break; + + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case 'd': + printf ("option d with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/dviware/mdvi/version.h.in b/dviware/mdvi/version.h.in new file mode 100644 index 0000000000..2ce751f816 --- /dev/null +++ b/dviware/mdvi/version.h.in @@ -0,0 +1,9 @@ +#ifndef _MDVI_VERSION_H +#define _MDVI_VERSION_H 1 + +#define MDVI_MAJOR @MAJOR@ +#define MDVI_MINOR @MINOR@ +#define MDVI_PATCH @PATCH@ +#define MDVI_VERSION "@VERSION@" + +#endif /* _MDVI_VERSION_H */ diff --git a/dviware/mdvi/x11/Makefile.in b/dviware/mdvi/x11/Makefile.in new file mode 100644 index 0000000000..b53678361e --- /dev/null +++ b/dviware/mdvi/x11/Makefile.in @@ -0,0 +1,60 @@ + +srcdir = @srcdir@ +VPATH = @srcdir@ + +-include ../config.mk + +OBJS = dvi.o dvidraw.o x11.o +SOURCES = dvi.c dvidraw.c x11.c +HEADERS = x11.h +OTHERFILES = Makefile.in + +INCLUDES = -I$(srcdir) -I.. -I$(srcdir)/../include +LOCAL_CFLAGS = $(INCLUDES) $(KPSE_CFLAGS) $(X_CFLAGS) +ALL_CFLAGS = $(CFLAGS) $(ADDCFLAGS) $(CPPFLAGS) $(LOCAL_CFLAGS) + +ALL_LIBS = $(KPSE_LIBS) $(T1LIB_LIBS) $(FREETYPE_LIBS) \ + $(X_LIBS) $(ADDLIBS) $(LIBS) + +DEPSOURCES = $(SOURCES) +DEPCFLAGS = $(ALL_CFLAGS) +DISTFILES = $(SOURCES) $(HEADERS) $(OTHERFILES) + +CLEANABLE += $(OBJS) $(PROGRAMS) core +DISTCLEANABLE += Makefile + +MDVILIB = ../lib/mdvi.a +PROGRAM = mdvi + +.PHONY: all +all: $(PROGRAM) + +mdvi: $(MDVILIB) $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(MDVILIB) $(ALL_LIBS) + +.PHONY: install +install: + $(MKINSTALLDIRS) $(bindir) + $(INSTALL) -m 755 $(PROGRAM) $(bindir)/$(PROGRAM) + +.PHONY: uninstall +uninstall: + $(RM) $(bindir)/$(PROGRAM) + +.PHONY: $(MDVILIB) +$(MDVILIB): + $(MAKE) -C ../lib + +../config.mk: + @echo "*** Error: Run \`configure' in the top source directory." + @exit 1 + +.c.o: + $(CC) $(ALL_CFLAGS) -c $< + +dvi.o: dvi.c + $(CC) $(ALL_CFLAGS) $(T1LIB_CFLAGS) $(FREETYPE_CFLAGS) -DLOCALEDIR=\"$(localedir)\" -c $< + +include $(FRAGDIR)/dist.mk +include $(FRAGDIR)/targets.mk +include $(FRAGDIR)/depend.mk diff --git a/dviware/mdvi/x11/dvi.c b/dviware/mdvi/x11/dvi.c new file mode 100644 index 0000000000..e47b6e8de1 --- /dev/null +++ b/dviware/mdvi/x11/dvi.c @@ -0,0 +1,1008 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <string.h> +#include <stdlib.h> +#include <getopt.h> + +#include "mdvi.h" +#include "private.h" +#include "defaults.h" +#include "version.h" + +#if defined(ENABLE_NLS) && defined(HAVE_LOCALE_H) +#include <locale.h> +#endif + +int profiling = 0; +int batch_mode = 0; +int registered_fonts = 0; + +#if WITH_TYPE1_FONTS +extern char *T1_GetLibIdent(); +#endif + +extern char *kpathsea_version_string; +extern int init_x11(void); +extern void view_page(DviContext *, int); +extern int mdvi_create_window(DviContext *, const char *); +extern Ulong get_color_byname __PROTO((const char *)); + +/* font types */ +extern DviFontInfo pk_font_info; +extern DviFontInfo pkn_font_info; +extern DviFontInfo gf_font_info; +extern DviFontInfo vf_font_info; +#ifdef WITH_OMEGA +extern DviFontInfo ovf_font_info; +#endif +#ifdef WITH_TRUETYPE_FONTS +extern DviFontInfo tt_font_info; +#endif +#ifdef WITH_TYPE1_FONTS +extern DviFontInfo t1_font_info; +#endif +#ifdef WITH_AFM_FILES +extern DviFontInfo afm_font_info; +#endif +extern DviFontInfo tfm_font_info; +#ifdef WITH_OMEGA +extern DviFontInfo ofm_font_info; +#endif + +static struct fontinfo { + DviFontInfo *info; + char *desc; + int klass; +} known_fonts[] = { + {&vf_font_info, "Virtual fonts", 0}, +#ifdef WITH_OMEGA + {&ovf_font_info, "Omega's virtual fonts", 0}, +#endif +#ifdef WITH_TRUETYPE_FONTS + {&tt_font_info, "TrueType fonts", 0}, +#endif +#ifdef WITH_TYPE1_FONTS + {&t1_font_info, "Type1 PostScript fonts", 0}, +#endif + {&pk_font_info, "Packed bitmap (auto-generated)", 1}, + {&pkn_font_info, "Packed bitmap", -2}, + {&gf_font_info, "Metafont's generic font format", 1}, +#ifdef WITH_OMEGA + {&ofm_font_info, "Omega font metrics", -1}, +#endif + {&tfm_font_info, "TeX font metrics", -1}, +#ifdef WITH_AFM_FILES + {&afm_font_info, "Adobe font metrics", -1}, +#endif + {0, 0} +}; + +static int print_info_only = 0; +char *logfile; +DviAppConfig *mdvi_app; +char *program_name; + +static char mdvi_banner[] = +"mdvi " MDVI_VERSION " -- A TeX DVI previewer for Unix\n" +"Copyright (C) 2000 Matias Atria\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under certain conditions. Try `mdvi --info' for details\n\n"; + +static char mdvi_long_banner[] = +"mdvi " MDVI_VERSION " -- A TeX DVI previewer for Unix\n" +"Copyright (C) 2000 Matias Atria\n\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 2 of the License, or\n" +"(at your option) any later version.\n\n" +"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n" +"PARTICULAR PURPOSE.\n\n"; + +static const char *orientstr[] = { + "tblr", "tbrl", "btlr", "btrl", + "rp90", "rm90", "irp90", "irm90" +}; + +static const char usage_help[] = +"Usage: mdvi [OPTION] ... DVIFILE\n\n" +"Options:\n" +" -a, --font-types=FONTS\n" +" specify which font types to use\n" +" -A, --fonts-omitted[=FONTS]\n" +" specify which font types not to use by default\n" +" -b, --boxes\n" +" see the world through TeX's eyes\n" +" -B, --bg=COLOR\n" +" set background color\n" +" -d, --debug=MASK\n" +" set debug mask (see --explain debug for more info)\n" +" -D, --dpi=DPI\n" +" set resolution to DPI pixels per inch\n" +" -e, --explain=TOPIC\n" +" give more detailed help on a particular topic, use topic `list' to\n" +" see the list of known topics\n" +" -f, --fallback-font=FONT-NAME\n" +" font to use when one is missing\n" +" -F, --fg=COLOR\n" +" set foreground color\n" +" -G, --gamma=NUMBER\n" +" gamma correction for antialiased glyphs\n" +" -h, --help[=TOPIC]\n" +" display help on a command line option. TOPIC may be the long name of an\n" +" option, or one of `papers' or `units'.\n" +" -H, --horizontal-margin=UNIT\n" +" size of horizontal margins\n" +" -i, --info\n" +" display licensing information and default settings\n" +" -l, --log-file=[LEVEL:]FILE\n" +" save all messages with priority at least LEVEL to FILE\n" +" -m, --mf-mode=MODE\n" +" Metafont mode to use when creating fonts\n" +" -M, --magnification=NUMBER\n" +" magnification factor (NUMBER = TeX's NUMBER/1000.0)\n" +" -N, --mono\n" +" to force monochrome configuration\n" +" -o, --orientation=ORIENTATION\n" +" set document on-screen orientation\n" +" --orientation=help\n" +" print option details and exit\n" +" -p, --paper=NAME\n" +" paper type to use\n" +" --paper=list\n" +" print known paper types and exit\n" +" -P, --page=NUMBER\n" +" start viewing page NUMBER\n" +" -r, --page-range=RANGE\n" +" specify which files should be read\n" +" --page-range=help\n" +" print option details and exit\n" +" -s, --shrink=NUMBER\n" +" shrinking factor for glyphs\n" +" -S, --sort-pages[=TYPE]\n" +" set page sorting type, where `TYPE' is one of up, down, random,\n" +" dviup, dvidown or none. If `TYPE' is not specified, `up' is assumed\n" +" -t, --pixel-density=NUMBER\n" +" pixel density for antialiased glyphs (0 <= NUMBER <= 100)\n" +" -T, --tex-page=NUMBER\n" +" start viewing TeX's (i.e. document's) page NUMBER\n" +" -V, --vertical-margin=UNIT\n" +" size of vertical margins\n" +" -x, --xdpi=DPI\n" +" set horizontal resolution\n" +" -y, --ydpi=DPI\n" +" set vertical resolution\n" +" -z, --batch\n" +" run in batch mode (no UI)\n"; + +static const char debug_help[] = +"Debugging masks: -d MASK, --debug=MASK\n" +" MASK is a numerical value, obtained by ORing the values given below\n" +"or a series of mask names separated by commas or by `|'. The masks known\n" +"to MDVI are:\n\n" +" Name Value Description\n" +"------------------------------------------------------------------------\n" +" opcode 1 DVI opcodes and arguments in `dvitype' style\n" +" fonts 2 messages related to the management of fonts\n" +" files 4 file operations\n" +" dvi 8 operations on DVI files\n" +" params 16 manipulation of DVI parameters\n" +" special 32 DVI specials\n" +" device 64 device-specific messages\n" +" glyphs 128 loading of glyphs (lots of output)\n" +" paths 256 paths configuration in kpathsea\n" +" search 512 file searches by kpathsea\n" +" vars 1024 traces environment variables (MDVI and kpathsea)\n" +" bitops 2048 bitmap operations (scaling, flipping, etc)\n" +" bitdata 4096 bitmap bits (MASSIVE amounts of output)\n" +" type1 8192 management of Type1 fonts\n" +" tt 16384 management of TrueType fonts\n" +" --- 32768 unused\n" +" fontmaps 65536 things involving font maps and encodings\n"; + +static const char orientation_help[] = +"Orientation options: -o ORIENTATION, --orienation=ORIENTATION\n" +" ORIENTATION is one of TBLR, TBRL, BTLR, BTRL, RP90, RM90, IRP90 or\n" +"IRM90, where TB=top-to-bottom, LR=left-to-right, etc.,\n" +"RP=rotate-positively (i.e. counter-clockwise), RM=rotate-negatively,\n" +"and the last two are the same than these, after a reflection with\n" +"respect to an imaginary vertical axis. The values Portrait, Landscape\n" +"and Seascape are synonyms for TBLR, RM90 and RP90, respectively.\n"; + +static const char range_help[] = +"Page range selection options: -r RANGE-SPEC, --page-range=RANGE-SPEC\n" +" RANGE-SPEC consists of up to 11 RANGE-LIST strings, separated by dots.\n" +"If there is only one list, it is assumed to apply to DVI page numbers.\n" +"Otherwise, each list applies to the corresponding TeX page \\counter (10 per\n" +"page). A RANGE-LIST is either empty or a comma-separated list of ranges, at\n" +"least one of which must contain the page counter in order for the page to be\n" +"processed. A range has the form LOWER:UPPER:STEP, which specifies the\n" +"sequence LOWER + STEP * n, for 0 <= n <= (UPPER - LOWER) / STEP. A\n" +"RANGE-LIST may optionally be written inside braces, for clarity, but no\n" +"white space is allowed anywhere in a RANGE-SPEC. Any part of a range (except\n" +"for the `:') may be omitted, in which case LOWER, UPPER and STEP take the\n" +"default values -INFINITY, +INFINITY and 1, respectively, except in two\n" +"cases: (1) The form ::STEP specifies the sequence `STEP * n' for `n' an\n" +"arbitrary integer, and (2) In the form :UPPER:STEP, LOWER is set to\n" +"`PREV_UPPER + 1' if the preceding range had a finite upper bound, and to\n" +"-INFINITY otherwise. An empty RANGE-LIST (written as `*') is equivalent\n" +"to {::}.\n" +" If the first RANGE-LIST begins with `D' or `d', it is assumed to apply to \n" +"DVI page numbers, regardless of whether it is the only RANGE-LIST in the \n" +"RANGE-SPEC.\n" +"Examples:\n" +" ::2 Matches all even DVI page numbers.\n" +" 1::2 Matches all odd DVI page numbers.\n" +" {1:4}.*.{1:11:2,:15}.*\n" +" Matches \\counter0=1,2,3,4, and \\counter1=1,3,5,7,11,12,13,14,15\n" +" D{::2}.{5:}.*\n" +" Matches all even DVI page numbers AND \\counter0 >= 5.\n"; + +static const char units_help[] = +"Units:\n" +" MDVI recognizes all TeX units, plus some more:\n" +" Metric units: meters (mt), centimeters (cm), milimeters (mm)\n" +" US units: yard (yd), feet (ft), inches (in)\n" +" TeX units: points (pt), picas (pc), didot points (dd),\n" +" ciceros (cc), scaled points (sp)\n" +" Other units: big/PostScript points (bp), charspace (cs)\n"; + +static const char log_help[] = +"Logfile option: -l, --log-file=[LEVEL:]FILE\n" +" Tells MDVI to save all messages with priority at least LEVEL to FILE.\n" +"LEVEL is one of `info', `warn', `err' and `debug'. FILE can be the name\n" +"of a file or the values 1 (standard output) or 2 (standard error). The\n" +"name `-' is equivalent to `1'.\n"; + +static const char font_type_help[] = +"Font support option: -a, --font-types=FONTS\n" +" Tells MDVI which font types should be supported. FONTS is a comma\n" +"separated list of font `families' that MDVI is to recognize during this\n" +"run. A type name can be preceded by a class ID, which will become the\n" +"default class for all fonts in the FONTS specification after that ID.\n" +"Examples:\n" +" --font-types=0:vf,t1,tt,1:pk,m:tfm\n" +"This entry means: put the font types vf (virtual fonts), t1 (Type1) and\n" +"tt (TrueType) in class 0 (highest priority). In class 1, put type pk\n" +"(packet bitmap format). Finally, put type tfm (TeX font metric format)\n" +"in the metric class. Thus, MDVI will not lookup fonts other than these\n" +"to resolve the font references in the DVI file.\n" +"\n" +"To see the list of all font types known to MDVI, and their default class,\n" +"use `--font-types=list'. For a brief description of the font lookup\n" +"mechanism, use `--explain=fonts'.\n"; + +static struct { + const char *topic; + const char *desc; + const char *string; +} topics[] = { + {"log", "log file options", log_help}, + {"mdvi", "command line options", usage_help}, + {"units", "units supported by MDVI and their syntax", units_help}, + {"orientation", "syntax for specifying orientations", orientation_help}, + {"ranges", "syntax for specifying page ranges", range_help}, + {"debug", "debugging options", debug_help}, + {"font-types", "font support selection", font_type_help}, + {0, 0} +}; + +static void print_paper_specs(const char *title, DviPaperSpec *spec) +{ + int i; + char buf[256]; + int len = 0; + + printf("%s:\n", title); + for(i = 0; spec[i].name; i++) { + int n; + + n = sprintf(buf, " %10s: %6s x %s", + spec[i].name, + spec[i].width, + spec[i].height); + while(n < 30) + buf[n++] = ' '; + buf[n] = 0; + printf("%s", buf); + if(len || n >= 78) { + fputc('\n', stdout); + len = 0; + } else + len = n; + } + if(len) fputc('\n', stdout); +} + +static void print_fonts(void) +{ + struct fontinfo *fi; + + printf("Known font formats:\n\n"); + printf("%8s %-30s Class\n", "Name", "Description"); + printf("-----------------------------------------------\n"); + for(fi = known_fonts; fi->info; fi++) { + printf("%8s %-30s ", fi->info->name, fi->desc); + if(fi->klass == -1) + putchar('M'); + else if(fi->klass < -1) + putchar('-'); + else + printf("%d", fi->klass); + putchar('\n'); + } + putchar('\n'); + printf("Priority classes: 0 (highest) - %d (lowest), M (metric)\n", + mdvi_get_font_classes()); +} + +static void print_papers(void) +{ + DviPaperSpec *spec; + + spec = mdvi_get_paper_specs(MDVI_PAPER_CLASS_ISO); + if(spec != NULL) { + print_paper_specs(_("ISO paper types"), spec); + mdvi_free_paper_specs(spec); + } + spec = mdvi_get_paper_specs(MDVI_PAPER_CLASS_US); + if(spec != NULL) { + print_paper_specs(_("US paper types"), spec); + mdvi_free_paper_specs(spec); + } + printf( +"Custom paper types:\n" +" <NUMBER>x<NUMBER><UNIT> (e.g., 210x292.7mm)\n" +" <NUMBER><UNIT>,<NUMBER><UNIT> (e.g., 208.5mm,13in)\n"); +} + +static void usage(const char *string, int exit_code) +{ + const char *help = NULL; + int i; + + if(string == NULL) + help = usage_help; + else for(i = 0; topics[i].topic; i++) { + if(STRCEQ(string, topics[i].topic)) { + help = topics[i].string; + break; + } + } + + printf("%s", mdvi_banner); + if(help == NULL) + fprintf(stderr, _("%s: I don't know about that\n"), string); + else + printf("%s", help); + exit(exit_code); +} + + +void print_config(DviAppConfig *app) +{ + int i; + + printf("%s", mdvi_long_banner); + printf( +"Environment variables, and compiled defaults:\n" +" MDVI_DPI resolution (in pixels per inch) %d\n" +" MDVI_VDPI vertical resolution %d\n" +" MDVI_MAGNIFICATION magnification (1.0 = normal) %.2f\n" +" MDVI_SHRINKING shrinking factor %d\n" +" MDVI_HSHRINK horizontal shrinking factor %d\n" +" MDVI_VSHRINK vertical shrinking factor %d\n" +" MDVI_HDRIFT horizontal drifting tolerance %d\n" +" MDVI_VDRIFT vertical drifting tolerance %d\n" +" MDVI_PIXEL_DENSITY pixel density %d\n" +" MDVI_GAMMA gamma correction factor %.2f\n" +" MDVI_PAPER paper name %s\n" +" MDVI_HMARGIN horizontal margins around pages %s\n" +" MDVI_VMARGIN vertical margins around pages %s\n" +" MDVI_FALLBACK_FONT font to use when one is missing %s\n" +" MDVI_MFMODE default metafont mode %s\n" +" MDVI_HRUNITS units for horizontal rulers %s\n" +" MDVI_VRUNITS units for vertical rulers %s\n" +" MDVI_ORIENTATION page on-screen orientation %s\n" +" MDVI_FONTSPEC default font configuration builtin\n" +" MDVI_FONTOMIT fonts types omitted by default PKN\n" +" MDVI_FOREGROUND foreground color %s\n" +" MDVI_BACKGROUND background color %s\n" +" MDVI_DEBUG debug mask\n", + MDVI_DPI, + MDVI_VDPI, + MDVI_MAGNIFICATION, + MDVI_DEFAULT_SHRINKING, + -1, /* HSHRINK */ + -1, /* VSHRINK */ + -1, /* HDRIFT */ + -1, /* VDRIFT */ + MDVI_DEFAULT_DENSITY, + MDVI_DEFAULT_GAMMA, + MDVI_PAPERNAME, + MDVI_HMARGIN, + MDVI_VMARGIN, + MDVI_FALLBACK_FONT, + MDVI_MFMODE ? MDVI_MFMODE : "auto", + MDVI_HRUNITS, + MDVI_VRUNITS, + MDVI_ORIENTATION, + MDVI_FOREGROUND, + MDVI_BACKGROUND); + + putchar('\n'); + printf("Current configuration:\n"); + printf(" dpi: %d\n", app->params.dpi); + printf(" vdpi: %d\n", app->params.vdpi); + printf(" magnification: %.2f\n", app->params.mag); + printf(" hshrink: %d\n", app->params.hshrink); + printf(" vshrink: %d\n", app->params.vshrink); + printf(" hdrift: %d\n", app->params.hdrift); + printf(" vdrift: %d\n", app->params.vdrift); + printf(" pixel density: %d\n", app->params.density); + printf(" gamma factor: %.2f\n", app->params.gamma); + printf(" paper type: %s\n", app->paper.name); + printf(" margins: (%s,%s)\n", app->hmargin, app->vmargin); + printf(" fallback font: %s\n", app->fallback_font); + printf(" Metafont mode: %s\n", app->mfmode ? app->mfmode : "auto"); + printf(" ruler units: (%s,%s)\n", app->hrule_units, app->vrule_units); + printf(" orientation: %s\n", orientstr[app->params.orientation]); + printf(" font types: %s\n", app->fontspec ? app->fontspec : "all"); + printf(" fonts omitted: %s\n", app->fontunspec ? app->fontunspec : "none"); + printf(" foreground: %s\n", app->fgcolor); + printf(" background: %s\n", app->bgcolor); + + putchar('\n'); + printf("Fonts supported in this configuration:\n"); + for(i = -1; i <= mdvi_get_font_classes(); i++) { + char ** list; + int j; + + list = mdvi_list_font_class(i); + if(list == NULL) + break; + printf(" Class "); + if(i == -1) + printf("M: "); + else + printf("%d: ", i); + if(list[0] == NULL) + printf("None"); + else for(j = 0; list[j]; j++) { + printf("%s%s", j ? ", " : "", list[j]); + xfree(list[j]); + } + xfree(list); + putchar('\n'); + } +} + +int process_options(DviAppConfig *app, int argc, char **argv) +{ + static struct option dviopts[] = { + {"batch", 0, 0, 'z'}, + {"debug", 1, 0, 'd'}, + {"help", 2, 0, 'h'}, + {"info", 0, 0, 'i'}, + {"bg", 1, 0, 'B'}, + {"boxes", 0, 0, 'b'}, + {"dpi", 1, 0, 'D'}, + {"debug", 2, 0, 'd'}, + {"explain", 1, 0, 'e'}, + {"fallback-font", 1, 0, 'f'}, + {"fg", 1, 0, 'F'}, + {"font-types", 2, 0, 'a'}, + {"fonts-omitted", 2, 0, 'A'}, + {"gamma", 1, 0, 'G'}, + {"horizontal-margin", 1, 0, 'H'}, + {"log-file", 1, 0, 'l'}, + {"magnification", 1, 0, 'M'}, + {"mf-mode", 1, 0, 'm'}, + {"mono", 0, 0, 'N'}, + {"orientation", 1, 0, 'o'}, + {"page", 1, 0, 'P'}, + {"page-range", 1, 0, 'r'}, + {"paper", 1, 0, 'p'}, + {"pixel-density", 1, 0, 't'}, + {"shrink", 1, 0, 's'}, + {"sort-pages", 2, 0, 'S'}, + {"tex-page", 1, 0, 'T'}, + {"vertical-margin", 1, 0, 'V'}, + {"xdpi", 1, 0, 'x'}, + {"ydpi", 1, 0, 'y'}, + {"version", 0, 0, 'v'}, + {0, 0, 0, 0} + }; + + while(1) { + int c; + int ndx; + char *arg; + + c = getopt_long(argc, argv, + "a::A::d:hiB:bD:e:f:F:G:H:il:M:m:No:P:r:p:t:s:S:T:V:x:y:zv", + dviopts, &ndx); + + arg = optarg; + if(c == -1) + break; + + switch(c) { + case 'A': + case 'a': + if(arg && STRCEQ(arg, "list")) { + printf("%s", mdvi_banner); + print_fonts(); + exit(EXIT_SUCCESS); + } else if(arg && STRCEQ(arg, "help")) + usage("font-types", EXIT_SUCCESS); + if(c == 'a') + registered_fonts += configure_fonts(arg, 1); + else + configure_fonts(arg, 0); + break; + case 'b': + app->params.flags |= MDVI_PARAM_CHARBOXES; + break; + case 'B': + app->bgcolor = arg; + break; + case 'd': { + long mask; + + if(STREQ(arg, "list")) + usage("debug", EXIT_SUCCESS); + if(mdvi_getint(arg, &mask) < 0) + mask = (long)mdvi_get_debugmask(arg); + add_debug_mask((Uint32)mask); + break; + } + case 'x': + case 'y': + case 'D': { + long dpi; + + if(mdvi_getint(arg, &dpi) < 0 || dpi <= 0) + warning(_("resolution must be a positive integer\n")); + else if(c == 'x') + app->params.dpi = (Uint)dpi; + else if(c == 'y') + app->params.vdpi = (Uint)dpi; + else + app->params.dpi = app->params.vdpi = (Uint)dpi; + break; + } + case 'e': + if(STRCEQ(arg, "list")) { + int i; + + printf("%s", mdvi_banner); + printf(_("Known topics\n")); + for(i = 0; topics[i].topic; i++) + printf(" %-12s: %s\n", + topics[i].topic, topics[i].desc); + exit(EXIT_SUCCESS); + } else + usage(arg, EXIT_SUCCESS); + break; + case 'f': + app->fallback_font = arg; + break; + case 'F': + app->fgcolor = arg; + break; + case 'g': + /* UNUSED */ + break; + case 'G': + app->params.gamma = strtod(arg, NULL); + break; + case 'h': + usage(NULL, EXIT_SUCCESS); + break; + case 'H': + app->hmargin = arg; + break; + case 'i': + print_info_only = 1; + break; + case 'l': + if(STRNEQ(arg, "info:", 5)) { + arg += 5; + mdvi_set_loglevel(LOG_INFO); + } else if(STRNEQ(arg, "warn:", 5)) { + arg += 5; + mdvi_set_loglevel(LOG_WARN); + } else if(STRNEQ(arg, "err:", 4)) { + arg += 4; + mdvi_set_loglevel(LOG_ERROR); + } else if(STRNEQ(arg, "debug:", 6)) { + arg += 6; + mdvi_set_loglevel(LOG_DEBUG); + } else + mdvi_set_loglevel(LOG_WARN); + if(*arg == 0 || STREQ(arg, "-") || atoi(arg) == 1) + mdvi_set_logstream(stdout); + else if(atoi(arg) == 2) + mdvi_set_logstream(stderr); + else + mdvi_set_logfile(arg); + break; + case 'm': + app->mfmode = arg; + break; + case 'M': { + double mag; + + if(mdvi_getfloat(arg, &mag) < 0 || mag <= 0) { + warning(_("magnification must be positive\n")); + } else + app->params.mag = mag; + break; + } + case 'N': + app->params.flags &= ~MDVI_PARAM_ANTIALIASED; + app->params.flags |= MDVI_PARAM_MONO; + break; + case 'o': + if(STRCEQ(arg, "help")) + usage("orientation", EXIT_SUCCESS); + app->params.orientation = mdvi_getorient(arg); + break; + case 'p': + if(STRCEQ(arg, "help") || STRCEQ(arg, "list")) { + print_papers(); + exit(EXIT_SUCCESS); + } + app->paper.name = arg; + break; + case 'P': + if(mdvi_getint(arg, (long *)&app->first_page) < 0) { + warning(_("page number must be a positive integer\n")); + app->first_page = 0; + } else + app->use_tex_page = 0; + break; + case 'r': + if(STRCEQ(arg, "help")) + usage("ranges", EXIT_SUCCESS); + app->page_ranges = arg; + break; + case 's': { + long h, v; + + if(sscanf(arg, "%ld,%ld", &h, &v) == 2) { + app->params.vshrink = (Uint)v; + app->params.hshrink = (Uint)h; + } else if(mdvi_getint(arg, &h) < 0 || h < 0) { + warning(_("shrinking factor must be a non-negative number\n")); + } else + app->params.vshrink = + app->params.hshrink = (Uint)h; + break; + } + case 'S': { + int v; + + if(arg == NULL) + app->page_sort = MDVI_PAGE_SORT_UP; + else if((v = mdvi_get_pagesort(arg)) < 0) { + warning(_("unknown sorting type `%s'\n"), + arg); + app->page_sort = MDVI_PAGE_SORT_NONE; + } else + app->page_sort = v; + break; + } + case 't': { + long s; + + if(mdvi_getint(arg, &s) < 0 || s < 0) + warning(_("pixel density must be a non-negative number\n")); + else if(s > 100) { + warning(_("pixel density should be less than 100\n")); + s = 100; + } + app->params.density = (Uint)s; + break; + } + case 'T': { + long s; + + if(mdvi_getint(arg, &s) < 0) + warning(_("tex-page must be an integer\n")); + else { + app->first_page = (int)s; + app->use_tex_page = 1; + } + break; + } + case 'V': + app->vmargin = arg; + break; + case 'v': { + char *a, *b; + + printf("%s", mdvi_long_banner); + /* Check the library versions and report any differences */ + a = strrchr(KPSE_VERSION, ' '); + a = (a ? a + 1 : KPSE_VERSION); + b = strrchr(kpathsea_version_string, ' '); + b = (b ? b + 1 : kpathsea_version_string); + printf("Compiled with kpathsea %s", a); + if(!STREQ(a, b)) + printf(", using %s", b); + fputc('\n', stdout); + printf("Additional features:\n"); +#ifdef WITH_TYPE1_FONTS + printf("\tType1 fonts (t1lib %s)", T1LIB_VERSION); + b = T1_GetLibIdent(); + if(!STREQ(T1LIB_VERSION, b)) + printf(", using %s", b); + fputc('\n', stdout); +#endif +#ifdef WITH_TRUETYPE_FONTS + printf("\tTrueType fonts (Freetype 1.x)\n"); +#endif +#ifdef WITH_AFM_FILES + printf("\tAFM files\n"); +#endif +#ifdef WITH_OMEGA + printf("\tOmega file formats\n"); +#endif +#ifdef WITH_REGEX_SPECIALS + printf("\tRegex \\specials\n"); +#endif + printf("Using %dbit bitmap units\n", BITMAP_BITS); + exit(EXIT_SUCCESS); + break; + } + case 'z': + batch_mode = 1; + break; + default: + usage(NULL, EXIT_FAILURE); + break; + } + } + return optind; +} + +int configure_fonts(const char *spec, int enabled) +{ + int done = 0; + int klass = -2; /* unspecified */ + int nclasses; + const char *ptr; + const char *text; + struct fontinfo *type; + int count = 0; + + nclasses = mdvi_get_font_classes(); + if(spec == NULL || STRCEQ(spec, "all")) { + for(type = known_fonts; type->info; type++) { + if(!enabled) + type->klass = -2; + else if(type->klass != -2) + mdvi_register_font_type(type->info, type->klass); + count++; + } + if(!enabled) + DEBUG((DBG_FONTS, "all font types disabled by default\n")); + } else for(ptr = text = spec; !done; ptr++) { + int len; + int k; + int status; + char *name; + + if(*ptr && *ptr != ',') + continue; + if(*ptr == 0) + done = 1; + if((len = ptr - text) == 0) + continue; + if(len >= 2 && text[1] == ':') { + switch(text[0]) { + case 'm': case 'M': + k = -1; + break; + case '0': case '1': + case '2': case '3': + case '4': case '5': + case '6': case '7': + case '8': case '9': + k = *text - '0'; + break; + default: + text -= 2; /* will be fixed later */ + break; + } + if(k < -1 || k > nclasses) { + k = klass; + warning("font class %d does not exist\n"); + } + klass = k; + text += 2; + } else if(*text == ':') + k = klass = -3; + else + k = klass; + for(type = known_fonts; type->info; type++) { + if(STRNCEQ(type->info->name, text, len)) + break; + } + text = ptr + 1; + if(type->info == NULL) + continue; + name = type->info->name; + if(!enabled) { + DEBUG((DBG_FONTS, "%s fonts disabled by default\n", + name)); + type->klass = -2; + continue; + } + if(k < -2) + k = type->klass; + /* if the user wants to put a metric font in a real class, + * or the other way around, give a warning */ + if(type->klass < 0 && k >= 0) { + warning("adding %s fonts to `real' class %d\n", + name, k); + } else if(type->klass >= 0 && k < 0) { + warning("adding %s fonts to the metric class\n", + name); + } + + status = mdvi_register_font_type(type->info, k); + if(status < 0) { + warning("could not register font type `%s' in class %d\n", + name, k); + } else { + DEBUG((DBG_FONTS, "%s: added to font class %d\n", + name, k)); + count++; + } + } + return count; +} + +int main(int argc, char **argv) +{ + DviPageSpec *spec; + DviContext *ctx; + char *dvifile; + char *ptr; + int i; + +#ifdef ENABLE_NLS + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); +#endif + + program_name = strrchr(argv[0], '/'); + if(program_name == NULL) + program_name = argv[0]; + else + program_name++; + /* get as integer */ + ptr = getenv("MDVI_DEBUG"); + if(ptr != NULL) { + long x; + + if(mdvi_getint(ptr, &x) < 0) + x = (long)mdvi_get_debugmask(ptr); + set_debug_mask((Uint32)x); + } + + mdvi_app = mdvi_init_app(program_name, "mdvi"); + + if(mdvi_app->fontunspec) + configure_fonts(mdvi_app->fontunspec, 0); + + i = process_options(mdvi_app, argc, argv); + if(i < 0) + exit(EXIT_FAILURE); + + dvifile = argv[i]; + + /* check that everything is alright */ + if(mdvi_check_config(mdvi_app) < 0) + exit(EXIT_FAILURE); + + if(mdvi_app->page_ranges != NULL) + spec = mdvi_parse_page_spec(mdvi_app->page_ranges); + else + spec = NULL; + + if(mdvi_app->fallback_font == NULL) + mdvi_set_fallback_font(mdvi_app->fallback_font); +#ifdef MDVI_FALLBACK_FONT + else + mdvi_set_fallback_font(MDVI_FALLBACK_FONT); +#endif + + /* if no fonts have been registered, do that now */ + if(!registered_fonts) + registered_fonts = configure_fonts(mdvi_app->fontspec, 1); + if(!registered_fonts) + fatal("no font types registered\n"); + + if(print_info_only) { + print_config(mdvi_app); + exit(EXIT_SUCCESS); + } + + if(dvifile == NULL) { + fprintf(stderr, _("%s: no DVI file specified\n"), + program_name); + fprintf(stderr, _("Try `%s --help' for more information\n"), + program_name); + exit(EXIT_FAILURE); + } + + ctx = mdvi_init_context(&mdvi_app->params, spec, dvifile); + if(ctx == NULL) + exit(1); + ctx->paper = mdvi_app->paper; + if(!batch_mode && init_x11() == -1) + exit(EXIT_FAILURE); + + if(mdvi_app->page_sort != MDVI_PAGE_SORT_NONE) + mdvi_sort_pages(ctx, mdvi_app->page_sort); + + if(mdvi_app->use_tex_page) + mdvi_app->first_page = + mdvi_find_tex_page(ctx, mdvi_app->first_page); + else if(mdvi_app->first_page < 0) + mdvi_app->first_page += MDVI_LASTPAGE(ctx) + 1; + + if(!MDVI_VALIDPAGE(ctx, mdvi_app->first_page)) + mdvi_app->first_page = 0; + + if(batch_mode == 0) { + /* beginning of device-specific code */ + ctx->params.fg = get_color_byname(mdvi_app->fgcolor); + ctx->params.bg = get_color_byname(mdvi_app->bgcolor); + mdvi_create_window(ctx, NULL); + mdvi_reset_color(ctx); + view_page(ctx, mdvi_app->first_page); + /* end of device-specific code */ + } else { + ctx->params.fg = (Ulong)-1; + ctx->params.bg = 0; + if(DEBUGGING(DVI)) { + printf("%s", ctx->filename); + for(i = 0; i < ctx->npages; i++) { + mdvi_dopage(ctx, i); + printf(" [%d]", ctx->pagemap[i][1]); + } + } else + for(i = 0; i < ctx->npages; i++) + mdvi_dopage(ctx, i); + fputc('\n', stdout); + } + + mdvi_destroy_context(ctx); + mdvi_flush_fontmaps(); + mdvi_flush_encodings(); + mdvi_ps_flush_fonts(); + flush_color_table(); + + exit(0); +} diff --git a/dviware/mdvi/x11/dvidraw.c b/dviware/mdvi/x11/dvidraw.c new file mode 100644 index 0000000000..f0ecb68d94 --- /dev/null +++ b/dviware/mdvi/x11/dvidraw.c @@ -0,0 +1,1510 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdarg.h> + +#include "mdvi.h" +#include "private.h" +#include "x11.h" + +#define WIN_BORDER 0 +#define STATUS_BORDER 0 + +#define PAGEMOVE_TINY 0 +#define PAGEMOVE_SMALL 1 +#define PAGEMOVE_NORMAL 2 +#define PAGEMOVE_LARGE 3 + +#include <X11/keysym.h> +#include <X11/cursorfont.h> + +typedef struct { + Window win; + Uint w; + Uint h; + int xorig; + int yorig; + int minx; + int miny; + int maxx; + int maxy; + int dirty; +} WinArea; + +#define MAX_MARKS 16 + +typedef struct { + DrawArea area; + char **strings; + int size; + int top; +} StatusLine; + +typedef void (*RulerDrawer) __PROTO((DviContext *, int, int, int, int)); + +typedef struct { + TopWindow dd_top; + WinArea dd_dvi; + Ulong dd_fg; + Ulong dd_bg; + Uint dd_page_w; + Uint dd_page_h; + Uint dd_paper_w; + Uint dd_paper_h; + double dd_hruler_inches; + double dd_vruler_inches; + short dd_hsteps; + short dd_vsteps; + Uint dd_base_x; + Uint dd_base_y; + short dd_marks[MAX_MARKS]; + GC dd_gc; + short dd_busy; + int dd_ruler_xorig; + int dd_ruler_yorig; + int dd_ruler_x; + int dd_ruler_y; + int dd_inruler; + RulerDrawer dd_ruler_draw; + int dd_reset_origin; + DviAppConfig *dd_app; +} DviDrawData; + +/* these are constant after initialization */ +static Cursor busy, point; +static GC rulergc; +static GC scrollgc; + +extern DviAppConfig *mdvi_app; + +static DviOrientation pos_rotate_sequence[] = { + MDVI_ORIENT_RP90, + MDVI_ORIENT_IRP90, + MDVI_ORIENT_IRM90, + MDVI_ORIENT_RM90, + MDVI_ORIENT_BTRL, + MDVI_ORIENT_TBLR, + MDVI_ORIENT_BTLR, + MDVI_ORIENT_TBRL +}; + +static DviOrientation neg_rotate_sequence[] = { + MDVI_ORIENT_RM90, + MDVI_ORIENT_IRM90, + MDVI_ORIENT_IRP90, + MDVI_ORIENT_RP90, + MDVI_ORIENT_TBLR, + MDVI_ORIENT_BTRL, + MDVI_ORIENT_TBRL, + MDVI_ORIENT_BTLR +}; + +static DviOrientation h_flip_sequence[] = { + MDVI_ORIENT_TBRL, + MDVI_ORIENT_TBLR, + MDVI_ORIENT_BTRL, + MDVI_ORIENT_BTLR, + MDVI_ORIENT_IRM90, + MDVI_ORIENT_IRP90, + MDVI_ORIENT_RM90, + MDVI_ORIENT_RP90 +}; + +static DviOrientation v_flip_sequence[] = { + MDVI_ORIENT_BTLR, + MDVI_ORIENT_BTRL, + MDVI_ORIENT_TBLR, + MDVI_ORIENT_TBRL, + MDVI_ORIENT_IRP90, + MDVI_ORIENT_IRM90, + MDVI_ORIENT_RP90, + MDVI_ORIENT_RM90 +}; + +/* + * I know this is poor style, but it saves a lot of routine + * typing. + */ +#define GET_DRAW_DATA \ + DviDrawData *dd = (DviDrawData *)dvi->device.device_data + +#define top dd->dd_top +#define dviwin dd->dd_dvi +#define page_w dd->dd_page_w +#define page_h dd->dd_page_h +#define paper_w dd->dd_paper_w +#define paper_h dd->dd_paper_h +#define hruler_inches dd->dd_hruler_inches +#define vruler_inches dd->dd_vruler_inches +#define hsteps dd->dd_hsteps +#define vsteps dd->dd_vsteps +#define base_x dd->dd_base_x +#define base_y dd->dd_base_y +#define marks dd->dd_marks +#define drawgc dd->dd_gc +#define inruler dd->dd_inruler +#define reset_origin dd->dd_reset_origin +#define dviapp dd->dd_app + +#define NORULER 0 +#define HRULER 1 +#define VRULER 2 +#define VHRULER 3 + +#define SET_RULER_ORIGIN(t,x,y) do { \ + XSync(dpy, False); \ + dd->dd_ruler_xorig = dd->dd_ruler_x = (x); \ + dd->dd_ruler_yorig = dd->dd_ruler_y = (y); \ + switch(t) { \ + case NORULER: dd->dd_ruler_draw = NULL; break; \ + case HRULER: dd->dd_ruler_draw = draw_hruler; break; \ + case VRULER: dd->dd_ruler_draw = draw_vruler; break; \ + case VHRULER: dd->dd_ruler_draw = draw_ruler; break; \ + } \ + dd->dd_inruler = (t); \ + } while(0) + +#define UNSET_RULER() do { \ + dd->dd_ruler_draw = NULL; dd->dd_inruler = NORULER; \ + } while(0) + +#define DRAW_RULER() do { \ + if(dd->dd_ruler_draw) \ + dd->dd_ruler_draw(dvi, \ + dd->dd_ruler_xorig, \ + dd->dd_ruler_yorig, \ + dd->dd_ruler_x, \ + dd->dd_ruler_y); \ + } while(0) + +#define MOVE_RULER(x,y) do { \ + DRAW_RULER(); \ + dd->dd_ruler_x = (x); \ + dd->dd_ruler_y = (y); \ + DRAW_RULER(); \ + } while(0) + +#define WORKING() do { \ + if(++dd->dd_busy == 1 && busy != None) \ + XDefineCursor(dpy, top.win, busy); \ + } while(0) +#define RESTING() do { \ + if(--dd->dd_busy == 0 && busy != None) \ + XUndefineCursor(dpy, top.win); \ + } while(0) + +int mdvi_create_window(DviContext *dvi, const char *geometry); +void view_page __PROTO((DviContext *dvi, int pageno)); + +static void print_key_help __PROTO((void)); +static void handle_special_key __PROTO((DviContext *dvi, int argno, int den, KeySym sym, int state)); +static void handle_key __PROTO((DviContext *dvi, XKeyEvent *ev)); +static void do_redraw __PROTO((DviContext *dvi)); +static void do_expose __PROTO((DviContext *dvi, int x, int y, Uint w, Uint h)); +static void handle_dvi __PROTO((DviContext *dvi, XEvent *ev)); +static void x11_draw_glyph __PROTO((DviContext *dvi, DviFontChar *ch, int x0, int y0)); +static void x11_draw_rule __PROTO((DviContext *dvi, int x, int y, Uint w, Uint h, int)); +static void draw_hticks __PROTO((DviContext *dvi, int x, int y, int x2)); +static void draw_vticks __PROTO((DviContext *dvi, int x, int y, int y2)); +static void draw_hruler __PROTO((DviContext *dvi, int x1, int y1, int x2, int y2)); +static void draw_vruler __PROTO((DviContext *dvi, int x1, int y1, int x2, int y2)); +static void draw_ruler __PROTO((DviContext *dvi, int x, int y, int x2, int y2)); +static void reset_page __PROTO((DviContext *dvi)); +static void reset_view_origin __PROTO((DviContext *dvi)); +static void position_windows __PROTO((DviContext *dvi)); +static int configure_window __PROTO((DviContext *dvi)); +static void scroll_window __PROTO((DviContext *dvi, int newx, int newy)); +static void pageup __PROTO((DviContext *dvi, int n, int mode)); +static void pageleft __PROTO((DviContext *dvi, int n, int mode)); +static int set_pageno __PROTO((DviContext *dvi, int page)); +static int set_tex_pageno __PROTO((DviContext *dvi, int page)); +static void top_events __PROTO((DviContext *dvi, XEvent *ev)); + +extern void font_print __PROTO((void)); + +/* functions that are used as DviDevice in the DVI context */ + +static void x11_draw_glyph(DviContext *dvi, DviFontChar *ch, int x0, int y0) +{ + int rx, ry; + int x, y, w, h; + int isbitmap; + int isbox; + DviGlyph *glyph; + GET_DRAW_DATA; + + /* coordinates into the page */ + rx = base_x + x0; + ry = base_y + y0; + + isbitmap = 1; + if(dvi->params.hshrink == 1 && dvi->params.vshrink == 1) + glyph = &ch->glyph; + else if(dvi->params.flags & MDVI_PARAM_ANTIALIASED) { + glyph = &ch->grey; + isbitmap = 0; + } else + glyph = &ch->shrunk; + + isbox = (glyph->data == NULL || + (dvi->params.flags & MDVI_PARAM_CHARBOXES)); + + x = glyph->x; + y = glyph->y; + w = glyph->w; + h = glyph->h; + + switch(dvi->params.orientation) { + case MDVI_ORIENT_TBLR: + break; + case MDVI_ORIENT_TBRL: + rx = page_w - rx; + break; + case MDVI_ORIENT_BTLR: + ry = page_h - ry; + break; + case MDVI_ORIENT_BTRL: + rx = page_w - rx; + ry = page_h - ry; + break; + case MDVI_ORIENT_RP90: + SWAPINT(rx, ry); + ry = page_h - ry; + break; + case MDVI_ORIENT_RM90: + SWAPINT(rx, ry); + rx = page_w - rx; + break; + case MDVI_ORIENT_IRM90: + SWAPINT(rx, ry); + rx = page_w - rx; + ry = page_h - ry; + break; + case MDVI_ORIENT_IRP90: + SWAPINT(rx, ry); + break; + default: + break; + } + + rx -= x + dviwin.xorig; + ry -= y + dviwin.yorig; + + /* + * drawing is allowed only in the rectangle inside + * [minx, miny] - [maxx, maxy] + * of dviwin + */ + if(rx > dviwin.maxx || dviwin.minx > rx + w || + ry > dviwin.maxy || dviwin.miny > ry + h) + return; + if(isbox) + XDrawRectangle(dpy, dviwin.win, drawgc, + rx, ry, w, h); + else if(isbitmap) + draw_bitmap(dviwin.win, (BITMAP *)glyph->data, rx, ry); + else + put_image(dviwin.win, glyph->data, rx, ry, w, h); +} + +static void x11_draw_rule(DviContext *dvi, int x, int y, Uint w, Uint h, int fill) +{ + int rx, ry; + GET_DRAW_DATA; + + rx = base_x + x; + ry = base_y + y; + + switch(dvi->params.orientation) { + case MDVI_ORIENT_TBLR: + break; + case MDVI_ORIENT_TBRL: + rx = page_w - rx - w; + break; + case MDVI_ORIENT_BTLR: + ry = page_h - ry - h; + break; + case MDVI_ORIENT_BTRL: + rx = page_w - rx - w; + ry = page_h - ry - h; + break; + case MDVI_ORIENT_RP90: + SWAPINT(rx, ry); + SWAPINT(w, h); + ry = page_h - ry - h; + break; + case MDVI_ORIENT_RM90: + SWAPINT(rx, ry); + SWAPINT(w, h); + rx = page_w - rx - w; + break; + case MDVI_ORIENT_IRM90: + SWAPINT(rx, ry); + SWAPINT(w, h); + rx = page_w - rx - w; + ry = page_h - ry - h; + break; + case MDVI_ORIENT_IRP90: + SWAPINT(rx, ry); + SWAPINT(w, h); + break; + } + rx -= dviwin.xorig; + ry -= dviwin.yorig; + + if(rx <= dviwin.maxx && dviwin.minx <= rx + w && + ry <= dviwin.maxy && dviwin.miny <= ry + h) { + if(fill == 0) + XDrawRectangle(dpy, dviwin.win, image_gc, + rx, ry, w ? w : 1, h ? h : 1); + else + XFillRectangle(dpy, dviwin.win, image_gc, + rx, ry, w ? w : 1, h ? h : 1); + } +} + +static int x11_interpolate_colors(void *device_data, + Ulong *pixels, int nlevels, Ulong fg, Ulong bg, double g, int density) +{ + double frac; + XColor xc, xfg, xbg; + int i, n; + + xfg.pixel = fg; + xbg.pixel = bg; + XQueryColor(dpy, colormap, &xfg); + XQueryColor(dpy, colormap, &xbg); + + n = nlevels - 1; + for(i = 0; i < nlevels; i++) { + if(g > 0) + frac = pow((double)i / n, 1 / g); + else + frac = 1 - pow((double)(n - i) / n, -g); + xc.red = frac * ((double)xfg.red - xbg.red) + xbg.red; + xc.green = frac * ((double)xfg.green - xbg.green) + xbg.green; + xc.blue = frac * ((double)xfg.blue - xbg.blue) + xbg.blue; + if(XAllocColor(dpy, colormap, &xc)) + pixels[i] = xc.pixel; + else + pixels[i] = (i * 100 >= density * 15) ? + xfg.pixel : xbg.pixel; + } + return nlevels; +} + +static void *x11_create_image(void *device_data, Uint w, Uint h, Uint bpp) +{ + XImage *image; + + image = XCreateImage(dpy, visual, depth, ZPixmap, 0, + (char *)0, w, h, bpp, 0); + image->data = xcalloc(image->bytes_per_line, h); + return image; +} + +static void x11_free_image(void *ptr) +{ + XImage *image = (XImage *)ptr; + char *data; + + data = image->data; + image->data = NULL; + XDestroyImage(image); + xfree(data); +} + +static void x11_put_pixel(void *image, int x, int y, Ulong color) +{ + XPutPixel((XImage *)image, x, y, color); +} + +static void x11_refresh(DviContext *dvi, void *device_data) +{ + GET_DRAW_DATA; + + configure_window(dvi); + if(!reset_origin) + set_pageno(dvi, dvi->currpage); +} + +static void x11_set_color(void *device_data, Ulong fg, Ulong bg) +{ + DviDrawData *dd = (DviDrawData *)device_data; + + if(fg != dd->dd_fg) { + DEBUG((DBG_DEVICE, "foreground %lu -> %lu\n", + dd->dd_fg, fg)); + XSetForeground(dpy, image_gc, fg); + dd->dd_fg = fg; + } + if(bg != dd->dd_bg) { + DEBUG((DBG_DEVICE, "background %lu -> %lu\n", + dd->dd_bg, bg)); + XSetBackground(dpy, image_gc, bg); + dd->dd_bg = bg; + } +} + +/* draws tick marks for horizontal rulers */ +static void draw_hticks(DviContext *dvi, int x, int y, int x2) +{ + int i, n; + double dh; + GET_DRAW_DATA; + + dh = hruler_inches * dvi->params.dpi / (hsteps * dvi->params.hshrink); + if(x > x2) + dh = -dh; + for(n = 0, i = x; (x < x2 ? i < x2 : i > x2); ) { + if(hsteps > 1 && (n % hsteps) == 0) + XDrawLine(dpy, dviwin.win, rulergc, i, y+6, i, y-6); + else if((hsteps & 1) || (n % (hsteps >> 1))) + XDrawLine(dpy, dviwin.win, rulergc, i, y+2, i, y-2); + else + XDrawLine(dpy, dviwin.win, rulergc, i, y+4, i, y-4); + i = x + FROUND(++n * dh); + } +} + +/* draws tick marks for vertical rulers */ +static void draw_vticks(DviContext *dvi, int x, int y, int y2) +{ + int i, n; + double dh; + GET_DRAW_DATA; + + dh = vruler_inches * dvi->params.vdpi / (vsteps * dvi->params.vshrink); + if(y > y2) + dh = -dh; + for(n = 0, i = y; (y < y2 ? i < y2 : i > y2); ) { + if(vsteps > 1 && (n % vsteps) == 0) + XDrawLine(dpy, dviwin.win, rulergc, x+6, i, x-6, i); + else if((vsteps & 1) || (n % (vsteps >> 1))) + XDrawLine(dpy, dviwin.win, rulergc, x+2, i, x-2, i); + else + XDrawLine(dpy, dviwin.win, rulergc, x+4, i, x-4, i); + i = y + FROUND(++n * dh); + } +} + +static void draw_hruler(DviContext *dvi, int x1, int y1, int x2, int y2) +{ + int tx, ty, n, d; + double fraction; + char str[64]; + GET_DRAW_DATA; + + /* grab the server */ + XRaiseWindow(dpy, dviwin.win); + XSync(dpy, True); + XGrabServer(dpy); + + /* draw a horizontal line */ + XDrawLine(dpy, dviwin.win, rulergc, + x1, y1, x2, y1); + + /* draw tick marks */ + draw_hticks(dvi, x1, y1, x2); + + /* draw a small rectangle at the end of the ruler */ + XFillRectangle(dpy, dviwin.win, rulergc, x2-1, y1-1, 3, 3); + XDrawLine(dpy, dviwin.win, rulergc, x2, y1, x2, y2); + + /* draw text */ + if(x1 != x2) { + /* make the text centered under the ruler */ + fraction = (double)abs(x1 - x2) * dvi->params.hshrink / + (dvi->params.dpi * hruler_inches); + d = sprintf(str, "%.2f", fraction); + n = XTextWidth(default_font, str, d); + tx = x2 + 15; + ty = y2 - FONT_HEIGHT(default_font) / 2 + + default_font->max_bounds.ascent; + if(ty - 2 < default_font->max_bounds.ascent) + ty = default_font->max_bounds.ascent + 2; + if(ty + default_font->max_bounds.descent + 2 > dviwin.h) + ty = dviwin.h - default_font->max_bounds.descent - 2; + if(tx < 2) + tx = 2; + if(tx + n + 2 > dviwin.w) + tx = Min(x2, dviwin.w) - n - 10; + XDrawString(dpy, dviwin.win, rulergc, tx, ty, str, d); + } + XUngrabServer(dpy); +} + +static void draw_vruler(DviContext *dvi, int x1, int y1, int x2, int y2) +{ + int tx, ty, n, d; + char str[64]; + double fraction; + GET_DRAW_DATA; + + /* grab the server */ + XGrabServer(dpy); + + /* draw a horizontal line */ + XDrawLine(dpy, dviwin.win, rulergc, x1, y1, x1, y2); + + /* draw tick marks */ + draw_vticks(dvi, x1, y1, y2); + + /* draw a small rectangle at the end of the ruler */ + XFillRectangle(dpy, dviwin.win, rulergc, x1-1, y2-1, 3, 3); + XDrawLine(dpy, dviwin.win, rulergc, x1, y2, x2, y2); + + /* draw text */ + if(y1 != y2) { + /* make the text centered under the ruler */ + fraction = (double)abs(y1 - y2) * dvi->params.vshrink / + (dvi->params.vdpi * vruler_inches); + d = sprintf(str, "%.2f", fraction); + n = XTextWidth(default_font, str, d); + if(n % 2) n++; + tx = x2 - n / 2; + ty = y2 + default_font->max_bounds.ascent + 10; + /* make sure the text is visible */ + if(tx < 2) + tx = 2; + if(tx + n + 2 > dviwin.w) + tx = dviwin.w - n - 2; + if(ty > 0 && ty > dviwin.h - 2) + ty = Min(y2, dviwin.h) - default_font->max_bounds.descent - 10; + if(ty < default_font->max_bounds.ascent + 2) + ty = default_font->max_bounds.ascent + 2; + XDrawString(dpy, dviwin.win, rulergc, tx, ty, str, d); + } + XUngrabServer(dpy); +} + +/*ARGSUSED*/ +static void draw_ruler(DviContext *dvi, int x0, int y0, int x, int y) +{ + GET_DRAW_DATA; + + /* Grab the server */ + XGrabServer(dpy); + + /* Draw horizontal line */ + XDrawLine(dpy, dviwin.win, rulergc, 0, y, dviwin.w, y); + + /* Draw vertical line */ + XDrawLine(dpy, dviwin.win, rulergc, x, 0, x, dviwin.h); + + /* hand back the server */ + XUngrabServer(dpy); + + /* draw ticks */ + + /* horizontal ticks */ + draw_hticks(dvi, x, y, dviwin.w); + draw_hticks(dvi, x, y, 0); + + /* vertical ticks */ + draw_vticks(dvi, x, y, dviwin.h); + draw_vticks(dvi, x, y, 0); + +} + +static void reset_page(DviContext *dvi) +{ + GET_DRAW_DATA; + + dviwin.minx = 0; + dviwin.miny = 0; + dviwin.maxx = dviwin.w; + dviwin.maxy = dviwin.h; + dviwin.dirty = 1; +} + +static void reset_view_origin(DviContext *dvi) +{ + GET_DRAW_DATA; + + switch(dvi->params.orientation) { + case MDVI_ORIENT_TBLR: + case MDVI_ORIENT_IRP90: + dviwin.xorig = 0; + dviwin.yorig = 0; + break; + case MDVI_ORIENT_TBRL: + case MDVI_ORIENT_RM90: + dviwin.xorig = page_w - dviwin.w; + dviwin.yorig = 0; + break; + case MDVI_ORIENT_BTLR: + case MDVI_ORIENT_RP90: + dviwin.xorig = 0; + dviwin.yorig = page_h - dviwin.h; + break; + case MDVI_ORIENT_BTRL: + case MDVI_ORIENT_IRM90: + dviwin.xorig = page_w - dviwin.w; + dviwin.yorig = page_h - dviwin.h; + break; + } + if(dviwin.xorig < 0) + dviwin.xorig = 0; + if(dviwin.yorig < 0) + dviwin.yorig = 0; + +} + +static void position_windows(DviContext *dvi) +{ + int tw, th; + GET_DRAW_DATA; + + tw = top.w - 2*WIN_BORDER; + th = top.h - 2*WIN_BORDER; + XMoveResizeWindow(dpy, dviwin.win, 0, 0, tw, th); + dviwin.w = tw; + dviwin.h = th; + reset_page(dvi); +} + +static int configure_window(DviContext *dvi) +{ + Uint w, h; + double ratio; + int hs, vs; + int changed = 0; + GET_DRAW_DATA; + + ratio = dvi->paper.inches_tall / dvi->paper.inches_wide; + base_x = unit2pix(dvi->params.dpi, dviapp->hmargin); + base_y = unit2pix(dvi->params.vdpi, dviapp->vmargin); + page_w = FROUND(dvi->dviconv * dvi->dvi_page_w); + page_h = FROUND(dvi->dvivconv * dvi->dvi_page_h); + hs = dvi->params.hshrink; + vs = dvi->params.vshrink; + if(!hs && !vs) { + /* compute both */ + w = root_w; + h = FROUND(w * ratio); + if(h > root_h) { + h = root_h; + w = FROUND(h / ratio); + } + /* determine shrinking factors */ + hs = ROUND(page_w + 2*base_x, w); + vs = ROUND(page_h + 2*base_y, h); + if(hs < 1) hs = 1; + if(vs < 1) vs = 1; + } else if(!hs) { + h = FROUND(dvi->params.vdpi * dvi->paper.inches_tall / + dvi->params.vshrink) + 2; + w = FROUND(h / ratio); + hs = ROUND(page_w + 2*base_x, w); + } else if(!vs) { + w = FROUND(dvi->params.dpi * dvi->paper.inches_wide / + dvi->params.hshrink) + 2; + h = FROUND(w * ratio); + vs = ROUND(page_h + 2*base_y, h); + } else { + w = FROUND(dvi->params.dpi * dvi->paper.inches_wide / + dvi->params.hshrink) + 2; + h = FROUND(dvi->params.vdpi * dvi->paper.inches_tall / + dvi->params.vshrink) + 2; + } + + /* convert page dimensions */ + if(!dvi->params.hshrink) { + dvi->params.hshrink = hs; + dvi->params.conv /= hs; + } + if(!dvi->params.vshrink) { + dvi->params.vshrink = vs; + dvi->params.vconv /= vs; + } + + /* fix margins */ + base_x = unit2pix(dvi->params.dpi, dviapp->hmargin) / dvi->params.hshrink; + base_y = unit2pix(dvi->params.vdpi, dviapp->vmargin) / dvi->params.vshrink; + + /* recompute things now that we have all the information */ + page_w = pixel_round(dvi, dvi->dvi_page_w) + base_x; + page_h = vpixel_round(dvi, dvi->dvi_page_h) + base_y; + + /* get paper dimensions */ + paper_w = FROUND(dvi->params.dpi * dvi->paper.inches_wide / + dvi->params.hshrink) + 2; + paper_h = FROUND(dvi->params.vdpi * dvi->paper.inches_tall / + dvi->params.vshrink) + 2; + + /* this is the new window size */ + if(page_w < paper_w) + page_w = paper_w; + if(page_h < paper_h) + page_h = paper_h; + + switch(dvi->params.orientation) { + case MDVI_ORIENT_TBLR: + case MDVI_ORIENT_TBRL: + case MDVI_ORIENT_BTLR: + case MDVI_ORIENT_BTRL: + break; + case MDVI_ORIENT_RP90: + case MDVI_ORIENT_RM90: + case MDVI_ORIENT_IRP90: + case MDVI_ORIENT_IRM90: + SWAPINT(paper_w, paper_h); + SWAPINT(page_w, page_h); + break; + } + + w = Min(page_w, root_w); + h = Min(page_h, root_h); + + changed = 1; + if(top.win == None) { + create_top_window(&top, dvi->filename, w, h); + expose_window(top.win, False); + get_win_size(top.win, &top.w, &top.h); + } else if(w != top.w || h != top.h) + XResizeWindow(dpy, top.win, w, h); + else + changed = 0; + + /* setup ruler units */ + hruler_inches = unit2pix_factor(dviapp->hrule_units); + vruler_inches = unit2pix_factor(dviapp->vrule_units); + ratio = hruler_inches * dvi->params.dpi; + if(ratio < 10) + hsteps = 1; + else if(ratio < 100) + hsteps = 5; + else + hsteps = 10; + ratio = vruler_inches * dvi->params.vdpi; + if(ratio < 10) + vsteps = 1; + else if(ratio < 100) + vsteps = 5; + else + vsteps = 10; + + return changed; +} + +int mdvi_create_window(DviContext *dvi, const char *geometry) +{ + DviDrawData *dd; + int i; + + dd = xalloc(DviDrawData); + memzero(dd, sizeof(DviDrawData)); + dvi->device.device_data = dd; + + /* if this looks weird, see the comment about bad style above */ + dviapp = mdvi_app; + top.win = None; + configure_window(dvi); + if(top.win == None) + return -1; + + XSelectInput(dpy, top.win, + ExposureMask|StructureNotifyMask|KeyPressMask); + + /* GC for drawing */ + drawgc = create_gc(GXcopy, top.win, dvi->params.fg, dvi->params.bg); + + /* GC for rulers */ + rulergc = create_gc(GXxor, top.win, white, black); + + /* create our child window */ + dviwin.win = create_window(top.win, dvi->params.bg, + top.w - 2*WIN_BORDER, + top.h - 2*WIN_BORDER, WIN_BORDER); + XSelectInput(dpy, dviwin.win, + ExposureMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask); + get_win_size(dviwin.win, &dviwin.w, &dviwin.h); + dviwin.minx = 0; + dviwin.miny = 0; + dviwin.maxx = dviwin.w; + dviwin.maxy = dviwin.h; + + reset_view_origin(dvi); + add_window_events(dviwin.win, ButtonMotionMask); + + /* GC for scrolling */ + scrollgc = create_gc(GXcopy, dviwin.win, dvi->params.fg, dvi->params.bg); + XSetGraphicsExposures(dpy, scrollgc, True); + + /* setup the functions in the dvi context */ + dvi->device.draw_glyph = x11_draw_glyph; + dvi->device.draw_rule = x11_draw_rule; + dvi->device.alloc_colors = x11_interpolate_colors; + dvi->device.create_image = x11_create_image; + dvi->device.free_image = x11_free_image; + dvi->device.put_pixel = x11_put_pixel; + dvi->device.set_color = x11_set_color; + dvi->device.refresh = NULL; /*x11_refresh;*/ + + /* initialize marks */ + for(i = 0; i < MAX_MARKS; i++) + marks[i] = -1; + + position_windows(dvi); + + printf("Type `q' to quit, `?' to see keyboard and mouse commands\n"); + + return 0; +} + +static void scroll_window(DviContext *dvi, int newx, int newy) +{ + int x, y, w, h; + int src_x, dest_x; + int src_y, dest_y; + GET_DRAW_DATA; + + x = newx - dviwin.xorig; + y = newy - dviwin.yorig; + dviwin.xorig = newx; + dviwin.yorig = newy; + dviwin.minx -= x; + dviwin.maxx -= x; + dviwin.miny -= y; + dviwin.maxy -= y; + if(dviwin.minx < 0) + dviwin.minx = 0; + if(dviwin.miny < 0) + dviwin.miny = 0; + if(dviwin.maxx > dviwin.w) + dviwin.maxx = dviwin.w; + if(dviwin.maxy > dviwin.h) + dviwin.maxy = dviwin.h; + + if(x > 0) { + src_x = x; + dest_x = 0; + } else { + src_x = 0; + dest_x = -x; + } + if(y > 0) { + src_y = y; + dest_y = 0; + } else { + src_y = 0; + dest_y = -y; + } + w = dviwin.w - abs(x); + h = dviwin.h - abs(y); + if(w <= 0 || h <= 0) { + /* need to refresh the entire window */ + reset_page(dvi); + XClearArea(dpy, dviwin.win, 0, 0, dviwin.w, dviwin.h, True); + } else { + XCopyArea(dpy, dviwin.win, dviwin.win, scrollgc, + src_x, src_y, w, h, dest_x, dest_y); + if(dest_x > 0 && h) + XClearArea(dpy, dviwin.win, + 0, dest_y, dviwin.w - w, h, True); + else if(dest_x == 0 && h) + XClearArea(dpy, dviwin.win, + w, dest_y, dviwin.w - w, h, True); + if(dest_y > 0 && w) + XClearArea(dpy, dviwin.win, + dest_x, 0, w, dviwin.h - h, True); + else if(dest_y == 0 && w) + XClearArea(dpy, dviwin.win, + dest_x, h, w, dviwin.h - h, True); + if(w < dviwin.w && h < dviwin.h) { + XClearArea(dpy, dviwin.win, + dest_x ? 0 : w, + dest_y ? 0 : h, + dviwin.w - w, dviwin.h - h, True); + } + } +} + +static void pageup(DviContext *dvi, int n, int mode) +{ + int z; + int maxh; + GET_DRAW_DATA; + + n = n * (int)page_h; + switch(mode) { + case PAGEMOVE_TINY: n /= 80; break; + case PAGEMOVE_SMALL: n /= 40; break; + case PAGEMOVE_NORMAL: n /= 10; break; + case PAGEMOVE_LARGE: break; + } + + z = dviwin.yorig + n; + maxh = page_h - dviwin.h; + if(z > maxh) + z = maxh; + if(z < 0) + z = 0; + if(z != dviwin.yorig) + scroll_window(dvi, dviwin.xorig, z); + else + beep_sound(); +} + +static void pageleft(DviContext *dvi, int n, int mode) +{ + int z; + int maxw; + GET_DRAW_DATA; + + n = n * (int)page_w; + switch(mode) { + case PAGEMOVE_TINY: n /= 80; break; + case PAGEMOVE_SMALL: n /= 40; break; + case PAGEMOVE_NORMAL: n /= 10; break; + case PAGEMOVE_LARGE: break; + } + z = dviwin.xorig + n; + maxw = page_w - dviwin.w; + if(z > maxw) + z = maxw; + if(z < 0) + z = 0; + if(z != dviwin.xorig) + scroll_window(dvi, z, dviwin.yorig); + else + beep_sound(); +} + +static int set_pageno(DviContext *dvi, int page) +{ + GET_DRAW_DATA; + + if(page < 0 || page > dvi->npages - 1) + return -1; + dvi->currpage = page; + reset_page(dvi); + XClearArea(dpy, dviwin.win, 0, 0, dviwin.w, dviwin.h, True); + return 0; +} + +static int set_tex_pageno(DviContext *dvi, int tex_page) +{ + int page; + + page = mdvi_find_tex_page(dvi, tex_page); + if(page == dvi->npages) + return -1; + return set_pageno(dvi, page); +} + +void print_key_help(void) +{ + printf( +"Keystroke commands: (S=Shift, C=Control)\n" +" PageUp/PageDown go to previous/next page\n" +" C-PageUp/PageDown go to first/last page\n" +" [S/C] Left/Right scroll document horizontally\n" +" Up/Down scroll document vertically\n" +" q quit\n" +" b switch between your eyes and TeX's\n" +" a toggle antialiasing\n" +" l redraw page\n" +" L reload the DVI file from disk\n" +" R/r rotate page clockwise/counter-clockwise\n" +" F/f flip page vertically/horizontally\n" +" ? this help\n" +" (NUM) p go to current page + NUM (-\\infty < NUM < \\infty)\n" +" (NUM) j go to output page number NUM (last+NUM if NUM < 0)\n" +" (NUM) t go to TeX's (i.e. document's) page number NUM\n" +" (NUM) d change resolution\n" +" (NUM) m change magnification\n" +" (NUM) s change shrinking factor (both set to NUM)\n" +" (NUM) x change horizontal shrinking factor\n" +" (NUM) y change vertical shrinking factor\n" +" (NUM) n change pixel density (for bitmap shrinking)\n" +" (NUM) g change gamma correction factor\n" +" C-Fn set bookmark\n" +" Fn goto bookmark\n" +"Mouse usage:\n" +" Button 1 display ruler\n" +" Button 1 + Shift display horizontal ruler\n" +" Button 1 + Control display vertical ruler\n" + ""); +} + +void handle_special_key(DviContext *dvi, int argno, int den, KeySym sym, int state) +{ + int arg; + GET_DRAW_DATA; + + switch(sym) { + case XK_Page_Down: + if(state & ControlMask) + arg = dvi->npages - 1; + else + arg = dvi->currpage + 1; + if(arg != dvi->currpage && set_pageno(dvi, arg) < 0) + beep_sound(); + break; + case XK_Page_Up: + if(state & ControlMask) + arg = 0; + else + arg = dvi->currpage - 1; + if(arg != dvi->currpage && set_pageno(dvi, arg) < 0) + beep_sound(); + break; + case XK_Left: + if(state & ControlMask) + arg = PAGEMOVE_TINY; + else if(state & ShiftMask) + arg = PAGEMOVE_SMALL; + else + arg = PAGEMOVE_NORMAL; + pageleft(dvi, -1, arg); + break; + case XK_Right: + if(state & ControlMask) + arg = PAGEMOVE_TINY; + else if(state & ShiftMask) + arg = PAGEMOVE_SMALL; + else + arg = PAGEMOVE_NORMAL; + pageleft(dvi, 1, arg); + break; + case XK_Up: + if(state & ControlMask) + arg = PAGEMOVE_TINY; + else if(state & ShiftMask) + arg = PAGEMOVE_SMALL; + else + arg = PAGEMOVE_NORMAL; + pageup(dvi, -1, arg); + break; + case XK_Down: + if(state & ControlMask) + arg = PAGEMOVE_TINY; + else if(state & ShiftMask) + arg = PAGEMOVE_SMALL; + else + arg = PAGEMOVE_NORMAL; + pageup(dvi, 1, arg); + break; + case XK_F1: arg = 0; goto setmark; + case XK_F2: arg = 1; goto setmark; + case XK_F3: arg = 2; goto setmark; + case XK_F4: arg = 3; goto setmark; + case XK_F5: arg = 4; goto setmark; + case XK_F6: arg = 5; goto setmark; + case XK_F7: arg = 6; goto setmark; + case XK_F8: arg = 7; goto setmark; + case XK_F9: arg = 8; goto setmark; + case XK_F10: arg = 9; goto setmark; + case XK_F11: arg = 10; goto setmark; + case XK_F12: arg = 11; goto setmark; + case XK_F13: arg = 12; goto setmark; + case XK_F14: arg = 13; goto setmark; + case XK_F15: arg = 14; goto setmark; + case XK_F16: arg = 15; goto setmark; + setmark: + if(arg < 0 || arg >= MAX_MARKS) { + beep_sound(); + break; + } + if(state & ControlMask) { + /* set a mark */ + marks[arg] = dvi->currpage; + } else if(marks[arg] >= 0) { + if(set_pageno(dvi, marks[arg]) < 0) + beep_sound(); + } + break; + default: + break; + } +} + +#define NEWNUMBER \ + (has_number = 1, has_dot = 0, number = 0, logten = 1, sign = 1) +#define RESETNUMBER \ + (has_number = has_dot = 0, number = 0, sign = 1) + +void handle_key(DviContext *dvi, XKeyEvent *ev) +{ + char num_buf[256]; + int length; + char ch; + KeySym sym; + XComposeStatus unused; + int reconfigure = 0; + static int has_number = 0; + static int sign = 1; + static int number; + static int has_dot = 0; + static double logten = 1; + GET_DRAW_DATA; + + length = XLookupString(ev, num_buf, 256, &sym, &unused); + if(length == 0) { + sym = XLookupKeysym(ev, 0); + if(sym != NoSymbol) { + handle_special_key(dvi, + has_number ? number : 0, + has_dot ? logten : 1, + sym, ev->state); + } + RESETNUMBER; + return; + } + if(length == 1) + ch = num_buf[0]; + else + ch = 0; + + /* if user is typing a number, update our state */ + if(ch >= '0' && ch <= '9') { + has_number = 1; + number = number * 10 + sign * (ch - '0'); + if(has_dot) logten *= 10; + return; + } else if(ch == '-') { + NEWNUMBER; + sign = -1; + return; + } else if(ch == '+') { + NEWNUMBER; + return; + } else if(ch == '.' && !has_dot) { + /* it's a floating point number */ + has_number = 1; + has_dot = 1; + logten = 1; + return; + } + + switch(ch) { + case 8: + if(has_number) + dvi->params.layer = FROUND((double)number / logten); + else if(dvi->params.layer) + dvi->params.layer--; + set_pageno(dvi, dvi->currpage); + break; + case 9: + if(has_number) + dvi->params.layer = FROUND((double)number / logten); + else + dvi->params.layer++; + reset_page(dvi); + break; + case 'q': + top.active = 0; + break; + case 'b': + dvi->params.flags ^= MDVI_PARAM_CHARBOXES; + set_pageno(dvi, dvi->currpage); + break; + case 'a': + dvi->params.flags ^= MDVI_PARAM_ANTIALIASED; + set_pageno(dvi, dvi->currpage); + break; + case 'p': + if(!has_number) + break; + number += dvi->currpage; + if(number < 0) + number = 0; + if(number > dvi->npages-1) + number = dvi->npages-1; + set_pageno(dvi, number); + break; + case 'j': + if(!has_number) + break; + if(number < 0) + has_number = (set_pageno(dvi, dvi->npages+number) < 0); + else + has_number = (set_pageno(dvi, number) < 0); + if(has_number) + beep_sound(); + break; + case 't': + if(!has_number) + break; + if(set_tex_pageno(dvi, number) < 0) + beep_sound(); + break; + case 'l': + set_pageno(dvi, dvi->currpage); + break; + case 'L': + /* reload! */ + WORKING(); + if(mdvi_reload(dvi, NULL) == -1) + beep_sound(); + else + reconfigure = 1; + RESTING(); + break; + case 'd': + /* change DPI */ + if(!has_number || number == dvi->params.dpi) + break; + WORKING(); + reconfigure = mdvi_set_dpi(dvi, number); + RESTING(); + break; + case 's': + if(!has_number || number < 0) + break; + WORKING(); + reconfigure = mdvi_set_shrink(dvi, number, number); + RESTING(); + break; + case 'x': + if(!has_number || number < 0) + break; + WORKING(); + reconfigure = mdvi_set_hshrink(dvi, number); + RESTING(); + break; + case 'y': + if(!has_number || number < 0) + break; + WORKING(); + reconfigure = mdvi_set_vshrink(dvi, number); + RESTING(); + break; + case 'm': { + double x; + + if(!has_number) + break; + x = has_dot ? (double)number / logten : (double)number; + if(x <= 0) { + warning(_("%s: magnification must be positive\n"), + dvi->filename); + break; + } + WORKING(); + reconfigure = mdvi_set_mag(dvi, x); + RESTING(); + break; + } + case '?': + print_key_help(); + break; + case 'r': + /* rotate +90 */ + reconfigure = mdvi_set_orientation(dvi, + pos_rotate_sequence[dvi->params.orientation]); + reset_origin = 1; + break; + case 'R': + /* rotate -90 */ + reconfigure = mdvi_set_orientation(dvi, + neg_rotate_sequence[dvi->params.orientation]); + reset_origin = 1; + break; + case 'f': + /* flip horizontally */ + reconfigure = mdvi_set_orientation(dvi, + h_flip_sequence[dvi->params.orientation]); + reset_origin = 1; + break; + case 'F': + /* flip vertically */ + reconfigure = mdvi_set_orientation(dvi, + v_flip_sequence[dvi->params.orientation]); + reset_origin = 1; + break; + case 'g': { + double x; + + if(!has_number) + break; + x = has_dot ? (double)number / logten : (double)number; + reconfigure = mdvi_set_gamma(dvi, x); + break; + } + case 'n': + if(!has_number) + break; + if(number < 0) + beep_sound(); + else + reconfigure = mdvi_set_density(dvi, number); + break; + case '/': + font_print(); + break; + } + + RESETNUMBER; + + if(reconfigure) { + configure_window(dvi); + if(!reset_origin) + set_pageno(dvi, dvi->currpage); + } +} + +static void top_events(DviContext *dvi, XEvent *ev) +{ + int tw, th; + GET_DRAW_DATA; + + tw = top.w; th = top.h; + + if(handle_top_events(&top, ev)) + return; + switch(ev->type) { + case ConfigureNotify: + if(reset_origin || + ev->xconfigure.width != tw || ev->xconfigure.height != th) { + position_windows(dvi); + if(reset_origin) { + reset_view_origin(dvi); + reset_origin = 0; + set_pageno(dvi, dvi->currpage); + } + } + break; + case KeyPress: + handle_key(dvi, &ev->xkey); + break; + } +} + +void do_redraw(DviContext *dvi) +{ + GET_DRAW_DATA; + + WORKING(); + if(mdvi_dopage(dvi, dvi->currpage) == -1) + fatal("%s: failed to display page\n", dvi->filename); + RESTING(); + XDrawRectangle(dpy, dviwin.win, normal_gc, + -dviwin.xorig, -dviwin.yorig, paper_w-1, paper_h-1); + reset_page(dvi); + dviwin.dirty = 0; +} + +void do_expose(DviContext *dvi, int x, int y, Uint w, Uint h) +{ + GET_DRAW_DATA; + + if(!dviwin.dirty) { + dviwin.minx = x; + dviwin.miny = y; + dviwin.maxx = x + w; + dviwin.maxy = y + h; + } else { + if(x < dviwin.minx) + dviwin.minx = x; + if(y < dviwin.miny) + dviwin.miny = y; + if(x + w > dviwin.maxx) + dviwin.maxx = x + w; + if(y + h > dviwin.maxy) + dviwin.maxy = y + h; + } +} + +void handle_dvi(DviContext *dvi, XEvent *ev) +{ + GET_DRAW_DATA; + + switch(ev->type) { + case ButtonPress: + if(inruler == NORULER && ev->xbutton.button == Button1) { + int type; + + /* Raise our window */ + XRaiseWindow(dpy, top.win); + XFlush(dpy); + + /* rulers */ + if(ev->xbutton.state & ControlMask) + type = VRULER; + else if(ev->xbutton.state & ShiftMask) + type = HRULER; + else + type = VHRULER; + SET_RULER_ORIGIN(type, ev->xbutton.x, ev->xbutton.y); + DRAW_RULER(); + XDefineCursor(dpy, top.win, point); + } + break; + case ButtonRelease: + if(inruler != NORULER) { + XUndefineCursor(dpy, top.win); + DRAW_RULER(); + UNSET_RULER(); + } + break; + case MotionNotify: + if(inruler != NORULER) + MOVE_RULER(ev->xmotion.x, ev->xmotion.y); + break; + case GraphicsExpose: + case Expose: + do_expose(dvi, ev->xexpose.x, ev->xexpose.y, + ev->xexpose.width, ev->xexpose.height); + dviwin.dirty = 1; + break; + } +} + +void view_page(DviContext *dvi, int pageno) +{ + GET_DRAW_DATA; + + if(busy == None) + busy = XCreateFontCursor(dpy, XC_watch); + if(point == None) + point = XCreateFontCursor(dpy, XC_crosshair); + do_expose(dvi, 0, 0, dviwin.w, dviwin.h); + set_pageno(dvi, pageno); + expose_window(dviwin.win, True); + while(top.active) { + XEvent ev; + + if(!XPending(dpy)) { + if(dviwin.dirty) + do_redraw(dvi); + else if(reset_origin) { + position_windows(dvi); + reset_view_origin(dvi); + set_pageno(dvi, dvi->currpage); + reset_origin = 0; + } + } + + XNextEvent(dpy, &ev); + if(ev.xany.window == top.win) + top_events(dvi, &ev); + else if(ev.xany.window == dviwin.win) + handle_dvi(dvi, &ev); + } + /* destroy everything */ + XFreeGC(dpy, drawgc); + XFreeGC(dpy, rulergc); + XFreeGC(dpy, scrollgc); + XDestroyWindow(dpy, dviwin.win); + /* destroy our private data */ + xfree(dvi->device.device_data); + dvi->device.device_data = NULL; +} diff --git a/dviware/mdvi/x11/x11.c b/dviware/mdvi/x11/x11.c new file mode 100644 index 0000000000..cd28fa1ba4 --- /dev/null +++ b/dviware/mdvi/x11/x11.c @@ -0,0 +1,750 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* This file contains routines I always use to make X programming easier */ + +#include "common.h" + +#ifndef X_DISPLAY_MISSING + +/*#define XSYNCH*/ +#define DEFAULT_FONT "-*-helvetica-medium-r-*-*-*-*-*-*-*-*-*-*" + +#include "x11.h" +#include "bitmap.h" +#include "private.h" + +#include <X11/Xatom.h> + +Display *dpy = NULL; +int scrno = 0; +GC normal_gc = NULL; +GC image_gc = NULL; +GC inv_gc = NULL; +int depth = 0; +Visual *visual = NULL; +Colormap colormap = None; +XFontStruct *default_font = NULL; +int bell_percent = 100; + +static Window group_leader = None; +static Atom protocols = None; +static Atom delete = None; +static XImage *image = NULL; + +Uint root_w = 0; +Uint root_h = 0; +Ulong black; +Ulong white; + +int errorhandler(Display *d, XErrorEvent *e) +{ + d=d, e=e; + abort(); +} + +#define NORMAL_EVENTS \ + (ExposureMask|KeyPressMask|StructureNotifyMask|\ + ButtonPressMask|ButtonReleaseMask) + +/* functions to query information about a window */ + +void get_screen_size(int *w, int *h) +{ + *w = root_w; + *h = root_h; +} + +void beep_sound(void) +{ + XBell(dpy, bell_percent); +} + +int get_win_size(Window win, Uint *w, Uint *h) +{ + Window junk; + int junk1; + + XGetGeometry(dpy, win, + &junk, &junk1, &junk1, + w, h, + (Uint*)&junk1, (Uint*)&junk1); + return 0; +} + +void free_propdata(PropData *prop) +{ + if(prop->name) { + /* this pointer was returned by XGetAtomName */ + XFree(prop->name); + prop->name = NULL; + } + prop->format = 8; + prop->type = XA_STRING; + prop->nitems = 0; + if(prop->data) { + xfree(prop->data); + prop->data = NULL; + } +} + +/* + * This is a general purpose function to get the data associated to a + * window's property. It serves as an example of how to use + * XGetWindowProperty. + * + * Returns -1 if there was an error, 0 on success. If all is well, it fills + * the `ret' PropData structure with all the information reported about the + * property. It must be freed with `free_propdata()'. + */ +int get_window_property(Display *dpy, Window w, Atom property, PropData *ret) +{ + Uchar *data; + int status; + Atom prop_type; + int prop_format; + Ulong prop_nitems; + Ulong bytes_left; + Uchar *copy, *ptr; + long size; + long length; + long total; + + /* request 1024 32bit words (we'll probably get much less than + * that), and get format and type */ + status = XGetWindowProperty(dpy, w, property, + 0L, 1024, False, + AnyPropertyType, &prop_type, + &prop_format, &prop_nitems, + &bytes_left, &data); + + if(status != Success || prop_type == None) + return -1; + + /* this is the number of bytes we just read */ + length = prop_nitems * (prop_format >> 3); + + /* this is the total length of the data for this property */ + total = length + bytes_left; + + /* allocate memory to hold all the data for this property. + * + * Note that we allocate one extra byte and set that to 0 so strings + * can be used directly. The docs for XGetWindowProperty say that + * this is automatically done, but they don't mention if this extra + * byte is included in the # of items returned. I assume it is not. + * The worst that can happen is that we're adding a second NUL at + * the end, but I better be safe than sorry. + */ + ptr = copy = (Uchar *)xmalloc(total + 1); + size = total; + if(ptr == NULL) { + XFree(data); + return -1; + } + + /* copy what we have so far */ + memcpy(copy, data, length); + ptr = copy + length; + + /* we dont need this anymore */ + XFree(data); + + while(bytes_left) { + int nbytes; + + /* we could request all the data that is left, but + * this will work too */ + XGetWindowProperty(dpy, w, property, + length / 4, 1024L, False, + AnyPropertyType, &prop_type, + &prop_format, &prop_nitems, + &bytes_left, &data); + + /* # of bytes we read */ + nbytes = prop_nitems * (prop_format >> 3); + + /* # of bytes so far */ + length += nbytes; + + /* check that we don't have more data than we should */ + if(length > total) { + printf("I expected %ld bytes, but already got %ld, " + "and there are %ld more to come.\n", + total, length, bytes_left); + break; + } + /* update our copy */ + memcpy(ptr, data, nbytes); + XFree(data); + ptr += nbytes; + } + copy[length] = 0; + + /* fill the PropData structure */ + ret->name = XGetAtomName(dpy, property); + ret->format = prop_format; + ret->type = prop_type; + ret->nitems = length / (prop_format >> 3); + ret->data = copy; + + return 0; +} + +/* open a connection to a remote display */ +int init_x11(void) +{ + XGCValues xg; + XKeyboardState kbd; + + dpy = XOpenDisplay(NULL); + if(dpy == NULL) { + error(_("connection to X server failed\n")); + return -1; + } + scrno = DefaultScreen(dpy); + get_win_size(RootWindow(dpy, scrno), &root_w, &root_h); + depth = DefaultDepth(dpy, scrno); + visual = DefaultVisual(dpy, scrno); + colormap = DefaultColormap(dpy, scrno); + black = BlackPixel(dpy, scrno); + white = WhitePixel(dpy, scrno); + + /* load a default font */ + default_font = XLoadQueryFont(dpy, DEFAULT_FONT); + if(default_font == NULL) + default_font = XLoadQueryFont(dpy, "fixed"); + if(default_font == NULL) { + error(_("%s: could not find display font `%s'\n"), + program_name, DEFAULT_FONT); + XCloseDisplay(dpy); + return -1; + } + + /* create GCs */ + xg.foreground = black; + xg.background = white; + xg.font = default_font->fid; + xg.graphics_exposures = False; + normal_gc = XCreateGC(dpy, RootWindow(dpy, scrno), + GCForeground|GCBackground|GCGraphicsExposures|GCFont, &xg); + image_gc = XCreateGC(dpy, RootWindow(dpy, scrno), + GCForeground|GCBackground|GCGraphicsExposures|GCFont, &xg); +#ifdef CHEAP_X_TRICK + XSetFunction(dpy, image_gc, GXand); +#endif + xg.foreground = white; + xg.background = black; + inv_gc = XCreateGC(dpy, RootWindow(dpy, scrno), + GCForeground|GCBackground|GCGraphicsExposures|GCFont, &xg); + + image = XCreateImage(dpy, visual, 1, XYBitmap, 0, + (char *)0, 0, 0, BITMAP_BITS, 0); +#ifdef WORD_BIG_ENDIAN + image->byte_order = image->bitmap_bit_order = MSBFirst; +#else + image->byte_order = image->bitmap_bit_order = LSBFirst; +#endif + +#if !defined(NODEBUG) && defined(XSYNCH) + XSynchronize(dpy, True); + XSetErrorHandler(errorhandler); +#endif + + /* get keyboard state */ + XGetKeyboardControl(dpy, &kbd); + bell_percent = kbd.bell_percent; + if(bell_percent < -100) + bell_percent = -100; + if(bell_percent > 100) + bell_percent = 100; + + return 0; +} + +int window_closed(XClientMessageEvent *ev, Window w) +{ + if(ev->window != w) + return 0; + if(ev->message_type == protocols && ev->data.l[0] == delete) + return 1; + return 0; +} + +int handle_top_events(TopWindow *tw, XEvent *ev) +{ + if(ev->xany.window != tw->win) + return 0; + switch(ev->type) { + case ClientMessage: + if(window_closed(&ev->xclient, tw->win)) { + tw->active = 0; + return 1; + } + break; + case ConfigureNotify: + tw->w = ev->xconfigure.width; + tw->h = ev->xconfigure.height; + break; + case KeyPress: { + if(XLookupKeysym((XKeyEvent *)ev, 0) == XK_Escape) { + tw->active = 0; + return 1; + } + break; + } + default: + break; + } + return 0; +} + +void close_top_window(TopWindow *tw) +{ + XDestroyWindow(dpy, tw->win); + if(tw->win == group_leader) + group_leader = None; + tw->win = None; + tw->active = 0; +} + +void expose_window(Window w, Bool putback) +{ + XEvent ev; + + XMapWindow(dpy, w); + while(!XCheckTypedWindowEvent(dpy, w, Expose, &ev)) + ; + if(putback) + XPutBackEvent(dpy, &ev); +} + +void resize_top_window(TopWindow *tw, Uint w, Uint h) +{ + XSizeHints size_hints; + + size_hints.width = w; + size_hints.height = h; + size_hints.flags = USSize; + XSetWMNormalHints(dpy, tw->win, &size_hints); + XResizeWindow(dpy, tw->win, w, h); + XFlush(dpy); + get_win_size(tw->win, &tw->w, &tw->h); +} + +int create_top_window(TopWindow *tw, const char *name, int w, int h) +{ + XSetWindowAttributes xwa; + + if(dpy == NULL && init_x11() == -1) + return -1; + + if(w > root_w) + w = root_w; + if(h > root_h) + h = root_h; + + xwa.background_pixel = white; + xwa.backing_pixel = white; + xwa.bit_gravity = NorthWestGravity; + xwa.backing_store = WhenMapped; + xwa.colormap = colormap; + + tw->win = XCreateWindow(dpy, + RootWindow(dpy, scrno), 0, 0, + w, h, 0, depth, + InputOutput, CopyFromParent, + CWBackPixel|CWBackingPixel| + CWBitGravity|CWBackingStore| + CWColormap, &xwa); + + /* select `Expose' events */ + XSelectInput(dpy, tw->win, NORMAL_EVENTS); + XStoreName(dpy, tw->win, name); + + protocols = XInternAtom(dpy, "WM_PROTOCOLS", False); + delete = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + if(delete != None) + XSetWMProtocols(dpy, tw->win, &delete, 1); + + /* set this as group leader, if it's the first */ + if(group_leader == None) + group_leader = tw->win; + else { + XWMHints hints; + + hints.window_group = (XID)group_leader; + hints.flags = WindowGroupHint; + XSetWMHints(dpy, tw->win, &hints); + } + + tw->active = 1; + return 0; +} + +void set_max_winsize(Window win, int w, int h) +{ + XSizeHints size_hints; + + size_hints.flags = PMaxSize; + size_hints.max_width = w; + size_hints.max_height = h; + XSetWMNormalHints(dpy, win, &size_hints); +} + +void add_window_events(Window w, Ulong mask) +{ + XWindowAttributes attr; + + XGetWindowAttributes(dpy, w, &attr); + attr.your_event_mask |= mask; + XSelectInput(dpy, w, attr.your_event_mask); + XFlush(dpy); +} + +void clear_window_events(Window w, Ulong mask) +{ + XWindowAttributes attr; + + XGetWindowAttributes(dpy, w, &attr); + attr.your_event_mask &= ~mask; + XSelectInput(dpy, w, attr.your_event_mask); + XFlush(dpy); +} + +void set_window_events(Window w, Ulong mask) +{ + XSelectInput(dpy, w, mask); +} + +Window create_window(Window parent, Ulong c, int w, int h, int b) +{ + XSetWindowAttributes xwa; + Window win; + + if(parent == None) + parent = RootWindow(dpy, scrno); + + xwa.background_pixel = c; + xwa.bit_gravity = NorthWestGravity; +#ifndef NODEBUG + xwa.backing_store = NotUseful; +#else + xwa.backing_store = WhenMapped; +#endif + xwa.colormap = colormap; + xwa.border_pixel = black; + win = XCreateWindow(dpy, parent, 0, 0, + w, h, b, depth, + InputOutput, CopyFromParent, + CWBackPixel|CWBitGravity|CWBackingStore|CWColormap, + &xwa); + + /* select `Expose' events */ + set_window_events(win, NORMAL_EVENTS); + + return win; +} + +Window create_subwindow(Window parent, Ulong c, int x, int y, int w, int h, int b) +{ + XSetWindowAttributes xwa; + Window win; + + if(parent == None) + parent = RootWindow(dpy, scrno); + + xwa.background_pixel = c; + xwa.bit_gravity = NorthWestGravity; +#ifndef NODEBUG + xwa.backing_store = NotUseful; +#else + xwa.backing_store = WhenMapped; +#endif + xwa.colormap = colormap; + xwa.border_pixel = black; + win = XCreateWindow(dpy, parent, + x, y, w, h, b, depth, + InputOutput, CopyFromParent, + CWBackPixel|CWBitGravity|CWBackingStore| + CWColormap, &xwa); + + /* select `Expose' events */ + set_window_events(win, NORMAL_EVENTS); + + return win; +} + +Pixmap create_pixmap(Window parent, int w, int h) +{ + Pixmap p; + + p = XCreatePixmap(dpy, parent, w, h, depth); + XFillRectangle(dpy, p, inv_gc, 0, 0, w, h); + return p; +} + +int create_draw_area(DrawArea *area, Window in, int w, int h, int b) +{ + XGCValues xgc; + + area->win = create_window(in, white, w, h, b); + if(area->win == None) + return -1; + xgc.foreground = black; + xgc.background = white; + xgc.graphics_exposures = False; + area->gc = XCreateGC(dpy, area->win, + GCForeground|GCBackground|GCGraphicsExposures, &xgc); + area->p = create_pixmap(area->win, w, h); + area->w = w; + area->h = h; + area->hidden = 1; + area->fg = black; + area->bg = white; + return 0; +} + +void set_area_foreground(DrawArea *area, Ulong fg) +{ + if(fg != area->fg) { + XSetForeground(dpy, area->gc, fg); + area->fg = fg; + } +} + +void set_area_background(DrawArea *area, Ulong bg) +{ + if(bg != area->bg) { + XSetBackground(dpy, area->gc, bg); + area->bg = bg; + } +} + +void destroy_area(DrawArea *area) +{ + XFreePixmap(dpy, area->p); + XFreeGC(dpy, area->gc); + XDestroyWindow(dpy, area->win); + area->win = None; + area->p = None; + area->w = 0; + area->h = 0; + area->hidden = 1; + area->gc = NULL; +} + +void refresh_area(DrawArea *area, int x, int y, int w, int h) +{ + if(!area->hidden) + XCopyArea(dpy, area->p, area->win, area->gc, x, y, w, h, x, y); +} + +void clear_area(DrawArea *area) +{ + XSetForeground(dpy, area->gc, area->bg); + XFillRectangle(dpy, area->p, area->gc, 0, 0, area->w, area->h); + XClearArea(dpy, area->win, 0, 0, area->w, area->h, True); + XSetForeground(dpy, area->gc, area->fg); +} + +void show_area(DrawArea *area) +{ + XEvent ev; + + if(!area->hidden) + return; + add_window_events(area->win, ExposureMask); + XFlush(dpy); + XMapWindow(dpy, area->win); + while(!XCheckTypedWindowEvent(dpy, area->win, Expose, &ev)) + ; + XPutBackEvent(dpy, &ev); + area->hidden = 0; +} + +void hide_area(DrawArea *area) +{ + XUnmapWindow(dpy, area->win); + area->hidden = 1; +} + +int resize_area(DrawArea *area, Uint w, Uint h) +{ + Pixmap p; + + p = create_pixmap(area->win, w, h); + if(p == None) + return -1; + XFreePixmap(dpy, area->p); + area->p = p; + XResizeWindow(dpy, area->win, w, h); + area->w = w; + area->h = h; + return 0; +} + +void set_clip_area(DrawArea *area, int x, int y, int w, int h) +{ + XRectangle rect; + + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XSetClipRectangles(dpy, area->gc, 0, 0, &rect, 1, Unsorted); +} + +void draw_line(Drawable d, int x0, int y0, int x1, int y1) +{ + XDrawLine(dpy, d, normal_gc, x0, y0, x1, y1); +} + +void draw_box(Drawable d, int x, int y, int w, int h, int filled) +{ + if(filled) + XFillRectangle(dpy, d, normal_gc, x, y, w, h); + else + XDrawRectangle(dpy, d, normal_gc, x, y, w, h); +} + +void attach_window(Window win, Window to) +{ + XReparentWindow(dpy, win, to, 0, 0); +} + +void detach_window(TopWindow *tw, Window win, int x, int y) +{ + /* set window transient for the top window */ + if(tw && win == tw->win) + return; + if(tw != NULL) + XSetTransientForHint(dpy, win, tw->win); + /* make window a child of the root */ + XReparentWindow(dpy, win, RootWindow(dpy, scrno), x, y); + /* and make it exit cleanly */ + if(delete != None) + XSetWMProtocols(dpy, win, &delete, 1); +} + +void close_x11(void) +{ + XFreeGC(dpy, normal_gc); + XFreeGC(dpy, inv_gc); + XFreeGC(dpy, image_gc); + XFreeFont(dpy, default_font); + XCloseDisplay(dpy); + dpy = NULL; +} + +void draw_bitmap(Drawable d, BITMAP *bm, int x, int y) +{ + if(bm->width <= 0 || bm->height <= 0) + return; + /* create X image */ + if(bm->data != NULL) { + image->width = bm->width; + image->height = bm->height; + image->data = (char *)bm->data; + image->bytes_per_line = bm->stride; + XPutImage(dpy, d, image_gc, image, + 0, 0, x, y, + bm->width, bm->height); + } +} + +void put_image(Drawable d, void *image, int x, int y, int w, int h) +{ + XPutImage(dpy, d, image_gc, (XImage *)image, + 0, 0, x, y, w, h); +} + +GC create_gc(int func, Window p, Ulong fg, Ulong bg) +{ + XGCValues xgc; + + xgc.foreground = fg; + xgc.background = bg; + xgc.function = func; + xgc.font = default_font->fid; + xgc.graphics_exposures = False; + return XCreateGC(dpy, p, + GCFunction|GCForeground|GCBackground| + GCGraphicsExposures|GCFont, &xgc); +} + +void draw_text(DrawArea *area, GC gc, int x, int y, const char *text, int justify) +{ + int n = strlen(text); + int w, y0; + + w = XTextWidth(default_font, text, n); + switch(justify & MX11_HJUSTIFY) { + case MX11_LEFT: + x = 2; break; + case MX11_RIGHT: + x = area->w - w - 2; + if(x < 2) x = 2; + break; + case MX11_HCENTER: + x = (area->w - w) / 2; + break; + } + switch(justify & MX11_VJUSTIFY) { + case MX11_ABOVE: + y -= default_font->max_bounds.descent; + if(y < 2) y = 2; + break; + case MX11_BELOW: + y += default_font->max_bounds.ascent; + if(y + default_font->max_bounds.descent + 2 > area->h) + y = area->h - default_font->max_bounds.descent - 2; + if(y < 2) y = 2; + break; + case MX11_VCENTER: + y -= FONT_HEIGHT(default_font) / 2 + + default_font->max_bounds.ascent; + if(y < 2) y = 2; + break; + } + if(gc == NULL) + gc = area->gc; + y0 = y - default_font->max_bounds.ascent; + XFillRectangle(dpy, area->p, inv_gc, + x, y0, w, FONT_HEIGHT(default_font)); + XDrawString(dpy, area->p, gc, x, y, text, n); +} + +Ulong get_color_byname(const char *name) +{ + XColor xc; + + if(dpy == NULL) + return 0UL; + if(!XParseColor(dpy, colormap, name, &xc)) { + warning(_("invalid color name `%s', using black\n")); + return black; + } + if(!XAllocColor(dpy, colormap, &xc)) { + warning(_("failed to allocate color `%s', using black\n")); + return black; + } + return xc.pixel; +} + +#endif /* X_DISPLAY_MISSING */ diff --git a/dviware/mdvi/x11/x11.h b/dviware/mdvi/x11/x11.h new file mode 100644 index 0000000000..fafdff5425 --- /dev/null +++ b/dviware/mdvi/x11/x11.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2000, Matias Atria + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/keysym.h> + +#include "mdvi.h" + +typedef struct { + char *name; /* name of the property */ + int format; /* format = 8, 16, 32 */ + Atom type; + int nitems; + Uchar *data; +} PropData; + +typedef struct { + Window win; + Pixmap p; + int w, h; + int hidden; + GC gc; + Ulong fg; + Ulong bg; +} DrawArea; + +typedef struct { + Window win; + Uint w; + Uint h; + int active; +} TopWindow; + +extern Display *dpy; +extern Colormap colormap; +extern int scrno; +extern GC normal_gc; +extern GC inv_gc; +extern GC color_gc; +extern GC image_gc; +extern int depth; +extern Visual *visual; +extern Ulong black; +extern Ulong white; +extern XFontStruct *default_font; +extern Uint root_w; +extern Uint root_h; + +#define MX11_LEFT 0x0001 +#define MX11_RIGHT 0x0002 +#define MX11_HCENTER 0x0004 +#define MX11_ABOVE 0x0100 +#define MX11_BELOW 0x0200 +#define MX11_VCENTER 0x0400 +#define MX11_HJUSTIFY 0x00ff +#define MX11_VJUSTIFY 0xff00 + +#define FONT_HEIGHT(x) ((x)->max_bounds.ascent + (x)->max_bounds.descent) +#define FONT_ASCENT(x) ((x)->max_bounds.ascent) +#define FONT_DESCENT(x) ((x)->max_bounds.descent) + +extern int init_x11 (void); +extern void close_x11 (void); +extern int handle_top_events (TopWindow *, XEvent *); +extern int create_top_window (TopWindow *, const char *, int, int); +extern void resize_top_window (TopWindow *, Uint, Uint); +extern Window create_window (Window, Ulong, int, int, int); +extern Window create_subwindow (Window, Ulong, int, int, int, int, int); +extern void expose_window (Window, Bool); +extern void close_top_window (TopWindow *); +extern void set_max_winsize (Window, int, int); +extern void set_window_events (Window, Ulong); +extern void add_window_events (Window, Ulong); +extern void clear_window_events (Window, Ulong); +extern Pixmap create_pixmap (Window, int, int); +extern int create_draw_area (DrawArea *, Window, int, int, int); +extern void destroy_area (DrawArea *); +extern void refresh_area (DrawArea *, int, int, int, int); +extern void show_area (DrawArea *); +extern void hide_area (DrawArea *); +extern void clear_area (DrawArea *); +extern int resize_area (DrawArea *, Uint, Uint); +extern void set_clip_area (DrawArea *, int, int, int, int); +extern void resize_top (TopWindow *, Uint, Uint); +extern int get_win_size (Window, Uint *, Uint *); +extern void draw_line (Drawable, int, int, int, int); +extern void draw_box (Drawable, int, int, int, int, int); +extern void draw_bitmap (Drawable, BITMAP *, int, int); +extern void draw_text (DrawArea *, GC, int, int, const char *, int); +extern void put_image (Drawable, void *, int, int, int, int); +extern int window_closed (XClientMessageEvent *, Window); +extern void detach_window (TopWindow *, Window, int, int); +extern void attach_window (Window, Window); +extern GC create_gc (int, Window, Ulong, Ulong); + +extern void beep_sound(void); +extern void set_area_foreground(DrawArea *, Ulong); +extern void set_area_background(DrawArea *, Ulong); +extern Ulong get_color_byname (const char *); + +extern int get_window_property (Display *, Window, Atom, PropData *); +extern void free_propdata (PropData *); |