From 6599da043e22e96ac830fb50a61c1b6d95d1b142 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 21 Aug 1997 18:57:35 -0400 Subject: [PATCH] Initial revision From-SVN: r14877 --- .cvsignore | 31 + COPYING | 340 + COPYING.LIB | 481 + ChangeLog | 5207 +++++ Makefile.in | 1608 ++ README | 47 + config-ml.in | 612 + config.guess | 833 + config.sub | 1177 ++ config/ChangeLog | 312 + config/mh-a68bsd | 12 + config/mh-aix386 | 1 + config/mh-apollo68 | 3 + config/mh-cxux | 14 + config/mh-cygwin32 | 16 + config/mh-decstation | 5 + config/mh-delta88 | 4 + config/mh-dgux | 4 + config/mh-dgux386 | 22 + config/mh-go32 | 4 + config/mh-hp300 | 13 + config/mh-hpux | 4 + config/mh-hpux8 | 4 + config/mh-irix4 | 7 + config/mh-irix5 | 3 + config/mh-irix6 | 7 + config/mh-lynxos | 2 + config/mh-lynxrs6k | 8 + config/mh-m68kpic | 1 + config/mh-ncr3000 | 17 + config/mh-ncrsvr43 | 9 + config/mh-necv4 | 11 + config/mh-papic | 1 + config/mh-ppcpic | 1 + config/mh-riscos | 15 + config/mh-sco | 10 + config/mh-solaris | 6 + config/mh-sparcpic | 1 + config/mh-sun3 | 3 + config/mh-sysv | 3 + config/mh-sysv4 | 11 + config/mh-vaxult2 | 2 + config/mh-windows | 16 + config/mh-x86pic | 1 + config/mpw-mh-mpw | 157 + config/mpw/ChangeLog | 53 + config/mpw/MoveIfChange | 19 + config/mpw/README | 23 + config/mpw/forward-include | 3 + config/mpw/g-mpw-make.sed | 293 + config/mpw/mpw-touch | 7 + config/mpw/mpw-true | 1 + config/mpw/null-command | 1 + config/mpw/open-brace | 4 + config/mpw/tr-7to8-src | 9 + config/mpw/true | 1 + config/mt-m68kpic | 1 + config/mt-netware | 1 + config/mt-papic | 1 + config/mt-ppcpic | 1 + config/mt-sparcpic | 1 + config/mt-v810 | 4 + config/mt-x86pic | 1 + configure | 1406 ++ configure.in | 874 + etc/ChangeLog | 392 + etc/Makefile.in | 88 + etc/configure | 858 + etc/configure.in | 7 + etc/make-stds.texi | 893 + etc/standards.texi | 3061 +++ include/COPYING | 340 + include/ChangeLog | 1254 ++ include/ansidecl.h | 154 + include/demangle.h | 90 + include/floatformat.h | 111 + include/fnmatch.h | 69 + include/getopt.h | 129 + include/libiberty.h | 161 + include/objalloc.h | 115 + include/obstack.h | 570 + install-sh | 287 + libiberty/COPYING.LIB | 481 + libiberty/ChangeLog | 2233 +++ libiberty/Makefile.in | 336 + libiberty/README | 129 + libiberty/alloca-botch.h | 5 + libiberty/alloca-norm.h | 23 + libiberty/alloca.c | 479 + libiberty/argv.c | 333 + libiberty/atexit.c | 14 + libiberty/basename.c | 43 + libiberty/bcmp.c | 49 + libiberty/bcopy.c | 35 + libiberty/bzero.c | 31 + libiberty/choose-temp.c | 147 + libiberty/clock.c | 73 + libiberty/concat.c | 167 + libiberty/config.h-vms | 13 + libiberty/config.table | 69 + libiberty/config/mh-a68bsd | 2 + libiberty/config/mh-aix | 10 + libiberty/config/mh-apollo68 | 2 + libiberty/config/mh-cxux7 | 3 + libiberty/config/mh-cygwin32 | 2 + libiberty/config/mh-go32 | 1 + libiberty/config/mh-hpbsd | 2 + libiberty/config/mh-irix4 | 4 + libiberty/config/mh-ncr3000 | 19 + libiberty/config/mh-riscix | 6 + libiberty/config/mh-sysv | 1 + libiberty/config/mh-sysv4 | 3 + libiberty/config/mh-windows | 2 + libiberty/config/mt-sunos4 | 2 + libiberty/config/mt-vxworks5 | 28 + libiberty/configure.bat | 15 + libiberty/configure.in | 66 + libiberty/copysign.c | 140 + libiberty/cplus-dem.c | 3087 +++ libiberty/dummy.c | 49 + libiberty/fdmatch.c | 73 + libiberty/floatformat.c | 401 + libiberty/fnmatch.c | 223 + libiberty/functions.def | 69 + libiberty/getcwd.c | 52 + libiberty/getopt.c | 760 + libiberty/getopt1.c | 190 + libiberty/getpagesize.c | 89 + libiberty/getruntime.c | 82 + libiberty/hex.c | 33 + libiberty/index.c | 11 + libiberty/insque.c | 50 + libiberty/makefile.dos | 29 + libiberty/makefile.vms | 37 + libiberty/memchr.c | 60 + libiberty/memcmp.c | 38 + libiberty/memcpy.c | 28 + libiberty/memmove.c | 18 + libiberty/memset.c | 19 + libiberty/mpw-config.in | 9 + libiberty/mpw-make.sed | 51 + libiberty/mpw.c | 1010 + libiberty/msdos.c | 15 + libiberty/objalloc.c | 289 + libiberty/obstack.c | 514 + libiberty/pexecute.c | 580 + libiberty/random.c | 373 + libiberty/rename.c | 22 + libiberty/rindex.c | 11 + libiberty/sigsetmask.c | 30 + libiberty/spaces.c | 78 + libiberty/strcasecmp.c | 82 + libiberty/strchr.c | 34 + libiberty/strdup.c | 10 + libiberty/strerror.c | 831 + libiberty/strncasecmp.c | 82 + libiberty/strrchr.c | 34 + libiberty/strsignal.c | 638 + libiberty/strstr.c | 51 + libiberty/strtod.c | 122 + libiberty/strtol.c | 143 + libiberty/strtoul.c | 110 + libiberty/tmpnam.c | 39 + libiberty/vasprintf.c | 165 + libiberty/vfork.c | 8 + libiberty/vfprintf.c | 13 + libiberty/vmsbuild.com | 166 + libiberty/vprintf.c | 15 + libiberty/vsprintf.c | 55 + libiberty/waitpid.c | 11 + libiberty/xatexit.c | 82 + libiberty/xexit.c | 36 + libiberty/xmalloc.c | 113 + libiberty/xstrdup.c | 17 + libiberty/xstrerror.c | 56 + libio/ChangeLog | 1940 ++ libio/Makefile.in | 124 + libio/NEWS | 51 + libio/PlotFile.cc | 157 + libio/PlotFile.h | 89 + libio/README | 30 + libio/SFile.cc | 82 + libio/SFile.h | 55 + libio/builtinbuf.cc | 78 + libio/builtinbuf.h | 68 + libio/cleanup.c | 17 + libio/config.shared | 487 + libio/config/hpux.mt | 3 + libio/config/isc.mt | 4 + libio/config/linux.mt | 26 + libio/config/mn10200.mt | 3 + libio/config/netware.mt | 16 + libio/config/sco4.mt | 3 + libio/configure.in | 93 + libio/dbz/Makefile.in | 217 + libio/dbz/README | 25 + libio/dbz/altbytes | 7 + libio/dbz/byteflip.c | 38 + libio/dbz/case.c | 129 + libio/dbz/case.h | 12 + libio/dbz/configure.in | 17 + libio/dbz/dbz.1 | 221 + libio/dbz/dbz.3z | 547 + libio/dbz/dbz.c | 1763 ++ libio/dbz/dbz.h | 32 + libio/dbz/dbzmain.c | 519 + libio/dbz/fake.c | 144 + libio/dbz/firstlast25 | 50 + libio/dbz/getmap | 6 + libio/dbz/random.c | 31 + libio/dbz/revbytes | 7 + libio/dbz/stdio.h | 1 + libio/depend | 352 + libio/editbuf.cc | 717 + libio/editbuf.h | 185 + libio/filebuf.cc | 206 + libio/filedoalloc.c | 102 + libio/fileops.c | 755 + libio/floatconv.c | 2375 +++ libio/floatio.h | 51 + libio/fstream.cc | 110 + libio/fstream.h | 92 + libio/gen-params | 698 + libio/genops.c | 852 + libio/indstream.cc | 121 + libio/indstream.h | 77 + libio/ioassign.cc | 49 + libio/ioextend.cc | 132 + libio/iofclose.c | 47 + libio/iofdopen.c | 121 + libio/iofflush.c | 38 + libio/iofgetpos.c | 46 + libio/iofgets.c | 40 + libio/iofopen.c | 49 + libio/iofprintf.c | 48 + libio/iofputs.c | 37 + libio/iofread.c | 38 + libio/iofscanf.c | 48 + libio/iofsetpos.c | 43 + libio/ioftell.c | 45 + libio/iofwrite.c | 44 + libio/iogetdelim.c | 99 + libio/iogetline.c | 74 + libio/iogets.c | 47 + libio/ioignore.c | 46 + libio/iolibio.h | 53 + libio/iomanip.cc | 90 + libio/iomanip.h | 165 + libio/iopadn.c | 65 + libio/ioperror.c | 22 + libio/iopopen.c | 222 + libio/ioprims.c | 72 + libio/ioprintf.c | 47 + libio/ioputs.c | 38 + libio/ioscanf.c | 47 + libio/ioseekoff.c | 43 + libio/ioseekpos.c | 39 + libio/iosetbuffer.c | 36 + libio/iosetvbuf.c | 78 + libio/iosprintf.c | 47 + libio/iosscanf.c | 47 + libio/iostdio.h | 114 + libio/iostream.cc | 821 + libio/iostream.h | 258 + libio/iostream.texi | 1971 ++ libio/iostreamP.h | 26 + libio/iostrerror.c | 12 + libio/ioungetc.c | 35 + libio/iovfprintf.c | 885 + libio/iovfscanf.c | 787 + libio/iovsprintf.c | 40 + libio/iovsscanf.c | 37 + libio/isgetline.cc | 139 + libio/isgetsb.cc | 59 + libio/isscan.cc | 45 + libio/istream.h | 25 + libio/libio.h | 267 + libio/libioP.h | 497 + libio/osform.cc | 54 + libio/ostream.h | 25 + libio/outfloat.c | 204 + libio/parsestream.cc | 317 + libio/parsestream.h | 156 + libio/pfstream.cc | 92 + libio/pfstream.h | 59 + libio/procbuf.cc | 55 + libio/procbuf.h | 50 + libio/sbform.cc | 40 + libio/sbgetline.cc | 31 + libio/sbscan.cc | 45 + libio/stdfiles.c | 44 + libio/stdio/ChangeLog | 93 + libio/stdio/Makefile.in | 23 + libio/stdio/clearerr.c | 10 + libio/stdio/configure.in | 48 + libio/stdio/fdopen.c | 9 + libio/stdio/feof.c | 34 + libio/stdio/ferror.c | 10 + libio/stdio/fgetc.c | 10 + libio/stdio/fileno.c | 12 + libio/stdio/fputc.c | 11 + libio/stdio/freopen.c | 14 + libio/stdio/fseek.c | 12 + libio/stdio/getc.c | 11 + libio/stdio/getchar.c | 10 + libio/stdio/getline.c | 13 + libio/stdio/getw.c | 13 + libio/stdio/popen.c | 23 + libio/stdio/putc.c | 12 + libio/stdio/putchar.c | 10 + libio/stdio/putw.c | 15 + libio/stdio/rewind.c | 10 + libio/stdio/setbuf.c | 9 + libio/stdio/setfileno.c | 17 + libio/stdio/setlinebuf.c | 11 + libio/stdio/snprintf.c | 51 + libio/stdio/stdio.h | 181 + libio/stdio/vfprintf.c | 35 + libio/stdio/vfscanf.c | 36 + libio/stdio/vprintf.c | 33 + libio/stdio/vscanf.c | 34 + libio/stdio/vsnprintf.c | 43 + libio/stdiostream.cc | 159 + libio/stdiostream.h | 79 + libio/stdstrbufs.cc | 115 + libio/stdstreams.cc | 153 + libio/stream.cc | 170 + libio/stream.h | 59 + libio/streambuf.cc | 343 + libio/streambuf.h | 475 + libio/strfile.h | 62 + libio/strops.c | 290 + libio/strstream.cc | 116 + libio/strstream.h | 113 + libio/tests/ChangeLog | 140 + libio/tests/Makefile.in | 197 + libio/tests/configure.in | 21 + libio/tests/hounddog.cc | 85 + libio/tests/hounddog.exp | 7 + libio/tests/hounddog.inp | 7 + libio/tests/putbackdog.cc | 97 + libio/tests/tFile.cc | 550 + libio/tests/tFile.exp | 75 + libio/tests/tFile.inp | 5 + libio/tests/tfformat.c | 4181 ++++ libio/tests/tiformat.c | 5112 +++++ libio/tests/tiomanip.cc | 35 + libio/tests/tiomanip.exp | 4 + libio/tests/tiomisc.cc | 236 + libio/tests/tiomisc.exp | 11 + libio/tests/tstdiomisc.c | 43 + libio/tests/tstdiomisc.exp | 8 + libio/testsuite/ChangeLog | 49 + libio/testsuite/Makefile.in | 89 + libio/testsuite/config/default.exp | 1 + libio/testsuite/configure.in | 21 + libio/testsuite/lib/libio.exp | 164 + libio/testsuite/libio.tests/hounddog.exp | 3 + libio/testsuite/libio.tests/putbackdog.exp | 3 + libio/testsuite/libio.tests/tFile.exp | 3 + libio/testsuite/libio.tests/tfformat.exp | 1 + libio/testsuite/libio.tests/tiformat.exp | 1 + libio/testsuite/libio.tests/tiomanip.exp | 1 + libio/testsuite/libio.tests/tiomisc.exp | 1 + libio/testsuite/libio.tests/tstdiomisc.exp | 1 + libstdc++/ChangeLog | 823 + libstdc++/Makefile.in | 307 + libstdc++/NEWS | 13 + libstdc++/algorithm | 7 + libstdc++/cassert | 7 + libstdc++/cctype | 7 + libstdc++/cerrno | 7 + libstdc++/cfloat | 7 + libstdc++/cinst.cc | 155 + libstdc++/ciso646 | 7 + libstdc++/climits | 7 + libstdc++/clocale | 7 + libstdc++/cmath | 76 + libstdc++/cmathi.cc | 7 + libstdc++/complex | 18 + libstdc++/complex.h | 6 + libstdc++/config/aix.ml | 8 + libstdc++/config/dec-osf.ml | 6 + libstdc++/config/elf.ml | 8 + libstdc++/config/elfshlibm.ml | 6 + libstdc++/config/hpux.ml | 6 + libstdc++/config/irix5.ml | 6 + libstdc++/config/linux.ml | 6 + libstdc++/config/sol2shm.ml | 6 + libstdc++/config/sunos4.ml | 9 + libstdc++/configure.in | 85 + libstdc++/csetjmp | 8 + libstdc++/csignal | 7 + libstdc++/cstdarg | 7 + libstdc++/cstddef | 7 + libstdc++/cstdio | 7 + libstdc++/cstdlib | 23 + libstdc++/cstdlibi.cc | 7 + libstdc++/cstring | 96 + libstdc++/cstringi.cc | 7 + libstdc++/ctime | 7 + libstdc++/cwchar | 7 + libstdc++/cwctype | 7 + libstdc++/deque | 7 + libstdc++/functional | 7 + libstdc++/iterator | 7 + libstdc++/list | 7 + libstdc++/map | 7 + libstdc++/memory | 7 + libstdc++/numeric | 7 + libstdc++/queue | 7 + libstdc++/set | 7 + libstdc++/sinst.cc | 132 + libstdc++/stack | 7 + libstdc++/std/bastring.cc | 514 + libstdc++/std/bastring.h | 560 + libstdc++/std/complext.cc | 273 + libstdc++/std/complext.h | 423 + libstdc++/std/dcomplex.h | 94 + libstdc++/std/fcomplex.h | 90 + libstdc++/std/ldcomplex.h | 98 + libstdc++/std/straits.h | 161 + libstdc++/stdexcept | 93 + libstdc++/stdexcepti.cc | 8 + libstdc++/stl.h | 15 + libstdc++/stl/ChangeLog | 192 + libstdc++/stl/README | 16 + libstdc++/stl/algo.h | 2665 +++ libstdc++/stl/algobase.h | 841 + libstdc++/stl/alloc.h | 674 + libstdc++/stl/bvector.h | 585 + libstdc++/stl/defalloc.h | 87 + libstdc++/stl/deque.h | 1452 ++ libstdc++/stl/function.h | 634 + libstdc++/stl/hash_map.h | 319 + libstdc++/stl/hash_set.h | 306 + libstdc++/stl/hashtable.h | 1013 + libstdc++/stl/heap.h | 204 + libstdc++/stl/iterator.h | 598 + libstdc++/stl/list.h | 624 + libstdc++/stl/map.h | 188 + libstdc++/stl/multimap.h | 182 + libstdc++/stl/multiset.h | 167 + libstdc++/stl/pair.h | 63 + libstdc++/stl/pthread_alloc.h | 344 + libstdc++/stl/rope.h | 2055 ++ libstdc++/stl/ropeimpl.h | 1510 ++ libstdc++/stl/set.h | 167 + libstdc++/stl/slist.h | 729 + libstdc++/stl/stack.h | 171 + libstdc++/stl/stl_config.h | 170 + libstdc++/stl/tempbuf.h | 121 + libstdc++/stl/tree.h | 1085 ++ libstdc++/stl/type_traits.h | 227 + libstdc++/stl/vector.h | 544 + libstdc++/stlinst.cc | 8 + libstdc++/string | 13 + libstdc++/tests/ChangeLog | 87 + libstdc++/tests/Makefile.in | 35 + libstdc++/tests/configure.in | 50 + libstdc++/tests/tcomplex.cc | 151 + libstdc++/tests/tcomplex.exp | 37 + libstdc++/tests/tcomplex.inp | 1 + libstdc++/tests/tlist.cc | 165 + libstdc++/tests/tlist.exp | 44 + libstdc++/tests/tmap.cc | 69 + libstdc++/tests/tmap.exp | 7 + libstdc++/tests/tstring.cc | 189 + libstdc++/tests/tstring.exp | 20 + libstdc++/tests/tstring.inp | 1 + libstdc++/tests/tvector.cc | 23 + libstdc++/tests/tvector.exp | 4 + libstdc++/testsuite/ChangeLog | 54 + libstdc++/testsuite/Makefile.in | 66 + libstdc++/testsuite/config/default.exp | 1 + libstdc++/testsuite/configure.in | 23 + libstdc++/testsuite/lib/libstdc++.exp | 165 + libstdc++/testsuite/libstdc++.tests/test.exp | 34 + libstdc++/utility | 8 + libstdc++/vector | 7 + ltconfig | 1064 ++ ltmain.sh | 1819 ++ missing | 134 + mkinstalldirs | 36 + move-if-change | 32 + mpw-README | 376 + mpw-build.in | 204 + mpw-config.in | 113 + mpw-configure | 448 + symlink-tree | 48 + texinfo/COPYING | 339 + texinfo/ChangeLog | 2389 +++ texinfo/INSTALL | 181 + texinfo/INTRODUCTION | 119 + texinfo/Makefile.in | 244 + texinfo/NEWS | 93 + texinfo/README | 163 + texinfo/TODO | 35 + texinfo/aclocal.m4 | 45 + texinfo/configure | 2025 ++ texinfo/configure.in | 48 + texinfo/dir | 16 + texinfo/dir-example | 309 + texinfo/dir.info-template | 67 + texinfo/emacs/Makefile.in | 91 + texinfo/emacs/detexinfo.el | 250 + texinfo/emacs/elisp-comp | 7 + texinfo/emacs/info.el | 1846 ++ texinfo/emacs/informat.el | 429 + texinfo/emacs/makeinfo.el | 247 + texinfo/emacs/new-useful-setqs | 180 + texinfo/emacs/texinfmt.el | 3979 ++++ texinfo/emacs/texinfo.el | 932 + texinfo/emacs/texnfo-tex.el | 346 + texinfo/emacs/texnfo-upd.el | 2058 ++ texinfo/gen-info-dir | 101 + texinfo/gpl.texinfo | 398 + texinfo/info/Makefile.in | 232 + texinfo/info/NEWS | 200 + texinfo/info/README | 37 + texinfo/info/clib.c | 112 + texinfo/info/clib.h | 42 + texinfo/info/dir.c | 273 + texinfo/info/display.c | 561 + texinfo/info/display.h | 76 + texinfo/info/doc.h | 58 + texinfo/info/dribble.c | 71 + texinfo/info/dribble.h | 41 + texinfo/info/echo_area.c | 1508 ++ texinfo/info/echo_area.h | 63 + texinfo/info/filesys.c | 617 + texinfo/info/filesys.h | 84 + texinfo/info/footnotes.c | 265 + texinfo/info/footnotes.h | 46 + texinfo/info/gc.c | 95 + texinfo/info/gc.h | 36 + texinfo/info/general.h | 94 + texinfo/info/indices.c | 667 + texinfo/info/indices.h | 39 + texinfo/info/info-stnd.texi | 1365 ++ texinfo/info/info-utils.c | 672 + texinfo/info/info-utils.h | 140 + texinfo/info/info.1 | 229 + texinfo/info/info.c | 565 + texinfo/info/info.h | 100 + texinfo/info/info.texi | 929 + texinfo/info/infodoc.c | 771 + texinfo/info/infomap.c | 274 + texinfo/info/infomap.h | 82 + texinfo/info/m-x.c | 195 + texinfo/info/makedoc.c | 481 + texinfo/info/man.c | 643 + texinfo/info/man.h | 36 + texinfo/info/nodemenu.c | 329 + texinfo/info/nodes.c | 1207 ++ texinfo/info/nodes.h | 168 + texinfo/info/search.c | 519 + texinfo/info/search.h | 75 + texinfo/info/session.c | 4263 +++++ texinfo/info/session.h | 146 + texinfo/info/signals.c | 173 + texinfo/info/signals.h | 89 + texinfo/info/termdep.h | 76 + texinfo/info/terminal.c | 769 + texinfo/info/terminal.h | 129 + texinfo/info/tilde.c | 376 + texinfo/info/tilde.h | 58 + texinfo/info/userdoc.texi | 1270 ++ texinfo/info/variables.c | 272 + texinfo/info/variables.h | 64 + texinfo/info/window.c | 1482 ++ texinfo/info/window.h | 229 + texinfo/info/xmalloc.c | 80 + texinfo/install-sh | 250 + texinfo/lgpl.texinfo | 548 + texinfo/liblic.texi | 23 + texinfo/libtxi/Makefile.in | 84 + texinfo/libtxi/alloca.c | 504 + texinfo/libtxi/bzero.c | 44 + texinfo/libtxi/getopt.c | 762 + texinfo/libtxi/getopt.h | 129 + texinfo/libtxi/getopt1.c | 180 + texinfo/libtxi/memcpy.c | 20 + texinfo/libtxi/memmove.c | 24 + texinfo/libtxi/strdup.c | 43 + texinfo/license.texi | 24 + texinfo/makeinfo/Makefile.in | 116 + texinfo/makeinfo/macro.texi | 177 + texinfo/makeinfo/macros/example.texi | 224 + texinfo/makeinfo/macros/html.texi | 269 + texinfo/makeinfo/macros/multifmt.texi | 41 + texinfo/makeinfo/macros/res-samp.texi | 32 + texinfo/makeinfo/macros/resume.texi | 64 + texinfo/makeinfo/macros/simpledoc.texi | 135 + texinfo/makeinfo/makeinfo.c | 9349 +++++++++ texinfo/makeinfo/makeinfo.h | 193 + texinfo/makeinfo/makeinfo.texi | 311 + texinfo/makeinfo/multi.c | 418 + texinfo/makeinfo/multiformat.texi | 40 + texinfo/testsuite/ChangeLog | 37 + texinfo/testsuite/Makefile.in | 100 + texinfo/testsuite/config/unix.exp | 29 + texinfo/testsuite/configure | 707 + texinfo/testsuite/configure.in | 5 + texinfo/testsuite/lib/utils.exp | 31 + texinfo/testsuite/makeinfo.0/atnode.exp | 19 + texinfo/testsuite/makeinfo.0/conditions.exp | 21 + texinfo/testsuite/makeinfo.0/mini.exp | 17 + texinfo/testsuite/makeinfo.0/missnode.exp | 25 + texinfo/testsuite/makeinfo.0/nonsense.exp | 12 + texinfo/testsuite/makeinfo.0/not.exp | 15 + texinfo/testsuite/makeinfo.0/smstruct.exp | 14 + texinfo/testsuite/text/atnode.texi | 21 + texinfo/testsuite/text/conditions.texi | 26 + texinfo/testsuite/text/dfltnode.texi | 21 + texinfo/testsuite/text/minimal.texi | 2 + texinfo/testsuite/text/missnode.texi | 22 + texinfo/testsuite/text/nonsense.texi | 3 + texinfo/testsuite/text/not.texi | 1 + texinfo/testsuite/text/smstruct.texi | 21 + texinfo/texinfo.tex | 4800 +++++ texinfo/texinfo.texi | 16886 +++++++++++++++++ texinfo/util/Makefile.in | 105 + texinfo/util/deref.c | 238 + texinfo/util/fixfonts | 84 + texinfo/util/gen-dir-node | 176 + texinfo/util/install-info.c | 1111 ++ texinfo/util/mkinstalldirs | 40 + texinfo/util/tex3patch | 71 + texinfo/util/texi2dvi | 367 + texinfo/util/texindex.c | 1793 ++ xiberty/configure.in | 101 + ylwrap | 107 + 633 files changed, 185145 insertions(+) create mode 100644 .cvsignore create mode 100644 COPYING create mode 100644 COPYING.LIB create mode 100644 ChangeLog create mode 100644 Makefile.in create mode 100644 README create mode 100644 config-ml.in create mode 100755 config.guess create mode 100755 config.sub create mode 100644 config/ChangeLog create mode 100644 config/mh-a68bsd create mode 100644 config/mh-aix386 create mode 100644 config/mh-apollo68 create mode 100644 config/mh-cxux create mode 100644 config/mh-cygwin32 create mode 100644 config/mh-decstation create mode 100644 config/mh-delta88 create mode 100644 config/mh-dgux create mode 100644 config/mh-dgux386 create mode 100644 config/mh-go32 create mode 100644 config/mh-hp300 create mode 100644 config/mh-hpux create mode 100644 config/mh-hpux8 create mode 100644 config/mh-irix4 create mode 100644 config/mh-irix5 create mode 100644 config/mh-irix6 create mode 100644 config/mh-lynxos create mode 100644 config/mh-lynxrs6k create mode 100644 config/mh-m68kpic create mode 100644 config/mh-ncr3000 create mode 100644 config/mh-ncrsvr43 create mode 100644 config/mh-necv4 create mode 100644 config/mh-papic create mode 100644 config/mh-ppcpic create mode 100644 config/mh-riscos create mode 100644 config/mh-sco create mode 100644 config/mh-solaris create mode 100644 config/mh-sparcpic create mode 100644 config/mh-sun3 create mode 100644 config/mh-sysv create mode 100644 config/mh-sysv4 create mode 100644 config/mh-vaxult2 create mode 100644 config/mh-windows create mode 100644 config/mh-x86pic create mode 100644 config/mpw-mh-mpw create mode 100644 config/mpw/ChangeLog create mode 100644 config/mpw/MoveIfChange create mode 100644 config/mpw/README create mode 100644 config/mpw/forward-include create mode 100644 config/mpw/g-mpw-make.sed create mode 100644 config/mpw/mpw-touch create mode 100644 config/mpw/mpw-true create mode 100644 config/mpw/null-command create mode 100644 config/mpw/open-brace create mode 100644 config/mpw/tr-7to8-src create mode 100644 config/mpw/true create mode 100644 config/mt-m68kpic create mode 100644 config/mt-netware create mode 100644 config/mt-papic create mode 100644 config/mt-ppcpic create mode 100644 config/mt-sparcpic create mode 100644 config/mt-v810 create mode 100644 config/mt-x86pic create mode 100755 configure create mode 100644 configure.in create mode 100644 etc/ChangeLog create mode 100644 etc/Makefile.in create mode 100755 etc/configure create mode 100644 etc/configure.in create mode 100644 etc/make-stds.texi create mode 100644 etc/standards.texi create mode 100644 include/COPYING create mode 100644 include/ChangeLog create mode 100644 include/ansidecl.h create mode 100644 include/demangle.h create mode 100644 include/floatformat.h create mode 100644 include/fnmatch.h create mode 100644 include/getopt.h create mode 100644 include/libiberty.h create mode 100644 include/objalloc.h create mode 100644 include/obstack.h create mode 100755 install-sh create mode 100644 libiberty/COPYING.LIB create mode 100644 libiberty/ChangeLog create mode 100644 libiberty/Makefile.in create mode 100644 libiberty/README create mode 100644 libiberty/alloca-botch.h create mode 100644 libiberty/alloca-norm.h create mode 100644 libiberty/alloca.c create mode 100644 libiberty/argv.c create mode 100644 libiberty/atexit.c create mode 100644 libiberty/basename.c create mode 100644 libiberty/bcmp.c create mode 100644 libiberty/bcopy.c create mode 100644 libiberty/bzero.c create mode 100644 libiberty/choose-temp.c create mode 100644 libiberty/clock.c create mode 100644 libiberty/concat.c create mode 100644 libiberty/config.h-vms create mode 100644 libiberty/config.table create mode 100644 libiberty/config/mh-a68bsd create mode 100644 libiberty/config/mh-aix create mode 100644 libiberty/config/mh-apollo68 create mode 100644 libiberty/config/mh-cxux7 create mode 100644 libiberty/config/mh-cygwin32 create mode 100644 libiberty/config/mh-go32 create mode 100644 libiberty/config/mh-hpbsd create mode 100644 libiberty/config/mh-irix4 create mode 100644 libiberty/config/mh-ncr3000 create mode 100644 libiberty/config/mh-riscix create mode 100644 libiberty/config/mh-sysv create mode 100644 libiberty/config/mh-sysv4 create mode 100644 libiberty/config/mh-windows create mode 100644 libiberty/config/mt-sunos4 create mode 100644 libiberty/config/mt-vxworks5 create mode 100644 libiberty/configure.bat create mode 100644 libiberty/configure.in create mode 100644 libiberty/copysign.c create mode 100644 libiberty/cplus-dem.c create mode 100644 libiberty/dummy.c create mode 100644 libiberty/fdmatch.c create mode 100644 libiberty/floatformat.c create mode 100644 libiberty/fnmatch.c create mode 100644 libiberty/functions.def create mode 100644 libiberty/getcwd.c create mode 100644 libiberty/getopt.c create mode 100644 libiberty/getopt1.c create mode 100644 libiberty/getpagesize.c create mode 100644 libiberty/getruntime.c create mode 100644 libiberty/hex.c create mode 100644 libiberty/index.c create mode 100644 libiberty/insque.c create mode 100644 libiberty/makefile.dos create mode 100644 libiberty/makefile.vms create mode 100644 libiberty/memchr.c create mode 100644 libiberty/memcmp.c create mode 100644 libiberty/memcpy.c create mode 100644 libiberty/memmove.c create mode 100644 libiberty/memset.c create mode 100644 libiberty/mpw-config.in create mode 100644 libiberty/mpw-make.sed create mode 100644 libiberty/mpw.c create mode 100644 libiberty/msdos.c create mode 100644 libiberty/objalloc.c create mode 100644 libiberty/obstack.c create mode 100644 libiberty/pexecute.c create mode 100644 libiberty/random.c create mode 100644 libiberty/rename.c create mode 100644 libiberty/rindex.c create mode 100644 libiberty/sigsetmask.c create mode 100644 libiberty/spaces.c create mode 100644 libiberty/strcasecmp.c create mode 100644 libiberty/strchr.c create mode 100644 libiberty/strdup.c create mode 100644 libiberty/strerror.c create mode 100644 libiberty/strncasecmp.c create mode 100644 libiberty/strrchr.c create mode 100644 libiberty/strsignal.c create mode 100644 libiberty/strstr.c create mode 100644 libiberty/strtod.c create mode 100644 libiberty/strtol.c create mode 100644 libiberty/strtoul.c create mode 100644 libiberty/tmpnam.c create mode 100644 libiberty/vasprintf.c create mode 100644 libiberty/vfork.c create mode 100644 libiberty/vfprintf.c create mode 100644 libiberty/vmsbuild.com create mode 100644 libiberty/vprintf.c create mode 100644 libiberty/vsprintf.c create mode 100644 libiberty/waitpid.c create mode 100644 libiberty/xatexit.c create mode 100644 libiberty/xexit.c create mode 100644 libiberty/xmalloc.c create mode 100644 libiberty/xstrdup.c create mode 100644 libiberty/xstrerror.c create mode 100644 libio/ChangeLog create mode 100644 libio/Makefile.in create mode 100644 libio/NEWS create mode 100644 libio/PlotFile.cc create mode 100644 libio/PlotFile.h create mode 100644 libio/README create mode 100644 libio/SFile.cc create mode 100644 libio/SFile.h create mode 100644 libio/builtinbuf.cc create mode 100644 libio/builtinbuf.h create mode 100644 libio/cleanup.c create mode 100644 libio/config.shared create mode 100644 libio/config/hpux.mt create mode 100644 libio/config/isc.mt create mode 100644 libio/config/linux.mt create mode 100644 libio/config/mn10200.mt create mode 100644 libio/config/netware.mt create mode 100644 libio/config/sco4.mt create mode 100644 libio/configure.in create mode 100644 libio/dbz/Makefile.in create mode 100644 libio/dbz/README create mode 100644 libio/dbz/altbytes create mode 100644 libio/dbz/byteflip.c create mode 100644 libio/dbz/case.c create mode 100644 libio/dbz/case.h create mode 100644 libio/dbz/configure.in create mode 100644 libio/dbz/dbz.1 create mode 100644 libio/dbz/dbz.3z create mode 100644 libio/dbz/dbz.c create mode 100644 libio/dbz/dbz.h create mode 100644 libio/dbz/dbzmain.c create mode 100644 libio/dbz/fake.c create mode 100644 libio/dbz/firstlast25 create mode 100755 libio/dbz/getmap create mode 100644 libio/dbz/random.c create mode 100644 libio/dbz/revbytes create mode 100644 libio/dbz/stdio.h create mode 100644 libio/depend create mode 100644 libio/editbuf.cc create mode 100644 libio/editbuf.h create mode 100644 libio/filebuf.cc create mode 100644 libio/filedoalloc.c create mode 100644 libio/fileops.c create mode 100644 libio/floatconv.c create mode 100644 libio/floatio.h create mode 100644 libio/fstream.cc create mode 100644 libio/fstream.h create mode 100755 libio/gen-params create mode 100644 libio/genops.c create mode 100644 libio/indstream.cc create mode 100644 libio/indstream.h create mode 100644 libio/ioassign.cc create mode 100644 libio/ioextend.cc create mode 100644 libio/iofclose.c create mode 100644 libio/iofdopen.c create mode 100644 libio/iofflush.c create mode 100644 libio/iofgetpos.c create mode 100644 libio/iofgets.c create mode 100644 libio/iofopen.c create mode 100644 libio/iofprintf.c create mode 100644 libio/iofputs.c create mode 100644 libio/iofread.c create mode 100644 libio/iofscanf.c create mode 100644 libio/iofsetpos.c create mode 100644 libio/ioftell.c create mode 100644 libio/iofwrite.c create mode 100644 libio/iogetdelim.c create mode 100644 libio/iogetline.c create mode 100644 libio/iogets.c create mode 100644 libio/ioignore.c create mode 100644 libio/iolibio.h create mode 100644 libio/iomanip.cc create mode 100644 libio/iomanip.h create mode 100644 libio/iopadn.c create mode 100644 libio/ioperror.c create mode 100644 libio/iopopen.c create mode 100644 libio/ioprims.c create mode 100644 libio/ioprintf.c create mode 100644 libio/ioputs.c create mode 100644 libio/ioscanf.c create mode 100644 libio/ioseekoff.c create mode 100644 libio/ioseekpos.c create mode 100644 libio/iosetbuffer.c create mode 100644 libio/iosetvbuf.c create mode 100644 libio/iosprintf.c create mode 100644 libio/iosscanf.c create mode 100644 libio/iostdio.h create mode 100644 libio/iostream.cc create mode 100644 libio/iostream.h create mode 100644 libio/iostream.texi create mode 100644 libio/iostreamP.h create mode 100644 libio/iostrerror.c create mode 100644 libio/ioungetc.c create mode 100644 libio/iovfprintf.c create mode 100644 libio/iovfscanf.c create mode 100644 libio/iovsprintf.c create mode 100644 libio/iovsscanf.c create mode 100644 libio/isgetline.cc create mode 100644 libio/isgetsb.cc create mode 100644 libio/isscan.cc create mode 100644 libio/istream.h create mode 100644 libio/libio.h create mode 100644 libio/libioP.h create mode 100644 libio/osform.cc create mode 100644 libio/ostream.h create mode 100644 libio/outfloat.c create mode 100644 libio/parsestream.cc create mode 100644 libio/parsestream.h create mode 100644 libio/pfstream.cc create mode 100644 libio/pfstream.h create mode 100644 libio/procbuf.cc create mode 100644 libio/procbuf.h create mode 100644 libio/sbform.cc create mode 100644 libio/sbgetline.cc create mode 100644 libio/sbscan.cc create mode 100644 libio/stdfiles.c create mode 100644 libio/stdio/ChangeLog create mode 100644 libio/stdio/Makefile.in create mode 100644 libio/stdio/clearerr.c create mode 100644 libio/stdio/configure.in create mode 100644 libio/stdio/fdopen.c create mode 100644 libio/stdio/feof.c create mode 100644 libio/stdio/ferror.c create mode 100644 libio/stdio/fgetc.c create mode 100644 libio/stdio/fileno.c create mode 100644 libio/stdio/fputc.c create mode 100644 libio/stdio/freopen.c create mode 100644 libio/stdio/fseek.c create mode 100644 libio/stdio/getc.c create mode 100644 libio/stdio/getchar.c create mode 100644 libio/stdio/getline.c create mode 100644 libio/stdio/getw.c create mode 100644 libio/stdio/popen.c create mode 100644 libio/stdio/putc.c create mode 100644 libio/stdio/putchar.c create mode 100644 libio/stdio/putw.c create mode 100644 libio/stdio/rewind.c create mode 100644 libio/stdio/setbuf.c create mode 100644 libio/stdio/setfileno.c create mode 100644 libio/stdio/setlinebuf.c create mode 100644 libio/stdio/snprintf.c create mode 100644 libio/stdio/stdio.h create mode 100644 libio/stdio/vfprintf.c create mode 100644 libio/stdio/vfscanf.c create mode 100644 libio/stdio/vprintf.c create mode 100644 libio/stdio/vscanf.c create mode 100644 libio/stdio/vsnprintf.c create mode 100644 libio/stdiostream.cc create mode 100644 libio/stdiostream.h create mode 100644 libio/stdstrbufs.cc create mode 100644 libio/stdstreams.cc create mode 100644 libio/stream.cc create mode 100644 libio/stream.h create mode 100644 libio/streambuf.cc create mode 100644 libio/streambuf.h create mode 100644 libio/strfile.h create mode 100644 libio/strops.c create mode 100644 libio/strstream.cc create mode 100644 libio/strstream.h create mode 100644 libio/tests/ChangeLog create mode 100644 libio/tests/Makefile.in create mode 100644 libio/tests/configure.in create mode 100644 libio/tests/hounddog.cc create mode 100644 libio/tests/hounddog.exp create mode 100644 libio/tests/hounddog.inp create mode 100644 libio/tests/putbackdog.cc create mode 100644 libio/tests/tFile.cc create mode 100644 libio/tests/tFile.exp create mode 100644 libio/tests/tFile.inp create mode 100644 libio/tests/tfformat.c create mode 100644 libio/tests/tiformat.c create mode 100644 libio/tests/tiomanip.cc create mode 100644 libio/tests/tiomanip.exp create mode 100644 libio/tests/tiomisc.cc create mode 100644 libio/tests/tiomisc.exp create mode 100644 libio/tests/tstdiomisc.c create mode 100644 libio/tests/tstdiomisc.exp create mode 100644 libio/testsuite/ChangeLog create mode 100644 libio/testsuite/Makefile.in create mode 100644 libio/testsuite/config/default.exp create mode 100644 libio/testsuite/configure.in create mode 100644 libio/testsuite/lib/libio.exp create mode 100644 libio/testsuite/libio.tests/hounddog.exp create mode 100644 libio/testsuite/libio.tests/putbackdog.exp create mode 100644 libio/testsuite/libio.tests/tFile.exp create mode 100644 libio/testsuite/libio.tests/tfformat.exp create mode 100644 libio/testsuite/libio.tests/tiformat.exp create mode 100644 libio/testsuite/libio.tests/tiomanip.exp create mode 100644 libio/testsuite/libio.tests/tiomisc.exp create mode 100644 libio/testsuite/libio.tests/tstdiomisc.exp create mode 100644 libstdc++/ChangeLog create mode 100644 libstdc++/Makefile.in create mode 100644 libstdc++/NEWS create mode 100644 libstdc++/algorithm create mode 100644 libstdc++/cassert create mode 100644 libstdc++/cctype create mode 100644 libstdc++/cerrno create mode 100644 libstdc++/cfloat create mode 100644 libstdc++/cinst.cc create mode 100644 libstdc++/ciso646 create mode 100644 libstdc++/climits create mode 100644 libstdc++/clocale create mode 100644 libstdc++/cmath create mode 100644 libstdc++/cmathi.cc create mode 100644 libstdc++/complex create mode 100644 libstdc++/complex.h create mode 100644 libstdc++/config/aix.ml create mode 100644 libstdc++/config/dec-osf.ml create mode 100644 libstdc++/config/elf.ml create mode 100644 libstdc++/config/elfshlibm.ml create mode 100644 libstdc++/config/hpux.ml create mode 100644 libstdc++/config/irix5.ml create mode 100644 libstdc++/config/linux.ml create mode 100644 libstdc++/config/sol2shm.ml create mode 100644 libstdc++/config/sunos4.ml create mode 100644 libstdc++/configure.in create mode 100644 libstdc++/csetjmp create mode 100644 libstdc++/csignal create mode 100644 libstdc++/cstdarg create mode 100644 libstdc++/cstddef create mode 100644 libstdc++/cstdio create mode 100644 libstdc++/cstdlib create mode 100644 libstdc++/cstdlibi.cc create mode 100644 libstdc++/cstring create mode 100644 libstdc++/cstringi.cc create mode 100644 libstdc++/ctime create mode 100644 libstdc++/cwchar create mode 100644 libstdc++/cwctype create mode 100644 libstdc++/deque create mode 100644 libstdc++/functional create mode 100644 libstdc++/iterator create mode 100644 libstdc++/list create mode 100644 libstdc++/map create mode 100644 libstdc++/memory create mode 100644 libstdc++/numeric create mode 100644 libstdc++/queue create mode 100644 libstdc++/set create mode 100644 libstdc++/sinst.cc create mode 100644 libstdc++/stack create mode 100644 libstdc++/std/bastring.cc create mode 100644 libstdc++/std/bastring.h create mode 100644 libstdc++/std/complext.cc create mode 100644 libstdc++/std/complext.h create mode 100644 libstdc++/std/dcomplex.h create mode 100644 libstdc++/std/fcomplex.h create mode 100644 libstdc++/std/ldcomplex.h create mode 100644 libstdc++/std/straits.h create mode 100644 libstdc++/stdexcept create mode 100644 libstdc++/stdexcepti.cc create mode 100644 libstdc++/stl.h create mode 100644 libstdc++/stl/ChangeLog create mode 100644 libstdc++/stl/README create mode 100644 libstdc++/stl/algo.h create mode 100644 libstdc++/stl/algobase.h create mode 100644 libstdc++/stl/alloc.h create mode 100644 libstdc++/stl/bvector.h create mode 100644 libstdc++/stl/defalloc.h create mode 100644 libstdc++/stl/deque.h create mode 100644 libstdc++/stl/function.h create mode 100644 libstdc++/stl/hash_map.h create mode 100644 libstdc++/stl/hash_set.h create mode 100644 libstdc++/stl/hashtable.h create mode 100644 libstdc++/stl/heap.h create mode 100644 libstdc++/stl/iterator.h create mode 100644 libstdc++/stl/list.h create mode 100644 libstdc++/stl/map.h create mode 100644 libstdc++/stl/multimap.h create mode 100644 libstdc++/stl/multiset.h create mode 100644 libstdc++/stl/pair.h create mode 100644 libstdc++/stl/pthread_alloc.h create mode 100644 libstdc++/stl/rope.h create mode 100644 libstdc++/stl/ropeimpl.h create mode 100644 libstdc++/stl/set.h create mode 100644 libstdc++/stl/slist.h create mode 100644 libstdc++/stl/stack.h create mode 100644 libstdc++/stl/stl_config.h create mode 100644 libstdc++/stl/tempbuf.h create mode 100644 libstdc++/stl/tree.h create mode 100644 libstdc++/stl/type_traits.h create mode 100644 libstdc++/stl/vector.h create mode 100644 libstdc++/stlinst.cc create mode 100644 libstdc++/string create mode 100644 libstdc++/tests/ChangeLog create mode 100644 libstdc++/tests/Makefile.in create mode 100644 libstdc++/tests/configure.in create mode 100644 libstdc++/tests/tcomplex.cc create mode 100644 libstdc++/tests/tcomplex.exp create mode 100644 libstdc++/tests/tcomplex.inp create mode 100644 libstdc++/tests/tlist.cc create mode 100644 libstdc++/tests/tlist.exp create mode 100644 libstdc++/tests/tmap.cc create mode 100644 libstdc++/tests/tmap.exp create mode 100644 libstdc++/tests/tstring.cc create mode 100644 libstdc++/tests/tstring.exp create mode 100644 libstdc++/tests/tstring.inp create mode 100644 libstdc++/tests/tvector.cc create mode 100644 libstdc++/tests/tvector.exp create mode 100644 libstdc++/testsuite/ChangeLog create mode 100644 libstdc++/testsuite/Makefile.in create mode 100644 libstdc++/testsuite/config/default.exp create mode 100644 libstdc++/testsuite/configure.in create mode 100644 libstdc++/testsuite/lib/libstdc++.exp create mode 100644 libstdc++/testsuite/libstdc++.tests/test.exp create mode 100644 libstdc++/utility create mode 100644 libstdc++/vector create mode 100755 ltconfig create mode 100644 ltmain.sh create mode 100755 missing create mode 100755 mkinstalldirs create mode 100755 move-if-change create mode 100644 mpw-README create mode 100644 mpw-build.in create mode 100644 mpw-config.in create mode 100644 mpw-configure create mode 100755 symlink-tree create mode 100644 texinfo/COPYING create mode 100644 texinfo/ChangeLog create mode 100644 texinfo/INSTALL create mode 100644 texinfo/INTRODUCTION create mode 100644 texinfo/Makefile.in create mode 100644 texinfo/NEWS create mode 100644 texinfo/README create mode 100644 texinfo/TODO create mode 100644 texinfo/aclocal.m4 create mode 100755 texinfo/configure create mode 100644 texinfo/configure.in create mode 100644 texinfo/dir create mode 100644 texinfo/dir-example create mode 100644 texinfo/dir.info-template create mode 100644 texinfo/emacs/Makefile.in create mode 100644 texinfo/emacs/detexinfo.el create mode 100755 texinfo/emacs/elisp-comp create mode 100644 texinfo/emacs/info.el create mode 100644 texinfo/emacs/informat.el create mode 100644 texinfo/emacs/makeinfo.el create mode 100644 texinfo/emacs/new-useful-setqs create mode 100644 texinfo/emacs/texinfmt.el create mode 100644 texinfo/emacs/texinfo.el create mode 100644 texinfo/emacs/texnfo-tex.el create mode 100644 texinfo/emacs/texnfo-upd.el create mode 100755 texinfo/gen-info-dir create mode 100644 texinfo/gpl.texinfo create mode 100644 texinfo/info/Makefile.in create mode 100644 texinfo/info/NEWS create mode 100644 texinfo/info/README create mode 100644 texinfo/info/clib.c create mode 100644 texinfo/info/clib.h create mode 100644 texinfo/info/dir.c create mode 100644 texinfo/info/display.c create mode 100644 texinfo/info/display.h create mode 100644 texinfo/info/doc.h create mode 100644 texinfo/info/dribble.c create mode 100644 texinfo/info/dribble.h create mode 100644 texinfo/info/echo_area.c create mode 100644 texinfo/info/echo_area.h create mode 100644 texinfo/info/filesys.c create mode 100644 texinfo/info/filesys.h create mode 100644 texinfo/info/footnotes.c create mode 100644 texinfo/info/footnotes.h create mode 100644 texinfo/info/gc.c create mode 100644 texinfo/info/gc.h create mode 100644 texinfo/info/general.h create mode 100644 texinfo/info/indices.c create mode 100644 texinfo/info/indices.h create mode 100644 texinfo/info/info-stnd.texi create mode 100644 texinfo/info/info-utils.c create mode 100644 texinfo/info/info-utils.h create mode 100644 texinfo/info/info.1 create mode 100644 texinfo/info/info.c create mode 100644 texinfo/info/info.h create mode 100644 texinfo/info/info.texi create mode 100644 texinfo/info/infodoc.c create mode 100644 texinfo/info/infomap.c create mode 100644 texinfo/info/infomap.h create mode 100644 texinfo/info/m-x.c create mode 100644 texinfo/info/makedoc.c create mode 100644 texinfo/info/man.c create mode 100644 texinfo/info/man.h create mode 100644 texinfo/info/nodemenu.c create mode 100644 texinfo/info/nodes.c create mode 100644 texinfo/info/nodes.h create mode 100644 texinfo/info/search.c create mode 100644 texinfo/info/search.h create mode 100644 texinfo/info/session.c create mode 100644 texinfo/info/session.h create mode 100644 texinfo/info/signals.c create mode 100644 texinfo/info/signals.h create mode 100644 texinfo/info/termdep.h create mode 100644 texinfo/info/terminal.c create mode 100644 texinfo/info/terminal.h create mode 100644 texinfo/info/tilde.c create mode 100644 texinfo/info/tilde.h create mode 100644 texinfo/info/userdoc.texi create mode 100644 texinfo/info/variables.c create mode 100644 texinfo/info/variables.h create mode 100644 texinfo/info/window.c create mode 100644 texinfo/info/window.h create mode 100644 texinfo/info/xmalloc.c create mode 100755 texinfo/install-sh create mode 100644 texinfo/lgpl.texinfo create mode 100644 texinfo/liblic.texi create mode 100644 texinfo/libtxi/Makefile.in create mode 100644 texinfo/libtxi/alloca.c create mode 100644 texinfo/libtxi/bzero.c create mode 100644 texinfo/libtxi/getopt.c create mode 100644 texinfo/libtxi/getopt.h create mode 100644 texinfo/libtxi/getopt1.c create mode 100644 texinfo/libtxi/memcpy.c create mode 100644 texinfo/libtxi/memmove.c create mode 100644 texinfo/libtxi/strdup.c create mode 100644 texinfo/license.texi create mode 100644 texinfo/makeinfo/Makefile.in create mode 100644 texinfo/makeinfo/macro.texi create mode 100644 texinfo/makeinfo/macros/example.texi create mode 100644 texinfo/makeinfo/macros/html.texi create mode 100644 texinfo/makeinfo/macros/multifmt.texi create mode 100644 texinfo/makeinfo/macros/res-samp.texi create mode 100644 texinfo/makeinfo/macros/resume.texi create mode 100644 texinfo/makeinfo/macros/simpledoc.texi create mode 100644 texinfo/makeinfo/makeinfo.c create mode 100644 texinfo/makeinfo/makeinfo.h create mode 100644 texinfo/makeinfo/makeinfo.texi create mode 100644 texinfo/makeinfo/multi.c create mode 100644 texinfo/makeinfo/multiformat.texi create mode 100644 texinfo/testsuite/ChangeLog create mode 100644 texinfo/testsuite/Makefile.in create mode 100644 texinfo/testsuite/config/unix.exp create mode 100755 texinfo/testsuite/configure create mode 100644 texinfo/testsuite/configure.in create mode 100644 texinfo/testsuite/lib/utils.exp create mode 100644 texinfo/testsuite/makeinfo.0/atnode.exp create mode 100644 texinfo/testsuite/makeinfo.0/conditions.exp create mode 100644 texinfo/testsuite/makeinfo.0/mini.exp create mode 100644 texinfo/testsuite/makeinfo.0/missnode.exp create mode 100644 texinfo/testsuite/makeinfo.0/nonsense.exp create mode 100644 texinfo/testsuite/makeinfo.0/not.exp create mode 100644 texinfo/testsuite/makeinfo.0/smstruct.exp create mode 100644 texinfo/testsuite/text/atnode.texi create mode 100644 texinfo/testsuite/text/conditions.texi create mode 100644 texinfo/testsuite/text/dfltnode.texi create mode 100644 texinfo/testsuite/text/minimal.texi create mode 100644 texinfo/testsuite/text/missnode.texi create mode 100644 texinfo/testsuite/text/nonsense.texi create mode 100644 texinfo/testsuite/text/not.texi create mode 100644 texinfo/testsuite/text/smstruct.texi create mode 100644 texinfo/texinfo.tex create mode 100644 texinfo/texinfo.texi create mode 100644 texinfo/util/Makefile.in create mode 100644 texinfo/util/deref.c create mode 100755 texinfo/util/fixfonts create mode 100755 texinfo/util/gen-dir-node create mode 100644 texinfo/util/install-info.c create mode 100755 texinfo/util/mkinstalldirs create mode 100755 texinfo/util/tex3patch create mode 100755 texinfo/util/texi2dvi create mode 100644 texinfo/util/texindex.c create mode 100644 xiberty/configure.in create mode 100755 ylwrap diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 000000000000..944dd6db9525 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,31 @@ +*-all +*-co +*-dirs +*-done +*-info +*-install +*-install-info +*-src +*-stamp-* +*-tagged +blockit +cfg-paper.info +config.status +configure.aux +configure.cp +configure.cps +configure.dvi +configure.fn +configure.fns +configure.ky +configure.kys +configure.log +configure.pg +configure.pgs +configure.toc +configure.tp +configure.tps +configure.vr +configure.vrs +dir.info +Makefile diff --git a/COPYING b/COPYING new file mode 100644 index 000000000000..60549be514af --- /dev/null +++ b/COPYING @@ -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. + + + Copyright (C) 19yy + + 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) 19yy 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. + + , 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/COPYING.LIB b/COPYING.LIB new file mode 100644 index 000000000000..eb685a5ec981 --- /dev/null +++ b/COPYING.LIB @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, 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 library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, 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 companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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. + + + Copyright (C) + + This library 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 of the License, 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 000000000000..5d2401a295e5 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,5207 @@ +Wed Aug 20 19:57:37 1997 Jason Merrill + + * Makefile.in (BISON, YACC): Use $$s. + (all-bison): Depend on all-texinfo. + +Tue Aug 19 01:41:32 1997 Jason Merrill + + * Makefile.in (BISON): Add -L flag. + (YACC): Likewise. + + + +Mon Aug 18 09:24:06 1997 Gavin Koch + + * config.sub: Add mipstx39. Delete r3900. + +Mon Aug 18 17:20:10 1997 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (all-autoconf): Depends on all-texinfo. + +Fri Aug 15 23:09:26 1997 Michael Meissner + + * config-ml.in ({powerpc,rs6000}*-*-*): Update to current AIX and + eabi targets. + +Thu Aug 14 14:42:17 1997 Ian Lance Taylor + + * configure: Get CFLAGS and CXXFLAGS from Makefile, if possible. + + * configure: When handling a Canadian Cross, handle YACC as well as + BISON. Just set BISON to bison. When setting YACC, prefer bison. + +Tue Aug 12 20:09:48 1997 Jason Merrill + + * Makefile.in (BISON): bison, not byacc or bison -y. + (YACC): bison -y or byacc or yacc. + (various): Add *-bison as appropriate. + (taz): No need to mess with BISON anymore. + +Tue Aug 12 22:33:08 1997 Ian Lance Taylor + + * configure: If OSTYPE matches *win32*, try to find a good value for + CONFIG_SHELL. + +Sun Aug 10 14:41:11 1997 Ian Lance Taylor + + * Makefile.in (taz): Get the version number from AM_INIT_AUTOMAKE in + configure.in if it is present. + +Sat Aug 9 00:58:01 1997 Ian Lance Taylor + + * Makefile.in (LD_FOR_TARGET): Change ld.new to ld-new. + +Fri Aug 8 16:30:13 1997 Doug Evans + + * config.sub: Recognize `arc' cpu. + * configure.in: Likewise. + * config-ml.in: Likewise. + +Thu Aug 7 11:02:34 1997 Ian Lance Taylor + + * Makefile.in ($(INSTALL_X11_MODULES)): Depend upon installdirs. + +Wed Aug 6 16:27:29 1997 Chris Provenzano + + * configure: Changed sed delimiter from ':' to '|' when + attempting to substitute ${config_shell} for SHELL. On + NT ${config_shell} may contain a ':' in it. + +Wed Aug 6 12:29:05 1997 Jason Merrill + + * Makefile.in (EXTRA_GCC_FLAGS): Fix for non-bash shells. + +Wed Aug 6 00:42:35 1997 Ian Lance Taylor + + * Makefile.in (AS_FOR_TARGET): Change as.new to as-new. + +Tue Aug 5 14:08:51 1997 Ian Lance Taylor + + * Makefile.in (NM_FOR_TARGET): Change nm.new to nm-new. + + * ylwrap: If the program is a relative path, force it to be + absolute. + +Tue Aug 5 12:12:44 1997 Andrew Cagney + + * configure (tooldir): Set BISON to `bison -y' and not just bison. + +Mon Aug 4 22:59:02 1997 Andrew Cagney + + * Makefile.in (CC_FOR_TARGET): When winsup/Makefile present, + correctly specify the target build directory $(TARGET_SUBDIR)/winsup + for libraries. + +Mon Aug 4 12:40:24 1997 Jason Merrill + + * Makefile.in (EXTRA_GCC_FLAGS): Fix handling of macros with values + separated by spaces. + +Thu Jul 31 19:49:49 1997 Ian Lance Taylor + + * ylwrap: New file. + * Makefile.in (DEVO_SUPPORT): Add ylwrap. + + * ltmain.sh: Handle /bin/sh at start of install program. + + * Makefile.in (DEVO_SUPPORT): Add ltconfig, ltmain.sh, and missing. + + * ltconfig, ltmain.sh: New files, from libtool 1.0. + * missing: New file, from automake 1.2. + +Thu Jul 24 12:57:56 1997 Ian Lance Taylor + + * Makefile.in: Treat tix like tk, putting it in X11_MODULES. Add + check-tk to CHECK_X11_MODULES. + +Wed Jul 23 17:03:29 1997 Ian Lance Taylor + + * config.sub: Merge with FSF. + +Tue Jul 22 19:08:29 1997 Ian Lance Taylor + + * config.guess: Merge with FSF. + +Tue Jul 22 14:50:42 1997 Robert Hoehne + + * configure: Treat msdosdjgpp like go32. + * configure.in: Likewise. Don't remove gprof for go32. + + * configure: Change Makefile.tem2 to Makefile.tm2. + +Mon Jul 21 10:31:26 1997 Stephen Peters + + * configure.in (noconfigdirs): For alpha-dec-osf*, don't ignore grep. + +Tue Jul 15 14:33:03 1997 Brendan Kehoe + + * install-sh (chmodcmd): Set to null if the DST directory already + exists. Same as Nov 11th change. + +Mon Jul 14 11:01:15 1997 Martin M. Hunt + + * configure (GDB_TK): Needs itcl and tix. + +Mon Jul 14 00:32:10 1997 Jason Merrill + + * config.guess: Update from FSF. + +Fri Jul 11 11:57:11 1997 Martin M. Hunt + + * Makefile.in (GDB_TK): Depend on itcl and tix. + +Fri Jul 4 13:25:31 1997 Ian Lance Taylor + + * Makefile.in (INSTALL_PROGRAM_ARGS): New variable. + (INSTALL_PROGRAM): Use $(INSTALL_PROGRAM_ARGS). + (INSTALL_SCRIPT): New variable. + (BASE_FLAGS_TO_PASS): Pass down INSTALL_SCRIPT. + * configure.in: If host is *-*-cygwin32*, set INSTALL_PROGRAM_ARGS + to -x. + * install-sh: Add support for -x option. + +Mon Jun 30 15:51:30 1997 Ian Lance Taylor + + * configure.in, Makefile.in: Treat tix like itcl. + +Thu Jun 26 13:59:19 1997 Ian Lance Taylor + + * Makefile.in (WINDRES): New variable. + (WINDRES_FOR_TARGET): New variable. + (BASE_FLAGS_TO_PASS): Add WINDRES_FOR_TARGET. + (EXTRA_HOST_FLAGS): Add WINDRES. + (EXTRA_TARGET_FLAGS): Add WINDRES. + (EXTRA_GCC_FLAGS): Add WINDRES. + ($(DO_X)): Pass down WINDRES. + ($(CONFIGURE_TARGET_MODULES)): Set WINDRES when configuring. + * configure: Treat WINDRES like DLLTOOL, and WINDRES_FOR_TARGET like + DLLTOOL_FOR_TARGET. + +Wed Jun 25 15:01:26 1997 Felix Lee + + * configure.in: configure sim before gdb for win32-x-ppc + +Wed Jun 25 12:18:54 1997 Brendan Kehoe + + Move gperf into the toplevel, from libg++. + * configure.in (target_tools): Add target-gperf. + (native_only): Add target-gperf. + * Makefile.in (all-target-gperf): New target, depend on + all-target-libg++. + (configure-target-gperf): Empty rule. + (ALL_TARGET_MODULES): Add all-target-gperf. + (CONFIGURE_TARGET_MODULES): Add configure-target-gperf. + (CHECK_TARGET_MODULES): Add check-target-gperf. + (INSTALL_TARGET_MODULES): Add install-target-gperf. + (CLEAN_TARGET_MODULES): Add clean-target-gperf. + +Mon Jun 23 10:51:53 1997 Jeffrey A Law (law@cygnus.com) + + * config.sub (mn10200): Recognize new basic machine. + +Thu Jun 19 14:16:42 1997 Brendan Kehoe + + * configure.in: Don't set ENABLE_MULTILIB, so we'll be passing + --enable-multilib down to subdirs; setting TARGET_SUBDIR was enough. + +Tue Jun 17 15:31:20 1997 Brendan Kehoe + + * configure.in: If we're building mips-sgi-irix6* native, turn on + ENABLE_MULTILIB and set TARGET_SUBDIR. + +Tue Jun 17 12:20:59 1997 Tom Tromey + + * Makefile.in (all-sn): Depend on all-grep. + +Mon Jun 16 11:11:10 1997 Ian Lance Taylor + + * configure.in: Use mh-ppcpic and mt-ppcpic for powerpc*-* targets. + + * configure: Set CFLAGS and CXXFLAGS, and substitute them into + Makefile. From Jeff Makey . + * Makefile.in: Add comment for CFLAGS and CXXFLAGS. + + * Makefile.in (DISTBISONFILES): Remove. + (taz): Don't futz with DISTBISONFILES. Change BISON to use + $(DEFAULT_YACC). + + * configure.in: Build itl, db, sn, etc., when building for native + cygwin32. + + * Makefile.in (LD): New variable. + (EXTRA_HOST_FLAGS): Pass down LD. + ($(DO_X)): Likewise. + +Mon Jun 16 11:10:35 1997 Philip Blundell + + * Makefile.in (INSTALL): Use $(SHELL) when executing install-sh. + +Fri Jun 13 10:22:56 1997 Bob Manson + + * configure.in (targargs): Strip out any supplied --build argument + before adding our own. Always add --build. + +Thu Jun 12 21:12:28 1997 Bob Manson + + * configure.in (targargs): Pass --build if we're doing + a cross-compile. + +Fri Jun 6 21:38:40 1997 Rob Savoye + + * configure: Use '|' instead of ":" as the seperator in + sed. Otherwise sed chokes on NT path names with drive + designators. Also look for "?:*" as the leading characters in an + absolute pathname. + +Mon Jun 2 13:05:20 1997 Gavin Koch + + * config.sub: Support for r3900. + +Wed May 21 17:33:31 1997 Ian Lance Taylor + + * configure.in: Use install-sh, not install.sh. + +Wed May 14 16:06:51 1997 Ian Lance Taylor + + * Makefile.in (taz): Improve check for BISON so it doesn't try to + apply it twice. + +Fri May 9 17:22:05 1997 Ian Lance Taylor + + * Makefile.in (INSTALL_MODULES): Put install-opcodes before + install-binutils. + +Thu May 8 17:29:50 1997 Ian Lance Taylor + + * Makefile.in: Add automake targets. + * configure.in (host_tools): Add automake. + +Tue May 6 15:49:52 1997 Ian Lance Taylor + + * configure: Default CXX to c++, not gcc. + * Makefile.in (CXX): Set to c++, not gcc. + (CXX_FOR_TARGET): When cross, transform c++, not gcc. + +Thu May 1 10:11:43 1997 Geoffrey Noer + + * install-sh: try appending a .exe if source file doesn't + exist + +Wed Apr 30 12:05:36 1997 Jason Merrill + + * configure.in: Turn on multilib by default. + (cross_only): Remove target-libiberty. + + * Makefile.in (all-gcc): Don't depend on libiberty. + +Mon Apr 28 18:39:45 1997 Michael Snyder + + * config.guess: improve algorithm for recognizing Gnu Hurd x86. + +Thu Apr 24 19:30:07 1997 Ian Lance Taylor + + * Makefile.in (DEVO_SUPPORT): Add mpw-install. + (DISTBISONFILES): Add ld/Makefile.in + +Tue Apr 22 17:17:28 1997 Geoffrey Noer + + * configure.in: if target is cygwin32 but host isn't cygwin32, + don't configure gdb tcl tk expect, not just gdb. + +Mon Apr 21 13:33:39 1997 Tom Tromey + + * configure.in: Added gnuserv everywhere sn appears. + + * Makefile.in (ALL_MODULES): Added all-gnuserv. + (CROSS_CHECK_MODULES): Added check-gnuserv. + (INSTALL_MODULES): Added install-gnuserv. + (CLEAN_MODULES): Added clean-gnuserv. + (all-gnuserv): New target. + +Thu Apr 17 13:57:06 1997 Per Fogelstrom + + * config.guess: Fixes for MIPS OpenBSD systems. + +Tue Apr 15 12:21:07 1997 Ian Lance Taylor + + * Makefile.in (INSTALL_XFORM): Remove. + (BASE_FLAGS_TO_PASS): Remove INSTALL_XFORM. + + * mkinstalldirs: New file, copied from automake. + * Makefile.in (installdirs): Rename from install-dirs. Use + mkinstalldirs. Change all users. + (DEVO_SUPPORT): Add mkinstalldirs. + +Mon Apr 14 11:21:38 1997 Ian Lance Taylor + + * install-sh: Rename from install.sh. + * Makefile.in (INSTALL): Change install.sh to install-sh. + (DEVO_SUPPORT): Likewise. + + * configure: Use ${config_shell} with ${moveifchange}. From Thomas + Graichen . + +Fri Apr 11 16:37:10 1997 Niklas Hallqvist + + * config.guess: Recognize OpenBSD systems correctly. + +Fri Apr 11 17:07:04 1997 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * README, Makefile.in (ETC_SUPPORT): Remove references to + cfg-paper*, configure.{texi,man,info*}._ + +Sun Apr 6 18:47:57 1997 Andrew Cagney + + * Makefile.in (all.normal): Ensure that gcc is built after all + the x11 - ie gdb - targets. + +Tue Apr 1 16:28:50 1997 Klaus Kaempf + + * makefile.vms: Don't run conf-a-gas. + +Mon Mar 31 16:26:55 1997 Joel Sherrill + + * configure.in (hppa1.1-*-rtems*): New target, like hppa-*-*elf*. + +Fri Mar 28 18:28:52 1997 Ian Lance Taylor + + * configure: Set cache_file to config.cache. + * Makefile.in (local-distclean): Remove config.cache. + +Wed Mar 26 18:49:39 1997 Ian Lance Taylor + + * COPYING: Update FSF address. + +Mon Mar 24 15:02:39 1997 Ian Lance Taylor + + * Makefile.in (install-dirs): Don't crash if prefix, and hence + MAKEDIRS, is empty. + +Mon Mar 24 12:40:55 1997 Doug Evans + + * config.sub: Tweak mn10300 entry. + +Fri Mar 21 15:35:27 1997 Michael Meissner + + * configure.in (host_tools): Put sim before gdb, so gdb's + configure.tgt can determine if the simulator was configured. + +Sun Mar 16 16:07:08 1997 Fred Fish + + * config.sub: Move BeOS $os case to be with other Cygnus + local cases. + +Sun Mar 16 01:34:55 1997 Martin Hunt + + * config.sub: Remove misplaced comment that broke Linux. + +Sat Mar 15 22:50:15 1997 Fred Fish + + * config.sub: Add BeOS support. + +Mon Mar 10 13:30:11 1997 Tom Tromey + + * Makefile.in (CHECK_X11_MODULES): Don't run check-tk. + +Wed Mar 5 12:09:29 1997 Martin + + * configure.in (noconfigdirs): Remove tcl and tk from + noconfigdirs for cygwin32 builds. + +Thu Feb 27 14:57:26 1997 Ken Raeburn + + * Makefile.in (GAS_SUPPORT_DIRS, BINUTILS_SUPPORT_DIRS): Remove + make-all.com, use makefile.vms instead. + +Tue Feb 25 18:46:14 1997 Stan Shebs + + * config.sub: Accept -lnews*. + +Thu Feb 13 22:04:44 1997 Klaus Kaempf + + * makefile.vms: New file. + * make-all.com: Remove. + +Wed Feb 12 12:54:18 1997 Jim Wilson + + * Makefile.in (EXTRA_GCC_FLAGS): Add LIBGCC2_DEBUG_CFLAGS. + +Sat Feb 8 20:36:49 1997 Michael Meissner + + * Makefile.in (all-itcl): The rule is all-itcl, not all-tcl. + +Tue Feb 4 11:39:29 1997 Tom Tromey + + * Makefile.in (ALL_MODULES): Added all-db. + (CROSS_CHECK_MODULES): Addec check-db. + (INSTALL_MODULES): Added install-db. + (CLEAN_MODULES): Added clean-db. + +Mon Feb 3 13:29:36 1997 Ian Lance Taylor + + * config.guess: Merge with latest FSF sources. + +Tue Jan 28 09:20:37 1997 Tom Tromey + + * Makefile.in (ALL_MODULES): Added all-itcl. + (CROSS_CHECK_MODULES): Added check-itcl. + (INSTALL_MODULES): Added install-itcl. + (CLEAN_MODULES): Added clean-itcl. + +Thu Jan 23 01:44:27 1997 Geoffrey Noer + + * configure.in: build gdb for mn10200 + +Fri Jan 17 15:32:15 1997 Doug Evans + + * Makefile.in (all-target-winsup): Depend on all-target-libio. + +Fri Jan 3 16:04:03 1997 Ian Lance Taylor + + * Makefile.in (MAKEINFO): Check for the existence of the Makefile, + rather than the makeinfo program. + (do-info): Depend upon all-texinfo. + +Tue Dec 31 16:00:31 1996 Ian Lance Taylor + + * configure.in: Remove uses of config/mh-linux. + + * config.sub, config.guess: Merge with latest FSF sources. + +Fri Dec 27 12:07:59 1996 Ian Lance Taylor + + * config.sub, config.guess: Merge with latest FSF sources. + +Wed Dec 18 22:46:39 1996 Stan Shebs + + * mpw-build.in: Build ld before gcc, use NewFolderRecursive. + * mpw-config.in: Test for NewFolderRecursive. + * mpw-install: Use symbolic name for startup filename. + * mpw-README: Add various additional details. + +Wed Dec 18 13:11:46 1996 Jim Wilson + + * configure.in (mips*-sgi-irix6*): Remove binutils from noconfigdirs. + +Wed Dec 18 10:29:31 1996 Jeffrey A Law (law@cygnus.com) + + * configure.in: Do build gcc and the target libraries for + the mn10200. + +Wed Dec 4 16:53:05 1996 Geoffrey Noer + + * configure.in: don't avoid building gdb for mn10300 any more + * Makefile.in: double-quote GCC_FOR_TARGET line in EXTRA_GCC_FLAGS + instead of single-quoting it. + +Tue Dec 3 23:26:50 1996 Jason Merrill + + * configure.in: Don't use --with-stabs on IRIX 6. + +Tue Dec 3 09:05:25 1996 Doug Evans + + * configure.in (m32r): Build gdb, libg++ now. + +Sun Dec 1 00:18:59 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * configure.in (mips*-sgi-irix6*): Remove gdb and related + directories from noconfigdirs. + +Tue Nov 26 11:45:33 1996 Kim Knuttila + + * config.sub (basic_machine): added mips16 configuration + +Sat Nov 23 19:26:22 1996 Michael Meissner + + * config.sub: Handle d10v-unknown. + +Thu Nov 21 16:19:44 1996 Geoffrey Noer + + * Makefile.in: add findutils + * configure.in: add findutils to list of host_tools + +Wed Nov 20 10:09:01 1996 Jeffrey A Law (law@cygnus.com) + + * config.sub: Handle mn10200 and mn10300. + +Tue Nov 19 16:35:14 1996 Michael Meissner + + * configure.in (d10v-*): Do not build librx. + +Mon Nov 18 13:28:41 1996 Jeffrey A Law (law@cygnus.com) + + * configure.in (mn10300): Build everything except gdb & libgloss. + +Wed Nov 13 14:59:46 1996 Per Bothner + + * config.guess: Patch for Dansk Data Elektronik servers, + from Niels Skou Olsen . + + For ncr, use /bin/uname rather than uname, since GNU uname does not + support -p. Suggested by Mark Mitchell . + + Patch for MIPS R4000 running System V, + from Eric S. Raymond . + + Fix thinko for nextstep. + + Patch for OSF1 in i?86, from Dan Murphy via Harlan Stenn. + + Sat Jun 24 18:58:17 1995 Morten Welinder + * config.guess: Guess mips-dec-mach_bsd4.3. + + Thu Oct 10 04:07:04 1996 Harlan Stenn + * config.guess (i?86-ncr-sysv*): Emit just enough of the minor + release numbers. + * config.guess (mips-mips-riscos*): Emit just enough of the + release number. + + Tue Oct 8 10:37:22 1996 Frank Vance + * config.guess (sparc-auspex-sunos*): Added. + (f300-fujitsu-*): Added. + + Wed Sep 25 22:00:35 1996 Jeff Woolsey + * config.guess: Recognize a Tadpole as a sparc. + +Wed Nov 13 00:53:09 1996 David J. MacKenzie + + * config.guess: Don't assume that NextStep version is either 2 or + 3. NextStep 4 (aka OpenStep 4) has come out now. + +Mon Nov 11 23:52:03 1996 David J. MacKenzie + + * config.guess: Support Cray T90 that reports itself as "CRAY TS". + From Rik Faith . + +Fri Nov 8 11:34:58 1996 David J. MacKenzie + + * config.sub: Contributions from bug-gnu-utils to: + Support plain "hppa" (no version given) architecture, reported by + OpenStep. + OpenBSD like NetBSD. + LynxOs is not a hardware supplier. + + * config.guess: Contributions from bug-gnu-utils to add support for: + OpenBSD like NetBSD. + Stratus systems. + More Pyramid systems. + i[n>4]86 Intel chips. + M680[n>4]0 Motorola chips. + Use unknown instead of lynx for hardware manufacturer. + +Mon Nov 11 10:09:08 1996 Brendan Kehoe + + * install.sh (chmodcmd): Set to null if the DST directory already + exists. + +Mon Nov 11 10:43:41 1996 Michael Meissner + + * configure.in (powerpc*-{eabi,elf,linux,rtem,sysv,solaris}*): Do + not use mt-ppc target Makefile fragment any more. + +Sun Nov 3 19:17:07 1996 Stu Grossman (grossman@critters.cygnus.com) + + * configure.in (*-*-windows): Exclude everything but those dirs + needed to build windows. + +Tue Oct 29 16:41:31 1996 Doug Evans + + * Makefile.in (all-target-winsup): Depend on all-target-librx. + +Mon Oct 28 17:32:46 1996 Stu Grossman (grossman@critters.cygnus.com) + + * configure.in: Exclude mmalloc from i386-windows. + * config/mh-windows: Add rules for building MSVC makefiles. + +Thu Oct 24 09:22:46 1996 Stu Grossman (grossman@critters.cygnus.com) + + * Undo my previous change. + +Thu Oct 24 12:12:04 1996 Ian Lance Taylor + + * Makefile.in (EXTRA_GCC_FLAGS): Pass down GCC_FOR_TARGET + unconditionally. + (MAKEOVERRIDES): Define (revert this part of October 18 change). + +Thu Oct 24 09:02:07 1996 Stu Grossman (grossman@critters.cygnus.com) + + * Makefile.in (FLAGS_TO_PASS): Add $(HOST_FLAGS) to allow the + host to add it's own flags. + * config/mh-windows (HOST_FLAGS): Set srcroot, which is needed + for MSVC build procedure. + +Tue Oct 22 15:20:26 1996 Ian Lance Taylor + + * configure: Handle GCC_FOR_TARGET like CC_FOR_TARGET. + +Fri Oct 18 13:37:13 1996 Ian Lance Taylor + + * Makefile.in (CC_FOR_TARGET): Check for xgcc, not Makefile. + (CXX_FOR_TARGET): Likewise. + (GCC_FOR_TARGET): Define. + (BASE_FLAGS_TO_PASS): Remove GCC_FOR_TARGET. + (EXTRA_GCC_FLAGS): Define GCC_FOR_TARGET based on whether + CC_FOR_TARGET was specified on the command line. + (MAKEOVERRIDES): Don't define. + +Thu Oct 17 10:27:56 1996 Doug Evans + + * configure.in (m32r): Fix spelling of libg++ libs. + +Thu Oct 10 10:37:17 1996 Stan Shebs + + * config.sub (-apple*): Remove, now redundant. + +Thu Oct 10 12:30:54 1996 Ian Lance Taylor + + * configure: Don't get confused by CPU-VENDOR-linux-gnu. + + * configure: Rework yesterday's sed script patch. + + * config.sub: Merge with FSF. + +Wed Oct 9 17:24:59 1996 Per Bothner + + * config.guess: Merge from FSF. + + 1996-09-12 Richard Stallman + * config.guess: Use pc instead of unknown, for pc clone systems. + Change linux to linux-gnu. + + Mon Jul 15 23:51:11 1996 Karl Heuer + * config.guess: Avoid non-portable tr syntax. + +Wed Oct 9 06:06:46 1996 Jeffrey A Law (law@cygnus.com) + + * test-build.mk (HOLES): Add "xargs" for gdb. + + * configure: Avoid hpux10.20 sed bug. + +Tue Oct 8 08:32:48 1996 Stu Grossman (grossman@critters.cygnus.com) + + * configure.in config/mh-windows: Add support for windows host + (that is a build done under the Microsoft build environment). + +Tue Oct 8 10:39:08 1996 Ian Lance Taylor + + * Makefile.in: Replace all uses of srcroot with s, to shrink + command line lengths. + + Patches from Geoffrey Noer : + * configure.in: If configuring for newlib, pass --with-newlib to + subdirectories. + * Makefile.in (CC_FOR_TARGET): If winsup/Makefile exists, pass a + -Bnewlib/ and -Lwinsup to gcc. + (CXX_FOR_TARGET): Likewise. + +Mon Oct 7 10:59:35 1996 Ian Lance Taylor + + * Makefile.in (ETC_SUPPORT): Add configure. + +Fri Oct 4 12:22:58 1996 Angela Marie Thomas (angela@cygnus.com) + + * configure.in: Use config/mh-dgux386 for i[345]86-dg-dgux + host configuration file. + +Thu Oct 3 09:28:25 1996 Jeffrey A Law (law@cygnus.com) + + * configure.in: Break mn10x00 support into separate + mn10200 and mn10300 configurations. + * config.sub: Likewise. + +Wed Oct 2 22:27:52 1996 Jeffrey A Law (law@cygnus.com) + + * configure.in: Add lots of stuff to noconfigdirs for + the mn10x00 targets. + + * config.sub, configure.in: Add mn10x00 support. + +Wed Oct 2 15:52:36 1996 Klaus Kaempf + + * make-all.com: Call conf-a-gas, not config-a-gas. + +Tue Oct 1 01:28:41 1996 James G. Smith + + * configure.in (noconfigdirs): Don't build libgloss for arm-coff + targets. + +Mon Sep 30 14:24:01 1996 Stan Shebs + + * mpw-README: Add much more detail for native PowerMac. + * mpw-install: New file. + * mpw-configure: Add --norecursion and --help options. + * mpw-config.in: Translate readme and install files when + copying to objdir. + * mpw-build.in: Don't always depend on byacc and flex. + (install-only-top): New action. + +Tue Sep 24 19:05:12 1996 Stan Shebs + + * configure.in (noconfigdirs): Don't configure any C++ dirs + if targeting D10V. + +Tue Sep 17 12:15:31 1996 Ian Lance Taylor + + * config.sub: Recognize mips64vr5000. + +Mon Sep 16 17:00:52 1996 Ian Lance Taylor + + * configure.in: Use a single line for host_tools and native_only. + +Mon Sep 9 12:21:30 1996 Doug Evans + + * config.sub, configure.in: Add entries for m32r. + +Thu Sep 5 13:52:47 1996 Tom Tromey + + * Makefile.in (inet-install): Don't run install-gzip. + +Wed Sep 4 17:26:13 1996 Stu Grossman (grossman@critters.cygnus.com) + + * configure.in: Don't config lots of things for *-*-windows*. + +Sat Aug 31 11:45:57 1996 Stan Shebs + + * mpw-config.in: Test for mpw-true, true, and null-command scripts. + (host_libs, host_tools): Copy from configure.in. + * mpw-configure: Don't complain about directories not found. + +Thu Aug 29 16:44:58 1996 Michael Meissner + + * configure.in (i[345]86): Recognize i686 for pentium pro. + (i[3456]86-*-dgux*): Use config/mh-sysv for the host configuration + file. + + * config.guess (i[345]86): Ditto. + +Mon Aug 26 18:34:42 1996 Martin M. Hunt + + * configure.in (noconfigdirs): Removed gdb for D10V. + +Wed Aug 21 18:56:38 1996 Fred Fish + + * configure: Fix three locations where shell scripts were + being run directly rather than with config_shell. + +Thu Aug 15 12:19:33 1996 Stan Shebs + + * mpw-configure: Handle multiple enable/disable options and + pass them down recursively, handle -c and -s flags appropriately + depending on choice of compiler, add escape mechanism for + quoted arguments to gC. + +Mon Aug 12 13:15:13 1996 Michael Meissner + + * configure.in (powerpc*-*-*): For eabi, system V.4, Linux, and + solaris targets, use config/mt-ppc to set C{,XX}FLAGS_FOR_TARGETS + so that -mrelocatable-lib and -mno-eabi are used. + + * Makefile.in (CONFIGURE_TARGET_MODULES): If target compiler does + not support --print-multi-lib, don't abort. + +Sun Aug 11 20:51:50 1996 Stu Grossman (grossman@critters.cygnus.com) + + * config/mh-cygwin32 (CFLAGS): Define _WIN32 to be compatible + with normal Windows compilation environment. + +Thu Aug 8 12:18:59 1996 Klaus Kaempf + + * make-all.com: Run config-a-gas. + * setup.com: Don't copy subdirectory files around. + +Tue Jul 30 17:49:31 1996 Brendan Kehoe + + * configure.in (*-*-ose): Remove exclusion of libgloss for this + target, it now compiles correctly. + +Sat Jul 27 15:10:43 1996 Stan Shebs + + * mpw-config.in: Generate Mac include for elf/dwarf2.h. + +Tue Jul 23 10:47:04 1996 Martin M. Hunt + + * configure.in (d10v-*-*): Remove ld from $noconfigdirs. + +Mon Jul 22 13:28:51 1996 Brendan Kehoe + + * configure.in (native_only): Add prms. + +Mon Jul 22 12:27:58 1996 Ian Lance Taylor + + * Makefile.in (GAS_SUPPORT_DIRS): Add make-all.com and setup.com. + (BINUTILS_SUPPORT_DIRS): Likewise. + +Thu Jul 18 12:55:40 1996 Michael Meissner + + * configure.in (d10v-*-*): Don't configure ld or gdb until the + d10v support is added. + +Wed Jul 17 14:33:09 1996 Martin M. Hunt + + * configure.in (d10v-*-*): New target. + +Mon Jul 15 11:53:00 1996 Jeffrey A Law (law@cygnus.com) + + * config.guess (HP 9000/811): Recognize this as a PA1.1 + machine. + +Fri Jul 12 23:21:17 1996 Ken Raeburn + + * Makefile.in (do-tar-gz): New target, split out from tail end of + taz target. Run each command separately, don't use pipes. + (taz): Use it. + +Fri Jul 12 12:08:04 1996 Stan Shebs + + * mpw-configure: Look for g-mpw-make.sed in config/mpw. + * mpw-build.in: No builds should depend on building byacc or flex, + they are assumed to be installed already. + +Fri Jul 12 09:52:52 1996 Michael Meissner + + * Makefile.in (CONFIGURE_TARGET_MODULES): Set r environment + variable that CC_FOR_TARGET needs. + +Thu Jul 11 10:09:45 1996 Michael Meissner + + * Makefile.in (CONFIGURE_TARGET_MODULES): Determine if the multlib + options have changed since the last time the subdirectory was + configured, and if it has, reconfigure. + (CLEAN_TARGET_MODULES): Delete multilib.out and tmpmulti.out, which + CONFIGURE_TARGET_MODULES uses to remember the old multilib options. + +Wed Jul 10 18:56:59 1996 Doug Evans + + * Makefile.in (ALL_MODULES,CROSS_CHECK_MODULES,INSTALL_MODULES, + CLEAN_MODULES): Add bash. + (all-bash): New target. + +Mon Jul 8 17:33:14 1996 Jim Wilson + + * configure.in (mips-sgi-irix6*): Use mh-irix6 instead of mh-irix5. + +Mon Jul 1 13:31:35 1996 Michael Meissner + + * config.sub (basic_machine): Recognize d10v as a valid processor. + +Fri Jun 28 12:14:35 1996 Stan Shebs + + * mpw-configure: Add support for --bindir. + * mpw-build.in: Use a GCC-specific build script for GCC actions. + +Wed Jun 26 17:20:12 1996 Geoffrey Noer + + * configure.in: add bash, time, gawk to list of hosttools and things + to only build for native toolchains + +Tue Jun 25 23:09:03 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (docdir): Remove. + +Tue Jun 25 19:00:08 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (datadir): Set to $(prefix)/share. + +Mon Jun 24 23:26:07 1996 Geoffrey Noer + + * configure.in: build diff and patch for cygwin32-hosted + toolchains. + +Mon Jun 24 15:01:12 1996 Joel Sherrill + + * config.sub: Accept -rtems*. + +Sun Jun 23 22:41:54 1996 Geoffrey Noer + + * configure.in: enable dosrel for cygwin32-hosted builds, + remove diff from the list of things not buildable + via Canadian Cross + +Sat Jun 22 11:39:01 1996 Jason Merrill + + * Makefile.in (TARGET_SUBDIR): Move comment to previous line so we + don't get ". ". + +Fri Jun 21 17:24:48 1996 Jim Wilson + + * configure.in (mips*-sgi-irix6*): Set noconfigdirs appropriately. + +Thu Jun 20 16:57:40 1996 Ken Raeburn + + * Makefile.in (taz): Handle case where tex3patch didn't even get + checked out. Also, if it was found, put the symlink in a new util + subdirectory. + +Thu Jun 20 12:20:33 1996 Michael Meissner + + * config.guess (*:Linux:*:*): Add support for PowerPC Linux. + +Tue Jun 18 14:24:12 1996 Klaus Kaempf (kkaempf@progis.de) + + * config.sub: Recognize -openvms. + * configure.in (alpha*-*-*vms*): Set noconfigdirs. + * make-all.com, setup.com: New files. + +Mon Jun 17 16:34:46 1996 Jason Merrill + + * Makefile.in (taz): tex3patch moved to texinfo/util. + +Sat Jun 15 17:13:25 1996 Geoffrey Noer + + * configure: enable_gdbtk=no for cygwin32-hosted toolchains + * configure.in: remove make from disable-if-Can-Cross list + enable gdb if ${host} and ${target} are cygwin32 + +Fri Jun 7 18:16:52 1996 Harlan Stenn + + * config.guess (i?86-ncr-sysv*): Emit minor release numbers. + Recognize the NCR 4850 machine and NCR Pentium-based platforms. + +Wed Jun 5 00:09:17 1996 Per Bothner + + * config.guess: Combine mips-mips-riscos cases, and use cpp to + distinguish sysv/svr4/bsd variants. + Based on a patch from Harlan Stenn . + +Fri Jun 7 14:24:49 1996 Tom Tromey + + * configure.in: Added copyright notice. + * move-if-change: Added copyright notice. + +Thu Jun 6 16:27:05 1996 Michael Meissner + + * configure.in (powerpcle-*-solaris*): Until we get shared + libraries working, don't build gdb, sim, make, tcl, tk, or + expect. + +Tue Jun 4 20:41:45 1996 Per Bothner + + * config.guess: Merge with FSF: + + Mon Jun 3 08:49:14 1996 Karl Heuer + * config.guess (*:Linux:*:*): Add guess for sparc-unknown-linux. + + Fri May 24 18:34:53 1996 Roland McGrath + * config.guess (AViiON:dgux:*:*): Fix typo in recognizing mc88110. + + Fri Apr 12 20:03:59 1996 Per Bothner + * config.guess: Combine two OSF1 rules. + Also recognize field test versions. From mjr@zk3.dec.com. + * config.guess (dgux): Use /usr/bin/uname rather than uname, + because GNU uname does not support -p. From pmr@pajato.com. + +Tue Jun 4 11:07:25 1996 Tom Tromey + + * Makefile.in (MAKEDIRS): Removed $(tooldir). + +Tue May 28 12:30:50 1996 Stan Shebs + + * mpw-README: Document GCCIncludes. + +Sun May 26 15:16:27 1996 Fred Fish + + * configure.in (alpha-*-linux*): Set enable_shared to yes. + +Tue May 21 15:41:39 1996 Stan Shebs + + * mpw-configure: Handle --enable-FOO and --disable-FOO. + +Mon May 20 10:12:29 1996 Geoffrey Noer + + * configure.in (*-*-cygwin32): Configure make. + +Tue May 7 14:19:42 1996 Tom Tromey + + * Makefile.in (inet-install): Quote value of INSTALL_MODULES. + +Fri May 3 08:57:17 1996 Tom Tromey + + * Makefile.in (all-inet): Depend on all-perl. + + * Makefile.in (inet-install): New target. + + * Makefile.in (all-inet): Depend on all-tcl. + (all-inet): Depend on all-send-pr. + +Tue Apr 30 13:55:51 1996 Michael Meissner + + * configure.in (powerpcle-*-solaris*): Turn off tk and tcl + temporarily. + +Thu Apr 25 11:48:20 1996 Ian Lance Taylor + + * configure.in: Don't configure --with-gnu-ld on AIX. + +Thu Apr 25 06:33:36 1996 Michael Meissner + + * configure.in (powerpcle-*-solaris*): Turn off gdb temporarily. + +Tue Apr 23 09:07:39 1996 Tom Tromey + + * Makefile.in (ALL_MODULES): Added all-inet. + (CROSS_CHECK_MODULES): Added check-inet. + (INSTALL_MODULES): Added install-inet. + (CLEAN_MODULES): Added clean-inet. + (all-indent): New target. + + * configure.in (host_tools): Added inet. + (native_only): Added inet. + (noconfigdirs): Added inet. + +Fri Apr 19 15:35:29 1996 Ian Lance Taylor + + * configure.in: Don't configure libgloss if we are not configuring + newlib. + +Wed Apr 17 19:30:01 1996 Rob Savoye + + * configure.in: Don't configure libgloss for unsupported + architectures. + +Tue Apr 16 11:17:05 1996 Michael Meissner + + * Makefile.in (CLEAN_MODULES): Add clean-apache. + +Mon Apr 15 15:09:05 1996 Tom Tromey + + * Makefile.in (ALL_MODULES): Include all-apache. + (CROSS_CHECK_MODULES): Include check-apache. + (INSTALL_MODULES): Include install-apache. + (all-apache): New target. + + * configure.in: Added apache everywhere perl is seen. + +Mon Apr 15 14:59:13 1996 Michael Meissner + + * Makefile.in: Add support for clean-{module} and + clean-target-{module} rules. + +Wed Apr 10 21:37:41 PDT 1996 Marilyn E. Sander + + * configure.in (*-*-ose) do not build libgloss. + +Mon Apr 8 16:16:20 1996 Michael Meissner + + * config.guess (prep*:SunOS:5.*:*): Turn into + powerpele-unknown-solaris2. + +Mon Apr 8 14:45:41 1996 Ian Lance Taylor + + * configure.in: Permit --enable-shared to specify a list of + directories. + +Fri Apr 5 08:17:57 1996 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (host==solaris): Pass only the first word of $CC + to /usr/bin/which when checking if we're using /usr/ccs/bin/cc. + +Fri Apr 5 03:16:13 1996 Jason Molenda (crash@phydeaux.cygnus.com) + + * Makefile.in (BASE_FLAGS_TO_PASS): pass down $(MAKE). + +Thu Mar 28 14:11:11 1996 Tom Tromey + + * Makefile.in (ALL_MODULES): Include all-perl. + (CROSS_CHECK_MODULES): Include check-perl. + (INSTALL_MODULES): Include install-perl. + (ALL_X11_MODULES): Include all-guile. + (CHECK_X11_MODULES): Include check-guile. + (INSTALL_X11_MODULES): Include install-guile. + (all-perl): New target. + (all-guile): New target. + + * configure.in (host_tools): Include perl and guile. + (native_only): Include perl and guile. + (noconfigdirs): Don't build guile and perl; no ports have been + done. + +Tue Mar 26 21:18:50 1996 Andrew Cagney + + * configure (--enable-*): Handle quoted option lists such as + --enable-sim-cflags='-g0 -O' better. + +Thu Mar 21 11:53:08 1996 Michael Meissner + + * Makefile.in ({,inst}all-target): New rule so we can make and + install all of the target directories easily. + +Wed Mar 20 18:10:57 1996 Andreas Schwab + + * configure.in: Add missing global flag in sed substitution when + deleting `target-' from ${configdirs}. + +Thu Mar 14 19:15:06 1996 Ian Lance Taylor + + * Makefile.in (DO_X): Don't get confused if CC contains `=' in an + option. + + * configure.in (mips*-nec-sysvr4*): Use a host_makefile_frag of + config/mh-necv4. + + * install.sh: Correct misspelling of transformbasename. + + * config.guess: Recognize mips-*-sysv*. + +Mon Mar 11 15:36:42 1996 Dawn Perchik + + * config.sub: Recognize mon960. + +Sun Mar 10 13:18:38 1996 Ian Lance Taylor + + * configure: Restore Canadian Cross handling of BISON and LEX, + removed in Feb 20 change. + +Fri Mar 8 20:07:09 1996 Per Bothner + + * README: Suggestions from Torbjorn Granlund : + Mention make install. Remove the old copyright date as well the + clumsy and rather pointless copyright on the README file. + +Fri Mar 8 17:51:35 1996 Ian Lance Taylor + + * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If there is a + Makefile after running symlink-tree, then run `make distclean' to + avoid clobbering any generated files in srcdir. + +Tue Mar 5 08:21:44 1996 J.T. Conklin + + * configure.in (m68k-*-netbsd*): Build everything now. + +Wed Feb 28 12:25:46 1996 Jason Merrill + + * Makefile.in (taz): Fix quoting. + +Tue Feb 27 11:33:57 1996 Doug Evans + + * configure.in (sparclet-*-*): Build everything now. + +Tue Feb 27 14:31:51 1996 Andreas Schwab + + * configure.in (m68k-*-linux*): New host. + +Mon Feb 26 14:32:44 1996 Ian Lance Taylor + + * configure: Check for bison before byacc. + +Tue Feb 20 23:12:35 1996 Stu Grossman (grossman@critters.cygnus.com) + + * Makefile.in configure: Change the way LEX and BISON/YACC are + set. configure now defines DEFAULT_LEX and DEFAULT_YACC by + searching PATH. These are used as fallbacks by Makefile.in if + flex/bison/byacc aren't in objdir. + +Mon Feb 19 11:45:30 1996 Ian Lance Taylor + + * Makefile.in: Make everything which depends upon all-bfd also + depend upon all-opcodes, in case --with-commonbfdlib is used. + +Thu Feb 15 19:50:50 1996 Michael Meissner + + * configure.in (host *-*-cygwin32): Don't build gdb if we are + building NT native compilers on Unix. + +Thu Feb 15 17:42:25 1996 Ian Lance Taylor + + * configure.in: Don't get CC from the host Makefile fragment if we + can find gcc in PATH, or if this is a Canadian Cross. Move the + Solaris test for /usr/ucb/cc to the post target script, just after + the compiler sanity test. + +Wed Feb 14 16:57:40 1996 Ian Lance Taylor + + * config.sub: Merge with FSF. + +Tue Feb 13 14:27:48 1996 Ian Lance Taylor + + * Makefile.in (RPATH_ENVVAR): New variable. + (REALLY_SET_LIB_PATH): Use it. + * configure.in: On HP/UX, set RPATH_ENVVAR to SHLIB_PATH. + +Mon Feb 12 15:28:49 1996 Doug Evans + + * config.sub, configure.in: Recognize sparclet cpu. + +Mon Feb 12 15:33:59 1996 Christian Bauernfeind + + * config.guess: Support m68k-cbm-sysv4. + +Sat Feb 10 12:06:42 1996 Andreas Schwab + + * config.guess (*:Linux:*:*): Guess m68k-unknown-linux and + m68k-unknown-linuxaout from linker help string. Put quotes around + $ld_help_string. + +Thu Dec 7 09:03:24 1995 Tom Horsley + + * config.guess (powerpc-harris-powerunix): Add guess for port + to new target. + +Thu Feb 8 15:37:52 1996 Brendan Kehoe + + * config.guess (UNAME_VERSION): Recognize X4.x as an OSF version. + +Mon Feb 5 16:36:51 1996 Ian Lance Taylor + + * configure.in: If --enable-shared was used, set SET_LIB_PATH to + $(REALLY_SET_LIB_PATH) in Makefile. + * Makefile.in (SET_LIB_PATH): New variable. + (REALLY_SET_LIB_PATH): New variable. + ($(DO_X)): Use $(SET_LIB_PATH). + (install.all, gcc-no-fixedincludes, $(ALL_MODULES)): Likewise. + ($(NATIVE_CHECK_MODULES), $(CROSS_CHECK_MODULES)): Likewise. + ($(INSTALL_MODULES), $(CONFIGURE_TARGET_MODULES)): Likewise. + ($(ALL_TARGET_MODULES), $(CHECK_TARGET_MODULES)): Likewise. + ($(INSTALL_TARGET_MODULES), $(ALL_X11_MODULES)): Likewise. + ($(CHECK_X11_MODULES), $(INSTALL_X11_MODULES)): Likewise. + (all-gcc, all-bootstrap, check-gcc, install-gcc): Likewise. + (install-dosrel): Likewise. + (all-opcodes): Depend upon all-libiberty. + +Sun Feb 4 16:51:11 1996 Steve Chamberlain + + * config.guess (*:CYGWIN*): New + +Sat Feb 3 10:42:35 1996 Michael Meissner + + * Makefile.in (all-target-winsup): All all-target-libiberty. + +Fri Feb 2 17:58:56 1996 Michael Meissner + + * configure.in (noconfigdirs): Add missing # in front of comment. + +Thu Feb 1 14:38:13 1996 Geoffrey Noer + + * configure.in: add second pass to things added to noconfigdirs + so *-gm-magic can exclude libgloss properly. + +Thu Feb 1 11:10:16 1996 Stan Shebs + + * mpw-configure (extralibs_name, rez_name): Set correctly + for MWC68K compiler. + + * mpw-README: Add more info on the necessary build tools. + +Thu Feb 1 10:22:38 1996 Steve Chamberlain + + * configure.in, config.sub: Recognize cygwin32. + +Wed Jan 31 14:17:10 1996 Richard Henderson + + * config.guess, config.sub: Recognize A/UX. + +Wed Jan 31 13:52:14 1996 Ian Lance Taylor + + * config.sub: Merge with gcc/config.sub. + +Thu Jan 25 11:01:10 1996 Raymond Jou + + * mpw-build.in (do-binutils): Add build of stamps. + +Thu Jan 25 17:05:26 1996 James G. Smith + + * config.sub: Add recognition for mips64vr4100*-* targets. + +Wed Jan 24 12:47:55 1996 Brendan Kehoe + + * test-build.mk: Add checking of `hpux9' rather than just `hpux'. + Add creation of gconfigargs with `--enable-shared' turned on. + ($(host)-stamp-stage2-configured): Pass $(gconfigargs). + ($(host)-stamp-stage3-configured): Likewise. + (HOLES): Add chatr and ldd. + (i386-ncr-sysv4.3*): Add use of /usr/ccs/bin in the PATH and HOLE_DIRS. + +Wed Jan 24 20:32:30 1996 Torbjorn Granlund + + * configure: Pass --nfp to recursive configures. + +Mon Jan 22 10:41:56 1996 Steve Chamberlain + + * Makefile.in (DLLTOOL): New. + (DLLTOOL_FOR_TARGET): New. + (EXTRA_HOST_FLAGS): Pass down DLLTOOL. + (EXTRA_TARGET_FLAGS): Ditto. + (EXTRA_GCC_FLAGS): Ditto. + (CONFIGURE_TARGET_MODULES): Ditto. + (DO_X): Ditto. + * configure: Add DLLTOOL. + +Fri Jan 19 13:30:15 1996 Stan Shebs + + SCO OpenServer 5 changes from Robert Lipe : + * configure.in (i[345]86-*-sco3.2v5*): Use mh-sysv instead of + mh-sco, since old workarounds no longer needed, and don't + build ld, since libraries have weak symbols in COFF. + +Sun Jan 14 23:01:31 1996 Fred Fish + + * Makefile.in (CONFIGURE_TARGET_MODULES): Add missing ';'. + +Fri Jan 12 15:25:35 1996 Ian Lance Taylor + + * configure.in: Make sure that ${CC} can be used to compile an + executable. + +Sat Jan 6 07:23:33 1996 Michael Meissner + + * Makefile.in (all-gdb): Depend on $(GDB_TK). + * configure (GDB_TK): Set GDB_TK to either "all-tcl all-tk" or + nothing depending on whether gdbtk is being built. + +Wed Jan 3 17:54:41 1996 Doug Evans + + * Makefile.in (newlib.tar.gz): Delete building of newlib's info files. + +Mon Jan 1 19:09:14 1996 Brendan Kehoe + + * configure.in (noconfigdirs): Put ld or gas in this early, if the + user specifically used --with-gnu-ld=no or --with-gnu-as=no. + +Sat Dec 30 16:08:57 1995 Doug Evans + + * config-ml.in: Add support for + --disable-{softfloat,m68881,m68000,m68020} on m68*-*-*. + Simplify setting of multidirs from --disable-foo. + +Fri Dec 29 07:56:11 1995 Michael Meissner + + * Makefile.in (EXTRA_GCC_FLAGS): If any of the make variables + LANGUAGES, BOOT_CFLAGS, STMP_FIXPROTO, LIMITS_H_TEST, + LIBGCC1_TEST, LIBGCC2_CFLAGS, LIBGCC2_INCLUDES, and ENQUIRE are + non-empty, pass them on to the GCC make. + (all-bootstrap): New rule that is like all-gcc, except it executes + the GCC bootstrap rule instead of the GCC all rule. + +Wed Dec 27 15:51:48 1995 Doug Evans + + * config-ml.in (ml_realsrcdir): New, to account for ${subdir}. + +Tue Dec 26 11:45:31 1995 Michael Meissner + + * config.guess (AViiON:dgux:*:*): Update from FSF to add pentium + DG/UX support. + +Fri Dec 15 10:01:27 1995 Stan Cox + + * config.sub (i*86*) Change [345] to [3456] + +Wed Dec 20 17:41:40 1995 Brendan Kehoe + + * configure.in (noconfigdirs): Add gas or ld if --with-gnu-as=no or + --with-gnu-ld=no. + +Wed Dec 20 15:15:35 1995 Michael Meissner + + * config-ml.in (rs6000*, powerpc*): Add switches to control which + AIX multilibs get built. + +Mon Dec 18 17:55:46 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (i386-win32): Don't build expect if we're not + building the tcl subdir. + +Mon Dec 18 11:47:19 1995 Stan Shebs + + * Makefile.in: (configure-target-examples, all-target-examples): + New targets, configure and build example programs. + +Fri Dec 15 16:13:03 1995 Stan Shebs + + * mpw-configure: If an mpw-config.in generated a file mk.sed, + use it as input to sedit the generated MPW makefile. + * mpw-README: Add a suggestion about Gestalt.h. + +Wed Dec 13 16:43:51 1995 Ian Lance Taylor + + * config.sub: Accept *-*-ieee*. + +Tue Dec 12 11:52:57 1995 Ian Lance Taylor + + * Makefile.in (local-distclean): Remove $(TARGET_SUBDIR). From + Ronald F. Guilmette . + +Mon Dec 11 15:31:58 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (host==powerpc-pe): Add many directories to noconfigdirs + for powerpc-pe native. + (target==i386-win32): add tcl, make to noconfigdirs if canadian cross. + (target==powerpc-pe): duplicate i386-win32 entry. + +Sat Dec 9 14:58:28 1995 Jim Wilson + + * configure.in (noconfigdirs): Exclude target-newlib for all versions + of vxworks, not just vxworks5.1. + +Mon Dec 4 12:05:40 1995 Stan Shebs + + * mpw-configure: Add support for exec-prefix. + +Mon Dec 4 10:22:50 1995 Jeffrey A. Law + + * config.guess: Recognize HP model 816 machines as having + a PA1.1 processor. + +Mon Dec 4 12:38:15 1995 Ian Lance Taylor + + * configure: Ignore new autoconf configure options. + +Thu Nov 30 14:45:25 1995 J.T. Conklin + + * config/mt-v810 (CC_FOR_TARGET): Add -ansi flag. NEC compiler + defaults to K&R mode, but doesn't have varargs.h, so we have to + compile in ANSI mode. + +Thu Nov 30 16:57:33 1995 Per Bothner + + * config.guess: Recognize Pentium under SCO. + From Robert Lipe . + +Wed Nov 29 13:49:08 1995 J.T. Conklin + + * configure.in (noconfigdirs): Disable target-libio on v810-*-*. + * config/mt-v810 (CC_FOR_TARGET, AS_FOR_TARGET, AR_FOR_TARGET, + RANLIB_FOR_TARGET): Set as appropriate for NEC v810 toolchain. + +Wed Nov 29 12:12:01 1995 Ian Lance Taylor + + * configure.in: Don't configure gas for alpha-dec-osf*. + +Tue Nov 28 17:16:48 1995 Ian Lance Taylor + + * configure.in: Default to --with-stabs for some targets for which + it makes sense: mips*-*-*, alpha*-*-osf*, i[345]86*-*-sysv4* and + i[345]86*-*-unixware*. + +Mon Nov 27 13:44:15 1995 Ian Lance Taylor + + * config-ml.in: Get list of multidirs using gcc --print-multi-lib + rather than basing it on the target. Simplify handling of options + controlling which directories to configure. Remove extraneous + slash in multi-clean target. + +Fri Nov 24 17:29:29 1995 Doug Evans + + * config-ml.in: Prefix more variables with ml_ so they don't collide + with configure's. + +Wed Nov 22 11:27:02 1995 Ian Lance Taylor + + * configure: Don't turn -v into --v. + +Tue Nov 21 16:48:02 1995 Doug Evans + + * configure.in (targargs): Fix typo. + + * Makefile.in (DEVO_SUPPORT): Add symlink-tree. + +Tue Nov 21 14:08:28 1995 Ian Lance Taylor + + * configure.in: Strip --host and --target options from + CONFIG_ARGUMENTS, and always configure for --host only. Add + --with-cross-host option when building with a cross-compiler. + * configure: Canonicalize the arguments put into config.status by + always using `=' for an option with an argument. Pass a presumed + --host or --target explicitly. + +Fri Nov 17 17:50:30 1995 Stan Shebs + + * config.sub: Merge -macos*, -magic*, -pe*, and -win32 cases + into general OS recognition case. + +Fri Nov 17 17:42:25 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (target_configdirs): add target-winsup only + for win32 target systems. + +Thu Nov 16 14:04:47 1995 Ian Lance Taylor + + * Makefile.in (all-target-libgloss): Depend upon + configure-target-newlib, since when libgloss is built it looks to + see if the newlib directory exists. + +Wed Nov 15 14:47:52 1995 Ken Raeburn + + * Makefile.in (DEVO_SUPPORT): Use config-ml.in instead of + cfg-ml-*.in. + +Wed Nov 15 11:45:23 1995 Ian Lance Taylor + + * configure: Handle LD and LD_FOR_TARGET when configuring a + Canadian Cross. + +Tue Nov 14 15:03:12 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * config/mh-i386win32: add LD_FOR_TARGET. + +Tue Nov 14 14:56:11 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (target_libs): add target-winsup. + (target==i386-win32): add patch diff flex make to $noconfigdirs. + (target==ppcle-pe): remove ld from $noconfigdirs. + +Tue Nov 14 01:25:50 1995 Doug Evans + + * Makefile.in (CONFIGURE_TARGET_MODULES): Pass --with-target-subdir. + Preserve relative path names in $srcdir. Build symlink tree if + configuring cross target dir and srcdir=. (= no VPATH support). + (configure-target-libg++): Depend on configure-target-librx. + * cfg-ml-com.in, cfg-ml-pos.in: Deleted. + * config-ml.in: New file. + * symlink-tree: New file. + * configure: Ensure srcdir="." if that's what it is. + +Mon Nov 13 12:34:20 1995 Stan Shebs + + * mpw-README: Clarify some phrasing, add notes about CodeWarrior + includes and FLEX_SKELETON setting. + * mpw-configure (--with-gnu-ld): New option, controls whether + to use PPCLink or ld with PowerMac GCC. + * mpw-build.in (all-grez, do-grez, install-grez): New targets. + * mpw-config.in: Configure grez if targeting Mac. + + * config.sub: Accept pmac and pmac-mpw as names for PowerMacs, + accept mpw and mac-mpw as names for m68k Macs, change macos7 to + just macos. + * configure.in: Configure grez resource compiler if targeting Mac. + * Makefile.in (all-grez, install-grez): New targets. + +Wed Nov 8 17:33:51 1995 Jason Merrill + + * configure: CXX defaults to gcc, not g++. If we find + gcc in the path, set CC to gcc -O2. + +Tue Nov 7 15:45:17 1995 Ian Lance Taylor + + * configure: Default ${build} correctly. Avoid picking up extra + spaces when reading CC and CXX from Makefile. When doing a + Canadian Cross, use plausible default values for numerous + variables. + * configure.in: When doing a Canadian Cross, don't try to + configure tools whose configure script can't handle it. + +Mon Nov 6 19:32:17 1995 Jim Wilson + + * cfg-ml-com.in (sh-*-*): Add m2 and ml/m2 to multidirs. + +Sun Nov 5 00:15:41 1995 Per Bothner + + * configure: Remove dubious bug reporting address. + +Fri Nov 3 08:17:54 1995 Per Bothner + + * Makefile.in ($(CONFIGURE_TARGET_MODULES)): If subdir has + configure script, run that instead of this directory's configure. + In either case, print a message that we're configuring the sub-dir. + +Thu Nov 2 23:23:36 1995 Per Bothner + + * configure.in: Before checking for the existence of various files, + use sed to filter out "target-". + +Thu Nov 2 13:24:56 1995 Ian Lance Taylor + + * Makefile.in (DO_X): Split rule to decrease command line length + for systems with small ARG_MAX values. From phdm@info.ucl.ac.be + (Philippe De Muyter). + +Wed Nov 1 15:18:35 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Makefile.in (all-patch): depend on all-libiberty. + +Wed Nov 1 12:23:20 1995 Ian Lance Taylor + + * configure.in: If the only directory in target_configdirs which + actually exists is libiberty, then set target_configdirs to empty, + to avoid trying to build a target libiberty in a gas or gdb + distribution. + +Tue Oct 31 17:52:39 1995 J.T. Conklin + + * configure.in (host_makefile_frag): Use m68k-sun-sunos* instead + of m68k-sun-* when selecting mh-sun3 to avoid matching NetBSD/sun3 + systems. + +Tue Oct 31 16:57:32 1995 Jim Wilson + + * configure.in (copy_dirs): Use sys-include instead of include + for --with-headers option. + +Tue Oct 31 10:29:36 1995 steve chamberlain + + * Makefile.in, configure.in: Make winsup builds work with + new scheme. + +Mon Oct 30 18:57:09 1995 Ian Lance Taylor + + * configure.in: Build the linker on AIX. + +Mon Oct 30 12:27:16 1995 Per Bothner + + * Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): Add $(TARGET_SUBDIR) + where needed. + +Mon Oct 30 12:45:25 1995 Doug Evans + + * Makefile.in (all-gcc): Fix typo. + +Sat Oct 28 10:27:59 1995 Per Bothner + + * Makefile.in ($(CHECK_TARGET_MODULES)): Fix typo. + +Fri Oct 27 23:14:12 1995 Per Bothner + + * configure.in: Rename libFOO to target-libFOO, and xiberty + to target-xiberty, to provide more flexibility. + (target_subdir): Define. Create if cross. + Set TARGET_SUBDIR in Makefile to ${target_subdir}. + * Makefile.in: Rename all-libFOO -> all-target-libFOO, all-xiberty + -> all-target-libiberty, configure-libFOO -> configure-target-libFOO, + check-libFOO -> check-target-libFOO, etc. + ($(DO_X)): Iterate over TARGET_CONFIGDIRS after SUBDIRS. + ($(CONFIGURE_TARGET_MODULES), $(CHECK_TARGET_MODULES), + $(ALL_TARGET_MODULES), $(INSTALL_TARGET_MODULES)): Update accordingly. + (configure-target-XXX): Depend on $(ALL_GCC), not all-gcc, to + allow ALL_GCC="" to only configure. + (DEVO_SUPPORT): Add cfg-ml-com.in and cfg-ml-pos.in. + (ETC_SUPPORT, ETC_SUPPORT_PFX): Merge; update 'taz' accordingly. + (LIBGXX_SUPPORT_DIRS): Remove xiberty. + +Sat Oct 28 01:53:49 1995 Ken Raeburn + + * Makefile.in (taz): Build "info" in etc explicitly. + +Fri Oct 27 09:32:30 1995 Stu Grossman (grossman@cygnus.com) + + * configure.in: Make sure that CC is undefined (as opposed to + null) if toplevel/config/mh-{host} doesn't define it. Fixes a + problem with autoconf trying to configure on a host without GCC. + +Thu Oct 26 22:35:01 1995 Stan Shebs + + * mpw-configure: Set host alias from choice of host compiler, + only use generic MPW Makefile sed if present, edit a file + named "hacked_Makefile.in" instead of "Makefile.in" if present. + * mpw-README: Add problem notes about CW6 and CW7. + +Thu Oct 26 05:45:10 1995 Ken Raeburn + + * Makefile.in (taz): Use ";" instead of ";;". + +Wed Oct 25 15:18:24 1995 Per Bothner + + * Makefile.in (taz): Grep for '^diststuff:' or '^info:' in + sub-directory Makefiles, instead of using DISTSTUFFDIRS and + DISTDOCDIRS. + (DISTSTUFFDIRS, DISTDOCDIRS): Removed - no longer used. + (newlib.tar.gz): Don't pass DISTDOCDIRS to recursive make. + +Wed Oct 25 14:43:55 1995 Per Bothner + + * Makefile.in (DISTDOCDIRS): Remove ld gprof bnutils gas libg++ gdb + and gnats, because they are now subsumed by DISTSTUFFDIRS. + Move bfd to DISTSTUFFDIRS. + +Tue Oct 24 18:19:09 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Makefile.in (X11_LIB): Removed. + (X11_FLAGS_TO_PASS): pass only X11_EXTRA_CFLAGS and X11_EXTRA_LIBS. + + * configure.in (host_makefile_frag): mh-aix & mh-sun removed. + +Sun Oct 22 13:04:42 1995 Michael Meissner + + * cfg-ml-com.in (powerpc*): Shorten some of the multilib directory + names. + +Fri Oct 20 18:02:10 1995 Michael Meissner + + * cfg-ml-com.in (powerpc*-eabi*): Add mcall-aixdesc varients. + +Thu Oct 19 10:40:57 1995 steve chamberlain + + * configure.in (i[345]86-*-win32): Always build newlib. + Don't configure cvs, autoconf or texinfo. + * Makefile.in (LD_FOR_TARGET): New. + (BASE_FLAGS_TO_PASS, EXTRA_TARGET_FLAGS, CONFIGURE_TARGET_MODULES): + Pass down LD_FOR_TARGET. + +Wed Oct 18 15:53:56 1995 steve chamberlain + + * winsup: New directory. + * Makefile.in: Build winsup. + * configure.in: Winsup is configured when target is win32. + Can only build win32 target GDB when native. + +Mon Oct 16 09:42:31 1995 Jeffrey A Law (law@cygnus.com) + + * config.guess: Recognize HP model 819 machines as having + a PA 1.1 processor. + +Mon Oct 16 10:49:43 1995 Ian Lance Taylor + + * configure: Fix sed loop which substitutes for CC and CXX to + avoid bug found in various sed implementations. + +Wed Oct 11 16:16:20 1995 Michael Meissner + + * cfg-ml-com.in (powerpc-*-eabisim): Delete separate rule for + simulator. Use standard powerpc-*-eabi*. + +Mon Oct 9 17:21:56 1995 Ian Lance Taylor + + * configure.in: Stop putting gas and binutils in noconfigdirs for + powerpc-*-aix* and rs6000-*-*. + +Mon Oct 9 12:38:40 1995 Michael Meissner + + * cfg-ml-com.in (powerpc*-*-eabisim*): Add support for building + -mcall-aixdesc libraries. + +Fri Oct 6 16:17:57 1995 Ken Raeburn + + Mon Sep 25 22:49:32 1995 Andreas Schwab + + * config.sub (arm | armel | armeb): Fix shell syntax. + +Fri Oct 6 14:40:28 1995 Michael Meissner + + * cfg-ml-com.in ({powerpc,rs6000}-ibm-aix*): Add multilibs for + -msoft-float and -mcpu=common support. + (powerpc*-*-eabisim*): Add support for building -mcall-aix + libraries. + +Thu Oct 5 13:26:37 1995 Brendan Kehoe + + * configure.in: Allow configuration and build of emacs19 for the alpha. + +Wed Oct 4 22:05:36 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (CC): Get ^CC, not just any old CC, from + ${host_makefile_frag}. + +Wed Oct 4 21:55:00 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (CC): Try to get CC from + ${srcdir}/${host_makefile_frag}, not ${host_makefile_frag}. + +Wed Oct 4 21:44:12 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Makefile.in (TARGET_CONFIGDIRS): configure targetdirs + only if it exists in $(srcdir). + +Wed Oct 4 11:52:31 1995 Ian Lance Taylor + + * configure: If CC and CXX are not set in the environment, set + them, based on either an existing Makefile or on searching for gcc + in PATH. Substitute for CC and CXX in Makefile. + * configure.in: Remove libm from target_libs. Separate + target_configdirs from configdirs. If CC is not set in + environment, try to get it from a host Makefile fragment. Rewrite + changes of configdirs to use skipdirs instead. A few minor + tweaks. Take directories out of target_configdirs as they are + taken out of configdirs. Remove existing Makefile files from + subdirectories. Substitute for TARGET_CONFIGDIRS and + CONFIG_ARGUMENTS in Makefile. + * Makefile.in (TARGET_CONFIGDIRS): New variable, automatically set + by configure.in. + (CONFIG_ARGUMENTS): Likewise. + (CONFIGURE_TARGET_MODULES): New variable. + ($(DO_X)): Loop over TARGET_CONFIGDIRS as well as SUBDIRS. + ($(CONFIGURE_TARGET_MODULES)): New target. + (configure-libg++, configure-libio): New targets. + (all-libg++): Depend upon configure-libg++. + (all-libio): Depend upon configure-libio. + (configure-libgloss, all-libgloss): New targets. + (configure-libstdc++): New target. + (all-libstdc++): Depend upon configure-libstdc++. + (configure-librx, all-librx): New targets. + (configure-newlib): New target. + (all-newlib): Depend upon configure-newlib + (configure-xiberty): New target. + (all-xiberty): Depend upon configure-xiberty. + +Sat Sep 30 04:32:59 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in (host i[345]86-*-win32): Expand the + noconfigdirs again. + +Thu Sep 28 21:18:49 1995 Stan Shebs + + * mpw-configure: Fix sed command file name. + +Thu Sep 28 17:39:56 1995 steve chamberlain + + * configure.in (host i[345]86-*-win32): Reduce the + noconfigdirs again. + +Wed Sep 27 12:24:00 1995 Ian Lance Taylor + + * configure.in: Don't configure ld and gdb for powerpc*-*-winnt* + or powerpc*-*-pe*, since they are not yet supported. + +Tue Sep 26 14:30:01 1995 Stan Shebs + + Add PowerMac support and many other enhancements. + * mpw-configure: New option --cc to select compiler to use, + paste options set according to --cc into the generated + Makefile, generate the Makefile by sed'ing the Unix Makefile.in + if mpw-make.sed is present. + * mpw-config.in: Don't test for gC1, test for mpw-touch, + add forward includes for PowerPC include files. + * mpw-build.in: Build using Makefile.PPC if present. + (do-byacc, etc): Remove separate version resource builds. + (do-gas): Build "stamps" before "all". + (do-gcc): Build "stamps-h" and "stamps-c" before "all". + * mpw-README: Update to reflect --cc option, PowerMac support, + and recently-reported compatibility problems. + +Fri Sep 22 12:15:42 1995 Doug Evans + + * cfg-ml-com.in (m68*-*-*): Only build multilibs for + embedded m68k systems (-aout, -coff, -elf, -vxworks). + (--with-multilib-top): Pass to recursive invocations. + +Tue Sep 19 13:51:05 1995 J.T. Conklin + + * configure.in (noconfigdirs): Disable libg++ and libstdc++ on + v810-*-*. + +Mon Sep 18 23:08:26 1995 J.T. Conklin + + * configure.in (noconfigdirs): Disable bfd, binutils, gas, gcc, + gdb, ld and opcodes on v810-*-*. + +Sat Sep 16 18:31:08 PDT 1995 Angela Marie Thomas + + * config/mh-ncrsvr43: Removed AR_FLAGS + +Tue Sep 12 18:03:31 1995 Ian Lance Taylor + + * Makefile.in (DO_X): Change do-realclean to do-maintainer-clean. + (local-maintainer-clean): New target. + (maintainer-clean): New target. + (realclean): Just depend upon maintainer-clean. + +Fri Sep 8 17:11:14 1995 J.T. Conklin + + * configure.in (noconfigdirs): Disable gdb on m68k-*-netbsd*. + +Fri Sep 8 16:46:29 1995 Ian Lance Taylor + + * configure.in: Build ld in mips*-*-bsd* case. + +Thu Sep 7 20:03:41 1995 Ken Raeburn + + * config.sub: Accept -lites* OS. From Ian Dall. + +Fri Sep 1 08:06:58 1995 James G. Smith + + * config.sub: recognise mips64vr4300 and mips64vr4300el as valid + targets. + +Wed Aug 30 21:06:50 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in: treat i386-win32 canadian cross the same as + i386-go32 canadian cross. + +Thu Aug 24 14:53:20 1995 Michael Meissner + + * cfg-ml-com.in (powerpc*-*-eabisim): Add support for PowerPC + running under the simulator to build a reduced set of libraries. + (powerpc-*-eabiaix): Add fine grained multilib support added to + other powerpc targets yesterday. + +Wed Aug 23 09:41:56 1995 Michael Meissner + + * cfg-ml-com.in (powerpc*): Add support for -disable-biendian, + -disable-softfloat, -disable-relocatable, -disable-aix, and + -disable-sysv to control which multilib libraries get built. + +Thu Aug 17 16:03:41 1995 Ken Raeburn + + * configure: Add Makefile.tem to list of files to remove in trap + handler. + +Mon Aug 14 19:27:56 1995 Per Bothner + + * config.guess (*Linux*): Add missing "exit"s. + Also, need specific check for alpha-unknown-linux (uses COFF). + +Fri Aug 11 15:38:20 1995 Per Bothner + + * config.guess: Merge with FSF: + + Wed Jun 28 17:57:27 1995 David Edelsohn + * config.guess (AIX4): More robust release numbering discovery. + + Thu Jun 22 19:01:24 1995 Kenneth Stailey (kstailey@eagle.dol-esa.gov) + * config.guess (i386-sequent-ptx): Properly get version number. + + Thu Jun 22 18:36:42 1995 Uwe Seimet (seimet@iris1.chemie.uni-kl.de) + * config.guess (mips:*:4*:UMIPS): New case. + +Mon Aug 7 09:21:35 1995 Doug Evans + + * configure.in (i386-go32 host): Fix typo (deja-gnu -> dejagnu). + (i386-win32 host): Likewise. Don't build readline. + +Sat Aug 5 09:51:49 1995 Fred Fish + + * Makefile.in (GDBTK_SUPPORT_DIRS): Define and pass as part of + SUPPORT_FILES to submakes. + +Fri Aug 4 13:04:36 1995 Fred Fish + + * Makefile.in (GDB_SUPPORT_DIRS): Add utils. + (DEVO_SUPPORT): Add mpw-README, mpw-build.in, mpw-config.h and + mpw-configure. + +Wed Aug 2 16:32:40 1995 Ken Raeburn + + * configure.in (appdirs): Use =, not ==, in test expression when + trying to build the text to print in the warning message for + Solaris users. + +Mon Jul 31 09:56:18 1995 steve chamberlain + + * cfg-ml-com.in (z8k-*-coff): Add 'std' multilib build. + +Fri Jul 28 00:16:31 1995 Jeffrey A. Law + + * config.guess: Recognize lynx-2.3. + +Thu Jul 27 15:47:59 1995 steve chamberlain + + * config.sub (z8ksim): Deleted + (z8k-*-coff): New, this is the one true name of the target. + +Thu Jul 27 14:33:33 1995 Doug Evans + + * cfg-ml-pos.in (dotdot): Work around SunOS sed bug. + +Thu Jul 27 13:31:05 1995 Fred Fish (fnf@cygnus.com) + + * config.guess (*:Linux:*:*): First try asking the linker what the + default object file format is (elf, aout, or coff). Then if this + fails, try previous methods. + +Thu Jul 27 11:28:17 1995 J.T. Conklin + + * configure.in: Don't build newlib for *-*-vxworks5.1. + +Thu Jul 27 11:18:47 1995 Brendan Kehoe + + * configure.in: Don't build newlib for a29k-*-vxworks5.1. + * test-build.mk: Add setting of --with-headers for a29k-vxworks5.1. + +Tue Jul 25 21:25:39 1995 Doug Evans + + * cfg-ml-pos.in (MULTITOP): Trim excess trailing "/.". + +Fri Jul 21 10:41:12 1995 Doug Evans + + * cfg-ml-com.in: New file. + * cfg-ml-pos.in: New file. + +Wed Jul 19 00:37:27 1995 Jeffrey A. Law + + * COPYING.NEWLIB: Add HP free copyright to list. + +Tue Jul 18 10:58:51 1995 Michael Meissner + + * config.sub: Recognize -eabi* for the system, not just -eabi. + +Mon Jul 3 13:44:51 1995 Steve Chamberlain + + * Makfile.in (DLLTOOL_FOR_TARGET): New name, pass it down. + * config.sub, configure.in (win32): New target and host. + +Wed Jun 28 23:57:08 1995 Steve Chamberlain + + * configure.in: Add i386-pe configuration. + +Fri Jun 23 14:28:44 1995 Stan Shebs + + * mpw-build.in (install): Install GDB after LD. + +Thu Jun 22 17:10:53 1995 Stan Shebs + + * mpw-config.in (elf/mips.h): Always forward-include, needed + for GDB to build. + +Wed Jun 21 15:17:30 1995 Rob Savoye + + * testsuite: New directory for customer acceptance and whole tool + chain tests. + +Wed Jun 21 16:50:29 1995 Ken Raeburn + + * configure: If per-host line isn't found, but AC_OUTPUT is found + and a configure script exists, run it instead. + +Thu Jun 15 21:09:24 1995 Per Bothner + + * config.guess: Update from FSF, for alpha-dec-winnt3.5 and Crays. + +Tue Jun 13 21:43:27 1995 Rob Savoye + + * configure: Set build_{cpu,vendor,os,alias} to host values when + --build isn't specified. + +Mon Jun 5 18:26:36 1995 Jason Merrill + + * Makefile.in (PICFLAG, PICFLAG_FOR_TARGET): New macros. + (FLAGS_TO_PASS): Pass them. + (EXTRA_TARGET_FLAGS): Ditto. + + * config/m?-*pic: Define PICFLAG* instead of LIB*FLAGS*. + +Wed May 31 22:27:42 1995 Jim Wilson + + * Makefile.in (all-libg++): Depend on all-libstdc++. + +Thu May 25 22:40:59 1995 J.T. Conklin + + * configure.in (noconfigdirs): Enable all packages for + i386-unknown-netbsd. + +Sat May 20 13:22:31 1995 Angela Marie Thomas + + * configure.in (noconfigdirs): Don't configure tk for i386-go32 + hosted builds (DOS builds) + +Thu May 18 18:08:49 1995 Ken Raeburn + + Changes for ARM based on patches from Richard Earnshaw: + * config.sub: Handle armeb and armel. + * configure.in: Omit arm linker only for riscix. + +Thu May 11 17:23:26 1995 Per Bothner + + * config.guess: Update from FSF. + +Tue May 9 15:52:05 1995 Michael Meissner + + * config.sub: Recognize powerpcle as the little endian varient of + the PowerPC. Recgonize ppc as a PowerPC variant, and ppcle as a + powerpcle variant. Convert pentium into i586, not i486. Add p5 + alias for i586. Map new x86 variants p6, k5, nexgen into i586 + temporarily. + +Tue May 2 16:29:41 1995 Jeff Law (law@snake.cs.utah.edu) + + * configure.in (hppa*-*-lites*): Treat like hppa*-*-*elf*. + +Sun Apr 30 21:38:09 1995 Jeff Law (law@snake.cs.utah.edu) + + * config.sub: Accept -lites* as a basic system type. + +Thu Apr 27 11:33:29 1995 Michael Meissner (meissner@cygnus.com) + + * config.guess (*:Linux:*:*): Check for whether the pre-BFD linker is + installed, and if so return linuxoldld as the system name. + +Wed Apr 26 10:59:02 1995 Jeff Law (law@snake.cs.utah.edu) + + * config.guess: Add hppa1.1-hp-lites support. + +Tue Apr 25 11:08:11 1995 Rob Savoye + + * configure.in: Don't build newlib for m68k-vxworks5.1. + +Wed Apr 19 17:02:43 1995 Jim Wilson + + * configure.in (mips-sgi-irix6): Use mh-irix5. + +Fri Apr 14 15:21:17 1995 Doug Evans + + * Makefile.in (all-gcc): Depend on all-ld (for libgcc1-test). + +Wed Apr 12 16:06:01 1995 Jason Merrill + + * test-build.mk: Enable building of shared libraries on IRIX 5 and + OSF/1. Fix compiler flags. + * build-all.mk: Support Linux and OSF/1 3.0. Fix compiler flags. + +Tue Apr 11 18:55:40 1995 Doug Evans + + * configure.in: Recognize --with-newlib. + (sparc-*-sunos4*): Build sim, dejagnu, expect, tcl if cross target. + +Mon Apr 10 14:38:20 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Makefile.in: move {all,check,install}-gdb from *_MODULES + to *_X11_MODULES due to gdbtk needing X include files et al. + +Mon Apr 10 11:42:22 1995 Stan Shebs + + Merge in support for Mac MPW as a host. + (Old change descriptions retained for informational value.) + + * mpw-config.in: Add generic include forwards for cpu-specific + include files in aout and elf directories. + + * mpw-configure: Added copyright. + * mpw-config.in: Check for presence of required build tools. + (target_libs): Add newlib. + (target_tools): Add examples. + (Read Me): Generate as "Read Me for MPW" instead. + * mpw-build.in: Base sub-builds on all-foo instead of do-foo. + (all-byacc, do-byacc, all-flex, do-flex, do-newlib): New actions. + (do-gas, do-gcc, do-gdb, do-ld): Build Version.r first. + + * mpw-configure: Remove subdir-specific makefile hackery, + delete mk.tmp after using it. + + * mpw-build.in (all): Display start and end times. + + * mpw-configure (host_canonical): Set. + (target_cpu): Always add to makefiles. + (ARCHDEFS, EMUL): Add to makefile only if nonempty. + (TM_FILE, XM_FILE, NM_FILE): No longer add to makefile. + (mpw-mh-mpw): Look for in srcdir and srcroot. + Use sed instead of mpw-edit-prefix to edit prefix definitions. + + * mpw-build.in: (install-only): New target. + + * mpw-configure (host_alias, target_alias): Rename from hostalias + and targetalias, add into generated Makefile. + (mk.tmp): If present, add into generated Makefile. + * mpw-build.in (all-gas): Build config.h first before gas proper. + + * mpw-configure (config.status): Write only if changed. + * mpw-config.in (readline): Configure it (not built, just used for + definitions). + + * mpw-config.in (elf/mips.h): Add a forward include. + + * mpw-config.in: Forward-include most .h files in include into + extra-include. + (readline): Don't build. + mpw-build.in (install): Install GDB. + + * mpw-configure (prefix, mpw_prefix): Handle it. + * mpw-config.in (mmalloc, readline): Don't configure. + * mpw-build.in (thisscript): Rename to ThisScript. + Use mpw-build instead of BuildProgram everywhere. + (mmalloc, readline): Don't build. + * mpw-README: New file, basic documentation about the MPW port. + + * mpw-config.in: Use forward-include to create include files. + + * mpw-configure: Add more things to the top of each configured + Makefile, including contents of config/mpw-mh-mpw. + * mpw-config.in (extra-include): Create this directory and fill it + with Posix-like include files when configuring. + + * config.sub (apple, mac, mpw): Add various aliases. + + * mpw-build.in: New file, top-level build script fragment for MPW. + * mpw-configure: New file, configure script for MPW. + * mpw-config.in: New file, config fragment for MPW. + +Fri Apr 7 19:33:16 1995 Jim Kingdon (kingdon@lioth.cygnus.com) + + * configure.in (host_libs): Remove glob, since it is gone from the + sources. + +Fri Mar 31 11:36:17 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Makefile.in: define empty GDB_NLM_DEPS var. + + * configure.in(target_makefile_frag): use config/mt-netware + for netware targets. + +Thu Mar 30 13:51:43 1995 Ian Lance Taylor + + * config.sub: Merge in recent FSF changes. Remove linux special + cases. + +Tue Mar 28 14:47:34 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + build-all.mk,config/mh-solaris: revert these two changes: + + Tue Mar 30 10:03:09 1993 Ian Lance Taylor (ian@cygnus.com) + + * build-all.mk: Use CC=cc -Xs on Solaris. + + Mon Mar 29 19:59:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config/mh-solaris: SunPRO C needs -Xs to be able to get a + working xmakefile for Emacs. + +Tue Mar 21 10:43:32 1995 Jim Kingdon (kingdon@lioth.cygnus.com) + + * glob/*: Removed. Schauer's 24 Feb 1994 readline change made us + stop using it. + * Makefile.in: Nuke all references to glob subdirectory. + +Thu Mar 16 13:35:30 1995 Jason Merrill + + * configure.in: Fix --enable-shared logic in per-host. + +Mon Mar 13 12:33:15 1995 Ian Lance Taylor + + * configure.in (*-hp-hpux[78]*): Use mh-hpux8. + +Mon Mar 6 10:21:58 1995 Jim Kingdon (kingdon@lioth.cygnus.com) + + * configure.in (noconfigdirs): Don't build gas on AIX, for + powerpc*-*-aix* as well as for rs6000*-*-aix*. + +Wed Mar 1 12:51:53 1995 Ian Lance Taylor + + * configure: Fix --cache-file to work if the file argument is a + relative path. + +Tue Feb 28 17:36:07 1995 Ian Lance Taylor + + * configure: If the --cache-file is used, pass it down to + configure in subdirectories. + +Mon Feb 27 12:52:46 1995 Kung Hsu + + * config.sub: add vxworks29k configuration. + +Fri Feb 10 16:12:26 1995 Ken Raeburn + + * Makefile.in (taz): Do "diststuff" part quietly. + +Sun Feb 5 14:16:35 1995 Doug Evans + + * config.sub: Mini-merge with gcc/config.sub. + +Sat Feb 4 12:11:35 1995 Jim Wilson + + * config.guess (IRIX): Sed - to _. + +Fri Feb 3 11:54:42 1995 J.T. Conklin + + * Makefile.in (source-vault, binary-vault): New targets. + +Thu Jan 26 13:00:11 1995 Michael Meissner + + * config.sub: Recognize -eabi as a basic system type. + +Thu Jan 12 13:13:23 1995 Jason Merrill + + * configure.in (enable_shared stuff): Fix typo. + +Thu Jan 12 01:36:51 1995 deanm@medulla.LABS.TEK.COM (Dean Messing) + + * Makefile.in (BASE_FLAGS_TO_PASS): Fix typo in passing LIBCXXFLAGS*. + +Wed Jan 11 16:29:53 1995 Jason Merrill + + * Makefile.in (LIBCXXFLAGS_FOR_TARGET): Add -fno-implicit-templates. + +Mon Jan 9 12:48:01 1995 Jim Kingdon + + * configure.in (rs6000-*-*): Don't build gas. + +Wed Jan 4 23:53:49 1995 Ian Lance Taylor + + * Makefile.in: Use /x/x/ instead of /brokensed/brokensed/, to + reduce command line length. + (AS_FOR_TARGET): Check for as.new, not Makefile. + (NM_FOR_TARGET): Check for nm.new, not Makefile. + +Wed Jan 4 13:02:39 1995 Per Bothner + + * config.guess: Merge from FSF. + +Thu Dec 15 17:11:37 1994 Ian Lance Taylor + + * configure: Don't use $ when handling program_suffix. + +Mon Dec 12 12:09:37 1994 Stu Grossman (grossman@cygnus.com) + + * configure.in: Configure tk for hppa/hpux. + +Fri Dec 2 15:55:38 1994 Per Bothner + + * Makefile.in (LIBGXX_SUPPORT_DIRS): Add libstdc++. + +Tue Nov 29 19:37:56 1994 Per Bothner + + * Makefile.in: Move -fno-implicit-template from CXXFLAGS + to LIBCXXFLAGS. Tests are better run without it. + +Wed Nov 23 10:29:25 1994 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Makefile.in (all-ispell): Depend on all-emacs19 instead of all-emacs. + +Mon Nov 21 11:14:01 1994 J.T. Conklin + + * configure.in (*-*-netware*): Don't configure xiberty. + +Mon Nov 14 08:49:15 1994 Stu Grossman (grossman@cygnus.com) + + * configure.in: Remove tk from native_only list. + +Fri Nov 11 15:31:26 1994 Bill Cox (bill@rtl.cygnus.com) + + * build-all.mk: Add mips-ncd-elf target to sun4 targets + for special NCD build. + +Mon Nov 7 20:58:17 1994 Ken Raeburn + + * Makefile.in (DEVO_SUPPORT): Remove configure.bat and + makeall.bat, they're only useful for binutils snapshots. + (binutils.tar.gz, gas+binutils.tar.gz): Add configure.bat and + makeall.bat to specified SUPPORT_FILES. + +Mon Nov 7 17:25:18 1994 Bill Cox (bill@cirdan.cygnus.com) + + * build-all.mk: Add Ericsson targets to sun4 and solaris + hosts. Add BNR's sun4 target to solaris host, so their + build-from-source will be tested in-house first. + +Sat Nov 5 18:43:30 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (LIBCFLAGS): New variable. + (CFLAGS_FOR_TARGET): Ditto. + (LIBCFLAGS_FOR_TARGET): Ditto. + (LIBCXXFLAGS): Ditto. + (CXXFLAGS_FOR_TARGET): Ditto. + (LIBCXXFLAGS_FOR_TARGET): Ditto. + (BASE_FLAGS_TO_PASS): Pass them. + (EXTRA_TARGET_FLAGS): Ditto. + + * configure.in, config/m[th]-*pic: Support --enable-shared. + +Sat Nov 5 15:44:00 1994 Per Bothner + + * configure.in (target_libs): Include libstdc++ again. + * config.guess: Update from FSF (for FreeBSD). + +Thu Nov 3 16:32:30 1994 Ken Raeburn + + * Makefile.in (DEVO_SUPPORT): Include configure.bat and + makeall.bat. + (DISTDOCDIRS): Add `etc'. + (ETC_SUPPORT_PFX): New variable. + (taz): Include anything from etc starting with a word in + ETC_SUPPORT_PFX. + +Wed Oct 26 16:19:35 1994 Ian Lance Taylor + + * config.sub: Update for recent FSF changes. Remove obsolete + h8300hds entry. Add -windows* and -osx as basic os. Minor + spacing changes. + +Thu Oct 20 18:41:56 1994 Per Bothner + + * configure.in (target_libs): Remove libstdc++ for libg++-2.6.1. + + * config.guess: Merge with FSF. + * configure.in: Match on i?86-ncr-sysv4.3, not i?86-ncr-sysv43. + +Thu Oct 20 19:26:56 1994 Ken Raeburn + + * configure: Since the "trap 0" handler will override the exit + status on many systems, only use it for "exit 1", and make it set + a non-zero exit status; reset it before "exit 0". Also, check + exit status of config.sub, and error out if it failed. + +Wed Oct 19 18:49:55 1994 Rob Savoye (rob@cygnus.com) + + * Makefile.in: (ALL_TARGET_MODULES,INSTALL_TARGET_MODULES) Build + and install libgloss. + +Tue Oct 18 15:25:24 1994 Ian Lance Taylor + + * Makefile.in (all-binutils): Depend upon all-byacc. + + * configure.in: Don't build emacs on Irix 5. + +Mon Oct 17 16:22:12 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * configure.in (*-*-netware*): Add libio. + +Thu Oct 13 15:51:20 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (ALL_TARGET_MODULES): Add libstdc++. + (CHECK_TARGET_MODULES): Ditto. + (INSTALL_TARGET_MODULES): Ditto. + (TARGET_LIBS): Ditto. + (all-libstdc++): Note dependencies. + +Thu Oct 13 01:43:08 1994 Ken Raeburn + + * Makefile.in (BINUTILS_SUPPORT_DIRS): Add gas. + +Tue Oct 11 12:12:29 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (CXXFLAGS): Use -fno-implicit-templates instead of + -fexternal-templates. + + * configure.in (target_libs): Add libstdc++. + (noconfigdirs): Add libstdc++ as appropriate. + +Thu Oct 6 18:00:54 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Update from FSF. + +Tue Oct 4 12:05:42 1994 Ian Lance Taylor + + * configure: Use ${config_shell} when running ${configsub}. + +Mon Oct 3 14:28:34 1994 Doug Evans + + * config.sub: No longer recognize h8300h. + +Mon Oct 3 12:40:54 1994 Ian Lance Taylor + + * config.sub: Remove extraneous differences between config.sub and + gcc/config.sub. + +Sat Oct 1 00:23:12 1994 Ken Raeburn + + * Makefile.in (DISTSTUFFDIRS): Add gas. + +Thu Sep 22 19:04:55 1994 Doug Evans (dje@canuck.cygnus.com) + + * COPYING.NEWLIB: New file. + +Mon Sep 19 18:25:40 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess (HP-UX): Patch from Harlan Stenn + to also emit release level. + +Wed Sep 7 13:15:25 1994 Jim Wilson (wilson@sphagnum.cygnus.com) + + * config.guess (sun4*:SunOS:*:*): Change '-JL' to '_JL'. + +Tue Sep 6 23:23:18 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.sub: Merge nextstep cleanup from FSF. + +Mon Sep 5 05:01:30 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * configure.in (arm-*-*): Don't configure ld for this target. + +Thu Sep 1 09:35:00 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * configure.in (*-*-netware): don't configure libg++, libio, + librx, or newlib. + +Wed Aug 31 13:52:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure.in (alpha-dec-osf*): Use osf*, not osf1*. Don't + configure ld--it works, but it doesn't support shared libraries. + +Sun Aug 28 18:13:45 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess (*-unknown-freebsd*): Get rid of possible + trailing "(Release)" in version string. + Patch from Paul Richards . + +Sat Aug 27 15:00:49 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Fix i486-ncr-sysv43 -> i486-ncr-sysv4.3. + Fix type: *-next-neststep -> *-next-nextstep. + + * config.guess: Merge from FSF: + + Fri Aug 26 18:45:25 1994 Philippe De Muyter (phdm@info.ucl.ac.be) + + * config.guess: Recognize powerpc-ibm-aix3.2.5. + + Wed Apr 20 06:36:32 1994 Philippe De Muyter (phdm@info.ucl.ac.be) + + * config.guess: Recognize UnixWare 1.1 (UNAME_SYSTEM is SYSTEM_V + instead of UNIX_SV for UnixWare 1.0). + +Sat Aug 27 01:56:30 1994 Stu Grossman (grossman@cygnus.com) + + * Makefile.in (all-gdb): Add dependencies on all-gcc and all-ld + to make gdb/nlm/* build after the compiler and linker. + +Fri Aug 26 14:30:05 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess (netbsd, freebsd, linux): Accept any machine, + not just i[34]86. + (m68k-atari-sysv4): Relocate to match FSF version. + + * config.guess: More merges from the FSF: + + Add a space before function call or macro invocation. + + Tue May 10 16:53:55 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * config.guess: Add trap cmd to remove dummy.c and dummy when + interrupted. + + Wed Apr 20 18:07:13 1994 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * config.guess (dummy.c): Redirect stderr for `hostinfo' command. + (dummy): Redirect stderr from compilation of dummy.c. + + Sat Apr 9 14:59:28 1994 Christian Kranz (kranz@sent5.uni-duisburg.de) + + * config.guess: Distinguish between NeXTStep 2.1 and 3.x. + +Fri Aug 26 13:42:20 1994 Ken Raeburn (raeburn@kr-laptop.cygnus.com) + + * configure: Accept and ignore --cache*, for compatibility with + new autoconf. + +Fri Aug 26 13:05:27 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Merge from FSF: + + Thu Aug 25 20:28:51 1994 Richard Stallman + + * config.guess (Pyramid*:OSx*:*:*): New case. + (PATH): Add /.attbin at end for finding uname. + (dummy.c): Handle i860-alliant-bsd. Follow whitespace conventions. + + Wed Aug 17 18:21:02 1994 Tor Egge (tegge@pvv.unit.no) + + * config.guess (M88*:DolphinOS:*:*): New case. + + Thu Aug 11 17:00:13 1994 Stan Cox (coxs@dg-rtp.dg.com) + + * config.guess (AViiON:dgux:*:*): Use TARGET_BINARY_INTERFACE + to select whether to use ELF or COFF. + + Sun Jul 24 16:20:53 1994 Richard Stallman + + * config.guess: Recognize i860-stardent-sysv and i860-unknown-sysv. + + Sun May 1 10:23:10 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu) + + * config.guess: Guess the OS version for HPUX. + + Tue Mar 1 21:53:03 1994 Karl Heuer (kwzh@hal.gnu.ai.mit.edu) + + * config.guess (UNAME_VERSION): Recognize aix3.2.4 and aix3.2.5. + +Fri Aug 26 11:19:08 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure.in: Recognize --with-headers, --with-libs, and + --without-newlib. + * Makefile.in (all-xiberty): Depend upon all-ld. + +Wed Aug 24 12:36:50 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure.in: Change i[34]86 to i[345]86. + +Mon Aug 22 10:58:33 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure (version): A few more tweaks to help message. + +Fri Aug 19 12:40:25 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Remove (for now) librx as a host library, + now that we're building it for target. + +Fri Aug 19 10:49:17 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure: Fix up help message; from karl@owl.hq.ileaf.com + (Karl Berry). + +Tue Aug 16 16:11:08 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * configure.in: Also configure librx. + +Mon Aug 15 16:51:45 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Update various rules to reflect that librx + is now needed for libg++. + +Fri Aug 12 18:07:21 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * config.sub: Accept mips64orion and mips64orionel as a CPU name. + +Mon Aug 8 11:36:17 1994 Stan Shebs (shebs@andros.cygnus.com) + + * configure.in: Configure the examples directory. + +Thu Aug 4 16:12:36 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure: Simplify Jun 2 1994 change. + +Wed Aug 3 04:58:16 1994 D. V. Henkel-Wallace (gumby@cygnus.com) + + * change CC to /usr/latest/bin/gcc for lynx host builds, since + /bin/gcc isn't good enough to build gcc. + +Wed Jul 27 09:07:14 1994 Fred Fish (fnf@cygnus.com) + + * Makefile.in (GDB_SUPPORT_FILES): Remove + (setup-dirs-gdb, gdb.tar.gz, make-gdb.tar.gz): Remove old rules. + (gdb.tar.gz): Add new rule to use standard distribution building + mechanism. + +Mon Jul 25 11:10:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Warn about use of /usr/ucb/cc on Solaris. From + Bill Cox . + +Sat Jul 23 12:19:46 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Recognize ISC. Patch from kwzh@gnu.ai.mit.edu. + +Fri Jul 22 17:53:59 1994 Stu Grossman (grossman@cygnus.com) + + * configure: Search current dir first in .gdbinit. + +Fri Jul 22 11:28:30 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.sub: Recognize freebsd (merged from gcc config.sub). + +Thu Jul 21 14:10:52 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.sub: Refer to NeXT's operating system as nextstep. + + * config.sub (case $basic_machine): Re-order the cases, to match + the order in the FSF version (which is mostly alphabethical). + Merge in some additions and changes from the FSF. + +Sat Jul 16 12:03:08 1994 Stan Shebs (shebs@andros.cygnus.com) + + * config.guess: Recognize m68k-atari-sysv4 and m88k-harris-csux7. + * config.sub: Recognize cxux7. + * configure.in: Use mh-cxux for m88k-harris-cxux*. + +Mon Jul 11 14:37:39 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.sub: Fix typo powerpc -> powerpc-*. + +Sat Jul 9 13:03:43 1994 Michael Tiemann (tiemann@blues.cygnus.com) + + * Makefile.in: `all-emacs19' depends on `all-byacc'. + + * Makefile.in: Add all-emacs19 and install-emacs19 rules (in + parallel with all-emacs and install-emacs). Top-level command + `make all-emacs19 CC=gcc' now behaves as `make all-emacs CC=gcc'. + +Thu Jun 30 16:53:42 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * test-build.mk ($(host)-stamp-stage2-installed): Remove + $(relbindir)/make before doing ``make install'', and use + $(GNU_MAKE) while doing it. Avoids problem on SunOS with + installing over running make binary. + ($(host)-stamp-stage3-installed): Likewise. + +Tue Jun 28 13:43:25 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Recognize Mach. + +Mon Jun 27 16:41:14 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure: Check ${exec_prefixoption}, not ${exec_prefix}, to + see whether --exec-prefix was used. + +Sun Jun 26 21:15:54 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * README: Explicitly mention libg++/README. (Zoo's idea.) + +Tue Jun 21 12:45:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in: Add all-librx target similar to all-libproc. + +Wed Jun 8 23:11:55 1994 Stu Grossman (grossman@cygnus.com) + + * config.guess: Rearrange tests for Alpha-OSF1 to properly deal + with post 1.2 uname bogosity. + +Thu Jun 9 00:27:59 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure: Remove temporary files on receipt of a signal. + +Tue Jun 7 12:06:24 1994 Ian Lance Taylor (ian@cygnus.com) + + * configure: If there is a package_makefile_frag, remove + ${subdir}/Makefile.tem after copying it in. + +Mon Jun 6 21:35:02 1994 D. V. Henkel-Wallace (gumby@cygnus.com) + + * build_all.mk: support rs6000 lynx identifies itself as + rs6000-lynx-lynxos2.2.2. Also, use /usr/cygnus/progressive/bin/gcc + since /bin/gcc is too feeble to compile a modern gcc. + +Mon Jun 6 16:06:34 1994 Karen Christiansen (karen@cirdan.cygnus.com) + + * brought devo/test-build.mk update-to-date with progressive/ + test-build.mk. Add lynx targets and hppa flag info. + +Sat Jun 4 17:23:54 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * configure.in: Use mh-ncrsvr43. Patch from + Tom McConnell . + +Fri Jun 3 17:47:24 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess (i386-unknown-bsdi): No longer need to + check #if defined(__bsdi__) && defined(__i386__). + +Thu Jun 2 18:56:46 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure: Set program_transform_nameoption correctly. + +Thu Jun 2 10:57:06 1994 Karen Christiansen (karen@cirdan.cygnus.com) + + * brought build-all.mk update-to-date with progressive build-all.mk, + added new targets and hppa info. + +Thu Jun 2 00:12:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure: If config.guess result is a prefix of the user + specified target, assume a native build and use the user specified + target as the host alias. Remove SunOS patch suffix removal hack. + * configure.in: Remove SunOS patch suffix removal hack. + + * Makefile.in (CROSS_CHECK_MODULES): Remove check-flex, since it's + in NATIVE_CHECK_MODULES. + +Wed Jun 1 10:49:41 1994 Bill Cox (bill@rtl.cygnus.com) + + * Makefile.in: Rename HOST_ONLY to NATIVE. + * configure: Delete SunOs patch suffix from host_canonical + and build_canonical variables that are prepended to Makefiles. + * configure.in: Add comments for easier maintenance. + +Tue May 31 19:39:47 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in: Add all-libproc target similar to all-gui. + +Tue May 31 17:16:33 1994 Tom Lord (lord@cygnus.com) + + * Makefile.in (CHECK_MODULES): split into + HOST_ONLY_CHECK_MODULES and CROSS_CHECK_MODULES. + +Tue May 31 16:36:36 1994 Paul Eggert (eggert@twinsun.com) + + * config.guess (i386-unknown-bsdi): New system to guess. + +Wed May 25 16:47:10 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in: Add all-gui target (but not yet build by "all"). + +Thu May 26 08:53:19 1994 Bill Cox (bill@rtl.cygnus.com) + + * config.sub: Move deletion of patch suffix from here... + * configure.in: To here, at Ian's suggestion. The top- + level scripts might need to know of a patch level. + +Wed May 25 09:15:54 1994 Bill Cox (bill@rtl.cygnus.com) + + * config.sub: Strip off patch suffix so rtl is recognized + as a sunos4.1.3 machine, even though it's been patched. + +Fri May 20 08:25:49 1994 Steve Chamberlain (sac@deneb.cygnus.com) + + * Makefile.in (INSTALL_LAST): Delete. + (INSTALL_DOSREL): New. + +Thu May 19 17:12:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Use ld for i[34]86-*-sysv4* and sparc-*-solaris2*. + Don't set use_gnu_ld to no for *-*-sysv4; that only controls + whether we pass down --with-gnu-ld anyhow. + +Thu May 19 09:29:12 1994 Steve Chamberlain (sac@cygnus.com) + + * Makefile.in (INSTALL_LAST): Change operation so it works + on more flavors of make. + * configure.in (go32): Don't build libg++ or libio. + +Fri May 13 13:28:34 1994 Steve Chamberlain (sac@cygnus.com) + + * Makefile.in (Move HOST_PREFIX_1 and friends up so + they can be overriden by templates. + +Sat May 7 16:46:44 1994 Steve Chamberlain (sac@cygnus.com) + + * configure.in (target==go32): Don't build gdb. + * dosrel: New directory. + +Fri May 6 14:19:25 1994 Steve Chamberlain (sac@cygnus.com) + + * configure.in (host==go32): Configure dosrel too. + * Makefile.in (INTALL_TARGET): Call INSTALL_LAST last. + (HOST_CC, HOST_PREFIX, HOST_PREFIX_1): Undefine, they should + be set by incoming names or templates. + (INSTALL_LAST): New rule. + * config/mh-go32: New fragment. + +Thu May 5 17:35:05 1994 Stan Shebs (shebs@andros.cygnus.com) + + * config.sub (sparclitefrw, sparclitefrwcompat): Don't set the os. + +Thu May 5 20:06:45 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * config/mh-lynxrs6k: Renamed from mh-lynxosrs6k, to make it + unique in 8.3 naming schemes. + * configure.in (appdirs): New variable. Currently empty, but will + be used in gas distribution. If nonempty, lists a set of + directories at least one of which must get configured, or top + level configuration is considered to have failed. + (rs6000-*-lynxos*): Use new file name. + +Thu May 5 13:38:36 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Eliminate XTRAFLAGS. + * Makefile.in (CC_FOR_TARGET): If newlib exists, refer to the + newlib include files using -idirafter, and also use -nostdinc. + (CXX_FOR_TARGET): Likewise. + (XTRAFLAGS): Removed. + (BASE_FLAGS_TO_PASS): Remove XTRAFLAGS_FOR_TARGET. + (EXTRA_HOST_FLAGS): Remove XTRAFLAGS. + (EXTRA_TARGET_FLAGS, EXTRA_GCC_FLAGS): Likewise. + ($(DO_X)): Don't pass down XTRAFLAGS. + +Thu May 5 00:16:36 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * configure.in (mips*-dec-bsd*): New target; do build linker. + (mips*-*-bsd*): New target; don't build linker. + +Wed May 4 20:10:10 1994 D. V. Henkel-Wallace (gumby@cygnus.com) + + * configure.in: support rs6000-*-lynxos* configuration. + support sunos4 as a cross target. + + * config.sub: look for lynx*, not lynx since the OS version may + legitimately be part of the name. + +Tue May 3 21:48:11 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * configure.in (i[34]86-*-sco*): Move to be with other i386 + targets. + (romp-*-*): New target. Skip various binary utilities. + (vax-*-*): New target. Don't build newlib. + (vax-*-vms): Renamed from *-*-vms. Don't build opcodes or newlib. + +Thu Apr 28 15:03:05 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure.in: Only set host_makefile_frag if config + directory exists. + +Wed Apr 27 12:14:30 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * install.sh: If $dstdir exists, don't check whether each + component does. + +Tue Apr 26 18:11:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * test-build.mk (HOLES): Add sleep; used by rcs/src/conf.sh. + +Mon Apr 25 15:06:34 1994 Stan Shebs (shebs@andros.cygnus.com) + + * configure.in (*-*-lynxos*): Don't configure newlib for either + native or cross Lynx. + +Sat Apr 16 11:58:16 1994 Doug Evans (dje@canuck.cygnus.com) + + * config.sub (sparc64-elf): Fix os. + (z8k): Remove duplicate. + +Thu Apr 14 23:33:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (gcc-no-fixedincludes): Touch gcc/include/fixed, not + gcc/stmp-fixproto, to try to prevent fixproto from being run. + +Wed Apr 13 15:14:52 1994 Bill Cox (bill@cygnus.com) + + * configure: Make file links cleanly even if Lynx fails on + an NFS symlink (at least fail cleanly). + +Mon Apr 11 10:58:56 1994 Jim Wilson (wilson@sphagnum.cygnus.com) + + * test-build.mk (CC): For mips-sgi-irix4, change -XNh1500 to + -XNh2000. + +Sat Apr 9 15:10:45 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure: Unknown options are fatal again. + +Fri Apr 8 12:01:41 1994 David J. Mackenzie (djm@cygnus.com) + + * configure: Ignore --x-includes and --x-libraries, for Autoconf + compatibility. + +Thu Apr 7 17:31:43 1994 Doug Evans (dje@canuck.cygnus.com) + + * build-all.mk: Add `clean' target. + +Wed Apr 6 20:44:56 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * config.guess: Add SINIX support. + * configure.in: Add mips-*-sysv4* support. + +Mon Apr 4 17:41:44 1994 Doug Evans (dje@canuck.cygnus.com) + + * build-all.mk: Document all useful targets. + If canonhost is sparc-sun-solaris2.3, change it to sparc-sun-solaris2. + If canonhost is mips-sgi-irix4.0.5H, change it to mips-sgi-irix4. + +Thu Mar 31 04:55:57 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure: Support --silent, --quiet. + +Wed Mar 30 21:37:38 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure: Support --disable-FEATURE. + +Tue Mar 29 19:15:05 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Recognize NCR running SVR4.3. + +Mon Mar 28 14:55:15 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Make BSDI generate i386-unknown-bsd386. + Patch from Paul Eggert . + +Mon Mar 28 12:54:52 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in (powerpc-*-aix*): Treat like rs6000-*-*. + +Sat Mar 26 11:25:48 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure: Make unrecognized options give nonfatal warnings + instead of fatal errors, and pass them to any subdirectory + configures in case they recognize them. + Make --x equivalent to --with-x. + +Fri Mar 25 21:52:10 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure: Add --enable-* options. Clean up usage message and + some comments. + +Thu Mar 24 09:12:53 1994 Doug Evans (dje@canuck.cygnus.com) + + * Makefile.in (NM_FOR_TARGET): Build tree version is now nm.new. + +Sun Mar 20 11:28:22 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * configure.in (hppa*-*-*): Enable binutils. + +Sat Mar 19 11:50:16 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.sub: Recognize cisco. + +Fri Mar 18 16:42:32 1994 Jason Merrill (jason@deneb.cygnus.com) + + * Makefile.in (CXXFLAGS): Add -fexternal-templates. + +Tue Mar 15 11:25:55 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: about target *-hitachi-hiuxwe2, don't print more + than one configuration name. Add comment. + +Sun Mar 6 23:13:38 1994 Hisashi MINAMINO (minamino@sra.co.jp) + + * config.guess: about target *-hitachi-hiuxwe2, fixed + machine guessing order. [Hitachi's CPU_IS_HP_MC68K + macro is incorrect.] + +Sun Mar 13 09:10:08 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in (TAGS): Just build TAGS in each subdirectory, rather + than the "make ls" stuff which used to be here. + +Fri Mar 11 12:52:39 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Recognize i[34]86-unknown-freebsd. + From Shawn M Carey . + +Thu Mar 3 14:24:21 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * configure.in (noconfigdirs for alpha): Remove libg++ and libio. + +Wed Mar 2 13:28:48 1994 Jim Kingdon (kingdon@deneb.cygnus.com) + + * config.guess: Check for ptx. + +Mon Feb 28 16:46:50 1994 Kung Hsu (kung@mexican.cygnus.com) + + * config.sub: Add os9k checking. + +Thu Feb 24 07:09:04 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * config.guess: Handle OSF1 running on HPPA processors + +Fri Feb 18 14:14:00 1994 Ken Raeburn (raeburn@rtl.cygnus.com) + + * configure: If subdir configure fails, print out a message with + subdirectory name, in case subdir's configure code didn't identify + itself. + +Fri Feb 18 12:50:15 1994 Doug Evans (dje@cygnus.com) + + * configure.in: Remove embedded newlines from configdirs. + Avoid mismatches of substrings. Fix matching strings at end + of configdirs. + +Fri Feb 11 15:33:33 1994 Stu Grossman (grossman at cygnus.com) + + * config.guess: Add Lynx/rs6000 config support. + +Tue Feb 8 13:41:09 1994 Ken Raeburn (raeburn@rtl.cygnus.com) + + * configure.in (alpha-dec-osf1*, alpha*-*-*): Build gas. + +Mon Feb 7 15:42:36 1994 Jeffrey A. Law (law@cygnus.com) + + * configure.in (hppa*-*-osf*): Treat this just like most other + PA configurations (eg no binutils or ld). + (hppa*-*-*elf*): These configurations have binutils and ld. + +Sun Feb 6 16:35:07 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * config.sub (hiux): Fix typo. From m-kasahr@sramhc.sra.co.JP. + +Sat Feb 5 01:00:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in (rs6000-*-*): Build gas. + +Wed Feb 2 13:57:57 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * Makefile.in: Avoid bug in losing hpux sed. + +Wed Feb 2 14:53:05 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in, test-build.mk: Remove MUNCH_NM; it was only needed + for GDB and GDB has been fixed to not need it. + +Mon Jan 31 18:40:55 1994 Stu Grossman (grossman at cygnus.com) + + * config/mh-lynxosrs6k: Account for lack of ranlib! + +Sun Jan 30 17:58:06 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * config.guess: Recognize vax hosts. + +Fri Jan 28 15:29:38 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * configure (while loop): Don't use "break 2" inside case + statement -- the case statement isn't an enclosing loop. + +Mon Jan 24 18:40:06 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Clean up NeXT support, to allow nextstep + on Intel machines. Make OS be nextstep. + +Sun Jan 23 18:47:22 1994 Richard Kenner (kenner@vlsi1.ultra.nyu.edu) + + * config.guess: Add alternate forms for Convex. + +Thu Jan 20 16:13:41 1994 Stu Grossman (grossman at cygnus.com) + + * configure: Completely rewrite option processing. Take + advantage of pattern-matching to avoid invoking test frequently. + Also clean up host and target defaulting logic. + +Mon Jan 17 15:06:56 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * Makefile.in: Replace all occurrances of "rootme" with "r" and + "$${rootme}" with "$$r", to increase the likelihood that the do-* + commands (plus user environment) will fit SCO limits. + +Thu Jan 6 11:20:57 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Don't issue warnings about directories which are + not being configured if -norecursion is set. Correct test for + --with-gnu-as and --with-gnu-ld to not get confused by substring + matches. + + * configure.in: Don't build gas for alpha-dec-osf1*. + +Tue Jan 4 17:10:19 1994 Stu Grossman (grossman at cygnus.com) + + * configure: Back out Per's change of 12/19/1993. It changes the + behavior of configure in unexpected and confusing ways. + + Also, use different delim char when calculating + program_transform_name so that the name can contain slashes. + +Sat Jan 1 13:45:31 1994 Rob Savoye (rob@darkstar.cygnus.com) + + * configure.in, config.sub: Add support for VSTa micro-kernel. + +Sat Dec 25 20:00:47 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + * configure.in: Nuke hacks which were used to get a special + version of GAS for HPPA configurations. + +Sun Dec 19 20:40:44 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * configure: If only ${target_alias} is given, use that + as the default for ${host_alias}. + * configure: Add missing back-slashes before nested quotes. + +Wed Dec 15 18:07:18 1993 david d `zoo' zuhn (zoo@andros.cygnus.com) + + * Makefile.in (BASE_FLAGS_TO_PASS): add YACC=$(BISON) + +Tue Dec 14 21:25:33 1993 Per Bothner (bothner@cygnus.com) + + * config.guess: Recognize some Tektronix configurations. + From Kaveh R. Ghazi . + +Sat Dec 11 11:18:00 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * config.sub: Match any flavor of SH. + +Thu Dec 2 17:16:58 1993 Ken Raeburn (raeburn@cujo.cygnus.com) + + * configure.in: Don't try to configure newlib for Alpha. + +Thu Dec 2 14:35:54 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Don't build ld for Irix 5. Don't build gas, + libg++ or libio for any Alpha target. + + * configure.in (mips*-sgi-irix5*): New target; use mh-irix5. + * config/mh-irix5. New file for Irix 5. + +Wed Dec 1 17:00:33 1993 Jason Merrill (jason@deneb.cygnus.com) + + * Makefile.in (GZIPPROG): Renamed from GZIP, which gzip uses for + default arguments -- so it tried to compress itself. + +Tue Nov 30 13:45:15 1993 david d `zoo' zuhn (zoo@andros.cygnus.com) + + * configure.in (notsupp): ensure that a space is always at the end + of the configdirs list, since the grep checks for an explicit space + +Tue Nov 16 15:04:27 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in (target i386-sysv4.2): don't build ld, since static + versions of many libraries are not available. + +Tue Nov 16 14:28:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Recognize Apollos (using environment variables). + * configure.in: Don't configure ld, binutils, or gprof for Apollo. + +Thu Nov 11 12:03:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Recognize Sony news mips running newsos. + +Wed Nov 10 16:57:00 1993 Mark Eichin (eichin@cygnus.com) + + * Makefile.in (all-cygnus, build-cygnus): "fi else" needs to be + "fi ; else" for bash. + +Tue Nov 9 15:54:01 1993 Mark Eichin (eichin@cygnus.com) + + * Makefile.in (BASE_FLAGS_TO_PASS): pass SHELL. + +Fri Nov 5 08:07:27 1993 D. V. Henkel-Wallace (gumby@blues.cygnus.com) + + * config.sub: accept unixware as an alias for svr4.2. + Fix some inconsistancies with the gcc version. + +Fri Nov 5 15:14:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in (DISTDOCDIRS): Add gdb. + +Fri Nov 5 11:59:42 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (DISTDOCDIRS): Add libg++ and libio. + +Fri Nov 5 10:35:05 1993 Ken Raeburn (raeburn@rover.cygnus.com) + + * Makefile.in (taz): Only build "info" in DISTDOCDIRS. + (DISTDOCDIRS): Don't assume libg++ and gdb folks necessarily want + this now. + +Thu Nov 4 18:58:23 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.sub: Accept hiux* as an OS name. + + * Makefile.in: Change RUNTEST_FLAGS back to RUNTESTFLAGS per + etc/make-stds.texi. The underscore came from gcc, and dje now + agrees that RUNTESTFLAGS is the correct name. + +Thu Nov 4 10:49:01 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * install.sh: Remove 'set -e'. It makes any conditionals + in the script useless. + + * config.guess: Automatically recognize arm-acorn-riscix + Patch from Richard Earnshaw (rwe11@cl.cam.ac.uk). + +Thu Nov 04 08:08:04 1993 Jeffrey Wheat (cassidy@cygnus.com) + + * Makefile.in: Change RUNTESTFLAGS to RUNTEST_FLAGS + +Wed Nov 3 22:09:46 1993 Ken Raeburn (raeburn@rtl.cygnus.com) + + * Makefile.in (DISTDOCDIRS): New variable. + (taz): Edit local Makefile.in sooner, instead of proto-toplev + Makefile.in later. Build "info" and "dvi" in DISTDOCDIRS. + +Wed Nov 3 21:31:52 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in (hppa target): check the source directory for the + pagas sub-directory + +Wed Nov 3 11:12:22 1993 Doug Evans (dje@canuck.cygnus.com) + + * config.sub: Allow -aout* and -elf*. + +Wed Nov 3 11:08:33 1993 Ken Raeburn (raeburn@rtl.cygnus.com) + + * configure.in: Don't build ld on i386-solaris2, same as for + sparc-solaris2. + +Tue Nov 2 14:21:25 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (taz): Add texinfo/lgpl.texinfo (for libg++). + +Tue Nov 2 13:38:30 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * configure.in: Configure gdb for alpha. + +Mon Nov 1 10:42:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in (CXXFLAGS): Add -O. + +Wed Oct 27 10:45:06 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * config.guess: added support for DG Aviion + +Tue Oct 26 14:37:37 1993 Ken Raeburn (raeburn@rover.cygnus.com) + + * configure.in: Produce warning message for subdirectories not + configurable for this host/target combination. Don't try to + configure gdb for vms. + +Mon Oct 25 11:22:15 1993 Ken Raeburn (raeburn@rover.cygnus.com) + + * Makefile.in (taz): Replace "byacc" with "bison -y" in the + appropriate files before making "diststuff". + (DISTBISONFILES): New var: list of files to be edited. + (DISTSTUFFDIRS): Add binutils. + +Fri Oct 22 20:32:15 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * config.sub: also handle mipsel and mips64el (for little endian mips) + +Fri Oct 22 07:59:20 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * configure.in: Add * to end of all OS names. + +Thu Oct 21 11:38:28 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * configure.in: Build newlib for LynxOS native. + +Wed Oct 20 09:56:12 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Add support for delta 88k running SVR3. + + * configure.in: Add comment about HP compiler vs. emacs. + +Tue Oct 19 16:02:22 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: don't build ld on solaris2 (not a viable option + due to bugs in getpwnam & getpwuid) + +Tue Oct 19 15:13:56 1993 Ken Raeburn (raeburn@rtl.cygnus.com) + + * configure.in: Accept alpha-dec-osf1*, not just -osf1, since + config.guess will produce a full version number. + +Tue Oct 19 15:58:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Build linker and binutils for alpha-dec-osf1. + +Tue Oct 19 11:41:55 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in: Remove -O from CXXFLAGS for consistency with CFLAGS, + and gdb/testsuite/Makefile.in. + +Sat Oct 9 18:39:07 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: recognize mips*- instead of mips- + +Fri Oct 8 14:15:39 1993 Ken Raeburn (raeburn@cygnus.com) + + * config.sub: Accept linux*coff and linux*elf as operating + systems. + +Thu Oct 7 12:57:19 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * config.sub: Recognize mips64, and mips3 as an alias for it. + +Wed Oct 6 13:54:21 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * configure.in: Remove alpha-dec-osf*, no longer necessary now that + gdb knows how to handle OSF/1 shared libraries. + +Tue Oct 5 11:55:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * configure.in: Recognize hppa*-*-hiux* (currently synonym for hpux). + * config.guess: Recognize Hitachi's HIUX. + * config.sub: Recognize h3050r* and hppahitachi. + Remove redundant cases for hp9k[23]*. + +Mon Oct 4 16:15:09 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: default to '--with-gnu-as' and '--with-gnu-ld' + if gas and ld are in the source tree and are in ${configdirs}. + If ${use_gnu_as} or ${use_gnu_ld} are 'no', then don't set the + the --with options (but still pass them down on the command line, + if they were explicitly specified). + +Fri Sep 24 19:11:13 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure: substitute SHELL value in Makefile.in with + ${CONFIG_SHELL} + +Thu Sep 23 18:05:13 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Build gas, ld, and binutils for *-*-sysv4* and + *-*-solaris2* targets. + +Sun Sep 19 17:01:41 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in: define M4, and pass it down to sub-makes; + all-autoconf now depends on all-m4 + +Sat Sep 18 00:38:23 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in ({AR,RANLIB}_FOR_TARGET): make contingent on + presence of {ar,ranlib} instead of a configured directory + +Wed Sep 15 08:41:44 1993 Jim Kingdon (kingdon@cirdan.cygnus.com) + + * config.guess: Accept 34?? as well as 33?? for NCR. + +Mon Sep 13 12:28:43 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: grab mt-hppa for HPPA targets; use 'gas ' instead + of 'gas' in sed commands, since 'gash' is now in the tree as well. + +Fri Sep 10 11:23:52 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure: grab values for $(CC) and $(CXX) from the + environment, so that someone can do "CC=gcc configure; make" and + have it work right (matching the way that autoconf works now) + + * configure.in, Makefile.in: add support for gash, the tcl + interface to Galaxy + + * config.guess: add NetBSD variants (hp300, x86) + +Thu Sep 9 16:48:52 1993 Jason Merrill (jason@deneb.cygnus.com) + + * install.sh: Support -d option (in the manner of SunOS 4 install, + as it is more deterministic than that of GNU install) + (chmodcmd): Set file to mode 755 by default (should also do default + chgrp and chown, but I don't feel like dealing with that now) + +Tue Sep 7 11:59:39 1993 Doug Evans (dje@canuck.cygnus.com) + + * config.sub: Remove h8300hhms alias. + +Tue Aug 31 11:00:09 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * configure.in: Match *-*-solaris2* not *-sun-solaris2*. + +Mon Aug 30 18:29:10 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in (gcc-no-fixedincludes): touch stmp-fixproto as well + as stmp-fixinc + +Wed Aug 25 16:35:59 1993 K. Richard Pixley (rich@sendai.cygnus.com) + + * config.sub: recognize m88110-bug-coff. + +Tue Aug 24 10:23:24 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in (all-libio): all dependencies on the toolchain used + to build this (gcc, gas, ld, etc) + +Fri Aug 20 17:24:24 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Deal with OSF/1 1.3 on alpha. + +Thu Aug 19 11:43:04 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * install.sh: add some 'else true' clauses for portability + + * configure.in: don't build libio for h8[35]00-*-* targets + +Tue Aug 17 19:02:31 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Add support for new libio. + +Sun Aug 15 20:48:55 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * install.sh: If one command fails, don't try the rest. Don't try + to remove $dsttmp (via trap) unless we have already created it. + If $src doesn't exist, detect it and exit with an error. + + * config.guess: Recognize BSD on hp300. + +Wed Aug 11 18:35:13 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config.guess: Map (9000/[34]??:HP-UX:*:*) to m68k-hp-hpux. + Bug report from "Hamish (H.I.) Macdonald" . + +Wed Aug 11 15:37:51 1993 Jason Merrill (jason@deneb.cygnus.com) + + * Makefile.in (all-send-pr): depends on all-prms + +Wed Aug 11 16:56:03 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Fix typo (9000/8??:4.3bsd -> 9000/7??:4.3bsd). + +Fri Aug 6 14:45:02 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * config.guess: From michael@mercury.cs.mun.ca (Michael Rendell): + Added test for mips-mips-riscos5. + +Thu Aug 5 15:45:08 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: use mh-hp300 for 68k HP hosts + +Mon Aug 2 11:56:53 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure: add support for CONFIG_SHELL, so that you can use + some alternate shell for evaluating configure scripts + +Sun Aug 1 11:36:27 1993 Fred Fish (fnf@deneb.cygnus.com) + + * Makefile.in (make-gdb.tar.gz): Sed bug reporting address + in configure script to bug-gdb@prep.ai.mit.edu when building + distribution archive. + * Makefile.in (COMPRESS): Remove def. + * Makefile.in (gdb.tar.gz, make-gdb.tar.gz): Renamed from + gdb.tar.Z and make-gdb.tar.Z respectively. + * Makefile.in (make-gdb.tar.gz): Now only build gzip'd archive. + * Makefile.in (make-gdb.tar.gz): Minor changes to move closer + to convergence with 'taz' target in Makefile.in. + +Fri Jul 30 12:34:57 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * install.sh (dsttmp): use trap to ensure that tmp files go + away on error conditions + +Wed Jul 28 11:57:36 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in (BASE_FLAGS_TO_PASS): remove LOADLIBES + +Tue Jul 27 12:43:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in (install-dirs): Deal with a prefix like /gnu; + its parent is '/' not ''. + + * Makefile.in (DEVO_SUPPORT): Add comments about ChangeLog. + +Fri Jul 23 09:53:37 1993 Jason Merrill (jason@wahini.cygnus.com) + + * configure: if ${newsrcdir}/configure doesn't exist, don't assume + that ${newsrcdir}/configure.in does. + +Tue Jul 20 11:28:50 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * test-build.mk: support for CONFIG_SHELL + +Mon Jul 19 21:54:46 1993 Fred Fish (fnf@deneb.cygnus.com) + + * config.sub (netware): Add as a basic system type. + +Wed Jul 14 12:03:11 1993 K. Richard Pixley (rich@sendai.cygnus.com) + + * Makefile.in (Makefile): depend on configure.in. Also drop the + $(srcdir)/ from the dependency on Makefile.in. + +Tue Jul 13 20:10:58 1993 Doug Evans (dje@canuck.cygnus.com) + + * config.sub: Recognize h8300hhms as h8300h-hitachi-hms. + (h8300hhms is temporary until multi-libraries are implemented). + * configure.in: Handle h8300h too. + +Sun Jul 11 17:35:27 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Recognize dpx/2 as m68k-bull-sysv3. + +Thu Jul 8 18:26:12 1993 John Gilmore (gnu@cygnus.com) + + * configure: Remove extraneous output when guessing host type. + * config.guess: Remove extraneous output when guessing using C + compiler rather than uname, or when guessing fails. + +Wed Jul 7 17:58:14 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com) + + * Makefile.in: remove all.cross and install.cross targets + + * configure: remove CROSS=-DCROSS_COMPILE and ALL=all.cross + definitions + +Tue Jul 6 10:39:44 1993 Steve Chamberlain (sac@phydeaux.cygnus.com) + + * configure.in (target sh): Build gprof. + +Thu Jul 1 16:52:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config.sub: change -solaris to -solaris2 + +Thu Jul 1 15:46:16 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * configure.in: Use config/mh-riscos for mips-*-sysv*. + +Wed Jun 30 09:31:58 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure: Correct error message for missing Makefile.in to + print correct directory. + +Tue Jun 29 13:52:16 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * install.sh: kludge around 386BSD shell bug + +Tue Jun 29 13:06:49 1993 Per Bothner (bothner@rtl.cygnus.com) + + * config.guess: Recognize NeXT. + * config.guess: Recognize i486-ncr-sysv4. + * Makefile.in (taz): rm $(TOOL)-$$VER before linking. + +Tue Jun 29 12:50:57 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (MAKEINFOFLAGS): New variable. + (FLAGS_TO_PASS): Pass MAKEINFO as MAKEINFO MAKEINFOFLAGS. + * build-all.mk, test-build.mk: Pass down --no-split as + MAKEINFOFLAGS when hosted on DOS. Compile DOS hosted without -g. + +Thu Jun 24 13:39:11 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (DEVO_SUPPORT): Add COPYING COPYING.LIB install.sh. + +Wed Jun 23 12:59:21 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (libg++.tar.z): New rule. + * Makefile.in (taz): Replace 'configure -rm' by 'make distclean'. + * Makefile.in (taz): Only do a single chmod. + +Fri Jun 18 12:03:10 1993 david d `zoo' zuhn (zoo at majipoor.cygnus.com) + + * install.sh: don't use dirname anymore (replaced with sed usage) + +Thu Jun 17 18:43:42 1993 Fred Fish (fnf@cygnus.com) + + * Makefile.in: Change extension for gzip'd files from '.z' to + '.gz' per new FSF standard usage. + +Thu Jun 17 16:58:50 1993 david d `zoo' zuhn (zoo at majipoor.cygnus.com) + + * configure: put quotes around the final value of program_transform_name + +Tue Jun 15 16:48:51 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: new install.sh support; update install-info rules + +Wed Jun 9 12:31:34 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure.in: Build diff for crosses, but not for go32 host. + + * configure.in: Build gprof only for native, and don't build it + for mips-*-*, rs6000-*-*, or i[34]86-*-sco*. + +Mon Jun 7 13:12:11 1993 david d `zoo' zuhn (zoo at deneb.cygnus.com) + + * configure.in: don't build gas,ld,binutils on for *-*-sysv4 + +Mon Jun 7 11:40:11 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * configure.in (host_tools): Add prms. + +Fri Jun 4 13:30:42 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: install gcc, do installation of $(INSTALL_MODULES) + with $(FLAGS_TO_PASS) on the command line + + * config.sub: Recognize lynx and lynxos + +Fri Jun 4 10:59:56 1993 Ian Lance Taylor (ian@cygnus.com) + + * config.sub: Accept -ecoff*, not just -ecoff. + +Thu Jun 3 17:38:54 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (taz): Use .gz suffix instead of .z. + (binutils.tar.gz, gas+binutils.tar.gz, gas.tar.gz): Fixed target + names. + +Thu Jun 3 00:27:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in (vault-install): add an 'else true' (for Ultrix) + +Wed Jun 2 18:19:16 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in (install-no-fixedincludes): install gcc last, so + that rebuilds that might happen during 'make install' don't get + bogus gcc include files + +Wed Jun 2 16:14:10 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + Change from Utah for HPPA support: + * config.guess: Recognize hppa1.x-hp-bsd. + +Wed Jun 2 11:53:33 1993 Per Bothner (bothner@rtl.cygnus.com) + + * config.guess: Add support for Motorola Delta 68k, up to r3v7. + Patch from pot@fly.cnuce.cnr.it (Francesco Potorti`). + +Tue Jun 1 17:48:42 1993 Rob Savoye (rob at darkstar.cygnus.com) + + * config.sub: Add support for rom68k and bug boot monitors. + +Mon May 31 09:36:37 1993 Jim Kingdon (kingdon@cygnus.com) + + * Makefile.in: Make all-opcodes depend on all-bfd. + +Thu May 27 08:05:31 1993 Ian Lance Taylor (ian@cygnus.com) + + * config.guess: Added special check for i[34]86-univel-sysv4*. + +Wed May 26 16:33:40 1993 Ian Lance Taylor (ian@cygnus.com) + + * config.guess: For i[34]86-unknown-sysv4 use UNAME_MACHINE for + the processor rather than assuming i486. + +Wed May 26 09:40:18 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.guess: Recognize SunOS6 as Solaris3. + +Tue May 25 23:03:11 1993 Per Bothner (bothner@cygnus.com) + + * config.guess: Fix typo. Avoid #elif (not in K&R 1). + Recognize SunOS 5.* only (and not [6-9].*) as being Solaris2. + +Tue May 25 12:44:18 1993 Ian Lance Taylor (ian@cygnus.com) + + * build-all.mk (all-cross): New target for Canadian Cross. + Added Q2 go32 targets. + * test-build.mk: Configure go32 cross sparclite-aout and + mips-idt-ecoff -with-gnu-ld. Moved build binary directory from + PARTIAL_HOLE_DIRS to BUILD_HOLES_DIRS. + +Mon May 24 15:30:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: fix Alpha GDB typo; also, don't build DejaGnu for + GO32 hosted toolchains + +Mon May 24 14:18:41 1993 Rob Savoye (rob at darkstar.cygnus.com) + + * configure: change so "-exec-prefix" gets passed down rather + than "-exec_prefix" so autoconf generated Makefiles get the + exec_prefix set right. + +Fri May 21 10:42:25 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config.guess: get the Solaris2 minor version number + + * Makefile.in: add standards.texi and make-stds.texi to ETC_SUPPORT + +Fri May 21 06:20:52 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * config.guess: Recognize some Sequent platforms. + +Thu May 20 14:33:48 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: added the vault-install target + + * configure.in: actually use the Sun3 makefile fragment that's in + config, also added the release dir to configdirs + +Thu May 20 14:19:18 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (taz): Fix modes on stuff in $(TOOL) dir also. + +Tue May 18 20:26:41 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: remove some program from Alpha targetted toolchains + +Tue May 18 15:23:19 1993 Ken Raeburn (raeburn@cygnus.com) + + * Makefile.in (DISTSTUFFDIRS): Renamed from PROTODIRS. Add ld and + gprof. + (taz): Run "make diststuff" in those directories instead of "make + proto-dir". Look for "VERSION=" only at start of line in subdir + Makefile. Use "gzip -9" for compression. + (TEXINFO_SUPPORT, DIST_SUPPORT, BINUTILS_SUPPORT_DIRS): New vars. + (binutils.tar.z): New target. + +Mon May 17 17:01:15 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * Makefile.in (taz): Include gpl.texinfo. + +Fri May 14 06:48:38 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * Makefile.in (setup-dirs): Merged into "taz" target. + (taz): Only do `proto-dir' stuff if a directory is actually needed + for this target. + +Wed May 12 13:09:44 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (MUNCH_NM): New variable, defined to be $(NM). + (FLAGS_TO_PASS): Pass down MUNCH_NM. + (HOST_CC, HOST_PREFIX, HOST_PREFIX_1): New variables. + (EXTRA_GCC_FLAGS): Pass down HOST_* variables. + (gcc-no-fixedincludes): Correct for current gcc Makefile. + +Tue May 11 10:14:25 1993 Fred Fish (fnf@cygnus.com) + + * Makefile.in (make-gdb.tar.Z): Add configure, config.guess, + config.sub, and move-if-change to gdb testsuite distribution + archive, so the testsuite can be extracted, configured, and + run separately from the gdb distribution. Blow away the Chill + tests that require a Chill compiled executable, since GNU Chill + is not yet publically available. + +Mon May 10 17:22:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * test-build.mk: set environment variables in a single command, + instead of a list of assignments and exports + + * config.guess: recognize Alpha/OSF1 systems + +Mon May 10 14:55:51 1993 K. Richard Pixley (rich@rtl.cygnus.com) + + * configure: Change help message to prefer --options rather than + -options. + +Mon May 10 05:58:35 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * config.sub: Convergent Tech. "miniframe" uses m68010, sez + zippy@ecst.csuchico.edu. + * config.guess: Recognize miniframe. + +Sun May 9 17:47:57 1993 Rob Savoye (rob at darkstar.cygnus.com) + + * Makefile.in: Use srcroot to find runtest rather than rootme. + Pass RUNTESTFLAGS and EXPECT down in BASE_FLAGS_TO_PASS. + +Fri May 7 14:55:59 1993 Ian Lance Taylor (ian@cygnus.com) + + * test-build.mk: Extensive additions to support building on a + machine other than the host. + +Wed May 5 08:35:04 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * configure (tooldir): Fix for i386-aix again. + +Mon May 3 19:00:27 1993 Per Bothner (bothner@cygnus.com) + + * configure, Makefile.in: Change definition of $(tooldir) + to match the FSF. + +Fri Apr 30 15:55:21 1993 Fred Fish (fnf@cygnus.com) + + * config.guess: Recognize i[34]86/SVR4. + +Fri Apr 30 15:52:46 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * Makefile.in (all-gdb): gdb depends on sim. + +Thu Apr 29 23:30:48 1993 Fred Fish (fnf@cygnus.com) + + * Makefile.in (gdb.tar.Z): Make prototype gdb testsuite directory + at the same time we make the prototype gdb directory. + * Makefile.in (make-gdb.tar.Z): Make the testsuite distribution + files at the same time as the gdb base release distribution. + +Thu Apr 29 12:50:37 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (check): Use individual check targets rather than + DO_X rule. + (check-gcc): Added. + +Thu Apr 29 09:50:07 1993 Jim Kingdon (kingdon@cygnus.com) + + * config.sub: Use sysv3.2 not sysv32 for canonical OS + for System V release 3.2. + +Thu Apr 29 10:33:22 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * config.sub: Recognize hppaosf. + * configure.in: Do configure ld/binutils/gas for it. + +Tue Apr 27 06:25:34 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * configure (tooldir): Alter syntax used to set this, for systems + where "\$" isn't handled right, like i386-aix. + +Thu Apr 22 08:17:35 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure: Pass program-transform-name, not + program_transform_name, to recursive configures. + +Thu Apr 22 02:58:21 1993 Ken Raeburn (raeburn@cygnus.com) + + * Makefile.in (gas+binutils.tar.z): New rule for building snapshots + of gas+ld+binutils. + +Mon Apr 19 17:41:30 1993 Per Bothner (bothner@cygnus.com) + + * config.guess: Recognize AIX3.2 as distinct from 3.1. + +Sat Apr 17 17:19:50 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: rename m88k-motorola-m88kbcs to m88k-motorola-sysv + + * config/mh-delta88: remove extraneous GCC references + +Tue Apr 13 16:52:16 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Makefile.in (PRMS): Set back to all-prms. + +Sat Apr 10 12:04:07 1993 Ian Lance Taylor (ian@cygnus.com) + + * test-build.mk: Pass -with-gnu-as for known MIPS native and MIPS + targets, rather than for MIPS hosts. + +Fri Apr 9 13:51:06 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: add comment for --with-x default values + + * config.guess: handle Motorola Delta88 box for SVR3 and SVR4. + + * Makefile.in: add check-* targets for each of the directories in + the tree. Add a definition of RUNTEST that will use the one we + just built, if it exists. Pass this down via FLAGS_TO_PASS. + +Thu Apr 8 09:21:30 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure.in: Removed obsolete references to bfd_target and + target_makefile_frag. + + * build-all.mk: Set assorted targets for Q2. + * config.sub: Recognize z8k-sim and h8300-hms. + * test-build.mk: Really don't pass host to configure. + (HOLES): Added uname. + +Wed Apr 7 15:48:19 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure: Handle an empty program-prefix, program-suffix or + program-transform-name correctly. + +Tue Apr 6 13:48:41 1993 Ian Lance Taylor (ian@cygnus.com) + + * build-all.mk: -G 8 no longer required for MIPS targets. + * test-build.mk: Don't pass host argument to configure; make it + guess. + +Tue Apr 6 10:36:53 1993 Fred Fish (fnf@cygnus.com) + + * Makefile.in (gdb.tar.Z): Fix for building gzip'd distribution. + * Makefile.in (COMPRESS): New macro, like GZIP. + +Fri Apr 2 09:02:31 1993 Ian Lance Taylor (ian@cygnus.com) + + * test-build.mk: Use -with-gnu-as for mips-sgi-irix4 as well. + + * build-all.mk: Set GCC to gcc -O -G 8 for MIPS targets, since gcc + with gas currently defaults to -G 0. + +Thu Apr 1 08:25:42 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (all-flex): flex depends on byacc. + + * build-all.mk: If host not specified, use config.guess. Pass TAG + to test-build.mk as RELEASE_TAG. + * test-build.mk (configargs): New variable containing arguments to + pass to configure. Set to -with-gnu-as on mips-dec-ultrix. + (FLAGS_TO_PASS): Pass down RELEASE_TAG. + + * config.guess: Use /bin/uname when checking -X argument on SCO, + to avoid invoking GNU uname which doesn't understand -X. + + * test-build.mk: Don't use /usr/unsupported/bin/as on AIX. + + * configure.in: Build gas for mips-*-*. + +Wed Mar 31 21:20:58 1993 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in (all.normal): insert missing backslash. + +Wed Mar 31 12:31:56 1993 Ian Lance Taylor (ian@cygnus.com) + + * build-all.mk, config/mh-irix4: Bump -XNh value to 1500 to match + gcc requirements. + + * Makefile.in: Complete overhaul to merge many almost identical + targets. + +Tue Mar 30 20:17:01 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (setup-dirs-gdb): Renamed from setup-dirs. + (gdb.tar.Z): Adjusted. + + * Makefile.in (setup-dirs, taz): New targets; should be general + enough to adapt for gdb sometime. Build only .z file. + (gas.tar.z): New target. + +Tue Mar 30 10:03:09 1993 Ian Lance Taylor (ian@cygnus.com) + + * build-all.mk: Use CC=cc -Xs on Solaris. + +Mon Mar 29 19:59:26 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config/mh-sun3: cc needs -J to compile cp-parse.c correctly + + * config/mh-solaris: SunPRO C needs -Xs to be able to get a + working xmakefile for Emacs. + +Thu Mar 25 15:14:30 1993 Fred Fish (fnf@cygnus.com) + + * Makefile.in: Incorporate changes suggested by wilson@cygnus.com + for handling BISON for FSF releases. + +Thu Mar 25 06:19:48 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * configure: Actually implement the change zoo just documented. + +Wed Mar 24 13:02:44 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com) + + * configure: when using config.guess, only set target_alias when + it's not already been set (ie, on the command line) + +Mon Mar 22 23:07:39 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: add installcheck target, set PRMS to install-prms + +Sun Mar 21 16:46:12 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure: add support for package_makefile_fragment, handle the + case where a directory has a configure.in file but no Makefile.in + more gracefully (with an actual understandable error message, even); + add support for --without (and add this to the usage message); also + explicitly add a --host=${host_alias} to the command line when + config.guess is used + +Sun Mar 21 12:11:58 1993 Jim Wilson (wilson@sphagnum.cygnus.com) + + * configure: Must use both --host and --target in recursive calls. + +Thu Mar 18 12:31:35 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: Change deja-gnu to dejagnu. + +Mon Mar 15 15:44:35 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure.in (h8300-*-*, h8500-*-*): Don't build libg++. + +Fri Mar 12 18:30:14 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: canonicalize all instances to *-*-solaris2*, + also strip out a number of tools to not build for go32 host + +Wed Mar 10 12:08:27 1993 K. Richard Pixley (rich@rtl.cygnus.com) + + * config.guess: add GPL. + + * Makefile.in, config.guess, config.sub, configure: bump + copyrights to 93. + +Wed Mar 10 07:12:48 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (do-info): Removed obsolete check for existence of + localenv file. + + * Makefile.in (MAKEOVERRIDES): Define to be empty. + +Wed Mar 10 03:11:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: a couple of 'else true' for decstation, + support for TclX + + * configure.in: configure tclX too; don't remove Tk on RS/6000 anymore + +Tue Mar 9 16:06:12 1993 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in (setup-dirs): change invocation of make to $(MAKE). + +Mon Mar 8 14:52:11 1993 Ken Raeburn (raeburn@cambridge) + + * config.guess: Recognize i386-ibm-aix (PS/2). + * configure.in: Use config/mh-aix386 file for it. + +Mon Mar 8 11:12:43 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (GCC_FOR_TARGET): Eliminated definition; use + CC_FOR_TARGET instead. + (BASE_FLAGS_TO_PASS): Pass GCC_FOR_TARGET=$(CC_FOR_TARGET). + +Wed Mar 3 16:00:28 1993 Steve Chamberlain (sac@ok.cygnus.com) + + * Makefile.in: Add sim to list of directories sent with gdb + +Wed Mar 3 11:42:39 1993 Ken Raeburn (raeburn@cygnus.com) + + * configure.in: Put back mips-dec-bsd* case. + +Tue Mar 2 21:15:58 1993 Fred Fish (fnf@cygnus.com) + + (Ultrix 2.2 support from Michael Rendell ) + * configure.in (vax-*-ultrix2*): Add Ultrix 2.2 triplet. + * config.guess: Change 'VAX*:ULTRIX:*:*' to 'VAX*:ULTRIX*:*:*'. + * config/mh-vaxult2: New file. + +Tue Mar 2 18:11:03 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: remove no-op mips-dec-bsd* in "case $target" + + * Makefile.in (dir.info): only run gen-info-dir if it exists, + (install-info): install dir.info only if it exists, + (all-expect, install-expect): pass along X11_FLAGS_TO_PASS + +Tue Mar 2 09:01:30 1993 Ken Raeburn (raeburn@cygnus.com) + + * configure.in: For vms target, skip bfd, ld, binutils. Do build + gas for mips-dec-bsd. + +Tue Mar 2 08:35:24 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure (makesrcdir): If ${srcdir} is relative and not ".", + and ${subdir} is not ".", set makesrcdir based on ${invsubdir}. + +Tue Feb 23 14:18:28 1993 Mike Werner (mtw@poseidon.cygnus.com) + + * configure.in: Added "dejagnu" to hosttools list. + +Mon Feb 22 23:28:38 1993 Per Bothner (bothner@rtl.cygnus.com) + + * config.sub, configure.in, config.guess: Add support + for Bosx, an AIX variant from Bull. + Patches from F.Pierresteguy@frcl.bull.fr. + +Sun Feb 21 11:15:22 1993 Mike Werner (mtw@poseidon.cygnus.com) + + * devo/dejagnu: Initial creation of devo/dejagnu. + Migrated dejagnu testcases and support files for testing software + tools to reside as subdirectories, currently called "testsuite", + within the directory of the software tool. Migrated all programs, + support libraries, etc. beloging to dejagnu proper from + devo/deja-gnu to devo/dejagnu. These files were moved "as is" + with no modifications. The changes to these files which will + allow them to configure, build, and execute properly will be made + in a future update. + +Fri Feb 19 20:19:39 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Makefile.in: Change send_pr to send-pr. + * configure.in: Likewise. + * send_pr: Renamed directory to send-pr. + +Fri Feb 19 19:00:13 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Add some extra semi-colons (needed if SHELL=bash). + +Fri Feb 19 00:59:33 1993 John Gilmore (gnu@cygnus.com) + + * README: Update for gdb-4.8 release. + * Makefile.in (gdb.tar.Z): Add texinfo/tex3patch. Build + gdb-xxx.tar.z (gzip'd) file also. + +Thu Feb 18 09:16:17 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: make all-diff depend on all-libiberty + +Tue Feb 16 16:06:31 1993 K. Richard Pixley (rich@cygnus.com) + + * config.guess: add vax-ultrix in the spirit of mips-ultrix. + +Tue Feb 16 05:57:15 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in, Makefile.in: add hello, tar, gzip, recode, indent + +Tue Feb 16 00:58:20 1993 John Gilmore (gnu@cygnus.com) + + * Makefile.in (DEVO_SUPPORT): Remove etc directory + (ETC_SUPPORT): Only add the files GDB wants from etc/. + (gdb.tar.Z): Use ETC_SUPPORT. Use byacc when building the file. + +Thu Feb 11 20:14:28 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: makeinfo binary is in a new location + +Tue Feb 9 12:42:27 1993 Ian Lance Taylor (ian@cygnus.com) + + * config.sub: Accept -ecoff as an OS. + + * Makefile.in: Various changes to eliminate a level of make + recursion and reduce the required command line length. + (BASE_FLAGS_TO_PASS): New variable holding flags passed to all + sub-makes. + (EXTRA_HOST_FLAGS, EXTRA_TARGET_FLAGS, EXTRA_GCC_FLAGS): New + variables holding settings for specific sub-makes. + (FLAGS_TO_PASS, TARGET_FLAGS_TO_PASS, GCC_FLAGS_TO_PASS): Rewrote + in terms of BASE_FLAGS_TO_PASS. + (TARGET_LIBS): New variable listing directories which use + TARGET_FLAGS_TO_PASS. + (subdir_do): Eliminated. + (do-*): New set of targets to replace subdir_do. + (various): All targets which used subdir_do now depend on do-*. + (local-clean): Renamed from do_clean. + (local-distclean): New target, dependency of distclean and + realclean. + (install-info): Don't create directories. Depend on dir.info + rather than calling make recursively. + (install-dir.info): Eliminated. + (install-info-dirs): Create all info directories here. + (dir.info): Depend upon do-install-info. + + * test-build.mk (HOLES): Added false. + +Sat Feb 6 14:05:09 1993 Per Bothner (bothner@rtl.cygnus.com) + + * config.guess: Recognize BSDI and BSDJ (Jolitz 386bsd). + +Thu Feb 4 20:49:18 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in (info): remove dependency on all-texinfo. The + problem was really in texinfo/C, not at this level. + +Thu Feb 4 13:38:41 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (info): Added dependency on all-texinfo (PR 2112). + +Thu Feb 4 01:50:53 1993 John Gilmore (gnu@cygnus.com) + + * Makefile.in (make-gdb.tar.Z): Change BISON to 'bison -y' for + GDB releases. + +Wed Feb 3 17:22:16 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * configure: Include srcdir in message about target of link not + being found. Don't convert `-' to `_' in `with' options being + passed to subdirs. + +Tue Feb 2 18:57:59 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: add uudecode to host_tools + + * Makefile.in: added {all,install}-uudecode targets, added them to + the appropriate lists + +Tue Feb 2 11:45:53 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (all-gcc): Added dependency on all-gas. + + * configure.in (mips-*-*): Build ld and binutils. + +Mon Feb 1 12:35:41 1993 K. Richard Pixley (rich@rtl.cygnus.com) + + * configure: check return code from mkdir, print error message and + exit on failure. + +Sat Jan 30 16:40:28 1993 John Gilmore (gnu@cygnus.com) + + * Makefile.in (make-gdb.tar.Z): New location for texinfo.tex. + +Thu Jan 28 15:09:59 1993 Ian Lance Taylor (ian@cygnus.com) + + * test-build.mk (HOLES): Added tar, cpio and uudecode. + +Wed Jan 27 16:50:32 1993 Jim Wilson (wilson@sphagnum.cygnus.com) + + * config.sub (h8500): Recognize this as a cpu type. + +Sat Jan 23 20:32:01 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure: source directory missing is no longer a warning + + * configure.in: recognize irix[34]* instead of irix[34] + + * Makefile.in: define and pass down X11_LIB + + * config/mh-sco: define X11_LIB to the mess that SCO ODT requires + +Sat Jan 23 13:49:40 1993 Per Bothner (bothner@cygnus.com) + + * guess-systype: Renamed to ... + * config.guess: ... by popular request. + * configure.in, Makefile.in: Update accordingly. + +Thu Jan 21 12:20:55 1993 Per Bothner (bothner@cygnus.com) + + * guess-systype: Patches from John Eaton : + + Add Convex, Cray/Unicos, and Encore/Multimax support. + + Execute ./dummy instead of assuming . is in PATH. + +Tue Jan 19 17:18:06 1993 Per Bothner (bothner@cygnus.com) + + * guess-systype: New shell script. Attempts to guess the + canonical host name of the executing host. + Only a few hosts are supported so far. + * configure: Call guess-systype if no host is specified. + +Tue Jan 19 08:26:07 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (gcc-no-fixedincludes): Made to work with current + gcc Makefile. + + +Fri Jan 15 10:27:02 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (GCC_FLAGS_TO_PASS): New variable. + (all-gcc, install-gcc, subdir_do): Use it. + +Wed Jan 13 17:06:45 1993 Jim Wilson (wilson@sphagnum.cygnus.com) + + * Makefile.in: Rename uninstalled gcc driver from gcc to xgcc. + +Wed Jan 6 20:29:16 1993 Mike Werner (mtw@rtl.cygnus.com) + + * Makefile.in: Removed explicit setting of SUBDIRS. SUBDIRS is now + set exclusively by configure, using configure.in . + +Wed Jan 6 13:44:11 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * test-build.mk: set $PATH for all builds + + * Makefile.in: pass TARGET_FLAGS_TO_PASS for xiberty and libm + +Wed Jan 6 11:02:10 1993 Fred Fish (fnf@cygnus.com) + + * Makefile.in (GCC_FOR_TARGET): Supply a default that matches + the one used in gcc/Makefile.in, so that a null expansion doesn't + override the one needed to build gcc with a native cc. + + +Tue Jan 5 07:55:12 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * configure: Accept -with arguments. + +Sun Jan 3 15:15:09 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * Makefile.in: added h8300sim + +Tue Dec 29 15:06:00 1992 Ian Lance Taylor (ian@cygnus.com) + + * config/mh-sco: Don't override BISON definition. + + * build-all.mk: If canonhost is i386-unknown-sco3.2v4, change it + to i386-sco3.2v4. Set TARGETS and CFLAGS for i386-sco3.2v4. + (all-cygnus, native, build-cygnus): Make + $(canonhost)-stamp-3stage-done, not $(host).... + * test-build.mk (stamp-3stage-compared): Use tail +10c for + i386-sco3.2v4. Added else true to if command. + +Mon Dec 28 12:08:56 1992 Ken Raeburn (raeburn@cygnus.com) + + * config.sub: (from FSF) Sequent uses a BSD-like OS. + +Mon Dec 28 08:32:06 1992 Minh Tran-Le (mtranle@paris.intellicorp.com) + + * configure.in (i[34]86-*-isc*): added; uses mh-sysv. + +Thu Dec 24 17:26:24 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: don't remove binutils from Solaris builds + +Thu Dec 24 14:08:38 1992 david d`zoo' zuhn (zoo@cygnus.com) + + * Makefile.in: get rid of earlier definitions for *clean, + also handle the recursive info rule better + +Thu Dec 24 12:40:21 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (mostlyclean, distclean, realclean): Fix to + do more-or-less the right thing. + +Wed Dec 16 10:25:31 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: Add lines defining CC and CXX, and use CXX rather + than gcc in definitions of CXX_FOR_BUILD and CXX_FOR_TARGET. + +Tue Dec 15 00:34:32 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: change all $(host_cpu)-$(host_vendor)-$(host_os) to + $(host_canonical). + + * configure.in: split the configdirs list into 4 categories (native + v. cross, library v. tool) and handle the cross-only and native- + only in more reasonable (and correct!) way. + +Mon Dec 14 17:04:22 1992 Stu Grossman (grossman at cygnus.com) + + * configure.in (hppa*-*-*): Don't remove bfd and gdb from + configdirs anymore. + +Sun Dec 13 00:37:26 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: extensive cleanup:: removed all of the explicit + clean-* targets, collapsed many wrappers around subdir_do into + one, added additional targets to satisfy standards.texi, deleted + some old targets, some changes for consistency + +Fri Dec 11 20:18:02 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: handle some programs as cross-only, and others as + native only + + * test-build.mk: handle partial holes in a more generic manner + + * Makefile.in: m4 depends on libiberty + +Mon Dec 7 06:43:27 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config/mh-sco: don't default $(CC) to gcc + +Thu Dec 3 21:52:11 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: add m4, textutils, fileutils, sed, shellutils, + time, wdiff, and find to configdirs + + * Makefile.in: all, clean, and install rules for the new programs + added to configure.in + +Mon Nov 30 14:54:34 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: use mh-sun for all *-sun-* hosts + + * config/mh-solaris: rework standard X location to use + $OPENWINHOME, if defined. + + * config/mh-sun: handle X11 include locations + + * config/mh-decstation: define NeedFunctionPrototypes to 0, to + work around dain-bramaged DECwindows include files + +Fri Nov 27 18:35:54 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: define flags for X11 include files and library file + locations, pass them down to the programs that need this info + + * build-all.mk: added a 'native' target, to 3stage the native toolchain + + * config/{mh-hpux,mh-solaris}: define the "standard" locations for + the vendor supplied X11 headers and libraries + +Sun Nov 22 18:59:13 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: start building libg++ for HP-UX targets + +Wed Nov 18 19:33:11 1992 John Gilmore (gnu@cygnus.com) + + * README: Update references to files moved into etc/. + +Sun Nov 15 09:36:08 1992 Fred Fish (fnf@cygnus.com) + + * config.sub (i386sol2, i486sol2): i[34]86-unknown-solaris2. + * configure.in (i[34]86-*-solaris2*): Use config/mh-sysv4. + +Thu Nov 12 08:50:42 1992 Ian Lance Taylor (ian@cygnus.com) + + * configure: accept dash as well as underscore in long option + names for FSF compatibility. + +Wed Nov 11 08:04:37 1992 Ian Lance Taylor (ian@cygnus.com) + + * config.sub: added -sco3.2v4 support from FSF. + +Sun Nov 8 21:14:30 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: expand the section that adds or removes + directories from the list of programs to build, to handle native + vs. cross in addition to host v. native + +Sat Nov 7 18:52:27 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Replace C++ in macro names with CXX. + This is less likely to break ... + +Sat Nov 7 15:16:58 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * test-build.mk: add -w to GNU_MAKE + +Fri Nov 6 23:10:37 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config.sub: remove 'sparc'-->'sparc-sun' default transformation, + add 'sparc' to list of recognized cpus. This needed to make + 'sparc-aout' expand to 'sparc-unknown-aout' instead of 'sparc-sun-aout'. + Delete some redundant ose68 variants. Recognize -wrs as an os, + then changes that into $CPU-wrs-vxworks. + + * configure.in: remove most references to gdbtest, regularize + target based program removal + + * test-build.mk: import from p3 tree (many fixes and changes) + +Fri Nov 6 20:59:00 1992 david d `zoo' zuhn (zoo@cygnus.com) + + * Makefile.in: added rules to handle tcl, tk, and expect + + * configure.in: handle those directories if they exist + +Thu Nov 5 14:35:41 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config.sub: removed bogus hppabsd and hppahpux names, since + "hppa" is not a valid cpu (hppa1.1 or hppa1.0 are, though) + +Thu Oct 29 00:12:41 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: all-gcc now depends on all-binutils. all-libg++ + depends upon all-xiberty + + * Makefile.in: changes from p3, including: + + Thu Oct 8 15:00:17 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (XTRAFLAGS): include newlib directories if + newlib/Makefile exists, rather than if host != target. + + Fri Sep 25 13:41:52 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: added -nostdinc to XTRAFLAGS if we are using gcc + from the same source tree and not building a cross-compiler. This + matters for the libg++ configuration if reconfiguring a tree that + has already been installed. + + Thu Sep 10 10:35:51 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: added -I for newlib/targ-include to XTRAFLAGS, to + pick up the machine and system specific header files. + + * Makefile.in: added AS_FOR_TARGET, passed down in + TARGET_FLAGS_TO_PASS. Added CC_FOR_BUILD, which is intended to be + the C compiler to use to create programs which are run in the + build environment, set it to default to $(CC), and passed it down + in FLAGS_TO_PASS and TARGET_FLAGS_TO_PASS. + + Mon Sep 7 22:34:42 1992 Ian Lance Taylor (ian@cirdan.cygnus.com) + + * Makefile.in: add $(host) = $(target) tests back to *_FOR_TARGET. + We need them for unusual native builds, like systems without + ranlib. + + * configure: also define $(host_canonical) and + $(target_canonical), which are the full, canonical names for the + given host and target + +Sun Nov 1 16:38:17 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Added separate definitions for C++. + +Fri Oct 30 11:37:52 1992 Fred Fish (fnf@cygnus.com) + + * configure.in (configdirs): Add deja-gnu. + +Fri Oct 23 00:39:18 1992 John Gilmore (gnu@cygnus.com) + + * README: Update for configure.texi and gdb-4.7 release. + +Wed Oct 21 21:54:27 1992 John Gilmore (gnu@cygnus.com) + + * Makefile.in: Move "all" target to top of file. + Previously, first target was ".PHONY" which caused BSD4.4 make + to build .PHONY when make was run without arguments. + +Mon Oct 19 01:17:54 1992 John Gilmore (gnu@cygnus.com) + + * Makefile.in: Add COPYING.LIB to GDB releases, now that there's + Library-copylefted code in libiberty. + +Tue Oct 13 01:22:32 1992 John Gilmore (gnu@cygnus.com) + + * config.sub: Replace m68kmote with plain old m68k. + +Fri Oct 9 03:14:24 1992 John Gilmore (gnu@cygnus.com) + + * Makefile.in: Remove space from blank line, avoid Make complaints. + +Thu Oct 8 18:41:45 1992 Ken Raeburn (raeburn@cygnus.com) + + * config.sub: Complain if no argument is given. Added support for + 386bsd as OS and target alias. + +Thu Oct 8 15:07:22 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (XTRAFLAGS): include newlib directories if + newlib/Makefile exists, rather than if host != target. + +Mon Oct 5 03:00:09 1992 Mark Eichin (eichin at tweedledumber.cygnus.com) + + * config.sub: recognize sparclite-wrs-vxworks. + + * Makefile.in (install-xiberty): added *-xiberty make rules (from + p3.) Added clean-xiberty to clean. + +Thu Oct 1 17:59:19 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: use *-*-* instead of nested cases for host and target + +Tue Sep 29 14:11:18 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: added -nostdinc to XTRAFLAGS if we are using gcc + from the same source tree and not building a cross-compiler. This + matters for the libg++ configuration if reconfiguring a tree that + has already been installed. + +Sep 20 08:53:10 1992 Fred Fish (fnf@cygnus.com) + + * config.sub (i486v/i486v4): Merge in from FSF version. + +Fri Sep 18 00:32:00 1992 Mark Eichin (eichin@cygnus.com) + + * configure: only set PWD if it is already set. + +Thu Sep 17 23:05:53 1992 Mark Eichin (eichin@cygnus.com) + + * configure: just set PWD=`pwd` at the top, since Ultrix sh + doesn't have unset and all success paths (and most error paths) + out set it anyway. (Note: should change all uses of ${PWD=`pwd`} + to just ${PWD} to avoid confusion.) + +Tue Sep 15 16:00:54 1992 Ian Lance Taylor (ian@cygnus.com) + + * configure: always set $(tooldir) to $(libdir)/$(target_alias), + even for a native compilation. + +Tue Sep 15 02:22:56 1992 John Gilmore (gnu@cygnus.com) + + Changes to make the gdb.tar.Z rule work better. + + * Makefile.in (GDB_SUPPORT_DIRS): Add opcodes. + (DEVO_SUPPORT): Add configure.texi. + (bfd-ilrt.tar.Z): Remove ancient rule. + +Thu Sep 10 10:43:19 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: added -I for newlib/targ-include to XTRAFLAGS, to + pick up the machine and system specific header files. + + * configure.in, config.sub: added new target m68010-adobe-scout, + with alias of adobe68k. Changed configure.in to check for + -scout before -sco* to avoid a false match. + + * Makefile.in: added AS_FOR_TARGET, passed down in + TARGET_FLAGS_TO_PASS. Added CC_FOR_BUILD, which is intended to be + the C compiler to use to create programs which are run in the + build environment, set it to default to $(CC), and passed it down + in FLAGS_TO_PASS and TARGET_FLAGS_TO_PASS. + +Wed Sep 9 12:21:42 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: added TARGET_FLAGS_TO_PASS, CC_FOR_TARGET, + AR_FOR_TARGET, RANLIB_FOR_TARGET, NM_FOR_TARGET. Pass + TARGET_FLAGS_TO_PASS, which defines CC, AR, RANLIB and NM as the + FOR_TARGET variants, to newlib and libg++. + +Tue Sep 8 17:28:30 1992 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (all-gas, all-gdb): Require all-opcodes to be built + first. + +Wed Sep 2 02:50:05 1992 John Gilmore (gnu@cygnus.com) + + * config.sub: Accept `elf' as an environment. + +Tue Sep 1 15:48:30 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * Makefile.in (all-opcodes): cd into the right directory + +Sun Aug 30 21:12:11 1992 Ian Lance Taylor (ian@cygnus.com) + + * configure: added -program_transform_name option, used as + argument to sed when installing programs. + configure.texi: added documentation for -program_prefix, + -program_suffix and -program_transform_name. + +Thu Aug 27 21:59:44 1992 John Gilmore (gnu@cygnus.com) + + * config.sub: Accept i486 where i386 ok. + +Thu Aug 27 13:04:42 1992 Brendan Kehoe (brendan@rtl.cygnus.com) + + * config.sub: accept we32k + +Mon Aug 24 14:05:14 1992 Ian Lance Taylor (ian@cygnus.com) + + * config.sub, configure.in: accept OSE68000 and OSE68k. + + * Makefile.in: don't create all directories for ``make install''; + let the subdirectories create the ones they need. + +Tue Aug 11 23:13:17 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * COPYING: new file, GPL v2 + +Tue Aug 4 01:12:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: use the new gen-info-dir, which needs a template + argument (which also lives in texinfo) + + * configure.texi, standards.texi: fix INFO-DIR-ENTRY + +Mon Aug 3 15:41:28 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config/mh-solaris: removed the -xs from CFLAGS (let the people + with Sun's C compiler deal with it themselved) + +Mon Aug 3 00:34:17 1992 Fred Fish (fnf@cygnus.com) + + * config.sub (ncr3000): Change i386 to i486. + +Thu Jul 23 00:12:17 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: add install-rcs, install-grep to + install-no-fixedincludes, removed install-bison and install-libgcc + +Tue Jul 21 01:01:50 1992 david d `zoo' zuhn (zoo@cygnus.com) + + * configure.in: grab the HPUX makefile fragment if on HPUX + +Mon Jul 20 11:02:09 1992 D. V. Henkel-Wallace (gumby@cygnus.com) + + * Makefile.in: eradicate bison spoor (ditto libgcc). + configure.in: recognise m68{k,000}-ericsson-OSE. + es1800 is alias for m68k-ericsson-OSE + +Sun Jul 19 17:49:02 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: rearrange the parts that remove programs from + configdirs, based now on HOST==TARGET or by canonical triple. + +Fri Jul 17 22:52:49 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * test-build.mk: recurse explicitly with -f test-build.mk when + appropriate. predicate stage3 and comparison on the existence + of gcc. That is, if gcc isn't around, we aren't three-staging. + On very clean, also remove ...stamp-co. Build in-place before + doing other builds. + +Thu Jul 16 18:33:09 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * Makefile.in, configure.in: add tgas + +Thu Jul 16 16:05:28 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: a number of changes merged in from progressive. + + * configure.in: add libm. + + * .cvsignore: ignore some stuff that comes from test-build.mk. + +Wed Jul 8 00:01:30 1992 Stu Grossman (grossman at cygnus.com) + + * config/mh-solaris: Use -xs when compiling so that Sun-C puts + a symbol-table into the executable. + +Tue Jul 7 00:24:52 1992 Fred Fish (fnf@cygnus.com) + + * config.sub: Add es1800 (m68k-ericsson-es1800). + +Tue Jun 30 20:24:41 1992 D. V. Henkel-Wallace (gumby@cygnus.com) + + * configure: Add program_suffix (parallel to program_prefix) + * Makefile.in: adjust directory-creating script for losing decstation + +Mon Jun 22 23:43:48 1992 Per Bothner (bothner@cygnus.com) + + * configure: Minor $subdir-related fixes. + +Mon Jun 22 18:30:26 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * configure: fix various problems with propogating + makefile_target_frag in subdirs. + * configure.in: config libgcc if its there + +Fri Jun 19 15:19:40 1992 Stu Grossman (grossman at cygnus.com) + + * config.sub: HPPA merge. + +Mon Jun 15 12:31:52 1992 Fred Fish (fnf@cygnus.com) + + * config/mh-ncr3000 (INSTALL): Don't use /usr/ucb/install, + it is broken on ncr 3000's. + +Sun Jun 14 10:29:19 1992 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Replace all-bison with all-byacc in all + dependency lines for other tools (which now use byacc). + +Fri Jun 12 22:21:57 1992 John Gilmore (gnu at cygnus.com) + + * config.sub: Add sun4sol2 => sparc-sun-solaris2. + +Tue Jun 9 17:18:11 1992 Fred Fish (fnf at cygnus.com) + + * config/{mh-ncr3000, mh-sysv4}: Add INSTALL. + +Thu Jun 4 12:07:32 1992 Mark Eichin (eichin@cygnus.com) + + * Makefile.in: make gprof rules similar to byacc rules (instead of + vestigal $(unsubdir) that didn't work...) + +Thu Jun 4 00:37:05 1992 Per Bothner (bothner@rtl.cygnus.com) + + * config.sub: Add support for Linux. + * Makefile.in: Use $(FLAGS_TO_PASS) more consistently + (at least for libg++). + +Tue Jun 02 20:03:00 1992 david d `zoo' zuhn (zoo@cygnus.com) + + * configure.texi: fix doc for the -nfp option to configure + +Tue Jun 2 17:20:52 1992 Michael Tiemann (tiemann@cygnus.com) + + * Makefile.in (all-binutils): ar needs flex, so depend on all-flex. + +Sun May 31 15:04:08 1992 Mark Eichin (eichin at cygnus.com) + + * config.sub: changed [^-]+ to [^-][^-]* so that it works under + Sun sed. (BSD 4.3 sed doesn't handle [^-]+ either.) + * configure.in: added solaris* host_makefile_frag hook. + +Sun May 31 01:10:34 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config.sub: changed recognition of m68000 so that various + m68k types can be specified via m680[01234]0 + +Sat May 30 21:01:06 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config.sub (basic_machine): fix sed so that '-foo' isn't + completely substituted out while .+'-foo' loses the '-foo' + +Wed May 27 23:18:52 1992 Michael Tiemann (tiemann@rtl.cygnus.com) + + * config.sub ($os): Add -aout. + +Fri May 22 14:00:02 1992 Per Bothner (bothner@cygnus.com) + + * configure: If host_makefile_frag is absolute, don't + prefix ${invsubdir} (relevant to libg++ auto-configure). + +Thu May 21 18:00:09 1992 Michael Tiemann (tiemann@rtl.cygnus.com) + + * Makefile.in (tooldir): Define it. + (all-ld): Depend on all-flex. + +Sun May 10 21:45:59 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (check): Fix libg++ special case. + +Fri May 8 08:31:41 1992 K. Richard Pixley (rich@cygnus.com) + + * configure: do not bury `pwd` into config.status, thus do fewer + pwd's. + + * configure: print the "Building in" message only when building in + other than "." AND verbose. + + * configure: remove -s, rework -v to better accomodate guested + configures. + + * standards.texi: updated to 3 may, fixed librid <-> libdir typo. + +Fri May 1 18:00:50 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: macroize flags passed on recursion. remove + fileutils. + +Thu Apr 30 08:56:20 1992 K. Richard Pixley (rich@cygnus.com) + + * configure: get makesrcdir right for subdirs deeper than 1. + + * Makefile.in: pass INSTALL, INSTALL_DATA, INSTALL_PROGRAM on + install. + +Fri Apr 24 15:51:51 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: don't print subdir_do or recursion lines. + +Fri Apr 24 15:22:04 1992 K. Richard Pixley (rich@cygnus.com) + + * standards.texi: added menu item. + + * Makefile.in: build and install standards.info. + + * standards.texi: new file. + +Wed Apr 22 18:06:55 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * configure: test for and move config.status pieces from + ${subdir}/. + +Wed Apr 22 14:38:34 1992 Fred Fish (fnf@cygnus.com) + + * config/mh-delta88, config/mh-ncr3000: Replace MINUS_G with + CFLAGS per new configuration strategy. + * configure: Test for existance of files before trying to mv + them, to avoid numerous non-existance messages. + +Tue Apr 21 12:31:33 1992 K. Richard Pixley (rich@cygnus.com) + + * configure: correct final line of config.status. + + * configure: patch from eggert. Avoids a protection problem if + the original Makefile.in is read only. + + * configure: use move-if-change from gcc to create config.status. + Some makefiles depend on config.status to tell if a directory + has been reconfigured for a different host. This change + prevents those directories from remaking everything in the case + where the reconfig was only intended to rebuild a Makefile. + + * configure: test for config.sub with "config.sub sun4" rather + than "config.sub ${host_alias}". Otherwise we can't tell a bad + host alias from a missing config.sub. + +Mon Apr 20 18:16:36 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: explicitly pass CFLAGS on recursion. no longer pass + MINUS_G (this can be done with CFLAGS). Default CFLAGS to -g. + +Fri Apr 17 18:27:51 1992 Per Bothner (bothner@cygnus.com) + + * configure: mkdir ${subdir} as needed. + +Wed Apr 15 17:37:22 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in,configure.in: added autoconf. + +Wed Apr 15 17:27:34 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: no longer pass against on recursion. + + * Makefile.in: added .NOEXPORT: so that stray makefile_frag + definitions are not inherited. + + * configure: correct makesrcdir when subdir is . + +Tue Apr 14 11:56:09 1992 Per Bothner (bothner@cygnus.com) + + * configure: Add support for 'subdirs' variable, which is + like 'configdirs', except that configure doesn't re-invoke + itself for subdirs, it just creates a Makefile for each subdir. + * configure.texi: Document subdirs. + +Mon Apr 13 18:50:16 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: added flex to configdirs + +Mon Apr 13 18:43:55 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: remove clean-stamps from clean. + +Sat Apr 11 03:52:03 1992 John Gilmore (gnu at cygnus.com) + + * configure.in: Add gdbtest to configdirs. + +Fri Apr 10 23:11:49 1992 Fred Fish (fnf@cygnus.com) + + * Makefile.in (MINUS_G): Add macro, default to -g, pass on + to recursive makes. + * configure.in: Recognize new ncr3000 config. + +Wed Apr 8 23:08:12 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in, configure.in: removed references to gdbm. + +Tue Apr 7 16:48:20 1992 Per Bothner (bothner@cygnus.com) + + * config.sub: Don't canonicalize os value + newsos* to bsd (readline needs to check for newsos). + (This fix was earlier made Jan 31, but got re-broken.) + +Mon Apr 6 14:34:08 1992 Stu Grossman (grossman at cygnus.com) + + * configure.in: sco is an os, not a vendor! + + * configure: Quote $( better. Keep various shells happy. + +Tue Mar 31 16:32:57 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: eliminate stamp-files. + +Mon Mar 30 22:20:23 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: add send_pr. remove "force" from .stmp-gprof rule. + Supress echoing of all the "if [ -d ... $(MAKE)" lines. + +Wed Mar 25 15:20:04 1992 Stu Grossman (grossman@cygnus.com) + + * config.sub: fix iris/iris3. + +Wed Mar 25 10:34:19 1992 K. Richard Pixley (rich@cygnus.com) + + * configure: re-add -rm. + +Tue Mar 24 23:50:16 1992 K. Richard Pixley (rich@cygnus.com) + + * Maskefile.in: add .stmp-rcs to all. + + * configure.in: remove gas from rs6000 build, use aix host fragment. + +Mon Mar 23 19:43:35 1992 K. Richard Pixley (rich@cygnus.com) + + * configure: pass down site_option during recursion. + +Thu Mar 19 16:49:36 1992 Stu Grossman (grossman at cygnus.com) + + * Makefile.in (all.cross): Add .stmp-bfd .stmp-readline. + +Wed Mar 18 15:29:33 1992 Mike Stump (mrs@cygnus.com) + + * configure: Change exec_prefix so that it really defaults to prefix. + +Sat Mar 14 17:20:38 1992 Fred Fish (fnf@cygnus.com) + + * Makefile.in, configure.in: Add support for mmalloc library. + +Fri Mar 13 18:44:18 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: add stmp dependencies for a few more things. + +Thu Mar 12 04:56:24 1992 K. Richard Pixley (rich@cygnus.com) + + * configure: adjusted error message on objdir/srcdir configure + collision, per john's suggestion. + + * Makefile.in: add libiberty stmp to all and all.cross. + +Wed Mar 11 02:07:52 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: remove force dependencies, add grep to all. + +Tue Mar 10 21:49:18 1992 K. Richard Pixley (rich@mars.cygnus.com) + + * Makefile.in: drop flex. make stamp files work. + + * configure: added test for conflicting configuration in srcdir, + remove trailing slashes from srcdir. Otherwise emacs gdb mode + gets cranky. use relative paths for configure and srcdir + whenever possible. Send some error messages to stderr that were + going to stdout. + +Tue Mar 10 18:01:55 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Fix libg++ rule to check for gcc directory + before using gcc/gcc. Also pass XTRAFLAGS. + +Thu Mar 5 21:45:07 1992 K. Richard Pixley (rich@sendai) + + * Makefile.in: added stmp-files so that directories aren't polled + when they are already built. + + * configure.texi: fixed a node pointer problem. + +Thu Mar 5 12:05:58 1992 Stu Grossman (grossman at cygnus.com) + + * config.sub configure.in config/mh-irix4 gdb/configure.in + gdb/mips-tdep.c gdb/mipsread.c gdb/procfs.c gdb/signame.h + gdb/tm-irix3.h gdb/tm-mips.h gdb/xm-irix4.h gdb/config/mt-irix3 + gdb/config/mh-irix4 texinfo/configure.in: Port to SGI Irix-4.x. + +Wed Mar 4 02:57:46 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * configure: -recurring becomes -silent. corrected help message + for -site= option. + + * Makefile.in: mkdir $(exec_prefix) and $(tooldir). + +Tue Mar 3 14:51:21 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * configure: when building Makefile for crosses, replace + tooldir and program_prefix. default srcdir from location of + config.sub. remove "for host in hosts" and "for target in + targets" loops. + +Wed Feb 26 19:48:25 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: Do not pass bindir or mandir to cvs. + +Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in, configure.in: removed traces of namesubdir, + -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced + copyrights to '92, changed some from Cygnus to FSF. + + * configure.texi: remove most references to multiple hosts, + multiple targets, subdirs, etc. + + * configure.man: removed rcsid. reference config.sub not + config.subr. + + * Makefile.in: mkdir $(infodir) on install-info. + +Wed Feb 19 15:41:13 1992 John Gilmore (gnu at cygnus.com) + + * configure.texi: Explain better about .gdbinit and about + the environment that configure.in sections run in. + +Fri Feb 7 07:55:00 1992 John Gilmore (gnu at cygnus.com) + + * configure.in: Ultrix is only a decstation if it's a MIPS. + +Fri Jan 31 21:54:51 1992 John Gilmore (gnu at cygnus.com) + + * README: DOC.configure => cfg-paper.texi. + +Fri Jan 31 21:48:18 1992 Stu Grossman (grossman at cygnus.com) + + * config.sub (near case $os): Don't convert newsos* to bsd! + +Fri Jan 31 02:27:32 1992 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Reinstall change from gdb-4.3 that reduces + the number of copies of COPYING that go into the GDB tar file. + +Thu Jan 30 16:17:30 1992 Stu Grossman (grossman at cygnus.com) + + * bfd/configure.in, config/mh-sco, gdb/config/mh-i386sco, + gdb/config/mt-i386v32, gdb/configure.in, readline/configure.in: + Fix SCO configuration stuff. + +Tue Jan 28 23:51:07 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in: For libg++, make sure the -I pointing + to the gcc directory goes *after* all the libg++-local -I flags. + Also, move just-gcc dependency from just-libg++ to all-libg++. + +Tue Jan 28 12:56:24 1992 Stu Grossman (grossman at cygnus.com) + + * configure: Change -x to -f to keep Ultrix /bin/test happy. + +Sat Jan 18 17:45:11 1992 Stu Grossman (grossman at cygnus.com) + + * Makefile.in (make-gdb.tar.Z): Remove texinfo targets. + +Sat Jan 18 17:03:21 1992 Fred Fish (fnf at cygnus.com) + + * config.sub: Add stratus configuration frags. Also + submitted to FSF. + +Sat Jan 18 15:35:29 1992 Stu Grossman (grossman at cygnus.com) + + * Makefile.in (DEV_SUPPORT): add configure.man. + + * config.sub(Decode manufacturer-specific): add -none*. + +Fri Jan 17 17:58:05 1992 Stu Grossman (grossman at cygnus.com) + + * Makefile.in: remove form feeds to make Sun's make happy. + (DEVO_SUPPORT): DOC.configure => cfg-paper.texi. + +Sat Jan 4 16:11:44 1992 John Gilmore (gnu at cygnus.com) + + * Makefile.in (AR_FLAGS): Make quieter. + +Thu Jan 2 22:57:12 1992 John Gilmore (gnu at cygnus.com) + + * configure.in: Add libg++. + * configure: When verbose, don't output the command line at each + level; it will be unremarkably the same as the previous version, + which will be the same as what the user typed. + +Fri Dec 27 16:26:47 1991 K. Richard Pixley (rich at cygnus.com) + + * configure.in, Makefile.in: fix clean-info, add flex. add + fileutils. + + * configure: be less sensitive to spaces in Makefile.in. Do not + look for sources in "..". Doing so breaks subdirectories that + might have their own configure. If a subdir has it's own + configure script, use it. + +Thu Dec 26 16:30:26 1991 K. Richard Pixley (rich at cygnus.com) + + * cfg-paper.texi: some changes suggested by rms. + +Thu Dec 26 10:13:36 1991 Fred Fish (fnf at cygnus.com) + + * config.sub: Merge in some small additions from the FSF version, + taken from the gcc distribution, to bring the Cygnus and FSF + versions into closer sync. + +Fri Dec 20 11:34:18 1991 Fred Fish (fnf at cygnus.com) + + * configure.in: Changed svr4 references to sysv4. + +Thu Dec 19 15:54:29 1991 K. Richard Pixley (rich at cygnus.com) + + * configure: added -V for version number option. + +Wed Dec 18 15:39:34 1991 K. Richard Pixley (rich at cygnus.com) + + * DOC.configure, cfg-paper.texi: revised, updated, and texinfo'd. + renamed from DOC.configure to cfg-paper.texi. + +Mon Dec 16 23:05:19 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * configure, config.subr, config.sub: config.subr is now + config.sub again. + +Fri Dec 13 01:17:06 1991 K. Richard Pixley (rich at cygnus.com) + + * configure.texi: new file, in progress. + + * Makefile.in: build info file and install the man page for + configure. + + * configure.man: new file, first cut. + + * configure: find config.subr again now that configuration "none" + has gone. removed all traces of the -ansi option. removed all + traces of the -languages option. + + * config.subr: resync from rms. + +Wed Dec 11 22:25:20 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * configure, config.sub, config.subr: merge config.sub into + config.subr, call the result config.subr, remove config.sub, use + config.subr. + + * Makefile.in: revised install for dir.info. + +Tue Dec 10 00:04:35 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * configure.in: add decstation host makefile frag. + + * Makefile.in: BISON now bison -y again. also install-gcc on + install. clean-gdbm on clean. infodir belongs in datadir. + Make directories for info install. Build dir.info here then + install it. + +Mon Dec 9 16:48:33 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: fix for bad directory tests. + +Sat Dec 7 00:17:01 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * configure: \{1,2\} appears to be a sysv'ism. Use a different + regexp. -srcdir relative was being handled incorrectly. + + * Makefile.in: unwrapped some for loops so that parallel makes + work again and so one can focus one's attention on a particular + package. + +Fri Dec 6 00:22:08 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * configure: added PWD as a stand in for `pwd` (for speed). use + elif wherever possible. make -srcdir work without -objdir. + -objdir= commented out. + +Thu Dec 5 22:46:52 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * configure: +options become --options. -subdirs commented out. + added -host, -datadir. Renamed -destdir to -prefix. Comment in + Makefile now at top of generated Makefile. Removed cvs log + entries. added -srcdir. create .gdbinit only if there is one + in ${srcdir}. + + * Makefile.in: idestdir and ddestdir go away. Added copyrights + and shift gpl to v2. Added ChangeLog if it didn't exist. docdir + and mandir now keyed off datadir by default. + +Fri Nov 22 07:38:11 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Freshly created ChangeLog. + + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 76 +version-control: never +End: diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 000000000000..af7fb16c2764 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,1608 @@ +# +# Makefile for directory with subdirs to build. +# Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation +# +# This file 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. +# + +srcdir = . + +prefix = /usr/local + +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +tooldir = $(exec_prefix)/$(target) + +program_transform_name = + +datadir = $(prefix)/share +mandir = $(prefix)/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +man3dir = $(mandir)/man3 +man4dir = $(mandir)/man4 +man5dir = $(mandir)/man5 +man6dir = $(mandir)/man6 +man7dir = $(mandir)/man7 +man8dir = $(mandir)/man8 +man9dir = $(mandir)/man9 +infodir = $(prefix)/info +includedir = $(prefix)/include +GDB_NLM_DEPS = + +SHELL = /bin/sh + +# INSTALL_PROGRAM_ARGS is changed by configure.in to use -x for a +# cygwin32 host. +INSTALL_PROGRAM_ARGS = + +INSTALL = $(SHELL) $$s/install-sh -c +INSTALL_PROGRAM = $(INSTALL) $(INSTALL_PROGRAM_ARGS) +INSTALL_SCRIPT = $(INSTALL) +INSTALL_DATA = $(INSTALL) -m 644 + +INSTALL_DOSREL = install-dosrel-fake + +AS = as +AR = ar +AR_FLAGS = rc +CC = cc + +# Special variables passed down in EXTRA_GCC_FLAGS. They are defined +# here so that they can be overridden by Makefile fragments. +HOST_CC = $(CC_FOR_BUILD) +HOST_PREFIX = +HOST_PREFIX_1 = loser- + +# These flag values are normally overridden by the configure script. +CFLAGS = -g +CXXFLAGS = -g -O2 + +LIBCFLAGS = $(CFLAGS) +CFLAGS_FOR_TARGET = $(CFLAGS) +LDFLAGS_FOR_TARGET = +LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET) +PICFLAG = +PICFLAG_FOR_TARGET = + +CXX = c++ + +# Use -O2 to stress test the compiler. +LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates +CXXFLAGS_FOR_TARGET = $(CXXFLAGS) +LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates + +RANLIB = ranlib + +DLLTOOL = dlltool +WINDRES = windres + +NM = nm + +LD = ld + +# Not plain GZIP, since gzip looks there for extra command-line options. +GZIPPROG = gzip + +# These values are substituted by configure. +DEFAULT_YACC = yacc +DEFAULT_LEX = lex + +BISON = `if [ -f $$r/bison/bison ] ; then \ + echo $$r/bison/bison -L $$s/bison/ ; \ + else \ + echo bison ; \ + fi` + +YACC = `if [ -f $$r/bison/bison ] ; then \ + echo $$r/bison/bison -y -L $$s/bison/ ; \ + elif [ -f $$r/byacc/byacc ] ; then \ + echo $$r/byacc/byacc ; \ + else \ + echo ${DEFAULT_YACC} ; \ + fi` + +LEX = `if [ -f $$r/flex/flex ] ; \ + then echo $$r/flex/flex ; \ + else echo ${DEFAULT_LEX} ; fi` + +M4 = `if [ -f $$r/m4/m4 ] ; \ + then echo $$r/m4/m4 ; \ + else echo m4 ; fi` + +MAKEINFO = `if [ -f $$r/texinfo/makeinfo/Makefile ] ; \ + then echo $$r/texinfo/makeinfo/makeinfo ; \ + else echo makeinfo ; fi` + +# This just becomes part of the MAKEINFO definition passed down to +# sub-makes. It lets flags be given on the command line while still +# using the makeinfo from the object tree. +MAKEINFOFLAGS = + +EXPECT = `if [ -f $$r/expect/expect ] ; \ + then echo $$r/expect/expect ; \ + else echo expect ; fi` + +RUNTEST = `if [ -f $$s/dejagnu/runtest ] ; \ + then echo $$s/dejagnu/runtest ; \ + else echo runtest ; fi` + + +# compilers to use to create programs which must be run in the build +# environment. +CC_FOR_BUILD = $(CC) +CXX_FOR_BUILD = $(CXX) + +SUBDIRS = "this is set via configure, don't edit this" +OTHERS = + +# This is set by the configure script to the list of directories which +# should be built using the target tools. +TARGET_CONFIGDIRS = libiberty libgloss newlib libio librx libstdc++ libg++ winsup + +# Target libraries are put under this directory: +# Changed by configure to $(target_alias) if cross. +TARGET_SUBDIR = . + +# This is set by the configure script to the arguments passed to configure. +CONFIG_ARGUMENTS = + +# This is set by configure to REALLY_SET_LIB_PATH if --enable-shared +# was used. +SET_LIB_PATH = + +# This is the name of the environment variable used for the path to +# the libraries. This may be changed by configure.in. +RPATH_ENVVAR = LD_LIBRARY_PATH + +# configure.in sets SET_LIB_PATH to this if --enable-shared was used. +REALLY_SET_LIB_PATH = \ + $(RPATH_ENVVAR)=$$r/bfd:$$r/opcodes:$$$(RPATH_ENVVAR); \ + export $(RPATH_ENVVAR); + +ALL = all.normal +INSTALL_TARGET = installdirs \ + $(INSTALL_MODULES) \ + $(INSTALL_TARGET_MODULES) \ + $(INSTALL_X11_MODULES) \ + install-gcc \ + $(INSTALL_DOSREL) + + +CC_FOR_TARGET = ` \ + if [ -f $$r/gcc/xgcc ] ; then \ + if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \ + if [ -f $$r/$(TARGET_SUBDIR)/winsup/Makefile ] ; then \ + echo $$r/gcc/xgcc -B$$r/gcc/ -B$$r/newlib/ -L$$r/$(TARGET_SUBDIR)/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + else \ + echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + fi; \ + else \ + echo $$r/gcc/xgcc -B$$r/gcc/; \ + fi; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(CC); \ + else \ + t='$(program_transform_name)'; echo gcc | sed -e 's/x/x/' $$t; \ + fi; \ + fi` + +# If CC_FOR_TARGET is not overriden on the command line, then this +# variable is passed down to the gcc Makefile, where it is used to +# build libgcc2.a. We define it here so that it can itself be +# overridden on the command line. +GCC_FOR_TARGET = $$r/gcc/xgcc -B$$r/gcc/ + + +CXX_FOR_TARGET = ` \ + if [ -f $$r/gcc/xgcc ] ; then \ + if [ -f $$r/$(TARGET_SUBDIR)/newlib/Makefile ] ; then \ + if [ -f $$r/$(TARGET_SUBDIR)/winsup/Makefile ] ; then \ + echo $$r/gcc/xgcc -B$$r/gcc/ -B$$r/newlib/ -L$$r/winsup -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + else \ + echo $$r/gcc/xgcc -B$$r/gcc/ -idirafter $$r/$(TARGET_SUBDIR)/newlib/targ-include -idirafter $$s/newlib/libc/include -nostdinc; \ + fi; \ + else \ + echo $$r/gcc/xgcc -B$$r/gcc/; \ + fi; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(CXX); \ + else \ + t='$(program_transform_name)'; echo c++ | sed -e 's/x/x/' $$t; \ + fi; \ + fi` + +AS_FOR_TARGET = ` \ + if [ -f $$r/gas/as-new ] ; then \ + echo $$r/gas/as-new ; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(AS); \ + else \ + t='$(program_transform_name)'; echo as | sed -e 's/x/x/' $$t ; \ + fi; \ + fi` + +LD_FOR_TARGET = ` \ + if [ -f $$r/ld/ld-new ] ; then \ + echo $$r/ld/ld-new ; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(LD); \ + else \ + t='$(program_transform_name)'; echo ld | sed -e 's/x/x/' $$t ; \ + fi; \ + fi` + +DLLTOOL_FOR_TARGET = ` \ + if [ -f $$r/binutils/dlltool ] ; then \ + echo $$r/binutils/dlltool ; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(DLLTOOL); \ + else \ + t='$(program_transform_name)'; echo dlltool | sed -e 's/x/x/' $$t ; \ + fi; \ + fi` + +WINDRES_FOR_TARGET = ` \ + if [ -f $$r/binutils/windres ] ; then \ + echo $$r/binutils/windres ; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(WINDRES); \ + else \ + t='$(program_transform_name)'; echo windres | sed -e 's/x/x/' $$t ; \ + fi; \ + fi` + +AR_FOR_TARGET = ` \ + if [ -f $$r/binutils/ar ] ; then \ + echo $$r/binutils/ar ; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(AR); \ + else \ + t='$(program_transform_name)'; echo ar | sed -e 's/x/x/' $$t ; \ + fi; \ + fi` + +RANLIB_FOR_TARGET = ` \ + if [ -f $$r/binutils/ranlib ] ; then \ + echo $$r/binutils/ranlib ; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(RANLIB); \ + else \ + t='$(program_transform_name)'; echo ranlib | sed -e 's/x/x/' $$t ; \ + fi; \ + fi` + +NM_FOR_TARGET = ` \ + if [ -f $$r/binutils/nm-new ] ; then \ + echo $$r/binutils/nm-new ; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + echo $(NM); \ + else \ + t='$(program_transform_name)'; echo nm | sed -e 's/x/x/' $$t ; \ + fi; \ + fi` + +#### host and target specific makefile fragments come in here. +### + +# Flags to pass down to all sub-makes. +# Please keep these in alphabetical order. +BASE_FLAGS_TO_PASS = \ + "AR_FLAGS=$(AR_FLAGS)" \ + "AR_FOR_TARGET=$(AR_FOR_TARGET)" \ + "AS_FOR_TARGET=$(AS_FOR_TARGET)" \ + "BISON=$(BISON)" \ + "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ + "CC_FOR_TARGET=$(CC_FOR_TARGET)" \ + "CFLAGS=$(CFLAGS)" \ + "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \ + "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \ + "CXXFLAGS=$(CXXFLAGS)" \ + "CXXFLAGS_FOR_TARGET=$(CXXFLAGS_FOR_TARGET)" \ + "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \ + "DLLTOOL_FOR_TARGET=$(DLLTOOL_FOR_TARGET)" \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LEX=$(LEX)" \ + "LD_FOR_TARGET=$(LD_FOR_TARGET)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ + "LIBCXXFLAGS=$(LIBCXXFLAGS)" \ + "LIBCXXFLAGS_FOR_TARGET=$(LIBCXXFLAGS_FOR_TARGET)" \ + "M4=$(M4)" \ + "MAKE=$(MAKE)" \ + "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ + "NM_FOR_TARGET=$(NM_FOR_TARGET)" \ + "PICFLAG=$(PICFLAG)" \ + "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \ + "RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \ + "SHELL=$(SHELL)" \ + "EXPECT=$(EXPECT)" \ + "RUNTEST=$(RUNTEST)" \ + "RUNTESTFLAGS=$(RUNTESTFLAGS)" \ + "WINDRES_FOR_TARGET=$(WINDRES_FOR_TARGET)" \ + "YACC=$(YACC)" \ + "exec_prefix=$(exec_prefix)" \ + "prefix=$(prefix)" \ + "tooldir=$(tooldir)" + +# Flags to pass down to most sub-makes, in which we're building with +# the host environment. +# If any variables are added here, they must be added to do-*, below. +EXTRA_HOST_FLAGS = \ + 'AR=$(AR)' \ + 'AS=$(AS)' \ + 'CC=$(CC)' \ + 'CXX=$(CXX)' \ + 'DLLTOOL=$(DLLTOOL)' \ + 'LD=$(LD)' \ + 'NM=$(NM)' \ + 'RANLIB=$(RANLIB)' \ + 'WINDRES=$(WINDRES)' + +FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) + +# Flags that are concerned with the location of the X11 include files +# and library files +# +# NOTE: until the top-level is getting the values via autoconf, it only +# causes problems to have this top-level Makefile overriding the autoconf-set +# values in child directories. Only variables that don't conflict with +# autoconf'ed ones should be passed by X11_FLAGS_TO_PASS for now. +# +X11_FLAGS_TO_PASS = \ + 'X11_EXTRA_CFLAGS=$(X11_EXTRA_CFLAGS)' \ + 'X11_EXTRA_LIBS=$(X11_EXTRA_LIBS)' + +# Flags to pass down to makes which are built with the target environment. +# The double $ decreases the length of the command line; the variables +# are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them. +# If any variables are added here, they must be added to do-*, below. +EXTRA_TARGET_FLAGS = \ + 'AR=$$(AR_FOR_TARGET)' \ + 'AS=$$(AS_FOR_TARGET)' \ + 'CC=$$(CC_FOR_TARGET)' \ + 'CFLAGS=$$(CFLAGS_FOR_TARGET)' \ + 'CXX=$$(CXX_FOR_TARGET)' \ + 'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \ + 'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \ + 'LD=$$(LD_FOR_TARGET)' \ + 'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \ + 'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \ + 'NM=$$(NM_FOR_TARGET)' \ + 'PICFLAG=$$(PICFLAG_FOR_TARGET)' \ + 'RANLIB=$$(RANLIB_FOR_TARGET)' \ + 'WINDRES=$$(WINDRES_FOR_TARGET)' + +TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) + +# Flags to pass down to gcc. gcc builds a library, libgcc.a, so it +# unfortunately needs the native compiler and the target ar and +# ranlib. +# If any variables are added here, they must be added to do-*, below. +# The HOST_* variables are a special case, which are used for the gcc +# cross-building scheme. +EXTRA_GCC_FLAGS = \ + 'AR=$$(AR_FOR_TARGET)' \ + 'AS=$(AS)' \ + 'CC=$(CC)' \ + 'CXX=$(CXX)' \ + 'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \ + 'HOST_CC=$(CC_FOR_BUILD)' \ + 'HOST_PREFIX=$(HOST_PREFIX)' \ + 'HOST_PREFIX_1=$(HOST_PREFIX_1)' \ + 'NM=$(NM)' \ + 'RANLIB=$$(RANLIB_FOR_TARGET)' \ + 'WINDRES=$$(WINDRES_FOR_TARGET)' \ + "GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \ + "`if test x'$(LANGUAGES)' != x; then echo 'LANGUAGES=$(LANGUAGES)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(STMP_FIXPROTO)' != x; then echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(LIMITS_H_TEST)' != x; then echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(LIBGCC1_TEST)' != x; then echo 'LIBGCC1_TEST=$(LIBGCC1_TEST)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(LIBGCC2_CFLAGS)' != x; then echo 'LIBGCC2_CFLAGS=$(LIBGCC2_CFLAGS)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(LIBGCC2_DEBUG_CFLAGS)' != x; then echo 'LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(LIBGCC2_INCLUDES)' != x; then echo 'LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(ENQUIRE)' != x; then echo 'ENQUIRE=$(ENQUIRE)'; else echo 'XFOO=bar'; fi`" \ + "`if test x'$(BOOT_CFLAGS)' != x; then echo 'BOOT_CFLAGS=$(BOOT_CFLAGS)'; else echo 'XFOO=bar'; fi`" + +GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) + +# This is a list of the targets for all of the modules which are compiled +# using $(FLAGS_TO_PASS). +ALL_MODULES = \ + all-apache \ + all-autoconf \ + all-automake \ + all-bash \ + all-bfd \ + all-binutils \ + all-bison \ + all-byacc \ + all-cvs \ + all-db \ + all-dejagnu \ + all-diff \ + all-dosutils \ + all-etc \ + all-fileutils \ + all-findutils \ + all-find \ + all-flex \ + all-gas \ + all-gawk \ + all-gnuserv \ + all-gprof \ + all-grep \ + all-grez \ + all-gzip \ + all-hello \ + all-indent \ + all-inet \ + all-ispell \ + all-itcl \ + all-ld \ + all-libiberty \ + all-m4 \ + all-make \ + all-mmalloc \ + all-opcodes \ + all-patch \ + all-perl \ + all-prms \ + all-rcs \ + all-readline \ + all-release \ + all-recode \ + all-sed \ + all-send-pr \ + all-shellutils \ + all-sim \ + all-sn \ + all-tar \ + all-tcl \ + all-texinfo \ + all-textutils \ + all-tgas \ + all-time \ + all-uudecode \ + all-wdiff + +# This is a list of the check targets for all of the modules which are +# compiled using $(FLAGS_TO_PASS). +# +# The list is in two parts. The first lists those tools which +# are tested as part of the host's native tool-chain, and not +# tested in a cross configuration. +NATIVE_CHECK_MODULES = \ + check-bison \ + check-byacc \ + check-flex + +CROSS_CHECK_MODULES = \ + check-apache \ + check-autoconf \ + check-automake \ + check-bash \ + check-bfd \ + check-binutils \ + check-cvs \ + check-db \ + check-dejagnu \ + check-diff \ + check-etc \ + check-fileutils \ + check-findutils \ + check-find \ + check-gas \ + check-gawk \ + check-gnuserv \ + check-gprof \ + check-grep \ + check-gzip \ + check-hello \ + check-indent \ + check-inet \ + check-ispell \ + check-itcl \ + check-ld \ + check-libiberty \ + check-m4 \ + check-make \ + check-mmcheckoc \ + check-opcodes \ + check-patch \ + check-perl \ + check-prms \ + check-rcs \ + check-readline \ + check-recode \ + check-sed \ + check-send-pr \ + check-shellutils \ + check-sn \ + check-sim \ + check-tar \ + check-tcl \ + check-texinfo \ + check-textutils \ + check-tgas \ + check-time \ + check-uudecode \ + check-wdiff + +CHECK_MODULES=$(NATIVE_CHECK_MODULES) $(CROSS_CHECK_MODULES) + +# This is a list of the install targets for all of the modules which are +# compiled using $(FLAGS_TO_PASS). +# We put install-opcodes before install-binutils because the installed +# binutils might be on PATH, and they might need the shared opcodes +# library. +INSTALL_MODULES = \ + install-apache \ + install-autoconf \ + install-automake \ + install-bash \ + install-bfd \ + install-opcodes \ + install-binutils \ + install-bison \ + install-byacc \ + install-cvs \ + install-db \ + install-dejagnu \ + install-diff \ + install-dosutils \ + install-etc \ + install-fileutils \ + install-findutils \ + install-find \ + install-flex \ + install-gas \ + install-gawk \ + install-gnuserv \ + install-gprof \ + install-grep \ + install-grez \ + install-gzip \ + install-hello \ + install-indent \ + install-inet \ + install-ispell \ + install-itcl \ + install-ld \ + install-libiberty \ + install-m4 \ + install-make \ + install-mmalloc \ + install-patch \ + install-perl \ + install-prms \ + install-rcs \ + install-readline \ + install-recode \ + install-sed \ + install-send-pr \ + install-shellutils \ + install-sim \ + install-sn \ + install-tar \ + install-tcl \ + install-texinfo \ + install-textutils \ + install-tgas \ + install-time \ + install-uudecode \ + install-wdiff + +# This is a list of the targets for all of the modules which are compiled +# using $(X11_FLAGS_TO_PASS). +ALL_X11_MODULES = \ + all-emacs \ + all-emacs19 \ + all-gdb \ + all-expect \ + all-gash \ + all-guile \ + all-tclX \ + all-tk \ + all-tix + +# This is a list of the check targets for all of the modules which are +# compiled using $(X11_FLAGS_TO_PASS). +CHECK_X11_MODULES = \ + check-emacs \ + check-gdb \ + check-guile \ + check-expect \ + check-gash \ + check-tclX \ + check-tk \ + check-tix + +# This is a list of the install targets for all the modules which are +# compiled using $(X11_FLAGS_TO_PASS). +INSTALL_X11_MODULES = \ + install-emacs \ + install-emacs19 \ + install-gdb \ + install-guile \ + install-expect \ + install-gash \ + install-tclX \ + install-tk \ + install-tix + +# This is a list of the targets for all of the modules which are compiled +# using $(TARGET_FLAGS_TO_PASS). +ALL_TARGET_MODULES = \ + all-target-libio \ + all-target-libstdc++ \ + all-target-librx \ + all-target-libg++ \ + all-target-newlib \ + all-target-winsup \ + all-target-libgloss \ + all-target-libiberty \ + all-target-gperf \ + all-target-examples + +# This is a list of the configure targets for all of the modules which +# are compiled using the target tools. +CONFIGURE_TARGET_MODULES = \ + configure-target-libio \ + configure-target-libstdc++ \ + configure-target-librx \ + configure-target-libg++ \ + configure-target-newlib \ + configure-target-winsup \ + configure-target-libgloss \ + configure-target-libiberty \ + configure-target-gperf \ + configure-target-examples + +# This is a list of the check targets for all of the modules which are +# compiled using $(TARGET_FLAGS_TO_PASS). +CHECK_TARGET_MODULES = \ + check-target-libio \ + check-target-libstdc++ \ + check-target-libg++ \ + check-target-newlib \ + check-target-winsup \ + check-target-libiberty \ + check-target-gperf + +# This is a list of the install targets for all of the modules which are +# compiled using $(TARGET_FLAGS_TO_PASS). +INSTALL_TARGET_MODULES = \ + install-target-libio \ + install-target-libstdc++ \ + install-target-libg++ \ + install-target-newlib \ + install-target-winsup \ + install-target-libgloss \ + install-target-libiberty \ + install-target-gperf + +# This is a list of the targets for which we can do a clean-{target}. +CLEAN_MODULES = \ + clean-apache \ + clean-autoconf \ + clean-automake \ + clean-bash \ + clean-bfd \ + clean-binutils \ + clean-bison \ + clean-byacc \ + clean-cvs \ + clean-db \ + clean-dejagnu \ + clean-diff \ + clean-dosutils \ + clean-etc \ + clean-fileutils \ + clean-findutils \ + clean-find \ + clean-flex \ + clean-gas \ + clean-gawk \ + clean-gnuserv \ + clean-gprof \ + clean-grep \ + clean-grez \ + clean-gzip \ + clean-hello \ + clean-indent \ + clean-inet \ + clean-ispell \ + clean-itcl \ + clean-ld \ + clean-libiberty \ + clean-m4 \ + clean-make \ + clean-mmalloc \ + clean-opcodes \ + clean-patch \ + clean-perl \ + clean-prms \ + clean-rcs \ + clean-readline \ + clean-release \ + clean-recode \ + clean-sed \ + clean-send-pr \ + clean-shellutils \ + clean-sim \ + clean-sn \ + clean-tar \ + clean-tcl \ + clean-texinfo \ + clean-textutils \ + clean-tgas \ + clean-time \ + clean-uudecode \ + clean-wdiff + +# All of the target modules that can be cleaned +CLEAN_TARGET_MODULES = \ + clean-target-libio \ + clean-target-libstdc++ \ + clean-target-librx \ + clean-target-libg++ \ + clean-target-newlib \ + clean-target-winsup \ + clean-target-libgloss \ + clean-target-libiberty \ + clean-target-gperf \ + clean-target-examples + +# All of the x11 modules that can be cleaned +CLEAN_X11_MODULES = \ + clean-emacs \ + clean-emacs19 \ + clean-gdb \ + clean-expect \ + clean-gash \ + clean-guile \ + clean-tclX \ + clean-tk \ + clean-tix + +# The first rule in the file had better be this one. Don't put any above it. +all: all.normal +.PHONY: all + +# The target built for a native build. +.PHONY: all.normal +all.normal: \ + $(ALL_MODULES) \ + $(ALL_X11_MODULES) \ + $(ALL_TARGET_MODULES) \ + all-gcc + +# Do a target for all the subdirectories. A ``make do-X'' will do a +# ``make X'' in all subdirectories (because, in general, there is a +# dependency (below) of X upon do-X, a ``make X'' will also do this, +# but it may do additional work as well). +# This target ensures that $(BASE_FLAGS_TO_PASS) appears only once, +# because it is so large that it can easily overflow the command line +# length limit on some systems. +DO_X = \ + do-clean \ + do-distclean \ + do-dvi \ + do-info \ + do-install-info \ + do-installcheck \ + do-mostlyclean \ + do-maintainer-clean \ + do-TAGS +.PHONY: $(DO_X) +$(DO_X): + @target=`echo $@ | sed -e 's/^do-//'`; \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + for i in $(SUBDIRS) -dummy-; do \ + if [ -f ./$$i/Makefile ]; then \ + case $$i in \ + gcc) \ + for flag in $(EXTRA_GCC_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \ + done; \ + ;; \ + *) \ + for flag in $(EXTRA_HOST_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \ + done; \ + ;; \ + esac ; \ + export AR AS CC CXX LD NM RANLIB DLLTOOL WINDRES; \ + if (cd ./$$i; \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \ + $${target}); \ + then true; else exit 1; fi; \ + else true; fi; \ + done + @target=`echo $@ | sed -e 's/^do-//'`; \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + for i in $(TARGET_CONFIGDIRS) -dummy-; do \ + if [ -f $(TARGET_SUBDIR)/$$i/Makefile ]; then \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \ + done; \ + export AR AS CC CXX LD NM RANLIB DLLTOOL WINDRES; \ + if (cd $(TARGET_SUBDIR)/$$i; \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \ + $${target}); \ + then true; else exit 1; fi; \ + else true; fi; \ + done + +# Here are the targets which correspond to the do-X targets. + +.PHONY: info installcheck dvi install-info +.PHONY: clean distclean mostlyclean maintainer-clean realclean +.PHONY: local-clean local-distclean local-maintainer-clean +info: do-info +installcheck: do-installcheck +dvi: do-dvi + +# Make sure makeinfo is built before we do a `make info'. +do-info: all-texinfo + +install-info: do-install-info dir.info + s=`cd $(srcdir); pwd`; export s; \ + if [ -f dir.info ] ; then \ + $(INSTALL_DATA) dir.info $(infodir)/dir.info ; \ + else true ; fi + +local-clean: + -rm -f *.a TEMP errs core *.o *~ \#* TAGS *.E + +local-distclean: + -rm -f Makefile config.status config.cache + -if [ "$(TARGET_SUBDIR)" != "." ]; then \ + rm -rf $(TARGET_SUBDIR); \ + else true; fi + +local-maintainer-clean: + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +clean: do-clean local-clean +mostlyclean: do-mostlyclean local-clean +distclean: do-distclean local-clean local-distclean +maintainer-clean: local-maintainer-clean do-maintainer-clean local-clean +maintainer-clean: local-distclean +realclean: maintainer-clean + +# This rule is used to clean specific modules. +.PHONY: $(CLEAN_MODULES) $(CLEAN_X11_MODULES) clean-gcc +$(CLEAN_MODULES) $(CLEAN_X11_MODULES) clean-gcc: + @dir=`echo $@ | sed -e 's/clean-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) clean); \ + else \ + true; \ + fi + +.PHONY: $(CLEAN_TARGET_MODULES) +$(CLEAN_TARGET_MODULES): + @dir=`echo $@ | sed -e 's/clean-target-//'`; \ + rm -f $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/tmpmulti.out; \ + if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $(TARGET_SUBDIR)/$${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) clean); \ + else \ + true; \ + fi + +clean-target: $(CLEAN_TARGET_MODULES) + +# Check target. + +.PHONY: check +check: $(CHECK_MODULES) \ + $(CHECK_TARGET_MODULES) \ + $(CHECK_X11_MODULES) \ + check-gcc + +# Installation targets. + +.PHONY: install uninstall source-vault binary-vault vault-install +install: $(INSTALL_TARGET) + +uninstall: + @echo "the uninstall target is not supported in this tree" + +source-vault: + $(MAKE) -f ./release/Build-A-Release \ + host=$(host_alias) source-vault + +binary-vault: + $(MAKE) -f ./release/Build-A-Release \ + host=$(host_alias) target=$(target_alias) + +vault-install: + @if [ -f ./release/vault-install ] ; then \ + ./release/vault-install $(host_alias) $(target_alias) ; \ + else \ + true ; \ + fi + +.PHONY: install.all +install.all: install-no-fixedincludes + @if [ -f ./gcc/Makefile ] ; then \ + r=`pwd` ; export r ; \ + $(SET_LIB_PATH) \ + (cd ./gcc; \ + $(MAKE) $(FLAGS_TO_PASS) install-headers) ; \ + else \ + true ; \ + fi + +# inet-install is used because the I*Net wants DejaGNU installed but +# not built. Similarly, gzip is built but not installed. +inet-install: + $(MAKE) INSTALL_MODULES="`echo $(INSTALL_MODULES) | sed -e 's/install-dejagnu//' -e 's/install-gzip//'`" install + +# install-no-fixedincludes is used because Cygnus can not distribute +# the fixed header files. +.PHONY: install-no-fixedincludes +install-no-fixedincludes: \ + installdirs \ + $(INSTALL_MODULES) \ + $(INSTALL_TARGET_MODULES) \ + $(INSTALL_X11_MODULES) \ + gcc-no-fixedincludes + +# Install the gcc headers files, but not the fixed include files, +# which Cygnus is not allowed to distribute. This rule is very +# dependent on the workings of the gcc Makefile.in. +.PHONY: gcc-no-fixedincludes +gcc-no-fixedincludes: + @if [ -f ./gcc/Makefile ]; then \ + rm -rf gcc/tmp-include; \ + mv gcc/include gcc/tmp-include 2>/dev/null; \ + mkdir gcc/include; \ + cp $(srcdir)/gcc/gsyslimits.h gcc/include/syslimits.h; \ + touch gcc/stmp-fixinc gcc/include/fixed; \ + rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd` ; export s; \ + $(SET_LIB_PATH) \ + (cd ./gcc; \ + $(MAKE) $(GCC_FLAGS_TO_PASS) install); \ + rm -rf gcc/include; \ + mv gcc/tmp-include gcc/include 2>/dev/null; \ + else true; fi + +# This rule is used to build the modules which use FLAGS_TO_PASS. To +# build a target all-X means to cd to X and make all. +# +# all-gui, and all-libproc are handled specially because +# they are still experimental, and if they fail to build, that +# shouldn't stop "make all". +.PHONY: $(ALL_MODULES) all-gui all-libproc +$(ALL_MODULES) all-gui all-libproc: + @dir=`echo $@ | sed -e 's/all-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) all); \ + else \ + true; \ + fi + +# These rules are used to check the modules which use FLAGS_TO_PASS. +# To build a target check-X means to cd to X and make check. Some +# modules are only tested in a native toolchain. + +.PHONY: $(CHECK_MODULES) $(NATIVE_CHECK_MODULES) $(CROSS_CHECK_MODULES) +$(NATIVE_CHECK_MODULES): + @if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \ + dir=`echo $@ | sed -e 's/check-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) check); \ + else \ + true; \ + fi; \ + fi + +$(CROSS_CHECK_MODULES): + @dir=`echo $@ | sed -e 's/check-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) check); \ + else \ + true; \ + fi + +# This rule is used to install the modules which use FLAGS_TO_PASS. +# To build a target install-X means to cd to X and make install. +.PHONY: $(INSTALL_MODULES) +$(INSTALL_MODULES): installdirs + @dir=`echo $@ | sed -e 's/install-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \ + else \ + true; \ + fi + +# This rule is used to configure the modules which are built with the +# target tools. +.PHONY: $(CONFIGURE_TARGET_MODULES) +$(CONFIGURE_TARGET_MODULES): + @dir=`echo $@ | sed -e 's/configure-target-//'`; \ + if [ -d $(TARGET_SUBDIR)/$${dir} ]; then \ + r=`pwd`; export r; \ + $(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/$${dir}/tmpmulti.out 2> /dev/null; \ + if [ -s $(TARGET_SUBDIR)/$${dir}/tmpmulti.out ]; then \ + if [ -f $(TARGET_SUBDIR)/$${dir}/multilib.out ]; then \ + if cmp $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/tmpmulti.out > /dev/null; then \ + rm -f $(TARGET_SUBDIR)/$${dir}/tmpmulti.out; \ + else \ + echo "Multilibs changed for $${dir}, reconfiguring"; \ + rm -f $(TARGET_SUBDIR)/$${dir}/multilib.out $(TARGET_SUBDIR)/$${dir}/Makefile; \ + mv $(TARGET_SUBDIR)/$${dir}/tmpmulti.out $(TARGET_SUBDIR)/$${dir}/multilib.out; \ + fi; \ + else \ + mv $(TARGET_SUBDIR)/$${dir}/tmpmulti.out $(TARGET_SUBDIR)/$${dir}/multilib.out; \ + fi; \ + fi; \ + fi; exit 0 # break command into two pieces + @dir=`echo $@ | sed -e 's/configure-target-//'`; \ + if [ ! -d $(TARGET_SUBDIR) ]; then \ + true; \ + elif [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ + true; \ + elif echo " $(TARGET_CONFIGDIRS) " | grep " $${dir} " >/dev/null 2>&1; then \ + if [ -d $(srcdir)/$${dir} ]; then \ + [ -d $(TARGET_SUBDIR)/$${dir} ] || mkdir $(TARGET_SUBDIR)/$${dir};\ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + AR="$(AR_FOR_TARGET)"; export AR; \ + AS="$(AS_FOR_TARGET)"; export AS; \ + CC="$(CC_FOR_TARGET)"; export CC; \ + CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \ + CXX="$(CXX_FOR_TARGET)"; export CXX; \ + CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \ + DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \ + LD="$(LD_FOR_TARGET)"; export LD; \ + LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \ + NM="$(NM_FOR_TARGET)"; export NM; \ + RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \ + WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \ + echo Configuring in $(TARGET_SUBDIR)/$${dir}; \ + cd $(TARGET_SUBDIR)/$${dir}; \ + case $(srcdir) in \ + /*) \ + topdir=$(srcdir) ;; \ + *) \ + case "$(TARGET_SUBDIR)" in \ + .) topdir="../$(srcdir)" ;; \ + *) topdir="../../$(srcdir)" ;; \ + esac ;; \ + esac; \ + if [ "$(srcdir)" = "." ] ; then \ + if [ "$(TARGET_SUBDIR)" != "." ] ; then \ + if $(SHELL) $$s/symlink-tree $${topdir}/$${dir} "no-such-file" ; then \ + if [ -f Makefile ]; then \ + if $(MAKE) distclean; then \ + true; \ + else \ + exit 1; \ + fi; \ + else \ + true; \ + fi; \ + else \ + exit 1; \ + fi; \ + else \ + true; \ + fi; \ + srcdiroption="--srcdir=."; \ + libsrcdir="."; \ + else \ + srcdiroption="--srcdir=$${topdir}/$${dir}"; \ + libsrcdir="$$s/$${dir}"; \ + fi; \ + if [ -f $${libsrcdir}/configure ] ; then \ + $(SHELL) $${libsrcdir}/configure \ + $(CONFIG_ARGUMENTS) $${srcdiroption} \ + --with-target-subdir="$(TARGET_SUBDIR)"; \ + else \ + $(SHELL) $$s/configure \ + $(CONFIG_ARGUMENTS) $${srcdiroption} \ + --with-target-subdir="$(TARGET_SUBDIR)"; \ + fi; \ + else \ + true; \ + fi; \ + else \ + true; \ + fi + +# This rule is used to build the modules which use TARGET_FLAGS_TO_PASS. +# To build a target all-X means to cd to X and make all. +.PHONY: $(ALL_TARGET_MODULES) +$(ALL_TARGET_MODULES): + @dir=`echo $@ | sed -e 's/all-target-//'`; \ + if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $(TARGET_SUBDIR)/$${dir}; $(MAKE) $(TARGET_FLAGS_TO_PASS) all); \ + else \ + true; \ + fi + +# This rule is used to check the modules which use TARGET_FLAGS_TO_PASS. +# To build a target install-X means to cd to X and make install. +.PHONY: $(CHECK_TARGET_MODULES) +$(CHECK_TARGET_MODULES): + @dir=`echo $@ | sed -e 's/check-target-//'`; \ + if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $(TARGET_SUBDIR)/$${dir};$(MAKE) $(TARGET_FLAGS_TO_PASS) check);\ + else \ + true; \ + fi + +# This rule is used to install the modules which use +# TARGET_FLAGS_TO_PASS. To build a target install-X means to cd to X +# and make install. +.PHONY: $(INSTALL_TARGET_MODULES) +$(INSTALL_TARGET_MODULES): installdirs + @dir=`echo $@ | sed -e 's/install-target-//'`; \ + if [ -f $(TARGET_SUBDIR)/$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $(TARGET_SUBDIR)/$${dir}; \ + $(MAKE) $(TARGET_FLAGS_TO_PASS) install); \ + else \ + true; \ + fi + +# This rule is used to build the modules which use X11_FLAGS_TO_PASS. +# To build a target all-X means to cd to X and make all. +.PHONY: $(ALL_X11_MODULES) +$(ALL_X11_MODULES): + @dir=`echo $@ | sed -e 's/all-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; \ + $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) all); \ + else \ + true; \ + fi + +# This rule is used to check the modules which use X11_FLAGS_TO_PASS. +# To build a target check-X means to cd to X and make all. +.PHONY: $(CHECK_X11_MODULES) +$(CHECK_X11_MODULES): + @dir=`echo $@ | sed -e 's/check-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; \ + $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) check); \ + else \ + true; \ + fi + +# This rule is used to install the modules which use X11_FLAGS_TO_PASS. +# To build a target install-X means to cd to X and make install. +.PHONY: $(INSTALL_X11_MODULES) +$(INSTALL_X11_MODULES): installdirs + @dir=`echo $@ | sed -e 's/install-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; \ + $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install); \ + else \ + true; \ + fi + +# gcc is the only module which uses GCC_FLAGS_TO_PASS. +.PHONY: all-gcc +all-gcc: + @if [ -f ./gcc/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) all); \ + else \ + true; \ + fi + +.PHONY: all-bootstrap +all-bootstrap: + @if [ -f ./gcc/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) bootstrap); \ + else \ + true; \ + fi + +.PHONY: check-gcc +check-gcc: + @if [ -f ./gcc/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) check); \ + else \ + true; \ + fi + +.PHONY: install-gcc +install-gcc: + @if [ -f ./gcc/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd gcc; $(MAKE) $(GCC_FLAGS_TO_PASS) install); \ + else \ + true; \ + fi + + +# EXPERIMENTAL STUFF +# This rule is used to install the modules which use FLAGS_TO_PASS. +# To build a target install-X means to cd to X and make install. +.PHONY: install-dosrel +install-dosrel: installdirs info + @dir=`echo $@ | sed -e 's/install-//'`; \ + if [ -f ./$${dir}/Makefile ] ; then \ + r=`pwd`; export r; \ + s=`cd $(srcdir); pwd`; export s; \ + $(SET_LIB_PATH) \ + (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) install); \ + else \ + true; \ + fi + +install-dosrel-fake: + + +# This is a list of inter-dependencies among modules. +all-apache: +all-autoconf: all-m4 all-texinfo +all-automake: +all-bash: +all-bfd: +all-binutils: all-libiberty all-opcodes all-bfd all-flex all-bison all-byacc +all-bison: all-texinfo +all-byacc: +all-cvs: +all-db: +all-dejagnu: all-tcl all-expect all-tk +all-diff: all-libiberty +all-emacs: +all-emacs19: all-bison all-byacc +all-etc: +configure-target-examples: $(ALL_GCC) +all-target-examples: configure-target-examples +all-expect: all-tcl all-tk +all-fileutils: all-libiberty +all-findutils: +all-find: +all-flex: all-libiberty all-bison all-byacc +all-gas: all-libiberty all-opcodes all-bfd +all-gash: all-tcl +all-gawk: +ALL_GCC = all-gcc +all-gcc: all-bison all-byacc all-binutils all-gas all-ld +all-bootstrap: all-libiberty all-bison all-byacc all-binutils all-gas all-ld +GDB_TK = all-tk all-tcl all-itcl all-tix +all-gdb: all-libiberty all-opcodes all-bfd all-mmalloc all-readline all-bison all-byacc all-sim $(gdbnlmrequirements) $(GDB_TK) +all-gnuserv: +configure-target-gperf: $(ALL_GCC) +all-target-gperf: configure-target-gperf all-target-libiberty all-target-libg++ +all-gprof: all-libiberty all-bfd all-opcodes +all-grep: all-libiberty +all-grez: all-libiberty all-bfd all-opcodes +all-gui: all-gdb all-libproc all-target-librx +all-guile: +all-gzip: all-libiberty +all-hello: all-libiberty +all-indent: +all-inet: all-tcl all-send-pr all-perl +all-ispell: all-emacs19 +all-itcl: all-tcl all-tk +all-ld: all-libiberty all-bfd all-opcodes all-bison all-byacc all-flex +configure-target-libg++: $(ALL_GCC) configure-target-librx +all-target-libg++: configure-target-libg++ all-gas all-ld all-gcc all-target-libiberty all-target-newlib all-target-libio all-target-librx all-target-libstdc++ +configure-target-libgloss: $(ALL_GCC) +all-target-libgloss: configure-target-libgloss configure-target-newlib +configure-target-libio: $(ALL_GCC) +all-target-libio: configure-target-libio all-gas all-ld all-gcc all-target-libiberty all-target-newlib +all-libiberty: +configure-target-librx: $(ALL_GCC) configure-target-newlib +all-target-librx: configure-target-librx +configure-target-libstdc++: $(ALL_GCC) +all-target-libstdc++: configure-target-libstdc++ all-gas all-ld all-gcc all-target-libiberty all-target-newlib all-target-libio +all-m4: all-libiberty +all-make: all-libiberty +all-mmalloc: +configure-target-newlib: $(ALL_GCC) +all-target-newlib: configure-target-newlib all-binutils all-gas all-gcc +all-opcodes: all-bfd all-libiberty +all-patch: all-libiberty +all-perl: +all-prms: all-libiberty +all-rcs: +all-readline: +all-recode: all-libiberty +all-sed: all-libiberty +all-send-pr: all-prms +all-shellutils: +all-sim: all-libiberty all-bfd all-opcodes +all-sn: all-tcl all-tk all-itcl all-db all-grep +all-tar: all-libiberty +all-tcl: +all-tclX: all-tcl all-tk +all-tk: all-tcl +all-texinfo: all-libiberty +all-textutils: +all-tgas: all-libiberty all-bfd all-opcodes +all-time: +all-tix: all-tcl all-tk +all-wdiff: +all-target-winsup: all-target-newlib all-target-libiberty all-target-librx all-target-libio configure-target-winsup +configure-target-winsup: configure-target-newlib +all-uudecode: all-libiberty +configure-target-libiberty: $(ALL_GCC) +all-target-libiberty: configure-target-libiberty all-gcc all-ld all-target-newlib +all-target: $(ALL_TARGET_MODULES) +install-target: $(INSTALL_TARGET_MODULES) + +### other supporting targets + +MAKEDIRS= \ + $(prefix) \ + $(exec_prefix) +.PHONY: installdirs +installdirs: mkinstalldirs + $(SHELL) $(srcdir)/mkinstalldirs $(MAKEDIRS) + +dir.info: do-install-info + if [ -f $(srcdir)/texinfo/gen-info-dir ] ; then \ + $(srcdir)/texinfo/gen-info-dir $(infodir) $(srcdir)/texinfo/dir.info-template > dir.info.new ; \ + mv -f dir.info.new dir.info ; \ + else true ; \ + fi + +dist: + @echo "Building a full distribution of this tree isn't done" + @echo "via 'make dist'. Check out the etc/ subdirectory" + +etags tags: TAGS + +# Right now this just builds TAGS in each subdirectory. emacs19 has the +# ability to use several tags files at once, so there is probably no need +# to combine them into one big TAGS file (like CVS 1.3 does). We could +# (if we felt like it) have this Makefile write a piece of elisp which +# the user could load to tell emacs19 where all the TAGS files we just +# built are. +TAGS: do-TAGS + +# with the gnu make, this is done automatically. + +Makefile: Makefile.in configure.in $(host_makefile_frag) $(target_makefile_frag) + $(SHELL) ./config.status + +# +# Support for building net releases + +# Files in devo used in any net release. +# ChangeLog omitted because it may refer to files which are not in this +# distribution (perhaps it would be better to include it anyway). +DEVO_SUPPORT= README Makefile.in configure configure.in \ + config.guess config.sub config move-if-change \ + mpw-README mpw-build.in mpw-config.in mpw-configure mpw-install \ + COPYING COPYING.LIB install-sh config-ml.in symlink-tree \ + mkinstalldirs ltconfig ltmain.sh missing ylwrap + +# Files in devo/etc used in any net release. +# ChangeLog omitted because it may refer to files which are not in this +# distribution (perhaps it would be better to include it anyway). +ETC_SUPPORT= Makefile.in configure configure.in standards.texi \ + make-stds.texi standards.info* + +# When you use `make setup-dirs' or `make taz' you should always redefine +# this macro. +SUPPORT_FILES = list-of-support-files-for-tool-in-question + +.PHONY: taz + +taz: $(DEVO_SUPPORT) $(SUPPORT_FILES) \ + texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo + # Take out texinfo from a few places; make simple BISON=bison line. + sed -e '/^all\.normal: /s/\all-texinfo //' \ + -e '/^ install-texinfo /d' \ + tmp + mv -f tmp Makefile.in + # + ./configure sun4 + [ -z "$(CONFIGURE_TARGET_MODULES)" ] \ + || $(MAKE) $(CONFIGURE_TARGET_MODULES) ALL_GCC="" \ + CC_FOR_TARGET="$(CC)" CXX_FOR_TARGET="$(CXX)" + # Make links, and run "make diststuff" or "make info" when needed. + rm -rf proto-toplev ; mkdir proto-toplev + set -e ; dirs="$(TOOL) $(DEVO_SUPPORT) $(SUPPORT_FILES)" ; \ + for d in $$dirs ; do \ + if [ -d $$d ]; then \ + if [ ! -f $$d/Makefile ] ; then true ; \ + elif grep '^diststuff:' $$d/Makefile >/dev/null ; then \ + (cd $$d ; $(MAKE) diststuff ) || exit 1 ; \ + elif grep '^info:' $$d/Makefile >/dev/null ; then \ + (cd $$d ; $(MAKE) info ) || exit 1 ; \ + fi ; \ + if [ -d $$d/proto-$$d.dir ]; then \ + ln -s ../$$d/proto-$$d.dir proto-toplev/$$d ; \ + else \ + ln -s ../$$d proto-toplev/$$d ; \ + fi ; \ + else ln -s ../$$d proto-toplev/$$d ; fi ; \ + done + cd etc ; $(MAKE) info + $(MAKE) distclean + # + mkdir proto-toplev/etc + (cd proto-toplev/etc; \ + for i in $(ETC_SUPPORT); do \ + ln -s ../../etc/$$i . ; \ + done) + # + # Take out texinfo from configurable dirs + rm proto-toplev/configure.in + sed -e '/^host_tools=/s/texinfo //' \ + proto-toplev/configure.in + # + mkdir proto-toplev/texinfo + ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/ + ln -s ../../texinfo/gpl.texinfo proto-toplev/texinfo/ + ln -s ../../texinfo/lgpl.texinfo proto-toplev/texinfo/ + if test -r texinfo/util/tex3patch ; then \ + mkdir proto-toplev/texinfo/util && \ + ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util ; \ + else true; fi + chmod og=u `find . -print` + if grep AM_INIT_AUTOMAKE $(TOOL)/configure.in >/dev/null 2>&1; then \ + ver=`sed < $(TOOL)/configure.in -n 's/AM_INIT_AUTOMAKE[^,]*, *\([^)]*\))/\1/p'`; \ + else \ + ver=`sed <$(TOOL)/Makefile.in -n 's/^VERSION *= *//p'`; \ + fi; \ + $(MAKE) -f Makefile.in do-tar-gz TOOL=$(TOOL) VER=$$ver + +do-tar-gz: + echo "==> Making $(TOOL)-$(VER).tar.gz" + -rm -f $(TOOL)-$(VER) + ln -s proto-toplev $(TOOL)-$(VER) + tar cfh $(TOOL)-$(VER).tar $(TOOL)-$(VER) + $(GZIPPROG) -v -9 $(TOOL)-$(VER).tar + +TEXINFO_SUPPORT= texinfo/texinfo.tex texinfo/gpl.texinfo texinfo/lgpl.texinfo +DIST_SUPPORT= $(DEVO_SUPPORT) $(TEXINFO_SUPPORT) + +.PHONY: gas.tar.gz +GAS_SUPPORT_DIRS= bfd include libiberty opcodes setup.com makefile.vms +gas.tar.gz: $(DIST_SUPPORT) $(GAS_SUPPORT_DIRS) gas + $(MAKE) -f Makefile.in taz TOOL=gas \ + SUPPORT_FILES="$(GAS_SUPPORT_DIRS)" + +# The FSF "binutils" release includes gprof and ld. +.PHONY: binutils.tar.gz +BINUTILS_SUPPORT_DIRS= bfd gas include libiberty opcodes ld gprof setup.com makefile.vms +binutils.tar.gz: $(DIST_SUPPORT) $(BINUTILS_SUPPORT_DIRS) binutils + $(MAKE) -f Makefile.in taz TOOL=binutils \ + SUPPORT_FILES="$(BINUTILS_SUPPORT_DIRS) makeall.bat configure.bat" + +.PHONY: gas+binutils.tar.gz +GASB_SUPPORT_DIRS= $(GAS_SUPPORT_DIRS) binutils ld gprof +gas+binutils.tar.gz: $(DIST_SUPPORT) $(GASB_SUPPORT_DIRS) gas + $(MAKE) -f Makefile.in taz TOOL=gas \ + SUPPORT_FILES="$(GASB_SUPPORT_DIRS) makeall.bat configure.bat" + +.PHONY: libg++.tar.gz +LIBGXX_SUPPORT_DIRS=include libstdc++ libio librx libiberty +libg++.tar.gz: $(DIST_SUPPORT) libg++ + $(MAKE) -f Makefile.in taz TOOL=libg++ \ + SUPPORT_FILES="$(LIBGXX_SUPPORT_DIRS)" + +GNATS_SUPPORT_DIRS=include libiberty send-pr +gnats.tar.gz: $(DIST_SUPPORT) $(GNATS_SUPPORT_DIRS) gnats + $(MAKE) -f Makefile.in taz TOOL=gnats \ + SUPPORT_FILES="$(GNATS_SUPPORT_DIRS)" + +.PHONY: gdb.tar.gz +GDB_SUPPORT_DIRS= bfd include libiberty mmalloc opcodes readline sim utils +GDBTK_SUPPORT_DIRS= `if [ -d tcl -a -d tk ] ; then echo tcl tk ; fi` +gdb.tar.gz: $(DIST_SUPPORT) $(GDB_SUPPORT_DIRS) gdb + $(MAKE) -f Makefile.in taz TOOL=gdb \ + SUPPORT_FILES="$(GDB_SUPPORT_DIRS) $(GDBTK_SUPPORT_DIRS)" + +.PHONY: newlib.tar.gz +NEWLIB_SUPPORT_DIRS=libgloss +# taz configures for the sun4 target which won't configure newlib. +# We need newlib configured so that the .info files are made. +# Unfortunately, it is not enough to just configure newlib separately: +# taz will build the .info files but since SUBDIRS won't contain newlib, +# distclean won't be run (leaving Makefile, config.status, and the tmp files +# used in building the .info files, eg: *.def, *.ref). +# The problem isn't solvable however without a lot of extra work because +# target libraries are built in subdir $(target_alias) which gets nuked during +# the make distclean. For now punt on the issue of shipping newlib info files +# with newlib net releases and wait for a day when some native target (sun4?) +# supports newlib (if only minimally). +newlib.tar.gz: $(DIST_SUPPORT) $(NEWLIB_SUPPORT_DIRS) newlib + $(MAKE) -f Makefile.in taz TOOL=newlib \ + SUPPORT_FILES="$(NEWLIB_SUPPORT_DIRS)" \ + DEVO_SUPPORT="$(DEVO_SUPPORT) COPYING.NEWLIB" newlib + +.NOEXPORT: +MAKEOVERRIDES= + + +# end of Makefile.in diff --git a/README b/README new file mode 100644 index 000000000000..eb0e436d860f --- /dev/null +++ b/README @@ -0,0 +1,47 @@ + README for GNU development tools + +This directory contains various GNU compilers, assemblers, linkers, +debuggers, etc., plus their support routines, definitions, and documentation. + +If you are receiving this as part of a GDB release, see the file gdb/README. +If with a binutils release, see binutils/README; if with a libg++ release, +see libg++/README, etc. That'll give you info about this +package -- supported targets, how to use it, how to report bugs, etc. + +It is now possible to automatically configure and build a variety of +tools with one command. To build all of the tools contained herein, +run the ``configure'' script here, e.g.: + + ./configure + make + +To install them (by default in /usr/local/bin, /usr/local/lib, etc), +then do: + make install + +(If the configure script can't determine your type of computer, give it +the name as an argument, for instance ``./configure sun4''. You can +use the script ``config.sub'' to test whether a name is recognized; if +it is, config.sub translates it to a triplet specifying CPU, vendor, +and OS.) + +If you have more than one compiler on your system, it is often best to +explicitly set CC in the environment before running configure, and to +also set CC when running make. For example (assuming sh/bash/ksh): + + CC=gcc ./configure + make + +A similar example using csh: + + setenv CC gcc + ./configure + make + +Much of the code and documentation enclosed is copyright by +the Free Software Foundation, Inc. See the file COPYING or +COPYING.LIB in the various directories, for a description of the +GNU General Public License terms under which you can copy the files. + +REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info +on where and how to report problems. diff --git a/config-ml.in b/config-ml.in new file mode 100644 index 000000000000..57613d90d7e4 --- /dev/null +++ b/config-ml.in @@ -0,0 +1,612 @@ +# Configure fragment invoked in the post-target section for subdirs +# wanting multilib support. +# +# It is advisable to support a few --enable/--disable options to let the +# user select which libraries s/he really wants. +# +# Subdirectories wishing to use multilib should put the following lines +# in the "post-target" section of configure.in. +# +# if [ "${srcdir}" = "." ] ; then +# if [ "${with_target_subdir}" != "." ] ; then +# . ${with_multisrctop}../../config-ml.in +# else +# . ${with_multisrctop}../config-ml.in +# fi +# else +# . ${srcdir}/../config-ml.in +# fi +# +# See librx/configure.in in the libg++ distribution for an example of how +# to handle autoconf'd libraries. +# +# Things are complicated because 6 separate cases must be handled: +# 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6. +# +# srcdir=. is special. It must handle make programs that don't handle VPATH. +# To implement this, a symlink tree is built for each library and for each +# multilib subdir. +# +# The build tree is layed out as +# +# ./ +# libg++ +# newlib +# m68020/ +# libg++ +# newlib +# m68881/ +# libg++ +# newlib +# +# The nice feature about this arrangement is that inter-library references +# in the build tree work without having to care where you are. Note that +# inter-library references also work in the source tree because symlink trees +# are built when srcdir=. +# +# Unfortunately, trying to access the libraries in the build tree requires +# the user to manually choose which library to use as GCC won't be able to +# find the right one. This is viewed as the lesser of two evils. +# +# Configure variables: +# ${with_target_subdir} = "." for native, or ${target_alias} for cross. +# Set by top level Makefile. +# ${with_multisrctop} = how many levels of multilibs there are in the source +# tree. It exists to handle the case of configuring in the source tree: +# ${srcdir} is not constant. +# ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881). +# +# Makefile variables: +# MULTISRCTOP = number of multilib levels in source tree (+1 if cross) +# (FIXME: note that this is different than ${with_multisrctop}. Check out.). +# MULTIBUILDTOP = number of multilib levels in build tree +# MULTIDIRS = list of multilib subdirs (eg: m68000 m68020 ...) +# (only defined in each library's main Makefile). +# MULTISUBDIR = installed subdirectory name with leading '/' (eg: /m68000) +# (only defined in each multilib subdir). + +# FIXME: Multilib is currently disabled by default for everything other than +# newlib. It is up to each target to turn on multilib support for the other +# libraries as desired. + +# We have to handle being invoked by both Cygnus configure and Autoconf. +# +# Cygnus configure incoming variables: +# srcdir, subdir, target, arguments +# +# Autoconf incoming variables: +# srcdir, target, ac_configure_args +# +# We *could* figure srcdir and target out, but we'd have to do work that +# our caller has already done to figure them out and requiring these two +# seems reasonable. + +if [ -n "${ac_configure_args}" ]; then + Makefile=${ac_file-Makefile} + ml_config_shell=${CONFIG_SHELL-/bin/sh} + ml_arguments="${ac_configure_args}" + ml_realsrcdir=${srcdir} +else + Makefile=${Makefile-Makefile} + ml_config_shell=${config_shell-/bin/sh} + ml_arguments="${arguments}" + if [ -n "${subdir}" -a "${subdir}" != "." ] ; then + ml_realsrcdir=${srcdir}/${subdir} + else + ml_realsrcdir=${srcdir} + fi +fi + +# Scan all the arguments and set all the ones we need. + +for option in ${ml_arguments} +do + case $option in + --*) ;; + -*) option=-$option ;; + esac + + case $option in + --*=*) + optarg=`echo $option | sed -e 's/^[^=]*=//'` + ;; + esac + + case $option in + --disable-*) + enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'` + eval $enableopt=no + ;; + --enable-*) + case "$option" in + *=*) ;; + *) optarg=yes ;; + esac + enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'` + eval $enableopt="$optarg" + ;; + --norecursion | --no*) + ml_norecursion=yes + ;; + --verbose | --v | --verb*) + ml_verbose=--verbose + ;; + --with-*) + case "$option" in + *=*) ;; + *) optarg=yes ;; + esac + withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'` + eval $withopt="$optarg" + ;; + --without-*) + withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'` + eval $withopt=no + ;; + esac +done + +# Only do this if --enable-multilib. +if [ "${enable_multilib}" = yes ]; then + +# Compute whether this is the library's top level directory +# (ie: not a multilib subdirectory, and not a subdirectory like libg++/src). +# ${with_multisubdir} tells us we're in the right branch, but we could be +# in a subdir of that. +# ??? The previous version could void this test by separating the process into +# two files: one that only the library's toplevel configure.in ran (to +# configure the multilib subdirs), and another that all configure.in's ran to +# update the Makefile. It seemed reasonable to collapse all multilib support +# into one file, but it does leave us with having to perform this test. +ml_toplevel_p=no +if [ -z "${with_multisubdir}" ]; then + if [ "${srcdir}" = "." ]; then + # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}. + # ${with_target_subdir} = "." for native, otherwise target alias. + if [ "${with_target_subdir}" = "." ]; then + if [ -f ${ml_realsrcdir}/../config-ml.in ]; then + ml_toplevel_p=yes + fi + else + if [ -f ${ml_realsrcdir}/../../config-ml.in ]; then + ml_toplevel_p=yes + fi + fi + else + # Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}. + if [ -f ${ml_realsrcdir}/../config-ml.in ]; then + ml_toplevel_p=yes + fi + fi +fi + +# If this is the library's top level directory, set multidirs to the +# multilib subdirs to support. This lives at the top because we need +# `multidirs' set right away. + +if [ "${ml_toplevel_p}" = yes ]; then + +multidirs= +for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do + dir=`echo $i | sed -e 's/;.*$//'` + if [ "${dir}" = "." ]; then + true + else + if [ -z "${multidirs}" ]; then + multidirs="${dir}" + else + multidirs="${multidirs} ${dir}" + fi + fi +done + +case "${target}" in +arc-*-elf*) + if [ x$enable_biendian != xyes ] + then + old_multidirs=${multidirs} + multidirs="" + for x in ${old_multidirs}; do + case "${x}" in + *be*) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + ;; +m68*-*-*) + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_m68881 = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *m68881* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_m68000 = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *m68000* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_m68020 = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *m68020* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + ;; +mips*-*-*) + if [ x$enable_single_float = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *single* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_biendian = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *el* ) : ;; + *eb* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + ;; +powerpc*-*-* | rs6000*-*-*) + if [ x$enable_softfloat = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *soft-float* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_powercpu = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + power | */power | */power/* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_powerpccpu = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *powerpc* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_powerpcos = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *mcall-linux* | *mcall-solaris* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_biendian = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *mlittle* | *mbig* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_sysv = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *mcall-sysv* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + if [ x$enable_aix = xno ] + then + old_multidirs="${multidirs}" + multidirs="" + for x in ${old_multidirs}; do + case "$x" in + *mcall-aix* ) : ;; + *) multidirs="${multidirs} ${x}" ;; + esac + done + fi + ;; +esac + +# Remove extraneous blanks from multidirs. +# Tests like `if [ -n "$multidirs" ]' require it. +multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'` + +# Add code to library's top level makefile to handle building the multilib +# subdirs. + +cat > Multi.tem <<\EOF + +# FIXME: There should be an @-sign in front of the `if'. +# Leave out until this is tested a bit more. +multi-do: + if [ -z "$(MULTIDIRS)" ]; then \ + true; \ + else \ + rootpre=`pwd`/; export rootpre; \ + srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \ + lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \ + compiler="$(CC)"; \ + for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \ + dir=`echo $$i | sed -e 's/;.*$$//'`; \ + if [ "$${dir}" = "." ]; then \ + true; \ + else \ + if [ -d ../$${dir}/$${lib} ]; then \ + flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \ + if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \ + CFLAGS="$(CFLAGS) $${flags}" \ + CXXFLAGS="$(CXXFLAGS) $${flags}" \ + LIBCFLAGS="$(LIBCFLAGS) $${flags}" \ + LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \ + $(DO)); then \ + true; \ + else \ + exit 1; \ + fi; \ + else true; \ + fi; \ + fi; \ + done; \ + fi + +# FIXME: There should be an @-sign in front of the `if'. +# Leave out until this is tested a bit more. +multi-clean: + if [ -z "$(MULTIDIRS)" ]; then \ + true; \ + else \ + lib=`pwd | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \ + for dir in Makefile $(MULTIDIRS); do \ + if [ -f ../$${dir}/$${lib}/Makefile ]; then \ + if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \ + then true; \ + else exit 1; \ + fi; \ + else true; \ + fi; \ + done; \ + fi +EOF + +cat ${Makefile} Multi.tem > Makefile.tem +rm -f ${Makefile} Multi.tem +mv Makefile.tem ${Makefile} + +fi # ${ml_toplevel_p} = yes + +if [ "${ml_verbose}" = --verbose ]; then + echo "Adding multilib support to Makefile in ${ml_realsrcdir}" + if [ "${ml_toplevel_p}" = yes ]; then + echo "multidirs=${multidirs}" + fi + echo "with_multisubdir=${with_multisubdir}" +fi + +if [ "${srcdir}" = "." ]; then + if [ "${with_target_subdir}" != "." ]; then + ml_srcdotdot="../" + else + ml_srcdotdot="" + fi +else + ml_srcdotdot="" +fi + +if [ -z "${with_multisubdir}" ]; then + ml_subdir= + ml_builddotdot= + : # ml_srcdotdot= # already set +else + ml_subdir="/${with_multisubdir}" + # The '[^/][^/]*' appears that way to work around a SunOS sed bug. + ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/ + if [ "$srcdir" = "." ]; then + ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot} + else + : # ml_srcdotdot= # already set + fi +fi + +if [ "${ml_toplevel_p}" = yes ]; then + ml_do='$(MAKE)' + ml_clean='$(MAKE)' +else + ml_do=true + ml_clean=true +fi + +# TOP is used by newlib and should not be used elsewhere for this purpose. +# MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty +# when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s. +# FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can +# delete TOP. Newlib may wish to continue to use TOP for its own purposes +# of course. +# MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile) +# and lists the subdirectories to recurse into. +# MULTISUBDIR is non-empty in each cpu subdirectory's Makefile +# (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with +# a leading '/'. +# MULTIDO is used for targets like all, install, and check where +# $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed. +# MULTICLEAN is used for the *clean targets. +# +# ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are +# currently kept separate because we don't want the *clean targets to require +# the existence of the compiler (which MULTIDO currently requires) and +# therefore we'd have to record the directory options as well as names +# (currently we just record the names and use --print-multi-lib to get the +# options). + +sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \ + -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \ + -e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \ + -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \ + -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \ + -e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \ + -e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \ + ${Makefile} > Makefile.tem +rm -f ${Makefile} +mv Makefile.tem ${Makefile} + +# If this is the library's top level, configure each multilib subdir. +# This is done at the end because this is the loop that runs configure +# in each multilib subdir and it seemed reasonable to finish updating the +# Makefile before going on to configure the subdirs. + +if [ "${ml_toplevel_p}" = yes ]; then + +# We must freshly configure each subdirectory. This bit of code is +# actually partially stolen from the main configure script. FIXME. + +if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then + + if [ "${ml_verbose}" = --verbose ]; then + echo "Running configure in multilib subdirs ${multidirs}" + echo "pwd: `pwd`" + fi + + ml_origdir=`pwd` + ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'` + # cd to top-level-build-dir/${with_target_subdir} + cd .. + + for ml_dir in ${multidirs}; do + + if [ "${ml_verbose}" = --verbose ]; then + echo "Running configure in multilib subdir ${ml_dir}" + echo "pwd: `pwd`" + fi + + if [ -d ${ml_dir} ]; then true; else mkdir ${ml_dir}; fi + if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi + + # Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../ + dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'` + + case ${srcdir} in + ".") + echo Building symlink tree in `pwd`/${ml_dir}/${ml_libdir} + if [ "${with_target_subdir}" != "." ]; then + ml_unsubdir="../" + else + ml_unsubdir="" + fi + (cd ${ml_dir}/${ml_libdir}; + ../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "") + ml_newsrcdir="." + ml_srcdiroption= + multisrctop=${dotdot} + ;; + *) + case "${srcdir}" in + /*) # absolute path + ml_newsrcdir=${srcdir} + ;; + *) # otherwise relative + ml_newsrcdir=${dotdot}${srcdir} + ;; + esac + ml_srcdiroption="-srcdir=${ml_newsrcdir}" + multisrctop= + ;; + esac + + case "${progname}" in + /*) ml_recprog=${progname} ;; + *) ml_recprog=${dotdot}${progname} ;; + esac + + # FIXME: POPDIR=${PWD=`pwd`} doesn't work here. + ML_POPDIR=`pwd` + cd ${ml_dir}/${ml_libdir} + + if [ -f ${ml_newsrcdir}/configure ]; then + ml_recprog=${ml_newsrcdir}/configure + fi + if eval ${ml_config_shell} ${ml_recprog} \ + --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \ + ${ml_arguments} ${ml_srcdiroption} ; then + true + else + exit 1 + fi + + cd ${ML_POPDIR} + + done + + cd ${ml_origdir} +fi + +fi # ${ml_toplevel_p} = yes +fi # ${enable_multilib} = yes diff --git a/config.guess b/config.guess new file mode 100755 index 000000000000..a73a8d93c0c0 --- /dev/null +++ b/config.guess @@ -0,0 +1,833 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. +# +# This file 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# The master version of this file is at the FSF in /home/gd/gnu/lib. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + alpha:OSF1:*:*) + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d84 + cmoveq \$4,0,\$3 + addl \$3,\$31,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 1) + UNAME_MACHINE="alphaev5" + ;; + 2) + UNAME_MACHINE="alphaev56" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'` + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:NetBSD:*:*) + echo m68k-cbm-netbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:NetBSD:*:*) + echo m68k-atari-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:NetBSD:*:*) + echo m68k-sun-netbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:NetBSD:*:*) + echo m68k-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >dummy.c + int main (argc, argv) int argc; char **argv; { + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + ${CC-cc} dummy.c -o dummy \ + && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[3478]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; + 9000/8?? ) HP_ARCH=hppa1.0 ;; + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo i386-pc-cygwin32 + exit 0 ;; + i*:MINGW*:*) + echo i386-pc-mingw32 + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin32 + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. + ld_help_string=`ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d84 + cmoveq \$4,0,\$3 + addl \$3,\$31,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 1) + UNAME_MACHINE="alphaev5" + ;; + 2) + UNAME_MACHINE="alphaev56" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >dummy.c < +main(argc, argv) + int argc; + char *argv[]; +{ +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + fi ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 +rm -f dummy.c dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/config.sub b/config.sub new file mode 100755 index 000000000000..eb77a640f01c --- /dev/null +++ b/config.sub @@ -0,0 +1,1177 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond ) # CYGNUS LOCAL + os= + basic_machine=$1 + ;; + -scout) # CYGNUS LOCAL + ;; + -wrs) # CYGNUS LOCAL + os=vxworks + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 \ + | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ + | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ + | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ + | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ + | mipstx39 | mipstx39el \ + | sparc | sparclet | sparclite | sparc64) + basic_machine=$basic_machine-unknown + ;; + m88110 | m680[01234]0 | m683?2 | m68360 | z8k | v70 | h8500 | w65) # CYGNUS LOCAL + basic_machine=$basic_machine-unknown + ;; + mips64vr4300 | mips64vr4300el) # CYGNUS LOCAL jsmith/vr4300 + basic_machine=$basic_machine-unknown + ;; + mips64vr4100 | mips64vr4100el) # CYGNUS LOCAL jsmith/vr4100 + basic_machine=$basic_machine-unknown + ;; + mips64vr5000 | mips64vr5000el) # CYGNUS LOCAL ian/vr5000 + basic_machine=$basic_machine-unknown + ;; + mips16) # CYGNUS LOCAL krk/mips16 + basic_machine=$basic_machine-unknown + ;; + d10v) # CYGNUS LOCAL meissner/d10v + basic_machine=$basic_machine-unknown + ;; + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[3456]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ + | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ + | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mipstx39-* | mipstx39el-* \ + | f301-*) + ;; + m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | h8500-* | d10v-*) # CYGNUS LOCAL + ;; + mips64vr4300-* | mips64vr4300el-*) # CYGNUS LOCAL jsmith/vr4300 + ;; + mips64vr4100-* | mips64vr4100el-*) # CYGNUS LOCAL jsmith/vr4100 + ;; + mips16-*) # CYGNUS LOCAL krk/mips16 + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) # CYGNUS LOCAL + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) # CYGNUS LOCAL + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) # CYGNUS LOCAL + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigados) + basic_machine=m68k-cbm + os=-amigados + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) # CYGNUS LOCAL + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) # CYGNUS LOCAL + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) # CYGNUS LOCAL + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) # CYGNUS LOCAL + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + w89k-*) # CYGNUS LOCAL + basic_machine=hppa1.1-winbond + os=-proelf + ;; + op50n-*) # CYGNUS LOCAL + basic_machine=hppa1.1-oki + os=-proelf + ;; + op60c-*) # CYGNUS LOCAL + basic_machine=hppa1.1-oki + os=-proelf + ;; + hppro) # CYGNUS LOCAL + basic_machine=hppa1.1-hp + os=-proelf + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) # CYGNUS LOCAL + basic_machine=hppa1.1-hp + os=-osf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + os=-mvs + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[3456]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[3456]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[3456]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[3456]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) # CYGNUS LOCAL + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) # CYGNUS LOCAL + basic_machine=i386-unknown + os=-vsta + ;; + i386-go32 | go32) # CYGNUS LOCAL + basic_machine=i386-unknown + os=-go32 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) # CYGNUS LOCAL + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) # CYGNUS LOCAL + basic_machine=i386-unknown + os=-msdos + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown # CYGNUS LOCAL + os=-netbsd + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) # CYGNUS LOCAL + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) # CYGNUS LOCAL + basic_machine=i960-intel + os=-mon960 + ;; + np1) + basic_machine=np1-gould + ;; + OSE68000 | ose68000) # CYGNUS LOCAL + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) # CYGNUS LOCAL + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5) + basic_machine=i586-intel + ;; + pentiumpro | p6) + basic_machine=i686-intel + ;; + pentium-* | p5-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + k5) + # We don't have specific support for AMD's K5 yet, so just call it a Pentium + basic_machine=i586-amd + ;; + nexen) + # We don't have specific support for Nexgen yet, so just call it a Pentium + basic_machine=i586-nexgen + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rom68k) # CYGNUS LOCAL + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) # CYGNUS LOCAL + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) # CYGNUS LOCAL + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) # CYGNUS LOCAL + basic_machine=m68k-tandem + ;; + stratus) # CYGNUS LOCAL + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) # CYGNUS LOCAL + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) # CYGNUS LOCAL + basic_machine=w65-wdc + os=-none + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) # CYGNUS LOCAL + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) # CYGNUS LOCAL + basic_machine=hppa1.1-winbond + ;; + op50n) # CYGNUS LOCAL + basic_machine=hppa1.1-oki + ;; + op60c) # CYGNUS LOCAL + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) # CYGNUS LOCAL + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) # CYGNUS LOCAL + basic_machine=powerpc-apple + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -unixware* | svr4*) + os=-sysv4 + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + # CYGNUS LOCAL + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mon960* | -lnews* ) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + # END CYGNUS LOCAL + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) # CYGNUS LOCAL + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) # CYGNUS LOCAL + os=-ose + ;; + -es1800*) # CYGNUS LOCAL + os=-ose + ;; + -xenix) + os=-xenix + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) # CYGNUS LOCAL + os=-aout + ;; + mips*-cisco) # CYGNUS LOCAL + os=-elf + ;; + mips*-*) # CYGNUS LOCAL + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) # CYGNUS LOCAL + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) # CYGNUS LOCAL + os=-proelf + ;; + *-winbond) # CYGNUS LOCAL + os=-proelf + ;; + *-oki) # CYGNUS LOCAL + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigados + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *-rom68k) # CYGNUS LOCAL + os=-coff + ;; + *-*bug) # CYGNUS LOCAL + os=-coff + ;; + *-apple) # CYGNUS LOCAL + os=-macos + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) # CYGNUS LOCAL + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) # CYGNUS LOCAL + vendor=hitachi + ;; + -mpw* | -macos*) # CYGNUS LOCAL + vendor=apple + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/config/ChangeLog b/config/ChangeLog new file mode 100644 index 000000000000..b68a85c7a214 --- /dev/null +++ b/config/ChangeLog @@ -0,0 +1,312 @@ +Wed Jul 23 12:32:18 1997 Robert Hoehne + + * mh-go32 (CFLAGS): Don't set -fno-omit-frame-pointer. + +Mon Jun 16 19:06:41 1997 Geoff Keating + + * mh-ppcpic: New file. + * mt-ppcpic: New file. + +Thu Mar 27 15:52:40 1997 Geoffrey Noer + + * mh-cygwin32: override CXXFLAGS, setting to -O2 only + (no debug) + +Tue Mar 25 18:16:43 1997 Geoffrey Noer + + * mh-cygwin32: override LIBGCC2_DEBUG_CFLAGS so debug info + isn't included in cygwin32-hosted libgcc2.a by default + +Wed Jan 8 19:56:43 1997 Geoffrey Noer + + * mh-cygwin32: override CFLAGS so debug info isn't included + in cygwin32-hosted tools by default + +Tue Dec 31 16:04:26 1996 Ian Lance Taylor + + * mh-linux: Remove. + +Mon Nov 11 10:29:51 1996 Michael Meissner + + * mt-ppc: Delete file, options moved to newlib configure. + +Fri Oct 4 12:21:03 1996 Angela Marie Thomas (angela@cygnus.com) + + * mh-dgux386: New file. x86 dgux specific flags + +Mon Sep 30 15:10:07 1996 Stan Shebs + + * mpw-mh-mpw (EXTRALIBS_PPC_XCOFF): New, was EXTRALIBS_PPC. + (EXTRALIBS_PPC): Use shared libraries instead of xcoff. + +Sat Aug 17 04:56:25 1996 Geoffrey Noer + + * mh-cygwin32: don't -D_WIN32 here anymore + +Thu Aug 15 19:46:44 1996 Stan Shebs + + * mpw-mh-mpw (SEGFLAG_68K, SEGFLAG_PPC): Remove. + (EXTRALIBS_PPC): Add libgcc.xcoff. + +Thu Aug 8 14:51:47 1996 Michael Meissner + + * mt-ppc: New file, add -mrelocatable-lib and -mno-eabi to all + target builds for PowerPC eabi targets. + +Fri Jul 12 12:06:01 1996 Stan Shebs + + * mpw: New subdir, Mac MPW configuration support bits. + +Mon Jul 8 17:30:52 1996 Jim Wilson + + * mh-irix6: New file. + +Mon Jul 8 15:15:37 1996 Jason Merrill + + * mt-sparcpic (PICFLAG_FOR_TARGET): Use -fPIC. + +Fri Jul 5 11:49:02 1996 Ian Lance Taylor + + * mh-irix4 (RANLIB): Don't define; Irix 4 does have ranlib. + +Sun Jun 23 22:59:25 1996 Geoffrey Noer + + * mh-cygwin32: new file. Like mh-go32 without the CFLAGS entry. + +Tue Mar 26 14:10:41 1996 Ian Lance Taylor + + * mh-go32 (CFLAGS): Define. + +Thu Mar 14 19:20:54 1996 Ian Lance Taylor + + * mh-necv4: New file. + +Thu Feb 15 13:07:43 1996 Ian Lance Taylor + + * mh-cxux (CC): New variable. + (CFLAGS, LDFLAGS): Remove. + * mh-ncrsvr43 (CC): New variable. + (CFLAGS): Remove. + * mh-solaris (CFLAGS): Remove. + + * mh-go32: Remove most variable settings, since they presumed a + Canadian Cross, which is now handled correctly by the configure + script. + + * mh-sparcpic (PICFLAG): Set to -fPIC, not -fpic. + +Mon Feb 12 14:53:39 1996 Andreas Schwab + + * mh-m68kpic, mt-m68kpic: New files. + +Thu Feb 1 14:15:42 1996 Stan Shebs + + * mpw-mh-mpw (CC_MWC68K): Add options similar to those used + in CC_MWCPPC, and -mc68020 -model far. + (AR_MWLINK68K): Add -xm library. + (AR_AR): Define. + (CC_LD_MWLINK68K): Remove -d. + (EXTRALIBS_MWC68K): Define. + +Thu Jan 25 16:05:33 1996 Ian Lance Taylor + + * mh-ncrsvr43 (CFLAGS): Remove -Hnocopyr. + +Tue Nov 7 15:41:30 1995 Stan Shebs + + * mpw-mh-mpw (CC_MWC68K, CC_MWCPPC): Remove unused include path. + (CC_MWCPPC): Add -mpw_chars, disable warnings, add comments + explaining reasons for various flags. + (EXTRALIBS_PPC, EXTRALIBS_MWCPPC ): Put runtime library first. + +Fri Oct 13 14:44:25 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * mh-aix, mh-sun: Removed. + + * mh-decstation (X11_EXTRA_CFLAGS): Define. + + * mh-sco, mh-solaris, mh-sysv4 (X11_EXTRA_LIBS): Define. + + * mh-hp300, mh-hpux, mh-hpux8, mh-solaris, mh-sun3, mh-sysv4: Don't + hardcode location of X stuff here. + +Thu Sep 28 13:14:56 1995 Stan Shebs + + * mpw-mh-mpw: Add definitions for various 68K and PowerMac + compilers, add definitions for library and link steps for + PowerMacs. + +Thu Sep 14 08:20:04 1995 Fred Fish + + * mh-hp300 (CC): Add "CC = cc -Wp,-H256000" to avoid + "too much defining" errors from the HPUX compiler. + +Thu Aug 17 17:28:56 1995 Ken Raeburn + + * mh-hp300 (RANLIB): Use "ar ts", in case GNU ar was used and + didn't build a symbol table. + +Thu Jun 22 17:47:24 1995 Stan Shebs + + * mpw-mh-mpw (CC): Define ANSI_PROTOTYPES. + +Mon Apr 10 12:29:48 1995 Stan Shebs + + * mpw-mh-mpw (EXTRALIBS): Always link in Math.o, CSANELIB.o, + and ToolLibs.o. + + * mpw-mh-mpw (CC): Define ALMOST_STDC. + (CFLAGS): Remove ALMOST_STDC, -mc68881. + (LDFLAGS): add -w. + + * mpw-mh-mpw (CFLAGS): Add -b option to put strings at the ends of + functions. + + * mpw-mh-mpw: New file, host makefile definitions for MPW. + +Fri Mar 31 11:35:17 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * mt-netware: New file. + +Mon Mar 13 12:31:29 1995 Ian Lance Taylor + + * mh-hpux8: New file. + * mh-hpux: Use X11R5 rather than X11R4. + +Thu Feb 9 11:04:13 1995 Ian Lance Taylor + + * mh-linux (SYSV): Don't define. + (RANLIB): Don't define. + +Wed Jan 11 16:29:34 1995 Jason Merrill + + * m?-*pic (LIBCXXFLAGS): Add -fno-implicit-templates. + +Thu Nov 3 17:27:19 1994 Ken Raeburn + + * mh-irix4 (CC): Increase maximum string length. + + * mh-sco (CC): Define away const, it doesn't work right; elements + of arrays of ptr-to-const are considered const themselves. + +Sat Jul 16 12:17:49 1994 Stan Shebs (shebs@andros.cygnus.com) + + * mh-cxux: New file, from Bob Rusk (rrusk@mail.csd.harris.com). + +Sat Jun 4 17:22:12 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * mh-ncrsvr43: New file from Tom McConnell + . + +Thu May 19 00:32:11 1994 Jeff Law (law@snake.cs.utah.edu) + + * mh-hpux (CC): Add -Wp,-H256000 to avoid "too much defining" + errors from the HPUX 8 compilers. + +Wed May 4 20:14:47 1994 D. V. Henkel-Wallace (gumby@cygnus.com) + + * mh-lynxrs6k: set SHELL to /bin/bash + +Tue Apr 12 12:38:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * mh-irix4 (CC): Change -XNh1500 to -XNh2000. + +Sat Dec 25 20:03:45 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + * mt-hppa: Delete. + +Tue Nov 16 22:54:39 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * mh-a68bsd: Define CC to gcc. + +Mon Nov 15 16:56:51 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * mh-linux: Don't put -static in LDFLAGS. Add comments. + +Mon Nov 15 13:37:58 1993 david d `zoo' zuhn (zoo@cirdan.cygnus.com) + + * mh-sysv4 (AR_FLAGS): change from cq to cr + +Fri Nov 5 08:12:32 1993 D. V. Henkel-Wallace (gumby@blues.cygnus.com) + + * mh-unixware: remove. It's the same as sysv4, and config.guess + can't tell the difference. So don't allow skew. + +Wed Oct 20 20:35:14 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * mh-hp300: Revert yesterday's change, but add comment explaining. + +Tue Oct 19 18:58:21 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * mh-hp300: Don't define CFLAGS to empty. Why should hp300 be + different from anything else? ("gdb doesn't understand the native + debug format" isn't a good enough answer because we might be using + gcc). + +Tue Oct 5 12:17:40 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * mh-alphaosf: Remove, no longer necessary now that gdb knows + how to handle OSF/1 shared libraries. + +Tue Jul 6 11:27:33 1993 Steve Chamberlain (sac@phydeaux.cygnus.com) + + * mh-alphaosf: New file. + +Thu Jul 1 15:49:33 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * mh-riscos: New file. + +Mon Jun 14 12:03:18 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com) + + * mh-aix, mh-aix386, mh-decstation, mh-delta88, mh-hpux, mh-irix4, + mh-ncr3000, mh-solaris, mh-sysv, mh-sysv4: remove INSTALL=cp line, + now that we're using install.sh globally + +Fri Jun 4 16:09:34 1993 Ian Lance Taylor (ian@cygnus.com) + + * mh-sysv4 (INSTALL): Use cp, not /usr/ucb/install. + +Thu Apr 8 11:21:52 1993 Ian Lance Taylor (ian@cygnus.com) + + * mt-a29k, mt-ebmon29k, mt-os68k, mt-ose68000, mt-ose68k, + mt-vxworks68, mt-vxworks960: Removed obsolete, unused target + Makefile fragment files. + +Mon Mar 8 15:05:25 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * mh-aix386: New file; old mh-aix, plus no-op RANLIB. + +Thu Oct 1 13:50:48 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * mh-solaris: INSTALL is NOT /usr/ucb/install + +Mon Aug 24 14:25:35 1992 Ian Lance Taylor (ian@cygnus.com) + + * mt-ose68000, mt-ose68k: renamed from mt-OSE*. + +Tue Jul 21 02:11:01 1992 D. V. Henkel-Wallace (gumby@cygnus.com) + + * mt-OSE68k, mt-680000: new configs. + +Thu Jul 16 17:12:09 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * mh-irix4: merged changes from progressive. + +Tue Jun 9 23:29:38 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Everywhere: Change RANLIB=echo>/dev/null (which confuses + some shells - and I don't blame them) to RANLIB=true. + * mh-solaris: Use /usr/ucb/install for INSTALL. + +Sun May 31 14:45:23 1992 Mark Eichin (eichin at cygnus.com) + + * mh-solaris2: Add new configuration for Solaris 2 (sysv, no ranlib) + +Fri Apr 10 23:10:08 1992 Fred Fish (fnf@cygnus.com) + + * mh-ncr3000: Add new configuration for NCR 3000. + +Tue Dec 10 00:10:55 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * ChangeLog: fresh changelog. + diff --git a/config/mh-a68bsd b/config/mh-a68bsd new file mode 100644 index 000000000000..c991289dd5f4 --- /dev/null +++ b/config/mh-a68bsd @@ -0,0 +1,12 @@ +RANLIB=true + +#None of the Apollo compilers can compile gas or binutils. The preprocessor +# chokes on bfd, the compiler won't let you assign integers to enums, and +# other problems. Defining CC to gcc is a questionable way to say "don't use +# the apollo compiler" (the preferred version of GCC could be called cc, +# or whatever), but I'm not sure leaving CC as cc is any better... + +#CC=cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DNO_STDARG +CC=gcc + +BISON=yacc diff --git a/config/mh-aix386 b/config/mh-aix386 new file mode 100644 index 000000000000..4accd1cddfbe --- /dev/null +++ b/config/mh-aix386 @@ -0,0 +1 @@ +RANLIB = @: diff --git a/config/mh-apollo68 b/config/mh-apollo68 new file mode 100644 index 000000000000..4497ed935853 --- /dev/null +++ b/config/mh-apollo68 @@ -0,0 +1,3 @@ +HDEFINES = -DUSG +RANLIB=true +CC= cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DUSG diff --git a/config/mh-cxux b/config/mh-cxux new file mode 100644 index 000000000000..54b2a16c8345 --- /dev/null +++ b/config/mh-cxux @@ -0,0 +1,14 @@ +# Configuration for Harris CX/UX 7 (and maybe 6), based on sysv4 configuration. + +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV -DSVR4 +RANLIB = true + +# C++ debugging is not yet supported under SVR4 (DWARF) +CXXFLAGS=-O + +# The l flag generates a warning from the SVR4 archiver, remove it. +AR_FLAGS = cq + +# Under CX/UX, we want to tell the compiler to use ANSI mode. +CC=cc -Xa diff --git a/config/mh-cygwin32 b/config/mh-cygwin32 new file mode 100644 index 000000000000..3f6c1c6cbeb3 --- /dev/null +++ b/config/mh-cygwin32 @@ -0,0 +1,16 @@ +# We don't want debugging info in Win32-hosted toolchains. +# Accomplish this by overriding CFLAGS. +CFLAGS=-O2 +CXXFLAGS=-O2 + +# We also need to override LIBGCC2_DEBUG_CFLAGS so libgcc2 will be +# build without debugging information + +LIBGCC2_DEBUG_CFLAGS= + +# We set MAKEINFOFLAGS to not split .info files, because the resulting +# file names don't work on DOS. +MAKEINFOFLAGS=--no-split + +# custom installation rules for cygwin32 (append .exe to binaries, etc.) +INSTALL_DOSREL=install-dosrel diff --git a/config/mh-decstation b/config/mh-decstation new file mode 100644 index 000000000000..37201926d5fb --- /dev/null +++ b/config/mh-decstation @@ -0,0 +1,5 @@ +CC = cc -Wf,-XNg1000 + +# for X11, since the native DECwindows include files are really broken when +# it comes to function prototypes. +X11_EXTRA_CFLAGS = "-DNeedFunctionPrototypes=0" diff --git a/config/mh-delta88 b/config/mh-delta88 new file mode 100644 index 000000000000..bc9c45302d55 --- /dev/null +++ b/config/mh-delta88 @@ -0,0 +1,4 @@ +RANLIB = true + + + diff --git a/config/mh-dgux b/config/mh-dgux new file mode 100644 index 000000000000..e7d85d6126a1 --- /dev/null +++ b/config/mh-dgux @@ -0,0 +1,4 @@ +HDEFINES=-DHOST_SYS=DGUX_SYS +CC=gcc -Wall -ansi -D__using_DGUX +RANLIB=true + diff --git a/config/mh-dgux386 b/config/mh-dgux386 new file mode 100644 index 000000000000..15885c3e0426 --- /dev/null +++ b/config/mh-dgux386 @@ -0,0 +1,22 @@ +# from mh-dgux +HDEFINES=-DHOST_SYS=DGUX_SYS +CC=gcc -Wall -ansi -D__using_DGUX +RANLIB = true + +# from mh-sysv4 +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV -DSVR4 +RANLIB = true + +# C++ debugging is not yet supported under SVR4 (DWARF) +CXXFLAGS=-O + +# The l flag generates a warning from the SVR4 archiver, remove it. +AR_FLAGS = cr + +X11_EXTRA_LIBS = -lnsl + +# from angela +# no debugging due to broken compiler, use BSD style timeofday +CFLAGS=-O -D_BSD_TIMEOFDAY_FLAVOR + diff --git a/config/mh-go32 b/config/mh-go32 new file mode 100644 index 000000000000..f12007b0e0fb --- /dev/null +++ b/config/mh-go32 @@ -0,0 +1,4 @@ +# We don't want to use debugging information on DOS. Unfortunately, +# this requires that we set CFLAGS. +# This used to set -fno-omit-frame-pointer. +CFLAGS=-O2 diff --git a/config/mh-hp300 b/config/mh-hp300 new file mode 100644 index 000000000000..761724d92de0 --- /dev/null +++ b/config/mh-hp300 @@ -0,0 +1,13 @@ +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV +# Avoid "too much defining" errors from HPUX compiler. +CC = cc -Wp,-H256000 +# If "ar" in $PATH is GNU ar, the symbol table may need rebuilding. +# If it's HP/UX ar, this should be harmless. +RANLIB = ar ts + +# Native cc can't bootstrap gcc with -g. Defining CFLAGS here loses (a) +# for non-gcc directories, (b) if we are compiling with gcc, not +# native cc. Neither (a) nor (b) has a trivial fix though. + +CFLAGS = diff --git a/config/mh-hpux b/config/mh-hpux new file mode 100644 index 000000000000..4d71c9dc837b --- /dev/null +++ b/config/mh-hpux @@ -0,0 +1,4 @@ +# Define SYSV as -DSYSV if you are using a System V operating system. +CC = cc -Wp,-H256000 +SYSV = -DSYSV +RANLIB = true diff --git a/config/mh-hpux8 b/config/mh-hpux8 new file mode 100644 index 000000000000..4d71c9dc837b --- /dev/null +++ b/config/mh-hpux8 @@ -0,0 +1,4 @@ +# Define SYSV as -DSYSV if you are using a System V operating system. +CC = cc -Wp,-H256000 +SYSV = -DSYSV +RANLIB = true diff --git a/config/mh-irix4 b/config/mh-irix4 new file mode 100644 index 000000000000..6872145e833a --- /dev/null +++ b/config/mh-irix4 @@ -0,0 +1,7 @@ +# Makefile changes for SGI's running IRIX-4.x. +# Tell compiler to use K&R C. We can't compile under the SGI Ansi +# environment. Also bump switch table size so that cp-parse will +# compile. Bump string length limit so linker builds. + +CC = cc -cckr -Wf,-XNg1500 -Wf,-XNk1000 -Wf,-XNh2000 -Wf,-XNl8192 +SYSV = -DSYSV diff --git a/config/mh-irix5 b/config/mh-irix5 new file mode 100644 index 000000000000..8bd7c99f844b --- /dev/null +++ b/config/mh-irix5 @@ -0,0 +1,3 @@ +# Makefile changes for SGI's running IRIX-5.x. +SYSV = -DSYSV +RANLIB = true diff --git a/config/mh-irix6 b/config/mh-irix6 new file mode 100644 index 000000000000..6d25c16b2f45 --- /dev/null +++ b/config/mh-irix6 @@ -0,0 +1,7 @@ +# Makefile changes for SGI's running IRIX-6.x. +SYSV = -DSYSV +RANLIB = true +# Specify the ABI, to ensure that all Irix 6 systems will behave the same. +# Also, using -32 avoids bugs that exist in the n32/n64 support in some +# versions of the SGI compiler. +CC = cc -32 diff --git a/config/mh-lynxos b/config/mh-lynxos new file mode 100644 index 000000000000..9afcb79fca7c --- /dev/null +++ b/config/mh-lynxos @@ -0,0 +1,2 @@ +# /bin/cc is less than useful for our purposes. Always use GCC +CC = /bin/gcc diff --git a/config/mh-lynxrs6k b/config/mh-lynxrs6k new file mode 100644 index 000000000000..b2793996eff3 --- /dev/null +++ b/config/mh-lynxrs6k @@ -0,0 +1,8 @@ +# LynxOS running on the rs6000 doesn't have ranlib +RANLIB = true + +# /bin/cc is less than useful for our purposes. Always use GCC +CC = /usr/cygnus/progressive/bin/gcc + +# /bin/sh is too buggy, so use /bin/bash instead. +SHELL = /bin/bash diff --git a/config/mh-m68kpic b/config/mh-m68kpic new file mode 100644 index 000000000000..92e48d90fbdf --- /dev/null +++ b/config/mh-m68kpic @@ -0,0 +1 @@ +PICFLAG=-fpic diff --git a/config/mh-ncr3000 b/config/mh-ncr3000 new file mode 100644 index 000000000000..5bbd8037009f --- /dev/null +++ b/config/mh-ncr3000 @@ -0,0 +1,17 @@ +# Host configuration file for an NCR 3000 (i486/SVR4) system. + +# The NCR 3000 ships with a MetaWare compiler installed as /bin/cc. +# This compiler not only emits obnoxious copyright messages every time +# you run it, but it chokes and dies on a whole bunch of GNU source +# files. Default to using the AT&T compiler installed in /usr/ccs/ATT/cc. +# Unfortunately though, the AT&T compiler sometimes generates code that +# the assembler barfs on if -g is used, so disable it by default as well. +CC = /usr/ccs/ATT/cc +CFLAGS = + +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV -DSVR4 +RANLIB = true + +# The l flag generates a warning from the SVR4 archiver, remove it. +AR_FLAGS = cq diff --git a/config/mh-ncrsvr43 b/config/mh-ncrsvr43 new file mode 100644 index 000000000000..43b09912ca91 --- /dev/null +++ b/config/mh-ncrsvr43 @@ -0,0 +1,9 @@ +# Host configuration file for an NCR 3000 (i486/SVR43) system. + +# The MetaWare compiler will generate a copyright message unless you +# turn it off by adding the -Hnocopyr flag. +CC = cc -Hnocopyr + +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV -DSVR4 +RANLIB = true diff --git a/config/mh-necv4 b/config/mh-necv4 new file mode 100644 index 000000000000..e887736f8bed --- /dev/null +++ b/config/mh-necv4 @@ -0,0 +1,11 @@ +# Host Makefile fragment for NEC MIPS SVR4. + +# The C compiler on NEC MIPS SVR4 needs bigger tables. +CC = cc -ZXNd=5000 -ZXNg=1000 + +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV -DSVR4 +RANLIB = true + +# NEC -lX11 needs some other libraries. +X11_EXTRA_LIBS = -lsocket -lnsl diff --git a/config/mh-papic b/config/mh-papic new file mode 100644 index 000000000000..35cf2c8ee4e3 --- /dev/null +++ b/config/mh-papic @@ -0,0 +1 @@ +PICFLAG=-fPIC diff --git a/config/mh-ppcpic b/config/mh-ppcpic new file mode 100644 index 000000000000..35cf2c8ee4e3 --- /dev/null +++ b/config/mh-ppcpic @@ -0,0 +1 @@ +PICFLAG=-fPIC diff --git a/config/mh-riscos b/config/mh-riscos new file mode 100644 index 000000000000..e586b30b1a90 --- /dev/null +++ b/config/mh-riscos @@ -0,0 +1,15 @@ +# This is for a MIPS running RISC/os 4.52C. + +# This is needed for GDB, but needs to be in the top-level make because +# if a library is compiled with the bsd headers and gets linked with the +# sysv system libraries all hell can break loose (e.g. a jmp_buf might be +# a different size). +# ptrace(2) apparently has problems in the BSD environment. No workaround is +# known except to select the sysv environment. Could we use /proc instead? +# These "sysv environments" and "bsd environments" often end up being a pain. +# +# This is not part of CFLAGS because perhaps not all C compilers have this +# option. +CC= cc -systype sysv + +RANLIB = true diff --git a/config/mh-sco b/config/mh-sco new file mode 100644 index 000000000000..cc337c98f937 --- /dev/null +++ b/config/mh-sco @@ -0,0 +1,10 @@ +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV +RANLIB = true +# You may need this if you don't have bison. +# BISON = yacc -Sm10400 +# The native C compiler botches some simple uses of const. Unfortunately, +# it doesn't defined anything like "__sco__" for us to test for in ansidecl.h. +CC = cc -Dconst= + +X11_EXTRA_LIBS = -lsocket -lm -lintl -lmalloc diff --git a/config/mh-solaris b/config/mh-solaris new file mode 100644 index 000000000000..ddbea549b937 --- /dev/null +++ b/config/mh-solaris @@ -0,0 +1,6 @@ +# Makefile changes for Suns running Solaris 2 + +SYSV = -DSYSV +RANLIB = true + +X11_EXTRA_LIBS = -lnsl -lsocket diff --git a/config/mh-sparcpic b/config/mh-sparcpic new file mode 100644 index 000000000000..35cf2c8ee4e3 --- /dev/null +++ b/config/mh-sparcpic @@ -0,0 +1 @@ +PICFLAG=-fPIC diff --git a/config/mh-sun3 b/config/mh-sun3 new file mode 100644 index 000000000000..dcd5155b736c --- /dev/null +++ b/config/mh-sun3 @@ -0,0 +1,3 @@ +# Sun's C compiler needs the -J flag to be able to compile cp-parse.c +# without overflowing the jump tables (-J says to use a 32 bit table) +CC = cc -J diff --git a/config/mh-sysv b/config/mh-sysv new file mode 100644 index 000000000000..16b1187b4471 --- /dev/null +++ b/config/mh-sysv @@ -0,0 +1,3 @@ +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV +RANLIB = true diff --git a/config/mh-sysv4 b/config/mh-sysv4 new file mode 100644 index 000000000000..810665106000 --- /dev/null +++ b/config/mh-sysv4 @@ -0,0 +1,11 @@ +# Define SYSV as -DSYSV if you are using a System V operating system. +SYSV = -DSYSV -DSVR4 +RANLIB = true + +# C++ debugging is not yet supported under SVR4 (DWARF) +CXXFLAGS=-O + +# The l flag generates a warning from the SVR4 archiver, remove it. +AR_FLAGS = cr + +X11_EXTRA_LIBS = -lnsl diff --git a/config/mh-vaxult2 b/config/mh-vaxult2 new file mode 100644 index 000000000000..3de2dc8ffe3e --- /dev/null +++ b/config/mh-vaxult2 @@ -0,0 +1,2 @@ +# The old BSD pcc isn't up to compiling parts of gdb so use gcc +CC = gcc diff --git a/config/mh-windows b/config/mh-windows new file mode 100644 index 000000000000..a5cc5d611df0 --- /dev/null +++ b/config/mh-windows @@ -0,0 +1,16 @@ +CC=cc +CFLAGS= +RANLIB=true +AR_FLAGS= + +.PHONY: windows +windows: nmake.mak + @echo "Don't forget to setup setvars.mak!" + +nmake.mak: to-be-built + @echo Building nmake files + @$(srcdir)/gdb/mswin/genmakes + +to-be-built: + @echo Recording commands + @$(srcdir)/gdb/mswin/recordit diff --git a/config/mh-x86pic b/config/mh-x86pic new file mode 100644 index 000000000000..92e48d90fbdf --- /dev/null +++ b/config/mh-x86pic @@ -0,0 +1 @@ +PICFLAG=-fpic diff --git a/config/mpw-mh-mpw b/config/mpw-mh-mpw new file mode 100644 index 000000000000..543ef4fb2a12 --- /dev/null +++ b/config/mpw-mh-mpw @@ -0,0 +1,157 @@ +# This is an MPW makefile fragment. + +# Since there are a multiplicity of Mac compilers and two different +# processors, this file is primarily a library of options for each +# compiler. Somebody else (such as a configure or build script) will +# make the actual choice. + +# Compiler to use for compiling. + +CC_MPW_C = C -d MPW_C -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -mc68020 -model far -b -w + +CC_SC = SC -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -mc68020 -model far -b -i '' -i : + +CC_MWC68K = MWC68K -d MPW -enum int -mpw_chars -sym on -w off -mc68020 -model far + +CC_PPCC = PPCC -d powerc=1 -d pascal= -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -w + +CC_MRC = MrC -d powerc=1 -d pascal= -d ALMOST_STDC -d ANSI_PROTOTYPES -d MPW -i '' -i : -jm + +CC_SMrC = SMrC -d MPW + +# "-mpw_chars" is necessary because GNU sources often mix signed and +# unsigned casually. +# "-w off" is not a great idea, but CW7 is complaining about enum +# assignments. +# "-opt global,peep,l4,speed" is sometimes good, and sometimes bad. +# We must use {CIncludes} so that MPW tools will work; {MWCIncludes} +# defines stdout, islower, etc, in ways that are incompatible with MPW's +# runtime. However, this cannot be done via -i "{CIncludes}", since +# that does not affect how <>-type includes happen; instead, the variable +# MWCIncludes must be set to point at {CIncludes}. + +CC_MWCPPC = MWCPPC -d MPW -enum int -mpw_chars -sym on -w off + +# Note that GCC does *not* wire in a definition of "pascal", so that +# it can be handled in another way if desired. + +CC_68K_GCC = gC -Dpascal= -DANSI_PROTOTYPES -DMPW + +CC_PPC_GCC = gC -Dpowerc=1 -Dpascal= -DANSI_PROTOTYPES -DMPW + +# Nothing for the default CFLAGS. + +CFLAGS = + +# Tool to use for making libraries/archives. + +AR_LIB = Lib + +AR_MWLINK68K = MWLink68K -xm library + +AR_PPCLINK = PPCLink -xm library + +AR_MWLINKPPC = MWLinkPPC -xm library + +AR_AR = ar + +AR_FLAGS = -o + +RANLIB_NULL = null-command + +RANLIB_RANLIB = ranlib + +# Compiler and/or linker to use for linking. + +CC_LD_LINK = Link -w -d -model far {CC_LD_TOOL_FLAGS} + +CC_LD_MWLINK68K = MWLink68K -w {CC_LD_TOOL_FLAGS} -sym on -model far + +CC_LD_PPCLINK = PPCLink -main __start -outputformat xcoff + +CC_LD_MWLINKPPC = MWLinkPPC -w {CC_LD_TOOL_FLAGS} -sym on + +CC_LD_GLD = gC + +# Extension for linker output. + +PROG_EXT_68K = + +PROG_EXT_XCOFF = .xcoff + +# Nothing for the default LDFLAGS. + +LDFLAGS = -w + +CC_LD_TOOL_FLAGS = -c 'MPS ' -t MPST + +# Libraries to link against. + +# It would appear that the math libraries are not +# needed except to provide a definition for scalb, +# which is called from ldexp, which is referenced +# in the m68k opcodes library. + +EXTRALIBS_C = \Option-d + "{CLibraries}"StdClib.o \Option-d + "{CLibraries}"Math.o \Option-d + "{CLibraries}"CSANELib.o \Option-d + "{Libraries}"Stubs.o \Option-d + "{Libraries}"Runtime.o \Option-d + "{Libraries}"Interface.o \Option-d + "{Libraries}"ToolLibs.o + +EXTRALIBS_MWC68K = \Option-d + "{CLibraries}"StdClib.o \Option-d + "{CLibraries}"Math.o \Option-d + "{CLibraries}"CSANELib.o \Option-d + "{Libraries}"Stubs.o \Option-d + "{Libraries}"Runtime.o \Option-d + "{Libraries}"Interface.o \Option-d + "{Libraries}"ToolLibs.o \Option-d + "{MW68KLibraries}MPW ANSI (4i) C.68K.Lib" + +EXTRALIBS_PPC_XCOFF = \Option-d + "{PPCLibraries}"StdCRuntime.o \Option-d + "{PPCLibraries}"InterfaceLib.xcoff \Option-d + "{PPCLibraries}"MathLib.xcoff \Option-d + "{PPCLibraries}"StdCLib.xcoff \Option-d + "{PPCLibraries}"PPCToolLibs.o \Option-d + "{PPCLibraries}"PPCCRuntime.o \Option-d + "{GCCPPCLibraries}"libgcc.xcoff + +EXTRALIBS_PPC = \Option-d + "{PPCLibraries}"StdCRuntime.o \Option-d + "{SharedLibraries}"InterfaceLib \Option-d + "{SharedLibraries}"MathLib \Option-d + "{SharedLibraries}"StdCLib \Option-d + "{PPCLibraries}"PPCToolLibs.o \Option-d + "{PPCLibraries}"PPCCRuntime.o \Option-d + "{GCCPPCLibraries}"libgcc.xcoff + +EXTRALIBS_MWCPPC = \Option-d + "{MWPPCLibraries}"MWStdCRuntime.Lib \Option-d + "{MWPPCLibraries}"InterfaceLib \Option-d + "{MWPPCLibraries}"StdCLib \Option-d + "{MWPPCLibraries}"MathLib \Option-d + "{MWPPCLibraries}"PPCToolLibs.o + +# Tool to make PEF with, if needed. + +MAKEPEF_NULL = null-command + +MAKEPEF_PPC = MakePEF + +MAKEPEF_FLAGS = \Option-d + -l InterfaceLib.xcoff=InterfaceLib \Option-d + -l MathLib.xcoff=MathLib \Option-d + -l StdCLib.xcoff=StdCLib + +MAKEPEF_TOOL_FLAGS = -ft MPST -fc 'MPS ' + +# Resource compiler to use. + +REZ_68K = Rez + +REZ_PPC = Rez -d WANT_CFRG + diff --git a/config/mpw/ChangeLog b/config/mpw/ChangeLog new file mode 100644 index 000000000000..3cdefbf7a750 --- /dev/null +++ b/config/mpw/ChangeLog @@ -0,0 +1,53 @@ +Tue Nov 26 12:34:12 1996 Stan Shebs + + * g-mpw-make.sed: Fix some comments. + +Mon Sep 16 14:42:52 1996 Stan Shebs + + * g-mpw-make.sed (HLDENV): Edit out all references. + +Thu Aug 15 19:49:23 1996 Stan Shebs + + * true: New script, identical to mpw-true. + * g-mpw-make.sed: Add @DASH_C_FLAG@ and @SEGMENT_FLAG()@ + to the editors for compile commands. + +Thu Aug 1 15:01:42 1996 Stan Shebs + + * mpw-true, mpw-touch, null-command: New scripts. + * README: Describe usage in more detail. + +Tue Dec 12 14:51:51 1995 Stan Shebs + + * g-mpw-make.sed: Don't edit out "version=" occurrences. + +Fri Dec 1 11:46:18 1995 Stan Shebs + + * g-mpw-make.sed (bindir, libdir): Edit the positions of + pathname separators to work with other pathnames better. + +Tue Nov 7 15:08:07 1995 Stan Shebs + + * g-mpw-make.sed: Add comment about Duplicate vs Catenate, + add additional pattern for editing link-compile commands. + +Tue Oct 24 14:28:51 1995 Stan Shebs + + * g-mpw-make.sed: Add handling for *.tab.[hc] files. + (CHILL_FOR_TARGET, CHILL_LIB): Edit out tricky definitions + of these. + +Thu Sep 28 21:05:10 1995 Stan Shebs + + * g-mpw-make.sed: New file, generic sed commands to translate + Unix makefiles into MPW makefile syntax. + +Fri Mar 17 11:51:20 1995 Stan Shebs + + * README: Clarify instructions. + * fi: Remove. + +Wed Dec 21 15:45:53 1994 Stan Shebs + + * MoveIfChange, README, fi, forward-include, open-brace, + tr-7to8-src: New files. diff --git a/config/mpw/MoveIfChange b/config/mpw/MoveIfChange new file mode 100644 index 000000000000..0dbc12582f5f --- /dev/null +++ b/config/mpw/MoveIfChange @@ -0,0 +1,19 @@ +# Rename a file only if it is different from a previously existing +# file of the same name. This is useful for keeping make from doing +# too much work if the contents of a file haven't changed. + +# This is an MPW translation of the standard GNU sh script move-if-change. + +Set exit 0 + +If "`exists -f "{2}"`" + Compare "{1}" "{2}" >dev:null + If {status} != 0 + Rename -y "{1}" "{2}" + Else + Echo "{2}" is unchanged + Delete -i -y "{1}" + End +Else + Rename -y "{1}" "{2}" +End diff --git a/config/mpw/README b/config/mpw/README new file mode 100644 index 000000000000..554700adc810 --- /dev/null +++ b/config/mpw/README @@ -0,0 +1,23 @@ +This directory contains MPW scripts and related files that are needed to +build Cygnus GNU tools for MPW. The scripts should be somewhere on the +command path; our usual practice has been to have a separate directory +for the scripts, and put the tools (byacc, flex, and sed at least) there +also; then it's easier to drag the support bits around as a group, or to +upgrade MPW versions. The complete package of scripts and tool binaries +is usually available as pub/mac/buildtools.cpt.hqx on ftp.cygnus.com. + +"tr-7to8-src" is actually the source to an MPW script that transforms +sequences like "\Option-d" into the actual 8-bit chars that MPW needs. +It's only the source because it can't itself include any 8-bit chars. +It *can* be processed into a genuine "tr-7to8" by using itself: + + tr-7to8 tr-7to8-src | sed -e 's/Src//' >new-tr-7to8 + +Use this to verify: + + compare tr-7to8 new-tr-7to8 + +If you don't have a working tr-7to8, then you will have to manually +replace all occurrences of "\Option-d" with real Option-d (which looks +like a delta), then do similarly with all the other "\Option-..." +strings, and then change "\SrcOption-d" into the string "\Option-d". diff --git a/config/mpw/forward-include b/config/mpw/forward-include new file mode 100644 index 000000000000..ddd6bd711058 --- /dev/null +++ b/config/mpw/forward-include @@ -0,0 +1,3 @@ +Echo '#include' ¶""{1}"¶" >"{2}".tem +MoveIfChange "{2}".tem "{2}" + diff --git a/config/mpw/g-mpw-make.sed b/config/mpw/g-mpw-make.sed new file mode 100644 index 000000000000..e7d3c7707362 --- /dev/null +++ b/config/mpw/g-mpw-make.sed @@ -0,0 +1,293 @@ +# Sed commands to translate Unix makefiles into MPW makefiles. +# These are nominally generic, but work best on the makefiles used +# for GNU programs. + +# Whack out any commented-out lines that are probably commands; +# they can only cause trouble later on. +/^# /d + +# Change dependency char. +/:$/s/:/ \\Option-f/g +/^[^ :#][^:]*:/s/\([ ]*\):\([ ]*\)/ \\Option-f /g + +# Change syntax of Makefile vars. +/\$/s/\${\([a-zA-Z0-9_-]*\)}/{\1}/g +/\$/s/\$(\([a-zA-Z0-9_-]*\))/{\1}/g +/ $@/s/ $@/ {Targ}/ + +# Double-$ are literals to Unix but not to MPW make. +/\$\$/s/\$\$/$/g + +# Change pathname syntax. +/\//s,\.\./\/\.\./,:::,g +/\//s,\.\./,::,g +/\.\//s,\./,:,g +/\//s,/,:,g +# Undo excess changes. +/and/s,and:or$,and/or, +/and/s,and:or ,and/or , +/want/s,want:need,want/need, +# Fixing up sed commands. +/-e/s_":\([^:]*\):d"_"/\1/d"_g +/-e/s_":\([^:]*\):,:\([^:]*\):d"_"/\1/,/\2/d"_g + +/=/s/ = \.$/ = :/ + +# Make these go away so that later edits not confused. +/HLDENV/s/{HLDENV}// + +# Comment out any explicit srcdir setting. +/srcdir/s/^srcdir/# srcdir/ + +/BASEDIR/s/^BASEDIR =.*$/BASEDIR = "{srcroot}"/ +/{BASEDIR}:/s/{BASEDIR}:/{BASEDIR}/g +/{srcdir}:/s/{srcdir}:/"{srcdir}"/g +/"{srcdir}":/s/"{srcdir}":/"{srcdir}"/g + +# Tweak some conventions that are backwards for the Mac. +/bindir/s/{exec_prefix}:bin/{exec_prefix}bin:/ +/libdir/s/{exec_prefix}:lib/{exec_prefix}lib:/ + +# Comment out settings of anything set by mpw host config. +/CC/s/^CC *=/#CC =/ +/CFLAGS/s/^CFLAGS *=/#CFLAGS =/ +/AR/s/^AR *=/#AR =/ +/AR_FLAGS/s/^AR_FLAGS *=/#AR_FLAGS =/ +/RANLIB/s/^RANLIB *=/#RANLIB =/ +/CC_LD/s/^CC_LD *=/#CC_LD =/ +/LDFLAGS/s/^LDFLAGS *=/#LDFLAGS =/ + +# Change -I usages. +/-I/s/-I\./-i :/g +/-I/s/-I::bfd/-i ::bfd:/g +/-I/s/-I::include/-i ::include:/g +/-I/s/-I/-i /g + +# Change -D usage. +/-D/s/\([ =]\)-D\([^ ]*\)/\1-d \2/g + +# Change continuation char. +/\\$/s/\\$/\\Option-d/ + +# Change wildcard char. +/\*/s/\*/\\Option-x/g + +# Change path of various types of source files. This rule does not allow +# for file names with multiple dots in the name. +/\.[chly]/s/\([ ><=]\)\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/\1"{s}"\2.\3/g +/\.[chly]/s/^\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/"{s}"\1.\2/ +# Allow files named *.tab.[ch] as a special case. +/\.tab\.[ch]/s/\([ ><=]\)\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/\1"{s}"\2.\3/g +/\.tab\.[ch]/s/^\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/"{s}"\1.\2/ +# Fix some overenthusiasms. +/{s}/s/"{s}""{srcdir}"/"{srcdir}"/g +/{s}/s/"{s}"{\([a-zA-Z0-9_]*\)dir}/"{\1dir}"/g +/{s}/s/"{s}"{\([a-zA-Z0-9_]*\)DIR}/"{\1DIR}"/g +/{s}/s/"{s}""{\([a-zA-Z0-9_]*\)dir}"/"{\1dir}"/g +/{s}/s/"{s}""{\([a-zA-Z0-9_]*\)DIR}"/"{\1DIR}"/g +/{s}/s/"{s}":/:/g +/{s}/s/^"{s}"//g +/{s}/s/"{s}""{s}"/"{s}"/g +/{s}/s/"{s}""{srcdir}"/"{s}"/g +/{s}/s/"{srcdir}""{s}"/"{s}"/g + +# The .def files are also typically source files. +/\.def/s/\([ ><]\)\([-a-zA-Z0-9_${}:"]*\)\.def/\1"{s}"\2.def/g +/\.def/s/^\([-a-zA-Z0-9_${}:"]*\)\.def/"{s}"\1.def/g + +# Change extension and path of objects. +/\.o/s/\([ =]\)\([-a-zA-Z0-9_${}:"]*\)\.o/\1"{o}"\2.c.o/g +/\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.o/"{o}"\1.c.o/ +# Allow *.tab.o files as a special case of a 2-dot-name file. +/\.o/s/\([ =]\)\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/\1"{o}"\2.tab.c.o/g +/\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/"{o}"\1.tab.c.o/ +# Clean up. +/"{o}"/s/"{o}""{o}"/"{o}"/g +/"{o}"/s/^"{o}"\([a-zA-Z0-9_]*\)=/\1=/ + +# Change extension of libs. +/\.a/s/lib\([a-z]*\)\.a/lib\1.o/g + +# Remove non-fail option. +/-/s/^\([ ]*\)-/\1/ +# Fix overeagernesses - assumes no one-letter commands. +/^[ ]*[a-z] /s/^\([ ]*\)\([a-z]\) /\1-\2 / + +# Remove non-echo option. (watch out for autoconf things) +/@/s/^\([ ]*\)@/\1/ + +# Change cp to Duplicate. +# Catenate is perhaps more accurate, but the pattern would have to +# identify the output file and add a '>' redirection into it. +/cp/s/^\([ ]*\)cp /\1Duplicate -d -y / +# Change mv to Rename. +/mv/s/^\([ ]*\)mv /\1Rename -y / +/Rename/s/^\([ ]*\)Rename -y -f/\1Rename -y/ +# Change rm to Delete. +/rm -rf/s/^\([ ]*\)rm -rf /\1Delete -i -y / +/rm -f/s/^\([ ]*\)rm -f /\1Delete -i -y / +/rm/s/^\([ ]*\)rm /\1Delete -i -y / +# Note that we don't mess with ln - directory-specific scripts +# must decide what to do with symlinks. +# Change cat to Catenate. +/cat/s/^\([ ]*\)cat /\1Catenate / +# Change touch to mpw-touch. +/touch/s/^\([ ]*\)touch /\1mpw-touch / +# Change mkdir to NewFolder. +/mkdir/s/^\([ ]*\)mkdir /\1NewFolder / +# Change var setting to Set. +/=/s/^\([ ]*\)\([-a-zA-Z0-9_]*\)=\([^;]*\); \\Option-d/\1Set \2 \3/ + +# Change tests. +/if /s/if \[ *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/ +/if /s/if \[ *-f \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/ +/if /s/if \[ ! *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/ +/if /s/if \[ ! *-f \([^ ]*\) ] *; *then \\Option-d/If "`Exists "\1"`" == ""/ + +/if /s/if \[ *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/ +/if /s/if \[ *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/ +/if /s/if \[ ! *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/ +/if /s/if \[ ! *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" == ""/ + +/if /s/if \[ -d \([^ ]*\) ] *; then true *; else mkdir \([^ ;]*\) *; fi/If "`Exists "\1"`" != "" NewFolder \2 End If/ + +/if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *\\Option-d/If "\1" == "\2"/ +/if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *then *\\Option-d/If "\1" == "\2"/ + +/if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/ +/if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/ + +/if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/ +/if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/ + +/^[ ]*else true$/c\ + Else\ + mpw-true\ + + +/else/s/^\([ ]*\)else[ ]*$/\1Else/ +/else/s/^\([ ]*\)else[; ]*\\Option-d$/\1Else/ + +/^[ ]*else[ ]*true[ ]*$/c\ + Else\ + mpw-true + +/^[ ]*else[ ]*true[; ]*fi$/c\ + Else\ + mpw-true\ + End If + +/fi/s/^\([ ]*\)fi *$/\1End/ +/fi/s/^\([ ]*\)fi *; *\\Option-d/\1End/ + +# Change looping. +/for/s/^\([ ]*\)for \([-a-zA-Z0-9_]*\) in \([^;]*\); *do *\\Option-d/\1For \2 In \3/ +/^\([ ]*\)do *\\Option-d/d +/done/s/^\([ ]*\)done *; *\\Option-d/\1End/ +/done/s/^\([ ]*\)done$/\1End/ + +# Trailing semicolons and continued lines are unneeded sh syntax. +/; \\Option-d/s/; \\Option-d// + +# Change move-if-change to MoveIfChange. +/move-if-change/s/\([^ ]*\)move-if-change/MoveIfChange/g + +# Change $(SHELL) to the script name by itself. +/SHELL/s/^\([ ]*\){SHELL} /\1/ + +# Change syntax of default rule dependency. +/^\.c\.o/s/^\.c\.o \\Option-f$/.c.o \\Option-f .c/ + +# Change default rule's action. +/{CC} -c/s/{CC} -c \(.*\) \$<$/{CC} @DASH_C_FLAG@ {DepDir}{Default}.c \1 @SEGMENT_FLAG({Default})@ -o {TargDir}{Default}.c.o/ + +# This is pretty disgusting, but I can't seem to detect empty rules. +/Option-f$/s/Option-f$/Option-f _oldest/g + +# Remove -c from explicit compiler calls. (but should not if GCC) +# Handle the case of a source file that is "{xxx}"file.c. +/ -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\)\.c/{\1CC}\2 @DASH_C_FLAG@ \3"\4"\5.c -o "{o}"\5.c.o/ +# Handle the case of a source file that is "{xxx}"dir:file.c. +/ -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\):\([-a-z_]*\)\.c/{\1CC}\2 @DASH_C_FLAG@ \3"\4"\5:\6.c -o "{o}"\6.c.o/ + +# Change linking cc to linking sequence. +/-o/s/^\([ ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\){LDFLAGS} \(.*\)-o \([^ ]*\) \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \5 -o \6{PROG_EXT} \7\ +\1{MAKEPEF} \6{PROG_EXT} -o \6 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\ +\1{REZ} "{s}"\6.r -o \6 -append -d PROG_NAME='"'\6'"' -d VERSION_STRING='"'{version}'"'/ +/-o/s/^\([ ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\)-o \([^ ]*\) \(.*\){LDFLAGS} \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \6 -o \5{PROG_EXT} \7\ +\1{MAKEPEF} \5{PROG_EXT} -o \5 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\ +\1{REZ} "{s}"\5.r -o \5 -append -d PROG_NAME='"'\5'"' -d VERSION_STRING='"'{version}'"'/ +/-o/s/^\([ ]*\){HOST_CC} \(.*\)-o \([^ ]*\) \(.*\)$/\1{HOST_CC_LD} \2 -o \3{PROG_EXT} \4\ +\1{MAKEPEF} \3{PROG_EXT} -o \3 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\ +\1{REZ} "{s}"\3.r -o \3 -append -d PROG_NAME='"'\3'"' -d VERSION_STRING='"'{version}'"'/ + +# Comment out .NOEXPORT rules. +/\.NOEXPORT/s/^\.NOEXPORT/#\.NOEXPORT/ +# Comment out .PHONY rules. +/\.PHONY/s/^\.PHONY/#\.PHONY/ +# Comment out .PRECIOUS rules. +/\.PRECIOUS/s/^\.PRECIOUS/#\.PRECIOUS/ +# Comment out .SUFFIXES rules. +/\.SUFFIXES/s/^\.SUFFIXES/#\.SUFFIXES/ + +# Set the install program appropriately. +/INSTALL/s/^INSTALL *= *`.*`:install.sh -c/INSTALL = Duplicate -y/ + +# Don't try to decide whether to use the tree's own tools. +/bison/s/`.*bison:bison.*`/bison -y/ +/byacc/s/`.*byacc:byacc.*`/byacc/ +/flex/s/`.*flex:flex.*`/flex/ + +# Turn transformed C comments in echo commands back into comments. +/echo/s,echo '\(.*\):\\Option-x\(.*\)\\Option-x:\(.*\)',echo '\1/*\2*/\3', + +# Whack out various clever expressions that search for tools, since +# the clever code is too /bin/sh specific. + +/^AR_FOR_TARGET = `/,/`$/c\ +AR_FOR_TARGET = ::binutils:ar\ + + +/^RANLIB_FOR_TARGET = `/,/`$/c\ +RANLIB_FOR_TARGET = ::binutils:ranlib\ + + +/^RANLIB_TEST_FOR_TARGET = /,/ranlib ] )$/c\ +RANLIB_TEST_FOR_TARGET = \ + + +/^EXPECT = `/,/`$/c\ +EXPECT = \ + + +/^RUNTEST = `/,/`$/c\ +RUNTEST = \ + + +/^CC_FOR_TARGET = `/,/`$/c\ +CC_FOR_TARGET = \ + + +/^CXX_FOR_TARGET = `/,/`$/c\ +CXX_FOR_TARGET = \ + + +/^CHILL_FOR_TARGET = `/,/`$/c\ +CHILL_FOR_TARGET = \ + + +/^CHILL_LIB = `/,/`$/c\ +CHILL_LIB = \ + +/sanit/s/{start-sanit...-[a-z0-9]*}// +/sanit/s/{end-sanit...-[a-z0-9]*}// + +# Add standard defines and default rules. +/^# srcdir/a\ +\ +s = "{srcdir}"\ +\ +o = :\ +\ +"{o}" \\Option-f : "{s}" + diff --git a/config/mpw/mpw-touch b/config/mpw/mpw-touch new file mode 100644 index 000000000000..c743a5122b51 --- /dev/null +++ b/config/mpw/mpw-touch @@ -0,0 +1,7 @@ +# "Touch" command. + +If "`Exists "{1}"`" != "" + SetFile -m . "{1}" +Else + Echo ' ' > "{1}" +End If diff --git a/config/mpw/mpw-true b/config/mpw/mpw-true new file mode 100644 index 000000000000..0506530d3c6d --- /dev/null +++ b/config/mpw/mpw-true @@ -0,0 +1 @@ +Exit 0 diff --git a/config/mpw/null-command b/config/mpw/null-command new file mode 100644 index 000000000000..4844c8ec5532 --- /dev/null +++ b/config/mpw/null-command @@ -0,0 +1 @@ +# This command does nothing. diff --git a/config/mpw/open-brace b/config/mpw/open-brace new file mode 100644 index 000000000000..58465dcc18c4 --- /dev/null +++ b/config/mpw/open-brace @@ -0,0 +1,4 @@ +# MPW makefiles seem not to have any way to get a literal open +# brace into a rule anywhere, so this does the job. + +Echo '{' diff --git a/config/mpw/tr-7to8-src b/config/mpw/tr-7to8-src new file mode 100644 index 000000000000..b20b649c8953 --- /dev/null +++ b/config/mpw/tr-7to8-src @@ -0,0 +1,9 @@ +StreamEdit -e \Option-d + '/\Option-x/ \Option-d + Replace /\Option-d\SrcOption-d/ "\Option-d\Option-d" -c \Option-5 ; \Option-d + Replace /\Option-d\SrcOption-f/ "\Option-d\Option-f" -c \Option-5 ; \Option-d + Replace /\Option-d\SrcOption-8/ "\Option-d\Option-8" -c \Option-5 ; \Option-d + Replace /\Option-d\SrcOption-5/ "\Option-d\Option-5" -c \Option-5 ; \Option-d + Replace /\Option-d\SrcOption-x/ "\Option-d\Option-x" -c \Option-5 ; \Option-d + Replace /\Option-d\SrcOption-r/ "\Option-d\Option-r" -c \Option-5' \Option-d + "{1}" diff --git a/config/mpw/true b/config/mpw/true new file mode 100644 index 000000000000..0506530d3c6d --- /dev/null +++ b/config/mpw/true @@ -0,0 +1 @@ +Exit 0 diff --git a/config/mt-m68kpic b/config/mt-m68kpic new file mode 100644 index 000000000000..ff9872755757 --- /dev/null +++ b/config/mt-m68kpic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fpic diff --git a/config/mt-netware b/config/mt-netware new file mode 100644 index 000000000000..9482f9b36d24 --- /dev/null +++ b/config/mt-netware @@ -0,0 +1 @@ +GDB_NLM_DEPS = all-gcc all-ld diff --git a/config/mt-papic b/config/mt-papic new file mode 100644 index 000000000000..35b8c9e4dc23 --- /dev/null +++ b/config/mt-papic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fPIC diff --git a/config/mt-ppcpic b/config/mt-ppcpic new file mode 100644 index 000000000000..35b8c9e4dc23 --- /dev/null +++ b/config/mt-ppcpic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fPIC diff --git a/config/mt-sparcpic b/config/mt-sparcpic new file mode 100644 index 000000000000..35b8c9e4dc23 --- /dev/null +++ b/config/mt-sparcpic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fPIC diff --git a/config/mt-v810 b/config/mt-v810 new file mode 100644 index 000000000000..97da6c265921 --- /dev/null +++ b/config/mt-v810 @@ -0,0 +1,4 @@ +CC_FOR_TARGET = ca732 -ansi +AS_FOR_TARGET = as732 +AR_FOR_TARGET = ar732 +RANLIB_FOR_TARGET = true diff --git a/config/mt-x86pic b/config/mt-x86pic new file mode 100644 index 000000000000..ff9872755757 --- /dev/null +++ b/config/mt-x86pic @@ -0,0 +1 @@ +PICFLAG_FOR_TARGET=-fpic diff --git a/configure b/configure new file mode 100755 index 000000000000..e168e94002d1 --- /dev/null +++ b/configure @@ -0,0 +1,1406 @@ +#!/bin/sh + +### WARNING: this file contains embedded tabs. Do not run untabify on this file. + +# Configuration script +# Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 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 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 was originally written by K. Richard Pixley. + +# +# Shell script to create proper links to machine-dependent files in +# preparation for compilation. +# +# If configure succeeds, it leaves its status in config.status. +# If configure fails after disturbing the status quo, +# config.status is removed. +# + +export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$) + +remove=rm +hard_link=ln +symbolic_link='ln -s' + +#for Test +#remove="echo rm" +#hard_link="echo ln" +#symbolic_link="echo ln -s" + +# clear some things potentially inherited from environment. + +Makefile=Makefile +Makefile_in=Makefile.in +arguments= +build_alias= +cache_file=config.cache +cache_file_option= +configdirs= +exec_prefix= +exec_prefixoption= +fatal= +floating_point=default +gas=default +host_alias=NOHOST +host_makefile_frag= +moveifchange= +norecursion= +other_options= +package_makefile_frag= +prefix=/usr/local +progname= +program_prefix= +program_prefixoption= +program_suffix= +program_suffixoption= +program_transform_name= +program_transform_nameoption= +redirect=">/dev/null" +removing= +site= +site_makefile_frag= +site_option= +srcdir= +srctrigger= +subdirs= +target_alias=NOTARGET +target_makefile_frag= +undefs=NOUNDEFS +version="$Revision: 1.244 $" +x11=default + +### we might need to use some other shell than /bin/sh for running subshells + +### If we are on Windows, search for the shell. This will permit people +### to not have /bin/sh, but to be able to see /SOME/PATH/sh configure +### without also having to set CONFIG_SHELL. This code will work when +### using bash, which sets OSTYPE. +case "${OSTYPE}" in +*win32*) + if [ x${CONFIG_SHELL} = x ]; then + if [ ! -f /bin/sh ]; then + if [ x${SHELL} != x ] && [ -f ${SHELL} ]; then + CONFIG_SHELL=${SHELL} + export CONFIG_SHELL + else + for prog in sh sh.exe bash bash.exe; do + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/$prog; then + CONFIG_SHELL=$dir/$prog + export CONFIG_SHELL + break + fi + done + IFS="$save_ifs" + test -n "${CONFIG_SHELL}" && break + done + fi + fi + fi + ;; +esac + +config_shell=${CONFIG_SHELL-/bin/sh} + +NO_EDIT="This file was generated automatically by configure. Do not edit." + +## this is a little touchy and won't always work, but... +## +## if the argv[0] starts with a slash then it is an absolute name that can (and +## must) be used as is. +## +## otherwise, if argv[0] has no slash in it, we can assume that it is on the +## path. Since PATH might include "." we also add `pwd` to the end of PATH. +## + +progname=$0 +# if PWD already has a value, it is probably wrong. +if [ -n "$PWD" ]; then PWD=`pwd`; fi + +case "${progname}" in +/*) ;; +*/*) ;; +*) + PATH=$PATH:${PWD=`pwd`} ; export PATH + ;; +esac + +# Loop over all args + +while : +do + +# Break out if there are no more args + case $# in + 0) + break + ;; + esac + +# Get the first arg, and shuffle + option=$1 + shift + +# Make all options have two hyphens + orig_option=$option # Save original for error messages + case $option in + --*) ;; + -*) option=-$option ;; + esac + +# Split out the argument for options that take them + case $option in + --*=*) + optarg=`echo $option | sed -e 's/^[^=]*=//'` + arguments="$arguments $option" + ;; +# These options have mandatory values. Since we didn't find an = sign, +# the value must be in the next argument + --bu* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-* | --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*) + optarg=$1 + shift + arguments="$arguments $option=$optarg" + ;; + --v) + arguments="$arguments -v" + ;; + --*) + arguments="$arguments $option" + ;; + esac + +# Now, process the options + case $option in + + --build* | --bu*) + case "$build_alias" in + "") build_alias=$optarg ;; + *) echo '***' Can only configure for one build machine at a time. 1>&2 + fatal=yes + ;; + esac + ;; + --cache*) + cache_file=$optarg + ;; + --disable-*) + enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'` + eval $enableopt=no + disableoptions="$disableoptions $option" + ;; + --enable-*) + case "$option" in + *=*) ;; + *) optarg=yes ;; + esac + + enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'` + eval "$enableopt='$optarg'" + enableoptions="$enableoptions '$option'" + ;; + --exec-prefix* | --ex*) + exec_prefix=$optarg + exec_prefixoption="--exec-prefix=$optarg" + ;; + --gas | --g*) + gas=yes + ;; + --help | --he*) + fatal=yes + ;; + --host* | --ho*) + case $host_alias in + NOHOST) host_alias=$optarg ;; + *) echo '***' Can only configure for one host at a time. 1>&2 + fatal=yes + ;; + esac + ;; + --nfp | --nf*) + floating_point=no + floating_pointoption="--nfp" + ;; + --norecursion | --no*) + norecursion=yes + ;; + --prefix* | --pre*) + prefix=$optarg + prefixoption="--prefix=$optarg" + ;; + --program-prefix* | --program-p*) + program_prefix=$optarg + program_prefixoption="--program-prefix=$optarg" + ;; + --program-suffix* | --program-s*) + program_suffix=$optarg + program_suffixoption="--program-suffix=$optarg" + ;; + --program-transform-name* | --program-t*) + # Double any backslashes or dollar signs in the argument + program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`" + program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'" + ;; + --rm) + removing=--rm + ;; + --silent | --sil* | --quiet | --q*) + redirect=">/dev/null" + verbose=--silent + ;; + --site* | --sit*) + site=$optarg + site_option="--site=$optarg" + ;; + --srcdir*/ | --sr*/) + # Remove trailing slashes. Otherwise, when the file name gets + # bolted into an object file as debug info, it has two slashes + # in it. Ordinarily this is ok, but emacs takes double slash + # to mean "forget the first part". + srcdir=`echo $optarg | sed -e 's:/$::'` + ;; + --srcdir* | --sr*) + srcdir=$optarg + ;; + --target* | --ta*) + case $target_alias in + NOTARGET) target_alias=$optarg ;; + *) echo '***' Can only configure for one target at a time. 1>&2 + fatal=yes + ;; + esac + ;; + --tmpdir* | --tm*) + TMPDIR=$optarg + tmpdiroption="--tmpdir=$optarg" + ;; + --verbose | --v | --verb*) + redirect= + verbose=--verbose + ;; + --version | --V | --vers*) + echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'` + exit 0 + ;; + --with-*) + case "$option" in + *=*) ;; + *) optarg=yes ;; + esac + + withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'` + eval $withopt="$optarg" + withoptions="$withoptions $option" + ;; + --without-*) + withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'` + eval $withopt=no + withoutoptions="$withoutoptions $option" + ;; + --x) with_x=yes + withoptions="$withoptions --with-x" + ;; + --x-i* | --x-l*) other_options="$other_options $orig_option" + ;; + --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*) + # These options were added to autoconf for emacs. + ;; + --*) + echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2 + exit 1 + ;; + *) + case $undefs in + NOUNDEFS) undefs=$option ;; + *) echo '***' Can only configure for one host and one target at a time. 1>&2 + fatal=yes + ;; + esac + ;; + esac +done + +# process host and target + +# Do some error checking and defaulting for the host and target type. +# The inputs are: +# configure --host=HOST --target=TARGET UNDEFS +# +# The rules are: +# 1. You aren't allowed to specify --host, --target, and undefs at the +# same time. +# 2. Host defaults to undefs. +# 3. If undefs is not specified, then host defaults to the current host, +# as determined by config.guess. +# 4. Target defaults to undefs. +# 5. If undefs is not specified, then target defaults to host. + +case "${fatal}" in +"") + # Make sure that host, target & undefs aren't all specified at the + # same time. + case $host_alias---$target_alias---$undefs in + NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS) + ;; + *) echo '***' Can only configure for one host and one target at a time. 1>&2 + fatal=yes + break 2 + ;; + esac + + # Now, do defaulting for host. + case $host_alias in + NOHOST) + case $undefs in + NOUNDEFS) + # Neither --host option nor undefs were present. + # Call config.guess. + guesssys=`echo ${progname} | sed 's/configure$/config.guess/'` + if host_alias=`${config_shell} ${guesssys}` + then + # If the string we are going to use for + # the target is a prefix of the string + # we just guessed for the host, then + # assume we are running native, and force + # the same string for both target and host. + case $target_alias in + NOTARGET) ;; + *) + if expr $host_alias : $target_alias >/dev/null + then + host_alias=$target_alias + fi + ;; + esac + echo "Configuring for a ${host_alias} host." 1>&2 + arguments="--host=$host_alias $arguments" + else + echo 'Config.guess failed to determine the host type. You need to specify one.' 1>&2 + fatal=yes + fi + ;; + *) + host_alias=$undefs + arguments="--host=$host_alias $arguments" + undefs=NOUNDEFS + ;; + esac + esac + + # Do defaulting for target. If --target option isn't present, default + # to undefs. If undefs isn't present, default to host. + case $target_alias in + NOTARGET) + case $undefs in + NOUNDEFS) + target_alias=$host_alias + ;; + *) + target_alias=$undefs + arguments="--target=$target_alias $arguments" + ;; + esac + esac + ;; +*) ;; +esac + +if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then + exec 1>&2 + echo Usage: configure [OPTIONS] [HOST] + echo + echo Options: [defaults in brackets] + echo ' --prefix=MYDIR install into MYDIR [/usr/local]' + echo ' --exec-prefix=MYDIR install host-dependent files into MYDIR [/usr/local]' + echo ' --help print this message [normal config]' + echo ' --build=BUILD configure for building on BUILD [BUILD=HOST]' + echo ' --host=HOST configure for HOST [determined via config.guess]' + echo ' --norecursion configure this directory only [recurse]' + echo ' --program-prefix=FOO prepend FOO to installed program names [""]' + echo ' --program-suffix=FOO append FOO to installed program names [""]' + echo ' --program-transform-name=P transform installed names by sed pattern P [""]' + echo ' --site=SITE configure with site-specific makefile for SITE' + echo ' --srcdir=DIR find the sources in DIR [. or ..]' + echo ' --target=TARGET configure for TARGET [TARGET=HOST]' + echo ' --tmpdir=TMPDIR create temporary files in TMPDIR [/tmp]' + echo ' --nfp configure for software floating point [hard float]' + echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)' + echo ' --without-FOO package FOO is NOT available' + echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)' + echo ' --disable-FOO do not include feature FOO' + echo + echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.' + echo + if [ -r config.status ] ; then + cat config.status + fi + + exit 1 +fi + +configsub=`echo ${progname} | sed 's/configure$/config.sub/'` +moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'` + +# this is a hack. sun4 must always be a valid host alias or this will fail. +if ${config_shell} ${configsub} sun4 >/dev/null 2>&1 ; then + true +else + echo '***' cannot find config.sub. 1>&2 + exit 1 +fi + +touch config.junk +if ${config_shell} ${moveifchange} config.junk config.trash ; then + true +else + echo '***' cannot find move-if-change. 1>&2 + exit 1 +fi +rm -f config.junk config.trash + +case "${srcdir}" in +"") + if [ -r configure.in ] ; then + srcdir=. + else + if [ -r ${progname}.in ] ; then + srcdir=`echo ${progname} | sed 's:/configure$::'` + else + echo '***' "Can't find configure.in. Try using --srcdir=some_dir" 1>&2 + exit 1 + fi + fi + ;; +*) + # Set srcdir to "." if that's what it is. + # This is important for multilib support. + if [ ! -d ${srcdir} ] ; then + echo "Invalid source directory ${srcdir}" >&2 + exit 1 + fi + pwd=`pwd` + srcpwd=`cd ${srcdir} ; pwd` + if [ "${pwd}" = "${srcpwd}" ] ; then + srcdir=. + fi +esac + +### warn about some conflicting configurations. + +case "${srcdir}" in +".") ;; +*) + if [ -f ${srcdir}/config.status ] ; then + echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2 + exit 1 + fi +esac + +# default exec_prefix +case "${exec_prefixoption}" in +"") exec_prefix="\$(prefix)" ;; +*) ;; +esac + +### break up ${srcdir}/configure.in. +case "`grep '^# per\-host:' ${srcdir}/configure.in`" in +"") + echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2 + # Check for a directory that's been converted to use autoconf since + # it was last configured. + if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then + echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2 + if [ -r ${srcdir}/configure ] ; then + echo '***' Running the local configure script. 1>&2 + case "${cache_file}" in + "") cache_file_option= ;; + *) cache_file_option="--cache-file=${cache_file}" ;; + esac + srcdiroption="--srcdir=${srcdir}" + case "${build_alias}" in + "") buildopt= ;; + *) buildopt="--build=${build_alias}" ;; + esac + eval exec ${config_shell} ${srcdir}/configure ${verbose} \ + ${buildopt} --host=${host_alias} --target=${target_alias} \ + ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \ + ${srcdiroption} \ + ${program_prefixoption} ${program_suffixoption} \ + ${program_transform_nameoption} ${site_option} \ + ${withoptions} ${withoutoptions} \ + ${enableoptions} ${disableoptions} ${floating_pointoption} \ + ${cache_file_option} ${removing} ${other_options} ${redirect} + else + echo '***' There is no configure script present though. 1>&2 + fi + fi + exit 1 + ;; +*) ;; +esac + +case "`grep '^# per\-target:' ${srcdir}/configure.in`" in +"") + echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2 + exit 1 + ;; +*) ;; +esac + +case "${TMPDIR}" in +"") TMPDIR=/tmp ; export TMPDIR ;; +*) ;; +esac + +# keep this filename short for &%*%$*# 14 char file names +tmpfile=${TMPDIR}/cONf$$ +# Note that under many versions of sh a trap handler for 0 will *override* any +# exit status you explicitly specify! At this point, the only non-error exit +# is at the end of the script; these actions are duplicated there, minus +# the "exit 1". Don't use "exit 0" anywhere after this without resetting the +# trap handler, or you'll lose. +trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15 + +# split ${srcdir}/configure.in into common, per-host, per-target, +# and post-target parts. Post-target is optional. +sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com +sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst +if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then + sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt + sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos +else + sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt + echo >${tmpfile}.pos +fi + +### do common part of configure.in + +. ${tmpfile}.com + +# some sanity checks on configure.in +case "${srctrigger}" in +"") + echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in. 1>&2 + exit 1 + ;; +*) ;; +esac + +case "${build_alias}" in +"") + if result=`${config_shell} ${configsub} ${host_alias}` ; then + build_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + build_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + build_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + build=${build_cpu}-${build_vendor}-${build_os} + build_alias=${host_alias} + fi + ;; +*) + if result=`${config_shell} ${configsub} ${build_alias}` ; then + buildopt="--build=${build_alias}" + build_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + build_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + build_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + build=${build_cpu}-${build_vendor}-${build_os} + else + echo "Unrecognized build system name ${build_alias}." 1>&2 + exit 1 + fi + ;; +esac + +if result=`${config_shell} ${configsub} ${host_alias}` ; then + true +else + echo "Unrecognized host system name ${host_alias}." 1>&2 + exit 1 +fi +host_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +host=${host_cpu}-${host_vendor}-${host_os} + +. ${tmpfile}.hst + +if result=`${config_shell} ${configsub} ${target_alias}` ; then + true +else + echo "Unrecognized target system name ${target_alias}." 1>&2 + exit 1 +fi +target_cpu=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $result | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +target=${target_cpu}-${target_vendor}-${target_os} + +. ${tmpfile}.tgt + +# Find the source files, if location was not specified. +case "${srcdir}" in +"") + srcdirdefaulted=1 + srcdir=. + if [ ! -r ${srctrigger} ] ; then + srcdir=.. + fi + ;; +*) ;; +esac + +if [ ! -r ${srcdir}/${srctrigger} ] ; then + case "${srcdirdefaulted}" in + "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;; + *) echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;; + esac + + echo '***' \(At least ${srctrigger} is missing.\) 1>&2 + exit 1 +fi + +# Some systems (e.g., one of the i386-aix systems the gas testers are +# using) don't handle "\$" correctly, so don't use it here. +tooldir='$(exec_prefix)'/${target_alias} + +if [ "${host_alias}" != "${target_alias}" ] ; then + if [ "${program_prefixoption}" = "" ] ; then + if [ "${program_suffixoption}" = "" ] ; then + if [ "${program_transform_nameoption}" = "" ] ; then + program_prefix=${target_alias}- ; + fi + fi + fi +fi + +# Merge program_prefix and program_suffix onto program_transform_name. +# (program_suffix used to use $, but it's hard to preserve $ through both +# make and sh.) +if [ "${program_suffix}" != "" ] ; then + program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}" +fi + +if [ "${program_prefix}" != "" ] ; then + program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}" +fi + +# If CC and CXX are not set in the environment, and the Makefile +# exists, try to extract them from it. This is to handle running +# ./config.status by hand. +if [ -z "${CC}" -a -r Makefile ]; then + sed -n -e ':loop +/\\$/ N +s/\\\n//g +t loop +/^CC[ ]*=/ s/CC[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc + CC=`tail -1 Makefile.cc` + rm -f Makefile.cc +fi + +if [ -z "${CFLAGS}" -a -r Makefile ]; then + sed -n -e ':loop +/\\$/ N +s/\\\n//g +t loop +/^CFLAGS[ ]*=/ s/CFLAGS[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc + CFLAGS=`tail -1 Makefile.cc` + rm -f Makefile.cc +fi + +if [ -z "${CXX}" -a -r Makefile ]; then + sed -n -e ':loop +/\\$/ N +s/\\\n//g +t loop +/^CXX[ ]*=/ s/CXX[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc + CXX=`tail -1 Makefile.cc` + rm -f Makefile.cc +fi + +if [ -z "${CXXFLAGS}" -a -r Makefile ]; then + sed -n -e ':loop +/\\$/ N +s/\\\n//g +t loop +/^CXXFLAGS[ ]*=/ s/CXXFLAGS[ ]*=[ ]*\(.*\)/\1/p' < Makefile > Makefile.cc + CXXFLAGS=`tail -1 Makefile.cc` + rm -f Makefile.cc +fi + +# Generate a default definition for YACC. This is used if the makefile can't +# locate bison or byacc in objdir. + +for prog in 'bison -y' byacc yacc +do + set dummy $prog; tmp=$2 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/$tmp; then + DEFAULT_YACC="$prog" + break + fi + done + IFS="$save_ifs" + + test -n "$DEFAULT_YACC" && break +done + +# Generate a default definition for LEX. This is used if the makefile can't +# locate flex in objdir. + +for prog in flex lex +do + set dummy $prog; tmp=$2 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/$tmp; then + DEFAULT_LEX="$prog" + break + fi + done + IFS="$save_ifs" + + test -n "$DEFAULT_LEX" && break +done + +if [ "${build}" != "${host}" ]; then + # If we are doing a Canadian Cross, in which the host and build systems + # are not the same, we set reasonable default values for the tools. + + tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD" + tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET" + tools="${tools} DLLTOOL DLLTOOL_FOR_TARGET GCC_FOR_TARGET HOST_PREFIX" + tools="${tools} HOST_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM" + tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET" + tools="${tools} WINDRES WINDRES_FOR_TARGET YACC" + + for var in ${tools}; do + if [ -z "`eval 'echo $'"${var}"`" -a -r Makefile ]; then + sed -n -e ':loop +/\\$/ N +s/\\\n//g +t loop +/^'"${var}"'[ ]*=/ s/'"${var}"'[ ]*=[ ]*\(.*\)/\1/p' \ + < Makefile > Makefile.v + t=`tail -1 Makefile.v` + if [ -n "${t}" ]; then + eval "${var}='${t}'" + fi + rm -f Makefile.v + fi + done + + AR=${AR-${host_alias}-ar} + AR_FOR_TARGET=${AR_FOR_TARGET-${target_alias}-ar} + AS=${AS-${host_alias}-as} + AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as} + BISON=${BISON-bison} + CC=${CC-${host_alias}-gcc} + CFLAGS=${CFLAGS-"-g -O2"} + CXX=${CXX-${host_alias}-c++} + CXXFLAGS=${CXXFLAGS-"-g -O2"} + CC_FOR_BUILD=${CC_FOR_BUILD-gcc} + CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc} + CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-c++} + DLLTOOL=${DLLTOOL-${host_alias}-dlltool} + DLLTOOL_FOR_TARGET=${DLLTOOL_FOR_TARGET-${target_alias}-dlltool} + GCC_FOR_TARGET=${GCC_FOR_TARGET-${CC_FOR_TARGET-${target_alias}-gcc}} + HOST_PREFIX=${build_alias}- + HOST_PREFIX_1=${build_alias}- + LD=${LD-${host_alias}-ld} + LD_FOR_TARGET=${LD_FOR_TARGET-${target_alias}-ld} + MAKEINFO=${MAKEINFO-makeinfo} + NM=${NM-${host_alias}-nm} + NM_FOR_TARGET=${NM_FOR_TARGET-${target_alias}-nm} + RANLIB=${RANLIB-${host_alias}-ranlib} + RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET-${target_alias}-ranlib} + WINDRES=${WINDRES-${host_alias}-windres} + WINDRES_FOR_TARGET=${WINDRES_FOR_TARGET-${target_alias}-windres} + + if [ -z "${YACC}" ]; then + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/bison; then + YACC="bison -y" + break + fi + if test -f $dir/byacc; then + YACC=byacc + break + fi + if test -f $dir/yacc; then + YACC=yacc + break + fi + done + IFS="$save_ifs" + if [ -z "${YACC}" ]; then + YACC="bison -y" + fi + fi + + if [ -z "${LEX}" ]; then + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/flex; then + LEX=flex + break + fi + if test -f $dir/lex; then + LEX=lex + break + fi + done + IFS="$save_ifs" + LEX=${LEX-flex} + fi + + # Export variables which autoconf might try to set. + export AS + export AR + export CC_FOR_BUILD + export DLLTOOL + export LD + export NM + export RANLIB + export WINDRES +else + # If CC is still not set, try to get gcc. + if [ -z "${CC}" ]; then + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/gcc; then + CC="gcc" + echo 'void f(){}' > conftest.c + if test -z "`${CC} -g -c conftest.c 2>&1`"; then + CFLAGS=${CFLAGS-"-g -O2"} + CXXFLAGS=${CFLAGS-"-g -O2"} + else + CFLAGS=${CFLAGS-"-O2"} + CXXFLAGS=${CFLAGS-"-O2"} + fi + rm -f conftest* + break + fi + done + IFS="$save_ifs" + CC=${CC-cc} + fi + + CXX=${CXX-"c++"} + CFLAGS=${CFLAGS-"-g"} + CXXFLAGS=${CXXFLAGS-"-g -O2"} +fi + +export CC +export CXX +export CFLAGS +export CXXFLAGS + +# FIXME: This should be in configure.in, not configure +case "$host" in + *go32*) + enable_gdbtk=no ;; + *msdosdjgpp*) + enable_gdbtk=no ;; + *cygwin32*) + enable_gdbtk=no ;; +esac + +# FIXME: This should be in configure.in, not configure +# Determine whether gdb needs tk/tcl or not. +if [ "$enable_gdbtk" != "no" ]; then + GDB_TK="all-tcl all-tk all-itcl all-tix" +else + GDB_TK="" +fi + +for subdir in . ${subdirs} ; do + + # ${subdir} is relative path from . to the directory we're currently + # configuring. + # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed. + invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'` + + ### figure out what to do with srcdir + case "${srcdir}" in + ".") # no -srcdir option. We're building in place. + makesrcdir=. ;; + /*) # absolute path + makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'` + ;; + *) # otherwise relative + case "${subdir}" in + .) makesrcdir=${srcdir} ;; + *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;; + esac + ;; + esac + + if [ "${subdir}/" != "./" ] ; then + Makefile=${subdir}/Makefile + fi + + if [ ! -d ${subdir} ] ; then + if mkdir ${subdir} ; then + true + else + echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2 + exit 1 + fi + fi + + case "${removing}" in + "") + case "${subdir}" in + .) ;; + *) eval echo Building in ${subdir} ${redirect} ;; + esac + + # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest) + # Set up the list of links to be made. + # ${links} is the list of link names, and ${files} is the list of names to link to. + + # Make the links. + configlinks="${links}" + if [ -r ${subdir}/config.status ] ; then + mv -f ${subdir}/config.status ${subdir}/config.back + fi + while [ -n "${files}" ] ; do + # set file to car of files, files to cdr of files + set ${files}; file=$1; shift; files=$* + set ${links}; link=$1; shift; links=$* + + if [ ! -r ${srcdir}/${file} ] ; then + echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 + echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2 + exit 1 + fi + + ${remove} -f ${link} + # Make a symlink if possible, otherwise try a hard link + if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then + true + else + # We need to re-remove the file because Lynx leaves a + # very strange directory there when it fails an NFS symlink. + ${remove} -r -f ${link} + ${hard_link} ${srcdir}/${file} ${link} + fi + if [ ! -r ${link} ] ; then + echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 + exit 1 + fi + + echo "Linked \"${link}\" to \"${srcdir}/${file}\"." + done + + # Create a .gdbinit file which runs the one in srcdir + # and tells GDB to look there for source files. + + if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then + case ${srcdir} in + .) ;; + *) cat > ${subdir}/.gdbinit < ${subdir}/Makefile.tem + else + cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem + site_makefile_frag= + fi + ;; + esac + # working copy now in ${subdir}/Makefile.tem + + # Conditionalize the makefile for this host. + rm -f ${Makefile} + case "${host_makefile_frag}" in + "") mv ${subdir}/Makefile.tem ${Makefile} ;; + *) + if [ ! -f ${host_makefile_frag} ] ; then + host_makefile_frag=${srcdir}/${host_makefile_frag} + fi + if [ -f ${host_makefile_frag} ] ; then + sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile} + else + echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2 + echo '***' is missing in ${PWD=`pwd`}. 1>&2 + mv ${subdir}/Makefile.tem ${Makefile} + fi + esac + # working copy now in ${Makefile} + + # Conditionalize the makefile for this target. + rm -f ${subdir}/Makefile.tem + case "${target_makefile_frag}" in + "") mv ${Makefile} ${subdir}/Makefile.tem ;; + *) + if [ ! -f ${target_makefile_frag} ] ; then + target_makefile_frag=${srcdir}/${target_makefile_frag} + fi + if [ -f ${target_makefile_frag} ] ; then + sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem + else + mv ${Makefile} ${subdir}/Makefile.tem + target_makefile_frag= + fi + ;; + esac + # real copy now in ${subdir}/Makefile.tem + + # Conditionalize the makefile for this package. + rm -f ${Makefile} + case "${package_makefile_frag}" in + "") mv ${subdir}/Makefile.tem ${Makefile} ;; + *) + if [ ! -f ${package_makefile_frag} ] ; then + package_makefile_frag=${srcdir}/${package_makefile_frag} + fi + if [ -f ${package_makefile_frag} ] ; then + sed -e "/^####/ r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile} + rm -f ${subdir}/Makefile.tem + else + echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2 + echo '***' is missing in ${PWD=`pwd`}. 1>&2 + mv ${subdir}/Makefile.tem ${Makefile} + fi + esac + # working copy now in ${Makefile} + + mv ${Makefile} ${subdir}/Makefile.tem + + # real copy now in ${subdir}/Makefile.tem + + # prepend warning about editting, and a bunch of variables. + rm -f ${Makefile} + cat > ${Makefile} <> ${Makefile} << EOF +build_alias = ${build_alias} +build_cpu = ${build_cpu} +build_vendor = ${build_vendor} +build_os = ${build_os} +build_canonical = ${build_cpu}-${build_vendor}-${build_os} +EOF + esac + + case "${package_makefile_frag}" in + "") ;; + /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;; + *) echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;; + esac + + case "${target_makefile_frag}" in + "") ;; + /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;; + *) echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;; + esac + + case "${host_makefile_frag}" in + "") ;; + /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;; + *) echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;; + esac + + if [ "${site_makefile_frag}" != "" ] ; then + echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile} + fi + + # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS, + # remove any form feeds. + if [ -z "${subdirs}" ]; then + rm -f ${subdir}/Makefile.tm2 + sed -e "s:^SUBDIRS[ ]*=.*$:SUBDIRS = ${configdirs}:" \ + -e "s:^NONSUBDIRS[ ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \ + ${subdir}/Makefile.tem > ${subdir}/Makefile.tm2 + rm -f ${subdir}/Makefile.tem + mv ${subdir}/Makefile.tm2 ${subdir}/Makefile.tem + fi + sed -e "s|^prefix[ ]*=.*$|prefix = ${prefix}|" \ + -e "s|^exec_prefix[ ]*=.*$|exec_prefix = ${exec_prefix}|" \ + -e "/^CC[ ]*=/{ + :loop1 + /\\\\$/ N + s/\\\\\\n//g + t loop1 + s%^CC[ ]*=.*$%CC = ${CC}% + }" \ + -e "/^CXX[ ]*=/{ + :loop2 + /\\\\$/ N + s/\\\\\\n//g + t loop2 + s%^CXX[ ]*=.*$%CXX = ${CXX}% + }" \ + -e "/^CFLAGS[ ]*=/{ + :loop3 + /\\\\$/ N + s/\\\\\\n//g + t loop3 + s%^CFLAGS[ ]*=.*$%CFLAGS = ${CFLAGS}% + }" \ + -e "/^CXXFLAGS[ ]*=/{ + :loop4 + /\\\\$/ N + s/\\\\\\n//g + t loop4 + s%^CXXFLAGS[ ]*=.*$%CXXFLAGS = ${CXXFLAGS}% + }" \ + -e "s|^SHELL[ ]*=.*$|SHELL = ${config_shell}|" \ + -e "s:^GDB_TK[ ]*=.*$:GDB_TK = ${GDB_TK}:" \ + -e "s|^srcdir[ ]*=.*$|srcdir = ${makesrcdir}|" \ + -e "s/ //" \ + -e "s:^program_prefix[ ]*=.*$:program_prefix = ${program_prefix}:" \ + -e "s:^program_suffix[ ]*=.*$:program_suffix = ${program_suffix}:" \ + -e "s:^program_transform_name[ ]*=.*$:program_transform_name = ${program_transform_name}:" \ + -e "s|^tooldir[ ]*=.*$|tooldir = ${tooldir}|" \ + -e "s:^DEFAULT_YACC[ ]*=.*$:DEFAULT_YACC = ${DEFAULT_YACC}:" \ + -e "s:^DEFAULT_LEX[ ]*=.*$:DEFAULT_LEX = ${DEFAULT_LEX}:" \ + ${subdir}/Makefile.tem >> ${Makefile} + + # If this is a Canadian Cross, preset the values of many more + # tools. + if [ "${build}" != "${host}" ]; then + for var in ${tools}; do + val=`eval 'echo $'"${var}"` + sed -e "/^${var}[ ]*=/{ + :loop1 + /\\\\$/ N + /\\\\$/ b loop1 + s/\\\\\\n//g + s%^${var}[ ]*=.*$%${var} = ${val}% + }" ${Makefile} > ${Makefile}.tem + mv -f ${Makefile}.tem ${Makefile} + done + fi + + # final copy now in ${Makefile} + + else + echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2 + fi + + rm -f ${subdir}/Makefile.tem + + case "${host_makefile_frag}" in + "") using= ;; + *) using="and \"${host_makefile_frag}\"" ;; + esac + + case "${target_makefile_frag}" in + "") ;; + *) using="${using} and \"${target_makefile_frag}\"" ;; + esac + + case "${site_makefile_frag}" in + "") ;; + *) using="${using} and \"${site_makefile_frag}\"" ;; + esac + + newusing=`echo "${using}" | sed 's/and/using/'` + using=${newusing} + echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using} + + . ${tmpfile}.pos + + # describe the chosen configuration in config.status. + # Make that file a shellscript which will reestablish + # the same configuration. Used in Makefiles to rebuild + # Makefiles. + + case "${norecursion}" in + "") arguments="${arguments} --norecursion" ;; + *) ;; + esac + + if [ ${subdir} = . ] ; then + echo "#!/bin/sh +# ${NO_EDIT} +# This directory was configured as follows: +${progname}" ${arguments} " +# ${using}" > ${subdir}/config.new + else + echo "#!/bin/sh +# ${NO_EDIT} +# This directory was configured as follows: +cd ${invsubdir} +${progname}" ${arguments} " +# ${using}" > ${subdir}/config.new + fi + chmod a+x ${subdir}/config.new + if [ -r ${subdir}/config.back ] ; then + mv -f ${subdir}/config.back ${subdir}/config.status + fi + ${config_shell} ${moveifchange} ${subdir}/config.new ${subdir}/config.status + ;; + + *) rm -f ${Makefile} ${subdir}/config.status ${links} ;; + esac +done + +# If there are subdirectories, then recur. +if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then + for configdir in ${configdirs} ; do + + if [ -d ${srcdir}/${configdir} ] ; then + eval echo Configuring ${configdir}... ${redirect} + case "${srcdir}" in + ".") ;; + *) + if [ ! -d ./${configdir} ] ; then + if mkdir ./${configdir} ; then + true + else + echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2 + exit 1 + fi + fi + ;; + esac + + POPDIR=${PWD=`pwd`} + cd ${configdir} + +### figure out what to do with srcdir + case "${srcdir}" in + ".") newsrcdir=${srcdir} ;; # no -srcdir option. We're building in place. + /*) # absolute path + newsrcdir=${srcdir}/${configdir} + srcdiroption="--srcdir=${newsrcdir}" + ;; + ?:*) # absolute path on win32 + newsrcdir=${srcdir}/${configdir} + srcdiroption="--srcdir=${newsrcdir}" + ;; + *) # otherwise relative + newsrcdir=../${srcdir}/${configdir} + srcdiroption="--srcdir=${newsrcdir}" + ;; + esac + + # Handle --cache-file=../XXX + case "${cache_file}" in + "") # empty + ;; + /*) # absolute path + cache_file_option="--cache-file=${cache_file}" + ;; + ?:*) # absolute path on win32 + cache_file_option="--cache-file=${cache_file}" + ;; + *) # relative path + cache_file_option="--cache-file=../${cache_file}" + ;; + esac + +### check for guested configure, otherwise fix possibly relative progname + if [ -f ${newsrcdir}/configure ] ; then + recprog=${newsrcdir}/configure + elif [ -f ${newsrcdir}/configure.in ] ; then + case "${progname}" in + /*) recprog=${progname} ;; + ?:*) recprog=${progname} ;; + *) recprog=../${progname} ;; + esac + else + eval echo No configuration information in ${configdir} ${redirect} + recprog= + fi + +### The recursion line is here. + if [ ! -z "${recprog}" ] ; then + if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \ + ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \ + ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${floating_pointoption} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then + true + else + echo Configure in `pwd` failed, exiting. 1>&2 + exit 1 + fi + fi + + cd ${POPDIR} + fi + done +fi + +# Perform the same cleanup as the trap handler, minus the "exit 1" of course, +# and reset the trap handler. +rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos +trap 0 + +exit 0 + +# +# Local Variables: +# fill-column: 131 +# End: +# + +# end of configure diff --git a/configure.in b/configure.in new file mode 100644 index 000000000000..e251e85b4247 --- /dev/null +++ b/configure.in @@ -0,0 +1,874 @@ +#! /bin/bash +############################################################################## + +## This file is a shell script fragment that supplies the information +## necessary to tailor a template configure script into the configure +## script appropriate for this directory. For more information, check +## any existing configure script. + +## Be warned, there are two types of configure.in files. There are those +## used by Autoconf, which are macros which are expanded into a configure +## script by autoconf. The other sort, of which this is one, is executed +## by Cygnus configure. + +## For more information on these two systems, check out the documentation +## for 'Autoconf' (autoconf.texi) and 'Configure' (configure.texi). + +# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. +# +# This file 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. + +############################################################################## + +### To add a new directory to the tree, first choose whether it is a target +### or a host dependent tool. Then put it into the appropriate list +### (library or tools, host or target), doing a dependency sort. For +### example, gdb requires that byacc (or bison) be built first, so it is in +### the ${host_tools} list after byacc and bison. + + +# these libraries are used by various programs built for the host environment +# +host_libs="mmalloc libiberty opcodes bfd readline gash db tcl tk tclX itcl tix" + +if [ "${enable_gdbgui}" = "yes" ] ; then + host_libs="${host_libs} libgui" +fi + +# these tools are built for the host environment +# Note, the powerpc-eabi build depends on sim occurring before gdb in order to +# know that we are building the simulator. +host_tools="texinfo byacc flex bison binutils ld gas gcc sim gdb make patch prms send-pr gprof gdbtest tgas etc expect dejagnu bash m4 autoconf automake ispell grep diff rcs cvs fileutils shellutils time textutils wdiff find emacs emacs19 uudecode hello tar gzip indent recode release sed utils guile perl apache inet gawk findutils sn" + +# these libraries are built for the target environment, and are built after +# the host libraries and the host tools (which may be a cross compiler) +# +target_libs="target-libiberty target-libgloss target-newlib target-libio target-librx target-libstdc++ target-libg++" + + +# these tools are built using the target libs, and are intended to run only +# in the target environment +# +# note: any program that *uses* libraries that are in the "target_libs" +# list belongs in this list. those programs are also very likely +# candidates for the "native_only" list which follows +# +target_tools="target-examples target-groff target-gperf" + +################################################################################ + +## These two lists are of directories that are to be removed from the +## ${configdirs} list for either cross-compilations or for native- +## compilations. For example, it doesn't make that much sense to +## cross-compile Emacs, nor is it terribly useful to compile target-libiberty in +## a native environment. + +# directories to be built in the native environment only +# +# This must be a single line because of the way it is searched by grep in +# the code below. +native_only="autoconf automake cvs emacs emacs19 fileutils find gawk grep gzip hello indent ispell m4 rcs recode sed shellutils tar textutils gash uudecode wdiff gprof target-groff guile perl apache inet time bash prms sn gnuserv target-gperf" + +# directories to be built in a cross environment only +# +cross_only="target-libgloss target-newlib" + +## All tools belong in one of the four categories, and are assigned above +## We assign ${configdirs} this way to remove all embedded newlines. This +## is important because configure will choke if they ever get through. +## ${configdirs} is directories we build using the host tools. +## ${target_configdirs} is directories we build using the target tools. +# +configdirs=`echo ${host_libs} ${host_tools}` +target_configdirs=`echo ${target_libs} ${target_tools}` + +################################################################################ + +srctrigger=move-if-change +srcname="gnu development package" + +# This gets set non-empty for some net releases of packages. +appdirs="" + +# per-host: + +# Work in distributions that contain no compiler tools, like Autoconf. +if [ -d ${srcdir}/config ]; then +case "${host}" in + m68k-hp-hpux*) host_makefile_frag=config/mh-hp300 ;; + m68k-apollo-sysv*) host_makefile_frag=config/mh-apollo68 ;; + m68k-apollo-bsd*) host_makefile_frag=config/mh-a68bsd ;; + m88k-dg-dgux*) host_makefile_frag=config/mh-dgux ;; + m88k-harris-cxux*) host_makefile_frag=config/mh-cxux ;; + m88k-motorola-sysv*) host_makefile_frag=config/mh-delta88;; + mips*-dec-ultrix*) host_makefile_frag=config/mh-decstation ;; + mips*-nec-sysv4*) host_makefile_frag=config/mh-necv4 ;; + mips*-sgi-irix6*) host_makefile_frag=config/mh-irix6 ;; + mips*-sgi-irix5*) host_makefile_frag=config/mh-irix5 ;; + mips*-sgi-irix4*) host_makefile_frag=config/mh-irix4 ;; + mips*-sgi-irix3*) host_makefile_frag=config/mh-sysv ;; + mips*-*-sysv4*) host_makefile_frag=config/mh-sysv4 ;; + mips*-*-sysv*) host_makefile_frag=config/mh-riscos ;; + i[3456]86-*-dgux*) host_makefile_frag=config/mh-dgux386 ;; + i[3456]86-ncr-sysv4.3) host_makefile_frag=config/mh-ncrsvr43 ;; + i[3456]86-ncr-sysv4*) host_makefile_frag=config/mh-ncr3000 ;; + i[3456]86-*-sco3.2v5*) host_makefile_frag=config/mh-sysv ;; + i[3456]86-*-sco*) host_makefile_frag=config/mh-sco ;; + i[3456]86-*-isc*) host_makefile_frag=config/mh-sysv ;; + i[3456]86-*-solaris2*) host_makefile_frag=config/mh-sysv4 ;; + i[3456]86-*-aix*) host_makefile_frag=config/mh-aix386 ;; + i[3456]86-*-go32*) host_makefile_frag=config/mh-go32 ;; + i[3456]86-*-msdosdjgpp*) host_makefile_frag=config/mh-go32 ;; + *-cygwin32*) host_makefile_frag=config/mh-cygwin32 ;; + *-windows*) host_makefile_frag=config/mh-windows ;; + vax-*-ultrix2*) host_makefile_frag=config/mh-vaxult2 ;; + *-*-solaris2*) host_makefile_frag=config/mh-solaris ;; + m68k-sun-sunos*) host_makefile_frag=config/mh-sun3 ;; + *-hp-hpux[78]*) host_makefile_frag=config/mh-hpux8 ;; + *-hp-hpux*) host_makefile_frag=config/mh-hpux ;; + *-*-hiux*) host_makefile_frag=config/mh-hpux ;; + rs6000-*-lynxos*) host_makefile_frag=config/mh-lynxrs6k ;; + *-*-lynxos*) host_makefile_frag=config/mh-lynxos ;; + *-*-sysv4*) host_makefile_frag=config/mh-sysv4 ;; + *-*-sysv*) host_makefile_frag=config/mh-sysv ;; +esac +fi + +# If we aren't going to be using gcc, see if we can extract a definition +# of CC from the fragment. +if [ -z "${CC}" -a "${build}" = "${host}" ]; then + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + found= + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/gcc; then + found=yes + break + fi + done + IFS="$save_ifs" + if [ -z "${found}" -a -n "${host_makefile_frag}" -a -f "${srcdir}/${host_makefile_frag}" ]; then + xx=`sed -n -e 's/^[ ]*CC[ ]*=[ ]*\(.*\)$/\1/p' < ${srcdir}/${host_makefile_frag}` + if [ -n "${xx}" ] ; then + CC=$xx + fi + fi +fi + +# We default to --with-shared on platforms where -fpic is meaningless. +# Well, we don't yet, but we will. +if false && [ "${host}" = "${target}" ] && [ x${enable_shared} = x ]; then + case "${target}" in + alpha-dec-osf*) enable_shared=yes ;; + alpha-*-linux*) enable_shared=yes ;; + mips-sgi-irix5*) enable_shared=yes ;; + *) enable_shared=no ;; + esac +fi + +case "${enable_shared}" in + yes) shared=yes ;; + no) shared=no ;; + "") shared=no ;; + *) shared=yes ;; +esac + +if [ x${shared} = xyes ]; then + waugh= + case "${host}" in + hppa*) waugh=config/mh-papic ;; + i[3456]86-*) waugh=config/mh-x86pic ;; + sparc64-*) waugh=config/mh-sparcpic ;; + powerpc*-*) waugh=config/mh-ppcpic ;; + *) waugh=config/mh-${host_cpu}pic ;; + esac + if [ -f ${srcdir}/${waugh} ]; then + if [ -n "${host_makefile_frag}" ] ; then + cat ${srcdir}/${host_makefile_frag} > mh-frag + cat ${srcdir}/${waugh} >> mh-frag + host_makefile_frag=mh-frag + else + host_makefile_frag=${waugh} + fi + fi +fi + +# per-target: + +case "${target}" in + v810*) target_makefile_frag=config/mt-v810 ;; + i[3456]86-*-netware*) target_makefile_frag=config/mt-netware ;; + powerpc-*-netware*) target_makefile_frag=config/mt-netware ;; +esac + +skipdirs= +gasdir=gas +use_gnu_ld= +use_gnu_as= + +# some tools are so dependent upon X11 that if we're not building with X, +# it's not even worth trying to configure, much less build, that tool. + +case ${with_x} in + yes | "") # the default value for this tree is that X11 is available + ;; + no) + skipdirs="${skipdirs} tk gash" + ;; + *) + echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2 + ;; +esac + +# Some tools are only suitable for building in a "native" situation. +# Those are added when we have a host==target configuration. For cross +# toolchains, we add some directories that should only be useful in a +# cross-compiler. + +is_cross_compiler= + +if [ x"${host}" = x"${target}" ] ; then + # when doing a native toolchain, don't build the targets + # that are in the 'cross only' list + skipdirs="${skipdirs} ${cross_only}" + is_cross_compiler=no + target_subdir=. + case "${host}" in + # We need multilib support for irix6, to get libiberty built + # properly for o32 and n32. + mips-sgi-irix6*) target_subdir=${host} ;; + esac +else + # similarly, don't build the targets in the 'native only' + # list when building a cross compiler + skipdirs="${skipdirs} ${native_only}" + is_cross_compiler=yes + target_subdir=${target_alias} +fi + +if [ ! -d ${target_subdir} ] ; then + if mkdir ${target_subdir} ; then true + else + echo "'*** could not make ${PWD=`pwd`}/${target_subdir}" 1>&2 + exit 1 + fi +fi + +copy_dirs= + +# Handle --with-headers=XXX. The contents of the named directory are +# copied to $(tooldir)/sys-include. +if [ x"${with_headers}" != x ]; then + if [ x${is_cross_compiler} = xno ]; then + echo 1>&2 '***' --with-headers is only supported when cross compiling + exit 1 + fi + case "${exec_prefixoption}" in + "") x=${prefix} ;; + *) x=${exec_prefix} ;; + esac + copy_dirs="${copy_dirs} ${with_headers} $x/${target_alias}/sys-include" +fi + +# Handle --with-libs=XXX. Multiple directories are permitted. The +# contents are copied to $(tooldir)/lib. +if [ x"${with_libs}" != x ]; then + if [ x${is_cross_compiler} = xno ]; then + echo 1>&2 '***' --with-libs is only supported when cross compiling + exit 1 + fi + # Copy the libraries in reverse order, so that files in the first named + # library override files in subsequent libraries. + case "${exec_prefixoption}" in + "") x=${prefix} ;; + *) x=${exec_prefix} ;; + esac + for l in ${with_libs}; do + copy_dirs="$l $x/${target_alias}/lib ${copy_dirs}" + done +fi + +# If both --with-headers and --with-libs are specified, default to +# --without-newlib. +if [ x"${with_headers}" != x ] && [ x"${with_libs}" != x ]; then + if [ x"${with_newlib}" = x ]; then + with_newlib=no + fi +fi + +# Recognize --with-newlib/--without-newlib. +if [ x${with_newlib} = xno ]; then + skipdirs="${skipdirs} target-newlib" +elif [ x${with_newlib} = xyes ]; then + skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` +fi + +# Default to using --with-stabs for certain targets. +if [ x${with_stabs} = x ]; then + case "${target}" in + mips*-*-irix6*) + ;; + mips*-*-* | alpha*-*-osf* | i[3456]86*-*-sysv4* | i[3456]86*-*-unixware*) + with_stabs=yes; + withoptions="${withoptions} --with-stabs" + ;; + esac +fi + +# Handle ${copy_dirs} +set fnord ${copy_dirs} +shift +while [ $# != 0 ]; do + if [ -f $2/COPIED ] && [ x"`cat $2/COPIED`" = x"$1" ]; then + : + else + echo Copying $1 to $2 + + # Use the install script to create the directory and all required + # parent directories. + if [ -d $2 ]; then + : + else + echo >config.temp + ${srcdir}/install-sh -c -m 644 config.temp $2/COPIED + fi + + # Copy the directory, assuming we have tar. + # FIXME: Should we use B in the second tar? Not all systems support it. + (cd $1; tar -cf - .) | (cd $2; tar -xpf -) + + # It is the responsibility of the user to correctly adjust all + # symlinks. If somebody can figure out how to handle them correctly + # here, feel free to add the code. + + echo $1 > $2/COPIED + fi + shift; shift +done + +# Configure extra directories which are host specific + +case "${host}" in + i[3456]86-*-go32*) + configdirs="$configdirs dosrel" ;; + *-cygwin32*) + configdirs="$configdirs dosrel" ;; +esac + +# Remove more programs from consideration, based on the host or +# target this usually means that a port of the program doesn't +# exist yet. + +noconfigdirs="" + +case "${host}" in + i[3456]86-*-vsta) + noconfigdirs="tcl expect dejagnu make texinfo bison patch flex byacc send-pr gprof uudecode dejagnu diff guile perl apache inet itcl tix db sn gnuserv" + ;; + i[3456]86-*-go32* | i[3456]86-*-msdosdjgpp*) + noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc send-pr uudecode dejagnu diff guile perl apache inet itcl tix db sn gnuserv" + ;; + *-*-cygwin32) + noconfigdirs="expect dejagnu cvs autoconf automake bison send-pr gprof rcs guile perl texinfo apache inet" + ;; + *-*-windows*) +# This is only used to build WinGDB... +# note that powerpc-eabi depends on sim configured before gdb. + configdirs="bfd libiberty opcodes readline sim gdb" + target_configdirs= + ;; + ppc*-*-pe) + noconfigdirs="patch diff make tk tcl expect dejagnu cvs autoconf automake texinfo bison send-pr gprof rcs guile perl apache inet itcl tix db sn gnuserv" + ;; +esac + + +case "${target}" in + *-*-netware) + noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-librx target-newlib target-libiberty target-libgloss" + ;; + *-*-vxworks*) + noconfigdirs="$noconfigdirs target-newlib target-libgloss" + ;; + alpha-dec-osf*) + # ld works, but does not support shared libraries. emacs doesn't + # work. newlib is not 64 bit ready. I'm not sure about fileutils. + # gas doesn't generate exception information. + noconfigdirs="$noconfigdirs gas ld emacs fileutils target-newlib target-libgloss" + ;; + alpha*-*-*vms*) + noconfigdirs="$noconfigdirs gdb ld target-newlib target-libgloss" + ;; + alpha*-*-*) + # newlib is not 64 bit ready + noconfigdirs="$noconfigdirs target-newlib target-libgloss" + ;; + arc-*-*) + noconfigdirs="$noconfigdirs target-libgloss" + ;; + arm-*-pe*) + noconfigdirs="$noconfigdirs target-libgloss" + ;; + arm-*-coff*) + noconfigdirs="$noconfigdirs target-libgloss" + ;; + arm-*-riscix*) + noconfigdirs="$noconfigdirs ld target-libgloss" + ;; + d10v-*-*) + noconfigdirs="$noconfigdirs target-librx target-libg++ target-libstdc++ target-libio target-libgloss" + ;; + h8300*-*-* | \ + h8500-*-*) + noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx target-libgloss" + ;; + hppa*-*-*elf* | \ + hppa*-*-lites* | \ + hppa*-*-rtems* ) + # Do configure ld/binutils/gas for this case. + ;; + hppa*-*-*) + # HP's C compiler doesn't handle Emacs correctly (but on BSD and Mach + # cc is gcc, and on any system a user should be able to link cc to + # whatever they want. FIXME, emacs emacs19). + case "${CC}" in + "" | cc*) noconfigdirs="$noconfigdirs emacs emacs19" ;; + *) ;; + esac + noconfigdirs="$noconfigdirs ld shellutils" + ;; + i[3456]86-*-go32* | i[3456]-*-msdosdjgpp*) + # but don't build gdb + noconfigdirs="$noconfigdirs gdb target-libg++ target-libstdc++ target-libio target-librx" + ;; + *-*-cygwin32) + target_configdirs="$target_configdirs target-winsup" + noconfigdirs="$noconfigdirs expect target-libgloss" + # always build newlib. + skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` + + # Can't build gdb for cygwin32 if not native. + case "${host}" in + *-*-cygwin32) ;; # keep gdb tcl tk expect etc. + *) noconfigdirs="$noconfigdirs gdb tcl tk expect itcl tix db sn gnuserv" + ;; + esac + ;; + i[3456]86-*-pe) + noconfigdirs="$noconfigdirs target-libg++ target-libstdc++ target-libio target-librx target-libgloss" + ;; + i[3456]86-*-sco3.2v5*) + # The linker does not yet know about weak symbols in COFF, + # and is not configured to handle mixed ELF and COFF. + noconfigdirs="$noconfigdirs gprof ld target-libgloss" + ;; + i[3456]86-*-sco*) + noconfigdirs="$noconfigdirs gprof target-libgloss" + ;; + i[3456]86-*-solaris2*) + # The linker does static linking correctly, but the Solaris C library + # has bugs such that some important functions won't work when statically + # linked. (See man pages for getpwuid, for example.) + noconfigdirs="$noconfigdirs ld target-libgloss" + ;; + i[3456]86-*-sysv4*) + # The SYSV4 C compiler doesn't handle Emacs correctly + case "${CC}" in + "" | cc*) noconfigdirs="$noconfigdirs emacs emacs19" ;; + *) ;; + esac + # but that's okay since emacs doesn't work anyway + noconfigdirs="$noconfigdirs emacs emacs19 target-libgloss" + ;; + mn10200-*-*) + noconfigdirs="$noconfigdirs target-libgloss" + ;; + mn10300-*-*) + noconfigdirs="$noconfigdirs target-libgloss" + ;; + powerpc-*-aix*) + # copied from rs6000-*-* entry + noconfigdirs="$noconfigdirs gprof cvs target-libgloss" + # This is needed until gcc and ld are fixed to work together. + use_gnu_ld=no + ;; + powerpc*-*-winnt* | powerpc*-*-pe* | ppc*-*-pe) + target_configdirs="$target_configdirs target-winsup" + noconfigdirs="$noconfigdirs gdb tcl tk make expect target-libgloss itcl tix db sn gnuserv" + # always build newlib. + skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` + ;; + # This is temporary until we can link against shared libraries + powerpcle-*-solaris*) + noconfigdirs="$noconfigdirs gdb sim make tcl tk expect itcl tix db sn gnuserv" + ;; + rs6000-*-lynxos*) + # The CVS server code doesn't work on the RS/6000 + # Newlib makes problems for libg++ in crosses. + noconfigdirs="$noconfigdirs target-newlib gprof cvs" + ;; + rs6000-*-aix*) + noconfigdirs="$noconfigdirs gprof" + # This is needed until gcc and ld are fixed to work together. + use_gnu_ld=no + ;; + rs6000-*-*) + noconfigdirs="$noconfigdirs gprof" + ;; + m68k-apollo-*) + noconfigdirs="$noconfigdirs ld binutils gprof target-libgloss" + ;; + mips*-*-irix5*) + # The GNU linker does not support shared libraries. + # emacs is emacs 18, which does not work on Irix 5 (emacs19 does work) + noconfigdirs="$noconfigdirs ld gprof emacs target-libgloss" + ;; + mips*-*-irix6*) + # The GNU assembler and linker do not support IRIX 6. + # emacs is emacs 18, which does not work on Irix 5 (emacs19 does work) + noconfigdirs="$noconfigdirs ld gas gprof emacs target-libgloss" + ;; + mips*-dec-bsd*) + noconfigdirs="$noconfigdirs gprof target-libgloss" + ;; + mips*-*-bsd*) + noconfigdirs="$noconfigdirs gprof target-libgloss" + ;; + mips*-*-*) + noconfigdirs="$noconfigdirs gprof" + ;; + romp-*-*) + noconfigdirs="$noconfigdirs bfd binutils ld gas opcodes target-libgloss" + ;; + sh-*-*) + case "${host}" in + i[3456]86-*-vsta) ;; # don't add gprof back in + i[3456]86-*-go32*) ;; # don't add gprof back in + i[3456]86-*-msdosdjgpp*) ;; # don't add gprof back in + *) skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'` ;; + esac + noconfigdirs="$noconfigdirs target-libgloss" + ;; + sparc-*-sunos4*) + if [ x${is_cross_compiler} != xno ] ; then + noconfigdirs="$noconfigdirs gdb gdbtest target-newlib target-libgloss" + else + use_gnu_ld=no + fi + ;; + v810-*-*) + noconfigdirs="$noconfigdirs bfd binutils gas gcc gdb ld target-libio target-libg++ target-libstdc++ opcodes target-libgloss" + ;; + vax-*-vms) + noconfigdirs="$noconfigdirs bfd binutils gdb ld target-newlib opcodes target-libgloss" + ;; + vax-*-*) + noconfigdirs="$noconfigdirs target-newlib target-libgloss" + ;; + *-*-lynxos*) + # Newlib makes problems for libg++ in crosses. + noconfigdirs="$noconfigdirs target-newlib target-libgloss" + ;; + *-*-macos* | \ + *-*-mpw*) + # Macs want a resource compiler. + configdirs="$configdirs grez" + ;; +esac + +# targets that need a second pass +case "${target}" in + *-gm-magic*) + noconfigdirs="$noconfigdirs target-libgloss" + ;; +esac + +# If we aren't building newlib, then don't build libgloss, since libgloss +# depends upon some newlib header files. +case "${noconfigdirs}" in + *target-libgloss*) ;; + *target-newlib*) noconfigdirs="$noconfigdirs target-libgloss" ;; +esac + +# If we are building a Canadian Cross, discard tools that can not be built +# using a cross compiler. FIXME: These tools should be fixed. +if [ "${build}" != "${host}" ]; then + noconfigdirs="$noconfigdirs expect dejagnu" +fi + +# Make sure we don't let GNU ld be added if we didn't want it. +if [ x$with_gnu_ld = xno ]; then + use_gnu_ld=no + noconfigdirs="$noconfigdirs ld" +fi + +# Make sure we don't let GNU as be added if we didn't want it. +if [ x$with_gnu_as = xno ]; then + use_gnu_as=no + noconfigdirs="$noconfigdirs gas" +fi + +# Remove the entries in $skipdirs and $noconfigdirs from $configdirs and +# $target_configdirs. +# If we have the source for $noconfigdirs entries, add them to $notsupp. + +notsupp="" +for dir in . $skipdirs $noconfigdirs ; do + dirname=`echo $dir | sed -e s/target-//g` + if [ $dir != . ] && echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then + configdirs=`echo " ${configdirs} " | sed -e "s/ ${dir} / /"` + if [ -r $srcdir/$dirname/configure ] \ + || [ -r $srcdir/$dirname/configure.in ]; then + if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then + true + else + notsupp="$notsupp $dir" + fi + fi + fi + if [ $dir != . ] && echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then + target_configdirs=`echo " ${target_configdirs} " | sed -e "s/ ${dir} / /"` + if [ -r $srcdir/$dirname/configure ] \ + || [ -r $srcdir/$dirname/configure.in ]; then + if echo " ${skipdirs} " | grep " ${dir} " >/dev/null 2>&1; then + true + else + notsupp="$notsupp $dir" + fi + fi + fi +done + +# Sometimes the tools are distributed with libiberty but with no other +# libraries. In that case, we don't want to build target-libiberty. +if [ -n "${target_configdirs}" ]; then + others= + for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do + if [ "$i" != "libiberty" ]; then + if [ -r $srcdir/$i/configure ] || [ -r $srcdir/$i/configure.in ]; then + others=yes; + break; + fi + fi + done + if [ -z "${others}" ]; then + target_configdirs= + fi +fi + +# Deconfigure all subdirectories, in case we are changing the +# configuration from one where a subdirectory is supported to one where it +# is not. +if [ -z "${norecursion}" -a -n "${configdirs}" ]; then + for i in `echo ${configdirs} | sed -e s/target-//g` ; do + rm -f $i/Makefile + done +fi +if [ -z "${norecursion}" -a -n "${target_configdirs}" ]; then + for i in `echo ${target_configdirs} | sed -e s/target-//g` ; do + rm -f ${target_subdir}/$i/Makefile + done +fi + +# Produce a warning message for the subdirs we can't configure. +# This isn't especially interesting in the Cygnus tree, but in the individual +# FSF releases, it's important to let people know when their machine isn't +# supported by the one or two programs in a package. + +if [ -n "${notsupp}" ] && [ -z "${norecursion}" ]; then + # If $appdirs is non-empty, at least one of those directories must still + # be configured, or we error out. (E.g., if the gas release supports a + # specified target in some subdirs but not the gas subdir, we shouldn't + # pretend that all is well.) + if [ -n "$appdirs" ]; then + for dir in $appdirs ; do + if [ -r $dir/Makefile.in ]; then + if echo " ${configdirs} " | grep " ${dir} " >/dev/null 2>&1; then + appdirs="" + break + fi + if echo " ${target_configdirs} " | grep " ${dir} " >/dev/null 2>&1; then + appdirs="" + break + fi + fi + done + if [ -n "$appdirs" ]; then + echo "*** This configuration is not supported by this package." 1>&2 + exit 1 + fi + fi + # Okay, some application will build, or we don't care to check. Still + # notify of subdirs not getting built. + echo "*** This configuration is not supported in the following subdirectories:" 1>&2 + echo " ${notsupp}" 1>&2 + echo " (Any other directories should still work fine.)" 1>&2 +fi + +# Set with_gnu_as and with_gnu_ld as appropriate. +# +# This is done by determining whether or not the appropriate directory +# is available, and by checking whether or not specific configurations +# have requested that this magic not happen. +# +# The command line options always override the explicit settings in +# configure.in, and the settings in configure.in override this magic. +# +# If the default for a toolchain is to use GNU as and ld, and you don't +# want to do that, then you should use the --without-gnu-as and +# --without-gnu-ld options for the configure script. + +if [ x${use_gnu_as} = x ] ; then + if [ x${with_gnu_as} != xno ] && echo " ${configdirs} " | grep " ${gasdir} " > /dev/null 2>&1 && [ -d ${srcdir}/${gasdir} ] ; then + with_gnu_as=yes + withoptions="$withoptions --with-gnu-as" + fi +fi + +if [ x${use_gnu_ld} = x ] ; then + if [ x${with_gnu_ld} != xno ] && echo " ${configdirs} " | grep " ld " > /dev/null 2>&1 && [ -d ${srcdir}/ld ] ; then + with_gnu_ld=yes + withoptions="$withoptions --with-gnu-ld" + fi +fi + +# If using newlib, add --with-newlib to the withoptions so that gcc/configure +# can detect this case. + +if [ x${with_newlib} != xno ] && echo " ${target_configdirs} " | grep " target-newlib " > /dev/null 2>&1 && [ -d ${srcdir}/newlib ] ; then + with_newlib=yes + withoptions="$withoptions --with-newlib" +fi + +if [ x${shared} = xyes ]; then + case "${target}" in + hppa*) target_makefile_frag=config/mt-papic ;; + i[3456]86-*) target_makefile_frag=config/mt-x86pic ;; + powerpc*-*) target_makefile_frag=config/mt-ppcpic ;; + *) target_makefile_frag=config/mt-${target_cpu}pic ;; + esac +fi + +# post-target: + +# Make sure that the compiler is able to generate an executable. If it +# can't, we are probably in trouble. We don't care whether we can run the +# executable--we might be using a cross compiler--we only care whether it +# can be created. At this point the main configure script has set CC. +echo "int main () { return 0; }" > conftest.c +${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c +if [ $? = 0 ] && [ -s conftest ]; then + : +else + echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed." + echo 1>&2 "*** You must set the environment variable CC to a working compiler." + rm -f conftest* + exit 1 +fi +rm -f conftest* + +# The Solaris /usr/ucb/cc compiler does not appear to work. +case "${host}" in + sparc-sun-solaris2*) + CCBASE="`echo ${CC-cc} | sed 's/ .*$//'`" + if [ "`/usr/bin/which $CCBASE`" = "/usr/ucb/cc" ] ; then + could_use= + [ -d /opt/SUNWspro/bin ] && could_use="/opt/SUNWspro/bin" + if [ -d /opt/cygnus/bin ] ; then + if [ "$could_use" = "" ] ; then + could_use="/opt/cygnus/bin" + else + could_use="$could_use or /opt/cygnus/bin" + fi + fi + if [ "$could_use" = "" ] ; then + echo "Warning: compilation may fail because you're using" + echo "/usr/ucb/cc. You should change your PATH or CC " + echo "variable and rerun configure." + else + echo "Warning: compilation may fail because you're using" + echo "/usr/ucb/cc, when you should use the C compiler from" + echo "$could_use. You should change your" + echo "PATH or CC variable and rerun configure." + fi + fi + ;; +esac + +# If --enable-shared was set, we must set LD_LIBRARY_PATH so that the +# binutils tools will find libbfd.so. +if [ "${shared}" = "yes" ]; then + sed -e 's/^SET_LIB_PATH[ ]*=.*$/SET_LIB_PATH = $(REALLY_SET_LIB_PATH)/' \ + Makefile > Makefile.tem + rm -f Makefile + mv -f Makefile.tem Makefile + + case "${host}" in + *-*-hpux*) + sed -e 's/RPATH_ENVVAR[ ]*=.*$/RPATH_ENVVAR = SHLIB_PATH/' \ + Makefile > Makefile.tem + rm -f Makefile + mv -f Makefile.tem Makefile + ;; + esac +fi + +# If we are building for a cygwin32 host, then set INSTALL_PROGRAM_ARGS to +# -x. This will cause programs to be installed with .exe extensions. +case "${host}" in +*-*-cygwin32*) + sed -e 's/^INSTALL_PROGRAM_ARGS[ ]*=.*$/INSTALL_PROGRAM_ARGS = -x/' \ + Makefile > Makefile.tem + rm -f Makefile + mv -f Makefile.tem Makefile + ;; +esac + +# Record target_configdirs and the configure arguments in Makefile. +target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'` +targargs=`echo "${arguments}" | \ + sed -e 's/--norecursion//' \ + -e 's/--cache[a-z-]*=[^ ]*//' \ + -e 's/--ho[a-z-]*=[^ ]*//' \ + -e 's/--bu[a-z-]*=[^ ]*//' \ + -e 's/--ta[a-z-]*=[^ ]*//'` + +# Passing a --with-cross-host argument lets the target libraries know +# whether they are being built with a cross-compiler or being built +# native. However, it would be better to use other mechanisms to make the +# sorts of decisions they want to make on this basis. Please consider +# this option to be deprecated. FIXME. +if [ x${is_cross_compiler} = xyes ]; then + targargs="--with-cross-host=${host_alias} ${targargs}" +fi + +# Default to --enable-multilib. +if [ x${enable_multilib} = x ]; then + targargs="--enable-multilib ${targargs}" +fi + +targargs="--host=${target_alias} --build=${build_alias} ${targargs}" +sed -e "s:^TARGET_CONFIGDIRS[ ]*=.*$:TARGET_CONFIGDIRS = ${target_configdirs}:" \ + -e "s%^CONFIG_ARGUMENTS[ ]*=.*$%CONFIG_ARGUMENTS = ${targargs}%" \ + -e "s%^TARGET_SUBDIR[ ]*=.*$%TARGET_SUBDIR = ${target_subdir}%" \ + Makefile > Makefile.tem +rm -f Makefile +mv -f Makefile.tem Makefile + +# +# Local Variables: +# fill-column: 131 +# End: +# diff --git a/etc/ChangeLog b/etc/ChangeLog new file mode 100644 index 000000000000..54c1a44f24a9 --- /dev/null +++ b/etc/ChangeLog @@ -0,0 +1,392 @@ +Tue Jun 17 15:50:23 1997 Angela Marie Thomas (angela@cygnus.com) + + * Install.in: Add /usr/bsd to PATH for Irix (home of compress) + +Thu Jun 12 13:47:00 1997 Angela Marie Thomas (angela@cygnus.com) + + * Install.in (show_exec_prefix_msg): fix quoting + +Wed Jun 4 15:31:43 1997 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * rebuilding.texi: Removed. + +Sat May 24 18:02:20 1997 Angela Marie Thomas (angela@cygnus.com) + + * cross-tools-fix: Remove host check since it doesn't matter + for this case. + * Install.in (guess_system): clean up more unused hosts. + * Install.in, cross-tools-fix, comp-tools-fix, comp-tools-verify: + Hack for host check to not warn the user for certain cases. + +Fri May 23 23:46:10 1997 Angela Marie Thomas (angela@cygnus.com) + + * subst-strings: Remove a lot of unused code + * Install.in: Remove reference to TAPEdflt, use variables instead of + string substitution when able. + +Fri Apr 11 17:25:52 1997 Ian Lance Taylor + + * configure.in: Change file named in AC_INIT to Makefile.in. + * configure: Rebuild. + +Fri Apr 11 18:12:42 1997 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Install.in (guess_system): Back out change to INSTALLHOST to + call all IRIX systems "mips-sgi-irix4" + + * Makefile.in: Remove references to configure.texi and cfg-paper.texi. + +Thu Apr 10 23:26:45 1997 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * srctree.texi, emacs-relnotes.texi, cfg-paper.texi: Remove. + * Install.in: Remove Ultrix-specific hacks. + Update Cygnus phone numbers. + (guess_system): Remove some old systems (Ultrix, OSF1 v1 & 2, + m68k-HPUX, m68k SunOS, etc.) + (show_gnu_root_msg): Remove. + Removed all the remove option code. + +Thu Apr 10 23:23:33 1997 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * configure.man, configure.texi: Remote. + +Mon Apr 7 18:15:00 1997 Brendan Kehoe + + * Fix the version string for OSF1 4.0 to recognize either + V4.* or X4.* + +Mon Apr 7 15:34:47 1997 Ian Lance Taylor + + * standards.texi, make-stds.texi: Update to current FSF versions. + +Tue Apr 1 16:19:31 1997 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Install.in (show_exec_prefix_msg): GDBTK_FILENAME to + GDBTK_LIBRARY, also update TCL_LIBRARY and TK_LIBRARY. + +Tue Nov 19 15:36:14 1996 Doug Evans + + * make-rel-sym-tree: New file. + +Wed Oct 23 00:34:07 1996 Angela Marie Thomas (angela@cygnus.com) + + * Lots of patches from progressive... + * Install.in: restore DDOPTS for AIX 4.x + * Install.in, subst-strings: add case for DG Aviion + * subst-strings: fix typo in INSTALLdir var setting + * comp-tools-verify: set SHLIB_PATH for shared libs + * Install.in, subst-strings: add case for solaris2.5 + * Install.in: fix regression for hppa1.1 check + * comp-tools-fix: set LD_LIBRARY_PATH + * comp-tools-fix: If fixincludes fixes /usr/include/limits.h, + install it as syslimits.h. + +Wed Oct 16 19:20:42 1996 Michael Meissner + + * Install.in (guess_system): Treat powerpc-ibm-aix4.1 the same as + rs6000-ibm-aix4.1, since the compiler now uses common mode by + default. + +Wed Oct 2 15:39:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * configure.in (AC_PROG_INSTALL): Added. + * Makefile.in (distclean): Remove config.cache. + +Wed Oct 2 14:33:58 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * configure.in: Switch to autoconf configure.in. + * configure: New. + * Makefile.in: Use autoconf-substituted values. + +Tue Jun 25 18:56:08 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (datadir): Changed to $(prefix)/share. + +Fri Mar 29 11:38:01 1996 J.T. Conklin (jtc@lisa.cygnus.com) + + * configure.man: Changed to be recognized by catman -w on Solaris. + +Wed Dec 6 15:40:28 1995 Doug Evans + + * comp-tools-fix (fixincludes): Define FIXPROTO_DEFINES from + .../install-tools/fixproto-defines. + +Sun Nov 12 19:31:27 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * comp-tools-verify (verify_cxx_initializers): delete argv, + argc declarations, add -static to compile line. + (verify_cxx_hello_world): delete argv, argc declarations, add + -static to compile line. + +Wed Sep 20 13:21:52 1995 Ian Lance Taylor + + * Makefile.in (maintainer-clean): New target, synonym for + realclean. + +Thu Sep 14 17:19:58 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Install.in (show_exec_prefix_msg): print out paths for + TCL_LIBRARY, TK_LIBRARY and GDBTK_FILENAME. + +Mon Aug 28 17:25:49 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Install.in (PATH): add /usr/ucb to $PATH (for SunOS 4.1.x). + +Tue Aug 15 21:51:58 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Install.in (guess_system): Match OSF/1 v3.x as the same as + v2.x--v2.x binaries are upward compatible. + +Tue Aug 15 21:46:54 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Install.in (guess_system): recognize HP 9000/800 systems as the + same as HP 9000/700 systems. + +Tue Aug 8 13:11:56 1995 Brendan Kehoe + + * Install.in: For emacs, run show_emacs_alternate_msg and exit. + (show_emacs_alternate_msg): New message saying how emacs can't be + installed in an alternate prefix. + +Thu Jun 8 00:42:56 1995 Angela Marie Thomas + + * subst-strings: change du commands to $BINDIR/. & $SRCDIR/. just + in case they are symlinks. + +Tue Apr 18 14:23:10 1995 J.T. Conklin + + * cdk-fix: Extracted table of targets that don't need their + headers fixed from gcc's configure script. + + * cdk-fix, cdk-verify: Use ${HOST} instead of ||HOSTstr|| + + * cdk-fix, cdk-verify: New files, install script fragments used + for Cygnus Developer's Kit. + + * Install.in (do_mkdir): New function. + + * Install.in: Added support for --with and --without options. + Changed so that tape commands are not run when extracting + from a file. + (do_mt): Changed to take only one argument. + +Wed Mar 29 11:16:38 1995 Jason Molenda (crash@phydeaux.cygnus.com) + + * Install.in: catch UNAME==alpha-dec-osf2.x and correct entry for + alpha-dec-osf1.x + +Fri Jan 27 12:04:29 1995 J.T. Conklin + + * subst-strings (mips-sgi-irix5): New entry in table. + +Thu Jan 19 12:15:44 1995 J.T. Conklin + + * Install.in: Major rewrite, bundle dependent code (for example, + fixincludes for comp-tools) will be inserted into the Install + script when it is generated. + +Tue Jan 17 16:51:32 1995 Ian Lance Taylor + + * Makefile.in (Makefile): Rebuild using $(SHELL). + +Thu Nov 3 19:30:33 1994 Ken Raeburn + + * Makefile.in (install-info): Depend on info. + +Fri Aug 19 16:16:38 1994 Jason Molenda (crash@phydeaux.cygnus.com) + + * Install.in: set $FIX_HEADER so fixproto can find fix-header. + +Fri May 6 16:18:58 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Makefile.in (install-info): add a semicolon in the if statement. + +Fri Apr 29 16:56:07 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * cfg-paper.texi: Update some outdated information. + + * Makefile.in (install-info): Pass file, not directory, as last + arg to INSTALL_DATA. + (uninstall): New target. + +Thu Apr 28 14:42:22 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure.texi: Comment out @smallbook. + + * Makefile.in: Define TEXI2DVI and TEXIDIR, and use the latter. + Remove info files in realclean, not clean, per coding standards. + Remove TeX output in clean. + +Tue Apr 26 17:18:03 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: fixincludes output is actually put in fixincludes.log, + but echo'ed messages claim it is fixinc.log. This is the same + messages as I logged in March 4 1994, but for some reason we found + the change hadn't been done. I'll have to dig through the logs + and find out what I really did do that day. :) + +Mon Apr 25 20:28:19 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: use eval to call do_mt() for Ultrix brokenness. + +Mon Apr 25 20:00:00 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in(do_mt): exit with error status 1 if # of parameters + != 3. + +Mon Apr 25 19:42:36 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: lose TAPE_FORWARD and TAPE_REWIND, add do_mt() + to do all tape movement operations. Currently untested. Addresses + PR # 4886 from bull. + + * Install.in: add 1994 to the copyright thing. + +Fri Apr 22 19:05:13 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * standards.texi: Update from FSF. + +Fri Apr 22 15:46:10 1994 Jason Molenda (crash@cygnus.com) + + * Install.in: Add $DDOPTS, has ``bs=124b'' for all systems except + AIX (some versions of AIX don't understand bs=124b. Silly OS). + +Mon Apr 4 22:55:05 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: null out $TOOLS before adding stuff to it + non-destructively. + +Wed Mar 30 21:45:35 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * standards.texi: Fix typo. + + * configure.texi, configure.man: Document --disable-. + +Mon Mar 28 13:22:15 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * standards.texi: Update from FSF. + +Sat Mar 26 09:21:44 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * standards.texi, make-stds.texi: Update from FSF. + +Fri Mar 25 22:59:45 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure.texi, configure.man: Document --enable-* options. + +Wed Mar 23 23:38:24 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: set CPP to be gcc -E for fixincludes. + +Wed Mar 23 13:42:48 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: set PATH to $PATH:/bin:/usr/bin so we can pick + up native tools even if the user doesn't have them in his + path. + + * Install.in: ``hppa-1.1-hp-hpux'' -> ``hppa1.1-hp-hpux''. + +Tue Mar 15 22:09:20 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: TAPE_REWIND and TAPE_FORWARD variables for Unixunaware, + added switch statement to detect if system is Unixunaware. + +Fri Mar 4 12:10:30 1994 Jason Molenda (crash@sendai.cygnus.com) + + * Install.in: fixincludes output is actually put in fixincludes.log, + but echo'ed messages claim it is fixinc.log. + +Wed Nov 3 02:58:02 1993 Jeffrey Osier (jeffrey@thepub.cygnus.com) + + * subst-strings: output TEXBUNDLE for more install notes matching + * install-texi.in: PRMS info now exists + +Tue Oct 26 16:57:12 1993 K. Richard Pixley (rich@sendai.cygnus.com) + + * subst-strings: match solaris*. Also, add default case to catch + and error out for unrecognized systems. + +Thu Aug 19 18:21:31 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Install.in: handle the new fixproto work + +Mon Jul 19 12:05:41 1993 david d `zoo' zuhn (zoo@cirdan.cygnus.com) + + * Install.in: remove "MT=tctl" for AIX (not needed, and barely + worked anyway) + +Mon Jun 14 19:09:22 1993 Jeffrey Osier (jeffrey@cygnus.com) + + * subst-strings: changed HOST to recognize Solaris for install notes + +Thu Jun 10 16:01:25 1993 Jeffrey Osier (jeffrey@cygnus.com) + + * dos-inst.texi: new file. + +Wed Jun 9 19:23:59 1993 Jeffrey Osier (jeffrey@rtl.cygnus.com) + + * install-texi.in: added conditionals (nearly complete) + cleaned up + added support for other releases (not done) + +Wed Jun 9 15:53:58 1993 Jim Kingdon (kingdon@cygnus.com) + + * Makefile.in (install-info): Use INSTALL_DATA. + ({dist,real}clean): Also delete Makefile and config.status. + +Fri Jun 4 17:09:56 1993 Jeffrey Osier (jeffrey@cygnus.com) + + * subst-strings: added data for OS_STRING + + * subst-strings: added support for OS_STRING + +Thu Jun 3 00:37:01 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Install.in: pull COPYING and COPYING.LIB off of the tape + +Tue Jun 1 16:52:08 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * subst-strings: replace RELEASE_DIR too + +Mon Mar 22 23:55:27 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: add installcheck target + +Wed Mar 17 02:21:15 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Install.in: fix 'source only' extraction bug where it looked for + the src dir under H-/src instead of src; also remove stray + reference to EMACSHIBIN + +Mon Mar 15 01:25:45 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * make-stds.texi: added 'installcheck' to the standard targets + +Tue Mar 9 19:48:28 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * standards.texi: added INFO-DIR-ENTRY, updated version from the FSF + +Tue Feb 9 12:40:23 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (standards.info): Added -I$(srcdir) to find + make-stds.texi. + +Mon Feb 1 16:32:56 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * standards.texi: updated to latest FSF version, which includes: + + * make-stds.texi: new file + +Mon Nov 30 01:31:40 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * install-texi.in, relnotes.texi, intro.texi: changed Cygnus phone + numbers from the old Palo Alto ones to the new Mtn. View numbers + +Mon Nov 16 16:50:43 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: define $(RM) to "rm -f" + +Sun Oct 11 16:05:48 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * intro.texi: added INFO-DIR-ENTRY + diff --git a/etc/Makefile.in b/etc/Makefile.in new file mode 100644 index 000000000000..a5d59d6efdb2 --- /dev/null +++ b/etc/Makefile.in @@ -0,0 +1,88 @@ +# +# Makefile.in for etc +# + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +srcdir = @srcdir@ +VPATH = @srcdir@ + +bindir = @bindir@ +libdir = @libdir@ +tooldir = $(libdir) +datadir = @datadir@ + +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +man3dir = $(mandir)/man3 +man4dir = $(mandir)/man4 +man5dir = $(mandir)/man5 +man6dir = $(mandir)/man6 +man7dir = $(mandir)/man7 +man8dir = $(mandir)/man8 +man9dir = $(mandir)/man9 +infodir = @infodir@ + +SHELL = /bin/sh + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi + +# Where to find texinfo.tex to format documentation with TeX. +TEXIDIR = $(srcdir)/../texinfo + +#### Host, target, and site specific Makefile fragments come in here. +### + +INFOFILES = standards.info +DVIFILES = standards.dvi + +all: + +install: + +uninstall: + +info: $(INFOFILES) + +install-info: info + if test ! -f standards.info ; then cd $(srcdir); fi; \ + for i in standards.info*; do \ + $(INSTALL_DATA) $$i $(infodir)/$$i; \ + done + +dvi: $(DVIFILES) + +standards.info: $(srcdir)/standards.texi + $(MAKEINFO) -I$(srcdir) -o standards.info $(srcdir)/standards.texi + +standards.dvi: $(srcdir)/standards.texi + TEXINPUTS=$(TEXIDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/standards.texi + + +clean: + rm -f *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.log + rm -f *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status config.cache + +maintainer-clean realclean: distclean + rm -f *.info* + +Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) + $(SHELL) ./config.status + +## these last targets are for standards.texi conformance +dist: +check: +installcheck: +TAGS: diff --git a/etc/configure b/etc/configure new file mode 100755 index 000000000000..c4a76356c468 --- /dev/null +++ b/etc/configure @@ -0,0 +1,858 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.12 +# 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: + +# 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= +# 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.12" + 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=Makefile.in + +# 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 $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +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 $srcdir $srcdir/.. $srcdir/../..; 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 $srcdir $srcdir/.. $srcdir/../.." 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. + +# 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 +# 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:553: 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="${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. + for ac_prog in ginstall installbsd 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. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + 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_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +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) 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 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# 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 </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.12" + 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" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%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%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%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 <> $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* + +EOF +cat >> $CONFIG_STATUS <> $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 + diff --git a/etc/configure.in b/etc/configure.in new file mode 100644 index 000000000000..b785068009eb --- /dev/null +++ b/etc/configure.in @@ -0,0 +1,7 @@ +dnl Process this file with autoconf to produce a configure script. +AC_PREREQ(2.5) +AC_INIT(Makefile.in) + +AC_PROG_INSTALL + +AC_OUTPUT(Makefile) diff --git a/etc/make-stds.texi b/etc/make-stds.texi new file mode 100644 index 000000000000..e7c9cf982178 --- /dev/null +++ b/etc/make-stds.texi @@ -0,0 +1,893 @@ +@comment This file is included by both standards.texi and make.texinfo. +@comment It was broken out of standards.texi on 1/6/93 by roland. + +@node Makefile Conventions +@chapter Makefile Conventions +@comment standards.texi does not print an index, but make.texinfo does. +@cindex makefile, conventions for +@cindex conventions for makefiles +@cindex standards for makefiles + +This +@ifinfo +node +@end ifinfo +@iftex +@ifset CODESTD +section +@end ifset +@ifclear CODESTD +chapter +@end ifclear +@end iftex +describes conventions for writing the Makefiles for GNU programs. + +@menu +* Makefile Basics:: General Conventions for Makefiles +* Utilities in Makefiles:: Utilities in Makefiles +* Command Variables:: Variables for Specifying Commands +* Directory Variables:: Variables for Installation Directories +* Standard Targets:: Standard Targets for Users +* Install Command Categories:: Three categories of commands in the `install' + rule: normal, pre-install and post-install. +@end menu + +@node Makefile Basics +@section General Conventions for Makefiles + +Every Makefile should contain this line: + +@example +SHELL = /bin/sh +@end example + +@noindent +to avoid trouble on systems where the @code{SHELL} variable might be +inherited from the environment. (This is never a problem with GNU +@code{make}.) + +Different @code{make} programs have incompatible suffix lists and +implicit rules, and this sometimes creates confusion or misbehavior. So +it is a good idea to set the suffix list explicitly using only the +suffixes you need in the particular Makefile, like this: + +@example +.SUFFIXES: +.SUFFIXES: .c .o +@end example + +@noindent +The first line clears out the suffix list, the second introduces all +suffixes which may be subject to implicit rules in this Makefile. + +Don't assume that @file{.} is in the path for command execution. When +you need to run programs that are a part of your package during the +make, please make sure that it uses @file{./} if the program is built as +part of the make or @file{$(srcdir)/} if the file is an unchanging part +of the source code. Without one of these prefixes, the current search +path is used. + +The distinction between @file{./} (the @dfn{build directory}) and +@file{$(srcdir)/} (the @dfn{source directory}) is important because +users can build in a separate directory using the @samp{--srcdir} option +to @file{configure}. A rule of the form: + +@smallexample +foo.1 : foo.man sedscript + sed -e sedscript foo.man > foo.1 +@end smallexample + +@noindent +will fail when the build directory is not the source directory, because +@file{foo.man} and @file{sedscript} are in the the source directory. + +When using GNU @code{make}, relying on @samp{VPATH} to find the source +file will work in the case where there is a single dependency file, +since the @code{make} automatic variable @samp{$<} will represent the +source file wherever it is. (Many versions of @code{make} set @samp{$<} +only in implicit rules.) A Makefile target like + +@smallexample +foo.o : bar.c + $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o +@end smallexample + +@noindent +should instead be written as + +@smallexample +foo.o : bar.c + $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@@ +@end smallexample + +@noindent +in order to allow @samp{VPATH} to work correctly. When the target has +multiple dependencies, using an explicit @samp{$(srcdir)} is the easiest +way to make the rule work well. For example, the target above for +@file{foo.1} is best written as: + +@smallexample +foo.1 : foo.man sedscript + sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@@ +@end smallexample + +GNU distributions usually contain some files which are not source +files---for example, Info files, and the output from Autoconf, Automake, +Bison or Flex. Since these files normally appear in the source +directory, they should always appear in the source directory, not in the +build directory. So Makefile rules to update them should put the +updated files in the source directory. + +However, if a file does not appear in the distribution, then the +Makefile should not put it in the source directory, because building a +program in ordinary circumstances should not modify the source directory +in any way. + +Try to make the build and installation targets, at least (and all their +subtargets) work correctly with a parallel @code{make}. + +@node Utilities in Makefiles +@section Utilities in Makefiles + +Write the Makefile commands (and any shell scripts, such as +@code{configure}) to run in @code{sh}, not in @code{csh}. Don't use any +special features of @code{ksh} or @code{bash}. + +The @code{configure} script and the Makefile rules for building and +installation should not use any utilities directly except these: + +@c dd find +@c gunzip gzip md5sum +@c mkfifo mknod tee uname + +@example +cat cmp cp diff echo egrep expr false grep install-info +ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true +@end example + +The compression program @code{gzip} can be used in the @code{dist} rule. + +Stick to the generally supported options for these programs. For +example, don't use @samp{mkdir -p}, convenient as it may be, because +most systems don't support it. + +It is a good idea to avoid creating symbolic links in makefiles, since a +few systems don't support them. + +The Makefile rules for building and installation can also use compilers +and related programs, but should do so via @code{make} variables so that the +user can substitute alternatives. Here are some of the programs we +mean: + +@example +ar bison cc flex install ld ldconfig lex +make makeinfo ranlib texi2dvi yacc +@end example + +Use the following @code{make} variables to run those programs: + +@example +$(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX) +$(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC) +@end example + +When you use @code{ranlib} or @code{ldconfig}, you should make sure +nothing bad happens if the system does not have the program in question. +Arrange to ignore an error from that command, and print a message before +the command to tell the user that failure of this command does not mean +a problem. (The Autoconf @samp{AC_PROG_RANLIB} macro can help with +this.) + +If you use symbolic links, you should implement a fallback for systems +that don't have symbolic links. + +Additional utilities that can be used via Make variables are: + +@example +chgrp chmod chown mknod +@end example + +It is ok to use other utilities in Makefile portions (or scripts) +intended only for particular systems where you know those utilities +exist. + +@node Command Variables +@section Variables for Specifying Commands + +Makefiles should provide variables for overriding certain commands, options, +and so on. + +In particular, you should run most utility programs via variables. +Thus, if you use Bison, have a variable named @code{BISON} whose default +value is set with @samp{BISON = bison}, and refer to it with +@code{$(BISON)} whenever you need to use Bison. + +File management utilities such as @code{ln}, @code{rm}, @code{mv}, and +so on, need not be referred to through variables in this way, since users +don't need to replace them with other programs. + +Each program-name variable should come with an options variable that is +used to supply options to the program. Append @samp{FLAGS} to the +program-name variable name to get the options variable name---for +example, @code{BISONFLAGS}. (The name @code{CFLAGS} is an exception to +this rule, but we keep it because it is standard.) Use @code{CPPFLAGS} +in any compilation command that runs the preprocessor, and use +@code{LDFLAGS} in any compilation command that does linking as well as +in any direct use of @code{ld}. + +If there are C compiler options that @emph{must} be used for proper +compilation of certain files, do not include them in @code{CFLAGS}. +Users expect to be able to specify @code{CFLAGS} freely themselves. +Instead, arrange to pass the necessary options to the C compiler +independently of @code{CFLAGS}, by writing them explicitly in the +compilation commands or by defining an implicit rule, like this: + +@smallexample +CFLAGS = -g +ALL_CFLAGS = -I. $(CFLAGS) +.c.o: + $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< +@end smallexample + +Do include the @samp{-g} option in @code{CFLAGS}, because that is not +@emph{required} for proper compilation. You can consider it a default +that is only recommended. If the package is set up so that it is +compiled with GCC by default, then you might as well include @samp{-O} +in the default value of @code{CFLAGS} as well. + +Put @code{CFLAGS} last in the compilation command, after other variables +containing compiler options, so the user can use @code{CFLAGS} to +override the others. + +Every Makefile should define the variable @code{INSTALL}, which is the +basic command for installing a file into the system. + +Every Makefile should also define the variables @code{INSTALL_PROGRAM} +and @code{INSTALL_DATA}. (The default for each of these should be +@code{$(INSTALL)}.) Then it should use those variables as the commands +for actual installation, for executables and nonexecutables +respectively. Use these variables as follows: + +@example +$(INSTALL_PROGRAM) foo $(bindir)/foo +$(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a +@end example + +@noindent +Always use a file name, not a directory name, as the second argument of +the installation commands. Use a separate command for each file to be +installed. + +@node Directory Variables +@section Variables for Installation Directories + +Installation directories should always be named by variables, so it is +easy to install in a nonstandard place. The standard names for these +variables are described below. They are based on a standard filesystem +layout; variants of it are used in SVR4, 4.4BSD, Linux, Ultrix v4, and +other modern operating systems. + +These two variables set the root for the installation. All the other +installation directories should be subdirectories of one of these two, +and nothing should be directly installed into these two directories. + +@table @samp +@item prefix +A prefix used in constructing the default values of the variables listed +below. The default value of @code{prefix} should be @file{/usr/local}. +When building the complete GNU system, the prefix will be empty and +@file{/usr} will be a symbolic link to @file{/}. +(If you are using Autoconf, write it as @samp{@@prefix@@}.) + +@item exec_prefix +A prefix used in constructing the default values of some of the +variables listed below. The default value of @code{exec_prefix} should +be @code{$(prefix)}. +(If you are using Autoconf, write it as @samp{@@exec_prefix@@}.) + +Generally, @code{$(exec_prefix)} is used for directories that contain +machine-specific files (such as executables and subroutine libraries), +while @code{$(prefix)} is used directly for other directories. +@end table + +Executable programs are installed in one of the following directories. + +@table @samp +@item bindir +The directory for installing executable programs that users can run. +This should normally be @file{/usr/local/bin}, but write it as +@file{$(exec_prefix)/bin}. +(If you are using Autoconf, write it as @samp{@@bindir@@}.) + +@item sbindir +The directory for installing executable programs that can be run from +the shell, but are only generally useful to system administrators. This +should normally be @file{/usr/local/sbin}, but write it as +@file{$(exec_prefix)/sbin}. +(If you are using Autoconf, write it as @samp{@@sbindir@@}.) + +@item libexecdir +@comment This paragraph adjusted to avoid overfull hbox --roland 5jul94 +The directory for installing executable programs to be run by other +programs rather than by users. This directory should normally be +@file{/usr/local/libexec}, but write it as @file{$(exec_prefix)/libexec}. +(If you are using Autoconf, write it as @samp{@@libexecdir@@}.) +@end table + +Data files used by the program during its execution are divided into +categories in two ways. + +@itemize @bullet +@item +Some files are normally modified by programs; others are never normally +modified (though users may edit some of these). + +@item +Some files are architecture-independent and can be shared by all +machines at a site; some are architecture-dependent and can be shared +only by machines of the same kind and operating system; others may never +be shared between two machines. +@end itemize + +This makes for six different possibilities. However, we want to +discourage the use of architecture-dependent files, aside from object +files and libraries. It is much cleaner to make other data files +architecture-independent, and it is generally not hard. + +Therefore, here are the variables Makefiles should use to specify +directories: + +@table @samp +@item datadir +The directory for installing read-only architecture independent data +files. This should normally be @file{/usr/local/share}, but write it as +@file{$(prefix)/share}. +(If you are using Autoconf, write it as @samp{@@datadir@@}.) +As a special exception, see @file{$(infodir)} +and @file{$(includedir)} below. + +@item sysconfdir +The directory for installing read-only data files that pertain to a +single machine--that is to say, files for configuring a host. Mailer +and network configuration files, @file{/etc/passwd}, and so forth belong +here. All the files in this directory should be ordinary ASCII text +files. This directory should normally be @file{/usr/local/etc}, but +write it as @file{$(prefix)/etc}. +(If you are using Autoconf, write it as @samp{@@sysconfdir@@}.) + +@c rewritten to avoid overfull hbox --tower +Do not install executables +@c here +in this directory (they probably +belong in @file{$(libexecdir)} or @file{$(sbindir)}). Also do not +install files that are modified in the normal course of their use +(programs whose purpose is to change the configuration of the system +excluded). Those probably belong in @file{$(localstatedir)}. + +@item sharedstatedir +The directory for installing architecture-independent data files which +the programs modify while they run. This should normally be +@file{/usr/local/com}, but write it as @file{$(prefix)/com}. +(If you are using Autoconf, write it as @samp{@@sharedstatedir@@}.) + +@item localstatedir +The directory for installing data files which the programs modify while +they run, and that pertain to one specific machine. Users should never +need to modify files in this directory to configure the package's +operation; put such configuration information in separate files that go +in @file{$(datadir)} or @file{$(sysconfdir)}. @file{$(localstatedir)} +should normally be @file{/usr/local/var}, but write it as +@file{$(prefix)/var}. +(If you are using Autoconf, write it as @samp{@@localstatedir@@}.) + +@item libdir +The directory for object files and libraries of object code. Do not +install executables here, they probably ought to go in @file{$(libexecdir)} +instead. The value of @code{libdir} should normally be +@file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}. +(If you are using Autoconf, write it as @samp{@@libdir@@}.) + +@item infodir +The directory for installing the Info files for this package. By +default, it should be @file{/usr/local/info}, but it should be written +as @file{$(prefix)/info}. +(If you are using Autoconf, write it as @samp{@@infodir@@}.) + +@item lispdir +The directory for installing any Emacs Lisp files in this package. By +default, it should be @file{/usr/local/share/emacs/site-lisp}, but it +should be written as @file{$(prefix)/share/emacs/site-lisp}. + +If you are using Autoconf, write the default as @samp{@@lispdir@@}. +In order to make @samp{@@lispdir@@} work, you need the following lines +in your @file{configure.in} file: + +@example +lispdir='$@{datadir@}/emacs/site-lisp' +AC_SUBST(lispdir) +@end example + +@item includedir +@c rewritten to avoid overfull hbox --roland +The directory for installing header files to be included by user +programs with the C @samp{#include} preprocessor directive. This +should normally be @file{/usr/local/include}, but write it as +@file{$(prefix)/include}. +(If you are using Autoconf, write it as @samp{@@includedir@@}.) + +Most compilers other than GCC do not look for header files in +@file{/usr/local/include}. So installing the header files this way is +only useful with GCC. Sometimes this is not a problem because some +libraries are only really intended to work with GCC. But some libraries +are intended to work with other compilers. They should install their +header files in two places, one specified by @code{includedir} and one +specified by @code{oldincludedir}. + +@item oldincludedir +The directory for installing @samp{#include} header files for use with +compilers other than GCC. This should normally be @file{/usr/include}. +(If you are using Autoconf, you can write it as @samp{@@oldincludedir@@}.) + +The Makefile commands should check whether the value of +@code{oldincludedir} is empty. If it is, they should not try to use +it; they should cancel the second installation of the header files. + +A package should not replace an existing header in this directory unless +the header came from the same package. Thus, if your Foo package +provides a header file @file{foo.h}, then it should install the header +file in the @code{oldincludedir} directory if either (1) there is no +@file{foo.h} there or (2) the @file{foo.h} that exists came from the Foo +package. + +To tell whether @file{foo.h} came from the Foo package, put a magic +string in the file---part of a comment---and @code{grep} for that string. +@end table + +Unix-style man pages are installed in one of the following: + +@table @samp +@item mandir +The top-level directory for installing the man pages (if any) for this +package. It will normally be @file{/usr/local/man}, but you should +write it as @file{$(prefix)/man}. +(If you are using Autoconf, write it as @samp{@@mandir@@}.) + +@item man1dir +The directory for installing section 1 man pages. Write it as +@file{$(mandir)/man1}. +@item man2dir +The directory for installing section 2 man pages. Write it as +@file{$(mandir)/man2} +@item @dots{} + +@strong{Don't make the primary documentation for any GNU software be a +man page. Write a manual in Texinfo instead. Man pages are just for +the sake of people running GNU software on Unix, which is a secondary +application only.} + +@item manext +The file name extension for the installed man page. This should contain +a period followed by the appropriate digit; it should normally be @samp{.1}. + +@item man1ext +The file name extension for installed section 1 man pages. +@item man2ext +The file name extension for installed section 2 man pages. +@item @dots{} +Use these names instead of @samp{manext} if the package needs to install man +pages in more than one section of the manual. +@end table + +And finally, you should set the following variable: + +@table @samp +@item srcdir +The directory for the sources being compiled. The value of this +variable is normally inserted by the @code{configure} shell script. +(If you are using Autconf, use @samp{srcdir = @@srcdir@@}.) +@end table + +For example: + +@smallexample +@c I have changed some of the comments here slightly to fix an overfull +@c hbox, so the make manual can format correctly. --roland +# Common prefix for installation directories. +# NOTE: This directory must exist when you start the install. +prefix = /usr/local +exec_prefix = $(prefix) +# Where to put the executable for the command `gcc'. +bindir = $(exec_prefix)/bin +# Where to put the directories used by the compiler. +libexecdir = $(exec_prefix)/libexec +# Where to put the Info files. +infodir = $(prefix)/info +@end smallexample + +If your program installs a large number of files into one of the +standard user-specified directories, it might be useful to group them +into a subdirectory particular to that program. If you do this, you +should write the @code{install} rule to create these subdirectories. + +Do not expect the user to include the subdirectory name in the value of +any of the variables listed above. The idea of having a uniform set of +variable names for installation directories is to enable the user to +specify the exact same values for several different GNU packages. In +order for this to be useful, all the packages must be designed so that +they will work sensibly when the user does so. + +@node Standard Targets +@section Standard Targets for Users + +All GNU programs should have the following targets in their Makefiles: + +@table @samp +@item all +Compile the entire program. This should be the default target. This +target need not rebuild any documentation files; Info files should +normally be included in the distribution, and DVI files should be made +only when explicitly asked for. + +By default, the Make rules should compile and link with @samp{-g}, so +that executable programs have debugging symbols. Users who don't mind +being helpless can strip the executables later if they wish. + +@item install +Compile the program and copy the executables, libraries, and so on to +the file names where they should reside for actual use. If there is a +simple test to verify that a program is properly installed, this target +should run that test. + +Do not strip executables when installing them. Devil-may-care users can +use the @code{install-strip} target to do that. + +If possible, write the @code{install} target rule so that it does not +modify anything in the directory where the program was built, provided +@samp{make all} has just been done. This is convenient for building the +program under one user name and installing it under another. + +The commands should create all the directories in which files are to be +installed, if they don't already exist. This includes the directories +specified as the values of the variables @code{prefix} and +@code{exec_prefix}, as well as all subdirectories that are needed. +One way to do this is by means of an @code{installdirs} target +as described below. + +Use @samp{-} before any command for installing a man page, so that +@code{make} will ignore any errors. This is in case there are systems +that don't have the Unix man page documentation system installed. + +The way to install Info files is to copy them into @file{$(infodir)} +with @code{$(INSTALL_DATA)} (@pxref{Command Variables}), and then run +the @code{install-info} program if it is present. @code{install-info} +is a program that edits the Info @file{dir} file to add or update the +menu entry for the given Info file; it is part of the Texinfo package. +Here is a sample rule to install an Info file: + +@comment This example has been carefully formatted for the Make manual. +@comment Please do not reformat it without talking to roland@gnu.ai.mit.edu. +@smallexample +$(infodir)/foo.info: foo.info + $(POST_INSTALL) +# There may be a newer info file in . than in srcdir. + -if test -f foo.info; then d=.; \ + else d=$(srcdir); fi; \ + $(INSTALL_DATA) $$d/foo.info $@@; \ +# Run install-info only if it exists. +# Use `if' instead of just prepending `-' to the +# line so we notice real errors from install-info. +# We use `$(SHELL) -c' because some shells do not +# fail gracefully when there is an unknown command. + if $(SHELL) -c 'install-info --version' \ + >/dev/null 2>&1; then \ + install-info --dir-file=$(infodir)/dir \ + $(infodir)/foo.info; \ + else true; fi +@end smallexample + +When writing the @code{install} target, you must classify all the +commands into three categories: normal ones, @dfn{pre-installation} +commands and @dfn{post-installation} commands. @xref{Install Command +Categories}. + +@item uninstall +Delete all the installed files---the copies that the @samp{install} +target creates. + +This rule should not modify the directories where compilation is done, +only the directories where files are installed. + +The uninstallation commands are divided into three categories, just like +the installation commands. @xref{Install Command Categories}. + +@item install-strip +Like @code{install}, but strip the executable files while installing +them. In many cases, the definition of this target can be very simple: + +@smallexample +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ + install +@end smallexample + +Normally we do not recommend stripping an executable unless you are sure +the program has no bugs. However, it can be reasonable to install a +stripped executable for actual execution while saving the unstripped +executable elsewhere in case there is a bug. + +@comment The gratuitous blank line here is to make the table look better +@comment in the printed Make manual. Please leave it in. +@item clean + +Delete all files from the current directory that are normally created by +building the program. Don't delete the files that record the +configuration. Also preserve files that could be made by building, but +normally aren't because the distribution comes with them. + +Delete @file{.dvi} files here if they are not part of the distribution. + +@item distclean +Delete all files from the current directory that are created by +configuring or building the program. If you have unpacked the source +and built the program without creating any other files, @samp{make +distclean} should leave only the files that were in the distribution. + +@item mostlyclean +Like @samp{clean}, but may refrain from deleting a few files that people +normally don't want to recompile. For example, the @samp{mostlyclean} +target for GCC does not delete @file{libgcc.a}, because recompiling it +is rarely necessary and takes a lot of time. + +@item maintainer-clean +Delete almost everything from the current directory that can be +reconstructed with this Makefile. This typically includes everything +deleted by @code{distclean}, plus more: C source files produced by +Bison, tags tables, Info files, and so on. + +The reason we say ``almost everything'' is that running the command +@samp{make maintainer-clean} should not delete @file{configure} even if +@file{configure} can be remade using a rule in the Makefile. More generally, +@samp{make maintainer-clean} should not delete anything that needs to +exist in order to run @file{configure} and then begin to build the +program. This is the only exception; @code{maintainer-clean} should +delete everything else that can be rebuilt. + +The @samp{maintainer-clean} target is intended to be used by a maintainer of +the package, not by ordinary users. You may need special tools to +reconstruct some of the files that @samp{make maintainer-clean} deletes. +Since these files are normally included in the distribution, we don't +take care to make them easy to reconstruct. If you find you need to +unpack the full distribution again, don't blame us. + +To help make users aware of this, the commands for the special +@code{maintainer-clean} target should start with these two: + +@smallexample +@@echo 'This command is intended for maintainers to use; it' +@@echo 'deletes files that may need special tools to rebuild.' +@end smallexample + +@item TAGS +Update a tags table for this program. +@c ADR: how? + +@item info +Generate any Info files needed. The best way to write the rules is as +follows: + +@smallexample +info: foo.info + +foo.info: foo.texi chap1.texi chap2.texi + $(MAKEINFO) $(srcdir)/foo.texi +@end smallexample + +@noindent +You must define the variable @code{MAKEINFO} in the Makefile. It should +run the @code{makeinfo} program, which is part of the Texinfo +distribution. + +Normally a GNU distribution comes with Info files, and that means the +Info files are present in the source directory. Therefore, the Make +rule for an info file should update it in the source directory. When +users build the package, ordinarily Make will not update the Info files +because they will already be up to date. + +@item dvi +Generate DVI files for all Texinfo documentation. +For example: + +@smallexample +dvi: foo.dvi + +foo.dvi: foo.texi chap1.texi chap2.texi + $(TEXI2DVI) $(srcdir)/foo.texi +@end smallexample + +@noindent +You must define the variable @code{TEXI2DVI} in the Makefile. It should +run the program @code{texi2dvi}, which is part of the Texinfo +distribution.@footnote{@code{texi2dvi} uses @TeX{} to do the real work +of formatting. @TeX{} is not distributed with Texinfo.} Alternatively, +write just the dependencies, and allow GNU @code{make} to provide the command. + +@item dist +Create a distribution tar file for this program. The tar file should be +set up so that the file names in the tar file start with a subdirectory +name which is the name of the package it is a distribution for. This +name can include the version number. + +For example, the distribution tar file of GCC version 1.40 unpacks into +a subdirectory named @file{gcc-1.40}. + +The easiest way to do this is to create a subdirectory appropriately +named, use @code{ln} or @code{cp} to install the proper files in it, and +then @code{tar} that subdirectory. + +Compress the tar file file with @code{gzip}. For example, the actual +distribution file for GCC version 1.40 is called @file{gcc-1.40.tar.gz}. + +The @code{dist} target should explicitly depend on all non-source files +that are in the distribution, to make sure they are up to date in the +distribution. +@ifset CODESTD +@xref{Releases, , Making Releases}. +@end ifset +@ifclear CODESTD +@xref{Releases, , Making Releases, standards, GNU Coding Standards}. +@end ifclear + +@item check +Perform self-tests (if any). The user must build the program before +running the tests, but need not install the program; you should write +the self-tests so that they work when the program is built but not +installed. +@end table + +The following targets are suggested as conventional names, for programs +in which they are useful. + +@table @code +@item installcheck +Perform installation tests (if any). The user must build and install +the program before running the tests. You should not assume that +@file{$(bindir)} is in the search path. + +@item installdirs +It's useful to add a target named @samp{installdirs} to create the +directories where files are installed, and their parent directories. +There is a script called @file{mkinstalldirs} which is convenient for +this; you can find it in the Texinfo package. +@c It's in /gd/gnu/lib/mkinstalldirs. +You can use a rule like this: + +@comment This has been carefully formatted to look decent in the Make manual. +@comment Please be sure not to make it extend any further to the right.--roland +@smallexample +# Make sure all installation directories (e.g. $(bindir)) +# actually exist by making them if necessary. +installdirs: mkinstalldirs + $(srcdir)/mkinstalldirs $(bindir) $(datadir) \ + $(libdir) $(infodir) \ + $(mandir) +@end smallexample + +This rule should not modify the directories where compilation is done. +It should do nothing but create installation directories. +@end table + +@node Install Command Categories +@section Install Command Categories + +@cindex pre-installation commands +@cindex post-installation commands +When writing the @code{install} target, you must classify all the +commands into three categories: normal ones, @dfn{pre-installation} +commands and @dfn{post-installation} commands. + +Normal commands move files into their proper places, and set their +modes. They may not alter any files except the ones that come entirely +from the package they belong to. + +Pre-installation and post-installation commands may alter other files; +in particular, they can edit global configuration files or data bases. + +Pre-installation commands are typically executed before the normal +commands, and post-installation commands are typically run after the +normal commands. + +The most common use for a post-installation command is to run +@code{install-info}. This cannot be done with a normal command, since +it alters a file (the Info directory) which does not come entirely and +solely from the package being installed. It is a post-installation +command because it needs to be done after the normal command which +installs the package's Info files. + +Most programs don't need any pre-installation commands, but we have the +feature just in case it is needed. + +To classify the commands in the @code{install} rule into these three +categories, insert @dfn{category lines} among them. A category line +specifies the category for the commands that follow. + +A category line consists of a tab and a reference to a special Make +variable, plus an optional comment at the end. There are three +variables you can use, one for each category; the variable name +specifies the category. Category lines are no-ops in ordinary execution +because these three Make variables are normally undefined (and you +@emph{should not} define them in the makefile). + +Here are the three possible category lines, each with a comment that +explains what it means: + +@smallexample + $(PRE_INSTALL) # @r{Pre-install commands follow.} + $(POST_INSTALL) # @r{Post-install commands follow.} + $(NORMAL_INSTALL) # @r{Normal commands follow.} +@end smallexample + +If you don't use a category line at the beginning of the @code{install} +rule, all the commands are classified as normal until the first category +line. If you don't use any category lines, all the commands are +classified as normal. + +These are the category lines for @code{uninstall}: + +@smallexample + $(PRE_UNINSTALL) # @r{Pre-uninstall commands follow.} + $(POST_UNINSTALL) # @r{Post-uninstall commands follow.} + $(NORMAL_UNINSTALL) # @r{Normal commands follow.} +@end smallexample + +Typically, a pre-uninstall command would be used for deleting entries +from the Info directory. + +If the @code{install} or @code{uninstall} target has any dependencies +which act as subroutines of installation, then you should start +@emph{each} dependency's commands with a category line, and start the +main target's commands with a category line also. This way, you can +ensure that each command is placed in the right category regardless of +which of the dependencies actually run. + +Pre-installation and post-installation commands should not run any +programs except for these: + +@example +[ basename bash cat chgrp chmod chown cmp cp dd diff echo +egrep expand expr false fgrep find getopt grep gunzip gzip +hostname install install-info kill ldconfig ln ls md5sum +mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee +test touch true uname xargs yes +@end example + +@cindex binary packages +The reason for distinguishing the commands in this way is for the sake +of making binary packages. Typically a binary package contains all the +executables and other files that need to be installed, and has its own +method of installing them---so it does not need to run the normal +installation commands. But installing the binary package does need to +execute the pre-installation and post-installation commands. + +Programs to build binary packages work by extracting the +pre-installation and post-installation commands. Here is one way of +extracting the pre-installation commands: + +@smallexample +make -n install -o all \ + PRE_INSTALL=pre-install \ + POST_INSTALL=post-install \ + NORMAL_INSTALL=normal-install \ + | gawk -f pre-install.awk +@end smallexample + +@noindent +where the file @file{pre-install.awk} could contain this: + +@smallexample +$0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ @{on = 0@} +on @{print $0@} +$0 ~ /^\t[ \t]*pre_install[ \t]*$/ @{on = 1@} +@end smallexample + +The resulting file of pre-installation commands is executed as a shell +script as part of installing the binary package. diff --git a/etc/standards.texi b/etc/standards.texi new file mode 100644 index 000000000000..4170093c65f4 --- /dev/null +++ b/etc/standards.texi @@ -0,0 +1,3061 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename standards.info +@settitle GNU Coding Standards +@c UPDATE THIS DATE WHENEVER YOU MAKE CHANGES! +@set lastupdate 16 January 1997 +@c %**end of header + +@ifinfo +@format +START-INFO-DIR-ENTRY +* Standards: (standards). GNU coding standards. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@c @setchapternewpage odd +@setchapternewpage off + +@c This is used by a cross ref in make-stds.texi +@set CODESTD 1 +@iftex +@set CHAPTER chapter +@end iftex +@ifinfo +@set CHAPTER node +@end ifinfo + +@ifinfo +GNU Coding Standards +Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). +@end ignore + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end ifinfo + +@titlepage +@title GNU Coding Standards +@author Richard Stallman +@author last updated @value{lastupdate} +@page + +@vskip 0pt plus 1filll +Copyright @copyright{} 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end titlepage + +@ifinfo +@node Top, Preface, (dir), (dir) +@top Version + +Last updated @value{lastupdate}. +@end ifinfo + +@menu +* Preface:: About the GNU Coding Standards +* Intellectual Property:: Keeping Free Software Free +* Design Advice:: General Program Design +* Program Behavior:: Program Behavior for All Programs +* Writing C:: Making The Best Use of C +* Documentation:: Documenting Programs +* Managing Releases:: The Release Process +@end menu + +@node Preface +@chapter About the GNU Coding Standards + +The GNU Coding Standards were written by Richard Stallman and other GNU +Project volunteers. Their purpose is to make the GNU system clean, +consistent, and easy to install. This document can also be read as a +guide to writing portable, robust and reliable programs. It focuses on +programs written in C, but many of the rules and principles are useful +even if you write in another programming language. The rules often +state reasons for writing in a certain way. + +Corrections or suggestions regarding this document should be sent to +@code{gnu@@prep.ai.mit.edu}. If you make a suggestion, please include a +suggested new wording for it; our time is limited. We prefer a context +diff to the @file{standards.texi} or @file{make-stds.texi} files, but if +you don't have those files, please mail your suggestion anyway. + +This release of the GNU Coding Standards was last updated +@value{lastupdate}. + +@node Intellectual Property +@chapter Keeping Free Software Free + +This @value{CHAPTER} discusses how you can make sure that GNU software +remains unencumbered. + +@menu +* Reading Non-Free Code:: Referring to Proprietary Programs +* Contributions:: Accepting Contributions +@end menu + +@node Reading Non-Free Code +@section Referring to Proprietary Programs + +Don't in any circumstances refer to Unix source code for or during +your work on GNU! (Or to any other proprietary programs.) + +If you have a vague recollection of the internals of a Unix program, +this does not absolutely mean you can't write an imitation of it, but +do try to organize the imitation internally along different lines, +because this is likely to make the details of the Unix version +irrelevant and dissimilar to your results. + +For example, Unix utilities were generally optimized to minimize +memory use; if you go for speed instead, your program will be very +different. You could keep the entire input file in core and scan it +there instead of using stdio. Use a smarter algorithm discovered more +recently than the Unix program. Eliminate use of temporary files. Do +it in one pass instead of two (we did this in the assembler). + +Or, on the contrary, emphasize simplicity instead of speed. For some +applications, the speed of today's computers makes simpler algorithms +adequate. + +Or go for generality. For example, Unix programs often have static +tables or fixed-size strings, which make for arbitrary limits; use +dynamic allocation instead. Make sure your program handles NULs and +other funny characters in the input files. Add a programming language +for extensibility and write part of the program in that language. + +Or turn some parts of the program into independently usable libraries. +Or use a simple garbage collector instead of tracking precisely when +to free memory, or use a new GNU facility such as obstacks. + + +@node Contributions +@section Accepting Contributions + +If someone else sends you a piece of code to add to the program you are +working on, we need legal papers to use it---the same sort of legal +papers we will need to get from you. @emph{Each} significant +contributor to a program must sign some sort of legal papers in order +for us to have clear title to the program. The main author alone is not +enough. + +So, before adding in any contributions from other people, tell us +so we can arrange to get the papers. Then wait until we tell you +that we have received the signed papers, before you actually use the +contribution. + +This applies both before you release the program and afterward. If +you receive diffs to fix a bug, and they make significant changes, we +need legal papers for it. + +You don't need papers for changes of a few lines here or there, since +they are not significant for copyright purposes. Also, you don't need +papers if all you get from the suggestion is some ideas, not actual code +which you use. For example, if you write a different solution to the +problem, you don't need to get papers. + +We know this is frustrating; it's frustrating for us as well. But if +you don't wait, you are going out on a limb---for example, what if the +contributor's employer won't sign a disclaimer? You might have to take +that code out again! + +The very worst thing is if you forget to tell us about the other +contributor. We could be very embarrassed in court some day as a +result. + +@node Design Advice +@chapter General Program Design + +This @value{CHAPTER} discusses some of the issues you should take into +account when designing your program. + +@menu +* Compatibility:: Compatibility with other implementations +* Using Extensions:: Using non-standard features +* ANSI C:: Using ANSI C features +* Source Language:: Using languages other than C +@end menu + +@node Compatibility +@section Compatibility with Other Implementations + +With occasional exceptions, utility programs and libraries for GNU +should be upward compatible with those in Berkeley Unix, and upward +compatible with @sc{ansi} C if @sc{ansi} C specifies their behavior, and +upward compatible with @sc{POSIX} if @sc{POSIX} specifies their +behavior. + +When these standards conflict, it is useful to offer compatibility +modes for each of them. + +@sc{ansi} C and @sc{POSIX} prohibit many kinds of extensions. Feel free +to make the extensions anyway, and include a @samp{--ansi}, +@samp{--posix}, or @samp{--compatible} option to turn them off. +However, if the extension has a significant chance of breaking any real +programs or scripts, then it is not really upward compatible. Try to +redesign its interface. + +Many GNU programs suppress extensions that conflict with POSIX if the +environment variable @code{POSIXLY_CORRECT} is defined (even if it is +defined with a null value). Please make your program recognize this +variable if appropriate. + +When a feature is used only by users (not by programs or command +files), and it is done poorly in Unix, feel free to replace it +completely with something totally different and better. (For example, +@code{vi} is replaced with Emacs.) But it is nice to offer a compatible +feature as well. (There is a free @code{vi} clone, so we offer it.) + +Additional useful features not in Berkeley Unix are welcome. +Additional programs with no counterpart in Unix may be useful, +but our first priority is usually to duplicate what Unix already +has. + +@node Using Extensions +@section Using Non-standard Features + +Many GNU facilities that already exist support a number of convenient +extensions over the comparable Unix facilities. Whether to use these +extensions in implementing your program is a difficult question. + +On the one hand, using the extensions can make a cleaner program. +On the other hand, people will not be able to build the program +unless the other GNU tools are available. This might cause the +program to work on fewer kinds of machines. + +With some extensions, it might be easy to provide both alternatives. +For example, you can define functions with a ``keyword'' @code{INLINE} +and define that as a macro to expand into either @code{inline} or +nothing, depending on the compiler. + +In general, perhaps it is best not to use the extensions if you can +straightforwardly do without them, but to use the extensions if they +are a big improvement. + +An exception to this rule are the large, established programs (such as +Emacs) which run on a great variety of systems. Such programs would +be broken by use of GNU extensions. + +Another exception is for programs that are used as part of +compilation: anything that must be compiled with other compilers in +order to bootstrap the GNU compilation facilities. If these require +the GNU compiler, then no one can compile them without having them +installed already. That would be no good. + +@node ANSI C +@section @sc{ansi} C and pre-@sc{ansi} C + +Do not ever use the ``trigraph'' feature of @sc{ansi} C. + +@sc{ansi} C is widespread enough now that it is ok to write new programs +that use @sc{ansi} C features (and therefore will not work in +non-@sc{ansi} compilers). And if a program is already written in +@sc{ansi} C, there's no need to convert it to support non-@sc{ansi} +compilers. + +However, it is easy to support non-@sc{ansi} compilers in most programs, +so you might still consider doing so when you write a program. Instead +of writing function definitions in @sc{ansi} prototype form, + +@example +int +foo (int x, int y) +@dots{} +@end example + +@noindent +write the definition in pre-@sc{ansi} style like this, + +@example +int +foo (x, y) + int x, y; +@dots{} +@end example + +@noindent +and use a separate declaration to specify the argument prototype: + +@example +int foo (int, int); +@end example + +You need such a declaration anyway, in a header file, to get the benefit +of @sc{ansi} C prototypes in all the files where the function is called. +And once you have it, you lose nothing by writing the function +definition in the pre-@sc{ansi} style. + +If you don't know non-@sc{ansi} C, there's no need to learn it; just +write in @sc{ansi} C. + +@node Source Language +@section Using Languages Other Than C + +Using a language other than C is like using a non-standard feature: it +will cause trouble for users. Even if GCC supports the other language, +users may find it inconvenient to have to install the compiler for that +other language in order to build your program. So please write in C. + +There are three exceptions for this rule: + +@itemize @bullet +@item +It is okay to use a special language if the same program contains an +interpreter for that language. + +For example, if your program links with GUILE, it is ok to write part of +the program in Scheme or another language supported by GUILE. + +@item +It is okay to use another language in a tool specifically intended for +use with that language. + +This is okay because the only people who want to build the tool will be +those who have installed the other language anyway. + +@item +If an application is not of extremely widespread interest, then perhaps +it's not important if the application is inconvenient to install. +@end itemize + +@node Program Behavior +@chapter Program Behavior for All Programs + +This @value{CHAPTER} describes how to write robust software. It also +describes general standards for error messages, the command line interface, +and how libraries should behave. + +@menu +* Semantics:: Writing robust programs +* Libraries:: Library behavior +* Errors:: Formatting error messages +* User Interfaces:: Standards for command line interfaces +* Option Table:: Table of long options. +* Memory Usage:: When and how to care about memory needs +@end menu + +@node Semantics +@section Writing Robust Programs + +Avoid arbitrary limits on the length or number of @emph{any} data +structure, including file names, lines, files, and symbols, by allocating +all data structures dynamically. In most Unix utilities, ``long lines +are silently truncated''. This is not acceptable in a GNU utility. + +Utilities reading files should not drop NUL characters, or any other +nonprinting characters @emph{including those with codes above 0177}. The +only sensible exceptions would be utilities specifically intended for +interface to certain types of printers that can't handle those characters. + +Check every system call for an error return, unless you know you wish to +ignore errors. Include the system error text (from @code{perror} or +equivalent) in @emph{every} error message resulting from a failing +system call, as well as the name of the file if any and the name of the +utility. Just ``cannot open foo.c'' or ``stat failed'' is not +sufficient. + +Check every call to @code{malloc} or @code{realloc} to see if it +returned zero. Check @code{realloc} even if you are making the block +smaller; in a system that rounds block sizes to a power of 2, +@code{realloc} may get a different block if you ask for less space. + +In Unix, @code{realloc} can destroy the storage block if it returns +zero. GNU @code{realloc} does not have this bug: if it fails, the +original block is unchanged. Feel free to assume the bug is fixed. If +you wish to run your program on Unix, and wish to avoid lossage in this +case, you can use the GNU @code{malloc}. + +You must expect @code{free} to alter the contents of the block that was +freed. Anything you want to fetch from the block, you must fetch before +calling @code{free}. + +If @code{malloc} fails in a noninteractive program, make that a fatal +error. In an interactive program (one that reads commands from the +user), it is better to abort the command and return to the command +reader loop. This allows the user to kill other processes to free up +virtual memory, and then try the command again. + +Use @code{getopt_long} to decode arguments, unless the argument syntax +makes this unreasonable. + +When static storage is to be written in during program execution, use +explicit C code to initialize it. Reserve C initialized declarations +for data that will not be changed. +@c ADR: why? + +Try to avoid low-level interfaces to obscure Unix data structures (such +as file directories, utmp, or the layout of kernel memory), since these +are less likely to work compatibly. If you need to find all the files +in a directory, use @code{readdir} or some other high-level interface. +These will be supported compatibly by GNU. + +By default, the GNU system will provide the signal handling functions of +@sc{BSD} and of @sc{POSIX}. So GNU software should be written to use +these. + +In error checks that detect ``impossible'' conditions, just abort. +There is usually no point in printing any message. These checks +indicate the existence of bugs. Whoever wants to fix the bugs will have +to read the source code and run a debugger. So explain the problem with +comments in the source. The relevant data will be in variables, which +are easy to examine with the debugger, so there is no point moving them +elsewhere. + +Do not use a count of errors as the exit status for a program. +@emph{That does not work}, because exit status values are limited to 8 +bits (0 through 255). A single run of the program might have 256 +errors; if you try to return 256 as the exit status, the parent process +will see 0 as the status, and it will appear that the program succeeded. + +If you make temporary files, check the @code{TMPDIR} environment +variable; if that variable is defined, use the specified directory +instead of @file{/tmp}. + +@node Libraries +@section Library Behavior + +Try to make library functions reentrant. If they need to do dynamic +storage allocation, at least try to avoid any nonreentrancy aside from +that of @code{malloc} itself. + +Here are certain name conventions for libraries, to avoid name +conflicts. + +Choose a name prefix for the library, more than two characters long. +All external function and variable names should start with this +prefix. In addition, there should only be one of these in any given +library member. This usually means putting each one in a separate +source file. + +An exception can be made when two external symbols are always used +together, so that no reasonable program could use one without the +other; then they can both go in the same file. + +External symbols that are not documented entry points for the user +should have names beginning with @samp{_}. They should also contain +the chosen name prefix for the library, to prevent collisions with +other libraries. These can go in the same files with user entry +points if you like. + +Static functions and variables can be used as you like and need not +fit any naming convention. + +@node Errors +@section Formatting Error Messages + +Error messages from compilers should look like this: + +@example +@var{source-file-name}:@var{lineno}: @var{message} +@end example + +Error messages from other noninteractive programs should look like this: + +@example +@var{program}:@var{source-file-name}:@var{lineno}: @var{message} +@end example + +@noindent +when there is an appropriate source file, or like this: + +@example +@var{program}: @var{message} +@end example + +@noindent +when there is no relevant source file. + +In an interactive program (one that is reading commands from a +terminal), it is better not to include the program name in an error +message. The place to indicate which program is running is in the +prompt or with the screen layout. (When the same program runs with +input from a source other than a terminal, it is not interactive and +would do best to print error messages using the noninteractive style.) + +The string @var{message} should not begin with a capital letter when +it follows a program name and/or file name. Also, it should not end +with a period. + +Error messages from interactive programs, and other messages such as +usage messages, should start with a capital letter. But they should not +end with a period. + +@node User Interfaces +@section Standards for Command Line Interfaces + +Please don't make the behavior of a utility depend on the name used +to invoke it. It is useful sometimes to make a link to a utility +with a different name, and that should not change what it does. + +Instead, use a run time option or a compilation switch or both +to select among the alternate behaviors. + +Likewise, please don't make the behavior of the program depend on the +type of output device it is used with. Device independence is an +important principle of the system's design; do not compromise it +merely to save someone from typing an option now and then. + +If you think one behavior is most useful when the output is to a +terminal, and another is most useful when the output is a file or a +pipe, then it is usually best to make the default behavior the one that +is useful with output to a terminal, and have an option for the other +behavior. + +Compatibility requires certain programs to depend on the type of output +device. It would be disastrous if @code{ls} or @code{sh} did not do so +in the way all users expect. In some of these cases, we supplement the +program with a preferred alternate version that does not depend on the +output device type. For example, we provide a @code{dir} program much +like @code{ls} except that its default output format is always +multi-column format. + +It is a good idea to follow the @sc{POSIX} guidelines for the +command-line options of a program. The easiest way to do this is to use +@code{getopt} to parse them. Note that the GNU version of @code{getopt} +will normally permit options anywhere among the arguments unless the +special argument @samp{--} is used. This is not what @sc{POSIX} +specifies; it is a GNU extension. + +Please define long-named options that are equivalent to the +single-letter Unix-style options. We hope to make GNU more user +friendly this way. This is easy to do with the GNU function +@code{getopt_long}. + +One of the advantages of long-named options is that they can be +consistent from program to program. For example, users should be able +to expect the ``verbose'' option of any GNU program which has one, to be +spelled precisely @samp{--verbose}. To achieve this uniformity, look at +the table of common long-option names when you choose the option names +for your program (@pxref{Option Table}). + +It is usually a good idea for file names given as ordinary arguments to +be input files only; any output files would be specified using options +(preferably @samp{-o} or @samp{--output}). Even if you allow an output +file name as an ordinary argument for compatibility, try to provide an +option as another way to specify it. This will lead to more consistency +among GNU utilities, and fewer idiosyncracies for users to remember. + +All programs should support two standard options: @samp{--version} +and @samp{--help}. + +@table @code +@item --version +This option should direct the program to information about its name, +version, origin and legal status, all on standard output, and then exit +successfully. Other options and arguments should be ignored once this +is seen, and the program should not perform its normal function. + +The first line is meant to be easy for a program to parse; the version +number proper starts after the last space. In addition, it contains +the canonical name for this program, in this format: + +@example +GNU Emacs 19.30 +@end example + +@noindent +The program's name should be a constant string; @emph{don't} compute it +from @code{argv[0]}. The idea is to state the standard or canonical +name for the program, not its file name. There are other ways to find +out the precise file name where a command is found in @code{PATH}. + +If the program is a subsidiary part of a larger package, mention the +package name in parentheses, like this: + +@example +emacsserver (GNU Emacs) 19.30 +@end example + +@noindent +If the package has a version number which is different from this +program's version number, you can mention the package version number +just before the close-parenthesis. + +If you @strong{need} to mention the version numbers of libraries which +are distributed separately from the package which contains this program, +you can do so by printing an additional line of version info for each +library you want to mention. Use the same format for these lines as for +the first line. + +Please don't mention all the libraries that the program uses ``just for +completeness''---that would produce a lot of unhelpful clutter. Please +mention library version numbers only if you find in practice that they +are very important to you in debugging. + +The following line, after the version number line or lines, should be a +copyright notice. If more than one copyright notice is called for, put +each on a separate line. + +Next should follow a brief statement that the program is free software, +and that users are free to copy and change it on certain conditions. If +the program is covered by the GNU GPL, say so here. Also mention that +there is no warranty, to the extent permitted by law. + +It is ok to finish the output with a list of the major authors of the +program, as a way of giving credit. + +Here's an example of output that follows these rules: + +@smallexample +GNU Emacs 19.34.5 +Copyright (C) 1996 Free Software Foundation, Inc. +GNU Emacs comes with NO WARRANTY, to the extent permitted by law. +You may redistribute copies of GNU Emacs +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING. +@end smallexample + +You should adapt this to your program, of course, filling in the proper +year, copyright holder, name of program, and the references to +distribution terms, and changing the rest of the wording as necessary. + +This copyright notice only needs to mention the most recent year in +which changes were made---there's no need to list the years for previous +versions' changes. You don't have to mention the name of the program in +these notices, if that is inconvenient, since it appeared in the first +line. + +@item --help +This option should output brief documentation for how to invoke the +program, on standard output, then exit successfully. Other options and +arguments should be ignored once this is seen, and the program should +not perform its normal function. + +Near the end of the @samp{--help} option's output there should be a line +that says where to mail bug reports. It should have this format: + +@example +Report bugs to @var{mailing-address}. +@end example +@end table + +@node Option Table +@section Table of Long Options + +Here is a table of long options used by GNU programs. It is surely +incomplete, but we aim to list all the options that a new program might +want to be compatible with. If you use names not already in the table, +please send @samp{gnu@@prep.ai.mit.edu} a list of them, with their +meanings, so we can update the table. + +@c Please leave newlines between items in this table; it's much easier +@c to update when it isn't completely squashed together and unreadable. +@c When there is more than one short option for a long option name, put +@c a semicolon between the lists of the programs that use them, not a +@c period. --friedman + +@table @samp +@item after-date +@samp{-N} in @code{tar}. + +@item all +@samp{-a} in @code{du}, @code{ls}, @code{nm}, @code{stty}, @code{uname}, +and @code{unexpand}. + +@item all-text +@samp{-a} in @code{diff}. + +@item almost-all +@samp{-A} in @code{ls}. + +@item append +@samp{-a} in @code{etags}, @code{tee}, @code{time}; +@samp{-r} in @code{tar}. + +@item archive +@samp{-a} in @code{cp}. + +@item archive-name +@samp{-n} in @code{shar}. + +@item arglength +@samp{-l} in @code{m4}. + +@item ascii +@samp{-a} in @code{diff}. + +@item assign +@samp{-v} in @code{gawk}. + +@item assume-new +@samp{-W} in Make. + +@item assume-old +@samp{-o} in Make. + +@item auto-check +@samp{-a} in @code{recode}. + +@item auto-pager +@samp{-a} in @code{wdiff}. + +@item auto-reference +@samp{-A} in @code{ptx}. + +@item avoid-wraps +@samp{-n} in @code{wdiff}. + +@item backward-search +@samp{-B} in @code{ctags}. + +@item basename +@samp{-f} in @code{shar}. + +@item batch +Used in GDB. + +@item baud +Used in GDB. + +@item before +@samp{-b} in @code{tac}. + +@item binary +@samp{-b} in @code{cpio} and @code{diff}. + +@item bits-per-code +@samp{-b} in @code{shar}. + +@item block-size +Used in @code{cpio} and @code{tar}. + +@item blocks +@samp{-b} in @code{head} and @code{tail}. + +@item break-file +@samp{-b} in @code{ptx}. + +@item brief +Used in various programs to make output shorter. + +@item bytes +@samp{-c} in @code{head}, @code{split}, and @code{tail}. + +@item c@t{++} +@samp{-C} in @code{etags}. + +@item catenate +@samp{-A} in @code{tar}. + +@item cd +Used in various programs to specify the directory to use. + +@item changes +@samp{-c} in @code{chgrp} and @code{chown}. + +@item classify +@samp{-F} in @code{ls}. + +@item colons +@samp{-c} in @code{recode}. + +@item command +@samp{-c} in @code{su}; +@samp{-x} in GDB. + +@item compare +@samp{-d} in @code{tar}. + +@item compat +Used in @code{gawk}. + +@item compress +@samp{-Z} in @code{tar} and @code{shar}. + +@item concatenate +@samp{-A} in @code{tar}. + +@item confirmation +@samp{-w} in @code{tar}. + +@item context +Used in @code{diff}. + +@item copyleft +@samp{-W copyleft} in @code{gawk}. + +@item copyright +@samp{-C} in @code{ptx}, @code{recode}, and @code{wdiff}; +@samp{-W copyright} in @code{gawk}. + +@item core +Used in GDB. + +@item count +@samp{-q} in @code{who}. + +@item count-links +@samp{-l} in @code{du}. + +@item create +Used in @code{tar} and @code{cpio}. + +@item cut-mark +@samp{-c} in @code{shar}. + +@item cxref +@samp{-x} in @code{ctags}. + +@item date +@samp{-d} in @code{touch}. + +@item debug +@samp{-d} in Make and @code{m4}; +@samp{-t} in Bison. + +@item define +@samp{-D} in @code{m4}. + +@item defines +@samp{-d} in Bison and @code{ctags}. + +@item delete +@samp{-D} in @code{tar}. + +@item dereference +@samp{-L} in @code{chgrp}, @code{chown}, @code{cpio}, @code{du}, +@code{ls}, and @code{tar}. + +@item dereference-args +@samp{-D} in @code{du}. + +@item diacritics +@samp{-d} in @code{recode}. + +@item dictionary-order +@samp{-d} in @code{look}. + +@item diff +@samp{-d} in @code{tar}. + +@item digits +@samp{-n} in @code{csplit}. + +@item directory +Specify the directory to use, in various programs. In @code{ls}, it +means to show directories themselves rather than their contents. In +@code{rm} and @code{ln}, it means to not treat links to directories +specially. + +@item discard-all +@samp{-x} in @code{strip}. + +@item discard-locals +@samp{-X} in @code{strip}. + +@item dry-run +@samp{-n} in Make. + +@item ed +@samp{-e} in @code{diff}. + +@item elide-empty-files +@samp{-z} in @code{csplit}. + +@item end-delete +@samp{-x} in @code{wdiff}. + +@item end-insert +@samp{-z} in @code{wdiff}. + +@item entire-new-file +@samp{-N} in @code{diff}. + +@item environment-overrides +@samp{-e} in Make. + +@item eof +@samp{-e} in @code{xargs}. + +@item epoch +Used in GDB. + +@item error-limit +Used in @code{makeinfo}. + +@item error-output +@samp{-o} in @code{m4}. + +@item escape +@samp{-b} in @code{ls}. + +@item exclude-from +@samp{-X} in @code{tar}. + +@item exec +Used in GDB. + +@item exit +@samp{-x} in @code{xargs}. + +@item exit-0 +@samp{-e} in @code{unshar}. + +@item expand-tabs +@samp{-t} in @code{diff}. + +@item expression +@samp{-e} in @code{sed}. + +@item extern-only +@samp{-g} in @code{nm}. + +@item extract +@samp{-i} in @code{cpio}; +@samp{-x} in @code{tar}. + +@item faces +@samp{-f} in @code{finger}. + +@item fast +@samp{-f} in @code{su}. + +@item fatal-warnings +@samp{-E} in @code{m4}. + +@item file +@samp{-f} in @code{info}, @code{gawk}, Make, @code{mt}, and @code{tar}; +@samp{-n} in @code{sed}; +@samp{-r} in @code{touch}. + +@item field-separator +@samp{-F} in @code{gawk}. + +@item file-prefix +@samp{-b} in Bison. + +@item file-type +@samp{-F} in @code{ls}. + +@item files-from +@samp{-T} in @code{tar}. + +@item fill-column +Used in @code{makeinfo}. + +@item flag-truncation +@samp{-F} in @code{ptx}. + +@item fixed-output-files +@samp{-y} in Bison. + +@item follow +@samp{-f} in @code{tail}. + +@item footnote-style +Used in @code{makeinfo}. + +@item force +@samp{-f} in @code{cp}, @code{ln}, @code{mv}, and @code{rm}. + +@item force-prefix +@samp{-F} in @code{shar}. + +@item format +Used in @code{ls}, @code{time}, and @code{ptx}. + +@item freeze-state +@samp{-F} in @code{m4}. + +@item fullname +Used in GDB. + +@item gap-size +@samp{-g} in @code{ptx}. + +@item get +@samp{-x} in @code{tar}. + +@item graphic +@samp{-i} in @code{ul}. + +@item graphics +@samp{-g} in @code{recode}. + +@item group +@samp{-g} in @code{install}. + +@item gzip +@samp{-z} in @code{tar} and @code{shar}. + +@item hashsize +@samp{-H} in @code{m4}. + +@item header +@samp{-h} in @code{objdump} and @code{recode} + +@item heading +@samp{-H} in @code{who}. + +@item help +Used to ask for brief usage information. + +@item here-delimiter +@samp{-d} in @code{shar}. + +@item hide-control-chars +@samp{-q} in @code{ls}. + +@item idle +@samp{-u} in @code{who}. + +@item ifdef +@samp{-D} in @code{diff}. + +@item ignore +@samp{-I} in @code{ls}; +@samp{-x} in @code{recode}. + +@item ignore-all-space +@samp{-w} in @code{diff}. + +@item ignore-backups +@samp{-B} in @code{ls}. + +@item ignore-blank-lines +@samp{-B} in @code{diff}. + +@item ignore-case +@samp{-f} in @code{look} and @code{ptx}; +@samp{-i} in @code{diff} and @code{wdiff}. + +@item ignore-errors +@samp{-i} in Make. + +@item ignore-file +@samp{-i} in @code{ptx}. + +@item ignore-indentation +@samp{-I} in @code{etags}. + +@item ignore-init-file +@samp{-f} in Oleo. + +@item ignore-interrupts +@samp{-i} in @code{tee}. + +@item ignore-matching-lines +@samp{-I} in @code{diff}. + +@item ignore-space-change +@samp{-b} in @code{diff}. + +@item ignore-zeros +@samp{-i} in @code{tar}. + +@item include +@samp{-i} in @code{etags}; +@samp{-I} in @code{m4}. + +@item include-dir +@samp{-I} in Make. + +@item incremental +@samp{-G} in @code{tar}. + +@item info +@samp{-i}, @samp{-l}, and @samp{-m} in Finger. + +@item initial +@samp{-i} in @code{expand}. + +@item initial-tab +@samp{-T} in @code{diff}. + +@item inode +@samp{-i} in @code{ls}. + +@item interactive +@samp{-i} in @code{cp}, @code{ln}, @code{mv}, @code{rm}; +@samp{-e} in @code{m4}; +@samp{-p} in @code{xargs}; +@samp{-w} in @code{tar}. + +@item intermix-type +@samp{-p} in @code{shar}. + +@item jobs +@samp{-j} in Make. + +@item just-print +@samp{-n} in Make. + +@item keep-going +@samp{-k} in Make. + +@item keep-files +@samp{-k} in @code{csplit}. + +@item kilobytes +@samp{-k} in @code{du} and @code{ls}. + +@item language +@samp{-l} in @code{etags}. + +@item less-mode +@samp{-l} in @code{wdiff}. + +@item level-for-gzip +@samp{-g} in @code{shar}. + +@item line-bytes +@samp{-C} in @code{split}. + +@item lines +Used in @code{split}, @code{head}, and @code{tail}. + +@item link +@samp{-l} in @code{cpio}. + +@item lint +@itemx lint-old +Used in @code{gawk}. + +@item list +@samp{-t} in @code{cpio}; +@samp{-l} in @code{recode}. + +@item list +@samp{-t} in @code{tar}. + +@item literal +@samp{-N} in @code{ls}. + +@item load-average +@samp{-l} in Make. + +@item login +Used in @code{su}. + +@item machine +No listing of which programs already use this; +someone should check to +see if any actually do and tell @code{gnu@@prep.ai.mit.edu}. + +@item macro-name +@samp{-M} in @code{ptx}. + +@item mail +@samp{-m} in @code{hello} and @code{uname}. + +@item make-directories +@samp{-d} in @code{cpio}. + +@item makefile +@samp{-f} in Make. + +@item mapped +Used in GDB. + +@item max-args +@samp{-n} in @code{xargs}. + +@item max-chars +@samp{-n} in @code{xargs}. + +@item max-lines +@samp{-l} in @code{xargs}. + +@item max-load +@samp{-l} in Make. + +@item max-procs +@samp{-P} in @code{xargs}. + +@item mesg +@samp{-T} in @code{who}. + +@item message +@samp{-T} in @code{who}. + +@item minimal +@samp{-d} in @code{diff}. + +@item mixed-uuencode +@samp{-M} in @code{shar}. + +@item mode +@samp{-m} in @code{install}, @code{mkdir}, and @code{mkfifo}. + +@item modification-time +@samp{-m} in @code{tar}. + +@item multi-volume +@samp{-M} in @code{tar}. + +@item name-prefix +@samp{-a} in Bison. + +@item nesting-limit +@samp{-L} in @code{m4}. + +@item net-headers +@samp{-a} in @code{shar}. + +@item new-file +@samp{-W} in Make. + +@item no-builtin-rules +@samp{-r} in Make. + +@item no-character-count +@samp{-w} in @code{shar}. + +@item no-check-existing +@samp{-x} in @code{shar}. + +@item no-common +@samp{-3} in @code{wdiff}. + +@item no-create +@samp{-c} in @code{touch}. + +@item no-defines +@samp{-D} in @code{etags}. + +@item no-deleted +@samp{-1} in @code{wdiff}. + +@item no-dereference +@samp{-d} in @code{cp}. + +@item no-inserted +@samp{-2} in @code{wdiff}. + +@item no-keep-going +@samp{-S} in Make. + +@item no-lines +@samp{-l} in Bison. + +@item no-piping +@samp{-P} in @code{shar}. + +@item no-prof +@samp{-e} in @code{gprof}. + +@item no-regex +@samp{-R} in @code{etags}. + +@item no-sort +@samp{-p} in @code{nm}. + +@item no-split +Used in @code{makeinfo}. + +@item no-static +@samp{-a} in @code{gprof}. + +@item no-time +@samp{-E} in @code{gprof}. + +@item no-timestamp +@samp{-m} in @code{shar}. + +@item no-validate +Used in @code{makeinfo}. + +@item no-wait +Used in @code{emacsclient}. + +@item no-warn +Used in various programs to inhibit warnings. + +@item node +@samp{-n} in @code{info}. + +@item nodename +@samp{-n} in @code{uname}. + +@item nonmatching +@samp{-f} in @code{cpio}. + +@item nstuff +@samp{-n} in @code{objdump}. + +@item null +@samp{-0} in @code{xargs}. + +@item number +@samp{-n} in @code{cat}. + +@item number-nonblank +@samp{-b} in @code{cat}. + +@item numeric-sort +@samp{-n} in @code{nm}. + +@item numeric-uid-gid +@samp{-n} in @code{cpio} and @code{ls}. + +@item nx +Used in GDB. + +@item old-archive +@samp{-o} in @code{tar}. + +@item old-file +@samp{-o} in Make. + +@item one-file-system +@samp{-l} in @code{tar}, @code{cp}, and @code{du}. + +@item only-file +@samp{-o} in @code{ptx}. + +@item only-prof +@samp{-f} in @code{gprof}. + +@item only-time +@samp{-F} in @code{gprof}. + +@item output +In various programs, specify the output file name. + +@item output-prefix +@samp{-o} in @code{shar}. + +@item override +@samp{-o} in @code{rm}. + +@item overwrite +@samp{-c} in @code{unshar}. + +@item owner +@samp{-o} in @code{install}. + +@item paginate +@samp{-l} in @code{diff}. + +@item paragraph-indent +Used in @code{makeinfo}. + +@item parents +@samp{-p} in @code{mkdir} and @code{rmdir}. + +@item pass-all +@samp{-p} in @code{ul}. + +@item pass-through +@samp{-p} in @code{cpio}. + +@item port +@samp{-P} in @code{finger}. + +@item portability +@samp{-c} in @code{cpio} and @code{tar}. + +@item posix +Used in @code{gawk}. + +@item prefix-builtins +@samp{-P} in @code{m4}. + +@item prefix +@samp{-f} in @code{csplit}. + +@item preserve +Used in @code{tar} and @code{cp}. + +@item preserve-environment +@samp{-p} in @code{su}. + +@item preserve-modification-time +@samp{-m} in @code{cpio}. + +@item preserve-order +@samp{-s} in @code{tar}. + +@item preserve-permissions +@samp{-p} in @code{tar}. + +@item print +@samp{-l} in @code{diff}. + +@item print-chars +@samp{-L} in @code{cmp}. + +@item print-data-base +@samp{-p} in Make. + +@item print-directory +@samp{-w} in Make. + +@item print-file-name +@samp{-o} in @code{nm}. + +@item print-symdefs +@samp{-s} in @code{nm}. + +@item printer +@samp{-p} in @code{wdiff}. + +@item prompt +@samp{-p} in @code{ed}. + +@item query-user +@samp{-X} in @code{shar}. + +@item question +@samp{-q} in Make. + +@item quiet +Used in many programs to inhibit the usual output. @strong{Note:} every +program accepting @samp{--quiet} should accept @samp{--silent} as a +synonym. + +@item quiet-unshar +@samp{-Q} in @code{shar} + +@item quote-name +@samp{-Q} in @code{ls}. + +@item rcs +@samp{-n} in @code{diff}. + +@item re-interval +Used in @code{gawk}. + +@item read-full-blocks +@samp{-B} in @code{tar}. + +@item readnow +Used in GDB. + +@item recon +@samp{-n} in Make. + +@item record-number +@samp{-R} in @code{tar}. + +@item recursive +Used in @code{chgrp}, @code{chown}, @code{cp}, @code{ls}, @code{diff}, +and @code{rm}. + +@item reference-limit +Used in @code{makeinfo}. + +@item references +@samp{-r} in @code{ptx}. + +@item regex +@samp{-r} in @code{tac} and @code{etags}. + +@item release +@samp{-r} in @code{uname}. + +@item reload-state +@samp{-R} in @code{m4}. + +@item relocation +@samp{-r} in @code{objdump}. + +@item rename +@samp{-r} in @code{cpio}. + +@item replace +@samp{-i} in @code{xargs}. + +@item report-identical-files +@samp{-s} in @code{diff}. + +@item reset-access-time +@samp{-a} in @code{cpio}. + +@item reverse +@samp{-r} in @code{ls} and @code{nm}. + +@item reversed-ed +@samp{-f} in @code{diff}. + +@item right-side-defs +@samp{-R} in @code{ptx}. + +@item same-order +@samp{-s} in @code{tar}. + +@item same-permissions +@samp{-p} in @code{tar}. + +@item save +@samp{-g} in @code{stty}. + +@item se +Used in GDB. + +@item sentence-regexp +@samp{-S} in @code{ptx}. + +@item separate-dirs +@samp{-S} in @code{du}. + +@item separator +@samp{-s} in @code{tac}. + +@item sequence +Used by @code{recode} to chose files or pipes for sequencing passes. + +@item shell +@samp{-s} in @code{su}. + +@item show-all +@samp{-A} in @code{cat}. + +@item show-c-function +@samp{-p} in @code{diff}. + +@item show-ends +@samp{-E} in @code{cat}. + +@item show-function-line +@samp{-F} in @code{diff}. + +@item show-tabs +@samp{-T} in @code{cat}. + +@item silent +Used in many programs to inhibit the usual output. +@strong{Note:} every program accepting +@samp{--silent} should accept @samp{--quiet} as a synonym. + +@item size +@samp{-s} in @code{ls}. + +@item sort +Used in @code{ls}. + +@item source +@samp{-W source} in @code{gawk}. + +@item sparse +@samp{-S} in @code{tar}. + +@item speed-large-files +@samp{-H} in @code{diff}. + +@item split-at +@samp{-E} in @code{unshar}. + +@item split-size-limit +@samp{-L} in @code{shar}. + +@item squeeze-blank +@samp{-s} in @code{cat}. + +@item start-delete +@samp{-w} in @code{wdiff}. + +@item start-insert +@samp{-y} in @code{wdiff}. + +@item starting-file +Used in @code{tar} and @code{diff} to specify which file within +a directory to start processing with. + +@item statistics +@samp{-s} in @code{wdiff}. + +@item stdin-file-list +@samp{-S} in @code{shar}. + +@item stop +@samp{-S} in Make. + +@item strict +@samp{-s} in @code{recode}. + +@item strip +@samp{-s} in @code{install}. + +@item strip-all +@samp{-s} in @code{strip}. + +@item strip-debug +@samp{-S} in @code{strip}. + +@item submitter +@samp{-s} in @code{shar}. + +@item suffix +@samp{-S} in @code{cp}, @code{ln}, @code{mv}. + +@item suffix-format +@samp{-b} in @code{csplit}. + +@item sum +@samp{-s} in @code{gprof}. + +@item summarize +@samp{-s} in @code{du}. + +@item symbolic +@samp{-s} in @code{ln}. + +@item symbols +Used in GDB and @code{objdump}. + +@item synclines +@samp{-s} in @code{m4}. + +@item sysname +@samp{-s} in @code{uname}. + +@item tabs +@samp{-t} in @code{expand} and @code{unexpand}. + +@item tabsize +@samp{-T} in @code{ls}. + +@item terminal +@samp{-T} in @code{tput} and @code{ul}. +@samp{-t} in @code{wdiff}. + +@item text +@samp{-a} in @code{diff}. + +@item text-files +@samp{-T} in @code{shar}. + +@item time +Used in @code{ls} and @code{touch}. + +@item to-stdout +@samp{-O} in @code{tar}. + +@item total +@samp{-c} in @code{du}. + +@item touch +@samp{-t} in Make, @code{ranlib}, and @code{recode}. + +@item trace +@samp{-t} in @code{m4}. + +@item traditional +@samp{-t} in @code{hello}; +@samp{-W traditional} in @code{gawk}; +@samp{-G} in @code{ed}, @code{m4}, and @code{ptx}. + +@item tty +Used in GDB. + +@item typedefs +@samp{-t} in @code{ctags}. + +@item typedefs-and-c++ +@samp{-T} in @code{ctags}. + +@item typeset-mode +@samp{-t} in @code{ptx}. + +@item uncompress +@samp{-z} in @code{tar}. + +@item unconditional +@samp{-u} in @code{cpio}. + +@item undefine +@samp{-U} in @code{m4}. + +@item undefined-only +@samp{-u} in @code{nm}. + +@item update +@samp{-u} in @code{cp}, @code{ctags}, @code{mv}, @code{tar}. + +@item usage +Used in @code{gawk}; same as @samp{--help}. + +@item uuencode +@samp{-B} in @code{shar}. + +@item vanilla-operation +@samp{-V} in @code{shar}. + +@item verbose +Print more information about progress. Many programs support this. + +@item verify +@samp{-W} in @code{tar}. + +@item version +Print the version number. + +@item version-control +@samp{-V} in @code{cp}, @code{ln}, @code{mv}. + +@item vgrind +@samp{-v} in @code{ctags}. + +@item volume +@samp{-V} in @code{tar}. + +@item what-if +@samp{-W} in Make. + +@item whole-size-limit +@samp{-l} in @code{shar}. + +@item width +@samp{-w} in @code{ls} and @code{ptx}. + +@item word-regexp +@samp{-W} in @code{ptx}. + +@item writable +@samp{-T} in @code{who}. + +@item zeros +@samp{-z} in @code{gprof}. +@end table + +@node Memory Usage +@section Memory Usage + +If it typically uses just a few meg of memory, don't bother making any +effort to reduce memory usage. For example, if it is impractical for +other reasons to operate on files more than a few meg long, it is +reasonable to read entire input files into core to operate on them. + +However, for programs such as @code{cat} or @code{tail}, that can +usefully operate on very large files, it is important to avoid using a +technique that would artificially limit the size of files it can handle. +If a program works by lines and could be applied to arbitrary +user-supplied input files, it should keep only a line in memory, because +this is not very hard and users will want to be able to operate on input +files that are bigger than will fit in core all at once. + +If your program creates complicated data structures, just make them in +core and give a fatal error if @code{malloc} returns zero. + +@node Writing C +@chapter Making The Best Use of C + +This @value{CHAPTER} provides advice on how best to use the C language +when writing GNU software. + +@menu +* Formatting:: Formatting Your Source Code +* Comments:: Commenting Your Work +* Syntactic Conventions:: Clean Use of C Constructs +* Names:: Naming Variables and Functions +* System Portability:: Portability between different operating systems +* CPU Portability:: Supporting the range of CPU types +* System Functions:: Portability and ``standard'' library functions +* Internationalization:: Techniques for internationalization +* Mmap:: How you can safely use @code{mmap}. +@end menu + +@node Formatting +@section Formatting Your Source Code + +It is important to put the open-brace that starts the body of a C +function in column zero, and avoid putting any other open-brace or +open-parenthesis or open-bracket in column zero. Several tools look +for open-braces in column zero to find the beginnings of C functions. +These tools will not work on code not formatted that way. + +It is also important for function definitions to start the name of the +function in column zero. This helps people to search for function +definitions, and may also help certain tools recognize them. Thus, +the proper format is this: + +@example +static char * +concat (s1, s2) /* Name starts in column zero here */ + char *s1, *s2; +@{ /* Open brace in column zero here */ + @dots{} +@} +@end example + +@noindent +or, if you want to use @sc{ansi} C, format the definition like this: + +@example +static char * +concat (char *s1, char *s2) +@{ + @dots{} +@} +@end example + +In @sc{ansi} C, if the arguments don't fit nicely on one line, +split it like this: + +@example +int +lots_of_args (int an_integer, long a_long, short a_short, + double a_double, float a_float) +@dots{} +@end example + +For the body of the function, we prefer code formatted like this: + +@example +if (x < foo (y, z)) + haha = bar[4] + 5; +else + @{ + while (z) + @{ + haha += foo (z, z); + z--; + @} + return ++x + bar (); + @} +@end example + +We find it easier to read a program when it has spaces before the +open-parentheses and after the commas. Especially after the commas. + +When you split an expression into multiple lines, split it +before an operator, not after one. Here is the right way: + +@example +if (foo_this_is_long && bar > win (x, y, z) + && remaining_condition) +@end example + +Try to avoid having two operators of different precedence at the same +level of indentation. For example, don't write this: + +@example +mode = (inmode[j] == VOIDmode + || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j]) + ? outmode[j] : inmode[j]); +@end example + +Instead, use extra parentheses so that the indentation shows the nesting: + +@example +mode = ((inmode[j] == VOIDmode + || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j]))) + ? outmode[j] : inmode[j]); +@end example + +Insert extra parentheses so that Emacs will indent the code properly. +For example, the following indentation looks nice if you do it by hand, +but Emacs would mess it up: + +@example +v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000 + + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000; +@end example + +But adding a set of parentheses solves the problem: + +@example +v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000 + + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000); +@end example + +Format do-while statements like this: + +@example +do + @{ + a = foo (a); + @} +while (a > 0); +@end example + +Please use formfeed characters (control-L) to divide the program into +pages at logical places (but not within a function). It does not matter +just how long the pages are, since they do not have to fit on a printed +page. The formfeeds should appear alone on lines by themselves. + + +@node Comments +@section Commenting Your Work + +Every program should start with a comment saying briefly what it is for. +Example: @samp{fmt - filter for simple filling of text}. + +Please write the comments in a GNU program in English, because English +is the one language that nearly all programmers in all countries can +read. If you do not write English well, please write comments in +English as well as you can, then ask other people to help rewrite them. +If you can't write comments in English, please find someone to work with +you and translate your comments into English. + +Please put a comment on each function saying what the function does, +what sorts of arguments it gets, and what the possible values of +arguments mean and are used for. It is not necessary to duplicate in +words the meaning of the C argument declarations, if a C type is being +used in its customary fashion. If there is anything nonstandard about +its use (such as an argument of type @code{char *} which is really the +address of the second character of a string, not the first), or any +possible values that would not work the way one would expect (such as, +that strings containing newlines are not guaranteed to work), be sure +to say so. + +Also explain the significance of the return value, if there is one. + +Please put two spaces after the end of a sentence in your comments, so +that the Emacs sentence commands will work. Also, please write +complete sentences and capitalize the first word. If a lower-case +identifier comes at the beginning of a sentence, don't capitalize it! +Changing the spelling makes it a different identifier. If you don't +like starting a sentence with a lower case letter, write the sentence +differently (e.g., ``The identifier lower-case is @dots{}''). + +The comment on a function is much clearer if you use the argument +names to speak about the argument values. The variable name itself +should be lower case, but write it in upper case when you are speaking +about the value rather than the variable itself. Thus, ``the inode +number NODE_NUM'' rather than ``an inode''. + +There is usually no purpose in restating the name of the function in +the comment before it, because the reader can see that for himself. +There might be an exception when the comment is so long that the function +itself would be off the bottom of the screen. + +There should be a comment on each static variable as well, like this: + +@example +/* Nonzero means truncate lines in the display; + zero means continue them. */ +int truncate_lines; +@end example + +Every @samp{#endif} should have a comment, except in the case of short +conditionals (just a few lines) that are not nested. The comment should +state the condition of the conditional that is ending, @emph{including +its sense}. @samp{#else} should have a comment describing the condition +@emph{and sense} of the code that follows. For example: + +@example +@group +#ifdef foo + @dots{} +#else /* not foo */ + @dots{} +#endif /* not foo */ +@end group +@end example + +@noindent +but, by contrast, write the comments this way for a @samp{#ifndef}: + +@example +@group +#ifndef foo + @dots{} +#else /* foo */ + @dots{} +#endif /* foo */ +@end group +@end example + + +@node Syntactic Conventions +@section Clean Use of C Constructs + +Please explicitly declare all arguments to functions. +Don't omit them just because they are @code{int}s. + +Declarations of external functions and functions to appear later in the +source file should all go in one place near the beginning of the file +(somewhere before the first function definition in the file), or else +should go in a header file. Don't put @code{extern} declarations inside +functions. + +It used to be common practice to use the same local variables (with +names like @code{tem}) over and over for different values within one +function. Instead of doing this, it is better declare a separate local +variable for each distinct purpose, and give it a name which is +meaningful. This not only makes programs easier to understand, it also +facilitates optimization by good compilers. You can also move the +declaration of each local variable into the smallest scope that includes +all its uses. This makes the program even cleaner. + +Don't use local variables or parameters that shadow global identifiers. + +Don't declare multiple variables in one declaration that spans lines. +Start a new declaration on each line, instead. For example, instead +of this: + +@example +@group +int foo, + bar; +@end group +@end example + +@noindent +write either this: + +@example +int foo, bar; +@end example + +@noindent +or this: + +@example +int foo; +int bar; +@end example + +@noindent +(If they are global variables, each should have a comment preceding it +anyway.) + +When you have an @code{if}-@code{else} statement nested in another +@code{if} statement, always put braces around the @code{if}-@code{else}. +Thus, never write like this: + +@example +if (foo) + if (bar) + win (); + else + lose (); +@end example + +@noindent +always like this: + +@example +if (foo) + @{ + if (bar) + win (); + else + lose (); + @} +@end example + +If you have an @code{if} statement nested inside of an @code{else} +statement, either write @code{else if} on one line, like this, + +@example +if (foo) + @dots{} +else if (bar) + @dots{} +@end example + +@noindent +with its @code{then}-part indented like the preceding @code{then}-part, +or write the nested @code{if} within braces like this: + +@example +if (foo) + @dots{} +else + @{ + if (bar) + @dots{} + @} +@end example + +Don't declare both a structure tag and variables or typedefs in the +same declaration. Instead, declare the structure tag separately +and then use it to declare the variables or typedefs. + +Try to avoid assignments inside @code{if}-conditions. For example, +don't write this: + +@example +if ((foo = (char *) malloc (sizeof *foo)) == 0) + fatal ("virtual memory exhausted"); +@end example + +@noindent +instead, write this: + +@example +foo = (char *) malloc (sizeof *foo); +if (foo == 0) + fatal ("virtual memory exhausted"); +@end example + +Don't make the program ugly to placate @code{lint}. Please don't insert any +casts to @code{void}. Zero without a cast is perfectly fine as a null +pointer constant, except when calling a varargs function. + +@node Names +@section Naming Variables and Functions + +The names of global variables and functions in a program serve as +comments of a sort. So don't choose terse names---instead, look for +names that give useful information about the meaning of the variable or +function. In a GNU program, names should be English, like other +comments. + +Local variable names can be shorter, because they are used only within +one context, where (presumably) comments explain their purpose. + +Please use underscores to separate words in a name, so that the Emacs +word commands can be useful within them. Stick to lower case; reserve +upper case for macros and @code{enum} constants, and for name-prefixes +that follow a uniform convention. + +For example, you should use names like @code{ignore_space_change_flag}; +don't use names like @code{iCantReadThis}. + +Variables that indicate whether command-line options have been +specified should be named after the meaning of the option, not after +the option-letter. A comment should state both the exact meaning of +the option and its letter. For example, + +@example +@group +/* Ignore changes in horizontal whitespace (-b). */ +int ignore_space_change_flag; +@end group +@end example + +When you want to define names with constant integer values, use +@code{enum} rather than @samp{#define}. GDB knows about enumeration +constants. + +Use file names of 14 characters or less, to avoid creating gratuitous +problems on older System V systems. You can use the program +@code{doschk} to test for this. @code{doschk} also tests for potential +name conflicts if the files were loaded onto an MS-DOS file +system---something you may or may not care about. + +@node System Portability +@section Portability between System Types + +In the Unix world, ``portability'' refers to porting to different Unix +versions. For a GNU program, this kind of portability is desirable, but +not paramount. + +The primary purpose of GNU software is to run on top of the GNU kernel, +compiled with the GNU C compiler, on various types of @sc{cpu}. The +amount and kinds of variation among GNU systems on different @sc{cpu}s +will be comparable to the variation among Linux-based GNU systems or +among BSD systems today. So the kinds of portability that are absolutely +necessary are quite limited. + +But many users do run GNU software on non-GNU Unix or Unix-like systems. +So supporting a variety of Unix-like systems is desirable, although not +paramount. + +The easiest way to achieve portability to most Unix-like systems is to +use Autoconf. It's unlikely that your program needs to know more +information about the host platform than Autoconf can provide, simply +because most of the programs that need such knowledge have already been +written. + +Avoid using the format of semi-internal data bases (e.g., directories) +when there is a higher-level alternative (@code{readdir}). + +As for systems that are not like Unix, such as MSDOS, Windows, the +Macintosh, VMS, and MVS, supporting them is usually so much work that it +is better if you don't. + +The planned GNU kernel is not finished yet, but you can tell which +facilities it will provide by looking at the GNU C Library Manual. The +GNU kernel is based on Mach, so the features of Mach will also be +available. However, if you use Mach features, you'll probably have +trouble debugging your program today. + +@node CPU Portability +@section Portability between @sc{cpu}s + +Even GNU systems will differ because of differences among @sc{cpu} +types---for example, difference in byte ordering and alignment +requirements. It is absolutely essential to handle these differences. +However, don't make any effort to cater to the possibility that an +@code{int} will be less than 32 bits. We don't support 16-bit machines +in GNU. + +Don't assume that the address of an @code{int} object is also the +address of its least-significant byte. This is false on big-endian +machines. Thus, don't make the following mistake: + +@example +int c; +@dots{} +while ((c = getchar()) != EOF) + write(file_descriptor, &c, 1); +@end example + +When calling functions, you need not worry about the difference between +pointers of various types, or between pointers and integers. On most +machines, there's no difference anyway. As for the few machines where +there is a difference, all of them support @sc{ansi} C, so you can use +prototypes (conditionalized to be active only in @sc{ansi} C) to make +the code work on those systems. + +In certain cases, it is ok to pass integer and pointer arguments +indiscriminately to the same function, and use no prototype on any +system. For example, many GNU programs have error-reporting functions +that pass their arguments along to @code{printf} and friends: + +@example +error (s, a1, a2, a3) + char *s; + int a1, a2, a3; +@{ + fprintf (stderr, "error: "); + fprintf (stderr, s, a1, a2, a3); +@} +@end example + +@noindent +In practice, this works on all machines, and it is much simpler than any +``correct'' alternative. Be sure @emph{not} to use a prototype +for such functions. + +However, avoid casting pointers to integers unless you really need to. +These assumptions really reduce portability, and in most programs they +are easy to avoid. In the cases where casting pointers to integers is +essential---such as, a Lisp interpreter which stores type information as +well as an address in one word---it is ok to do so, but you'll have to +make explicit provisions to handle different word sizes. + +@node System Functions +@section Calling System Functions + +C implementations differ substantially. @sc{ansi} C reduces but does not +eliminate the incompatibilities; meanwhile, many users wish to compile +GNU software with pre-@sc{ansi} compilers. This chapter gives +recommendations for how to use the more or less standard C library +functions to avoid unnecessary loss of portability. + +@itemize @bullet +@item +Don't use the value of @code{sprintf}. It returns the number of +characters written on some systems, but not on all systems. + +@item +@code{main} should be declared to return type @code{int}. It should +terminate either by calling @code{exit} or by returning the integer +status code; make sure it cannot ever return an undefined value. + +@item +Don't declare system functions explicitly. + +Almost any declaration for a system function is wrong on some system. +To minimize conflicts, leave it to the system header files to declare +system functions. If the headers don't declare a function, let it +remain undeclared. + +While it may seem unclean to use a function without declaring it, in +practice this works fine for most system library functions on the +systems where this really happens; thus, the disadvantage is only +theoretical. By contrast, actual declarations have frequently caused +actual conflicts. + +@item +If you must declare a system function, don't specify the argument types. +Use an old-style declaration, not an @sc{ansi} prototype. The more you +specify about the function, the more likely a conflict. + +@item +In particular, don't unconditionally declare @code{malloc} or +@code{realloc}. + +Most GNU programs use those functions just once, in functions +conventionally named @code{xmalloc} and @code{xrealloc}. These +functions call @code{malloc} and @code{realloc}, respectively, and +check the results. + +Because @code{xmalloc} and @code{xrealloc} are defined in your program, +you can declare them in other files without any risk of type conflict. + +On most systems, @code{int} is the same length as a pointer; thus, the +calls to @code{malloc} and @code{realloc} work fine. For the few +exceptional systems (mostly 64-bit machines), you can use +@strong{conditionalized} declarations of @code{malloc} and +@code{realloc}---or put these declarations in configuration files +specific to those systems. + +@item +The string functions require special treatment. Some Unix systems have +a header file @file{string.h}; others have @file{strings.h}. Neither +file name is portable. There are two things you can do: use Autoconf to +figure out which file to include, or don't include either file. + +@item +If you don't include either strings file, you can't get declarations for +the string functions from the header file in the usual way. + +That causes less of a problem than you might think. The newer @sc{ansi} +string functions should be avoided anyway because many systems still +don't support them. The string functions you can use are these: + +@example +strcpy strncpy strcat strncat +strlen strcmp strncmp +strchr strrchr +@end example + +The copy and concatenate functions work fine without a declaration as +long as you don't use their values. Using their values without a +declaration fails on systems where the width of a pointer differs from +the width of @code{int}, and perhaps in other cases. It is trivial to +avoid using their values, so do that. + +The compare functions and @code{strlen} work fine without a declaration +on most systems, possibly all the ones that GNU software runs on. +You may find it necessary to declare them @strong{conditionally} on a +few systems. + +The search functions must be declared to return @code{char *}. Luckily, +there is no variation in the data type they return. But there is +variation in their names. Some systems give these functions the names +@code{index} and @code{rindex}; other systems use the names +@code{strchr} and @code{strrchr}. Some systems support both pairs of +names, but neither pair works on all systems. + +You should pick a single pair of names and use it throughout your +program. (Nowadays, it is better to choose @code{strchr} and +@code{strrchr} for new programs, since those are the standard @sc{ansi} +names.) Declare both of those names as functions returning @code{char +*}. On systems which don't support those names, define them as macros +in terms of the other pair. For example, here is what to put at the +beginning of your file (or in a header) if you want to use the names +@code{strchr} and @code{strrchr} throughout: + +@example +#ifndef HAVE_STRCHR +#define strchr index +#endif +#ifndef HAVE_STRRCHR +#define strrchr rindex +#endif + +char *strchr (); +char *strrchr (); +@end example +@end itemize + +Here we assume that @code{HAVE_STRCHR} and @code{HAVE_STRRCHR} are +macros defined in systems where the corresponding functions exist. +One way to get them properly defined is to use Autoconf. + +@node Internationalization +@section Internationalization + +GNU has a library called GNU gettext that makes it easy to translate the +messages in a program into various languages. You should use this +library in every program. Use English for the messages as they appear +in the program, and let gettext provide the way to translate them into +other languages. + +Using GNU gettext involves putting a call to the @code{gettext} macro +around each string that might need translation---like this: + +@example +printf (gettext ("Processing file `%s'...")); +@end example + +@noindent +This permits GNU gettext to replace the string @code{"Processing file +`%s'..."} with a translated version. + +Once a program uses gettext, please make a point of writing calls to +@code{gettext} when you add new strings that call for translation. + +Using GNU gettext in a package involves specifying a @dfn{text domain +name} for the package. The text domain name is used to separate the +translations for this package from the translations for other packages. +Normally, the text domain name should be the same as the name of the +package---for example, @samp{fileutils} for the GNU file utilities. + +To enable gettext to work well, avoid writing code that makes +assumptions about the structure of words or sentences. When you want +the precise text of a sentence to vary depending on the data, use two or +more alternative string constants each containing a complete sentences, +rather than inserting conditionalized words or phrases into a single +sentence framework. + +Here is an example of what not to do: + +@example +printf ("%d file%s processed", nfiles, + nfiles != 1 ? "s" : ""); +@end example + +@noindent +The problem with that example is that it assumes that plurals are made +by adding `s'. If you apply gettext to the format string, like this, + +@example +printf (gettext ("%d file%s processed"), nfiles, + nfiles != 1 ? "s" : ""); +@end example + +@noindent +the message can use different words, but it will still be forced to use +`s' for the plural. Here is a better way: + +@example +printf ((nfiles != 1 ? "%d files processed" + : "%d file processed"), + nfiles); +@end example + +@noindent +This way, you can apply gettext to each of the two strings +independently: + +@example +printf ((nfiles != 1 ? gettext ("%d files processed") + : gettext ("%d file processed")), + nfiles); +@end example + +@noindent +This can any method of forming the plural of the word for ``file'', and +also handles languages that require agreement in the word for +``processed''. + +A similar problem appears at the level of sentence structure with this +code: + +@example +printf ("# Implicit rule search has%s been done.\n", + f->tried_implicit ? "" : " not"); +@end example + +@noindent +Adding @code{gettext} calls to this code cannot give correct results for +all languages, because negation in some languages requires adding words +at more than one place in the sentence. By contrast, adding +@code{gettext} calls does the job straightfowardly if the code starts +out like this: + +@example +printf (f->tried_implicit + ? "# Implicit rule search has been done.\n", + : "# Implicit rule search has not been done.\n"); +@end example + +@node Mmap +@section Mmap + +Don't assume that @code{mmap} either works on all files or fails +for all files. It may work on some files and fail on others. + +The proper way to use @code{mmap} is to try it on the specific file for +which you want to use it---and if @code{mmap} doesn't work, fall back on +doing the job in another way using @code{read} and @code{write}. + +The reason this precaution is needed is that the GNU kernel (the HURD) +provides a user-extensible file system, in which there can be many +different kinds of ``ordinary files.'' Many of them support +@code{mmap}, but some do not. It is important to make programs handle +all these kinds of files. + +@node Documentation +@chapter Documenting Programs + +@menu +* GNU Manuals:: Writing proper manuals. +* Manual Structure Details:: Specific structure conventions. +* NEWS File:: NEWS files supplement manuals. +* Change Logs:: Recording Changes +* Man Pages:: Man pages are secondary. +* Reading other Manuals:: How far you can go in learning + from other manuals. +@end menu + +@node GNU Manuals +@section GNU Manuals + +The preferred way to document part of the GNU system is to write a +manual in the Texinfo formatting language. See the Texinfo manual, +either the hardcopy, or the on-line version available through +@code{info} or the Emacs Info subsystem (@kbd{C-h i}). + +Programmers often find it most natural to structure the documentation +following the structure of the implementation, which they know. But +this structure is not necessarily good for explaining how to use the +program; it may be irrelevant and confusing for a user. + +At every level, from the sentences in a paragraph to the grouping of +topics into separate manuals, the right way to structure documentation +is according to the concepts and questions that a user will have in mind +when reading it. Sometimes this structure of ideas matches the +structure of the implementation of the software being documented---but +often they are different. Often the most important part of learning to +write good documentation is learning to notice when you are structuring +the documentation like the implementation, and think about better +alternatives. + +For example, each program in the GNU system probably ought to be +documented in one manual; but this does not mean each program should +have its own manual. That would be following the structure of the +implementation, rather than the structure that helps the user +understand. + +Instead, each manual should cover a coherent @emph{topic}. For example, +instead of a manual for @code{diff} and a manual for @code{diff3}, we +have one manual for ``comparison of files'' which covers both of those +programs, as well as @code{cmp}. By documenting these programs +together, we can make the whole subject clearer. + +The manual which discusses a program should document all of the +program's command-line options and all of its commands. It should give +examples of their use. But don't organize the manual as a list of +features. Instead, organize it logically, by subtopics. Address the +questions that a user will ask when thinking about the job that the +program does. + +In general, a GNU manual should serve both as tutorial and reference. +It should be set up for convenient access to each topic through Info, +and for reading straight through (appendixes aside). A GNU manual +should give a good introduction to a beginner reading through from the +start, and should also provide all the details that hackers want. + +That is not as hard as it first sounds. Arrange each chapter as a +logical breakdown of its topic, but order the sections, and write their +text, so that reading the chapter straight through makes sense. Do +likewise when structuring the book into chapters, and when structuring a +section into paragraphs. The watchword is, @emph{at each point, address +the most fundamental and important issue raised by the preceding text.} + +If necessary, add extra chapters at the beginning of the manual which +are purely tutorial and cover the basics of the subject. These provide +the framework for a beginner to understand the rest of the manual. The +Bison manual provides a good example of how to do this. + +Don't use Unix man pages as a model for how to write GNU documentation; +most of them are terse, badly structured, and give inadequate +explanation of the underlying concepts. (There are, of course +exceptions.) Also Unix man pages use a particular format which is +different from what we use in GNU manuals. + +Please do not use the term ``pathname'' that is used in Unix +documentation; use ``file name'' (two words) instead. We use the term +``path'' only for search paths, which are lists of file names. + +Please do not use the term ``illegal'' to refer to erroneous input to a +computer program. Please use ``invalid'' for this, and reserve the term +``illegal'' for violations of law. + +@node Manual Structure Details +@section Manual Structure Details + +The title page of the manual should state the version of the programs or +packages documented in the manual. The Top node of the manual should +also contain this information. If the manual is changing more +frequently than or independent of the program, also state a version +number for the manual in both of these places. + +Each program documented in the manual should should have a node named +@samp{@var{program} Invocation} or @samp{Invoking @var{program}}. This +node (together with its subnodes, if any) should describe the program's +command line arguments and how to run it (the sort of information people +would look in a man page for). Start with an @samp{@@example} +containing a template for all the options and arguments that the program +uses. + +Alternatively, put a menu item in some menu whose item name fits one of +the above patterns. This identifies the node which that item points to +as the node for this purpose, regardless of the node's actual name. + +There will be automatic features for specifying a program name and +quickly reading just this part of its manual. + +If one manual describes several programs, it should have such a node for +each program described. + +@node NEWS File +@section The NEWS File + +In addition to its manual, the package should have a file named +@file{NEWS} which contains a list of user-visible changes worth +mentioning. In each new release, add items to the front of the file and +identify the version they pertain to. Don't discard old items; leave +them in the file after the newer items. This way, a user upgrading from +any previous version can see what is new. + +If the @file{NEWS} file gets very long, move some of the older items +into a file named @file{ONEWS} and put a note at the end referring the +user to that file. + +@node Change Logs +@section Change Logs + +Keep a change log to describe all the changes made to program source +files. The purpose of this is so that people investigating bugs in the +future will know about the changes that might have introduced the bug. +Often a new bug can be found by looking at what was recently changed. +More importantly, change logs can help you eliminate conceptual +inconsistencies between different parts of a program, by giving you a +history of how the conflicting concepts arose and who they came from. + +@menu +* Change Log Concepts:: +* Style of Change Logs:: +* Simple Changes:: +* Conditional Changes:: +@end menu + +@node Change Log Concepts +@subsection Change Log Concepts + +You can think of the change log as a conceptual ``undo list'' which +explains how earlier versions were different from the current version. +People can see the current version; they don't need the change log +to tell them what is in it. What they want from a change log is a +clear explanation of how the earlier version differed. + +The change log file is normally called @file{ChangeLog} and covers an +entire directory. Each directory can have its own change log, or a +directory can use the change log of its parent directory--it's up to +you. + +Another alternative is to record change log information with a version +control system such as RCS or CVS. This can be converted automatically +to a @file{ChangeLog} file. + +There's no need to describe the full purpose of the changes or how they +work together. If you think that a change calls for explanation, you're +probably right. Please do explain it---but please put the explanation +in comments in the code, where people will see it whenever they see the +code. For example, ``New function'' is enough for the change log when +you add a function, because there should be a comment before the +function definition to explain what it does. + +However, sometimes it is useful to write one line to describe the +overall purpose of a batch of changes. + +The easiest way to add an entry to @file{ChangeLog} is with the Emacs +command @kbd{M-x add-change-log-entry}. An entry should have an +asterisk, the name of the changed file, and then in parentheses the name +of the changed functions, variables or whatever, followed by a colon. +Then describe the changes you made to that function or variable. + +@node Style of Change Logs +@subsection Style of Change Logs + +Here are some examples of change log entries: + +@example +* register.el (insert-register): Return nil. +(jump-to-register): Likewise. + +* sort.el (sort-subr): Return nil. + +* tex-mode.el (tex-bibtex-file, tex-file, tex-region): +Restart the tex shell if process is gone or stopped. +(tex-shell-running): New function. + +* expr.c (store_one_arg): Round size up for move_block_to_reg. +(expand_call): Round up when emitting USE insns. +* stmt.c (assign_parms): Round size up for move_block_from_reg. +@end example + +It's important to name the changed function or variable in full. Don't +abbreviate function or variable names, and don't combine them. +Subsequent maintainers will often search for a function name to find all +the change log entries that pertain to it; if you abbreviate the name, +they won't find it when they search. + +For example, some people are tempted to abbreviate groups of function +names by writing @samp{* register.el (@{insert,jump-to@}-register)}; +this is not a good idea, since searching for @code{jump-to-register} or +@code{insert-register} would not find that entry. + +Separate unrelated change log entries with blank lines. When two +entries represent parts of the same change, so that they work together, +then don't put blank lines between them. Then you can omit the file +name and the asterisk when successive entries are in the same file. + +@node Simple Changes +@subsection Simple Changes + +Certain simple kinds of changes don't need much detail in the change +log. + +When you change the calling sequence of a function in a simple fashion, +and you change all the callers of the function, there is no need to make +individual entries for all the callers that you changed. Just write in +the entry for the function being called, ``All callers changed.'' + +@example +* keyboard.c (Fcommand_execute): New arg SPECIAL. +All callers changed. +@end example + +When you change just comments or doc strings, it is enough to write an +entry for the file, without mentioning the functions. Just ``Doc +fixes'' is enough for the change log. + +There's no need to make change log entries for documentation files. +This is because documentation is not susceptible to bugs that are hard +to fix. Documentation does not consist of parts that must interact in a +precisely engineered fashion. To correct an error, you need not know +the history of the erroneous passage; it is enough to compare what the +documentation says with the way the program actually works. + +@node Conditional Changes +@subsection Conditional Changes + +C programs often contain compile-time @code{#if} conditionals. Many +changes are conditional; sometimes you add a new definition which is +entirely contained in a conditional. It is very useful to indicate in +the change log the conditions for which the change applies. + +Our convention for indicating conditional changes is to use square +brackets around the name of the condition. + +Here is a simple example, describing a change which is conditional but +does not have a function or entity name associated with it: + +@example +* xterm.c [SOLARIS2]: Include string.h. +@end example + +Here is an entry describing a new definition which is entirely +conditional. This new definition for the macro @code{FRAME_WINDOW_P} is +used only when @code{HAVE_X_WINDOWS} is defined: + +@example +* frame.h [HAVE_X_WINDOWS] (FRAME_WINDOW_P): Macro defined. +@end example + +Here is an entry for a change within the function @code{init_display}, +whose definition as a whole is unconditional, but the changes themselves +are contained in a @samp{#ifdef HAVE_LIBNCURSES} conditional: + +@example +* dispnew.c (init_display) [HAVE_LIBNCURSES]: If X, call tgetent. +@end example + +Here is an entry for a change that takes affect only when +a certain macro is @emph{not} defined: + +@example +(gethostname) [!HAVE_SOCKETS]: Replace with winsock version. +@end example + +@node Man Pages +@section Man Pages + +In the GNU project, man pages are secondary. It is not necessary or +expected for every GNU program to have a man page, but some of them do. +It's your choice whether to include a man page in your program. + +When you make this decision, consider that supporting a man page +requires continual effort each time the program is changed. The time +you spend on the man page is time taken away from more useful work. + +For a simple program which changes little, updating the man page may be +a small job. Then there is little reason not to include a man page, if +you have one. + +For a large program that changes a great deal, updating a man page may +be a substantial burden. If a user offers to donate a man page, you may +find this gift costly to accept. It may be better to refuse the man +page unless the same person agrees to take full responsibility for +maintaining it---so that you can wash your hands of it entirely. If +this volunteer later ceases to do the job, then don't feel obliged to +pick it up yourself; it may be better to withdraw the man page from the +distribution until someone else agrees to update it. + +When a program changes only a little, you may feel that the +discrepancies are small enough that the man page remains useful without +updating. If so, put a prominent note near the beginning of the man +page explaining that you don't maintain it and that the Texinfo manual +is more authoritative. The note should say how to access the Texinfo +documentation. + +@node Reading other Manuals +@section Reading other Manuals + +There may be non-free books or documentation files that describe the +program you are documenting. + +It is ok to use these documents for reference, just as the author of a +new algebra textbook can read other books on algebra. A large portion +of any non-fiction book consists of facts, in this case facts about how +a certain program works, and these facts are necessarily the same for +everyone who writes about the subject. But be careful not to copy your +outline structure, wording, tables or examples from preexisting non-free +documentation. Copying from free documentation may be ok; please check +with the FSF about the individual case. + +@node Managing Releases +@chapter The Release Process + +Making a release is more than just bundling up your source files in a +tar file and putting it up for FTP. You should set up your software so +that it can be configured to run on a variety of systems. Your Makefile +should conform to the GNU standards described below, and your directory +layout should also conform to the standards discussed below. Doing so +makes it easy to include your package into the larger framework of +all GNU software. + +@menu +* Configuration:: How Configuration Should Work +* Makefile Conventions:: Makefile Conventions +* Releases:: Making Releases +@end menu + +@node Configuration +@section How Configuration Should Work + +Each GNU distribution should come with a shell script named +@code{configure}. This script is given arguments which describe the +kind of machine and system you want to compile the program for. + +The @code{configure} script must record the configuration options so +that they affect compilation. + +One way to do this is to make a link from a standard name such as +@file{config.h} to the proper configuration file for the chosen system. +If you use this technique, the distribution should @emph{not} contain a +file named @file{config.h}. This is so that people won't be able to +build the program without configuring it first. + +Another thing that @code{configure} can do is to edit the Makefile. If +you do this, the distribution should @emph{not} contain a file named +@file{Makefile}. Instead, it should include a file @file{Makefile.in} which +contains the input used for editing. Once again, this is so that people +won't be able to build the program without configuring it first. + +If @code{configure} does write the @file{Makefile}, then @file{Makefile} +should have a target named @file{Makefile} which causes @code{configure} +to be rerun, setting up the same configuration that was set up last +time. The files that @code{configure} reads should be listed as +dependencies of @file{Makefile}. + +All the files which are output from the @code{configure} script should +have comments at the beginning explaining that they were generated +automatically using @code{configure}. This is so that users won't think +of trying to edit them by hand. + +The @code{configure} script should write a file named @file{config.status} +which describes which configuration options were specified when the +program was last configured. This file should be a shell script which, +if run, will recreate the same configuration. + +The @code{configure} script should accept an option of the form +@samp{--srcdir=@var{dirname}} to specify the directory where sources are found +(if it is not the current directory). This makes it possible to build +the program in a separate directory, so that the actual source directory +is not modified. + +If the user does not specify @samp{--srcdir}, then @code{configure} should +check both @file{.} and @file{..} to see if it can find the sources. If +it finds the sources in one of these places, it should use them from +there. Otherwise, it should report that it cannot find the sources, and +should exit with nonzero status. + +Usually the easy way to support @samp{--srcdir} is by editing a +definition of @code{VPATH} into the Makefile. Some rules may need to +refer explicitly to the specified source directory. To make this +possible, @code{configure} can add to the Makefile a variable named +@code{srcdir} whose value is precisely the specified directory. + +The @code{configure} script should also take an argument which specifies the +type of system to build the program for. This argument should look like +this: + +@example +@var{cpu}-@var{company}-@var{system} +@end example + +For example, a Sun 3 might be @samp{m68k-sun-sunos4.1}. + +The @code{configure} script needs to be able to decode all plausible +alternatives for how to describe a machine. Thus, @samp{sun3-sunos4.1} +would be a valid alias. For many programs, @samp{vax-dec-ultrix} would +be an alias for @samp{vax-dec-bsd}, simply because the differences +between Ultrix and @sc{BSD} are rarely noticeable, but a few programs +might need to distinguish them. +@c Real 4.4BSD now runs on some Suns. + +There is a shell script called @file{config.sub} that you can use +as a subroutine to validate system types and canonicalize aliases. + +Other options are permitted to specify in more detail the software +or hardware present on the machine, and include or exclude optional +parts of the package: + +@table @samp +@item --enable-@var{feature}@r{[}=@var{parameter}@r{]} +Configure the package to build and install an optional user-level +facility called @var{feature}. This allows users to choose which +optional features to include. Giving an optional @var{parameter} of +@samp{no} should omit @var{feature}, if it is built by default. + +No @samp{--enable} option should @strong{ever} cause one feature to +replace another. No @samp{--enable} option should ever substitute one +useful behavior for another useful behavior. The only proper use for +@samp{--enable} is for questions of whether to build part of the program +or exclude it. + +@item --with-@var{package} +@c @r{[}=@var{parameter}@r{]} +The package @var{package} will be installed, so configure this package +to work with @var{package}. + +@c Giving an optional @var{parameter} of +@c @samp{no} should omit @var{package}, if it is used by default. + +Possible values of @var{package} include @samp{x}, @samp{x-toolkit}, +@samp{gnu-as} (or @samp{gas}), @samp{gnu-ld}, @samp{gnu-libc}, and +@samp{gdb}. + +Do not use a @samp{--with} option to specify the file name to use to +find certain files. That is outside the scope of what @samp{--with} +options are for. + +@item --nfp +The target machine has no floating point processor. + +@item --gas +The target machine assembler is GAS, the GNU assembler. +This is obsolete; users should use @samp{--with-gnu-as} instead. + +@item --x +The target machine has the X Window System installed. +This is obsolete; users should use @samp{--with-x} instead. +@end table + +All @code{configure} scripts should accept all of these ``detail'' +options, whether or not they make any difference to the particular +package at hand. In particular, they should accept any option that +starts with @samp{--with-} or @samp{--enable-}. This is so users will +be able to configure an entire GNU source tree at once with a single set +of options. + +You will note that the categories @samp{--with-} and @samp{--enable-} +are narrow: they @strong{do not} provide a place for any sort of option +you might think of. That is deliberate. We want to limit the possible +configuration options in GNU software. We do not want GNU programs to +have idiosyncratic configuration options. + +Packages that perform part of the compilation process may support cross-compilation. +In such a case, the host and target machines for the program may be +different. The @code{configure} script should normally treat the +specified type of system as both the host and the target, thus producing +a program which works for the same type of machine that it runs on. + +The way to build a cross-compiler, cross-assembler, or what have you, is +to specify the option @samp{--host=@var{hosttype}} when running +@code{configure}. This specifies the host system without changing the +type of target system. The syntax for @var{hosttype} is the same as +described above. + +Bootstrapping a cross-compiler requires compiling it on a machine other +than the host it will run on. Compilation packages accept a +configuration option @samp{--build=@var{hosttype}} for specifying the +configuration on which you will compile them, in case that is different +from the host. + +Programs for which cross-operation is not meaningful need not accept the +@samp{--host} option, because configuring an entire operating system for +cross-operation is not a meaningful thing. + +Some programs have ways of configuring themselves automatically. If +your program is set up to do this, your @code{configure} script can simply +ignore most of its arguments. + +@comment The makefile standards are in a separate file that is also +@comment included by make.texinfo. Done by roland@gnu.ai.mit.edu on 1/6/93. +@comment For this document, turn chapters into sections, etc. +@lowersections +@include make-stds.texi +@raisesections + +@node Releases +@section Making Releases + +Package the distribution of Foo version 69.96 in a gzipped tar file +named @file{foo-69.96.tar.gz}. It should unpack into a subdirectory +named @file{foo-69.96}. + +Building and installing the program should never modify any of the files +contained in the distribution. This means that all the files that form +part of the program in any way must be classified into @dfn{source +files} and @dfn{non-source files}. Source files are written by humans +and never changed automatically; non-source files are produced from +source files by programs under the control of the Makefile. + +Naturally, all the source files must be in the distribution. It is okay +to include non-source files in the distribution, provided they are +up-to-date and machine-independent, so that building the distribution +normally will never modify them. We commonly include non-source files +produced by Bison, @code{lex}, @TeX{}, and @code{makeinfo}; this helps avoid +unnecessary dependencies between our distributions, so that users can +install whichever packages they want to install. + +Non-source files that might actually be modified by building and +installing the program should @strong{never} be included in the +distribution. So if you do distribute non-source files, always make +sure they are up to date when you make a new distribution. + +Make sure that the directory into which the distribution unpacks (as +well as any subdirectories) are all world-writable (octal mode 777). +This is so that old versions of @code{tar} which preserve the +ownership and permissions of the files from the tar archive will be +able to extract all the files even if the user is unprivileged. + +Make sure that all the files in the distribution are world-readable. + +Make sure that no file name in the distribution is more than 14 +characters long. Likewise, no file created by building the program +should have a name longer than 14 characters. The reason for this is +that some systems adhere to a foolish interpretation of the POSIX +standard, and refuse to open a longer name, rather than truncating as +they did in the past. + +Don't include any symbolic links in the distribution itself. If the tar +file contains symbolic links, then people cannot even unpack it on +systems that don't support symbolic links. Also, don't use multiple +names for one file in different directories, because certain file +systems cannot handle this and that prevents unpacking the +distribution. + +Try to make sure that all the file names will be unique on MS-DOS. A +name on MS-DOS consists of up to 8 characters, optionally followed by a +period and up to three characters. MS-DOS will truncate extra +characters both before and after the period. Thus, +@file{foobarhacker.c} and @file{foobarhacker.o} are not ambiguous; they +are truncated to @file{foobarha.c} and @file{foobarha.o}, which are +distinct. + +Include in your distribution a copy of the @file{texinfo.tex} you used +to test print any @file{*.texinfo} or @file{*.texi} files. + +Likewise, if your program uses small GNU software packages like regex, +getopt, obstack, or termcap, include them in the distribution file. +Leaving them out would make the distribution file a little smaller at +the expense of possible inconvenience to a user who doesn't know what +other files to get. + +@contents + +@bye diff --git a/include/COPYING b/include/COPYING new file mode 100644 index 000000000000..60549be514af --- /dev/null +++ b/include/COPYING @@ -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. + + + Copyright (C) 19yy + + 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) 19yy 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. + + , 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/include/ChangeLog b/include/ChangeLog new file mode 100644 index 000000000000..984d4b7914ea --- /dev/null +++ b/include/ChangeLog @@ -0,0 +1,1254 @@ +Fri Aug 8 16:43:56 1997 Doug Evans + + * dis-asm.h (arc_get_disassembler): Declare. + +Wed Jul 30 11:39:50 1997 Per Bothner + + * demangle.h (DMGL_JAVA): New option to request Java demangling. + +Tue Jul 22 17:59:54 1997 Ian Lance Taylor + + * libiberty.h (PEXECUTE_*): Define. + (pexecute, pwait): Declare. + +Fri Jun 6 13:02:33 1997 Andrew Cagney + + * remote-sim.h (sim_kill): Mark as depreciated. + +Fri May 23 13:43:41 1997 Fred Fish + + * bfdlink.h (struct bfd_link_info): Add task_link member. + +Thu May 22 11:32:49 1997 Andrew Cagney + + * remote-sim.h: Review documentation. Clarify restrictions on + when functions can be called. + +Wed May 21 16:47:53 1997 Andrew Cagney + + * remote-sim.h (sim_set_profile_size): Add prototype, document as + depreciated. + +Tue May 20 09:32:22 1997 Andrew Cagney + + * remote-sim.h (sim_open): Add callback struct. + (sim_set_callbacks): Drop SIM_DESC argument. Document. + (sim_size): Remove recently added SIM_DESC argument. Document. + +Mon May 19 19:14:44 1997 Andrew Cagney + + * remote-sim.h: Pass SD into sim_size. + +Thu May 15 01:24:16 1997 Mark Alexander + + * obstack.h (obstack_specify_allocation_with_arg, obstack_chunkfun, + obstack_freefun): Eliminate compile warnings in gdb. + +Tue May 13 10:21:14 1997 Nick Clifton + + * coff/arm.h (constants): Added new flag bits F_APCS_26 and + F_APCS_SET for the f_flags field of the filehdr structure. Added new + flags: F_APCS26, F_ARM_2, F_ARM_3, F_ARM_7, F_ARM_7T to store + information in the flags field of the internal_f structure used by BFD + routines. + +Tue Apr 22 10:24:34 1997 Fred Fish + + * floatformat.h (floatformat_byteorders): Add comments for previous + formats and add floatformat_littlebyte_bigword, primarily for ARM. + Add declaration for floatformat_ieee_double_littlebyte_bigword. + +Fri Apr 18 13:04:49 1997 Andrew Cagney + + * remote-sim.h (sim_stop): New interface - asynchronous + notification of a request to stop / suspend the running + simulation. + + * remote-sim.h (enum sim_stop): Add sim_running and sim_polling as + states for use internal to simulators. + + * callback.h (struct host_callback_strut): Put a magic number at + the end of the struct to allow basic checking. + (struct host_callback_struct ): Add poll_quit - so + that the console etc can be polled at regular intervals. + +Thu Apr 17 02:17:12 1997 Doug Evans + + * remote-sim.h (struct _bfd): Declare. + (sim_load): Return SIM_RC. New arg `abfd'. + (sim_create_inferior): Return SIM_RC. Delete arg `start_address'. + +Wed Apr 2 17:09:12 1997 Andrew Cagney + + * remote-sim.h (sim_trace, sim_size): Make these global. They + will go away shortly. + +Wed Apr 2 15:23:49 1997 Doug Evans + + * remote-sim.h (SIM_OPEN_KIND, SIM_RC): New enums. + (sim_open): New argument `kind'. + +Wed Apr 2 14:45:51 1997 Ian Lance Taylor + + * COPYING: Update FSF address. + +Fri Mar 28 15:29:54 1997 Mike Meissner + + * callback.h (top level): Include stdarg.h or varargs.h if + va_start is not defined. + (host_callback_struct): Make {,e}vprintf_filtered take a va_list + instead of void *, since va_list might be an array or structure + type. + +Fri Mar 28 15:44:41 1997 H.J. Lu + + * libiberty.h (basename): Add prototype for glibc and linux. + +Mon Mar 17 19:22:12 1997 Ian Lance Taylor + + * objalloc.h: New file. + +Mon Mar 17 14:57:55 1997 Andrew Cagney + + * remote-sim.h: New file, copied in from gdb/remote-sim.h. One + day this will be placed in a directory of its own. + +Sat Mar 15 19:00:14 1997 Ian Lance Taylor + + * obstack.h: Update to current FSF version. + +Thu Mar 6 15:46:59 1997 Andrew Cagney + + * callback.h (struct host_callback_struct): Add callbacks - + flush_stdout, write_stderr, flush_stderr, vprintf_filtered, + evprintf_filtered. Delete redundant callbacks - printf_filtered. + +Thu Feb 27 23:18:27 1997 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_info): Remove lprefix and lprefix_len + fields. + +Tue Feb 25 00:10:49 1997 Ian Lance Taylor + + * dis-asm.h (INIT_DISASSEMBLE_INFO_NO_ARCH): Initialize + bytes_per_chunk and display_endian. + +Mon Feb 24 17:47:02 1997 Ian Lance Taylor + + From Eric Youngdale : + * bfdlink.h (struct bfd_elf_version_expr): Define. + (struct bfd_elf_version_deps): Define. + (struct bfd_elf_version_tree): Define. + +Thu Feb 6 14:20:01 1997 Martin M. Hunt + + * dis-asm.h: (disassemble_info): Add new fields + bytes_per_chunk and display_endian to control the + display of raw instructions. + +Sun Dec 8 17:11:12 1996 Doug Evans + + * callback.h (host_callback): New member `error'. + +Wed Nov 20 00:40:23 1996 Doug Evans + + * callback.h: New file, moved here from gdb. + +Mon Nov 18 16:34:00 1996 Dawn Perchik + + * libiberty.h: Checkin again; last checkin failed due to sticky tag. + +Wed Nov 13 08:22:00 1996 Dawn Perchik + + * libiberty.h: Revert last commit due to conflicts with hpux + system headers. + +Tue Nov 12 16:31:00 1996 Dawn Perchik + + * libiberty.h: Move prototypes from argv.c here. + +Thu Oct 31 14:56:18 1996 Doug Evans + + * ansidecl.h (VPARAMS,VA_START): Define. + +Fri Oct 25 12:08:04 1996 Ian Lance Taylor + + * dis-asm.h (disassemble_info): Add bytes_per_line field. + (INIT_DISASSEMBLE_INFO_NO_ARCH): Initialize bytes_per_line field. + +Thu Oct 24 17:10:01 1996 Ian Lance Taylor + + * dis-asm.h (disassemble_info): Add symbol field. + (INIT_DISASSEMBLE_INFO_NO_ARCH): Initialize symbol field. + +Thu Oct 17 11:17:40 1996 Doug Evans + + * dis-asm.h (print_insn_m32r): Declare. + +Mon Oct 14 23:56:52 1996 Ian Lance Taylor + + * libiberty.h: Declare parameter types for xmalloc and xrealloc. + +Thu Oct 3 13:45:27 1996 Ian Lance Taylor + + * fnmatch.h: New file. + +Thu Oct 3 10:33:14 1996 Jeffrey A Law (law@cygnus.com) + + * dis-asm.h (print_insn_mn10x00): Delete declaration. + (print_insn_mn10200, print_insn_mn10300): Declare. + +Wed Oct 2 21:24:43 1996 Jeffrey A Law (law@cygnus.com) + + * dis-asm.h (print_insn_mn10x00): Declare. + +Mon Sep 30 13:56:11 1996 Fred Fish + + * libiberty.h: Remove #ifndef PRIVATE_XMALLOC. + +Tue Aug 13 16:10:30 1996 Stu Grossman (grossman@critters.cygnus.com) + + * obstack.h: Change bcopy to memcpy. Works better on Posix + systems, which generally lack bcopy. + +Mon Aug 12 17:03:18 1996 Stu Grossman (grossman@critters.cygnus.com) + + * ansidecl.h: Change WIN32 to _WIN32. + +Fri Jul 26 13:58:18 1996 Ian Lance Taylor + + * dis-asm.h: Add flavour field. + (print_insn_alpha): Declare. + (print_insn_alpha_osf, print_insn_alpha_vms): Don't declare. + (INIT_DISASSEMBLE_INFO): Initialize flavour field. + +Tue Jul 23 17:37:58 1996 Fred Fish + + * libiberty.h (PRIVATE_XMALLOC): Enclose xmalloc/xrealloc + definitions inside #ifndef so that programs that want to + can define PRIVATE_XMALLOC and then define xmalloc and + xrealloc anyway they want. + (basename): Document in source that we can't declare the + parameter type because it is declared inconsistently across + different systems. + +Mon Jul 22 13:16:13 1996 Richard Henderson + + * dis-asm.h (print_insn_alpha): Don't declare. + (print_insn_alpha_osf, print_insn_alpha_vms): Declare. + +Wed Jul 17 14:45:12 1996 Martin M. Hunt + + * dis-asm.h: (print_insn_d10v): Declare. + +Mon Jul 15 16:55:38 1996 Stu Grossman (grossman@critters.cygnus.com) + + * dis-asm.h: Get rid of decls for print_insn_i8086, + print_insn_sparc64 and print_insn_sparclite. + * (INIT_DISASSEMBLE_INFO): Split into two pieces. One, + INIT_DISASSEMBLE_INFO_NO_ARCH inits everything except for endian, + mach, and arch. + +Fri Jul 12 10:19:27 1996 Stu Grossman (grossman@critters.cygnus.com) + + * dis-asm.h (print_insn_i8086): Declare. + +Wed Jul 3 16:02:39 1996 Stu Grossman (grossman@critters.cygnus.com) + + * dis-asm.h (print_insn_sparclite): Declare. + +Tue Jun 18 16:02:46 1996 Jeffrey A. Law + + * dis-asm.h (print_insn_h8300s): Declare. + +Tue Jun 18 15:11:33 1996 Klaus Kaempf + + * fopen-vms.h: New file. + +Tue Jun 4 18:58:16 1996 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_info): Add notice_all field. + +Fri Apr 26 10:33:12 1996 Doug Evans + + * demangle.h (#ifdef IN_GCC): #include "gansidecl.h". + (PROTO,PTR,const): Delete. + +Mon Apr 22 17:27:42 1996 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_info): Add traditional_format field. + +Mon Apr 15 15:16:56 1996 Doug Evans + + * libiberty.h (choose_temp_base): Add prototype. + +Tue Mar 12 17:29:46 1996 Ian Lance Taylor + + * bfdlink.h (bfd_wrapped_link_hash_lookup): Declare. + (struct bfd_link_info): Add wrap_hash field. + +Wed Feb 14 16:49:17 1996 Martin Anantharaman + + * ieee.h (ieee_record_enum_type): Define + ieee_external_reference_info_enum. + +Fri Feb 2 17:09:25 1996 Doug Evans + + * dis-asm.h (DISASM_RAW_INSN): Delete. + +Tue Jan 23 09:21:47 1996 Doug Evans + + * dis-asm.h (INIT_DISASSEMBLE_INFO): Set endian to BFD_ENDIAN_UNKNOWN. + New argument FPRINTF_FUNC. + +Mon Jan 22 16:37:59 1996 Doug Evans + + * dis-asm.h (disassemble_info): New members arch, mach, endian. + (INIT_DISASSEMBLE_INFO): Initialize them. + (DISASM_RAW_INSN{,FLAG}): Define. + +Thu Jan 18 11:32:38 1996 Ian Lance Taylor + + * demangle.h (cplus_demangle_opname): Change opname parameter to + const char *. + (cplus_mangle_opname): Change return type and opname parameter to + const char *. + +Fri Jan 5 00:01:22 1996 Ian Lance Taylor + + * ieee.h (enum ieee_record): Add ieee_asn_record_enum, + ieee_at_record_enum, ieee_ty_record_enum, ieee_atn_record_enum, + ieee_bb_record_enum, and ieee_be_record_enum. + +Wed Jan 3 13:12:09 1996 Fred Fish + + * obstack.h: Update copyright to 1996. + (_obstack_memory_used): Declare. + (obstack_memory_used): Define macro. + +Thu Dec 28 11:42:12 1995 Ian Lance Taylor + + * libiberty.h (xstrdup): Declare. + +Thu Dec 21 14:47:17 1995 Michael Meissner + + * wait.h: Protect all macros with #ifndef. + +Tue Oct 24 21:45:40 1995 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_info): Add static_link field. + +Tue Sep 12 16:28:04 1995 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_callbacks): Add symbol parameter to + warning callback. + +Fri Sep 1 13:11:51 1995 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_callbacks): Change warning callback + to take BFD, section, and address arguments. + +Thu Aug 31 16:45:12 1995 steve chamberlain + + * bfdlink.h (struct bfd_link_info): Remove PE stuff. + +Tue Aug 22 03:18:23 1995 Ken Raeburn + + * libiberty.h: Declare xstrerror. From Pat Rankin. + +Mon Aug 21 18:11:36 1995 steve chamberlain + + * bfdlink.h (struct bfd_link_info): Remove PE stuff. + +Wed Aug 2 08:14:12 1995 Doug Evans + + * dis-asm.h (print_insn_sparc64): Declare. + +Mon Jul 10 13:26:49 1995 Eric Youngdale + + * bfdlink.h (struct bfd_link_info): Add new field symbolic. + +Sun Jul 2 17:48:40 1995 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_info): Change type of base_file to + PTR. + +Thu Jun 29 00:02:45 1995 Steve Chamberlain + + * bfdlink.h (struct bfd_link_info): Added base_file member. + +Tue Jun 20 16:40:04 1995 Steve Chamberlain + + * ansidecl.h: win32s is ANSI enough. + +Thu May 18 04:25:50 1995 Ken Raeburn + + Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk) + + * dis-asm.h (print_insn_arm): Delete declaration. + (print_insn_{little,big}_arm): New declarations. + + * floatformat.h (floatformat_arm_ext): Declare. + +Sat May 13 10:14:08 1995 Steve Chamberlain + + * coff/pe.h: New file. + * bfdlink.h (subsytem, stack_heap_parameters): New. + * coff/i386.h (NT_SECTION_ALIGNMENT, NT_FILE_ALIGNMENT, + NT_DEF_RESERVE, NT_DEF_COMMIT): New. + * coff/internal.h (internal_filehdr): New fields for PE. + (IMAGE_DATA_DIRECTORY): New. + (internal_aouthdr): New fields for PE. + +Thu May 4 14:36:42 1995 Jason Merrill + + * demangle.h: Don't include ansidecl.h if IN_GCC. + +Tue Feb 21 00:37:28 1995 Jeff Law (law@snake.cs.utah.edu) + + * hp-symtab.h: Don't use bitfield enumerations, the HP C compiler + does not handle them correctly. + +Thu Feb 9 14:20:27 1995 Ian Lance Taylor + + * libiberty.h (basename): Don't declare parameter type; some + systems have this in their header files. + +Wed Feb 8 17:35:38 1995 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_hash_entry): Change format of common + symbol information, to remove restrictions on maximum size and + alignment power, by using a pointer to a structure instead. + +Mon Feb 6 14:55:32 1995 Ian Lance Taylor + + * bfdlink.h (enum bfd_link_hash_type): Rename bfd_link_hash_weak + to bfd_link_hash_undefweak. Add bfd_link_hash_defweak. + +Mon Jan 16 21:00:23 1995 Stan Shebs + + * dis-asm.h (GDB_INIT_DISASSEMBLE_INFO, etc): Remove all + GDB-specific definitions. + +Sun Jan 15 18:39:35 1995 Steve Chamberlain + + * dis-asm.h (print_insn_w65): Declare. + +Thu Jan 12 17:51:17 1995 Ken Raeburn + + * libiberty.h (hex_p): Fix sense of test. + +Wed Jan 11 22:36:40 1995 Ken Raeburn + + * libiberty.h (_hex_array_size, _hex_bad, _hex_value, hex_init, + hex_p, hex_value): New macros and declarations, for hex.c. + +Fri Jan 6 17:44:14 1995 Ian Lance Taylor + + * dis-asm.h: Make idempotent. + +Wed Dec 14 13:08:43 1994 Stan Shebs + + * progress.h: New file, empty definitions for progress macros. + +Fri Nov 25 00:14:05 1994 Jeff Law (law@snake.cs.utah.edu) + + * hp-symtab.h: New file describing the debug symbols emitted + by the HP C compilers. + +Fri Nov 11 15:48:37 1994 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_hash_entry): Change u.c.size from 24 + to 26 bits, and change u.c.alignment_power from 8 to 6 bits. 6 + bit in the alignment power is enough for a 64 bit address space. + +Mon Oct 31 13:02:51 1994 Stan Shebs (shebs@andros.cygnus.com) + + * demangle.h (cplus_mangle_opname): Declare. + +Tue Oct 25 11:38:02 1994 Ian Lance Taylor + + * bfdlink.h (struct bfd_link_callbacks): Fix comments for + multiple_common field. + +Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org) + + * aout/aout64.h: Only define QMAGIC if it isn't already defined. + + * dis-asm.h: Add support for the ARM. + +Wed Aug 10 12:51:41 1994 Doug Evans (dje@canuck.cygnus.com) + + * libiberty.h (strsignal): Document its existence even if we + can't declare it. + +Tue Aug 2 14:40:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * os9k.h: Remove u_int16, u_int32, and owner_id typedefs and + expand their uses. Those names conflict with Mach headers. + +Fri Jul 22 14:17:12 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * bfdlink.h (struct bfd_link_hash_entry): Change u.c.size into a + bitfield. Add field u.c.alignment_power. + +Sun Jul 10 00:26:39 1994 Ian Dall (dall@hfrd.dsto.gov.au) + + * dis-asm.h: Add print_insn_ns32k declaration. + +Mon Jun 20 17:13:29 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * bfdlink.h (bfd_link_hash_table): Make creator a const pointer. + +Sat Jun 18 16:09:32 1994 Stan Shebs (shebs@andros.cygnus.com) + + * demangle.h (cplus_demangle_opname): Declare. + +Thu Jun 16 15:19:03 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfdlink.h (struct bfd_link_info): Add new field shared. + +Mon Jun 6 14:39:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfdlink.h (struct bfd_link_hash_entry): Remove written field: + not needed for all backends. + +Thu Apr 28 19:06:50 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * dis-asm.h (disassembler): Declare. + +Fri Apr 1 00:38:17 1994 Jim Wilson (wilson@mole.gnu.ai.mit.edu) + + * obstack.h: Delete use of IN_GCC to control whether + stddef.h or gstddef.h is included. + +Tue Mar 22 13:06:02 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfdlink.h (enum bfd_link_order_type): Add bfd_data_link_order. + (struct bfd_link_order): Add data field to union. + +Mon Mar 21 18:45:26 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfdlink.h (struct bfd_link_callbacks): Change bitsize argument + to add_to_set to reloc. Remove bitsize argument from constructor. + Comment that reloc_overflow, reloc_dangerous and unattached_reloc + must handle NULL pointers for reloc location. + (enum bfd_link_order_type): Add bfd_section_reloc_link_order and + bfd_symbol_reloc_link_order. + (struct bfd_link_order): Add reloc field to union. + (struct bfd_link_order_reloc): Define. + +Mon Mar 14 12:27:50 1994 Ian Lance Taylor (ian@cygnus.com) + + * ieee-float.h: Removed; no longer used. + +Tue Mar 1 18:10:49 1994 Kung Hsu (kung@mexican.cygnus.com) + + * os9k.h: os9000 target specific header file, the header of the + object file is used now. + +Sun Feb 27 21:52:26 1994 Jim Kingdon (kingdon@deneb.cygnus.com) + + * floatformat.h: New file, intended to replace ieee-float.h. + +Sun Feb 20 17:15:42 1994 Ian Lance Taylor (ian@lisa.cygnus.com) + + * ansidecl.h (ANSI_PROTOTYPES): Define if using ANSI prototypes. + +Wed Feb 16 01:07:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * libiberty.h: Don't declare strsignal, to avoid conflicts with + Solaris system header files. + +Sat Feb 12 22:11:32 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * libiberty.h (xexit): Use __volatile__ to avoid losing if + compiling with gcc -traditional. + +Thu Feb 10 14:05:41 1994 Ian Lance Taylor (ian@cygnus.com) + + * libiberty.h: New file. Declares functions provided by + libiberty. + +Tue Feb 8 05:19:52 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + Handle obstack_chunk_alloc returning NULL. This allows + obstacks to be used by libraries, without forcing them + to call exit or longjmp. + * obstack.h (struct obstack): Add alloc_failed flag. + _obstack_begin, _obstack_begin_1): Declare to return int, not void. + (obstack_finish): If alloc_failed, return NULL. + (obstack_base, obstack_next_free, objstack_object_size): + If alloc_failed, return 0. + (obstack_grow, obstack_grow0, obstack_1grow, obstack_ptr_grow, + obstack_int_grow, obstack_blank): If alloc_failed, do nothing that + could corrupt the obstack. + +Mon Jan 24 15:06:05 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfdlink.h (struct bfd_link_callbacks): Add name, reloc_name and + addend argments to reloc_overflow callback. + +Fri Jan 21 19:13:12 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * dis-asm.h (print_insn_big_powerpc, print_insn_little_powerpc, + print_insn_rs6000): Declare. + +Thu Jan 6 14:15:55 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfdlink.h (struct bfd_link_callbacks): Add bitsize argument to + add_to_set field. Add new callback named constructor. + +Thu Dec 30 10:44:06 1993 Ian Lance Taylor (ian@rtl.cygnus.com) + + * bfdlink.h: New file for new BFD linker backend routines. + +Mon Nov 29 10:43:57 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * dis-asm.h (enum dis_insn_tyupe): Remove non-ANSI trailing comma. + +Sat Oct 2 20:42:26 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * dis-asm.h: Move comment to right place. + +Mon Aug 9 19:03:35 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * obstack.h (obstack_chunkfun, obstack_freefun): Add defns from + previous version. Are these Cygnus local changes? + +Fri Aug 6 17:05:47 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * getopt.h, obstack.h: Update to latest FSF version. + +Mon Aug 2 16:37:14 1993 Stu Grossman (grossman at cygnus.com) + + * coff/i386.h: Add Lynx magic number. + +Mon Aug 2 14:45:29 1993 John Gilmore (gnu@cygnus.com) + + * dis-asm.h: Move enum outside of struct defn to avoid warnings. + +Mon Aug 2 08:49:30 1993 Stu Grossman (grossman at cygnus.com) + + * wait.h (WEXITSTATUS, WSTOPSIG): Mask down to 8 bits. This is + for systems that store stuff into the high 16 bits of a wait + status. + +Fri Jul 30 18:38:02 1993 John Gilmore (gnu@cygnus.com) + + * dis-asm.h: Add new fields insn_info_valid, branch_delay_insns, + data_size, insn_type, target, target2. These are used to return + information from the instruction decoders back to the calling + program. Add comments, make more readable. + +Mon Jul 19 22:14:14 1993 Fred Fish (fnf@deneb.cygnus.com) + + * nlm: New directory containing NLM/NetWare includes. + +Thu Jul 15 12:10:04 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * dis-asm.h (struct disassemble_info): New field application_data. + +Thu Jul 15 12:41:15 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * dis-asm.h: Added declaration of print_insn_m88k. + +Thu Jul 8 09:05:26 1993 Doug Evans (dje@canuck.cygnus.com) + + * opcode/h8300.h: Lots of little fixes for the h8/300h. + +Fri Jul 2 10:31:59 1993 Ian Lance Taylor (ian@cygnus.com) + + * ansidecl.h: Use ANSI macros if __mips and _SYSTYPE_SVR4 are + defined, since RISC/OS cc handles ANSI declarations in SVR4 mode + but does not define __STDC__. + +Sun Jun 20 18:27:52 1993 Ken Raeburn (raeburn@poseidon.cygnus.com) + + * dis-asm.h: Don't need to include ansidecl.h any more. + +Fri Jun 18 03:22:10 1993 John Gilmore (gnu@cygnus.com) + + * oasys.h: Eliminate "int8_type", "int16_type", "int32_type", and + their variants. These changes are coordinated with corresponding + changes in ../bfd/oasys.c. + +Wed Jun 16 10:43:08 1993 Fred Fish (fnf@cygnus.com) + + * bfd.h: Note that it has been removed. + +Tue Jun 8 12:16:03 1993 Steve Chamberlain (sac@phydeaux.cygnus.com) + + Support for H8/300-H + * dis-asm.h (print_insn_h8300, print_insn_h8300h): Declare it. + * coff/h8300.h: New magic number. + * coff/internal.h: New relocations. + * opcode/h8300.h: Lots of new opcodes. + +Tue Jun 1 07:35:03 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * ansidecl.h (const): Don't define it if it's already defined. + +Thu May 27 18:19:51 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * dis-asm.h (print_insn_hppa): Declare it. + + * bfd.h: Moved to bfd directory. Small stub here includes it + without requiring "-I../bfd". + +Thu Apr 29 12:06:13 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * bfd.h: Updated with BSF_FUNCTION. + +Mon Apr 26 18:15:50 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * bfd.h, dis-asm.h: Updated with Hitachi SH. + +Fri Apr 23 18:41:38 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * bfd.h: Updated with alpha changes. + * dis-asm.h: Added alpha. + +Fri Apr 16 17:35:30 1993 Jim Kingdon (kingdon@cygnus.com) + + * bfd.h: Update for signed bfd_*get_*. + +Thu Apr 15 09:24:21 1993 Jim Kingdon (kingdon@cygnus.com) + + * bfd.h: Updated for file_truncated error. + +Thu Apr 8 10:53:47 1993 Ian Lance Taylor (ian@cygnus.com) + + * ansidecl.h: If no ANSI, define const to be empty. + +Thu Apr 1 09:00:10 1993 Jim Kingdon (kingdon@cygnus.com) + + * dis-asm.h: Declare a29k and i960 print_insn_*. + + * dis-asm.h: Add print_address_func and related stuff. + + * dis-asm.h (dis_asm_read_memory): Fix prototype. + +Wed Mar 31 17:40:16 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * dis-asm.h: Add print_insn_sparc. + +Wed Mar 31 17:51:42 1993 Ian Lance Taylor (ian@cygnus.com) + + * bfd.h: Updated for BFD_RELOC_MIPS_GPREL and bfd_[gs]et_gp_size + prototypes. + +Wed Mar 31 16:35:12 1993 Stu Grossman (grossman@cygnus.com) + + * dis-asm.h: (disassemble_info): Fix typo in prototype of + dis_asm_memory_error(). + +Tue Mar 30 19:09:23 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * dis-asm.h (disassembler_info): Add read_memory_func, + memory_error_func, buffer, and length. + ({GDB_,}INIT_DISASSEMBLE_INFO): Set them. + print_insn_*: Remove second argument. + +Tue Mar 30 14:48:55 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * bfd.h: Update for lma field of section. + +Tue Mar 30 12:22:55 1993 Jim Kingdon (kingdon@cygnus.com) + + * ansidecl.h: Use ANSI versions on AIX regardless of __STDC__. + +Fri Mar 19 14:49:49 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * dis-asm.h: Add h8500. + +Thu Mar 18 13:49:09 1993 Per Bothner (bothner@rtl.cygnus.com) + + * ieee-float.h: Moved from ../gdb. + * dis-asm.h: New file. Interface to dis-assembler. + +Thu Mar 11 10:52:57 1993 Fred Fish (fnf@cygnus.com) + + * demangle.h (DMGL_NO_OPTS): Add define (set to 0) to use + in place of bare 0, for readability reasons. + +Tue Mar 2 17:50:11 1993 Fred Fish (fnf@cygnus.com) + + * demangle.h: Replace all references to cfront with ARM. + +Tue Feb 23 12:21:14 1993 Ian Lance Taylor (ian@cygnus.com) + + * bfd.h: Update for new elements in JUMP_TABLE. + +Tue Feb 16 00:51:30 1993 John Gilmore (gnu@cygnus.com) + + * bfd.h: Update for BFD_VERSION 2.1. + +Tue Jan 26 11:49:20 1993 Ian Lance Taylor (ian@cygnus.com) + + * bfd.h: Update for SEC_IS_COMMON flag. + +Tue Jan 19 12:25:12 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfd.h: Update for bfd_asymbol_value bug fix. + +Fri Jan 8 16:37:18 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * bfd.h: Update to include ECOFF tdata and target_flavour. + +Sun Dec 27 17:52:30 1992 Fred Fish (fnf@cygnus.com) + + * bfd.h: Add declaration for bfd_get_size(). + +Tue Dec 22 22:42:46 1992 Fred Fish (fnf@cygnus.com) + + * demangle.h: Protect file from multiple inclusions with + #if !defined(DEMANGLE_H)...#define DEMANGLE_H...#endif. + +Mon Dec 21 21:25:50 1992 Stu Grossman (grossman at cygnus.com) + + * bfd.h: Update to get hppa_core_struct from bfd.c. + +Thu Dec 17 00:42:35 1992 John Gilmore (gnu@cygnus.com) + + * bfd.h: Update to get tekhex tdata name change from bfd. + +Mon Nov 9 23:55:42 1992 John Gilmore (gnu@cygnus.com) + + * ansidecl.h: Update comments to discourage use of EXFUN. + +Thu Nov 5 16:35:44 1992 Ian Lance Taylor (ian@cygnus.com) + + * bfd.h: Update to bring in SEC_SHARED_LIBRARY. + +Thu Nov 5 03:21:32 1992 John Gilmore (gnu@cygnus.com) + + * bfd.h: Update to match EXFUN, bfd_seclet_struct, and SDEF + cleanups in bfd. + +Wed Nov 4 07:28:05 1992 Ken Raeburn (raeburn@cygnus.com) + + * bout.h (N_CALLNAME, N_BALNAME): Define as char-type values, so + widening works consistently. + +Fri Oct 16 03:17:08 1992 John Gilmore (gnu@cygnus.com) + + * getopt.h: Update to Revised Standard FSF Version. + +Thu Oct 15 21:43:22 1992 K. Richard Pixley (rich@sendai.cygnus.com) + + * getopt.h (struct option): use the provided enum for has_arg. + + * demangle.h (AUTO_DEMANGLING, GNU_DEMANGLING, + LUCID_DEMANGLING): ultrix compilers require enums to be + enums and ints to be ints and casts where they meet. cast some + enums into ints. + +Thu Oct 15 04:35:51 1992 John Gilmore (gnu@cygnus.com) + + * bfd.h: Update after comment changes. + +Thu Oct 8 09:03:02 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * bfd.h (bfd_get_symbol_leading_char): new macro for getting in xvec + +Thu Sep 3 09:10:50 1992 Stu Grossman (grossman at cygnus.com) + + * bfd.h (struct reloc_howto_struct): size needs to be signed if + it's going to hold negative values. + +Sun Aug 30 17:50:27 1992 Per Bothner (bothner@rtl.cygnus.com) + + * demangle.h: New file, moved from ../gdb. Made independent + of gdb. Allow demangling style option to be passed as a + parameter to cplus_demangle(), but using the + current_demangling_style global as the default. + +Sat Aug 29 10:07:55 1992 Fred Fish (fnf@cygnus.com) + + * obstack.h: Merge comment change from current FSF version. + +Thu Aug 27 12:59:29 1992 Brendan Kehoe (brendan@cygnus.com) + + * bfd.h: add we32k + +Tue Aug 25 15:07:47 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * bfd.h: new after Z8000 stuff + +Mon Aug 17 09:01:23 1992 Ken Raeburn (raeburn@cygnus.com) + + * bfd.h: Regenerated after page/segment size changes. + +Sat Aug 1 13:46:31 1992 Fred Fish (fnf@cygnus.com) + + * obstack.h: Merge changes from current FSF version. + +Mon Jul 20 21:06:23 1992 Fred Fish (fnf@cygnus.com) + + * obstack.h (area_id, flags): Remove, replace with extra_arg, + use_extra_arg, and maybe_empty_object. + * obstack.h (OBSTACK_MAYBE_EMPTY_OBJECT, OBSTACK_MMALLOC_LIKE): + Remove, replaced by maybe_empty_object and use_extra_arg bitfields. + * obstack.h (obstack_full_begin, _obstack_begin): Remove area_id + and flags arguments. + * obstack.h (obstack_alloc_arg): New macro to set extra_arg. + +Thu Jul 16 08:12:44 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * bfd.h: new after adding BFD_IS_RELAXABLE + +Sat Jul 4 03:22:23 1992 John Gilmore (gnu at cygnus.com) + + * bfd.h: Regen after adding BSF_FILE. + +Mon Jun 29 14:18:36 1992 Fred Fish (fnf at sunfish) + + * obstack.h: Convert bcopy() use to memcpy(), which is more + portable, more standard, and can take advantage of gcc's builtin + functions for increased performance. + +Thu Jun 25 04:46:08 1992 John Gilmore (gnu at cygnus.com) + + * ansidecl.h (PARAMS): Incorporate this macro from gdb's defs.h. + It's a cleaner way to forward-declare function prototypes. + +Fri Jun 19 15:46:32 1992 Stu Grossman (grossman at cygnus.com) + + * bfd.h: HPPA merge. + +Tue Jun 16 21:30:56 1992 K. Richard Pixley (rich@cygnus.com) + + * getopt.h: gratuitous white space changes merged from other prep + releases. + +Thu Jun 11 01:10:55 1992 John Gilmore (gnu at cygnus.com) + + * bfd.h: Regen'd from bfd.c after removing elf_core_tdata_struct. + +Mon May 18 17:29:03 1992 K. Richard Pixley (rich@cygnus.com) + + * getopt.h: merged changes from make-3.62.11. + + * getopt.h: merged changes from grep-1.6 (alpha). + +Fri May 8 14:53:32 1992 K. Richard Pixley (rich@cygnus.com) + + * getopt.h: merged changes from bison-1.18. + +Sat Mar 14 17:25:20 1992 Fred Fish (fnf@cygnus.com) + + * obstack.h: Add "area_id" and "flags" members to obstack + structure. Add obstack_chunkfun() and obstack_freefun() to + set functions explicitly. Convert maybe_empty_object to + a bit in "flags". + +Thu Feb 27 22:01:02 1992 Per Bothner (bothner@cygnus.com) + + * wait.h (WIFSTOPPED): Add IBM rs6000-specific version. + +Fri Feb 21 20:49:20 1992 John Gilmore (gnu at cygnus.com) + + * obstack.h: Add obstack_full_begin. + * bfd.h, obstack.h: Protolint. + +Thu Jan 30 01:18:42 1992 John Gilmore (gnu at cygnus.com) + + * bfd.h: Remove comma from enum declaration. + +Mon Jan 27 22:01:13 1992 Steve Chamberlain (sac at cygnus.com) + + * bfd.h : new target entr, bfd_relax_section + +Wed Dec 18 17:19:44 1991 Stu Grossman (grossman at cygnus.com) + + * bfd.h, ieee.h, opcode/m68k.h, opcode/sparc.h: ANSIfy enums. + +Thu Dec 12 20:59:56 1991 John Gilmore (gnu at cygnus.com) + + * fopen-same.h, fopen-bin.h: New files for configuring + whether fopen distinguishes binary files or not. For use + by host-dependent config files. + +Sat Nov 30 20:46:43 1991 Steve Chamberlain (sac at rtl.cygnus.com) + + * bfd.h: change the documentation format. + + * created coff, elf and opcode and aout directories. Moved: + + aout64.h ==> aout/aout64.h + ar.h ==> aout/ar.h + a.out.encap.h ==> aout/encap.h + a.out.host.h ==> aout/host.h + a.out.hp.h ==> aout/hp.h + a.out.sun4.h ==> aout/sun4.h + ranlib.h ==> aout/ranlib.h + reloc.h ==> aout/reloc.h + stab.def ==> aout/stab.def + stab.gnu.h ==> aout/stab_gnu.h + + coff-a29k.h ==> coff/a29k.h + coff-h8300.h ==> coff/h8300.h + coff-i386.h ==> coff/i386.h + coff-i960.h ==> coff/i960.h + internalcoff.h ==> coff/internal.h + coff-m68k.h ==> coff/m68k.h + coff-m88k.h ==> coff/m88k.h + coff-mips.h ==> coff/mips.h + coff-rs6000.h ==> coff/rs6000.h + + elf-common.h ==> elf/common.h + dwarf.h ==> elf/dwarf.h + elf-external.h ==> elf/external.h + elf-internal.h ==> elf/internal.h + + a29k-opcode.h ==> opcode/a29k.h + arm-opcode.h ==> opcode/arm.h + h8300-opcode.h ==> opcode/h8300.h + i386-opcode.h ==> opcode/i386.h + i860-opcode.h ==> opcode/i860.h + i960-opcode.h ==> opcode/i960.h + m68k-opcode.h ==> opcode/m68k.h + m88k-opcode.h ==> opcode/m88k.h + mips-opcode.h ==> opcode/mips.h + np1-opcode.h ==> opcode/np1.h + ns32k-opcode.h ==> opcode/ns32k.h + pn-opcode.h ==> opcode/pn.h + pyr-opcode.h ==> opcode/pyr.h + sparc-opcode.h ==> opcode/sparc.h + tahoe-opcode.h ==> opcode/tahoe.h + vax-opcode.h ==> opcode/vax.h + + + +Wed Nov 27 10:38:31 1991 Steve Chamberlain (sac at rtl.cygnus.com) + + * internalcoff.h: (internal_scnhdr) took out #def dependency, now + s_nreloc and s_nlnno are always long. (internal_reloc): allways + has an offset field now. + +Fri Nov 22 08:12:58 1991 John Gilmore (gnu at cygnus.com) + + * coff-rs6000.h: Lint; use unsigned chars for external fields. + * internalcoff.h: Lint; cast storage classes to signed char. + +Thu Nov 21 21:01:05 1991 Per Bothner (bothner at cygnus.com) + + * stab.def: Remove the GNU extended type codes (e.g. N_SETT). + * aout64.h: The heuristic for distinguishing between + sunos-style and bsd-style ZMAGIC files (wrt. where the + text segment starts) is moved into (the default definition of) + the macro N_HEADER_IN_TEXT. This definition is only used + if no other definition is used - e.g. bfd/newsos3.c defines + N_HEADER_IN_TEXT(x) to be always 0 (as before). + +Thu Nov 21 11:53:03 1991 John Gilmore (gnu at cygnus.com) + + * aout64.h (N_TXTADDR, N_TXTOFF, N_TXTSIZE): New definitions + that should handle all uses. LOGICAL_ versions deleted. + Eliminate N_HEADER_IN_TEXT, using a_entry to determine which + kind of zmagic a.out file we are looking at. + * coff-rs6000.h: Typo. + +Tue Nov 19 18:43:37 1991 Per Bothner (bothner at cygnus.com) + + (Note: This is a revised entry, as was aout64.h.) + * aout64.h: Some cleanups of N_TXTADDR and N_TXTOFF: + Will now work for both old- and new-style ZMAGIC files, + depending on N_HEADER_IN_TEXT macro. + Add LOGICAL_TXTADDR, LOICAL_TXTOFF and LOGICAL_TXTSIZE + that don't count the exec header as part + of the text segment, to be consistent with bfd. + * a.out.sun4.h: Simplified/fixed for previous change. + +Mon Nov 18 00:02:06 1991 Fred Fish (fnf at cygnus.com) + + * dwarf.h: Update to DWARF draft 5 version from gcc2. + +Thu Nov 14 19:44:59 1991 Per Bothner (bothner at cygnus.com) + + * stab.def: Added defs for extended GNU symbol types, + such as N_SETT. These are normally ifdef'd out (because + of conflicts with a.out.gnu.h), but are used by bfb_stab_name(). + +Thu Nov 14 19:17:03 1991 Fred Fish (fnf at cygnus.com) + + * elf-common.h: Add defines to support ELF symbol table code. + +Mon Nov 11 19:01:06 1991 Fred Fish (fnf at cygnus.com) + + * elf-internal.h, elf-external.h, elf-common.h: Add support for + note sections, which are used in ELF core files to hold copies + of various /proc structures. + +Thu Nov 7 08:58:26 1991 Steve Chamberlain (sac at cygnus.com) + + * internalcoff.h: took out the M88 dependency in the lineno + struct. + * coff-m88k.h: defines GET_LINENO_LNNO and PUT_LINENO_LNNO to use + 32bit linno entries. + * a29k-opcode.h: fixed encoding of mtacc + +Sun Nov 3 11:54:22 1991 Per Bothner (bothner at cygnus.com) + + * bfd.h: Updated from ../bfd/bfd-in.h (q.v). + +Fri Nov 1 11:13:53 1991 John Gilmore (gnu at cygnus.com) + + * internalcoff.h: Add x_csect defines. + +Fri Oct 25 03:18:20 1991 John Gilmore (gnu at cygnus.com) + + * Rename COFF-related files in `coff-ARCH.h' form. + coff-a29k.h, coff-i386.h, coff-i960.h, coff-m68k.h, coff-m88k.h, + coff-mips.h, coff-rs6000.h to be exact. + +Thu Oct 24 22:11:11 1991 John Gilmore (gnu at cygnus.com) + + RS/6000 support, by Metin G. Ozisik, Mimi Phûông-Thåo Võ, and + John Gilmore. + + * a.out.gnu.h: Update slightly. + * bfd.h: Add new error code, fix doc, add bfd_arch_rs6000. + * internalcoff.h: Add more F_ codes for filehdr. Add + rs/6000-dependent fields to aouthdr. Add storage classes + to syments. Add 6000-specific auxent. Add r_size in reloc. + * rs6000coff.c: New file. + +Thu Oct 24 04:13:20 1991 Fred Fish (fnf at cygnus.com) + + * dwarf.h: New file for dwarf support. Copied from gcc2 + distribution. + +Wed Oct 16 13:31:45 1991 John Gilmore (gnu at cygnus.com) + + * aout64.h: Remove PAGE_SIZE defines; they are target-dependent. + Add N_FN_SEQ for N_FN symbol type used on Sequent machines. + * stab.def: Include N_FN_SEQ in table. + * bout.h: External formats of structures use unsigned chars. + +Fri Oct 11 12:40:43 1991 Steve Chamberlain (steve at cygnus.com) + + * bfd.h:upgrade from bfd.c + * internalcoff.h: add n_name, n_zeroes and n_offset macros + * amdcoff.h: Define OMAGIC and AOUTHDRSZ. + +Fri Oct 11 10:58:06 1991 Per Bothner (bothner at cygnus.com) + + * a.out.host.h: Change SEGMENT_SIZE to 0x1000 for Sony. + * bfd.h (align_power): Add (actually move) comment. + +Tue Oct 8 15:29:32 1991 Per Bothner (bothner at cygnus.com) + + * sys/h-rtbsd.h: Define MISSING_VFPRINT (for binutils/bucomm.c). + +Sun Oct 6 19:24:39 1991 John Gilmore (gnu at cygnus.com) + + * aout64.h: Move struct internal_exec to ../bfd/libaout.h so + it can be shared by all `a.out-family' code. Rename + EXTERNAL_LIST_SIZE to EXTERNAL_NLIST_SIZE. Use basic types + for nlist members, and make strx integral rather than pointer. + More commentary on n_type values. + * bout.h: Provide a struct external_exec rather than an + internal_exec. + * m68kcoff.h: Remove `tagentries' which snuck in from the i960 + COFF port. + +Fri Oct 4 01:25:59 1991 John Gilmore (gnu at cygnus.com) + + * h8300-opcode.h: Remove `_enum' from the typedef for an enum. + * bfd.h: Update to match bfd changes. + + * sys/h-i386mach.h, sysdep.h: Add 386 Mach host support. + +Tue Oct 1 04:58:42 1991 John Gilmore (gnu at cygnus.com) + + * bfd.h, elf-common.h, elf-external.h, elf-internal.h: + Add preliminary ELF support, sufficient for GDB, from Fred Fish. + * sysdep.h, sys/h-amix.h: Support Amiga SVR4. + + * sys/h-vaxult.h: Make it work. (David Taylor ) + * a.out.vax.h: Remove unused and confusing file. + +Mon Sep 30 12:52:35 1991 Per Bothner (bothner at cygnus.com) + + * sysdep.h: Define NEWSOS3_SYS, and use it. + +Fri Sep 20 13:38:21 1991 John Gilmore (gnu at cygnus.com) + + * a.out.gnu.h (N_FN): Its value *really is* 0x1F. + Fix it, and add comments warning about or-ing N_EXT with it + and/or N_WARNING. + * aout64.h (N_FN): Fix value, add comments about N_EXT. + * stab.def (table at end): Update to show all the type + values <0x20, including low order bits. Move N_FN to + its rightful place. + +Tue Sep 17 17:41:37 1991 Stu Grossman (grossman at cygnus.com) + + * sys/h-irix3.h: sgi/irix support. + +Tue Sep 17 07:52:59 1991 John Gilmore (gnu at cygint.cygnus.com) + + * stab.def (N_DEFD): Add GNU Modula-2 debug stab, from Andrew + Beers. + +Thu Sep 12 14:12:59 1991 John Gilmore (gnu at cygint.cygnus.com) + + * internalcoff.h (SYMNMLEN, FILNMLEN, DIMNUM): Define these + for internalcoff, separately from the various external coff's. + * amdcoff.h, bcs88kcoff.h, i386coff.h, intel-coff.h, m68kcoff.h, + m88k-bcs.h: Prefix SYMNMLEN, FILNMLEN, and DIMNUM with E_'s for + the external struct definitions. + * ecoff.h: Remove these #define's, kludge no longer needed. + + * sys/h-ultra3.h: Add new Ultracomputer host. + * sysdep.h: Add ULTRA3_SYM1_SYS and use it. + +Tue Sep 10 10:11:46 1991 John Gilmore (gnu at cygint.cygnus.com) + + * i386coff.h (LINESZ): Always 6, not based on sizeof(). + (Fix from Peter Schauer .) + +Wed Sep 4 08:58:37 1991 John Gilmore (gnu at cygint.cygnus.com) + + * a.out.gnu.h, aout64.h: Add N_WARNING. Change N_FN to 0x0E, + to match SunOS and BSD. Add N_COMM as 0x12 for SunOS shared lib + support. + * stab.def: Add N_COMM to table, fix overlap comment. + +Tue Sep 3 06:29:20 1991 John Gilmore (gnu at cygint.cygnus.com) + + Merge with latest FSF versions of these files. + + * stab.gnu.h: Add LAST_UNUSED_STAB_CODE. + * stab.def: Update to GPL2. Move N_WARNING out, since not a + debug symbol. Change comments, and reorder table to numeric + order. Update final table comment. + (N_DSLINE, N_BSLINE): Renumber from 0x66 and 0x68, to 0x46 and 0x48. + + * obstack.h: GPL2. Merge. + +Fri Aug 23 01:54:23 1991 John Gilmore (gnu at cygint.cygnus.com) + + * a.out.gnu.h, a.out.sun4.h: Make SEGMENT_SIZE able to depend + on the particular a.out being examined. + * a.out.sun4.h: Define segment sizes for Sun-3's and Sun-4's. + * FIXME: a.out.gnu.h is almost obsolete. + * FIXME: a.out.sun4.h should be renamed a.out.sun.h now. + +Wed Aug 21 20:32:13 1991 John Gilmore (gnu at cygint.cygnus.com) + + * Start a ChangeLog for the includes directory. + + * a.out.gnu.h (N_FN): Fix value -- was 15, should be 0x1E. + * stab.def: Update allocation table in comments at end, + to reflect reality as I know it. + + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/include/ansidecl.h b/include/ansidecl.h new file mode 100644 index 000000000000..abe87a9390ba --- /dev/null +++ b/include/ansidecl.h @@ -0,0 +1,154 @@ +/* ANSI and traditional C compatability macros + Copyright 1991, 1992, 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + +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. */ + +/* ANSI and traditional C compatibility macros + + ANSI C is assumed if __STDC__ is #defined. + + Macro ANSI C definition Traditional C definition + ----- ---- - ---------- ----------- - ---------- + PTR `void *' `char *' + LONG_DOUBLE `long double' `double' + VOLATILE `volatile' `' + SIGNED `signed' `' + PTRCONST `void *const' `char *' + ANSI_PROTOTYPES 1 not defined + + CONST is also defined, but is obsolete. Just use const. + + obsolete -- DEFUN (name, arglist, args) + + Defines function NAME. + + ARGLIST lists the arguments, separated by commas and enclosed in + parentheses. ARGLIST becomes the argument list in traditional C. + + ARGS list the arguments with their types. It becomes a prototype in + ANSI C, and the type declarations in traditional C. Arguments should + be separated with `AND'. For functions with a variable number of + arguments, the last thing listed should be `DOTS'. + + obsolete -- DEFUN_VOID (name) + + Defines a function NAME, which takes no arguments. + + obsolete -- EXFUN (name, (prototype)) -- obsolete. + + Replaced by PARAMS. Do not use; will disappear someday soon. + Was used in external function declarations. + In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in + parentheses). In traditional C it is `NAME()'. + For a function that takes no arguments, PROTOTYPE should be `(void)'. + + obsolete -- PROTO (type, name, (prototype) -- obsolete. + + This one has also been replaced by PARAMS. Do not use. + + PARAMS ((args)) + + We could use the EXFUN macro to handle prototype declarations, but + the name is misleading and the result is ugly. So we just define a + simple macro to handle the parameter lists, as in: + + static int foo PARAMS ((int, char)); + + This produces: `static int foo();' or `static int foo (int, char);' + + EXFUN would have done it like this: + + static int EXFUN (foo, (int, char)); + + but the function is not external...and it's hard to visually parse + the function name out of the mess. EXFUN should be considered + obsolete; new code should be written to use PARAMS. + + DOTS is also obsolete. + + Examples: + + extern int printf PARAMS ((const char *format, ...)); +*/ + +#ifndef _ANSIDECL_H + +#define _ANSIDECL_H 1 + + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + + +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) +/* All known AIX compilers implement these things (but don't always + define __STDC__). The RISC/OS MIPS compiler defines these things + in SVR4 mode, but does not define __STDC__. */ + +#define PTR void * +#define PTRCONST void *CONST +#define LONG_DOUBLE long double + +#define AND , +#define NOARGS void +#define VOLATILE volatile +#define SIGNED signed + +#define PARAMS(paramlist) paramlist +#define ANSI_PROTOTYPES 1 + +#define VPARAMS(ARGS) ARGS +#define VA_START(va_list,var) va_start(va_list,var) + +/* These are obsolete. Do not use. */ +#define CONST const +#define DOTS , ... +#define PROTO(type, name, arglist) type name arglist +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(void) + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define AND ; +#define NOARGS +#ifndef const /* some systems define it in header files for non-ansi mode */ +#define const +#endif +#define VOLATILE +#define SIGNED + +#define PARAMS(paramlist) () + +#define VPARAMS(ARGS) (va_alist) va_dcl +#define VA_START(va_list,var) va_start(va_list) + +/* These are obsolete. Do not use. */ +#define CONST +#define DOTS +#define PROTO(type, name, arglist) type name () +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() + +#endif /* ANSI C. */ + +#endif /* ansidecl.h */ diff --git a/include/demangle.h b/include/demangle.h new file mode 100644 index 000000000000..00f6a0c3bc0a --- /dev/null +++ b/include/demangle.h @@ -0,0 +1,90 @@ +/* Defs for interface to demanglers. + Copyright 1992, 1995, 1996 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. */ + + +#if !defined (DEMANGLE_H) +#define DEMANGLE_H + +#ifdef IN_GCC +#include "gansidecl.h" +#define PARAMS(ARGS) PROTO(ARGS) +#else /* ! IN_GCC */ +#include +#endif /* IN_GCC */ + +/* Options passed to cplus_demangle (in 2nd parameter). */ + +#define DMGL_NO_OPTS 0 /* For readability... */ +#define DMGL_PARAMS (1 << 0) /* Include function args */ +#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ +#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ + +#define DMGL_AUTO (1 << 8) +#define DMGL_GNU (1 << 9) +#define DMGL_LUCID (1 << 10) +#define DMGL_ARM (1 << 11) +/* If none of these are set, use 'current_demangling_style' as the default. */ +#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM) + +/* Enumeration of possible demangling styles. + + Lucid and ARM styles are still kept logically distinct, even though + they now both behave identically. The resulting style is actual the + union of both. I.E. either style recognizes both "__pt__" and "__rf__" + for operator "->", even though the first is lucid style and the second + is ARM style. (FIXME?) */ + +extern enum demangling_styles +{ + unknown_demangling = 0, + auto_demangling = DMGL_AUTO, + gnu_demangling = DMGL_GNU, + lucid_demangling = DMGL_LUCID, + arm_demangling = DMGL_ARM +} current_demangling_style; + +/* Define string names for the various demangling styles. */ + +#define AUTO_DEMANGLING_STYLE_STRING "auto" +#define GNU_DEMANGLING_STYLE_STRING "gnu" +#define LUCID_DEMANGLING_STYLE_STRING "lucid" +#define ARM_DEMANGLING_STYLE_STRING "arm" + +/* Some macros to test what demangling style is active. */ + +#define CURRENT_DEMANGLING_STYLE current_demangling_style +#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO) +#define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU) +#define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID) +#define ARM_DEMANGLING (CURRENT_DEMANGLING_STYLE & DMGL_ARM) + +extern char * +cplus_demangle PARAMS ((const char *mangled, int options)); + +extern int +cplus_demangle_opname PARAMS ((const char *opname, char *result, int options)); + +extern const char * +cplus_mangle_opname PARAMS ((const char *opname, int options)); + +/* Note: This sets global state. FIXME if you care about multi-threading. */ + +extern void +set_cplus_marker_for_demangling PARAMS ((int ch)); + +#endif /* DEMANGLE_H */ diff --git a/include/floatformat.h b/include/floatformat.h new file mode 100644 index 000000000000..90daca21bcbd --- /dev/null +++ b/include/floatformat.h @@ -0,0 +1,111 @@ +/* IEEE floating point support declarations, for GDB, the GNU Debugger. + Copyright (C) 1991 Free Software Foundation, Inc. + +This file is part of GDB. + +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. */ + +#if !defined (FLOATFORMAT_H) +#define FLOATFORMAT_H 1 + +#include "ansidecl.h" + +/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the + bytes are concatenated according to the byteorder flag, then each of those + fields is contiguous. We number the bits with 0 being the most significant + (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field + contains with the *_start and *_len fields. */ + +/* What is the order of the bytes. */ + +enum floatformat_byteorders { + + /* Standard little endian byte order. + EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */ + + floatformat_little, + + /* Standard big endian byte order. + EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */ + + floatformat_big, + + /* Little endian byte order but big endian word order. + EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */ + + floatformat_littlebyte_bigword + +}; + +enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no }; + +struct floatformat +{ + enum floatformat_byteorders byteorder; + unsigned int totalsize; /* Total size of number in bits */ + + /* Sign bit is always one bit long. 1 means negative, 0 means positive. */ + unsigned int sign_start; + + unsigned int exp_start; + unsigned int exp_len; + /* Amount added to "true" exponent. 0x3fff for many IEEE extendeds. */ + unsigned int exp_bias; + /* Exponent value which indicates NaN. This is the actual value stored in + the float, not adjusted by the exp_bias. This usually consists of all + one bits. */ + unsigned int exp_nan; + + unsigned int man_start; + unsigned int man_len; + + /* Is the integer bit explicit or implicit? */ + enum floatformat_intbit intbit; +}; + +/* floatformats for IEEE single and double, big and little endian. */ + +extern const struct floatformat floatformat_ieee_single_big; +extern const struct floatformat floatformat_ieee_single_little; +extern const struct floatformat floatformat_ieee_double_big; +extern const struct floatformat floatformat_ieee_double_little; + +/* floatformat for ARM IEEE double, little endian bytes and big endian words */ + +extern const struct floatformat floatformat_ieee_double_littlebyte_bigword; + +/* floatformats for various extendeds. */ + +extern const struct floatformat floatformat_i387_ext; +extern const struct floatformat floatformat_m68881_ext; +extern const struct floatformat floatformat_i960_ext; +extern const struct floatformat floatformat_m88110_ext; +extern const struct floatformat floatformat_arm_ext; + +/* Convert from FMT to a double. + FROM is the address of the extended float. + Store the double in *TO. */ + +extern void +floatformat_to_double PARAMS ((const struct floatformat *, char *, double *)); + +/* The converse: convert the double *FROM to FMT + and store where TO points. */ + +extern void +floatformat_from_double PARAMS ((const struct floatformat *, + double *, char *)); + +#endif /* defined (FLOATFORMAT_H) */ diff --git a/include/fnmatch.h b/include/fnmatch.h new file mode 100644 index 000000000000..1a653ab6314b --- /dev/null +++ b/include/fnmatch.h @@ -0,0 +1,69 @@ +/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + +NOTE: The canonical source of this file is maintained with the GNU C Library. +Bugs can be reported to bug-glibc@prep.ai.mit.edu. + +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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef _FNMATCH_H + +#define _FNMATCH_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (__cplusplus) || (defined (__STDC__) && __STDC__) +#undef __P +#define __P(args) args +#else /* Not C++ or ANSI C. */ +#undef __P +#define __P(args) () +/* We can get away without defining `const' here only because in this file + it is used only inside the prototype for `fnmatch', which is elided in + non-ANSI C where `const' is problematical. */ +#endif /* C++ or ANSI C. */ + + +/* We #undef these before defining them because some losing systems + (HP-UX A.08.07 for example) define these in . */ +#undef FNM_PATHNAME +#undef FNM_NOESCAPE +#undef FNM_PERIOD + +/* Bits set in the FLAGS argument to `fnmatch'. */ +#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ +#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ + +#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE) +#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ +#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +#endif + +/* Value returned by `fnmatch' if STRING does not match PATTERN. */ +#define FNM_NOMATCH 1 + +/* Match STRING against the filename pattern PATTERN, + returning zero if it matches, FNM_NOMATCH if not. */ +extern int fnmatch __P ((const char *__pattern, const char *__string, + int __flags)); + +#ifdef __cplusplus +} +#endif + +#endif /* fnmatch.h */ diff --git a/include/getopt.h b/include/getopt.h new file mode 100644 index 000000000000..abf915383200 --- /dev/null +++ b/include/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/include/libiberty.h b/include/libiberty.h new file mode 100644 index 000000000000..893d2a937298 --- /dev/null +++ b/include/libiberty.h @@ -0,0 +1,161 @@ +/* Function declarations for libiberty. + Written by Cygnus Support, 1994. + + The libiberty library provides a number of functions which are + missing on some operating systems. We do not declare those here, + to avoid conflicts with the system header files on operating + systems that do support those functions. In this file we only + declare those functions which are specific to libiberty. */ + +#ifndef LIBIBERTY_H +#define LIBIBERTY_H + +#include "ansidecl.h" + +/* Build an argument vector from a string. Allocates memory using + malloc. Use freeargv to free the vector. */ + +extern char **buildargv PARAMS ((char *)); + +/* Free a vector returned by buildargv. */ + +extern void freeargv PARAMS ((char **)); + +/* Return the last component of a path name. Note that we can't use a + prototype here because the parameter is declared inconsistently + across different systems, sometimes as "char *" and sometimes as + "const char *" */ + +#if defined(__GNU_LIBRARY__ ) || defined (__linux__) +extern char *basename PARAMS ((const char *)); +#else +extern char *basename (); +#endif + +/* Concatenate an arbitrary number of strings, up to (char *) NULL. + Allocates memory using xmalloc. */ + +extern char *concat PARAMS ((const char *, ...)); + +/* Check whether two file descriptors refer to the same file. */ + +extern int fdmatch PARAMS ((int fd1, int fd2)); + +/* Get the amount of time the process has run, in microseconds. */ + +extern long get_run_time PARAMS ((void)); + +/* Choose a temporary directory to use for scratch files. */ + +extern char *choose_temp_base PARAMS ((void)); + +/* Allocate memory filled with spaces. Allocates using malloc. */ + +extern const char *spaces PARAMS ((int count)); + +/* Return the maximum error number for which strerror will return a + string. */ + +extern int errno_max PARAMS ((void)); + +/* Return the name of an errno value (e.g., strerrno (EINVAL) returns + "EINVAL"). */ + +extern const char *strerrno PARAMS ((int)); + +/* Given the name of an errno value, return the value. */ + +extern int strtoerrno PARAMS ((const char *)); + +/* ANSI's strerror(), but more robust. */ + +extern char *xstrerror PARAMS ((int)); + +/* Return the maximum signal number for which strsignal will return a + string. */ + +extern int signo_max PARAMS ((void)); + +/* Return a signal message string for a signal number + (e.g., strsignal (SIGHUP) returns something like "Hangup"). */ +/* This is commented out as it can conflict with one in system headers. + We still document its existence though. */ + +/*extern const char *strsignal PARAMS ((int));*/ + +/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns + "SIGHUP"). */ + +extern const char *strsigno PARAMS ((int)); + +/* Given the name of a signal, return its number. */ + +extern int strtosigno PARAMS ((const char *)); + +/* Register a function to be run by xexit. Returns 0 on success. */ + +extern int xatexit PARAMS ((void (*fn) (void))); + +/* Exit, calling all the functions registered with xatexit. */ + +#ifndef __GNUC__ +extern void xexit PARAMS ((int status)); +#else +typedef void libiberty_voidfn PARAMS ((int status)); +__volatile__ libiberty_voidfn xexit; +#endif + +/* Set the program name used by xmalloc. */ + +extern void xmalloc_set_program_name PARAMS ((const char *)); + +/* Allocate memory without fail. If malloc fails, this will print a + message to stderr (using the name set by xmalloc_set_program_name, + if any) and then call xexit. */ + +#ifdef ANSI_PROTOTYPES +/* Get a definition for size_t. */ +#include +#endif +extern PTR xmalloc PARAMS ((size_t)); + +/* Reallocate memory without fail. This works like xmalloc. + + FIXME: We do not declare the parameter types for the same reason as + xmalloc. */ + +extern PTR xrealloc PARAMS ((PTR, size_t)); + +/* Copy a string into a memory buffer without fail. */ + +extern char *xstrdup PARAMS ((const char *)); + +/* hex character manipulation routines */ + +#define _hex_array_size 256 +#define _hex_bad 99 +extern char _hex_value[_hex_array_size]; +extern void hex_init PARAMS ((void)); +#define hex_p(c) (hex_value (c) != _hex_bad) +/* If you change this, note well: Some code relies on side effects in + the argument being performed exactly once. */ +#define hex_value(c) (_hex_value[(unsigned char) (c)]) + +/* Definitions used by the pexecute routine. */ + +#define PEXECUTE_FIRST 1 +#define PEXECUTE_LAST 2 +#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST) +#define PEXECUTE_SEARCH 4 +#define PEXECUTE_VERBOSE 8 + +/* Execute a program. */ + +extern int pexecute PARAMS ((const char *, char * const *, const char *, + const char *, char **, char **, int)); + +/* Wait for pexecute to finish. */ + +extern int pwait PARAMS ((int, int *, int)); + +#endif /* ! defined (LIBIBERTY_H) */ diff --git a/include/objalloc.h b/include/objalloc.h new file mode 100644 index 000000000000..24f87f8749da --- /dev/null +++ b/include/objalloc.h @@ -0,0 +1,115 @@ +/* objalloc.h -- routines to allocate memory for objects + Copyright 1997 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Solutions. + +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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef OBJALLOC_H +#define OBJALLOC_H + +#include "ansidecl.h" + +/* These routines allocate space for an object. The assumption is + that the object will want to allocate space as it goes along, but + will never want to free any particular block. There is a function + to free a block, which also frees all more recently allocated + blocks. There is also a function to free all the allocated space. + + This is essentially a specialization of obstacks. The main + difference is that a block may not be allocated a bit at a time. + Another difference is that these routines are always built on top + of malloc, and always pass an malloc failure back to the caller, + unlike more recent versions of obstacks. */ + +/* This is what an objalloc structure looks like. Callers should not + refer to these fields, nor should they allocate these structure + themselves. Instead, they should only create them via + objalloc_init, and only access them via the functions and macros + listed below. The structure is only defined here so that we can + access it via macros. */ + +struct objalloc +{ + char *current_ptr; + unsigned int current_space; + PTR chunks; +}; + +/* Work out the required alignment. */ + +struct objalloc_align { char x; double d; }; + +#if defined (__STDC__) && __STDC__ +#ifndef offsetof +#include +#endif +#define OBJALLOC_ALIGN \ + ((ptrdiff_t) ((char *) &((struct objalloc_align *) 0)->d - (char *) 0)) +#else +#define OBJALLOC_ALIGN \ + ((long) ((char *) &((struct objalloc_align *) 0)->d - (char *) 0)) +#endif + +/* Create an objalloc structure. Returns NULL if malloc fails. */ + +extern struct objalloc *objalloc_create PARAMS ((void)); + +/* Allocate space from an objalloc structure. Returns NULL if malloc + fails. */ + +extern PTR _objalloc_alloc PARAMS ((struct objalloc *, unsigned long)); + +/* The macro version of objalloc_alloc. We only define this if using + gcc, because otherwise we would have to evaluate the arguments + multiple times, or use a temporary field as obstack.h does. */ + +#if defined (__GNUC__) && defined (__STDC__) && __STDC__ + +/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and + does not implement __extension__. But that compiler doesn't define + __GNUC_MINOR__. */ +#if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) +#define __extension__ +#endif + +#define objalloc_alloc(o, l) \ + __extension__ \ + ({ struct objalloc *__o = (o); \ + unsigned long __len = (l); \ + if (__len == 0) \ + __len = 1; \ + __len = (__len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); \ + (__len <= __o->current_space \ + ? (__o->current_ptr += __len, \ + __o->current_space -= __len, \ + (PTR) (__o->current_ptr - __len)) \ + : _objalloc_alloc (__o, __len)); }) + +#else /* ! __GNUC__ */ + +#define objalloc_alloc(o, l) _objalloc_alloc ((o), (l)) + +#endif /* ! __GNUC__ */ + +/* Free an entire objalloc structure. */ + +extern void objalloc_free PARAMS ((struct objalloc *)); + +/* Free a block allocated by objalloc_alloc. This also frees all more + recently allocated blocks. */ + +extern void objalloc_free_block PARAMS ((struct objalloc *, PTR)); + +#endif /* OBJALLOC_H */ diff --git a/include/obstack.h b/include/obstack.h new file mode 100644 index 000000000000..ffc6b9ecfca4 --- /dev/null +++ b/include/obstack.h @@ -0,0 +1,570 @@ +/* obstack.h - object stack macros + Copyright (C) 1988,89,90,91,92,93,94,96 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Summary: + +All the apparent functions defined here are macros. The idea +is that you would use these pre-tested macros to solve a +very specific set of problems, and they would run fast. +Caution: no side-effects in arguments please!! They may be +evaluated MANY times!! + +These macros operate a stack of objects. Each object starts life +small, and may grow to maturity. (Consider building a word syllable +by syllable.) An object can move while it is growing. Once it has +been "finished" it never changes address again. So the "top of the +stack" is typically an immature growing object, while the rest of the +stack is of mature, fixed size and fixed address objects. + +These routines grab large chunks of memory, using a function you +supply, called `obstack_chunk_alloc'. On occasion, they free chunks, +by calling `obstack_chunk_free'. You must define them and declare +them before using any obstack macros. + +Each independent stack is represented by a `struct obstack'. +Each of the obstack macros expects a pointer to such a structure +as the first argument. + +One motivation for this package is the problem of growing char strings +in symbol tables. Unless you are "fascist pig with a read-only mind" +--Gosper's immortal quote from HAKMEM item 154, out of context--you +would not like to put any arbitrary upper limit on the length of your +symbols. + +In practice this often means you will build many short symbols and a +few long symbols. At the time you are reading a symbol you don't know +how long it is. One traditional method is to read a symbol into a +buffer, realloc()ating the buffer every time you try to read a symbol +that is longer than the buffer. This is beaut, but you still will +want to copy the symbol from the buffer to a more permanent +symbol-table entry say about half the time. + +With obstacks, you can work differently. Use one obstack for all symbol +names. As you read a symbol, grow the name in the obstack gradually. +When the name is complete, finalize it. Then, if the symbol exists already, +free the newly read name. + +The way we do this is to take a large chunk, allocating memory from +low addresses. When you want to build a symbol in the chunk you just +add chars above the current "high water mark" in the chunk. When you +have finished adding chars, because you got to the end of the symbol, +you know how long the chars are, and you can create a new object. +Mostly the chars will not burst over the highest address of the chunk, +because you would typically expect a chunk to be (say) 100 times as +long as an average object. + +In case that isn't clear, when we have enough chars to make up +the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) +so we just point to it where it lies. No moving of chars is +needed and this is the second win: potentially long strings need +never be explicitly shuffled. Once an object is formed, it does not +change its address during its lifetime. + +When the chars burst over a chunk boundary, we allocate a larger +chunk, and then copy the partly formed object from the end of the old +chunk to the beginning of the new larger chunk. We then carry on +accreting characters to the end of the object as we normally would. + +A special macro is provided to add a single char at a time to a +growing object. This allows the use of register variables, which +break the ordinary 'growth' macro. + +Summary: + We allocate large chunks. + We carve out one object at a time from the current chunk. + Once carved, an object never moves. + We are free to append data of any size to the currently + growing object. + Exactly one object is growing in an obstack at any one time. + You can run one obstack per control block. + You may have as many control blocks as you dare. + Because of the way we do it, you can `unwind' an obstack + back to a previous state. (You may remove objects much + as you would with a stack.) +*/ + + +/* Don't do the contents of this file more than once. */ + +#ifndef __OBSTACK_H__ +#define __OBSTACK_H__ + +/* We use subtraction of (char *) 0 instead of casting to int + because on word-addressable machines a simple cast to int + may ignore the byte-within-word field of the pointer. */ + +#ifndef __PTR_TO_INT +#define __PTR_TO_INT(P) ((P) - (char *) 0) +#endif + +#ifndef __INT_TO_PTR +#define __INT_TO_PTR(P) ((P) + (char *) 0) +#endif + +/* We need the type of the resulting object. In ANSI C it is ptrdiff_t + but in traditional C it is usually long. If we are in ANSI C and + don't already have ptrdiff_t get it. */ + +#if defined (__STDC__) && __STDC__ && ! defined (offsetof) +#if defined (__GNUC__) && defined (IN_GCC) +/* On Next machine, the system's stddef.h screws up if included + after we have defined just ptrdiff_t, so include all of stddef.h. + Otherwise, define just ptrdiff_t, which is all we need. */ +#ifndef __NeXT__ +#define __need_ptrdiff_t +#endif +#endif + +#include +#endif + +#if defined (__STDC__) && __STDC__ +#define PTR_INT_TYPE ptrdiff_t +#else +#define PTR_INT_TYPE long +#endif + +struct _obstack_chunk /* Lives at front of each chunk. */ +{ + char *limit; /* 1 past end of this chunk */ + struct _obstack_chunk *prev; /* address of prior chunk or NULL */ + char contents[4]; /* objects begin here */ +}; + +struct obstack /* control current object in current chunk */ +{ + long chunk_size; /* preferred size to allocate chunks in */ + struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ + PTR_INT_TYPE temp; /* Temporary for some macros. */ + int alignment_mask; /* Mask of alignment for each object. */ +#if defined (__STDC__) && __STDC__ + /* These prototypes vary based on `use_extra_arg', and we use + casts to the prototypeless function type in all assignments, + but having prototypes here quiets -Wstrict-prototypes. */ + struct _obstack_chunk *(*chunkfun) (void *, long); + void (*freefun) (void *, struct _obstack_chunk *); + void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ +#else + struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ + void (*freefun) (); /* User's function to free a chunk. */ + char *extra_arg; /* first arg for chunk alloc/dealloc funcs */ +#endif + unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ + unsigned maybe_empty_object:1;/* There is a possibility that the current + chunk contains a zero-length object. This + prevents freeing the chunk if we allocate + a bigger chunk to replace it. */ + unsigned alloc_failed:1; /* chunk alloc func returned 0 */ +}; + +/* Declare the external functions we use; they are in obstack.c. */ + +#if defined (__STDC__) && __STDC__ +extern void _obstack_newchunk (struct obstack *, int); +extern void _obstack_free (struct obstack *, void *); +extern int _obstack_begin (struct obstack *, int, int, + void *(*) (long), void (*) (void *)); +extern int _obstack_begin_1 (struct obstack *, int, int, + void *(*) (void *, long), + void (*) (void *, void *), void *); +/* CYGNUS LOCAL */ +extern int _obstack_memory_used (struct obstack *); +/* END CYGNUS LOCAL */ +#else +extern void _obstack_newchunk (); +extern void _obstack_free (); +extern int _obstack_begin (); +extern int _obstack_begin_1 (); +/* CYGNUS LOCAL */ +extern int _obstack_memory_used (); +/* END CYGNUS LOCAL */ +#endif + +#if defined (__STDC__) && __STDC__ + +/* Do the function-declarations after the structs + but before defining the macros. */ + +void obstack_init (struct obstack *obstack); + +void * obstack_alloc (struct obstack *obstack, int size); + +void * obstack_copy (struct obstack *obstack, void *address, int size); +void * obstack_copy0 (struct obstack *obstack, void *address, int size); + +void obstack_free (struct obstack *obstack, void *block); + +void obstack_blank (struct obstack *obstack, int size); + +void obstack_grow (struct obstack *obstack, void *data, int size); +void obstack_grow0 (struct obstack *obstack, void *data, int size); + +void obstack_1grow (struct obstack *obstack, int data_char); +void obstack_ptr_grow (struct obstack *obstack, void *data); +void obstack_int_grow (struct obstack *obstack, int data); + +void * obstack_finish (struct obstack *obstack); + +int obstack_object_size (struct obstack *obstack); + +int obstack_room (struct obstack *obstack); +void obstack_1grow_fast (struct obstack *obstack, int data_char); +void obstack_ptr_grow_fast (struct obstack *obstack, void *data); +void obstack_int_grow_fast (struct obstack *obstack, int data); +void obstack_blank_fast (struct obstack *obstack, int size); + +void * obstack_base (struct obstack *obstack); +void * obstack_next_free (struct obstack *obstack); +int obstack_alignment_mask (struct obstack *obstack); +int obstack_chunk_size (struct obstack *obstack); +/* CYGNUS LOCAL */ +int obstack_memory_used (struct obstack *obstack); +/* END CYGNUS LOCAL */ + +#endif /* __STDC__ */ + +/* Non-ANSI C cannot really support alternative functions for these macros, + so we do not declare them. */ + +/* Pointer to beginning of object being allocated or to be allocated next. + Note that this might not be the final address of the object + because a new chunk might be needed to hold the final size. */ + +#define obstack_base(h) ((h)->alloc_failed ? 0 : (h)->object_base) + +/* Size for allocating ordinary chunks. */ + +#define obstack_chunk_size(h) ((h)->chunk_size) + +/* Pointer to next byte not yet allocated in current chunk. */ + +#define obstack_next_free(h) ((h)->alloc_failed ? 0 : (h)->next_free) + +/* Mask specifying low bits that should be clear in address of an object. */ + +#define obstack_alignment_mask(h) ((h)->alignment_mask) + +/* To prevent prototype warnings provide complete argument list in + standard C version. */ +#if defined (__STDC__) && __STDC__ + +#define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) + +#define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) + +#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ + _obstack_begin ((h), (size), (alignment), \ + (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun)) + +#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ + _obstack_begin_1 ((h), (size), (alignment), \ + (void *(*) (void *, long)) (chunkfun), \ + (void (*) (void *, void *)) (freefun), (arg)) + +#define obstack_chunkfun(h, newchunkfun) \ + ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) + +#define obstack_freefun(h, newfreefun) \ + ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) + +#else + +#define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) + +#define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) + +#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ + _obstack_begin ((h), (size), (alignment), \ + (void *(*) ()) (chunkfun), (void (*) ()) (freefun)) + +#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ + _obstack_begin_1 ((h), (size), (alignment), \ + (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg)) + +#define obstack_chunkfun(h, newchunkfun) \ + ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun)) + +#define obstack_freefun(h, newfreefun) \ + ((h) -> freefun = (void (*)()) (newfreefun)) + +#endif + +#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) + +#define obstack_blank_fast(h,n) ((h)->next_free += (n)) + +/* CYGNUS LOCAL */ +#define obstack_memory_used(h) _obstack_memory_used (h) +/* END CYGNUS LOCAL */ + +#if defined (__GNUC__) && defined (__STDC__) && __STDC__ +/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and + does not implement __extension__. But that compiler doesn't define + __GNUC_MINOR__. */ +#if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) +#define __extension__ +#endif + +/* For GNU C, if not -traditional, + we can define these macros to compute all args only once + without using a global variable. + Also, we can avoid using the `temp' slot, to make faster code. */ + +#define obstack_object_size(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + __o->alloc_failed ? 0 : \ + (unsigned) (__o->next_free - __o->object_base); }) + +#define obstack_room(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->chunk_limit - __o->next_free); }) + +#define obstack_grow(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len > __o->chunk_limit) \ + _obstack_newchunk (__o, __len); \ + if (!__o->alloc_failed) \ + { \ + memcpy (__o->next_free, (char *) (where), __len); \ + __o->next_free += __len; \ + } \ + (void) 0; }) + +#define obstack_grow0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, __len + 1); \ + if (!__o->alloc_failed) \ + { \ + memcpy (__o->next_free, (char *) (where), __len); \ + __o->next_free += __len; \ + *(__o->next_free)++ = 0; \ + } \ + (void) 0; }) + +#define obstack_1grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, 1); \ + if (!__o->alloc_failed) \ + *(__o->next_free)++ = (datum); \ + (void) 0; }) + +/* These assume that the obstack alignment is good enough for pointers or ints, + and that the data added so far to the current object + shares that much alignment. */ + +#define obstack_ptr_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (void *)); \ + if (!__o->alloc_failed) \ + *((void **)__o->next_free)++ = ((void *)datum); \ + (void) 0; }) + +#define obstack_int_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (int) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (int)); \ + if (!__o->alloc_failed) \ + *((int *)__o->next_free)++ = ((int)datum); \ + (void) 0; }) + +#define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr) +#define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) + +#define obstack_blank(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + if (!__o->alloc_failed) \ + __o->next_free += __len; \ + (void) 0; }) + +#define obstack_alloc(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_blank (__h, (length)); \ + obstack_finish (__h); }) + +#define obstack_copy(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow (__h, (where), (length)); \ + obstack_finish (__h); }) + +#define obstack_copy0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow0 (__h, (where), (length)); \ + obstack_finish (__h); }) + +/* The local variable is named __o1 to avoid a name conflict + when obstack_blank is called. */ +#define obstack_finish(OBSTACK) \ +__extension__ \ +({ struct obstack *__o1 = (OBSTACK); \ + void *value; \ + if (__o1->alloc_failed) \ + value = 0; \ + else \ + { \ + value = (void *) __o1->object_base; \ + if (__o1->next_free == value) \ + __o1->maybe_empty_object = 1; \ + __o1->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ + & ~ (__o1->alignment_mask)); \ + if (__o1->next_free - (char *)__o1->chunk \ + > __o1->chunk_limit - (char *)__o1->chunk) \ + __o1->next_free = __o1->chunk_limit; \ + __o1->object_base = __o1->next_free; \ + } \ + value; }) + +#define obstack_free(OBSTACK, OBJ) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + void *__obj = (OBJ); \ + if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ + __o->next_free = __o->object_base = __obj; \ + else (obstack_free) (__o, __obj); }) + +#else /* not __GNUC__ or not __STDC__ */ + +#define obstack_object_size(h) \ + (unsigned) ((h)->alloc_failed ? 0 : (h)->next_free - (h)->object_base) + +#define obstack_room(h) \ + (unsigned) ((h)->chunk_limit - (h)->next_free) + +/* Note that the call to _obstack_newchunk is enclosed in (..., 0) + so that we can avoid having void expressions + in the arms of the conditional expression. + Casting the third operand to void was tried before, + but some compilers won't accept it. */ + +#define obstack_grow(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + ((h)->alloc_failed ? 0 : \ + (memcpy ((h)->next_free, (char *) (where), (h)->temp), \ + (h)->next_free += (h)->temp))) + +#define obstack_grow0(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ + ((h)->alloc_failed ? 0 : \ + (memcpy ((h)->next_free, (char *) (where), (h)->temp), \ + (h)->next_free += (h)->temp, \ + *((h)->next_free)++ = 0))) + +#define obstack_1grow(h,datum) \ +( (((h)->next_free + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), 1), 0) : 0), \ + ((h)->alloc_failed ? 0 : \ + (*((h)->next_free)++ = (datum)))) + +#define obstack_ptr_grow(h,datum) \ +( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ + ((h)->alloc_failed ? 0 : \ + (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))) + +#define obstack_int_grow(h,datum) \ +( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ + ((h)->alloc_failed ? 0 : \ + (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))) + +#define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr) +#define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) + +#define obstack_blank(h,length) \ +( (h)->temp = (length), \ + (((h)->chunk_limit - (h)->next_free < (h)->temp) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + ((h)->alloc_failed ? 0 : \ + ((h)->next_free += (h)->temp))) + +#define obstack_alloc(h,length) \ + (obstack_blank ((h), (length)), obstack_finish ((h))) + +#define obstack_copy(h,where,length) \ + (obstack_grow ((h), (where), (length)), obstack_finish ((h))) + +#define obstack_copy0(h,where,length) \ + (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) + +#define obstack_finish(h) \ +( (h)->alloc_failed ? 0 : \ + (((h)->next_free == (h)->object_base \ + ? (((h)->maybe_empty_object = 1), 0) \ + : 0), \ + (h)->temp = __PTR_TO_INT ((h)->object_base), \ + (h)->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ + & ~ ((h)->alignment_mask)), \ + (((h)->next_free - (char *) (h)->chunk \ + > (h)->chunk_limit - (char *) (h)->chunk) \ + ? ((h)->next_free = (h)->chunk_limit) : 0), \ + (h)->object_base = (h)->next_free, \ + __INT_TO_PTR ((h)->temp))) + +#if defined (__STDC__) && __STDC__ +#define obstack_free(h,obj) \ +( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) +#else +#define obstack_free(h,obj) \ +( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0))) +#endif + +#endif /* not __GNUC__ or not __STDC__ */ + +#endif /* not __OBSTACK_H__ */ diff --git a/install-sh b/install-sh new file mode 100755 index 000000000000..853408cec353 --- /dev/null +++ b/install-sh @@ -0,0 +1,287 @@ +#!/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="" +# CYGNUS LOCAL: exeext variable +exeext="" +# END CYGNUS LOCAL + +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;; + + # CYGNUS LOCAL: -x option + -x=*) exeext=`echo $1 | sed 's/-x=//'` + shift + continue;; + + -x) exeext=".exe" + shift + continue;; + # END CYGNUS LOCAL + + *) 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 + +# CYGNUS LOCAL noer +# Win32-based gcc automatically appends .exe to produced executables, +# whether asked for or not. This breaks installs. The following +# changes the value of $src to $src.exe if $src is missing + + if [ -f $src ] + then + true + elif [ -f $src.exe ] + then + echo "install: $src does not exist, trying with .exe appended" + src="$src".exe + fi + +# end CYGNUS LOCAL noer + +# 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 + + # CYGNUS LOCAL: Use exeext + case "`basename $dst`" in + *.*) ;; + *) dst="$dst$exeext" ;; + esac + # END CYGNUS LOCAL +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/libiberty/COPYING.LIB b/libiberty/COPYING.LIB new file mode 100644 index 000000000000..eb685a5ec981 --- /dev/null +++ b/libiberty/COPYING.LIB @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, 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 library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, 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 companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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. + + + Copyright (C) + + This library 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 of the License, 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog new file mode 100644 index 000000000000..265acc49a4e4 --- /dev/null +++ b/libiberty/ChangeLog @@ -0,0 +1,2233 @@ +Tue Aug 19 20:28:45 1997 Geoffrey Noer + + * config/mh-cygwin32: also build random.o + +Tue Aug 19 17:10:56 1997 Jason Merrill + + * cplus-dem.c: Add 'extern' to prepends_underscore. + +Wed Jul 30 11:42:19 1997 Per Bothner + + * cplus-dem.c: Various changes to produce Java output when passed + DMGL_JAVA. Thus "::" becomes "." and "JArray" becomes "Foo[]". + (main): Support --java and -j flags to set DMGL_JAVA. + +Tue Jul 22 19:05:23 1997 Robert Hoehne + + * config/mh-go32 (CC, AR, RANLIB): Don't define. + +Tue Jul 22 17:49:54 1997 Ian Lance Taylor + + * Makefile.in (REQUIRED_OFILES): Add pexecute.o. + (pexecute.o): New target. + + * Makefile.in (stamp-needed): New target, replacing needed-list. + (needed-list): Just depend upon stamp-needed. + (stamp-config): New target, replacing config.h. + (config.h): Just depend upon stamp-config. + (mostlyclean): Remove stamp-*. + +Thu Jun 12 11:00:18 1997 Angela Marie Thomas (angela@cygnus.com) + + * Makefile.in (FLAGS_TO_PASS): pass INSTALL, INSTALL_PROGRAM and + INSTALL_DATA for multilibbed installs + +Tue Jun 3 13:21:05 1997 Doug Evans + + Tue Dec 10 09:44:57 1996 Paul Eggert + + * choose-temp.c (choose_temp_base): Don't dump core if TMPDIR is empty. + + * choose-temp.c (try): Insist that temp dir be searchable. + + Wed Oct 23 17:36:39 1996 Doug Rupp (rupp@gnat.com) + + * choose-temp.c (choose_temp_base): On VMS, use proper syntax + for current directory. + + Sat Feb 15 19:03:48 1997 Geoffrey Noer (noer@cygnus.com) + + * pexecute.c: Remove special cases for cygwin32. + (pwait): Remove local definition of `pid'. + + Tue Nov 12 18:26:15 1996 Doug Rupp (rupp@gnat.com) + + * pexecute.c (vfork): Supply new definition for VMS. + (pwait): Use waitpid instead of wait for VMS. + +Tue May 20 14:02:20 1997 Brendan Kehoe + + * cplus-dem.c (do_type): Handle `J'. + (demangle_fund_type): Print "complex" for it. + +Wed Apr 30 12:15:45 1997 Jason Merrill + + * configure.in: Don't turn on multilib here. + +Mon Apr 28 19:04:31 1997 Michael Snyder + + * obstack.c: move _obstack_memory_used outside of ifdef. Cannot be + elided; needed by gdb and not present in libc. + +Thu Apr 24 19:33:47 1997 Ian Lance Taylor + + * Makefile.in (clean): Remove tmpmulti.out. + +Tue Apr 22 10:25:15 1997 Fred Fish + + * floatformat.c (floatformat_ieee_double_littlebyte_bigword): + Add new floatformat, mainly for ARM doubles. + +Mon Apr 14 12:11:16 1997 Ian Lance Taylor + + * config.table: Use ${config_shell} with ${moveifchange}. From + Thomas Graichen . + +Fri Apr 4 03:09:24 1997 Ulrich Drepper + + * configure.in: Enable multilibing by default. + Update multilib template to read config-ml.in. + +Tue Apr 1 16:26:39 1997 Klaus Kaempf + + * makefile.vms: Add objalloc. + +Mon Mar 31 23:57:51 1997 H.J. Lu + + * cplus-dem.c (demangle_it): Add prototype declaration. + (usage, fatal): Likewise. + + * xexit.c (_xexit_cleanup): Add prototype. + + * strerror.c (init_error_tables): Declare. + +Fri Mar 28 11:43:20 1997 H.J. Lu + + * functions.def: Add DEF of vasprintf, and DEFFUNC of strsignal. + * strsignal.c: Only define strsignal if NEED_strsignal. + * Makefile.in (REQUIRED_OFILES): Remove vasprintf.o. + * configure.in: Add NEED_strsignal to xconfig.h. Add vasprintf.o + to xneeded-list. + * config/mh-cygwin32 (HDEFINES): Add -DNEED_strsignal. + (EXTRA_OFILES): Define to vasprintf.o. + * config/mh-windows (HDEFINES): Add -DNEED_strsignal. + (EXTRA_OFILES): Add vasprintf.o. + * config/mt-vxworks5 (vxconfig.h): Define NEED_strsignal. + (vxneeded-list): Add vasprintf.o. + +Thu Mar 20 17:02:09 1997 Ian Lance Taylor + + * objalloc.c: Include . + +Mon Mar 17 19:23:11 1997 Ian Lance Taylor + + * objalloc.c: New file. + * Makefile.in (CFILES): Add objalloc.c + (REQUIRED_OFILES): Add objalloc.o. + (objalloc.o): New target. + +Sat Mar 15 18:49:41 1997 Ian Lance Taylor + + * obstack.c: Update to current FSF version. + +Fri Mar 14 14:18:47 1997 Ian Lance Taylor + + * cplus-dem.c: Add prototypes for all static functions. + (mystrstr): Make static. Make arguments and result const. + (cplus_match): Remove; not used. + +Tue Mar 11 14:20:31 1997 Brendan Kehoe + + * cplus-dem.c (gnu_special): Call demangled_fund_type for other + __t* symbols. + +Tue Mar 11 15:41:21 1997 H.J. Lu + + * spaces.c: Declare malloc and free properly. + * strsignal.c (init_signal_tables): Add prototype. + * xatexit.c (_xexit_cleanup): Add parameter declarations. + +Wed Feb 19 15:43:24 1997 Brendan Kehoe + + * Makefile.in (lneeded-list): If alloca.o is needed, xexit.o is + also required because of xmalloc.o. + +Fri Feb 14 13:43:38 1997 Ian Lance Taylor + + * strsignal.c: Unconditionally redefine sys_siglist around the + inclusion of the system header files. + +Thu Feb 13 22:01:04 1997 Klaus Kaempf + + * makefile.vms: Remove 8 bit characters. Update to latest + gcc release. + +Tue Feb 4 11:52:19 1997 Ian Lance Taylor + + * strsignal.c: Use NEED_sys_siglist instead of + LOSING_SYS_SIGLIST. + * config.table: Don't use mh-lynxos. + * config/mh-lynxos: Remove. + +Thu Jan 16 14:51:03 1997 Bob Manson + + * cplus-dem.c: Fix indenting; make identical to the copy + in GCC. + (do_type, case 'M'): Check for a template as well as a class. + +Thu Dec 19 13:51:33 1996 Brendan Kehoe + + * config/mt-vxworks5 (vxneeded-list): Remove sigsetmask.o, since + vxworks 5.[0-3] all have sigsetmask in them; the one provided by + libiberty is incorrect, as well. + +Mon Dec 2 15:03:42 1996 Michael Meissner + + * alloca.c (alloca): When compiled with an ANSI/ISO compiler, + alloca takes a size_t argument, not just unsigned. + +Mon Nov 18 15:42:08 1996 Jason Merrill + + * cplus-dem.c: Note that this file also lives in GCC. + +Mon Nov 18 15:19:00 1996 Dawn Perchik + + * alloca.c: Remove include of libiberty.h for hpux. + * argv.c: Replace defs from libiberty.h. + * spaces.c: Put back externs from removed from libiberty.h. + * vasprintf.c: Remove include of libiberty.h for hpux. + +Mon Nov 18 14:08:00 1996 Dawn Perchik + + * cplus-dem.c: Checking in again; last checkin filed due to sticky tag. + +Wed Nov 13 08:22:00 1996 Dawn Perchik + + * cplus-dem.c: Revert last two commits due to conflicts with + hpux system headers. + +Wed Nov 13 08:22:00 1996 Dawn Perchik + + * alloca.c, argv.c, spaces.c, strcasecmp.c, vasprintf.c, vprintf.c: + Revert last commit due to conflicts with hpux system headers. + +Wed Nov 13 10:36:50 1996 Michael Meissner + + * cplus-dem.c (x{m,re}alloc): Make declarations compatibile with + libiberty.h when compiled with a standard compiler. + +Tue Nov 12 16:31:00 1996 Dawn Perchik + + * alloca.c: Include libiberty.h for definition of xmalloc. + Don't redefine NULL. + * argv.c: Move prototypes to libiberty.h. + * cplus-dem.c: Include libiberty.h for definition of xmalloc. + Don't redefine NULL. + Use casts to eliminate compiler warnings. + * spaces.c: Remove prototypes for malloc and free which are + already in libibrty.h. + * strcasecmp.c: Use casts to eliminate compiler warnings. + * vasprintf.c: Include libiberty.h for definition of malloc. + Don't redefine NULL. + * vprintf.c: Include stdarg.h if __STDC__. + +Fri Oct 11 15:42:12 1996 Stu Grossman (grossman@critters.cygnus.com) + + * config/mh-windows: Add strcasecmp.o to EXTRA_OFILES. + +Fri Oct 11 11:16:31 1996 Stan Shebs + + * mpw.c (mpwify_filename): Rewrite to simplify, and to handle + upward components correctly. + +Tue Oct 8 08:55:34 1996 Stu Grossman (grossman@critters.cygnus.com) + + * config.table, config/mh-windows: Add support for building under + MSVC (the Microsoft build environment). + +Mon Oct 7 10:50:27 1996 Ian Lance Taylor + + * fnmatch.c: Undef const if not __STDC__. + +Thu Oct 3 13:46:39 1996 Ian Lance Taylor + + * fnmatch.c: New file. + * Makefile.in (CFILES): Add fnmatch.c. + (REQUIRED_OFILES): Add fnmatch.o. + (fnmatch.o): New target. + +Wed Sep 18 14:49:13 1996 Jason Merrill + + * cplus-dem.c (demangle_template): Fix handling of address args. + (gnu_special): Handle type_info stuff. + +Fri Sep 13 17:52:55 1996 Stan Shebs + + * mpw.c (DebugPI): Make settable from the env var DEBUG_PATHNAMES. + (mpwify_filename): Handle "::/" case. + +Thu Sep 12 13:30:40 1996 Geoffrey Noer + + * config/mh-cygwin32: new file (need -DNEED_basename and + -DNEED_sys_siglist for native NT rebuilding) + * config.table (*-*-cygwin32): new entry + * choose-temp.c: bring in sync with gcc (revert Aug 17 change) + +Thu Aug 29 16:48:45 1996 Michael Meissner + + * config.table (i[345]86-*-*): Recognize i686 for pentium pro. + +Tue Aug 27 13:47:58 1996 Stan Shebs + + * pexecute.c (pexecute) [MPW]: Remove old bogus code that + messed with arguments that included a '/', add escape chars + to double quotes, remove const decl from arg that Mac + compilers don't seem to like. + +Sat Aug 17 04:44:27 1996 Geoffrey Noer + + * pexecute.c: Update test for win32 (&& ! cygwin32). + * choose-temp.c: fix WIN32 preprocessor defines + +Thu Aug 15 12:26:48 1996 Stan Shebs + + * mpw-make.sed: Add @DASH_C_FLAG@ and @SEGMENT_FLAG({Default})@ + to editing of default makefile rule. + +Sun Aug 11 21:03:27 1996 Stu Grossman (grossman@critters.cygnus.com) + + * alloca-norm.h: Include if _WIN32. + * argv.c: Include non-prototyped decls for malloc and string + functions if ! _WIN32 or if __GNUC__. + +Thu Aug 8 12:42:40 1996 Klaus Kaempf + + * config.h-vms: New file. + * makefile.vms: Use it. + +Wed Aug 7 17:16:12 1996 Stu Grossman (grossman@critters.cygnus.com) + + * getopt.c (_getopt_internal): If argc is 0, just return (before + we reference *argv and segfault). + +Mon Aug 5 01:29:08 1996 Jason Merrill + + * Makefile.in (distclean): Add multilib.out. + +Thu Jul 18 17:40:55 1996 Ian Lance Taylor + + * alloca-norm.h: Change #ifdef sparc to #if defined (sparc) && + defined (sun). From Andrew Gierth . + +Mon Jul 1 13:40:44 1996 Ken Raeburn + + Tue May 28 15:29:03 1996 Pat Rankin + + * vmsbuild.com (REQUIRD_OFILES): Add choose-temp.o and xstrdup.o. + + Thu Jan 25 18:20:04 1996 Pat Rankin + + * vmsbuild.com: Changes to handle DEFFUNC(on_exit). + (do_ofiles): Allow nonexistent source file in pass 3. + (chk_deffunc): New routine. + +Tue Jun 25 19:24:43 1996 Doug Evans + + * pexecute.c (PEXECUTE_VERBOSE): Define. + (MPW pexecute): Check flags & PEXECUTE_VERBOSE instead of verbose_flag. + +Tue Jun 25 23:11:48 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (docdir): Removed. + +Tue Jun 25 23:01:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (oldincludedir): Removed. + +Tue Jun 25 22:50:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (datadir): Set to $(prefix)/share. + +Thu Jun 20 21:17:52 1996 Ian Lance Taylor + + * cplus-dem.c (demangle_arm_pt): Reindent. Avoid endless loop by + checking for errors from do_type. + +Tue Jun 18 14:36:19 1996 Klaus Kaempf + + * makefile.vms: New file. + * xmalloc.c: If VMS, include and rather + than declaring malloc, realloc, and sbrk. + +Mon Jun 10 13:17:17 1996 Doug Evans + + * pexecute.c: New file. + +Wed Jun 5 16:57:45 1996 Richard Henderson + + * xmalloc.c: Declare sbrk. + +Sat May 4 05:08:45 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * alloca-norm.h: Add SPARCworks cc compatible __builtin_alloca + declaration. + +Mon Apr 22 18:41:49 1996 Ian Lance Taylor + + * xstrerror.c: Include . + +Sun Apr 21 11:55:12 1996 Doug Evans + + * Makefile.in (CFILES): Add atexit.c. + +Sun Apr 21 09:50:09 1996 Stephen L Moshier (moshier@world.std.com) + + * choose-temp.c: Include sys/types.h before sys/file.h for sco3.2v5. + +Wed Apr 17 11:17:55 1996 Doug Evans + + * choose-temp.c: Don't #include sys/file.h ifdef NO_SYS_FILE_H. + #include + * config/mt-vxworks5 (HDEFINES): Define NO_SYS_FILE_H. + +Tue Apr 16 11:27:16 1996 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (lneeded-list): If alloca.o is needed, so is xmalloc.o. + Reverts Feb 8, 1995 change. + +Mon Apr 15 12:53:26 1996 Doug Evans + + * choose-temp.c: New file. + * Makefile.in (CFILES): Add choose-temp.c. + (REQUIRED_OFILES): Add choose-temp.o. + +Sat Apr 13 14:19:30 1996 Stu Grossman (grossman@critters.cygnus.com) + + * floatformat.c (floatformat_to_double): Don't bias exponent when + handling zero's, denorms or NaNs. + +Thu Apr 11 13:36:56 1996 Stu Grossman (grossman@critters.cygnus.com) + + * floatformat.c (floatformat_to_double): Fix bugs with handling + numbers with fractions < 32 bits. + +Mon Apr 8 14:48:34 1996 Ian Lance Taylor + + * config.table: Permit --enable-shared to specify a list of + directories. + +Tue Mar 19 22:02:07 1996 Jason Merrill + + * cplus-dem.c (demangle_template): Fix for non-mangled pointer + arguments. + +Fri Mar 8 17:24:18 1996 Ian Lance Taylor + + * configure.in: If srcdir is `.' and with_target_subdir is not + `.', then set MULTISRCTOP before calling config-ml.in. + +Thu Mar 7 13:37:10 1996 Stan Shebs + + * mpw.c (mpw_open): Add debugging output option. + +Wed Mar 6 17:36:03 1996 Jason Merrill + + * cplus-dem.c (demangle_template): Fix for address-of-extern arguments. + +Tue Feb 27 12:00:50 1996 Raymond Jou + + * mpw.c (mpwify_filename): Change 6 to 5 in + strncmp (unixname, "/tmp/", 5). + +Tue Feb 20 10:55:53 1996 Ian Lance Taylor + + * cplus-dem.c (demangle_template): Initialize is_bool. Correctly + handle 0 as a pointer value parameter. + +Mon Feb 5 16:41:44 1996 Ian Lance Taylor + + * Makefile.in (all): Depend upon required-list. + (required-list): New target. + (clean): Remove required-list. + +Wed Jan 31 10:19:41 1996 Steve Chamberlain + + * win32.c: Deleted. + * config.table (i386-*-win32): Deleted. + * config/mh-i386win32: Deleted. + +Thu Jan 18 11:34:17 1996 Ian Lance Taylor + + * cplus-dem.c (cplus_demangle_opname): Change opname parameter to + const char *. + (cplus_mangle_opname): Change return type and opname parameter to + const char *. Don't cast return value. + +Tue Jan 16 12:13:11 1996 Stan Shebs + + * mpw.c: Include Timer.h, in order to get m68k Microseconds trap + definition. + +Wed Jan 3 13:15:04 1996 Fred Fish + + * obstack.c: Update copyright to 1996. + (_obstack_memory_used): Define new function. Called via + obstack_memory_used macro. + +Thu Dec 28 11:39:40 1995 Ian Lance Taylor + + * xstrdup.c: New file. + * Makefile.in (CFILES): Add xstrdup.c. + (REQUIRED_OFILES): Add xstrdup.o. + (xstrdup.o): New target. + +Mon Dec 11 18:18:52 1995 Mike Stump + + * atexit.c: New stub to provide atexit on systems that have + on_exit, like SunOS 4.1.x systems. + * functions.def (on_exit, atexit): Ditto. + +Mon Dec 11 15:42:14 1995 Stan Shebs + + * mpw.c (mpw_abort): Remove decl. + (mpw_access): Move debugging printf. + +Sat Dec 2 01:25:23 1995 Ian Lance Taylor + + * config.table: Consistently use ${host} rather than ${xhost} or + ${target}. + * configure.in: Don't bother to set ${xhost} before calling + config.table. + +Tue Nov 28 14:16:57 1995 Brendan Kehoe + + * Makefile.in (.c.o): Use test instead of the left bracket, to + avoid problems with some versions of make. + +Tue Nov 28 11:45:17 1995 Stan Shebs + + * mpw-make.sed: Fix INCDIR edit to work with Nov 14 change. + +Tue Nov 21 11:26:34 1995 Fred Fish + + * config/mh-hpux: Remove. It was only used to define EXTRA_OFILES, + which was set to just alloca.o, which is now automatically marked + as needed by the autoconfiguration process. + +Tue Nov 21 14:15:06 1995 Ian Lance Taylor + + * config.table: Check ${with_cross_host} rather than comparing + ${host} and ${target}. + +Thu Nov 16 14:34:42 1995 Ian Lance Taylor + + * configure.in: If with_target_subdir is empty, set xhost to + ${host} rather than ${target} before calling config.table. + +Tue Nov 14 01:38:30 1995 Doug Evans + + * Makefile.in (MULTITOP): Deleted. + (MULTISRCTOP, MULTIBUILDTOP): New. + (FLAGS_TO_PASS): Delete INCDIR. + (INCDIR): Add $(MULTISRCTOP). + (install_to_libdir): Add $(MULTISUBDIR). Call $(MULTIDO). + * configure.in: Delete call to cfg-ml-com.in. Call config-ml.in + instead of cfg-ml-pos.in. + (cross-compile check): Change to test for with_target_subdir. + (EXTRA_LINKS): Delete. + +Sun Nov 12 12:13:04 1995 Stan Shebs + + * mpw-make.sed: Add getpagesize.c.o to needed-list. + * mpw.c [USE_MW_HEADERS]: Conditionalize compiling of + functions that are supplied by Metrowerks libraries. + (fstat): Clean up descriptor->pointer conversion code. + (InstallConsole, etc): Empty definitions, for when linking + with SIOUX. + +Sun Nov 5 19:25:27 1995 Per Bothner + + * Makefile.in (FLAGS_TO_PASS): Also pass PICFLAGS. + (.c.o): Stylistic change. + +Thu Nov 2 12:06:29 1995 Ian Lance Taylor + + * strtol.c, strtoul.c: Don't include . From + phdm@info.ucl.ac.be (Philippe De Muyter). + +Wed Nov 1 11:59:36 1995 Ian Lance Taylor + + * configure.in: Correct sed call. + +Mon Oct 30 13:03:45 1995 Per Bothner + + * configure.in: Clean up / simplify for native. + + * configure.in: Merge in stuff from ../xiberty/configure.in. + * Makefile.in (CC): Add definition (so it can be overrridden + by ../configure). + +Tue Oct 24 17:57:27 1995 Stan Shebs + + * mpw-make.sed: Leave strerror.c.o in standard list of functions. + * mpw.c (R_OK, ENOENT, EACCESS, ENOSYS): Remove. + (link): Remove useless definition with error return. + (last_microseconds, warn_if_spin_delay, record_for_spin_delay): + Use UnsignedWide type for microsecond counts. + +Thu Oct 19 10:52:07 1995 Michael Meissner + + * memcmp.c (memcmp): Argument types are const void *, not void + *const. + + * strncasecmp.c (strncasecmp): Include ansidecl.h/stdarg.h, not + sys/types.h. + * strcasecmp.c (strcasecmp): Ditto. + +Tue Oct 10 11:03:24 1995 Fred Fish + + * Makefile.in (BISON): Remove macro. + +Tue Sep 26 15:06:46 1995 Stan Shebs + + * Makefile.in (HFILES): Add default empty definition. + * mpw-config.in (config.h): Only update if changed. + * mpw-make.in: Remove. + * mpw-make.sed: New file, edits Makefile.in into MPW makefile. + * mpw.c: Remove semi-clone of strerror code. + (sys_nerr, sys_errlist): Define here. + (Microseconds): Only define as A-line trap if m68k Mac. + +Wed Sep 20 12:53:32 1995 Ian Lance Taylor + + * Makefile.in (maintainer-clean): New synonym for distclean. + +Mon Aug 28 19:47:52 1995 Per Bothner + + * config.table: For host, generalize rs6000-ibm-aix* + to *-ibm-aix* so we also include powerpc. + +Tue Aug 22 03:18:05 1995 Ken Raeburn + + Fri Jun 16 18:35:40 1995 Pat Rankin (rankin@eql.caltech.edu) + + * xstrerror.c: New file. + * Makefile.in, vmsbuild.com: Compile it. + +Mon Jul 31 12:16:32 1995 steve chamberlain + + * config.table (i386-*-win32): New. + +Fri Jul 21 11:35:52 1995 Doug Evans + + * Makefile.in (MULTITOP): New variable. + (MULTIDIRS, MULTISUBDIR, MULTIDO, MULTICLEAN): Likewise. + (all): Add multilib support. + (install_to_tooldir, *clean): Likewise. + +Mon Jul 10 11:47:27 1995 Ken Raeburn + + * makefile.dos (OBJS): Add hex.o. From DJ Delorie. + +Fri Jun 30 17:28:59 1995 Pat Rankin (rankin@eql.caltech.edu) + + * vmsbuild.com: create "new-lib.olb", build libiberty under that + name, and then make it become "liberty.olb" when done, so that an + incomplete build attempt never leaves behind something which looks + like a complete library. + +Thu Jun 29 00:22:02 1995 Steve Chamberlain + + * config/mh-i386pe: New file for PE hosts. + * config.table: Understand PE hosts. + +Wed Jun 28 19:13:23 1995 Jason Merrill + + * cplus-dem.c: Update from gcc. + + * argv.c, dummy.c: If __STDC__, #include "alloca-conf.h" after + . + * alloca-norm.h: If __STDC__, declare alloca with its parameter. + +Thu Jun 22 18:57:47 1995 Stan Shebs + + * mpw-make.in (ALL_CFLAGS): Define NEED_basename. + * mpw.c: Only test DebugPI once whenever printing debug info. + (mpwify_filename): If filename is /tmp/foo, change it into :_foo, + also fix to not write on input filename buffer. + (mpw_access): Use stat() instead of open(), works for directories + as well as files. + +Mon Jun 19 00:33:22 1995 Jason Merrill + + * Makefile.in: Massage broken shells that require 'else true'. + +Sat Jun 17 23:21:58 1995 Fred Fish + + * alloca-norm.h: Declare alloca as type "PTR" to match functions.def. + Declare __builtin_alloca in the sparc case, as argv.c did. + * argv.c: Replace inline version of alloca-norm.h at start of file with + a #include of alloca-conf.h. Precede it with an include of ansidecl.h + because alloca-norm.h needs to declare alloca as "PTR". + +Mon Jun 12 14:24:26 1995 Steve Chamberlain + + * win32.c: New file. + +Fri Jun 9 15:16:14 1995 Jason Merrill + + * dummy.c: #include "alloca-conf.h". + +Wed Jun 7 11:46:23 1995 Jason Merrill + + * Makefile.in (mostlyclean): Remove stamp-picdir. + (clean): Don't. + +Mon Jun 5 18:46:06 1995 Jason Merrill + + * config.table (frags): Use toplevel pic frags. + + * Makefile.in (PICFLAG): New macro. + (all): Depend on stamp-picdir. + (needed-list): Ditto. + (.c.o): Also build pic object. + (stamp-picdir): New rule. + (mostlyclean): Remove pic. + (clean): Remove stamp-picdir. + +Fri Mar 24 16:55:48 1995 Pat Rankin (rankin@eql.caltech.edu) + + * vmsbuild.com (config.h): Add `#define NEED_basename'. + +Tue May 23 10:12:46 1995 Per Bothner + + * clock.c, getopt.c, strtod.c, vsprintf.c: Change from using LGPL + to libio-style copyright. + * getpagesize.c: Remove FSF copyright. + +Sat May 20 12:30:23 1995 Ken Raeburn + + Added improved VMS support from Pat Rankin: + + Fri Mar 17 18:40:36 1995 Pat Rankin (rankin@eql.caltech.edu) + + * vmsbuild.com: new file. + + * getpagesize.c (getpagesize): implement for VMS; + * strerror.c (strerror, strerrno, strtoerrno): add rudimentary + support for EVMSERR. + +Thu May 18 17:01:42 1995 Ken Raeburn + + Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk) + + * floatformat.c (floatformat_arm_ext): Define. + +Tue May 16 13:30:59 1995 Per Bothner + + * basename.c, bcmp.c, getcwd.c, insque.c, rename.c, sigsetmask.c, + strerror.c, strsignal.c: Remove FSF copyright. + * sigsetmask.c: #include - seems to be needed by ISC. + +Mon May 15 19:53:17 1995 Per Bothner + + * bcopy.c, bzero.c, memcmp.c, memcpy.c, memset.c, strchr.c, + strrchr.c, strstr.c, vfork.c: Remove FSF Copyright, because this + might contaminate libstdc++ with the LGPL. (OK'd by RMS 11 Oct 94.) + * strchr.c, strrchr.c: Add cast to suppress const warning. + +Thu May 4 14:36:42 1995 Jason Merrill + + * cplus-dem.c: Use const instead of CONST. Don't include + ansidecl.h directly. + +Wed Apr 19 01:30:27 1995 Jason Merrill + + * cplus-dem.c: Don't include libiberty.h. Do declare xmalloc and + xrealloc. + (-DMAIN): Don't rely on an externally-defined version number; + instead, require the version number to be defined as a + preprocessor macro. Handle the RS/6000 leading dot. Define + xmalloc, xrealloc and fatal. Don't strip a leading underscore + if we couldn't demangle the word. + +Tue Apr 4 13:03:51 1995 Stan Shebs + + (Old mpw.c change descriptions retained for informational value.) + * mpw.c (warning_threshold): Default to .4 sec. + (overflow_count, current_progress): New globals. + (warn_if_spin_delay): Include current progress type, + such as program name, in message. + (mpw_start_progress): Set current_progress variable from arg. + (mpw_end_progress): Report spin delays by power-of-two-size + buckets instead of constant-size buckets. + + * mpw.c: Clean up formatting, types, returns, etc. + (ENOSYS): Define. + (mpw_fread, mpw_fwrite): Define. + (sleep): Define correctly. + + * mpw.c: New code to implement cursor spinning support. + (umask): New function. + (mpw_fopen, mpw_fseek, stat, fstat): Call PROGRESS. + + * mpw.c (mpw_basename, mpw_mixed_basename): New functions, find + basenames for MPW and MPW/Unix filenames. + (mpw_special_init): New function, calls Macsbug if desired. + + * mpw.c: Add GPL notice. + (mpwify_filename): Add more transformations. + (mpw_fopen): Call mpwify_filename on file names. + (rename): Remove. + (chdir, getcwd): Add simple definitions. + + * mpw.c: Random cleanups, remove unused code bits. + Added copy of strerror.c for gcc's use. + (stat, fstat, _stat): New versions based on Guido van Rossum code. + + * mpw.c (mpw_fseek): Make it work correctly when doing SEEK_CUR. + + * mpw.c (stat): Remove hack definition, get from sys/stat.h. + (fork, vfork, etc): Print error messages if called. + (getrusage, sbrk, environ, isatty, link, utime, mkdir, rmdir, + rename, chown): Define. + + * mpw-config.in: New file, MPW version of configure.in. + * mpw-make.in: New file, MPW version of Makefile.in. + * mpw.c: New file, MPW compatibility routines. + +Fri Mar 24 14:10:30 1995 Jim Kingdon (kingdon@lioth.cygnus.com) + + * basename.c: Include config.h before checking for NEED_basename. + +Thu Mar 23 19:09:54 1995 Jason Merrill + + * functions.def: Add DEFFUNC for basename. + + * basename.c: Only define basename if NEED_basename. + +Thu Mar 16 13:36:05 1995 Jason Merrill + + * config.table: Fix --enable-shared logic for native builds. + +Mon Mar 13 11:05:11 1995 Jason Merrill + + * cplus-dem.c (demangle_template): Demangle bool literals properly. + +Mon Mar 6 23:57:28 1995 Stu Grossman (grossman@cygnus.com) + + * strtol.c strtoul.c: Replace these with less buggy versions from + NetBSD. (strtoul in particular couldn't handle base 16.) + +Wed Mar 1 15:59:01 1995 Ian Lance Taylor + + * config/mt-vxworks5 (HDEFINES): Define NO_SYS_PARAM_H. + + * clock.c: If NO_SYS_PARAM_H is defined, don't include + . + * getcwd.c, getpagesize.c, getruntime.c: Likewise. + +Fri Feb 17 15:40:55 1995 Ian Lance Taylor + + * getruntime.c (get_run_time): Don't assume that CLOCKS_PER_SEC is + a number; ANSI appears to permit any expression, including a + function call. + + * config.table (*-*-vxworks5*): Use mt-vxworks5 when configuring + xiberty. + * config/mt-vxworks5: New file. + +Thu Feb 9 14:19:45 1995 Ian Lance Taylor + + * basename.c (basename): Change argument to be const. + +Wed Feb 8 18:06:52 1995 Jason Merrill + + * Makefile.in (lneeded-list): Don't worry about xmalloc. + +Sun Jan 15 00:40:36 1995 Jeff Law (law@snake.cs.utah.edu) + + * Makefile.in (distclean): Delete xhost-mkfrag. + +Thu Jan 12 16:54:18 1995 Jason Merrill + + * Makefile.in (lneeded-list): If alloca.o is needed, so is xmalloc.o. + +Wed Jan 11 22:39:56 1995 Ken Raeburn + + * hex.c: New file. + * Makefile.in (REQUIRED_OFILES, CFILES): List it. + (hex.o): Add dependencies. + + * cplus-dem.c (demangle_prefix): For GNU style constructor and + destructor names, try demangling the remainder of the string. + +Wed Dec 28 00:49:15 1994 Ian Lance Taylor + + * vasprintf.c (int_vasprintf): New static function. + (vasprintf): Use int_vasprintf. Removes assumption that va_list + is assignment compatible. + +Sat Nov 5 19:29:12 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (LIBCFLAGS): New variable. + (FLAGS_TO_PASS): Pass it. + (.c.o): Use it. + +Thu Nov 3 19:09:47 1994 Ken Raeburn + + * getopt.c, getopt1.c: Do compile these functions under Linux, + since many native versions are based on glibc but are buggy. + +Mon Oct 24 15:16:46 1994 Per Bothner + + * vasprintf.c: Make 'format' arg be const, to avoid a mismatch + with prototype in GNU libc. Support stdarg.h as well as varargs.h. + +Tue Oct 11 17:48:27 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (REQUIRED_OFILES): Add vasprintf.o. + * functions.def: Remove vasprintf. + +Wed Sep 14 17:04:55 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * xmalloc.c (first_break): New static variable. + (xmalloc_set_program_name): Record sbrk (0) in first_break. + (xmalloc): If memory allocation fails, try to report how much + memory was allocated by the program up to this point. + (xrealloc): Likewise. + +Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org) + + * Makefile.in (ERRORS_CC): New variable, defaulted to $(CC). Use it + when linking dummy. + * config.table: Add host RISCiX Makefile frag. + * config/mh-riscix: New file. + +Thu Aug 25 17:29:44 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * Makefile.in (FLAGS_TO_PASS): Define. + ($(RULE1)): Use $(FLAGS_TO_PASS). + +Wed Aug 24 17:08:47 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * vasprintf.c: Include . + (vasprintf): Add casts to void for va_arg to avoid gcc warnings. + * xatexit.c: Declare malloc. + +Fri Aug 19 15:29:12 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (demangle_args): Fix a bug in previous patch (the + one below). + +Thu Aug 18 14:37:14 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (demangle args): Handle ARM repeat encoding where + the type index is greater than 9. + +Wed Aug 17 16:13:49 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (demangle_qualified): accept optional '_' between + qualified name. This is baecause the template name may end with + numeric and can mixed up with the length of next qualified name. + +Wed Aug 3 05:52:14 1994 D. V. Henkel-Wallace (gumby@cygnus.com) + + * config/mt-sunos4: Use our standard location for cross-includes + and cross-libs when the target is also a "host" environment (ie no + newlib; includes and such don't belong to us). This is specific + to the Cygnus Support environment. + +Tue Aug 2 15:25:12 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (demangle_template): demangle as xxx<'Q'> not + xxx. + +Mon Aug 1 17:02:48 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (main): flush stdout to make pipe work. + +Sat Jul 16 12:56:32 1994 Stan Shebs (shebs@andros.cygnus.com) + + * config.table (*-*-cxux7*): Recognize. + * floatformat.c (floatformat_m88110_ext) [HARRIS_FLOAT_FORMAT]: + Harris-specific float format. + * config/mh-cxux7: New file. + +Wed Jun 29 00:26:17 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * cplus-dem.c (demangle_template): Make sure that the result of + consume_count doesn't index beyond the end of the string. + +Mon Jun 20 23:54:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * cplus-dem.c (gnu_special): Handle vtable mangling of gcc-2.4.5 and + earlier. Improve test for new vtable mangling. Change output back + to `virtual table'. + +Mon Jun 20 11:37:30 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * obstack.c: Always compile this code, even if using the GNU + library. Avoids problems with relatively recent binary + incompatibility. + +Thu Jun 16 17:54:01 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * cplus-dem.c: Include libiberty.h. + (xmalloc, xrealloc, free): Don't declare. + (strstr): Don't declare parameters. + (xmalloc, xrealloc): Don't define. + (long_options): Add no-strip-underscores. + (main): Call xmalloc_set_program_name. Pass n in short options to + getopt_long. Handle option 'n' to not strip underscores. + (usage): Mention -n and --no-strip-underscores. + +Sun Jun 12 01:37:09 1994 Jason Merrill (jason@deneb.cygnus.com) + + * cplus-dem.c (demangle_template): Separate consecutive >'s with a + space. + (gnu_special): Demangle template and qualified names in a vtable name. + +Fri May 27 12:27:52 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + From gas-2.3 and binutils-2.4 net releases: + + Wed May 11 22:32:00 1994 DJ Delorie (dj@ctron.com) + + * makefile.dos: [new] Makefile for dos/go32 + * configure.bat: update for latest files + * msdos.c: remove some functions now in libc.a + +Fri May 20 18:53:32 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * cplus-dem.c (gnu_special): Recognize thunks, as well as + the new naming style for vtables (when -fvtable-thunks). + +Wed May 18 13:34:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (XTRAFLAGS): Don't define. + (.c.o, dummy.o): Don't use XTRAFLAGS. + ($(RULE1)): Don't pass XTRAFLAGS down in recursive call. + +Fri May 13 16:02:12 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * vasprintf.c: New file. + * Makefile.in, functions.def: Add it. + +Fri May 13 16:20:28 1994 Jason Merrill (jason@deneb.cygnus.com) + + * cplus-dem.c (demangle_fund_type): Grok bool. + +Fri May 6 14:44:21 1994 Steve Chamberlain (sac@cygnus.com) + + * config.table: Add go32 + * config/mh-go32: New template. + +Fri May 6 11:01:59 1994 D. V. Henkel-Wallace (gumby@rtl.cygnus.com) + + * config.table, config/mt-sunos4: config for when sun4 is cross target. + +Mon Apr 11 00:54:33 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu) + + * getopt.c [not __GNU_LIBRARY__] [__GCC__] [not __STDC__]: + Declare strlen to return int. Don't include stddef.h. + +Fri Apr 1 00:38:17 1994 Jim Wilson (wilson@mole.gnu.ai.mit.edu) + + * getopt.c: Delete use of IN_GCC to control whether + stddef.h or gstddef.h is included. + +Thu Apr 14 14:00:56 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (demangle_signature): Fix a bug in template function + type numbering. + +Wed Apr 13 17:23:03 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (demangle_signature): Fix template function with arm + style argument type number, Tn. + +Wed Apr 13 17:11:15 1994 Jason Merrill (jason@deneb.cygnus.com) + + * cplus-dem.c (optable): Add new[] and delete[]. + +Fri Apr 8 11:21:42 1994 Jim Kingdon (kingdon@deneb.cygnus.com) + + * argv.c (buildargv): Don't produce empty argument just because + there is trailing whitespace. + +Wed Apr 6 11:42:14 1994 Kung Hsu (kung@mexican.cygnus.com) + + * cplus-dem.c (demangle_template): fix 'Q' qualified name bug. + Handle 'p' same as 'P'. + * cplus-dem.c (do_type): Handle 'p' same as 'P'. + +Sat Mar 26 12:00:13 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * floatformat.c (get_field, put_field): Fix off by one error in + little endian case. + +Thu Mar 24 10:40:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * floatformat.c (floatformat_from_double): Pass unsigned char *, + not char *, to put_field. + +Fri Mar 18 12:34:33 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * memmove.c: Re-wrote; placed in public domain. + +Wed Mar 16 10:33:07 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + + * cplus-dem.c (demangle_prefix): If ARM demangling, don't treat + __Q* as a constructor. + +Mon Mar 14 12:26:02 1994 Ian Lance Taylor (ian@cygnus.com) + + * ieee-float.c: Removed; no longer used. + * Makefile.in: Changed accordingly. + +Mon Mar 7 12:28:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * floatformat.c (get_field): Removed unused local variable i. + (put_field): Removed unused local variable i. + +Sun Feb 27 21:50:11 1994 Jim Kingdon (kingdon@deneb.cygnus.com) + + * floatformat.c: New file, intended to replace ieee-float.c. + * Makefile.in: Change accordingly. + +Thu Feb 24 11:51:12 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * getopt.c: Remove #ifdef GETOPT_COMPAT and #if 0 code. + (_getopt_initialize): New function, broken out of _getopt_internal. + (_getopt_internal): + 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. + +Thu Feb 10 14:44:16 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu) + + * getopt.c [not __GNU_LIBRARY__] [__GNUC__] [not IN_GCC]: + Test just __STDC__, not emacs. + +Wed Feb 9 00:14:00 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu) + + * getopt.c [not __GNU_LIBRARY__] [__GNUC__] [not IN_GCC] + [emacs] [not __STDC__]: Don't include stddef.h. Don't declare strlen. + +Fri Dec 24 19:43:00 1993 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu) + + * getopt.c (_NO_PROTO): Define before config.h is included. + +Mon Sep 20 15:59:03 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * getopt.c, getopt1.c [emacs || CONFIG_BROKETS]: Include + only under these, else "config.h". + +Thu Aug 12 18:16:49 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu) + + * getopt.c, getopt1.c [HAVE_CONFIG_H]: Include + instead of "config.h". + +Sun Feb 20 17:17:01 1994 Ian Lance Taylor (ian@lisa.cygnus.com) + + * concat.c: Check ANSI_PROTOTYPES rather than __STDC__ to decide + whether to use prototypes or not. + * strerror.c (const): Never undefine; let ansidecl.h handle it. + * strsignal.c (const): Likewise. + +Thu Feb 17 13:27:35 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * xatexit.c (_xexit_cleanup): Declare as extern; don't initialize. + Merging common and initialized variables need not be supported by + ANSI C compilers. + (xatexit): Initialize _xexit_cleanup if not already set. + * xexit.c: Comment fix. + +Wed Feb 16 01:15:36 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * xmalloc.c: Don't declare xexit; it's declared in libiberty.h. + (xrealloc): If oldmem is NULL, allocate with malloc, rather than + assuming that realloc works correctly. + +Tue Feb 15 09:26:16 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * concat.c, ieee-float.c: Replace inclusion of + with explicit function declarations, as recommended by Ian Taylor. + +Sat Feb 12 10:31:11 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * xmalloc.c (xmalloc, xrealloc): Use PTR and size_t throughout. + (malloc, realloc): Declare. + +Thu Feb 10 17:08:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * argv.c, basename.c: Include ansidecl.h and libiberty.h. + * concat.c, fdmatch.c, getruntime.c, spaces.c: Likewise. + * strerror.c, strsignal.c, xatexit.c, xexit.c: Likewise. + * xmalloc.c: Likewise. + * concat.c: Don't declare xmalloc. If __STDC__, use + macros, not macros. + * spaces.c (spaces): Make return type const. Don't crash if + malloc returns NULL. + * strerror.c (struct error_info): Make name and msg fields const. + (error_names): Make const. + (strerrno): Make const. + (strtoerrno): Make argument const. + * strsignal.c (struct signal_info): Make name and msg fields + const. + (signal_names, sys_siglist): Make const. + (strsignal, strsigno): Make const. + (strtosigno): Make argument const. + * xatexit.c: Declare parameter types. + * xmalloc.c (name): Make const. + (xmalloc_set_program_name): Make argument const. + * Makefile.in (INCDIR): Define. + (.c.o): Use $(INCDIR). + (dummy.o): Likewise. + (argv.o, basename.o): New targets; depend on libiberty.h. + (concat.o, fdmatch.o, getruntime.o, spaces.o): Likewise. + (strerror.o, strsignal.o, xatexit.o, xexit.o): Likewise. + (xmalloc.o): Likewise. + (cplus-dem.o): New target; depend on demangle.h. + (getopt.o, getopt1.o): New targets; depend on getopt.h. + (ieee-float.o): New target; depend on ieee-float.h. + (obstack.o): New target; depend on obstack.h. + +Tue Feb 8 05:29:08 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + Handle obstack_chunk_alloc returning NULL. This allows + obstacks to be used by libraries, without forcing them + to call exit or longjmp. + * obstack.c (_obstack_begin, _obstack_begin_1, _obstack_newchunk): + If CALL_CHUNKFUN returns NULL, set alloc_failed, else clear it. + (_obstack_begin, _obstack_begin_1): Return 1 if successful, 0 if not. + +Tue Feb 8 00:32:28 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * concat.c, ieee-float.c: Include . + +Sun Feb 6 21:28:46 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * xmalloc.c (xmalloc_set_program_name): New function. + (xmalloc, xrealloc): Include the name in the error message, if set. + + * Replace atexit.c with xatexit.c. + * Makefile.in (CFILES), functions.def: Change references. + +Sat Feb 5 14:02:32 1994 Stan Shebs (shebs@andros.cygnus.com) + + * getruntime.c (get_run_time): Use getrusage or times if + HAVE_GETRUSAGE or HAVE_TIMES are defined. + +Fri Feb 4 15:49:38 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * atexit.c: New file. + * Makefile.in (CFILES), functions.def: Add it. + * xexit.c: New file. + * Makefile.in (CFILES, REQUIRED_OFILES): Add it. + * xmalloc.c (xmalloc, xrealloc): Call xexit instead of exit. + Change request for 0 bytes into request for 1 byte. + +Wed Feb 2 11:36:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * xmalloc.c (xmalloc, xrealloc): Print size using %lu, and cast to + unsigned long, to avoid warnings. + +Fri Jan 28 17:49:06 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * dummy.c: Don't include time.h ever; always define clock_t as + "unsigned long". Until gcc/fixincludes ensures that clock_t + exists, __STDC__ isn't a sufficient test. And if clock() doesn't + exist, clock_t probably doesn't either. + +Mon Jan 24 11:52:31 1994 Stan Shebs (shebs@andros.cygnus.com) + + * clock.c, getruntime.c: New files. + * Makefile.in: Add to file lists. + * functions.def (clock): Add to list. + * dummy.c (time.h): Add if __STDC__. + (clock_t): #define as "unsigned long" if not __STDC__. + +Tue Jan 11 11:27:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * strtod.c: Declare atof. From edler@jan.ultra.nyu.edu (Jan + Edler). + +Tue Dec 28 14:17:30 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (errors): Use CFLAGS as well as LDFLAGS when + linking. + +Fri Dec 17 12:26:07 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c (demangle_arm_pt): New function. Common code + for ARM template demangling. + * cplus-dem.c (demangle_class_name): Use demangle_arm_pt. + * cplus-dem.c (demangle_prefix): Likewise. + +Tue Nov 30 15:47:48 1993 Jason Merrill (jason@deneb.cygnus.com) + + * cplus-dem.c (cplus_demangle_opname): Add CONST to please gcc. + +Sat Nov 27 11:05:50 1993 Fred Fish (fnf@cygnus.com) + + Merge changes from tom@basil.icce.rug.nl (Tom R.Hageman) + * strerror.c, strsignal.c: As a small space optimization, don't + include messages when they aren't actually used. + + Merge changes from takefive.co.at!joe (Josef Leherbauer) + * cplus-dem.c (demangle_prefix, demangle_function_name, + cplus_demangle_opname): Fixes for systems where cplus_marker + is something other than '$'. + +Fri Nov 26 13:51:11 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * waitpid.c: Simple-minded approcimation to waitpid + using vanilla wait. + * functions.def, Makefile.in: Update accordingly, + +Thu Nov 18 18:01:15 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c(demangle_template): fix bug template instantiation + with value of user defined type. + +Wed Nov 17 18:30:21 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c(cplus_demangle_opname): add the subject new function + to support unified search of operator in class. + +Wed Nov 10 09:47:22 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + gcc -Wall lint: + * strtoul.c (strtoul): use "(digit = *s) != '\0'" not just + "digit = *s" as condition in while loop. + +Tue Nov 9 15:52:22 1993 Mark Eichin (eichin@cygnus.com) + + * Makefile.in: pass SHELL to recursive make + +Thu Nov 4 12:09:26 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * vfprintf.c, vprintf.c, vsprintf.c: Make format arg + be (const char*), for ANSI (and gcc w/fixproto) consistency. + +Thu Nov 4 08:29:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.table: Make *-*-hiux* use mh-hpux. + +Fri Oct 22 07:53:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * config.table: Add * to end of all OS names. + +Tue Oct 19 17:12:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in (lneeded-list): ensure that object file names are + not duplicated, as multiple instances of the same object file in + a library causes problems on some machines + +Mon Oct 18 21:59:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * strcasecmp.c, strncasecmp.c: Change u_char to unsigned char. + +Fri Oct 15 22:17:11 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * strncasecmp.c: new file, implements strncasecmp + * strcasecmp.c: new file, implement strcasecmp + + * Makefile.in (CFILES): list these two new source files + + * functions.def: add strcasecmp and strncasecmp entries + +Fri Oct 15 14:53:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * strtoul.c (strtoul), strtol.c (strtol): Handle overflow + according to ANSI C. + +Thu Oct 14 16:34:19 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c: add support of ARM global constructor/destructor, + and 'G' for passing record or union in parameter. + +Wed Oct 13 13:36:19 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in: Fix comment to clarify that stuff in REQUIRED_OFILES + should not be in functions.def. + +Wed Oct 13 13:13:38 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * functions.def: Removed xmalloc. Stuff in REQUIRED_OFILES should + not be in functions.def. + +Mon Oct 4 18:26:39 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c: change globl constructor/destructor to proper name + +Tue Sep 28 18:11:07 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c: fix bug in constructor/destructor + +Tue Sep 28 16:20:49 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c: support both old and new _vt$... vtbl mangled names + +Fri Sep 24 19:07:16 1993 Jason Merrill (jason@deneb.cygnus.com) + + * cplus-dem.c: Fix demangle_template prototype + +Fri Sep 24 17:32:55 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * cplus-dem.c: fix template demangling + * cplus-dem.c: fix const type demangling + * cplus-dem.c: fix constructor/destructor, virtual table, + qualifier, global constructor/destructor demangling + +Wed Sep 1 23:13:11 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * strsignal.c, strerror.c: Use fully-bracketed initializer to + keep gcc -Wall happy. + +Fri Aug 27 10:30:09 1993 Jason Merrill (jason@deneb.cygnus.com) + + * cplus-dem.c (do_type): Add CONSTS to make gcc happy with last + patch. + +Fri Aug 27 11:24:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + Patch from Paul Flinders: + * cplus-dem.c (do_type): Deal with arrays. + +Tue Aug 24 14:23:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * cplus-dem.c (demangle_qualified: Deal with GNU format for more + than 9 classes. + +Wed Aug 18 19:50:29 1993 Jason Merrill (jason@deneb.cygnus.com) + + * Makefile.in (dummy.o): Redirect to /dev/null to avoid "variable + not initialized" warnings under HP/UX + +Sun Aug 15 20:42:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * strerror.c: Move include of stdio.h after sys_errlist #define. + Also remove NULL definition (stdio.h always defines NULL, so it + never did anything but clutter up the code). + +Sat Aug 14 14:21:49 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * Makefile.in, functions.def: handle xmalloc.c + + * xmalloc.c: provide xmalloc and xrealloc functions + +Thu Aug 12 17:38:57 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * cplus-dem.c: Fix a comment. + +Sat Aug 7 13:56:35 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * getopt1.c: Declare const the way getopt.c does. + +Fri Aug 6 17:03:13 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * obstack.c, alloca.c: Update from FSF. + * getopt.c, getopt1.c: Update to current FSF version, which + doesn't use alloca. + +Tue Jul 27 14:03:57 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Makefile.in (demangle): Add the target with a message saying + where demangle went. + +Mon Jul 26 15:49:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * Makefile.in: Remove obsolete `demangle' target. + +Thu Jul 22 08:31:01 1993 Fred Fish (fnf@deneb.cygnus.com) + + * cplus-dem.c (arm_special): Apply patch from arg@lucid.com to + avoid infinite loop on vtbl symbols with disambiguating "junk" + tacked on the end. + +Mon Jul 19 14:10:37 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * strsignal.c: work around some systems losing definitions of + sys_siglist + + * config/mh-lynxos: this system has a losing definition of + sys_siglist + + * config.table: use mh-lynxos for *-*-lynxos + +Mon Jul 19 17:08:52 1993 Ken Raeburn (raeburn@rtl.cygnus.com) + + * config.table: Add support for HPPA BSD hosts. + + * config/mh-hpbsd: New file. + +Mon Jul 12 18:00:40 1993 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in (TAGS): make work when srcdir != objdir. + +Sun Jun 27 15:35:31 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * cplus-dem.c (main): Add long options, including --help and + --version. + (usage): New function from code in main. + +Tue Jun 22 11:37:38 1993 Per Bothner (bothner@deneb.cygnus.com) + + * config.table: New shell scipt, sourced by both ./configure,in + and ../xiberty/configure.in, to avoid maintainance lossages. + * configure.in and ../xiberty/configure.in: Use config.table. + + * configure.in: Don't use mh-aix for AIX 3.2, only for 3.1. + * configure.in: Map *-*-irix* (except irix4) to mh-sysv. + * ../xiberty/configure.in: Update from ./configure.in. + +Tue Jun 15 17:05:31 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: remove parentdir support + +Wed May 26 12:59:09 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * cplus-dem.c (xrealloc): Match definition with prototype. + +Tue May 25 14:27:51 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * cplus-dem.c (demangle_prefix): Demangle cfront + local variables as an extension to ARM demangling. + +Fri May 21 09:53:57 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * ieee-float.c: Don't require pointers to double to be aligned. + +Tue May 18 17:12:10 1993 Fred Fish (fnf@cygnus.com) + + (merge changes from dlong@cse.ucsc.edu) + * cplus-dem.c (consume_count): Simplify. + * cplus-dem.c (arm_pt, demangle_class_name): New functions. + * cplus-dem.c (various): Calls to arm_pt, demangle_class_name. + + * cplus-dem.c (xmalloc, xrealloc, strstr): Make extern decls into + full prototypes. + * cplus-dem.c (free): Add prototype. + * cplus-dem.c (optable): Fully bracketize initializer. + +Fri May 14 17:13:05 1993 Per Bothner (bothner@cygnus.com) + + * cplus-dem.c: Whether initial underscores are stripped + depends on the external variable prepends_underscore + (which is generated by the binutils Makefile). + +Fri May 14 07:32:20 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * cplus-dem.c (mop_up, arm_special): Remove some unused variables. + +Tue May 4 20:31:59 1993 Fred Fish (fnf@cygnus.com) + + * cplus-dem.c (consume_count): Return zero if arg does not + start with digit, and don't consume any input. + +Tue May 4 08:10:28 1993 Jim Kingdon (kingdon@cygnus.com) + + * Makefile.in (demangle): Use ${srcdir} not $^. + + * strtod.c: New file, needed at least for BSD 4.3. + +Sun May 2 11:30:42 1993 Fred Fish (fnf@cygnus.com) + + * strsignal.c (sys_siglist): For ANSI compilations, type is + "const char *const". Also remove conditionalization on __STDC__ + since const is defined away for non-ANSI. + +Wed Apr 28 19:29:55 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * configure.in: Recognize *-*-hpux. + * config/mh-hpux: New file. + +Tue Apr 27 15:22:19 1993 Per Bothner (bothner@cygnus.com) + + * tmpnam.c: Added ANSI tmpnam() function. + * functions.def, Makefile.in: Update accordingly. + +Tue Apr 27 13:38:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * cplus-dem.c (demangle_function_name): Get the demangling of + stop__1A right. + +Fri Apr 16 23:48:24 1993 Jim Kingdon (kingdon at calvin) + + * cplus-dem.c: Declare strstr return type. + +Fri Mar 26 12:01:26 1993 Jim Kingdon (kingdon@cygnus.com) + + * strsignal.c: Add some AIX signals. + +Thu Mar 25 15:17:23 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (MAKEOVERRIDES): Define to be empty. + +Wed Mar 24 01:59:25 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com) + + * Makefile.in: add installcheck & dvi targets + +Thu Mar 18 14:05:44 1993 Per Bothner (bothner@rtl.cygnus.com) + + * ieee-float.c: New file, moved from ../gdb (since it is + needed by ../opcode/m68k-dis.c). + +Tue Mar 2 17:47:31 1993 Fred Fish (fnf@cygnus.com) + + * cplus-dem.c: Replace all references to cfront with ARM. + +Fri Feb 26 00:17:07 1993 Per Bothner (bothner@rtl.cygnus.com) + + * cplus-dem.c: Fix main program (when compiled with -DMAIN) + to be more useful as a filter. + +Sat Feb 20 21:41:39 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Makefile.in (install_to_libdir, install_to_tooldir): Go into the + destination directory before running $(RANLIB), in case that + program tries to create a file in the current directory as part of + its work. + +Thu Feb 18 23:00:19 1993 John Gilmore (gnu@cygnus.com) + + * strsignal.c (sys_siglist): Remove yet another *%^&%&$# "const" + because BSD 4.4 lacks one. Isn't this fun? + +Thu Feb 18 11:24:25 1993 Fred Fish (fnf@cygnus.com) + + * cplus-dem.c (demangle_signature): Set func_done after + demangling a template. + * cplus-dem.c (demangle_template): Fix several small bugs + in demangling GNU style templates. + * cplus-dem.c (demangle_prefix): Fix for templates in GNU + style constructors. + * cplus-dem.c (gnu_special): Fix for templates in GNU style + static data members. + +Tue Feb 16 17:28:35 1993 Fred Fish (fnf@cygnus.com) + + * cplus-dem.c (demangle_signature): Modify to include type + modifiers like static and const in remembered types. + +Thu Feb 11 22:20:47 1993 Fred Fish (fnf@cygnus.com) + + * cplus-dem.c (demangled_qualified): Add new parameter that tells + whether to prepend or append the qualifiers. + * cplus-dem.c (string_prepends): Used now, remove #if 0. + * cplus-dem.c (demangle_signature): Call demangle_qualified + with prepending. + * cplus_dem.c (gnu_special): Recognize static data members that + use qualified names. + * cplus-dem.c (demangle_qualified): Accumulate qualifiers in a + temporary buffer and the prepend or append them to the result, + as specified by the new "append" flag. + * cplus-dem.c (do_type): Call demangled_qualified with + appending. + +Mon Dec 28 10:47:19 1992 Ken Raeburn (raeburn@cygnus.com) + + * strsignal.c (signal_table): Now const. + (init_signal_tables): Variable eip now points to const. + + * strerror.c (error_table): Now const. + (init_error_tables): Variable eip now points to const. + +Tue Dec 15 15:36:50 1992 Per Bothner (bothner@cygnus.com) + + * memchr.c (memchr): New (ANSI standard) function. + * Makefile.in, functions.def: Added memchr. + * Makefile.in (AR_FLAGS): Use rc instad of non-standard cq. + +Wed Dec 2 22:49:10 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * getopt.c: remove use of USG around , which never meant + anything anyway + + * config/mh-{aix,apollo68,ncr3000,sysv,sysv4}: removed definitions + of USG and USGr4 + +Thu Nov 19 03:09:33 1992 Brendan Kehoe (brendan@lisa.cygnus.com) + + * cplus-dem.c (demangle_fund_type): Recognize `w', a wide character; + it's now a type according to the ANSI X3J16 working paper; output + "wchar_t" for it. + (demangle_template): Accept `w' as an integral type. + (xmalloc, xrealloc): Use `char *', not `PTR'. Cast calls to their + counterparts malloc and realloc to `char *'. + (main): Exit with a 0 status. + * Makefile.in (demangle): Don't expect the user to define + DEMANGLE, instead force to be cplus-dem.c. Look in $(srcdir)/../include + for demangle.h. Pass it any HDEFINES or XTRAFLAGS. + +Wed Nov 18 18:56:20 1992 John Gilmore (gnu@cygnus.com) + + * Makefile.in (AR_FLAGS): Avoid verbosity. + * config/mh-sysv4: Remove AR_FLAGS override, use INSTALL=cp, + replace USGr4 with HAVE_SYSCONF. + * config/mh-solaris: Remove; mh-sysv4 works now. + * getpagesize.c: Replace USGr4 with HAVE_SYSCONF. + * configure.in: Simplify host matching table, remove separate + solaris config file. + +Sun Nov 15 09:35:16 1992 Fred Fish (fnf@cygnus.com) + + * configure.in (i[34]86-*-solaris2*): Add, use mh-sysv4. + +Tue Nov 3 21:27:03 1992 Brendan Kehoe (brendan@cygnus.com) + + * cplus-dem.c (xmalloc, xrealloc): Add decls. + (remember_type): Don't cast xmalloc. + (string_need): Likewise; don't cast xrealloc either. + +Fri Oct 23 08:52:01 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in, functions.defs, rename.c: added simple + implementation of rename, since some binutils programs use it. + +Thu Oct 15 15:18:22 1992 Per Bothner (bothner@cygnus.com) + + * strsignal.c: Add appropriate 'const' to sys_siglist + extern declaration (if __STDC__). (Needed for Linux.) + * strsignal.c (strsignal): Add cast to remove const-ness. + +Fri Oct 9 03:22:55 1992 John Gilmore (gnu@cygnus.com) + + * Makefile.in (needed.awk, needed2.awk): Remove erroneous \'s + before "'s, diagnosed by BSD 4.4 awk. + +Thu Oct 8 15:25:12 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: create config.h and needed-list through $(CONFIG_H) + and $(NEEDED_LIST), to give some hooks for xiberty. + +Thu Oct 1 23:31:42 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: use cpu-vendor-triple instead of nested cases + +Wed Sep 30 11:26:59 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in, argv.c, basename.c, bcmp.c, bcopy.c, bzero.c, + concat.c, cplus-dem.c, fdmatch.c, getcwd.c, getopt.c, getopt1.c, + getpagesize.c, insque.c, memcmp.c, memcpy.c, memmove.c, memset.c, + obstack.c, sigsetmask.c, spaces.c, strchr.c, strerror.c, + strrchr.c, strsignal.c, strstr.c, vfork.c, vsprintf.c: + Convert from using GPL to LGPL. + +Sat Sep 26 04:01:30 1992 John Gilmore (gnu@cygnus.com) + + * Makefile.in (errors): Leave dummy.o and dummy around so that + we can see how the needed list was generated (it's sometimes wrong). + (mostlyclean): Remove them. + +Mon Sep 21 14:50:42 1992 Ian Lance Taylor (ian@cygnus.com) + + * getcwd.c: supply a default if MAXPATHLEN is not defined. + + * config/mh-irix4: set EXTRA_OFILES to alloca.o, from WRS. + +Wed Sep 9 12:41:48 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: Use XTRAFLAGS when compiling, so that xiberty works + when cross-compiling. + +Thu Sep 3 13:29:39 1992 K. Richard Pixley (rich@sendai.cygnus.com) + + * cplus-dem.c: (demangle_prefix): reduction in strength of strstr + as a time optimization. + + * cplus-dem.c (cplus_demangle): remove strpbrk test. Appears to + be more expensive than simply demangling. + + * cplus-dem.c (cplus_match): new function. + +Tue Sep 1 15:24:04 1992 Per Bothner (bothner@rtl.cygnus.com) + + * cplus-dem.c: #include , to define NULL. + Define current_demangling_style. + +Sun Aug 30 17:58:19 1992 Per Bothner (bothner@rtl.cygnus.com) + + * cplus-dem.c: New file, moved from ../gdb. + * cplus-dem.c (set_cplus_marker_for_demangling): New exported + function, to avoid compiling in target-dependency for CPLUS_MARKER. + * cplus-dem.c (cplus_demangle): Allow demangling style option + to be passed as a parameter, but using the global variable + current_demangling_style as a default. + * Makefile.in: Update for cplus-dem.c + +Sat Aug 29 10:44:09 1992 Fred Fish (fnf@cygnus.com) + + * obstack.c: Merge in comment changes from FSF version. Now + matches the FSF version exactly. + +Fri Aug 28 18:39:08 1992 John Gilmore (gnu@cygnus.com) + + * obstack.c (CALL_FREEFUN): Can't use ?: with void values (at + least on losing DECstations!); use if-then-else instead. + +Wed Aug 19 14:40:34 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: always create installation directories. + +Mon Aug 10 17:33:40 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: clean up definition of CFILES, more comments + +Sat Aug 8 23:10:59 1992 Fred Fish (fnf@cygnus.com) + + * getopt.c (my_index): Make first arg const to match strchr, + which it sometimes is remapped to. + +Sat Aug 1 13:48:50 1992 Fred Fish (fnf@cygnus.com) + + * obstack.c (DEFAULT_ALIGNMENT): Update to match FSF version. + * obstack.c (_obstack_begin): Initialize use_extra_arg. + * obstack.c (_obstack_begin_1): New, from FSF version. + +Mon Jul 20 21:07:58 1992 Fred Fish (fnf@cygnus.com) + + * obstack.c (CALL_CHECKFUN, CALL_FREEFUN): Use use_extra_arg and + extra_arg. + * obstack.c (_obstack_begin): Remove area_id and flags arguments + (previously added for mmalloc support, interface has changed). + Also convert flags usage to use use_extra_arg and maybe_empty_object. + +Fri Jul 10 00:41:53 1992 Fred Fish (fnf@cygnus.com) + + * argv.c: Move expandargv inline and eliminate static variables. + Rewrite to always allocate in powers of two. Fix to return an + argv with a single null string arg if passed a null string. + +Fri Jul 3 20:27:29 1992 Fred Fish (fnf@cygnus.com) + + * random.c, sigsetmask.c, strerror.c, strsignal.c: Remove + "(void)" casts from function calls where the return value is + ignored, in accordance with GNU coding standards. + +Mon Jun 29 10:54:19 1992 Fred Fish (fnf at cygnus.com) + + * bcopy.c, strerror.c, strsignal.c: Lint. + +Thu Jun 25 09:18:41 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * getopt.c: merge changes from make. + +Thu Jun 25 04:43:22 1992 John Gilmore (gnu at cygnus.com) + + * alloca.c: Incorporate fixes from gdb/alloca.c. + FIXME: Eventually move gdb's alloca configuration files here, + and remove gdb/alloca.c and its Makefile.in support. + +Tue Jun 23 21:56:30 1992 Fred Fish (fnf@cygnus.com) + + * dummy.c: Define NOTHING to /*nothing*/, change return type + of main to int and return zero. + * functions.def: Supply NOTHING as the fourth arg to macros + that don't have an explicit arg, to satisfy picky preprocessors. + +Wed Jun 17 18:13:58 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Clean up *clean rules, as per standards.texi. + +Tue Jun 16 16:11:59 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * getopt.c, getopt1.c: merged largely gratuitous, mostly + whitespace diffs from other prep distributions. + +Mon Jun 15 12:25:46 1992 Fred Fish (fnf@cygnus.com) + + * config/mh-ncr3000 (INSTALL): Don't use /usr/ucb/install, + it is broken on ncr 3000's. + +Mon Jun 15 01:03:26 1992 John Gilmore (gnu at cygnus.com) + + * sigsetmask.c: Rewrite. Old one was very confused about its + arguments and result. New one can't do much, but at least knows + what it can't do, and it's good enough for GDB's use. + +Sun Jun 14 15:17:40 1992 Stu Grossman (grossman at cygnus.com) + + * functions.def: Use proper prototype for strtoul. + +Fri Jun 12 19:22:40 1992 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Add random.c. + * config/mh-*: Use "true" rather than "echo >/dev/null" for ranlib. + * configure.in: update solaris2 config. + +Wed Jun 10 16:31:29 1992 Fred Fish (fnf@cygnus.com) + + * random.c: Add for random() and srandom(). + * functions.def: Add random + +Tue Jun 9 17:27:18 1992 Fred Fish (fnf@cygnus.com) + + * config/{mh-ncr3000, mh-sysv4}: Add definition for INSTALL + using /usr/ucb/install. + +Mon Jun 1 13:20:17 1992 Per Bothner (bothner@rtl.cygnus.com) + + * strerror.c: Kludge to guard against a conflict with + possible declaration of sys_errlist in errno.h. + +Sun May 31 15:07:47 1992 Mark Eichin (eichin at cygnus.com) + + * configure.in, config/mh-solaris: add solaris2 config support. + +Fri May 29 17:23:23 1992 Per Bothner (bothner@rtl.cygnus.com) + + * sigsetmask.c: #ifdef out sigsetmask if SIG_SETMASK + is not defined (should be defined in signal.h, says Posix.). + +Mon May 18 17:35:04 1992 K. Richard Pixley (rich@cygnus.com) + + * getopt.c: merged changes from make-3.62.11. + +Fri May 8 14:53:07 1992 K. Richard Pixley (rich@cygnus.com) + + * getopt.c: merged changes from bison-1.18. + +Tue May 5 11:51:40 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Don't have $(EXTRA_OFILES) depend on config.h, + since that introduces a circular dependency. + ($(EXTRA_OFILES) are used to build config.h.) + + * strtoul.c: Fixes to handle non-decimal bases better. + +Wed Apr 22 09:27:51 1992 Fred Fish (fnf@cygnus.com) + + * config/mh-ncr3000: Replace MINUS_G with CFLAGS. + * Makefile.dos: Finish MINUS_G eradication. + * Makefile.in (CFILES): Add strsignal.c. + * Makefile.in (REQUIRED_OFILES): Add strerror.o strsignal.o + * Makefile.in (needed-list): Split creation of errors file to + separate make target. + * Makefile.in (config.h, needed2.awk, errors): New targets. + * Makefile.in (clean): Split to multiple lines, add needed2.awk + and config.h. + * dummy.c (DEFFUNC, DEFVAR): Add defines and undefs. + * functions.def (strerror): Remove from optional list. + * functions.def (sys_nerr, sys_errlist, sys_siglist): DEFVAR's + * functions.def (strerror, psignal): DEFFUNC's + * strerror.c: Rewrite from scratch to use sys_errlist only if + available, add errno_max(), add strerrno(), add strtoerrno(), + add test driver. + * strsignal.c: New file, signal equivalent to strerror.c. + Uses sys_siglist if available, defines signo_max(), strsignal(), + strsigno(), strtosigno(), psignal(), and test driver. + +Mon Apr 20 20:49:32 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: do not print recursion line. + + * Makefile.in: allow CFLAGS to be passed in from command line. + Removed MINUS_G. Default CFLAGS to -g. + +Mon Apr 20 12:57:46 1992 Per Bothner (bothner@rtl.cygnus.com) + + * config/mh-aix: New. EXTRA_OFILES lists copysign.o, + so libg++ users don't have to be inconvenienced by a + libc.a bug (libc.a needs copysign, but doesn't define it!). + * configure.in: Use config/mh-aix. + * strtoul.c: Handle '-' as required by ANSI. + Clean up radix handling. + * strstr.c: Fix buggy algorithm. + * Makefile.in: Change so that ${EXTRA_OFILES} is + appended to needed-list (which is used by libg++). + +Fri Apr 10 22:51:41 1992 Fred Fish (fnf@cygnus.com) + + * configure.in: Recognize new ncr3000 config. + * config/mh-ncr3000: New config file. + +Wed Apr 1 23:31:43 1992 John Gilmore (gnu at cygnus.com) + + * argv.c, dummy.c: Lint. + +Tue Mar 31 18:46:44 1992 Fred Fish (fnf@cygnus.com) + + * config/mh-sysv4: New config file. + * configure.in (host_makefile_frag): Set to config/mh-sysv4 for + host_os == sysv4. + * getpagesize.c: For SVR4, use sysconf(_SC_PAGESIZE) to get + pagesize. + +Sun Mar 29 12:26:42 1992 John Gilmore (gnu at cygnus.com) + + * getopt.c: Lint. + +Fri Mar 27 08:32:55 1992 Fred Fish (fnf@cygnus.com) + + * functions.def (alloca): Fix return type and args to avoid + type clash with gcc's builtin alloca. + +Tue Mar 24 23:33:42 1992 K. Richard Pixley (rich@cygnus.com) + + * configure.in, config/mh-irix4: irix4 support. + + * Makefile.in, functions.def, alloca.c: added alloca. + +Tue Mar 24 17:34:46 1992 Stu Grossman (grossman at cygnus.com) + + * obstack.c (CALL_FREEFUN): Make it compile on DECstations. + +Thu Mar 19 13:57:42 1992 Fred Fish (fnf@cygnus.com) + + * argv.c: Fix various external function definitions to be + correct in an ANSI compilation environment. + +Sat Mar 14 17:28:17 1992 Fred Fish (fnf@cygnus.com) + + * obstack.c: Changes to support calling mmalloc functions, + which take an additional argument over malloc functions. + +Fri Mar 6 22:01:10 1992 K. Richard Pixley (rich@cygnus.com) + + * added check target. + +Thu Feb 27 22:19:39 1992 Per Bothner (bothner@cygnus.com) + + * argv.c: #include alloca-conf.h (needed by AIX). + +Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in, configure.in: removed traces of namesubdir, + -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced + copyrights to '92, changed some from Cygnus to FSF. + +Sat Feb 22 01:09:21 1992 Stu Grossman (grossman at cygnus.com) + + * argv.c: Check in Fred's version which fixes problems with + alloca(). + +Fri Feb 7 21:46:08 1992 Stu Grossman (grossman at cygnus.com) + + * makefile.dos: Remove NUL to keep patch from failing. + +Thu Jan 30 22:48:41 1992 Stu Grossman (grossman at cygnus.com) + + * getopt.c (_getopt_internal): Fix usage of enum has_arg. + +Mon Jan 20 18:53:23 1992 Stu Grossman (grossman at cygnus.com) + + * getopt.c, getopt1.c, ../include/getopt.h: Get latest versions. + +Sat Jan 18 16:53:01 1992 Fred Fish (fnf at cygnus.com) + + * argv.c: New file to build and destroy standard argument + vectors from a command string. + + * Makefile.in: Add argv.c and argv.o to appropriate macros. + +Fri Dec 20 12:12:57 1991 Fred Fish (fnf at cygnus.com) + + * configure.in: Change svr4 references to sysv4. + + * rindex.c: Declare return type of externally used function + strrchr(). + +Thu Dec 19 18:35:03 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Remove "***" in normal output, since Make produces + this on errors, and it's convenient to search for. + +Tue Dec 17 23:21:30 1991 Per Bothner (bothner at cygnus.com) + + * memcmp.c, memcpy.c, memmove.c, memset.c, strchr.c, strrchr.c: + New ANSI functions. The old non-ANSI functions (such as bcopy) + should be avoided. + * bcopy.c: Fix to correctly handle overlapping regions. + * index.c, rindex.c: Re-write in terms of strchr() and strrchr(). + * functions.def: Add the new functions. + * functions.def: Add 4th parameter to DEF macro, + an ansidecl.h-style prototype. + * dummy.c: Use expanded DEF macro to create a dummy function + call, with correct parameter types. (This avoids some + complaints from gcc about predefined builtins.) + + Move the functionality of config/mh-default into Makefile.in. + This avoid duplication, and simplifies things slightly. + * Makefile.in: Tweak so we don't need config/mh-default. + * README: Update. + * configure.in: No longer need config/mh-default. + * config/mh-default: Deleted. + * config/mh-sysv: Remove lines copied from old mh-default. + +Tue Dec 17 05:46:46 1991 John Gilmore (gnu at cygnus.com) + + * fdmatch.c (fdmatch): Don't compare st_rdev, which is for + 'mknod' device numbers. + +Mon Dec 16 12:25:34 1991 Fred Fish (fnf at cygnus.com) + + * fdmatch.c, Makefile.in: Add new function that takes two + open file descriptors and returns nonzero if they refer to + the same file, zero otherwise. (used in gdb) + +Wed Dec 11 17:40:39 1991 Steve Chamberlain (sac at rtl.cygnus.com) + From DJ: + * msdos.c: stub functions for dos. + * makefile.dos, configdj.bat: new. + * getopt.c: Don't include alloca-conf.h in a GO32 world. + + +Tue Dec 10 04:14:49 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: infodir belongs in datadir. + +Fri Dec 6 23:26:45 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: remove spaces following hyphens because bsd make + can't cope. added standards.text support. install using + INSTALL_DATA. + + * configure.in: remove commontargets as it is no longer a + recognized hook. + +Thu Dec 5 22:46:46 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: idestdir and ddestdir go away. Added copyrights + and shift gpl to v2. Added ChangeLog if it didn't exist. docdir + and mandir now keyed off datadir by default. + +Fri Nov 22 19:15:29 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in: find-needed.awk does not fit in 14 chars. + + * Makefile.in: Suppress error checking when compiling the test + program, because Ultrix make/sh aborts there due to a bug. + +Fri Nov 22 12:23:17 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Re-did how EXTRA_OFILES is used to be more useful. + * README: Explained how the auto-configuration works, + and how to add new files and/or configurations. + +Fri Nov 22 09:45:23 1991 John Gilmore (gnu at cygnus.com) + + * strtoul.c: Avoid defining ULONG_MAX if already defined; + cast a const char * to char * for pedants. + + * getopt.c: Only define "const" after local include files get to, + and only if they haven't defined it. + +Thu Nov 21 16:58:53 1991 John Gilmore (gnu at cygnus.com) + + * getcwd.c (remove getwd.c): GNU code should call getcwd(). We + emulate it with getwd() if available. This avoids callers having + to find a MAXPATHLEN or PATH_MAX value from somewhere. + * Makefile.in, functions.def: getwd->getcwd. + * configure.in: Use generic case for every system. + * config/mh-{delta88,mach,rs6000,svr4}: Remove. + * config/mh-sysv: Use default handling, just add -DUSG. + +Thu Nov 14 10:58:05 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in, config/mh-default: Re-do make magic + so that for the default ("automatic") mode we only + compile the files we actually need. Do this using + a recursive make: The top-level generates the list + of needed files (loosely, the ones missing in libc), + and then passes that list to the recursive make. + * config/mh-mach: Remove obsolete STRERROR-{C,O} macros. + +Tue Nov 12 19:10:57 1991 John Gilmore (gnu at cygnus.com) + + RS/6000 host support (grumble). + + * configure.in: Build alloca-conf.h file from alloca-norm.h + (everything else) or alloca-botch.h (rs/6000). + * Makefile.in: Include . on the include path. + * getopt.c: Use alloca-conf.h. + * alloca-norm.h: How to declare alloca on reasonable machines. + * alloca-botch.h: How to declare alloca on braindead machines. + +Tue Nov 12 09:21:48 1991 Fred Fish (fnf at cygnus.com) + + * concat.c : New file, like concat() in gdb but can take a + variable number of arguments rather than fixed at 3 args. For + now, client applications must supply an xmalloc(), which is a + front end function to malloc() that deals with out-of-memory + conditions. + + * Makefile.in: Add concat.c and concat.o to appropriate macros. + +Sat Nov 9 13:29:59 1991 Fred Fish (fnf at cygnus.com) + + * config/mh-svr4: Add sigsetmask to list of required functions. + +Sun Nov 3 11:57:56 1991 Per Bothner (bothner at cygnus.com) + + * vsprintf.c: New file. + * functions.def, Makefile.in: Add vsprintf. + +Sun Oct 27 16:31:22 1991 John Gilmore (gnu at cygnus.com) + + * configure.in, config/mh-rs6000: Add rs/6000 host support. + * Makefile.in: Compile with debug info. + +Fri Oct 25 17:01:12 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in, configure.in, and new files: dummy.c, functions.def, + config/mf-default: Added a default configuration mode, + which includes into libiberty.a functions that are "missing" in libc. + * strdup.c, vprintf.c, vfprintf.c: New files. + +Thu Oct 24 02:29:26 1991 Fred Fish (fnf at cygnus.com) + + * config/hmake-svr4: New file. + + * config/hmake-sysv: Add HOST_CFILES and HOST_OFILES. + + * basename.c, bcmp.c, bcopy.c, bzero.c, getpagesize.c getwd.c, + index.c, insque.c, rindex.c, spaces.c, strstr.c, vfork.c: New + files containing either portable C versions or emulations using + native library calls. + + * strerror.c: Add copyright, internal documentation, etc. + + * strtol.c: Replace hardwired hex constants with some more + portable macros. Remove illegal (according to gcc) cast. + + * strtoul.c: Replace hardwired hex constant with more portable + macro. + + * Makefile.in: Move TARGETLIB and CFLAGS where makefile fragments + can override them. Add new source and object file names to CFILES + and OFILES respectively. + + * configure.in: Add support for SVR4 makefile fragments. + +Tue Oct 22 19:00:23 1991 Steve Chamberlain (steve at cygnus.com) + + * Makefile.in: Move RANLIB, AR and AR_FLAGS to where they can be + over-ridden by config/hmake-* + * configure.in: added m88kcvs to sysv list + +Fri Oct 4 01:29:08 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Most hosts need strerror, but one or two don't, + and they override these definitions in the host-dependent makefile + fragment. + * config/hmake-mach: The odd man out on strerror -- it's supplied. + * strerror.c: New file. + + * strtol.c, strtoul.c: Add strtol to libiberty, since Mach lacks + it and bfd uses it. + * configure.in, Makefile.in, config/hmake-mach: Only configure + strtol & strotoul in on Mach. + +Tue Sep 3 06:36:23 1991 John Gilmore (gnu at cygint.cygnus.com) + + * obstack.c: Merge with latest FSF version. + + +Local Variables: +version-control: never +End: diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in new file mode 100644 index 000000000000..46874e12bf4e --- /dev/null +++ b/libiberty/Makefile.in @@ -0,0 +1,336 @@ +# +# Makefile +# Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation +# +# This file is part of the libiberty library. +# Libiberty 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 of the License, or (at your option) any later version. +# +# Libiberty 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 libiberty; see the file COPYING.LIB. If not, +# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +# This file was written, and is maintained by K. Richard Pixley +# . + +# +# Makefile for libiberty directory +# + +srcdir = . + +prefix = /usr/local + +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib + +datadir = $(prefix)/share + +mandir = $(prefix)/man +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +man3dir = $(mandir)/man3 +man4dir = $(mandir)/man4 +man5dir = $(mandir)/man5 +man6dir = $(mandir)/man6 +man7dir = $(mandir)/man7 +man8dir = $(mandir)/man8 +man9dir = $(mandir)/man9 +infodir = $(prefix)/info +includedir = $(prefix)/include + +SHELL = /bin/sh + +# Multilib support variables. +MULTISRCTOP = +MULTIBUILDTOP = +MULTIDIRS = +MULTISUBDIR = +MULTIDO = true +MULTICLEAN = true + +INSTALL = install -c +INSTALL_PROGRAM = $(INSTALL) +INSTALL_DATA = $(INSTALL) + +AR = ar +AR_FLAGS = rc + +ERRORS_CC = $(CC) +CC = cc +CFLAGS = -g +LIBCFLAGS = $(CFLAGS) +MAKEINFO = makeinfo +RANLIB = ranlib + +PICFLAG = + +MAKEOVERRIDES = + +TARGETLIB = libiberty.a + +CONFIG_H = lconfig.h +NEEDED_LIST = lneeded-list + +# HOST_OFILES contains the list of objects that should be in the +# library (in addition to the REQUIRED_OFILES and EXTRA_OFILES). +# A configuration may override this with a fixed list a object files +# names (hard to maintain), or some other way to generate a list. +HOST_OFILES=`cat needed-list` + +# Extra targets that the top-level target depends on. +# Specifically, what needs to be made before HOST_OFILES can be used. +# Can be empty if HOST_OFILES is just a list of file names. +DO_ALSO = needed-list + +# A configuration can specify extra .o files that should be included, +# even if they are in libc. (Perhaps the libc version is buggy.) +EXTRA_OFILES = + +# Flags to pass to a recursive make. +FLAGS_TO_PASS = \ + "AR=$(AR)" \ + "AR_FLAGS=$(AR_FLAGS)" \ + "CC=$(CC)" \ + "CFLAGS=$(CFLAGS)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "EXTRA_OFILES=$(EXTRA_OFILES)" \ + "HDEFINES=$(HDEFINES)" \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LOADLIBES=$(LOADLIBES)" \ + "PICFLAG=$(PICFLAG)" \ + "RANLIB=$(RANLIB)" \ + "SHELL=$(SHELL)" + +all: stamp-picdir $(TARGETLIB) required-list + @if [ "$(RULE1)" != "not-used" ]; then \ + $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all; \ + else true; \ + fi + +.PHONY: check installcheck +check installcheck: + + +#### Host, target, and site specific Makefile fragments come in here. +### + +INCDIR=$(srcdir)/$(MULTISRCTOP)../include + +COMPILE.c = $(CC) -c $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) +.c.o: + test -z "$(PICFLAG)" || \ + $(COMPILE.c) $(PICFLAG) $< -o pic/$@ + $(COMPILE.c) $< + +# The default target just invokes make recursively. +# However, the automatic configuration (in config/mh_default). +# first causes it to figure out the objects missing in libc. +info install-info clean-info dvi: + +# Include files that are in this directory. +HFILES = + +# NOTE: If you add new files to the library, add them to this list +# (alphabetical), and add them to REQUIRED_OFILES or 'functions.def'. +CFILES = alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c bzero.c \ + choose-temp.c clock.c concat.c cplus-dem.c fdmatch.c fnmatch.c \ + getcwd.c getopt.c getopt1.c getpagesize.c getruntime.c \ + floatformat.c hex.c index.c insque.c \ + memchr.c memcmp.c memcpy.c memmove.c memset.c objalloc.c \ + obstack.c random.c rename.c rindex.c sigsetmask.c spaces.c \ + strcasecmp.c strncasecmp.c \ + strchr.c strdup.c strerror.c strrchr.c strsignal.c \ + strstr.c strtod.c strtol.c strtoul.c tmpnam.c \ + vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c waitpid.c \ + xatexit.c xexit.c xmalloc.c xstrdup.c xstrerror.c +# These are always included in the library. +REQUIRED_OFILES = argv.o basename.o choose-temp.o concat.o cplus-dem.o \ + fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o \ + floatformat.o objalloc.o obstack.o pexecute.o spaces.o strerror.o \ + strsignal.o xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o + +# Do we want/need any config overrides? +# + +STAGESTUFF = $(TARGETLIB) *.o + +INSTALL_DEST = libdir +install: install_to_$(INSTALL_DEST) + +install_to_libdir: all + $(INSTALL_DATA) $(TARGETLIB) $(libdir)/$(TARGETLIB).n + ( cd $(libdir) ; $(RANLIB) $(libdir)/$(TARGETLIB).n ) + mv -f $(libdir)/$(TARGETLIB).n $(libdir)$(MULTISUBDIR)/$(TARGETLIB) + @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install + +install_to_tooldir: all + $(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib/$(TARGETLIB).n + ( cd $(tooldir) ; $(RANLIB) $(tooldir)/lib/$(TARGETLIB).n ) + mv -f $(tooldir)/lib/$(TARGETLIB).n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB) + @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install + +# The default configuration adds to libiberty all those functions that are +# missing in libc. More precisely, it includes whatever $(CC) fails to find. +# Then a sed+awk combination translates the ld error messages into +# a list of .o files. + +stamp-needed: stamp-picdir $(NEEDED_LIST) + cp $(NEEDED_LIST) needed-tmp + $(SHELL) $(srcdir)/../move-if-change needed-tmp needed-list + touch stamp-needed + +needed-list: stamp-needed ; @true + +lneeded-list: $(EXTRA_OFILES) needed.awk errors + rm -f lneeded-list + f=""; \ + for i in `awk -f needed.awk >lneeded-list + +# Generate an awk script that looks for functions in functions.def + +needed.awk: $(srcdir)/functions.def Makefile + echo "# !Automatically generated from $(srcdir)/functions.def"\ + "- DO NOT EDIT!" >needed.awk + grep '^DEF(' < $(srcdir)/functions.def \ + | sed -e '/DEF/s|DEF.\([^,]*\).*|/\1/ { printf "\1.o " }|' \ + >>needed.awk + +stamp-config: $(CONFIG_H) + cp $(CONFIG_H) config.tmp + $(SHELL) $(srcdir)/../move-if-change config.tmp config.h + touch stamp-config + +config.h: stamp-config ; @true + +lconfig.h: needed2.awk errors + echo "/* !Automatically generated from $(srcdir)/functions.def"\ + "- DO NOT EDIT! */" >lconfig.h + awk -f needed2.awk >lconfig.h + +# Generate an awk script that looks for variables in functions.def + +needed2.awk: $(srcdir)/functions.def Makefile + echo "# !Automatically generated from $(srcdir)/functions.def"\ + "- DO NOT EDIT!" >needed2.awk + grep '^DEFVAR(' < $(srcdir)/functions.def \ + | sed -e '/DEFVAR/s|DEFVAR.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \ + >>needed2.awk + grep '^DEFFUNC(' < $(srcdir)/functions.def \ + | sed -e '/DEFFUNC/s|DEFFUNC.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \ + >>needed2.awk + +dummy.o: $(srcdir)/dummy.c $(srcdir)/functions.def + $(CC) -c $(CFLAGS) -I. -I$(INCDIR) $(HDEFINES) $(srcdir)/dummy.c 2>/dev/null + +errors: dummy.o $(EXTRA_OFILES) + -($(ERRORS_CC) -o dummy $(CFLAGS) $(LDFLAGS) $(ERRORS_LDFLAGS) dummy.o $(EXTRA_OFILES) $(LOADLIBES)) >errors 2>&1 || true + +# required-list is used when building a shared bfd/opcodes/libiberty library. +required-list: Makefile + echo $(REQUIRED_OFILES) > required-list + +$(HOST_OFILES) $(REQUIRED_OFILES) : config.h + +RULE1 = $(TARGETLIB) +$(RULE1): $(REQUIRED_OFILES) $(DO_ALSO) .always. + @$(MAKE) RULE1=not-used RULE2=$(TARGETLIB) $(FLAGS_TO_PASS) \ + "HOST_OFILES=$(HOST_OFILES)" + +# Rule invoked by recursive make in $(RULE1). +RULE2 = not-used +$(RULE2): $(REQUIRED_OFILES) $(HOST_OFILES) + rm -rf $(TARGETLIB) + $(AR) $(AR_FLAGS) $(TARGETLIB) \ + $(REQUIRED_OFILES) $(HOST_OFILES) + $(RANLIB) $(TARGETLIB) + +stamp-picdir: + if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \ + mkdir pic; \ + else true; fi + touch stamp-picdir + +.always.: +# Do nothing. + +.PHONY: all etags tags ls clean stage1 stage2 .always. + +etags tags: TAGS + +TAGS: $(CFILES) $(HFILES) + etags `for i in $(HFILES) $(CFILES); do echo $(srcdir)/$$i ; done` + +# The standalone demangler (c++filt) has been moved to binutils. +demangle: + @echo "The standalone demangler, now named c++filt, is now" + @echo "a part of binutils." + @false + +ls: + @echo Makefile $(HFILES) $(CFILES) + +# Need to deal with profiled libraries, too. + +mostlyclean: + rm -rf *.o pic core errs \#* *.E a.out + rm -f needed.awk needed2.awk errors dummy needed-list config.h stamp-* + rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir + @$(MULTICLEAN) multi-clean DO=mostlyclean +clean: mostlyclean + rm -f *.a required-list tmpmulti.out + @$(MULTICLEAN) multi-clean DO=clean +distclean: clean + rm -f *~ Makefile config.status alloca-conf.h xhost-mkfrag TAGS multilib.out + @$(MULTICLEAN) multi-clean DO=distclean +maintainer-clean realclean: distclean + +force: + +Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) + $(SHELL) ./config.status + +argv.o: $(INCDIR)/libiberty.h +basename.o: $(INCDIR)/libiberty.h +concat.o: $(INCDIR)/libiberty.h +cplus-dem.o: $(INCDIR)/demangle.h +fdmatch.o: $(INCDIR)/libiberty.h +fnmatch.o: $(INCDIR)/fnmatch.h +getopt.o: $(INCDIR)/getopt.h +getopt1.o: $(INCDIR)/getopt.h +getruntime.o: $(INCDIR)/libiberty.h +hex.o: $(INCDIR)/libiberty.h +floatformat.o: $(INCDIR)/floatformat.h +objalloc.o: $(INCDIR)/objalloc.h +obstack.o: $(INCDIR)/obstack.h +pexecute.o: $(INCDIR)/libiberty.h +spaces.o: $(INCDIR)/libiberty.h +strerror.o: $(INCDIR)/libiberty.h +strsignal.o: $(INCDIR)/libiberty.h +xatexit.o: $(INCDIR)/libiberty.h +xexit.o: $(INCDIR)/libiberty.h +xmalloc.o: $(INCDIR)/libiberty.h +xstrdup.o: $(INCDIR)/libiberty.h +xstrerror.o: $(INCDIR)/libiberty.h diff --git a/libiberty/README b/libiberty/README new file mode 100644 index 000000000000..5081bbac1968 --- /dev/null +++ b/libiberty/README @@ -0,0 +1,129 @@ +This directory contains the -liberty library of free software. +It is a collection of subroutines used by various GNU programs. +Current members include: + + getopt -- get options from command line + obstack -- stacks of arbitrarily-sized objects + strerror -- error message strings corresponding to errno + strtol -- string-to-long conversion + strtoul -- string-to-unsigned-long conversion + +We expect many of the GNU subroutines that are floating around to +eventually arrive here. + +To build the library, do: + + ./configure HOSTTYPE + make + +Please report bugs and fixes to "bug-gnu-utils@prep.ai.mit.edu". Thank you. + +ADDING A NEW FILE +================= + +There are two sets of files: Those that are "required" will be +included in the library for all configurations, while those +that are "optional" will be included in the library only if "needed." + +To add a new required file, edit Makefile to add the source file +name to CFILES and the object file to REQUIRED_OFILES. + +Adding a new optional file is more fragile. As a general rule, +an optional file will be included in the library if it provides +functionality missing in the "standard" C library. +For most hosts, the Makefile automatically figures out which +functionality is missing by compiling and linking a dummy test +program, and examining the error messages. + +So to get this to work, you should do the following: + +1) Select one function defined in the file you're adding. +For example, the getcwd function. +2) Add that function to the list in the file functions.def. +3) The name of the new file must be the same as the function +you've chosen with the .c suffix added. E.g. getcwd() must be +defined in getcwd.c. (The file can define other functions as well.) +4) In Makefile.in, add the name of the source file (e.g. getcwd.c) +to CFILES. + +The file you've added (e.g. getcwd.c) should compile and work +on all hosts where it is needed (e.g. not found when linking +the dummy.c program). It does not have to work or even +compile on hosts where it is not needed. + +HOW THE AUTOMATIC CONFIGURATION WORKS +===================================== + +The libiberty.a target (in RULE1) depends on $(DO_ALSO). +For normal configurations, DO_ALSO=needed-list. + +So needed-list is first made. The needed-list rule compiles +dummy.c. Because dummy.c includes functions.def, the +resulting object file will contain a call to each of the +optional functions (for simplicity assume each optional file +defines a single function). This object file will be linked +against the standard libraries (as defined by using $(CC) +and various flags). Any function missing will causes the +linker to emit an error message. We assume the name +of the missing function(s) are in the error message(s). +The awk script find-needed.awk has been generated from +functions.def. It is used to search the linker output +messages for words that match the functions listed in +functions.def. The list of functions found is written +on a single line to the file needed-list. + +After needed-list has been generated, the libiberty.a +target (in RULE1) just calls 'make' recursively. +It passes the contents of needed-list using the +definition (expanded) HOST_OFILES="`cat needed-list`". +It also tells the inferior 'make' to use RULE2. + +The inferior 'make' is very conventional: The main +rule is $(RULE2) (which is libiberty.a). It depends +on a list of object files: $(REQUIRED_OFILES) $(HOST_OFILES) +(and $(EXTRA_OFILES), which is usually empty). The superior +'make' passes in $(HOST_OFILES); the others are fixed +in the Makefile. + +ADDING A NEW CONFIGURATION +========================== + +On most hosts you should be able to use the scheme for automatically +figuring out which files are needed. In that case, you probably +don't need a special Makefile stub for that configuration. + +If the fully automatic scheme doesn't work, you may be able to get +by with defining EXTRA_OFILES in your Makefile stub. This is +a list of object file names that should be treated as required +for this configuration - they will be included in libiberty.a, +regardless of whatever might be in the C library. Moreover, +when the dummy.c program is linked, it will be linked with +$(EXTRA_OFILES). Therefore, if a function in functions.def +is defined by one of the EXTRA_OFILES, it will not be listed as +"needed". Thus if your hal9000 host needs a special implementation +of getcwd, you can just create hal9000-getcwd.c, and define: + EXTRA_OFILES=hal9000-getcwd.o +Or if you want to use the libiberty version of strstr(), +even though there is a version in the C library (it might be +buggy or slow), just define: + EXTRA_OFILES=strstr.o + +You can create a "manual" host configuration FOO with a file +config/mh-FOO. In it, the HOST_OFILES macro should explicitly +list that subset of the optional files that should be in the +library. You should also set: + DO_ALSO = +This overrides all of the magic needed to automatically +determine which files are "needed." However, keeping that list +up to date is another matter... + +HOW THE MANUAL CONFIGURATION WORKS +================================== + +This also uses a recursive make, but the superior make +does not do anything interesting - it just calls the +inferior make with HOST_OFILES defined as $(HOST_OFILES), +which is the list you created in your configuration. + +You probably don't want to depend on manual configuration, +because keeping the HOST_OFILES list up-to-date will be a pain. diff --git a/libiberty/alloca-botch.h b/libiberty/alloca-botch.h new file mode 100644 index 000000000000..c909573f58c6 --- /dev/null +++ b/libiberty/alloca-botch.h @@ -0,0 +1,5 @@ +/* RS/6000 AIX botched alloca and requires a pragma, which ordinary compilers + throw up about, so we have to put it in a specially-configured file. + Like this one. */ + +#pragma alloca diff --git a/libiberty/alloca-norm.h b/libiberty/alloca-norm.h new file mode 100644 index 000000000000..394a65332777 --- /dev/null +++ b/libiberty/alloca-norm.h @@ -0,0 +1,23 @@ +/* "Normal" configuration for alloca. */ + +#ifdef __GNUC__ +#define alloca __builtin_alloca +#else /* ! defined (__GNUC__) */ +#if defined (sparc) && defined (sun) +#include +#ifdef __STDC__ +extern void *__builtin_alloca(); +#else /* ! defined (__STDC__) */ +extern char *__builtin_alloca(); /* Stupid include file doesn't declare it */ +#endif /* ! defined (__STDC__) */ +#else /* ! defined (sparc) || ! defined (sun) */ +#ifdef __STDC__ +PTR alloca (size_t); +#else /* ! defined (__STDC__) */ +PTR alloca (); /* must agree with functions.def */ +#endif /* ! defined (__STDC__) */ +#endif /* ! defined (sparc) || ! defined (sun) */ +#ifdef _WIN32 +#include +#endif +#endif /* ! defined (__GNUC__) */ diff --git a/libiberty/alloca.c b/libiberty/alloca.c new file mode 100644 index 000000000000..911d42fcb8c4 --- /dev/null +++ b/libiberty/alloca.c @@ -0,0 +1,479 @@ +/* alloca.c -- allocate automatically reclaimed memory + (Mostly) portable public-domain implementation -- D A Gwyn + + This implementation of the PWB library alloca function, + which is used to allocate space off the run-time stack so + that it is automatically reclaimed upon procedure exit, + was inspired by discussions with J. Q. Johnson of Cornell. + J.Otto Tennant contributed the Cray support. + + There are some preprocessor constants that can + be defined when compiling for your specific system, for + improved efficiency; however, the defaults should be okay. + + The general concept of this implementation is to keep + track of all alloca-allocated blocks, and reclaim any + that are found to be deeper in the stack than the current + invocation. This heuristic does not reclaim storage as + soon as it becomes invalid, but it will do so eventually. + + As a special case, alloca(0) reclaims storage without + allocating any. It is a good idea to use alloca(0) in + your main control loop, etc. to force garbage collection. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* If compiling with GCC, this file's not needed. */ +#ifndef alloca + +#ifdef emacs +#ifdef static +/* actually, only want this if static is defined as "" + -- this is for usg, in which emacs must undefine static + in order to make unexec workable + */ +#ifndef STACK_DIRECTION +you +lose +-- must know STACK_DIRECTION at compile-time +#endif /* STACK_DIRECTION undefined */ +#endif /* static */ +#endif /* emacs */ + +/* If your stack is a linked list of frames, you have to + provide an "address metric" ADDRESS_FUNCTION macro. */ + +#if defined (CRAY) && defined (CRAY_STACKSEG_END) +long i00afunc (); +#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) +#else +#define ADDRESS_FUNCTION(arg) &(arg) +#endif + +#if __STDC__ +#include +typedef void *pointer; +#else +typedef char *pointer; +typedef unsigned size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +/* Different portions of Emacs need to call different versions of + malloc. The Emacs executable needs alloca to call xmalloc, because + ordinary malloc isn't protected from input signals. On the other + hand, the utilities in lib-src need alloca to call malloc; some of + them are very simple, and don't have an xmalloc routine. + + Non-Emacs programs expect this to call use xmalloc. + + Callers below should use malloc. */ + +#ifndef emacs +#define malloc xmalloc +extern pointer xmalloc (); +#endif + +/* Define STACK_DIRECTION 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 */ + +#ifndef STACK_DIRECTION +#define STACK_DIRECTION 0 /* Direction unknown. */ +#endif + +#if STACK_DIRECTION != 0 + +#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ + +#else /* STACK_DIRECTION == 0; need run-time code. */ + +static int stack_dir; /* 1 or -1 once known. */ +#define STACK_DIR stack_dir + +static void +find_stack_direction () +{ + static char *addr = NULL; /* Address of first `dummy', once known. */ + auto char dummy; /* To get stack address. */ + + if (addr == NULL) + { /* Initial entry. */ + addr = ADDRESS_FUNCTION (dummy); + + find_stack_direction (); /* Recurse once. */ + } + else + { + /* Second entry. */ + if (ADDRESS_FUNCTION (dummy) > addr) + stack_dir = 1; /* Stack grew upward. */ + else + stack_dir = -1; /* Stack grew downward. */ + } +} + +#endif /* STACK_DIRECTION == 0 */ + +/* An "alloca header" is used to: + (a) chain together all alloca'ed blocks; + (b) keep track of stack depth. + + It is very important that sizeof(header) agree with malloc + alignment chunk size. The following default should work okay. */ + +#ifndef ALIGN_SIZE +#define ALIGN_SIZE sizeof(double) +#endif + +typedef union hdr +{ + char align[ALIGN_SIZE]; /* To force sizeof(header). */ + struct + { + union hdr *next; /* For chaining headers. */ + char *deep; /* For stack depth measure. */ + } h; +} header; + +static header *last_alloca_header = NULL; /* -> last alloca header. */ + +/* Return a pointer to at least SIZE bytes of storage, + which will be automatically reclaimed upon exit from + the procedure that called alloca. Originally, this space + was supposed to be taken from the current stack frame of the + caller, but that method cannot be made to work for some + implementations of C, for example under Gould's UTX/32. */ + +pointer +alloca (size) + size_t size; +{ + auto char probe; /* Probes stack depth: */ + register char *depth = ADDRESS_FUNCTION (probe); + +#if STACK_DIRECTION == 0 + if (STACK_DIR == 0) /* Unknown growth direction. */ + find_stack_direction (); +#endif + + /* Reclaim garbage, defined as all alloca'd storage that + was allocated from deeper in the stack than currently. */ + + { + register header *hp; /* Traverses linked list. */ + + for (hp = last_alloca_header; hp != NULL;) + if ((STACK_DIR > 0 && hp->h.deep > depth) + || (STACK_DIR < 0 && hp->h.deep < depth)) + { + register header *np = hp->h.next; + + free ((pointer) hp); /* Collect garbage. */ + + hp = np; /* -> next header. */ + } + else + break; /* Rest are not deeper. */ + + last_alloca_header = hp; /* -> last valid storage. */ + } + + if (size == 0) + return NULL; /* No allocation required. */ + + /* Allocate combined header + user data storage. */ + + { + register pointer new = malloc (sizeof (header) + size); + /* Address of header. */ + + ((header *) new)->h.next = last_alloca_header; + ((header *) new)->h.deep = depth; + + last_alloca_header = (header *) new; + + /* User storage begins just after header. */ + + return (pointer) ((char *) new + sizeof (header)); + } +} + +#if defined (CRAY) && defined (CRAY_STACKSEG_END) + +#ifdef DEBUG_I00AFUNC +#include +#endif + +#ifndef CRAY_STACK +#define CRAY_STACK +#ifndef CRAY2 +/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ +struct stack_control_header + { + long shgrow:32; /* Number of times stack has grown. */ + long shaseg:32; /* Size of increments to stack. */ + long shhwm:32; /* High water mark of stack. */ + long shsize:32; /* Current size of stack (all segments). */ + }; + +/* The stack segment linkage control information occurs at + the high-address end of a stack segment. (The stack + grows from low addresses to high addresses.) The initial + part of the stack segment linkage control information is + 0200 (octal) words. This provides for register storage + for the routine which overflows the stack. */ + +struct stack_segment_linkage + { + long ss[0200]; /* 0200 overflow words. */ + long sssize:32; /* Number of words in this segment. */ + long ssbase:32; /* Offset to stack base. */ + long:32; + long sspseg:32; /* Offset to linkage control of previous + segment of stack. */ + long:32; + long sstcpt:32; /* Pointer to task common address block. */ + long sscsnm; /* Private control structure number for + microtasking. */ + long ssusr1; /* Reserved for user. */ + long ssusr2; /* Reserved for user. */ + long sstpid; /* Process ID for pid based multi-tasking. */ + long ssgvup; /* Pointer to multitasking thread giveup. */ + long sscray[7]; /* Reserved for Cray Research. */ + long ssa0; + long ssa1; + long ssa2; + long ssa3; + long ssa4; + long ssa5; + long ssa6; + long ssa7; + long sss0; + long sss1; + long sss2; + long sss3; + long sss4; + long sss5; + long sss6; + long sss7; + }; + +#else /* CRAY2 */ +/* The following structure defines the vector of words + returned by the STKSTAT library routine. */ +struct stk_stat + { + long now; /* Current total stack size. */ + long maxc; /* Amount of contiguous space which would + be required to satisfy the maximum + stack demand to date. */ + long high_water; /* Stack high-water mark. */ + long overflows; /* Number of stack overflow ($STKOFEN) calls. */ + long hits; /* Number of internal buffer hits. */ + long extends; /* Number of block extensions. */ + long stko_mallocs; /* Block allocations by $STKOFEN. */ + long underflows; /* Number of stack underflow calls ($STKRETN). */ + long stko_free; /* Number of deallocations by $STKRETN. */ + long stkm_free; /* Number of deallocations by $STKMRET. */ + long segments; /* Current number of stack segments. */ + long maxs; /* Maximum number of stack segments so far. */ + long pad_size; /* Stack pad size. */ + long current_address; /* Current stack segment address. */ + long current_size; /* Current stack segment size. This + number is actually corrupted by STKSTAT to + include the fifteen word trailer area. */ + long initial_address; /* Address of initial segment. */ + long initial_size; /* Size of initial segment. */ + }; + +/* The following structure describes the data structure which trails + any stack segment. I think that the description in 'asdef' is + out of date. I only describe the parts that I am sure about. */ + +struct stk_trailer + { + long this_address; /* Address of this block. */ + long this_size; /* Size of this block (does not include + this trailer). */ + long unknown2; + long unknown3; + long link; /* Address of trailer block of previous + segment. */ + long unknown5; + long unknown6; + long unknown7; + long unknown8; + long unknown9; + long unknown10; + long unknown11; + long unknown12; + long unknown13; + long unknown14; + }; + +#endif /* CRAY2 */ +#endif /* not CRAY_STACK */ + +#ifdef CRAY2 +/* Determine a "stack measure" for an arbitrary ADDRESS. + I doubt that "lint" will like this much. */ + +static long +i00afunc (long *address) +{ + struct stk_stat status; + struct stk_trailer *trailer; + long *block, size; + long result = 0; + + /* We want to iterate through all of the segments. The first + step is to get the stack status structure. We could do this + more quickly and more directly, perhaps, by referencing the + $LM00 common block, but I know that this works. */ + + STKSTAT (&status); + + /* Set up the iteration. */ + + trailer = (struct stk_trailer *) (status.current_address + + status.current_size + - 15); + + /* There must be at least one stack segment. Therefore it is + a fatal error if "trailer" is null. */ + + if (trailer == 0) + abort (); + + /* Discard segments that do not contain our argument address. */ + + while (trailer != 0) + { + block = (long *) trailer->this_address; + size = trailer->this_size; + if (block == 0 || size == 0) + abort (); + trailer = (struct stk_trailer *) trailer->link; + if ((block <= address) && (address < (block + size))) + break; + } + + /* Set the result to the offset in this segment and add the sizes + of all predecessor segments. */ + + result = address - block; + + if (trailer == 0) + { + return result; + } + + do + { + if (trailer->this_size <= 0) + abort (); + result += trailer->this_size; + trailer = (struct stk_trailer *) trailer->link; + } + while (trailer != 0); + + /* We are done. Note that if you present a bogus address (one + not in any segment), you will get a different number back, formed + from subtracting the address of the first block. This is probably + not what you want. */ + + return (result); +} + +#else /* not CRAY2 */ +/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. + Determine the number of the cell within the stack, + given the address of the cell. The purpose of this + routine is to linearize, in some sense, stack addresses + for alloca. */ + +static long +i00afunc (long address) +{ + long stkl = 0; + + long size, pseg, this_segment, stack; + long result = 0; + + struct stack_segment_linkage *ssptr; + + /* Register B67 contains the address of the end of the + current stack segment. If you (as a subprogram) store + your registers on the stack and find that you are past + the contents of B67, you have overflowed the segment. + + B67 also points to the stack segment linkage control + area, which is what we are really interested in. */ + + stkl = CRAY_STACKSEG_END (); + ssptr = (struct stack_segment_linkage *) stkl; + + /* If one subtracts 'size' from the end of the segment, + one has the address of the first word of the segment. + + If this is not the first segment, 'pseg' will be + nonzero. */ + + pseg = ssptr->sspseg; + size = ssptr->sssize; + + this_segment = stkl - size; + + /* It is possible that calling this routine itself caused + a stack overflow. Discard stack segments which do not + contain the target address. */ + + while (!(this_segment <= address && address <= stkl)) + { +#ifdef DEBUG_I00AFUNC + fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); +#endif + if (pseg == 0) + break; + stkl = stkl - pseg; + ssptr = (struct stack_segment_linkage *) stkl; + size = ssptr->sssize; + pseg = ssptr->sspseg; + this_segment = stkl - size; + } + + result = address - this_segment; + + /* If you subtract pseg from the current end of the stack, + you get the address of the previous stack segment's end. + This seems a little convoluted to me, but I'll bet you save + a cycle somewhere. */ + + while (pseg != 0) + { +#ifdef DEBUG_I00AFUNC + fprintf (stderr, "%011o %011o\n", pseg, size); +#endif + stkl = stkl - pseg; + ssptr = (struct stack_segment_linkage *) stkl; + size = ssptr->sssize; + pseg = ssptr->sspseg; + result += size; + } + return (result); +} + +#endif /* not CRAY2 */ +#endif /* CRAY */ + +#endif /* no alloca */ diff --git a/libiberty/argv.c b/libiberty/argv.c new file mode 100644 index 000000000000..60694f919bb9 --- /dev/null +++ b/libiberty/argv.c @@ -0,0 +1,333 @@ +/* Create and destroy argument vectors (argv's) + Copyright (C) 1992 Free Software Foundation, Inc. + Written by Fred Fish @ Cygnus Support + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* Create and destroy argument vectors. An argument vector is simply an + array of string pointers, terminated by a NULL pointer. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#ifdef isspace +#undef isspace +#endif +#define isspace(ch) ((ch) == ' ' || (ch) == '\t') + +/* Routines imported from standard C runtime libraries. */ + +#ifdef __STDC__ + +#include +extern void *memcpy (void *s1, const void *s2, size_t n); /* 4.11.2.1 */ +extern size_t strlen (const char *s); /* 4.11.6.3 */ +extern void *malloc (size_t size); /* 4.10.3.3 */ +extern void *realloc (void *ptr, size_t size); /* 4.10.3.4 */ +extern void free (void *ptr); /* 4.10.3.2 */ +extern char *strdup (const char *s); /* Non-ANSI */ + +#else /* !__STDC__ */ + +#if !defined _WIN32 || defined __GNUC__ +extern char *memcpy (); /* Copy memory region */ +extern int strlen (); /* Count length of string */ +extern char *malloc (); /* Standard memory allocater */ +extern char *realloc (); /* Standard memory reallocator */ +extern void free (); /* Free malloc'd memory */ +extern char *strdup (); /* Duplicate a string */ +#endif + +#endif /* __STDC__ */ + +#include "alloca-conf.h" + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef EOS +#define EOS '\0' +#endif + +#define INITIAL_MAXARGC 8 /* Number of args + NULL in initial argv */ + + +/* + +NAME + + freeargv -- free an argument vector + +SYNOPSIS + + void freeargv (vector) + char **vector; + +DESCRIPTION + + Free an argument vector that was built using buildargv. Simply scans + through the vector, freeing the memory for each argument until the + terminating NULL is found, and then frees the vector itself. + +RETURNS + + No value. + +*/ + +void freeargv (vector) +char **vector; +{ + register char **scan; + + if (vector != NULL) + { + for (scan = vector; *scan != NULL; scan++) + { + free (*scan); + } + free (vector); + } +} + +/* + +NAME + + buildargv -- build an argument vector from a string + +SYNOPSIS + + char **buildargv (sp) + char *sp; + +DESCRIPTION + + Given a pointer to a string, parse the string extracting fields + separated by whitespace and optionally enclosed within either single + or double quotes (which are stripped off), and build a vector of + pointers to copies of the string for each field. The input string + remains unchanged. + + All of the memory for the pointer array and copies of the string + is obtained from malloc. All of the memory can be returned to the + system with the single function call freeargv, which takes the + returned result of buildargv, as it's argument. + + The memory for the argv array is dynamically expanded as necessary. + +RETURNS + + Returns a pointer to the argument vector if successful. Returns NULL + if the input string pointer is NULL or if there is insufficient + memory to complete building the argument vector. + +NOTES + + In order to provide a working buffer for extracting arguments into, + with appropriate stripping of quotes and translation of backslash + sequences, we allocate a working buffer at least as long as the input + string. This ensures that we always have enough space in which to + work, since the extracted arg is never larger than the input string. + + If the input is a null string (as opposed to a NULL pointer), then + buildarg returns an argv that has one arg, a null string. + + Argv is always kept terminated with a NULL arg pointer, so it can + be passed to freeargv at any time, or returned, as appropriate. +*/ + +char **buildargv (input) +char *input; +{ + char *arg; + char *copybuf; + int squote = 0; + int dquote = 0; + int bsquote = 0; + int argc = 0; + int maxargc = 0; + char **argv = NULL; + char **nargv; + + if (input != NULL) + { + copybuf = alloca (strlen (input) + 1); + /* Is a do{}while to always execute the loop once. Always return an + argv, even for null strings. See NOTES above, test case below. */ + do + { + /* Pick off argv[argc] */ + while (isspace (*input)) + { + input++; + } + if ((maxargc == 0) || (argc >= (maxargc - 1))) + { + /* argv needs initialization, or expansion */ + if (argv == NULL) + { + maxargc = INITIAL_MAXARGC; + nargv = (char **) malloc (maxargc * sizeof (char *)); + } + else + { + maxargc *= 2; + nargv = (char **) realloc (argv, maxargc * sizeof (char *)); + } + if (nargv == NULL) + { + if (argv != NULL) + { + freeargv (argv); + argv = NULL; + } + break; + } + argv = nargv; + argv[argc] = NULL; + } + /* Begin scanning arg */ + arg = copybuf; + while (*input != EOS) + { + if (isspace (*input) && !squote && !dquote && !bsquote) + { + break; + } + else + { + if (bsquote) + { + bsquote = 0; + *arg++ = *input; + } + else if (*input == '\\') + { + bsquote = 1; + } + else if (squote) + { + if (*input == '\'') + { + squote = 0; + } + else + { + *arg++ = *input; + } + } + else if (dquote) + { + if (*input == '"') + { + dquote = 0; + } + else + { + *arg++ = *input; + } + } + else + { + if (*input == '\'') + { + squote = 1; + } + else if (*input == '"') + { + dquote = 1; + } + else + { + *arg++ = *input; + } + } + input++; + } + } + *arg = EOS; + argv[argc] = strdup (copybuf); + if (argv[argc] == NULL) + { + freeargv (argv); + argv = NULL; + break; + } + argc++; + argv[argc] = NULL; + + while (isspace (*input)) + { + input++; + } + } + while (*input != EOS); + } + return (argv); +} + +#ifdef MAIN + +/* Simple little test driver. */ + +static char *tests[] = +{ + "a simple command line", + "arg 'foo' is single quoted", + "arg \"bar\" is double quoted", + "arg \"foo bar\" has embedded whitespace", + "arg 'Jack said \\'hi\\'' has single quotes", + "arg 'Jack said \\\"hi\\\"' has double quotes", + "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 1 2 3 4 5 6 7 8 9", + + /* This should be expanded into only one argument. */ + "trailing-whitespace ", + + "", + NULL +}; + +main () +{ + char **argv; + char **test; + char **targs; + + for (test = tests; *test != NULL; test++) + { + printf ("buildargv(\"%s\")\n", *test); + if ((argv = buildargv (*test)) == NULL) + { + printf ("failed!\n\n"); + } + else + { + for (targs = argv; *targs != NULL; targs++) + { + printf ("\t\"%s\"\n", *targs); + } + printf ("\n"); + } + freeargv (argv); + } + +} + +#endif /* MAIN */ diff --git a/libiberty/atexit.c b/libiberty/atexit.c new file mode 100644 index 000000000000..4463cb695018 --- /dev/null +++ b/libiberty/atexit.c @@ -0,0 +1,14 @@ +/* Wrapper to implement ANSI C's atexit using SunOS's on_exit. */ +/* This function is in the public domain. --Mike Stump. */ + +#ifndef NEED_on_exit +int +atexit(f) + void (*f)(); +{ + /* If the system doesn't provide a definition for atexit, use on_exit + if the system provides that. */ + on_exit (f, 0); + return 0; +} +#endif diff --git a/libiberty/basename.c b/libiberty/basename.c new file mode 100644 index 000000000000..689b0c2d39a0 --- /dev/null +++ b/libiberty/basename.c @@ -0,0 +1,43 @@ +/* Return the basename of a pathname. + This file is in the public domain. */ + +/* +NAME + basename -- return pointer to last component of a pathname + +SYNOPSIS + char *basename (const char *name) + +DESCRIPTION + Given a pointer to a string containing a typical pathname + (/usr/src/cmd/ls/ls.c for example), returns a pointer to the + last component of the pathname ("ls.c" in this case). + +BUGS + Presumes a UNIX style path with UNIX style separators. +*/ + +#include "ansidecl.h" +#include "libiberty.h" + +#include "config.h" + +#ifdef NEED_basename + +char * +basename (name) + const char *name; +{ + const char *base = name; + + while (*name) + { + if (*name++ == '/') + { + base = name; + } + } + return (char *) base; +} + +#endif diff --git a/libiberty/bcmp.c b/libiberty/bcmp.c new file mode 100644 index 000000000000..11e4417db159 --- /dev/null +++ b/libiberty/bcmp.c @@ -0,0 +1,49 @@ +/* bcmp + This function is in the public domain. */ + +/* + +NAME + + bcmp -- compare two memory regions + +SYNOPSIS + + int bcmp (char *from, char *to, int count) + +DESCRIPTION + + Compare two memory regions and return zero if they are identical, + non-zero otherwise. If count is zero, return zero. + +NOTES + + No guarantee is made about the non-zero returned value. In + particular, the results may be signficantly different than + strcmp(), where the return value is guaranteed to be less than, + equal to, or greater than zero, according to lexicographical + sorting of the compared regions. + +BUGS + +*/ + + +int +bcmp (from, to, count) + char *from, *to; + int count; +{ + int rtnval = 0; + + while (count-- > 0) + { + if (*from++ != *to++) + { + rtnval = 1; + break; + } + } + return (rtnval); +} + diff --git a/libiberty/bcopy.c b/libiberty/bcopy.c new file mode 100644 index 000000000000..b655363d879e --- /dev/null +++ b/libiberty/bcopy.c @@ -0,0 +1,35 @@ +/* bcopy -- copy memory regions of arbitary length + +NAME + bcopy -- copy memory regions of arbitrary length + +SYNOPSIS + void bcopy (char *in, char *out, int length) + +DESCRIPTION + Copy LENGTH bytes from memory region pointed to by IN to memory + region pointed to by OUT. + +BUGS + Significant speed improvements can be made in some cases by + implementing copies of multiple bytes simultaneously, or unrolling + the copy loop. + +*/ + +void +bcopy (src, dest, len) + register char *src, *dest; + int len; +{ + if (dest < src) + while (len--) + *dest++ = *src++; + else + { + char *lasts = src + (len-1); + char *lastd = dest + (len-1); + while (len--) + *(char *)lastd-- = *(char *)lasts--; + } +} diff --git a/libiberty/bzero.c b/libiberty/bzero.c new file mode 100644 index 000000000000..d01644b7f4b8 --- /dev/null +++ b/libiberty/bzero.c @@ -0,0 +1,31 @@ +/* Portable version of bzero for systems without it. + This function is in the public domain. */ + +/* +NAME + bzero -- zero the contents of a specified memory region + +SYNOPSIS + void bzero (char *to, int count) + +DESCRIPTION + Zero COUNT bytes of memory pointed to by TO. + +BUGS + Significant speed enhancements may be made in some environments + by zeroing more than a single byte at a time, or by unrolling the + loop. + +*/ + + +void +bzero (to, count) + char *to; + int count; +{ + while (count-- > 0) + { + *to++ = 0; + } +} diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c new file mode 100644 index 000000000000..798de4822a58 --- /dev/null +++ b/libiberty/choose-temp.c @@ -0,0 +1,147 @@ +/* Utility to pick a temporary filename prefix. + Copyright (C) 1996 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If not, +write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This file exports one function: choose_temp_base. */ + +/* This file lives in at least two places: libiberty and gcc. + Don't change one without the other. */ + +#ifndef NO_SYS_FILE_H +#include +#include /* May get R_OK, etc. on some systems. */ +#endif + +#ifndef R_OK +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#endif + +#include /* May get P_tmpdir. */ + +#ifdef IN_GCC +#include "config.h" +#include "gansidecl.h" +extern char *xmalloc (); +#else +#include "ansidecl.h" +#include "libiberty.h" +#if defined (__MSDOS__) || defined (_WIN32) +#define DIR_SEPARATOR '\\' +#endif +#endif + +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +/* On MSDOS, write temp files in current dir + because there's no place else we can expect to use. */ +/* ??? Although the current directory is tried as a last resort, + this is left in so that on MSDOS it is prefered to /tmp on the + off chance that someone requires this, since that was the previous + behaviour. */ +#ifdef __MSDOS__ +#ifndef P_tmpdir +#define P_tmpdir "." +#endif +#endif + +/* Name of temporary file. + mktemp requires 6 trailing X's. */ +#define TEMP_FILE "ccXXXXXX" + +/* Subroutine of choose_temp_base. + If BASE is non-NULL, returh it. + Otherwise it checks if DIR is a usable directory. + If success, DIR is returned. + Otherwise NULL is returned. */ + +static char * +try (dir, base) + char *dir, *base; +{ + if (base != 0) + return base; + if (dir != 0 + && access (dir, R_OK | W_OK | X_OK) == 0) + return dir; + return 0; +} + +/* Return a prefix for temporary file names or NULL if unable to find one. + The current directory is chosen if all else fails so the program is + exited if a temporary directory can't be found (mktemp fails). + The buffer for the result is obtained with xmalloc. */ + +char * +choose_temp_base () +{ + char *base = 0; + char *temp_filename; + int len; + static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 }; + static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 }; + +#ifndef MPW + base = try (getenv ("TMPDIR"), base); + base = try (getenv ("TMP"), base); + base = try (getenv ("TEMP"), base); + +#ifdef P_tmpdir + base = try (P_tmpdir, base); +#endif + + /* Try /usr/tmp, then /tmp. */ + base = try (usrtmp, base); + base = try (tmp, base); + + /* If all else fails, use the current directory! */ + if (base == 0) +#ifdef VMS + base = "["; +#else + base = "."; +#endif + +#else /* MPW */ + base = ":"; +#endif + + len = strlen (base); + temp_filename = xmalloc (len + 1 /*DIR_SEPARATOR*/ + + strlen (TEMP_FILE) + 1); + strcpy (temp_filename, base); + +#ifndef MPW + if (len != 0 + && temp_filename[len-1] != '/' + && temp_filename[len-1] != DIR_SEPARATOR) + temp_filename[len++] = DIR_SEPARATOR; +#else /* MPW */ + if (temp_filename[len-1] != ':') + temp_filename[len++] = ':'; +#endif /* MPW */ + strcpy (temp_filename + len, TEMP_FILE); + + mktemp (temp_filename); + if (strlen (temp_filename) == 0) + abort (); + return temp_filename; +} diff --git a/libiberty/clock.c b/libiberty/clock.c new file mode 100644 index 000000000000..b60de1657a45 --- /dev/null +++ b/libiberty/clock.c @@ -0,0 +1,73 @@ +/* ANSI-compatible clock function. + Copyright (C) 1994, 1995 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. */ + +#ifdef HAVE_GETRUSAGE +#include +#include +#endif + +#ifdef HAVE_TIMES +#ifndef NO_SYS_PARAM_H +#include +#endif +#include +#endif + +/* FIXME: should be able to declare as clock_t. */ + +long +clock () +{ +#ifdef HAVE_GETRUSAGE + struct rusage rusage; + + getrusage (0, &rusage); + return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec + + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); +#else +#ifdef HAVE_TIMES + struct tms tms; + + times (&tms); + return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); +#else +#ifdef VMS + struct + { + int proc_user_time; + int proc_system_time; + int child_user_time; + int child_system_time; + } vms_times; + + times (&vms_times); + return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; +#else + /* A fallback, if nothing else available. */ + return 0; +#endif /* VMS */ +#endif /* HAVE_TIMES */ +#endif /* HAVE_GETRUSAGE */ +} + diff --git a/libiberty/concat.c b/libiberty/concat.c new file mode 100644 index 000000000000..5b132c85764f --- /dev/null +++ b/libiberty/concat.c @@ -0,0 +1,167 @@ +/* Concatenate variable number of strings. + Copyright (C) 1991, 1994 Free Software Foundation, Inc. + Written by Fred Fish @ Cygnus Support + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* + +NAME + + concat -- concatenate a variable number of strings + +SYNOPSIS + + #include + + char *concat (s1, s2, s3, ..., NULL) + +DESCRIPTION + + Concatenate a variable number of strings and return the result + in freshly malloc'd memory. + + Returns NULL if insufficient memory is available. The argument + list is terminated by the first NULL pointer encountered. Pointers + to empty strings are ignored. + +NOTES + + This function uses xmalloc() which is expected to be a front end + function to malloc() that deals with low memory situations. In + typical use, if malloc() returns NULL then xmalloc() diverts to an + error handler routine which never returns, and thus xmalloc will + never return a NULL pointer. If the client application wishes to + deal with low memory situations itself, it should supply an xmalloc + that just directly invokes malloc and blindly returns whatever + malloc returns. +*/ + + +#include "ansidecl.h" +#include "libiberty.h" + +#ifdef ANSI_PROTOTYPES +#include +#else +#include +#endif + +#ifdef __STDC__ +#include +extern size_t strlen (const char *s); +#else +extern int strlen (); +#endif + +#define NULLP (char *)0 + +/* VARARGS */ +#ifdef ANSI_PROTOTYPES +char * +concat (const char *first, ...) +#else +char * +concat (va_alist) + va_dcl +#endif +{ + register int length; + register char *newstr; + register char *end; + register const char *arg; + va_list args; +#ifndef ANSI_PROTOTYPES + const char *first; +#endif + + /* First compute the size of the result and get sufficient memory. */ + +#ifdef ANSI_PROTOTYPES + va_start (args, first); +#else + va_start (args); + first = va_arg (args, const char *); +#endif + + if (first == NULLP) + length = 0; + else + { + length = strlen (first); + while ((arg = va_arg (args, const char *)) != NULLP) + { + length += strlen (arg); + } + } + newstr = (char *) xmalloc (length + 1); + va_end (args); + + /* Now copy the individual pieces to the result string. */ + + if (newstr != NULLP) + { +#ifdef ANSI_PROTOTYPES + va_start (args, first); +#else + va_start (args); + first = va_arg (args, const char *); +#endif + end = newstr; + if (first != NULLP) + { + arg = first; + while (*arg) + { + *end++ = *arg++; + } + while ((arg = va_arg (args, const char *)) != NULLP) + { + while (*arg) + { + *end++ = *arg++; + } + } + } + *end = '\000'; + va_end (args); + } + + return (newstr); +} + +#ifdef MAIN + +/* Simple little test driver. */ + +#include + +int +main () +{ + printf ("\"\" = \"%s\"\n", concat (NULLP)); + printf ("\"a\" = \"%s\"\n", concat ("a", NULLP)); + printf ("\"ab\" = \"%s\"\n", concat ("a", "b", NULLP)); + printf ("\"abc\" = \"%s\"\n", concat ("a", "b", "c", NULLP)); + printf ("\"abcd\" = \"%s\"\n", concat ("ab", "cd", NULLP)); + printf ("\"abcde\" = \"%s\"\n", concat ("ab", "c", "de", NULLP)); + printf ("\"abcdef\" = \"%s\"\n", concat ("", "a", "", "bcd", "ef", NULLP)); + return 0; +} + +#endif diff --git a/libiberty/config.h-vms b/libiberty/config.h-vms new file mode 100644 index 000000000000..ccac6a2bcc73 --- /dev/null +++ b/libiberty/config.h-vms @@ -0,0 +1,13 @@ +#ifndef NEED_strerror +#define NEED_strerror +#endif +#ifndef NEED_basename +#define NEED_basename +#endif +#ifndef NEED_psignal +#define NEED_psignal +#endif +#ifndef NEED_on_exit +#define NEED_on_exit +#endif + diff --git a/libiberty/config.table b/libiberty/config.table new file mode 100644 index 000000000000..dba783b489f0 --- /dev/null +++ b/libiberty/config.table @@ -0,0 +1,69 @@ +case "${host}" in + rs6000-ibm-aix3.1 | rs6000-ibm-aix) + frag=mh-aix + files=${xsrcdir}alloca-botch.h ;; + *-ibm-aix*) files=${xsrcdir}alloca-botch.h ;; + arm-*-riscix*) frag=mh-riscix ;; + m68k-apollo-bsd*) frag=mh-a68bsd ;; + m68k-apollo-sysv*) frag=mh-apollo68 ;; + i[3456]86-ncr-sysv4*) frag=mh-ncr3000 ;; + *-*-cxux7*) frag=mh-cxux7 ;; + *-*-cygwin32) frag=mh-cygwin32 ;; + *-*-dgux*) frag=mh-sysv ;; + hppa*-hp-bsd*) frag=mh-hpbsd ;; + *-*-hpux*) frag=mh-hpux ;; + *-*-hiux*) frag=mh-hpux ;; + *-*-irix4*) frag=mh-irix4 ;; + *-*-irix*) frag=mh-sysv ;; + *-*-m88kbcs*) frag=mh-sysv ;; + *-*-solaris2*) frag=mh-sysv4 ;; + *-*-sysv4*) frag=mh-sysv4 ;; + *-*-sysv*) frag=mh-sysv ;; + *-*-go32) frag=mh-go32 ;; + i[345]86-*-windows*) frag=mh-windows ;; + + *-*-vxworks5*) + # VxWorks 5 needs special action, because the usual + # autoconfiguration scheme does not work. + frag=mt-vxworks5 + ;; +esac + +# Try to handle funky case of solaris 2 -> sun 4. +case "${host}" in + sparc-sun-sunos4.1.3) + if [ "${with_cross_host}" != "${host}" ] ; then + frag=mt-sunos4 + fi + ;; +esac + +frags=$frag + +# If they didn't specify --enable-shared, don't generate shared libs. +case "${enable_shared}" in + yes) shared=yes ;; + no) shared=no ;; + *) shared=yes ;; +esac +if [ "${shared}" = "yes" ]; then + case "${host}" in + hppa*-*-*) frags="${frags} ../../config/mh-papic" ;; + i[3456]86-*-*) frags="${frags} ../../config/mh-x86pic" ;; + *-*-*) frags="${frags} ../../config/mh-${host_cpu}pic" ;; + esac +fi + +echo "# Warning: this fragment is automatically generated" > temp-frag + +for frag in ${frags}; do + frag=${srcdir}/${xsrcdir}config/$frag + if [ -f ${frag} ]; then + echo "Appending ${frag} to xhost-mkfrag" + echo "# Following fragment copied from ${frag}" >> temp-frag + cat ${frag} >> temp-frag + fi +done + +frag=xhost-mkfrag +${config_shell} ${moveifchange} temp-frag xhost-mkfrag diff --git a/libiberty/config/mh-a68bsd b/libiberty/config/mh-a68bsd new file mode 100644 index 000000000000..3c5a237e60ba --- /dev/null +++ b/libiberty/config/mh-a68bsd @@ -0,0 +1,2 @@ +RANLIB=ranlib +CC= cc -A ansi -A runtype,any -A systype,any -U__STDC__ diff --git a/libiberty/config/mh-aix b/libiberty/config/mh-aix new file mode 100644 index 000000000000..c7b848d976aa --- /dev/null +++ b/libiberty/config/mh-aix @@ -0,0 +1,10 @@ +HDEFINES = -D__IEEE_BIG_ENDIAN +RANLIB=true +INSTALL=cp + +# Most releases of AIX 3.1 include an incorrect internal version of copysign +# in libc.a for use by some libc public functions including modf. The public +# version of copysign in libm.a is usable. For the sake of libg++ (which +# uses modf), we add copysign here. Supposedly, this problem is fixed in AIX +# 3.1.8 and above, including all releases of AIX 3.2. +EXTRA_OFILES = copysign.o diff --git a/libiberty/config/mh-apollo68 b/libiberty/config/mh-apollo68 new file mode 100644 index 000000000000..651770ce31cd --- /dev/null +++ b/libiberty/config/mh-apollo68 @@ -0,0 +1,2 @@ +RANLIB=true +CC= cc -A ansi -A runtype,any -A systype,any -U__STDC__ diff --git a/libiberty/config/mh-cxux7 b/libiberty/config/mh-cxux7 new file mode 100644 index 000000000000..6d4d30bf46ff --- /dev/null +++ b/libiberty/config/mh-cxux7 @@ -0,0 +1,3 @@ +HDEFINES = -DHAVE_SYSCONF -DHARRIS_FLOAT_FORMAT +RANLIB=true +INSTALL = cp diff --git a/libiberty/config/mh-cygwin32 b/libiberty/config/mh-cygwin32 new file mode 100644 index 000000000000..f45bdc8bad79 --- /dev/null +++ b/libiberty/config/mh-cygwin32 @@ -0,0 +1,2 @@ +HDEFINES=-DNEED_sys_siglist -DNEED_basename -DNEED_strsignal +EXTRA_OFILES=vasprintf.o random.o diff --git a/libiberty/config/mh-go32 b/libiberty/config/mh-go32 new file mode 100644 index 000000000000..919290ef5396 --- /dev/null +++ b/libiberty/config/mh-go32 @@ -0,0 +1 @@ +HDEFINES=-DHAVE_GETRUSAGE diff --git a/libiberty/config/mh-hpbsd b/libiberty/config/mh-hpbsd new file mode 100644 index 000000000000..ce11dcd6ac98 --- /dev/null +++ b/libiberty/config/mh-hpbsd @@ -0,0 +1,2 @@ +# HPPA hosts using BSD +RANLIB=true diff --git a/libiberty/config/mh-irix4 b/libiberty/config/mh-irix4 new file mode 100644 index 000000000000..ace767827122 --- /dev/null +++ b/libiberty/config/mh-irix4 @@ -0,0 +1,4 @@ +CC = cc -cckr +RANLIB = true +INSTALL = cp +EXTRA_OFILES = alloca.o diff --git a/libiberty/config/mh-ncr3000 b/libiberty/config/mh-ncr3000 new file mode 100644 index 000000000000..3a45c22b1281 --- /dev/null +++ b/libiberty/config/mh-ncr3000 @@ -0,0 +1,19 @@ +# Host configuration file for an NCR 3000 (i486/SVR4) system. + +# The NCR 3000 ships with a MetaWare compiler installed as /bin/cc. +# This compiler not only emits obnoxious copyright messages every time +# you run it, but it chokes and dies on a whole bunch of GNU source +# files. Default to using the AT&T compiler installed in /usr/ccs/ATT/cc. +# Unfortunately though, the AT&T compiler sometimes generates code that +# the assembler barfs on if -g is used, so disable it by default as well. +CC = /usr/ccs/ATT/cc +CFLAGS = + +RANLIB = true + +# The /usr/ucb/install program is incompatible (complains about unknown +# group staff). Use good old cp... +INSTALL = cp + +# The l flag generates a warning from the SVR4 archiver, remove it. +AR_FLAGS = cq diff --git a/libiberty/config/mh-riscix b/libiberty/config/mh-riscix new file mode 100644 index 000000000000..0209279de56a --- /dev/null +++ b/libiberty/config/mh-riscix @@ -0,0 +1,6 @@ +# The native linker only reports the first undefined symbol if linking with a +# shared library. So build using gcc and link statically (this requires +# gcc 2.6.0 or above). + +ERRORS_CC = gcc +ERRORS_LDFLAGS = -static diff --git a/libiberty/config/mh-sysv b/libiberty/config/mh-sysv new file mode 100644 index 000000000000..eb102d550108 --- /dev/null +++ b/libiberty/config/mh-sysv @@ -0,0 +1 @@ +RANLIB=true diff --git a/libiberty/config/mh-sysv4 b/libiberty/config/mh-sysv4 new file mode 100644 index 000000000000..4d1aa3cd61d5 --- /dev/null +++ b/libiberty/config/mh-sysv4 @@ -0,0 +1,3 @@ +HDEFINES = -DHAVE_SYSCONF +RANLIB=true +INSTALL = cp diff --git a/libiberty/config/mh-windows b/libiberty/config/mh-windows new file mode 100644 index 000000000000..f20c51f21910 --- /dev/null +++ b/libiberty/config/mh-windows @@ -0,0 +1,2 @@ +HDEFINES=-DNEED_basename -DNEED_sys_siglist -DNEED_strsignal -DNO_SYS_FILE_H +EXTRA_OFILES=strcasecmp.o vasprintf.o diff --git a/libiberty/config/mt-sunos4 b/libiberty/config/mt-sunos4 new file mode 100644 index 000000000000..c25baa6ead68 --- /dev/null +++ b/libiberty/config/mt-sunos4 @@ -0,0 +1,2 @@ +XTRAFLAGS = -isystem /s1/cygnus/dejagnu/sparc-sun-sunos4.1.3/include/ +LOADLIBES = -L/s1/cygnus/dejagnu/sparc-sun-sunos4.1.3/lib diff --git a/libiberty/config/mt-vxworks5 b/libiberty/config/mt-vxworks5 new file mode 100644 index 000000000000..916d69e55214 --- /dev/null +++ b/libiberty/config/mt-vxworks5 @@ -0,0 +1,28 @@ +# VxWorks 5.x target Makefile fragment. +# The autoconfiguration fails for a VxWorks target, because the +# libraries are actually on the target board, not in the file system. +# Therefore, we compute the dependencies by hand. + +HDEFINES = -DNO_SYS_PARAM_H -DNO_SYS_FILE_H +CONFIG_H = vxconfig.h +NEEDED_LIST = vxneeded-list + +vxconfig.h: Makefile + if [ -f ../newlib/Makefile ]; then \ + $(MAKE) $(FLAGS_TO_PASS) xconfig.h; \ + cp xconfig.h vxconfig.h; \ + else \ + echo "#define NEED_sys_nerr 1" >vxconfig.h; \ + echo "#define NEED_sys_errlist 1" >>vxconfig.h; \ + echo "#define NEED_sys_siglist 1" >>vxconfig.h; \ + echo "#define NEED_strsignal 1" >>vxconfig.h; \ + echo "#define NEED_psignal 1" >>vxconfig.h; \ + fi + +vxneeded-list: Makefile + if [ -f ../newlib/Makefile ]; then \ + $(MAKE) $(FLAGS_TO_PASS) xneeded-list; \ + cp xneeded-list vxneeded-list; \ + else \ + echo getopt.o getpagesize.o insque.o random.o strcasecmp.o strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o >vxneeded-list; \ + fi diff --git a/libiberty/configure.bat b/libiberty/configure.bat new file mode 100644 index 000000000000..ed33777174b3 --- /dev/null +++ b/libiberty/configure.bat @@ -0,0 +1,15 @@ +@echo off +if "%1" == "h8/300" goto h8300 + +echo Configuring libiberty for go32 +copy Makefile.dos Makefile +echo #define NEED_sys_siglist 1 >> config.h +echo #define NEED_psignal 1 >> config.h +update alloca-normal.h alloca-conf.h +goto exit + +:h8300 +echo Configuring libiberty for H8/300 +copy Makefile.dos Makefile + +:exit diff --git a/libiberty/configure.in b/libiberty/configure.in new file mode 100644 index 000000000000..b0020d8bab42 --- /dev/null +++ b/libiberty/configure.in @@ -0,0 +1,66 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../configure. + +configdirs= +srctrigger=getopt1.c +srcname="-liberty library" + +# per-host: + +files="alloca-norm.h" +links="alloca-conf.h" + +. ${srcdir}/config.table +host_makefile_frag=${frag} + +# per-target: + +# post-target: + +# If this is the target libiberty, check at compile time whether we are using +# newlib. If we are, we already know the files we need, since the linker +# will fail when run on some of the newlib targets. +if [ -n "${with_target_subdir}" ] ; then + cat > Makefile.tem <<'!EOF!' +CONFIG_H = xconfig.h +NEEDED_LIST = xneeded-list + +xconfig.h: Makefile + if [ -f ../newlib/Makefile ]; then \ + echo "#define NEED_sys_nerr 1" >xconfig.h; \ + echo "#define NEED_sys_errlist 1" >>xconfig.h; \ + echo "#define NEED_sys_siglist 1" >>xconfig.h; \ + echo "#define NEED_strsignal 1" >>xconfig.h; \ + echo "#define NEED_psignal 1" >>xconfig.h; \ + else \ + $(MAKE) $(FLAGS_TO_PASS) lconfig.h; \ + cp lconfig.h xconfig.h; \ + fi + +xneeded-list: Makefile + if [ -f ../newlib/Makefile ]; then \ + echo insque.o random.o strdup.o alloca.o vasprintf.o >xneeded-list; \ + else \ + $(MAKE) $(FLAGS_TO_PASS) lneeded-list; \ + cp lneeded-list xneeded-list; \ + fi +!EOF! +sed -e "/^####/ r Makefile.tem" \ + -e '/INSTALL_DEST =/s/libdir/tooldir/' ${Makefile} > Makefile.tem3 +mv Makefile.tem3 ${Makefile} +rm -f Makefile.tem +fi + +# We need multilib support, but only if configuring for the target. +if [ -n "${with_target_subdir}" ] ; then + if [ "${srcdir}" = "." ] ; then + if [ "${with_target_subdir}" != "." ] ; then + . ${with_multisrctop}../../config-ml.in + else + . ${with_multisrctop}../config-ml.in + fi + else + . ${srcdir}/../config-ml.in + fi +fi diff --git a/libiberty/copysign.c b/libiberty/copysign.c new file mode 100644 index 000000000000..0b5f8c3d9df8 --- /dev/null +++ b/libiberty/copysign.c @@ -0,0 +1,140 @@ +#include + +#ifdef __IEEE_BIG_ENDIAN + +typedef union +{ + double value; + struct + { + unsigned int sign : 1; + unsigned int exponent: 11; + unsigned int fraction0:4; + unsigned int fraction1:16; + unsigned int fraction2:16; + unsigned int fraction3:16; + + } number; + struct + { + unsigned int sign : 1; + unsigned int exponent: 11; + unsigned int quiet:1; + unsigned int function0:3; + unsigned int function1:16; + unsigned int function2:16; + unsigned int function3:16; + } nan; + struct + { + unsigned long msw; + unsigned long lsw; + } parts; + long aslong[2]; +} __ieee_double_shape_type; + +#endif + +#ifdef __IEEE_LITTLE_ENDIAN + +typedef union +{ + double value; + struct + { +#ifdef __SMALL_BITFIELDS + unsigned int fraction3:16; + unsigned int fraction2:16; + unsigned int fraction1:16; + unsigned int fraction0: 4; +#else + unsigned int fraction1:32; + unsigned int fraction0:20; +#endif + unsigned int exponent :11; + unsigned int sign : 1; + } number; + struct + { +#ifdef __SMALL_BITFIELDS + unsigned int function3:16; + unsigned int function2:16; + unsigned int function1:16; + unsigned int function0:3; +#else + unsigned int function1:32; + unsigned int function0:19; +#endif + unsigned int quiet:1; + unsigned int exponent: 11; + unsigned int sign : 1; + } nan; + struct + { + unsigned long lsw; + unsigned long msw; + } parts; + + long aslong[2]; + +} __ieee_double_shape_type; + +#endif + +#ifdef __IEEE_BIG_ENDIAN +typedef union +{ + float value; + struct + { + unsigned int sign : 1; + unsigned int exponent: 8; + unsigned int fraction0: 7; + unsigned int fraction1: 16; + } number; + struct + { + unsigned int sign:1; + unsigned int exponent:8; + unsigned int quiet:1; + unsigned int function0:6; + unsigned int function1:16; + } nan; + long p1; + +} __ieee_float_shape_type; +#endif + +#ifdef __IEEE_LITTLE_ENDIAN +typedef union +{ + float value; + struct + { + unsigned int fraction0: 7; + unsigned int fraction1: 16; + unsigned int exponent: 8; + unsigned int sign : 1; + } number; + struct + { + unsigned int function1:16; + unsigned int function0:6; + unsigned int quiet:1; + unsigned int exponent:8; + unsigned int sign:1; + } nan; + long p1; + +} __ieee_float_shape_type; +#endif + + +double DEFUN(copysign, (x, y), double x AND double y) +{ + __ieee_double_shape_type a,b; + b.value = y; + a.value = x; + a.number.sign =b.number.sign; + return a.value; +} diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c new file mode 100644 index 000000000000..5794a5bb869e --- /dev/null +++ b/libiberty/cplus-dem.c @@ -0,0 +1,3087 @@ +/* Demangler for GNU C++ + Copyright 1989, 1991, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Written by James Clark (jjc@jclark.uucp) + Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This file exports two functions; cplus_mangle_opname and cplus_demangle. + + This file imports xmalloc and xrealloc, which are like malloc and + realloc except that they generate a fatal error if there is no + available memory. */ + +/* This file lives in both GCC and libiberty. When making changes, please + try not to break either. */ + +#include +#include +#include + +#include +#undef CURRENT_DEMANGLING_STYLE +#define CURRENT_DEMANGLING_STYLE work->options + +extern char *xmalloc PARAMS((unsigned)); +extern char *xrealloc PARAMS((char *, unsigned)); + +static const char *mystrstr PARAMS ((const char *, const char *)); + +static const char * +mystrstr (s1, s2) + const char *s1, *s2; +{ + register const char *p = s1; + register int len = strlen (s2); + + for (; (p = strchr (p, *s2)) != 0; p++) + { + if (strncmp (p, s2, len) == 0) + { + return (p); + } + } + return (0); +} + +/* In order to allow a single demangler executable to demangle strings + using various common values of CPLUS_MARKER, as well as any specific + one set at compile time, we maintain a string containing all the + commonly used ones, and check to see if the marker we are looking for + is in that string. CPLUS_MARKER is usually '$' on systems where the + assembler can deal with that. Where the assembler can't, it's usually + '.' (but on many systems '.' is used for other things). We put the + current defined CPLUS_MARKER first (which defaults to '$'), followed + by the next most common value, followed by an explicit '$' in case + the value of CPLUS_MARKER is not '$'. + + We could avoid this if we could just get g++ to tell us what the actual + cplus marker character is as part of the debug information, perhaps by + ensuring that it is the character that terminates the gcc_compiled + marker symbol (FIXME). */ + +#if !defined (CPLUS_MARKER) +#define CPLUS_MARKER '$' +#endif + +enum demangling_styles current_demangling_style = gnu_demangling; + +static char cplus_markers[] = { CPLUS_MARKER, '.', '$', '\0' }; + +void +set_cplus_marker_for_demangling (ch) + int ch; +{ + cplus_markers[0] = ch; +} + +/* Stuff that is shared between sub-routines. + Using a shared structure allows cplus_demangle to be reentrant. */ + +struct work_stuff +{ + int options; + char **typevec; + int ntypes; + int typevec_size; + int constructor; + int destructor; + int static_type; /* A static member function */ + int const_type; /* A const member function */ +}; + +#define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI) +#define PRINT_ARG_TYPES (work -> options & DMGL_PARAMS) + +static const struct optable +{ + const char *in; + const char *out; + int flags; +} optable[] = { + {"nw", " new", DMGL_ANSI}, /* new (1.92, ansi) */ + {"dl", " delete", DMGL_ANSI}, /* new (1.92, ansi) */ + {"new", " new", 0}, /* old (1.91, and 1.x) */ + {"delete", " delete", 0}, /* old (1.91, and 1.x) */ + {"vn", " new []", DMGL_ANSI}, /* GNU, pending ansi */ + {"vd", " delete []", DMGL_ANSI}, /* GNU, pending ansi */ + {"as", "=", DMGL_ANSI}, /* ansi */ + {"ne", "!=", DMGL_ANSI}, /* old, ansi */ + {"eq", "==", DMGL_ANSI}, /* old, ansi */ + {"ge", ">=", DMGL_ANSI}, /* old, ansi */ + {"gt", ">", DMGL_ANSI}, /* old, ansi */ + {"le", "<=", DMGL_ANSI}, /* old, ansi */ + {"lt", "<", DMGL_ANSI}, /* old, ansi */ + {"plus", "+", 0}, /* old */ + {"pl", "+", DMGL_ANSI}, /* ansi */ + {"apl", "+=", DMGL_ANSI}, /* ansi */ + {"minus", "-", 0}, /* old */ + {"mi", "-", DMGL_ANSI}, /* ansi */ + {"ami", "-=", DMGL_ANSI}, /* ansi */ + {"mult", "*", 0}, /* old */ + {"ml", "*", DMGL_ANSI}, /* ansi */ + {"amu", "*=", DMGL_ANSI}, /* ansi (ARM/Lucid) */ + {"aml", "*=", DMGL_ANSI}, /* ansi (GNU/g++) */ + {"convert", "+", 0}, /* old (unary +) */ + {"negate", "-", 0}, /* old (unary -) */ + {"trunc_mod", "%", 0}, /* old */ + {"md", "%", DMGL_ANSI}, /* ansi */ + {"amd", "%=", DMGL_ANSI}, /* ansi */ + {"trunc_div", "/", 0}, /* old */ + {"dv", "/", DMGL_ANSI}, /* ansi */ + {"adv", "/=", DMGL_ANSI}, /* ansi */ + {"truth_andif", "&&", 0}, /* old */ + {"aa", "&&", DMGL_ANSI}, /* ansi */ + {"truth_orif", "||", 0}, /* old */ + {"oo", "||", DMGL_ANSI}, /* ansi */ + {"truth_not", "!", 0}, /* old */ + {"nt", "!", DMGL_ANSI}, /* ansi */ + {"postincrement","++", 0}, /* old */ + {"pp", "++", DMGL_ANSI}, /* ansi */ + {"postdecrement","--", 0}, /* old */ + {"mm", "--", DMGL_ANSI}, /* ansi */ + {"bit_ior", "|", 0}, /* old */ + {"or", "|", DMGL_ANSI}, /* ansi */ + {"aor", "|=", DMGL_ANSI}, /* ansi */ + {"bit_xor", "^", 0}, /* old */ + {"er", "^", DMGL_ANSI}, /* ansi */ + {"aer", "^=", DMGL_ANSI}, /* ansi */ + {"bit_and", "&", 0}, /* old */ + {"ad", "&", DMGL_ANSI}, /* ansi */ + {"aad", "&=", DMGL_ANSI}, /* ansi */ + {"bit_not", "~", 0}, /* old */ + {"co", "~", DMGL_ANSI}, /* ansi */ + {"call", "()", 0}, /* old */ + {"cl", "()", DMGL_ANSI}, /* ansi */ + {"alshift", "<<", 0}, /* old */ + {"ls", "<<", DMGL_ANSI}, /* ansi */ + {"als", "<<=", DMGL_ANSI}, /* ansi */ + {"arshift", ">>", 0}, /* old */ + {"rs", ">>", DMGL_ANSI}, /* ansi */ + {"ars", ">>=", DMGL_ANSI}, /* ansi */ + {"component", "->", 0}, /* old */ + {"pt", "->", DMGL_ANSI}, /* ansi; Lucid C++ form */ + {"rf", "->", DMGL_ANSI}, /* ansi; ARM/GNU form */ + {"indirect", "*", 0}, /* old */ + {"method_call", "->()", 0}, /* old */ + {"addr", "&", 0}, /* old (unary &) */ + {"array", "[]", 0}, /* old */ + {"vc", "[]", DMGL_ANSI}, /* ansi */ + {"compound", ", ", 0}, /* old */ + {"cm", ", ", DMGL_ANSI}, /* ansi */ + {"cond", "?:", 0}, /* old */ + {"cn", "?:", DMGL_ANSI}, /* pseudo-ansi */ + {"max", ">?", 0}, /* old */ + {"mx", ">?", DMGL_ANSI}, /* pseudo-ansi */ + {"min", "*", DMGL_ANSI} /* ansi */ +}; + + +typedef struct string /* Beware: these aren't required to be */ +{ /* '\0' terminated. */ + char *b; /* pointer to start of string */ + char *p; /* pointer after last character */ + char *e; /* pointer after end of allocated space */ +} string; + +#define STRING_EMPTY(str) ((str) -> b == (str) -> p) +#define PREPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ + string_prepend(str, " ");} +#define APPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ + string_append(str, " ");} + +#define ARM_VTABLE_STRING "__vtbl__" /* Lucid/ARM virtual table prefix */ +#define ARM_VTABLE_STRLEN 8 /* strlen (ARM_VTABLE_STRING) */ + +/* Prototypes for local functions */ + +static char * +mop_up PARAMS ((struct work_stuff *, string *, int)); + +#if 0 +static int +demangle_method_args PARAMS ((struct work_stuff *work, const char **, string *)); +#endif + +static int +demangle_template PARAMS ((struct work_stuff *work, const char **, string *, + string *)); + +static int +arm_pt PARAMS ((struct work_stuff *, const char *, int, const char **, + const char **)); + +static void +demangle_arm_pt PARAMS ((struct work_stuff *, const char **, int, string *)); + +static int +demangle_class_name PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_qualified PARAMS ((struct work_stuff *, const char **, string *, + int, int)); + +static int +demangle_class PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_fund_type PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_signature PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_prefix PARAMS ((struct work_stuff *, const char **, string *)); + +static int +gnu_special PARAMS ((struct work_stuff *, const char **, string *)); + +static int +arm_special PARAMS ((struct work_stuff *, const char **, string *)); + +static void +string_need PARAMS ((string *, int)); + +static void +string_delete PARAMS ((string *)); + +static void +string_init PARAMS ((string *)); + +static void +string_clear PARAMS ((string *)); + +#if 0 +static int +string_empty PARAMS ((string *)); +#endif + +static void +string_append PARAMS ((string *, const char *)); + +static void +string_appends PARAMS ((string *, string *)); + +static void +string_appendn PARAMS ((string *, const char *, int)); + +static void +string_prepend PARAMS ((string *, const char *)); + +static void +string_prependn PARAMS ((string *, const char *, int)); + +static int +get_count PARAMS ((const char **, int *)); + +static int +consume_count PARAMS ((const char **)); + +static int +demangle_args PARAMS ((struct work_stuff *, const char **, string *)); + +static int +do_type PARAMS ((struct work_stuff *, const char **, string *)); + +static int +do_arg PARAMS ((struct work_stuff *, const char **, string *)); + +static void +demangle_function_name PARAMS ((struct work_stuff *, const char **, string *, + const char *)); + +static void +remember_type PARAMS ((struct work_stuff *, const char *, int)); + +static void +forget_types PARAMS ((struct work_stuff *)); + +static void +string_prepends PARAMS ((string *, string *)); + +/* Translate count to integer, consuming tokens in the process. + Conversion terminates on the first non-digit character. + Trying to consume something that isn't a count results in + no consumption of input and a return of 0. */ + +static int +consume_count (type) + const char **type; +{ + int count = 0; + + while (isdigit (**type)) + { + count *= 10; + count += **type - '0'; + (*type)++; + } + return (count); +} + +int +cplus_demangle_opname (opname, result, options) + const char *opname; + char *result; + int options; +{ + int len, i, len1, ret; + string type; + struct work_stuff work[1]; + const char *tem; + + len = strlen(opname); + result[0] = '\0'; + ret = 0; + work->options = options; + + if (opname[0] == '_' && opname[1] == '_' + && opname[2] == 'o' && opname[3] == 'p') + { + /* ANSI. */ + /* type conversion operator. */ + tem = opname + 4; + if (do_type (work, &tem, &type)) + { + strcat (result, "operator "); + strncat (result, type.b, type.p - type.b); + string_delete (&type); + ret = 1; + } + } + else if (opname[0] == '_' && opname[1] == '_' + && opname[2] >= 'a' && opname[2] <= 'z' + && opname[3] >= 'a' && opname[3] <= 'z') + { + if (opname[4] == '\0') + { + /* Operator. */ + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 2 + && memcmp (optable[i].in, opname + 2, 2) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + ret = 1; + break; + } + } + } + else + { + if (opname[2] == 'a' && opname[5] == '\0') + { + /* Assignment. */ + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 3 + && memcmp (optable[i].in, opname + 2, 3) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + ret = 1; + break; + } + } + } + } + } + else if (len >= 3 + && opname[0] == 'o' + && opname[1] == 'p' + && strchr (cplus_markers, opname[2]) != NULL) + { + /* see if it's an assignment expression */ + if (len >= 10 /* op$assign_ */ + && memcmp (opname + 3, "assign_", 7) == 0) + { + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + len1 = len - 10; + if (strlen (optable[i].in) == len1 + && memcmp (optable[i].in, opname + 10, len1) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + strcat (result, "="); + ret = 1; + break; + } + } + } + else + { + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + len1 = len - 3; + if (strlen (optable[i].in) == len1 + && memcmp (optable[i].in, opname + 3, len1) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + ret = 1; + break; + } + } + } + } + else if (len >= 5 && memcmp (opname, "type", 4) == 0 + && strchr (cplus_markers, opname[4]) != NULL) + { + /* type conversion operator */ + tem = opname + 5; + if (do_type (work, &tem, &type)) + { + strcat (result, "operator "); + strncat (result, type.b, type.p - type.b); + string_delete (&type); + ret = 1; + } + } + return ret; + +} +/* Takes operator name as e.g. "++" and returns mangled + operator name (e.g. "postincrement_expr"), or NULL if not found. + + If OPTIONS & DMGL_ANSI == 1, return the ANSI name; + if OPTIONS & DMGL_ANSI == 0, return the old GNU name. */ + +const char * +cplus_mangle_opname (opname, options) + const char *opname; + int options; +{ + int i; + int len; + + len = strlen (opname); + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].out) == len + && (options & DMGL_ANSI) == (optable[i].flags & DMGL_ANSI) + && memcmp (optable[i].out, opname, len) == 0) + return optable[i].in; + } + return (0); +} + +/* char *cplus_demangle (const char *mangled, int options) + + If MANGLED is a mangled function name produced by GNU C++, then + a pointer to a malloced string giving a C++ representation + of the name will be returned; otherwise NULL will be returned. + It is the caller's responsibility to free the string which + is returned. + + The OPTIONS arg may contain one or more of the following bits: + + DMGL_ANSI ANSI qualifiers such as `const' and `void' are + included. + DMGL_PARAMS Function parameters are included. + + For example, + + cplus_demangle ("foo__1Ai", DMGL_PARAMS) => "A::foo(int)" + cplus_demangle ("foo__1Ai", DMGL_PARAMS | DMGL_ANSI) => "A::foo(int)" + cplus_demangle ("foo__1Ai", 0) => "A::foo" + + cplus_demangle ("foo__1Afe", DMGL_PARAMS) => "A::foo(float,...)" + cplus_demangle ("foo__1Afe", DMGL_PARAMS | DMGL_ANSI)=> "A::foo(float,...)" + cplus_demangle ("foo__1Afe", 0) => "A::foo" + + Note that any leading underscores, or other such characters prepended by + the compilation system, are presumed to have already been stripped from + MANGLED. */ + +char * +cplus_demangle (mangled, options) + const char *mangled; + int options; +{ + string decl; + int success = 0; + struct work_stuff work[1]; + char *demangled = NULL; + + if ((mangled != NULL) && (*mangled != '\0')) + { + memset ((char *) work, 0, sizeof (work)); + work -> options = options; + if ((work->options & DMGL_STYLE_MASK) == 0) + work->options |= (int)current_demangling_style & DMGL_STYLE_MASK; + + string_init (&decl); + + /* First check to see if gnu style demangling is active and if the + string to be demangled contains a CPLUS_MARKER. If so, attempt to + recognize one of the gnu special forms rather than looking for a + standard prefix. In particular, don't worry about whether there + is a "__" string in the mangled string. Consider "_$_5__foo" for + example. */ + + if ((AUTO_DEMANGLING || GNU_DEMANGLING)) + { + success = gnu_special (work, &mangled, &decl); + } + if (!success) + { + success = demangle_prefix (work, &mangled, &decl); + } + if (success && (*mangled != '\0')) + { + success = demangle_signature (work, &mangled, &decl); + } + if (work->constructor == 2) + { + string_prepend(&decl, "global constructors keyed to "); + work->constructor = 0; + } + else if (work->destructor == 2) + { + string_prepend(&decl, "global destructors keyed to "); + work->destructor = 0; + } + demangled = mop_up (work, &decl, success); + } + return (demangled); +} + +static char * +mop_up (work, declp, success) + struct work_stuff *work; + string *declp; + int success; +{ + char *demangled = NULL; + + /* Discard the remembered types, if any. */ + + forget_types (work); + if (work -> typevec != NULL) + { + free ((char *) work -> typevec); + } + + /* If demangling was successful, ensure that the demangled string is null + terminated and return it. Otherwise, free the demangling decl. */ + + if (!success) + { + string_delete (declp); + } + else + { + string_appendn (declp, "", 1); + demangled = declp -> b; + } + return (demangled); +} + +/* + +LOCAL FUNCTION + + demangle_signature -- demangle the signature part of a mangled name + +SYNOPSIS + + static int + demangle_signature (struct work_stuff *work, const char **mangled, + string *declp); + +DESCRIPTION + + Consume and demangle the signature portion of the mangled name. + + DECLP is the string where demangled output is being built. At + entry it contains the demangled root name from the mangled name + prefix. I.E. either a demangled operator name or the root function + name. In some special cases, it may contain nothing. + + *MANGLED points to the current unconsumed location in the mangled + name. As tokens are consumed and demangling is performed, the + pointer is updated to continuously point at the next token to + be consumed. + + Demangling GNU style mangled names is nasty because there is no + explicit token that marks the start of the outermost function + argument list. */ + +static int +demangle_signature (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 1; + int func_done = 0; + int expect_func = 0; + const char *oldmangled = NULL; + string trawname; + string tname; + + while (success && (**mangled != '\0')) + { + switch (**mangled) + { + case 'Q': + oldmangled = *mangled; + success = demangle_qualified (work, mangled, declp, 1, 0); + if (success) + { + remember_type (work, oldmangled, *mangled - oldmangled); + } + if (AUTO_DEMANGLING || GNU_DEMANGLING) + { + expect_func = 1; + } + oldmangled = NULL; + break; + + case 'S': + /* Static member function */ + if (oldmangled == NULL) + { + oldmangled = *mangled; + } + (*mangled)++; + work -> static_type = 1; + break; + + case 'C': + /* a const member function */ + if (oldmangled == NULL) + { + oldmangled = *mangled; + } + (*mangled)++; + work -> const_type = 1; + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (oldmangled == NULL) + { + oldmangled = *mangled; + } + success = demangle_class (work, mangled, declp); + if (success) + { + remember_type (work, oldmangled, *mangled - oldmangled); + } + if (AUTO_DEMANGLING || GNU_DEMANGLING) + { + expect_func = 1; + } + oldmangled = NULL; + break; + + case 'F': + /* Function */ + /* ARM style demangling includes a specific 'F' character after + the class name. For GNU style, it is just implied. So we can + safely just consume any 'F' at this point and be compatible + with either style. */ + + oldmangled = NULL; + func_done = 1; + (*mangled)++; + + /* For lucid/ARM style we have to forget any types we might + have remembered up to this point, since they were not argument + types. GNU style considers all types seen as available for + back references. See comment in demangle_args() */ + + if (LUCID_DEMANGLING || ARM_DEMANGLING) + { + forget_types (work); + } + success = demangle_args (work, mangled, declp); + break; + + case 't': + /* G++ Template */ + string_init(&trawname); + string_init(&tname); + if (oldmangled == NULL) + { + oldmangled = *mangled; + } + success = demangle_template (work, mangled, &tname, &trawname); + if (success) + { + remember_type (work, oldmangled, *mangled - oldmangled); + } + string_append(&tname, (work -> options & DMGL_JAVA) ? "." : "::"); + string_prepends(declp, &tname); + if (work -> destructor & 1) + { + string_prepend (&trawname, "~"); + string_appends (declp, &trawname); + work->destructor -= 1; + } + if ((work->constructor & 1) || (work->destructor & 1)) + { + string_appends (declp, &trawname); + work->constructor -= 1; + } + string_delete(&trawname); + string_delete(&tname); + oldmangled = NULL; + expect_func = 1; + break; + + case '_': + /* At the outermost level, we cannot have a return type specified, + so if we run into another '_' at this point we are dealing with + a mangled name that is either bogus, or has been mangled by + some algorithm we don't know how to deal with. So just + reject the entire demangling. */ + success = 0; + break; + + default: + if (AUTO_DEMANGLING || GNU_DEMANGLING) + { + /* Assume we have stumbled onto the first outermost function + argument token, and start processing args. */ + func_done = 1; + success = demangle_args (work, mangled, declp); + } + else + { + /* Non-GNU demanglers use a specific token to mark the start + of the outermost function argument tokens. Typically 'F', + for ARM-demangling, for example. So if we find something + we are not prepared for, it must be an error. */ + success = 0; + } + break; + } + /* + if (AUTO_DEMANGLING || GNU_DEMANGLING) + */ + { + if (success && expect_func) + { + func_done = 1; + success = demangle_args (work, mangled, declp); + } + } + } + if (success && !func_done) + { + if (AUTO_DEMANGLING || GNU_DEMANGLING) + { + /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and + bar__3fooi is 'foo::bar(int)'. We get here when we find the + first case, and need to ensure that the '(void)' gets added to + the current declp. Note that with ARM, the first case + represents the name of a static data member 'foo::bar', + which is in the current declp, so we leave it alone. */ + success = demangle_args (work, mangled, declp); + } + } + if (success && work -> static_type && PRINT_ARG_TYPES) + { + string_append (declp, " static"); + } + if (success && work -> const_type && PRINT_ARG_TYPES) + { + string_append (declp, " const"); + } + return (success); +} + +#if 0 + +static int +demangle_method_args (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 0; + + if (work -> static_type) + { + string_append (declp, *mangled + 1); + *mangled += strlen (*mangled); + success = 1; + } + else + { + success = demangle_args (work, mangled, declp); + } + return (success); +} + +#endif + +static int +demangle_template (work, mangled, tname, trawname) + struct work_stuff *work; + const char **mangled; + string *tname; + string *trawname; +{ + int i; + int is_pointer; + int is_real; + int is_integral; + int is_char; + int is_bool; + int r; + int need_comma = 0; + int success = 0; + int done; + const char *old_p; + const char *start; + int symbol_len; + int is_java_array; + string temp; + + (*mangled)++; + start = *mangled; + /* get template name */ + if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r) + { + return (0); + } + if (trawname) + string_appendn (trawname, *mangled, r); + is_java_array = (work -> options & DMGL_JAVA) + && strncmp (*mangled, "JArray1Z", 8) == 0; + if (! is_java_array) + { + string_appendn (tname, *mangled, r); + string_append (tname, "<"); + } + *mangled += r; + /* get size of template parameter list */ + if (!get_count (mangled, &r)) + { + return (0); + } + for (i = 0; i < r; i++) + { + if (need_comma) + { + string_append (tname, ", "); + } + /* Z for type parameters */ + if (**mangled == 'Z') + { + (*mangled)++; + /* temp is initialized in do_type */ + success = do_type (work, mangled, &temp); + if (success) + { + string_appends (tname, &temp); + } + string_delete(&temp); + if (!success) + { + break; + } + } + else + { + /* otherwise, value parameter */ + old_p = *mangled; + is_pointer = 0; + is_real = 0; + is_integral = 0; + is_char = 0; + is_bool = 0; + done = 0; + /* temp is initialized in do_type */ + success = do_type (work, mangled, &temp); + /* + if (success) + { + string_appends (tname, &temp); + } + */ + string_delete(&temp); + if (!success) + { + break; + } + /* + string_append (tname, "="); + */ + while (*old_p && !done) + { + switch (*old_p) + { + case 'P': + case 'p': + case 'R': + done = is_pointer = 1; + break; + case 'C': /* const */ + case 'S': /* explicitly signed [char] */ + case 'U': /* unsigned */ + case 'V': /* volatile */ + case 'F': /* function */ + case 'M': /* member function */ + case 'O': /* ??? */ + case 'J': /* complex */ + old_p++; + continue; + case 'Q': /* qualified name */ + done = is_integral = 1; + break; + case 'T': /* remembered type */ + abort (); + break; + case 'v': /* void */ + abort (); + break; + case 'x': /* long long */ + case 'l': /* long */ + case 'i': /* int */ + case 's': /* short */ + case 'w': /* wchar_t */ + done = is_integral = 1; + break; + case 'b': /* bool */ + done = is_bool = 1; + break; + case 'c': /* char */ + done = is_char = 1; + break; + case 'r': /* long double */ + case 'd': /* double */ + case 'f': /* float */ + done = is_real = 1; + break; + default: + /* it's probably user defined type, let's assume + it's integral, it seems hard to figure out + what it really is */ + done = is_integral = 1; + } + } + if (is_integral) + { + if (**mangled == 'm') + { + string_appendn (tname, "-", 1); + (*mangled)++; + } + while (isdigit (**mangled)) + { + string_appendn (tname, *mangled, 1); + (*mangled)++; + } + } + else if (is_char) + { + char tmp[2]; + int val; + if (**mangled == 'm') + { + string_appendn (tname, "-", 1); + (*mangled)++; + } + string_appendn (tname, "'", 1); + val = consume_count(mangled); + if (val == 0) + { + success = 0; + break; + } + tmp[0] = (char)val; + tmp[1] = '\0'; + string_appendn (tname, &tmp[0], 1); + string_appendn (tname, "'", 1); + } + else if (is_bool) + { + int val = consume_count (mangled); + if (val == 0) + string_appendn (tname, "false", 5); + else if (val == 1) + string_appendn (tname, "true", 4); + else + success = 0; + } + else if (is_real) + { + if (**mangled == 'm') + { + string_appendn (tname, "-", 1); + (*mangled)++; + } + while (isdigit (**mangled)) + { + string_appendn (tname, *mangled, 1); + (*mangled)++; + } + if (**mangled == '.') /* fraction */ + { + string_appendn (tname, ".", 1); + (*mangled)++; + while (isdigit (**mangled)) + { + string_appendn (tname, *mangled, 1); + (*mangled)++; + } + } + if (**mangled == 'e') /* exponent */ + { + string_appendn (tname, "e", 1); + (*mangled)++; + while (isdigit (**mangled)) + { + string_appendn (tname, *mangled, 1); + (*mangled)++; + } + } + } + else if (is_pointer) + { + symbol_len = consume_count (mangled); + if (symbol_len == 0) + { + success = 0; + break; + } + if (symbol_len == 0) + string_appendn (tname, "0", 1); + else + { + char *p = xmalloc (symbol_len + 1), *q; + strncpy (p, *mangled, symbol_len); + p [symbol_len] = '\0'; + q = cplus_demangle (p, work->options); + string_appendn (tname, "&", 1); + if (q) + { + string_append (tname, q); + free (q); + } + else + string_append (tname, p); + free (p); + } + *mangled += symbol_len; + } + } + need_comma = 1; + } + if (is_java_array) + { + string_append (tname, "[]"); + } + else + { + if (tname->p[-1] == '>') + string_append (tname, " "); + string_append (tname, ">"); + } + + /* + if (work -> static_type) + { + string_append (declp, *mangled + 1); + *mangled += strlen (*mangled); + success = 1; + } + else + { + success = demangle_args (work, mangled, declp); + } + } + */ + return (success); +} + +static int +arm_pt (work, mangled, n, anchor, args) + struct work_stuff *work; + const char *mangled; + int n; + const char **anchor, **args; +{ + /* ARM template? */ + if (ARM_DEMANGLING && (*anchor = mystrstr (mangled, "__pt__"))) + { + int len; + *args = *anchor + 6; + len = consume_count (args); + if (*args + len == mangled + n && **args == '_') + { + ++*args; + return 1; + } + } + return 0; +} + +static void +demangle_arm_pt (work, mangled, n, declp) + struct work_stuff *work; + const char **mangled; + int n; + string *declp; +{ + const char *p; + const char *args; + const char *e = *mangled + n; + + /* ARM template? */ + if (arm_pt (work, *mangled, n, &p, &args)) + { + string arg; + string_init (&arg); + string_appendn (declp, *mangled, p - *mangled); + string_append (declp, "<"); + /* should do error checking here */ + while (args < e) { + string_clear (&arg); + do_type (work, &args, &arg); + string_appends (declp, &arg); + string_append (declp, ","); + } + string_delete (&arg); + --declp->p; + string_append (declp, ">"); + } + else + { + string_appendn (declp, *mangled, n); + } + *mangled += n; +} + +static int +demangle_class_name (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int n; + int success = 0; + + n = consume_count (mangled); + if (strlen (*mangled) >= n) + { + demangle_arm_pt (work, mangled, n, declp); + success = 1; + } + + return (success); +} + +/* + +LOCAL FUNCTION + + demangle_class -- demangle a mangled class sequence + +SYNOPSIS + + static int + demangle_class (struct work_stuff *work, const char **mangled, + strint *declp) + +DESCRIPTION + + DECLP points to the buffer into which demangling is being done. + + *MANGLED points to the current token to be demangled. On input, + it points to a mangled class (I.E. "3foo", "13verylongclass", etc.) + On exit, it points to the next token after the mangled class on + success, or the first unconsumed token on failure. + + If the CONSTRUCTOR or DESTRUCTOR flags are set in WORK, then + we are demangling a constructor or destructor. In this case + we prepend "class::class" or "class::~class" to DECLP. + + Otherwise, we prepend "class::" to the current DECLP. + + Reset the constructor/destructor flags once they have been + "consumed". This allows demangle_class to be called later during + the same demangling, to do normal class demangling. + + Returns 1 if demangling is successful, 0 otherwise. + +*/ + +static int +demangle_class (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 0; + string class_name; + + string_init (&class_name); + if (demangle_class_name (work, mangled, &class_name)) + { + if ((work->constructor & 1) || (work->destructor & 1)) + { + string_prepends (declp, &class_name); + if (work -> destructor & 1) + { + string_prepend (declp, "~"); + work -> destructor -= 1; + } + else + { + work -> constructor -= 1; + } + } + string_prepend (declp, (work -> options & DMGL_JAVA) ? "." : "::"); + string_prepends (declp, &class_name); + success = 1; + } + string_delete (&class_name); + return (success); +} + +/* + +LOCAL FUNCTION + + demangle_prefix -- consume the mangled name prefix and find signature + +SYNOPSIS + + static int + demangle_prefix (struct work_stuff *work, const char **mangled, + string *declp); + +DESCRIPTION + + Consume and demangle the prefix of the mangled name. + + DECLP points to the string buffer into which demangled output is + placed. On entry, the buffer is empty. On exit it contains + the root function name, the demangled operator name, or in some + special cases either nothing or the completely demangled result. + + MANGLED points to the current pointer into the mangled name. As each + token of the mangled name is consumed, it is updated. Upon entry + the current mangled name pointer points to the first character of + the mangled name. Upon exit, it should point to the first character + of the signature if demangling was successful, or to the first + unconsumed character if demangling of the prefix was unsuccessful. + + Returns 1 on success, 0 otherwise. + */ + +static int +demangle_prefix (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 1; + const char *scan; + int i; + + if (strlen(*mangled) >= 11 && strncmp(*mangled, "_GLOBAL_", 8) == 0) + { + char *marker = strchr (cplus_markers, (*mangled)[8]); + if (marker != NULL && *marker == (*mangled)[10]) + { + if ((*mangled)[9] == 'D') + { + /* it's a GNU global destructor to be executed at program exit */ + (*mangled) += 11; + work->destructor = 2; + if (gnu_special (work, mangled, declp)) + return success; + } + else if ((*mangled)[9] == 'I') + { + /* it's a GNU global constructor to be executed at program init */ + (*mangled) += 11; + work->constructor = 2; + if (gnu_special (work, mangled, declp)) + return success; + } + } + } + else if (ARM_DEMANGLING && strncmp(*mangled, "__std__", 7) == 0) + { + /* it's a ARM global destructor to be executed at program exit */ + (*mangled) += 7; + work->destructor = 2; + } + else if (ARM_DEMANGLING && strncmp(*mangled, "__sti__", 7) == 0) + { + /* it's a ARM global constructor to be executed at program initial */ + (*mangled) += 7; + work->constructor = 2; + } + + /* This block of code is a reduction in strength time optimization + of: + scan = mystrstr (*mangled, "__"); */ + + { + scan = *mangled; + + do { + scan = strchr (scan, '_'); + } while (scan != NULL && *++scan != '_'); + + if (scan != NULL) --scan; + } + + if (scan != NULL) + { + /* We found a sequence of two or more '_', ensure that we start at + the last pair in the sequence. */ + i = strspn (scan, "_"); + if (i > 2) + { + scan += (i - 2); + } + } + + if (scan == NULL) + { + success = 0; + } + else if (work -> static_type) + { + if (!isdigit (scan[0]) && (scan[0] != 't')) + { + success = 0; + } + } + else if ((scan == *mangled) + && (isdigit (scan[2]) || (scan[2] == 'Q') || (scan[2] == 't'))) + { + /* The ARM says nothing about the mangling of local variables. + But cfront mangles local variables by prepending __ + to them. As an extension to ARM demangling we handle this case. */ + if ((LUCID_DEMANGLING || ARM_DEMANGLING) && isdigit (scan[2])) + { + *mangled = scan + 2; + consume_count (mangled); + string_append (declp, *mangled); + *mangled += strlen (*mangled); + success = 1; + } + else + { + /* A GNU style constructor starts with __[0-9Qt]. But cfront uses + names like __Q2_3foo3bar for nested type names. So don't accept + this style of constructor for cfront demangling. */ + if (!(LUCID_DEMANGLING || ARM_DEMANGLING)) + work -> constructor += 1; + *mangled = scan + 2; + } + } + else if ((scan == *mangled) && !isdigit (scan[2]) && (scan[2] != 't')) + { + /* Mangled name starts with "__". Skip over any leading '_' characters, + then find the next "__" that separates the prefix from the signature. + */ + if (!(ARM_DEMANGLING || LUCID_DEMANGLING) + || (arm_special (work, mangled, declp) == 0)) + { + while (*scan == '_') + { + scan++; + } + if ((scan = mystrstr (scan, "__")) == NULL || (*(scan + 2) == '\0')) + { + /* No separator (I.E. "__not_mangled"), or empty signature + (I.E. "__not_mangled_either__") */ + success = 0; + } + else + { + demangle_function_name (work, mangled, declp, scan); + } + } + } + else if (ARM_DEMANGLING && scan[2] == 'p' && scan[3] == 't') + { + /* Cfront-style parameterized type. Handled later as a signature. */ + success = 1; + + /* ARM template? */ + demangle_arm_pt (work, mangled, strlen (*mangled), declp); + } + else if (*(scan + 2) != '\0') + { + /* Mangled name does not start with "__" but does have one somewhere + in there with non empty stuff after it. Looks like a global + function name. */ + demangle_function_name (work, mangled, declp, scan); + } + else + { + /* Doesn't look like a mangled name */ + success = 0; + } + + if (!success && (work->constructor == 2 || work->destructor == 2)) + { + string_append (declp, *mangled); + *mangled += strlen (*mangled); + success = 1; + } + return (success); +} + +/* + +LOCAL FUNCTION + + gnu_special -- special handling of gnu mangled strings + +SYNOPSIS + + static int + gnu_special (struct work_stuff *work, const char **mangled, + string *declp); + + +DESCRIPTION + + Process some special GNU style mangling forms that don't fit + the normal pattern. For example: + + _$_3foo (destructor for class foo) + _vt$foo (foo virtual table) + _vt$foo$bar (foo::bar virtual table) + __vt_foo (foo virtual table, new style with thunks) + _3foo$varname (static data member) + _Q22rs2tu$vw (static data member) + __t6vector1Zii (constructor with template) + __thunk_4__$_7ostream (virtual function thunk) + */ + +static int +gnu_special (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int n; + int success = 1; + const char *p; + + if ((*mangled)[0] == '_' + && strchr (cplus_markers, (*mangled)[1]) != NULL + && (*mangled)[2] == '_') + { + /* Found a GNU style destructor, get past "__" */ + (*mangled) += 3; + work -> destructor += 1; + } + else if ((*mangled)[0] == '_' + && (((*mangled)[1] == '_' + && (*mangled)[2] == 'v' + && (*mangled)[3] == 't' + && (*mangled)[4] == '_') + || ((*mangled)[1] == 'v' + && (*mangled)[2] == 't' + && strchr (cplus_markers, (*mangled)[3]) != NULL))) + { + /* Found a GNU style virtual table, get past "_vt" + and create the decl. Note that we consume the entire mangled + input string, which means that demangle_signature has no work + to do. */ + if ((*mangled)[2] == 'v') + (*mangled) += 5; /* New style, with thunks: "__vt_" */ + else + (*mangled) += 4; /* Old style, no thunks: "_vt" */ + while (**mangled != '\0') + { + p = strpbrk (*mangled, cplus_markers); + switch (**mangled) + { + case 'Q': + success = demangle_qualified (work, mangled, declp, 0, 1); + break; + case 't': + success = demangle_template (work, mangled, declp, 0); + break; + default: + if (isdigit(*mangled[0])) + { + n = consume_count(mangled); + } + else + { + n = strcspn (*mangled, cplus_markers); + } + string_appendn (declp, *mangled, n); + (*mangled) += n; + } + + if (success && ((p == NULL) || (p == *mangled))) + { + if (p != NULL) + { + string_append (declp, + (work -> options & DMGL_JAVA) ? "." : "::"); + (*mangled)++; + } + } + else + { + success = 0; + break; + } + } + if (success) + string_append (declp, " virtual table"); + } + else if ((*mangled)[0] == '_' + && (strchr("0123456789Qt", (*mangled)[1]) != NULL) + && (p = strpbrk (*mangled, cplus_markers)) != NULL) + { + /* static data member, "_3foo$varname" for example */ + (*mangled)++; + switch (**mangled) + { + case 'Q': + success = demangle_qualified (work, mangled, declp, 0, 1); + break; + case 't': + success = demangle_template (work, mangled, declp, 0); + break; + default: + n = consume_count (mangled); + string_appendn (declp, *mangled, n); + (*mangled) += n; + } + if (success && (p == *mangled)) + { + /* Consumed everything up to the cplus_marker, append the + variable name. */ + (*mangled)++; + string_append (declp, (work -> options & DMGL_JAVA) ? "." : "::"); + n = strlen (*mangled); + string_appendn (declp, *mangled, n); + (*mangled) += n; + } + else + { + success = 0; + } + } + else if (strncmp (*mangled, "__thunk_", 8) == 0) + { + int delta = ((*mangled) += 8, consume_count (mangled)); + char *method = cplus_demangle (++*mangled, work->options); + if (method) + { + char buf[50]; + sprintf (buf, "virtual function thunk (delta:%d) for ", -delta); + string_append (declp, buf); + string_append (declp, method); + free (method); + n = strlen (*mangled); + (*mangled) += n; + } + else + { + success = 0; + } + } + else if (strncmp (*mangled, "__t", 3) == 0 + && ((*mangled)[3] == 'i' || (*mangled)[3] == 'f')) + { + p = (*mangled)[3] == 'i' ? " type_info node" : " type_info function"; + (*mangled) += 4; + switch (**mangled) + { + case 'Q': + success = demangle_qualified (work, mangled, declp, 0, 1); + break; + case 't': + success = demangle_template (work, mangled, declp, 0); + break; + default: + success = demangle_fund_type (work, mangled, declp); + break; + } + if (success && **mangled != '\0') + success = 0; + if (success) + string_append (declp, p); + } + else + { + success = 0; + } + return (success); +} + +/* + +LOCAL FUNCTION + + arm_special -- special handling of ARM/lucid mangled strings + +SYNOPSIS + + static int + arm_special (struct work_stuff *work, const char **mangled, + string *declp); + + +DESCRIPTION + + Process some special ARM style mangling forms that don't fit + the normal pattern. For example: + + __vtbl__3foo (foo virtual table) + __vtbl__3foo__3bar (bar::foo virtual table) + + */ + +static int +arm_special (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int n; + int success = 1; + const char *scan; + + if (strncmp (*mangled, ARM_VTABLE_STRING, ARM_VTABLE_STRLEN) == 0) + { + /* Found a ARM style virtual table, get past ARM_VTABLE_STRING + and create the decl. Note that we consume the entire mangled + input string, which means that demangle_signature has no work + to do. */ + scan = *mangled + ARM_VTABLE_STRLEN; + while (*scan != '\0') /* first check it can be demangled */ + { + n = consume_count (&scan); + if (n==0) + { + return (0); /* no good */ + } + scan += n; + if (scan[0] == '_' && scan[1] == '_') + { + scan += 2; + } + } + (*mangled) += ARM_VTABLE_STRLEN; + while (**mangled != '\0') + { + n = consume_count (mangled); + string_prependn (declp, *mangled, n); + (*mangled) += n; + if ((*mangled)[0] == '_' && (*mangled)[1] == '_') + { + string_prepend (declp, "::"); + (*mangled) += 2; + } + } + string_append (declp, " virtual table"); + } + else + { + success = 0; + } + return (success); +} + +/* + +LOCAL FUNCTION + + demangle_qualified -- demangle 'Q' qualified name strings + +SYNOPSIS + + static int + demangle_qualified (struct work_stuff *, const char *mangled, + string *result, int isfuncname, int append); + +DESCRIPTION + + Demangle a qualified name, such as "Q25Outer5Inner" which is + the mangled form of "Outer::Inner". The demangled output is + prepended or appended to the result string according to the + state of the append flag. + + If isfuncname is nonzero, then the qualified name we are building + is going to be used as a member function name, so if it is a + constructor or destructor function, append an appropriate + constructor or destructor name. I.E. for the above example, + the result for use as a constructor is "Outer::Inner::Inner" + and the result for use as a destructor is "Outer::Inner::~Inner". + +BUGS + + Numeric conversion is ASCII dependent (FIXME). + + */ + +static int +demangle_qualified (work, mangled, result, isfuncname, append) + struct work_stuff *work; + const char **mangled; + string *result; + int isfuncname; + int append; +{ + int qualifiers; + int namelength; + int success = 1; + const char *p; + char num[2]; + string temp; + + string_init (&temp); + switch ((*mangled)[1]) + { + case '_': + /* GNU mangled name with more than 9 classes. The count is preceded + by an underscore (to distinguish it from the <= 9 case) and followed + by an underscore. */ + p = *mangled + 2; + qualifiers = atoi (p); + if (!isdigit (*p) || *p == '0') + success = 0; + + /* Skip the digits. */ + while (isdigit (*p)) + ++p; + + if (*p != '_') + success = 0; + + *mangled = p + 1; + break; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + /* The count is in a single digit. */ + num[0] = (*mangled)[1]; + num[1] = '\0'; + qualifiers = atoi (num); + + /* If there is an underscore after the digit, skip it. This is + said to be for ARM-qualified names, but the ARM makes no + mention of such an underscore. Perhaps cfront uses one. */ + if ((*mangled)[2] == '_') + { + (*mangled)++; + } + (*mangled) += 2; + break; + + case '0': + default: + success = 0; + } + + if (!success) + return success; + + /* Pick off the names and collect them in the temp buffer in the order + in which they are found, separated by '::'. */ + + while (qualifiers-- > 0) + { + if (*mangled[0] == '_') + *mangled = *mangled + 1; + if (*mangled[0] == 't') + { + success = demangle_template(work, mangled, &temp, 0); + if (!success) break; + } + else + { + namelength = consume_count (mangled); + if (strlen (*mangled) < namelength) + { + /* Simple sanity check failed */ + success = 0; + break; + } + string_appendn (&temp, *mangled, namelength); + *mangled += namelength; + } + if (qualifiers > 0) + { + string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::"); + } + } + + /* If we are using the result as a function name, we need to append + the appropriate '::' separated constructor or destructor name. + We do this here because this is the most convenient place, where + we already have a pointer to the name and the length of the name. */ + + if (isfuncname && (work->constructor & 1 || work->destructor & 1)) + { + string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::"); + if (work -> destructor & 1) + { + string_append (&temp, "~"); + } + string_appendn (&temp, (*mangled) - namelength, namelength); + } + + /* Now either prepend the temp buffer to the result, or append it, + depending upon the state of the append flag. */ + + if (append) + { + string_appends (result, &temp); + } + else + { + if (!STRING_EMPTY (result)) + { + string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::"); + } + string_prepends (result, &temp); + } + + string_delete (&temp); + return (success); +} + +/* + +LOCAL FUNCTION + + get_count -- convert an ascii count to integer, consuming tokens + +SYNOPSIS + + static int + get_count (const char **type, int *count) + +DESCRIPTION + + Return 0 if no conversion is performed, 1 if a string is converted. +*/ + +static int +get_count (type, count) + const char **type; + int *count; +{ + const char *p; + int n; + + if (!isdigit (**type)) + { + return (0); + } + else + { + *count = **type - '0'; + (*type)++; + if (isdigit (**type)) + { + p = *type; + n = *count; + do + { + n *= 10; + n += *p - '0'; + p++; + } + while (isdigit (*p)); + if (*p == '_') + { + *type = p + 1; + *count = n; + } + } + } + return (1); +} + +/* result will be initialised here; it will be freed on failure */ + +static int +do_type (work, mangled, result) + struct work_stuff *work; + const char **mangled; + string *result; +{ + int n; + int done; + int success; + string decl; + const char *remembered_type; + int constp; + int volatilep; + + string_init (&decl); + string_init (result); + + done = 0; + success = 1; + while (success && !done) + { + int member; + switch (**mangled) + { + + /* A pointer type */ + case 'P': + case 'p': + (*mangled)++; + if (! (work -> options & DMGL_JAVA)) + string_prepend (&decl, "*"); + break; + + /* A reference type */ + case 'R': + (*mangled)++; + string_prepend (&decl, "&"); + break; + + /* An array */ + case 'A': + { + const char *p = ++(*mangled); + + string_prepend (&decl, "("); + string_append (&decl, ")["); + /* Copy anything up until the next underscore (the size of the + array). */ + while (**mangled && **mangled != '_') + ++(*mangled); + if (**mangled == '_') + { + string_appendn (&decl, p, *mangled - p); + string_append (&decl, "]"); + *mangled += 1; + } + else + success = 0; + break; + } + + /* A back reference to a previously seen type */ + case 'T': + (*mangled)++; + if (!get_count (mangled, &n) || n >= work -> ntypes) + { + success = 0; + } + else + { + remembered_type = work -> typevec[n]; + mangled = &remembered_type; + } + break; + + /* A function */ + case 'F': + (*mangled)++; + if (!STRING_EMPTY (&decl) && decl.b[0] == '*') + { + string_prepend (&decl, "("); + string_append (&decl, ")"); + } + /* After picking off the function args, we expect to either find the + function return type (preceded by an '_') or the end of the + string. */ + if (!demangle_args (work, mangled, &decl) + || (**mangled != '_' && **mangled != '\0')) + { + success = 0; + } + if (success && (**mangled == '_')) + { + (*mangled)++; + } + break; + + case 'M': + case 'O': + { + constp = 0; + volatilep = 0; + + member = **mangled == 'M'; + (*mangled)++; + if (!isdigit (**mangled) && **mangled != 't') + { + success = 0; + break; + } + + string_append (&decl, ")"); + string_prepend (&decl, (work -> options & DMGL_JAVA) ? "." : "::"); + if (isdigit (**mangled)) + { + n = consume_count (mangled); + if (strlen (*mangled) < n) + { + success = 0; + break; + } + string_prependn (&decl, *mangled, n); + *mangled += n; + } + else + { + string temp; + string_init (&temp); + success = demangle_template (work, mangled, &temp, NULL); + if (success) + { + string_prependn (&decl, temp.b, temp.p - temp.b); + string_clear (&temp); + } + else + break; + } + string_prepend (&decl, "("); + if (member) + { + if (**mangled == 'C') + { + (*mangled)++; + constp = 1; + } + if (**mangled == 'V') + { + (*mangled)++; + volatilep = 1; + } + if (*(*mangled)++ != 'F') + { + success = 0; + break; + } + } + if ((member && !demangle_args (work, mangled, &decl)) + || **mangled != '_') + { + success = 0; + break; + } + (*mangled)++; + if (! PRINT_ANSI_QUALIFIERS) + { + break; + } + if (constp) + { + APPEND_BLANK (&decl); + string_append (&decl, "const"); + } + if (volatilep) + { + APPEND_BLANK (&decl); + string_append (&decl, "volatile"); + } + break; + } + case 'G': + (*mangled)++; + break; + + case 'C': + (*mangled)++; + /* + if ((*mangled)[1] == 'P') + { + */ + if (PRINT_ANSI_QUALIFIERS) + { + if (!STRING_EMPTY (&decl)) + { + string_prepend (&decl, " "); + } + string_prepend (&decl, "const"); + } + break; + /* + } + */ + + /* fall through */ + default: + done = 1; + break; + } + } + + switch (**mangled) + { + /* A qualified name, such as "Outer::Inner". */ + case 'Q': + success = demangle_qualified (work, mangled, result, 0, 1); + break; + + default: + success = demangle_fund_type (work, mangled, result); + break; + } + + if (success) + { + if (!STRING_EMPTY (&decl)) + { + string_append (result, " "); + string_appends (result, &decl); + } + } + else + { + string_delete (result); + } + string_delete (&decl); + return (success); +} + +/* Given a pointer to a type string that represents a fundamental type + argument (int, long, unsigned int, etc) in TYPE, a pointer to the + string in which the demangled output is being built in RESULT, and + the WORK structure, decode the types and add them to the result. + + For example: + + "Ci" => "const int" + "Sl" => "signed long" + "CUs" => "const unsigned short" + + */ + +static int +demangle_fund_type (work, mangled, result) + struct work_stuff *work; + const char **mangled; + string *result; +{ + int done = 0; + int success = 1; + + /* First pick off any type qualifiers. There can be more than one. */ + + while (!done) + { + switch (**mangled) + { + case 'C': + (*mangled)++; + if (PRINT_ANSI_QUALIFIERS) + { + APPEND_BLANK (result); + string_append (result, "const"); + } + break; + case 'U': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "unsigned"); + break; + case 'S': /* signed char only */ + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "signed"); + break; + case 'V': + (*mangled)++; + if (PRINT_ANSI_QUALIFIERS) + { + APPEND_BLANK (result); + string_append (result, "volatile"); + } + break; + case 'J': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "complex"); + break; + default: + done = 1; + break; + } + } + + /* Now pick off the fundamental type. There can be only one. */ + + switch (**mangled) + { + case '\0': + case '_': + break; + case 'v': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "void"); + break; + case 'x': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "long long"); + break; + case 'l': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "long"); + break; + case 'i': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "int"); + break; + case 's': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "short"); + break; + case 'b': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "bool"); + break; + case 'c': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "char"); + break; + case 'w': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "wchar_t"); + break; + case 'r': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "long double"); + break; + case 'd': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "double"); + break; + case 'f': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "float"); + break; + case 'G': + (*mangled)++; + if (!isdigit (**mangled)) + { + success = 0; + break; + } + /* fall through */ + /* An explicit type, such as "6mytype" or "7integer" */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + APPEND_BLANK (result); + if (!demangle_class_name (work, mangled, result)) { + --result->p; + success = 0; + } + break; + case 't': + success = demangle_template(work,mangled, result, 0); + break; + default: + success = 0; + break; + } + + return (success); +} + +/* `result' will be initialized in do_type; it will be freed on failure */ + +static int +do_arg (work, mangled, result) + struct work_stuff *work; + const char **mangled; + string *result; +{ + const char *start = *mangled; + + if (!do_type (work, mangled, result)) + { + return (0); + } + else + { + remember_type (work, start, *mangled - start); + return (1); + } +} + +static void +remember_type (work, start, len) + struct work_stuff *work; + const char *start; + int len; +{ + char *tem; + + if (work -> ntypes >= work -> typevec_size) + { + if (work -> typevec_size == 0) + { + work -> typevec_size = 3; + work -> typevec + = (char **) xmalloc (sizeof (char *) * work -> typevec_size); + } + else + { + work -> typevec_size *= 2; + work -> typevec + = (char **) xrealloc ((char *)work -> typevec, + sizeof (char *) * work -> typevec_size); + } + } + tem = xmalloc (len + 1); + memcpy (tem, start, len); + tem[len] = '\0'; + work -> typevec[work -> ntypes++] = tem; +} + +/* Forget the remembered types, but not the type vector itself. */ + +static void +forget_types (work) + struct work_stuff *work; +{ + int i; + + while (work -> ntypes > 0) + { + i = --(work -> ntypes); + if (work -> typevec[i] != NULL) + { + free (work -> typevec[i]); + work -> typevec[i] = NULL; + } + } +} + +/* Process the argument list part of the signature, after any class spec + has been consumed, as well as the first 'F' character (if any). For + example: + + "__als__3fooRT0" => process "RT0" + "complexfunc5__FPFPc_PFl_i" => process "PFPc_PFl_i" + + DECLP must be already initialised, usually non-empty. It won't be freed + on failure. + + Note that g++ differs significantly from ARM and lucid style mangling + with regards to references to previously seen types. For example, given + the source fragment: + + class foo { + public: + foo::foo (int, foo &ia, int, foo &ib, int, foo &ic); + }; + + foo::foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } + void foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } + + g++ produces the names: + + __3fooiRT0iT2iT2 + foo__FiR3fooiT1iT1 + + while lcc (and presumably other ARM style compilers as well) produces: + + foo__FiR3fooT1T2T1T2 + __ct__3fooFiR3fooT1T2T1T2 + + Note that g++ bases it's type numbers starting at zero and counts all + previously seen types, while lucid/ARM bases it's type numbers starting + at one and only considers types after it has seen the 'F' character + indicating the start of the function args. For lucid/ARM style, we + account for this difference by discarding any previously seen types when + we see the 'F' character, and subtracting one from the type number + reference. + + */ + +static int +demangle_args (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + string arg; + int need_comma = 0; + int r; + int t; + const char *tem; + char temptype; + + if (PRINT_ARG_TYPES) + { + string_append (declp, "("); + if (**mangled == '\0') + { + string_append (declp, "void"); + } + } + + while (**mangled != '_' && **mangled != '\0' && **mangled != 'e') + { + if ((**mangled == 'N') || (**mangled == 'T')) + { + temptype = *(*mangled)++; + + if (temptype == 'N') + { + if (!get_count (mangled, &r)) + { + return (0); + } + } + else + { + r = 1; + } + if (ARM_DEMANGLING && work -> ntypes >= 10) + { + /* If we have 10 or more types we might have more than a 1 digit + index so we'll have to consume the whole count here. This + will lose if the next thing is a type name preceded by a + count but it's impossible to demangle that case properly + anyway. Eg if we already have 12 types is T12Pc "(..., type1, + Pc, ...)" or "(..., type12, char *, ...)" */ + if ((t = consume_count(mangled)) == 0) + { + return (0); + } + } + else + { + if (!get_count (mangled, &t)) + { + return (0); + } + } + if (LUCID_DEMANGLING || ARM_DEMANGLING) + { + t--; + } + /* Validate the type index. Protect against illegal indices from + malformed type strings. */ + if ((t < 0) || (t >= work -> ntypes)) + { + return (0); + } + while (--r >= 0) + { + tem = work -> typevec[t]; + if (need_comma && PRINT_ARG_TYPES) + { + string_append (declp, ", "); + } + if (!do_arg (work, &tem, &arg)) + { + return (0); + } + if (PRINT_ARG_TYPES) + { + string_appends (declp, &arg); + } + string_delete (&arg); + need_comma = 1; + } + } + else + { + if (need_comma & PRINT_ARG_TYPES) + { + string_append (declp, ", "); + } + if (!do_arg (work, mangled, &arg)) + { + return (0); + } + if (PRINT_ARG_TYPES) + { + string_appends (declp, &arg); + } + string_delete (&arg); + need_comma = 1; + } + } + + if (**mangled == 'e') + { + (*mangled)++; + if (PRINT_ARG_TYPES) + { + if (need_comma) + { + string_append (declp, ","); + } + string_append (declp, "..."); + } + } + + if (PRINT_ARG_TYPES) + { + string_append (declp, ")"); + } + return (1); +} + +static void +demangle_function_name (work, mangled, declp, scan) + struct work_stuff *work; + const char **mangled; + string *declp; + const char *scan; +{ + int i; + int len; + string type; + const char *tem; + + string_appendn (declp, (*mangled), scan - (*mangled)); + string_need (declp, 1); + *(declp -> p) = '\0'; + + /* Consume the function name, including the "__" separating the name + from the signature. We are guaranteed that SCAN points to the + separator. */ + + (*mangled) = scan + 2; + + if (LUCID_DEMANGLING || ARM_DEMANGLING) + { + + /* See if we have an ARM style constructor or destructor operator. + If so, then just record it, clear the decl, and return. + We can't build the actual constructor/destructor decl until later, + when we recover the class name from the signature. */ + + if (strcmp (declp -> b, "__ct") == 0) + { + work -> constructor += 1; + string_clear (declp); + return; + } + else if (strcmp (declp -> b, "__dt") == 0) + { + work -> destructor += 1; + string_clear (declp); + return; + } + } + + if (declp->p - declp->b >= 3 + && declp->b[0] == 'o' + && declp->b[1] == 'p' + && strchr (cplus_markers, declp->b[2]) != NULL) + { + /* see if it's an assignment expression */ + if (declp->p - declp->b >= 10 /* op$assign_ */ + && memcmp (declp->b + 3, "assign_", 7) == 0) + { + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + len = declp->p - declp->b - 10; + if (strlen (optable[i].in) == len + && memcmp (optable[i].in, declp->b + 10, len) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + string_append (declp, "="); + break; + } + } + } + else + { + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + int len = declp->p - declp->b - 3; + if (strlen (optable[i].in) == len + && memcmp (optable[i].in, declp->b + 3, len) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + break; + } + } + } + } + else if (declp->p - declp->b >= 5 && memcmp (declp->b, "type", 4) == 0 + && strchr (cplus_markers, declp->b[4]) != NULL) + { + /* type conversion operator */ + tem = declp->b + 5; + if (do_type (work, &tem, &type)) + { + string_clear (declp); + string_append (declp, "operator "); + string_appends (declp, &type); + string_delete (&type); + } + } + else if (declp->b[0] == '_' && declp->b[1] == '_' + && declp->b[2] == 'o' && declp->b[3] == 'p') + { + /* ANSI. */ + /* type conversion operator. */ + tem = declp->b + 4; + if (do_type (work, &tem, &type)) + { + string_clear (declp); + string_append (declp, "operator "); + string_appends (declp, &type); + string_delete (&type); + } + } + else if (declp->b[0] == '_' && declp->b[1] == '_' + && declp->b[2] >= 'a' && declp->b[2] <= 'z' + && declp->b[3] >= 'a' && declp->b[3] <= 'z') + { + if (declp->b[4] == '\0') + { + /* Operator. */ + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 2 + && memcmp (optable[i].in, declp->b + 2, 2) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + break; + } + } + } + else + { + if (declp->b[2] == 'a' && declp->b[5] == '\0') + { + /* Assignment. */ + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 3 + && memcmp (optable[i].in, declp->b + 2, 3) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + break; + } + } + } + } + } +} + +/* a mini string-handling package */ + +static void +string_need (s, n) + string *s; + int n; +{ + int tem; + + if (s->b == NULL) + { + if (n < 32) + { + n = 32; + } + s->p = s->b = xmalloc (n); + s->e = s->b + n; + } + else if (s->e - s->p < n) + { + tem = s->p - s->b; + n += tem; + n *= 2; + s->b = xrealloc (s->b, n); + s->p = s->b + tem; + s->e = s->b + n; + } +} + +static void +string_delete (s) + string *s; +{ + if (s->b != NULL) + { + free (s->b); + s->b = s->e = s->p = NULL; + } +} + +static void +string_init (s) + string *s; +{ + s->b = s->p = s->e = NULL; +} + +static void +string_clear (s) + string *s; +{ + s->p = s->b; +} + +#if 0 + +static int +string_empty (s) + string *s; +{ + return (s->b == s->p); +} + +#endif + +static void +string_append (p, s) + string *p; + const char *s; +{ + int n; + if (s == NULL || *s == '\0') + return; + n = strlen (s); + string_need (p, n); + memcpy (p->p, s, n); + p->p += n; +} + +static void +string_appends (p, s) + string *p, *s; +{ + int n; + + if (s->b != s->p) + { + n = s->p - s->b; + string_need (p, n); + memcpy (p->p, s->b, n); + p->p += n; + } +} + +static void +string_appendn (p, s, n) + string *p; + const char *s; + int n; +{ + if (n != 0) + { + string_need (p, n); + memcpy (p->p, s, n); + p->p += n; + } +} + +static void +string_prepend (p, s) + string *p; + const char *s; +{ + if (s != NULL && *s != '\0') + { + string_prependn (p, s, strlen (s)); + } +} + +static void +string_prepends (p, s) + string *p, *s; +{ + if (s->b != s->p) + { + string_prependn (p, s->b, s->p - s->b); + } +} + +static void +string_prependn (p, s, n) + string *p; + const char *s; + int n; +{ + char *q; + + if (n != 0) + { + string_need (p, n); + for (q = p->p - 1; q >= p->b; q--) + { + q[n] = q[0]; + } + memcpy (p->b, s, n); + p->p += n; + } +} + +/* To generate a standalone demangler program for testing purposes, + just compile and link this file with -DMAIN and libiberty.a. When + run, it demangles each command line arg, or each stdin string, and + prints the result on stdout. */ + +#ifdef MAIN + +#include "getopt.h" + +static char *program_name; +static char *program_version = VERSION; +static int flags = DMGL_PARAMS | DMGL_ANSI; + +static void demangle_it PARAMS ((char *)); +static void usage PARAMS ((FILE *, int)); +static void fatal PARAMS ((char *)); + +static void +demangle_it (mangled_name) + char *mangled_name; +{ + char *result; + + result = cplus_demangle (mangled_name, flags); + if (result == NULL) + { + printf ("%s\n", mangled_name); + } + else + { + printf ("%s\n", result); + free (result); + } +} + +static void +usage (stream, status) + FILE *stream; + int status; +{ + fprintf (stream, "\ +Usage: %s [-_] [-n] [-s {gnu,lucid,arm}] [--strip-underscores]\n\ + [--no-strip-underscores] [--format={gnu,lucid,arm}]\n\ + [--help] [--version] [arg...]\n", + program_name); + exit (status); +} + +#define MBUF_SIZE 512 +char mbuffer[MBUF_SIZE]; + +/* Defined in the automatically-generated underscore.c. */ +extern int prepends_underscore; + +int strip_underscore = 0; + +static struct option long_options[] = { + {"strip-underscores", no_argument, 0, '_'}, + {"format", required_argument, 0, 's'}, + {"help", no_argument, 0, 'h'}, + {"java", no_argument, 0, 'j'}, + {"no-strip-underscores", no_argument, 0, 'n'}, + {"version", no_argument, 0, 'v'}, + {0, no_argument, 0, 0} +}; + +int +main (argc, argv) + int argc; + char **argv; +{ + char *result; + int c; + + program_name = argv[0]; + + strip_underscore = prepends_underscore; + + while ((c = getopt_long (argc, argv, "_ns:j", long_options, (int *) 0)) != EOF) + { + switch (c) + { + case '?': + usage (stderr, 1); + break; + case 'h': + usage (stdout, 0); + case 'n': + strip_underscore = 0; + break; + case 'v': + printf ("GNU %s version %s\n", program_name, program_version); + exit (0); + case '_': + strip_underscore = 1; + break; + case 'j': + flags |= DMGL_JAVA; + break; + case 's': + if (strcmp (optarg, "gnu") == 0) + { + current_demangling_style = gnu_demangling; + } + else if (strcmp (optarg, "lucid") == 0) + { + current_demangling_style = lucid_demangling; + } + else if (strcmp (optarg, "arm") == 0) + { + current_demangling_style = arm_demangling; + } + else + { + fprintf (stderr, "%s: unknown demangling style `%s'\n", + program_name, optarg); + exit (1); + } + break; + } + } + + if (optind < argc) + { + for ( ; optind < argc; optind++) + { + demangle_it (argv[optind]); + } + } + else + { + for (;;) + { + int i = 0; + c = getchar (); + /* Try to read a label. */ + while (c != EOF && (isalnum(c) || c == '_' || c == '$' || c == '.')) + { + if (i >= MBUF_SIZE-1) + break; + mbuffer[i++] = c; + c = getchar (); + } + if (i > 0) + { + int skip_first = 0; + + if (mbuffer[0] == '.') + ++skip_first; + if (strip_underscore && mbuffer[skip_first] == '_') + ++skip_first; + + if (skip_first > i) + skip_first = i; + + mbuffer[i] = 0; + + result = cplus_demangle (mbuffer + skip_first, flags); + if (result) + { + if (mbuffer[0] == '.') + putc ('.', stdout); + fputs (result, stdout); + free (result); + } + else + fputs (mbuffer, stdout); + + fflush (stdout); + } + if (c == EOF) + break; + putchar (c); + } + } + + exit (0); +} + +static void +fatal (str) + char *str; +{ + fprintf (stderr, "%s: %s\n", program_name, str); + exit (1); +} + +char * malloc (); +char * realloc (); + +char * +xmalloc (size) + unsigned size; +{ + register char *value = (char *) malloc (size); + if (value == 0) + fatal ("virtual memory exhausted"); + return value; +} + +char * +xrealloc (ptr, size) + char *ptr; + unsigned size; +{ + register char *value = (char *) realloc (ptr, size); + if (value == 0) + fatal ("virtual memory exhausted"); + return value; +} +#endif /* main */ diff --git a/libiberty/dummy.c b/libiberty/dummy.c new file mode 100644 index 000000000000..08da647e30eb --- /dev/null +++ b/libiberty/dummy.c @@ -0,0 +1,49 @@ +#include + +#ifdef __STDC__ +#include +#define clock_t unsigned long +#define DEF(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (ARGS); +#define DEFFUNC(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (ARGS); +#else +#define void int +#define size_t unsigned long +#define clock_t unsigned long +#define DEF(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (); +#define DEFFUNC(NAME, RETURN_TYPE, ARGLIST, ARGS) extern RETURN_TYPE NAME (); +#endif + +#define DEFVAR(NAME,DECL,USE) extern DECL; + +#define NOTHING /*nothing*/ + +#include "alloca-conf.h" +#include "functions.def" + +/* Always use our: getopt.o getopt1.o obstack.o spaces.o */ + +int +main (argc, argv) + int argc; char **argv; +{ + +/* Create a dummy function call for each DEF-defined function. */ + +#undef DEF +#undef DEFVAR +#undef DEFFUNC +#undef AND +#define AND = 0; +/* ARGS expands into a set of declaration. NAME ARG_LIST expands + info a function call that uses those variables as actual parameters. + If the function has been DEF'ed correctly, we can pass the right + number and types of parameters, which is nice. (E.g. gcc may + otherwise complain about the wrong number of parameters to certain + builtins.) */ +#define DEF(NAME, RETURN_TYPE, ARG_LIST, ARGS) { ARGS; NAME ARG_LIST; } +#define DEFVAR(NAME, DECL, USE) { USE; } +#define DEFFUNC(NAME, RETURN_TYPE, ARG_LIST, ARGS) { ARGS; NAME ARG_LIST; } +#include "functions.def" + + return (0); +} diff --git a/libiberty/fdmatch.c b/libiberty/fdmatch.c new file mode 100644 index 000000000000..7af039f5a2b8 --- /dev/null +++ b/libiberty/fdmatch.c @@ -0,0 +1,73 @@ +/* Compare two open file descriptors to see if they refer to the same file. + Copyright (C) 1991 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +/* + +NAME + + fdmatch -- see if two file descriptors refer to same file + +SYNOPSIS + + int fdmatch (int fd1, int fd2) + +DESCRIPTION + + Check to see if two open file descriptors refer to the same file. + This is useful, for example, when we have an open file descriptor + for an unnamed file, and the name of a file that we believe to + correspond to that fd. This can happen when we are exec'd with + an already open file (stdout for example) or from the SVR4 /proc + calls that return open file descriptors for mapped address spaces. + All we have to do is open the file by name and check the two file + descriptors for a match, which is done by comparing major&minor + device numbers and inode numbers. + +BUGS + + (FIXME: does this work for networks?) + It works for NFS, which assigns a device number to each mount. + +*/ + +#include "ansidecl.h" +#include "libiberty.h" +#include +#include + +int fdmatch (fd1, fd2) + int fd1; + int fd2; +{ + struct stat sbuf1; + struct stat sbuf2; + + if ((fstat (fd1, &sbuf1) == 0) && + (fstat (fd2, &sbuf2) == 0) && + (sbuf1.st_dev == sbuf2.st_dev) && + (sbuf1.st_ino == sbuf2.st_ino)) + { + return (1); + } + else + { + return (0); + } +} diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c new file mode 100644 index 000000000000..7f6086f43068 --- /dev/null +++ b/libiberty/floatformat.c @@ -0,0 +1,401 @@ +/* IEEE floating point support routines, for GDB, the GNU Debugger. + Copyright (C) 1991, 1994 Free Software Foundation, Inc. + +This file is part of GDB. + +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 "floatformat.h" +#include /* ldexp */ +#ifdef __STDC__ +#include +extern void *memcpy (void *s1, const void *s2, size_t n); +extern void *memset (void *s, int c, size_t n); +#else +extern char *memcpy (); +extern char *memset (); +#endif + +/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not + going to bother with trying to muck around with whether it is defined in + a system header, what we do if not, etc. */ +#define FLOATFORMAT_CHAR_BIT 8 + +/* floatformats for IEEE single and double, big and little endian. */ +const struct floatformat floatformat_ieee_single_big = +{ + floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no +}; +const struct floatformat floatformat_ieee_single_little = +{ + floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no +}; +const struct floatformat floatformat_ieee_double_big = +{ + floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no +}; +const struct floatformat floatformat_ieee_double_little = +{ + floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no +}; + +/* floatformat for IEEE double, little endian byte order, with big endian word + ordering, as on the ARM. */ + +const struct floatformat floatformat_ieee_double_littlebyte_bigword = +{ + floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no +}; + +const struct floatformat floatformat_i387_ext = +{ + floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, + floatformat_intbit_yes +}; +const struct floatformat floatformat_m68881_ext = +{ + /* Note that the bits from 16 to 31 are unused. */ + floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, floatformat_intbit_yes +}; +const struct floatformat floatformat_i960_ext = +{ + /* Note that the bits from 0 to 15 are unused. */ + floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64, + floatformat_intbit_yes +}; +const struct floatformat floatformat_m88110_ext = +{ +#ifdef HARRIS_FLOAT_FORMAT + /* Harris uses raw format 128 bytes long, but the number is just an ieee + double, and the last 64 bits are wasted. */ + floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52, + floatformat_intbit_no +#else + floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, + floatformat_intbit_yes +#endif /* HARRIS_FLOAT_FORMAT */ +}; +const struct floatformat floatformat_arm_ext = +{ + /* Bits 1 to 16 are unused. */ + floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, + floatformat_intbit_yes +}; + +static unsigned long get_field PARAMS ((unsigned char *, + enum floatformat_byteorders, + unsigned int, + unsigned int, + unsigned int)); + +/* Extract a field which starts at START and is LEN bytes long. DATA and + TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */ +static unsigned long +get_field (data, order, total_len, start, len) + unsigned char *data; + enum floatformat_byteorders order; + unsigned int total_len; + unsigned int start; + unsigned int len; +{ + unsigned long result; + unsigned int cur_byte; + int cur_bitshift; + + /* Start at the least significant part of the field. */ + cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1; + cur_bitshift = + ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT; + result = *(data + cur_byte) >> (-cur_bitshift); + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + + /* Move towards the most significant part of the field. */ + while (cur_bitshift < len) + { + if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) + /* This is the last byte; zero out the bits which are not part of + this field. */ + result |= + (*(data + cur_byte) & ((1 << (len - cur_bitshift)) - 1)) + << cur_bitshift; + else + result |= *(data + cur_byte) << cur_bitshift; + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + } + return result; +} + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/* Convert from FMT to a double. + FROM is the address of the extended float. + Store the double in *TO. */ + +void +floatformat_to_double (fmt, from, to) + const struct floatformat *fmt; + char *from; + double *to; +{ + unsigned char *ufrom = (unsigned char *)from; + double dto; + long exponent; + unsigned long mant; + unsigned int mant_bits, mant_off; + int mant_bits_left; + int special_exponent; /* It's a NaN, denorm or zero */ + + exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, + fmt->exp_start, fmt->exp_len); + /* Note that if exponent indicates a NaN, we can't really do anything useful + (not knowing if the host has NaN's, or how to build one). So it will + end up as an infinity or something close; that is OK. */ + + mant_bits_left = fmt->man_len; + mant_off = fmt->man_start; + dto = 0.0; + + special_exponent = exponent == 0 || exponent == fmt->exp_nan; + + /* Don't bias zero's, denorms or NaNs. */ + if (!special_exponent) + exponent -= fmt->exp_bias; + + /* Build the result algebraically. Might go infinite, underflow, etc; + who cares. */ + + /* If this format uses a hidden bit, explicitly add it in now. Otherwise, + increment the exponent by one to account for the integer bit. */ + + if (!special_exponent) + if (fmt->intbit == floatformat_intbit_no) + dto = ldexp (1.0, exponent); + else + exponent++; + + while (mant_bits_left > 0) + { + mant_bits = min (mant_bits_left, 32); + + mant = get_field (ufrom, fmt->byteorder, fmt->totalsize, + mant_off, mant_bits); + + dto += ldexp ((double)mant, exponent - mant_bits); + exponent -= mant_bits; + mant_off += mant_bits; + mant_bits_left -= mant_bits; + } + + /* Negate it if negative. */ + if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) + dto = -dto; + *to = dto; +} + +static void put_field PARAMS ((unsigned char *, enum floatformat_byteorders, + unsigned int, + unsigned int, + unsigned int, + unsigned long)); + +/* Set a field which starts at START and is LEN bytes long. DATA and + TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */ +static void +put_field (data, order, total_len, start, len, stuff_to_put) + unsigned char *data; + enum floatformat_byteorders order; + unsigned int total_len; + unsigned int start; + unsigned int len; + unsigned long stuff_to_put; +{ + unsigned int cur_byte; + int cur_bitshift; + + /* Start at the least significant part of the field. */ + cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1; + cur_bitshift = + ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT; + *(data + cur_byte) &= + ~(((1 << ((start + len) % FLOATFORMAT_CHAR_BIT)) - 1) << (-cur_bitshift)); + *(data + cur_byte) |= + (stuff_to_put & ((1 << FLOATFORMAT_CHAR_BIT) - 1)) << (-cur_bitshift); + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + + /* Move towards the most significant part of the field. */ + while (cur_bitshift < len) + { + if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) + { + /* This is the last byte. */ + *(data + cur_byte) &= + ~((1 << (len - cur_bitshift)) - 1); + *(data + cur_byte) |= (stuff_to_put >> cur_bitshift); + } + else + *(data + cur_byte) = ((stuff_to_put >> cur_bitshift) + & ((1 << FLOATFORMAT_CHAR_BIT) - 1)); + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + } +} + +/* The converse: convert the double *FROM to an extended float + and store where TO points. Neither FROM nor TO have any alignment + restrictions. */ + +void +floatformat_from_double (fmt, from, to) + CONST struct floatformat *fmt; + double *from; + char *to; +{ + double dfrom; + int exponent; + double mant; + unsigned int mant_bits, mant_off; + int mant_bits_left; + unsigned char *uto = (unsigned char *)to; + + memcpy (&dfrom, from, sizeof (dfrom)); + memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT); + if (dfrom == 0) + return; /* Result is zero */ + if (dfrom != dfrom) + { + /* From is NaN */ + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, + fmt->exp_len, fmt->exp_nan); + /* Be sure it's not infinity, but NaN value is irrel */ + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start, + 32, 1); + return; + } + + /* If negative, set the sign bit. */ + if (dfrom < 0) + { + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1); + dfrom = -dfrom; + } + + /* How to tell an infinity from an ordinary number? FIXME-someday */ + + mant = frexp (dfrom, &exponent); + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len, + exponent + fmt->exp_bias - 1); + + mant_bits_left = fmt->man_len; + mant_off = fmt->man_start; + while (mant_bits_left > 0) + { + unsigned long mant_long; + mant_bits = mant_bits_left < 32 ? mant_bits_left : 32; + + mant *= 4294967296.0; + mant_long = (unsigned long)mant; + mant -= mant_long; + + /* If the integer bit is implicit, then we need to discard it. + If we are discarding a zero, we should be (but are not) creating + a denormalized number which means adjusting the exponent + (I think). */ + if (mant_bits_left == fmt->man_len + && fmt->intbit == floatformat_intbit_no) + { + mant_long &= 0x7fffffff; + mant_bits -= 1; + } + else if (mant_bits < 32) + { + /* The bits we want are in the most significant MANT_BITS bits of + mant_long. Move them to the least significant. */ + mant_long >>= 32 - mant_bits; + } + + put_field (uto, fmt->byteorder, fmt->totalsize, + mant_off, mant_bits, mant_long); + mant_off += mant_bits; + mant_bits_left -= mant_bits; + } +} + + +#ifdef IEEE_DEBUG + +/* This is to be run on a host which uses IEEE floating point. */ + +void +ieee_test (n) + double n; +{ + double result; + char exten[16]; + + floatformat_to_double (&floatformat_ieee_double_big, &n, &result); + if (n != result) + printf ("Differ(to): %.20g -> %.20g\n", n, result); + floatformat_from_double (&floatformat_ieee_double_big, &n, &result); + if (n != result) + printf ("Differ(from): %.20g -> %.20g\n", n, result); + + floatformat_from_double (&floatformat_m68881_ext, &n, exten); + floatformat_to_double (&floatformat_m68881_ext, exten, &result); + if (n != result) + printf ("Differ(to+from): %.20g -> %.20g\n", n, result); + +#if IEEE_DEBUG > 1 + /* This is to be run on a host which uses 68881 format. */ + { + long double ex = *(long double *)exten; + if (ex != n) + printf ("Differ(from vs. extended): %.20g\n", n); + } +#endif +} + +int +main () +{ + ieee_test (0.5); + ieee_test (256.0); + ieee_test (0.12345); + ieee_test (234235.78907234); + ieee_test (-512.0); + ieee_test (-0.004321); + return 0; +} +#endif diff --git a/libiberty/fnmatch.c b/libiberty/fnmatch.c new file mode 100644 index 000000000000..685d9e40edcc --- /dev/null +++ b/libiberty/fnmatch.c @@ -0,0 +1,223 @@ +/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + +NOTE: The canonical source of this file is maintained with the GNU C Library. +Bugs can be reported to bug-glibc@prep.ai.mit.edu. + +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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use 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 +#else +#include "config.h" +#endif +#endif + + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +/* This code to undef const added in libiberty. */ +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include +#include +#include + + +/* 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. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) +extern int errno; +#endif + +/* Match STRING against the filename pattern PATTERN, returning zero if + it matches, nonzero if not. */ +int +fnmatch (pattern, string, flags) + const char *pattern; + const char *string; + int flags; +{ + register const char *p = pattern, *n = string; + register char c; + +/* Note that this evalutes C many times. */ +#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c)) + + while ((c = *p++) != '\0') + { + c = FOLD (c); + + switch (c) + { + case '?': + if (*n == '\0') + return FNM_NOMATCH; + else if ((flags & FNM_FILE_NAME) && *n == '/') + return FNM_NOMATCH; + else if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + break; + + case '\\': + if (!(flags & FNM_NOESCAPE)) + { + c = *p++; + c = FOLD (c); + } + if (FOLD (*n) != c) + return FNM_NOMATCH; + break; + + case '*': + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + + for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) + if (((flags & FNM_FILE_NAME) && *n == '/') || + (c == '?' && *n == '\0')) + return FNM_NOMATCH; + + if (c == '\0') + return 0; + + { + char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; + c1 = FOLD (c1); + for (--p; *n != '\0'; ++n) + if ((c == '[' || FOLD (*n) == c1) && + fnmatch (p, n, flags & ~FNM_PERIOD) == 0) + return 0; + return FNM_NOMATCH; + } + + case '[': + { + /* Nonzero if the sense of the character class is inverted. */ + register int not; + + if (*n == '\0') + return FNM_NOMATCH; + + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + + not = (*p == '!' || *p == '^'); + if (not) + ++p; + + c = *p++; + for (;;) + { + register char cstart = c, cend = c; + + if (!(flags & FNM_NOESCAPE) && c == '\\') + cstart = cend = *p++; + + cstart = cend = FOLD (cstart); + + if (c == '\0') + /* [ (unterminated) loses. */ + return FNM_NOMATCH; + + c = *p++; + c = FOLD (c); + + if ((flags & FNM_FILE_NAME) && c == '/') + /* [/] can never match. */ + return FNM_NOMATCH; + + if (c == '-' && *p != ']') + { + cend = *p++; + if (!(flags & FNM_NOESCAPE) && cend == '\\') + cend = *p++; + if (cend == '\0') + return FNM_NOMATCH; + cend = FOLD (cend); + + c = *p++; + } + + if (FOLD (*n) >= cstart && FOLD (*n) <= cend) + goto matched; + + if (c == ']') + break; + } + if (!not) + return FNM_NOMATCH; + break; + + matched:; + /* Skip the rest of the [...] that already matched. */ + while (c != ']') + { + if (c == '\0') + /* [... (unterminated) loses. */ + return FNM_NOMATCH; + + c = *p++; + if (!(flags & FNM_NOESCAPE) && c == '\\') + /* XXX 1003.2d11 is unclear if this is right. */ + ++p; + } + if (not) + return FNM_NOMATCH; + } + break; + + default: + if (c != FOLD (*n)) + return FNM_NOMATCH; + } + + ++n; + } + + if (*n == '\0') + return 0; + + if ((flags & FNM_LEADING_DIR) && *n == '/') + /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ + return 0; + + return FNM_NOMATCH; +} + +#endif /* _LIBC or not __GNU_LIBRARY__. */ diff --git a/libiberty/functions.def b/libiberty/functions.def new file mode 100644 index 000000000000..aeed4c69c3b0 --- /dev/null +++ b/libiberty/functions.def @@ -0,0 +1,69 @@ +/* + * List of function definitions that may *optionally* be included + * in libiberty.a. The function names must match the filenames, + * e.g. bzero() is defined in bzero.c. (While each file can contain + * extra functions, do not list them.) + * + * In the default libiberty configuration, these object files + * (e.g bzero.o) are included if and only if cc fails to find + * the corresponding function in libc. + */ + +DEF(atexit, int, (f), void (*f)()) +DEF(bcmp, int, (s1, s2, length), char *s1 AND char *s2 AND int length ) +DEF(bcopy, void, (s1, s2, length), char *s1 AND char *s2 AND int length ) +DEF(bzero, void, (s, length), char *s AND int length) +DEF(clock, clock_t, (), NOTHING) +DEF(getopt, int, (argc, argv, optstring), + int argc AND char **argv AND CONST char *optstring) +DEF(getpagesize, int , (), NOTHING) +DEF(getcwd, char*, (buf, len), char *buf AND int len) +DEF(index, char*, (s, c), char *s AND int c) +DEF(insque, void, (), NOTHING) +DEF(memchr, PTR, (s, c, length), CONST PTR s AND int c AND size_t length) +DEF(memcmp, int, (s1, s2, length), + CONST PTR s1 AND CONST PTR s2 AND size_t length) +DEF(memcpy, PTR, (s1, s2, length), PTR s1 AND CONST PTR s2 AND size_t length) +DEF(memmove, PTR, (s1, s2, length), PTR s1 AND CONST PTR s2 AND size_t length) +DEF(memset, PTR, (s, val, length), PTR s AND int val AND size_t length ) +DEF(random, long int, (), NOTHING) +DEF(rename, int, (f, t), char *f AND char *t) +DEF(rindex, char*, (s, c), char *s AND int c) +DEF(strcasecmp, int, (s1, s2), char *s1 AND char *s2) +DEF(strncasecmp, int, (s1, s2, n), char *s1 AND char *s2 AND int n) +DEF(strchr, char*, (s, c), CONST char *s AND int c) +DEF(strdup, char*, (s1), char * s1) +DEF(strrchr, char*, (s, c), CONST char *s AND int c) +DEF(strstr, char*, (), NOTHING) +DEF(strtod, double, (), NOTHING) +DEF(strtol, long, (), NOTHING) +DEF(strtoul, unsigned long, (), NOTHING) +DEF(tmpnam, char *, (s), char * s) +DEF(vfork, int, (), NOTHING) +DEF(vfprintf, int, (), NOTHING) +DEF(vprintf, int, (), NOTHING) +DEF(vsprintf, int, (), NOTHING) +DEF(sigsetmask, int, (), NOTHING) +DEF(alloca, PTR, (size), size_t size) +DEF(waitpid, int, (pid, statp, opts), int pid AND int* statp AND int opts ) +DEF(vasprintf, int, (), NOTHING) + +/* List of global variables that we want to look for in the host + environment, and to generate an entry NEED_ in config.h + if they are not found. The first arg is the variable name, the + second arg is how to declare the variable, and the third is how to + use it. */ + +DEFVAR(sys_nerr, int sys_nerr, sys_nerr = 0) +DEFVAR(sys_errlist, char *sys_errlist[], sys_errlist[0] = 0) +DEFVAR(sys_siglist, char *sys_siglist[], sys_siglist[0] = 0) + +/* List of global functions that we want to look for in the host + environment, and to generate an entry NEED_ in config.h + if they are not found. */ + +DEFFUNC(strerror, char*, (), NOTHING) +DEFFUNC(psignal, void, (signo, message), unsigned signo AND char *message) +DEFFUNC(basename, char *, (name), CONST char *name) +DEFFUNC(on_exit, void, (f, arg), void (*f)() AND char *arg) +DEFFUNC(strsignal, char *, (), NOTHING) diff --git a/libiberty/getcwd.c b/libiberty/getcwd.c new file mode 100644 index 000000000000..60c1dd84eed9 --- /dev/null +++ b/libiberty/getcwd.c @@ -0,0 +1,52 @@ +/* Emulate getcwd using getwd. + This function is in the public domain. */ + +/* +NAME + getcwd -- get absolute pathname for current working directory + +SYNOPSIS + char *getcwd (char pathname[len], len) + +DESCRIPTION + Copy the absolute pathname for the current working directory into + the supplied buffer and return a pointer to the buffer. If the + current directory's path doesn't fit in LEN characters, the result + is NULL and errno is set. + +BUGS + Emulated via the getwd() call, which is reasonable for most + systems that do not have getcwd(). + +*/ + +#ifndef NO_SYS_PARAM_H +#include +#endif +#include + +extern char *getwd (); +extern int errno; + +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif + +char * +getcwd (buf, len) + char *buf; + int len; +{ + char ourbuf[MAXPATHLEN]; + char *result; + + result = getwd (ourbuf); + if (result) { + if (strlen (ourbuf) >= len) { + errno = ERANGE; + return 0; + } + strcpy (buf, ourbuf); + } + return buf; +} diff --git a/libiberty/getopt.c b/libiberty/getopt.c new file mode 100644 index 000000000000..79080aa54b3b --- /dev/null +++ b/libiberty/getopt.c @@ -0,0 +1,760 @@ +/* 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 . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +#define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +#if defined (emacs) || defined (CONFIG_BROKETS) +/* We use 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 +#else +#include "config.h" +#endif +#endif + +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* 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__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +#include +#endif /* GNU C library. */ + +/* 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 +#define my_index strchr +#else + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +char *getenv (); + +static char * +my_index (str, chr) + 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 (argv) + 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 (optstring) + 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 (argc, argv, optstring, longopts, longind, long_only) + 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 (argc == 0) + return EOF; + + 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; + 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 (nameend - nextchar == 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 (argc, argv, optstring) + 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/libiberty/getopt1.c b/libiberty/getopt1.c new file mode 100644 index 000000000000..c3400e5b6436 --- /dev/null +++ b/libiberty/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 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 +#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 + +/* 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 +#else +char *getenv (); +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + 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 (argc, argv, options, long_options, opt_index) + 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 + +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/libiberty/getpagesize.c b/libiberty/getpagesize.c new file mode 100644 index 000000000000..e9784b8520b8 --- /dev/null +++ b/libiberty/getpagesize.c @@ -0,0 +1,89 @@ +/* Emulation of getpagesize() for systems that need it. */ + +/* + +NAME + + getpagesize -- return the number of bytes in page of memory + +SYNOPSIS + + int getpagesize (void) + +DESCRIPTION + + Returns the number of bytes in a page of memory. This is the + granularity of many of the system memory management routines. + No guarantee is made as to whether or not it is the same as the + basic memory management hardware page size. + +BUGS + + Is intended as a reasonable replacement for systems where this + is not provided as a system call. The value of 4096 may or may + not be correct for the systems where it is returned as the default + value. + +*/ + +#ifndef VMS + +#include +#ifndef NO_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYSCONF +#include +#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE) +#else +#ifdef PAGESIZE +#define GNU_OUR_PAGESIZE PAGESIZE +#else /* no PAGESIZE */ +#ifdef EXEC_PAGESIZE +#define GNU_OUR_PAGESIZE EXEC_PAGESIZE +#else /* no EXEC_PAGESIZE */ +#ifdef NBPG +#define GNU_OUR_PAGESIZE (NBPG * CLSIZE) +#ifndef CLSIZE +#define CLSIZE 1 +#endif /* CLSIZE */ +#else /* no NBPG */ +#ifdef NBPC +#define GNU_OUR_PAGESIZE NBPC +#else /* no NBPC */ +#define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */ +#endif /* NBPC */ +#endif /* NBPG */ +#endif /* EXEC_PAGESIZE */ +#endif /* PAGESIZE */ +#endif /* HAVE_SYSCONF */ + +int +getpagesize () +{ + return (GNU_OUR_PAGESIZE); +} + +#else /* VMS */ + +#if 0 /* older distributions of gcc-vms are missing */ +#include +#endif +#ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */ +#define SYI$_PAGE_SIZE 4452 +#endif +extern unsigned long lib$getsyi(const unsigned short *,...); + +int getpagesize () +{ + long pagsiz = 0L; + unsigned short itmcod = SYI$_PAGE_SIZE; + + (void) lib$getsyi (&itmcod, (void *) &pagsiz); + if (pagsiz == 0L) + pagsiz = 512L; /* VAX default */ + return (int) pagsiz; +} + +#endif /* VMS */ diff --git a/libiberty/getruntime.c b/libiberty/getruntime.c new file mode 100644 index 000000000000..1be3b4c4a2a0 --- /dev/null +++ b/libiberty/getruntime.c @@ -0,0 +1,82 @@ +/* Return time used so far, in microseconds. + Copyright (C) 1994 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "ansidecl.h" +#include "libiberty.h" + +/* There are several ways to get elapsed execution time; unfortunately no + single way is available for all host systems, nor are there reliable + ways to find out which way is correct for a given host. */ + +#include + +/* These should go away when libiberty uses autoconf. */ + +#if defined(__sun__) && !defined(__svr4__) +#define HAVE_GETRUSAGE +#endif + +#ifdef HAVE_SYSCONF +#define HAVE_TIMES +#endif + +#ifdef HAVE_GETRUSAGE +#include +#include +#endif + +#ifdef HAVE_TIMES +#ifndef NO_SYS_PARAM_H +#include +#endif +#include +#endif + +/* This is a fallback; if wrong, it will likely make obviously wrong + results. */ + +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1 +#endif + +long +get_run_time () +{ +#ifdef HAVE_GETRUSAGE + struct rusage rusage; + + getrusage (0, &rusage); + return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec + + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); +#else /* ! HAVE_GETRUSAGE */ +#ifdef HAVE_TIMES + struct tms tms; + + times (&tms); + return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); +#else /* ! HAVE_TIMES */ + /* Fall back on clock and hope it's correctly implemented. */ + const long clocks_per_sec = CLOCKS_PER_SEC; + if (clocks_per_sec <= 1000000) + return clock () * (1000000 / clocks_per_sec); + else + return clock () / clocks_per_sec; +#endif /* HAVE_TIMES */ +#endif /* HAVE_GETRUSAGE */ +} diff --git a/libiberty/hex.c b/libiberty/hex.c new file mode 100644 index 000000000000..3a2eef03d4c0 --- /dev/null +++ b/libiberty/hex.c @@ -0,0 +1,33 @@ +/* Hex character manipulation support. + Copyright (C) 1995 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "libiberty.h" + +char _hex_value[_hex_array_size]; + +void hex_init () +{ + int i; + for (i = 0; i < _hex_array_size; i++) + _hex_value[i] = _hex_bad; + for (i = 0; i < 10; i++) + _hex_value['0' + i] = i; + for (i = 0; i < 6; i++) + _hex_value['a' + i] = _hex_value['A' + i] = 10 + i; +} diff --git a/libiberty/index.c b/libiberty/index.c new file mode 100644 index 000000000000..e5a00f54d946 --- /dev/null +++ b/libiberty/index.c @@ -0,0 +1,11 @@ +/* Stub implementation of (obsolete) index(). */ + +extern char * strchr(); + +char * +index (s, c) + char *s; + int c; +{ + return strchr (s, c); +} diff --git a/libiberty/insque.c b/libiberty/insque.c new file mode 100644 index 000000000000..775019f8fffc --- /dev/null +++ b/libiberty/insque.c @@ -0,0 +1,50 @@ +/* insque(3C) routines + This file is in the public domain. */ + +/* +NAME + insque, remque -- insert, remove an element from a queue + +SYNOPSIS + struct qelem { + struct qelem *q_forw; + struct qelem *q_back; + char q_data[]; + }; + + void insque (struct qelem *elem, struct qelem *pred) + + void remque (struct qelem *elem) + +DESCRIPTION + Routines to manipulate queues built from doubly linked lists. + The insque routine inserts ELEM in the queue immediately after + PRED. The remque routine removes ELEM from its containing queue. +*/ + + +struct qelem { + struct qelem *q_forw; + struct qelem *q_back; +}; + + +void +insque (elem, pred) + struct qelem *elem; + struct qelem *pred; +{ + elem -> q_forw = pred -> q_forw; + pred -> q_forw -> q_back = elem; + elem -> q_back = pred; + pred -> q_forw = elem; +} + + +void +remque (elem) + struct qelem *elem; +{ + elem -> q_forw -> q_back = elem -> q_back; + elem -> q_back -> q_forw = elem -> q_forw; +} diff --git a/libiberty/makefile.dos b/libiberty/makefile.dos new file mode 100644 index 000000000000..7eba62c33953 --- /dev/null +++ b/libiberty/makefile.dos @@ -0,0 +1,29 @@ +CFLAGS=-O2 + +OBJS = \ + argv.o \ + basename.o \ + concat.o \ + cplus-dem.o \ + fdmatch.o \ + floatformat.o \ + getopt.o \ + getopt1.o \ + getruntime.o \ + hex.o \ + msdos.o \ + obstack.o \ + spaces.o \ + strerror.o \ + strsignal.o \ + xatexit.o \ + xexit.o \ + xmalloc.o \ + $E + +.c.o: + gcc -I../include $(CFLAGS) -c $< + +libiberty.a : $(OBJS) + -rm libiberty.a + ar rvs libiberty.a $(OBJS) diff --git a/libiberty/makefile.vms b/libiberty/makefile.vms new file mode 100644 index 000000000000..6f49ee1b1ea6 --- /dev/null +++ b/libiberty/makefile.vms @@ -0,0 +1,37 @@ +# +# Makefile for libiberty under openVMS/Alpha +# +# For use with gnu-make for vms +# +# Created by Klaus K"ampf, kkaempf@progis.de +# +# + +OBJS=bcopy.obj,bcmp.obj,getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\ + getopt1.obj,cplus-dem.obj,strncasecmp.obj,strcasecmp.obj,strdup.obj,\ + concat.obj,getruntime.obj,getpagesize.obj,alloca.obj,xstrerror.obj,\ + xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj + +ifeq ($(CC),gcc) +CFLAGS=/include=([],[-.include]) +else +# assume dec c +CFLAGS=/noopt/debug/include=([],[-.include])/define=("const=")/warnings=disable=(missingreturn,implicitfunc) +endif + +libiberty.olb: config.h alloca-conf.h $(OBJS) + purge + lib/create libiberty *.obj + +alloca-conf.h: alloca-norm.h + $(CP) $< $@ + +config.h: config.h-vms + $(CP) $< $@ + +clean: + $$ purge + $(RM) alloca-conf.h; + $(RM) config.h; + $(RM) *.obj; + $(RM) libiberty.olb; diff --git a/libiberty/memchr.c b/libiberty/memchr.c new file mode 100644 index 000000000000..93ef43d3f88d --- /dev/null +++ b/libiberty/memchr.c @@ -0,0 +1,60 @@ +/* +FUNCTION + <>---find character in memory + +INDEX + memchr + +ANSI_SYNOPSIS + #include + void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>); + +TRAD_SYNOPSIS + #include + void *memchr(<[src]>, <[c]>, <[length]>) + void *<[src]>; + void *<[c]>; + size_t <[length]>; + +DESCRIPTION + This function searches memory starting at <<*<[src]>>> for the + character <[c]>. The search only ends with the first + occurrence of <[c]>, or after <[length]> characters; in + particular, <> does not terminate the search. + +RETURNS + If the character <[c]> is found within <[length]> characters + of <<*<[src]>>>, a pointer to the character is returned. If + <[c]> is not found, then <> is returned. + +PORTABILITY +<> requires no supporting OS subroutines. + +QUICKREF + memchr ansi pure + +*/ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +PTR +memchr (src_void, c, length) + register CONST PTR src_void; + int c; + size_t length; +{ + CONST unsigned char *src = (CONST unsigned char *)src_void; + + while (--length >= 0) + { + if (*src == c) + return (PTR)src; + src++; + } + return NULL; +} diff --git a/libiberty/memcmp.c b/libiberty/memcmp.c new file mode 100644 index 000000000000..127ae0c8019d --- /dev/null +++ b/libiberty/memcmp.c @@ -0,0 +1,38 @@ +/* memcmp -- compare two memory regions. + This function is in the public domain. */ + +/* +NAME + memcmp -- compare two memory regions + +SYNOPSIS + int memcmp (const void *from, const void *to, size_t count) + +DESCRIPTION + Compare two memory regions and return less than, + equal to, or greater than zero, according to lexicographical + ordering of the compared regions. +*/ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +int +DEFUN(memcmp, (str1, str2, count), + const PTR str1 AND const PTR str2 AND size_t count) +{ + register unsigned char *s1 = (unsigned char*)str1; + register unsigned char *s2 = (unsigned char*)str2; + + while (count-- > 0) + { + if (*s1++ != *s2++) + return s1[-1] < s2[-1] ? -1 : 1; + } + return 0; +} + diff --git a/libiberty/memcpy.c b/libiberty/memcpy.c new file mode 100644 index 000000000000..c28208a0f7e8 --- /dev/null +++ b/libiberty/memcpy.c @@ -0,0 +1,28 @@ +/* memcpy (the standard C function) + This function is in the public domain. */ + +/* +NAME + memcpy -- copy memory regions of arbitary length + +SYNOPSIS + void* memcpy (void *out, const void *in, size_t n); + +DESCRIPTION + Copy LENGTH bytes from memory region pointed to by IN to memory + region pointed to by OUT. +*/ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +PTR +DEFUN(memcpy, (out, in, length), PTR out AND CONST PTR in AND size_t length) +{ + bcopy(in, out, length); + return out; +} diff --git a/libiberty/memmove.c b/libiberty/memmove.c new file mode 100644 index 000000000000..818fc2496622 --- /dev/null +++ b/libiberty/memmove.c @@ -0,0 +1,18 @@ +/* Wrapper to implement ANSI C's memmove using BSD's bcopy. */ +/* This function is in the public domain. --Per Bothner. */ +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +PTR +memmove (s1, s2, n) + PTR s1; + CONST PTR s2; + size_t n; +{ + bcopy (s2, s1, n); + return s1; +} diff --git a/libiberty/memset.c b/libiberty/memset.c new file mode 100644 index 000000000000..5f54831e83c4 --- /dev/null +++ b/libiberty/memset.c @@ -0,0 +1,19 @@ +/* memset + This implementation is in the public domain. */ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +PTR +DEFUN(memset, (dest, val, len), + PTR dest AND register int val AND register size_t len) +{ + register unsigned char *ptr = (unsigned char*)dest; + while (len-- > 0) + *ptr++ = val; + return dest; +} diff --git a/libiberty/mpw-config.in b/libiberty/mpw-config.in new file mode 100644 index 000000000000..829d8e730d46 --- /dev/null +++ b/libiberty/mpw-config.in @@ -0,0 +1,9 @@ +# MPW configuration fragment for libiberty. + +forward-include "{srcdir}"alloca-norm.h alloca-conf.h + +Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new + +MoveIfChange "{o}"config.new "{o}"config.h + + diff --git a/libiberty/mpw-make.sed b/libiberty/mpw-make.sed new file mode 100644 index 000000000000..6f2a5e77b2bd --- /dev/null +++ b/libiberty/mpw-make.sed @@ -0,0 +1,51 @@ +# Sed commands to finish translating libiberty's Unix makefile to MPW syntax. + +# Comment out a useless thing. +/^\.always\./s/^/#/ + +# Replace the auto-generated list with the list of what we know we need. +s/`cat needed-list`/"{o}"alloca.c.o "{o}"bcopy.c.o "{o}"getpagesize.c.o "{o}"insque.c.o "{o}"mpw.c.o "{o}"strcasecmp.c.o "{o}"strdup.c.o "{o}"strncasecmp.c.o/ + +# Paste in some desirable definitions. +# The default rule here completely replaces the tricky stuff in the Unix +# Makefile.in. +/^###$/a\ +\ +HDEFINES = -d NEED_sys_siglist -d NEED_sys_errlist -d NEED_basename -d NEED_strcasecmp -d NEED_strncasecmp\ +INCLUDES = -i : -i {INCDIR}: -i {INCDIR}:mpw: -i ::extra-include: -i "{s}"\ +\ +.c.o \\Option-f .c\ + {CC} @DASH_C_FLAG@ {DepDir}{Default}.c {LIBCFLAGS} {INCLUDES} {HDEFINES} @SEGMENT_FLAG({Default})@ -o {TargDir}{Default}.c.o\ + +# Remove dependency on needed-list, which we don't use. +/DO_ALSO =/s/needed-list// + +/INCDIR=/s/"{srcdir}"{MULTISRCTOP}::/"{topsrcdir}"/ + +# Whack out the COMPILE.c trickiness. +/^COMPILE.c /,/^$/d + +# Remove the multido trickiness from the "all" target. +/^all \\Option-f/,/^$/c\ +all \\Option-f {TARGETLIB}\ + + +# Remove the RULE1/RULE2 crud. +/if \[/,/fi/d +/^RULE1 =/,/RULE2 =/d +/RULE2/s/RULE2/TARGETLIB/ + +# Don't want fdmatch ever. +s/ "{o}"fdmatch.c.o// + +# Fix paths to generated files. +/config.h/s/"{s}"config.h/"{o}"config.h/ + +# Whack out config rebuild rules. +/^"{o}"config.h \\Option-f/,/^$/d + + + + + + diff --git a/libiberty/mpw.c b/libiberty/mpw.c new file mode 100644 index 000000000000..4380da45203d --- /dev/null +++ b/libiberty/mpw.c @@ -0,0 +1,1010 @@ +/* MPW-Unix compatibility library. + Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This should only be compiled and linked under MPW. */ + +#include "mpw.h" + +#include + +#ifndef USE_MW_HEADERS +#include +#include +#endif + +#include +#include + +#include + +/* Initialize to 0 at first, then set to errno_max() later. */ + +int sys_nerr = 0; + +/* Debug flag for pathname hacking. Set this to one and rebuild. */ + +int DebugPI = -1; + +void +mpwify_filename(char *unixname, char *macname) +{ + int i, j; + + /* (should truncate 255 chars from end of name, not beginning) */ + if (strlen (unixname) > 255) + { + fprintf (stderr, "Pathname \"%s\" is too long for Macs, truncating\n", + unixname); + } + j = 0; + /* If you're going to end up with one or more colons in the middle of a + a path after an all-Unix relative path is translated, you must add a + colon on the front, so that the first component is not thought to be + a disk name. */ + if (unixname[0] != '/' && ! strchr (unixname, ':') && strchr (unixname, '/')) + { + macname[j++] = ':'; + } + for (i = 0; unixname[i] != '\0' && i < 255; ++i) + { + if (i == 0 && unixname[i] == '/') + { + if (strncmp (unixname, "/tmp/", 5) == 0) + { + /* A temporary name, make a more Mac-flavored tmpname. */ + /* A better choice would be {Boot}Trash:foo, but + that would require being able to identify the + boot disk's and trashcan's name. Another option + would be to have an env var, so user can point it + at a ramdisk. */ + macname[j++] = ':'; + macname[j++] = 't'; + macname[j++] = 'm'; + macname[j++] = 'p'; + macname[j++] = '_'; + i += 4; + } + else + { + /* Don't copy the leading slash. */ + } + } + else if (unixname[i] == ':' && unixname[i+1] == '/') + { + macname[j++] = ':'; + i += 1; + } + else if (unixname[i] == '.' && unixname[i+1] == '/') + { + macname[j++] = ':'; + i += 1; + } + else if (unixname[i] == '.' && unixname[i+1] == '.' && unixname[i+2] == '/') + { + macname[j++] = ':'; + macname[j++] = ':'; + i += 2; + } + else if (unixname[i] == '/') + { + macname[j++] = ':'; + } + else + { + macname[j++] = unixname[i]; + } + } + macname[j] = '\0'; + /* Allow for getting the debug flag from an env var; quite useful. */ + if (DebugPI < 0) + DebugPI = (*(getenv ("DEBUG_PATHNAMES")) == '1' ? 1 : 0); + if (DebugPI) + { + fprintf (stderr, "# Made \"%s\"\n", unixname); + fprintf (stderr, "# into \"%s\"\n", macname); + } +} + +/* MPW-flavored basename finder. */ + +char * +mpw_basename (name) + char *name; +{ + char *base = name; + + while (*name) + { + if (*name++ == ':') + { + base = name; + } + } + return base; +} + +/* Mixed MPW/Unix basename finder. This can be led astray by + filenames with slashes in them and come up with a basename that + either corresponds to no file or (worse) to some other file, so + should only be tried if other methods of finding a file via a + basename have failed. */ + +char * +mpw_mixed_basename (name) + char *name; +{ + char *base = name; + + while (*name) + { + if (*name == '/' || *name == ':') + { + base = name + 1; + } + ++name; + } + return base; +} + +/* This function is fopen() modified to create files that are type TEXT + or 'BIN ', and always of type 'MPS '. */ + +FILE * +mpw_fopen (char *name, char *mode) +{ +#undef fopen + int errnum; + FILE *fp; + char tmpname[256]; + + mpwify_filename (name, tmpname); + PROGRESS (1); + fp = fopen (tmpname, mode); + errnum = errno; + + /* If writing, need to set type and creator usefully. */ + if (strchr (mode, 'w')) + { + char *pname = (char *) malloc (strlen (tmpname) + 2); + OSErr e; + struct FInfo fi; + + pname[0] = strlen (tmpname); + strcpy (pname+1, tmpname); + + e = GetFInfo ((ConstStr255Param) pname, 0, &fi); + /* should do spiffier error handling */ + if (e != 0) + fprintf(stderr, "GetFInfo returns %d\n", e); + if (strchr (mode, 'b')) + { + fi.fdType = (OSType) 'BIN '; + } + else + { + fi.fdType = (OSType) 'TEXT'; + } + fi.fdCreator = (OSType) 'MPS '; + e = SetFInfo ((ConstStr255Param) pname, 0, &fi); + if (e != 0) + fprintf(stderr, "SetFInfo returns %d\n", e); + free (pname); + } + if (fp == NULL) + errno = errnum; + return fp; +} + +/* This is a version of fseek() modified to fill the file with zeros + if seeking past the end of it. */ + +#define ZEROBLKSIZE 4096 + +char zeros[ZEROBLKSIZE]; + +int +mpw_fseek (FILE *fp, int offset, int whence) +{ +#undef fseek + int cursize, numleft; + + PROGRESS (1); + if (whence == SEEK_SET) + { + fseek (fp, 0, SEEK_END); + cursize = ftell (fp); + if (offset > cursize) + { + numleft = offset - cursize; + while (numleft > ZEROBLKSIZE) + { + /* This might fail, should check for that. */ + PROGRESS (1); + fwrite (zeros, 1, ZEROBLKSIZE, fp); + numleft -= ZEROBLKSIZE; + } + PROGRESS (1); + fwrite (zeros, 1, numleft, fp); + fflush (fp); + } + } + return fseek (fp, offset, whence); +} + +int +mpw_fread (char *ptr, int size, int nitems, FILE *stream) +{ +#undef fread + int rslt; + + PROGRESS (1); + rslt = fread (ptr, size, nitems, stream); + PROGRESS (1); + return rslt; +} + +int +mpw_fwrite (char *ptr, int size, int nitems, FILE *stream) +{ +#undef fwrite + int rslt; + + PROGRESS (1); + rslt = fwrite (ptr, size, nitems, stream); + PROGRESS (1); + return rslt; +} + +int +link () +{ + fprintf (stderr, "link not available!\n"); + mpw_abort (); +} + +int +fork () +{ + fprintf (stderr, "fork not available!\n"); + mpw_abort (); +} + +int +vfork () +{ + fprintf (stderr, "vfork not available!\n"); + mpw_abort (); + return (-1); +} + +int +pipe (int *fd) +{ + fprintf (stderr, "pipe not available!\n"); + mpw_abort (); + return (-1); +} + +#ifndef USE_MW_HEADERS +int +execvp (char *file, char **argv) +{ + fprintf (stderr, "execvp not available!\n"); + mpw_abort (); + return (-1); +} + +int +execv (char *path, char **argv) +{ + fprintf (stderr, "execv not available!\n"); + mpw_abort (); + return (-1); +} +#endif + +int +kill (int pid, int sig) +{ + fprintf (stderr, "kill not available!\n"); + mpw_abort (); + return (-1); +} + +int +wait (int *status) +{ + *status = 0; + return 0; +} + +#ifndef USE_MW_HEADERS +int +sleep (int seconds) +{ + unsigned long start_time, now; + + time (&start_time); + + while (1) + { + PROGRESS (1); + time (&now); + if (now > start_time + seconds) + return 0; + } +} +#endif + +void +putenv (char *str) +{ + /* The GCC driver calls this to do things for collect2, but we + don't care about collect2. */ +} + +int +chmod (char *path, int mode) +{ + /* Pretend it was all OK. */ + return 0; +} + +#ifndef USE_MW_HEADERS +int +getuid () +{ + /* One value is as good as another... */ + return 0; +} + +int +getgid () +{ + /* One value is as good as another... */ + return 0; +} +#endif + +/* Instead of coredumping, which is not a normal Mac facility, we + drop into Macsbug. If we then "g" from Macsbug, the program will + exit cleanly. */ + +void +mpw_abort () +{ + /* Make sure no output still buffered up, then zap into MacsBug. */ + fflush(stdout); + fflush(stderr); + printf("## Abort! ##\n"); +#ifdef MPW_SADE + SysError(8005); +#else + Debugger(); +#endif + /* "g" in MacsBug will then cause a regular error exit. */ + exit (1); +} + +/* Imitation getrusage based on the ANSI clock() function. */ + +int +getrusage (int who, struct rusage *rusage) +{ + int clk = clock (); + +#if 0 + rusage->ru_utime.tv_sec = clk / CLOCKS_PER_SEC; + rusage->ru_utime.tv_usec = ((clk * 1000) / CLOCKS_PER_SEC) * 1000; + rusage->ru_stime.tv_sec = 0; + rusage->ru_stime.tv_usec = 0; +#endif +} + +int +sbrk () +{ + return 0; +} + +#ifndef USE_MW_HEADERS +int +isatty (int fd) +{ + return 0; +} + +/* This is inherited from Timothy Murray's Posix library. */ + +#include "utime.h" + +int +utime (char *filename, struct utimbuf *times) +{ + CInfoPBRec cipbr; + HFileInfo *fpb = (HFileInfo *) &cipbr; + DirInfo *dpb = (DirInfo *) &cipbr; + unsigned char pname[256]; + short err; + + strcpy ((char *) pname, filename); + c2pstr (pname); + + dpb->ioDrDirID = 0L; + fpb->ioNamePtr = pname; + fpb->ioVRefNum = 0; + fpb->ioFDirIndex = 0; + fpb->ioFVersNum = 0; + err = PBGetCatInfo (&cipbr, 0); + if (err != noErr) { + errno = ENOENT; + return -1; + } + dpb->ioDrDirID = 0L; + fpb->ioFlMdDat = times->modtime; + fpb->ioFlCrDat = times->actime; + err = PBSetCatInfo (&cipbr, 0); + if (err != noErr) { + errno = EACCES; + return -1; + } + return 0; +} + +int +mkdir (char *path, int mode) +{ + errno = ENOSYS; + return -1; +} + +int +rmdir () +{ + errno = ENOSYS; + return -1; +} +#endif + +chown () +{ + errno = ENOSYS; + return -1; +} + +char *myenviron[] = {NULL}; + +char **environ = myenviron; + +#ifndef USE_MW_HEADERS + +/* Minimal 'stat' emulation: tells directories from files and + gives length and mtime. + + Derived from code written by Guido van Rossum, CWI, Amsterdam + and placed by him in the public domain. */ + +extern int __uid, __gid; + +int __uid = 0; +int __gid = 0; + +/* Bits in ioFlAttrib: */ +#define LOCKBIT (1<<0) /* File locked */ +#define DIRBIT (1<<4) /* It's a directory */ + +/* Macified "stat" in which filename is given relative to a directory, + specified by long DirID. */ + +static int +_stat (char *name, long dirid, struct stat *buf) +{ + CInfoPBRec cipbr; + HFileInfo *fpb = (HFileInfo*) &cipbr; + DirInfo *dpb = (DirInfo*) &cipbr; + Str255 pname; + short err; + + /* Make a temp copy of the name and pascalize. */ + strcpy ((char *) pname, name); + c2pstr (pname); + + cipbr.dirInfo.ioDrDirID = dirid; + cipbr.hFileInfo.ioNamePtr = pname; + cipbr.hFileInfo.ioVRefNum = 0; + cipbr.hFileInfo.ioFDirIndex = 0; + cipbr.hFileInfo.ioFVersNum = 0; + err = PBGetCatInfo (&cipbr, 0); + if (err != noErr) + { + errno = ENOENT; + return -1; + } + /* Mac files are readable if they can be accessed at all. */ + buf->st_mode = 0444; + /* Mark unlocked files as writeable. */ + if (!(fpb->ioFlAttrib & LOCKBIT)) + buf->st_mode |= 0222; + if (fpb->ioFlAttrib & DIRBIT) + { + /* Mark directories as "executable". */ + buf->st_mode |= 0111 | S_IFDIR; + buf->st_size = dpb->ioDrNmFls; + buf->st_rsize = 0; + } + else + { + buf->st_mode |= S_IFREG; + /* Mark apps as "executable". */ + if (fpb->ioFlFndrInfo.fdType == 'APPL') + buf->st_mode |= 0111; + /* Fill in the sizes of data and resource forks. */ + buf->st_size = fpb->ioFlLgLen; + buf->st_rsize = fpb->ioFlRLgLen; + } + /* Fill in various times. */ + buf->st_atime = fpb->ioFlCrDat; + buf->st_mtime = fpb->ioFlMdDat; + buf->st_ctime = fpb->ioFlCrDat; + /* Set up an imitation inode number. */ + buf->st_ino = (unsigned short) fpb->ioDirID; + /* Set up an imitation device. */ + GetVRefNum (buf->st_ino, &buf->st_dev); + buf->st_uid = __uid; + buf->st_gid = __gid; +/* buf->st_FlFndrInfo = fpb->ioFlFndrInfo; */ + return 0; +} + +/* stat() sets up an empty dirid. */ + +int +stat (char *path, struct stat *buf) +{ + long rslt, errnum; + char tmpname[256]; + + mpwify_filename (path, tmpname); + if (DebugPI) + fprintf (stderr, "# stat (%s, %x)", tmpname, buf); + PROGRESS (1); + rslt = _stat (tmpname, 0L, buf); + errnum = errno; + if (DebugPI) + { + fprintf (stderr, " -> %d", rslt); + if (rslt != 0) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + fflush (stderr); + } + if (rslt != 0) + errno = errnum; + return rslt; +} + +int +fstat (int fd, struct stat *buf) +{ + FCBPBRec fcb; + FILE *fp; + Str255 pathname; + long dirid = 0L, temp; + long rslt, errnum; + short err; + + if (DebugPI < 0) + DebugPI = (*(getenv ("DEBUG_PATHNAMES")) == '1' ? 1 : 0); + if (DebugPI) + fprintf (stderr, "# fstat (%d, %x)", fd, buf); + PROGRESS (1); + pathname[0] = 0; +#ifdef FIOFNAME + /* Use an MPW-specific ioctl to get the pathname associated with + the file descriptor. */ + ioctl (fd, FIOFNAME, (long *) pathname); +#else + you lose +#endif + if (DebugPI) + fprintf (stderr, " (name is %s)", pathname); + dirid = 0L /* fcb.ioFCBParID */ ; + rslt = _stat ((char *) pathname, dirid, buf); + errnum = errno; + if (DebugPI) + { + fprintf (stderr, " -> %d", rslt); + if (rslt != 0) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + fflush (stderr); + } + if (rslt != 0) + errno = errnum; + return rslt; +} + +#endif /* n USE_MW_HEADERS */ + +chdir () +{ + errno = ENOSYS; + return (-1); +} + +char * +getcwd (char *buf, int size) +{ + if (buf == NULL) + buf = (char *) malloc (size); + strcpy(buf, ":"); + return buf; +} + +/* This should probably be more elaborate for MPW. */ + +char * +getpwd () +{ + return ":"; +} + +int +mpw_open (char *filename, int arg2, int arg3) +{ +#undef open + int fd, errnum = 0; + char tmpname[256]; + + mpwify_filename (filename, tmpname); + fd = open (tmpname, arg2); + errnum = errno; + + if (DebugPI) + { + fprintf (stderr, "# open (%s, %d, %d)", tmpname, arg2, arg3); + fprintf (stderr, " -> %d", fd); + if (fd == -1) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + } + if (fd == -1) + errno = errnum; + return fd; +} + +int +mpw_access (char *filename, unsigned int cmd) +{ +#undef access + + int rslt, errnum = 0; + struct stat st; + char tmpname[256]; + + mpwify_filename (filename, tmpname); + if (cmd & R_OK || cmd & X_OK) + { + rslt = stat (tmpname, &st); + errnum = errno; + if (rslt >= 0) + { + if (((st.st_mode & 004 == 0) && (cmd & R_OK)) + || ((st.st_mode & 002 == 0) && (cmd & W_OK)) + || ((st.st_mode & 001 == 0) && (cmd & X_OK))) + { + rslt = -1; + errnum = EACCES; + } + } + } + if (DebugPI) + { + fprintf (stderr, "# mpw_access (%s, %d)", tmpname, cmd); + fprintf (stderr, " -> %d", rslt); + if (rslt != 0) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + } + if (rslt != 0) + errno = errnum; + return rslt; +} + +/* The MPW library creat() has no mode argument. */ + +int +mpw_creat (char *path, /* mode_t */ int mode) +{ +#undef creat + +#ifdef USE_MW_HEADERS + return creat (path, mode); +#else + return creat (path); +#endif +} + +/* This is a hack to get control in an MPW tool before it crashes the + machine. */ + +mpw_special_init (name) + char *name; +{ + if (strstr (name, "DEBUG")) + DebugStr("\pat beginning of program"); +} + +static int current_umask; + +int +umask(int mask) +{ + int oldmask = current_umask; + + current_umask = mask; + return oldmask; +} + +/* Cursor-spinning stuff that includes metering of spin rate and delays. */ + +/* Nonzero when cursor spinning has been set up properly. */ + +int cursor_inited; + +/* Nonzero if spin should be measured and excessive delays reported. */ + +int measure_spin; + +/* Nonzero if spin histogram and rate data should be written out. */ + +int dump_spin_data; + +long warning_threshold = 400000; + +long bucket_size = 1024; + +long bucket_power = 10; + +long numbuckets = 300; + +int *delay_counts; + +int overflow_count; + +char *current_progress; + +static UnsignedWide last_microseconds; + +static char *last_spin_file = ""; + +static int last_spin_line; + +void +warn_if_spin_delay (char *file, int line) +{ + long diff, ix; + UnsignedWide now; + + Microseconds(&now); + + diff = now.lo - last_microseconds.lo; + + if (diff > warning_threshold) + fprintf (stderr, "# %s: %ld.%06ld sec delay getting from %s:%d to %s:%d\n", + (current_progress ? current_progress : ""), + diff / 1000000, diff % 1000000, + last_spin_file, last_spin_line, file, line); + if (dump_spin_data) + { + if (diff >= 0) + { + ix = diff >> bucket_power; + if (ix >= 0 && ix < numbuckets && delay_counts != NULL) + ++delay_counts[ix]; + else + ++overflow_count; + } + else + fprintf (stderr, "raw diff is %ld (?)\n", diff); + } +} + +void +record_for_spin_delay (char *file, int line) +{ + Microseconds (&last_microseconds); + last_spin_file = file; + last_spin_line = line; +} + +void +mpw_start_progress (char *str, int n, char *file, int line) +{ + int i; + char *measure, *threshold; + + if (!cursor_inited) + { + InitCursorCtl (nil); + cursor_inited = 1; + record_for_spin_delay (file, line); + measure = getenv ("MEASURE_SPIN"); + if (measure != NULL && measure[0] != '\0') + { + measure_spin = 1; + if (strcmp (measure, "all") == 0) + dump_spin_data = 1; + } + threshold = getenv ("SPIN_WARN_THRESHOLD"); + if (threshold != NULL && threshold[0] != '\0') + warning_threshold = atol (threshold); + if (dump_spin_data) + { + if (delay_counts == NULL) + delay_counts = (int *) malloc (numbuckets * sizeof (int)); + for (i = 0; i < numbuckets; ++i) + delay_counts[i] = 0; + overflow_count = 0; + } + } + current_progress = str; + + sys_nerr = errno_max (); + + mpw_special_init (str); +} + +void +mpw_progress (int n) +{ + SpinCursor (32); +} + +void +mpw_progress_measured (int n, char *file, int line) +{ + if (measure_spin) + warn_if_spin_delay (file, line); + SpinCursor (32); + if (measure_spin) + record_for_spin_delay (file, line); +} + +void +mpw_end_progress (char *str, char *file, int line) +{ + long i, delay, count = 0, sum = 0, avgdelay, spinrate; + long curpower = 0, curgroup = 0; + + /* Warn if it's been a while since the last spin. */ + if (measure_spin) + warn_if_spin_delay (file, line); + + /* Dump all the nonzero delay counts and an approximation of the delay. */ + if (dump_spin_data && delay_counts != NULL) + { + for (i = 0; i < numbuckets; ++i) + { + delay = (i + 1) * bucket_size; + sum += delay_counts[i] * (i + 1); + count += delay_counts[i]; + if (delay <= (1 << curpower)) + { + curgroup += delay_counts[i]; + } + else + { + if (curgroup > 0) + fprintf (stderr, + "# %s: %d delays between %ld.%06ld and %ld.%06ld sec\n", + (str ? str : ""), + curgroup, + (1 << curpower) / 1000000, + (1 << curpower) % 1000000, + (1 << (curpower + 1)) / 1000000, + (1 << (curpower + 1)) % 1000000); + ++curpower; + curgroup = 0; + } + } + if (count > 0) + { + avgdelay = (sum * bucket_size) / count; + spinrate = 1000000 / avgdelay; + fprintf (stderr, "# %s: Average spin rate is %d times/sec\n", + (str ? str : ""), spinrate); + } + } +} + +#ifdef PROGRESS_TEST + +/* Test program. */ + +main () +{ + int i, j; + double x = 1.0, y = 2.4; + long start = Microseconds (), tm; FIXME + + START_PROGRESS ("hi", 0); + + for (i = 0; i < 1000; ++i) + { + PROGRESS (1); + + for (j = 0; j < (i * 100); ++j) + { + x += (x * y) / j; + } + } + + END_PROGRESS ("hi"); + + tm = Microseconds () - start; + + printf ("Total time is %d.%d secs\n", tm / 1000000, tm % 1000000); +} + +#endif + +#ifdef USE_MW_HEADERS +/* Empty definitions for Metrowerks' SIOUX console library. */ + +#ifndef __CONSOLE__ +#include +#endif + +short +InstallConsole(short fd) +{ +#pragma unused (fd) + return 0; +} + +void +RemoveConsole(void) +{ +} + +long +WriteCharsToConsole(char *buf, long n) +{ +#pragma unused (buf, n) + return 0; +} + +long ReadCharsFromConsole(char *buf, long n) +{ +#pragma unused (buf, n) + return 0; +} + +extern char * +__ttyname(long fd) +{ + static char *__devicename = "null device"; + + if (fd >= 0 && fd <= 2) + return (__devicename); + return NULL; +} + +#endif diff --git a/libiberty/msdos.c b/libiberty/msdos.c new file mode 100644 index 000000000000..923e64d4ede6 --- /dev/null +++ b/libiberty/msdos.c @@ -0,0 +1,15 @@ +char msg[] = "No vfork available - aborting\n"; +vfork() +{ + write(1, msg, sizeof(msg)); +} + +sigsetmask() +{ + /* no signals support in go32 (yet) */ +} + +waitpid() +{ + return -1; +} diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c new file mode 100644 index 000000000000..34687d3891a2 --- /dev/null +++ b/libiberty/objalloc.c @@ -0,0 +1,289 @@ +/* objalloc.c -- routines to allocate memory for objects + Copyright 1997 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Solutions. + +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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "ansidecl.h" +#include "objalloc.h" + +/* Get a definition for NULL. */ +#include + +#if VMS +#include +#include +#else + +#ifdef ANSI_PROTOTYPES +/* Get a definition for size_t. */ +#include +#endif + +/* For systems with larger pointers than ints, this must be declared. */ +extern PTR malloc PARAMS ((size_t)); +#endif + +/* These routines allocate space for an object. Freeing allocated + space may or may not free all more recently allocated space. + + We handle large and small allocation requests differently. If we + don't have enough space in the current block, and the allocation + request is for more than 512 bytes, we simply pass it through to + malloc. */ + +/* The objalloc structure is defined in objalloc.h. */ + +/* This structure appears at the start of each chunk. */ + +struct objalloc_chunk +{ + /* Next chunk. */ + struct objalloc_chunk *next; + /* If this chunk contains large objects, this is the value of + current_ptr when this chunk was allocated. If this chunk + contains small objects, this is NULL. */ + char *current_ptr; +}; + +/* The aligned size of objalloc_chunk. */ + +#define CHUNK_HEADER_SIZE \ + ((sizeof (struct objalloc_chunk) + OBJALLOC_ALIGN - 1) \ + &~ (OBJALLOC_ALIGN - 1)) + +/* We ask for this much memory each time we create a chunk which is to + hold small objects. */ + +#define CHUNK_SIZE (4096 - 32) + +/* A request for this amount or more is just passed through to malloc. */ + +#define BIG_REQUEST (512) + +/* Create an objalloc structure. */ + +struct objalloc * +objalloc_create () +{ + struct objalloc *ret; + struct objalloc_chunk *chunk; + + ret = (struct objalloc *) malloc (sizeof *ret); + if (ret == NULL) + return NULL; + + ret->chunks = (PTR) malloc (CHUNK_SIZE); + if (ret->chunks == NULL) + { + free (ret); + return NULL; + } + + chunk = (struct objalloc_chunk *) ret->chunks; + chunk->next = NULL; + chunk->current_ptr = NULL; + + ret->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE; + ret->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE; + + return ret; +} + +/* Allocate space from an objalloc structure. */ + +PTR +_objalloc_alloc (o, len) + struct objalloc *o; + unsigned long len; +{ + /* We avoid confusion from zero sized objects by always allocating + at least 1 byte. */ + if (len == 0) + len = 1; + + len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); + + if (len <= o->current_space) + { + o->current_ptr += len; + o->current_space -= len; + return (PTR) (o->current_ptr - len); + } + + if (len >= BIG_REQUEST) + { + char *ret; + struct objalloc_chunk *chunk; + + ret = (char *) malloc (CHUNK_HEADER_SIZE + len); + if (ret == NULL) + return NULL; + + chunk = (struct objalloc_chunk *) ret; + chunk->next = (struct objalloc_chunk *) o->chunks; + chunk->current_ptr = o->current_ptr; + + o->chunks = (PTR) chunk; + + return (PTR) (ret + CHUNK_HEADER_SIZE); + } + else + { + struct objalloc_chunk *chunk; + + chunk = (struct objalloc_chunk *) malloc (CHUNK_SIZE); + if (chunk == NULL) + return NULL; + chunk->next = (struct objalloc_chunk *) o->chunks; + chunk->current_ptr = NULL; + + o->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE; + o->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE; + + o->chunks = (PTR) chunk; + + return objalloc_alloc (o, len); + } +} + +/* Free an entire objalloc structure. */ + +void +objalloc_free (o) + struct objalloc *o; +{ + struct objalloc_chunk *l; + + l = (struct objalloc_chunk *) o->chunks; + while (l != NULL) + { + struct objalloc_chunk *next; + + next = l->next; + free (l); + l = next; + } + + free (o); +} + +/* Free a block from an objalloc structure. This also frees all more + recently allocated blocks. */ + +void +objalloc_free_block (o, block) + struct objalloc *o; + PTR block; +{ + struct objalloc_chunk *p, *small; + char *b = (char *) block; + + /* First set P to the chunk which contains the block we are freeing, + and set Q to the last small object chunk we see before P. */ + small = NULL; + for (p = (struct objalloc_chunk *) o->chunks; p != NULL; p = p->next) + { + if (p->current_ptr == NULL) + { + if (b > (char *) p && b < (char *) p + CHUNK_SIZE) + break; + small = p; + } + else + { + if (b == (char *) p + CHUNK_HEADER_SIZE) + break; + } + } + + /* If we can't find the chunk, the caller has made a mistake. */ + if (p == NULL) + abort (); + + if (p->current_ptr == NULL) + { + struct objalloc_chunk *q; + struct objalloc_chunk *first; + + /* The block is in a chunk containing small objects. We can + free every chunk through SMALL, because they have certainly + been allocated more recently. After SMALL, we will not see + any chunks containing small objects; we can free any big + chunk if the current_ptr is greater than or equal to B. We + can then reset the new current_ptr to B. */ + + first = NULL; + q = (struct objalloc_chunk *) o->chunks; + while (q != p) + { + struct objalloc_chunk *next; + + next = q->next; + if (small != NULL) + { + if (small == q) + small = NULL; + free (q); + } + else if (q->current_ptr > b) + free (q); + else if (first == NULL) + first = q; + + q = next; + } + + if (first == NULL) + first = p; + o->chunks = (PTR) first; + + /* Now start allocating from this small block again. */ + o->current_ptr = b; + o->current_space = ((char *) p + CHUNK_SIZE) - b; + } + else + { + struct objalloc_chunk *q; + char *current_ptr; + + /* This block is in a large chunk by itself. We can free + everything on the list up to and including this block. We + then start allocating from the next chunk containing small + objects, setting current_ptr from the value stored with the + large chunk we are freeing. */ + + current_ptr = p->current_ptr; + p = p->next; + + q = (struct objalloc_chunk *) o->chunks; + while (q != p) + { + struct objalloc_chunk *next; + + next = q->next; + free (q); + q = next; + } + + o->chunks = (PTR) p; + + while (p->current_ptr != NULL) + p = p->next; + + o->current_ptr = current_ptr; + o->current_space = ((char *) p + CHUNK_SIZE) - current_ptr; + } +} diff --git a/libiberty/obstack.c b/libiberty/obstack.c new file mode 100644 index 000000000000..a6880caaa6ce --- /dev/null +++ b/libiberty/obstack.c @@ -0,0 +1,514 @@ +/* obstack.c - subroutines used implicitly by object stack macros + Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "obstack.h" + +/* NOTE BEFORE MODIFYING THIS FILE: This version number must be + incremented whenever callers compiled using an old obstack.h can no + longer properly call the functions in this obstack.c. */ +#define OBSTACK_INTERFACE_VERSION 1 + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself, and the installed library + supports the same library interface we do. 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. */ + +#include /* Random thing to get __GNU_LIBRARY__. */ +#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 +#include +#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +/* CYGNUS LOCAL (not to be elided!) */ + +int +_obstack_memory_used (h) + struct obstack *h; +{ + register struct _obstack_chunk* lp; + register int nbytes = 0; + + for (lp = h->chunk; lp != 0; lp = lp->prev) + { + nbytes += lp->limit - (char *) lp; + } + return nbytes; +} + +/* END CYGNUS LOCAL */ + +#ifndef ELIDE_CODE + + +#if defined (__STDC__) && __STDC__ +#define POINTER void * +#else +#define POINTER char * +#endif + +/* Determine default alignment. */ +struct fooalign {char x; double d;}; +#define DEFAULT_ALIGNMENT \ + ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0)) +/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. + But in fact it might be less smart and round addresses to as much as + DEFAULT_ROUNDING. So we prepare for it to do that. */ +union fooround {long x; double d;}; +#define DEFAULT_ROUNDING (sizeof (union fooround)) + +/* When we copy a long block of data, this is the unit to do it with. + On some machines, copying successive ints does not work; + in such a case, redefine COPYING_UNIT to `long' (if that works) + or `char' as a last resort. */ +#ifndef COPYING_UNIT +#define COPYING_UNIT int +#endif + +/* The non-GNU-C macros copy the obstack into this global variable + to avoid multiple evaluation. */ + +struct obstack *_obstack; + +/* Define a macro that either calls functions with the traditional malloc/free + calling interface, or calls functions with the mmalloc/mfree interface + (that adds an extra first argument), based on the state of use_extra_arg. + For free, do not use ?:, since some compilers, like the MIPS compilers, + do not allow (expr) ? void : void. */ + +#define CALL_CHUNKFUN(h, size) \ + (((h) -> use_extra_arg) \ + ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ + : (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size))) + +#define CALL_FREEFUN(h, old_chunk) \ + do { \ + if ((h) -> use_extra_arg) \ + (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ + else \ + (*(void (*) ()) (h)->freefun) ((old_chunk)); \ + } while (0) + + +/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). + Objects start on multiples of ALIGNMENT (0 means use default). + CHUNKFUN is the function to use to allocate chunks, + and FREEFUN the function to free them. + + Return nonzero if successful, zero if out of memory. + To recover from an out of memory error, + free up some memory, then call this again. */ + +int +_obstack_begin (h, size, alignment, chunkfun, freefun) + struct obstack *h; + int size; + int alignment; + POINTER (*chunkfun) (); + void (*freefun) (); +{ + register struct _obstack_chunk *chunk; /* points to new chunk */ + + if (alignment == 0) + alignment = DEFAULT_ALIGNMENT; + if (size == 0) + /* Default size is what GNU malloc can fit in a 4096-byte block. */ + { + /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. + Use the values for range checking, because if range checking is off, + the extra bytes won't be missed terribly, but if range checking is on + and we used a larger request, a whole extra 4096 bytes would be + allocated. + + These number are irrelevant to the new GNU malloc. I suspect it is + less sensitive to the size of the request. */ + int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + + 4 + DEFAULT_ROUNDING - 1) + & ~(DEFAULT_ROUNDING - 1)); + size = 4096 - extra; + } + + h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; + h->freefun = freefun; + h->chunk_size = size; + h->alignment_mask = alignment - 1; + h->use_extra_arg = 0; + + chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); + if (!chunk) + { + h->alloc_failed = 1; + return 0; + } + h->alloc_failed = 0; + h->next_free = h->object_base = chunk->contents; + h->chunk_limit = chunk->limit + = (char *) chunk + h->chunk_size; + chunk->prev = 0; + /* The initial chunk now contains no empty object. */ + h->maybe_empty_object = 0; + return 1; +} + +int +_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg) + struct obstack *h; + int size; + int alignment; + POINTER (*chunkfun) (); + void (*freefun) (); + POINTER arg; +{ + register struct _obstack_chunk *chunk; /* points to new chunk */ + + if (alignment == 0) + alignment = DEFAULT_ALIGNMENT; + if (size == 0) + /* Default size is what GNU malloc can fit in a 4096-byte block. */ + { + /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. + Use the values for range checking, because if range checking is off, + the extra bytes won't be missed terribly, but if range checking is on + and we used a larger request, a whole extra 4096 bytes would be + allocated. + + These number are irrelevant to the new GNU malloc. I suspect it is + less sensitive to the size of the request. */ + int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + + 4 + DEFAULT_ROUNDING - 1) + & ~(DEFAULT_ROUNDING - 1)); + size = 4096 - extra; + } + + h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; + h->freefun = freefun; + h->chunk_size = size; + h->alignment_mask = alignment - 1; + h->extra_arg = arg; + h->use_extra_arg = 1; + + chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); + if (!chunk) + { + h->alloc_failed = 1; + return 0; + } + h->alloc_failed = 0; + h->next_free = h->object_base = chunk->contents; + h->chunk_limit = chunk->limit + = (char *) chunk + h->chunk_size; + chunk->prev = 0; + /* The initial chunk now contains no empty object. */ + h->maybe_empty_object = 0; + return 1; +} + +/* Allocate a new current chunk for the obstack *H + on the assumption that LENGTH bytes need to be added + to the current object, or a new object of length LENGTH allocated. + Copies any partial object from the end of the old chunk + to the beginning of the new one. */ + +void +_obstack_newchunk (h, length) + struct obstack *h; + int length; +{ + register struct _obstack_chunk *old_chunk = h->chunk; + register struct _obstack_chunk *new_chunk; + register long new_size; + register int obj_size = h->next_free - h->object_base; + register int i; + int already; + + /* Compute size for new chunk. */ + new_size = (obj_size + length) + (obj_size >> 3) + 100; + if (new_size < h->chunk_size) + new_size = h->chunk_size; + + /* Allocate and initialize the new chunk. */ + new_chunk = CALL_CHUNKFUN (h, new_size); + if (!new_chunk) + { + h->alloc_failed = 1; + return; + } + h->alloc_failed = 0; + h->chunk = new_chunk; + new_chunk->prev = old_chunk; + new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; + + /* Move the existing object to the new chunk. + Word at a time is fast and is safe if the object + is sufficiently aligned. */ + if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) + { + for (i = obj_size / sizeof (COPYING_UNIT) - 1; + i >= 0; i--) + ((COPYING_UNIT *)new_chunk->contents)[i] + = ((COPYING_UNIT *)h->object_base)[i]; + /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, + but that can cross a page boundary on a machine + which does not do strict alignment for COPYING_UNITS. */ + already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); + } + else + already = 0; + /* Copy remaining bytes one by one. */ + for (i = already; i < obj_size; i++) + new_chunk->contents[i] = h->object_base[i]; + + /* If the object just copied was the only data in OLD_CHUNK, + free that chunk and remove it from the chain. + But not if that chunk might contain an empty object. */ + if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) + { + new_chunk->prev = old_chunk->prev; + CALL_FREEFUN (h, old_chunk); + } + + h->object_base = new_chunk->contents; + h->next_free = h->object_base + obj_size; + /* The new chunk certainly contains no empty object yet. */ + h->maybe_empty_object = 0; +} + +/* Return nonzero if object OBJ has been allocated from obstack H. + This is here for debugging. + If you use it in a program, you are probably losing. */ + +#if defined (__STDC__) && __STDC__ +/* Suppress -Wmissing-prototypes warning. We don't want to declare this in + obstack.h because it is just for debugging. */ +int _obstack_allocated_p (struct obstack *h, POINTER obj); +#endif + +int +_obstack_allocated_p (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ + + lp = (h)->chunk; + /* We use >= rather than > since the object cannot be exactly at + the beginning of the chunk but might be an empty object exactly + at the end of an adjacent chunk. */ + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) + { + plp = lp->prev; + lp = plp; + } + return lp != 0; +} + +/* Free objects in obstack H, including OBJ and everything allocate + more recently than OBJ. If OBJ is zero, free everything in H. */ + +#undef obstack_free + +/* This function has two names with identical definitions. + This is the first one, called from non-ANSI code. */ + +void +_obstack_free (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ + + lp = h->chunk; + /* We use >= because there cannot be an object at the beginning of a chunk. + But there can be an empty object at that address + at the end of another chunk. */ + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) + { + plp = lp->prev; + CALL_FREEFUN (h, lp); + lp = plp; + /* If we switch chunks, we can't tell whether the new current + chunk contains an empty object, so assume that it may. */ + h->maybe_empty_object = 1; + } + if (lp) + { + h->object_base = h->next_free = (char *) (obj); + h->chunk_limit = lp->limit; + h->chunk = lp; + } + else if (obj != 0) + /* obj is not in any of the chunks! */ + abort (); +} + +/* This function is used from ANSI code. */ + +void +obstack_free (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ + + lp = h->chunk; + /* We use >= because there cannot be an object at the beginning of a chunk. + But there can be an empty object at that address + at the end of another chunk. */ + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) + { + plp = lp->prev; + CALL_FREEFUN (h, lp); + lp = plp; + /* If we switch chunks, we can't tell whether the new current + chunk contains an empty object, so assume that it may. */ + h->maybe_empty_object = 1; + } + if (lp) + { + h->object_base = h->next_free = (char *) (obj); + h->chunk_limit = lp->limit; + h->chunk = lp; + } + else if (obj != 0) + /* obj is not in any of the chunks! */ + abort (); +} + +#if 0 +/* These are now turned off because the applications do not use it + and it uses bcopy via obstack_grow, which causes trouble on sysV. */ + +/* Now define the functional versions of the obstack macros. + Define them to simply use the corresponding macros to do the job. */ + +#if defined (__STDC__) && __STDC__ +/* These function definitions do not work with non-ANSI preprocessors; + they won't pass through the macro names in parentheses. */ + +/* The function names appear in parentheses in order to prevent + the macro-definitions of the names from being expanded there. */ + +POINTER (obstack_base) (obstack) + struct obstack *obstack; +{ + return obstack_base (obstack); +} + +POINTER (obstack_next_free) (obstack) + struct obstack *obstack; +{ + return obstack_next_free (obstack); +} + +int (obstack_object_size) (obstack) + struct obstack *obstack; +{ + return obstack_object_size (obstack); +} + +int (obstack_room) (obstack) + struct obstack *obstack; +{ + return obstack_room (obstack); +} + +void (obstack_grow) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + obstack_grow (obstack, pointer, length); +} + +void (obstack_grow0) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + obstack_grow0 (obstack, pointer, length); +} + +void (obstack_1grow) (obstack, character) + struct obstack *obstack; + int character; +{ + obstack_1grow (obstack, character); +} + +void (obstack_blank) (obstack, length) + struct obstack *obstack; + int length; +{ + obstack_blank (obstack, length); +} + +void (obstack_1grow_fast) (obstack, character) + struct obstack *obstack; + int character; +{ + obstack_1grow_fast (obstack, character); +} + +void (obstack_blank_fast) (obstack, length) + struct obstack *obstack; + int length; +{ + obstack_blank_fast (obstack, length); +} + +POINTER (obstack_finish) (obstack) + struct obstack *obstack; +{ + return obstack_finish (obstack); +} + +POINTER (obstack_alloc) (obstack, length) + struct obstack *obstack; + int length; +{ + return obstack_alloc (obstack, length); +} + +POINTER (obstack_copy) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + return obstack_copy (obstack, pointer, length); +} + +POINTER (obstack_copy0) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + return obstack_copy0 (obstack, pointer, length); +} + +#endif /* __STDC__ */ + +#endif /* 0 */ + +#endif /* !ELIDE_CODE */ diff --git a/libiberty/pexecute.c b/libiberty/pexecute.c new file mode 100644 index 000000000000..ab5f392780c2 --- /dev/null +++ b/libiberty/pexecute.c @@ -0,0 +1,580 @@ +/* Utilities to execute a program in a subprocess (possibly linked by pipes + with other subprocesses), and wait for it. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If not, +write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This file exports two functions: pexecute and pwait. */ + +/* This file lives in at least two places: libiberty and gcc. + Don't change one without the other. */ + +#include +#include + +#ifdef IN_GCC +#include "config.h" +#include "gansidecl.h" +/* ??? Need to find a suitable header file. */ +#define PEXECUTE_FIRST 1 +#define PEXECUTE_LAST 2 +#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST) +#define PEXECUTE_SEARCH 4 +#define PEXECUTE_VERBOSE 8 +#else +#include "libiberty.h" +#endif + +/* stdin file number. */ +#define STDIN_FILE_NO 0 + +/* stdout file number. */ +#define STDOUT_FILE_NO 1 + +/* value of `pipe': port index for reading. */ +#define READ_PORT 0 + +/* value of `pipe': port index for writing. */ +#define WRITE_PORT 1 + +static char *install_error_msg = "installation problem, cannot exec `%s'"; + +/* pexecute: execute a program. + + PROGRAM and ARGV are the arguments to execv/execvp. + + THIS_PNAME is name of the calling program (i.e. argv[0]). + + TEMP_BASE is the path name, sans suffix, of a temporary file to use + if needed. This is currently only needed for MSDOS ports that don't use + GO32 (do any still exist?). Ports that don't need it can pass NULL. + + (FLAGS & PEXECUTE_SEARCH) is non-zero if $PATH should be searched + (??? It's not clear that GCC passes this flag correctly). + (FLAGS & PEXECUTE_FIRST) is nonzero for the first process in chain. + (FLAGS & PEXECUTE_FIRST) is nonzero for the last process in chain. + FIRST_LAST could be simplified to only mark the last of a chain of processes + but that requires the caller to always mark the last one (and not give up + early if some error occurs). It's more robust to require the caller to + mark both ends of the chain. + + The result is the pid on systems like Unix where we fork/exec and on systems + like WIN32 and OS2 where we use spawn. It is up to the caller to wait for + the child. + + The result is the WEXITSTATUS on systems like MSDOS where we spawn and wait + for the child here. + + Upon failure, ERRMSG_FMT and ERRMSG_ARG are set to the text of the error + message with an optional argument (if not needed, ERRMSG_ARG is set to + NULL), and -1 is returned. `errno' is available to the caller to use. + + pwait: cover function for wait. + + PID is the process id of the task to wait for. + STATUS is the `status' argument to wait. + FLAGS is currently unused (allows future enhancement without breaking + upward compatibility). Pass 0 for now. + + The result is the pid of the child reaped, + or -1 for failure (errno says why). + + On systems that don't support waiting for a particular child, PID is + ignored. On systems like MSDOS that don't really multitask pwait + is just a mechanism to provide a consistent interface for the caller. + + pfinish: finish generation of script + + pfinish is necessary for systems like MPW where a script is generated that + runs the requested programs. +*/ + +#ifdef __MSDOS__ + +/* MSDOS doesn't multitask, but for the sake of a consistent interface + the code behaves like it does. pexecute runs the program, tucks the + exit code away, and returns a "pid". pwait must be called to fetch the + exit code. */ + +#include + +/* For communicating information from pexecute to pwait. */ +static int last_pid = 0; +static int last_status = 0; +static int last_reaped = 0; + +int +pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) + const char *program; + char * const *argv; + const char *this_pname; + const char *temp_base; + char **errmsg_fmt, **errmsg_arg; + int flags; +{ + int rc; + + last_pid++; + if (last_pid < 0) + last_pid = 1; + + if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) + abort (); + +#ifdef __GO32__ + /* ??? What are the possible return values from spawnv? */ + rc = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv); +#else + char *scmd, *rf; + FILE *argfile; + int i, el = flags & PEXECUTE_SEARCH ? 4 : 0; + + scmd = (char *) xmalloc (strlen (program) + strlen (temp_base) + 6 + el); + rf = scmd + strlen(program) + 2 + el; + sprintf (scmd, "%s%s @%s.gp", program, + (flags & PEXECUTE_SEARCH ? ".exe" : ""), temp_base); + argfile = fopen (rf, "w"); + if (argfile == 0) + { + int errno_save = errno; + free (scmd); + errno = errno_save; + *errmsg_fmt = "cannot open `%s.gp'"; + *errmsg_arg = temp_base; + return -1; + } + + for (i=1; argv[i]; i++) + { + char *cp; + for (cp = argv[i]; *cp; cp++) + { + if (*cp == '"' || *cp == '\'' || *cp == '\\' || isspace (*cp)) + fputc ('\\', argfile); + fputc (*cp, argfile); + } + fputc ('\n', argfile); + } + fclose (argfile); + + rc = system (scmd); + + { + int errno_save = errno; + remove (rf); + free (scmd); + errno = errno_save; + } +#endif + + if (rc == -1) + { + *errmsg_fmt = install_error_msg; + *errmsg_arg = program; + return -1; + } + + /* Tuck the status away for pwait, and return a "pid". */ + last_status = rc << 8; + return last_pid; +} + +int +pwait (pid, status, flags) + int pid; + int *status; + int flags; +{ + /* On MSDOS each pexecute must be followed by it's associated pwait. */ + if (pid != last_pid + /* Called twice for the same child? */ + || pid == last_reaped) + { + /* ??? ECHILD would be a better choice. Can we use it here? */ + errno = EINVAL; + return -1; + } + /* ??? Here's an opportunity to canonicalize the values in STATUS. + Needed? */ + *status = last_status; + last_reaped = last_pid; + return last_pid; +} + +#endif /* MSDOS */ + +#if defined (_WIN32) + +#include +extern int _spawnv (); +extern int _spawnvp (); + +int +pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) + const char *program; + char * const *argv; + const char *this_pname; + const char *temp_base; + char **errmsg_fmt, **errmsg_arg; + int flags; +{ + int pid; + + if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) + abort (); + pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv) (_P_NOWAIT, program, argv); + if (pid == -1) + { + *errmsg_fmt = install_error_msg; + *errmsg_arg = program; + return -1; + } + return pid; +} + +int +pwait (pid, status, flags) + int pid; + int *status; + int flags; +{ + /* ??? Here's an opportunity to canonicalize the values in STATUS. + Needed? */ + return cwait (status, pid, WAIT_CHILD); +} + +#endif /* _WIN32 */ + +#ifdef OS2 + +/* ??? Does OS2 have process.h? */ +extern int spawnv (); +extern int spawnvp (); + +int +pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) + const char *program; + char * const *argv; + const char *this_pname; + const char *temp_base; + char **errmsg_fmt, **errmsg_arg; + int flags; +{ + int pid; + + if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) + abort (); + /* ??? Presumably 1 == _P_NOWAIT. */ + pid = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv); + if (pid == -1) + { + *errmsg_fmt = install_error_msg; + *errmsg_arg = program; + return -1; + } + return pid; +} + +int +pwait (pid, status, flags) + int pid; + int *status; + int flags; +{ + /* ??? Here's an opportunity to canonicalize the values in STATUS. + Needed? */ + int pid = wait (status); + return pid; +} + +#endif /* OS2 */ + +#ifdef MPW + +/* MPW pexecute doesn't actually run anything; instead, it writes out + script commands that, when run, will do the actual executing. + + For example, in GCC's case, GCC will write out several script commands: + + cpp ... + cc1 ... + as ... + ld ... + + and then exit. None of the above programs will have run yet. The task + that called GCC will then execute the script and cause cpp,etc. to run. + The caller must invoke pfinish before calling exit. This adds + the finishing touches to the generated script. */ + +static int first_time = 1; + +int +pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) + const char *program; + char **argv; + const char *this_pname; + const char *temp_base; + char **errmsg_fmt, **errmsg_arg; + int flags; +{ + char tmpprogram[255]; + char *cp, *tmpname; + int i; + + mpwify_filename (program, tmpprogram); + if (first_time) + { + printf ("Set Failed 0\n"); + first_time = 0; + } + + fputs ("If {Failed} == 0\n", stdout); + /* If being verbose, output a copy of the command. It should be + accurate enough and escaped enough to be "clickable". */ + if (flags & PEXECUTE_VERBOSE) + { + fputs ("\tEcho ", stdout); + fputc ('\'', stdout); + fputs (tmpprogram, stdout); + fputc ('\'', stdout); + fputc (' ', stdout); + for (i=1; argv[i]; i++) + { + /* We have to quote every arg, so that when the echo is + executed, the quotes are stripped and the original arg + is left. */ + fputc ('\'', stdout); + for (cp = argv[i]; *cp; cp++) + { + /* Write an Option-d esc char in front of special chars. */ + if (strchr ("\"'+", *cp)) + fputc ('\266', stdout); + fputc (*cp, stdout); + } + fputc ('\'', stdout); + fputc (' ', stdout); + } + fputs ("\n", stdout); + } + fputs ("\t", stdout); + fputs (tmpprogram, stdout); + fputc (' ', stdout); + + for (i=1; argv[i]; i++) + { + if (strchr (argv[i], ' ')) + fputc ('\'', stdout); + for (cp = argv[i]; *cp; cp++) + { + /* Write an Option-d esc char in front of special chars. */ + if (strchr ("\"'+", *cp)) + { + fputc ('\266', stdout); + } + fputc (*cp, stdout); + } + if (strchr (argv[i], ' ')) + fputc ('\'', stdout); + fputc (' ', stdout); + } + + fputs ("\n", stdout); + + /* Output commands that arrange to clean up and exit if a failure occurs. + We have to be careful to collect the status from the program that was + run, rather than some other script command. Also, we don't exit + immediately, since necessary cleanups are at the end of the script. */ + fputs ("\tSet TmpStatus {Status}\n", stdout); + fputs ("\tIf {TmpStatus} != 0\n", stdout); + fputs ("\t\tSet Failed {TmpStatus}\n", stdout); + fputs ("\tEnd\n", stdout); + fputs ("End\n", stdout); + + /* We're just composing a script, can't fail here. */ + return 0; +} + +int +pwait (pid, status, flags) + int pid; + int *status; + int flags; +{ + *status = 0; + return 0; +} + +/* Write out commands that will exit with the correct error code + if something in the script failed. */ + +void +pfinish () +{ + printf ("\tExit \"{Failed}\"\n"); +} + +#endif /* MPW */ + +/* include for Unix-like environments but not for Dos-like environments */ +#if ! defined (__MSDOS__) && ! defined (OS2) && ! defined (MPW) \ + && ! defined (_WIN32) + +#ifdef VMS +#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \ + lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1) +#else +#ifdef USG +#define vfork fork +#endif +#endif + +extern int execv (); +extern int execvp (); + +int +pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) + const char *program; + char * const *argv; + const char *this_pname; + const char *temp_base; + char **errmsg_fmt, **errmsg_arg; + int flags; +{ + int (*func)() = (flags & PEXECUTE_SEARCH ? execvp : execv); + int pid; + int pdes[2]; + int input_desc, output_desc; + int retries, sleep_interval; + /* Pipe waiting from last process, to be used as input for the next one. + Value is STDIN_FILE_NO if no pipe is waiting + (i.e. the next command is the first of a group). */ + static int last_pipe_input; + + /* If this is the first process, initialize. */ + if (flags & PEXECUTE_FIRST) + last_pipe_input = STDIN_FILE_NO; + + input_desc = last_pipe_input; + + /* If this isn't the last process, make a pipe for its output, + and record it as waiting to be the input to the next process. */ + if (! (flags & PEXECUTE_LAST)) + { + if (pipe (pdes) < 0) + { + *errmsg_fmt = "pipe"; + *errmsg_arg = NULL; + return -1; + } + output_desc = pdes[WRITE_PORT]; + last_pipe_input = pdes[READ_PORT]; + } + else + { + /* Last process. */ + output_desc = STDOUT_FILE_NO; + last_pipe_input = STDIN_FILE_NO; + } + + /* Fork a subprocess; wait and retry if it fails. */ + sleep_interval = 1; + for (retries = 0; retries < 4; retries++) + { + pid = vfork (); + if (pid >= 0) + break; + sleep (sleep_interval); + sleep_interval *= 2; + } + + switch (pid) + { + case -1: + { +#ifdef vfork + *errmsg_fmt = "fork"; +#else + *errmsg_fmt = "vfork"; +#endif + *errmsg_arg = NULL; + return -1; + } + + case 0: /* child */ + /* Move the input and output pipes into place, if necessary. */ + if (input_desc != STDIN_FILE_NO) + { + close (STDIN_FILE_NO); + dup (input_desc); + close (input_desc); + } + if (output_desc != STDOUT_FILE_NO) + { + close (STDOUT_FILE_NO); + dup (output_desc); + close (output_desc); + } + + /* Close the parent's descs that aren't wanted here. */ + if (last_pipe_input != STDIN_FILE_NO) + close (last_pipe_input); + + /* Exec the program. */ + (*func) (program, argv); + + /* Note: Calling fprintf and exit here doesn't seem right for vfork. */ + fprintf (stderr, "%s: ", this_pname); + fprintf (stderr, install_error_msg, program); +#ifdef IN_GCC + fprintf (stderr, ": %s\n", my_strerror (errno)); +#else + fprintf (stderr, ": %s\n", xstrerror (errno)); +#endif + exit (-1); + /* NOTREACHED */ + return 0; + + default: + /* In the parent, after forking. + Close the descriptors that we made for this child. */ + if (input_desc != STDIN_FILE_NO) + close (input_desc); + if (output_desc != STDOUT_FILE_NO) + close (output_desc); + + /* Return child's process number. */ + return pid; + } +} + +int +pwait (pid, status, flags) + int pid; + int *status; + int flags; +{ + /* ??? Here's an opportunity to canonicalize the values in STATUS. + Needed? */ +#ifdef VMS + pid = waitpid (-1, status, 0); +#else + pid = wait (status); +#endif + return pid; +} + +#endif /* ! __MSDOS__ && ! OS2 && ! MPW && ! _WIN32 */ diff --git a/libiberty/random.c b/libiberty/random.c new file mode 100644 index 000000000000..e205719832b9 --- /dev/null +++ b/libiberty/random.c @@ -0,0 +1,373 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* + * This is derived from the Berkeley source: + * @(#)random.c 5.5 (Berkeley) 7/6/88 + * It was reworked for the GNU C Library by Roland McGrath. + */ + +#include + +#if 0 + +#include +#include +#include +#include + +#else + +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */ +#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits*/ + +#ifdef __STDC__ +# define PTR void * +# define NULL (void *) 0 +#else +# define PTR char * +# define NULL 0 +#endif + +#endif + +long int random (); + +/* An improved random number generation package. In addition to the standard + rand()/srand() like interface, this package also has a special state info + interface. The initstate() routine is called with a seed, an array of + bytes, and a count of how many bytes are being passed in; this array is + then initialized to contain information for random number generation with + that much state information. Good sizes for the amount of state + information are 32, 64, 128, and 256 bytes. The state can be switched by + calling the setstate() function with the same array as was initiallized + with initstate(). By default, the package runs with 128 bytes of state + information and generates far better random numbers than a linear + congruential generator. If the amount of state information is less than + 32 bytes, a simple linear congruential R.N.G. is used. Internally, the + state information is treated as an array of longs; the zeroeth element of + the array is the type of R.N.G. being used (small integer); the remainder + of the array is the state information for the R.N.G. Thus, 32 bytes of + state information will give 7 longs worth of state information, which will + allow a degree seven polynomial. (Note: The zeroeth word of state + information also has some other information stored in it; see setstate + for details). The random number generation technique is a linear feedback + shift register approach, employing trinomials (since there are fewer terms + to sum up that way). In this approach, the least significant bit of all + the numbers in the state table will act as a linear feedback shift register, + and will have period 2^deg - 1 (where deg is the degree of the polynomial + being used, assuming that the polynomial is irreducible and primitive). + The higher order bits will have longer periods, since their values are + also influenced by pseudo-random carries out of the lower bits. The + total period of the generator is approximately deg*(2**deg - 1); thus + doubling the amount of state information has a vast influence on the + period of the generator. Note: The deg*(2**deg - 1) is an approximation + only good for large deg, when the period of the shift register is the + dominant factor. With deg equal to seven, the period is actually much + longer than the 7*(2**7 - 1) predicted by this formula. */ + + + +/* For each of the currently supported random number generators, we have a + break value on the amount of state information (you need at least thi + bytes of state info to support this random number generator), a degree for + the polynomial (actually a trinomial) that the R.N.G. is based on, and + separation between the two lower order coefficients of the trinomial. */ + +/* Linear congruential. */ +#define TYPE_0 0 +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +/* x**7 + x**3 + 1. */ +#define TYPE_1 1 +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +/* x**15 + x + 1. */ +#define TYPE_2 2 +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +/* x**31 + x**3 + 1. */ +#define TYPE_3 3 +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +/* x**63 + x + 1. */ +#define TYPE_4 4 +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + + +/* Array versions of the above information to make code run faster. + Relies on fact that TYPE_i == i. */ + +#define MAX_TYPES 5 /* Max number of types above. */ + +static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; +static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; + + + +/* Initially, everything is set up as if from: + initstate(1, randtbl, 128); + Note that this initialization takes advantage of the fact that srandom + advances the front and rear pointers 10*rand_deg times, and hence the + rear pointer which starts at 0 will also end up at zero; thus the zeroeth + element of the state information, which contains info about the current + position of the rear pointer is just + (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */ + +static long int randtbl[DEG_3 + 1] = + { TYPE_3, + 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, + 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, + 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, + 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, + 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7, + 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, + 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, + 0xf5ad9d0e, 0x8999220b, 0x27fb47b9 + }; + +/* FPTR and RPTR are two pointers into the state info, a front and a rear + pointer. These two pointers are always rand_sep places aparts, as they + cycle through the state information. (Yes, this does mean we could get + away with just one pointer, but the code for random is more efficient + this way). The pointers are left positioned as they would be from the call: + initstate(1, randtbl, 128); + (The position of the rear pointer, rptr, is really 0 (as explained above + in the initialization of randtbl) because the state table pointer is set + to point to randtbl[1] (as explained below).) */ + +static long int *fptr = &randtbl[SEP_3 + 1]; +static long int *rptr = &randtbl[1]; + + + +/* The following things are the pointer to the state information table, + the type of the current generator, the degree of the current polynomial + being used, and the separation between the two pointers. + Note that for efficiency of random, we remember the first location of + the state information, not the zeroeth. Hence it is valid to access + state[-1], which is used to store the type of the R.N.G. + Also, we remember the last location, since this is more efficient than + indexing every time to find the address of the last element to see if + the front and rear pointers have wrapped. */ + +static long int *state = &randtbl[1]; + +static int rand_type = TYPE_3; +static int rand_deg = DEG_3; +static int rand_sep = SEP_3; + +static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])]; + +/* Initialize the random number generator based on the given seed. If the + type is the trivial no-state-information type, just remember the seed. + Otherwise, initializes state[] based on the given "seed" via a linear + congruential generator. Then, the pointers are set to known locations + that are exactly rand_sep places apart. Lastly, it cycles the state + information a given number of times to get rid of any initial dependencies + introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + for default usage relies on values produced by this routine. */ +void +srandom (x) + unsigned int x; +{ + state[0] = x; + if (rand_type != TYPE_0) + { + register long int i; + for (i = 1; i < rand_deg; ++i) + state[i] = (1103515145 * state[i - 1]) + 12345; + fptr = &state[rand_sep]; + rptr = &state[0]; + for (i = 0; i < 10 * rand_deg; ++i) + random(); + } +} + +/* Initialize the state information in the given array of N bytes for + future random number generation. Based on the number of bytes we + are given, and the break values for the different R.N.G.'s, we choose + the best (largest) one we can and set things up for it. srandom is + then called to initialize the state information. Note that on return + from srandom, we set state[-1] to be the type multiplexed with the current + value of the rear pointer; this is so successive calls to initstate won't + lose this information and will be able to restart with setstate. + Note: The first thing we do is save the current state, if any, just like + setstate so that it doesn't matter when initstate is called. + Returns a pointer to the old state. */ +PTR +initstate (seed, arg_state, n) + unsigned int seed; + PTR arg_state; + unsigned long n; +{ + PTR ostate = (PTR) &state[-1]; + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; + if (n < BREAK_1) + { + if (n < BREAK_0) + { + errno = EINVAL; + return NULL; + } + rand_type = TYPE_0; + rand_deg = DEG_0; + rand_sep = SEP_0; + } + else if (n < BREAK_2) + { + rand_type = TYPE_1; + rand_deg = DEG_1; + rand_sep = SEP_1; + } + else if (n < BREAK_3) + { + rand_type = TYPE_2; + rand_deg = DEG_2; + rand_sep = SEP_2; + } + else if (n < BREAK_4) + { + rand_type = TYPE_3; + rand_deg = DEG_3; + rand_sep = SEP_3; + } + else + { + rand_type = TYPE_4; + rand_deg = DEG_4; + rand_sep = SEP_4; + } + + state = &((long int *) arg_state)[1]; /* First location. */ + /* Must set END_PTR before srandom. */ + end_ptr = &state[rand_deg]; + srandom(seed); + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; + + return ostate; +} + +/* Restore the state from the given state array. + Note: It is important that we also remember the locations of the pointers + in the current state information, and restore the locations of the pointers + from the old state information. This is done by multiplexing the pointer + location into the zeroeth word of the state information. Note that due + to the order in which things are done, it is OK to call setstate with the + same state as the current state + Returns a pointer to the old state information. */ + +PTR +setstate (arg_state) + PTR arg_state; +{ + register long int *new_state = (long int *) arg_state; + register int type = new_state[0] % MAX_TYPES; + register int rear = new_state[0] / MAX_TYPES; + PTR ostate = (PTR) &state[-1]; + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; + + switch (type) + { + case TYPE_0: + case TYPE_1: + case TYPE_2: + case TYPE_3: + case TYPE_4: + rand_type = type; + rand_deg = degrees[type]; + rand_sep = seps[type]; + break; + default: + /* State info munged. */ + errno = EINVAL; + return NULL; + } + + state = &new_state[1]; + if (rand_type != TYPE_0) + { + rptr = &state[rear]; + fptr = &state[(rear + rand_sep) % rand_deg]; + } + /* Set end_ptr too. */ + end_ptr = &state[rand_deg]; + + return ostate; +} + +/* If we are using the trivial TYPE_0 R.N.G., just do the old linear + congruential bit. Otherwise, we do our fancy trinomial stuff, which is the + same in all ther other cases due to all the global variables that have been + set up. The basic operation is to add the number at the rear pointer into + the one at the front pointer. Then both pointers are advanced to the next + location cyclically in the table. The value returned is the sum generated, + reduced to 31 bits by throwing away the "least random" low bit. + Note: The code takes advantage of the fact that both the front and + rear pointers can't wrap on the same call by not testing the rear + pointer if the front one has wrapped. Returns a 31-bit random number. */ + +long int +random () +{ + if (rand_type == TYPE_0) + { + state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX; + return state[0]; + } + else + { + long int i; + *fptr += *rptr; + /* Chucking least random bit. */ + i = (*fptr >> 1) & LONG_MAX; + ++fptr; + if (fptr >= end_ptr) + { + fptr = state; + ++rptr; + } + else + { + ++rptr; + if (rptr >= end_ptr) + rptr = state; + } + return i; + } +} diff --git a/libiberty/rename.c b/libiberty/rename.c new file mode 100644 index 000000000000..ae26e2d00407 --- /dev/null +++ b/libiberty/rename.c @@ -0,0 +1,22 @@ +/* rename -- rename a file + This function is in the public domain. */ + +/* Rename a file. */ + +#include + +int +rename (zfrom, zto) + char *zfrom; + char *zto; +{ + if (link (zfrom, zto) < 0) + { + if (errno != EEXIST) + return -1; + if (unlink (zto) < 0 + || link (zfrom, zto) < 0) + return -1; + } + return unlink (zfrom); +} diff --git a/libiberty/rindex.c b/libiberty/rindex.c new file mode 100644 index 000000000000..061d1269f178 --- /dev/null +++ b/libiberty/rindex.c @@ -0,0 +1,11 @@ +/* Stub implementation of (obsolete) rindex(). */ + +extern char *strrchr (); + +char * +rindex (s, c) + char *s; + int c; +{ + return strrchr (s, c); +} diff --git a/libiberty/sigsetmask.c b/libiberty/sigsetmask.c new file mode 100644 index 000000000000..2a09e6a6c5ac --- /dev/null +++ b/libiberty/sigsetmask.c @@ -0,0 +1,30 @@ +/* Version of sigsetmask.c + Written by Steve Chamberlain (sac@cygnus.com). + Contributed by Cygnus Support. + This file is in the public doamin. */ + +/* Set the current signal mask to the set provided, and return the + previous value */ + +#define _POSIX_SOURCE +#include +/* Including seems to be needed by ISC. */ +#include +#include + +#ifdef SIG_SETMASK +int +DEFUN(sigsetmask,(set), + int set) +{ + sigset_t new; + sigset_t old; + + sigemptyset (&new); + if (set != 0) { + abort(); /* FIXME, we don't know how to translate old mask to new */ + } + sigprocmask(SIG_SETMASK, &new, &old); + return 1; /* FIXME, we always return 1 as old value. */ +} +#endif diff --git a/libiberty/spaces.c b/libiberty/spaces.c new file mode 100644 index 000000000000..ea925712e3f8 --- /dev/null +++ b/libiberty/spaces.c @@ -0,0 +1,78 @@ +/* Allocate memory region filled with spaces. + Copyright (C) 1991 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* + +NAME + + spaces -- return a pointer to a buffer full of spaces + +SYNOPSIS + + char *spaces (int count) + +DESCRIPTION + + Returns a pointer to a memory region filled with the specified + number of spaces and null terminated. The returned pointer is + valid until at least the next call. + +BUGS + +*/ + +#include "ansidecl.h" +#include "libiberty.h" + +#if VMS +#include +#include +#else +/* For systems with larger pointers than ints, these must be declared. */ +extern PTR malloc PARAMS ((size_t)); +extern void free PARAMS ((PTR)); +#endif + +const char * +spaces (count) + int count; +{ + register char *t; + static char *buf; + static int maxsize; + + if (count > maxsize) + { + if (buf) + { + free (buf); + } + buf = malloc (count + 1); + if (buf == (char *) 0) + return 0; + for (t = buf + count ; t != buf ; ) + { + *--t = ' '; + } + maxsize = count; + buf[count] = '\0'; + } + return (const char *) (buf + maxsize - count); +} + diff --git a/libiberty/strcasecmp.c b/libiberty/strcasecmp.c new file mode 100644 index 000000000000..3aa930b696f0 --- /dev/null +++ b/libiberty/strcasecmp.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific written prior permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; +#endif /* LIBC_SCCS and not lint */ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +/* + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ +typedef unsigned char uc; +static unsigned char charmap[] = { + (uc)'\000',(uc)'\001',(uc)'\002',(uc)'\003',(uc)'\004',(uc)'\005',(uc)'\006',(uc)'\007', + (uc)'\010',(uc)'\011',(uc)'\012',(uc)'\013',(uc)'\014',(uc)'\015',(uc)'\016',(uc)'\017', + (uc)'\020',(uc)'\021',(uc)'\022',(uc)'\023',(uc)'\024',(uc)'\025',(uc)'\026',(uc)'\027', + (uc)'\030',(uc)'\031',(uc)'\032',(uc)'\033',(uc)'\034',(uc)'\035',(uc)'\036',(uc)'\037', + (uc)'\040',(uc)'\041',(uc)'\042',(uc)'\043',(uc)'\044',(uc)'\045',(uc)'\046',(uc)'\047', + (uc)'\050',(uc)'\051',(uc)'\052',(uc)'\053',(uc)'\054',(uc)'\055',(uc)'\056',(uc)'\057', + (uc)'\060',(uc)'\061',(uc)'\062',(uc)'\063',(uc)'\064',(uc)'\065',(uc)'\066',(uc)'\067', + (uc)'\070',(uc)'\071',(uc)'\072',(uc)'\073',(uc)'\074',(uc)'\075',(uc)'\076',(uc)'\077', + (uc)'\100',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147', + (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157', + (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167', + (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\133',(uc)'\134',(uc)'\135',(uc)'\136',(uc)'\137', + (uc)'\140',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147', + (uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157', + (uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167', + (uc)'\170',(uc)'\171',(uc)'\172',(uc)'\173',(uc)'\174',(uc)'\175',(uc)'\176',(uc)'\177', + (uc)'\200',(uc)'\201',(uc)'\202',(uc)'\203',(uc)'\204',(uc)'\205',(uc)'\206',(uc)'\207', + (uc)'\210',(uc)'\211',(uc)'\212',(uc)'\213',(uc)'\214',(uc)'\215',(uc)'\216',(uc)'\217', + (uc)'\220',(uc)'\221',(uc)'\222',(uc)'\223',(uc)'\224',(uc)'\225',(uc)'\226',(uc)'\227', + (uc)'\230',(uc)'\231',(uc)'\232',(uc)'\233',(uc)'\234',(uc)'\235',(uc)'\236',(uc)'\237', + (uc)'\240',(uc)'\241',(uc)'\242',(uc)'\243',(uc)'\244',(uc)'\245',(uc)'\246',(uc)'\247', + (uc)'\250',(uc)'\251',(uc)'\252',(uc)'\253',(uc)'\254',(uc)'\255',(uc)'\256',(uc)'\257', + (uc)'\260',(uc)'\261',(uc)'\262',(uc)'\263',(uc)'\264',(uc)'\265',(uc)'\266',(uc)'\267', + (uc)'\270',(uc)'\271',(uc)'\272',(uc)'\273',(uc)'\274',(uc)'\275',(uc)'\276',(uc)'\277', + (uc)'\300',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347', + (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357', + (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367', + (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\333',(uc)'\334',(uc)'\335',(uc)'\336',(uc)'\337', + (uc)'\340',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347', + (uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357', + (uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367', + (uc)'\370',(uc)'\371',(uc)'\372',(uc)'\373',(uc)'\374',(uc)'\375',(uc)'\376',(uc)'\377', +}; + +int +strcasecmp(s1, s2) + const char *s1, *s2; +{ + register unsigned char u1, u2; + + for (;;) { + u1 = (unsigned char) *s1++; + u2 = (unsigned char) *s2++; + if (charmap[u1] != charmap[u2]) { + return charmap[u1] - charmap[u2]; + } + if (u1 == '\0') { + return 0; + } + } +} + diff --git a/libiberty/strchr.c b/libiberty/strchr.c new file mode 100644 index 000000000000..22976ce248af --- /dev/null +++ b/libiberty/strchr.c @@ -0,0 +1,34 @@ +/* Portable version of strchr() + This function is in the public domain. */ + +/* +NAME + strchr -- return pointer to first occurance of a character + +SYNOPSIS + char *strchr (const char *s, int c) + +DESCRIPTION + Returns a pointer to the first occurance of character C in + string S, or a NULL pointer if no occurance is found. + +BUGS + Behavior when character is the null character is implementation + dependent. +*/ + +#include + +char * +strchr (s, c) + register CONST char *s; + int c; +{ + do { + if (*s == c) + { + return (char*)s; + } + } while (*s++); + return (0); +} diff --git a/libiberty/strdup.c b/libiberty/strdup.c new file mode 100644 index 000000000000..1785b34f2745 --- /dev/null +++ b/libiberty/strdup.c @@ -0,0 +1,10 @@ +char * +strdup(s) + char *s; +{ + char *result = (char*)malloc(strlen(s) + 1); + if (result == (char*)0) + return (char*)0; + strcpy(result, s); + return result; +} diff --git a/libiberty/strerror.c b/libiberty/strerror.c new file mode 100644 index 000000000000..f5e2eebee2e2 --- /dev/null +++ b/libiberty/strerror.c @@ -0,0 +1,831 @@ +/* Extended support for using errno values. + Written by Fred Fish. fnf@cygnus.com + This file is in the public domain. --Per Bothner. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#include "config.h" + +#ifndef NEED_sys_errlist +/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least) + might declare sys_errlist in a way that the compiler might consider + incompatible with our later declaration, perhaps by using const + attributes. So we hide the declaration in errno.h (if any) using a + macro. */ +#define sys_errlist sys_errlist__ +#endif + +#include +#include + +#ifndef NEED_sys_errlist +#undef sys_errlist +#endif + +/* Routines imported from standard C runtime libraries. */ + +#ifdef __STDC__ +#include +extern void *malloc (size_t size); /* 4.10.3.3 */ +extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ +#else /* !__STDC__ */ +extern char *malloc (); /* Standard memory allocater */ +extern char *memset (); +#endif /* __STDC__ */ + +#ifndef MAX +# define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +static void init_error_tables PARAMS ((void)); + +/* Translation table for errno values. See intro(2) in most UNIX systems + Programmers Reference Manuals. + + Note that this table is generally only accessed when it is used at runtime + to initialize errno name and message tables that are indexed by errno + value. + + Not all of these errnos will exist on all systems. This table is the only + thing that should have to be updated as new error numbers are introduced. + It's sort of ugly, but at least its portable. */ + +struct error_info +{ + int value; /* The numeric value from */ + const char *name; /* The equivalent symbolic value */ +#ifdef NEED_sys_errlist + const char *msg; /* Short message about this value */ +#endif +}; + +#ifdef NEED_sys_errlist +# define ENTRY(value, name, msg) {value, name, msg} +#else +# define ENTRY(value, name, msg) {value, name} +#endif + +static const struct error_info error_table[] = +{ +#if defined (EPERM) + ENTRY(EPERM, "EPERM", "Not owner"), +#endif +#if defined (ENOENT) + ENTRY(ENOENT, "ENOENT", "No such file or directory"), +#endif +#if defined (ESRCH) + ENTRY(ESRCH, "ESRCH", "No such process"), +#endif +#if defined (EINTR) + ENTRY(EINTR, "EINTR", "Interrupted system call"), +#endif +#if defined (EIO) + ENTRY(EIO, "EIO", "I/O error"), +#endif +#if defined (ENXIO) + ENTRY(ENXIO, "ENXIO", "No such device or address"), +#endif +#if defined (E2BIG) + ENTRY(E2BIG, "E2BIG", "Arg list too long"), +#endif +#if defined (ENOEXEC) + ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"), +#endif +#if defined (EBADF) + ENTRY(EBADF, "EBADF", "Bad file number"), +#endif +#if defined (ECHILD) + ENTRY(ECHILD, "ECHILD", "No child processes"), +#endif +#if defined (EWOULDBLOCK) /* Put before EAGAIN, sometimes aliased */ + ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"), +#endif +#if defined (EAGAIN) + ENTRY(EAGAIN, "EAGAIN", "No more processes"), +#endif +#if defined (ENOMEM) + ENTRY(ENOMEM, "ENOMEM", "Not enough space"), +#endif +#if defined (EACCES) + ENTRY(EACCES, "EACCES", "Permission denied"), +#endif +#if defined (EFAULT) + ENTRY(EFAULT, "EFAULT", "Bad address"), +#endif +#if defined (ENOTBLK) + ENTRY(ENOTBLK, "ENOTBLK", "Block device required"), +#endif +#if defined (EBUSY) + ENTRY(EBUSY, "EBUSY", "Device busy"), +#endif +#if defined (EEXIST) + ENTRY(EEXIST, "EEXIST", "File exists"), +#endif +#if defined (EXDEV) + ENTRY(EXDEV, "EXDEV", "Cross-device link"), +#endif +#if defined (ENODEV) + ENTRY(ENODEV, "ENODEV", "No such device"), +#endif +#if defined (ENOTDIR) + ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"), +#endif +#if defined (EISDIR) + ENTRY(EISDIR, "EISDIR", "Is a directory"), +#endif +#if defined (EINVAL) + ENTRY(EINVAL, "EINVAL", "Invalid argument"), +#endif +#if defined (ENFILE) + ENTRY(ENFILE, "ENFILE", "File table overflow"), +#endif +#if defined (EMFILE) + ENTRY(EMFILE, "EMFILE", "Too many open files"), +#endif +#if defined (ENOTTY) + ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"), +#endif +#if defined (ETXTBSY) + ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"), +#endif +#if defined (EFBIG) + ENTRY(EFBIG, "EFBIG", "File too large"), +#endif +#if defined (ENOSPC) + ENTRY(ENOSPC, "ENOSPC", "No space left on device"), +#endif +#if defined (ESPIPE) + ENTRY(ESPIPE, "ESPIPE", "Illegal seek"), +#endif +#if defined (EROFS) + ENTRY(EROFS, "EROFS", "Read-only file system"), +#endif +#if defined (EMLINK) + ENTRY(EMLINK, "EMLINK", "Too many links"), +#endif +#if defined (EPIPE) + ENTRY(EPIPE, "EPIPE", "Broken pipe"), +#endif +#if defined (EDOM) + ENTRY(EDOM, "EDOM", "Math argument out of domain of func"), +#endif +#if defined (ERANGE) + ENTRY(ERANGE, "ERANGE", "Math result not representable"), +#endif +#if defined (ENOMSG) + ENTRY(ENOMSG, "ENOMSG", "No message of desired type"), +#endif +#if defined (EIDRM) + ENTRY(EIDRM, "EIDRM", "Identifier removed"), +#endif +#if defined (ECHRNG) + ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"), +#endif +#if defined (EL2NSYNC) + ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"), +#endif +#if defined (EL3HLT) + ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"), +#endif +#if defined (EL3RST) + ENTRY(EL3RST, "EL3RST", "Level 3 reset"), +#endif +#if defined (ELNRNG) + ENTRY(ELNRNG, "ELNRNG", "Link number out of range"), +#endif +#if defined (EUNATCH) + ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"), +#endif +#if defined (ENOCSI) + ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"), +#endif +#if defined (EL2HLT) + ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"), +#endif +#if defined (EDEADLK) + ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"), +#endif +#if defined (ENOLCK) + ENTRY(ENOLCK, "ENOLCK", "No record locks available"), +#endif +#if defined (EBADE) + ENTRY(EBADE, "EBADE", "Invalid exchange"), +#endif +#if defined (EBADR) + ENTRY(EBADR, "EBADR", "Invalid request descriptor"), +#endif +#if defined (EXFULL) + ENTRY(EXFULL, "EXFULL", "Exchange full"), +#endif +#if defined (ENOANO) + ENTRY(ENOANO, "ENOANO", "No anode"), +#endif +#if defined (EBADRQC) + ENTRY(EBADRQC, "EBADRQC", "Invalid request code"), +#endif +#if defined (EBADSLT) + ENTRY(EBADSLT, "EBADSLT", "Invalid slot"), +#endif +#if defined (EDEADLOCK) + ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"), +#endif +#if defined (EBFONT) + ENTRY(EBFONT, "EBFONT", "Bad font file format"), +#endif +#if defined (ENOSTR) + ENTRY(ENOSTR, "ENOSTR", "Device not a stream"), +#endif +#if defined (ENODATA) + ENTRY(ENODATA, "ENODATA", "No data available"), +#endif +#if defined (ETIME) + ENTRY(ETIME, "ETIME", "Timer expired"), +#endif +#if defined (ENOSR) + ENTRY(ENOSR, "ENOSR", "Out of streams resources"), +#endif +#if defined (ENONET) + ENTRY(ENONET, "ENONET", "Machine is not on the network"), +#endif +#if defined (ENOPKG) + ENTRY(ENOPKG, "ENOPKG", "Package not installed"), +#endif +#if defined (EREMOTE) + ENTRY(EREMOTE, "EREMOTE", "Object is remote"), +#endif +#if defined (ENOLINK) + ENTRY(ENOLINK, "ENOLINK", "Link has been severed"), +#endif +#if defined (EADV) + ENTRY(EADV, "EADV", "Advertise error"), +#endif +#if defined (ESRMNT) + ENTRY(ESRMNT, "ESRMNT", "Srmount error"), +#endif +#if defined (ECOMM) + ENTRY(ECOMM, "ECOMM", "Communication error on send"), +#endif +#if defined (EPROTO) + ENTRY(EPROTO, "EPROTO", "Protocol error"), +#endif +#if defined (EMULTIHOP) + ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"), +#endif +#if defined (EDOTDOT) + ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"), +#endif +#if defined (EBADMSG) + ENTRY(EBADMSG, "EBADMSG", "Not a data message"), +#endif +#if defined (ENAMETOOLONG) + ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"), +#endif +#if defined (EOVERFLOW) + ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"), +#endif +#if defined (ENOTUNIQ) + ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"), +#endif +#if defined (EBADFD) + ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"), +#endif +#if defined (EREMCHG) + ENTRY(EREMCHG, "EREMCHG", "Remote address changed"), +#endif +#if defined (ELIBACC) + ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"), +#endif +#if defined (ELIBBAD) + ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"), +#endif +#if defined (ELIBSCN) + ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"), +#endif +#if defined (ELIBMAX) + ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"), +#endif +#if defined (ELIBEXEC) + ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"), +#endif +#if defined (EILSEQ) + ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"), +#endif +#if defined (ENOSYS) + ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"), +#endif +#if defined (ELOOP) + ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"), +#endif +#if defined (ERESTART) + ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"), +#endif +#if defined (ESTRPIPE) + ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"), +#endif +#if defined (ENOTEMPTY) + ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"), +#endif +#if defined (EUSERS) + ENTRY(EUSERS, "EUSERS", "Too many users"), +#endif +#if defined (ENOTSOCK) + ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"), +#endif +#if defined (EDESTADDRREQ) + ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"), +#endif +#if defined (EMSGSIZE) + ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"), +#endif +#if defined (EPROTOTYPE) + ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"), +#endif +#if defined (ENOPROTOOPT) + ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"), +#endif +#if defined (EPROTONOSUPPORT) + ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"), +#endif +#if defined (ESOCKTNOSUPPORT) + ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"), +#endif +#if defined (EOPNOTSUPP) + ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"), +#endif +#if defined (EPFNOSUPPORT) + ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"), +#endif +#if defined (EAFNOSUPPORT) + ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"), +#endif +#if defined (EADDRINUSE) + ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"), +#endif +#if defined (EADDRNOTAVAIL) + ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"), +#endif +#if defined (ENETDOWN) + ENTRY(ENETDOWN, "ENETDOWN", "Network is down"), +#endif +#if defined (ENETUNREACH) + ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"), +#endif +#if defined (ENETRESET) + ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"), +#endif +#if defined (ECONNABORTED) + ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"), +#endif +#if defined (ECONNRESET) + ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"), +#endif +#if defined (ENOBUFS) + ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"), +#endif +#if defined (EISCONN) + ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"), +#endif +#if defined (ENOTCONN) + ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"), +#endif +#if defined (ESHUTDOWN) + ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"), +#endif +#if defined (ETOOMANYREFS) + ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"), +#endif +#if defined (ETIMEDOUT) + ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"), +#endif +#if defined (ECONNREFUSED) + ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"), +#endif +#if defined (EHOSTDOWN) + ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"), +#endif +#if defined (EHOSTUNREACH) + ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"), +#endif +#if defined (EALREADY) + ENTRY(EALREADY, "EALREADY", "Operation already in progress"), +#endif +#if defined (EINPROGRESS) + ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"), +#endif +#if defined (ESTALE) + ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"), +#endif +#if defined (EUCLEAN) + ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"), +#endif +#if defined (ENOTNAM) + ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"), +#endif +#if defined (ENAVAIL) + ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"), +#endif +#if defined (EISNAM) + ENTRY(EISNAM, "EISNAM", "Is a named type file"), +#endif +#if defined (EREMOTEIO) + ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"), +#endif + ENTRY(0, NULL, NULL) +}; + +#ifdef EVMSERR +/* This is not in the table, because the numeric value of EVMSERR (32767) + lies outside the range of sys_errlist[]. */ +static struct { int value; const char *name, *msg; } + evmserr = { EVMSERR, "EVMSERR", "VMS-specific error" }; +#endif + +/* Translation table allocated and initialized at runtime. Indexed by the + errno value to find the equivalent symbolic value. */ + +static const char **error_names; +static int num_error_names = 0; + +/* Translation table allocated and initialized at runtime, if it does not + already exist in the host environment. Indexed by the errno value to find + the descriptive string. + + We don't export it for use in other modules because even though it has the + same name, it differs from other implementations in that it is dynamically + initialized rather than statically initialized. */ + +#ifdef NEED_sys_errlist + +static int sys_nerr; +static const char **sys_errlist; + +#else + +extern int sys_nerr; +extern char *sys_errlist[]; + +#endif + + +/* + +NAME + + init_error_tables -- initialize the name and message tables + +SYNOPSIS + + static void init_error_tables (); + +DESCRIPTION + + Using the error_table, which is initialized at compile time, generate + the error_names and the sys_errlist (if needed) tables, which are + indexed at runtime by a specific errno value. + +BUGS + + The initialization of the tables may fail under low memory conditions, + in which case we don't do anything particularly useful, but we don't + bomb either. Who knows, it might succeed at a later point if we free + some memory in the meantime. In any case, the other routines know + how to deal with lack of a table after trying to initialize it. This + may or may not be considered to be a bug, that we don't specifically + warn about this particular failure mode. + +*/ + +static void +init_error_tables () +{ + const struct error_info *eip; + int nbytes; + + /* If we haven't already scanned the error_table once to find the maximum + errno value, then go find it now. */ + + if (num_error_names == 0) + { + for (eip = error_table; eip -> name != NULL; eip++) + { + if (eip -> value >= num_error_names) + { + num_error_names = eip -> value + 1; + } + } + } + + /* Now attempt to allocate the error_names table, zero it out, and then + initialize it from the statically initialized error_table. */ + + if (error_names == NULL) + { + nbytes = num_error_names * sizeof (char *); + if ((error_names = (const char **) malloc (nbytes)) != NULL) + { + memset (error_names, 0, nbytes); + for (eip = error_table; eip -> name != NULL; eip++) + { + error_names[eip -> value] = eip -> name; + } + } + } + +#ifdef NEED_sys_errlist + + /* Now attempt to allocate the sys_errlist table, zero it out, and then + initialize it from the statically initialized error_table. */ + + if (sys_errlist == NULL) + { + nbytes = num_error_names * sizeof (char *); + if ((sys_errlist = (const char **) malloc (nbytes)) != NULL) + { + memset (sys_errlist, 0, nbytes); + sys_nerr = num_error_names; + for (eip = error_table; eip -> name != NULL; eip++) + { + sys_errlist[eip -> value] = eip -> msg; + } + } + } + +#endif + +} + +/* + +NAME + + errno_max -- return the max errno value + +SYNOPSIS + + int errno_max (); + +DESCRIPTION + + Returns the maximum errno value for which a corresponding symbolic + name or message is available. Note that in the case where + we use the sys_errlist supplied by the system, it is possible for + there to be more symbolic names than messages, or vice versa. + In fact, the manual page for perror(3C) explicitly warns that one + should check the size of the table (sys_nerr) before indexing it, + since new error codes may be added to the system before they are + added to the table. Thus sys_nerr might be smaller than value + implied by the largest errno value defined in . + + We return the maximum value that can be used to obtain a meaningful + symbolic name or message. + +*/ + +int +errno_max () +{ + int maxsize; + + if (error_names == NULL) + { + init_error_tables (); + } + maxsize = MAX (sys_nerr, num_error_names); + return (maxsize - 1); +} + +#ifdef NEED_strerror + +/* + +NAME + + strerror -- map an error number to an error message string + +SYNOPSIS + + char *strerror (int errnoval) + +DESCRIPTION + + Maps an errno number to an error message string, the contents of + which are implementation defined. On systems which have the external + variables sys_nerr and sys_errlist, these strings will be the same + as the ones used by perror(). + + If the supplied error number is within the valid range of indices + for the sys_errlist, but no message is available for the particular + error number, then returns the string "Error NUM", where NUM is the + error number. + + If the supplied error number is not a valid index into sys_errlist, + returns NULL. + + The returned string is only guaranteed to be valid only until the + next call to strerror. + +*/ + +char * +strerror (errnoval) + int errnoval; +{ + char *msg; + static char buf[32]; + +#ifdef NEED_sys_errlist + + if (error_names == NULL) + { + init_error_tables (); + } + +#endif + + if ((errnoval < 0) || (errnoval >= sys_nerr)) + { +#ifdef EVMSERR + if (errnoval == evmserr.value) + msg = evmserr.msg; + else +#endif + /* Out of range, just return NULL */ + msg = NULL; + } + else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL)) + { + /* In range, but no sys_errlist or no entry at this index. */ + sprintf (buf, "Error %d", errnoval); + msg = buf; + } + else + { + /* In range, and a valid message. Just return the message. */ + msg = (char *) sys_errlist[errnoval]; + } + + return (msg); +} + +#endif /* NEED_strerror */ + + +/* + +NAME + + strerrno -- map an error number to a symbolic name string + +SYNOPSIS + + const char *strerrno (int errnoval) + +DESCRIPTION + + Given an error number returned from a system call (typically + returned in errno), returns a pointer to a string containing the + symbolic name of that error number, as found in . + + If the supplied error number is within the valid range of indices + for symbolic names, but no name is available for the particular + error number, then returns the string "Error NUM", where NUM is + the error number. + + If the supplied error number is not within the range of valid + indices, then returns NULL. + +BUGS + + The contents of the location pointed to are only guaranteed to be + valid until the next call to strerrno. + +*/ + +const char * +strerrno (errnoval) + int errnoval; +{ + const char *name; + static char buf[32]; + + if (error_names == NULL) + { + init_error_tables (); + } + + if ((errnoval < 0) || (errnoval >= num_error_names)) + { +#ifdef EVMSERR + if (errnoval == evmserr.value) + name = evmserr.name; + else +#endif + /* Out of range, just return NULL */ + name = NULL; + } + else if ((error_names == NULL) || (error_names[errnoval] == NULL)) + { + /* In range, but no error_names or no entry at this index. */ + sprintf (buf, "Error %d", errnoval); + name = (const char *) buf; + } + else + { + /* In range, and a valid name. Just return the name. */ + name = error_names[errnoval]; + } + + return (name); +} + +/* + +NAME + + strtoerrno -- map a symbolic errno name to a numeric value + +SYNOPSIS + + int strtoerrno (char *name) + +DESCRIPTION + + Given the symbolic name of a error number, map it to an errno value. + If no translation is found, returns 0. + +*/ + +int +strtoerrno (name) + const char *name; +{ + int errnoval = 0; + + if (name != NULL) + { + if (error_names == NULL) + { + init_error_tables (); + } + for (errnoval = 0; errnoval < num_error_names; errnoval++) + { + if ((error_names[errnoval] != NULL) && + (strcmp (name, error_names[errnoval]) == 0)) + { + break; + } + } + if (errnoval == num_error_names) + { +#ifdef EVMSERR + if (strcmp (name, evmserr.name) == 0) + errnoval = evmserr.value; + else +#endif + errnoval = 0; + } + } + return (errnoval); +} + + +/* A simple little main that does nothing but print all the errno translations + if MAIN is defined and this file is compiled and linked. */ + +#ifdef MAIN + +#include + +int +main () +{ + int errn; + int errnmax; + const char *name; + char *msg; + char *strerror (); + + errnmax = errno_max (); + printf ("%d entries in names table.\n", num_error_names); + printf ("%d entries in messages table.\n", sys_nerr); + printf ("%d is max useful index.\n", errnmax); + + /* Keep printing values until we get to the end of *both* tables, not + *either* table. Note that knowing the maximum useful index does *not* + relieve us of the responsibility of testing the return pointer for + NULL. */ + + for (errn = 0; errn <= errnmax; errn++) + { + name = strerrno (errn); + name = (name == NULL) ? "" : name; + msg = strerror (errn); + msg = (msg == NULL) ? "" : msg; + printf ("%-4d%-18s%s\n", errn, name, msg); + } + + return 0; +} + +#endif diff --git a/libiberty/strncasecmp.c b/libiberty/strncasecmp.c new file mode 100644 index 000000000000..4485cac7a6a2 --- /dev/null +++ b/libiberty/strncasecmp.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific written prior permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; +#endif /* LIBC_SCCS and not lint */ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +/* + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ +static unsigned char charmap[] = { + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', +}; + +int +strncasecmp(s1, s2, n) + const char *s1, *s2; + register size_t n; +{ + register unsigned char u1, u2; + + for (; n != 0; --n) { + u1 = (unsigned char) *s1++; + u2 = (unsigned char) *s2++; + if (charmap[u1] != charmap[u2]) { + return charmap[u1] - charmap[u2]; + } + if (u1 == '\0') { + return 0; + } + } + return 0; +} diff --git a/libiberty/strrchr.c b/libiberty/strrchr.c new file mode 100644 index 000000000000..30f9e8a3658a --- /dev/null +++ b/libiberty/strrchr.c @@ -0,0 +1,34 @@ +/* Portable version of strrchr(). + This function is in the public domain. */ + +/* +NAME + strrchr -- return pointer to last occurance of a character + +SYNOPSIS + char *strrchr (const char *s, int c) + +DESCRIPTION + Returns a pointer to the last occurance of character C in + string S, or a NULL pointer if no occurance is found. + +BUGS + Behavior when character is the null character is implementation + dependent. +*/ + +#include + +char * +strrchr (s, c) + register CONST char *s; + int c; +{ + char *rtnval = 0; + + do { + if (*s == c) + rtnval = (char*) s; + } while (*s++); + return (rtnval); +} diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c new file mode 100644 index 000000000000..7d40b4cedff9 --- /dev/null +++ b/libiberty/strsignal.c @@ -0,0 +1,638 @@ +/* Extended support for using signal values. + Written by Fred Fish. fnf@cygnus.com + This file is in the public domain. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#include "config.h" + +/* We need to declare sys_siglist, because even if the system provides + it we can't assume that it is declared in (for example, + SunOS provides sys_siglist, but it does not declare it in any + header file). fHowever, we can't declare sys_siglist portably, + because on some systems it is declared with const and on some + systems it is declared without const. If we were using autoconf, + we could work out the right declaration. Until, then we just + ignore any declaration in the system header files, and always + declare it ourselves. With luck, this will always work. */ +#define sys_siglist no_such_symbol + +#include +#include + +/* Routines imported from standard C runtime libraries. */ + +#ifdef __STDC__ +#include +extern void *malloc (size_t size); /* 4.10.3.3 */ +extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ +#else /* !__STDC__ */ +extern char *malloc (); /* Standard memory allocater */ +extern char *memset (); +#endif /* __STDC__ */ + +/* Undefine the macro we used to hide the definition of sys_siglist + found in the system header files. */ +#undef sys_siglist + +#ifndef NULL +# ifdef __STDC__ +# define NULL (void *) 0 +# else +# define NULL 0 +# endif +#endif + +#ifndef MAX +# define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +static void init_signal_tables PARAMS ((void)); + +/* Translation table for signal values. + + Note that this table is generally only accessed when it is used at runtime + to initialize signal name and message tables that are indexed by signal + value. + + Not all of these signals will exist on all systems. This table is the only + thing that should have to be updated as new signal numbers are introduced. + It's sort of ugly, but at least its portable. */ + +struct signal_info +{ + int value; /* The numeric value from */ + const char *name; /* The equivalent symbolic value */ +#ifdef NEED_sys_siglist + const char *msg; /* Short message about this value */ +#endif +}; + +#ifdef NEED_sys_siglist +# define ENTRY(value, name, msg) {value, name, msg} +#else +# define ENTRY(value, name, msg) {value, name} +#endif + +static const struct signal_info signal_table[] = +{ +#if defined (SIGHUP) + ENTRY(SIGHUP, "SIGHUP", "Hangup"), +#endif +#if defined (SIGINT) + ENTRY(SIGINT, "SIGINT", "Interrupt"), +#endif +#if defined (SIGQUIT) + ENTRY(SIGQUIT, "SIGQUIT", "Quit"), +#endif +#if defined (SIGILL) + ENTRY(SIGILL, "SIGILL", "Illegal instruction"), +#endif +#if defined (SIGTRAP) + ENTRY(SIGTRAP, "SIGTRAP", "Trace/breakpoint trap"), +#endif +/* Put SIGIOT before SIGABRT, so that if SIGIOT==SIGABRT then SIGABRT + overrides SIGIOT. SIGABRT is in ANSI and POSIX.1, and SIGIOT isn't. */ +#if defined (SIGIOT) + ENTRY(SIGIOT, "SIGIOT", "IOT trap"), +#endif +#if defined (SIGABRT) + ENTRY(SIGABRT, "SIGABRT", "Aborted"), +#endif +#if defined (SIGEMT) + ENTRY(SIGEMT, "SIGEMT", "Emulation trap"), +#endif +#if defined (SIGFPE) + ENTRY(SIGFPE, "SIGFPE", "Arithmetic exception"), +#endif +#if defined (SIGKILL) + ENTRY(SIGKILL, "SIGKILL", "Killed"), +#endif +#if defined (SIGBUS) + ENTRY(SIGBUS, "SIGBUS", "Bus error"), +#endif +#if defined (SIGSEGV) + ENTRY(SIGSEGV, "SIGSEGV", "Segmentation fault"), +#endif +#if defined (SIGSYS) + ENTRY(SIGSYS, "SIGSYS", "Bad system call"), +#endif +#if defined (SIGPIPE) + ENTRY(SIGPIPE, "SIGPIPE", "Broken pipe"), +#endif +#if defined (SIGALRM) + ENTRY(SIGALRM, "SIGALRM", "Alarm clock"), +#endif +#if defined (SIGTERM) + ENTRY(SIGTERM, "SIGTERM", "Terminated"), +#endif +#if defined (SIGUSR1) + ENTRY(SIGUSR1, "SIGUSR1", "User defined signal 1"), +#endif +#if defined (SIGUSR2) + ENTRY(SIGUSR2, "SIGUSR2", "User defined signal 2"), +#endif +/* Put SIGCLD before SIGCHLD, so that if SIGCLD==SIGCHLD then SIGCHLD + overrides SIGCLD. SIGCHLD is in POXIX.1 */ +#if defined (SIGCLD) + ENTRY(SIGCLD, "SIGCLD", "Child status changed"), +#endif +#if defined (SIGCHLD) + ENTRY(SIGCHLD, "SIGCHLD", "Child status changed"), +#endif +#if defined (SIGPWR) + ENTRY(SIGPWR, "SIGPWR", "Power fail/restart"), +#endif +#if defined (SIGWINCH) + ENTRY(SIGWINCH, "SIGWINCH", "Window size changed"), +#endif +#if defined (SIGURG) + ENTRY(SIGURG, "SIGURG", "Urgent I/O condition"), +#endif +#if defined (SIGIO) + /* "I/O pending" has also been suggested, but is misleading since the + signal only happens when the process has asked for it, not everytime + I/O is pending. */ + ENTRY(SIGIO, "SIGIO", "I/O possible"), +#endif +#if defined (SIGPOLL) + ENTRY(SIGPOLL, "SIGPOLL", "Pollable event occurred"), +#endif +#if defined (SIGSTOP) + ENTRY(SIGSTOP, "SIGSTOP", "Stopped (signal)"), +#endif +#if defined (SIGTSTP) + ENTRY(SIGTSTP, "SIGTSTP", "Stopped (user)"), +#endif +#if defined (SIGCONT) + ENTRY(SIGCONT, "SIGCONT", "Continued"), +#endif +#if defined (SIGTTIN) + ENTRY(SIGTTIN, "SIGTTIN", "Stopped (tty input)"), +#endif +#if defined (SIGTTOU) + ENTRY(SIGTTOU, "SIGTTOU", "Stopped (tty output)"), +#endif +#if defined (SIGVTALRM) + ENTRY(SIGVTALRM, "SIGVTALRM", "Virtual timer expired"), +#endif +#if defined (SIGPROF) + ENTRY(SIGPROF, "SIGPROF", "Profiling timer expired"), +#endif +#if defined (SIGXCPU) + ENTRY(SIGXCPU, "SIGXCPU", "CPU time limit exceeded"), +#endif +#if defined (SIGXFSZ) + ENTRY(SIGXFSZ, "SIGXFSZ", "File size limit exceeded"), +#endif +#if defined (SIGWIND) + ENTRY(SIGWIND, "SIGWIND", "SIGWIND"), +#endif +#if defined (SIGPHONE) + ENTRY(SIGPHONE, "SIGPHONE", "SIGPHONE"), +#endif +#if defined (SIGLOST) + ENTRY(SIGLOST, "SIGLOST", "Resource lost"), +#endif +#if defined (SIGWAITING) + ENTRY(SIGWAITING, "SIGWAITING", "Process's LWPs are blocked"), +#endif +#if defined (SIGLWP) + ENTRY(SIGLWP, "SIGLWP", "Signal LWP"), +#endif +#if defined (SIGDANGER) + ENTRY(SIGDANGER, "SIGDANGER", "Swap space dangerously low"), +#endif +#if defined (SIGGRANT) + ENTRY(SIGGRANT, "SIGGRANT", "Monitor mode granted"), +#endif +#if defined (SIGRETRACT) + ENTRY(SIGRETRACT, "SIGRETRACT", "Need to relinguish monitor mode"), +#endif +#if defined (SIGMSG) + ENTRY(SIGMSG, "SIGMSG", "Monitor mode data available"), +#endif +#if defined (SIGSOUND) + ENTRY(SIGSOUND, "SIGSOUND", "Sound completed"), +#endif +#if defined (SIGSAK) + ENTRY(SIGSAK, "SIGSAK", "Secure attention"), +#endif + ENTRY(0, NULL, NULL) +}; + +/* Translation table allocated and initialized at runtime. Indexed by the + signal value to find the equivalent symbolic value. */ + +static const char **signal_names; +static int num_signal_names = 0; + +/* Translation table allocated and initialized at runtime, if it does not + already exist in the host environment. Indexed by the signal value to find + the descriptive string. + + We don't export it for use in other modules because even though it has the + same name, it differs from other implementations in that it is dynamically + initialized rather than statically initialized. */ + +#ifdef NEED_sys_siglist + +static int sys_nsig; +static const char **sys_siglist; + +#else + +static int sys_nsig = NSIG; +extern const char * const sys_siglist[]; + +#endif + + +/* + +NAME + + init_signal_tables -- initialize the name and message tables + +SYNOPSIS + + static void init_signal_tables (); + +DESCRIPTION + + Using the signal_table, which is initialized at compile time, generate + the signal_names and the sys_siglist (if needed) tables, which are + indexed at runtime by a specific signal value. + +BUGS + + The initialization of the tables may fail under low memory conditions, + in which case we don't do anything particularly useful, but we don't + bomb either. Who knows, it might succeed at a later point if we free + some memory in the meantime. In any case, the other routines know + how to deal with lack of a table after trying to initialize it. This + may or may not be considered to be a bug, that we don't specifically + warn about this particular failure mode. + +*/ + +static void +init_signal_tables () +{ + const struct signal_info *eip; + int nbytes; + + /* If we haven't already scanned the signal_table once to find the maximum + signal value, then go find it now. */ + + if (num_signal_names == 0) + { + for (eip = signal_table; eip -> name != NULL; eip++) + { + if (eip -> value >= num_signal_names) + { + num_signal_names = eip -> value + 1; + } + } + } + + /* Now attempt to allocate the signal_names table, zero it out, and then + initialize it from the statically initialized signal_table. */ + + if (signal_names == NULL) + { + nbytes = num_signal_names * sizeof (char *); + if ((signal_names = (const char **) malloc (nbytes)) != NULL) + { + memset (signal_names, 0, nbytes); + for (eip = signal_table; eip -> name != NULL; eip++) + { + signal_names[eip -> value] = eip -> name; + } + } + } + +#ifdef NEED_sys_siglist + + /* Now attempt to allocate the sys_siglist table, zero it out, and then + initialize it from the statically initialized signal_table. */ + + if (sys_siglist == NULL) + { + nbytes = num_signal_names * sizeof (char *); + if ((sys_siglist = (const char **) malloc (nbytes)) != NULL) + { + memset (sys_siglist, 0, nbytes); + sys_nsig = num_signal_names; + for (eip = signal_table; eip -> name != NULL; eip++) + { + sys_siglist[eip -> value] = eip -> msg; + } + } + } + +#endif + +} + + +/* + +NAME + + signo_max -- return the max signo value + +SYNOPSIS + + int signo_max (); + +DESCRIPTION + + Returns the maximum signo value for which a corresponding symbolic + name or message is available. Note that in the case where + we use the sys_siglist supplied by the system, it is possible for + there to be more symbolic names than messages, or vice versa. + In fact, the manual page for psignal(3b) explicitly warns that one + should check the size of the table (NSIG) before indexing it, + since new signal codes may be added to the system before they are + added to the table. Thus NSIG might be smaller than value + implied by the largest signo value defined in . + + We return the maximum value that can be used to obtain a meaningful + symbolic name or message. + +*/ + +int +signo_max () +{ + int maxsize; + + if (signal_names == NULL) + { + init_signal_tables (); + } + maxsize = MAX (sys_nsig, num_signal_names); + return (maxsize - 1); +} + + +/* + +NAME + + strsignal -- map a signal number to a signal message string + +SYNOPSIS + + const char *strsignal (int signo) + +DESCRIPTION + + Maps an signal number to an signal message string, the contents of + which are implementation defined. On systems which have the external + variable sys_siglist, these strings will be the same as the ones used + by psignal(). + + If the supplied signal number is within the valid range of indices + for the sys_siglist, but no message is available for the particular + signal number, then returns the string "Signal NUM", where NUM is the + signal number. + + If the supplied signal number is not a valid index into sys_siglist, + returns NULL. + + The returned string is only guaranteed to be valid only until the + next call to strsignal. + +*/ + +#ifdef NEED_strsignal + +const char * +strsignal (signo) + int signo; +{ + const char *msg; + static char buf[32]; + +#ifdef NEED_sys_siglist + + if (signal_names == NULL) + { + init_signal_tables (); + } + +#endif + + if ((signo < 0) || (signo >= sys_nsig)) + { + /* Out of range, just return NULL */ + msg = NULL; + } + else if ((sys_siglist == NULL) || (sys_siglist[signo] == NULL)) + { + /* In range, but no sys_siglist or no entry at this index. */ + sprintf (buf, "Signal %d", signo); + msg = (const char *) buf; + } + else + { + /* In range, and a valid message. Just return the message. */ + msg = (const char *) sys_siglist[signo]; + } + + return (msg); +} + +#endif /* NEED_strsignal */ + +/* + +NAME + + strsigno -- map an signal number to a symbolic name string + +SYNOPSIS + + const char *strsigno (int signo) + +DESCRIPTION + + Given an signal number, returns a pointer to a string containing + the symbolic name of that signal number, as found in . + + If the supplied signal number is within the valid range of indices + for symbolic names, but no name is available for the particular + signal number, then returns the string "Signal NUM", where NUM is + the signal number. + + If the supplied signal number is not within the range of valid + indices, then returns NULL. + +BUGS + + The contents of the location pointed to are only guaranteed to be + valid until the next call to strsigno. + +*/ + +const char * +strsigno (signo) + int signo; +{ + const char *name; + static char buf[32]; + + if (signal_names == NULL) + { + init_signal_tables (); + } + + if ((signo < 0) || (signo >= num_signal_names)) + { + /* Out of range, just return NULL */ + name = NULL; + } + else if ((signal_names == NULL) || (signal_names[signo] == NULL)) + { + /* In range, but no signal_names or no entry at this index. */ + sprintf (buf, "Signal %d", signo); + name = (const char *) buf; + } + else + { + /* In range, and a valid name. Just return the name. */ + name = signal_names[signo]; + } + + return (name); +} + + +/* + +NAME + + strtosigno -- map a symbolic signal name to a numeric value + +SYNOPSIS + + int strtosigno (char *name) + +DESCRIPTION + + Given the symbolic name of a signal, map it to a signal number. + If no translation is found, returns 0. + +*/ + +int +strtosigno (name) + const char *name; +{ + int signo = 0; + + if (name != NULL) + { + if (signal_names == NULL) + { + init_signal_tables (); + } + for (signo = 0; signo < num_signal_names; signo++) + { + if ((signal_names[signo] != NULL) && + (strcmp (name, signal_names[signo]) == 0)) + { + break; + } + } + if (signo == num_signal_names) + { + signo = 0; + } + } + return (signo); +} + + +/* + +NAME + + psignal -- print message about signal to stderr + +SYNOPSIS + + void psignal (unsigned signo, char *message); + +DESCRIPTION + + Print to the standard error the message, followed by a colon, + followed by the description of the signal specified by signo, + followed by a newline. +*/ + +#ifdef NEED_psignal + +void +psignal (signo, message) + unsigned signo; + char *message; +{ + if (signal_names == NULL) + { + init_signal_tables (); + } + if ((signo <= 0) || (signo >= sys_nsig)) + { + fprintf (stderr, "%s: unknown signal\n", message); + } + else + { + fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]); + } +} + +#endif /* NEED_psignal */ + + +/* A simple little main that does nothing but print all the signal translations + if MAIN is defined and this file is compiled and linked. */ + +#ifdef MAIN + +#include + +int +main () +{ + int signo; + int maxsigno; + const char *name; + const char *msg; + + maxsigno = signo_max (); + printf ("%d entries in names table.\n", num_signal_names); + printf ("%d entries in messages table.\n", sys_nsig); + printf ("%d is max useful index.\n", maxsigno); + + /* Keep printing values until we get to the end of *both* tables, not + *either* table. Note that knowing the maximum useful index does *not* + relieve us of the responsibility of testing the return pointer for + NULL. */ + + for (signo = 0; signo <= maxsigno; signo++) + { + name = strsigno (signo); + name = (name == NULL) ? "" : name; + msg = strsignal (signo); + msg = (msg == NULL) ? "" : msg; + printf ("%-4d%-18s%s\n", signo, name, msg); + } + + return 0; +} + +#endif diff --git a/libiberty/strstr.c b/libiberty/strstr.c new file mode 100644 index 000000000000..fab36e3fb3d4 --- /dev/null +++ b/libiberty/strstr.c @@ -0,0 +1,51 @@ +/* Simple implementation of strstr for systems without it. + This function is in the public domain. */ + +/* + +NAME + + strstr -- locate first occurance of a substring + +SYNOPSIS + + #include + + char *strstr (char *s1, char *s2) + +DESCRIPTION + + Locates the first occurance in the string pointed to by S1 of + the string pointed to by S2. Returns a pointer to the substring + found, or a NULL pointer if not found. If S2 points to a string + with zero length, the function returns S1. + +BUGS + +*/ + + +/* FIXME: The above description is ANSI compiliant. This routine has not + been validated to comply with it. -fnf */ + +char * +strstr (s1, s2) + char *s1, *s2; +{ + register char *p = s1; + extern char *strchr (); + extern int strncmp (); +#if __GNUC__==2 + extern __SIZE_TYPE__ strlen (); +#endif + register int len = strlen (s2); + + for (; (p = strchr (p, *s2)) != 0; p++) + { + if (strncmp (p, s2, len) == 0) + { + return (p); + } + } + return (0); +} diff --git a/libiberty/strtod.c b/libiberty/strtod.c new file mode 100644 index 000000000000..c86c73de9b38 --- /dev/null +++ b/libiberty/strtod.c @@ -0,0 +1,122 @@ +/* Implementation of strtod for systems with atof. + Copyright (C) 1991, 1995 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. */ + +#include + +extern double atof (); + +/* Disclaimer: this is currently just used by CHILL in GDB and therefore + has not been tested well. It may have been tested for nothing except + that it compiles. */ + +double +strtod (str, ptr) + char *str; + char **ptr; +{ + char *p; + + if (ptr == (char **)0) + return atof (str); + + p = str; + + while (isspace (*p)) + ++p; + + if (*p == '+' || *p == '-') + ++p; + + /* INF or INFINITY. */ + if ((p[0] == 'i' || p[0] == 'I') + && (p[1] == 'n' || p[1] == 'N') + && (p[2] == 'f' || p[2] == 'F')) + { + if ((p[3] == 'i' || p[3] == 'I') + && (p[4] == 'n' || p[4] == 'N') + && (p[5] == 'i' || p[5] == 'I') + && (p[6] == 't' || p[6] == 'T') + && (p[7] == 'y' || p[7] == 'Y')) + { + *ptr = p + 7; + return atof (str); + } + else + { + *ptr = p + 3; + return atof (str); + } + } + + /* NAN or NAN(foo). */ + if ((p[0] == 'n' || p[0] == 'N') + && (p[1] == 'a' || p[1] == 'A') + && (p[2] == 'n' || p[2] == 'N')) + { + p += 3; + if (*p == '(') + { + ++p; + while (*p != '\0' && *p != ')') + ++p; + if (*p == ')') + ++p; + } + *ptr = p; + return atof (str); + } + + /* digits, with 0 or 1 periods in it. */ + if (isdigit (*p) || *p == '.') + { + int got_dot = 0; + while (isdigit (*p) || (!got_dot && *p == '.')) + { + if (*p == '.') + got_dot = 1; + ++p; + } + + /* Exponent. */ + if (*p == 'e' || *p == 'E') + { + int i; + i = 1; + if (p[i] == '+' || p[i] == '-') + ++i; + if (isdigit (p[i])) + { + while (isdigit (p[i])) + ++i; + *ptr = p + i; + return atof (str); + } + } + *ptr = p; + return atof (str); + } + /* Didn't find any digits. Doesn't look like a number. */ + *ptr = str; + return 0.0; +} diff --git a/libiberty/strtol.c b/libiberty/strtol.c new file mode 100644 index 000000000000..db27ee0a8759 --- /dev/null +++ b/libiberty/strtol.c @@ -0,0 +1,143 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#if 0 +#include +#endif +#include "ansidecl.h" + +/* FIXME: It'd be nice to configure around these, but the include files are too + painful. These macros should at least be more portable than hardwired hex + constants. */ + +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +#ifndef LONG_MAX +#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF */ +#endif + +#ifndef LONG_MIN +#define LONG_MIN ((long)(~LONG_MAX)) /* 0x80000000 */ +#endif + +/* + * Convert a string to a long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long +strtol(nptr, endptr, base) + CONST char *nptr; + char **endptr; + register int base; +{ + register CONST char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/libiberty/strtoul.c b/libiberty/strtoul.c new file mode 100644 index 000000000000..40902452fed3 --- /dev/null +++ b/libiberty/strtoul.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#if 0 +#include +#endif +#include "ansidecl.h" + +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +/* + * Convert a string to an unsigned long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long +strtoul(nptr, endptr, base) + CONST char *nptr; + char **endptr; + register int base; +{ + register CONST char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/libiberty/tmpnam.c b/libiberty/tmpnam.c new file mode 100644 index 000000000000..c06146774252 --- /dev/null +++ b/libiberty/tmpnam.c @@ -0,0 +1,39 @@ +#include + +#ifndef L_tmpnam +#define L_tmpname 100 +#endif +#ifndef P_tmpdir +#define P_tmpdir "/usr/tmp" +#endif + +static char tmpnam_buffer[L_tmpnam]; +static int tmpnam_counter; + +extern int getpid (); + +char * +tmpnam (s) + char *s; +{ + int pid = getpid (); + + if (s == NULL) + s = tmpnam_buffer; + + /* Generate the filename and make sure that there isn't one called + it already. */ + + while (1) + { + FILE *f; + sprintf (s, "%s/%s%x.%x", P_tmpdir, "t", pid, tmpnam_counter); + f = fopen (s, "r"); + if (f == NULL) + break; + tmpnam_counter++; + fclose (f); + } + + return s; +} diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c new file mode 100644 index 000000000000..3794cbd2c4fb --- /dev/null +++ b/libiberty/vasprintf.c @@ -0,0 +1,165 @@ +/* Like vsprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. + Copyright (C) 1994 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include +#include +#include +#ifdef __STDC__ +#include +#else +#include +#endif + +#ifdef TEST +int global_total_width; +#endif + +unsigned long strtoul (); +char *malloc (); + +static int +int_vasprintf (result, format, args) + char **result; + const char *format; + va_list *args; +{ + const char *p = format; + /* Add one to make sure that it is never zero, which might cause malloc + to return NULL. */ + int total_width = strlen (format) + 1; + va_list ap; + + memcpy ((PTR) &ap, (PTR) args, sizeof (va_list)); + + while (*p != '\0') + { + if (*p++ == '%') + { + while (strchr ("-+ #0", *p)) + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, &p, 10); + if (*p == '.') + { + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, &p, 10); + } + while (strchr ("hlL", *p)) + ++p; + /* Should be big enough for any format specifier except %s. */ + total_width += 30; + switch (*p) + { + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + case 'c': + (void) va_arg (ap, int); + break; + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + (void) va_arg (ap, double); + break; + case 's': + total_width += strlen (va_arg (ap, char *)); + break; + case 'p': + case 'n': + (void) va_arg (ap, char *); + break; + } + } + } +#ifdef TEST + global_total_width = total_width; +#endif + *result = malloc (total_width); + if (*result != NULL) + return vsprintf (*result, format, *args); + else + return 0; +} + +int +vasprintf (result, format, args) + char **result; + const char *format; + va_list args; +{ + return int_vasprintf (result, format, &args); +} + +#ifdef TEST +void +checkit +#ifdef __STDC__ + (const char* format, ...) +#else + (va_alist) + va_dcl +#endif +{ + va_list args; + char *result; + +#ifdef __STDC__ + va_start (args, format); +#else + char *format; + va_start (args); + format = va_arg (args, char *); +#endif + vasprintf (&result, format, args); + if (strlen (result) < global_total_width) + printf ("PASS: "); + else + printf ("FAIL: "); + printf ("%d %s\n", global_total_width, result); +} + +int +main () +{ + checkit ("%d", 0x12345678); + checkit ("%200d", 5); + checkit ("%.300d", 6); + checkit ("%100.150d", 7); + checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\ +777777777777777777333333333333366666666666622222222222777777777777733333"); + checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"); +} +#endif /* TEST */ diff --git a/libiberty/vfork.c b/libiberty/vfork.c new file mode 100644 index 000000000000..86c45919f660 --- /dev/null +++ b/libiberty/vfork.c @@ -0,0 +1,8 @@ +/* Emulate vfork using just plain fork, for systems without a real vfork. + This function is in the public domain. */ + +int +vfork () +{ + return (fork ()); +} diff --git a/libiberty/vfprintf.c b/libiberty/vfprintf.c new file mode 100644 index 000000000000..ce3fdf9c4745 --- /dev/null +++ b/libiberty/vfprintf.c @@ -0,0 +1,13 @@ +#include +#include +#include +#undef vfprintf + +int +vfprintf (file, format, ap) + FILE *file; + const char *format; + va_list ap; +{ + return _doprnt (format, ap, file); +} diff --git a/libiberty/vmsbuild.com b/libiberty/vmsbuild.com new file mode 100644 index 000000000000..9400b45723af --- /dev/null +++ b/libiberty/vmsbuild.com @@ -0,0 +1,166 @@ +$! libiberty/vmsbuild.com -- build liberty.olb for VMS host, VMS target +$! +$ CC = "gcc /noVerbose/Debug/Incl=([],[-.include])" +$ LIBR = "library /Obj" +$ LINK = "link" +$ DELETE= "delete /noConfirm" +$ SEARCH= "search /Exact" +$ ECHO = "write sys$output" +$ ABORT = "exit %x002C" +$! +$ LIB_NAME = "liberty.olb" !this is what we're going to construct +$ WORK_LIB = "new-lib.olb" !used to guard against an incomplete build +$ +$! manually copied from Makefile.in +$ REQUIRED_OFILES = "argv.o basename.o choose-temp.o concat.o cplus-dem.o "- + + "fdmatch.o getopt.o getopt1.o getruntime.o hex.o "- + + "floatformat.o obstack.o spaces.o strerror.o strsignal.o "- + + "vasprintf.o xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o" +$! anything not caught by link+search of dummy.* should be added here +$ EXTRA_OFILES = "" +$! +$! move to the directory which contains this command procedure +$ old_dir = f$environ("DEFAULT") +$ new_dir = f$parse("_._;",f$environ("PROCEDURE")) - "_._;" +$ set default 'new_dir' +$ +$ ECHO "Starting libiberty build..." +$ create config.h +/* libiberty config.h for VMS */ +#define NEED_sys_siglist +#define NEED_psignal +#define NEED_basename +$ if f$search("alloca-conf.h").eqs."" then - + copy alloca-norm.h alloca-conf.h +$ LIBR 'WORK_LIB' /Create +$ +$! first pass: compile "required" modules +$ ofiles = REQUIRED_OFILES + " " + EXTRA_OFILES +$ pass = 1 +$ gosub do_ofiles +$ +$! second pass: process dummy.c, using the first pass' results +$ ECHO " now checking run-time library for missing functionality" +$ if f$search("dummy.obj").nes."" then DELETE dummy.obj;* +$ define/noLog sys$error _NL: !can't use /User_Mode here due to gcc +$ define/noLog sys$output _NL: ! driver's use of multiple image activation +$ on error then continue +$ 'CC' dummy.c +$ deassign sys$error !restore, more or less +$ deassign sys$output +$ if f$search("dummy.obj").eqs."" then goto pass2_failure1 +$! link dummy.obj, capturing full linker feedback in dummy.map +$ oldmsg = f$environ("MESSAGE") +$ set message /Facility/Severity/Identification/Text +$ define/User sys$output _NL: +$ define/User sys$error _NL: +$ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,- + gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr +$ set message 'oldmsg' +$ if f$search("dummy.map").eqs."" then goto pass2_failure2 +$ DELETE dummy.obj;* +$ SEARCH dummy.map "%LINK-I-UDFSYM" /Output=dummy.list +$ DELETE dummy.map;* +$ ECHO " check completed" +$! we now have a file with one entry per line of unresolvable symbols +$ ofiles = "" +$ if f$trnlnm("IFILE$").nes."" then close/noLog ifile$ +$ open/Read ifile$ dummy.list +$iloop: read/End=idone ifile$ iline +$ iline = f$edit(iline,"COMPRESS,TRIM,LOWERCASE") +$ ofiles = ofiles + " " + f$element(1," ",iline) + ".o" +$ goto iloop +$idone: close ifile$ +$ DELETE dummy.list;* +$ on error then ABORT +$ +$! third pass: compile "missing" modules collected in pass 2 +$ pass = 3 +$ gosub do_ofiles +$ +$! finish up +$ LIBR 'WORK_LIB' /Compress /Output='LIB_NAME' !new-lib.olb -> liberty.olb +$ DELETE 'WORK_LIB';* +$ +$! all done +$ ECHO "Completed libiberty build." +$ type sys$input: + + You many wish to do + $ COPY LIBERTY.OLB GNU_CC:[000000] + so that this run-time library resides in the same location as gcc's + support library. When building gas, be sure to leave the original + copy of liberty.olb here so that gas's build procedure can find it. + +$ set default 'old_dir' +$ exit +$ +$! +$! compile each element of the space-delimited list 'ofiles' +$! +$do_ofiles: +$ ofiles = f$edit(ofiles,"COMPRESS,TRIM") +$ i = 0 +$oloop: +$ f = f$element(i," ",ofiles) +$ if f.eqs." " then goto odone +$ f = f - ".o" !strip dummy suffix +$ ECHO " ''f'" +$ skip_f = 0 +$ if pass.eq.3 .and. f$search("''f'.c").eqs."" then gosub chk_deffunc +$ if .not.skip_f +$ then +$ 'CC' 'f'.c +$ LIBR 'WORK_LIB' 'f'.obj /Insert +$ DELETE 'f'.obj;* +$ endif +$ i = i + 1 +$ goto oloop +$odone: +$ return +$ +$! +$! check functions.def for a DEFFUNC() entry corresponding to missing file 'f'.c +$! +$chk_deffunc: +$ define/User sys$output _NL: +$ define/User sys$error _NL: +$ SEARCH functions.def "DEFFUNC","''f'" /Match=AND +$ if (($status.and.%x7FFFFFFF) .eq. 1) +$ then +$ skip_f = 1 +$ open/Append config_h config.h +$ write config_h "#define NEED_''f'" +$ close config_h +$ endif +$ return +$ +$! +$pass2_failure1: +$! if we reach here, dummy.c failed to compile and we're really stuck +$ type sys$input: + + Cannot compile the library contents checker (dummy.c + functions.def), + so cannot continue! + +$! attempt the compile again, without suppressing diagnostic messages this time +$ on error then ABORT +0*f$verify(v) +$ v = f$verify(1) +$ 'CC' dummy.c +$ ABORT +0*f$verify(v) !'f$verify(0)' +$! +$pass2_failure2: +$! should never reach here.. +$ type sys$input: + + Cannot link the library contents checker (dummy.obj), so cannot continue! + +$! attempt the link again, without suppressing diagnostic messages this time +$ on error then ABORT +0*f$verify(v) +$ v = f$verify(1) +$ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,- + gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr +$ ABORT +0*f$verify(v) !'f$verify(0)' +$ +$! not reached +$ exit diff --git a/libiberty/vprintf.c b/libiberty/vprintf.c new file mode 100644 index 000000000000..89c289eb1056 --- /dev/null +++ b/libiberty/vprintf.c @@ -0,0 +1,15 @@ +#include +#ifdef __STDC__ +#include +#else +#include +#endif +#include +#undef vprintf +int +vprintf (format, ap) + const char *format; + va_list ap; +{ + return vfprintf (stdout, format, ap); +} diff --git a/libiberty/vsprintf.c b/libiberty/vsprintf.c new file mode 100644 index 000000000000..bf0760cf6d38 --- /dev/null +++ b/libiberty/vsprintf.c @@ -0,0 +1,55 @@ +/* Simple implementation of vsprintf for systems without it. + Highly system-dependent, but should work on most "traditional" + implementations of stdio; newer ones should already have vsprintf. + Written by Per Bothner of Cygnus Support. + Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu). + Copyright (C) 1991, 1995 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. */ + +#include +#include +#include +#undef vsprintf + +int +vsprintf (buf, format, ap) + char *buf; + const char *format; + va_list ap; +{ + FILE b; + int ret; +#ifdef VMS + b->_flag = _IOWRT|_IOSTRG; + b->_ptr = buf; + b->_cnt = 12000; +#else + b._flag = _IOWRT|_IOSTRG; + b._ptr = buf; + b._cnt = 12000; +#endif + ret = _doprnt(format, ap, &b); + putc('\0', &b); + return ret; + +} diff --git a/libiberty/waitpid.c b/libiberty/waitpid.c new file mode 100644 index 000000000000..23db0b932d2e --- /dev/null +++ b/libiberty/waitpid.c @@ -0,0 +1,11 @@ +int +waitpid (pid, stat_loc, options) + int pid, *stat_loc, options; +{ + for (;;) + { + int wpid = wait(stat_loc); + if (wpid == pid || wpid == -1) + return wpid; + } +} diff --git a/libiberty/xatexit.c b/libiberty/xatexit.c new file mode 100644 index 000000000000..31476c29ddca --- /dev/null +++ b/libiberty/xatexit.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * %sccs.include.redist.c% + */ + +/* Adapted from newlib/libc/stdlib/{,at}exit.[ch]. + If you use xatexit, you must call xexit instead of exit. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#include + +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +/* For systems with larger pointers than ints, this must be declared. */ +PTR malloc PARAMS ((size_t)); + +static void xatexit_cleanup PARAMS ((void)); + +/* Pointer to function run by xexit. */ +extern void (*_xexit_cleanup) PARAMS ((void)); + +#define XATEXIT_SIZE 32 + +struct xatexit { + struct xatexit *next; /* next in list */ + int ind; /* next index in this table */ + void (*fns[XATEXIT_SIZE]) PARAMS ((void)); /* the table itself */ +}; + +/* Allocate one struct statically to guarantee that we can register + at least a few handlers. */ +static struct xatexit xatexit_first; + +/* Points to head of LIFO stack. */ +static struct xatexit *xatexit_head = &xatexit_first; + +/* Register function FN to be run by xexit. + Return 0 if successful, -1 if not. */ + +int +xatexit (fn) + void (*fn) PARAMS ((void)); +{ + register struct xatexit *p; + + /* Tell xexit to call xatexit_cleanup. */ + if (!_xexit_cleanup) + _xexit_cleanup = xatexit_cleanup; + + p = xatexit_head; + if (p->ind >= XATEXIT_SIZE) + { + if ((p = (struct xatexit *) malloc (sizeof *p)) == NULL) + return -1; + p->ind = 0; + p->next = xatexit_head; + xatexit_head = p; + } + p->fns[p->ind++] = fn; + return 0; +} + +/* Call any cleanup functions. */ + +static void +xatexit_cleanup () +{ + register struct xatexit *p; + register int n; + + for (p = xatexit_head; p; p = p->next) + for (n = p->ind; --n >= 0;) + (*p->fns[n]) (); +} diff --git a/libiberty/xexit.c b/libiberty/xexit.c new file mode 100644 index 000000000000..431bbe02991a --- /dev/null +++ b/libiberty/xexit.c @@ -0,0 +1,36 @@ +/* xexit.c -- Run any exit handlers, then exit. + Copyright (C) 1994, 95, 1997 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If not, write +to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#include + +/* This variable is set by xatexit if it is called. This way, xmalloc + doesn't drag xatexit into the link. */ +void (*_xexit_cleanup) PARAMS ((void)); + +void +xexit (code) + int code; +{ + if (_xexit_cleanup != NULL) + (*_xexit_cleanup) (); + exit (code); +} diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c new file mode 100644 index 000000000000..c479b1f9e957 --- /dev/null +++ b/libiberty/xmalloc.c @@ -0,0 +1,113 @@ +/* memory allocation routines with error checking. + Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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 of the License, or (at your option) any later version. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#include + +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#define ptrdiff_t long +#endif + +#if VMS +#include +#include +#else +/* For systems with larger pointers than ints, these must be declared. */ +PTR malloc PARAMS ((size_t)); +PTR realloc PARAMS ((PTR, size_t)); +PTR sbrk PARAMS ((ptrdiff_t)); +#endif + +/* The program name if set. */ +static const char *name = ""; + +/* The initial sbrk, set when the program name is set. */ +static char *first_break = NULL; + +void +xmalloc_set_program_name (s) + const char *s; +{ + name = s; + if (first_break == NULL) + first_break = (char *) sbrk (0); +} + +PTR +xmalloc (size) + size_t size; +{ + PTR newmem; + + if (size == 0) + size = 1; + newmem = malloc (size); + if (!newmem) + { + extern char **environ; + size_t allocated; + + if (first_break != NULL) + allocated = (char *) sbrk (0) - first_break; + else + allocated = (char *) sbrk (0) - (char *) &environ; + fprintf (stderr, + "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n", + name, *name ? ": " : "", + (unsigned long) size, (unsigned long) allocated); + xexit (1); + } + return (newmem); +} + +PTR +xrealloc (oldmem, size) + PTR oldmem; + size_t size; +{ + PTR newmem; + + if (size == 0) + size = 1; + if (!oldmem) + newmem = malloc (size); + else + newmem = realloc (oldmem, size); + if (!newmem) + { + extern char **environ; + size_t allocated; + + if (first_break != NULL) + allocated = (char *) sbrk (0) - first_break; + else + allocated = (char *) sbrk (0) - (char *) &environ; + fprintf (stderr, + "\n%s%sCan not reallocate %lu bytes after allocating %lu bytes\n", + name, *name ? ": " : "", + (unsigned long) size, (unsigned long) allocated); + xexit (1); + } + return (newmem); +} diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c new file mode 100644 index 000000000000..9d08bc704055 --- /dev/null +++ b/libiberty/xstrdup.c @@ -0,0 +1,17 @@ +/* xstrdup.c -- Duplicate a string in memory, using xmalloc. + This trivial function is in the public domain. + Ian Lance Taylor, Cygnus Support, December 1995. */ + +#include "ansidecl.h" +#include "libiberty.h" + +char * +xstrdup (s) + const char *s; +{ + char *ret; + + ret = xmalloc (strlen (s) + 1); + strcpy (ret, s); + return ret; +} diff --git a/libiberty/xstrerror.c b/libiberty/xstrerror.c new file mode 100644 index 000000000000..770b653ba800 --- /dev/null +++ b/libiberty/xstrerror.c @@ -0,0 +1,56 @@ +/* xstrerror.c -- jacket routine for more robust strerror() usage. + Fri Jun 16 18:30:00 1995 Pat Rankin + This code is in the public domain. */ + +#include + +#include "libiberty.h" +#include "config.h" + +#ifdef VMS +#include +#if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES) +extern char *strerror PARAMS ((int,...)); +#define DONT_DECLARE_STRERROR +#endif +#endif /* VMS */ + +#ifndef DONT_DECLARE_STRERROR +extern char *strerror PARAMS ((int)); +#endif + +/* If strerror returns NULL, we'll format the number into a static buffer. */ + +#define ERRSTR_FMT "undocumented error #%d" +static char xstrerror_buf[sizeof ERRSTR_FMT + 20]; + +/* Like strerror, but result is never a null pointer. */ + +char * +xstrerror (errnum) + int errnum; +{ + char *errstr; +#ifdef VMS + char *(*vmslib_strerror) PARAMS ((int,...)); + + /* Override any possibly-conflicting declaration from system header. */ + vmslib_strerror = (char *(*) PARAMS ((int,...))) strerror; + /* Second argument matters iff first is EVMSERR, but it's simpler to + pass it unconditionally. `vaxc$errno' is declared in + and maintained by the run-time library in parallel to `errno'. + We assume that `errnum' corresponds to the last value assigned to + errno by the run-time library, hence vaxc$errno will be relevant. */ + errstr = (*vmslib_strerror) (errnum, vaxc$errno); +#else + errstr = strerror (errnum); +#endif + + /* If `errnum' is out of range, result might be NULL. We'll fix that. */ + if (!errstr) + { + sprintf (xstrerror_buf, ERRSTR_FMT, errnum); + errstr = xstrerror_buf; + } + return errstr; +} diff --git a/libio/ChangeLog b/libio/ChangeLog new file mode 100644 index 000000000000..de8f618cabf1 --- /dev/null +++ b/libio/ChangeLog @@ -0,0 +1,1940 @@ +Wed Aug 20 02:01:34 1997 Jason Merrill + + * iostream.h: Add copy assignment ops for _IO_?stream_withassign. + +Tue Jul 22 10:31:41 1997 Brendan Kehoe + + * config.shared (CHECK_SUBDIRS): Use install-sh, not install.sh. + +Wed Jun 25 12:20:55 1997 Brendan Kehoe + + * config.shared (DOING_GPERF): Look for this, defining TOLIBGXX + and LIBS for it. + +Wed Jun 18 11:03:34 1997 Bob Manson + + * config.shared (FLAGS_TO_PASS): Don't include RUNTEST. + +Tue Jun 17 22:23:48 1997 Bob Manson + + * config.shared (FLAGS_TO_PASS): Pass RUNTEST and RUNTESTFLAGS. + +Fri May 16 21:08:53 1997 Bob Manson + + * iovfprintf.c: Declare __cvt_double before use. + + * floatconv.c (d2b): Use _G_int32_t instead of int for the + e and bits parameters. + (_IO_strtod): Use _G_int32_t. + + * gen-params: Look for NO_USE_DTOA and USE_INT32_FLAGS. + + * strops.c (_IO_str_init_static): use _G_int32_t appropriately. + + * libio.h: If _G_NO_USE_DTOA is set, then don't define + _IO_USE_DTOA. + + * config/mn10200.mt: Don't use dtoa, it only works + for "real" doubles. + +Thu May 15 17:44:12 1997 Bob Manson + + * configure.in: Set CHECK_SUBDIRS to testsuite if we're doing + a cross compile. + + * config.shared(check): Only run make check in the directories + specified by CHECK_SUBDIRS. Set CHECK_SUBDIRS to SUBDIRS + if it has no previous value. + +Thu May 1 17:35:19 1997 Jason Merrill + + * Makefile.in (test, tpipe): Add $(CFLAGS). + +Wed Apr 30 12:16:29 1997 Jason Merrill + + * configure.in: Don't turn on multilib here. + +Sat Apr 26 13:38:21 1997 Bob Manson + + * configure.in (configdirs): Add testsuite directory. + + * testsuite/ChangeLog: + * testsuite/Makefile.in: + * testsuite/libio.tests/tiomanip.exp: + * testsuite/libio.tests/tstdiomisc.exp: + * testsuite/libio.tests/tiomisc.exp: + * testsuite/libio.tests/tFile.exp: + * testsuite/libio.tests/tfformat.exp: + * testsuite/libio.tests/tiformat.exp: + * testsuite/libio.tests/hounddog.exp: + * testsuite/libio.tests/putbackdog.exp: + * testsuite/configure.in: + * testsuite/lib/libio.exp: + * testsuite/config/default.exp: + New files for DejaGnu-style testsuite. + +Fri Apr 4 03:16:44 1997 Ulrich Drepper + + * configure.in: Enable multilibing by default. + Update multilib template to read config-ml.in. + + * floatconv.c: Enable use in cross targets which use the + newlib ieeefp.h header. + +Thu Jan 23 09:16:16 1997 Brendan Kehoe + + * libioP.h (_IO_file_attach): Delete redundant decl. + +Tue Jan 21 22:13:45 1997 Brendan Kehoe + + * streambuf.h (class ios): Take out STREAMSIZE member, since we + only need (and should only have) the global one. + +Tue Jan 7 14:02:40 1997 Jason Merrill + + * iostream.h (long long fns): Use __extension__. + + * gen-params: Use _G_llong and _G_ullong instead of long long for + deduced types. + +Fri Dec 6 13:13:30 1996 Jason Merrill + + * dbz/dbz.c: Use off_t. + +Sat Nov 23 15:44:37 1996 Jason Merrill + + * Makefile.in (install): Don't install _G_config.h with other headers. + +Mon Nov 18 17:12:41 1996 Jason Merrill + + * config.shared (SUBDIRS): Use -O instead of -O3 for debugging. + +Sun Nov 3 12:43:34 1996 Jason Merrill + + * iostream.cc (write_int): Treat string literals as const. + +Thu Sep 26 10:09:18 1996 Michael Meissner + + * depend: Regenerate. + +Wed Sep 25 22:54:45 1996 Jason Merrill + + * config.shared (depend.new): Deal with headers that don't end in .h. + +Thu Aug 29 17:05:53 1996 Michael Meissner + + * configure.in (i[345]86-*-*): Recognize i686 for pentium pro. + +Mon Aug 5 01:26:32 1996 Jason Merrill + + * config{ure.in,.shared} (DISTCLEAN): Add multilib.out. + +Fri Aug 2 17:39:35 1996 Jason Merrill + + * libio.h (NULL): Use __null. + * libioP.h (NULL): Ditto. + * streambuf.h (NULL): Ditto. + * ioextend.cc (get_array_element): Use NULL instead of (void*)0. + +Fri Jul 5 18:26:41 1996 Jim Wilson + + * strfile.h (struct _IO_streambuf): New struct type. + (struct _IO_strfile): Use it. + +Tue Jun 18 18:24:21 1996 Jason Merrill + + * fstream.h (fstreambase): Make __my_fb mutable. + From Joe Buck. + +Tue Jun 18 11:03:53 1996 Brendan Kehoe + + * dbz/fake.c (main): Set return type to int. + * dbz/dbzmain.c (main): Likewise. + * dbz/byteflip.c (main): Likewise. + +Mon Jun 17 14:05:36 1996 Jason Merrill + + * gen-params: Check if clog conflicts with system libraries. + * stdstreams.cc: If it does, use __IO_clog. + * iostream.h: Likewise. + +Tue Jun 11 13:39:31 1996 Brendan Kehoe + + * stdiostream.h (istdiostream (FILE*)): Put istream base + initializer before init for __f. + (ostdiostream (FILE*)): Likewise for ostream base init. + +Tue May 14 11:47:21 1996 Per Bothner + + * strfile.h (_IO_str_fields): Removed _len field. + (_IO_STR_DYNAMIC, _IO_STR_FROZEN): new macros. + * strstream.h (strstreambuf::is_static): Removed. + (strstreambuf::frozen): Use _IO_STR_DYNAMIC instead of is_static. + * strstream.h, strstream.cc: Remove support for !_IO_NEW_STREAMS. + * strstream.cc (strstreambuf::init_dynamic): Don't set _s._len. + * strops.c (_IO_str_init_static): Better handling of the + negative (== unbounded) size case. + (_IO_str_overflow, _IO_str_underflow, _IO_str_count): Re-write + to not use _s._len, and otherwise cleanup/fix. + * strstream.h, strstream.cc (strstreambase::strstreambase()): Call + ios::init here. + (other constructors): Simplify - init already called. + +Tue May 14 10:55:21 1996 Per Bothner + + Change so that strstreambuf default constructor does no allocation. + * strstream.h (strstreambuf::init_dynamic): Default initial size = 0. + * strstream.cc (strstreambuf::init_dynamic): Don't allocate a + buffer (yet) if initial_size is 0. + * strops.c (_IO_str_overflow): Add 100 to size of re-allocated + buffer, to handle case when initial size is 0. + + * iostdio.h (remove, rename, tmpfile, tempnam): Comment out. + +Mon May 13 23:19:39 1996 Per Bothner + + * fileops.c (_IO_file_close_it): Just call _IO_do_flush rather + than _IO_file_sync, to avoid useless lseek. + +Tue May 14 10:48:48 1996 Jason Merrill + + * floatconv.c (_IO_strtod): Force rv into the stack. + + * config.shared (gxx_includedir): Now $(includedir)/g++. + +Sat Apr 27 02:37:49 1996 Jason Merrill + + * libioP.h (JUMP*): Implement for thunks. + (_IO_jump_t): Add second dummy field for thunks. + +Thu Apr 25 13:20:00 1996 Jason Merrill + + * config.shared (CXX): Use gcc, not g++. + +Wed Apr 24 10:29:50 1996 Doug Evans + + * config.shared (depend.new): Delete $(srcdir)/ from foo.{c,cc} + for SunOS VPATH. + * depend: Regenerated. + +Fri Apr 19 17:24:51 1996 Jason Merrill + + * Version 2.8.0b3. + +Wed Apr 10 17:16:01 1996 Jason Merrill + + * configure.in (ALL): Don't build iostream.a. + +Mon Apr 8 14:44:11 1996 Per Bothner + + * iosetvbuf.c (_IO_setvbuf): Clear _IO_UNBUFFERED unless _IONBF. + +Mon Apr 8 15:08:23 1996 Ian Lance Taylor + + * configure.in: Permit --enable-shared to specify a list of + directories. + +Fri Apr 5 17:48:56 1996 Per Bothner + + * config.shared (MOSTLYCLEAN): Also remove ${EXTRA_MOSTLYCLEAN}. + +Fri Mar 22 23:25:00 1996 Ulrich Drepper + + * genops.c (_IO_sputbackc, _IO_sungetc): Clear EOF flag if putsh + back was successful. + +Wed Mar 27 11:54:08 1996 Jason Merrill + + * Version 2.8.0b2. + +Fri Mar 22 15:39:36 1996 Per Bothner + + * fileops.c (_IO_do_write): Revert previous fix. (It fails to + handle the case that fp->_IO_read_end != fp->_IO_write_base.) + (_IO_file_overflow): Instead, if _IO_read_ptr is at the end of + the buffer, reset all the read pointers to _IO_buf_base. + +Tue Mar 12 12:03:17 1996 Per Bothner + + * fileops.c (_IO_do_write): Even if to_do==0, must re-set buffer + pointers. Bug and solution from Luke Blanshard . + +Wed Feb 28 10:00:24 1996 Jason Merrill + + * Version 2.8.0b1. + +Tue Feb 27 18:08:16 1996 Per Bothner + + * iopopen.c (_IO_proc_open): Use (char*)0 rather than imprecise NULL. + + * streambuf.h (ios): Add ios::binary; deprecate ios::bin. + * filebuf.cc (filebuf::open): Handle ios::binary. + +Fri Feb 9 12:40:19 1996 Brendan Kehoe + + * cleanup.c (_IO_cleanup_registration_needed) [!_G_HAVE_ATEXIT]: Init + to NULL. + * filedoalloc.c (_IO_cleanup_registration_needed): Remove decl. + +Thu Feb 8 08:12:50 1996 Brendan Kehoe + + * filedoalloc.c (_IO_cleanup_registration_needed): Revert previous + change, since cleanup.c only defines it if _G_HAVE_ATEXIT. + +Wed Feb 7 15:10:17 1996 Brendan Kehoe + + * filedoalloc.c (_IO_cleanup_registration_needed): Declare as extern. + +Tue Dec 12 17:21:13 1995 Per Bothner + + * indstream.h, instream.cc (indirectbuf::uflow): New method. + * indstream.cc (indirectbuf::underflow): Fix to use sgetc, not sbumpc. + Fixes bug reported by Kevin Beyer . + + * indstream.cc (indirectbuf::seekpos): Add paranoia test. + +Fri Dec 8 14:55:34 1995 Per Bothner + + * stream.h: Add warning to not use these functions. + * stream.cc (str, chr): Re-implement here (from libg++). + +Tue Nov 28 15:07:01 1995 Per Bothner + + * config.shared: Use test instead of [ to avoid DEC Unix lossage. + +Thu Nov 23 14:51:43 1995 Per Bothner + + * iopopen.c: Move #include ahead of #include + to deal with BSDI's literal implementation of Posix. + +Sat Nov 25 11:21:55 1995 Doug Evans + + * Makefile.in (install): Set rootme. + * config.shared (TOPDIR): Set with ${foo-...} rather than ${foo=...}. + (INSTALL): Handle absolute, dot, relative-not-dot values of srcdir. + (TEXIDIR): Likewise. + +Tue Nov 21 14:12:05 1995 Ian Lance Taylor + + * configure.in: Check ${with_cross_host} rather than comparing + ${host} and ${target}. + +Mon Nov 20 13:55:29 1995 Brendan Kehoe + + * configure.in: Match *-sco3.2v[45]*. + +Wed Nov 15 20:19:31 1995 Brendan Kehoe + + * config.shared (FLAGS_TO_PASS): Also pass SHLIB and SHCURSES. + +Tue Nov 14 01:41:08 1995 Doug Evans + + * config.shared (TO_REAL_TOPDIR): Define. + (MULTITOP): Deleted. + (MULTISRCTOP, MULTIBUILDTOP): New. + (TOPDIR): Change MULTITOP to MULTIBUILDTOP, and use TO_REAL_TOPDIR. + (INSTALL): Add with_multisrctop, TO_REAL_TOPDIR. + (TEXIDIR): Use TO_REAL_TOPDIR. + (LIBS): Delete MULTITOP. + (FLAGS_TO_PASS): Add NM. + (CXXINCLUDES): Delete MULTITOP. + (depend.new): Delete adding MULTITOP to ../ build tree references. + Add MULTISRCTOP to ../ source tree references. + * configure.in: Delete call to cfg-ml-com.in. Call config-ml.in + instead of cfg-ml-pos.in. + +Sun Nov 12 16:30:48 1995 Per Bothner + + * Makefile.in (VERSION): Set to 2.7.1. + * configure.in: Add warning for Linux. + * config.shared (DISTCLEAN): Add EXTRA_DISTCLEAN. + + * editbuf.h (edit_mark::index_in_buffer): Avoid unused param warning. + + * iostream.cc (istream::operator>> (char*)): Improve ANSI compliance. + +Fri Nov 10 08:41:37 1995 Brendan Kehoe + + * config.shared (check): Add missing semicolon. + +Thu Nov 9 17:27:22 1995 Jason Merrill + + * configure.in (ALL): Remove $(OSPRIM_OBJECTS). + * config.shared (check): Set LD_LIBRARY_PATH. + * NEWS: Fix typo. + * iogetdelim.c (_IO_getdelim): Index *lineptr, rather than lineptr. + From alan@spri.levels.unisa.edu.au (Alan Modra). + +Mon Nov 6 15:03:33 1995 Per Bothner + + * streambuf.cc, editbuf.cc, isgetline.cc, parsestream.cc: + Fixes to avoid -Wall warnings. + +Fri Nov 3 16:41:41 1995 Brendan Kehoe + + * gen-params [!__STDC__]: Include varargs.h instead of stdarg.h. + +Thu Nov 2 15:04:03 1995 Per Bothner + + * config.shared: Re-write if X then Y else true fi to (not X) || Y. + +Wed Nov 1 13:26:44 1995 Per Bothner + + * iostream.h (istream::ipfx): Add default argument value. + Reported by Yotam Medini . + + * libioP.h (_IO_blen): Fix typo. + Reported by Bryan T. Vold . + +Fri Oct 27 19:26:20 1995 Per Bothner + + * Makefile.in (_G_config.h): Set CC to $(CC) rather than to $(CXX), + now that CXX defaults to g++ and CC default to gcc (when found). + * config.shared: Simplify CXX and CC, since they get overridden + by ../configure anyway. + +Wed Oct 25 19:45:50 1995 Brendan Kehoe + + * iostdio.h: Wrap including the file with #ifndef _IOSTDIO_H. + +Wed Oct 25 11:14:25 1995 Per Bothner + + * libio.h (_IO_seekoff, _IO_seekpos): New declarations. + * libioP.h (_IO_seekoff, _IO_seekpos): Remove declarations. + * libioP.h: Cleanup; remove old !_IO_UNIFIED_JUMPTABLES stuff. + + * filebuf.cc (filebuf::~filebuf): Only call SYSYCLOSE if currently + open. Bug found by Martin Gerbershagen . + + * streambuf.h (streambuf::pubseekoff, streambuf::pubseekpos): + Added, from ANSI draft. + * filebuf.cc (filebuf::open), iostream.cc (variables places), SFile.cc: + Use pubseekoff/pubseekpos rather than sseekoff/sseekpos. + + * Makefile.in (install): Don't install libiostream.a. + + * filedoalloc.c: Also #include . + +Mon Oct 9 18:09:54 1995 Jason Molenda + + * config.shared (SUFFIXES): add .c. + +Tue Sep 26 16:08:01 1995 Per Bothner + + * procbuf.cc: Move #pragma implementation to beginning. + +Wed Sep 20 17:53:33 1995 Per Bothner + + * procbuf.h, procbuf.cc: Add #pragma interface/implementation stuff. + +Wed Sep 20 18:59:00 1995 John Eaton + + * procbuf.h: Protect from being included multiple times. + +Wed Sep 20 15:47:14 1995 John Eaton + + * procbuf.h (procbuf): Add '_next' pointer field for compatibility + with _IO_proc_file. + +Wed Sep 20 13:54:02 1995 Ian Lance Taylor + + * config.shared: Add support for maintainer-clean target as a + synonym for realclean. + * dbz/Makefile.in: Likewise. + +Mon Sep 11 12:11:19 1995 Per Bothner + + * iopopen.c: #include before . + This is in accordance with Posix, and needed for ISC. + +Fri Sep 8 00:11:55 1995 Brendan Kehoe + + * gen-params: Use double quotes in the eval setting $TYPE to + $VALUE, to preserve any single quotes in $VALUE. + +Mon Aug 21 11:39:09 1995 Jason Merrill + + * gen-params: Test for an appropriate version of gcc before using + mode attributes. + + * config.shared: Add $(PICDIR) to $ALL. + +Mon Aug 7 17:51:40 1995 Per Bothner + + * gen-params: Generate new macro _G_HAVE_SYS_CDEFS. + * libio.h: If _G_HAVE_SYS_CDEFS, get __P from . + +Fri Aug 4 23:21:17 1995 Paul Eggert + + * gen-params: When following typedef changes, allow typedefs + that do not have a space before the defined type name, + e.g. `typedef void *__gnuc_va_list;' as in Linux. Also, + not require a space in the definiens, e.g. `typedef void*foo;'. + +Thu Aug 3 17:54:15 1995 Per Bothner + + * iostream.h, iostream.cc (istream::sync): Added missing method. + +Thu Aug 3 17:49:34 1995 Per Bothner + + * configure.in: Remove netbsd special case. + * config/netbsd.mt: Removed; no longer used. + +Tue Jun 20 16:07:12 1995 Paul Eggert + + * gen-params: Take transitive closure of `typedef' relation. + This is needed for BSD/OS 2.0, which has + fpos_t -> off_t -> quad_t -> long long. + +Mon Jul 24 18:28:10 1995 Doug Evans + + * config.shared (TOPDIR): Delete extra '/', $rootme may be empty. + +Sat Jul 22 13:27:45 1995 Doug Evans + + * config.shared (depend.new): Fix quoting in DO NOT EDIT line. + + * Makefile.in (_G_config.h): Add multilib support. + (install): Likewise. + * config.shared: Likewise. + * configure.in: Likewise. + +Wed Jun 28 17:40:25 1995 Jason Merrill + + * PlotFile.h, SFile.h, builtinbuf.h, editbuf.h, fstream.h, + indstream.h, iomanip.h, iostream.h, parsestream.h, pfstream.h, + procbuf.h, stdiostream.h, stream.h, streambuf.h, strstream.h: Wrap + with extern "C++". + +Thu Jun 22 04:34:01 1995 Jason Merrill + + * gen-params: Surround attributes with __. + +Mon Jun 19 00:33:22 1995 Jason Merrill + + * config.shared (SUBDIRS): Massage broken shells that require + 'else true'. + +Sat Jun 17 11:25:38 1995 Jason Merrill + + * streambuf.h: Declare inline members inline in class. + +Thu Jun 15 20:45:13 1995 Per Bothner + + * Makefile.in (VERSION): Update to version 2.7.0. + +Wed Jun 14 21:41:11 1995 Jason Merrill + + * Makefile.in (STDIO_WRAP_OBJECTS): Remove stdfiles.o. + (LIBIO_OBJECTS): Add stdfiles.o. + +Wed Jun 7 16:11:36 1995 Jason Merrill + + * config.shared (all): Appease bash. + +Wed Jun 7 11:16:38 1995 Jason Merrill + + * configure.in (MOSTLYCLEAN): Remove stamp-picdir. + + * config.shared (MOSTLYCLEAN): Ditto. + (CLEAN): Don't. + +Mon Jun 5 18:29:39 1995 Jason Merrill + + * config/mh-*pic: Removed. + + * configure.in (MOSTLYCLEAN): Remove pic objects. + (frags): Use toplevel pic fragments. + + * config.shared (CXXFLAGS): Use -O3. + (PICFLAG, PICDIR): New macros. + (all): Depend on $(PICDIR). + (FLAGS_TO_PASS): Pass PICFLAG. + (.x.o): Also build pic object. + (stamp-picdir): Create directory for pic objects. + (MOSTLYCLEAN): Remove pic objects. + (CLEAN): Remove stamp-picdir. + + * Makefile.in (iostream.list): Depend on stamp-picdir. + (c++clean): Don't remove _G_config.h. + +Mon Jun 5 15:03:47 1995 Per Bothner + + * strstream.h, strstream.cc (strstream::strstream()): Re-implement to + be like ostrstream::ostrestream(), and not leak memory. + + * streambuf.h: Use #if !_IO_UNIFIED_JUMPTABLES instead of #ifndef. + + * iolibio.h (_IO_rewind): Add missing flags when calling _IO_seekoff. + +Thu May 25 22:30:21 1995 J.T. Conklin + + * config/netbsd.mt (G_CONFIG_ARGS): Add defn for off_t. Another + layer of typedefs has been added and the gen-params script can + not handle it. + +Wed May 10 03:02:58 1995 Jason Merrill + + * iolibio.h (_IO_rewind): Add new argument to _IO_seekoff. + + * config/linux.mt (LIBIOSTREAM_OBJECTS): Include $(STDIO_WRAP_OBJECTS). + (LIBIOSTREAM_DEP): Include stdio.list. + (LIBIOSTREAM_USE): Include `cat stdio.list`. + + * Makefile.in (LIBIOSTREAM_DEP): New variable. + (LIBIOSTREAM_USE): Ditto. + (libiostream.a): Use them. + (iostream.list): Ditto. + (stdio.list): New rule. + (stdio/stdio.list): Ditto. + +Tue May 9 18:29:38 1995 Jason Merrill + + * libioP.h (_IO_jump_t): Change TYPE for __dummy from int to + _G_size_t. + +Sat May 6 13:50:37 1995 Per Bothner + + * libio.h (_IO_UNIFIED_JUMPTABLES): #define as true. + (_IO_FILE): Remove _jumps field (#if _IO_UNIFIED_JUMPTABLES). + + * libioP.h (enum _IO_seekflags_): Removed. + + * libioP.h (_IO_setbuf_t): Change return value of setpos jumptable + function to match C++ streambuf::setpos. (Return NULL on failure.) + * fileops.c (_IO_file_setbuf), genops.c (_IO_default_setbuf), + filebuf.cc, iosetvbuf.c: Update to use new setbuf conventions. + + * streambuf.h (streambuf): Re-order virtual functions more logically. + * streambuf.cc (streambuf::uflow), streambuf.h: New virtual. + * libioP.h (struct _IO_jump_t): Define using new JUMP_FIELD macro. + And re-order in more logical order consistent with streambuf vtable. + * fileops.c (_IO_file_jumps), iopopen.c (_IO_proc_jumps), iovfprintf.c + (_IO_helper_jumps), streambuf.cc (_IO_streambuf_jumps), strops.c + (_IO_str_jumps): Update accordingly, using JUMP_INIT macro. + * stdfiles.c: Set vtable to point to _IO_file_jumps. + * filebuf.cc, iopopen.c, iovfprintf.c (helper_vfprintf), iovsprintf.c, + iovsscanf.c: Use macros and #if to set jumptables. + + * streambuf.c: _IO_streambuf_jumps and the _IO_sb_* methods are not + needed #if _IO_UNIFIED_JUMPTABLES. + * filebuf.cc (filebuf::__new): Also no longer needed. + * fstream.cc (fstreambase::__fb_init, fstreambase::fstreambase): Fix. + * stdstrbufs.c: Use filebuf vtable instead of builtinbuf's. + * builtinbuf.h, builtinbuf.cc (builtinbuf): Commented out #if + _IO_UNIFIED_JUMPTABLES - no longer needed. + * strstream.cc (SET_STR_JUMPS): Does nothing now. + + * builtinbuf.cc, fileops.c, genops.c, iofgetpos.c, iofsetpos.c, + ioftell.c, iopopen.c, ioseekoff.c, ioseekpos.c, iosetvbuf.c, + iovfprintf.c, iovfscanf.c, strops.c: Use DEFUN and DEFUN_VOID. + * filebuf.cc, fileops.c, genops.c, iopopen.c, ioseekoff.c, ioseekpos.c, + iosetvbuf.c, iovfscanf.c: Use new JUMP_* and IO_OVERFLOW/... macros. + + * libioP.h (_IO_seekpos_t): Third arg is now an int (using _IOS_INPUT + and _IOS_OUTPUT), not an enum _IO_seekflags_. Flags values are + changed, and their sense inverted (to match streambuf::seekpos). + * libioP.h (_IO_seekoff_t): Similarly match streambuf::seekoff. + * filebuf.cc, fileops.c (_IO_file_fopen, _IO_file_seekoff), genops.c + (_IO_default_seekpos, _IO_default_seekpos), iofgetpos.c, iofsetpos.c, + iolibio.h (_IO_fseek), ioftell.c, ioseekoff.c, ioseekpos.c, + iostream.cc, streambuf.cc, strops.c (_IO_str_seekoff), strstream.cc: + New seekpos/seekoff conventions. + * iostreamP.h (convert_to_seekflags): Removed - no longer needed. + + * iolibio.h (_IO_fread): New declaration. + + * dbz/Makefile.in: Re-arrange for cleaner dependencies. + +Fri May 5 15:55:22 1995 Per Bothner + + * libioP.h (_IO_JUMPS. JUMP_FIELD, JUMP0, JUMP1, JUMP2, JUMP3, + JUMP_INIT, _IO_FINISH, _IO_OVERFLOW, ... _IO_SYSSTAT): New macros + in preparation for new unified jumptable/vtable implementation. + * cleanup.c, filedoalloc.c, iofclose.c, iofflush.c, iofiledoalloc.c, + ioprims.c, iosetbuffer.c, iostrerror.c, ioungetc.c: Use DEFUN. + * filedoalloc.c, iofclose, iofflush, iosetbuffer.c: Use new macros. + + * iofopen.c, iofdopen.c: Use macros and #if for new jumptables. + + * gen-params: Do not #include . + Add missing quote in 'eval'. + Do add #include in test for . + * config/netbsd.mt: New file, defining _G_CONFIG_ARGS (for fpos_t). + * configure.in: Use netbsd.mt for NetBSD. + +Wed May 3 15:03:47 1995 Per Bothner + + * libioP.h (DEFUN, DEFUN_VOID, AND): New macros, from ansidecl.h. + * iofdopen.c, iofgets.c, iofopen.c, iofputs.c, iofread.c, iofwrite.c, + iogetdelim.c, iogetline.c, iogets.c, ioignore.c, iopadn.c, ioperror.c, + ioputs.c, iovsprintf.c, iovsscanf.c, outfloat.c: Use DEFUN. + +Mon May 1 16:22:30 1995 Jason Merrill + + * gen-params: #include . Don't use __WCHAR_TYPE__ in + definition of _G_wchar_t. Use __attribute__ ((mode)) to get + specific-sized ints under gcc, don't worry about int8 or int64 + otherwise. Provide defaults if deduction fails. + +Thu Apr 27 18:27:53 1995 Per Bothner + + * streambuf.h (ios::~ios): Delete _arrays. + (_IO_NEW_STREAMS): Turn on. + * libio.h (__adjust_column): Remove bogus declaration. + * genops.c (_IO_set_column): Fix typo (in commented-out code). + +Tue Apr 25 17:14:29 1995 Jason Merrill + + * config.shared (CXXINCLUDES): Use a shell variable with a + different name from the make variable. + * configure.in: Update accordingly. + +Mon Apr 17 17:19:40 1995 Per Bothner + + * streambuf.h (__adjust_column): Remove redundant declaration. + +Sat Apr 15 11:39:25 1995 Per Bothner + + * config.shared (do-clean-dvi): Also remove *.cps. + + * gen-params: Use ${SED} instead of sed. + + * libio.h: Remove #if'd out stuff (confuses makedepend). + + * stdstreams.cc (STD_STR): Standard streams start with ios::dec set. + +Fri Apr 14 23:46:31 1995 Per Bothner + + * iostream.h, iostream.cc (istream::read, ostream::write): + Use streamsize for the length parameter. + + * streambuf.h: Removed redundant __overflow and __underflow. + + * fstream.h, fstream.cc: Add void fstreambase::attach(int). + + * iosscanf.c (_IO_sscanf): Fix non-__STDC__ missing declaration. + +Mon Apr 3 15:40:55 1995 Jason Merrill + + * indstream.*: Fix prototypes of xsputn and xsgetn. + + * fileops.c: Avoid ??? trigraph. + +Mon Mar 27 16:16:38 1995 Jason Merrill + + * iomanip.h (operator<< (ostream&, const omanip&): Define + separately. + (operator>> (istream&, const imanip&): Ditto. + +Mon Mar 27 08:56:00 1995 Brendan Kehoe (brendan@lisa.cygnus.com) + + * builtinbuf.cc (builtinbuf::setbuf): Cast NULL to streambuf*, to + avoid warning/error about conversion from void*. + * indstream.cc (indirectbuf::seekoff): Likewise. + (indirectbuf::seekpos): Likewise. + * filebuf.cc (filebuf::setbuf): Likewise. + (filebuf::close): Cast NULL to filebuf*. + +Wed Mar 1 14:23:18 1995 Per Bothner + + * configure.in (DISTCLEAN): Add, with target-mkfrag. + +Fri Feb 24 01:01:08 1995 Jason Merrill + + * configure.in (frags): Don't require so many dashes in the + canonical target name. + +Sat Feb 18 13:18:30 1995 Per Bothner + + * streambuf.cc (streambuf::sync): Always return 0, even for + non-flushed output. This is required by the ANSI/ISO draft. + * genops.c (_IO_sync): Likewise always return 0. + +Fri Feb 17 16:33:28 1995 Per Bothner + + * fileops.c (_IO_file_close_it): Call _IO_file_sync, rather + than _IO_do_flush, because we want to adjust the file pointer + if reading and not at end (as in SVR4, and as in fflush). + Also, make sure to return error indication if sync fails. + (_IO_file_sync): Ignore seek error if it is ESPIPE. + (_IO_file_seekoff): If not readable, do dumb lseek. + * iofclose.c (_IO_fclose): If closing a non-filebuf, return -1 + if _IO_ERR_SEEN. + +Fri Feb 17 19:31:00 1995 Ian Lance Taylor + + * gen-params: Check for struct tms in , defining + HAVE_SYS_TIMES accordingly. + +Wed Feb 15 21:05:11 1995 Per Bothner + + * strops.c (_IO_str_count): Use LEN macro. + (_IO_str_seekoff): Update _len field. + +Mon Feb 6 19:29:00 1995 Jason Merrill + + * gen-params: Default to short, long and long long for 16, 32 and + 64 bit types, in case detection fails. + +Wed Jan 25 18:07:30 1995 Jason Merrill + + * gen-params (_G_wint_t): Allow for broken promotions. + +Tue Jan 24 16:15:40 1995 Per Bothner + + * stdstrbufs.cc (_IO_fake_stdiobufs): Add an extra layer of struct, + to force correct alignment on i960s. + (DEF_STDIOBUF, _IO_{stdin,stdout,stderr}_buf): Update accordingly. + +Thu Jan 19 18:30:53 1995 Jason Merrill + + * config.shared (CXXINCLUDES): Add libstdc++ to includes for + building libg++. + (LIBS): Also link with libstdc++ when building libg++ toys. + Don't set EXPORT_ALL_VARIABLES; users will have to set + LD_LIBRARY_PATH themselves. + +Fri Dec 30 16:38:13 1994 Mike Stump + + * config/linux.mt: Fix build problem on linux 1.0.8. + +Thu Dec 22 11:49:45 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * config/netware.mt: Use gcc to pre-link iostream.nlm's objects + instead of using nlmconv, so that references to functions in + libgcc.a are resolved. + + * configure.in: Append .mt to target makefile fragment file names. + + * floatconv.c (tens, tinytens, bigtens): Added const qualifier. + +Tue Dec 20 09:59:50 1994 Mike Stump + + * gen-params (VTABLE_LABEL_PREFIX): Since some systems have GNU nm + as nm, and they demangle by default, we have to notice this, and + try --no-cplus (linux) or --no-demangle when running nm. + +Wed Dec 14 18:13:58 1994 Per Bothner + + * gen-params: To determine vt-name-mangling using dummy.C add + #include and #prama interface/implementation to avoid problem with + assemblers that don't emit local symbols. Reported under HPUX 8 + by Thomas Arend . + + * streambuf.h (ios::ios): Move inline definition after + that of ios::init (which ios::ios calls). + +Sun Dec 4 19:50:32 1994 Per Bothner + + * fileops.c (_IO_file_init, _IO_file_close_it, _IO_file_sync): + Set _offset to _IO_pos_BAD, to support applications that follow + POSIX.1 rules on mixing file handles. + + * fileops.c (_IO_file_overflow): Handle case that buffer was + allocated (perhaps by setvbuf) but _IO_write_base is still 0. + + * iostdio.h (setbuffer): #define as _IO_setbuffer. + * streambuf.h, filebuf.cc: Removed filebuf::do_write. + +Tue Nov 29 23:38:57 1994 Per Bothner (bothner@rtl.cygnus.com) + + * floatconv.c (setword0, setword1): Fix typo. + +Tue Nov 29 15:37:29 1994 Per Bothner + + * config.shared: Move -fno-implicit-template from CXXFLAGS + to LIBCXXFLAGS. Tests are better run without it. + + * floatconv.c (word0, word1): Re-place/re-implement using unions + instead of casts to avoid optimizer problems. + + * dbz/dbzmain.c: Renamed dirname -> dir_name to avoid OSF + header file braindamage. + +Sat Nov 5 19:44:00 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * config.shared (LIBCFLAGS): Define. + (LIBCXXFLAGS): Define. + (DOING_LIBGXX): Define TOLIBGXX. Change LIBS to use -lg++. Add + LD_LIBRARY_PATH and .EXPORT_ALL_VARIABLES:. + (FLAGS_TO_PASS): Add LIBC{,XX}FLAGS. + (XC{,XX}FLAGS): Set to LIBCFLAGS or CFLAGS depending on $LIBDIR. + (COMPILE.c): Define, use in .c.o rule. + (COMPILE.cc): Define, use in .cc.o rule. + +Sat Nov 5 15:12:12 1994 Per Bothner + + * Makefile.in (VERSION): Update to 0.67. + + * streambuf.h (ios::dont_close): Is now set by default. + * fstream.h, fstream.cc (__fb_init): New function. Clears + ios::dont_close. Change fstreambase constructors to call it. + * strstream.cc: *strstream constructors must clear ios::dont_close. + * iostream.cc: Simplify - don't need to set ios::dont_close. + * ioassign.cc: Simplify - assume ios::dont_close is always set. + + * fstream.h, fstream.cc: If _IO_NEW_STREAMS, put the + filebuf as a member __my_fb. + * strstream.{h,cc}: Likewile use a strstreambuf member __my_sb. + * streambuf.h, stdstreams.cc, ioextend.cc: + Fix if _IO_NEW_STREAMS to not use ios::dont_close. + + * streambuf.h (class ios): Move rdbuf later, to avoid + inability of g++ to inline. + * filebuf.cc (filebuf::~filebuf): Call _IO_do_flush. + + * config.shared: Emit rules to make depend. + * depend: New file. + +Fri Nov 4 17:19:11 1994 Per Bothner + + * README: Fix typos. + * libio.h: Add comment. Update Copyright notice. + +Fri Nov 4 21:46:30 1994 Paul Eggert + + * libio.h (__P): Change argument name spelling from + `paramlist' to `protos' for compatibility with BSDI 1.1. + +Thu Nov 3 00:45:16 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * config.shared (CXXFLAGS): Add -fno-implicit-templates. + +Mon Oct 24 15:57:35 1994 Per Bothner + + * config.shared: Define NOSTDIC and use it for libio too. + +Thu Oct 20 19:45:35 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * iogetdelim.c: #include . + +Thu Oct 20 17:09:52 1994 Per Bothner + + * iostream.h: Add classes _IO_istream_withassign and + _IO_ostream_withassign. Re-type cin, cout, cerr, clog. + (class iostream): Don't add extra _gcount field. + * ioassign.cc: New file. Implement operator= for cin etc. + * streambuf.h (class ios): Change return type of operator=. + * Makefile.in (IOSTREAM_OBJECTS): Add ioassign.o. + + * Makefile.in: Re-arrange, so linux.mt overrides can work. + + * fileops.c (_IO_file_seekoff): Optimize seeks within buffer. + +Wed Oct 19 14:25:47 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * gen-params (wint_t): Return to using __WCHAR_TYPE__ for + compatibility with gcc versions prior to 2.6.1. + +Tue Oct 18 17:08:18 1994 Per Bothner + + * Makefile.in: Define _G_CONFOG_H as _G_config.h for Linux. Use it. + (IO_OBJECTS): Add iogetdelim.o. + * config/linux.mt: New file. + * configure.in: Select config/linux.mt if Linux. + * iogetdelim.c: Verious cleanups, many from + Ulrich Drepper . + * libioP.h: Add _IO_getdelim. Use (void) for no-parameter functions. + +Thu Oct 13 16:30:56 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * libio.h: Rename USE_DTOA to _IO_USE_DTOA for namespace reasons. + * iostream.cc, iovfscanf.c, iovfprintf, floatconv.c: + Update USE_DTOA -> _IO_USE_DTOA. + + * libio.h (_IO_feof, _IO_ferror): Move to here ... + * iolibio: ... from here + + * iostream.cc (istream::get, istream::ignore, istream::read): + Set _gcount to 0 if ipfx0 failed. + + * iostream.cc (flush): Do virtual function call, rather than + going through jumptable. (To get correct method in derived class.) + Bug and fix from John Wiegley . + + * iofdopen.c (O_ACCMODE): Define using O_RDWR, not O_RDWRITE. + + * streambuf.h (ios::rdbuf(streambuf*)): New. + * streambuf.h (ios::operator=): Make private (i.e. dis-allow). + +Wed Oct 12 19:09:20 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * gen-params: Define _G_NO_NRV and _G_NO_EXTERN_TEMPLATES if not + compiling with g++. + +Thu Oct 6 16:03:43 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iostream.texi (ostrstream::str): Note that NUL is not written + automatically. + +Wed Oct 5 17:28:29 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iogetdelim.c (_IO_getdelim): New function. + +Wed Oct 5 15:40:22 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * config/netware.mt: New file, first cut at Netware NLM support. + * configure.in (*-*-netware*): Use config/netware.mt. + + * config.shared (NLMCONV, LD): New definition. + + * gen-params: check for nm in ${binutils}/nm.new. + * config.shared: Likewise. + +Tue Oct 4 12:20:01 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iomanip.h (omanip::operator<<): Make 2nd arg be const. + Bug and fix reported by Greg McGary . + + * strstream.cc (strstreambuf::pcount): Simplify, to match + ANSI/ISO specification. + +Mon Sep 26 15:19:52 1994 Jason Merrill (jason@deneb.cygnus.com) + + * gen-params: Include and if they exist. + +Thu Sep 8 14:41:41 1994 Jason Merrill (jason@deneb.cygnus.com) + + * iostream.h (class istream): Declare operator>>(long double&). + (class ostream): Define operator<<(long double). + + * iostream.cc (istream::operator>>(long double&)): Define. + +Wed Sep 7 14:42:29 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iostream.texi (Overflow): Fix bugs in example. + +Fri Sep 2 17:45:57 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iostream.tex: Document a little on how to write your + own streambuf-derived class, with an example. + +Tue Aug 30 13:03:57 1994 Brendan Kehoe (brendan@lisa.cygnus.com) + + * floatconv.c (s2b): Declare X and Y to be _G_int32_t. + (diff, quorem): Declare BORROW, Y, and Z likewise. + (ulp): Declare L likewise. + (_IO_strtod): Declare L and AADJ likewise. + (_IO_dtoa): Declare L and D likewise. Cast division of D by DS to + _G_int32_t. + +Mon Aug 29 16:01:54 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iosetvbuf.c (_IO_setvbuf): If setting _IOFBF and no + buffer was specified, call __doallocate. + + * fileops.c, floatconv.c: Add a bunch of parentheses to + shut up gcc warnings. Patch from H.J.Lu. + + * stdiostream.cc (stdiobuf::sys_read): Inline call to getc + for the normal case (size==1). + +Sat Aug 20 12:14:52 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Increase to 0.66. + +Fri Aug 19 17:28:41 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iolibio.h: Added _IO_printf prototype. + Added extern "C" { ... } wrappers #ifdef __cplusplus. + Bugs reported by Neal Becker . + +Wed Aug 17 18:17:15 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * fileops.c (_IO_file_seekoff): For _IO_seek_cur, adjust for + read-ahead before jumping to label dumb. + +Wed Aug 3 13:15:01 1994 H.J. Lu (hjl@nynexst.com) + + * libioP.h (CHECK_FILE(FILE,RET)): new, which checks for + FILE == NULL and _IO_MAGIC_MASK. + (COERCE_FILE(FILE)): merged into CHECK_FILE(FILE,RET) + with typo fixes. + + * iofread.c, iofwrite.c: add CHECK_FILE(fp, 0); + * iofclose.c: add CHECK_FILE(fp, EOF); remove _IO_MAGIC_MASK check. + + * iofflush.c, iofgetpos.c, iofputs.c, iofscanf.c, + iofsetpos.c, iofvbuf.c, ioungetc.c: + Add CHECK_FILE(fp, EOF) and remove COERCE_FILE(fp). + + * iofgets.c: add CHECK_FILE(fp, NULL) and remove COERCE_FILE(fp). + * iofprintf.c: add CHECK_FILE(fp, -1) and remove COERCE_FILE(fp). + * ioftell.c: add CHECK_FILE(fp, -1L) and remove COERCE_FILE(fp). + * iosetbuffer.c: add CHECK_FILE(fp, ) and remove COERCE_FILE(fp). + +Fri Aug 12 15:35:39 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iofdopen.c (_IO_fdopen): #define O_ACCMODE if it isn't. + Still set O_APPEND if "a" is given, but don't unset it + if it isn't. Added comment. + +Mon Aug 8 13:11:00 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * gen-params (VTABLE_LABEL_PREFIX): Changes in the implementation. + For look for _*vt[$_.]7*filebuf in the nm output, because that + matches what g++ produces and has produced. Thus it should be + somewhat more robust. + +Sun Aug 7 22:52:49 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * gen-params (CC): Remove no-longer-needed -I options + passed to xgcc (now they are implied by the -B options). + +Wed Jul 20 16:41:13 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (tooldir): Added definition, so we can do + 'make install' in this directory. + Bug reported by Klamer Schutte . + +Mon Jul 18 18:02:34 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * gen-params (VTABLE_LABEL_PREFIX): Remove filename sppearing + by itself. Add comment explaining what is going on. + +Tue Dec 21 13:02:48 1993 H.J. Lu (hjl@jalod) + + * libio.h: define _IO_uid_t and _IO_HAVE_ST_BLKSIZE + as _G_xxxxxxxx. + +Tue Dec 21 13:02:48 1993 H.J. Lu (hjl@jalod) + + * iopopen.c: Don't include . It is included in "libioP.h". + + * iopopen.c (_IO_proc_close) : check if fp is on the list + before close it. + +Thu Jul 14 16:38:47 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * gen-params (CONFIG_NM): Make sed scripts to find vtable name + mangling more robost for different forms of nm output. + +Tue Dec 21 13:02:48 1993 H.J. Lu (hjl@jalod) + + * iofopen.c (_IO_fopen): don't check [redundantly] fp == NULL after + IO_file_init(&fp->_file). + + * iomanip.h (template class iapp): + change ostream to istream. + +Tue Jul 12 14:09:02 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Increase to 0.65. + * libioP.h (builtinbuf_vtable): Only define #ifdef __cplusplus. + + * gen-params (_G_int8_t): Only define if defined(__STDC__), + because K&R C compilers don't have signed char. + (_G_int64_t, _G_uint64_t): Only define if defined(__GNUC__) + because other compilers may not have long long. + +Sun Mar 06 13:10:21 1994 H.J. Lu (hjl@nynexst.com) + + * floatconv.c (_IO_dtoa ()): fix a small memory leak, set the + "on_stack" field to be 0 if "result" is not NULL. + +Sat Mar 05 13:18:20 1994 H.J. Lu (hjl@nynexst.com) + + * floatconv.c (_IO_dtoa ()): if the number of digits of the + floating point number is more than the previous one, free the + old string and allocate a new one. + [Minor optimization to avoid Bcopy. -PB] + +Mon Jul 11 10:53:41 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * fileops.c (_IO_file_underflow): 'count' should be unsigned, + since it contains the return value of read. Reported by + Teemu Torma . + +Tue Dec 21 13:02:48 1993 H.J. Lu (hjl@nynexst.com) + + * floatconv.c (_IO_strtod ()): make "+" and "-" as error. + +Sat Jul 9 15:09:21 1994 Per Bothner (bothner@kalessin.cygnus.com) + + Make sure _IO_FILE::_flags is always initialized correctly, for the + C functions (fopen, fdopen, popen), and not just the C++ functions. + * fileops.c (_IO_file_init): Set _flags to CLOSED_FILEBUF_FLAGS. + * fileops.c (_IO_file_fopen): Remove bogus assignment. + * filebuf.cc (filebuf constructors): Don't pass CLOSED_FILEBUF_FLAGS + to streambuf constructor - _IO_file_init does it instead. + * filebuf.cc (CLOSED_FILEBUF_FLAGS): Removed. + * iopopen.c (_IO_proc_open): Use _IO_mask_flags. + +Thu Jun 30 08:49:53 1994 Jason Merrill (jason@deneb.cygnus.com) + + * dbz/Makefile.in (mostlyclean): Add target. + +Wed Jun 29 09:30:12 1994 Jason Merrill (jason@deneb.cygnus.com) + + * gen-params: Woops, can't run a C program to determine target + characteristics. Sigh. + +Tue Jun 28 03:11:33 1994 Jason Merrill (jason@deneb.cygnus.com) + + * gen-params: Add _G_{,u}int{8,16,64}_t, use a short C program to + determine what all these should be rather than trying to compare + the MAX numbers in the shell. + +Sun Jun 26 21:04:24 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdiostream.h, stdiostream.cc (stdiobuf::xsgetn): Removed. + Too hairy. If we want to optimize it, we should do so in + filebuf::xsgetn (or rather _IO_file_xsgetn). + + * stdiostream.h (class stdiobuf), stdiostream.cc: Fix parameter + and return types of virtual function to matcher base types (Oops!). + * streamstream.cc (stdiobuf::xsgetn, stdiobuf::xsputn): + Optimize to call fread.fwrite directly if !buffered. + * fileops.c: Fix comment. + +Fri Jun 24 11:28:18 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdiostream.h (istdiostream, ostdiostream): New classes. + + More robust final cleanup. + * cleanup.c (_IO_register_cleanup): Register _IO_cleanup, + rather than _IO_flush_all. + * filedoalloc.c: Update comment. + * genops.c (_IO_unbuffer_all): New. Makes all files unbuffered. + * genops.c (_IO_cleanup), libioP.h: New function. Call + _IO_flush_all, and then _IO_unbuffer_all. This is in case C++ + destructors try to do output *after* _IO_cleanup is called. + + Construct standard stdiobufs statically (using type punning). + * stdstrbufs.c; Unless _STDIO_USES_IOSTREAM declare standard + stdiobufs (for stdin, stdout, and stderr), using type punning + (struct _IO_fake_stdiobuf). This avoids constructor-time problems. + * stdstreams.cc: Remove the declarations of the stdiobufs. + Instead use the new (fake) ones in stdstrbufs.cc. We no longer + have to call ios::sync_with_stdio at constructor time. + + Preliminary support for new ANSI streambuf::uflow virtual. + * libioP.h (struct _IO_jump_t): Add __uflow field. + * genops.c (_IO_default_uflow), libioP.h: New function. + * fileops.c (_IO_file_jumps), iopopen.c (IO_proc_jumps), + iovfprintf.c (_IO_helper_jumps), strops.c (_IO_str_jumps), + streambuf.cc (_IO_streambuf_jumps): Add _IO_default_uflow. + * genops.c (__uflow): New function. + (save_for_backup): New function. Some code shared by + __underflow and __uflow, moved out from the former. + (_IO_default_uflow): New function. + * libio.h (_IO_getc): Call __uflow, not __underflow. + +Wed Jun 22 20:22:49 1994 Per Bothner (bothner@kalessin.cygnus.com) + + Make sure that the vtable of a streambuf is always valid, + which makes ios::rdbuf simpler and faster. + * gen-params: Add code to determine _G_VTABLE_LABEL_HAS_LENGTH, + _G_VTABLE_LABEL_PREFIX, _G_VTABLE_LABEL_PREFIX_ID, and + _G_USING_THUNKS, which describe how virtual function tables are named. + * stdfiles.c (FILEBUF_LITERAL): Moved to libioP.h. + * libioP.h (builtinbuf_vtable): New (complicated) declaration. + * filebuf.cc (filebuf::__new), strstream.cc (SET_STR_JUMPS): + Initialize vtable to builtinbuf_vtable, not NULL. + * stdstrbufs.cc: New file. Same as stdfiles.c, except that + vtable is initialized to builtinbuf_vtable, not NULL. + * streambuf.h (ios::rdbuf): Can now simplify/optimize, due to + above changes. Always, just return _strbuf. + * builtinbuf.h, builtinbuf.cc (builtinbuf::vtable, + builtinbuf::get_builtin_vtable): Removed. No longer needed. + * streambuf.h, builtinbuf.cc (ios::_IO_fix_vtable): No longer needed. + Only defined #ifdef _STREAM_COMPAT, for binary compatibility. + * Makefile.in: Move stdfiles.o from IO_OBJECTS to STDIO_WRAP_OBJECTS. + (IOSTREAM_OBJECT): Add stdstrbufs.o. + * Makefile.in (_G_config.h): Pass $(CXXFLAGS) as part of $(CXX). + +Fri Feb 11 11:08:01 1994 SBPM Marc GINGOLD (marc@david.saclay.cea.fr) + + * iovfprintf.c (helper_vfprintf): add + hp->_IO_file_flags = _IO_MAGIC|(_IO_IS_FILEBUF+_IO_NO_READS); + [This is needed because _IO_vfprintf checks for _IO_UNBUFFERED. -PB] + [Actually: don't set _IO_IS_FILEBUF. -PB] + +Wed Jun 22 13:49:22 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdiostream.cc, stdiostream.h (stdiobuf::buffered): New methods. + + * iofdopen.c (_IO_fdopen): Various minor improvements. + + * iovfscanf.c: Don't return EOF on control_failure. + +Tue Dec 21 13:02:48 1993 H.J. Lu (hjl@nynexst.com) + + * iovfscanf.c: Enforce the sequence of the conversion specifications. + +Fri Jun 17 20:57:22 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iofdopen.c: Use fcntl to check that requested access mode is + compatible with existing access mode, and to change the + O_APPEND file status flag if need be. + +Thu Jun 16 17:33:50 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * streambuf.h (ios::init): Initialize all the fields. + This may be overkill, but the current ANSI working paper requires it. + * streambuf.h (ios::ios): Reimplement in terms of ios::init. + * iostream.cc (Non-default constructors istream::istream, + ostream::ostream, iostream::iostream): Cannot use a mem-initializer, + because it is ignored if initializing a derived class. Instead, + call ios::init. + +Wed Jun 15 13:35:37 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdstreams.cc (ISTREAM_DEF): Fix typo (it's a _fake_istream, not + a _fake_ostream). Reported by Jason Shirk . + + * stdiostream.h, stdiostream.cc (stdiobuf::~stdiobuf): New. + Call _IO_do_flush. + * stdiostream.cc (stdiobuf::sync): Call _IO_do_flush rather + than filebuf::sync (to avoid bad seeks). + + * libioP.h (_IO_do_flush): Add missing parentheses. + +Fri Jun 3 19:16:57 1994 Jason Merrill (jason@deneb.cygnus.com) + + * config.shared (CXXFLAGS): Remove -fno-implicit-templates. + + * iomanip.h: Add explicit external instantiations. + +Wed Jun 1 14:14:44 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * libio.h (struct _IO_FILE_plus): Move definition from here ... + * libioP.h (struct _IO_FILE_plus): ... to here. Since this + file is private to the implementation, we can rename the fields + from the implementor's to the user's name anme space. + (This avoids a lossage on SCO, whose stdio.h has a #define _file.) + * iofdopen.c, iofopen.c, stdfiles.c: Fix field references accordingly. + * iopopen.c (struct_IO_proc_file): Rename fields from + implementor's name space to user's, and update usages. + * streambuf.h (streambuf::_vtable): Re-implement to not need + struct _IO_FILE_plus. + * strfile.h (struct _IO_strfile_): Likewise. + +Wed Jun 1 13:57:48 1994 Jason Merrill (jason@deneb.cygnus.com) + + * config.shared (CXXFLAGS): Use -fno-implicit-templates instead of + -fexternal-templates. + +Tue May 31 08:49:28 1994 Mike Stump (mrs@cygnus.com) + + * genops.c, iofclose.c, iofdopen.c, iofopen.c, iopopen.c: Be + consistent about protecting #include . + + * ioputs.c: Add #include , to avoid warning on alpha. + + * iofdopen.c: Add #include , so that malloc works on + machines where sizeof(int) != sizeof(void *). + +Mon May 30 17:26:49 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * pfstream.cc (ipfstream::ipfstream, opfstream::opfstream): + Reverse sense of test of return value of procbuf::open. + (It returns NULL on failure.) + + * filedoalloc.c (_IO_file_doallocate): Remove dead code for + USE_MALLOC_BUF. Add code to return EOF if ALLOC_BUF fails. + +Sat May 28 13:47:47 1994 Jason Merrill (jason@deneb.cygnus.com) + + * iomanip.cc: Explicitly instantiate smanip and + smanip. + +Wed May 25 16:04:12 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * strfile.h: Use __P instead of _PARAMS. + +Fri May 20 11:42:17 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * libio.h: Rename _PARAMS macro to __P for better glibc and BSD + compatibility. (Also define _PARAMS for backwards compatibility.) + * cleanup.c, iolibio.h, ioperror.c, iovfprintf.c, iovfscanf.c, + libioP.h: Use __P instead of _PARAMS. + * iostdio.h: Use __P instead of _ARGS. + + * fileops.c (_IO_file_read): Minor stylistic tweak. (It is + preferable to test errno *after* the error return.) + +Fri May 13 15:25:36 1994 Jason Merrill (jason@deneb.cygnus.com) + + * iostream.*: Add insertor and extractor for bool (just pretend + it's an int). + +Fri May 13 14:12:03 1994 Mike Stump (mrs@cygnus.com) + + * gen-params: Check for builtin bool support. + +Wed May 11 00:48:35 1994 Jason Merrill (jason@deneb.cygnus.com) + + Make libg++ build with gcc -ansi -pedantic-errors + * gen-params: #ifdef __STRICT_ANSI__, #define _G_NO_NRV. + * pfstream.cc (ipfstream::ipfstream): Wrap use of variable-size + array in #ifndef __STRICT_ANSI__. + +Fri May 6 12:42:21 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Increase to 0.64. + + * isgetline.cc (istream::getline): The delimiter should *not* + be included in the gcount(). + + * filedoalloc.c: #include (If __STDC__) to get malloc. + * iostream.h (ostream::put): Remove overloaded versions, to match + new working paper. (Actually just put inside _STREAM_COMPAT, for now.) + +Tue May 3 14:14:57 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * genops.c (_IO_default_finish): Make robust when called + multiple times on the same _IO_FILE*. (One way this can + happen is by the builtinbuf destructor being followed by the + streambuf destructor.) + +Mon May 2 13:55:26 1994 Jason Merrill (jason@deneb.cygnus.com) + + * gen-params: Actually determine wint_t rather than depending on + cpp to provide it or defaulting to the underlying type for + wchar_t. + +Sat Apr 30 14:47:30 1994 Jason Merrill (jason@deneb.cygnus.com) + + * gen-params: Add _G_wint_t, allow __*_TYPE__ to override values + at compile time, fix definition of _G_ARGS. + +Fri Apr 29 16:55:37 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * libio.h: Remove #pragma interface. (There is no implementation.) + +Mon Mar 28 14:22:26 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iostream.cc (ostream::operator<<(double)): Add/fix support + for printing '+' when ios::showpos is set. + (Fixes bug reported by Doug Moore .) + * iostream.cc (istream::read): Set eofbit as well as failbit on eof. + * iostream.cc (ostream::operator<<(int)): Fix conversion + to unsigned (used to lose on INT_MIN). + * iostream.cc (ostream::operator<<(long)): Use (unsigned long), + rather than (unsigned) for temporary. + + * config.shared, Makefile.in: Remove definitions and uses + of XTRAFLAGS. It is no longer needed, since it is + now implied by the -B flag. + +Fri Mar 25 00:31:22 1994 Jason Merrill (jason@deneb.cygnus.com) + + * builtinbuf.h: Add put /**/ around comment on trailing #endif. + + * Makefile.in (c++clean): Make clean in tests subdir, too. + +Wed Mar 23 16:42:09 1994 Doug Evans (dje@canuck.cygnus.com) + + * configure.in: Remove Makefile.tem before creating it. + Needed when configuring from read-only source trees. + +Wed Mar 16 14:06:42 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdstreams.cc: Fix so that stdiobuf are used for cin/cout/cerr, + unless _STDIO_USES_IOSTREAM is defined. + * filebuf.cc (filebuf::setbuf): Fix confusion about return + value from _IO_file_setbuf. + +Sun Mar 13 00:54:12 1994 Paul Eggert (eggert@twinsun.com) + + * config.shared: Ensure that `all' precedes `.PHONY'; + BSDI 1.1 needs this. + +Sat Mar 12 03:58:00 1994 Paul Eggert (eggert@twinsun.com) + + * config.shared: Output a definition of INSTALL that uses + $${rootme}, not ${rootme}. Most `make's don't care, but BSDI + 1.1 `make' does. + +Fri Mar 4 17:33:01 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iopopen.c: #define _POSIX_SOURCE. + * isgetline.c (istream::getline): Various fixes. + +Thu Mar 3 17:58:20 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * iostream.cc (write_int): Fix test for when to add initial '0' + when ios::oct and ios::showbase are set. + For hex, showbase adds initial 0x (or 0X) regardless of val==0. + Bugs reported by Phil Roth . + +Mon Feb 21 13:18:20 1994 H.J. Lu (hjl@nynexst.com) + + * libio.h (_IO_PENDING_OUTPUT_COUNT(_fp)): return the + pending output count in _fp. + +Fri Feb 25 09:26:57 1994 Ian Lance Taylor (ian@cygnus.com) + + * gen-params: For HAVE_SYS_WAIT, compile dummy.c, not dummy.C. + +Tue Feb 22 11:19:09 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * streambuf.h, genops.c, libioP.h: Rename references to + _IO_FILE fields other_gbase => _IO_save_base, + _aux_limit => _IO_backup_base, and _other_egptr => _IO_save_end. + * libio.h: Remove no-longer needed macros _other_gbase, + _aux_limit, and _other_egptr. + * genops.c (__underflow, _IO_default_finishh, _IO_unsave_markers): + Check _IO_save_base for NULL before FREEing it or calling + _IO_free_backup_area. + +Thu Feb 17 15:26:59 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * gen-params: Improve deduction of _G_uint32 and _G_int32. + Should now work for 16-bit, 32-bit, or 64-bit targets. + * gen-params: Check for sys/wait.h using ${CC}, since it's + now used in a C file, not a C++ file. + * floatconv.c: Typedef _G_uint32_t as unsigned32, and use + unsigned32 in place of unsigned long. (Needed for Alpha.) + +Tue Feb 8 13:40:15 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * fileops.c (_IO_file_close_it): Simplify by using _IO_do_flush. + * fileops.c (_IO_file_finish): Don't call _IO_file_close_it - + do it inline. Call _IO_do_flush even if _IO_DELETE_DONT_CLOSE. + * fileops.c (_IO_file_attach): Set _IO_DELETE_DONT_CLOSE. + * genops.c (_IO_flush_all): Only call overflow if there is + something to write. + * iofclose.c (_IO_fclose): Check that magic number is correct, + and clear it when done. Avoids crashing some buggy applications. + * iogetline.c (_IO_getline): Don't gratuitously increment old_len. + * iogets.c (_IO_gets): Take care to get required ANSi semantics. + +Sun Feb 6 19:50:39 1994 Jason Merrill (jason@deneb.cygnus.com) + + * iomanip.cc: Explicitly instantiate operator<< and >>. + +Fri Feb 4 12:28:22 1994 Jason Merrill (jason@deneb.cygnus.com) + + * config.shared (CXXFLAGS): Use -fexternal-templates. + + * iomanip.h: Uncomment #pragma interface. + +Thu Jan 20 13:48:40 1994 Per Bothner (bothner@kalessin.cygnus.com) + + If no characters are read by fgets, ANSI C doesn't allow '\0' to + be written to the buffer, but it is required by ANSI C++ + for istream::get and istream::getline. Both use _IO_getline ... + * iogetline.c (_IO_getline): Don't write a '\0' at the end + of the read data. The input buffer length does not include + space for a '\0'. + * iofgets.c, iogets.c: Change appropriately. + Also check for _IO_ERR_SEEN, as required by ANSI. + * isgetline.cc: Update accordingly. + +Mon Jan 17 13:24:26 1994 Jason Merrill (jason@deneb.cygnus.com) + + * Makefile.in (c++clean): Added target for compiler testing + (i.e. make c++clean all). + +Mon Jan 10 11:20:42 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * libio.h (_IO_putc): Add parentheses. + Patch from Rik Faith . + +Tue Jan 4 01:32:28 1993 Hongjiu Lu (hjl@nynexst.com) + + * genops.c (_IO_default_xsputn): + (_IO_default_xsgetn): + * ioignore.c: change "_IO_size_t count" to + "_IO_ssize_t count". + * iogetline.c: change "_IO_size_t len" to + "_IO_ssize_t len". + +Mon Dec 20 00:31:21 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config.shared (CXXINCLUDES): Fix quoting of $(NOSTDINC). + +Sun Dec 19 21:03:45 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Increase to 0.63. + +Fri Dec 17 13:02:44 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * iofread.c (_IO_fread): Return 0 if either size or count is 0. + * iofwrite.c (_IO_fwrite): Return 0 if either size or count is 0. + (This is consistent with fread, and most implementations, but not + with a literal reading of the ANSI spec.) + * iovfscanf.c (_IO_vfscanf): If got EOF while skipping spaces, + set seen_eof and break (instead of returning). + * sbscan.cc (streambuf::vscan): Set error state before returning. + * streambuf.h: Add a forward declarations for class istream + to work around a g++ vtable name mangling bug. (Patch from + harry@pdsrc.hilco.com via Jeffrey A Law .) + * NEWS: New file. + +Sat Dec 11 16:21:08 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * iovfprintf.c (struct helper_file, _IO_helper_overflow, + helper_vfprintf, _IO_helper_jumps): New structs and functions. + (_IO_vfprintf): Use helper_vfprintf to make printing to + unbuffered files more efficient. + * genops.c (_IO_default_underflow), libioP.h: New function. + + * iovsscanf.c (_IO_vsscanf): The input string's length marks + its logical end-of-file. + +Wed Dec 8 13:20:46 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * indstream.cc (indirectbuf::sync()): Don't crash if get_stream() + or put_stream() are NULL; sync() both streams even if error. + +Sun Dec 5 19:24:29 1993 Brendan Kehoe (brendan@lisa.cygnus.com) + + * iostreamP.h (convert_to_seekflags): Use _IO_seek_set instead of + 0 inside the conditial expressions. + + * iofsetpos.c (_IO_fsetpos): Delete unused var `pos'. + +Sat Dec 4 15:57:26 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * filedoalloc.c (_IO_file_doallocate): Change type of couldbetty + to int, and type of size to _IO_size_t, instead of size_t. + (Change needed for Ultrix, which incorrectly deliberately doesn't + define size_t in if _POSIX_SOURCE is defined.) + +Thu Dec 2 22:43:03 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * fileops.c (_IO_file_finish): Remove redundant call to _IO_un_link. + * iofclose.c (_IO_fclose): Don't call fp->_jumps->__close; it's + too low-level. Instead call _IO_file_close_it. + * dbz/Makefile.in (rclean, distclean): Add some missing files. + +Wed Dec 1 13:19:14 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config/hpux.mt (MATH_H_INLINES): No longer define. + Patch from Jeffrey A Law . + +Fri Nov 26 13:28:36 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config.shared (CINCLUDES): Define default if libg++. + * iofread.c: Use _IO_sgetn.c. + * iolibio.h (_IO_clearerr): Fix typo. + * genops.c (_IO_seekmark): Return 0 on success. + * floactconv.c (Binit): Change to static. + * iofclose.c (_IO_fclose): Check if file is _IO_stdin, _IO_stdout, + or _IO_stderr; if so don't try to free it. Fix from hjl@nynexst.com. + + * genops.c (_IO_default_sync), libioP.h: New function. + * libioP.h (_IO_default_close): Use _IO_default_sync -same interface. + + * Makefile.in: Increase version to 0.62. + * iopopen.c (_IO_proc_close): Use waitpid (available in libibarty, + if needed), rather than wait. Don't block/ignore SIGINT etc, + as this is counter to Posix.2. + * iopopen.c: Chain open proc_files, and have the child close + the ones that are open (as required by Posix.2). + + * fstream.h (fstreambase::rdbuf), strstream.h (strstreambase + ::rdbuf): Call ios::rdbuf() instead of getting _strbuf directly. + + * sbscan.cc (streambuf::vscan): Comment out duplicate default arg. + * floatconv.c: Recognize Alpha and i860 as little-endian. + * streambuf.cc: Return two bogus value returns from void functions. + * iolibio.h, iofwrite.c: Fix buffer type to (const void*). + * libio.h: Predefine of struct _IO_FILE to help non-g++-compilers. + * libioP.h, pfstream.cc, stdfiles.c, iovfscanf.c: Cleanup syntax junk. + * stdstreams.cc: Minor simplification. + * streambuf.h, builtinbuf.cc: Add non-const ios::_IO_fix_vtable() + for temporary binary compatibility. + + * filedoalloc.c, fileops.c: Add _POSIX_SOURCE. + * fileops.c, iofopen.c, iofputs.c, iostream.cc, strops.c, + strstream.cc, genops.c: Add some missing #includes. + * iofopen.c, iofdopen.c: Return NULL if malloc fails. + * iovfscanf.c: Fix return type in strtol prototype. + * fwrite.c: Remove bogus file. + +Wed Nov 17 14:09:42 1993 Per Bothner (bothner@cygnus.com) + + * builtinbuf.cc (ios::_IO_fix_vtable), streambuf.h: Make method + const, to reduce problems with -Wcast-qual. + +Tue Nov 16 19:30:42 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * config.shared (CXXINCLUDE): use ${} instead of $() for NOSTDINC + +Tue Nov 16 14:15:45 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * iopopen.c (_IO_proc_close): Re-structure to avoid + declarations after statements. + * floatconv.c: If not __STDC__, #define DBL_MANT_DIG. + * config/isc.mt (G_CONFIG_ARGS): Remove bogus spaces. + Patch from David A. Avery . + +Tue Nov 16 15:58:31 1993 Mark Eichin (eichin@cygnus.com) + + * Makefile.in (_G_config.h): explicitly use $(SHELL) to run + gen-params, since we know it is a script (we're explicitly looking + in ${srcdir} for it) and /bin/sh might not be good enough. + +Mon Nov 15 13:26:22 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * builtinbuf.cc: Don't depend on initialization of static + variable builtinbuf::vtable, since that might happen after + we need it (for a static constructor). Instead, initialize + it when needed by inlining the code from get_builtin_vtable + into ios::_IO_fix_vtable(). + + * floatconv.c: Avoid using #elif, which some C compilers lack. + * iogetline.c, libioP.h: Make char parameter be int, to avoid + some default promotion anomalies. + +Fri Nov 5 11:49:46 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config.shared (do-clean-dvi): Remove TeX work files. + * iopopen.c (extern _IO_fork): Don't use parameter type void. + * strops.c (_IO_str_init_static): Clear the allocate_buffer + function pointer, to mark the strfile as being static. + Bug fix from Mike Raisbeck . + +Thu Nov 4 10:44:24 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * filebuf.cc (filebuf:): Use sseekoff rather than seekoff + (which loses if vtable pointer is NULL). + + * iostream.cc (ostream::operator<<(long long n)): Fix thinko. + + * Makefile.in (VERSION): Increase to 0.60. + * Makefile.in (IO_OBJECTS): Added iopopen.o. + * config.shared (DISTCLEAN): Also remove Make.pack. + * config.shared (CXXINCLUDES): Add $(NOSTDINC). + + * config.shared (INSTALL): Fix so it ues the correct install.sh + whether $srcdir is absolute or relative. + + * floatconv.c (DBL_MAX_10_EXP): Fix default value. + +Wed Nov 3 10:20:49 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * gen-params: Make more robust to allow random junk (NeXT + has spaces) before typedefs. + + * fileops.c (_IO_file_overflow): Reduce code duplication. + * Makefile.in (IO_OBJECTS): Remove ioputs.o. + + * iovfscanf.c, libio.h: Extra parameter to _IO_vfscanf, + for optionally setting an error indication.. + * iofscanf.c, ioscanf.c, iofscanf.c, iovsscanf.c: Fix calls to + _IO_vfscanf to pass an extra NULL. + * sbscan.cc (streambuf::vscan): If passed an extra stream, + set its error state (using new _IO_vfscanf parameter. + + * filedoalloc.c, fileops.c, genops.c, iogetline.c, ioignore.c, + libio.h, libioP.h, streambuf.cc streambuf.h, strfile.h, strops.c, + strstream.cc: Replace macros (_base, _ebuf, _eback, _gptr, _egptr, + _pbase, _pptr, _epptr) by field names (_IO_buf_base, _IO_buf_end, + _IO_read_base, _IO_read_pre, IO_read_end, _IO_write_base, + _IO_write_ptr, _IO_write_end). + * libio.h: Remove the old macros (which fixes a conflict. + +Mon Nov 1 15:22:12 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * iostream.cc: Use _IO_sputn instead of sputn. _IO_sputn does + not require a vtable pointer, and is also slightly faster. + + * builtinbuf.{h,cc} (builtinbuf::setbuf): Fix return and + parameter types. + +Mon Oct 25 12:56:33 1993 Per Bothner (bothner@kalessin.cygnus.com) + + Kludge to make sure _IO_FILE buffers get flushed before exit. + * dbz/dbzmain.c, dbz/fake.c, dbz/byteflip.c: + Invoke DBZ_FINISH macro (if defined) before (normal) exits. + * dbz/Makefile.in (CFLAGS): Define DBZ_FINISH to call _IO_flush_all. + +Sat Oct 23 22:10:53 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (VERSION): Set to 0.60 for libg++ release. + * fileops.c (_IO_file_attach): Set _offset to _IO_pos_BAD. + * iostream.cc (ostream::flush): Fix thinkp. + * editbuf.cc, isgetsb.cc, isscan.cc, osform.cc, parsestream.cc, + pfstream.cc, sbform.cc, sbscan.cc, stdstreams.cc, stream.cc: + Replace #include "ioprivate.h" by #include "libioP.h" (and + sometimes stdarg.h, stdlib.h and/or string.h). + * ioprivate.h: Removed. + + +Thu Oct 21 19:24:02 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * PlotFile.h, SFile.h, editbuf.cc, editbuf.h, filebuf.cc, + fstream.cc, fstream.h, indstream.cc, indstream.h, iomanip.cc, + iomanip.h, ioprivate.h, iostream.cc, iostream.h, isgetline.cc, + isgetsb.cc, parsestream.cc, parsestream.h, pfstream.cc, + pfstream.h, procbuf.cc, procbuf.h, stdiostream.cc, stdiostream.h, + stdstreams.cc, streambuf.cc, streambuf.h, strstream.cc, + strstream.h: Remove old (duplicate) copyright notices. + + * iostream.cc: Fix calls to sync() to be safe in the presence + of vtable-less streambufs. + +Wed Oct 20 15:22:04 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * streambuf.h (streambuf::underflow, streambuf::overflow): + Don't make virtual functions pure. + * streambuf.cc (streambuf::underflow, streambuf::overflow): + Default definitions (return EOF). + * fstream.h: Add new (int fd, char* buf, int len) constructors. + These are deprecated, but added for AT&T compatibility. + * fstream.cc fstreambase::fstreambase(int fd, char *p, int l): New. + +Thu Oct 14 14:57:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: use 'mv -f' instead of 'mv' + +Tue Oct 12 05:01:44 1993 Mike Stump (mrs@cygnus.com) + + * floatconv.c: Fix typo, change __STDC to __STDC__. + +Mon Oct 11 17:03:12 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * cleanup.c: It should be #if _G_HAVE_ATEXIT, not #ifdef. + + * floatconv.c, iostrerror.c, iovfprintf.c, iovfscanf.c, libioP.h: + Bunch of fixes to allow use of non-ANSI (K&R) C compilers. + + * Makefile.in (iostream.list): Use CC=$(CXX) to force use of gcc. + * README: New file. + +Fri Oct 8 16:19:58 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Move ioungetc.o from STDIO_WRAP_OBJECTS to + IO_OBJECTS (since it is needed for iovfscanf.c). + * iostrerror.c: Add declaration of strerror. + +Thu Oct 7 12:02:28 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * cleanup.c: New file, to cause flushing at exit. + * filedoalloc.c: Cause flushing on exit. + * Makefile.in (OSPRIM_OBJECTS): Add cleanup.o. + * gen-params: Check for atexit. + +Tue Oct 5 19:11:14 1993 Mike Stump (mrs@cygnus.com) + + * ioperror.c (_IO_strerror): Add missing ()s in _PARAMS usage. + +Tue Oct 5 10:33:37 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * iofprintf.c, iofscanf.c, ioprintf.c, ioscanf.c, iosprintf.c, + iosscanf.c: Remove bogus semi-colon after va_dcl. + * ioperror.c: Fix typos in declaration. + +Mon Oct 4 17:12:22 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * configure.in (CLEAN): Define (as _G_config.h *.a). + + * fileops.c (_IO_file_read): Don't assume EINTR is defined. + * iosetbuf.c: Replace by generalized ... + * iosetbuffer.c: ... variant, derived from BSD. + * Makefile.in (STDIO_WRAP_OBJECTS): Change correspondingly. + * iosetvbuf.c (iosetvbuf): Minor ANSI tweak. + * iostdio.h (setbuf, setlinebuf): New #defines. + * iolibio.h (_IO_setbuf, _IO_setlinebuf): (Re-)define as macros. + * Makefile.in (LIBIO_OBJECTS): New macro. + +Tue Sep 28 14:15:52 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * libioP.h (_IO_proc_open, _IO_proc_close): Add missing return types. + * procbuf.cc: Belated fixes. + +Mon Sep 27 14:04:47 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: List new files. Add STDIO_WRAP_OBJECTS macro. + * floatconv.c (d2b): Use Exp_msk11 instead of Exp_msk1. + * iofgetpos.c (_IO_fgetpos), iofsetpos.c (_IO_fsetpos): Clean up. + * iolibio.h: New file. Declarations of _IO_foo, for most foo + where foo is a stdio function. (Remove these from libio.h.) + * iostream.h (istream::istreambuf, ostream::ostreambuf): Move + obsolete functions inside #ifdef _STREAM_COMPAT. + * libio.h, libioP.h, streambuf.h, parsestream.h, stdiostream.h: + Use _IO_fpos_t rather than _IO_pos_t. + * iopopen.c: New file type, for pipe (popen-like) streams. + * procbuf.cc: Now just a C++ wrapper for the files in iopopen.c. + * streambuf.h (ios::unsetf): Return complete old value of flags. + * iogets.c (_IO_gets(), ioungetc.c (_IO_ungetc), ioperror.c + (_IO_perror), iostrerror.c (_IO_strerror): New files and + functions, for stdio implementation. + * iostdio.h: Add declarations for various recently-added functions. + +Sun Sep 12 14:24:55 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * streambuf.h (ios::showpos):: Fix typo. + +Fri Aug 27 12:05:47 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * iopadn.c (_IO_padn): Change to return count of chars written. + * outfloat.c, iovfprintf.c: Change for new _IO_padn interface. + * iostream.cc (ostream::operator<<): Make sure to set badbit + on a failure (many places). Use _IO_padn more. + * iostream.cc (ostream& ostream::operator<<(const void *p): Move to + * osform.cc: ... here, to reduce linking-in-the-world syndrome. + * osform.cc: Use rdbuf(), instead of _strbuf directly. + + * genops.c (_IO_sgetn), libio.h: New function. + * streambuf.h (streambuf.h::sgetn): Use _IO_sgetn. + * SFile.cc (SFile::operator[]): Use sseekoff, not seekoff. + +Thu Aug 26 10:16:31 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * config.shared (SUBDIRS): only recurse if the directory is configured + +Wed Aug 25 12:56:12 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * config/{hpux.mt, isc.mt, sco4.mt}: + Moved from ../libg++/config (since they affect _G_config.h). + * configure.in: Set target_make_frag to one of the above files. + +Fri Aug 20 00:53:14 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * iofopen.c (iofopen): Fix type passed to _IO_un_link(). + * Makefile.in (_G_config.h): Pass $CC (not $CXX) as CC. + + * configure.in (configdirs): Add dbz and stdio. + * fileops.c (_IO_file_seekoff): Convert more old functionality. + * iofdopen.c: Use mode parameter to set _flags. + * iofscanf.c, ioputs.c, ioscanf.c, iosprintf.c: New files. + * Makefile.in (IO_OBJECTS): Added new objects. + * iostdio.h: Add feof. fscanf, puts, sprintf, vsprintf. + * libio.h: Add _IO_vprintf macro. + * iofopen.c: Invoke _IO_un_link if failure. + * iovsprintf.c: Write terminating NUL. + + * libioP.h: Add COERCE_FILE macro (by default does nothing). + * iofclose.c, iofflush.c, iofgets.c, iofprintf.c, iofputs.c, + iofread.c, ioftell.c, iofwrite.c, iosetbuf.c, iosetvbuf.c: + Invoke COERCE_FILE macro. + * ioftell.c: Use _IO_seekoff. + +Wed Aug 18 22:49:56 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * sbform.cc (streambuf::form), sbscan.cc (streambuf::scan): + Remove cast to _IO_va_list. (Loses if array type.) + + * libio.h: Handle _IO_va_list for systems that need . + * floatconv.h: Fix typo (reported by H.J.Lu). + +Wed Aug 18 19:34:04 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in (INSTALLDIR): handle native vs. cross case + + * Makefile.in (install): don't use $TARGETLIB, set INSTALLDIR to + $(libdir) + +Wed Aug 18 12:10:03 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Rename iostream-files to iostream.list. + * configure.in: Add iostream.list to MOSTLYCLEAN. + +Tue Aug 17 18:56:59 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in: Depend on _G_config.h where appropriate. + * config.shared (CXXINCLUDES): If doing libg++, search ../libio. + +Tue Aug 17 17:34:24 1993 Per Bothner (bothner@kalessin.cygnus.com) + + New directory. Based on old libg++/iostream code, + but extensively re-written. + + diff --git a/libio/Makefile.in b/libio/Makefile.in new file mode 100644 index 000000000000..ccf8f3ecc528 --- /dev/null +++ b/libio/Makefile.in @@ -0,0 +1,124 @@ +# Copyright (C) 1993, 1995 Free Software Foundation +# +# This file is part of the GNU IO 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 this library; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +srcdir = . + +VERSION = 2.8.0 +# The config file (overriden by Linux). +_G_CONFIG_H=_G_config.h +tooldir = $(exec_prefix)/$(target) +INSTALLDIR = $(libdir) + +IO_OBJECTS = filedoalloc.o floatconv.o genops.o fileops.o \ + iovfprintf.o \ + iovfscanf.o ioignore.o iopadn.o \ + iofgetpos.o iofread.o iofscanf.o \ + iofsetpos.o iogetdelim.o iogetline.o \ + ioprintf.o ioseekoff.o ioseekpos.o \ + outfloat.o strops.o iofclose.o iopopen.o ioungetc.o + +# These emulate stdio functionality, but with a different name (_IO_ungetc +# instead of ungetc), and using _IO_FILE instead of FILE. +# They are not needed for C++ iostream, nor stdio, though some stdio +# files are build using the same source files (see stdio/configure.in). +# They are needed for iostdio.h. They are needed under Linux to avoid +# version incompatibility problems with the C library. +# iofclose.o is not here, because it is needed for stdio (by pclose). +STDIO_WRAP_OBJECTS = iofdopen.o iofflush.o iofgets.o iofopen.o iofprintf.o iofputs.o iofwrite.o \ + iogets.o ioperror.o ioputs.o ioscanf.o iosetbuffer.o iosetvbuf.o \ + iosprintf.o iosscanf.o ioftell.o iovsprintf.o iovsscanf.o + +IOSTREAM_OBJECTS = builtinbuf.o filebuf.o fstream.o \ + indstream.o ioassign.o ioextend.o iomanip.o iostream.o \ + isgetline.o isgetsb.o isscan.o \ + osform.o procbuf.o sbform.o sbgetline.o sbscan.o \ + stdiostream.o stdstrbufs.o stdstreams.o stream.o streambuf.o strstream.o \ + PlotFile.o SFile.o parsestream.o pfstream.o editbuf.o + +# These files define _IO_read etc, which are just wrappers for read(2) etc. +# They need to be changed to use name-space-clean (e.g. __read) versions +# for each specific libc. +OSPRIM_OBJECTS = ioprims.o iostrerror.o cleanup.o + +LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(OSPRIM_OBJECTS) +LIBIO_OBJECTS = $(IO_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS) stdfiles.o + +LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS) +LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS) + +USER_INCLUDES = *.h + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +libio.a: $(_G_CONFIG_H) $(LIBIO_OBJECTS) + -rm -rf libio.a + $(AR) $(AR_FLAGS) libio.a $(LIBIO_OBJECTS) + $(RANLIB) libio.a + +libiostream.a: $(_G_CONFIG_H) $(LIBIOSTREAM_DEP) + -rm -rf libiostream.a + $(AR) $(AR_FLAGS) libiostream.a $(LIBIOSTREAM_USE) + $(RANLIB) libiostream.a + +test: test.o libio.a + $(CC) $(CFLAGS) -o test test.o libio.a +tpipe: tpipe.o libio.a + $(CC) $(CFLAGS) -o tpipe tpipe.o libio.a + +iostream.list: stamp-picdir $(_G_CONFIG_H) $(LIBIOSTREAM_DEP) + @echo "$(LIBIOSTREAM_USE)"> iostream.list + +stdio/stdio.list: force + @rootme=`pwd`/ ; export rootme; cd stdio ; \ + $(MAKE) $(FLAGS_TO_PASS) stdio.list + +stdio.list: stdio/stdio.list + rm -f tstdio.list + sed 's,\([a-z_]*\.o\),stdio/\1,g' stdio/stdio.list > tstdio.list + mv tstdio.list stdio.list + +_G_config.h: ${srcdir}/gen-params + rootme=`pwd`/ ; export rootme; \ + CC="$(CC)"; export CC; \ + CXX="$(CXX) $(NOSTDINC) $(CXXFLAGS)"; export CXX; \ + CONFIG_NM="$(NM)"; export CONFIG_NM; \ + $(SHELL) ${srcdir}/gen-params LIB_VERSION=$(VERSION) $(G_CONFIG_ARGS) >tmp-params.h + mv tmp-params.h _G_config.h + +install: + rootme=`pwd`/ ; export rootme ; \ + if [ -z "$(MULTISUBDIR)" ]; then \ + if [ "$(_G_CONFIG_H)" != "" ]; then \ + rm -f $(tooldir)/include/_G_config.h ; \ + $(INSTALL_DATA) _G_config.h $(tooldir)/include/_G_config.h || exit 1; \ + else true; \ + fi ; \ + cd $(srcdir); \ + for FILE in $(USER_INCLUDES); do if [ $$FILE != _G_config.h ]; then \ + rm -f $(gxx_includedir)/$$FILE ; \ + $(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE ; \ + chmod a-x $(gxx_includedir)/$$FILE ; \ + else true; fi; done ; \ + else true; \ + fi + @rootme=`pwd`/ ; export rootme ; \ + $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install + +c++clean: + rm -rf $(IOSTREAM_OBJECTS) + @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=tests" DO=clean subdir_do diff --git a/libio/NEWS b/libio/NEWS new file mode 100644 index 000000000000..4a4ade283704 --- /dev/null +++ b/libio/NEWS @@ -0,0 +1,51 @@ +*** Major changes in libio version 2.7.0: + +* The data representations of _IO_FILE and streambufs have been modified. + The layout of the jump-table table _IO_jumps_t has been re-arranged + to match that of a virtual function table of a streambuf. Therefore, + we no longer need a separate _IO_FILE::_jumps pointer; instead it can + be shared with the virtual function table pointer. In addition to + saving space, this also removes the overhead when double indirection + was needed, and there are many simplificatons (e.g. we no longer need + the builtinbuf class. + +* The streambuf::uflow virtual has been added, to match the standard. + +* The ifstream, ofstream, and fstream classes now include the filebuf + as a member, rather than being pointed to it. Various related changes. + +* Version number changed to generally follow libg++ (and gcc). + +*** Major changes in libio version 0.66 (released with libg++ 2.6.1): + +* Some documentation and an example in iostream.texi on how to derive + your own class from streambuf. + +* New functions added to stdio: getline, detdelim, snprintf, vsnprintf. + This is for compatibility with the GNU C library. + +*** Major changes in libio version 0.65 (released with libg++ 2.6): + +* _IO_getline and streambuf::sgetline no longer write a '\0' at the end. + +* A number of improvements to get closer to the ANSI/ISO C++ working +paper, such as: +- Added (preliminary support for) new ANSI streambuf::uflow virtual. +- Added istdiostream and ostdiostream classes. +- Added ostream::operator<<(bool) and istream::operator>>(bool&). + +* More robust (and faster) initialization and cleanup of standard streambufs. + +* Many small bug fixes, portability improvements, and random enhancements. + +*** Major changes in libio version 0.63 (released with libg++ 2.5.3): + +* There is a g++ bug that causes inconsistent name mangling for the +assembler name of the virtual function table for the istream class. +A work-around has been put into streambuf.h, which will make g++ +always do the right thing. Note that this may require you to +recompile programs that were incorrectly compiled by g++. + +* Functions that do printf-style formatting to the unbuffered +streams have been optimized to write to a temporary buffer. + diff --git a/libio/PlotFile.cc b/libio/PlotFile.cc new file mode 100644 index 000000000000..98b2d839555d --- /dev/null +++ b/libio/PlotFile.cc @@ -0,0 +1,157 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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 may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988, 1992, 1993 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + converted to use iostream library by Per Bothner (bothner@cygnus.com) + +This file is part of the GNU IO 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 this library; 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 GCC 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. */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include + +/* + PlotFile implementation module +*/ + + +PlotFile& PlotFile:: cmd(char c) +{ + ofstream::put(c); + return *this; +} + +PlotFile& PlotFile:: operator<<(const int x) +{ +#if defined(convex) + ofstream::put((char)(x>>8)); + ofstream::put((char)(x&0377)); +#else + ofstream::put((char)(x&0377)); + ofstream::put((char)(x>>8)); +#endif + return *this; +} + +PlotFile& PlotFile:: operator<<(const char *s) +{ + *(ofstream*)this << s; + return *this; +} + + +PlotFile& PlotFile:: arc(const int xi, const int yi, + const int x0, const int y0, + const int x1, const int y1) +{ + return cmd('a') << xi << yi << x0 << y0 << x1 << y1; +} + + +PlotFile& PlotFile:: box(const int x0, const int y0, + const int x1, const int y1) +{ + line(x0, y0, x0, y1); + line(x0, y1, x1, y1); + line(x1, y1, x1, y0); + return line(x1, y0, x0, y0); +} + +PlotFile& PlotFile:: circle(const int x, const int y, const int r) +{ + return cmd('c') << x << y << r; +} + +PlotFile& PlotFile:: cont(const int xi, const int yi) +{ + return cmd('n') << xi << yi; +} + +PlotFile& PlotFile:: dot(const int xi, const int yi, const int dx, + int n, const int* pat) +{ + cmd('d') << xi << yi << dx << n; + while (n-- > 0) *this << *pat++; + return *this; +} + +PlotFile& PlotFile:: erase() +{ + return cmd('e'); +} + +PlotFile& PlotFile:: label(const char* s) +{ + return cmd('t') << s << "\n"; +} + +PlotFile& PlotFile:: line(const int x0, const int y0, + const int x1, const int y1) +{ + return cmd('l') << x0 << y0 << x1 << y1; +} + +PlotFile& PlotFile:: linemod(const char* s) +{ + return cmd('f') << s << "\n"; +} + +PlotFile& PlotFile:: move(const int xi, const int yi) +{ + return cmd('m') << xi << yi; +} + +PlotFile& PlotFile:: point(const int xi, const int yi) +{ + return cmd('p') << xi << yi; +} + +PlotFile& PlotFile:: space(const int x0, const int y0, + const int x1, const int y1) +{ + return cmd('s') << x0 << y0 << x1 << y1; +} diff --git a/libio/PlotFile.h b/libio/PlotFile.h new file mode 100644 index 000000000000..82b08bc4681c --- /dev/null +++ b/libio/PlotFile.h @@ -0,0 +1,89 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* + a very simple implementation of a class to output unix "plot" + format plotter files. See corresponding unix man pages for + more details. + + written by Doug Lea (dl@rocky.oswego.edu) + converted to use iostream library by Per Bothner (bothner@cygnus.com) +*/ + +#ifndef _PlotFile_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _PlotFile_h + +#include + +/* + Some plot libraries have the `box' command to draw boxes. Some don't. + `box' is included here via moves & lines to allow both possiblilties. +*/ + +extern "C++" { +class PlotFile : public ofstream +{ +protected: + PlotFile& cmd(char c); + PlotFile& operator << (const int x); + PlotFile& operator << (const char *s); + +public: + + PlotFile() : ofstream() { } + PlotFile(int fd) : ofstream(fd) { } + PlotFile(const char *name, int mode=ios::out, int prot=0664) + : ofstream(name, mode, prot) { } + +// PlotFile& remove() { ofstream::remove(); return *this; } + +// int filedesc() { return ofstream::filedesc(); } +// const char* name() { return File::name(); } +// void setname(const char* newname) { File::setname(newname); } +// int iocount() { return File::iocount(); } + + PlotFile& arc(const int xi, const int yi, + const int x0, const int y0, + const int x1, const int y1); + PlotFile& box(const int x0, const int y0, + const int x1, const int y1); + PlotFile& circle(const int x, const int y, const int r); + PlotFile& cont(const int xi, const int yi); + PlotFile& dot(const int xi, const int yi, const int dx, + int n, const int* pat); + PlotFile& erase(); + PlotFile& label(const char* s); + PlotFile& line(const int x0, const int y0, + const int x1, const int y1); + PlotFile& linemod(const char* s); + PlotFile& move(const int xi, const int yi); + PlotFile& point(const int xi, const int yi); + PlotFile& space(const int x0, const int y0, + const int x1, const int y1); +}; +} // extern "C++" +#endif diff --git a/libio/README b/libio/README new file mode 100644 index 000000000000..c2d564965ca4 --- /dev/null +++ b/libio/README @@ -0,0 +1,30 @@ +This is libio, the GNU C/C++ input/output library. + +By default, the library is configured to build the C++ iostream +facility (in $libdir/libiostream.a). + +The library can be configured to build the C stdio facility +that is part of a C run-time library. + +This library is distributed with libg++; see ../libg++/README +for installation instructions, and where to send bug reports +and questions. + +* Copyright restrictions + +The files in this directory are generally covered by the GNU Public +License (which is in the file ../COPYING), but modified with the +following: + + 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. + +A few source files and subroutines are covered by other (but +less restrictive) copyright conditions. E.g. some code (such +as iovfprintf.c) is based on software that was developed by the +University of California, Berkeley, for the Berkeley Software +Distribution (BSD-4.4), and bears their copyright; and one +file (floatconv.c) is derived from ("free") code copyrighted AT&T. diff --git a/libio/SFile.cc b/libio/SFile.cc new file mode 100644 index 000000000000..e5daa645695e --- /dev/null +++ b/libio/SFile.cc @@ -0,0 +1,82 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU C++ Library. This library 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 of the License, 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 Library General Public License for more details. +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include + +SFile::SFile(const char *filename, int size, int mode, int prot) +: fstream(filename, mode, prot) +{ + sz = size; +} + +SFile::SFile(int fd, int size) +: fstream(fd) +{ + sz = size; +} + +void SFile::open(const char *name, int size, int mode, int prot) +{ + fstream::open(name, mode, prot); + sz = size; +} + +SFile& SFile::get(void* x) +{ + read(x, sz); + return *this; +} + +SFile& SFile::put(void* x) +{ + write(x, sz); + return *this; +} + +SFile& SFile::operator[](long i) +{ + if (rdbuf()->pubseekoff(i * sz, ios::beg) == EOF) + set(ios::badbit); + return *this; +} diff --git a/libio/SFile.h b/libio/SFile.h new file mode 100644 index 000000000000..f07277cee49f --- /dev/null +++ b/libio/SFile.h @@ -0,0 +1,55 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1988, 1992, 1993 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of the GNU IO 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 this library; 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. */ + +#ifndef _SFile_h +#ifdef __GNUG__ +#pragma interface +#endif +#define _SFile_h 1 + +#include + +extern "C++" { +class SFile: public fstream +{ + protected: + int sz; // unit size for structured binary IO + +public: + SFile() : fstream() { } + SFile(int fd, int size); + SFile(const char *name, int size, int mode, int prot=0664); + void open(const char *name, int size, int mode, int prot=0664); + + int size() { return sz; } + int setsize(int s) { int old = sz; sz = s; return old; } + + SFile& get(void* x); + SFile& put(void* x); + SFile& operator[](long i); +}; +} // extern "C++" + +#endif diff --git a/libio/builtinbuf.cc b/libio/builtinbuf.cc new file mode 100644 index 000000000000..05e65a5c371b --- /dev/null +++ b/libio/builtinbuf.cc @@ -0,0 +1,78 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifdef __GNUC__ +#pragma implementation +#endif +#define _STREAM_COMPAT +#include "builtinbuf.h" +#include "iostreamP.h" +#if !_IO_UNIFIED_JUMPTABLES +int builtinbuf::overflow(int ch) { return _IO_OVERFLOW (this, ch); } + +int builtinbuf::underflow() { return _IO_UNDERFLOW (this); } + +streamsize builtinbuf::xsgetn(char* buf, streamsize n) +{ return _IO_XSGETN (this, buf, n); } + +streamsize builtinbuf::xsputn(const char* buf, streamsize n) +{ return _IO_XSPUTN (this, buf, n); } + +int builtinbuf::doallocate() { return _IO_DOALLOCATE (this); } + +builtinbuf::~builtinbuf() { _IO_FINISH (this); } + +int builtinbuf::sync() { return _IO_SYNC (this); } + +streambuf* builtinbuf::setbuf(char *buf, int n) +{ return (streambuf*)_IO_SETBUF (this, buf, n); } + +streampos builtinbuf::seekoff(streamoff off, _seek_dir dir, int mode) +{ + return _IO_SEEKOFF (this, off, dir, mode); +} + +streampos builtinbuf::seekpos(streampos pos, int mode) +{ + return _IO_SEEKPOS (this, pos, mode); +} + +int builtinbuf::pbackfail(int c) +{ return _IO_PBACKFAIL (this, c); } + +streamsize builtinbuf::sys_read(char* buf, streamsize size) +{ return _IO_SYSREAD (this, buf, size); } + +streampos builtinbuf::sys_seek(streamoff off, _seek_dir dir) +{ return _IO_SYSSEEK (this, off, dir); } + +streamsize builtinbuf::sys_write(const char* buf, streamsize size) +{ return _IO_SYSWRITE (this, buf, size); } + +int builtinbuf::sys_stat(void* buf) // Actually, a (struct stat*) +{ return _IO_SYSSTAT (this, buf); } + +int builtinbuf::sys_close() +{ return _IO_SYSCLOSE (this); } +#endif diff --git a/libio/builtinbuf.h b/libio/builtinbuf.h new file mode 100644 index 000000000000..0e0c6e85a9ef --- /dev/null +++ b/libio/builtinbuf.h @@ -0,0 +1,68 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifndef _BUILTINBUF_H +#define _BUILTINBUF_H + +#ifdef __GNUC__ +#pragma interface +#endif + +#include + +#if !_IO_UNIFIED_JUMPTABLES +// A builtinbuf a a streambuf where all the virtual operations +// call the _IO_jump_t table. + +extern "C++" { +class builtinbuf : public streambuf { + friend ios; + virtual int overflow(int); + virtual int underflow(); + virtual streamsize xsgetn(char *, streamsize); + virtual streamsize xsputn(const char *, streamsize); + virtual streambuf* setbuf(char*, int); + virtual int doallocate(); + virtual ~builtinbuf(); + virtual int sync(); + + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); + virtual int pbackfail(int c); + virtual streamsize sys_read(char* buf, streamsize size); + virtual streampos sys_seek(streamoff, _seek_dir); + virtual streamsize sys_write(const char*, streamsize); + virtual int sys_stat(void*); // Actually, a (struct stat*) + virtual int sys_close(); +#if 0 + virtual int get_column(); + virtual int set_column(int); +#endif + private: + builtinbuf() { } +}; +} // extern "C++" +#endif + +#endif /* _BUILTINBUF_H */ diff --git a/libio/cleanup.c b/libio/cleanup.c new file mode 100644 index 000000000000..a0c5052d3958 --- /dev/null +++ b/libio/cleanup.c @@ -0,0 +1,17 @@ +#include "libioP.h" +#if _G_HAVE_ATEXIT +#include + +typedef void (*voidfunc) __P((void)); + +static void +DEFUN_VOID(_IO_register_cleanup) +{ + atexit ((voidfunc)_IO_cleanup); + _IO_cleanup_registration_needed = 0; +} + +void (*_IO_cleanup_registration_needed)() = _IO_register_cleanup; +#else +void (*_IO_cleanup_registration_needed)() = NULL; +#endif /* _G_HAVE_ATEXIT */ diff --git a/libio/config.shared b/libio/config.shared new file mode 100644 index 000000000000..8c79350e6f5d --- /dev/null +++ b/libio/config.shared @@ -0,0 +1,487 @@ +# Copyright (C) 1993, 1995, 1997 Free Software Foundation +# +# This file is part of the GNU IO 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, 675 Mass Ave, Cambridge, MA 02139, USA. + +# Significant variables: + +# Note that TO_TOPDIR does *not* include multilib. +test -z "${TO_TOPDIR}" && TO_TOPDIR=${TOLIBGXX}../ +# Native configurations build target libraries in directories at the same +# level as the rest of the tree. Cross configurations build target libraries +# one level deeper. TO_REAL_TOPDIR accounts for this. +# Obviously, TO_REAL_TOPDIR can only be used in the build tree. +if [ "${with_target_subdir}" != "." ] ; then + TO_REAL_TOPDIR="${TO_TOPDIR}../" +else + TO_REAL_TOPDIR="${TO_TOPDIR}" +fi +DOING_LIBGXX=${DOING_LIBGXX-false} +THIS_FILE="${srcdir}/${TOLIBGXX}config.shared" + +echo "# Start of package fragment generated by ${THIS_FILE}." +echo "" + +# Multilib support. +echo 'MULTISRCTOP =' +echo 'MULTIBUILDTOP =' +echo 'MULTIDIRS =' +echo 'MULTISUBDIR =' +echo 'MULTIDO = true' +echo 'MULTICLEAN = true' +echo '' + +# TOLIBGXX +# MOSTLYCLEAN +# CLEAN +# DISTCLEAN +# REALCLEAN +# SUBDIRS [defaults to (configdirs)] +# INFO_FILES List of (basenames of) texinfo files +# INFO_SUBDIRS [default: empty] sub-directories containing documentation + +# ??? This doesn't appear to be used by us or any of our callers. +# Note that all uses in this file are single-quoted. +rootme=${rootme-`pwd`} + +# libg++ uses the convention that $rootme includes a trailing '/'. +# We use that in the definition of TOPDIR. $rootme is either empty +# or an absolute pathname to the current directory (with trailing '/'). +TOPDIR=${TOPDIR-'$${rootme}$(MULTIBUILDTOP)'${TO_REAL_TOPDIR}} +echo '#' TOPDIR="${TOPDIR} invsubdir=${invsubdir} subdir=${subdir}" +SUBDIRS=${SUBDIRS-${configdirs}} +CHECK_SUBDIRS=${CHECK_SUBDIRS-${SUBDIRS}} + +echo "srcdir = ${srcdir}" +echo "SUBDIRS = ${SUBDIRS}" +echo "CHECK_SUBDIRS = ${CHECK_SUBDIRS}" + +echo "prefix = ${prefix-/usr/local}" +echo "exec_prefix = ${exec_prefix-'${prefix}'}" + +echo 'bindir = $(exec_prefix)/bin' +echo 'libdir = $(exec_prefix)/lib' + +echo 'datadir = $(prefix)/lib' +echo 'mandir = $(prefix)/man' +echo 'man1dir = $(mandir)/man1' +echo 'man2dir = $(mandir)/man2' +echo 'man3dir = $(mandir)/man3' +echo 'man4dir = $(mandir)/man4' +echo 'man5dir = $(mandir)/man5' +echo 'man6dir = $(mandir)/man6' +echo 'man7dir = $(mandir)/man7' +echo 'man8dir = $(mandir)/man8' +echo 'man9dir = $(mandir)/man9' + +echo 'infodir = $(prefix)/info' +echo 'includedir = $(prefix)/include' +echo 'gxx_includedir = $(includedir)/g++' +echo 'docdir = $(datadir)/doc' +echo '' +echo 'SHELL = /bin/sh' +echo '' +case "$srcdir" in + /*) echo 'INSTALL = $(srcdir)'/"${TO_TOPDIR}install-sh -c" ;; + .) echo 'INSTALL = $${rootme}'"${with_multisrctop}${TO_REAL_TOPDIR}install-sh -c" ;; + *) echo 'INSTALL = $${rootme}$(srcdir)'/"${TO_TOPDIR}install-sh -c" ;; +esac +echo 'INSTALL_PROGRAM = $(INSTALL)' +echo 'INSTALL_DATA = $(INSTALL)' +echo '' +echo 'AR = `if [ -f' ${TOPDIR}'binutils/ar ] ; \' +echo " then echo ${TOPDIR}binutils/ar ; "'\' +echo ' else echo ar ; fi`' +echo 'AR_FLAGS = rc' +echo 'RANLIB = `if [ -f' ${TOPDIR}'binutils/ranlib ] ; \' +echo ' then echo '${TOPDIR}'binutils/ranlib ; \' +echo ' else echo ranlib ; fi`' +echo 'NM = `if [ -f' ${TOPDIR}'binutils/nm.new ] ; \' +echo ' then echo '${TOPDIR}'binutils/nm.new ; \' +echo ' else echo nm ; fi`' +echo 'NLMCONV = `if [ -f' ${TOPDIR}'binutils/nlmconv ] ; \' +echo ' then echo '${TOPDIR}'binutils/nlmconv ; \' +echo ' else echo nlmconv ; fi`' +echo 'LD = `if [ -f' ${TOPDIR}'ld/ld.new ] ; \' +echo ' then echo '${TOPDIR}'ld/ld.new ; \' +echo ' else echo ld ; fi`' +echo '' +echo 'MAKEINFO = `if [ -f '${TOPDIR}'texinfo/C/makeinfo ] ; \' +echo ' then echo '${TOPDIR}'texinfo/C/makeinfo ; \' +echo ' else echo makeinfo ; fi`' +case "$srcdir" in + .) echo 'TEXIDIR = '"${with_multisrctop}${TO_REAL_TOPDIR}texinfo" ;; + *) echo 'TEXIDIR = $(srcdir)'/"${TO_TOPDIR}texinfo" ;; +esac +echo 'TEXI2DVI = TEXINPUTS=${TEXIDIR}:$$TEXINPUTS texi2dvi' +echo '' +echo 'CC = cc' +echo 'CXX = gcc' +echo '' +# FIXME!!! +if true ; then + echo 'WRAP_C_INCLUDES =' +else + echo 'WRAP_C_INCLUDES = -I$(srcdir)'/${TOLIBGXX}g++-include +fi +echo 'CFLAGS = -g' +echo 'CXXFLAGS = -g -O' +echo 'LIBCFLAGS = $(CFLAGS)' +echo 'LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates' +echo 'PICFLAG =' +if [ "${LIBDIR}" = "yes" ]; then + echo 'PICDIR = stamp-picdir' +else + echo 'PICDIR = ' +fi + +if test "${DOING_LIBGXX}" = "true" ; then + echo "TOLIBGXX = ${TOLIBGXX}" + echo 'PROTODIR = $(srcdir)'/${TOLIBGXX}src/gen + echo "LIBS = -L./${TOLIBGXX} -L./${TOLIBGXX}../libstdc++ -lg++ -lstdc++" + + # You can override iostream (e.g. in a site- or host-Makefile fragment) to: + # iostream (Normal iostream library) + # old-stream (Old stream library; no longer supported) + # no-stream (If you don't want iostream to be part of libg++) + echo 'IO_DIR = ../libio' + echo '# IO_DIR = no-stream' +elif test "${DOING_GPERF}" = "true" ; then + echo "IO_DIR = libio" + echo "TOLIBGXX = ${TOLIBGXX}" + echo "LIBS = -L./${TOLIBGXX} -L./${TOLIBGXX}../libstdc++ -lg++ -lstdc++" +fi + +if [ -z "${ALL}" ] ; then + if [ -n "${TARGETLIB}" ] ; then + ALL='$(TARGETLIB)' + echo "TARGETLIB = ${TARGETLIB}" + elif [ -n "${TARGETPROG}" ] ; then + ALL='${TARGETPROG}' + echo "TARGETPROG = ${TARGETPROG}" + else + echo "config error: neither ALL, TARGETLIB or TARGETPROG is defined" 1>&2 + fi +fi + +ALL='$(PICDIR)'" ${ALL}" + +echo "all: ${ALL} multi-all" +if [ "${SUBDIRS}" != "" ] ; then + echo ' @rootme=`pwd`/; export rootme; \' + echo ' $(MAKE) "DODIRS=$(SUBDIRS)" DO=all $(FLAGS_TO_PASS) subdir_do' +fi +echo '.PHONY: all' +echo '' + +echo '.PHONY: multi-all' +echo 'multi-all:' +echo ' @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all' +echo '' + +echo +if [ "${SUBDIRS}" != "" ] ; then + echo '.PHONY: subdir_do' + echo 'subdir_do: force' + echo ' @rootme=`pwd`/; export rootme; \' + echo ' for i in $(DODIRS); do \' + echo ' if [ -f ./$$i/Makefile ] ; then \' + echo ' echo "cd $$i; make $(DO) ..." ; \' + echo ' (cd $$i ; $(MAKE) $(FLAGS_TO_PASS) $(DO)) || exit 1 ; \' + echo ' else true ; fi ; \' + echo ' done' + echo '' + echo '# List of variables to pass to sub-makes. This should not be needed' + echo '# by GNU make or Sun make (both of which pass command-line variable' + echo '# overrides thouh $(MAKE)) but may be needed by older versions.' + echo '' + echo 'FLAGS_TO_PASS= \' + echo ' "INSTALL=$(INSTALL)" \' + echo ' "INSTALL_DATA=$(INSTALL_DATA)" \' + echo ' "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \' + echo ' "prefix=$(prefix)" \' + echo ' "exec_prefix=$(exec_prefix)" \' + echo ' "tooldir=$(tooldir)" \' + echo ' "AR=$(AR)" \' + echo ' "AR_FLAGS=$(AR_FLAGS)" \' + echo ' "CC=$(CC)" \' + echo ' "CXX=$(CXX)" \' + echo ' "CFLAGS=$(CFLAGS)" \' + echo ' "CXXFLAGS=$(CXXFLAGS)" \' + echo ' "NM=$(NM)" \' + echo ' "RANLIB=$(RANLIB)" \' + echo ' "LIBCFLAGS=$(LIBCFLAGS)" \' + echo ' "LIBCXXFLAGS=$(LIBCXXFLAGS)" \' + echo ' "LOADLIBES=$(LOADLIBES)" \' + echo ' "LDFLAGS=$(LDFLAGS)" \' + echo ' "MAKEINFO=$(MAKEINFO)" \' + echo ' "SHLIB=$(SHLIB)" \' + echo ' "SHCURSES=$(SHCURSES)" \' + echo ' "PICFLAG=$(PICFLAG)" \' + echo ' "RUNTESTFLAGS=$(RUNTESTFLAGS)"' +fi + +echo 'NOSTDINC = -nostdinc++' +if test -n "${XCXXINCLUDES}" ; then + echo "CXXINCLUDES = ${XCXXINCLUDES} "'$(NOSTDINC)' +elif test "${DOING_LIBGXX}" = "true" ; then + echo 'CXXINCLUDES = $(NOSTDINC) -I. -I'"${TO_TOPDIR}libio"' -I$(srcdir) -I$(srcdir)/'"${TOLIBGXX}"'$(IO_DIR) -I$(srcdir)/'"${TOLIBGXX}"'../libstdc++ -I$(srcdir)/'"${TOLIBGXX}src"' $(WRAP_C_INCLUDES)' +fi +if test -n "${XCINCLUDES}" ; then + echo "CINCLUDES = ${XCINCLUDES}" +elif test "${DOING_LIBGXX}" = "true" ; then + echo 'CINCLUDES =' +fi + +if [ "${LIBDIR}" = "yes" ]; then + echo 'XCFLAGS = $(LIBCFLAGS)' + echo 'XCXXFLAGS = $(LIBCXXFLAGS)' +else + echo 'XCFLAGS = $(CFLAGS)' + echo 'XCXXFLAGS = $(CXXFLAGS)' +fi + +echo '.SUFFIXES: .o .C .cc .c' +echo 'COMPILE.c = $(CC) -c $(XCFLAGS) $(CINCLUDES)' +echo '.c.o:' +if [ "${LIBDIR}" = "yes" ]; then +echo ' test -z "$(PICFLAG)" ||\' +echo ' $(COMPILE.c) $(PICFLAG) $< -o pic/$@' +fi +echo ' $(COMPILE.c) $<' +[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo ' @touch stamp' +echo 'COMPILE.cc = $(CXX) -c $(XCXXFLAGS) $(CXXINCLUDES)' +echo '.C.o:' +if [ "${LIBDIR}" = "yes" ]; then +echo ' test -z "$(PICFLAG)" ||\' +echo ' $(COMPILE.cc) $(PICFLAG) $< -o pic/$@' +fi +echo ' $(COMPILE.cc) $<' +[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo ' @touch stamp' +echo '.cc.o:' +if [ "${LIBDIR}" = "yes" ]; then +echo ' test -z "$(PICFLAG)" || \' +echo ' $(COMPILE.cc) $(PICFLAG) $< -o pic/$@' +fi +echo ' $(COMPILE.cc) $<' +[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo ' @touch stamp' +echo '' + +if [ -n "${TARGETLIB}" ] ; then + echo TARGETLIB = ${TARGETLIB} +fi +if [ -n "${TARGETPROG}" ] ; then + echo TARGETPROG = ${TARGETPROG} +fi + +if [ "${LIBDIR}" = "yes" ]; then + echo '' + echo 'stamp-picdir:' + echo ' if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \' + echo ' mkdir pic; \' + echo ' else true; fi' + echo ' touch stamp-picdir' +fi + +echo '' +echo '.PHONY: install' +echo 'install:' +echo '.PHONY: check' +if [ "${CHECK}" != "check" ] ; then + echo "check: ${ALL} ${CHECK}" + if [ "${CHECK_SUBDIRS}" != "" ] ; then + echo ' rootme=`pwd`/; export rootme; \' + echo ' SAVE_LLPATH="$${SAVE_LLPATH-$$LD_LIBRARY_PATH}"; export SAVE_LLPATH; \' + echo ' LD_LIBRARY_PATH="$${rootme}${TOLIBGXX}../libstdc++:$${rootme}${TOLIBGXX}../libg++:$$SAVE_LLPATH"; \' + echo ' export LD_LIBRARY_PATH; \' + echo ' $(MAKE) "DODIRS=$(CHECK_SUBDIRS)" DO=check $(FLAGS_TO_PASS) subdir_do' + fi +fi + +# Generate rules for documentation (depending on INFO_FILES and INFO_SUBDIRS). + +echo '.PHONY: info dvi install-info clean-info' + +# emit the rule for 'info' +# (Note that the top-level ../Makefile.in greps for '^info:' when making +# a release (in "make taz"), so don't break that!) +if [ -z "${INFO_FILES}" ] ; then + echo 'info:' +else + echo info: `for file in ${INFO_FILES} ; do echo $file.info ; done` +fi +if [ "${INFO_SUBDIRS}" != "" ] ; then + echo ' @rootme=`pwd`/; export rootme; \ + $(MAKE) "DODIRS='${INFO_SUBDIRS}'" DO=info $(FLAGS_TO_PASS) subdir_do' +fi + +# emit the rule for 'dvi' +if [ -z "${INFO_FILES}" ] ; then + echo 'dvi:' +else + echo dvi: `for file in ${INFO_FILES} ; do echo $file.dvi ; done` +fi +if [ "${INFO_SUBDIRS}" != "" ] ; then + echo ' @rootme=`pwd`/; export rootme; \ + $(MAKE) "DODIRS='${INFO_SUBDIRS}'" DO=dvi $(FLAGS_TO_PASS) subdir_do' +fi + +# Emit rules for each *.info and *.dvi file +for file in ${INFO_FILES} ; do + echo ${file}.info: '$(srcdir)'/${file}.texi + echo ' $(MAKEINFO) -I$(srcdir) -I$(TEXIDIR) $(srcdir)/'${file}.texi -o ${file}.info + echo ${file}.dvi: '$(srcdir)'/${file}.texi + echo ' $(TEXI2DVI) $(srcdir)'/${file}.texi + echo "${file}.ps: ${file}.dvi" + echo " dvips ${file} -o" +done + +# emit the rule for install-info +echo 'install-info:' +if [ -n "${INFO_FILES}" ] ; then + echo ' -parent=`echo $(infodir)|sed -e' "'"'s@/[^/]*$$@@'"'"'`; \' + echo ' if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi' + echo ' -if [ -d $(infodir) ] ; then true ; else mkdir $(infodir) ; fi' + echo ' for i in *.info* ; do \' + echo ' $(INSTALL_DATA) $$i $(infodir)/$$i ; \' + echo ' done' +fi +if [ "${INFO_SUBDIRS}" != "" ] ; then + echo ' @rootme=`pwd`/; export rootme; \ + $(MAKE) "DODIRS='${INFO_SUBDIRS}'" DO=install-info $(FLAGS_TO_PASS) subdir_do' +fi + +# emit clean-info and clean-dvi rules +echo '.PHONY: do-clean-info clean-info do-clean-dvi clean-dvi' +echo do-clean-info: +if [ -n "${INFO_FILES}" ] ; then + echo ' rm -f *.info*' +fi +echo 'do-clean-dvi:' +if [ -n "${INFO_FILES}" ] ; then + echo ' rm -f *.dvi *.aux *.cp *.cps *.fn* *.ky *.log *.pg *.toc *.tp *.vr' +fi +for type in info dvi ; do + echo clean-${type}: do-clean-${type} + if [ "${INFO_SUBDIRS}" != "" ] ; then + echo ' @rootme=`pwd`/; export rootme; \ + $(MAKE) "DODIRS='${NFO_SUBDIRS}'" DO=clean-'${type} '$(FLAGS_TO_PASS) subdir_do' + fi +done + +echo '' + +echo '.PHONY: boltcc' +echo 'boltcc:' +echo ' rootme=`pwd`/ ; export rootme ; $(MAKE) $(FLAGS_TO_PASS)' +echo '' + +# Emit clean rules + +echo '' +echo '# clean rules' + +MOSTLYCLEAN="${MOSTLYCLEAN-*.o pic stamp-picdir core ${EXTRA_MOSTLYCLEAN}} `if test -n "${TOUCH_ON_COMPILE}"; then echo stamp; else true; fi`" +CLEAN="${CLEAN-${TARGETPROG} ${TARGETLIB}}" +DISTCLEAN="${DISTCLEAN-config.status Makefile *~ Make.pack multilib.out ${EXTRA_DISTCLEAN-}}" +REALCLEAN="${REALCLEAN-depend *.info*}" + + +echo '.PHONY: mostlyclean clean distclean maintainer-clean realclean' +if test -z "${SUBDIRS}" ; then + echo "mostlyclean: clean-dvi" + echo " rm -rf ${MOSTLYCLEAN}" + echo ' @$(MULTICLEAN) multi-clean DO=mostlyclean' + echo "clean: clean-dvi" + echo " rm -rf ${MOSTLYCLEAN} ${CLEAN}" + echo ' @$(MULTICLEAN) multi-clean DO=clean' + echo "distclean: clean" + echo ' @$(MULTICLEAN) multi-clean DO=distclean' + echo " rm -rf ${DISTCLEAN}" + echo "maintainer-clean realclean: clean clean-info" + echo ' @$(MULTICLEAN) multi-clean DO=maintainer-clean' + echo " rm -rf ${DISTCLEAN} ${REALCLEAN}" +else + echo '.PHONY: do-clean subdir_distclean subdir_maintainer_clean' + echo "mostlyclean: do-clean-dvi" + echo " rm -rf ${MOSTLYCLEAN}" + echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=mostlyclean subdir_do' + echo ' @$(MULTICLEAN) multi-clean DO=mostlyclean' + echo "do-clean: do-clean-dvi" + echo " rm -rf ${MOSTLYCLEAN} ${CLEAN}" + echo "clean: do-clean" + echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=clean subdir_do' + echo ' @$(MULTICLEAN) multi-clean DO=clean' + # distclean and maintainer-clean are tricky because they remove the Makefile. + echo "subdir_distclean:" + echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=distclean subdir_do' + echo "distclean: do-clean subdir_distclean" + echo ' @$(MULTICLEAN) multi-clean DO=distclean' + echo " rm -rf ${DISTCLEAN}" + echo "subdir_maintainer_clean:" + echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=maintainer-clean subdir_do' + echo "maintainer-clean realclean: do-clean subdir_maintainer_clean do-clean-info" + echo ' @$(MULTICLEAN) multi-clean DO=maintainer-clean' + echo " rm -rf ${DISTCLEAN} ${REALCLEAN}" +fi + +echo '' +echo '.PHONY: force' +echo 'force:' +echo '' +echo '# with the gnu make, this is done automatically.' +echo '' +echo 'Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)' +echo ' $(SHELL) ./config.status' +echo '' +echo '.NOEXPORT:' +echo 'MAKEOVERRIDES=' + +cat <<"EOF" +DEPEND_SOURCES = ${srcdir}/*.cc ${srcdir}/*.c +depend.new: +# The sed script below attempts to make the depend output portable. +# It cleans up the depenency information generated by cpp. +# It replaces instances of $(srcdir)/ by the string '$(srcdir)/'. +# It removes remaining absolute files names (such as /usr/include/stdio.h). +# It removes lines containing only "\\". +# It inserts '$(MULTISRCTOP)' in '$(srcdir)/..'. +# In order to support SunOS VPATH, $(srcdir)/[a-z]*.{c,cc} is replaced with +# [a-z]*.{c,cc} (the directory part is removed). +# The awk script removes a continuation marker that is followed by +# a blank line, since that may confuse make. + echo "# AUTOMATICALLY GENERATED BY 'make depend' - DO NOT EDIT" \ + >depend.new + $(CXX) -M $(CXXINCLUDES) $(DEPEND_SOURCES) \ + | sed -e 's|$(srcdir)/|$$(srcdir)/|g' \ + -e 's| /[^ ]*||g' \ + -e '/^[ ]*\\$$/d' -e 's/^[ ]*$$//' \ + | sed -e 's|$$(srcdir)/[.][.]|$$(srcdir)/$$(MULTISRCTOP)..|g' \ + -e 's|$$(srcdir)/\([^/]*[.]c\)|\1|' \ + | awk 'BEGIN { prev = "" } \ + /^( )*$$/ { if (prev ~ /\\$$/) \ + { prev = substr(prev,1,length(prev)-1); next } } \ + { print prev; prev = $$0 } \ + END { if (prev !~ /^( )*$$/) print prev }' \ + >> depend.new +$(srcdir)/depend: depend.new + mv depend.new $(srcdir)/depend +EOF + +if [ -f ${srcdir}/${subdir}/depend ] ; then + cat ${srcdir}/${subdir}/depend +fi + +echo "# End of package fragment generated by ${THIS_FILE}." diff --git a/libio/config/hpux.mt b/libio/config/hpux.mt new file mode 100644 index 000000000000..fc95afa64fa9 --- /dev/null +++ b/libio/config/hpux.mt @@ -0,0 +1,3 @@ +# Flags to pass to gen-params when building _G_config.h. +# For example: G_CONFIG_ARGS = size_t="unsigned long" +G_CONFIG_ARGS = DOLLAR_IN_LABEL=1 diff --git a/libio/config/isc.mt b/libio/config/isc.mt new file mode 100644 index 000000000000..15cbb8c36c2e --- /dev/null +++ b/libio/config/isc.mt @@ -0,0 +1,4 @@ +# Flags to pass to gen-params when building _G_config.h. +# For example: G_CONFIG_ARGS = size_t="unsigned long" +G_CONFIG_ARGS = pid_t="unsigned short" \ + gid_t="unsigned short" uid_t="unsigned short" diff --git a/libio/config/linux.mt b/libio/config/linux.mt new file mode 100644 index 000000000000..25d29c539a59 --- /dev/null +++ b/libio/config/linux.mt @@ -0,0 +1,26 @@ +# Since the Linux C library has libio, we have to be very careful. + +# By default, we build libio and use it. If someone wants to not +# build it, let them go to extra work. The reason is that the user +# may want a newer, bug fixed libio, also on a linux 1.0.8 system +# things just won't build with the bottom section uncommented. + +# Comment this out to avoid including the stdio functions in libiostream.a: +LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS) +LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS) stdio.list +LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS) `cat stdio.list` + +# Comment the above and uncomment the below to use the code in the Linux libc: +# We have _G_config.h in /usr/include. +# _G_CONFIG_H= + +# We have those in libc.a. +# IO_OBJECTS= +# STDIO_WRAP_OBJECTS= +# OSPRIM_OBJECTS= + +# We have the rest in /usr/include. +# USER_INCLUDES=PlotFile.h SFile.h builtinbuf.h editbuf.h fstream.h \ +# indstream.h iomanip.h iostream.h istream.h ostream.h \ +# parsestream.h pfstream.h procbuf.h stdiostream.h stream.h \ +# streambuf.h strfile.h strstream.h diff --git a/libio/config/mn10200.mt b/libio/config/mn10200.mt new file mode 100644 index 000000000000..71e79167658b --- /dev/null +++ b/libio/config/mn10200.mt @@ -0,0 +1,3 @@ +# Flags to pass to gen-params when building _G_config.h. +# For example: G_CONFIG_ARGS = size_t="unsigned long" +G_CONFIG_ARGS = NO_USE_DTOA=1 USE_INT32_FLAGS=1 diff --git a/libio/config/netware.mt b/libio/config/netware.mt new file mode 100644 index 000000000000..339a865717c0 --- /dev/null +++ b/libio/config/netware.mt @@ -0,0 +1,16 @@ +IMPDIR= $(srcdir)/config/netware + +PRELUDE= prelude.o + +iostream.def: Makefile + -rm -f iostream.def + echo "description \"libiostream\"" >> iostream.def + echo "screenname \"NONE\"" >> iostream.def + echo "version `echo $(VERSION) | sed 's|\.|,|g'`" >> iostream.def + echo "export @$(IMPDIR)/iostream.imp" >> iostream.def + +iostream.O: $(PRELUDE) $(LIBIOSTREAM_OBJECTS) + $(CC) -Xlinker -Ur -o $@ $(PRELUDE) $(LIBIOSTREAM_OBJECTS) + +iostream.nlm: iostream.def iostream.O $(IMPDIR)/iostream.imp + $(NLMCONV) -l $(LD) -T iostream.def iostream.O iostream.nlm diff --git a/libio/config/sco4.mt b/libio/config/sco4.mt new file mode 100644 index 000000000000..1d8f6f189c38 --- /dev/null +++ b/libio/config/sco4.mt @@ -0,0 +1,3 @@ +# Flags to pass to gen-params when building _G_config.h. +# For example: G_CONFIG_ARGS = size_t="unsigned long" +G_CONFIG_ARGS = MATH_H_INLINES=1 diff --git a/libio/configure.in b/libio/configure.in new file mode 100644 index 000000000000..d6359382bcfc --- /dev/null +++ b/libio/configure.in @@ -0,0 +1,93 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../configure. + +configdirs="tests dbz stdio testsuite" +srctrigger=libioP.h +srcname="input/output library" +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +echo "# Warning: this fragment is automatically generated" > temp.mt +frags= + +case "${target}" in + *-hpux*) frags=hpux.mt ;; + *-linux*) + echo "WARNING: The I/O implementation in FSF libg++ 2.8.x is not" + echo " compatible with Linux libc through 5.2.x." + echo " See libg++/README for more information." + echo " YOU ARE ON YOUR OWN!" + frags=linux.mt ;; + *-sco3.2v[45]*) frags=sco4.mt ;; + *-isc*) frags=isc.mt ;; + *-netware*) frags=netware.mt ;; + *) frags=${target_cpu}.mt ;; +esac + +case "${enable_shared}" in + yes) shared=yes ;; + no) shared=no ;; + *libio*) shared=yes ;; + *) shared=no ;; +esac + +if [ "${shared}" = "yes" ]; then + case "${target}" in + hppa*-*) frags="${frags} ../../config/mh-papic" ;; + i[3456]86-*) frags="${frags} ../../config/mh-x86pic" ;; + *) frags="${frags} ../../config/mh-${target_cpu}pic" ;; + esac +fi + +for frag in ${frags}; do + frag=${srcdir}/config/$frag + if [ -f ${frag} ]; then + echo "Appending ${frag} to target-mkfrag" + echo "# Following fragment copied from ${frag}" >> temp.mt + cat ${frag} >> temp.mt + fi +done + +target_makefile_frag=target-mkfrag +${moveifchange} temp.mt target-mkfrag + +LIBDIR=yes +TO_TOPDIR=../ +ALL='$(_G_CONFIG_H) libio.a iostream.list' +XCINCLUDES='-I. -I$(srcdir)' +XCXXINCLUDES='-I. -I$(srcdir)' +MOSTLYCLEAN='*.o pic stamp-picdir core iostream.list' +DISTCLEAN='config.status Makefile *~ Make.pack target-mkfrag multilib.out' +CLEAN='_G_config.h *.a' +INFO_FILES=iostream +if [ -n "${with_cross_host}" ] ; then + CHECK_SUBDIRS=testsuite +fi +(. ${srcdir}/config.shared) >${package_makefile_frag} + +# post-target: + +# If cross-compiling, don't build gperf or the utils. They +# will get built by the target compiler, which is confusing. +# We cannot test the installation. We install in $(tooldir). +if [ -n "${with_cross_host}" ] ; then + rm -f Makefile.tem + sed \ + -e 's|INSTALLDIR.*=.*$|INSTALLDIR = $(tooldir)/lib|' \ + Makefile >Makefile.tem + mv -f Makefile.tem Makefile +fi + +if [ "${srcdir}" = "." ] ; then + if [ "${with_target_subdir}" != "." ] ; then + . ${with_multisrctop}../../config-ml.in + else + . ${with_multisrctop}../config-ml.in + fi +else + . ${srcdir}/../config-ml.in +fi diff --git a/libio/dbz/Makefile.in b/libio/dbz/Makefile.in new file mode 100644 index 000000000000..3f7833be8407 --- /dev/null +++ b/libio/dbz/Makefile.in @@ -0,0 +1,217 @@ +srcdir = . +CFLAGS = -g +C_FLAGS = $(CFLAGS) -I$(srcdir) -I.. -I$(srcdir)/.. -DDBZ_FINISH='_IO_flush_all()' +CC = `if [ -f ../../../gcc/gcc ] ; \ + then echo ../../../gcc/gcc -B../../../gcc/ ; \ + else echo gcc ; fi` +LIBIO = ../libio.a ../../libiberty/libiberty.a +LIBS = $(LIBIO) +# LIBS = ../libcnews.a +DBM = +RFC = -DHAVERFCIZE +CASE = case.o +DEBUG = -DDBZDEBUG +LINTFLAGS = -h $(DEBUG) $(RFC) -I$(srcdir) +LDFLAGS = +# =()@>()= +NEWSBIN = /usr/lib/newsbin +# workaround for System V make bug +SHELL = /bin/sh + +# database sizes for performance tests, regression, and regression prime-find +TSIZE=12007 +RSIZE=4019 +RPSIZE=2679 + +#### host and target dependent Makefile fragments come in here. +## + +# history files for regression and performance tests +RHIST=hist3.3 +R2HIST=hist10 +THIST=hist13 + +#all: dbz +all: +install: +install-info: +info: + +check: r rclean + +bininstall: dbz + cp dbz $(NEWSBIN) + +cmp: dbz + cmp dbz $(NEWSBIN)/dbz + +newsinstall: + : nothing + +u: dbz.o + ar ruv ../libcnews.a dbz.o + cmp dbz.h ../h/dbz.h + +t: tdbz fake + +lint: + lint $(LINTFLAGS) dbzmain.c dbz.c + +.c.o: + $(CC) $(C_FLAGS) -c $< + +rdbz.o: rdbz.c + $(CC) $(C_FLAGS) $(DEBUG) -DDEFSIZE=$(RSIZE) -c rdbz.c + +rdbzmain.o: rdbzmain.c + $(CC) $(C_FLAGS) $(RFC) -c rdbzmain.c + +tdbz.o: $(srcdir)/dbz.c + cp $(srcdir)/dbz.c tdbz.c + $(CC) $(C_FLAGS) -DDEFSIZE=$(TSIZE) -c tdbz.c + rm tdbz.c + +dbz: dbzmain.o $(CASE) + $(CC) $(LDFLAGS) dbzmain.o $(CASE) $(PRE) $(DBM) $(LIBS) $(POST) -o $@ + +tdbz: dbzmain.o tdbz.o $(CASE) + $(CC) $(LDFLAGS) dbzmain.o tdbz.o $(CASE) $(PRE) $(LIBS) $(POST) -o $@ + +rdbz: rdbzmain.o rdbz.o $(CASE) + $(CC) $(LDFLAGS) rdbzmain.o rdbz.o $(CASE) $(PRE) $(LIBS) $(POST) -o $@ + +fake: fake.o random.o + $(CC) $(LDFLAGS) fake.o random.o $(PRE) $(LIBS) $(POST) -o $@ + +byteflip: byteflip.o + $(CC) $(LDFLAGS) byteflip.o $(PRE) $(LIBS) $(POST) -o $@ + +hist10: fake + ./fake -t -e 75 10000 >$@ + +hist3.3: fake + ./fake -t -e 75 3300 >$@ + +hist13: fake + ./fake -t -e 75 13000 >$@ + +r: $(srcdir)/getmap $(srcdir)/revbytes $(srcdir)/altbytes stamp-r8 + : success! + +stamp-r0: + : 'WARNING: creates about 2MB of debris; do "make rclean" afterward' + rm -f dbase dbase[23] dbase.* dbase[23].* + test ! -d xx || rmdir xx + @touch stamp-r0 + +stamp-r1: $(RHIST) $(R2HIST) stamp-r0 + : crude check of synthetic history file + ( sed 25q $(RHIST) ; tail -25 $(RHIST) ) >histjunk + cmp histjunk $(srcdir)/firstlast25 + rm histjunk + @touch stamp-r1 + +r2a: rdbz stamp-r1 + : basic tests, exercising as many options as possible + cp $(RHIST) dbase + mkdir xx + chmod -w xx + ./rdbz -E 1000 -0 -M -i -S -u -U -C xx dbase + rmdir xx + sed '/> 0/d' $(RHIST) >dbase.used + test "`cat dbase.used | wc -l`" -eq "`sed -n '2s/ .*//p' dbase.dir`" ; + +stamp-r2: r2a + cp $(RHIST) dbase2 + ./rdbz -E 1000 -0 -p $(RPSIZE) -t ' ' dbase2 + cmp $(RHIST) dbase + cmp dbase dbase2 + cmp dbase.dir dbase2.dir + cmp dbase.pag dbase2.pag + ./rdbz -E 1000 -0 -c dbase + ./rdbz -E 1000 -0 -c -i -q -M -U dbase + @touch stamp-r2 + +stamp-r3: stamp-r2 + : build a database and then add to it + sed 1000q $(RHIST) >dbase2 + sed 1,1000d $(RHIST) >dbase2.add + ./rdbz -E 1000 -0 dbase2 + ./rdbz -E 1000 -0 -a dbase2 dbase2.add + cmp dbase dbase2 + cmp dbase.dir dbase2.dir + cmp dbase.pag dbase2.pag + @touch stamp-r3 + +stamp-r4: stamp-r3 + : build based on existing one, test extraction and readonly files + ./rdbz -E 1000 -0 -f dbase dbase2 + test "`cat dbase.used | wc -l`" -eq "`awk 'NR==2{print $$1}' dbase2.dir`" ; + test "`cat dbase.used | wc -l`" -eq "`awk 'NR==2{print $$2}' dbase2.dir`" ; + chmod -w dbase2.dir dbase2.pag + ./rdbz -E 1000 -x dbase2 dbase >dbase.temp + cmp dbase.used dbase.temp + @touch stamp-r4 + +stamp-r5: stamp-r4 + : try some small case perversions + sed 's/\(@[^ ]*\)A/\1a/' dbase >dbase.ick + ./rdbz -E 1000 -x dbase2 dbase.ick >dbase.temp + cmp dbase.used dbase.temp + sed -n 's/A\([^ ]*@\)/a\1/p' dbase >dbase.ick + ./rdbz -x dbase2 dbase.ick >dbase.temp + test ! -s dbase.temp ; + rm -f dbase2.dir dbase2.pag + @touch stamp-r5 + +stamp-r6: stamp-r5 + : try it without tags, case-insensitive, with case perversions + ./rdbz -E 1000 -0 -p '0 b 1' dbase2 + tr '[A-M][n-z]' '[a-m][N-Z]' dbase.ick + ./rdbz -E 1000 -x dbase2 dbase.ick >dbase.temp + cmp dbase.used dbase.temp + rm -f dbase.temp dbase.ick + @touch stamp-r6 + +stamp-r7: byteflip stamp-r6 + : test various perversions of byte ordering + awk -f $(srcdir)/revbytes dbase.dir >dbase2.dir + ./byteflip `$(srcdir)/getmap dbase.dir` `$(srcdir)/getmap dbase2.dir` dbase2.pag + cp dbase dbase2 + ./rdbz -E 1000 -0 -c dbase2 + awk -f $(srcdir)/altbytes dbase.dir >dbase2.dir + dd conv=swab dbase2.pag + ./rdbz -E 1000 -0 -c dbase2 + cp dbase2 dbase3 + ./rdbz -E 1000 -0 -f dbase2 dbase3 + ./rdbz -E 1000 -0 -c dbase3 + test " `$(srcdir)/getmap dbase2.dir`" = " `$(srcdir)/getmap dbase3.dir`" ; + @touch stamp-r7 + +stamp-r8: stamp-r7 + : test massive overflow, throw in case sensitivity and tag mask + cp $(R2HIST) dbase + ./rdbz -E 1000 -0 -p '0 0 7ffc0000' dbase + ./rdbz -E 1000 -0 -cq dbase + sed 100q dbase | egrep '[aA].* ' | tr aA Aa >dbase.ick + ./rdbz -x dbase dbase.ick >dbase.temp + test ! -s dbase.temp ; + @touch stamp-r8 + +rclean: + rm -f dbase dbase[23] dbase.* dbase[23].* fake fake.o random.o + rm -f rdbz rdbz.o rdbzmain.o $(RHIST) $(R2HIST) byteflip byteflip.o + rm -f histjunk core stamp-r? *~ + test ! -d xx || rmdir xx + +mostlyclean: rclean + rm -f *.o [a-z]dbz [a-z][a-z]dbz junk* PostScript.out + rm -f hist* dbase* *.bak mon.out gmon.out core dbm.h + +clean: mostlyclean + rm -f dbz + +distclean: clean + rm -rf Makefile config.status rdbz.c rdbzmain.c + +maintainer-clean realclean: distclean diff --git a/libio/dbz/README b/libio/dbz/README new file mode 100644 index 000000000000..e7fa8765ad5c --- /dev/null +++ b/libio/dbz/README @@ -0,0 +1,25 @@ +The dbz package was "liberated" from C News. +It is included with the GNU libio because it provides +a fairly good work-out for a stdio implementation. +The Makefile.in, configure.in, and stdio.h have been +set up to test libio. + +------ + +This is the new, improved, lemon-freshened :-) dbz. + +Just "make" will get you dbz.o and the dbz program. "make r" runs an +extensive set of regression tests; most of the mysterious oddments lying +around here are to do with that. "make rclean" cleans up after "make r". + +You probably want to inspect the #ifdef list early in dbz.c before +compiling, although the defaults should work all right on most systems. + +If you are not building this as part of C News, you will need to change +the -I option in FLAGS in the Makefile to "-I.", and delete the DBMLIBS +and RFC lines entirely. That will break some of the regression tests; +at some point I'll fix this. + +If you are using this independently from C News, you probably still want +to look through ../notebook/problems, as some of the portability problems +described in there can affect dbz. diff --git a/libio/dbz/altbytes b/libio/dbz/altbytes new file mode 100644 index 000000000000..26cc9fb9e023 --- /dev/null +++ b/libio/dbz/altbytes @@ -0,0 +1,7 @@ +NR == 1 { + printf "%s %s %s %s %s %s %s %s %s", $1, $2, $3, $4, $5, $6, $7, $8, $9 + for (i = 10; i <= NF; i += 2) + printf " %s %s", $(i+1), $i + printf "\n" +} +NR > 1 { print } diff --git a/libio/dbz/byteflip.c b/libio/dbz/byteflip.c new file mode 100644 index 000000000000..d54c6591fa18 --- /dev/null +++ b/libio/dbz/byteflip.c @@ -0,0 +1,38 @@ +#include + +#define MAXWORD 32 + +int +main(argc, argv) +int argc; +char *argv[]; +{ + register int len; + int inmap[MAXWORD]; + int outmap[MAXWORD]; + char in[MAXWORD]; + char out[MAXWORD]; + register int i; + register int a; + + a = 1; + len = atoi(argv[a++]); + if (len > MAXWORD) + abort(); /* kind of drastic... */ + for (i = 0; i < len; i++) + inmap[i] = atoi(argv[a++]); + if (atoi(argv[a++]) != len) + abort(); + for (i = 0; i < len; i++) + outmap[i] = atoi(argv[a++]); + + while (fread(in, 1, len, stdin) == len) { + for (i = 0; i < len; i++) + out[outmap[i]] = in[inmap[i]]; + fwrite(out, 1, len, stdout); + } +#ifdef DBZ_FINISH + DBZ_FINISH; +#endif + exit(0); +} diff --git a/libio/dbz/case.c b/libio/dbz/case.c new file mode 100644 index 000000000000..87b741ff54a7 --- /dev/null +++ b/libio/dbz/case.c @@ -0,0 +1,129 @@ +/* + * case-mapping stuff + * + * We exploit the fact that we are dealing only with headers here, and + * headers are limited to the ASCII characters by RFC822. It is barely + * possible that we might be dealing with a translation into another + * character set, but in particular it's very unlikely for a header + * character to be outside -128..255. + * + * Life would be a whole lot simpler if tolower() could safely and portably + * be applied to any char. + */ +#include +#include "string.h" +#include "case.h" + +/* note that case.h knows the value of OFFSET */ +#define OFFSET 128 /* avoid trouble with negative chars */ +#define MAPSIZE (256+OFFSET) +char casemap[MAPSIZE]; /* relies on init to '\0' */ +static int primed = 0; /* has casemap been set up? */ + +/* + - prime - set up case-mapping stuff + */ +static void +prime() +{ + register char *lp; + register char *up; + register int c; + register int i; + static char lower[] = "abcdefghijklmnopqrstuvwxyz"; + static char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + for (lp = lower, up = upper; *lp != '\0'; lp++, up++) { + c = *lp; + casemap[c+OFFSET] = c; + casemap[*up+OFFSET] = c; + } + for (i = 0; i < MAPSIZE; i++) + if (casemap[i] == '\0') + casemap[i] = (char)(i-OFFSET); + primed = 1; +} + +/* + - cistrncmp - case-independent strncmp + */ +int /* < == > 0 */ +cistrncmp(s1, s2, len) +char *s1; +char *s2; +int len; +{ + register char *p1; + register char *p2; + register int n; + + if (!primed) + prime(); + + p1 = s1; + p2 = s2; + n = len; + while (--n >= 0 && *p1 != '\0' && TOLOW(*p1) == TOLOW(*p2)) { + p1++; + p2++; + } + if (n < 0) + return(0); + + /* + * The following case analysis is necessary so that characters + * which look negative collate low against normal characters but + * high against the end-of-string NUL. + */ + if (*p1 == '\0' && *p2 == '\0') + return(0); + else if (*p1 == '\0') + return(-1); + else if (*p2 == '\0') + return(1); + else + return(TOLOW(*p1) - TOLOW(*p2)); +} + +/* + - rfc822ize - do the bizarre case conversion needed for rfc822 message-ids + * + * Actually, this is not quite complete. Absolute, total, full RFC822 + * compliance requires a horrible parsing job, because of the arcane + * quoting conventions -- abc"def"ghi is not equivalent to abc"DEF"ghi, + * for example. There are three or four things that might occur in the + * domain part of a message-id that are case-sensitive. They don't seem + * to ever occur in real news, thank Cthulhu. (What? You were expecting + * a merciful and forgiving deity to be invoked in connection with RFC822? + * Forget it; none of them would come near it.) + */ +char * /* returns the argument */ +rfc822ize(s) +char *s; +{ + register char *p; + static char post[] = "postmaster"; + static int postlen = sizeof(post)-1; + + if (!primed) + prime(); + + p = strrchr(s, '@'); + if (p == NULL) /* no local/domain split */ + p = ""; /* assume all local */ + else if (p - (s+1) == postlen && CISTREQN(s+1, post, postlen)) { + /* crazy special case -- "postmaster" is case-insensitive */ + p = s; + } +#ifdef NONSTANDARD +#ifdef RFCVIOLATION +#ifdef B_2_11_MISTAKE + p = s; /* all case-insensitive */ +#endif +#endif +#endif + for (; *p != '\0'; p++) + *p = TOLOW(*p); + + return(s); +} diff --git a/libio/dbz/case.h b/libio/dbz/case.h new file mode 100644 index 000000000000..d5ef69615506 --- /dev/null +++ b/libio/dbz/case.h @@ -0,0 +1,12 @@ +extern int cistrncmp(); +extern char *rfc822ize(); + +extern char casemap[]; + +/* must call cistrncmp before invoking TOLOW... */ +#define TOLOW(c) (casemap[(c)+128]) /* see case.c for why 128 */ + +/* ...but the use of it in CISTREQN is safe without the preliminary call (!) */ +/* CISTREQN is an optimised case-insensitive strncmp(a,b,n)==0; n > 0 */ +#define CISTREQN(a, b, n) \ + (TOLOW((a)[0]) == TOLOW((b)[0]) && cistrncmp(a, b, n) == 0) diff --git a/libio/dbz/configure.in b/libio/dbz/configure.in new file mode 100644 index 000000000000..4cb9b57ce0fa --- /dev/null +++ b/libio/dbz/configure.in @@ -0,0 +1,17 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../configure. + +configdirs= +srctrigger=dbzmain.c +srcname="libio dbz test" + +# per-host: + +# per-target: + +files="dbz.c dbzmain.c" +links="rdbz.c rdbzmain.c" + +# post-target: + diff --git a/libio/dbz/dbz.1 b/libio/dbz/dbz.1 new file mode 100644 index 000000000000..d2fff17af985 --- /dev/null +++ b/libio/dbz/dbz.1 @@ -0,0 +1,221 @@ +.TH DBZ 1 "11 Feb 1992" +.BY "C News" +.SH NAME +dbz \- operate on dbz databases of text +.SH SYNOPSIS +.B dbz +[ +.BR \- { axmc } +] [ +.B \-t +c +] [ +.B \-l +length +] [ +.BR \- { qiue } +] [ +.B \-f +old +] [ +.B \-p +parms +] database file ... +.SH DESCRIPTION +.I Dbz +is a shell-level interface to the +.IR dbz (3z) +database routines for indexed access to a text file. +.PP +The +.I database +file must be a text file, +one line per database record, +with the key the first field on the line. +The +.B \-t +option sets the field-separator character; the default is tab. +Setting the separator character to NUL (with +.BR "\-t\ ''" ) +makes the whole line the key. +Lines must not exceed 1023 bytes in length including the newline; +this limit can be increased with the +.B \-l +option. +The limitations and restrictions of +.IR dbz (3z) +must also be observed; +in particular, it remains the user's responsibility to ensure that +no attempt is made to store two entries (whether identical or not) +with the same key. +.PP +In the absence of options, +.I dbz +creates a +.IR dbz (3z) +index for the database; +the index comprises files +.IB database .pag +and +.IB database .dir +in the same directory. +Any previous index is silently overwritten. +The +.BR \-a , +.BR \-x , +.BR \-m , +and +.B \-c +options specify other operations. +.PP +With +.BR \-a , +.I dbz +appends lines from the +.IR file (s) +(standard input if none) +to the database, updating both the +text file and the indexes. +.PP +With +.BR \-x , +.I dbz +reads keys from the +.IR file (s) +(standard input if none) +and prints (on standard output) the corresponding lines, if any, +from the database. +The input is in the form of database lines, although only the keys are +significant. +The +.B \-q +option makes +.B \-x +print the input lines whose keys are found instead of the database +lines; this is somewhat faster. +.PP +With +.BR \-m , +operation is the same as for +.B \-x +except that the keys which are \fInot\fR present in the database are printed. +.PP +With +.BR \-c , +.I dbz +checks the database for internal consistency. +The +.B \-q +option causes this check to be done more quickly but less thoroughly +(each key is looked up in the index, but no check is made to be sure +that the index entry points to the right place). +.PP +The +.B \-i +option suppresses the use of +.IR dbz (3z)'s +.I incore +facility. +This makes accesses slower, but keeps the files current +during updating +and reduces +startup/shutdown overhead. +.PP +Normally, +.I dbz +checks whether a key is already in the database before adding it. +The +.B \-u +option suppresses this check, speeding things up at the expense of safety. +.PP +A new index is normally created with default size, +case mapping, and tagging. +The default size is right for 90-100,000 records. +The default case mapping is right for RFC822 message-ids. +See +.IR dbz (3z) +for what tagging is about. +(Note, these defaults can be changed when +.IR dbz (3z) +is installed.) +.PP +If the +.B \-f +option is given, +size, case mapping, and tagging +are instead initialized based on the +database +.IR old . +This is mostly useful when +creating a new generation of an existing database. +(See the description of +.I dbzagain +in +.IR dbz (3z) +for details.) +.PP +If the +.B \-p +option is given, the +.I parms +string specifies the size, case mapping, and tagging. +If +.I parms +is a single decimal number, +that is taken as the expected number of records +in the index, with case mapping and tagging defaulted. +Alternatively, +.I parms +can be three fields\(ema decimal number, a case-mapping code character, and a +hexadecimal tag mask\(emseparated by white space. +The decimal number is, again, the expected number of records; +0 means ``use the default''. +See +.IR dbz (3z) +for possible choices of case-mapping code, +but in particular, +.B 0 +means ``no case mapping''. +See +.IR dbz (3z) +for details on tag masks; +0 means ``use the default''. +.PP +If the +.B \-e +option is given, the decimal number in +.B \-p +is taken to be the exact table size, not the expected number of records, +and invocation of +.I dbzsize +(see +.IR dbz (3z)) +to predict a good size for that number of records is suppressed. +.PP +The +.B \&.pag +file is normally about 6 bytes per record (based on the estimate given to +.B \-p +or the previous history of the +.B \-f +database). +The +.B \&.dir +file is tiny. +.SH SEE ALSO +dbz(3z) +.SH HISTORY +Written at U of Toronto by Henry Spencer, for the C News project. +See +.IR dbz (3z) +for the history of the underlying database routines. +.SH BUGS +There are a number of undocumented options with obscure effects, +meant for debugging and regression testing of +.IR dbz (3z). +.PP +Permissions for the index files probably ought to be taken from those +of the base file. +.PP +The line-length limit is a blemish, alleviated only slightly by +.BR \-l . diff --git a/libio/dbz/dbz.3z b/libio/dbz/dbz.3z new file mode 100644 index 000000000000..6df25311c701 --- /dev/null +++ b/libio/dbz/dbz.3z @@ -0,0 +1,547 @@ +.TH DBZ 3Z "3 Feb 1991" +.BY "C News" +.SH NAME +dbminit, fetch, store, dbmclose \- somewhat dbm-compatible database routines +.br +dbzfresh, dbzagain, dbzfetch, dbzstore \- database routines +.br +dbzsync, dbzsize, dbzincore, dbzcancel, dbzdebug \- database routines +.SH SYNOPSIS +.nf +.B #include +.PP +.B dbminit(base) +.B char *base; +.PP +.B datum +.B fetch(key) +.B datum key; +.PP +.B store(key, value) +.B datum key; +.B datum value; +.PP +.B dbmclose() +.PP +.B dbzfresh(base, size, fieldsep, cmap, tagmask) +.B char *base; +.B long size; +.B int fieldsep; +.B int cmap; +.B long tagmask; +.PP +.B dbzagain(base, oldbase) +.B char *base; +.B char *oldbase; +.PP +.B datum +.B dbzfetch(key) +.B datum key; +.PP +.B dbzstore(key, value) +.B datum key; +.B datum value; +.PP +.B dbzsync() +.PP +.B long +.B dbzsize(nentries) +.B long nentries; +.PP +.B dbzincore(newvalue) +.PP +.B dbzcancel() +.PP +.B dbzdebug(newvalue) +.SH DESCRIPTION +These functions provide an indexing system for rapid random access to a +text file (the +.I base +.IR file ). +Subject to certain constraints, they are call-compatible with +.IR dbm (3), +although they also provide some extensions. +(Note that they are +.I not +file-compatible with +.I dbm +or any variant thereof.) +.PP +In principle, +.I dbz +stores key-value pairs, where both key and value are arbitrary sequences +of bytes, specified to the functions by +values of type +.IR datum , +typedefed in the header file to be a structure with members +.I dptr +(a value of type +.I char * +pointing to the bytes) +and +.I dsize +(a value of type +.I int +indicating how long the byte sequence is). +.PP +In practice, +.I dbz +is more restricted than +.IR dbm . +A +.I dbz +database +must be an index into a base file, +with the database +.IR value s +being +.IR fseek (3) +offsets into the base file. +Each such +.I value +must ``point to'' a place in the base file where the corresponding +.I key +sequence is found. +A key can be no longer than +.SM DBZMAXKEY +(a constant defined in the header file) bytes. +No key can be an initial subsequence of another, +which in most applications requires that keys be +either bracketed or terminated in some way (see the +discussion of the +.I fieldsep +parameter of +.IR dbzfresh , +below, +for a fine point on terminators). +.PP +.I Dbminit +opens a database, +an index into the base file +.IR base , +consisting of files +.IB base .dir +and +.IB base .pag +which must already exist. +(If the database is new, they should be zero-length files.) +Subsequent accesses go to that database until +.I dbmclose +is called to close the database. +The base file need not exist at the time of the +.IR dbminit , +but it must exist before accesses are attempted. +.PP +.I Fetch +searches the database for the specified +.IR key , +returning the corresponding +.IR value +if any. +.I Store +stores the +.IR key - value +pair in the database. +.I Store +will fail unless the database files are writeable. +See below for a complication arising from case mapping. +.PP +.I Dbzfresh +is a variant of +.I dbminit +for creating a new database with more control over details. +Unlike for +.IR dbminit , +the database files need not exist: +they will be created if necessary, +and truncated in any case. +.PP +.IR Dbzfresh 's +.I size +parameter specifies the size of the first hash table within the database, +in key-value pairs. +Performance will be best if +.I size +is a prime number and +the number of key-value pairs stored in the database does not exceed +about 2/3 of +.IR size . +(The +.I dbzsize +function, given the expected number of key-value pairs, +will suggest a database size that meets these criteria.) +Assuming that an +.I fseek +offset is 4 bytes, +the +.B .pag +file will be +.RI 4* size +bytes +(the +.B .dir +file is tiny and roughly constant in size) +until +the number of key-value pairs exceeds about 80% of +.IR size . +(Nothing awful will happen if the database grows beyond 100% of +.IR size , +but accesses will slow down somewhat and the +.B .pag +file will grow somewhat.) +.PP +.IR Dbzfresh 's +.I fieldsep +parameter specifies the field separator in the base file. +If this is not +NUL (0), and the last character of a +.I key +argument is NUL, that NUL compares equal to either a NUL or a +.I fieldsep +in the base file. +This permits use of NUL to terminate key strings without requiring that +NULs appear in the base file. +The +.I fieldsep +of a database created with +.I dbminit +is the horizontal-tab character. +.PP +For use in news systems, various forms of case mapping (e.g. uppercase to +lowercase) in keys are available. +The +.I cmap +parameter to +.I dbzfresh +is a single character specifying which of several mapping algorithms to use. +Available algorithms are: +.RS +.TP +.B 0 +case-sensitive: no case mapping +.TP +.B B +same as +.B 0 +.TP +.B NUL +same as +.B 0 +.TP +.B = +case-insensitive: uppercase and lowercase equivalent +.TP +.B b +same as +.B = +.TP +.B C +RFC822 message-ID rules, case-sensitive before `@' (with certain exceptions) +and case-insensitive after +.TP +.B ? +whatever the local default is, normally +.B C +.RE +.PP +Mapping algorithm +.B 0 +(no mapping) is faster than the others and is overwhelmingly the correct +choice for most applications. +Unless compatibility constraints interfere, it is more efficient to pre-map +the keys, storing mapped keys in the base file, than to have +.I dbz +do the mapping on every search. +.PP +For historical reasons, +.I fetch +and +.I store +expect their +.I key +arguments to be pre-mapped, but expect unmapped keys in the base file. +.I Dbzfetch +and +.I dbzstore +do the same jobs but handle all case mapping internally, +so the customer need not worry about it. +.PP +.I Dbz +stores only the database +.IR value s +in its files, relying on reference to the base file to confirm a hit on a key. +References to the base file can be minimized, greatly speeding up searches, +if a little bit of information about the keys can be stored in the +.I dbz +files. +This is ``free'' if there are some unused bits in an +.I fseek +offset, +so that the offset can be +.I tagged +with some information about the key. +The +.I tagmask +parameter of +.I dbzfresh +allows specifying the location of unused bits. +.I Tagmask +should be a mask with +one group of +contiguous +.B 1 +bits. +The bits in the mask should +be unused (0) in +.I most +offsets. +The bit immediately above the mask (the +.I flag +bit) should be unused (0) in +.I all +offsets; +.I (dbz)store +will reject attempts to store a key-value pair in which the +.I value +has the flag bit on. +Apart from this restriction, tagging is invisible to the user. +As a special case, a +.I tagmask +of 1 means ``no tagging'', for use with enormous base files or +on systems with unusual offset representations. +.PP +A +.I size +of 0 +given to +.I dbzfresh +is synonymous with the local default; +the normal default is suitable for tables of 90-100,000 +key-value pairs. +A +.I cmap +of 0 (NUL) is synonymous with the character +.BR 0 , +signifying no case mapping +(note that the character +.B ? +specifies the local default mapping, +normally +.BR C ). +A +.I tagmask +of 0 is synonymous with the local default tag mask, +normally 0x7f000000 (specifying the top bit in a 32-bit offset +as the flag bit, and the next 7 bits as the mask, +which is suitable for base files up to circa 24MB). +Calling +.I dbminit(name) +with the database files empty is equivalent to calling +.IR dbzfresh(name,0,'\et','?',0) . +.PP +When databases are regenerated periodically, as in news, +it is simplest to pick the parameters for a new database based on the old one. +This also permits some memory of past sizes of the old database, so that +a new database size can be chosen to cover expected fluctuations. +.I Dbzagain +is a variant of +.I dbminit +for creating a new database as a new generation of an old database. +The database files for +.I oldbase +must exist. +.I Dbzagain +is equivalent to calling +.I dbzfresh +with the same field separator, case mapping, and tag mask as the old database, +and a +.I size +equal to the result of applying +.I dbzsize +to the largest number of entries in the +.I oldbase +database and its previous 10 generations. +.PP +When many accesses are being done by the same program, +.I dbz +is massively faster if its first hash table is in memory. +If an internal flag is 1, +an attempt is made to read the table in when +the database is opened, and +.I dbmclose +writes it out to disk again (if it was read successfully and +has been modified). +.I Dbzincore +sets the flag to +.I newvalue +(which should be 0 or 1) +and returns the previous value; +this does not affect the status of a database that has already been opened. +The default is 0. +The attempt to read the table in may fail due to memory shortage; +in this case +.I dbz +quietly falls back on its default behavior. +.IR Store s +to an in-memory database are not (in general) written out to the file +until +.IR dbmclose +or +.IR dbzsync , +so if robustness in the presence of crashes +or concurrent accesses +is crucial, in-memory databases +should probably be avoided. +.PP +.I Dbzsync +causes all buffers etc. to be flushed out to the files. +It is typically used as a precaution against crashes or concurrent accesses +when a +.IR dbz -using +process will be running for a long time. +It is a somewhat expensive operation, +especially +for an in-memory database. +.PP +.I Dbzcancel +cancels any pending writes from buffers. +This is typically useful only for in-core databases, since writes are +otherwise done immediately. +Its main purpose is to let a child process, in the wake of a +.IR fork , +do a +.I dbmclose +without writing its parent's data to disk. +.PP +If +.I dbz +has been compiled with debugging facilities available (which makes it +bigger and a bit slower), +.I dbzdebug +alters the value (and returns the previous value) of an internal flag +which (when 1; default is 0) causes +verbose and cryptic debugging output on standard output. +.PP +Concurrent reading of databases is fairly safe, +but there is no (inter)locking, +so concurrent updating is not. +.PP +The database files include a record of the byte order of the processor +creating the database, and accesses by processors with different byte +order will work, although they will be slightly slower. +Byte order is preserved by +.IR dbzagain . +However, +agreement on the size and internal structure of an +.I fseek +offset is necessary, as is consensus on +the character set. +.PP +An open database occupies three +.I stdio +streams and their corresponding file descriptors; +a fourth is needed for an in-memory database. +Memory consumption is negligible (except for +.I stdio +buffers) except for in-memory databases. +.SH SEE ALSO +dbz(1), dbm(3) +.SH DIAGNOSTICS +Functions returning +.I int +values return 0 for success, \-1 for failure. +Functions returning +.I datum +values return a value with +.I dptr +set to NULL for failure. +.I Dbminit +attempts to have +.I errno +set plausibly on return, but otherwise this is not guaranteed. +An +.I errno +of +.B EDOM +from +.I dbminit +indicates that the database did not appear to be in +.I dbz +format. +.SH HISTORY +The original +.I dbz +was written by +Jon Zeeff (zeeff@b-tech.ann-arbor.mi.us). +Later contributions by David Butler and Mark Moraes. +Extensive reworking, +including this documentation, +by Henry Spencer (henry@zoo.toronto.edu) as +part of the C News project. +Hashing function by Peter Honeyman. +.SH BUGS +The +.I dptr +members of returned +.I datum +values point to static storage which is overwritten by later calls. +.PP +Unlike +.IR dbm , +.I dbz +will misbehave if an existing key-value pair is `overwritten' by +a new +.I (dbz)store +with the same key. +The user is responsible for avoiding this by using +.I (dbz)fetch +first to check for duplicates; +an internal optimization remembers the result of the +first search so there is minimal overhead in this. +.PP +Waiting until after +.I dbminit +to bring the base file into existence +will fail if +.IR chdir (2) +has been used meanwhile. +.PP +The RFC822 case mapper implements only a first approximation to the +hideously-complex RFC822 case rules. +.PP +The prime finder in +.I dbzsize +is not particularly quick. +.PP +Should implement the +.I dbm +functions +.IR delete , +.IR firstkey , +and +.IR nextkey . +.PP +On C implementations which trap integer overflow, +.I dbz +will refuse to +.I (dbz)store +an +.I fseek +offset equal to the greatest +representable +positive number, +as this would cause overflow in the biased representation used. +.PP +.I Dbzagain +perhaps ought to notice when many offsets +in the old database were +too big for +tagging, and shrink the tag mask to match. +.PP +Marking +.IR dbz 's +file descriptors +.RI close-on- exec +would be a better approach to the problem +.I dbzcancel +tries to address, but that's harder to do portably. diff --git a/libio/dbz/dbz.c b/libio/dbz/dbz.c new file mode 100644 index 000000000000..c7e8444952b0 --- /dev/null +++ b/libio/dbz/dbz.c @@ -0,0 +1,1763 @@ +/* + +dbz.c V3.2 + +Copyright 1988 Jon Zeeff (zeeff@b-tech.ann-arbor.mi.us) +You can use this code in any manner, as long as you leave my name on it +and don't hold me responsible for any problems with it. + +Hacked on by gdb@ninja.UUCP (David Butler); Sun Jun 5 00:27:08 CDT 1988 + +Various improvments + INCORE by moraes@ai.toronto.edu (Mark Moraes) + +Major reworking by Henry Spencer as part of the C News project. + +These routines replace dbm as used by the usenet news software +(it's not a full dbm replacement by any means). It's fast and +simple. It contains no AT&T code. + +In general, dbz's files are 1/20 the size of dbm's. Lookup performance +is somewhat better, while file creation is spectacularly faster, especially +if the incore facility is used. + +*/ + +#include +#include +#include +#include +#include +#ifndef __STDC__ +extern int errno; +#endif +#include + +/* + * #ifdef index. "LIA" = "leave it alone unless you know what you're doing". + * + * FUNNYSEEKS SEEK_SET is not 0, get it from + * INDEX_SIZE backward compatibility with old dbz; avoid using this + * NMEMORY number of days of memory for use in sizing new table (LIA) + * INCORE backward compatibility with old dbz; use dbzincore() instead + * DBZDEBUG enable debugging + * DEFSIZE default table size (not as critical as in old dbz) + * OLDBNEWS default case mapping as in old B News; set NOBUFFER + * BNEWS default case mapping as in current B News; set NOBUFFER + * DEFCASE default case-map algorithm selector + * NOTAGS fseek offsets are strange, do not do tagging (see below) + * NPAGBUF size of .pag buffer, in longs (LIA) + * SHISTBUF size of ASCII-file buffer, in bytes (LIA) + * MAXRUN length of run which shifts to next table (see below) (LIA) + * OVERFLOW long-int arithmetic overflow must be avoided, will trap + * NOBUFFER do not buffer hash-table i/o, B News locking is defective + */ + +#ifdef FUNNYSEEKS +#include +#else +#define SEEK_SET 0 +#endif +#ifdef OVERFLOW +#include +#endif + +static int dbzversion = 3; /* for validating .dir file format */ + +/* + * The dbz database exploits the fact that when news stores a + * tuple, the `value' part is a seek offset into a text file, pointing to + * a copy of the `key' part. This avoids the need to store a copy of + * the key in the dbz files. However, the text file *must* exist and be + * consistent with the dbz files, or things will fail. + * + * The basic format of the database is a simple hash table containing the + * values. A value is stored by indexing into the table using a hash value + * computed from the key; collisions are resolved by linear probing (just + * search forward for an empty slot, wrapping around to the beginning of + * the table if necessary). Linear probing is a performance disaster when + * the table starts to get full, so a complication is introduced. The + * database is actually one *or more* tables, stored sequentially in the + * .pag file, and the length of linear-probe sequences is limited. The + * search (for an existing item or an empty slot) always starts in the + * first table, and whenever MAXRUN probes have been done in table N, + * probing continues in table N+1. This behaves reasonably well even in + * cases of massive overflow. There are some other small complications + * added, see comments below. + * + * The table size is fixed for any particular database, but is determined + * dynamically when a database is rebuilt. The strategy is to try to pick + * the size so the first table will be no more than 2/3 full, that being + * slightly before the point where performance starts to degrade. (It is + * desirable to be a bit conservative because the overflow strategy tends + * to produce files with holes in them, which is a nuisance.) + */ + +/* + * The following is for backward compatibility. + */ +#ifdef INDEX_SIZE +#define DEFSIZE INDEX_SIZE +#endif + +/* + * ANSI C says the offset argument to fseek is a long, not an off_t, for some + * reason. Let's use off_t anyway. + */ +#define SOF (sizeof(off_t)) + +/* + * We assume that unused areas of a binary file are zeros, and that the + * bit pattern of `(off_t)0' is all zeros. The alternative is rather + * painful file initialization. Note that okayvalue(), if OVERFLOW is + * defined, knows what value of an offset would cause overflow. + */ +#define VACANT ((off_t)0) +#define BIAS(o) ((o)+1) /* make any valid off_t non-VACANT */ +#define UNBIAS(o) ((o)-1) /* reverse BIAS() effect */ + +/* + * In a Unix implementation, or indeed any in which an off_t is a byte + * count, there are a bunch of high bits free in an off_t. There is a + * use for them. Checking a possible hit by looking it up in the base + * file is relatively expensive, and the cost can be dramatically reduced + * by using some of those high bits to tag the value with a few more bits + * of the key's hash. This detects most false hits without the overhead of + * seek+read+strcmp. We use the top bit to indicate whether the value is + * tagged or not, and don't tag a value which is using the tag bits itself. + * We're in trouble if the off_t representation wants to use the top bit. + * The actual bitmasks and offset come from the configuration stuff, + * which permits fiddling with them as necessary, and also suppressing + * them completely (by defining the masks to 0). We build pre-shifted + * versions of the masks for efficiency. + */ +static off_t tagbits; /* pre-shifted tag mask */ +static off_t taghere; /* pre-shifted tag-enable bit */ +static off_t tagboth; /* tagbits|taghere */ +#define HASTAG(o) ((o)&taghere) +#define TAG(o) ((o)&tagbits) +#define NOTAG(o) ((o)&~tagboth) +#define CANTAG(o) (((o)&tagboth) == 0) +#define MKTAG(v) (((v)<>= 1; + c.tagshift++; + } + c.tagmask = m; + c.tagenb = (m << 1) & ~m; + break; + } + + /* write it out */ + fn = enstring(name, dir); + if (fn == NULL) + return(-1); + f = fopen(fn, "w"); + free(fn); + if (f == NULL) { + DEBUG(("dbzfresh: unable to write config\n")); + return(-1); + } + if (putconf(f, &c) < 0) { + (void) fclose(f); + return(-1); + } + if (fclose(f) == EOF) { + DEBUG(("dbzfresh: fclose failure\n")); + return(-1); + } + + /* create/truncate .pag */ + fn = enstring(name, pag); + if (fn == NULL) + return(-1); + f = fopen(fn, "w"); + free(fn); + if (f == NULL) { + DEBUG(("dbzfresh: unable to create/truncate .pag file\n")); + return(-1); + } else + (void) fclose(f); + + /* and punt to dbminit for the hard work */ + return(dbminit(name)); +} + +/* + - dbzsize - what's a good table size to hold this many entries? + */ +long +dbzsize(contents) +long contents; /* 0 means what's the default */ +{ + register long n; + + if (contents <= 0) { /* foulup or default inquiry */ + DEBUG(("dbzsize: preposterous input (%ld)\n", contents)); + return(DEFSIZE); + } + n = (contents/2)*3; /* try to keep table at most 2/3 full */ + if (!(n&01)) /* make it odd */ + n++; + DEBUG(("dbzsize: tentative size %ld\n", n)); + while (!isprime(n)) /* and look for a prime */ + n += 2; + DEBUG(("dbzsize: final size %ld\n", n)); + + return(n); +} + +/* + - isprime - is a number prime? + * + * This is not a terribly efficient approach. + */ +static int /* predicate */ +isprime(x) +register long x; +{ + static int quick[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 0 }; + register int *ip; + register long div; + register long stop; + + /* hit the first few primes quickly to eliminate easy ones */ + /* this incidentally prevents ridiculously small tables */ + for (ip = quick; (div = *ip) != 0; ip++) + if (x%div == 0) { + DEBUG(("isprime: quick result on %ld\n", (long)x)); + return(0); + } + + /* approximate square root of x */ + for (stop = x; x/stop < stop; stop >>= 1) + continue; + stop <<= 1; + + /* try odd numbers up to stop */ + for (div = *--ip; div < stop; div += 2) + if (x%div == 0) + return(0); + + return(1); +} + +/* + - dbzagain - set up a new database to be a rebuild of an old one + */ +int /* 0 success, -1 failure */ +dbzagain(name, oldname) +char *name; /* base name; .dir and .pag must exist */ +char *oldname; /* base name; all must exist */ +{ + register char *fn; + struct dbzconfig c; + register int i; + register long top; + register FILE *f; + register int newtable; + register off_t newsize; + + if (pagf != NULL) { + DEBUG(("dbzagain: database already open\n")); + return(-1); + } + + /* pick up the old configuration */ + fn = enstring(oldname, dir); + if (fn == NULL) + return(-1); + f = fopen(fn, "r"); + free(fn); + if (f == NULL) { + DEBUG(("dbzagain: cannot open old .dir file\n")); + return(-1); + } + i = getconf(f, (FILE *)NULL, &c); + (void) fclose(f); + if (i < 0) { + DEBUG(("dbzagain: getconf failed\n")); + return(-1); + } + + /* tinker with it */ + top = 0; + newtable = 0; + for (i = 0; i < NUSEDS; i++) { + if (top < c.used[i]) + top = c.used[i]; + if (c.used[i] == 0) + newtable = 1; /* hasn't got full usage history yet */ + } + if (top == 0) { + DEBUG(("dbzagain: old table has no contents!\n")); + newtable = 1; + } + for (i = NUSEDS-1; i > 0; i--) + c.used[i] = c.used[i-1]; + c.used[0] = 0; + newsize = dbzsize(top); + if (!newtable || newsize > c.tsize) /* don't shrink new table */ + c.tsize = newsize; + + /* write it out */ + fn = enstring(name, dir); + if (fn == NULL) + return(-1); + f = fopen(fn, "w"); + free(fn); + if (f == NULL) { + DEBUG(("dbzagain: unable to write new .dir\n")); + return(-1); + } + i = putconf(f, &c); + (void) fclose(f); + if (i < 0) { + DEBUG(("dbzagain: putconf failed\n")); + return(-1); + } + + /* create/truncate .pag */ + fn = enstring(name, pag); + if (fn == NULL) + return(-1); + f = fopen(fn, "w"); + free(fn); + if (f == NULL) { + DEBUG(("dbzagain: unable to create/truncate .pag file\n")); + return(-1); + } else + (void) fclose(f); + + /* and let dbminit do the work */ + return(dbminit(name)); +} + +/* + - dbminit - open a database, creating it (using defaults) if necessary + * + * We try to leave errno set plausibly, to the extent that underlying + * functions permit this, since many people consult it if dbminit() fails. + */ +int /* 0 success, -1 failure */ +dbminit(name) +char *name; +{ + register int i; + register size_t s; + register char *dirfname; + register char *pagfname; + + if (pagf != NULL) { + DEBUG(("dbminit: dbminit already called once\n")); + errno = 0; + return(-1); + } + + /* open the .dir file */ + dirfname = enstring(name, dir); + if (dirfname == NULL) + return(-1); + dirf = fopen(dirfname, "r+"); + if (dirf == NULL) { + dirf = fopen(dirfname, "r"); + dirronly = 1; + } else + dirronly = 0; + free(dirfname); + if (dirf == NULL) { + DEBUG(("dbminit: can't open .dir file\n")); + return(-1); + } + + /* open the .pag file */ + pagfname = enstring(name, pag); + if (pagfname == NULL) { + (void) fclose(dirf); + return(-1); + } + pagf = fopen(pagfname, "r+b"); + if (pagf == NULL) { + pagf = fopen(pagfname, "rb"); + if (pagf == NULL) { + DEBUG(("dbminit: .pag open failed\n")); + (void) fclose(dirf); + free(pagfname); + return(-1); + } + pagronly = 1; + } else if (dirronly) + pagronly = 1; + else + pagronly = 0; +#ifdef NOBUFFER + /* + * B News does not do adequate locking on its database accesses. + * Why it doesn't get into trouble using dbm is a mystery. In any + * case, doing unbuffered i/o does not cure the problem, but does + * enormously reduce its incidence. + */ + (void) setbuf(pagf, (char *)NULL); +#else +#ifdef _IOFBF + (void) setvbuf(pagf, (char *)pagbuf, _IOFBF, sizeof(pagbuf)); +#endif +#endif + pagpos = -1; + /* don't free pagfname, need it below */ + + /* open the base file */ + basef = fopen(name, "r"); + if (basef == NULL) { + DEBUG(("dbminit: basefile open failed\n")); + basefname = enstring(name, ""); + if (basefname == NULL) { + (void) fclose(pagf); + (void) fclose(dirf); + free(pagfname); + pagf = NULL; + return(-1); + } + } else + basefname = NULL; +#ifdef _IOFBF + if (basef != NULL) + (void) setvbuf(basef, basebuf, _IOFBF, sizeof(basebuf)); +#endif + + /* pick up configuration */ + if (getconf(dirf, pagf, &conf) < 0) { + DEBUG(("dbminit: getconf failure\n")); + (void) fclose(basef); + (void) fclose(pagf); + (void) fclose(dirf); + free(pagfname); + pagf = NULL; + errno = EDOM; /* kind of a kludge, but very portable */ + return(-1); + } + tagbits = conf.tagmask << conf.tagshift; + taghere = conf.tagenb << conf.tagshift; + tagboth = tagbits | taghere; + mybytemap(mybmap); + bytesame = 1; + for (i = 0; i < SOF; i++) + if (mybmap[i] != conf.bytemap[i]) + bytesame = 0; + + /* get first table into core, if it looks desirable and feasible */ + s = (size_t)conf.tsize * SOF; + if (incore && (off_t)(s/SOF) == conf.tsize) { + bufpagf = fopen(pagfname, (pagronly) ? "rb" : "r+b"); + if (bufpagf != NULL) + corepag = getcore(bufpagf); + } else { + bufpagf = NULL; + corepag = NULL; + } + free(pagfname); + + /* misc. setup */ + crcinit(); + written = 0; + prevp = FRESH; + DEBUG(("dbminit: succeeded\n")); + return(0); +} + +/* + - enstring - concatenate two strings into a malloced area + */ +static char * /* NULL if malloc fails */ +enstring(s1, s2) +char *s1; +char *s2; +{ + register char *p; + + p = malloc((size_t)strlen(s1) + (size_t)strlen(s2) + 1); + if (p != NULL) { + (void) strcpy(p, s1); + (void) strcat(p, s2); + } else { + DEBUG(("enstring(%s, %s) out of memory\n", s1, s2)); + } + return(p); +} + +/* + - dbmclose - close a database + */ +int +dbmclose() +{ + register int ret = 0; + + if (pagf == NULL) { + DEBUG(("dbmclose: not opened!\n")); + return(-1); + } + + if (fclose(pagf) == EOF) { + DEBUG(("dbmclose: fclose(pagf) failed\n")); + ret = -1; + } + pagf = basef; /* ensure valid pointer; dbzsync checks it */ + if (dbzsync() < 0) + ret = -1; + if (bufpagf != NULL && fclose(bufpagf) == EOF) { + DEBUG(("dbmclose: fclose(bufpagf) failed\n")); + ret = -1; + } + if (corepag != NULL) + free((char *)corepag); + corepag = NULL; + if (fclose(basef) == EOF) { + DEBUG(("dbmclose: fclose(basef) failed\n")); + ret = -1; + } + if (basefname != NULL) + free(basefname); + basef = NULL; + pagf = NULL; + if (fclose(dirf) == EOF) { + DEBUG(("dbmclose: fclose(dirf) failed\n")); + ret = -1; + } + + DEBUG(("dbmclose: %s\n", (ret == 0) ? "succeeded" : "failed")); + return(ret); +} + +/* + - dbzsync - push all in-core data out to disk + */ +int +dbzsync() +{ + register int ret = 0; + + if (pagf == NULL) { + DEBUG(("dbzsync: not opened!\n")); + return(-1); + } + if (!written) + return(0); + + if (corepag != NULL) { + if (putcore(corepag, bufpagf) < 0) { + DEBUG(("dbzsync: putcore failed\n")); + ret = -1; + } + } + if (!conf.olddbz) + if (putconf(dirf, &conf) < 0) + ret = -1; + + DEBUG(("dbzsync: %s\n", (ret == 0) ? "succeeded" : "failed")); + return(ret); +} + +/* + - dbzcancel - cancel writing of in-core data + * Mostly for use from child processes. + * Note that we don't need to futz around with stdio buffers, because we + * always fflush them immediately anyway and so they never have stale data. + */ +int +dbzcancel() +{ + if (pagf == NULL) { + DEBUG(("dbzcancel: not opened!\n")); + return(-1); + } + + written = 0; + return(0); +} + +/* + - dbzfetch - fetch() with case mapping built in + */ +datum +dbzfetch(key) +datum key; +{ + char buffer[DBZMAXKEY + 1]; + datum mappedkey; + register size_t keysize; + + DEBUG(("dbzfetch: (%s)\n", key.dptr)); + + /* Key is supposed to be less than DBZMAXKEY */ + keysize = key.dsize; + if (keysize >= DBZMAXKEY) { + keysize = DBZMAXKEY; + DEBUG(("keysize is %d - truncated to %d\n", key.dsize, DBZMAXKEY)); + } + + mappedkey.dptr = mapcase(buffer, key.dptr, keysize); + buffer[keysize] = '\0'; /* just a debug aid */ + mappedkey.dsize = keysize; + + return(fetch(mappedkey)); +} + +/* + - fetch - get an entry from the database + * + * Disgusting fine point, in the name of backward compatibility: if the + * last character of "key" is a NUL, that character is (effectively) not + * part of the comparison against the stored keys. + */ +datum /* dptr NULL, dsize 0 means failure */ +fetch(key) +datum key; +{ + char buffer[DBZMAXKEY + 1]; + static off_t key_ptr; /* return value points here */ + datum output; + register size_t keysize; + register size_t cmplen; + register char *sepp; + + DEBUG(("fetch: (%s)\n", key.dptr)); + output.dptr = NULL; + output.dsize = 0; + prevp = FRESH; + + /* Key is supposed to be less than DBZMAXKEY */ + keysize = key.dsize; + if (keysize >= DBZMAXKEY) { + keysize = DBZMAXKEY; + DEBUG(("keysize is %d - truncated to %d\n", key.dsize, DBZMAXKEY)); + } + + if (pagf == NULL) { + DEBUG(("fetch: database not open!\n")); + return(output); + } else if (basef == NULL) { /* basef didn't exist yet */ + basef = latebase(); + if (basef == NULL) + return(output); + } + + cmplen = keysize; + sepp = &conf.fieldsep; + if (key.dptr[keysize-1] == '\0') { + cmplen--; + sepp = &buffer[keysize-1]; + } + start(&srch, &key, FRESH); + while ((key_ptr = search(&srch)) != NOTFOUND) { + DEBUG(("got 0x%lx\n", key_ptr)); + + /* fetch the key */ + if (fseek(basef, key_ptr, SEEK_SET) != 0) { + DEBUG(("fetch: seek failed\n")); + return(output); + } + if (fread(buffer, 1, keysize, basef) != keysize) { + DEBUG(("fetch: read failed\n")); + return(output); + } + + /* try it */ + buffer[keysize] = '\0'; /* terminated for DEBUG */ + (void) mapcase(buffer, buffer, keysize); + DEBUG(("fetch: buffer (%s) looking for (%s) size = %d\n", + buffer, key.dptr, keysize)); + if (memcmp(key.dptr, buffer, cmplen) == 0 && + (*sepp == conf.fieldsep || *sepp == '\0')) { + /* we found it */ + output.dptr = (char *)&key_ptr; + output.dsize = SOF; + DEBUG(("fetch: successful\n")); + return(output); + } + } + + /* we didn't find it */ + DEBUG(("fetch: failed\n")); + prevp = &srch; /* remember where we stopped */ + return(output); +} + +/* + - latebase - try to open a base file that wasn't there at the start + */ +static FILE * +latebase() +{ + register FILE *it; + + if (basefname == NULL) { + DEBUG(("latebase: name foulup\n")); + return(NULL); + } + it = fopen(basefname, "r"); + if (it == NULL) { + DEBUG(("latebase: still can't open base\n")); + } else { + DEBUG(("latebase: late open succeeded\n")); + free(basefname); + basefname = NULL; +#ifdef _IOFBF + (void) setvbuf(it, basebuf, _IOFBF, sizeof(basebuf)); +#endif + } + return(it); +} + +/* + - dbzstore - store() with case mapping built in + */ +int +dbzstore(key, data) +datum key; +datum data; +{ + char buffer[DBZMAXKEY + 1]; + datum mappedkey; + register size_t keysize; + + DEBUG(("dbzstore: (%s)\n", key.dptr)); + + /* Key is supposed to be less than DBZMAXKEY */ + keysize = key.dsize; + if (keysize >= DBZMAXKEY) { + DEBUG(("dbzstore: key size too big (%d)\n", key.dsize)); + return(-1); + } + + mappedkey.dptr = mapcase(buffer, key.dptr, keysize); + buffer[keysize] = '\0'; /* just a debug aid */ + mappedkey.dsize = keysize; + + return(store(mappedkey, data)); +} + +/* + - store - add an entry to the database + */ +int /* 0 success, -1 failure */ +store(key, data) +datum key; +datum data; +{ + off_t value; + + if (pagf == NULL) { + DEBUG(("store: database not open!\n")); + return(-1); + } else if (basef == NULL) { /* basef didn't exist yet */ + basef = latebase(); + if (basef == NULL) + return(-1); + } + if (pagronly) { + DEBUG(("store: database open read-only\n")); + return(-1); + } + if (data.dsize != SOF) { + DEBUG(("store: value size wrong (%d)\n", data.dsize)); + return(-1); + } + if (key.dsize >= DBZMAXKEY) { + DEBUG(("store: key size too big (%d)\n", key.dsize)); + return(-1); + } + + /* copy the value in to ensure alignment */ + (void) memcpy((char *)&value, data.dptr, SOF); + DEBUG(("store: (%s, %ld)\n", key.dptr, (long)value)); + if (!okayvalue(value)) { + DEBUG(("store: reserved bit or overflow in 0x%lx\n", value)); + return(-1); + } + + /* find the place, exploiting previous search if possible */ + start(&srch, &key, prevp); + while (search(&srch) != NOTFOUND) + continue; + + prevp = FRESH; + conf.used[0]++; + DEBUG(("store: used count %ld\n", conf.used[0])); + written = 1; + return(set(&srch, value)); +} + +/* + - dbzincore - control attempts to keep .pag file in core + */ +int /* old setting */ +dbzincore(value) +int value; +{ + register int old = incore; + + incore = value; + return(old); +} + +/* + - getconf - get configuration from .dir file + */ +static int /* 0 success, -1 failure */ +getconf(df, pf, cp) +register FILE *df; /* NULL means just give me the default */ +register FILE *pf; /* NULL means don't care about .pag */ +register struct dbzconfig *cp; +{ + register int c; + register int i; + int err = 0; + + c = (df != NULL) ? getc(df) : EOF; + if (c == EOF) { /* empty file, no configuration known */ + cp->olddbz = 0; + if (df != NULL && pf != NULL && getc(pf) != EOF) + cp->olddbz = 1; + cp->tsize = DEFSIZE; + cp->fieldsep = '\t'; + for (i = 0; i < NUSEDS; i++) + cp->used[i] = 0; + cp->valuesize = SOF; + mybytemap(cp->bytemap); + cp->casemap = DEFCASE; + cp->tagenb = TAGENB; + cp->tagmask = TAGMASK; + cp->tagshift = TAGSHIFT; + DEBUG(("getconf: defaults (%ld, %c, (0x%lx/0x%lx<<%d))\n", + cp->tsize, cp->casemap, cp->tagenb, + cp->tagmask, cp->tagshift)); + return(0); + } + (void) ungetc(c, df); + + /* first line, the vital stuff */ + if (getc(df) != 'd' || getc(df) != 'b' || getc(df) != 'z') + err = -1; + if (getno(df, &err) != dbzversion) + err = -1; + cp->tsize = getno(df, &err); + cp->fieldsep = getno(df, &err); + while ((c = getc(df)) == ' ') + continue; + cp->casemap = c; + cp->tagenb = getno(df, &err); + cp->tagmask = getno(df, &err); + cp->tagshift = getno(df, &err); + cp->valuesize = getno(df, &err); + if (cp->valuesize != SOF) { + DEBUG(("getconf: wrong off_t size (%d)\n", cp->valuesize)); + err = -1; + cp->valuesize = SOF; /* to protect the loops below */ + } + for (i = 0; i < cp->valuesize; i++) + cp->bytemap[i] = getno(df, &err); + if (getc(df) != '\n') + err = -1; + DEBUG(("size %ld, sep %d, cmap %c, tags 0x%lx/0x%lx<<%d, ", cp->tsize, + cp->fieldsep, cp->casemap, cp->tagenb, cp->tagmask, + cp->tagshift)); + DEBUG(("bytemap (%d)", cp->valuesize)); + for (i = 0; i < cp->valuesize; i++) { + DEBUG((" %d", cp->bytemap[i])); + } + DEBUG(("\n")); + + /* second line, the usages */ + for (i = 0; i < NUSEDS; i++) + cp->used[i] = getno(df, &err); + if (getc(df) != '\n') + err = -1; + DEBUG(("used %ld %ld %ld...\n", cp->used[0], cp->used[1], cp->used[2])); + + if (err < 0) { + DEBUG(("getconf error\n")); + return(-1); + } + return(0); +} + +/* + - getno - get a long + */ +static long +getno(f, ep) +FILE *f; +int *ep; +{ + register char *p; +# define MAXN 50 + char getbuf[MAXN]; + register int c; + + while ((c = getc(f)) == ' ') + continue; + if (c == EOF || c == '\n') { + DEBUG(("getno: missing number\n")); + *ep = -1; + return(0); + } + p = getbuf; + *p++ = c; + while ((c = getc(f)) != EOF && c != '\n' && c != ' ') + if (p < &getbuf[MAXN-1]) + *p++ = c; + if (c == EOF) { + DEBUG(("getno: EOF\n")); + *ep = -1; + } else + (void) ungetc(c, f); + *p = '\0'; + + if (strspn(getbuf, "-1234567890") != strlen(getbuf)) { + DEBUG(("getno: `%s' non-numeric\n", getbuf)); + *ep = -1; + } + return(atol(getbuf)); +} + +/* + - putconf - write configuration to .dir file + */ +static int /* 0 success, -1 failure */ +putconf(f, cp) +register FILE *f; +register struct dbzconfig *cp; +{ + register int i; + register int ret = 0; + + if (fseek(f, 0, SEEK_SET) != 0) { + DEBUG(("fseek failure in putconf\n")); + ret = -1; + } + fprintf(f, "dbz %d %ld %d %c %ld %ld %d %d", dbzversion, cp->tsize, + cp->fieldsep, cp->casemap, cp->tagenb, + cp->tagmask, cp->tagshift, cp->valuesize); + for (i = 0; i < cp->valuesize; i++) + fprintf(f, " %d", cp->bytemap[i]); + fprintf(f, "\n"); + for (i = 0; i < NUSEDS; i++) + fprintf(f, "%ld%c", cp->used[i], (i < NUSEDS-1) ? ' ' : '\n'); + + (void) fflush(f); + if (ferror(f)) + ret = -1; + + DEBUG(("putconf status %d\n", ret)); + return(ret); +} + +/* + - getcore - try to set up an in-core copy of .pag file + */ +static off_t * /* pointer to copy, or NULL */ +getcore(f) +FILE *f; +{ + register off_t *p; + register size_t i; + register size_t nread; + register char *it; + + it = malloc((size_t)conf.tsize * SOF); + if (it == NULL) { + DEBUG(("getcore: malloc failed\n")); + return(NULL); + } + + nread = fread(it, SOF, (size_t)conf.tsize, f); + if (ferror(f)) { + DEBUG(("getcore: read failed\n")); + free(it); + return(NULL); + } + + p = (off_t *)it + nread; + i = (size_t)conf.tsize - nread; + while (i-- > 0) + *p++ = VACANT; + return((off_t *)it); +} + +/* + - putcore - try to rewrite an in-core table + */ +static int /* 0 okay, -1 fail */ +putcore(tab, f) +off_t *tab; +FILE *f; +{ + if (fseek(f, 0, SEEK_SET) != 0) { + DEBUG(("fseek failure in putcore\n")); + return(-1); + } + (void) fwrite((char *)tab, SOF, (size_t)conf.tsize, f); + (void) fflush(f); + return((ferror(f)) ? -1 : 0); +} + +/* + - start - set up to start or restart a search + */ +static void +start(sp, kp, osp) +register struct searcher *sp; +register datum *kp; +register struct searcher *osp; /* may be FRESH, i.e. NULL */ +{ + register long h; + + h = hash(kp->dptr, kp->dsize); + if (osp != FRESH && osp->hash == h) { + if (sp != osp) + *sp = *osp; + DEBUG(("search restarted\n")); + } else { + sp->hash = h; + sp->tag = MKTAG(h / conf.tsize); + DEBUG(("tag 0x%lx\n", sp->tag)); + sp->place = h % conf.tsize; + sp->tabno = 0; + sp->run = (conf.olddbz) ? conf.tsize : MAXRUN; + sp->aborted = 0; + } + sp->seen = 0; +} + +/* + - search - conduct part of a search + */ +static off_t /* NOTFOUND if we hit VACANT or error */ +search(sp) +register struct searcher *sp; +{ + register off_t dest; + register off_t value; + off_t val; /* buffer for value (can't fread register) */ + register off_t place; + + if (sp->aborted) + return(NOTFOUND); + + for (;;) { + /* determine location to be examined */ + place = sp->place; + if (sp->seen) { + /* go to next location */ + if (--sp->run <= 0) { + sp->tabno++; + sp->run = MAXRUN; + } + place = (place+1)%conf.tsize + sp->tabno*conf.tsize; + sp->place = place; + } else + sp->seen = 1; /* now looking at current location */ + DEBUG(("search @ %ld\n", place)); + + /* get the tagged value */ + if (corepag != NULL && place < conf.tsize) { + DEBUG(("search: in core\n")); + value = MAPIN(corepag[place]); + } else { + /* seek, if necessary */ + dest = place * SOF; + if (pagpos != dest) { + if (fseek(pagf, dest, SEEK_SET) != 0) { + DEBUG(("search: seek failed\n")); + pagpos = -1; + sp->aborted = 1; + return(NOTFOUND); + } + pagpos = dest; + } + + /* read it */ + if (fread((char *)&val, sizeof(val), 1, pagf) == 1) + value = MAPIN(val); + else if (ferror(pagf)) { + DEBUG(("search: read failed\n")); + pagpos = -1; + sp->aborted = 1; + return(NOTFOUND); + } else + value = VACANT; + + /* and finish up */ + pagpos += sizeof(val); + } + + /* vacant slot is always cause to return */ + if (value == VACANT) { + DEBUG(("search: empty slot\n")); + return(NOTFOUND); + }; + + /* check the tag */ + value = UNBIAS(value); + DEBUG(("got 0x%lx\n", value)); + if (!HASTAG(value)) { + DEBUG(("tagless\n")); + return(value); + } else if (TAG(value) == sp->tag) { + DEBUG(("match\n")); + return(NOTAG(value)); + } else { + DEBUG(("mismatch 0x%lx\n", TAG(value))); + } + } + /* NOTREACHED */ +} + +/* + - okayvalue - check that a value can be stored + */ +static int /* predicate */ +okayvalue(value) +off_t value; +{ + if (HASTAG(value)) + return(0); +#ifdef OVERFLOW + if (value == LONG_MAX) /* BIAS() and UNBIAS() will overflow */ + return(0); +#endif + return(1); +} + +/* + - set - store a value into a location previously found by search + */ +static int /* 0 success, -1 failure */ +set(sp, value) +register struct searcher *sp; +off_t value; +{ + register off_t place = sp->place; + register off_t v = value; + + if (sp->aborted) + return(-1); + + if (CANTAG(v) && !conf.olddbz) { + v |= sp->tag | taghere; + if (v != UNBIAS(VACANT)) /* BIAS(v) won't look VACANT */ +#ifdef OVERFLOW + if (v != LONG_MAX) /* and it won't overflow */ +#endif + value = v; + } + DEBUG(("tagged value is 0x%lx\n", value)); + value = BIAS(value); + value = MAPOUT(value); + + /* If we have the index file in memory, use it */ + if (corepag != NULL && place < conf.tsize) { + corepag[place] = value; + DEBUG(("set: incore\n")); + return(0); + } + + /* seek to spot */ + pagpos = -1; /* invalidate position memory */ + if (fseek(pagf, place * SOF, SEEK_SET) != 0) { + DEBUG(("set: seek failed\n")); + sp->aborted = 1; + return(-1); + } + + /* write in data */ + if (fwrite((char *)&value, SOF, 1, pagf) != 1) { + DEBUG(("set: write failed\n")); + sp->aborted = 1; + return(-1); + } + /* fflush improves robustness, and buffer re-use is rare anyway */ + if (fflush(pagf) == EOF) { + DEBUG(("set: fflush failed\n")); + sp->aborted = 1; + return(-1); + } + + DEBUG(("set: succeeded\n")); + return(0); +} + +/* + - mybytemap - determine this machine's byte map + * + * A byte map is an array of ints, sizeof(off_t) of them. The 0th int + * is the byte number of the high-order byte in my off_t, and so forth. + */ +static void +mybytemap(map) +int map[]; /* -> int[SOF] */ +{ + union { + off_t o; + char c[SOF]; + } u; + register int *mp = &map[SOF]; + register int ntodo; + register int i; + + u.o = 1; + for (ntodo = (int)SOF; ntodo > 0; ntodo--) { + for (i = 0; i < SOF; i++) + if (u.c[i] != 0) + break; + if (i == SOF) { + /* trouble -- set it to *something* consistent */ + DEBUG(("mybytemap: nonexistent byte %d!!!\n", ntodo)); + for (i = 0; i < SOF; i++) + map[i] = i; + return; + } + DEBUG(("mybytemap: byte %d\n", i)); + *--mp = i; + while (u.c[i] != 0) + u.o <<= 1; + } +} + +/* + - bytemap - transform an off_t from byte ordering map1 to map2 + */ +static off_t /* transformed result */ +bytemap(ino, map1, map2) +off_t ino; +int *map1; +int *map2; +{ + union oc { + off_t o; + char c[SOF]; + }; + union oc in; + union oc out; + register int i; + + in.o = ino; + for (i = 0; i < SOF; i++) + out.c[map2[i]] = in.c[map1[i]]; + return(out.o); +} + +/* + * This is a simplified version of the pathalias hashing function. + * Thanks to Steve Belovin and Peter Honeyman + * + * hash a string into a long int. 31 bit crc (from andrew appel). + * the crc table is computed at run time by crcinit() -- we could + * precompute, but it takes 1 clock tick on a 750. + * + * This fast table calculation works only if POLY is a prime polynomial + * in the field of integers modulo 2. Since the coefficients of a + * 32-bit polynomial won't fit in a 32-bit word, the high-order bit is + * implicit. IT MUST ALSO BE THE CASE that the coefficients of orders + * 31 down to 25 are zero. Happily, we have candidates, from + * E. J. Watson, "Primitive Polynomials (Mod 2)", Math. Comp. 16 (1962): + * x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + x^0 + * x^31 + x^3 + x^0 + * + * We reverse the bits to get: + * 111101010000000000000000000000001 but drop the last 1 + * f 5 0 0 0 0 0 0 + * 010010000000000000000000000000001 ditto, for 31-bit crc + * 4 8 0 0 0 0 0 0 + */ + +#define POLY 0x48000000L /* 31-bit polynomial (avoids sign problems) */ + +static long CrcTable[128]; + +/* + - crcinit - initialize tables for hash function + */ +static void +crcinit() +{ + register int i, j; + register long sum; + + for (i = 0; i < 128; ++i) { + sum = 0L; + for (j = 7 - 1; j >= 0; --j) + if (i & (1 << j)) + sum ^= POLY >> j; + CrcTable[i] = sum; + } + DEBUG(("crcinit: done\n")); +} + +/* + - hash - Honeyman's nice hashing function + */ +static long +hash(name, size) +register char *name; +register int size; +{ + register long sum = 0L; + + while (size--) { + sum = (sum >> 7) ^ CrcTable[(sum ^ (*name++)) & 0x7f]; + } + DEBUG(("hash: returns (%ld)\n", sum)); + return(sum); +} + +/* + * case-mapping stuff + * + * Borrowed from C News, by permission of the authors. Somewhat modified. + * + * We exploit the fact that we are dealing only with headers here, and + * headers are limited to the ASCII characters by RFC822. It is barely + * possible that we might be dealing with a translation into another + * character set, but in particular it's very unlikely for a header + * character to be outside -128..255. + * + * Life would be a whole lot simpler if tolower() could safely and portably + * be applied to any char. + */ + +#define OFFSET 128 /* avoid trouble with negative chars */ + +/* must call casencmp before invoking TOLOW... */ +#define TOLOW(c) (cmap[(c)+OFFSET]) + +/* ...but the use of it in CISTREQN is safe without the preliminary call (!) */ +/* CISTREQN is an optimised case-insensitive strncmp(a,b,n)==0; n > 0 */ +#define CISTREQN(a, b, n) \ + (TOLOW((a)[0]) == TOLOW((b)[0]) && casencmp(a, b, n) == 0) + +#define MAPSIZE (256+OFFSET) +static char cmap[MAPSIZE]; /* relies on init to '\0' */ +static int mprimed = 0; /* has cmap been set up? */ + +/* + - mapprime - set up case-mapping stuff + */ +static void +mapprime() +{ + register char *lp; + register char *up; + register int c; + register int i; + static char lower[] = "abcdefghijklmnopqrstuvwxyz"; + static char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + for (lp = lower, up = upper; *lp != '\0'; lp++, up++) { + c = *lp; + cmap[c+OFFSET] = c; + cmap[*up+OFFSET] = c; + } + for (i = 0; i < MAPSIZE; i++) + if (cmap[i] == '\0') + cmap[i] = (char)(i-OFFSET); + mprimed = 1; +} + +/* + - casencmp - case-independent strncmp + */ +static int /* < == > 0 */ +casencmp(s1, s2, len) +char *s1; +char *s2; +int len; +{ + register char *p1; + register char *p2; + register int n; + + if (!mprimed) + mapprime(); + + p1 = s1; + p2 = s2; + n = len; + while (--n >= 0 && *p1 != '\0' && TOLOW(*p1) == TOLOW(*p2)) { + p1++; + p2++; + } + if (n < 0) + return(0); + + /* + * The following case analysis is necessary so that characters + * which look negative collate low against normal characters but + * high against the end-of-string NUL. + */ + if (*p1 == '\0' && *p2 == '\0') + return(0); + else if (*p1 == '\0') + return(-1); + else if (*p2 == '\0') + return(1); + else + return(TOLOW(*p1) - TOLOW(*p2)); +} + +/* + - mapcase - do case-mapped copy + */ +static char * /* returns src or dst */ +mapcase(dst, src, siz) +char *dst; /* destination, used only if mapping needed */ +char *src; /* source; src == dst is legal */ +size_t siz; +{ + register char *s; + register char *d; + register char *c; /* case break */ + register char *e; /* end of source */ + + + c = cipoint(src, siz); + if (c == NULL) + return(src); + + if (!mprimed) + mapprime(); + s = src; + e = s + siz; + d = dst; + + while (s < c) + *d++ = *s++; + while (s < e) + *d++ = TOLOW(*s++); + + return(dst); +} + +/* + - cipoint - where in this message-ID does it become case-insensitive? + * + * The RFC822 code is not quite complete. Absolute, total, full RFC822 + * compliance requires a horrible parsing job, because of the arcane + * quoting conventions -- abc"def"ghi is not equivalent to abc"DEF"ghi, + * for example. There are three or four things that might occur in the + * domain part of a message-id that are case-sensitive. They don't seem + * to ever occur in real news, thank Cthulhu. (What? You were expecting + * a merciful and forgiving deity to be invoked in connection with RFC822? + * Forget it; none of them would come near it.) + */ +static char * /* pointer into s, or NULL for "nowhere" */ +cipoint(s, siz) +char *s; +size_t siz; +{ + register char *p; + static char post[] = "postmaster"; + static int plen = sizeof(post)-1; + + switch (conf.casemap) { + case '0': /* unmapped, sensible */ + return(NULL); + break; + case 'C': /* C News, RFC 822 conformant (approx.) */ + p = memchr(s, '@', siz); + if (p == NULL) /* no local/domain split */ + return(NULL); /* assume all local */ + else if (p - (s+1) == plen && CISTREQN(s+1, post, plen)) { + /* crazy -- "postmaster" is case-insensitive */ + return(s); + } else + return(p); + break; + case '=': /* 2.11, neither sensible nor conformant */ + return(s); /* all case-insensitive */ + break; + } + + DEBUG(("cipoint: unknown case mapping `%c'\n", conf.casemap)); + return(NULL); /* just leave it alone */ +} + +/* + - dbzdebug - control dbz debugging at run time + */ +int /* old value */ +dbzdebug(value) +int value; +{ +#ifdef DBZDEBUG + register int old = debug; + + debug = value; + return(old); +#else + return(-1); +#endif +} diff --git a/libio/dbz/dbz.h b/libio/dbz/dbz.h new file mode 100644 index 000000000000..3d7e8ed702cb --- /dev/null +++ b/libio/dbz/dbz.h @@ -0,0 +1,32 @@ +/* for dbm and dbz */ +typedef struct { + char *dptr; + int dsize; +} datum; + +/* standard dbm functions */ +extern int dbminit(); +extern datum fetch(); +extern int store(); +extern int delete(); /* not in dbz */ +extern datum firstkey(); /* not in dbz */ +extern datum nextkey(); /* not in dbz */ +extern int dbmclose(); /* in dbz, but not in old dbm */ + +/* new stuff for dbz */ +extern int dbzfresh(); +extern int dbzagain(); +extern datum dbzfetch(); +extern int dbzstore(); +extern int dbzsync(); +extern long dbzsize(); +extern int dbzincore(); +extern int dbzcancel(); +extern int dbzdebug(); + +/* + * In principle we could handle unlimited-length keys by operating a chunk + * at a time, but it's not worth it in practice. Setting a nice large + * bound on them simplifies the code and doesn't hurt anything. + */ +#define DBZMAXKEY 255 diff --git a/libio/dbz/dbzmain.c b/libio/dbz/dbzmain.c new file mode 100644 index 000000000000..4317a0d08312 --- /dev/null +++ b/libio/dbz/dbzmain.c @@ -0,0 +1,519 @@ +/* + * dbz - use and test dbz in various ways + * + * -Log- + */ + +#include +#include +#include +#include +#include + +#ifdef FUNNYSEEKS +#include +#else +#define SEEK_SET 0 +#endif + +#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) + +#ifndef lint +static char RCSid[] = "$Header: /egcs/carton/cvsfiles/egcs/./libio/dbz/dbzmain.c,v 1.1 1997/08/21 22:58:23 jason Exp $"; +#endif + +char *progname; + +char *inname = "(no file)"; /* filename for messages etc. */ +long lineno; /* line number for messages etc. */ + +char *my_basename; +char *pagname; +char *dir_name; +char *str2dup(); +FILE *base; + +int op = 'b'; /* what to do, default build a new table */ +int baseinput = 1; /* is the base file also the input? */ + +char *from = NULL; /* old table to use for dbzagain() */ +int omitzero = 0; /* omit lines tagged with 0 */ +long every = 0; /* report every n lines */ +int syncs = 0; /* dbzsync() on each report */ +int quick = 0; /* quick checking, not too thorough */ +int sweep = 0; /* sweep file checking all offsets */ +int useincore = 1; /* should we use incore facility? */ +long xxx = 0; /* debugging variable */ +int printx = 0; /* print xxx after all is done */ +int unique = 1; /* before store(), check with fetch() */ +int usefresh = 0; /* use dbzfresh? */ +long siz = 0; /* -p size */ +char map = 'C'; /* -p map */ +long tag = 0; /* -p tag mask */ +int exact = 0; /* do not run dbzsize(siz) */ +int dbzint = 1; /* use new interface? */ +char fs = '\t'; /* field separator, default tab */ +int unopen = 0; /* make base unopenable during dbminit? */ +char *change = NULL; /* chdir here before dbmclose */ + +#define DEFBUF 1024 /* default line-buffer size */ +int buflen = DEFBUF; /* line length limit */ +char lbuf[DEFBUF]; +char *line = lbuf; +char cbuf[DEFBUF]; +char *cmp = cbuf; + +void fail(); +void dofile(); +void runs(); +void dosweep(); +void mkfiles(); +void crfile(); +void doline(); +void process(); + +#ifdef HAVERFCIZE +extern char *rfc822ize(); +#else +#define rfc822ize(n) (n) +#endif + +extern char *malloc(); + +/* + - main - parse arguments and handle options + */ +int +main(argc, argv) +int argc; +char *argv[]; +{ + int c; + int errflg = 0; + extern int optind; + extern char *optarg; + int doruns = 0; + extern long atol(); + + progname = argv[0]; + + while ((c = getopt(argc, argv, "axcmt:l:R0E:SqOiX:Yuf:p:eMUC:d")) != EOF) + switch (c) { + case 'a': /* append to existing table */ + if (op != 'b') + fail("only one of -a -x -c -m can be given", ""); + op = 'a'; + baseinput = 0; + break; + case 'x': /* extract from existing table */ + if (op != 'b') + fail("only one of -a -x -c -m can be given", ""); + op = 'x'; + baseinput = 0; + break; + case 'c': /* check existing table */ + if (op != 'b') + fail("only one of -a -x -c -m can be given", ""); + op = 'c'; + break; + case 'm': /* extract missing (complement of -x) */ + if (op != 'b') + fail("only one of -a -x -c -m can be given", ""); + op = 'm'; + baseinput = 0; + break; + case 't': /* set field separator */ + if (strlen(optarg) > 1) + fail("only one field separator allowed", ""); + fs = *optarg; + break; + case 'l': /* override line-length limit */ + buflen = atoi(optarg) + 1; + if (buflen <= 2) + fail("bad -l value `%s'", optarg); + line = malloc(buflen); + cmp = malloc(buflen); + if (line == NULL || cmp == NULL) + fail("cannot allocate %s-byte buffers", optarg); + break; + case 'R': /* print run statistics */ + doruns = 1; + break; + case '0': /* omit lines tagged (by fake -t) with 0 */ + omitzero = 1; + break; + case 'E': /* report every n items */ + every = atol(optarg); + break; + case 'S': /* dbzsync() on each -E report */ + syncs = 1; + break; + case 'q': /* quick check or extract */ + quick = 1; + break; + case 'O': /* sweep file checking all offsets */ + sweep = 1; + break; + case 'i': /* don't use incore */ + useincore = 0; + break; + case 'X': /* set xxx */ + xxx = atoi(optarg); + break; + case 'Y': /* print xxx afterward */ + printx = 1; + break; + case 'u': /* don't check uniqueness */ + unique = 0; + break; + case 'f': /* init from existing table's parameters */ + from = optarg; + break; + case 'p': /* parameters for dbzfresh */ + if (sscanf(optarg, "%ld %1s %lx", &siz, &map, &tag) != 3) { + map = '?'; + tag = 0; + if (sscanf(optarg, "%ld", &siz) != 1) + fail("bad -n value `%s'", optarg); + } + usefresh = 1; + break; + case 'e': /* -p size is exact, don't dbzsize() it */ + exact = 1; + break; + case 'M': /* use old dbm interface + rfc822ize */ + dbzint = 0; + break; + case 'U': /* make base unopenable during init */ + unopen = 1; + break; + case 'C': /* change directories before dbmclose */ + change = optarg; + break; + case 'd': /* Debugging. */ + if (dbzdebug(1) < 0) + fail("dbz debugging not available", ""); + break; + case '?': + default: + errflg++; + break; + } + if (errflg || optind >= argc || (optind+1 < argc && baseinput)) { + fprintf(stderr, "usage: %s ", progname); + fprintf(stderr, "[-a] [-x] [-c] database [file] ...\n"); + exit(2); + } + + (void) dbzincore(useincore); + my_basename = argv[optind]; + pagname = str2dup(my_basename, ".pag"); + dir_name = str2dup(my_basename, ".dir"); + mkfiles(); + optind++; + + if (baseinput) /* implies no further arguments */ + process(base, my_basename); + else if (optind >= argc) + process(stdin, "stdin"); + else + for (; optind < argc; optind++) + dofile(argv[optind]); + + if (change != NULL) + (void) chdir(change); + if (dbmclose() < 0) + fail("dbmclose failed", ""); + if (doruns) + runs(pagname); + if (sweep) + dosweep(my_basename, pagname); + if (printx) + printf("%ld\n", xxx); +#ifdef DBZ_FINISH + DBZ_FINISH; +#endif + exit(0); +} + +/* + - dofile - open a file and invoke process() + */ +void +dofile(name) +char *name; +{ + register FILE *in; + + if (STREQ(name, "-")) + process(stdin, "-"); + else { + in = fopen(name, "r"); + if (in == NULL) + fail("cannot open `%s'", name); + process(in, name); + (void) fclose(in); + } +} + +/* + - mkfiles - create empty files and open them up + */ +void +mkfiles() +{ + if (op == 'b' && !dbzint) { + crfile(dir_name); + crfile(pagname); + } + + base = fopen(my_basename, (op == 'a') ? "a" : "r"); + if (base == NULL) + fail("cannot open `%s'", my_basename); + if (unopen) + (void) chmod(my_basename, 0); + if (from != NULL) { + if (dbzagain(my_basename, from) < 0) + fail("dbzagain(`%s'...) failed", my_basename); + } else if (op == 'b' && dbzint) { + if (!exact) + siz = dbzsize(siz); + if (dbzfresh(my_basename, siz, (int)fs, map, tag) < 0) + fail("dbzfresh(`%s'...) failed", my_basename); + } else if (dbminit(my_basename) < 0) + fail("dbminit(`%s') failed", my_basename); + if (unopen) + (void) chmod(my_basename, 0600); /* hard to restore original */ +} + +/* + - crfile - create a file + */ +void +crfile(name) +char *name; +{ + register int f; + + f = creat(name, 0666); + if (f < 0) + fail("cannot create `%s'", name); + (void) close(f); +} + +/* + - process - process input file + */ +void +process(in, name) +FILE *in; +char *name; +{ + register off_t place; + + inname = name; + lineno = 0; + + for (;;) { + place = ftell(in); + if (fgets(line, buflen, in) == NULL) + return; + lineno++; + if (every > 0 && lineno%every == 0) { + fprintf(stderr, "%ld\n", lineno); + if (dbzsync() < 0) + fail("dbzsync failed", ""); + } + doline(line, place); + } + /* NOTREACHED */ +} + +/* + - doline - process input line + */ +void +doline(lp, inoffset) +char *lp; +off_t inoffset; +{ + register char *p; + register char pc; + datum key, value; + off_t place = inoffset; + register int shouldfind; + register int llen; + char keytext[DBZMAXKEY+1]; + + p = NULL; + if (fs != '\0') + p = strchr(lp, fs); + if (p == NULL) + p = lp + strlen(lp); + if (p > lp && *(p-1) == '\n') + p--; + if (p - lp > DBZMAXKEY) + fail("key of `%.40s...' too long", lp); + pc = *p; + *p = '\0'; + (void) strcpy(keytext, lp); + *p = pc; + key.dptr = (dbzint) ? keytext : rfc822ize(keytext); + key.dsize = strlen(keytext)+1; + + switch (op) { + case 'a': + place = ftell(base); + llen = strlen(lp); + if (fwrite(lp, 1, llen, base) != llen) + fail("write error in `%s'", my_basename); + /* FALLTHROUGH */ + case 'b': + if (omitzero && p != NULL && *(p+1) == '0') + return; + if (unique) { + value = (dbzint) ? dbzfetch(key) : fetch(key); + if (value.dptr != NULL) + fail("`%.40s...' already present", lp); + } + value.dptr = (char *)&place; + value.dsize = (int)sizeof(off_t); + if (((dbzint) ? dbzstore(key, value) : store(key, value)) < 0) + fail("store failed on `%.40s...'", lp); + break; + case 'c': + value = (dbzint) ? dbzfetch(key) : fetch(key); + shouldfind = (omitzero && p != NULL && *(p+1) == '0') ? 0 : 1; + if (!shouldfind && (value.dptr != NULL || value.dsize != 0)) + fail("`%.40s...' found, shouldn't be", lp); + if (shouldfind && (value.dptr == NULL || + value.dsize != sizeof(off_t))) + fail("can't find `%.40s...'", lp); + if (shouldfind && !quick) { + (void) memcpy((char *)&place, value.dptr, sizeof(off_t)); + if (place != inoffset) + fail("offset mismatch on `%.40s...'", lp); + if (fseek(base, place, SEEK_SET) == -1) + fail("fseek failed on `%.40s...'", lp); + if (fgets(cmp, buflen, base) == NULL) + fail("can't read line for `%.40s...'", lp); + if (!STREQ(lp, cmp)) + fail("compare failed on `%.40s...'", lp); + } + break; + case 'x': + value = (dbzint) ? dbzfetch(key) : fetch(key); + if (value.dptr != NULL && !quick) { + (void) memcpy((char *)&place, value.dptr, sizeof(off_t)); + if (fseek(base, place, SEEK_SET) == -1) + fail("fseek failed on `%.40s...'", lp); + if (fgets(cmp, buflen, base) == NULL) + fail("can't read line for `%.40s...'", lp); + fputs(cmp, stdout); + } else if (value.dptr != NULL) + fputs(lp, stdout); + break; + case 'm': + value = (dbzint) ? dbzfetch(key) : fetch(key); + if (value.dptr == NULL) { + fputs(keytext, stdout); + putchar('\n'); + } + break; + default: + fail("unknown operator -- can't happen", ""); + break; + } +} + +/* + - runs - print run statistics + */ +void +runs(file) +char *file; +{ + register FILE *fd; + off_t it; + register long run; + + fd = fopen(file, "r"); + if (fd == NULL) + fail("cannot reopen `%s'", file); + run = 0; + while (fread((char *)&it, sizeof(off_t), 1, fd) == 1) { + if (it != 0) + run++; + else if (run > 0) { + printf("%ld\n", run); + run = 0; + } + } + (void) fclose(fd); +} + +/* + - dosweep - sweep pag file checking for valid offsets + */ +void +dosweep(fn, pn) +char *fn; +char *pn; +{ + register FILE *pf; + off_t it; + char nl; + register FILE *hf; + + hf = fopen(fn, "r"); + if (hf == NULL) + fail("cannot reopen `%s'", fn); + pf = fopen(pn, "r"); + if (pf == NULL) + fail("cannot reopen `%s'", pn); + while (fread((char *)&it, sizeof(off_t), 1, pf) == 1) { + it = (it & ((off_t)0x80000000)) ? (it&~((off_t)0xff000000)) : it; + if (it != 0 && it != 1) { /* 0 empty, 1 known okay */ + it--; /* get rid of bias */ + (void) fseek(hf, it-1, SEEK_SET); + nl = getc(hf); + if (nl != '\n') + fprintf(stderr, "offset 0%lo does not point to line\n", + (long)it); + } + } + (void) fclose(hf); + (void) fclose(pf); +} + +/* + - fail - complain and die + */ +void +fail(s1, s2) +char *s1; +char *s2; +{ + fprintf(stderr, "%s: (file `%s', line %ld) ", progname, inname, lineno); + fprintf(stderr, s1, s2); + fprintf(stderr, "\n"); + exit(1); +} + +/* + - str2dup - concatenate strings and malloc result + */ +char * +str2dup(s1, s2) +char *s1; +char *s2; +{ + register char *p; + + p = malloc((size_t)strlen(s1) + strlen(s2) + 1); + if (p == NULL) + fail("can't allocate space for strings", ""); + (void) strcpy(p, s1); + (void) strcat(p, s2); + return(p); +} diff --git a/libio/dbz/fake.c b/libio/dbz/fake.c new file mode 100644 index 000000000000..ed2a2b759376 --- /dev/null +++ b/libio/dbz/fake.c @@ -0,0 +1,144 @@ +/* + * fake - make up random lines resembling history-file entries, reproducibly + * + * -Log- + */ + +#include +#include +#include +#include + +#define MAXSTR 500 /* For sizing strings -- DON'T use BUFSIZ! */ +#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) + +#ifndef lint +static char RCSid[] = "$Header: /rel/cvsfiles/devo/libio/dbz/fake.c,v 1.2 1993/10/25 20:02:42 bothner Exp $"; +#endif + +int midonly = 0; /* just message ids, rest not realistic */ +int tag = 0; /* tag lines with random digit for later use */ +int expired = -1; /* percentage of lines to be expired */ + +int debug = 0; +char *progname; + +char *inname; /* filename for messages etc. */ +long lineno; /* line number for messages etc. */ + +void doline(); +void addchars(); +void seed(); + +/* + - main - parse arguments and handle options + */ +int +main(argc, argv) +int argc; +char *argv[]; +{ + int c; + int errflg = 0; + FILE *in; + struct stat statbuf; + extern int optind; + extern char *optarg; + void process(); + register long no; + extern long atol(); + char line[MAXSTR]; + + progname = argv[0]; + + while ((c = getopt(argc, argv, "ms:te:d")) != EOF) + switch (c) { + case 'm': /* message-ids only */ + midonly = 1; + break; + case 's': /* seed */ + seed(atol(optarg)); + break; + case 't': /* tag lines with a random digit */ + tag = 1; + break; + case 'e': /* percentage to be expired */ + expired = atoi(optarg); + break; + case 'd': /* Debugging. */ + debug++; + break; + case '?': + default: + errflg++; + break; + } + if (errflg || optind != argc - 1) { + fprintf(stderr, "usage: %s ", progname); + fprintf(stderr, "[-m] [-s seed] length\n"); + exit(2); + } + + for (no = atol(argv[optind]); no > 0; no--) { + doline(line); + puts(line); + } +#ifdef DBZ_FINISH + DBZ_FINISH; +#endif + exit(0); +} + +/* + - doline - generate random history pseudo-line + */ +void +doline(buf) +char *buf; +{ + char tagch[2]; + + (void) strcpy(buf, "<"); + addchars(buf, range(4, 20)); + (void) strcat(buf, "@"); + addchars(buf, range(8, 20)); + if (midonly) + (void) strcat(buf, ">\tx"); + else { + if (tag) { + tagch[0] = "1234567890"[range(0,9)]; + tagch[1] = '\0'; + (void) strcat(buf, ">\t"); + (void) strcat(buf, tagch); + (void) strcat(buf, "00000000~-"); + } else + (void) strcat(buf, ">\t1234567890~-"); + } + if (range(1, 100) > expired) { + if (midonly) + (void) strcat(buf, "\tx"); + else { + (void) strcat(buf, "\t"); + addchars(buf, range(10, 30)); + } + } +} + +/* + - addchars - generate n random characters suitable for history file + */ +void +addchars(buf, len) +char *buf; +int len; +{ + register int i; + register char *p = buf + strlen(buf); + static char vocab[] = "1234567890.abcde.fghij.klmno.pqrst.uvwxyz.\ +1234567890.ABCDE.FGHIJ.KLMNO.PQRST.UVWXYZ.1234567890.\ +1234567890.abcde.fghij.klmno.pqrst.uvwxyz.1234567890"; + + for (i = len; i > 0; i--) + *p++ = vocab[range(0, sizeof(vocab)-2)]; + *p++ = '\0'; +} diff --git a/libio/dbz/firstlast25 b/libio/dbz/firstlast25 new file mode 100644 index 000000000000..4850468c0c2a --- /dev/null +++ b/libio/dbz/firstlast25 @@ -0,0 +1,50 @@ + 600000000~- 90fz0706yo.1Env21x8b + 200000000~- +<1Hy.ufmjqe371x5.o@HEEl0tAp4> 700000000~- + 600000000~- + 700000000~- +<6kUzkf.v74@iC1iGj882RQ0zli> 400000000~- + 600000000~- +<.wVJi1DX42@5.4i6.jaZ6qw9Ln1.> 500000000~- + 300000000~- +<43hQ.5shbE7@912400.ajES6x0sXl.M> 400000000~- + 600000000~- +<923s5e67d5Oq085Y.1@6Pik68584> 900000000~- +<.5.n5cx5aD62i9q8@Ai60Sc.4x> 200000000~- +<9N9n@3.1ql87.yj2xFs.zLqI> 700000000~- Q2.kni8kZps7kF5uiEv32B38y4z.p +<.X.fw.6LtoT.0@pp6bp.5s6yh74.> 400000000~- +<54c1w@7..u1.99m9T4j.BNGBiK> 600000000~- .F3hb.OFh06V..p + 500000000~- + 000000000~- +<0C605s6plaAgfM.ap40@e6d66n.uv01W.j.8ph.> 100000000~- m.x7TY8.8DQ5 +<.2.14xdn.@D0g.W.uZ.75gyyg.q1G> 100000000~- +<.A..03.@5v..64.5v3.3tbjUo.> 500000000~- +<72..c19ms65.WCf0G3.@83seEG9nnhM.O.j22> 900000000~- + 000000000~- NPLL42XVfM +<6HO.nFal1ufl3.8b@3.n0k7a.IDgNy> 700000000~- Wv4j3Itccnh0Zp3 + 400000000~- k67.hvXwv6X745R4rh2ybuFN3n. +<62dIeg.fW92.ov375@x76mf5c6.37.v> 000000000~- + 900000000~- +<.9Xr.7V91..oe5CG.hX@p5x3jos3s27R6O3yj1> 400000000~- + 100000000~- + 200000000~- + 400000000~- +<87.W3r6is4.@svVqQCBiNqz400A.qwj> 200000000~- +<0liI7Lu0Mx435m7M99@87Xw.8j63.9.> 500000000~- + 200000000~- e27S.BKVD70P.o + 200000000~- +<.2.69hy3JT1@Aq3.r83o.9> 700000000~- +<.W7EurYppo4fhzs.I@8651m2W7v> 700000000~- +<3m02.@22074.a5ct2j3> 900000000~- +<.fy9Epa@.1.kNGCNokFwB8ezo1WM> 800000000~- + 900000000~- + 100000000~- 9A6Ejq5t55I4VJ6.q1 + 300000000~- + 400000000~- + 000000000~- +<.0p3G7novlrYz9kjI@Sx.2w.yqzerZl12781.k> 700000000~- +<51ny.pQ7ay4@nfU2l1f0ixG09584.m> 000000000~- 38K5bhK7cr6.bg.5MlC2Fxq06Ziuw. +<2.cau.9s@.n4Pk0Jd9g> 300000000~- + 300000000~- c8.t4Q0.8t0.m50 +<.t13789u5AqM4m3.z0T@P17e.ypf> 200000000~- q17z.fZ3.FyD533WthqZs8q7 + 100000000~- diff --git a/libio/dbz/getmap b/libio/dbz/getmap new file mode 100755 index 000000000000..fd746cad7d95 --- /dev/null +++ b/libio/dbz/getmap @@ -0,0 +1,6 @@ +#!/bin/sh +awk 'NR == 1 { + for (i = 9; i <= NF; i++) + printf "%s ", $i + printf "\n" +}' $* diff --git a/libio/dbz/random.c b/libio/dbz/random.c new file mode 100644 index 000000000000..1d8de3a2b44d --- /dev/null +++ b/libio/dbz/random.c @@ -0,0 +1,31 @@ +/* + * random-number generator for testing + */ +static unsigned long next = 1; + +/* + - range - generate a random number within an inclusive range + * + * Algorithm from ANSI C standard. Limitation: max-min <= 32767. + */ +int +range(min, max) +int min; +int max; +{ + register int temp; + + next = next * 1103515245 + 12345; + temp = (int)((next/65536)%32768); + return(temp%(max - min + 1) + min); +} + +/* + - seed - seed random number generator + */ +void +seed(n) +long n; +{ + next = (unsigned long)n; +} diff --git a/libio/dbz/revbytes b/libio/dbz/revbytes new file mode 100644 index 000000000000..b3d80c2685fb --- /dev/null +++ b/libio/dbz/revbytes @@ -0,0 +1,7 @@ +NR == 1 { + printf "%s %s %s %s %s %s %s %s %s", $1, $2, $3, $4, $5, $6, $7, $8, $9 + for (i = NF; i > 9; i--) + printf " %s", $i + printf "\n" +} +NR > 1 { print } diff --git a/libio/dbz/stdio.h b/libio/dbz/stdio.h new file mode 100644 index 000000000000..80faee30ad96 --- /dev/null +++ b/libio/dbz/stdio.h @@ -0,0 +1 @@ +#include "../iostdio.h" diff --git a/libio/depend b/libio/depend new file mode 100644 index 000000000000..171356c080f3 --- /dev/null +++ b/libio/depend @@ -0,0 +1,352 @@ +# AUTOMATICALLY GENERATED BY 'make depend' - DO NOT EDIT + +PlotFile.o: PlotFile.cc \ + $(srcdir)/PlotFile.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h +SFile.o: SFile.cc \ + $(srcdir)/SFile.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h +builtinbuf.o: builtinbuf.cc \ + $(srcdir)/builtinbuf.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/iostreamP.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +editbuf.o: editbuf.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/editbuf.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +filebuf.o: filebuf.cc \ + $(srcdir)/iostreamP.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/builtinbuf.h +fstream.o: fstream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +indstream.o: indstream.cc \ + $(srcdir)/indstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h +ioassign.o: ioassign.cc \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +ioextend.o: ioextend.cc \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h +iomanip.o: iomanip.cc \ + $(srcdir)/iomanip.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h +iostream.o: iostream.cc \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/floatio.h +isgetline.o: isgetline.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +isgetsb.o: isgetsb.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +isscan.o: isscan.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +osform.o: osform.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h +parsestream.o: parsestream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/parsestream.h \ + $(srcdir)/streambuf.h +pfstream.o: pfstream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/pfstream.h \ + $(srcdir)/fstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/procbuf.h +procbuf.o: procbuf.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/procbuf.h \ + $(srcdir)/streambuf.h +sbform.o: sbform.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/streambuf.h +sbgetline.o: sbgetline.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/streambuf.h +sbscan.o: sbscan.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/streambuf.h +stdiostream.o: stdiostream.cc \ + $(srcdir)/stdiostream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +stdstrbufs.o: stdstrbufs.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +stdstreams.o: stdstreams.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/iostream.h +stream.o: stream.cc \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/stream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/strstream.h \ + $(srcdir)/strfile.h +streambuf.o: streambuf.cc \ + $(srcdir)/iostreamP.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h +strstream.o: strstream.cc \ + $(srcdir)/iostreamP.h \ + $(srcdir)/streambuf.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/strstream.h \ + $(srcdir)/iostream.h \ + $(srcdir)/strfile.h +cleanup.o: cleanup.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +filedoalloc.o: filedoalloc.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +fileops.o: fileops.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +floatconv.o: floatconv.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +genops.o: genops.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofclose.o: iofclose.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofdopen.o: iofdopen.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofflush.o: iofflush.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofgetpos.o: iofgetpos.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofgets.o: iofgets.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofopen.o: iofopen.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofprintf.o: iofprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofputs.o: iofputs.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofread.o: iofread.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofscanf.o: iofscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofsetpos.o: iofsetpos.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioftell.o: ioftell.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iofwrite.o: iofwrite.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iogetdelim.o: iogetdelim.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iogetline.o: iogetline.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iogets.o: iogets.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioignore.o: ioignore.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iopadn.o: iopadn.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioperror.o: ioperror.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iopopen.o: iopopen.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioprims.o: ioprims.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioprintf.o: ioprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioputs.o: ioputs.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioscanf.o: ioscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioseekoff.o: ioseekoff.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioseekpos.o: ioseekpos.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iosetbuffer.o: iosetbuffer.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iosetvbuf.o: iosetvbuf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iosprintf.o: iosprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iosscanf.o: iosscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iostrerror.o: iostrerror.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +ioungetc.o: ioungetc.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +iovfprintf.o: iovfprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/floatio.h +iovfscanf.o: iovfscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/floatio.h +iovsprintf.o: iovsprintf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/strfile.h +iovsscanf.o: iovsscanf.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/strfile.h +outfloat.o: outfloat.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +stdfiles.o: stdfiles.c \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h \ + $(srcdir)/libio.h _G_config.h +strops.o: strops.c \ + $(srcdir)/strfile.h \ + $(srcdir)/libio.h _G_config.h \ + $(srcdir)/libioP.h \ + $(srcdir)/iolibio.h diff --git a/libio/editbuf.cc b/libio/editbuf.cc new file mode 100644 index 000000000000..22304820f8fd --- /dev/null +++ b/libio/editbuf.cc @@ -0,0 +1,717 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include "libioP.h" +#include "editbuf.h" +#include +#include + +/* NOTE: Some of the code here is taken from GNU emacs */ +/* Hence this file falls under the GNU License! */ + +// Invariants for edit_streambuf: +// An edit_streambuf is associated with a specific edit_string, +// which again is a sub-string of a specific edit_buffer. +// An edit_streambuf is always in either get mode or put mode, never both. +// In get mode, gptr() is the current position, +// and pbase(), pptr(), and epptr() are all NULL. +// In put mode, pptr() is the current position, +// and eback(), gptr(), and egptr() are all NULL. +// Any edit_streambuf that is actively doing insertion (as opposed to +// replacing) // must have its pptr() pointing to the start of the gap. +// Only one edit_streambuf can be actively inserting into a specific +// edit_buffer; the edit_buffer's _writer field points to that edit_streambuf. +// That edit_streambuf "owns" the gap, and the actual start of the +// gap is the pptr() of the edit_streambuf; the edit_buffer::_gap_start pointer +// will only be updated on an edit_streambuf::overflow(). + +int edit_streambuf::truncate() +{ + str->buffer->delete_range(str->buffer->tell((buf_char*)pptr()), + str->buffer->tell(str->end)); + return 0; +} + +#ifdef OLD_STDIO +inline void disconnect_gap_from_file(edit_buffer* buffer, FILE* fp) +{ + if (buffer->gap_start_ptr != &fp->__bufp) + return; + buffer->gap_start_normal = fp->__bufp; + buffer->gap_start_ptr = &buffer->gap_start_normal; +} +#endif + +void edit_streambuf::flush_to_buffer(edit_buffer* buffer) +{ + if (pptr() > buffer->_gap_start && pptr() < buffer->gap_end()) + buffer->_gap_start = pptr(); +} + +void edit_streambuf::disconnect_gap_from_file(edit_buffer* buffer) +{ + if (buffer->_writer != this) return; + flush_to_buffer(buffer); + setp(pptr(),pptr()); + buffer->_writer = NULL; +} + +buf_index edit_buffer::tell(buf_char *ptr) +{ + if (ptr <= gap_start()) + return ptr - data; + else + return ptr - gap_end() + size1(); +} + +#if 0 +buf_index buf_cookie::tell() +{ + return str->buffer->tell(file->__bufp); +} +#endif + +buf_index edit_buffer::tell(edit_mark*mark) +{ + return tell(data + mark->index_in_buffer(this)); +} + +// adjust the position of the gap + +void edit_buffer::move_gap(buf_offset pos) +{ + if (pos < size1()) + gap_left (pos); + else if (pos > size1()) + gap_right (pos); +} + +void edit_buffer::gap_left (int pos) +{ + register buf_char *to, *from; + register int i; + int new_s1; + + i = size1(); + from = gap_start(); + to = from + gap_size(); + new_s1 = size1(); + + /* Now copy the characters. To move the gap down, + copy characters up. */ + + for (;;) + { + /* I gets number of characters left to copy. */ + i = new_s1 - pos; + if (i == 0) + break; +#if 0 + /* If a quit is requested, stop copying now. + Change POS to be where we have actually moved the gap to. */ + if (QUITP) + { + pos = new_s1; + break; + } +#endif + /* Move at most 32000 chars before checking again for a quit. */ + if (i > 32000) + i = 32000; + new_s1 -= i; + while (--i >= 0) + *--to = *--from; + } + + /* Adjust markers, and buffer data structure, to put the gap at POS. + POS is where the loop above stopped, which may be what was specified + or may be where a quit was detected. */ + adjust_markers (pos << 1, size1() << 1, gap_size(), data); +#ifndef OLD_STDIO + _gap_start = data + pos; +#else + if (gap_start_ptr == &gap_start_normal) + gap_start_normal = data + pos; +#endif + __gap_end_pos = to - data; +/* QUIT;*/ +} + +void edit_buffer::gap_right (int pos) +{ + register buf_char *to, *from; + register int i; + int new_s1; + + i = size1(); + to = gap_start(); + from = i + gap_end(); + new_s1 = i; + + /* Now copy the characters. To move the gap up, + copy characters down. */ + + while (1) + { + /* I gets number of characters left to copy. */ + i = pos - new_s1; + if (i == 0) + break; +#if 0 + /* If a quit is requested, stop copying now. + Change POS to be where we have actually moved the gap to. */ + if (QUITP) + { + pos = new_s1; + break; + } +#endif + /* Move at most 32000 chars before checking again for a quit. */ + if (i > 32000) + i = 32000; + new_s1 += i; + while (--i >= 0) + *to++ = *from++; + } + + adjust_markers ((size1() + gap_size()) << 1, (pos + gap_size()) << 1, + - gap_size(), data); +#ifndef OLD_STDIO + _gap_start = data+pos; +#else + if (gap_start_ptr == &gap_start_normal) + gap_start_normal = data + pos; +#endif + __gap_end_pos = from - data; +/* QUIT;*/ +} + +/* make sure that the gap in the current buffer is at least k + characters wide */ + +void edit_buffer::make_gap(buf_offset k) +{ + register buf_char *p1, *p2, *lim; + buf_char *old_data = data; + int s1 = size1(); + + if (gap_size() >= k) + return; + + /* Get more than just enough */ + if (buf_size > 1000) k += 2000; + else k += /*200;*/ 20; // for testing! + + p1 = (buf_char *) realloc (data, s1 + size2() + k); + if (p1 == 0) + abort(); /*memory_full ();*/ + + k -= gap_size(); /* Amount of increase. */ + + /* Record new location of text */ + data = p1; + + /* Transfer the new free space from the end to the gap + by shifting the second segment upward */ + p2 = data + buf_size; + p1 = p2 + k; + lim = p2 - size2(); + while (lim < p2) + *--p1 = *--p2; + + /* Finish updating text location data */ + __gap_end_pos += k; + +#ifndef OLD_STDIO + _gap_start = data + s1; +#else + if (gap_start_ptr == &gap_start_normal) + gap_start_normal = data + s1; +#endif + + /* adjust markers */ + adjust_markers (s1 << 1, (buf_size << 1) + 1, k, old_data); + buf_size += k; +} + +/* Add `amount' to the position of every marker in the current buffer + whose current position is between `from' (exclusive) and `to' (inclusive). + Also, any markers past the outside of that interval, in the direction + of adjustment, are first moved back to the near end of the interval + and then adjusted by `amount'. */ + +void edit_buffer::adjust_markers(register mark_pointer low, + register mark_pointer high, + int amount, buf_char *old_data) +{ + register struct edit_mark *m; + register mark_pointer mpos; + /* convert to mark_pointer */ + amount <<= 1; + + if (_writer) + _writer->disconnect_gap_from_file(this); + + for (m = mark_list(); m != NULL; m = m->chain) + { + mpos = m->_pos; + if (amount > 0) + { + if (mpos > high && mpos < high + amount) + mpos = high + amount; + } + else + { + if (mpos > low + amount && mpos <= low) + mpos = low + amount; + } + if (mpos > low && mpos <= high) + mpos += amount; + m->_pos = mpos; + } + + // Now adjust files + edit_streambuf *file; + + for (file = files; file != NULL; file = file->next) { + mpos = file->current() - old_data; + if (amount > 0) + { + if (mpos > high && mpos < high + amount) + mpos = high + amount; + } + else + { + if (mpos > low + amount && mpos <= low) + mpos = low + amount; + } + if (mpos > low && mpos <= high) + mpos += amount; + char* new_pos = data + mpos; + file->set_current(new_pos, file->is_reading()); + } +} + +#if 0 +stdio_ + __off == index at start of buffer (need only be valid after seek ? ) + __buf == + +if read/read_delete/overwrite mode: + __endp <= min(*gap_start_ptr, edit_string->end->ptr(buffer)) + +if inserting: + must have *gap_start_ptr == __bufp && *gap_start_ptr+gap == __endp + file->edit_string->end->ptr(buffer) == *gap_start_ptr+end +if write_mode: + if before gap +#endif + +int edit_streambuf::underflow() +{ + if (!(_mode & ios::in)) + return EOF; + struct edit_buffer *buffer = str->buffer; + if (!is_reading()) { // Must switch from put to get mode. + disconnect_gap_from_file(buffer); + set_current(pptr(), 1); + } + buf_char *str_end = str->end->ptr(buffer); + retry: + if (gptr() < egptr()) { + return *gptr(); + } + if ((buf_char*)gptr() == str_end) + return EOF; + if (str_end <= buffer->gap_start()) { + setg(eback(), gptr(), str_end); + goto retry; + } + if (gptr() < buffer->gap_start()) { + setg(eback(), gptr(), buffer->gap_start()); + goto retry; + } + if (gptr() == buffer->gap_start()) { + disconnect_gap_from_file(buffer); +// fp->__offset += fp->__bufp - fp->__buffer; + setg(buffer->gap_end(), buffer->gap_end(), str_end); + } + else + setg(eback(), gptr(), str_end); + goto retry; +} + +int edit_streambuf::overflow(int ch) +{ + if (_mode == ios::in) + return EOF; + struct edit_buffer *buffer = str->buffer; + flush_to_buffer(buffer); + if (ch == EOF) + return 0; + if (is_reading()) { // Must switch from get to put mode. + set_current(gptr(), 0); + } + buf_char *str_end = str->end->ptr(buffer); + retry: + if (pptr() < epptr()) { + *pptr() = ch; + pbump(1); + return (unsigned char)ch; + } + if ((buf_char*)pptr() == str_end || inserting()) { + /* insert instead */ + if (buffer->_writer) + buffer->_writer->flush_to_buffer(); // Redundant? + buffer->_writer = NULL; + if (pptr() >= buffer->gap_end()) + buffer->move_gap(pptr() - buffer->gap_size()); + else + buffer->move_gap(pptr()); + buffer->make_gap(1); + setp(buffer->gap_start(), buffer->gap_end()); + buffer->_writer = this; + *pptr() = ch; + pbump(1); + return (unsigned char)ch; + } + if (str_end <= buffer->gap_start()) { + // Entire string is left of gap. + setp(pptr(), str_end); + } + else if (pptr() < buffer->gap_start()) { + // Current pos is left of gap. + setp(pptr(), buffer->gap_start()); + goto retry; + } + else if (pptr() == buffer->gap_start()) { + // Current pos is at start of gap; move to end of gap. +// disconnect_gap_from_file(buffer); + setp(buffer->gap_end(), str_end); +// __offset += __bufp - __buffer; + } + else { + // Otherwise, current pos is right of gap. + setp(pptr(), str_end); + } + goto retry; +} + +void edit_streambuf::set_current(char *new_pos, int reading) +{ + if (reading) { + setg(new_pos, new_pos, new_pos); + setp(NULL, NULL); + } + else { + setg(NULL, NULL, NULL); + setp(new_pos, new_pos); + } +} + +// Called by fseek(fp, pos, whence) if fp is bound to a edit_buffer. + +streampos edit_streambuf::seekoff(streamoff offset, _seek_dir dir, + int /* =ios::in|ios::out*/) +{ + struct edit_buffer *buffer = str->buffer; + disconnect_gap_from_file(buffer); + buf_index cur_pos = buffer->tell((buf_char*)current());; + buf_index start_pos = buffer->tell(str->start); + buf_index end_pos = buffer->tell(str->end); + switch (dir) { + case ios::beg: + offset += start_pos; + break; + case ios::cur: + offset += cur_pos; + break; + case ios::end: + offset += end_pos; + break; + } + if (offset < start_pos || offset > end_pos) + return EOF; + buf_char *new_pos = buffer->data + offset; + buf_char* gap_start = buffer->gap_start(); + if (new_pos > gap_start) { + buf_char* gap_end = buffer->gap_end(); + new_pos += gap_end - gap_start; + if (new_pos >= buffer->data + buffer->buf_size) abort(); // Paranoia. + } + set_current(new_pos, is_reading()); + return EOF; +} + +#if 0 +int buf_seek(void *arg_cookie, fpos_t * pos, int whence) +{ + struct buf_cookie *cookie = arg_cookie; + FILE *file = cookie->file; + struct edit_buffer *buffer = cookie->str->buffer; + buf_char *str_start = cookie->str->start->ptr(buffer); + disconnect_gap_from_file(buffer, cookie->file); + fpos_t cur_pos, new_pos; + if (file->__bufp <= *buffer->gap_start_ptr + || str_start >= buffer->__gap_end) + cur_pos = str_start - file->__bufp; + else + cur_pos = + (*buffer->gap_start_ptr - str_start) + (file->__bufp - __gap_end); + end_pos = ...; + switch (whence) { + case SEEK_SET: + new_pos = *pos; + break; + case SEEK_CUR: + new_pos = cur_pos + *pos; + break; + case SEEK_END: + new_pos = end_pos + *pos; + break; + } + if (new_pos > end_pos) { + seek to end_pos; + insert_nulls(new_pos - end_pos); + return; + } + if (str_start + new_pos <= *gap_start_ptr &* *gap_start_ptr < end) { + __buffer = str_start; + __off = 0; + __bufp = str_start + new_pos; + file->__get_limit = + *buffer->gap_start_ptr; /* what if gap_start_ptr == &bufp ??? */ + } else if () { + + } + *pos = new_pos; +} +#endif + +/* Delete characters from `from' up to (but not incl) `to' */ + +void edit_buffer::delete_range (buf_index from, buf_index to) +{ + register int numdel; + + if ((numdel = to - from) <= 0) + return; + + /* Make sure the gap is somewhere in or next to what we are deleting */ + if (from > size1()) + gap_right (from); + if (to < size1()) + gap_left (to); + + /* Relocate all markers pointing into the new, larger gap + to point at the end of the text before the gap. */ + adjust_markers ((to + gap_size()) << 1, (to + gap_size()) << 1, + - numdel - gap_size(), data); + + __gap_end_pos = to + gap_size(); + _gap_start = data + from; +} + +void edit_buffer::delete_range(struct edit_mark *start, struct edit_mark *end) +{ + delete_range(tell(start), tell(end)); +} + +void buf_delete_chars(struct edit_buffer *, struct edit_mark *, size_t) +{ + abort(); +} + +edit_streambuf::edit_streambuf(edit_string* bstr, int mode) +{ + _mode = mode; + str = bstr; + edit_buffer* buffer = bstr->buffer; + next = buffer->files; + buffer->files = this; + char* buf_ptr = bstr->start->ptr(buffer); + _inserting = 0; +// setb(buf_ptr, buf_ptr, 0); + set_current(buf_ptr, !(mode & ios::out+ios::trunc+ios::app)); + if (_mode & ios::trunc) + truncate(); + if (_mode & ios::ate) + seekoff(0, ios::end); +} + +// Called by fclose(fp) if fp is bound to a edit_buffer. + +#if 0 +static int buf_close(void *arg) +{ + register struct buf_cookie *cookie = arg; + struct edit_buffer *buffer = cookie->str->buffer; + struct buf_cookie **ptr; + for (ptr = &buffer->files; *ptr != cookie; ptr = &(*ptr)->next) ; + *ptr = cookie->next; + disconnect_gap_from_file(buffer, cookie->file); + free (cookie); + return 0; +} +#endif + +edit_streambuf::~edit_streambuf() +{ + if (_mode == ios::out) + truncate(); + // Unlink this from list of files associated with bstr->buffer. + edit_streambuf **ptr = &str->buffer->files; + for (; *ptr != this; ptr = &(*ptr)->next) { } + *ptr = next; + + disconnect_gap_from_file(str->buffer); +} + +edit_buffer::edit_buffer() +{ + buf_size = /*200;*/ 15; /* for testing! */ + data = (buf_char*)malloc(buf_size); + files = NULL; +#ifndef OLD_STDIO + _gap_start = data; + _writer = NULL; +#else + gap_start_normal = data; + gap_start_ptr = &gap_start_normal; +#endif + __gap_end_pos = buf_size; + start_mark.chain = &end_mark; + start_mark._pos = 0; + end_mark.chain = NULL; + end_mark._pos = 2 * buf_size + 1; +} + +// Allocate a new mark, which is adjusted by 'delta' bytes from 'this'. +// Restrict new mark to lie within 'str'. + +edit_mark::edit_mark(struct edit_string *str, long delta) +{ + struct edit_buffer *buf = str->buffer; + chain = buf->start_mark.chain; + buf->start_mark.chain = this; + mark_pointer size1 = buf->size1() << 1; + int gap_size = buf->gap_size() << 1; + delta <<= 1; + + // check if new and old marks are opposite sides of gap + if (_pos <= size1 && _pos + delta > size1) + delta += gap_size; + else if (_pos >= size1 + gap_size && _pos + delta < size1 + gap_size) + delta -= gap_size; + + _pos = _pos + delta; + if (_pos < str->start->_pos & ~1) + _pos = (str->start->_pos & ~ 1) + (_pos & 1); + else if (_pos >= str->end->_pos) + _pos = (str->end->_pos & ~ 1) + (_pos & 1); +} + +// A (slow) way to find the buffer a mark belongs to. + +edit_buffer * edit_mark::buffer() +{ + struct edit_mark *mark; + for (mark = this; mark->chain != NULL; mark = mark->chain) ; + // Assume that the last mark on the chain is the end_mark. + return (edit_buffer *)((char*)mark - offsetof(edit_buffer, end_mark)); +} + +edit_mark::~edit_mark() +{ + // Must unlink mark from chain of owning buffer + struct edit_buffer *buf = buffer(); + if (this == &buf->start_mark || this == &buf->end_mark) abort(); + edit_mark **ptr; + for (ptr = &buf->start_mark.chain; *ptr != this; ptr = &(*ptr)->chain) ; + *ptr = this->chain; +} + +int edit_string::length() const +{ + ptrdiff_t delta = end->ptr(buffer) - start->ptr(buffer); + if (end->ptr(buffer) <= buffer->gap_start() || + start->ptr(buffer) >= buffer->gap_end()) + return delta; + return delta - buffer->gap_size(); +} + +buf_char * edit_string::copy_bytes(int *lenp) const +{ + char *new_str; + int len1, len2; + buf_char *start1, *start2; + start1 = start->ptr(buffer); + if (end->ptr(buffer) <= buffer->gap_start() + || start->ptr(buffer) >= buffer->gap_end()) { + len1 = end->ptr(buffer) - start1; + len2 = 0; + start2 = NULL; // To avoid a warning from g++. + } + else { + len1 = buffer->gap_start() - start1; + start2 = buffer->gap_end(); + len2 = end->ptr(buffer) - start2; + } + new_str = (char*)malloc(len1 + len2 + 1); + memcpy(new_str, start1, len1); + if (len2 > 0) memcpy(new_str + len1, start2, len2); + new_str[len1+len2] = '\0'; + *lenp = len1+len2; + return new_str; +} + +// Replace the buf_chars in 'this' with ones from 'src'. +// Equivalent to deleting this, then inserting src, except tries +// to leave marks in place: Marks whose offset from the start +// of 'this' is less than 'src->length()' will still have the +// same offset in 'this' when done. + +void edit_string::assign(struct edit_string *src) +{ + edit_streambuf dst_file(this, ios::out); + if (buffer == src->buffer /*&& ???*/) { /* overly conservative */ + int src_len; + buf_char *new_str; + new_str = src->copy_bytes(&src_len); + dst_file.sputn(new_str, src_len); + free (new_str); + } else { + edit_streambuf src_file(src, ios::in); + for ( ; ; ) { + int ch = src_file.sbumpc(); + if (ch == EOF) break; + dst_file.sputc(ch); + } + } +} diff --git a/libio/editbuf.h b/libio/editbuf.h new file mode 100644 index 000000000000..d15758f257ea --- /dev/null +++ b/libio/editbuf.h @@ -0,0 +1,185 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#ifndef _EDITBUF_H +#define _EDITBUF_H +#ifdef __GNUG__ +#pragma interface +#endif +#include +#include + +extern "C++" { +typedef unsigned long mark_pointer; +// At some point, it might be nice to parameterize this code +// in terms of buf_char. +typedef /*unsigned*/ char buf_char; + +// Logical pos from start of buffer (does not count gap). +typedef long buf_index; + +// Pos from start of buffer, possibly including gap_size. +typedef long buf_offset; + +#if 0 +struct buf_cookie { + FILE *file; + struct edit_string *str; + struct buf_cookie *next; + buf_index tell(); +}; +#endif + +struct edit_buffer; +struct edit_mark; + +// A edit_string is defined as the region between the 'start' and 'end' marks. +// Normally (always?) 'start->insert_before()' should be false, +// and 'end->insert_before()' should be true. + +struct edit_string { + struct edit_buffer *buffer; // buffer that 'start' and 'end' belong to + struct edit_mark *start, *end; + int length() const; // count of buf_chars currently in string + edit_string(struct edit_buffer *b, + struct edit_mark *ms, struct edit_mark *me) + { buffer = b; start = ms; end = me; } +/* Make a fresh, contiguous copy of the data in STR. + Assign length of STR to *LENP. + (Output has extra NUL at out[*LENP].) */ + buf_char *copy_bytes(int *lenp) const; +// FILE *open_file(char *mode); + void assign(struct edit_string *src); // copy bytes from src to this +}; + +struct edit_streambuf : public streambuf { + friend edit_buffer; + edit_string *str; + edit_streambuf* next; // Chain of edit_streambuf's for a edit_buffer. + short _mode; + edit_streambuf(edit_string* bstr, int mode); + ~edit_streambuf(); + virtual int underflow(); + virtual int overflow(int c = EOF); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + void flush_to_buffer(); + void flush_to_buffer(edit_buffer* buffer); + int _inserting; + int inserting() { return _inserting; } + void inserting(int i) { _inserting = i; } +// int delete_chars(int count, char* cut_buf); Not implemented. + int truncate(); + int is_reading() { return gptr() != NULL; } + buf_char* current() { return is_reading() ? gptr() : pptr(); } + void set_current(char *p, int is_reading); + protected: + void disconnect_gap_from_file(edit_buffer* buffer); +}; + +// A 'edit_mark' indicates a position in a buffer. +// It is "attached" the text (rather than the offset). +// There are two kinds of mark, which have different behavior +// when text is inserted at the mark: +// If 'insert_before()' is true the mark will be adjusted to be +// *after* the new text. + +struct edit_mark { + struct edit_mark *chain; + mark_pointer _pos; + inline int insert_before() { return _pos & 1; } + inline unsigned long index_in_buffer(struct edit_buffer *) + { return _pos >> 1; } + inline buf_char *ptr(struct edit_buffer *buf); + buf_index tell(); + edit_mark() { } + edit_mark(struct edit_string *str, long delta); + edit_buffer *buffer(); + ~edit_mark(); +}; + +// A 'edit_buffer' consists of a sequence of buf_chars (the data), +// a list of edit_marks pointing into the data, and a list of FILEs +// also pointing into the data. +// A 'edit_buffer' coerced to a edit_string is the string of +// all the buf_chars in the buffer. + +// This implementation uses a conventional buffer gap (as in Emacs). +// The gap start is defined by de-referencing a (buf_char**). +// This is because sometimes a FILE is inserting into the buffer, +// so rather than having each putc adjust the gap, we use indirection +// to have the gap be defined as the write pointer of the FILE. +// (This assumes that putc adjusts a pointer (as in GNU's libc), not an index.) + +struct edit_buffer { + buf_char *data; /* == emacs buffer_text.p1+1 */ + buf_char *_gap_start; + edit_streambuf* _writer; // If non-NULL, currently writing stream + inline buf_char *gap_start() + { return _writer ? _writer->pptr() : _gap_start; } + buf_offset __gap_end_pos; // size of part 1 + size of gap + /* int gap; implicit: buf_size - size1 - size2 */ + int buf_size; + struct edit_streambuf *files; + struct edit_mark start_mark; + struct edit_mark end_mark; + edit_buffer(); + inline buf_offset gap_end_pos() { return __gap_end_pos; } + inline struct edit_mark *start_marker() { return &start_mark; } + inline struct edit_mark *end_marker() { return &end_mark; } +/* these should be protected, ultimately */ + buf_index tell(edit_mark*); + buf_index tell(buf_char*); + inline buf_char *gap_end() { return data + gap_end_pos(); } + inline int gap_size() { return gap_end() - gap_start(); } + inline int size1() { return gap_start() - data; } + inline int size2() { return buf_size - gap_end_pos(); } + inline struct edit_mark * mark_list() { return &start_mark; } + void make_gap (buf_offset); + void move_gap (buf_offset pos); + void move_gap (buf_char *pos) { move_gap(pos - data); } + void gap_left (int pos); + void gap_right (int pos); + void adjust_markers(mark_pointer low, mark_pointer high, + int amount, buf_char *old_data); + void delete_range(buf_index from, buf_index to); + void delete_range(struct edit_mark *start, struct edit_mark *end); +}; + +extern buf_char * bstr_copy(struct edit_string *str, int *lenp); + +// Convert a edit_mark to a (buf_char*) + +inline buf_char *edit_mark::ptr(struct edit_buffer *buf) + { return buf->data + index_in_buffer(buf); } + +inline void edit_streambuf::flush_to_buffer() +{ + edit_buffer* buffer = str->buffer; + if (buffer->_writer == this) flush_to_buffer(buffer); +} +} // extern "C++" +#endif /* !_EDITBUF_H*/ + diff --git a/libio/filebuf.cc b/libio/filebuf.cc new file mode 100644 index 000000000000..1e2682fbce95 --- /dev/null +++ b/libio/filebuf.cc @@ -0,0 +1,206 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993, 1995 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#include "iostreamP.h" +#include +#include +#include +#include +#include "builtinbuf.h" + +void filebuf::init() +{ + _IO_file_init(this); +} + +filebuf::filebuf() +{ + _IO_file_init(this); +} + +#if !_IO_UNIFIED_JUMPTABLES +/* This is like "new filebuf()", but it uses the _IO_file_jump jumptable, + for eficiency. */ + +filebuf* filebuf::__new() +{ + filebuf *fb = new filebuf; + _IO_JUMPS(fb) = &_IO_file_jumps; + fb->_vtable() = builtinbuf_vtable; + return fb; +} +#endif + +filebuf::filebuf(int fd) +{ + _IO_file_init(this); + _IO_file_attach(this, fd); +} + +filebuf::filebuf(int fd, char* p, int len) +{ + _IO_file_init(this); + _IO_file_attach(this, fd); + setbuf(p, len); +} + +filebuf::~filebuf() +{ + if (_IO_file_is_open(this)) + { + _IO_do_flush (this); + if (!(xflags() & _IO_DELETE_DONT_CLOSE)) + _IO_SYSCLOSE (this); + } +} + +filebuf* filebuf::open(const char *filename, ios::openmode mode, int prot) +{ + if (_IO_file_is_open (this)) + return NULL; + int posix_mode; + int read_write; + if (mode & ios::app) + mode |= ios::out; + if ((mode & (ios::in|ios::out)) == (ios::in|ios::out)) { + posix_mode = O_RDWR; + read_write = 0; + } + else if (mode & ios::out) + posix_mode = O_WRONLY, read_write = _IO_NO_READS; + else if (mode & (int)ios::in) + posix_mode = O_RDONLY, read_write = _IO_NO_WRITES; + else + posix_mode = 0, read_write = _IO_NO_READS+_IO_NO_WRITES; + if (mode & ios::binary) + { + mode &= ~ios::binary; +#ifdef O_BINARY + /* This is a (mis-)feature of DOS/Windows C libraries. */ + posix_mode |= O_BINARY; +#endif + } + if ((mode & (int)ios::trunc) || mode == (int)ios::out) + posix_mode |= O_TRUNC; + if (mode & ios::app) + posix_mode |= O_APPEND, read_write |= _IO_IS_APPENDING; + if (!(mode & (int)ios::nocreate) && mode != ios::in) + posix_mode |= O_CREAT; + if (mode & (int)ios::noreplace) + posix_mode |= O_EXCL; + int fd = ::open(filename, posix_mode, prot); + if (fd < 0) + return NULL; + _fileno = fd; + xsetflags(read_write, _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); + if (mode & (ios::ate|ios::app)) { + if (pubseekoff(0, ios::end) == EOF) + return NULL; + } + _IO_link_in(this); + return this; +} + +filebuf* filebuf::open(const char *filename, const char *mode) +{ + return (filebuf*)_IO_file_fopen(this, filename, mode); +} + +filebuf* filebuf::attach(int fd) +{ + return (filebuf*)_IO_file_attach(this, fd); +} + +streambuf* filebuf::setbuf(char* p, int len) +{ + return (streambuf*)_IO_file_setbuf (this, p, len); +} + +int filebuf::doallocate() { return _IO_file_doallocate(this); } + +int filebuf::overflow(int c) +{ + return _IO_file_overflow(this, c); +} + +int filebuf::underflow() +{ + return _IO_file_underflow(this); +} + +int filebuf::sync() +{ + return _IO_file_sync(this); +} + +streampos filebuf::seekoff(streamoff offset, _seek_dir dir, int mode) +{ + return _IO_file_seekoff (this, offset, dir, mode); +} + +filebuf* filebuf::close() +{ + return (_IO_file_close_it(this) ? (filebuf*)NULL : this); +} + +streamsize filebuf::sys_read(char* buf, streamsize size) +{ + return _IO_file_read(this, buf, size); +} + +streampos filebuf::sys_seek(streamoff offset, _seek_dir dir) +{ + return _IO_file_seek(this, offset, dir); +} + +streamsize filebuf::sys_write(const char *buf, streamsize n) +{ + return _IO_file_write (this, buf, n); +} + +int filebuf::sys_stat(void* st) +{ + return _IO_file_stat (this, st); +} + +int filebuf::sys_close() +{ + return _IO_file_close (this); +} + +streamsize filebuf::xsputn(const char *s, streamsize n) +{ + return _IO_file_xsputn(this, s, n); +} + +streamsize filebuf::xsgetn(char *s, streamsize n) +{ + // FIXME: OPTIMIZE THIS (specifically, when unbuffered()). + return streambuf::xsgetn(s, n); +} + +// Non-ANSI AT&T-ism: Default open protection. +const int filebuf::openprot = 0644; diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c new file mode 100644 index 000000000000..f838bb3458f7 --- /dev/null +++ b/libio/filedoalloc.c @@ -0,0 +1,102 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* Modified for GNU iostream by Per Bothner 1991, 1992. */ + +#define _POSIX_SOURCE +#include "libioP.h" +#include +#include +#ifdef __STDC__ +#include +#include +#endif + +/* + * Allocate a file buffer, or switch to unbuffered I/O. + * Per the ANSI C standard, ALL tty devices default to line buffered. + * + * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek + * optimisation) right after the _fstat() that finds the buffer size. + */ + +int +DEFUN(_IO_file_doallocate, (fp), + register _IO_FILE *fp) +{ + register _IO_size_t size; + int couldbetty; + register char *p; + struct stat st; + + /* If _IO_cleanup_registration_needed is non-zero, we should call the + function it points to. This is to make sure _IO_cleanup gets called + on exit. We call it from _IO_file_doallocate, since that is likely + to get called by any program that does buffered I/O. */ + if (_IO_cleanup_registration_needed) + (*_IO_cleanup_registration_needed)(); + + if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0) + { + couldbetty = 0; + size = _IO_BUFSIZ; +#if 0 + /* do not try to optimise fseek() */ + fp->_flags |= __SNPT; +#endif + } + else + { + couldbetty = S_ISCHR(st.st_mode); +#if _IO_HAVE_ST_BLKSIZE + size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize; +#else + size = _IO_BUFSIZ; +#endif + } + p = ALLOC_BUF(size); + if (p == NULL) + return EOF; + _IO_setb(fp, p, p+size, 1); + if (couldbetty && isatty(fp->_fileno)) + fp->_flags |= _IO_LINE_BUF; + return 1; +} diff --git a/libio/fileops.c b/libio/fileops.c new file mode 100644 index 000000000000..812af94d0f95 --- /dev/null +++ b/libio/fileops.c @@ -0,0 +1,755 @@ +/* +Copyright (C) 1993, 1995 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* written by Per Bothner (bothner@cygnus.com) */ + +#define _POSIX_SOURCE +#include "libioP.h" +#include +#include +#include +#include +#include +#ifndef errno +extern int errno; +#endif + +/* An fstream can be in at most one of put mode, get mode, or putback mode. + Putback mode is a variant of get mode. + + In a filebuf, there is only one current position, instead of two + separate get and put pointers. In get mode, the current posistion + is that of gptr(); in put mode that of pptr(). + + The position in the buffer that corresponds to the position + in external file system is normally _IO_read_end, except in putback + mode, when it is _IO_save_end. + If the field _fb._offset is >= 0, it gives the offset in + the file as a whole corresponding to eGptr(). (?) + + PUT MODE: + If a filebuf is in put mode, then all of _IO_read_ptr, _IO_read_end, + and _IO_read_base are equal to each other. These are usually equal + to _IO_buf_base, though not necessarily if we have switched from + get mode to put mode. (The reason is to maintain the invariant + that _IO_read_end corresponds to the external file position.) + _IO_write_base is non-NULL and usually equal to _IO_base_base. + We also have _IO_write_end == _IO_buf_end, but only in fully buffered mode. + The un-flushed character are those between _IO_write_base and _IO_write_ptr. + + GET MODE: + If a filebuf is in get or putback mode, eback() != egptr(). + In get mode, the unread characters are between gptr() and egptr(). + The OS file position corresponds to that of egptr(). + + PUTBACK MODE: + Putback mode is used to remember "excess" characters that have + been sputbackc'd in a separate putback buffer. + In putback mode, the get buffer points to the special putback buffer. + The unread characters are the characters between gptr() and egptr() + in the putback buffer, as well as the area between save_gptr() + and save_egptr(), which point into the original reserve buffer. + (The pointers save_gptr() and save_egptr() are the values + of gptr() and egptr() at the time putback mode was entered.) + The OS position corresponds to that of save_egptr(). + + LINE BUFFERED OUTPUT: + During line buffered output, _IO_write_base==base() && epptr()==base(). + However, ptr() may be anywhere between base() and ebuf(). + This forces a call to filebuf::overflow(int C) on every put. + If there is more space in the buffer, and C is not a '\n', + then C is inserted, and pptr() incremented. + + UNBUFFERED STREAMS: + If a filebuf is unbuffered(), the _shortbuf[1] is used as the buffer. +*/ + +#define CLOSED_FILEBUF_FLAGS \ + (_IO_IS_FILEBUF+_IO_NO_READS+_IO_NO_WRITES+_IO_TIED_PUT_GET) + + +void +DEFUN(_IO_file_init, (fp), + register _IO_FILE *fp) +{ + /* POSIX.1 allows another file handle to be used to change the position + of our file descriptor. Hence we actually don't know the actual + position before we do the first fseek (and until a following fflush). */ + fp->_offset = _IO_pos_BAD; + fp->_IO_file_flags |= CLOSED_FILEBUF_FLAGS; + + _IO_link_in(fp); + fp->_fileno = -1; +} + +int +DEFUN(_IO_file_close_it, (fp), + register _IO_FILE* fp) +{ + int write_status, close_status; + if (!_IO_file_is_open(fp)) + return EOF; + + write_status = _IO_do_flush (fp); + + _IO_unsave_markers(fp); + + close_status = _IO_SYSCLOSE (fp); + + /* Free buffer. */ + _IO_setb(fp, NULL, NULL, 0); + _IO_setg(fp, NULL, NULL, NULL); + _IO_setp(fp, NULL, NULL); + + _IO_un_link(fp); + fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS; + fp->_fileno = EOF; + fp->_offset = _IO_pos_BAD; + + return close_status ? close_status : write_status; +} + +void +DEFUN(_IO_file_finish, (fp), + register _IO_FILE* fp) +{ + if (_IO_file_is_open(fp)) + { + _IO_do_flush (fp); + if (!(fp->_flags & _IO_DELETE_DONT_CLOSE)) + _IO_SYSCLOSE (fp); + } + _IO_default_finish(fp); +} + +_IO_FILE * +DEFUN(_IO_file_fopen, (fp, filename, mode), + register _IO_FILE *fp AND const char *filename AND const char *mode) +{ + int oflags = 0, omode; + int read_write, fdesc; + int oprot = 0666; + if (_IO_file_is_open (fp)) + return 0; + switch (*mode++) { + case 'r': + omode = O_RDONLY; + read_write = _IO_NO_WRITES; + break; + case 'w': + omode = O_WRONLY; + oflags = O_CREAT|O_TRUNC; + read_write = _IO_NO_READS; + break; + case 'a': + omode = O_WRONLY; + oflags = O_CREAT|O_APPEND; + read_write = _IO_NO_READS|_IO_IS_APPENDING; + break; + default: + errno = EINVAL; + return NULL; + } + if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) { + omode = O_RDWR; + read_write &= _IO_IS_APPENDING; + } + fdesc = open(filename, omode|oflags, oprot); + if (fdesc < 0) + return NULL; + fp->_fileno = fdesc; + _IO_mask_flags(fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); + if (read_write & _IO_IS_APPENDING) + if (_IO_SEEKOFF (fp, (_IO_off_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT) + == _IO_pos_BAD) + return NULL; + _IO_link_in(fp); + return fp; +} + +_IO_FILE* +DEFUN(_IO_file_attach, (fp, fd), + _IO_FILE *fp AND int fd) +{ + if (_IO_file_is_open(fp)) + return NULL; + fp->_fileno = fd; + fp->_flags &= ~(_IO_NO_READS+_IO_NO_WRITES); + fp->_flags |= _IO_DELETE_DONT_CLOSE; + fp->_offset = _IO_pos_BAD; + return fp; +} + +_IO_FILE* +DEFUN(_IO_file_setbuf, (fp, p, len), + register _IO_FILE *fp AND char* p AND _IO_ssize_t len) +{ + if (_IO_default_setbuf(fp, p, len) == NULL) + return NULL; + + fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end + = fp->_IO_buf_base; + _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); + + return fp; +} + +/* Write TO_DO bytes from DATA to FP. + Then mark FP as having empty buffers. */ + +int +DEFUN(_IO_do_write, (fp, data, to_do), + register _IO_FILE *fp AND const char* data AND _IO_size_t to_do) +{ + _IO_size_t count; + if (to_do == 0) + return 0; + else + { + if (fp->_flags & _IO_IS_APPENDING) + /* On a system without a proper O_APPEND implementation, + you would need to sys_seek(0, SEEK_END) here, but is + is not needed nor desirable for Unix- or Posix-like systems. + Instead, just indicate that offset (before and after) is + unpredictable. */ + fp->_offset = _IO_pos_BAD; + else if (fp->_IO_read_end != fp->_IO_write_base) + { + _IO_pos_t new_pos + = _IO_SYSSEEK(fp, fp->_IO_write_base - fp->_IO_read_end, 1); + if (new_pos == _IO_pos_BAD) + return EOF; + fp->_offset = new_pos; + } + count = _IO_SYSWRITE (fp, data, to_do); + if (fp->_cur_column) + fp->_cur_column + = _IO_adjust_column (fp->_cur_column - 1, data, to_do) + 1; + } + _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); + fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base; + fp->_IO_write_end = (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) ? fp->_IO_buf_base + : fp->_IO_buf_end; + return count != to_do ? EOF : 0; +} + +int +DEFUN(_IO_file_underflow, (fp), + register _IO_FILE *fp) +{ + _IO_ssize_t count; +#if 0 + /* SysV does not make this test; take it out for compatibility */ + if (fp->_flags & _IO_EOF_SEEN) + return (EOF); +#endif + + if (fp->_flags & _IO_NO_READS) + return EOF; + if (fp->_IO_read_ptr < fp->_IO_read_end) + return *(unsigned char*)fp->_IO_read_ptr; + + if (fp->_IO_buf_base == NULL) + _IO_doallocbuf(fp); + + /* Flush all line buffered files before reading. */ + /* FIXME This can/should be moved to genops ?? */ + if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED)) + _IO_flush_all_linebuffered(); + + _IO_switch_to_get_mode(fp); + + count = _IO_SYSREAD (fp, fp->_IO_buf_base, + fp->_IO_buf_end - fp->_IO_buf_base); + if (count <= 0) + { + if (count == 0) + fp->_flags |= _IO_EOF_SEEN; + else + fp->_flags |= _IO_ERR_SEEN, count = 0; + } + fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_buf_base; + fp->_IO_read_end = fp->_IO_buf_base + count; + fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end + = fp->_IO_buf_base; + if (count == 0) + return EOF; + if (fp->_offset != _IO_pos_BAD) + _IO_pos_adjust(fp->_offset, count); + return *(unsigned char*)fp->_IO_read_ptr; +} + +int +DEFUN(_IO_file_overflow, (f, ch), + register _IO_FILE* f AND int ch) +{ + if (f->_flags & _IO_NO_WRITES) /* SET ERROR */ + return EOF; + /* If currently reading or no buffer allocated. */ + if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0) + { + /* Allocate a buffer if needed. */ + if (f->_IO_write_base == 0) + { + _IO_doallocbuf(f); + _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base); + } + /* Otherwise must be currently reading. + If _IO_read_ptr (and hence also _IO_read_end) is at the buffer end, + logically slide the buffer forwards one block (by setting the + read pointers to all point at the beginning of the block). This + makes room for subsequent output. + Otherwise, set the read pointers to _IO_read_end (leaving that + alone, so it can continue to correspond to the external position). */ + if (f->_IO_read_ptr == f->_IO_buf_end) + f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base; + f->_IO_write_ptr = f->_IO_read_ptr; + f->_IO_write_base = f->_IO_write_ptr; + f->_IO_write_end = f->_IO_buf_end; + f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end; + + if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) + f->_IO_write_end = f->_IO_write_ptr; + f->_flags |= _IO_CURRENTLY_PUTTING; + } + if (ch == EOF) + return _IO_do_flush(f); + if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */ + if (_IO_do_flush(f) == EOF) + return EOF; + *f->_IO_write_ptr++ = ch; + if ((f->_flags & _IO_UNBUFFERED) + || ((f->_flags & _IO_LINE_BUF) && ch == '\n')) + if (_IO_do_flush(f) == EOF) + return EOF; + return (unsigned char)ch; +} + +int +DEFUN(_IO_file_sync, (fp), + register _IO_FILE* fp) +{ + _IO_size_t delta; + /* char* ptr = cur_ptr(); */ + if (fp->_IO_write_ptr > fp->_IO_write_base) + if (_IO_do_flush(fp)) return EOF; + delta = fp->_IO_read_ptr - fp->_IO_read_end; + if (delta != 0) + { +#ifdef TODO + if (_IO_in_backup(fp)) + delta -= eGptr() - Gbase(); +#endif + _IO_off_t new_pos = _IO_SYSSEEK (fp, delta, 1); + if (new_pos != (_IO_off_t)EOF) + fp->_IO_read_end = fp->_IO_read_ptr; +#ifdef ESPIPE + else if (errno == ESPIPE) + ; /* Ignore error from unseekable devices. */ +#endif + else + return EOF; + } + fp->_offset = _IO_pos_BAD; + /* FIXME: Cleanup - can this be shared? */ + /* setg(base(), ptr, ptr); */ + return 0; +} + +_IO_pos_t +DEFUN(_IO_file_seekoff, (fp, offset, dir, mode), + register _IO_FILE *fp AND _IO_off_t offset AND int dir AND int mode) +{ + _IO_pos_t result; + _IO_off_t delta, new_offset; + long count; + + if (mode == 0) + dir = _IO_seek_cur, offset = 0; /* Don't move any pointers. */ + + /* Flush unwritten characters. + (This may do an unneeded write if we seek within the buffer. + But to be able to switch to reading, we would need to set + egptr to ptr. That can't be done in the current design, + which assumes file_ptr() is eGptr. Anyway, since we probably + end up flushing when we close(), it doesn't make much difference.) + FIXME: simulate mem-papped files. */ + + if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode(fp)) + if (_IO_switch_to_get_mode(fp)) return EOF; + + if (fp->_IO_buf_base == NULL) + { + _IO_doallocbuf(fp); + _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base); + _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); + } + + switch (dir) + { + case _IO_seek_cur: + /* Adjust for read-ahead (bytes is buffer). */ + offset -= fp->_IO_read_end - fp->_IO_read_ptr; + if (fp->_offset == _IO_pos_BAD) + goto dumb; + /* Make offset absolute, assuming current pointer is file_ptr(). */ + offset += _IO_pos_as_off(fp->_offset); + + dir = _IO_seek_set; + break; + case _IO_seek_set: + break; + case _IO_seek_end: + { + struct stat st; + if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG(st.st_mode)) + { + offset += st.st_size; + dir = _IO_seek_set; + } + else + goto dumb; + } + } + /* At this point, dir==_IO_seek_set. */ + + /* If destination is within current buffer, optimize: */ + if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL + && !_IO_in_backup (fp)) + { + /* Offset relative to start of main get area. */ + _IO_pos_t rel_offset = offset - fp->_offset + + (fp->_IO_read_end - fp->_IO_read_base); + if (rel_offset >= 0) + { +#if 0 + if (_IO_in_backup(fp)) + _IO_switch_to_main_get_area(fp); +#endif + if (rel_offset <= fp->_IO_read_end - fp->_IO_read_base) + { + _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base + rel_offset, + fp->_IO_read_end); + _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base); + return offset; + } +#ifdef TODO + /* If we have streammarkers, seek forward by reading ahead. */ + if (_IO_have_markers(fp)) + { + int to_skip = rel_offset + - (fp->_IO_read_ptr - fp->_IO_read_base); + if (ignore(to_skip) != to_skip) + goto dumb; + return offset; + } +#endif + } +#ifdef TODO + if (rel_offset < 0 && rel_offset >= Bbase() - Bptr()) + { + if (!_IO_in_backup(fp)) + _IO_switch_to_backup_area(fp); + gbump(fp->_IO_read_end + rel_offset - fp->_IO_read_ptr); + return offset; + } +#endif + } + +#ifdef TODO + _IO_unsave_markers(fp); +#endif + + if (fp->_flags & _IO_NO_READS) + goto dumb; + + /* Try to seek to a block boundary, to improve kernel page management. */ + new_offset = offset & ~(fp->_IO_buf_end - fp->_IO_buf_base - 1); + delta = offset - new_offset; + if (delta > fp->_IO_buf_end - fp->_IO_buf_base) + { + new_offset = offset; + delta = 0; + } + result = _IO_SYSSEEK (fp, new_offset, 0); + if (result < 0) + return EOF; + if (delta == 0) + count = 0; + else + { + count = _IO_SYSREAD (fp, fp->_IO_buf_base, + fp->_IO_buf_end - fp->_IO_buf_base); + if (count < delta) + { + /* We weren't allowed to read, but try to seek the remainder. */ + offset = count == EOF ? delta : delta-count; + dir = _IO_seek_cur; + goto dumb; + } + } + _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base+delta, fp->_IO_buf_base+count); + _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base); + fp->_offset = result + count; + _IO_mask_flags(fp, 0, _IO_EOF_SEEN); + return offset; + dumb: + + _IO_unsave_markers(fp); + result = _IO_SYSSEEK (fp, offset, dir); + if (result != EOF) + _IO_mask_flags(fp, 0, _IO_EOF_SEEN); + fp->_offset = result; + _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); + _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base); + return result; +} + +_IO_ssize_t +DEFUN(_IO_file_read, (fp, buf, size), + register _IO_FILE* fp AND void* buf AND _IO_ssize_t size) +{ + for (;;) + { + _IO_ssize_t count = _IO_read(fp->_fileno, buf, size); +#ifdef EINTR + if (count == -1 && errno == EINTR) + continue; +#endif + return count; + } +} + +_IO_pos_t +DEFUN(_IO_file_seek, (fp, offset, dir), + _IO_FILE *fp AND _IO_off_t offset AND int dir) +{ + return _IO_lseek(fp->_fileno, offset, dir); +} + +int +DEFUN(_IO_file_stat, (fp, st), + _IO_FILE *fp AND void* st) +{ + return _IO_fstat(fp->_fileno, (struct stat*)st); +} + +int +DEFUN(_IO_file_close, (fp), + _IO_FILE* fp) +{ + return _IO_close(fp->_fileno); +} + +_IO_ssize_t +DEFUN(_IO_file_write, (f, data, n), + register _IO_FILE* f AND const void* data AND _IO_ssize_t n) +{ + _IO_ssize_t to_do = n; + while (to_do > 0) + { + _IO_ssize_t count = _IO_write(f->_fileno, data, to_do); + if (count == EOF) + { +#ifdef EINTR + if (errno == EINTR) + continue; + else +#endif + { + f->_flags |= _IO_ERR_SEEN; + break; + } + } + to_do -= count; + data = (void*)((char*)data + count); + } + n -= to_do; + if (f->_offset >= 0) + f->_offset += n; + return n; +} + +_IO_size_t +DEFUN(_IO_file_xsputn, (f, data, n), + _IO_FILE *f AND const void *data AND _IO_size_t n) +{ + register const char *s = (char*) data; + _IO_size_t to_do = n; + int must_flush = 0; + _IO_size_t count; + + if (n <= 0) + return 0; + /* This is an optimized implementation. + If the amount to be written straddles a block boundary + (or the filebuf is unbuffered), use sys_write directly. */ + + /* First figure out how much space is available in the buffer. */ + count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ + if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING)) + { + count = f->_IO_buf_end - f->_IO_write_ptr; + if (count >= n) + { register const char *p; + for (p = s + n; p > s; ) + { + if (*--p == '\n') { + count = p - s + 1; + must_flush = 1; + break; + } + } + } + } + /* Then fill the buffer. */ + if (count > 0) + { + if (count > to_do) + count = to_do; + if (count > 20) { + memcpy(f->_IO_write_ptr, s, count); + s += count; + } + else + { + register char *p = f->_IO_write_ptr; + register int i = (int)count; + while (--i >= 0) *p++ = *s++; + } + f->_IO_write_ptr += count; + to_do -= count; + } + if (to_do + must_flush > 0) + { _IO_size_t block_size, dont_write; + /* Next flush the (full) buffer. */ + if (__overflow(f, EOF) == EOF) + return n - to_do; + + /* Try to maintain alignment: write a whole number of blocks. + dont_write is what gets left over. */ + block_size = f->_IO_buf_end - f->_IO_buf_base; + dont_write = block_size >= 128 ? to_do % block_size : 0; + + count = to_do - dont_write; + if (_IO_do_write(f, s, count) == EOF) + return n - to_do; + to_do = dont_write; + + /* Now write out the remainder. Normally, this will fit in the + buffer, but it's somewhat messier for line-buffered files, + so we let _IO_default_xsputn handle the general case. */ + if (dont_write) + to_do -= _IO_default_xsputn(f, s+count, dont_write); + } + return n - to_do; +} + +#if 0 +/* Work in progress */ +_IO_size_t +DEFUN(_IO_file_xsgetn, (fp, data, n), + _IO_FILE *fp AND void *data AND _IO_size_t n) +{ + register _IO_size_t more = n; + register char *s = data; + for (;;) + { + _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */ + if (count > 0) + { + if (count > more) + count = more; + if (count > 20) + { + memcpy(s, fp->_IO_read_ptr, count); + s += count; + fp->_IO_read_ptr += count; + } + else if (count <= 0) + count = 0; + else + { + register char *p = fp->_IO_read_ptr; + register int i = (int)count; + while (--i >= 0) *s++ = *p++; + fp->_IO_read_ptr = p; + } + more -= count; + } +#if 0 + if (! _IO_in put_mode (fp) + && ! _IO_have_markers (fp) && ! IO_have_backup (fp)) + { + /* This is an optimization of _IO_file_underflow */ + if (fp->_flags & _IO_NO_READS) + break; + /* If we're reading a lot of data, don't bother allocating + a buffer. But if we're only reading a bit, perhaps we should ??*/ + if (count <= 512 && fp->_IO_buf_base == NULL) + _IO_doallocbuf(fp); + if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED)) + _IO_flush_all_linebuffered(); + + _IO_switch_to_get_mode(fp); ???; + count = _IO_SYSREAD (fp, s, more); + if (count <= 0) + { + if (count == 0) + fp->_flags |= _IO_EOF_SEEN; + else + fp->_flags |= _IO_ERR_SEEN, count = 0; + } + + s += count; + more -= count; + } +#endif + if (more == 0 || __underflow(fp) == EOF) + break; + } + return n - more; +} +#endif + +struct _IO_jump_t _IO_file_jumps = { + JUMP_INIT_DUMMY, + JUMP_INIT(finish, _IO_file_finish), + JUMP_INIT(overflow, _IO_file_overflow), + JUMP_INIT(underflow, _IO_file_underflow), + JUMP_INIT(uflow, _IO_default_uflow), + JUMP_INIT(pbackfail, _IO_default_pbackfail), + JUMP_INIT(xsputn, _IO_file_xsputn), + JUMP_INIT(xsgetn, _IO_default_xsgetn), + JUMP_INIT(seekoff, _IO_file_seekoff), + JUMP_INIT(seekpos, _IO_default_seekpos), + JUMP_INIT(setbuf, _IO_file_setbuf), + JUMP_INIT(sync, _IO_file_sync), + JUMP_INIT(doallocate, _IO_file_doallocate), + JUMP_INIT(read, _IO_file_read), + JUMP_INIT(write, _IO_file_write), + JUMP_INIT(seek, _IO_file_seek), + JUMP_INIT(close, _IO_file_close), + JUMP_INIT(stat, _IO_file_stat) +}; diff --git a/libio/floatconv.c b/libio/floatconv.c new file mode 100644 index 000000000000..9503187b5d57 --- /dev/null +++ b/libio/floatconv.c @@ -0,0 +1,2375 @@ +/* +Copyright (C) 1993, 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include +#ifdef _IO_USE_DTOA +/**************************************************************** + * + * The author of this software is David M. Gay. + * + * Copyright (c) 1991 by AT&T. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + * + ***************************************************************/ + +/* Some cleaning up by Per Bothner, bothner@cygnus.com, 1992, 1993. + Re-written to not need static variables + (except result, result_k, HIWORD, LOWORD). */ + +/* Note that the checking of _DOUBLE_IS_32BITS is for use with the + cross targets that employ the newlib ieeefp.h header. -- brendan */ + +/* Please send bug reports to + David M. Gay + AT&T Bell Laboratories, Room 2C-463 + 600 Mountain Avenue + Murray Hill, NJ 07974-2070 + U.S.A. + dmg@research.att.com or research!dmg + */ + +/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. + * + * This strtod returns a nearest machine number to the input decimal + * string (or sets errno to ERANGE). With IEEE arithmetic, ties are + * broken by the IEEE round-even rule. Otherwise ties are broken by + * biased rounding (add half and chop). + * + * Inspired loosely by William D. Clinger's paper "How to Read Floating + * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * + * 1. We only require IEEE, IBM, or VAX double-precision + * arithmetic (not IEEE double-extended). + * 2. We get by with floating-point arithmetic in a case that + * Clinger missed -- when we're computing d * 10^n + * for a small integer d and the integer n is not too + * much larger than 22 (the maximum integer k for which + * we can represent 10^k exactly), we may be able to + * compute (d*10^k) * 10^(e-k) with just one roundoff. + * 3. Rather than a bit-at-a-time adjustment of the binary + * result in the hard case, we use floating-point + * arithmetic to determine the adjustment to within + * one bit; only in really hard cases do we need to + * compute a second residual. + * 4. Because of 3., we don't need a large table of powers of 10 + * for ten-to-e (just some small tables, e.g. of 10^k + * for 0 <= k <= 22). + */ + +/* + * #define IEEE_8087 for IEEE-arithmetic machines where the least + * significant byte has the lowest address. + * #define IEEE_MC68k for IEEE-arithmetic machines where the most + * significant byte has the lowest address. + * #define Sudden_Underflow for IEEE-format machines without gradual + * underflow (i.e., that flush to zero on underflow). + * #define IBM for IBM mainframe-style floating-point arithmetic. + * #define VAX for VAX-style floating-point arithmetic. + * #define Unsigned_Shifts if >> does treats its left operand as unsigned. + * #define No_leftright to omit left-right logic in fast floating-point + * computation of dtoa. + * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. + * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines + * that use extended-precision instructions to compute rounded + * products and quotients) with IBM. + * #define ROUND_BIASED for IEEE-format with biased rounding. + * #define Inaccurate_Divide for IEEE-format with correctly rounded + * products but inaccurate quotients, e.g., for Intel i860. + * #define KR_headers for old-style C function headers. + */ + +#ifdef DEBUG +#include +#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} +#endif + +#ifdef __STDC__ +#include +#include +#include +#define CONST const +#else +#define CONST +#define KR_headers + +/* In this case, we assume IEEE floats. */ +#define FLT_ROUNDS 1 +#define FLT_RADIX 2 +#define DBL_MANT_DIG 53 +#define DBL_DIG 15 +#define DBL_MAX_10_EXP 308 +#define DBL_MAX_EXP 1024 +#endif + +#include +#ifndef __MATH_H__ +#include +#endif + +#ifdef Unsigned_Shifts +#define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000; +#else +#define Sign_Extend(a,b) /*no-op*/ +#endif + +#if defined(__i386__) || defined(__i860__) || defined(clipper) +#define IEEE_8087 +#endif +#if defined(MIPSEL) || defined(__alpha__) +#define IEEE_8087 +#endif +#if defined(__sparc__) || defined(sparc) || defined(MIPSEB) +#define IEEE_MC68k +#endif + +#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 + +#ifndef _DOUBLE_IS_32BITS +#if FLT_RADIX==16 +#define IBM +#else +#if DBL_MANT_DIG==56 +#define VAX +#else +#if DBL_MANT_DIG==53 && DBL_MAX_10_EXP==308 +#define IEEE_Unknown +#else +Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. +#endif +#endif +#endif +#endif /* !_DOUBLE_IS_32BITS */ +#endif + +typedef _G_uint32_t unsigned32; + +union doubleword { + double d; + unsigned32 u[2]; +}; + +#ifdef IEEE_8087 +#define HIWORD 1 +#define LOWORD 0 +#define TEST_ENDIANNESS /* nothing */ +#else +#if defined(IEEE_MC68k) +#define HIWORD 0 +#define LOWORD 1 +#define TEST_ENDIANNESS /* nothing */ +#else +static int HIWORD = -1, LOWORD; +static void test_endianness() +{ + union doubleword dw; + dw.d = 10; + if (dw.u[0] != 0) /* big-endian */ + HIWORD=0, LOWORD=1; + else + HIWORD=1, LOWORD=0; +} +#define TEST_ENDIANNESS if (HIWORD<0) test_endianness(); +#endif +#endif + +#if 0 +union doubleword _temp; +#endif +#if defined(__GNUC__) && !defined(_DOUBLE_IS_32BITS) +#define word0(x) ({ union doubleword _du; _du.d = (x); _du.u[HIWORD]; }) +#define word1(x) ({ union doubleword _du; _du.d = (x); _du.u[LOWORD]; }) +#define setword0(D,W) \ + ({ union doubleword _du; _du.d = (D); _du.u[HIWORD]=(W); (D)=_du.d; }) +#define setword1(D,W) \ + ({ union doubleword _du; _du.d = (D); _du.u[LOWORD]=(W); (D)=_du.d; }) +#define setwords(D,W0,W1) ({ union doubleword _du; \ + _du.u[HIWORD]=(W0); _du.u[LOWORD]=(W1); (D)=_du.d; }) +#define addword0(D,W) \ + ({ union doubleword _du; _du.d = (D); _du.u[HIWORD]+=(W); (D)=_du.d; }) +#else +#define word0(x) ((unsigned32 *)&x)[HIWORD] +#ifndef _DOUBLE_IS_32BITS +#define word1(x) ((unsigned32 *)&x)[LOWORD] +#else +#define word1(x) 0 +#endif +#define setword0(D,W) word0(D) = (W) +#ifndef _DOUBLE_IS_32BITS +#define setword1(D,W) word1(D) = (W) +#define setwords(D,W0,W1) (setword0(D,W0),setword1(D,W1)) +#else +#define setword1(D,W) +#define setwords(D,W0,W1) (setword0(D,W0)) +#endif +#define addword0(D,X) (word0(D) += (X)) +#endif + +/* The following definition of Storeinc is appropriate for MIPS processors. */ +#if defined(IEEE_8087) + defined(VAX) +#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ +((unsigned short *)a)[0] = (unsigned short)c, a++) +#else +#if defined(IEEE_MC68k) +#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ +((unsigned short *)a)[1] = (unsigned short)c, a++) +#else +#define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) +#endif +#endif + +/* #define P DBL_MANT_DIG */ +/* Ten_pmax = floor(P*log(2)/log(5)) */ +/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ +/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ +/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ + +#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_Unknown) +#define Exp_shift 20 +#define Exp_shift1 20 +#define Exp_msk1 0x100000 +#define Exp_msk11 0x100000 +#define Exp_mask 0x7ff00000 +#define P 53 +#define Bias 1023 +#define IEEE_Arith +#define Emin (-1022) +#define Exp_1 0x3ff00000 +#define Exp_11 0x3ff00000 +#define Ebits 11 +#define Frac_mask 0xfffff +#define Frac_mask1 0xfffff +#define Ten_pmax 22 +#define Bletch 0x10 +#define Bndry_mask 0xfffff +#define Bndry_mask1 0xfffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 1 +#define Tiny0 0 +#define Tiny1 1 +#define Quick_max 14 +#define Int_max 14 +#define Infinite(x) (word0(x) == 0x7ff00000) /* sufficient test for here */ +#else +#undef Sudden_Underflow +#define Sudden_Underflow +#ifdef IBM +#define Exp_shift 24 +#define Exp_shift1 24 +#define Exp_msk1 0x1000000 +#define Exp_msk11 0x1000000 +#define Exp_mask 0x7f000000 +#define P 14 +#define Bias 65 +#define Exp_1 0x41000000 +#define Exp_11 0x41000000 +#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ +#define Frac_mask 0xffffff +#define Frac_mask1 0xffffff +#define Bletch 4 +#define Ten_pmax 22 +#define Bndry_mask 0xefffff +#define Bndry_mask1 0xffffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 4 +#define Tiny0 0x100000 +#define Tiny1 0 +#define Quick_max 14 +#define Int_max 15 +#else /* VAX */ +#define Exp_shift 23 +#define Exp_shift1 7 +#define Exp_msk1 0x80 +#define Exp_msk11 0x800000 +#define Exp_mask 0x7f80 +#define P 56 +#define Bias 129 +#define Exp_1 0x40800000 +#define Exp_11 0x4080 +#define Ebits 8 +#define Frac_mask 0x7fffff +#define Frac_mask1 0xffff007f +#define Ten_pmax 24 +#define Bletch 2 +#define Bndry_mask 0xffff007f +#define Bndry_mask1 0xffff007f +#define LSB 0x10000 +#define Sign_bit 0x8000 +#define Log2P 1 +#define Tiny0 0x80 +#define Tiny1 0 +#define Quick_max 15 +#define Int_max 15 +#endif +#endif + +#ifndef IEEE_Arith +#define ROUND_BIASED +#endif + +#ifdef RND_PRODQUOT +#define rounded_product(a,b) a = rnd_prod(a, b) +#define rounded_quotient(a,b) a = rnd_quot(a, b) +extern double rnd_prod(double, double), rnd_quot(double, double); +#else +#define rounded_product(a,b) a *= b +#define rounded_quotient(a,b) a /= b +#endif + +#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) +#define Big1 0xffffffff + +#define Kmax 15 + +/* (1<on_stack = 1; + v->k = BIGINT_MINIMUM_K; + v->maxwds = 1 << BIGINT_MINIMUM_K; + v->sign = v->wds = 0; + return v; +} + +/* Allocate a Bigint with '1<k = k; + rv->maxwds = x; + rv->sign = rv->wds = 0; + rv->on_stack = 0; + return rv; +} + +static void +Bfree +#ifdef KR_headers + (v) Bigint *v; +#else + (Bigint *v) +#endif +{ + if (v && !v->on_stack) + free (v); +} + +static void +Bcopy +#ifdef KR_headers + (x, y) Bigint *x, *y; +#else + (Bigint *x, Bigint *y) +#endif +{ + register unsigned32 *xp, *yp; + register int i = y->wds; + x->sign = y->sign; + x->wds = i; + for (xp = x->x, yp = y->x; --i >= 0; ) + *xp++ = *yp++; +} + +/* Make sure b has room for at least 1<k >= k) + return b; + else + { + Bigint *rv = Balloc (k); + Bcopy(rv, b); + Bfree(b); + return rv; + } +} + +/* Return b*m+a. b is modified. + Assumption: 0xFFFF*m+a fits in 32 bits. */ + +static Bigint * +multadd +#ifdef KR_headers + (b, m, a) Bigint *b; int m, a; +#else + (Bigint *b, int m, int a) +#endif +{ + int i, wds; + unsigned32 *x, y; + unsigned32 xi, z; + + wds = b->wds; + x = b->x; + i = 0; + do { + xi = *x; + y = (xi & 0xffff) * m + a; + z = (xi >> 16) * m + (y >> 16); + a = (int)(z >> 16); + *x++ = (z << 16) + (y & 0xffff); + } + while(++i < wds); + if (a) { + if (wds >= b->maxwds) + b = Brealloc(b, b->k+1); + b->x[wds++] = a; + b->wds = wds; + } + return b; + } + +static Bigint * +s2b +#ifdef KR_headers + (result, s, nd0, nd, y9) + Bigint *result; CONST char *s; int nd0, nd; unsigned32 y9; +#else + (Bigint *result, CONST char *s, int nd0, int nd, unsigned32 y9) +#endif +{ + int i, k; + _G_int32_t x, y; + + x = (nd + 8) / 9; + for(k = 0, y = 1; x > y; y <<= 1, k++) ; + result = Brealloc(result, k); + result->x[0] = y9; + result->wds = 1; + + i = 9; + if (9 < nd0) + { + s += 9; + do + result = multadd(result, 10, *s++ - '0'); + while (++i < nd0); + s++; + } + else + s += 10; + for(; i < nd; i++) + result = multadd(result, 10, *s++ - '0'); + return result; +} + +static int +hi0bits +#ifdef KR_headers + (x) register unsigned32 x; +#else + (register unsigned32 x) +#endif +{ + register int k = 0; + + if (!(x & 0xffff0000)) { + k = 16; + x <<= 16; + } + if (!(x & 0xff000000)) { + k += 8; + x <<= 8; + } + if (!(x & 0xf0000000)) { + k += 4; + x <<= 4; + } + if (!(x & 0xc0000000)) { + k += 2; + x <<= 2; + } + if (!(x & 0x80000000)) { + k++; + if (!(x & 0x40000000)) + return 32; + } + return k; + } + +static int +lo0bits +#ifdef KR_headers + (y) unsigned32 *y; +#else + (unsigned32 *y) +#endif +{ + register int k; + register unsigned32 x = *y; + + if (x & 7) { + if (x & 1) + return 0; + if (x & 2) { + *y = x >> 1; + return 1; + } + *y = x >> 2; + return 2; + } + k = 0; + if (!(x & 0xffff)) { + k = 16; + x >>= 16; + } + if (!(x & 0xff)) { + k += 8; + x >>= 8; + } + if (!(x & 0xf)) { + k += 4; + x >>= 4; + } + if (!(x & 0x3)) { + k += 2; + x >>= 2; + } + if (!(x & 1)) { + k++; + x >>= 1; + if (!x & 1) + return 32; + } + *y = x; + return k; + } + +static Bigint * +i2b +#ifdef KR_headers + (result, i) Bigint *result; int i; +#else + (Bigint* result, int i) +#endif +{ + result = Brealloc(result, 1); + result->x[0] = i; + result->wds = 1; + return result; +} + +/* Do: c = a * b. */ + +static Bigint * +mult +#ifdef KR_headers + (c, a, b) Bigint *a, *b, *c; +#else + (Bigint *c, Bigint *a, Bigint *b) +#endif +{ + int k, wa, wb, wc; + unsigned32 carry, y, z; + unsigned32 *x, *xa, *xae, *xb, *xbe, *xc, *xc0; + unsigned32 z2; + if (a->wds < b->wds) { + Bigint *tmp = a; + a = b; + b = tmp; + } + k = a->k; + wa = a->wds; + wb = b->wds; + wc = wa + wb; + if (wc > a->maxwds) + k++; + c = Brealloc(c, k); + for(x = c->x, xa = x + wc; x < xa; x++) + *x = 0; + xa = a->x; + xae = xa + wa; + xb = b->x; + xbe = xb + wb; + xc0 = c->x; + for(; xb < xbe; xb++, xc0++) { + if ((y = *xb & 0xffff)) { + x = xa; + xc = xc0; + carry = 0; + do { + z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; + carry = z >> 16; + z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; + carry = z2 >> 16; + Storeinc(xc, z2, z); + } + while(x < xae); + *xc = carry; + } + if ((y = *xb >> 16)) { + x = xa; + xc = xc0; + carry = 0; + z2 = *xc; + do { + z = (*x & 0xffff) * y + (*xc >> 16) + carry; + carry = z >> 16; + Storeinc(xc, z, z2); + z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; + carry = z2 >> 16; + } + while(x < xae); + *xc = z2; + } + } + for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; + c->wds = wc; + return c; + } + +/* Returns b*(5**k). b is modified. */ +/* Re-written by Per Bothner to not need a static list. */ + +static Bigint * +pow5mult +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + static int p05[6] = { 5, 25, 125, 625, 3125, 15625 }; + + for (; k > 6; k -= 6) + b = multadd(b, 15625, 0); /* b *= 5**6 */ + if (k == 0) + return b; + else + return multadd(b, p05[k-1], 0); +} + +/* Re-written by Per Bothner so shift can be in place. */ + +static Bigint * +lshift +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + int i; + unsigned32 *x, *x1, *xe; + int old_wds = b->wds; + int n = k >> 5; + int k1 = b->k; + int n1 = n + old_wds + 1; + + if (k == 0) + return b; + + for(i = b->maxwds; n1 > i; i <<= 1) + k1++; + b = Brealloc(b, k1); + + xe = b->x; /* Source limit */ + x = xe + old_wds; /* Source pointer */ + x1 = x + n; /* Destination pointer */ + if (k &= 0x1f) { + int k1 = 32 - k; + unsigned32 z = *--x; + if ((*x1 = (z >> k1)) != 0) { + ++n1; + } + while (x > xe) { + unsigned32 w = *--x; + *--x1 = (z << k) | (w >> k1); + z = w; + } + *--x1 = z << k; + } + else + do { + *--x1 = *--x; + } while(x > xe); + while (x1 > xe) + *--x1 = 0; + b->wds = n1 - 1; + return b; +} + +static int +cmp +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + unsigned32 *xa, *xa0, *xb, *xb0; + int i, j; + + i = a->wds; + j = b->wds; +#ifdef DEBUG + if (i > 1 && !a->x[i-1]) + Bug("cmp called with a->x[a->wds-1] == 0"); + if (j > 1 && !b->x[j-1]) + Bug("cmp called with b->x[b->wds-1] == 0"); +#endif + if (i -= j) + return i; + xa0 = a->x; + xa = xa0 + j; + xb0 = b->x; + xb = xb0 + j; + for(;;) { + if (*--xa != *--xb) + return *xa < *xb ? -1 : 1; + if (xa <= xa0) + break; + } + return 0; + } + +/* Do: c = a-b. */ + +static Bigint * +diff +#ifdef KR_headers + (c, a, b) Bigint *c, *a, *b; +#else + (Bigint *c, Bigint *a, Bigint *b) +#endif +{ + int i, wa, wb; + _G_int32_t borrow, y; /* We need signed shifts here. */ + unsigned32 *xa, *xae, *xb, *xbe, *xc; + _G_int32_t z; + + i = cmp(a,b); + if (!i) { + c = Brealloc(c, 0); + c->wds = 1; + c->x[0] = 0; + return c; + } + if (i < 0) { + Bigint *tmp = a; + a = b; + b = tmp; + i = 1; + } + else + i = 0; + c = Brealloc(c, a->k); + c->sign = i; + wa = a->wds; + xa = a->x; + xae = xa + wa; + wb = b->wds; + xb = b->x; + xbe = xb + wb; + xc = c->x; + borrow = 0; + do { + y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(xc, z, y); + } + while(xb < xbe); + while(xa < xae) { + y = (*xa & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*xa++ >> 16) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(xc, z, y); + } + while(!*--xc) + wa--; + c->wds = wa; + return c; + } + +static double +ulp +#ifdef KR_headers + (x) double x; +#else + (double x) +#endif +{ + register _G_int32_t L; + double a; + + L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; +#ifndef Sudden_Underflow + if (L > 0) { +#endif +#ifdef IBM + L |= Exp_msk1 >> 4; +#endif + setwords(a, L, 0); +#ifndef Sudden_Underflow + } + else { + L = -L >> Exp_shift; + if (L < Exp_shift) + setwords(a, 0x80000 >> L, 0); + else { + L -= Exp_shift; + setwords(a, 0, L >= 31 ? 1 : 1 << (31 - L)); + } + } +#endif + return a; + } + +static double +b2d +#ifdef KR_headers + (a, e) Bigint *a; int *e; +#else + (Bigint *a, int *e) +#endif +{ + unsigned32 *xa, *xa0, w, y, z; + int k; + double d; + unsigned32 d0, d1; + + xa0 = a->x; + xa = xa0 + a->wds; + y = *--xa; +#ifdef DEBUG + if (!y) Bug("zero y in b2d"); +#endif + k = hi0bits(y); + *e = 32 - k; + if (k < Ebits) { + d0 = Exp_1 | y >> (Ebits - k); + w = xa > xa0 ? *--xa : 0; +#ifndef _DOUBLE_IS_32BITS + d1 = y << ((32-Ebits) + k) | w >> (Ebits - k); +#endif + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + d0 = Exp_1 | y << k | z >> (32 - k); + y = xa > xa0 ? *--xa : 0; +#ifndef _DOUBLE_IS_32BITS + d1 = z << k | y >> (32 - k); +#endif + } + else { + d0 = Exp_1 | y; +#ifndef _DOUBLE_IS_32BITS + d1 = z; +#endif + } + ret_d: +#ifdef VAX + setwords(d, d0 >> 16 | d0 << 16, d1 >> 16 | d1 << 16); +#else + setwords (d, d0, d1); +#endif + return d; + } + +static Bigint * +d2b +#ifdef KR_headers + (result, d, e, bits) Bigint *result; double d; _G_int32_t *e, *bits; +#else + (Bigint *result, double d, _G_int32_t *e, _G_int32_t *bits) +#endif +{ + int de, i, k; + unsigned32 *x, y, z; + unsigned32 d0, d1; +#ifdef VAX + d0 = word0(d) >> 16 | word0(d) << 16; + d1 = word1(d) >> 16 | word1(d) << 16; +#else + d0 = word0(d); + d1 = word1(d); +#endif + + result = Brealloc(result, 1); + x = result->x; + + z = d0 & Frac_mask; + d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ + + de = (int)(d0 >> Exp_shift); /* The exponent part of d. */ + + /* Put back the suppressed high-order bit, if normalized. */ +#ifndef IBM +#ifndef Sudden_Underflow + if (de) +#endif + z |= Exp_msk11; +#endif + +#ifndef _DOUBLE_IS_32BITS + if ((y = d1)) { + if ((k = lo0bits(&y))) { + x[0] = y | z << (32 - k); + z >>= k; + } + else + x[0] = y; + i = result->wds = (x[1] = z) ? 2 : 1; + } + else { +#endif /* !_DOUBLE_IS_32BITS */ +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + x[0] = z; + i = result->wds = 1; +#ifndef _DOUBLE_IS_32BITS + k += 32; + } +#endif +#ifndef Sudden_Underflow + if (de) { +#endif +#ifdef IBM + *e = (de - Bias - (P-1) << 2) + k; + *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask); +#else + *e = de - Bias - (P-1) + k; + *bits = P - k; +#endif +#ifndef Sudden_Underflow + } + else { + *e = de - Bias - (P-1) + 1 + k; + *bits = 32*i - hi0bits(x[i-1]); + } +#endif + return result; + } + +static double +ratio +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + double da, db; + int k, ka, kb; + + da = b2d(a, &ka); + db = b2d(b, &kb); + k = ka - kb + 32*(a->wds - b->wds); +#ifdef IBM + if (k > 0) { + addword0(da, (k >> 2)*Exp_msk1); + if (k &= 3) + da *= 1 << k; + } + else { + k = -k; + addword0(db,(k >> 2)*Exp_msk1); + if (k &= 3) + db *= 1 << k; + } +#else + if (k > 0) + addword0(da, k*Exp_msk1); + else { + k = -k; + addword0(db, k*Exp_msk1); + } +#endif + return da / db; + } + +static CONST double +tens[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22 +#ifdef VAX + , 1e23, 1e24 +#endif + }; + +#ifdef IEEE_Arith +static CONST double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; +static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 }; +#define n_bigtens 5 +#else +#ifdef IBM +static CONST double bigtens[] = { 1e16, 1e32, 1e64 }; +static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 }; +#define n_bigtens 3 +#else +/* Also used for the case when !_DOUBLE_IS_32BITS. */ +static CONST double bigtens[] = { 1e16, 1e32 }; +static CONST double tinytens[] = { 1e-16, 1e-32 }; +#define n_bigtens 2 +#endif +#endif + + double +_IO_strtod +#ifdef KR_headers + (s00, se) CONST char *s00; char **se; +#else + (CONST char *s00, char **se) +#endif +{ + _G_int32_t bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, + e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; + CONST char *s, *s0, *s1; + double aadj, aadj1, adj, rv, rv0; + _G_int32_t L; + unsigned32 y, z; + Bigint _bb, _b_avail, _bd, _bd0, _bs, _delta; + Bigint *bb = Binit(&_bb); + Bigint *bd = Binit(&_bd); + Bigint *bd0 = Binit(&_bd0); + Bigint *bs = Binit(&_bs); + Bigint *b_avail = Binit(&_b_avail); + Bigint *delta = Binit(&_delta); + + TEST_ENDIANNESS; + sign = nz0 = nz = 0; + rv = 0.; + (void)&rv; /* Force rv into the stack */ + for(s = s00;;s++) switch(*s) { + case '-': + sign = 1; + /* no break */ + case '+': + if (*++s) + goto break2; + /* no break */ + case 0: + /* "+" and "-" should be reported as an error? */ + sign = 0; + s = s00; + goto ret; + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case ' ': + continue; + default: + goto break2; + } + break2: + if (*s == '0') { + nz0 = 1; + while(*++s == '0') ; + if (!*s) + goto ret; + } + s0 = s; + y = z = 0; + for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < 16) + z = 10*z + c - '0'; + nd0 = nd; + if (c == '.') { + c = *++s; + if (!nd) { + for(; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for(; c >= '0' && c <= '9'; c = *++s) { + have_dig: + nz++; + if (c -= '0') { + nf += nz; + for(i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 1) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 1) + z = 10*z + c; + nz = 0; + } + } + } + dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + s = s00; + goto ret; + } + s00 = s; + esign = 0; + switch(c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while(c == '0') + c = *++s; + if (c > '0' && c <= '9') { + e = c - '0'; + s1 = s; + while((c = *++s) >= '0' && c <= '9') + e = 10*e + c - '0'; + if (s - s1 > 8) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 9999999; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) + s = s00; + goto ret; + } + e1 = e -= nf; + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; + rv = y; + if (k > 9) + rv = tens[k - 9] * rv + z; + if (nd <= DBL_DIG +#ifndef RND_PRODQUOT + && FLT_ROUNDS == 1 +#endif + ) { + if (!e) + goto ret; + if (e > 0) { + if (e <= Ten_pmax) { +#ifdef VAX + goto vax_ovfl_check; +#else + /* rv = */ rounded_product(rv, tens[e]); + goto ret; +#endif + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ + e -= i; + rv *= tens[i]; +#ifdef VAX + /* VAX exponent range is so narrow we must + * worry about overflow here... + */ + vax_ovfl_check: + addword0(rv, - P*Exp_msk1); + /* rv = */ rounded_product(rv, tens[e]); + if ((word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) + goto ovfl; + addword0(rv, P*Exp_msk1); +#else + /* rv = */ rounded_product(rv, tens[e]); +#endif + goto ret; + } + } +#ifndef Inaccurate_Divide + else if (e >= -Ten_pmax) { + /* rv = */ rounded_quotient(rv, tens[-e]); + goto ret; + } +#endif + } + e1 += nd - k; + + /* Get starting approximation = rv * 10**e1 */ + + if (e1 > 0) { + if ((i = e1 & 15)) + rv *= tens[i]; + if (e1 &= ~15) { + if (e1 > DBL_MAX_10_EXP) { + ovfl: + errno = ERANGE; +#if defined(sun) && !defined(__svr4__) +/* SunOS defines HUGE_VAL as __infinity(), which is in libm. */ +#undef HUGE_VAL +#endif +#ifndef HUGE_VAL +#define HUGE_VAL 1.7976931348623157E+308 +#endif + rv = HUGE_VAL; + goto ret; + } + if (e1 >>= 4) { + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + rv *= bigtens[j]; + /* The last multiplication could overflow. */ + addword0(rv, -P*Exp_msk1); + rv *= bigtens[j]; + if ((z = word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-P)) + goto ovfl; + if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { + /* set to largest number */ + /* (Can't trust DBL_MAX) */ + setwords(rv, Big0, Big1); + } + else + addword0(rv, P*Exp_msk1); + } + + } + } + else if (e1 < 0) { + e1 = -e1; + if ((i = e1 & 15)) + rv /= tens[i]; + if (e1 &= ~15) { + e1 >>= 4; + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + rv *= tinytens[j]; + /* The last multiplication could underflow. */ + rv0 = rv; + rv *= tinytens[j]; + if (!rv) { + rv = 2.*rv0; + rv *= tinytens[j]; + if (!rv) { + undfl: + rv = 0.; + errno = ERANGE; + goto ret; + } + setwords(rv, Tiny0, Tiny1); + /* The refinement below will clean + * this approximation up. + */ + } + } + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bd0 = s2b(bd0, s0, nd0, nd, y); + bd = Brealloc(bd, bd0->k); + + for(;;) { + Bcopy(bd, bd0); + bb = d2b(bb, rv, &bbe, &bbbits); /* rv = bb * 2^bbe */ + bs = i2b(bs, 1); + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; +#ifdef Sudden_Underflow +#ifdef IBM + j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); +#else + j = P + 1 - bbbits; +#endif +#else + i = bbe + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j = bbe + (P-Emin); + else + j = P + 1 - bbbits; +#endif + bb2 += j; + bd2 += j; + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + Bigint *b_tmp; + bs = pow5mult(bs, bb5); + b_tmp = mult(b_avail, bs, bb); + b_avail = bb; + bb = b_tmp; + } + if (bb2 > 0) + bb = lshift(bb, bb2); + if (bd5 > 0) + bd = pow5mult(bd, bd5); + if (bd2 > 0) + bd = lshift(bd, bd2); + if (bs2 > 0) + bs = lshift(bs, bs2); + delta = diff(delta, bb, bd); + dsign = delta->sign; + delta->sign = 0; + i = cmp(delta, bs); + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask) + break; + delta = lshift(delta,Log2P); + if (cmp(delta, bs) > 0) + goto drop_down; + break; + } + if (i == 0) { + /* exactly half-way between */ + if (dsign) { + if ((word0(rv) & Bndry_mask1) == Bndry_mask1 + && word1(rv) == 0xffffffff) { + /*boundary case -- increment exponent*/ + setword0(rv, (word0(rv) & Exp_mask) + + Exp_msk1); +#ifdef IBM + setword0 (rv, + word0(rv) | (Exp_msk1 >> 4)); +#endif + setword1(rv, 0); + break; + } + } + else if (!(word0(rv) & Bndry_mask) && !word1(rv)) { + drop_down: + /* boundary case -- decrement exponent */ +#ifdef Sudden_Underflow + L = word0(rv) & Exp_mask; +#ifdef IBM + if (L < Exp_msk1) +#else + if (L <= Exp_msk1) +#endif + goto undfl; + L -= Exp_msk1; +#else + L = (word0(rv) & Exp_mask) - Exp_msk1; +#endif + setwords(rv, L | Bndry_mask1, 0xffffffff); +#ifdef IBM + continue; +#else + break; +#endif + } +#ifndef ROUND_BIASED + if (!(word1(rv) & LSB)) + break; +#endif + if (dsign) + rv += ulp(rv); +#ifndef ROUND_BIASED + else { + rv -= ulp(rv); +#ifndef Sudden_Underflow + if (!rv) + goto undfl; +#endif + } +#endif + break; + } + if ((aadj = ratio(delta, bs)) <= 2.) { + if (dsign) + aadj = aadj1 = 1.; + else if (word1(rv) || word0(rv) & Bndry_mask) { +#ifndef Sudden_Underflow + if (word1(rv) == Tiny1 && !word0(rv)) + goto undfl; +#endif + aadj = 1.; + aadj1 = -1.; + } + else { + /* special case -- power of FLT_RADIX to be */ + /* rounded down... */ + + if (aadj < 2./FLT_RADIX) + aadj = 1./FLT_RADIX; + else + aadj *= 0.5; + aadj1 = -aadj; + } + } + else { + aadj *= 0.5; + aadj1 = dsign ? aadj : -aadj; +#ifdef Check_FLT_ROUNDS + switch(FLT_ROUNDS) { + case 2: /* towards +infinity */ + aadj1 -= 0.5; + break; + case 0: /* towards 0 */ + case 3: /* towards -infinity */ + aadj1 += 0.5; + } +#else + if (FLT_ROUNDS == 0) + aadj1 += 0.5; +#endif + } + y = word0(rv) & Exp_mask; + + /* Check for overflow */ + + if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { + rv0 = rv; + addword0(rv, - P*Exp_msk1); + adj = aadj1 * ulp(rv); + rv += adj; + if ((word0(rv) & Exp_mask) >= + Exp_msk1*(DBL_MAX_EXP+Bias-P)) { + if (word0(rv0) == Big0 && word1(rv0) == Big1) + goto ovfl; + setwords(rv, Big0, Big1); + continue; + } + else + addword0(rv, P*Exp_msk1); + } + else { +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { + rv0 = rv; + addword0(rv, P*Exp_msk1); + adj = aadj1 * ulp(rv); + rv += adj; +#ifdef IBM + if ((word0(rv) & Exp_mask) < P*Exp_msk1) +#else + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) +#endif + { + if (word0(rv0) == Tiny0 + && word1(rv0) == Tiny1) + goto undfl; + setwords(rv, Tiny0, Tiny1); + continue; + } + else + addword0(rv, -P*Exp_msk1); + } + else { + adj = aadj1 * ulp(rv); + rv += adj; + } +#else + /* Compute adj so that the IEEE rounding rules will + * correctly round rv + adj in some half-way cases. + * If rv * ulp(rv) is denormalized (i.e., + * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid + * trouble from bits lost to denormalization; + * example: 1.2e-307 . + */ + if (y <= (P-1)*Exp_msk1 && aadj >= 1.) { + aadj1 = (double)(int)(aadj + 0.5); + if (!dsign) + aadj1 = -aadj1; + } + adj = aadj1 * ulp(rv); + rv += adj; +#endif + } + z = word0(rv) & Exp_mask; + if (y == z) { + /* Can we stop now? */ + L = (_G_int32_t)aadj; + aadj -= L; + /* The tolerances below are conservative. */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask) { + if (aadj < .4999999 || aadj > .5000001) + break; + } + else if (aadj < .4999999/FLT_RADIX) + break; + } + } + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); + Bfree(b_avail); + ret: + if (se) + *se = (char *)s; + return sign ? -rv : rv; + } + +static int +quorem +#ifdef KR_headers + (b, S) Bigint *b, *S; +#else + (Bigint *b, Bigint *S) +#endif +{ + int n; + _G_int32_t borrow, y; + unsigned32 carry, q, ys; + unsigned32 *bx, *bxe, *sx, *sxe; + _G_int32_t z; + unsigned32 si, zs; + + n = S->wds; +#ifdef DEBUG + /*debug*/ if (b->wds > n) + /*debug*/ Bug("oversize b in quorem"); +#endif + if (b->wds < n) + return 0; + sx = S->x; + sxe = sx + --n; + bx = b->x; + bxe = bx + n; + q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ +#ifdef DEBUG + /*debug*/ if (q > 9) + /*debug*/ Bug("oversized quotient in quorem"); +#endif + if (q) { + borrow = 0; + carry = 0; + do { + si = *sx++; + ys = (si & 0xffff) * q + carry; + zs = (si >> 16) * q + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*bx >> 16) - (zs & 0xffff) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(bx, z, y); + } + while(sx <= sxe); + if (!*bxe) { + bx = b->x; + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + if (cmp(b, S) >= 0) { + q++; + borrow = 0; + carry = 0; + bx = b->x; + sx = S->x; + do { + si = *sx++; + ys = (si & 0xffff) + carry; + zs = (si >> 16) + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*bx >> 16) - (zs & 0xffff) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(bx, z, y); + } + while(sx <= sxe); + bx = b->x; + bxe = bx + n; + if (!*bxe) { + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + return q; + } + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the long + * calculation. + */ + + char * +_IO_dtoa +#ifdef KR_headers + (d, mode, ndigits, decpt, sign, rve) + double d; int mode, ndigits, *decpt, *sign; char **rve; +#else + (double d, int mode, int ndigits, int *decpt, int *sign, char **rve) +#endif +{ + /* Arguments ndigits, decpt, sign are similar to those + of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4-9 should give the same return values as 2-3, i.e., + 4 <= mode <= 9 ==> same return as mode + 2 + (mode & 1). These modes are mainly for + debugging; often they run slower but sometimes + faster than modes 2-3. + 4,5,8,9 ==> left-to-right digit generation. + 6-9 ==> don't try fast floating-point estimate + (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + _G_int32_t bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, + j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, + spec_case, try_quick; + _G_int32_t L; +#ifndef Sudden_Underflow + int denorm; +#endif + Bigint _b_avail, _b, _mhi, _mlo, _S; + Bigint *b_avail = Binit(&_b_avail); + Bigint *b = Binit(&_b); + Bigint *S = Binit(&_S); + /* mhi and mlo are only set and used if leftright. */ + Bigint *mhi = NULL, *mlo = NULL; + double d2, ds, eps; + char *s, *s0; + static Bigint *result = NULL; + static int result_k; + + TEST_ENDIANNESS; + if (result) { + /* result is contains a string, so its fields (interpreted + as a Bigint have been trashed. Restore them. + This is a really ugly interface - result should + not be static, since that is not thread-safe. FIXME. */ + result->k = result_k; + result->maxwds = 1 << result_k; + result->on_stack = 0; + } + + if (word0(d) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + setword0(d, word0(d) & ~Sign_bit); /* clear sign bit */ + } + else + *sign = 0; + +#if defined(IEEE_Arith) + defined(VAX) +#ifdef IEEE_Arith + if ((word0(d) & Exp_mask) == Exp_mask) +#else + if (word0(d) == 0x8000) +#endif + { + /* Infinity or NaN */ + *decpt = 9999; +#ifdef IEEE_Arith + if (!word1(d) && !(word0(d) & 0xfffff)) + { + s = "Infinity"; + if (rve) + *rve = s + 8; + } + else +#endif + { + s = "NaN"; + if (rve) + *rve = s +3; + } + return s; + } +#endif +#ifdef IBM + d += 0; /* normalize */ +#endif + if (!d) { + *decpt = 1; + s = "0"; + if (rve) + *rve = s + 1; + return s; + } + + b = d2b(b, d, &be, &bbits); + i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); +#ifndef Sudden_Underflow + if (i) { +#endif + d2 = d; + setword0(d2, (word0(d2) & Frac_mask1) | Exp_11); +#ifdef IBM + if (j = 11 - hi0bits(word0(d2) & Frac_mask)) + d2 /= 1 << j; +#endif + + i -= Bias; +#ifdef IBM + i <<= 2; + i += j; +#endif +#ifndef Sudden_Underflow + denorm = 0; + } + else { + /* d is denormalized */ + unsigned32 x; + + i = bbits + be + (Bias + (P-1) - 1); + x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32) + : word1(d) << (32 - i); + d2 = x; + addword0(d2, - 31*Exp_msk1); /* adjust exponent */ + i -= (Bias + (P-1) - 1) + 1; + denorm = 1; + } +#endif + + /* Now i is the unbiased base-2 exponent. */ + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(d) = i*log(2)/log(10) + log10(d2) + * + * This suggests computing an approximation k to log10(d) by + * + * k = i*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i) by 0.301029995663981; since |i| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ + + ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; + if (k >= 0 && k <= Ten_pmax) { + if (d < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + try_quick = 1; + if (mode > 5) { + mode -= 4; + try_quick = 0; + } + leftright = 1; + switch(mode) { + case 0: + case 1: + ilim = ilim1 = -1; + i = 18; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + /* i is now an upper bound of the number of digits to generate. */ + j = sizeof(unsigned32) * (1< result->k) + { + Bfree (result); + result = Balloc(result_k); + } + s = s0 = (char *)result; + + if (ilim >= 0 && ilim <= Quick_max && try_quick) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + d2 = d; + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + d /= bigtens[n_bigtens-1]; + ieps++; + } + for(; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + d /= ds; + } + else if ((j1 = -k)) { + d *= tens[j1 & 0xf]; + for(j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + d *= bigtens[i]; + } + } + if (k_check && d < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + d *= 10.; + ieps++; + } + eps = ieps*d + 7.; + addword0(eps, - (P-1)*Exp_msk1); + if (ilim == 0) { + d -= 5.; + if (d > eps) + goto one_digit; + if (d < -eps) + goto no_digits; + goto fast_failed; + } +#ifndef No_leftright + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + eps = 0.5/tens[ilim-1] - eps; + for(i = 0;;) { + L = (_G_int32_t)d; + d -= L; + *s++ = '0' + (int)L; + if (d < eps) + goto ret1; + if (1. - d < eps) + goto bump_up; + if (++i >= ilim) + break; + eps *= 10.; + d *= 10.; + } + } + else { +#endif + /* Generate ilim digits, then fix them up. */ + eps *= tens[ilim-1]; + for(i = 1;; i++, d *= 10.) { + L = (_G_int32_t)d; + d -= L; + *s++ = '0' + (int)L; + if (i == ilim) { + if (d > 0.5 + eps) + goto bump_up; + else if (d < 0.5 - eps) { + while(*--s == '0'); + s++; + goto ret1; + } + break; + } + } +#ifndef No_leftright + } +#endif + fast_failed: + s = s0; + d = d2; + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + if (ilim < 0 || d <= 5*ds) + goto no_digits; + goto one_digit; + } + for(i = 1;; i++) { + L = (_G_int32_t)(d / ds); + d -= L*ds; +#ifdef Check_FLT_ROUNDS + /* If FLT_ROUNDS == 2, L will usually be high by 1 */ + if (d < 0) { + L--; + d += ds; + } +#endif + *s++ = '0' + (int)L; + if (i == ilim) { + d += d; + if (d > ds || (d == ds && L & 1)) { + bump_up: + while(*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + break; + } + if (!(d *= 10.)) + break; + } + goto ret1; + } + + m2 = b2; + m5 = b5; + if (leftright) { + if (mode < 2) { + i = +#ifndef Sudden_Underflow + denorm ? be + (Bias + (P-1) - 1 + 1) : +#endif +#ifdef IBM + 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); +#else + 1 + P - bbits; +#endif + } + else { + j = ilim - 1; + if (m5 >= j) + m5 -= j; + else { + s5 += j -= m5; + b5 += j; + m5 = 0; + } + if ((i = ilim) < 0) { + m2 -= i; + i = 0; + } + } + b2 += i; + s2 += i; + mhi = i2b(Binit(&_mhi), 1); + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + Bigint *b_tmp; + mhi = pow5mult(mhi, m5); + b_tmp = mult(b_avail, mhi, b); + b_avail = b; + b = b_tmp; + } + if ((j = b5 - m5)) + b = pow5mult(b, j); + } + else + b = pow5mult(b, b5); + } + S = i2b(S, 1); + if (s5 > 0) + S = pow5mult(S, s5); + + /* Check for special case that d is a normalized power of 2. */ + + if (mode < 2) { + if (!word1(d) && !(word0(d) & Bndry_mask) +#ifndef Sudden_Underflow + && word0(d) & Exp_mask +#endif + ) { + /* The special case */ + b2 += Log2P; + s2 += Log2P; + spec_case = 1; + } + else + spec_case = 0; + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ + if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f)) + i = 32 - i; + if (i > 4) { + i -= 4; + b2 += i; + m2 += i; + s2 += i; + } + else if (i < 4) { + i += 28; + b2 += i; + m2 += i; + s2 += i; + } + if (b2 > 0) + b = lshift(b, b2); + if (s2 > 0) + S = lshift(S, s2); + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (leftright) + mhi = multadd(mhi, 10, 0); + ilim = ilim1; + } + } + if (ilim <= 0 && mode > 2) { + if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { + /* no digits, fcvt style */ + no_digits: + k = -1 - ndigits; + goto ret; + } + one_digit: + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) + mhi = lshift(mhi, m2); + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + if (spec_case) { + mlo = Brealloc(Binit(&_mlo), mhi->k); + Bcopy(mlo, mhi); + mhi = lshift(mhi, Log2P); + } + else + mlo = mhi; + + for(i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + b_avail = diff(b_avail, S, mhi); /* b_avail = S - mi */ + j1 = b_avail->sign ? 1 : cmp(b, b_avail); +#ifndef ROUND_BIASED + if (j1 == 0 && !mode && !(word1(d) & 1)) { + if (dig == '9') + goto round_9_up; + if (j > 0) + dig++; + *s++ = dig; + goto ret; + } +#endif + if (j < 0 || (j == 0 && !mode +#ifndef ROUND_BIASED + && !(word1(d) & 1) +#endif + )) { + if (j1 > 0) { + b = lshift(b, 1); + j1 = cmp(b, S); + if ((j1 > 0 || (j1 == 0 && dig & 1)) + && dig++ == '9') + goto round_9_up; + } + *s++ = dig; + goto ret; + } + if (j1 > 0) { + if (dig == '9') { /* possible if i == 1 */ + round_9_up: + *s++ = '9'; + goto roundoff; + } + *s++ = dig + 1; + goto ret; + } + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (mlo == mhi) + mlo = mhi = multadd(mhi, 10, 0); + else { + mlo = multadd(mlo, 10, 0); + mhi = multadd(mhi, 10, 0); + } + } + } + else + for(i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (i >= ilim) + break; + b = multadd(b, 10, 0); + } + + /* Round off last digit */ + + b = lshift(b, 1); + j = cmp(b, S); + if (j > 0 || (j == 0 && dig & 1)) { + roundoff: + while(*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + ++*s++; + } + else { + while(*--s == '0'); + s++; + } + ret: + Bfree(b_avail); + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } + ret1: + Bfree(b); + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + return s0; + } +#endif /* _IO_USE_DTOA */ diff --git a/libio/floatio.h b/libio/floatio.h new file mode 100644 index 000000000000..827767bde359 --- /dev/null +++ b/libio/floatio.h @@ -0,0 +1,51 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * %W% (Berkeley) %G% + */ + +/* + * Floating point scanf/printf (input/output) definitions. + */ + +/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ +#define MAXEXP 308 +/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ +#define MAXFRACT 39 diff --git a/libio/fstream.cc b/libio/fstream.cc new file mode 100644 index 000000000000..8930e0b9271f --- /dev/null +++ b/libio/fstream.cc @@ -0,0 +1,110 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#define _STREAM_COMPAT +extern "C" { +#include "libioP.h" +} +#include + +inline void +fstreambase::__fb_init() +{ +#ifdef _IO_NEW_STREAMS +#if !_IO_UNIFIED_JUMPTABLES + /* Uses the _IO_file_jump jumptable, for eficiency. */ + __my_fb._jumps = &_IO_file_jumps; + __my_fb._vtable() = builtinbuf_vtable; +#endif + init (&__my_fb); +#else + init(filebuf::__new()); + _flags &= ~ios::dont_close; +#endif +} + +fstreambase::fstreambase() +{ + __fb_init (); +} + +fstreambase::fstreambase(int fd) +{ + __fb_init (); + _IO_file_attach(rdbuf(), fd); +} + +fstreambase::fstreambase(const char *name, int mode, int prot) +{ + __fb_init (); + if (!rdbuf()->open(name, mode, prot)) + set(ios::badbit); +} + +fstreambase::fstreambase(int fd, char *p, int l) +{ +#ifdef _IO_NEW_STREAMS + __fb_init (); +#else + init(filebuf::__new()); +#endif + _IO_file_attach(rdbuf(), fd); + _IO_file_setbuf(rdbuf(), p, l); +} + +void fstreambase::open(const char *name, int mode, int prot) +{ + clear(); + if (!rdbuf()->open(name, mode, prot)) + set(ios::badbit); +} + +void fstreambase::close() +{ + if (!rdbuf()->close()) + set(ios::failbit); +} + +void fstreambase::attach(int fd) +{ + if (!rdbuf()->attach(fd)) + set(ios::failbit); +} + +#if 0 +static int mode_to_sys(enum open_mode mode) +{ + return O_WRONLY; +} + +static char* fopen_cmd_arg(io_mode i) +{ + return "w"; +} +#endif diff --git a/libio/fstream.h b/libio/fstream.h new file mode 100644 index 000000000000..ea98f5caed05 --- /dev/null +++ b/libio/fstream.h @@ -0,0 +1,92 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifndef _FSTREAM_H +#define _FSTREAM_H +#ifdef __GNUG__ +#pragma interface +#endif +#include + +extern "C++" { +class fstreambase : virtual public ios { +#ifdef _IO_NEW_STREAMS + mutable filebuf __my_fb; // mutable so rdbuf() can be const +#endif + void __fb_init (); + public: + fstreambase(); + fstreambase(int fd); + fstreambase(int fd, char *p, int l); /* Deprecated */ + fstreambase(const char *name, int mode, int prot=0664); + void close(); +#ifdef _IO_NEW_STREAMS + filebuf* rdbuf() const { return &__my_fb; } +#else + filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); } +#endif + void open(const char *name, int mode, int prot=0664); + int is_open() const { return rdbuf()->is_open(); } + void setbuf(char *ptr, int len) { rdbuf()->setbuf(ptr, len); } + void attach(int fd); +#ifdef _STREAM_COMPAT + int filedesc() { return rdbuf()->fd(); } + fstreambase& raw() { rdbuf()->setbuf(NULL, 0); return *this; } +#endif +}; + +class ifstream : public fstreambase, public istream { + public: + ifstream() : fstreambase() { } + ifstream(int fd) : fstreambase(fd) { } + ifstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/ + ifstream(const char *name, int mode=ios::in, int prot=0664) + : fstreambase(name, mode, prot) { } + void open(const char *name, int mode=ios::in, int prot=0664) + { fstreambase::open(name, mode, prot); } +}; + +class ofstream : public fstreambase, public ostream { + public: + ofstream() : fstreambase() { } + ofstream(int fd) : fstreambase(fd) { } + ofstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/ + ofstream(const char *name, int mode=ios::out, int prot=0664) + : fstreambase(name, mode, prot) { } + void open(const char *name, int mode=ios::out, int prot=0664) + { fstreambase::open(name, mode, prot); } +}; + +class fstream : public fstreambase, public iostream { + public: + fstream() : fstreambase() { } + fstream(int fd) : fstreambase(fd) { } + fstream(const char *name, int mode, int prot=0664) + : fstreambase(name, mode, prot) { } + fstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/ + void open(const char *name, int mode, int prot=0664) + { fstreambase::open(name, mode, prot); } +}; +} // extern "C++" +#endif /*!_FSTREAM_H*/ diff --git a/libio/gen-params b/libio/gen-params new file mode 100755 index 000000000000..9fb7272dd830 --- /dev/null +++ b/libio/gen-params @@ -0,0 +1,698 @@ +#!/bin/sh +# Copyright (C) 1992, 1993, 1994 Free Software Foundation +# +# This file is part of the GNU IO 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 this library; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Written by Per Bothner (bothner@cygnus.com) + +# This is a shell-script that figures out various things about a +# system, and writes (to stdout) a C-style include files with +# suitable definitions, including all the standard Posix types. +# It works by compiling various test programs -- some are run through +# the C pre-processor, and the output examined. +# The test programs are only compiled, not executed, so the script +# should even if you're cross-compiling. +# It uses $CC (which defaults to cc) to compile C programs (extension .c), +# and $CXX (which defaults to gcc) to compile C++ programs (extension .C). +# The shell-script is written for libg++.a. + +# Usage: gen-params [NAME1=name1 ...] +# - where an assignment (such as size_t="unsigned int" means to +# use that value, instead of trying to figure it out. + +# Uncomment following line for debugging +# set -x + +SED=sed + +# Evaluate the arguments (which should be assignments): +for arg in "$@"; do + # Quote arg (i.e. FOO=bar => FOO='bar'), then eval it. + eval `echo "$arg" | ${SED} -e "s|^\(.*\)=\(.*\)|\1='\2'|"` +done + +macro_prefix=${macro_prefix-"_G_"} +rootdir=`pwd`/.. +gccdir=${gccdir-${rootdir}/gcc} +binutilsdir=${binutilsdir-${rootdir}/binutils} +CC=${CC-`if [ -f ${gccdir}/xgcc ] ; \ + then echo ${gccdir}/xgcc -B${gccdir}/ ; \ + else echo cc ; fi`} +CXX=${CXX-`if [ -f ${gccdir}/xgcc ] ; \ + then echo ${gccdir}/xgcc -B${gccdir}/ ; \ + else echo gcc ; fi`} +CPP=${CPP-`echo ${CC} -E`} +CONFIG_NM=${CONFIG_NM-`if [ -f ${binutilsdir}/nm.new ] ; \ + then echo ${binutilsdir}/nm.new ; \ + else echo nm ; fi`} + +cat <dummy.h <dummy.C <&2; exit -1; + fi + fi + echo "#define ${macro_prefix}NAMES_HAVE_UNDERSCORE ${NAMES_HAVE_UNDERSCORE}" + + if test -z "${VTABLE_LABEL_PREFIX}" ; then + # Determine how virtual function tables are named. This is fragile, + # because different nm's produce output in different formats. + ${CONFIG_NM} dummy.o >TMP + if [ -n "`${SED} -n -e 's/ virtual table/nope/p' TMP 2>/dev/null || + ${CONFIG_NM} --no-demangle dummy.o >TMP 2>/dev/null || + ${CONFIG_NM} dummy.o >TMP 2>/dev/null + fi + # First we look for a pattern that matches historical output from g++. + # We surround the actual label name by <> to separate it from + # other nm junk. + ${SED} -n -e 's/_*vt[$_.]7*filebuf/<&>/p' dummy.out + # For paranoia's sake (e.g. if we're using some other C++ compiler) + # we try a more general pattern, and append the result. + grep -v foo /p' \ + >>dummy.out + # Now we get rid of the <>, and any other junk on the nm output line. + # (We get rid of in case nm included debugging output for + # class filebuf itself.) Finally, we select the first line of + # the result, and hope that's what we wanted! + vtab_name=`${SED} -n -e '//d' -e 's/^.*<\(.*\)>.*$/\1/p' \ + &2; exit 1 +# fi + else + # The compile failed for some reason (no C++?) + echo "gen-params: could not compile dummy.C with ${CXX}" 1>&2; exit 1; + fi +fi + +# A little test program to check if struct stat has st_blksize. +cat >dummy.c < +#include +int BLKSIZE(struct stat *st) +{ + return st->st_blksize; +} +!EOF! + +if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_ST_BLKSIZE 1" +else + echo "#define ${macro_prefix}HAVE_ST_BLKSIZE 0" +fi + +# A little test program to check if the name 'clog' is defined in libm, +# as it is under DEC UNIX. +cat >dummy.c <&1 >/dev/null | grep clog >/dev/null; then + echo "#define ${macro_prefix}CLOG_CONFLICT 1" +fi + +echo "" + +# Next, generate definitions for the standard types (such as mode_t) +# compatible with those in the standard C header files. +# It works by a dummy program through the C pre-processor, and then +# using sed to search for typedefs in the output. + +for hdr in wchar wctype; do + eval $hdr=0 + cat >dummy.c < +EOF + if ${CPP} dummy.c >/dev/null 2>&1 ; then eval $hdr=1; fi +done + +cat >dummy.c < +#include +#ifdef __STDC__ +#include +#else /* !__STDC__ */ +#include +#endif /* __STDC__ */ +#include +#include +#include +#ifdef __STDC__ +#include +#endif +#if WCHAR == 1 +#include +#endif +#if WCTYPE == 1 +#include +#endif +#ifdef size_t +typedef size_t Xsize_t; +#elif defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ Xsize_t; +#endif +#ifdef ptrdiff_t +typedef ptrdiff_t Xptrdiff_t; +#elif defined(__PTRDIFF_TYPE__) +typedef __PTRDIFF_TYPE__ Xptrdiff_t; +#endif +#ifdef wchar_t +typedef wchar_t Xwchar_t; +#elif defined(__WCHAR_TYPE__) +typedef __WCHAR_TYPE__ Xwchar_t; +#endif +#ifdef va_list +typedef va_list XXXva_list; +#endif +#ifdef BUFSIZ +long XBUFSIZ=BUFSIZ; +#endif +#ifdef FOPEN_MAX +long XFOPEN_MAX=FOPEN_MAX; +#endif +#ifdef FILENAME_MAX +long XFILENAME_MAX=FILENAME_MAX; +#endif +#ifdef SHRT_MAX +long XSHRT_MAX=SHRT_MAX; +#endif +#ifdef INT_MAX +long XINT_MAX=INT_MAX; +#endif +#ifdef LONG_MAX +long XLONG_MAX=LONG_MAX; +#endif +#ifdef LONG_LONG_MAX +long XLONG_LONG_MAX=LONG_LONG_MAX; +#endif +!EOF! + +if ${CPP} dummy.c -DWCHAR=$wchar -DWCTYPE=$wctype >TMP ; then true +else + echo "gen-params: could not invoke ${CPP} on dummy.c" 1>&2 ; exit 1 +fi +tr ' ' ' ' dummy.out + +for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t ptrdiff_t sigset_t size_t ssize_t time_t uid_t va_list wchar_t wint_t int16_t uint16_t int32_t uint_32_t u_int16_t u_int32_t; do + IMPORTED=`eval 'echo $'"$TYPE"` + if [ -n "${IMPORTED}" ] ; then + eval "$TYPE='$IMPORTED'" + else + t=$TYPE + VALUE='' + + # Follow `typedef VALUE TYPE' chains, but don't loop indefinitely. + for iteration in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + # Search dummy.out for a typedef for X*$t. + sed_script=" + s/unsigned long long/_G_ullong/g + s/long long/_G_llong/g + /.*typedef *\\(.*[^ ]\\) *X*$t *;.*/{s||\1|;p;q;} + /.*typedef *\\(.*[^ a-zA-Z0-9_]\\)X*$t *;.*/{s||\1|;p;q;} + " + t=`${SED} -n "$sed_script" /dev/null + # Now select the first definition. + if [ -s TMP ]; then + eval "$NAME='"`${SED} -e '2,$d' /dev/null + # Now select the first definition. + if [ -s TMP ]; then + eval "$NAME='"`${SED} -e '2,$d' 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +typedef int ${macro_prefix}int8_t __attribute__((__mode__(__QI__))); +typedef unsigned int ${macro_prefix}uint8_t __attribute__((__mode__(__QI__))); +typedef int ${macro_prefix}int16_t __attribute__((__mode__(__HI__))); +typedef unsigned int ${macro_prefix}uint16_t __attribute__((__mode__(__HI__))); +typedef int ${macro_prefix}int32_t __attribute__((__mode__(__SI__))); +typedef unsigned int ${macro_prefix}uint32_t __attribute__((__mode__(__SI__))); +typedef int ${macro_prefix}int64_t __attribute__((__mode__(__DI__))); +typedef unsigned int ${macro_prefix}uint64_t __attribute__((__mode__(__DI__))); +__extension__ typedef long long ${macro_prefix}llong; +__extension__ typedef unsigned long long ${macro_prefix}ullong; +#else +typedef $int16_t ${macro_prefix}int16_t; +typedef $uint16_t ${macro_prefix}uint16_t; +typedef $int32_t ${macro_prefix}int32_t; +typedef $uint32_t ${macro_prefix}uint32_t; +#endif + +typedef ${clock_t-int /* default */} ${macro_prefix}clock_t; +typedef ${dev_t-int /* default */} ${macro_prefix}dev_t; +typedef ${fpos_t-long /* default */} ${macro_prefix}fpos_t; +typedef ${gid_t-int /* default */} ${macro_prefix}gid_t; +typedef ${ino_t-int /* default */} ${macro_prefix}ino_t; +typedef ${mode_t-int /* default */} ${macro_prefix}mode_t; +typedef ${nlink_t-int /* default */} ${macro_prefix}nlink_t; +typedef ${off_t-long /* default */} ${macro_prefix}off_t; +typedef ${pid_t-int /* default */} ${macro_prefix}pid_t; +#ifndef __PTRDIFF_TYPE__ +#define __PTRDIFF_TYPE__ ${ptrdiff_t-long int /* default */} +#endif +typedef __PTRDIFF_TYPE__ ${macro_prefix}ptrdiff_t; +typedef ${sigset_t-int /* default */} ${macro_prefix}sigset_t; +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ ${size_t-unsigned long /* default */} +#endif +typedef __SIZE_TYPE__ ${macro_prefix}size_t; +typedef ${time_t-int /* default */} ${macro_prefix}time_t; +typedef ${uid_t-int /* default */} ${macro_prefix}uid_t; +typedef ${wchar_t-int /* default */} ${macro_prefix}wchar_t; + +#define ${macro_prefix}BUFSIZ ${BUFSIZ-1024 /* default */} +#define ${macro_prefix}FOPEN_MAX ${FOPEN_MAX-32 /* default */} +#define ${macro_prefix}FILENAME_MAX ${FILENAME_MAX-1024 /* default */} +#if defined (__cplusplus) || defined (__STDC__) +#define ${macro_prefix}ARGS(ARGLIST) ARGLIST +#else +#define ${macro_prefix}ARGS(ARGLIST) () +#endif +#if !defined (__GNUG__) || defined (__STRICT_ANSI__) +#define ${macro_prefix}NO_NRV +#endif +#if !defined (__GNUG__) +#define _G_NO_EXTERN_TEMPLATES +#endif +!EOF! + +# ssize_t is the signed version of size_t +if [ -n "${ssize_t}" ] ; then + echo "typedef ${ssize_t} ${macro_prefix}ssize_t;" +elif [ -z "${size_t}" ] ; then + echo "typedef long ${macro_prefix}ssize_t;" +else + # Remove "unsigned" from ${size_t} to get ${ssize_t}. + tmp="`echo ${size_t} | ${SED} -e 's|unsigned||g' -e 's| | |g'`" + if [ -z "$tmp" ] ; then + tmp=int + else + # check $tmp doesn't conflict with + echo "#include + extern $tmp read();" >dummy.c + ${CC} -c dummy.c >/dev/null 2>&1 || tmp=int + fi + echo "typedef $tmp /* default */ ${macro_prefix}ssize_t;" +fi + +# wint_t is often the integral type to which wchar_t promotes. +if [ -z "${wint_t}" ] ; then + for TYPE in int 'unsigned int' 'long int' 'long unsigned int'; do + cat >dummy.C </dev/null 2>&1 ; then + wint_t="$TYPE /* default */" + break + fi + done +fi +echo "typedef ${wint_t-int /* wchar_t is broken */} ${macro_prefix}wint_t;" + +# va_list can cause problems (e.g. some systems have va_list as a struct). +# Check to see if ${va_list-char*} really is compatible with stdarg.h. +cat >dummy.C < +} +long foo(X_va_list ap) { return va_arg(ap, long); } +long bar(int i, ...) +{ va_list ap; long j; va_start(ap, i); j = foo(ap); va_end(ap); return j; } +!EOF! +if ${CXX} -c dummy.C >/dev/null 2>&1 ; then + # Ok: We have something that works. + echo "typedef ${va_list-char* /* default */} ${macro_prefix}va_list;" +else + # No, it breaks. Indicate that must be included. + echo "#define ${macro_prefix}NEED_STDARG_H +#define ${macro_prefix}va_list va_list" +fi + +cat >dummy.c < +extern int (*signal())(); +extern int dummy (int); +main() +{ + int (*oldsig)(int) = signal (1, dummy); + (void) signal (2, oldsig); + return 0; +} +!EOF! +if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}signal_return_type int" +else + echo "#define ${macro_prefix}signal_return_type void" +fi + +# check sprintf return type + +cat >dummy.c < +extern int sprintf(); char buf[100]; +int main() { return sprintf(buf, "%d", 34); } +!EOF! +if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}sprintf_return_type int" +else + echo "#define ${macro_prefix}sprintf_return_type char*" +fi + +if test -n "${HAVE_ATEXIT}" ; then + echo "#define ${macro_prefix}HAVE_ATEXIT ${HAVE_ATEXIT}" +else + cat >dummy.c < +int main() +{ + atexit (0); +} +!EOF! + if ${CC} dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_ATEXIT 1" + else + echo "#define ${macro_prefix}HAVE_ATEXIT 0" + fi +fi + + +# *** Check for presence of certain include files *** + +# check for sys/resource.h + +if test -n "${HAVE_SYS_RESOURCE}" ; then + echo "#define ${macro_prefix}HAVE_SYS_RESOURCE ${HAVE_SYS_RESOURCE}" +else + cat >dummy.c < +#include +#include + int main() + { + struct rusage res; + getrusage(RUSAGE_SELF, &res); + return (int)(res.ru_utime.tv_sec + (res.ru_utime.tv_usec / 1000000.0)); + } +!EOF! + # Note: We link because some systems have sys/resource, but not getrusage(). + if ${CC} dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_SYS_RESOURCE 1" + else + echo "#define ${macro_prefix}HAVE_SYS_RESOURCE 0" + fi +fi + +# check for struct tms in sys/times.h + +if test -n "${HAVE_SYS_TIMES}" ; then + echo "#define ${macro_prefix}HAVE_SYS_TIMES ${HAVE_SYS_TIMES}" +else + cat >dummy.c < +#include + int main() + { + struct tms s; + return s.tms_utime; + } +!EOF! + if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_SYS_TIMES 1" + else + echo "#define ${macro_prefix}HAVE_SYS_TIMES 0" + fi +fi + +# check for sys/socket.h + +if test -n "${HAVE_SYS_SOCKET}" ; then + echo "#define ${macro_prefix}HAVE_SYS_SOCKET ${HAVE_SYS_SOCKET}" +else + echo '#include ' >dummy.c + echo '#include ' >>dummy.c + if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_SYS_SOCKET 1" + else + echo "#define ${macro_prefix}HAVE_SYS_SOCKET 0" + fi +fi + +# check for sys/cdefs.h + +if test -n "${HAVE_SYS_CDEFS}" ; then + echo "#define ${macro_prefix}HAVE_SYS_CDEFS ${HAVE_SYS_CDEFS}" +else + echo '#include ' >dummy.c + echo 'extern int myfunc __P((int, int));' >>dummy.c + if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_SYS_CDEFS 1" + else + echo "#define ${macro_prefix}HAVE_SYS_CDEFS 0" + fi +fi + +# Check for a (Posix-compatible) sys/wait.h */ + +if test -n "${HAVE_SYS_WAIT}" ; then + echo "#define ${macro_prefix}HAVE_SYS_WAIT ${HAVE_SYS_WAIT}" +else + cat >dummy.c < +#include + int f() { int i; wait(&i); return i; } +!EOF! + if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_SYS_WAIT 1" + else + echo "#define ${macro_prefix}HAVE_SYS_WAIT 0" + fi +fi + +if test -n "${HAVE_UNISTD}" ; then + echo "#define ${macro_prefix}HAVE_UNISTD ${HAVE_UNISTD}" +else + echo '#include ' >dummy.c + if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_UNISTD 1" + else + echo "#define ${macro_prefix}HAVE_UNISTD 0" + fi +fi + +if test -n "${HAVE_DIRENT}" ; then + echo "#define ${macro_prefix}HAVE_DIRENT ${HAVE_DIRENT}" +else + echo '#include +#include ' >dummy.c + if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_DIRENT 1" + else + echo "#define ${macro_prefix}HAVE_DIRENT 0" + fi +fi + +if test -n "${HAVE_CURSES}" ; then + echo "#define ${macro_prefix}HAVE_CURSES ${HAVE_CURSES}" +else + echo '#include ' >dummy.c + if ${CC} -c dummy.c >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_CURSES 1" + else + echo "#define ${macro_prefix}HAVE_CURSES 0" + fi +fi + +# There is no test for this at the moment; it is just set by the +# configuration files. +if test -n "${MATH_H_INLINES}" ; then + echo "#define ${macro_prefix}MATH_H_INLINES ${MATH_H_INLINES}" +else + echo "#define ${macro_prefix}MATH_H_INLINES 0" +fi + +if test -n "${HAVE_BOOL}" ; then + echo "#define ${macro_prefix}HAVE_BOOL ${HAVE_BOOL}" +else + echo 'bool i=true,j=false;' >dummy.C + if ${CXX} -c dummy.C >/dev/null 2>&1 ; then + echo "#define ${macro_prefix}HAVE_BOOL 1" + else + echo "#define ${macro_prefix}HAVE_BOOL 0" + fi +fi + +if test -n "${NO_USE_DTOA}" ; then + echo "#define ${macro_prefix}NO_USE_DTOA 1" +fi +if test -n "${USE_INT32_FLAGS}" ; then + echo "#define ${macro_prefix}USE_INT32_FLAGS 1" +fi + +# Uncomment the following line if you don't have working templates. +# echo "#define ${macro_prefix}NO_TEMPLATES" + +rm -f dummy.C dummy.o dummy.c dummy.out TMP core a.out + +echo "#endif /* !${macro_prefix}config_h */" diff --git a/libio/genops.c b/libio/genops.c new file mode 100644 index 000000000000..23a6fdeaeac7 --- /dev/null +++ b/libio/genops.c @@ -0,0 +1,852 @@ +/* +Copyright (C) 1993, 1995 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Generic or default I/O operations. */ + +#include "libioP.h" +#ifdef __STDC__ +#include +#endif +#include + +void +DEFUN(_IO_un_link, (fp), + _IO_FILE *fp) +{ + if (fp->_flags & _IO_LINKED) { + _IO_FILE **f; + for (f = &_IO_list_all; *f != NULL; f = &(*f)->_chain) { + if (*f == fp) { + *f = fp->_chain; + break; + } + } + fp->_flags &= ~_IO_LINKED; + } +} + +void +DEFUN(_IO_link_in, (fp), + _IO_FILE *fp) +{ + if ((fp->_flags & _IO_LINKED) == 0) { + fp->_flags |= _IO_LINKED; + fp->_chain = _IO_list_all; + _IO_list_all = fp; + } +} + +/* Return minimum _pos markers + Assumes the current get area is the main get area. */ + +_IO_size_t +DEFUN(_IO_least_marker, (fp), + register _IO_FILE *fp) +{ + _IO_ssize_t least_so_far = fp->_IO_read_end - fp->_IO_read_base; + register struct _IO_marker *mark; + for (mark = fp->_markers; mark != NULL; mark = mark->_next) + if (mark->_pos < least_so_far) + least_so_far = mark->_pos; + return least_so_far; +} + +/* Switch current get area from backup buffer to (start of) main get area. */ + +void +DEFUN(_IO_switch_to_main_get_area, (fp), + _IO_FILE *fp) +{ + char *tmp; + fp->_flags &= ~_IO_IN_BACKUP; + /* Swap _IO_read_end and _IO_save_end. */ + tmp = fp->_IO_read_end; fp->_IO_read_end= fp->_IO_save_end; fp->_IO_save_end= tmp; + /* Swap _IO_read_base and _IO_save_base. */ + tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp; + fp->_IO_read_ptr = fp->_IO_read_base; +} + +/* Switch current get area from main get area to (end of) backup area. */ + +void +DEFUN(_IO_switch_to_backup_area, (fp), + register _IO_FILE *fp) +{ + char *tmp; + fp->_flags |= _IO_IN_BACKUP; + /* Swap _IO_read_end and _IO_save_end. */ + tmp = fp->_IO_read_end; fp->_IO_read_end = fp->_IO_save_end; fp->_IO_save_end = tmp; + /* Swap _gbase and _IO_save_base. */ + tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp; + fp->_IO_read_ptr = fp->_IO_read_end; +} + +int +DEFUN(_IO_switch_to_get_mode, (fp), + register _IO_FILE *fp) +{ + if (fp->_IO_write_ptr > fp->_IO_write_base) + if (_IO_OVERFLOW (fp, EOF) == EOF) + return EOF; + if (_IO_in_backup(fp)) + fp->_IO_read_base = fp->_IO_backup_base; + else + { + fp->_IO_read_base = fp->_IO_buf_base; + if (fp->_IO_write_ptr > fp->_IO_read_end) + fp->_IO_read_end = fp->_IO_write_ptr; + } + fp->_IO_read_ptr = fp->_IO_write_ptr; + + fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = fp->_IO_read_ptr; + + fp->_flags &= ~_IO_CURRENTLY_PUTTING; + return 0; +} + +void +DEFUN(_IO_free_backup_area, (fp), + register _IO_FILE *fp) +{ + if (_IO_in_backup (fp)) + _IO_switch_to_main_get_area(fp); /* Just in case. */ + free (fp->_IO_save_base); + fp->_IO_save_base = NULL; + fp->_IO_save_end = NULL; + fp->_IO_backup_base = NULL; +} + +#if 0 +int +DEFUN(_IO_switch_to_put_mode, (fp), + register _IO_FILE *fp) +{ + fp->_IO_write_base = fp->_IO_read_ptr; + fp->_IO_write_ptr = fp->_IO_read_ptr; + /* Following is wrong if line- or un-buffered? */ + fp->_IO_write_end = fp->_flags & _IO_IN_BACKUP ? fp->_IO_read_end : fp->_IO_buf_end; + + fp->_IO_read_ptr = fp->_IO_read_end; + fp->_IO_read_base = fp->_IO_read_end; + + fp->_flags |= _IO_CURRENTLY_PUTTING; + return 0; +} +#endif + +int +DEFUN(__overflow, (f, ch), + _IO_FILE *f AND int ch) +{ + return _IO_OVERFLOW (f, ch); +} + +static int +DEFUN(save_for_backup, (fp), + _IO_FILE *fp) +{ + /* Append [_IO_read_base.._IO_read_end] to backup area. */ + int least_mark = _IO_least_marker(fp); + /* needed_size is how much space we need in the backup area. */ + int needed_size = (fp->_IO_read_end - fp->_IO_read_base) - least_mark; + int current_Bsize = fp->_IO_save_end - fp->_IO_save_base; + int avail; /* Extra space available for future expansion. */ + int delta; + struct _IO_marker *mark; + if (needed_size > current_Bsize) + { + char *new_buffer; + avail = 100; + new_buffer = (char*)malloc(avail+needed_size); + if (new_buffer == NULL) + return EOF; /* FIXME */ + if (least_mark < 0) + { + memcpy(new_buffer + avail, + fp->_IO_save_end + least_mark, + -least_mark); + memcpy(new_buffer +avail - least_mark, + fp->_IO_read_base, + fp->_IO_read_end - fp->_IO_read_base); + } + else + memcpy(new_buffer + avail, + fp->_IO_read_base + least_mark, + needed_size); + if (fp->_IO_save_base) + free (fp->_IO_save_base); + fp->_IO_save_base = new_buffer; + fp->_IO_save_end = new_buffer + avail + needed_size; + } + else + { + avail = current_Bsize - needed_size; + if (least_mark < 0) + { + memmove(fp->_IO_save_base + avail, + fp->_IO_save_end + least_mark, + -least_mark); + memcpy(fp->_IO_save_base + avail - least_mark, + fp->_IO_read_base, + fp->_IO_read_end - fp->_IO_read_base); + } + else if (needed_size > 0) + memcpy(fp->_IO_save_base + avail, + fp->_IO_read_base + least_mark, + needed_size); + } + /* FIXME: Dubious arithmetic if pointers are NULL */ + fp->_IO_backup_base = fp->_IO_save_base + avail; + /* Adjust all the streammarkers. */ + delta = fp->_IO_read_end - fp->_IO_read_base; + for (mark = fp->_markers; mark != NULL; mark = mark->_next) + mark->_pos -= delta; + return 0; +} + +int +DEFUN(__underflow, (fp), + _IO_FILE *fp) +{ + if (_IO_in_put_mode(fp)) + if (_IO_switch_to_get_mode(fp) == EOF) return EOF; + if (fp->_IO_read_ptr < fp->_IO_read_end) + return *(unsigned char*)fp->_IO_read_ptr; + if (_IO_in_backup(fp)) + { + _IO_switch_to_main_get_area(fp); + if (fp->_IO_read_ptr < fp->_IO_read_end) + return *fp->_IO_read_ptr; + } + if (_IO_have_markers(fp)) + { + if (save_for_backup (fp)) + return EOF; + } + else if (_IO_have_backup(fp)) + _IO_free_backup_area(fp); + return _IO_UNDERFLOW (fp); +} + +int +DEFUN(__uflow, (fp), + _IO_FILE *fp) +{ + if (_IO_in_put_mode(fp)) + if (_IO_switch_to_get_mode(fp) == EOF) return EOF; + if (fp->_IO_read_ptr < fp->_IO_read_end) + return *(unsigned char*)fp->_IO_read_ptr++; + if (_IO_in_backup(fp)) + { + _IO_switch_to_main_get_area(fp); + if (fp->_IO_read_ptr < fp->_IO_read_end) + return *fp->_IO_read_ptr++; + } + if (_IO_have_markers(fp)) + { + if (save_for_backup (fp)) + return EOF; + } + else if (_IO_have_backup(fp)) + _IO_free_backup_area(fp); + return _IO_UFLOW (fp); +} + +void +DEFUN(_IO_setb, (f, b, eb, a), + _IO_FILE *f AND char *b AND char *eb AND int a) +{ + if (f->_IO_buf_base && !(f->_flags & _IO_USER_BUF)) + FREE_BUF(f->_IO_buf_base); + f->_IO_buf_base = b; + f->_IO_buf_end = eb; + if (a) + f->_flags &= ~_IO_USER_BUF; + else + f->_flags |= _IO_USER_BUF; +} + +void +DEFUN(_IO_doallocbuf, (fp), + register _IO_FILE *fp) +{ + if (fp->_IO_buf_base) + return; + if (!(fp->_flags & _IO_UNBUFFERED)) + if (_IO_DOALLOCATE (fp) != EOF) + return; + _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0); +} + +int +DEFUN(_IO_default_underflow, (fp), + _IO_FILE *fp) +{ + return EOF; +} + +int +DEFUN(_IO_default_uflow, (fp), + _IO_FILE *fp) +{ + int ch = _IO_UNDERFLOW (fp); + if (ch == EOF) + return EOF; + return *(unsigned char*)fp->_IO_read_ptr++; +} + +_IO_size_t +DEFUN(_IO_default_xsputn, (f, data, n), + register _IO_FILE *f AND const void *data AND _IO_size_t n) +{ + register const char *s = (char*) data; + register _IO_size_t more = n; + if (more <= 0) + return 0; + for (;;) + { + _IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ + if (count > 0) + { + if (count > more) + count = more; + if (count > 20) + { + memcpy(f->_IO_write_ptr, s, count); + s += count; + f->_IO_write_ptr += count; + } + else if (count <= 0) + count = 0; + else + { + register char *p = f->_IO_write_ptr; + register _IO_ssize_t i; + for (i = count; --i >= 0; ) *p++ = *s++; + f->_IO_write_ptr = p; + } + more -= count; + } + if (more == 0 || __overflow(f, (unsigned char)*s++) == EOF) + break; + more--; + } + return n - more; +} + +_IO_size_t +DEFUN(_IO_sgetn, (fp, data, n), + _IO_FILE *fp AND void *data AND _IO_size_t n) +{ + /* FIXME handle putback buffer here! */ + return _IO_XSGETN (fp, data, n); +} + +_IO_size_t +DEFUN(_IO_default_xsgetn, (fp, data, n), + _IO_FILE *fp AND void *data AND _IO_size_t n) +{ + register _IO_size_t more = n; + register char *s = (char*) data; + for (;;) + { + _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */ + if (count > 0) + { + if (count > more) + count = more; + if (count > 20) + { + memcpy(s, fp->_IO_read_ptr, count); + s += count; + fp->_IO_read_ptr += count; + } + else if (count <= 0) + count = 0; + else + { + register char *p = fp->_IO_read_ptr; + register int i = (int)count; + while (--i >= 0) *s++ = *p++; + fp->_IO_read_ptr = p; + } + more -= count; + } + if (more == 0 || __underflow(fp) == EOF) + break; + } + return n - more; +} + +int +DEFUN(_IO_sync, (fp), + register _IO_FILE *fp) +{ + return 0; +} + +_IO_FILE* +DEFUN(_IO_default_setbuf, (fp, p, len), + register _IO_FILE *fp AND char* p AND _IO_ssize_t len) +{ + if (_IO_SYNC (fp) == EOF) + return NULL; + if (p == NULL || len == 0) + { + fp->_flags |= _IO_UNBUFFERED; + _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0); + } + else + { + fp->_flags &= ~_IO_UNBUFFERED; + _IO_setb(fp, p, p+len, 0); + } + fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = 0; + fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end = 0; + return fp; +} + +_IO_pos_t +DEFUN(_IO_default_seekpos, (fp, pos, mode), + _IO_FILE *fp AND _IO_pos_t pos AND int mode) +{ + return _IO_SEEKOFF (fp, _IO_pos_as_off(pos), 0, mode); +} + +int +DEFUN(_IO_default_doallocate, (fp), + _IO_FILE *fp) +{ + char *buf = ALLOC_BUF(_IO_BUFSIZ); + if (buf == NULL) + return EOF; + _IO_setb(fp, buf, buf+_IO_BUFSIZ, 1); + return 1; +} + +void +DEFUN(_IO_init, (fp, flags), + register _IO_FILE *fp AND int flags) +{ + fp->_flags = _IO_MAGIC|flags; + fp->_IO_buf_base = NULL; + fp->_IO_buf_end = NULL; + fp->_IO_read_base = NULL; + fp->_IO_read_ptr = NULL; + fp->_IO_read_end = NULL; + fp->_IO_write_base = NULL; + fp->_IO_write_ptr = NULL; + fp->_IO_write_end = NULL; + fp->_chain = NULL; /* Not necessary. */ + + fp->_IO_save_base = NULL; + fp->_IO_backup_base = NULL; + fp->_IO_save_end = NULL; + fp->_markers = NULL; + fp->_cur_column = 0; +} + +int +DEFUN(_IO_default_sync, (fp), + _IO_FILE *fp) +{ + return 0; +} + +/* The way the C++ classes are mapped into the C functions in the + current implementation, this function can get called twice! */ + +void +DEFUN(_IO_default_finish, (fp), + _IO_FILE *fp) +{ + struct _IO_marker *mark; + if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF)) + { + FREE_BUF(fp->_IO_buf_base); + fp->_IO_buf_base = fp->_IO_buf_end = NULL; + } + + for (mark = fp->_markers; mark != NULL; mark = mark->_next) + mark->_sbuf = NULL; + + if (fp->_IO_save_base) + { + free (fp->_IO_save_base); + fp->_IO_save_base = NULL; + } + + _IO_un_link(fp); +} + +_IO_pos_t +DEFUN(_IO_default_seekoff, (fp, offset, dir, mode), + register _IO_FILE *fp AND _IO_off_t offset AND int dir AND int mode) +{ + return _IO_pos_BAD; +} + +int +DEFUN(_IO_sputbackc, (fp, c), + register _IO_FILE *fp AND int c) +{ + int result; + + if (fp->_IO_read_ptr > fp->_IO_read_base + && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c) + { + fp->_IO_read_ptr--; + result = (unsigned char)c; + } + else + result = _IO_PBACKFAIL (fp, c); + + if (result != EOF) + fp->_flags &= ~_IO_EOF_SEEN; + + return result; +} + +int +DEFUN(_IO_sungetc, (fp), + register _IO_FILE *fp) +{ + int result; + + if (fp->_IO_read_ptr > fp->_IO_read_base) + { + fp->_IO_read_ptr--; + result = (unsigned char)*fp->_IO_read_ptr; + } + else + result = _IO_PBACKFAIL (fp, EOF); + + if (result != EOF) + fp->_flags &= ~_IO_EOF_SEEN; + + return result; +} + +#if 0 /* Work in progress */ +void +DEFUN(_IO_set_column, (fp, c), + register _IO_FILE *fp AND int c) +{ + if (c == -1) + fp->_column = -1; + else + fp->_column = c - (fp->_IO_write_ptr - fp->_IO_write_base); +} +#else +int +DEFUN(_IO_set_column, (fp, i), + register _IO_FILE *fp AND int i) +{ + fp->_cur_column = i+1; + return 0; +} +#endif + + +unsigned +DEFUN(_IO_adjust_column, (start, line, count), + unsigned start AND const char *line AND int count) +{ + register const char *ptr = line + count; + while (ptr > line) + if (*--ptr == '\n') + return line + count - ptr - 1; + return start + count; +} + +int +DEFUN(_IO_get_column, (fp), + register _IO_FILE *fp) +{ + if (fp->_cur_column) + return _IO_adjust_column(fp->_cur_column - 1, + fp->_IO_write_base, + fp->_IO_write_ptr - fp->_IO_write_base); + return -1; +} + +int +DEFUN_VOID(_IO_flush_all) +{ + int result = 0; + _IO_FILE *fp; + for (fp = _IO_list_all; fp != NULL; fp = fp->_chain) + if (fp->_IO_write_ptr > fp->_IO_write_base + && _IO_OVERFLOW (fp, EOF) == EOF) + result = EOF; + return result; +} + +void +DEFUN_VOID(_IO_flush_all_linebuffered) +{ + _IO_FILE *fp; + for (fp = _IO_list_all; fp != NULL; fp = fp->_chain) + if (fp->_flags & _IO_LINE_BUF) + _IO_OVERFLOW (fp, EOF); +} + +void +DEFUN_VOID(_IO_unbuffer_all) +{ + _IO_FILE *fp; + for (fp = _IO_list_all; fp != NULL; fp = fp->_chain) + if (! (fp->_flags & _IO_UNBUFFERED)) + _IO_SETBUF (fp, NULL, 0); +} + +void +DEFUN_VOID(_IO_cleanup) +{ + _IO_flush_all (); + + /* We currently don't have a reliable mechanism for making sure that + C++ static destructors are executed in the correct order. + So it is possible that other static destructord might want to + write to cout - and they're supposed to be able to do so. + + The following will make the standard streambufs be unbuffered, + which forces any output from late destructors to be written out. */ + _IO_unbuffer_all (); +} + +void +DEFUN(_IO_init_marker, (marker, fp), + struct _IO_marker *marker AND _IO_FILE *fp) +{ + marker->_sbuf = fp; + if (_IO_in_put_mode(fp)) + _IO_switch_to_get_mode(fp); + if (_IO_in_backup(fp)) + marker->_pos = fp->_IO_read_ptr - fp->_IO_read_end; + else + marker->_pos = fp->_IO_read_ptr - fp->_IO_read_base; + + /* Should perhaps sort the chain? */ + marker->_next = fp->_markers; + fp->_markers = marker; +} + +void +DEFUN(_IO_remove_marker, (marker), + register struct _IO_marker *marker) +{ + /* Unlink from sb's chain. */ + register struct _IO_marker **ptr = &marker->_sbuf->_markers; + for (; ; ptr = &(*ptr)->_next) + { + if (*ptr == NULL) + break; + else if (*ptr == marker) + { + *ptr = marker->_next; + return; + } + } +#if 0 + if _sbuf has a backup area that is no longer needed, should we delete + it now, or wait until the next underflow? +#endif +} + +#define BAD_DELTA EOF + +int +DEFUN(_IO_marker_difference, (mark1, mark2), + struct _IO_marker *mark1 AND struct _IO_marker *mark2) +{ + return mark1->_pos - mark2->_pos; +} + +/* Return difference between MARK and current posistion of MARK's stream. */ +int +DEFUN(_IO_marker_delta, (mark), + struct _IO_marker *mark) +{ + int cur_pos; + if (mark->_sbuf == NULL) + return BAD_DELTA; + if (_IO_in_backup(mark->_sbuf)) + cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_end; + else + cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_base; + return mark->_pos - cur_pos; +} + +int +DEFUN(_IO_seekmark, (fp, mark, delta), + _IO_FILE *fp AND struct _IO_marker *mark AND int delta) +{ + if (mark->_sbuf != fp) + return EOF; + if (mark->_pos >= 0) + { + if (_IO_in_backup(fp)) + _IO_switch_to_main_get_area(fp); + fp->_IO_read_ptr = fp->_IO_read_base + mark->_pos; + } + else + { + if (!_IO_in_backup(fp)) + _IO_switch_to_backup_area(fp); + fp->_IO_read_ptr = fp->_IO_read_end + mark->_pos; + } + return 0; +} + +void +DEFUN(_IO_unsave_markers, (fp), + register _IO_FILE *fp) +{ + register struct _IO_marker *mark = fp->_markers; + if (mark) + { +#ifdef TODO + streampos offset = seekoff(0, ios::cur, ios::in); + if (offset != EOF) + { + offset += eGptr() - Gbase(); + for ( ; mark != NULL; mark = mark->_next) + mark->set_streampos(mark->_pos + offset); + } + else + { + for ( ; mark != NULL; mark = mark->_next) + mark->set_streampos(EOF); + } +#endif + fp->_markers = 0; + } + + if (_IO_have_backup(fp)) + _IO_free_backup_area(fp); +} + +int +DEFUN(_IO_nobackup_pbackfail, (fp, c), + register _IO_FILE *fp AND int c) +{ + if (fp->_IO_read_ptr > fp->_IO_read_base) + fp->_IO_read_ptr--; + if (c != EOF && *fp->_IO_read_ptr != c) + *fp->_IO_read_ptr = c; + return (unsigned char)c; +} + +int +DEFUN(_IO_default_pbackfail, (fp, c), + register _IO_FILE *fp AND int c) +{ + if (fp->_IO_read_ptr <= fp->_IO_read_base) + { + /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/ + if (_IO_have_backup(fp) && !_IO_in_backup(fp)) + _IO_switch_to_backup_area(fp); + + if (!_IO_have_backup(fp)) + { + /* No backup buffer: allocate one. */ + /* Use nshort buffer, if unused? (probably not) FIXME */ + int backup_size = 128; + char *bbuf = (char*)malloc(backup_size); + if (bbuf == NULL) + return EOF; + fp->_IO_save_base = bbuf; + fp->_IO_save_end = fp->_IO_save_base + backup_size; + fp->_IO_backup_base = fp->_IO_save_end; + _IO_switch_to_backup_area(fp); + } + else if (fp->_IO_read_ptr <= fp->_IO_read_base) + { + /* Increase size of existing backup buffer. */ + _IO_size_t new_size; + _IO_size_t old_size = fp->_IO_read_end - fp->_IO_read_base; + char *new_buf; + new_size = 2 * old_size; + new_buf = (char*)malloc(new_size); + if (new_buf == NULL) + return EOF; + memcpy(new_buf+(new_size-old_size), fp->_IO_read_base, old_size); + free (fp->_IO_read_base); + _IO_setg(fp, + new_buf, new_buf+(new_size-old_size), new_buf+new_size); + fp->_IO_backup_base = fp->_IO_read_ptr; + } + } + fp->_IO_read_ptr--; + if (c != EOF && *fp->_IO_read_ptr != c) + *fp->_IO_read_ptr = c; + return (unsigned char)*fp->_IO_read_ptr; +} + +_IO_pos_t +DEFUN(_IO_default_seek, (fp, offset, dir), + _IO_FILE *fp AND _IO_off_t offset AND int dir) +{ + return _IO_pos_BAD; +} + +int +DEFUN(_IO_default_stat, (fp, st), + _IO_FILE *fp AND void* st) +{ + return EOF; +} + +_IO_ssize_t +DEFUN(_IO_default_read, (fp, data, n), + register _IO_FILE* fp AND void* data AND _IO_ssize_t n) +{ + return -1; +} + +_IO_ssize_t +DEFUN(_IO_default_write, (fp, data, n), + register _IO_FILE* fp AND const void* data AND _IO_ssize_t n) +{ + return 0; +} + + +#ifdef TODO +#if defined(linux) +#define IO_CLEANUP ; +#endif + +#ifdef IO_CLEANUP + IO_CLEANUP +#else +struct __io_defs { + __io_defs() { } + ~__io_defs() { _IO_cleanup(); } +}; +__io_defs io_defs__; +#endif + +#endif /* TODO */ diff --git a/libio/indstream.cc b/libio/indstream.cc new file mode 100644 index 000000000000..15a1bb2778d3 --- /dev/null +++ b/libio/indstream.cc @@ -0,0 +1,121 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +indirectbuf::indirectbuf(streambuf *get, streambuf *put, int delete_mode) +: streambuf() +{ + _get_stream = get; + _put_stream = put == NULL ? get : put; + _delete_flags = delete_mode; +} + +indirectbuf::~indirectbuf() +{ + if (_delete_flags & ios::in) delete get_stream(); + if (_delete_flags & ios::out) delete put_stream(); +} + +streamsize indirectbuf::xsputn(const char* s, streamsize n) +{ + return put_stream()->sputn(s, n); +} + +streamsize indirectbuf::xsgetn(char* s, streamsize n) +{ + return get_stream()->sgetn(s, n); +} + +int indirectbuf::overflow(int c /* = EOF */) +{ + if (c == EOF) + return put_stream()->overflow(c); + else + return put_stream()->sputc(c); +} + +int indirectbuf::underflow() +{ + return get_stream()->sgetc(); +} + +int indirectbuf::uflow() +{ + return get_stream()->sbumpc(); +} + +streampos indirectbuf::seekoff(streamoff off, _seek_dir dir, int mode) +{ + int ret_val = 0; + int select = mode == 0 ? (ios::in|ios::out) : mode; + streambuf *gbuf = (select & ios::in) ? get_stream() : (streambuf*)NULL; + streambuf *pbuf = (select & ios::out) ? put_stream() : (streambuf*)NULL; + if (gbuf == pbuf) + ret_val = gbuf->seekoff(off, dir, mode); + else { + if (gbuf) + ret_val = gbuf->seekoff(off, dir, ios::in); + if (pbuf && ret_val != EOF) + ret_val = pbuf->seekoff(off, dir, ios::out); + } + return ret_val; +} + +streampos indirectbuf::seekpos(streampos pos, int mode) +{ + int ret_val = EOF; + int select = mode == 0 ? (ios::in|ios::out) : mode; + streambuf *gbuf = (select & ios::in) ? get_stream() : (streambuf*)NULL; + streambuf *pbuf = (select & ios::out) ? put_stream() : (streambuf*)NULL; + if (gbuf == pbuf && gbuf != NULL) + ret_val = gbuf->seekpos(pos, mode); + else { + if (gbuf) + ret_val = gbuf->seekpos(pos, ios::in); + if (pbuf && ret_val != EOF) + ret_val = pbuf->seekpos(pos, ios::out); + } + return ret_val; +} + +int indirectbuf::sync() +{ + streambuf *gbuf = get_stream(); + int get_ret_val = gbuf ? gbuf->sync() : 0; + streambuf *pbuf = put_stream(); + int put_ret_val = (pbuf && pbuf != gbuf) ? pbuf->sync() : 0; + return get_ret_val || put_ret_val; +} + +int indirectbuf::pbackfail(int c) +{ + return get_stream()->sputbackc(c); +} diff --git a/libio/indstream.h b/libio/indstream.h new file mode 100644 index 000000000000..c4558623d079 --- /dev/null +++ b/libio/indstream.h @@ -0,0 +1,77 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#ifndef _INDSTREAM_H +#define _INDSTREAM_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include + +extern "C++" { +// An indirectbuf is one that forwards all of its I/O requests +// to another streambuf. +// All get-related requests are sent to get_stream(). +// All put-related requests are sent to put_stream(). + +// An indirectbuf can be used to implement Common Lisp +// synonym-streams and two-way-streams. +// +// class synonymbuf : public indirectbuf { +// Symbol *sym; +// synonymbuf(Symbol *s) { sym = s; } +// virtual streambuf *lookup_stream(int mode) { +// return coerce_to_streambuf(lookup_value(sym)); } +// }; + +class indirectbuf : public streambuf { + protected: + streambuf *_get_stream; // Optional cache for get_stream(). + streambuf *_put_stream; // Optional cache for put_stream(). + int _delete_flags; + public: + streambuf *get_stream() + { return _get_stream ? _get_stream : lookup_stream(ios::in); } + streambuf *put_stream() + { return _put_stream ? _put_stream : lookup_stream(ios::out); } + virtual streambuf *lookup_stream(int/*mode*/) { return NULL; } // ERROR! + indirectbuf(streambuf *get=NULL, streambuf *put=NULL, int delete_mode=0); + virtual ~indirectbuf(); + virtual streamsize xsputn(const char* s, streamsize n); + virtual streamsize xsgetn(char* s, streamsize n); + virtual int underflow(); + virtual int uflow(); + virtual int overflow(int c = EOF); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); + virtual int sync(); + virtual int pbackfail(int c); +}; +} // extern "C++" + +#endif /* !_INDSTREAM_H */ diff --git a/libio/ioassign.cc b/libio/ioassign.cc new file mode 100644 index 000000000000..5b8e68bbf539 --- /dev/null +++ b/libio/ioassign.cc @@ -0,0 +1,49 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#include +#include "libioP.h" + +// These method are provided for backward compatibility reasons. +// It's generally poor style to use them. +// They are not supported by the ANSI/ISO working paper. + +_IO_istream_withassign& _IO_istream_withassign::operator=(istream& rhs) +{ + if (&rhs != (istream*)this) + { + init (rhs.rdbuf ()); + _gcount = 0; + } + return *this; +} + +_IO_ostream_withassign& _IO_ostream_withassign::operator=(ostream& rhs) +{ + if (&rhs != (ostream*)this) + init (rhs.rdbuf ()); + return *this; +} diff --git a/libio/ioextend.cc b/libio/ioextend.cc new file mode 100644 index 000000000000..a31ff36e6e58 --- /dev/null +++ b/libio/ioextend.cc @@ -0,0 +1,132 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include + +static int __xalloc = 0; + +int ios::xalloc() +{ + return __xalloc++; +} + +static ios::fmtflags __used_fmt_flags += ios::skipws | ios::left | ios::right | ios::internal +| ios::dec | ios::oct | ios::hex | ios::showbase | ios::showpoint +| ios::uppercase | ios::showpos | ios::scientific | ios::fixed +#ifndef _IO_NEW_STREAMS +| ios::dont_close +#endif +| ios::unitbuf | ios::stdio; + +ios::fmtflags ios::bitalloc() +{ + fmtflags bit_to_try = (fmtflags)1; + for (; bit_to_try; bit_to_try <<= 1) + { + if ((__used_fmt_flags & bit_to_try) == 0) + { + __used_fmt_flags |= bit_to_try; + return bit_to_try; + } + } + return 0; +} + +// NOTE: This implementation of ios::iword and ios::pword assumes +// that these methods are seldom used, so we want to minimize +// the space and time overhead when NOT using these methods. +// +// ANSI specifies two conceptually-infinite arrays, one whose +// elements are longs, and one whose elements are (void*)s. +// We implement this as a single array, each of whose element is +// a (struct ptr_and_long), which has space for both a long and a void*. +// We also specify that (the i field of) the 0'th element of the array +// contains the allocated length of the array (not counting that +// initial element). + +struct ptr_and_long { + void *p; + long i; +}; + +static struct ptr_and_long& +get_array_element(ios& io, int index) +{ + if (index < 0) + io._throw_failure(); + register struct ptr_and_long *array = (ptr_and_long*)io._arrays; + int old_length = array == NULL ? 0 : array[0].i; + if (index >= old_length) + { + register int i; + int new_length = index + 10; + register struct ptr_and_long *new_array + = new ptr_and_long[1 + new_length]; + if (array != NULL) + { + for (i = 1; i <= old_length; i++) + new_array[i] = array[i]; + delete [] array; + } + for (i = old_length + 1; i <= new_length; i++) + { + new_array[i].i = 0; + new_array[i].p = NULL; + } + new_array[0].i = new_length; + new_array[0].p = NULL; + io._arrays = (void*)new_array; + array = new_array; + } + return array[index+1]; +} + +long& ios::iword(int index) +{ + return get_array_element(*this, index).i; +} + +void*& ios::pword(int index) +{ + return get_array_element(*this, index).p; +} + +long ios::iword(int index) const +{ + if (index < 0) + _throw_failure(); + register struct ptr_and_long *pl_array = (ptr_and_long*)_arrays; + int len = pl_array == NULL ? 0 : pl_array[0].i; + return index >= len ? 0 : pl_array[index+1].i; +} + +void* ios::pword(int index) const +{ + if (index < 0) + _throw_failure(); + register struct ptr_and_long *pl_array = (ptr_and_long*)_arrays; + int len = pl_array == NULL ? 0 : pl_array[0].i; + return index >= len ? 0 : pl_array[index+1].p; +} diff --git a/libio/iofclose.c b/libio/iofclose.c new file mode 100644 index 000000000000..f3ae0964e826 --- /dev/null +++ b/libio/iofclose.c @@ -0,0 +1,47 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#ifdef __STDC__ +#include +#endif + +int +DEFUN(_IO_fclose, (fp), + register _IO_FILE *fp) +{ + int status; + CHECK_FILE(fp, EOF); + if (fp->_IO_file_flags & _IO_IS_FILEBUF) + status = _IO_file_close_it(fp); + else + status = fp->_flags & _IO_ERR_SEEN ? -1 : 0; + _IO_FINISH (fp); + if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr) + { + fp->_IO_file_flags = 0; + free(fp); + } + return status; +} diff --git a/libio/iofdopen.c b/libio/iofdopen.c new file mode 100644 index 000000000000..f8bc76869ad9 --- /dev/null +++ b/libio/iofdopen.c @@ -0,0 +1,121 @@ +/* +Copyright (C) 1993, 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifdef __STDC__ +#include +#endif +#include "libioP.h" +#include + +#ifndef _IO_fcntl +#define _IO_fcntl fcntl +#endif + +_IO_FILE * +DEFUN(_IO_fdopen, (fd, mode), + int fd AND const char *mode) +{ + int read_write; + int posix_mode = 0; + struct _IO_FILE_plus *fp; + int fd_flags; + + switch (*mode++) + { + case 'r': + read_write = _IO_NO_WRITES; + break; + case 'w': + read_write = _IO_NO_READS; + break; + case 'a': + posix_mode = O_APPEND; + read_write = _IO_NO_READS|_IO_IS_APPENDING; + break; + default: +#ifdef EINVAL + errno = EINVAL; +#endif + return NULL; + } + if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) + read_write &= _IO_IS_APPENDING; +#ifdef F_GETFL + fd_flags = _IO_fcntl (fd, F_GETFL); +#ifndef O_ACCMODE +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + if (fd_flags == -1 + || ((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES)) + || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS))) + return NULL; + + /* The May 93 draft of P1003.4/D14.1 (redesignated as 1003.1b) + [System Application Program Interface (API) Amendment 1: + Realtime Extensions], Rationale B.8.3.3 + Open a Stream on a File Descriptor says: + + Although not explicitly required by POSIX.1, a good + implementation of append ("a") mode would cause the + O_APPEND flag to be set. + + (Historical implementations [such as Solaris2] do a one-time + seek in fdopen.) + + However, we do not turn O_APPEND off if the mode is "w" (even + though that would seem consistent) because that would be more + likely to break historical programs. + */ + if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND)) + { +#ifdef F_SETFL + if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1) +#endif + return NULL; + } +#endif + + fp = (struct _IO_FILE_plus*)malloc(sizeof(struct _IO_FILE_plus)); + if (fp == NULL) + return NULL; + _IO_init(&fp->file, 0); + _IO_JUMPS(&fp->file) = &_IO_file_jumps; + _IO_file_init(&fp->file); +#if !_IO_UNIFIED_JUMPTABLES + fp->vtable = NULL; +#endif + if (_IO_file_attach(&fp->file, fd) == NULL) + { + _IO_un_link(&fp->file); + free (fp); + return NULL; + } + fp->file._flags &= ~_IO_DELETE_DONT_CLOSE; + + fp->file._IO_file_flags = + _IO_mask_flags(&fp->file, read_write, + _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); + + return (_IO_FILE*)fp; +} diff --git a/libio/iofflush.c b/libio/iofflush.c new file mode 100644 index 000000000000..ecb816d41986 --- /dev/null +++ b/libio/iofflush.c @@ -0,0 +1,38 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +int +DEFUN(_IO_fflush, (fp), + register _IO_FILE *fp) +{ + if (fp == NULL) + return _IO_flush_all(); + else + { + CHECK_FILE(fp, EOF); + return _IO_SYNC (fp) ? EOF : 0; + } +} diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c new file mode 100644 index 000000000000..5e7a8632102a --- /dev/null +++ b/libio/iofgetpos.c @@ -0,0 +1,46 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include +/* ANSI explicily requires setting errno to a positive value on failure. */ + +int +DEFUN(_IO_fgetpos, (fp, posp), + _IO_FILE* fp AND _IO_fpos_t *posp) +{ + _IO_fpos_t pos; + CHECK_FILE(fp, EOF); + pos = _IO_seekoff(fp, 0, _IO_seek_cur, 0); + if (pos == _IO_pos_BAD) + { +#ifdef EIO + if (errno == 0) + errno = EIO; +#endif + return EOF; + } + *posp = pos; + return 0; +} diff --git a/libio/iofgets.c b/libio/iofgets.c new file mode 100644 index 000000000000..7b0b708a2083 --- /dev/null +++ b/libio/iofgets.c @@ -0,0 +1,40 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +char* +DEFUN(_IO_fgets, (buf, n, fp), + char* buf AND int n AND _IO_FILE* fp) +{ + _IO_size_t count; + CHECK_FILE(fp, NULL); + if (n <= 0) + return NULL; + count = _IO_getline(fp, buf, n - 1, '\n', 1); + if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN)) + return NULL; + buf[count] = 0; + return buf; +} diff --git a/libio/iofopen.c b/libio/iofopen.c new file mode 100644 index 000000000000..96910520ce73 --- /dev/null +++ b/libio/iofopen.c @@ -0,0 +1,49 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#ifdef __STDC__ +#include +#endif + +_IO_FILE * +DEFUN(_IO_fopen, (filename, mode), + const char *filename AND const char *mode) +{ + struct _IO_FILE_plus *fp = + (struct _IO_FILE_plus*)malloc(sizeof(struct _IO_FILE_plus)); + if (fp == NULL) + return NULL; + _IO_init(&fp->file, 0); + _IO_JUMPS(&fp->file) = &_IO_file_jumps; + _IO_file_init(&fp->file); +#if !_IO_UNIFIED_JUMPTABLES + fp->vtable = NULL; +#endif + if (_IO_file_fopen(&fp->file, filename, mode) != NULL) + return (_IO_FILE*)fp; + _IO_un_link(&fp->file); + free (fp); + return NULL; +} diff --git a/libio/iofprintf.c b/libio/iofprintf.c new file mode 100644 index 000000000000..11c76421809f --- /dev/null +++ b/libio/iofprintf.c @@ -0,0 +1,48 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +_IO_fprintf +#ifdef __STDC__ + (_IO_FILE *fp, const char* format, ...) +#else +(fp, format, va_alist) _IO_FILE *fp; char *format; va_dcl +#endif +{ + int ret; + va_list args; + CHECK_FILE(fp, -1); + _IO_va_start(args, format); + ret = _IO_vfprintf(fp, format, args); + va_end(args); + return ret; +} diff --git a/libio/iofputs.c b/libio/iofputs.c new file mode 100644 index 000000000000..7a2580f7e356 --- /dev/null +++ b/libio/iofputs.c @@ -0,0 +1,37 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include + +int +DEFUN(_IO_fputs, (str, fp), + const char *str AND _IO_FILE *fp) +{ + _IO_size_t len = strlen(str); + CHECK_FILE(fp, EOF); + if (_IO_sputn(fp, str, len) != len) + return EOF; + return 1; +} diff --git a/libio/iofread.c b/libio/iofread.c new file mode 100644 index 000000000000..8516cf30c147 --- /dev/null +++ b/libio/iofread.c @@ -0,0 +1,38 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +_IO_size_t +DEFUN(_IO_fread, (buf, size, count, fp), + void *buf AND _IO_size_t size AND _IO_size_t count AND _IO_FILE* fp) +{ + _IO_size_t bytes_requested = size*count; + _IO_size_t bytes_read; + CHECK_FILE(fp, 0); + if (bytes_requested == 0) + return 0; + bytes_read = _IO_sgetn(fp, (char *)buf, bytes_requested); + return bytes_requested == bytes_read ? count : bytes_read / size; +} diff --git a/libio/iofscanf.c b/libio/iofscanf.c new file mode 100644 index 000000000000..3e12d9b5315c --- /dev/null +++ b/libio/iofscanf.c @@ -0,0 +1,48 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +_IO_fscanf +#ifdef __STDC__ + (_IO_FILE *fp, const char* format, ...) +#else +(fp, format, va_alist) _IO_FILE *fp; char *format; va_dcl +#endif +{ + int ret; + va_list args; + CHECK_FILE(fp, EOF); + _IO_va_start(args, format); + ret = _IO_vfscanf(fp, format, args, NULL); + va_end(args); + return ret; +} diff --git a/libio/iofsetpos.c b/libio/iofsetpos.c new file mode 100644 index 000000000000..ac8a3deb12d1 --- /dev/null +++ b/libio/iofsetpos.c @@ -0,0 +1,43 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include +#include + +int +DEFUN(_IO_fsetpos, (fp, posp), + _IO_FILE* fp AND const _IO_fpos_t *posp) +{ + CHECK_FILE(fp, EOF); + if (_IO_seekpos(fp, *posp, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD) + { + /*ANSI explicily requires setting errno to a positive value on failure.*/ +#ifdef EIO + if (errno == 0) + errno = EIO; +#endif + return EOF; + } + return 0; +} diff --git a/libio/ioftell.c b/libio/ioftell.c new file mode 100644 index 000000000000..d49ddaac8213 --- /dev/null +++ b/libio/ioftell.c @@ -0,0 +1,45 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include +/* ANSI explicily requires setting errno to a positive value on failure. */ + +long int +DEFUN(_IO_ftell, (fp), + _IO_FILE* fp) +{ + _IO_pos_t pos; + CHECK_FILE(fp, -1L); + pos = _IO_seekoff(fp, 0, _IO_seek_cur, 0); + if (pos == _IO_pos_BAD) + { +#ifdef EIO + if (errno == 0) + errno = EIO; +#endif + return -1L; + } + return _IO_pos_as_off(pos); +} diff --git a/libio/iofwrite.c b/libio/iofwrite.c new file mode 100644 index 000000000000..eb3cd32b028a --- /dev/null +++ b/libio/iofwrite.c @@ -0,0 +1,44 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +_IO_size_t +DEFUN(_IO_fwrite, (buf, size, count, fp), + const void* buf AND _IO_size_t size AND _IO_size_t count + AND _IO_FILE *fp) +{ + _IO_size_t request = size*count; + _IO_size_t written; + CHECK_FILE(fp, 0); + if (request == 0) + return 0; + written = _IO_sputn(fp, (const char *)buf, request); + /* Many traditional implementations return 0 if size==0 && count > 0, + but ANSI seems to require us to return count in this case. */ + if (written == request) + return count; + else + return written/size; +} diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c new file mode 100644 index 000000000000..ee6c0bf1f197 --- /dev/null +++ b/libio/iogetdelim.c @@ -0,0 +1,99 @@ +/* +Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifdef __STDC__ +#include +#endif +#include "libioP.h" +#include +#include + +/* Read up to (and including) a TERMINATOR from FP into *LINEPTR + (and null-terminate it). *LINEPTR is a pointer returned from malloc (or + NULL), pointing to *N characters of space. It is realloc'ed as + necessary. Returns the number of characters read (not including the + null terminator), or -1 on error or EOF. */ + +_IO_ssize_t +DEFUN(_IO_getdelim, (lineptr, n, delimiter, fp), + char **lineptr AND _IO_size_t *n AND int delimiter AND _IO_FILE *fp) +{ + register _IO_ssize_t cur_len = 0; + _IO_ssize_t len; + + if (lineptr == NULL || n == NULL) + { +#ifdef EINVAL + errno = EINVAL; +#endif + return -1; + } + CHECK_FILE (fp, -1); + if (_IO_ferror (fp)) + return -1; + + if (*lineptr == NULL || *n == 0) + { + *n = 120; + *lineptr = (char *) malloc (*n); + if (*lineptr == NULL) + return -1; + } + + len = fp->_IO_read_end - fp->_IO_read_ptr; + if (len <= 0) + { + if (__underflow (fp) == EOF) + return -1; + len = fp->_IO_read_end - fp->_IO_read_ptr; + } + + for (;;) + { + _IO_size_t needed; + char *t; + t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len); + if (t != NULL) + len = (t - fp->_IO_read_ptr) + 1; + /* make enough space for len+1 (for final NUL) bytes. */ + needed = cur_len + len + 1; + if (needed > *n) + { + if (t == NULL && needed < 2 * *n) + needed = 2 * *n; /* Be generous. */ + *n = needed; + *lineptr = (char *) realloc (*lineptr, needed); + if (*lineptr == NULL) + return -1; + } + memcpy (*lineptr + cur_len, (void *) fp->_IO_read_ptr, len); + fp->_IO_read_ptr += len; + cur_len += len; + if (t != NULL || __underflow (fp) == EOF) + break; + len = fp->_IO_read_end - fp->_IO_read_ptr; + } + (*lineptr)[cur_len] = '\0'; + return cur_len; +} diff --git a/libio/iogetline.c b/libio/iogetline.c new file mode 100644 index 000000000000..278905d135d3 --- /dev/null +++ b/libio/iogetline.c @@ -0,0 +1,74 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include + +/* Algorithm based on that used by Berkeley pre-4.4 fgets implementation. + + Read chars into buf (of size n), until delim is seen. + Return number of chars read (at most n). + Does not put a terminating '\0' in buf. + If extract_delim < 0, leave delimiter unread. + If extract_delim > 0, insert delim in output. */ + +_IO_size_t +DEFUN(_IO_getline, (fp, buf, n, delim, extract_delim), + _IO_FILE *fp AND char* buf AND _IO_size_t n + AND int delim AND int extract_delim) +{ + register char *ptr = buf; + do + { + _IO_ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr; + char *t; + if (len <= 0) + if (__underflow(fp) == EOF) + break; + else + len = fp->_IO_read_end - fp->_IO_read_ptr; + if (len >= n) + len = n; + t = (char*)memchr((void*)fp->_IO_read_ptr, delim, len); + if (t != NULL) + { + _IO_size_t old_len = ptr-buf; + len = t - fp->_IO_read_ptr; + if (extract_delim >= 0) + { + t++; + if (extract_delim > 0) + len++; + } + memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len); + fp->_IO_read_ptr = t; + return old_len + len; + } + memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len); + fp->_IO_read_ptr += len; + ptr += len; + n -= len; + } while (n != 0); + return ptr - buf; +} diff --git a/libio/iogets.c b/libio/iogets.c new file mode 100644 index 000000000000..f45d9c16e3fd --- /dev/null +++ b/libio/iogets.c @@ -0,0 +1,47 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include + +char* +DEFUN(_IO_gets, (buf), + char* buf) +{ + _IO_size_t count; + int ch = _IO_getc (_IO_stdin); + if (ch == EOF) + return NULL; + if (ch == '\n') + count = 0; + else + { + buf[0] = (char)ch; + count = _IO_getline(_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1; + if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN) + return NULL; + } + buf[count] = 0; + return buf; +} diff --git a/libio/ioignore.c b/libio/ioignore.c new file mode 100644 index 000000000000..a7c2f286755f --- /dev/null +++ b/libio/ioignore.c @@ -0,0 +1,46 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +int +DEFUN(_IO_ignore, (fp, n), + register _IO_FILE *fp AND _IO_size_t n) +{ + register _IO_size_t more = n; + for (;;) + { + _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; + if (count > 0) + { + if (count > more) + count = more; + fp->_IO_read_ptr += count; + more -= count; + } + if (more == 0 || __underflow(fp) == EOF) + break; + } + return n - more; +} diff --git a/libio/iolibio.h b/libio/iolibio.h new file mode 100644 index 000000000000..e5de77ea85c3 --- /dev/null +++ b/libio/iolibio.h @@ -0,0 +1,53 @@ +#include "libio.h" + +/* These emulate stdio functionality, but with a different name + (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int _IO_fclose __P((_IO_FILE*)); +extern _IO_FILE *_IO_fdopen __P((int, const char*)); +extern int _IO_fflush __P((_IO_FILE*)); +extern int _IO_fgetpos __P((_IO_FILE*, _IO_fpos_t*)); +extern char* _IO_fgets __P((char*, int, _IO_FILE*)); +extern _IO_FILE *_IO_fopen __P((const char*, const char*)); +extern int _IO_fprintf __P((_IO_FILE*, const char*, ...)); +extern int _IO_fputs __P((const char*, _IO_FILE*)); +extern int _IO_fsetpos __P((_IO_FILE*, const _IO_fpos_t *)); +extern long int _IO_ftell __P((_IO_FILE*)); +extern _IO_size_t _IO_fread __P((void*, _IO_size_t, _IO_size_t, _IO_FILE*)); +extern _IO_size_t _IO_fwrite __P((const void*, + _IO_size_t, _IO_size_t, _IO_FILE*)); +extern char* _IO_gets __P((char*)); +extern void _IO_perror __P((const char*)); +extern int _IO_printf __P((const char*, ...)); +extern int _IO_puts __P((const char*)); +extern int _IO_scanf __P((const char*, ...)); +extern void _IO_setbuffer __P((_IO_FILE *, char*, _IO_size_t)); +extern int _IO_setvbuf __P((_IO_FILE*, char*, int, _IO_size_t)); +extern int _IO_sscanf __P((const char*, const char*, ...)); +extern int _IO_sprintf __P((char *, const char*, ...)); +extern int _IO_ungetc __P((int, _IO_FILE*)); +extern int _IO_vsscanf __P((const char *, const char *, _IO_va_list)); +extern int _IO_vsprintf __P((char*, const char*, _IO_va_list)); +#ifndef _IO_pos_BAD +#define _IO_pos_BAD ((_IO_fpos_t)(-1)) +#endif +#define _IO_clearerr(FP) ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN)) +#define _IO_fseek(__fp, __offset, __whence) \ + (_IO_seekoff(__fp, __offset, __whence, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD ? EOF : 0) +#define _IO_rewind(FILE) (void)_IO_seekoff(FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT) +#define _IO_vprintf(FORMAT, ARGS) _IO_vfprintf(_IO_stdout, FORMAT, ARGS) +#define _IO_freopen(FILENAME, MODE, FP) \ + (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE)) +#define _IO_fileno(FP) ((FP)->_fileno) +extern _IO_FILE* _IO_popen __P((const char*, const char*)); +#define _IO_pclose _IO_fclose +#define _IO_setbuf(_FP, _BUF) _IO_setbuffer(_FP, _BUF, _IO_BUFSIZ) +#define _IO_setlinebuf(_FP) _IO_setvbuf(_FP, NULL, 1, 0) + +#ifdef __cplusplus +} +#endif diff --git a/libio/iomanip.cc b/libio/iomanip.cc new file mode 100644 index 000000000000..fddba55a2b98 --- /dev/null +++ b/libio/iomanip.cc @@ -0,0 +1,90 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "iomanip.h" + + +// Those functions are called through a pointer, +// thus it does not make sense, to inline them. + +ios & __iomanip_setbase (ios& i, int n) +{ + ios::fmtflags b; + switch (n) + { + case 8: + b = ios::oct; break; + case 10: + b = ios::dec; break; + case 16: + b = ios::hex; break; + default: + b = 0; + } + i.setf(b, ios::basefield); + return i; +} + +ios & __iomanip_setfill (ios& i, int n) +{ + //FIXME if ( i.flags() & ios::widechar ) + i.fill( (char) n); + //FIXME else + //FIXME i.fill( (wchar) n); + return i; +} + +ios & __iomanip_setprecision (ios& i, int n) +{ + i.precision(n); + return i; +} +ios & __iomanip_setw (ios& i, int n) +{ + i.width(n); + return i; +} + +ios & __iomanip_setiosflags (ios& i, ios::fmtflags n) +{ + i.setf(n,n); + return i; +} + +ios & __iomanip_resetiosflags (ios& i, ios::fmtflags n) +{ + i.setf(0,n); + return i; +} + +template class smanip; +template class smanip; +template istream& operator>>(istream&, const smanip&); +template istream& operator>>(istream&, const smanip&); +template ostream& operator<<(ostream&, const smanip&); +template ostream& operator<<(ostream&, const smanip&); diff --git a/libio/iomanip.h b/libio/iomanip.h new file mode 100644 index 000000000000..fe1156569b47 --- /dev/null +++ b/libio/iomanip.h @@ -0,0 +1,165 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifndef _IOMANIP_H +#ifdef __GNUG__ +#pragma interface +#endif +#define _IOMANIP_H + +#include + +extern "C++" { +//----------------------------------------------------------------------------- +// Parametrized Manipulators as specified by ANSI draft +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Stream Manipulators +//----------------------------------------------------------------------------- +// +template class smanip; // TP = Type Param + +template class sapp { + ios& (*_f)(ios&, TP); +public: + sapp(ios& (*f)(ios&, TP)) : _f(f) {} + // + smanip operator()(TP a) + { return smanip(_f, a); } +}; + +template class smanip { + ios& (*_f)(ios&, TP); + TP _a; +public: + smanip(ios& (*f)(ios&, TP), TP a) : _f(f), _a(a) {} + // + friend + istream& operator>>(istream& i, const smanip& m); + friend + ostream& operator<<(ostream& o, const smanip& m); +}; + +#ifdef __GNUG__ +extern template class smanip; +extern template class smanip; +#endif + +template +inline istream& operator>>(istream& i, const smanip& m) +{ (*m._f)(i, m._a); return i; } + +template +inline ostream& operator<<(ostream& o, const smanip& m) +{ (*m._f)(o, m._a); return o;} + +#ifdef __GNUG__ +extern template istream& operator>>(istream&, const smanip&); +extern template istream& operator>>(istream&, const smanip&); +extern template ostream& operator<<(ostream&, const smanip&); +extern template ostream& operator<<(ostream&, const smanip&); +#endif + +//----------------------------------------------------------------------------- +// Input-Stream Manipulators +//----------------------------------------------------------------------------- +// +template class imanip; + +template class iapp { + istream& (*_f)(istream&, TP); +public: + iapp(istream& (*f)(istream&,TP)) : _f(f) {} + // + imanip operator()(TP a) + { return imanip(_f, a); } +}; + +template class imanip { + istream& (*_f)(istream&, TP); + TP _a; +public: + imanip(istream& (*f)(istream&, TP), TP a) : _f(f), _a(a) {} + // + friend + istream& operator>>(istream& i, const imanip& m); +}; + +template +inline istream& operator>>(istream& i, const imanip& m) +{ return (*m._f)( i, m._a); } + +//----------------------------------------------------------------------------- +// Output-Stream Manipulators +//----------------------------------------------------------------------------- +// +template class omanip; + +template class oapp { + ostream& (*_f)(ostream&, TP); +public: + oapp(ostream& (*f)(ostream&,TP)) : _f(f) {} + // + omanip operator()(TP a) + { return omanip(_f, a); } +}; + +template class omanip { + ostream& (*_f)(ostream&, TP); + TP _a; +public: + omanip(ostream& (*f)(ostream&, TP), TP a) : _f(f), _a(a) {} + // + friend + ostream& operator<<(ostream& o, const omanip& m); +}; + +template +inline ostream& operator<<(ostream& o, const omanip& m) +{ return (*m._f)(o, m._a); } + +//----------------------------------------------------------------------------- +// Available Manipulators +//----------------------------------------------------------------------------- + +// +// Macro to define an iomanip function, with one argument +// The underlying function is `__iomanip_' +// +#define __DEFINE_IOMANIP_FN1(type,param,function) \ + extern ios& __iomanip_##function (ios&, param); \ + inline type function (param n) \ + { return type (__iomanip_##function, n); } + +__DEFINE_IOMANIP_FN1( smanip, int, setbase) +__DEFINE_IOMANIP_FN1( smanip, int, setfill) +__DEFINE_IOMANIP_FN1( smanip, int, setprecision) +__DEFINE_IOMANIP_FN1( smanip, int, setw) + +__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, resetiosflags) +__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, setiosflags) +} // extern "C++" + +#endif /*!_IOMANIP_H*/ diff --git a/libio/iopadn.c b/libio/iopadn.c new file mode 100644 index 000000000000..0e502b712c3b --- /dev/null +++ b/libio/iopadn.c @@ -0,0 +1,65 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#define PADSIZE 16 +static char const blanks[PADSIZE] = +{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; +static char const zeroes[PADSIZE] = +{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; + +_IO_ssize_t +DEFUN(_IO_padn, (fp, pad, count), + _IO_FILE *fp AND int pad AND _IO_ssize_t count) +{ + char padbuf[PADSIZE]; + const char *padptr; + register int i; + _IO_size_t written = 0, w; + + if (pad == ' ') + padptr = blanks; + else if (pad == '0') + padptr = zeroes; + else + { + for (i = PADSIZE; --i >= 0; ) padbuf[i] = pad; + padptr = padbuf; + } + for (i = count; i >= PADSIZE; i -= PADSIZE) + { + w = _IO_sputn(fp, padptr, PADSIZE); + written += w; + if (w != PADSIZE) + return written; + } + + if (i > 0) + { + w = _IO_sputn(fp, padptr, i); + written += w; + } + return written; +} diff --git a/libio/ioperror.c b/libio/ioperror.c new file mode 100644 index 000000000000..55d822b63a64 --- /dev/null +++ b/libio/ioperror.c @@ -0,0 +1,22 @@ +#include "libioP.h" +#include +#include +#ifndef errno +extern int errno; +#endif + +#ifndef _IO_strerror +extern char* _IO_strerror __P((int)); +#endif + +void +DEFUN(_IO_perror, (s), + const char *s) +{ + char *error = _IO_strerror (errno); + + if (s != NULL && *s != '\0') + _IO_fprintf (_IO_stderr, "%s:", s); + + _IO_fprintf (_IO_stderr, "%s\n", error ? error : ""); +} diff --git a/libio/iopopen.c b/libio/iopopen.c new file mode 100644 index 000000000000..ef6ad12449f1 --- /dev/null +++ b/libio/iopopen.c @@ -0,0 +1,222 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* written by Per Bothner (bothner@cygnus.com) */ + +#define _POSIX_SOURCE +#include "libioP.h" +#include +#if _IO_HAVE_SYS_WAIT +#include +#include +#ifdef __STDC__ +#include +#endif +#include + +#ifndef _IO_fork +#define _IO_fork vfork /* defined in libiberty, if needed */ +_IO_pid_t _IO_fork(); +#endif + +#endif /* _IO_HAVE_SYS_WAIT */ + +#ifndef _IO_pipe +#define _IO_pipe pipe +extern int _IO_pipe(); +#endif + +#ifndef _IO_dup2 +#define _IO_dup2 dup2 +extern int _IO_dup2(); +#endif + +#ifndef _IO_waitpid +#define _IO_waitpid waitpid +#endif + +#ifndef _IO_execl +#define _IO_execl execl +#endif +#ifndef _IO__exit +#define _IO__exit _exit +#endif + +struct _IO_proc_file +{ + struct _IO_FILE_plus file; + /* Following fields must match those in class procbuf (procbuf.h) */ + _IO_pid_t pid; + struct _IO_proc_file *next; +}; +typedef struct _IO_proc_file _IO_proc_file; + +static struct _IO_proc_file *proc_file_chain = NULL; + +_IO_FILE * +DEFUN(_IO_proc_open, (fp, command, mode), + _IO_FILE* fp AND const char *command AND const char *mode) +{ +#if _IO_HAVE_SYS_WAIT + int read_or_write; + int pipe_fds[2]; + int parent_end, child_end; + _IO_pid_t child_pid; + if (_IO_file_is_open(fp)) + return NULL; + if (_IO_pipe(pipe_fds) < 0) + return NULL; + if (mode[0] == 'r') + { + parent_end = pipe_fds[0]; + child_end = pipe_fds[1]; + read_or_write = _IO_NO_WRITES; + } + else + { + parent_end = pipe_fds[1]; + child_end = pipe_fds[0]; + read_or_write = _IO_NO_READS; + } + ((_IO_proc_file*)fp)->pid = child_pid = _IO_fork(); + if (child_pid == 0) + { + int child_std_end = mode[0] == 'r' ? 1 : 0; + _IO_close(parent_end); + if (child_end != child_std_end) + { + _IO_dup2(child_end, child_std_end); + _IO_close(child_end); + } + /* Posix.2: "popen() shall ensure that any streams from previous + popen() calls that remain open in the parent process are closed + in the new child process." */ + while (proc_file_chain) + { + _IO_close (_IO_fileno ((_IO_FILE *) proc_file_chain)); + proc_file_chain = proc_file_chain->next; + } + + _IO_execl("/bin/sh", "sh", "-c", command, (char *)0); + _IO__exit(127); + } + _IO_close(child_end); + if (child_pid < 0) + { + _IO_close(parent_end); + return NULL; + } + _IO_fileno(fp) = parent_end; + + /* Link into proc_file_chain. */ + ((_IO_proc_file*)fp)->next = proc_file_chain; + proc_file_chain = (_IO_proc_file*)fp; + + _IO_mask_flags (fp, read_or_write, _IO_NO_READS|_IO_NO_WRITES); + return fp; +#else /* !_IO_HAVE_SYS_WAIT */ + return NULL; +#endif +} + +_IO_FILE * +DEFUN(_IO_popen, (command, mode), + const char *command AND const char *mode) +{ + _IO_proc_file *fpx = (_IO_proc_file*)malloc(sizeof(_IO_proc_file)); + _IO_FILE *fp = (_IO_FILE*)fpx; + if (fp == NULL) + return NULL; + _IO_init(fp, 0); + _IO_JUMPS(fp) = &_IO_proc_jumps; + _IO_file_init(fp); +#if !_IO_UNIFIED_JUMPTABLES + ((struct _IO_FILE_plus*)fp)->vtable = NULL; +#endif + if (_IO_proc_open (fp, command, mode) != NULL) + return fp; + free (fpx); + return NULL; +} + +int +DEFUN(_IO_proc_close, (fp), + _IO_FILE *fp) +{ + /* This is not name-space clean. FIXME! */ +#if _IO_HAVE_SYS_WAIT + int wstatus; + _IO_proc_file **ptr = &proc_file_chain; + _IO_pid_t wait_pid; + int status = -1; + + /* Unlink from proc_file_chain. */ + for ( ; *ptr != NULL; ptr = &(*ptr)->next) + { + if (*ptr == (_IO_proc_file*)fp) + { + *ptr = (*ptr)->next; + status = 0; + break; + } + } + + if (status < 0 || _IO_close(_IO_fileno(fp)) < 0) + return -1; + /* POSIX.2 Rationale: "Some historical implementations either block + or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting + for the child process to terminate. Since this behavior is not + described in POSIX.2, such implementations are not conforming." */ + do + { + wait_pid = _IO_waitpid (((_IO_proc_file*)fp)->pid, &wstatus, 0); + } while (wait_pid == -1 && errno == EINTR); + if (wait_pid == -1) + return -1; + return wstatus; +#else /* !_IO_HAVE_SYS_WAIT */ + return -1; +#endif +} + +struct _IO_jump_t _IO_proc_jumps = { + JUMP_INIT_DUMMY, + JUMP_INIT(finish, _IO_file_finish), + JUMP_INIT(overflow, _IO_file_overflow), + JUMP_INIT(underflow, _IO_file_underflow), + JUMP_INIT(uflow, _IO_default_uflow), + JUMP_INIT(pbackfail, _IO_default_pbackfail), + JUMP_INIT(xsputn, _IO_file_xsputn), + JUMP_INIT(xsgetn, _IO_default_xsgetn), + JUMP_INIT(seekoff, _IO_file_seekoff), + JUMP_INIT(seekpos, _IO_default_seekpos), + JUMP_INIT(setbuf, _IO_file_setbuf), + JUMP_INIT(sync, _IO_file_sync), + JUMP_INIT(doallocate, _IO_file_doallocate), + JUMP_INIT(read, _IO_file_read), + JUMP_INIT(write, _IO_file_write), + JUMP_INIT(seek, _IO_file_seek), + JUMP_INIT(close, _IO_proc_close), + JUMP_INIT(stat, _IO_file_stat) +}; diff --git a/libio/ioprims.c b/libio/ioprims.c new file mode 100644 index 000000000000..faa69e0feffd --- /dev/null +++ b/libio/ioprims.c @@ -0,0 +1,72 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* I/O OS-level primitives. + Needs to be replaced if not using Unix. + Also needs to be replaced if avoiding name-space pollution + (in which case read would be defined in terms of _IO_read, + rather than vice versa). */ + +#include "libioP.h" +#include +#include + +#ifdef TODO +/* Add open, isatty */ +#endif + +_IO_ssize_t +DEFUN(_IO_read, (fildes, buf, nbyte), + int fildes AND void *buf AND _IO_size_t nbyte) +{ + return read (fildes, buf, nbyte); +} + +_IO_ssize_t +DEFUN(_IO_write, (fildes, buf, nbyte), + int fildes AND const void *buf AND _IO_size_t nbyte) +{ + return write (fildes, buf, nbyte); +} + +_IO_off_t +DEFUN(_IO_lseek, (fildes, offset, whence), + int fildes AND _IO_off_t offset AND int whence) +{ + return lseek (fildes, offset, whence); +} + +int +DEFUN(_IO_close, (fildes), + int fildes) +{ + return close (fildes); +} + +int +DEFUN(_IO_fstat, (fildes, buf), + int fildes AND struct stat *buf) +{ + return fstat (fildes, buf); +} diff --git a/libio/ioprintf.c b/libio/ioprintf.c new file mode 100644 index 000000000000..0b99c2a6637f --- /dev/null +++ b/libio/ioprintf.c @@ -0,0 +1,47 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +_IO_printf +#ifdef __STDC__ + (const char* format, ...) +#else +(format, va_alist) char *format; va_dcl +#endif +{ + int ret; + va_list args; + _IO_va_start(args, format); + ret = _IO_vfprintf(_IO_stdout, format, args); + va_end(args); + return ret; +} diff --git a/libio/ioputs.c b/libio/ioputs.c new file mode 100644 index 000000000000..f0a81642853d --- /dev/null +++ b/libio/ioputs.c @@ -0,0 +1,38 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include + +int +DEFUN(_IO_puts, (str), + const char *str) +{ + _IO_size_t len = strlen(str); + if (_IO_sputn(_IO_stdout, str, len) != len) + return EOF; + if (_IO_putc('\n', _IO_stdout) == EOF) + return EOF; + return len+1; +} diff --git a/libio/ioscanf.c b/libio/ioscanf.c new file mode 100644 index 000000000000..405d1e2eb0f7 --- /dev/null +++ b/libio/ioscanf.c @@ -0,0 +1,47 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +_IO_scanf +#ifdef __STDC__ + (const char* format, ...) +#else +(format, va_alist) char *format; va_dcl +#endif +{ + int ret; + va_list args; + _IO_va_start(args, format); + ret = _IO_vfscanf(_IO_stdin, format, args, NULL); + va_end(args); + return ret; +} diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c new file mode 100644 index 000000000000..06f4b9d2fe10 --- /dev/null +++ b/libio/ioseekoff.c @@ -0,0 +1,43 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include + +_IO_pos_t +DEFUN(_IO_seekoff, (fp, offset, dir, mode), + _IO_FILE* fp AND _IO_off_t offset AND int dir AND int mode) +{ + /* If we have a backup buffer, get rid of it, since the __seekoff + callback may not know to do the right thing about it. + This may be over-kill, but it'll do for now. TODO */ + + if (_IO_have_backup (fp)) + { + if (dir == _IO_seek_cur && _IO_in_backup (fp)) + offset -= fp->_IO_read_end - fp->_IO_read_ptr; + _IO_free_backup_area (fp); + } + + return _IO_SEEKOFF (fp, offset, dir, mode); +} diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c new file mode 100644 index 000000000000..1884f9df8f7c --- /dev/null +++ b/libio/ioseekpos.c @@ -0,0 +1,39 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include + +_IO_pos_t +DEFUN(_IO_seekpos, (fp, pos, mode), + _IO_FILE* fp AND _IO_pos_t pos AND int mode) +{ + /* If we have a backup buffer, get rid of it, since the __seekoff + callback may not know to do the right thing about it. + This may be over-kill, but it'll do for now. TODO */ + + if (_IO_have_backup (fp)) + _IO_free_backup_area (fp); + + return _IO_SEEKPOS (fp, pos, mode); +} diff --git a/libio/iosetbuffer.c b/libio/iosetbuffer.c new file mode 100644 index 000000000000..eb78d75d9ab2 --- /dev/null +++ b/libio/iosetbuffer.c @@ -0,0 +1,36 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +void +DEFUN(_IO_setbuffer, (fp, buf, size), + _IO_FILE *fp AND char *buf AND _IO_size_t size) +{ + CHECK_FILE(fp, ); + fp->_flags &= ~_IO_LINE_BUF; + if (!buf) + size = 0; + (void) _IO_SETBUF (fp, buf, size); +} diff --git a/libio/iosetvbuf.c b/libio/iosetvbuf.c new file mode 100644 index 000000000000..1b2da4f104c9 --- /dev/null +++ b/libio/iosetvbuf.c @@ -0,0 +1,78 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#define _IOFBF 0 /* Fully buffered. */ +#define _IOLBF 1 /* Line buffered. */ +#define _IONBF 2 /* No buffering. */ + +int +DEFUN(_IO_setvbuf, (fp, buf, mode, size), + _IO_FILE* fp AND char* buf AND int mode AND _IO_size_t size) +{ + CHECK_FILE(fp, EOF); + switch (mode) + { + case _IOFBF: + fp->_IO_file_flags &= ~_IO_LINE_BUF|_IO_UNBUFFERED; + if (buf == NULL) + { + if (fp->_IO_buf_base == NULL) + { + /* There is no flag to distinguish between "fully buffered + mode has been explicitly set" as opposed to "line + buffering has not been explicitly set". In both + cases, _IO_LINE_BUF is off. If this is a tty, and + _IO_filedoalloc later gets called, it cannot know if + it should set the _IO_LINE_BUF flag (because that is + the default), or not (because we have explicitly asked + for fully buffered mode). So we make sure a buffer + gets allocated now, and explicitly turn off line + buffering. + + A possibly cleaner alternative would be to add an + extra flag, but then flags are a finite resource. */ + if (_IO_DOALLOCATE (fp) < 0) + return EOF; + fp->_IO_file_flags &= ~_IO_LINE_BUF; + } + return 0; + } + break; + case _IOLBF: + fp->_IO_file_flags &= ~_IO_UNBUFFERED; + fp->_IO_file_flags |= _IO_LINE_BUF; + if (buf == NULL) + return 0; + break; + case _IONBF: + buf = NULL; + size = 0; + break; + default: + return EOF; + } + return _IO_SETBUF (fp, buf, size) == NULL ? EOF : 0; +} diff --git a/libio/iosprintf.c b/libio/iosprintf.c new file mode 100644 index 000000000000..b873eb4455d5 --- /dev/null +++ b/libio/iosprintf.c @@ -0,0 +1,47 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +_IO_sprintf +#ifdef __STDC__ + (char *string, const char* format, ...) +#else +(string, format, va_alist) char *string; char *format; va_dcl +#endif +{ + int ret; + va_list args; + _IO_va_start(args, format); + ret = _IO_vsprintf(string, format, args); + va_end(args); + return ret; +} diff --git a/libio/iosscanf.c b/libio/iosscanf.c new file mode 100644 index 000000000000..58868778c48e --- /dev/null +++ b/libio/iosscanf.c @@ -0,0 +1,47 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +_IO_sscanf +#ifdef __STDC__ + (const char * string, const char* format, ...) +#else +(string, format, va_alist) char *string; char *format; va_dcl +#endif +{ + int ret; + va_list args; + _IO_va_start(args, format); + ret = _IO_vsscanf(string, format, args); + va_end(args); + return ret; +} diff --git a/libio/iostdio.h b/libio/iostdio.h new file mode 100644 index 000000000000..9ed47a4654a4 --- /dev/null +++ b/libio/iostdio.h @@ -0,0 +1,114 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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 file defines a stdio-like environment, except that it avoid + link-time name clashes with an existing stdio. + It allows for testing the libio using stdio-using programs + with an incompatible libc.a. + It is not predantically correct - e.g. some macros are used + that may evaluate a stream argument more than once. */ + +#ifndef _IOSTDIO_H +#define _IOSTDIO_H + +#include "iolibio.h" + +typedef _IO_FILE FILE; +#ifndef EOF +#define EOF (-1) +#endif +#ifndef BUFSIZ +#define BUFSIZ 1024 +#endif + +/* #define size_t, fpos_t L_tmpname TMP_MAX */ + +#define _IOFBF 0 /* Fully buffered. */ +#define _IOLBF 1 /* Line buffered. */ +#define _IONBF 2 /* No buffering. */ + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#define stdin _IO_stdin +#define stdout _IO_stdout +#define stderr _IO_stderr + +#define getc(_fp) _IO_getc(_fp) +#define putc(_ch, _fp) _IO_putc(_ch, _fp) + +#define clearerr _IO_clearerr +#define fclose _IO_fclose +#define feof _IO_feof +#define ferror _IO_ferror +#define fflush _IO_fflush +#define fgetc(__fp) _IO_getc(_fp) +#define fgetpos _IO_fgetpos +#define fgets _IO_fgets +#define fopen _IO_fopen +#define fprintf _IO_fprintf +#define fputc(_ch, _fp) _IO_putc(_ch, _fp) +#define fputs _IO_fputs +#define fread _IO_fread +#define freopen _IO_freopen +#define fscanf _IO_fscanf +#define fseek _IO_fseek +#define fsetpos _IO_fsetpos +#define ftell _IO_ftell +#define fwrite _IO_fwrite +#define gets _IO_gets +#define perror _IO_perror +#define printf _IO_printf +#define puts _IO_puts +#define rewind _IO_rewind +#define scanf _IO_scanf +#define setbuf _IO_setbuf +#define setbuffer _IO_setbuffer +#define setvbuf _IO_setvbuf +#define sprintf _IO_sprintf +#define sscanf _IO_sscanf +#define ungetc _IO_ungetc +#define vfprintf _IO_vfprintf +#define vprintf(__fmt, __args) vfprintf(stdout, __fmt, __args) +#define vsprintf _IO_vsprintf + +#if 0 +/* We can use the libc versions of these, since they don't pass FILE*s. */ +#define remove ??? __P((const char*)) +#define rename ??? __P((const char* _old, const char* _new)) +#define tmpfile ??? __P((void)) +#define tmpnam ??? __P((char*)) +#endif + +#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE) +#define fdopen _IO_fdopen +#define fileno _IO_fileno +#define popen _IO_popen +#define pclose _IO_pclose +#define setbuf _IO_setbuf +#define setlinebuf _IO_setlinebuf +#endif + +#endif /* _IOSTDIO_H */ diff --git a/libio/iostream.cc b/libio/iostream.cc new file mode 100644 index 000000000000..78b09cb6af33 --- /dev/null +++ b/libio/iostream.cc @@ -0,0 +1,821 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUC__ +#pragma implementation +#endif +#define _STREAM_COMPAT +#include +#include "libioP.h" +#include /* Needed for sprintf */ +#include +#include +#include +#include "floatio.h" + +#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */ + +//#define isspace(ch) ((ch)==' ' || (ch)=='\t' || (ch)=='\n') + +istream::istream(streambuf *sb, ostream* tied) +{ + init (sb, tied); + _gcount = 0; +} + +int skip_ws(streambuf* sb) +{ + int ch; + for (;;) { + ch = sb->sbumpc(); + if (ch == EOF || !isspace(ch)) + return ch; + } +} + +istream& istream::get(char& c) +{ + if (ipfx1()) { + int ch = _strbuf->sbumpc(); + if (ch == EOF) { + set(ios::eofbit|ios::failbit); + _gcount = 0; + } + else { + c = (char)ch; + _gcount = 1; + } + } + else + _gcount = 0; + return *this; +} + +int istream::peek() +{ + if (!good()) + return EOF; + if (_tie && rdbuf()->in_avail() == 0) + _tie->flush(); + int ch = _strbuf->sgetc(); + if (ch == EOF) + set(ios::eofbit); + return ch; +} + +istream& istream::ignore(int n /* = 1 */, int delim /* = EOF */) +{ + _gcount = 0; + if (ipfx1()) { + register streambuf* sb = _strbuf; + if (delim == EOF) { + _gcount = sb->ignore(n); + return *this; + } + for (;;) { +#if 0 + if (n != MAXINT) // FIXME +#endif + if (--n < 0) + break; + int ch = sb->sbumpc(); + if (ch == EOF) { + set(ios::eofbit|ios::failbit); + break; + } + _gcount++; + if (ch == delim) + break; + } + } + return *this; +} + +istream& istream::read(char *s, streamsize n) +{ + if (ipfx1()) { + _gcount = _strbuf->sgetn(s, n); + if (_gcount != n) + set(ios::failbit|ios::eofbit); + } + else + _gcount = 0; + return *this; +} + +int +istream::sync () +{ + streambuf *sb = rdbuf (); + if (sb == NULL) + return EOF; + if (sb->sync ()) // Later: pubsync + { + setstate (ios::badbit); + return EOF; + } + else + return 0; +} + +istream& istream::seekg(streampos pos) +{ + pos = _strbuf->pubseekpos(pos, ios::in); + if (pos == streampos(EOF)) + set(ios::badbit); + return *this; +} + +istream& istream::seekg(streamoff off, _seek_dir dir) +{ + streampos pos = _IO_seekoff (_strbuf, off, (int) dir, _IOS_INPUT); + if (pos == streampos(EOF)) + set(ios::badbit); + return *this; +} + +streampos istream::tellg() +{ +#if 0 + streampos pos = _strbuf->pubseekoff(0, ios::cur, ios::in); +#else + streampos pos = _IO_seekoff (_strbuf, 0, _IO_seek_cur, _IOS_INPUT); +#endif + if (pos == streampos(EOF)) + set(ios::badbit); + return pos; +} + +istream& istream::operator>>(char& c) +{ + if (ipfx0()) { + int ch = _strbuf->sbumpc(); + if (ch == EOF) + set(ios::eofbit|ios::failbit); + else + c = (char)ch; + } + return *this; +} + +istream& +istream::operator>> (char* ptr) +{ + register char *p = ptr; + int w = width(0); + if (ipfx0()) + { + register streambuf* sb = _strbuf; + for (;;) + { + int ch = sb->sbumpc(); + if (ch == EOF) + { + set(ios::eofbit); + break; + } + else if (isspace(ch) || w == 1) + { + sb->sputbackc(ch); + break; + } + else *p++ = ch; + w--; + } + if (p == ptr) + set(ios::failbit); + } + *p = '\0'; + return *this; +} + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#define LONGEST long long +#else +#define LONGEST long +#endif + +static int read_int(istream& stream, unsigned LONGEST& val, int& neg) +{ + if (!stream.ipfx0()) + return 0; + register streambuf* sb = stream.rdbuf(); + int base = 10; + int ndigits = 0; + register int ch = skip_ws(sb); + if (ch == EOF) + goto eof_fail; + neg = 0; + if (ch == '+') { + ch = skip_ws(sb); + } + else if (ch == '-') { + neg = 1; + ch = skip_ws(sb); + } + if (ch == EOF) goto eof_fail; + if (!(stream.flags() & ios::basefield)) { + if (ch == '0') { + ch = sb->sbumpc(); + if (ch == EOF) { + val = 0; + return 1; + } + if (ch == 'x' || ch == 'X') { + base = 16; + ch = sb->sbumpc(); + if (ch == EOF) goto eof_fail; + } + else { + sb->sputbackc(ch); + base = 8; + ch = '0'; + } + } + } + else if ((stream.flags() & ios::basefield) == ios::hex) + base = 16; + else if ((stream.flags() & ios::basefield) == ios::oct) + base = 8; + val = 0; + for (;;) { + if (ch == EOF) + break; + int digit; + if (ch >= '0' && ch <= '9') + digit = ch - '0'; + else if (ch >= 'A' && ch <= 'F') + digit = ch - 'A' + 10; + else if (ch >= 'a' && ch <= 'f') + digit = ch - 'a' + 10; + else + digit = 999; + if (digit >= base) { + sb->sputbackc(ch); + if (ndigits == 0) + goto fail; + else + return 1; + } + ndigits++; + val = base * val + digit; + ch = sb->sbumpc(); + } + return 1; + fail: + stream.set(ios::failbit); + return 0; + eof_fail: + stream.set(ios::failbit|ios::eofbit); + return 0; +} + +#define READ_INT(TYPE) \ +istream& istream::operator>>(TYPE& i)\ +{\ + unsigned LONGEST val; int neg;\ + if (read_int(*this, val, neg)) {\ + if (neg) val = -val;\ + i = (TYPE)val;\ + }\ + return *this;\ +} + +READ_INT(short) +READ_INT(unsigned short) +READ_INT(int) +READ_INT(unsigned int) +READ_INT(long) +READ_INT(unsigned long) +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +READ_INT(long long) +READ_INT(unsigned long long) +#endif +#if _G_HAVE_BOOL +READ_INT(bool) +#endif + +istream& istream::operator>>(long double& x) +{ + if (ipfx0()) + scan("%lg", &x); + return *this; +} + +istream& istream::operator>>(double& x) +{ + if (ipfx0()) + scan("%lg", &x); + return *this; +} + +istream& istream::operator>>(float& x) +{ + if (ipfx0()) + scan("%g", &x); + return *this; +} + +istream& istream::operator>>(register streambuf* sbuf) +{ + if (ipfx0()) { + register streambuf* inbuf = rdbuf(); + // FIXME: Should optimize! + for (;;) { + register int ch = inbuf->sbumpc(); + if (ch == EOF) { + set(ios::eofbit); + break; + } + if (sbuf->sputc(ch) == EOF) { + set(ios::failbit); + break; + } + } + } + return *this; +} + +ostream& ostream::operator<<(char c) +{ + if (opfx()) { +#if 1 + // This is what the cfront implementation does. + if (_strbuf->sputc(c) == EOF) + goto failed; +#else + // This is what cfront documentation and current ANSI drafts say. + int w = width(0); + char fill_char = fill(); + register int padding = w > 0 ? w - 1 : 0; + register streambuf *sb = _strbuf; + if (!(flags() & ios::left) && padding) // Default adjustment. + if (_IO_padn(sb, fill_char, padding) < padding) + goto failed; + if (sb->sputc(c) == EOF) + goto failed; + if (flags() & ios::left && padding) // Left adjustment. + if (_IO_padn(sb, fill_char, padding) < padding) + goto failed; +#endif + osfx(); + } + return *this; + failed: + set(ios::badbit); + osfx(); + return *this; +} + +/* Write VAL on STREAM. + If SIGN<0, val is the absolute value of a negative number. + If SIGN>0, val is a signed non-negative number. + If SIGN==0, val is unsigned. */ + +static void write_int(ostream& stream, unsigned LONGEST val, int sign) +{ +#define WRITE_BUF_SIZE (10 + sizeof(unsigned LONGEST) * 3) + char buf[WRITE_BUF_SIZE]; + register char *buf_ptr = buf+WRITE_BUF_SIZE; // End of buf. + const char *show_base = ""; + int show_base_len = 0; + int show_pos = 0; // If 1, print a '+'. + + // Now do the actual conversion, placing the result at the *end* of buf. + // Note that we use separate code for decimal, octal, and hex, + // so we can divide by optimizable constants. + if ((stream.flags() & ios::basefield) == ios::oct) { // Octal + do { + *--buf_ptr = (val & 7) + '0'; + val = val >> 3; + } while (val != 0); + if ((stream.flags() & ios::showbase) && (*buf_ptr != '0')) + *--buf_ptr = '0'; + } + else if ((stream.flags() & ios::basefield) == ios::hex) { // Hex + const char *xdigs = (stream.flags() & ios::uppercase) ? "0123456789ABCDEF0X" + : "0123456789abcdef0x"; + do { + *--buf_ptr = xdigs[val & 15]; + val = val >> 4; + } while (val != 0); + if ((stream.flags() & ios::showbase)) { + show_base = xdigs + 16; // Either "0X" or "0x". + show_base_len = 2; + } + } + else { // Decimal +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) + // Optimization: Only use long long when we need to. + while (val > UINT_MAX) { + *--buf_ptr = (val % 10) + '0'; + val /= 10; + } + // Use more efficient (int) arithmetic for the rest. + register unsigned int ival = (unsigned int)val; +#else + register unsigned LONGEST ival = val; +#endif + do { + *--buf_ptr = (ival % 10) + '0'; + ival /= 10; + } while (ival != 0); + if (sign > 0 && (stream.flags() & ios::showpos)) + show_pos=1; + } + + int buf_len = buf+WRITE_BUF_SIZE - buf_ptr; + int w = stream.width(0); + + // Calculate padding. + int len = buf_len+show_pos; + if (sign < 0) len++; + len += show_base_len; + int padding = len > w ? 0 : w - len; + + // Do actual output. + register streambuf* sbuf = stream.rdbuf(); + ios::fmtflags pad_kind = + stream.flags() & (ios::left|ios::right|ios::internal); + char fill_char = stream.fill(); + if (padding > 0 + && pad_kind != (ios::fmtflags)ios::left + && pad_kind != (ios::fmtflags)ios::internal) // Default (right) adjust. + if (_IO_padn(sbuf, fill_char, padding) < padding) + goto failed; + if (sign < 0 || show_pos) + { + char ch = sign < 0 ? '-' : '+'; + if (sbuf->sputc(ch) < 0) + goto failed; + } + if (show_base_len) + if (_IO_sputn(sbuf, show_base, show_base_len) <= 0) + goto failed; + if (pad_kind == (ios::fmtflags)ios::internal && padding > 0) + if (_IO_padn(sbuf, fill_char, padding) < padding) + goto failed; + if (_IO_sputn (sbuf, buf_ptr, buf_len) != buf_len) + goto failed; + if (pad_kind == (ios::fmtflags)ios::left && padding > 0) // Left adjustment + if (_IO_padn(sbuf, fill_char, padding) < padding) + goto failed; + stream.osfx(); + return; + failed: + stream.set(ios::badbit); + stream.osfx(); +} + +ostream& ostream::operator<<(int n) +{ + if (opfx()) { + int sign = 1; + unsigned int abs_n = (unsigned)n; + if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0) + abs_n = -((unsigned)n), sign = -1; + write_int(*this, abs_n, sign); + } + return *this; +} + +ostream& ostream::operator<<(unsigned int n) +{ + if (opfx()) + write_int(*this, n, 0); + return *this; +} + + +ostream& ostream::operator<<(long n) +{ + if (opfx()) { + int sign = 1; + unsigned long abs_n = (unsigned long)n; + if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0) + abs_n = -((unsigned long)n), sign = -1; + write_int(*this, abs_n, sign); + } + return *this; +} + +ostream& ostream::operator<<(unsigned long n) +{ + if (opfx()) + write_int(*this, n, 0); + return *this; +} + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +ostream& ostream::operator<<(long long n) +{ + if (opfx()) { + int sign = 1; + unsigned long long abs_n = (unsigned long long)n; + if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0) + abs_n = -((unsigned long long)n), sign = -1; + write_int(*this, abs_n, sign); + } + return *this; +} + + +ostream& ostream::operator<<(unsigned long long n) +{ + if (opfx()) + write_int(*this, n, 0); + return *this; +} +#endif /*__GNUC__*/ + +ostream& ostream::operator<<(double n) +{ + if (opfx()) { + // Uses __cvt_double (renamed from static cvt), in Chris Torek's + // stdio implementation. The setup code uses the same logic + // as in __vsbprintf.C (also based on Torek's code). + int format_char; + if ((flags() & ios::floatfield) == ios::fixed) + format_char = 'f'; + else if ((flags() & ios::floatfield) == ios::scientific) + format_char = flags() & ios::uppercase ? 'E' : 'e'; + else + format_char = flags() & ios::uppercase ? 'G' : 'g'; + + int prec = precision(); + if (prec <= 0 && !(flags() & ios::fixed)) + prec = 6; /* default */ + + // Do actual conversion. +#ifdef _IO_USE_DTOA + if (_IO_outfloat(n, rdbuf(), format_char, width(0), + prec, flags(), + flags() & ios::showpos ? '+' : 0, + fill()) < 0) + set(ios::badbit|ios::failbit); // ?? +#else + int fpprec = 0; // 'Extra' (suppressed) floating precision. + if (prec > MAXFRACT) { + if (flags() & (ios::fixed|ios::scientific) & ios::showpos) + fpprec = prec - MAXFRACT; + prec = MAXFRACT; + } + int negative; + char buf[BUF]; + int sign = '\0'; + char *cp = buf; + *cp = 0; + int size = __cvt_double(n, prec, + flags() & ios::showpoint ? 0x80 : 0, + &negative, + format_char, cp, buf + sizeof(buf)); + if (negative) sign = '-'; + else if (flags() & ios::showpos) sign = '+'; + if (*cp == 0) + cp++; + + // Calculate padding. + int fieldsize = size + fpprec; + if (sign) fieldsize++; + int padding = 0; + int w = width(0); + if (fieldsize < w) + padding = w - fieldsize; + + // Do actual output. + register streambuf* sbuf = rdbuf(); + register i; + char fill_char = fill(); + ios::fmtflags pad_kind = + flags() & (ios::left|ios::right|ios::internal); + if (pad_kind != (ios::fmtflags)ios::left // Default (right) adjust. + && pad_kind != (ios::fmtflags)ios::internal) + for (i = padding; --i >= 0; ) sbuf->sputc(fill_char); + if (sign) + sbuf->sputc(sign); + if (pad_kind == (ios::fmtflags)ios::internal) + for (i = padding; --i >= 0; ) sbuf->sputc(fill_char); + + // Emit the actual concented field, followed by extra zeros. + _IO_sputn (sbuf, cp, size); + for (i = fpprec; --i >= 0; ) sbuf->sputc('0'); + + if (pad_kind == (ios::fmtflags)ios::left) // Left adjustment + for (i = padding; --i >= 0; ) sbuf->sputc(fill_char); +#endif + osfx(); + } + return *this; +} + +ostream& ostream::operator<<(const char *s) +{ + if (opfx()) + { + if (s == NULL) + s = "(null)"; + int len = strlen(s); + int w = width(0); +// FIXME: Should we: if (w && len>w) len = w; + char fill_char = fill(); + register streambuf *sbuf = rdbuf(); + register int padding = w > len ? w - len : 0; + if (!(flags() & ios::left) && padding > 0) // Default adjustment. + if (_IO_padn(sbuf, fill_char, padding) != padding) + goto failed; + if (_IO_sputn (sbuf, s, len) != len) + goto failed; + if (flags() & ios::left && padding > 0) // Left adjustment. + if (_IO_padn(sbuf, fill_char, padding) != padding) + goto failed; + osfx(); + } + return *this; + failed: + set(ios::badbit); + osfx(); + return *this; +} + +#if 0 +ostream& ostream::operator<<(const void *p) +{ Is in osform.cc, to avoid pulling in all of _IO_vfprintf by this file. */ } +#endif + +ostream& ostream::operator<<(register streambuf* sbuf) +{ + if (opfx()) + { + char buffer[_IO_BUFSIZ]; + register streambuf* outbuf = _strbuf; + for (;;) + { + _IO_size_t count = _IO_sgetn(sbuf, buffer, _IO_BUFSIZ); + if (count <= 0) + break; + if (_IO_sputn(outbuf, buffer, count) != count) + { + set(ios::badbit); + break; + } + } + osfx(); + } + return *this; +} + +ostream::ostream(streambuf* sb, ostream* tied) +{ + init (sb, tied); +} + +ostream& ostream::seekp(streampos pos) +{ + pos = _strbuf->pubseekpos(pos, ios::out); + if (pos == streampos(EOF)) + set(ios::badbit); + return *this; +} + +ostream& ostream::seekp(streamoff off, _seek_dir dir) +{ + streampos pos = _IO_seekoff (_strbuf, off, (int) dir, _IOS_OUTPUT); + if (pos == streampos(EOF)) + set(ios::badbit); + return *this; +} + +streampos ostream::tellp() +{ +#if 1 + streampos pos = _IO_seekoff (_strbuf, 0, _IO_seek_cur, _IOS_OUTPUT); +#else + streampos pos = _strbuf->pubseekoff(0, ios::cur, ios::out); +#endif + if (pos == streampos(EOF)) + set(ios::badbit); + return pos; +} + +ostream& ostream::flush() +{ + if (_strbuf->sync()) + set(ios::badbit); + return *this; +} + +ostream& flush(ostream& outs) +{ + return outs.flush(); +} + +istream& ws(istream& ins) +{ + if (ins.ipfx1()) { + int ch = skip_ws(ins._strbuf); + if (ch == EOF) + ins.set(ios::eofbit); + else + ins._strbuf->sputbackc(ch); + } + return ins; +} + +// Skip white-space. Return 0 on failure (EOF), or 1 on success. +// Differs from ws() manipulator in that failbit is set on EOF. +// Called by ipfx() and ipfx0() if needed. + +int istream::_skip_ws() +{ + int ch = skip_ws(_strbuf); + if (ch == EOF) { + set(ios::eofbit|ios::failbit); + return 0; + } + else { + _strbuf->sputbackc(ch); + return 1; + } +} + +ostream& ends(ostream& outs) +{ + outs.put('\0'); + return outs; +} + +ostream& endl(ostream& outs) +{ + return flush(outs.put('\n')); +} + +ostream& ostream::write(const char *s, streamsize n) +{ + if (opfx()) { + if (_IO_sputn(_strbuf, s, n) != n) + set(ios::failbit); + } + return *this; +} + +void ostream::do_osfx() +{ + if (flags() & ios::unitbuf) + flush(); + if (flags() & ios::stdio) { + fflush(stdout); + fflush(stderr); + } +} + +iostream::iostream(streambuf* sb, ostream* tied) +{ + init (sb, tied); +} + +// NOTE: extension for compatibility with old libg++. +// Not really compatible with fistream::close(). +#ifdef _STREAM_COMPAT +void ios::close() +{ + if (_strbuf->_flags & _IO_IS_FILEBUF) + ((struct filebuf*)rdbuf())->close(); + else if (_strbuf != NULL) + rdbuf()->sync(); + _strbuf = NULL; + _state = badbit; +} + +int istream::skip(int i) +{ + int old = (_flags & ios::skipws) != 0; + if (i) + _flags |= ios::skipws; + else + _flags &= ~ios::skipws; + return old; +} +#endif diff --git a/libio/iostream.h b/libio/iostream.h new file mode 100644 index 000000000000..d663b42430ca --- /dev/null +++ b/libio/iostream.h @@ -0,0 +1,258 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifndef _IOSTREAM_H +#ifdef __GNUG__ +#pragma interface +#endif +#define _IOSTREAM_H + +#include + +extern "C++" { +class istream; class ostream; +typedef ios& (*__manip)(ios&); +typedef istream& (*__imanip)(istream&); +typedef ostream& (*__omanip)(ostream&); + +extern istream& ws(istream& ins); +extern ostream& flush(ostream& outs); +extern ostream& endl(ostream& outs); +extern ostream& ends(ostream& outs); + +class ostream : virtual public ios +{ + // NOTE: If fields are changed, you must fix _fake_ostream in stdstreams.C! + void do_osfx(); + public: + ostream() { } + ostream(streambuf* sb, ostream* tied=NULL); + int opfx() { + if (!good()) return 0; else { if (_tie) _tie->flush(); return 1;} } + void osfx() { if (flags() & (ios::unitbuf|ios::stdio)) + do_osfx(); } + ostream& flush(); + ostream& put(char c) { _strbuf->sputc(c); return *this; } +#ifdef _STREAM_COMPAT + /* Temporary binary compatibility. REMOVE IN NEXT RELEASE. */ + ostream& put(unsigned char c) { return put((char)c); } + ostream& put(signed char c) { return put((char)c); } +#endif + ostream& write(const char *s, streamsize n); + ostream& write(const unsigned char *s, streamsize n) + { return write((const char*)s, n);} + ostream& write(const signed char *s, streamsize n) + { return write((const char*)s, n);} + ostream& write(const void *s, streamsize n) + { return write((const char*)s, n);} + ostream& seekp(streampos); + ostream& seekp(streamoff, _seek_dir); + streampos tellp(); + ostream& form(const char *format ...); + ostream& vform(const char *format, _IO_va_list args); + + ostream& operator<<(char c); + ostream& operator<<(unsigned char c) { return (*this) << (char)c; } + ostream& operator<<(signed char c) { return (*this) << (char)c; } + ostream& operator<<(const char *s); + ostream& operator<<(const unsigned char *s) + { return (*this) << (const char*)s; } + ostream& operator<<(const signed char *s) + { return (*this) << (const char*)s; } + ostream& operator<<(const void *p); + ostream& operator<<(int n); + ostream& operator<<(unsigned int n); + ostream& operator<<(long n); + ostream& operator<<(unsigned long n); +#if defined(__GNUC__) + __extension__ ostream& operator<<(long long n); + __extension__ ostream& operator<<(unsigned long long n); +#endif + ostream& operator<<(short n) {return operator<<((int)n);} + ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);} +#if _G_HAVE_BOOL + ostream& operator<<(bool b) { return operator<<((int)b); } +#endif + ostream& operator<<(double n); + ostream& operator<<(float n) { return operator<<((double)n); } + ostream& operator<<(long double n) { return operator<<((double)n); } + ostream& operator<<(__omanip func) { return (*func)(*this); } + ostream& operator<<(__manip func) {(*func)(*this); return *this;} + ostream& operator<<(streambuf*); +#ifdef _STREAM_COMPAT + streambuf* ostreambuf() const { return _strbuf; } +#endif +}; + +class istream : virtual public ios +{ + // NOTE: If fields are changed, you must fix _fake_istream in stdstreams.C! +protected: + _IO_size_t _gcount; + + int _skip_ws(); + public: + istream(): _gcount (0) { } + istream(streambuf* sb, ostream*tied=NULL); + istream& get(char* ptr, int len, char delim = '\n'); + istream& get(unsigned char* ptr, int len, char delim = '\n') + { return get((char*)ptr, len, delim); } + istream& get(char& c); + istream& get(unsigned char& c) { return get((char&)c); } + istream& getline(char* ptr, int len, char delim = '\n'); + istream& getline(unsigned char* ptr, int len, char delim = '\n') + { return getline((char*)ptr, len, delim); } + istream& get(signed char& c) { return get((char&)c); } + istream& get(signed char* ptr, int len, char delim = '\n') + { return get((char*)ptr, len, delim); } + istream& getline(signed char* ptr, int len, char delim = '\n') + { return getline((char*)ptr, len, delim); } + istream& read(char *ptr, streamsize n); + istream& read(unsigned char *ptr, streamsize n) + { return read((char*)ptr, n); } + istream& read(signed char *ptr, streamsize n) + { return read((char*)ptr, n); } + istream& read(void *ptr, streamsize n) + { return read((char*)ptr, n); } + istream& get(streambuf& sb, char delim = '\n'); + istream& gets(char **s, char delim = '\n'); + int ipfx(int need = 0) { + if (!good()) { set(ios::failbit); return 0; } + else { + if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush(); + if (!need && (flags() & ios::skipws)) return _skip_ws(); + else return 1; + } + } + int ipfx0() { // Optimized version of ipfx(0). + if (!good()) { set(ios::failbit); return 0; } + else { + if (_tie) _tie->flush(); + if (flags() & ios::skipws) return _skip_ws(); + else return 1; + } + } + int ipfx1() { // Optimized version of ipfx(1). + if (!good()) { set(ios::failbit); return 0; } + else { + if (_tie && rdbuf()->in_avail() == 0) _tie->flush(); + return 1; + } + } + void isfx() { } + int get() { if (!ipfx1()) return EOF; + else { int ch = _strbuf->sbumpc(); + if (ch == EOF) set(ios::eofbit); + return ch; + } } + int peek(); + _IO_size_t gcount() { return _gcount; } + istream& ignore(int n=1, int delim = EOF); + int sync (); + istream& seekg(streampos); + istream& seekg(streamoff, _seek_dir); + streampos tellg(); + istream& putback(char ch) { + if (good() && _strbuf->sputbackc(ch) == EOF) clear(ios::badbit); + return *this;} + istream& unget() { + if (good() && _strbuf->sungetc() == EOF) clear(ios::badbit); + return *this;} + istream& scan(const char *format ...); + istream& vscan(const char *format, _IO_va_list args); +#ifdef _STREAM_COMPAT + istream& unget(char ch) { return putback(ch); } + int skip(int i); + streambuf* istreambuf() const { return _strbuf; } +#endif + + istream& operator>>(char*); + istream& operator>>(unsigned char* p) { return operator>>((char*)p); } + istream& operator>>(signed char*p) { return operator>>((char*)p); } + istream& operator>>(char& c); + istream& operator>>(unsigned char& c) {return operator>>((char&)c);} + istream& operator>>(signed char& c) {return operator>>((char&)c);} + istream& operator>>(int&); + istream& operator>>(long&); +#if defined(__GNUC__) + __extension__ istream& operator>>(long long&); + __extension__ istream& operator>>(unsigned long long&); +#endif + istream& operator>>(short&); + istream& operator>>(unsigned int&); + istream& operator>>(unsigned long&); + istream& operator>>(unsigned short&); +#if _G_HAVE_BOOL + istream& operator>>(bool&); +#endif + istream& operator>>(float&); + istream& operator>>(double&); + istream& operator>>(long double&); + istream& operator>>( __manip func) {(*func)(*this); return *this;} + istream& operator>>(__imanip func) { return (*func)(*this); } + istream& operator>>(streambuf*); +}; + +class iostream : public istream, public ostream +{ + public: + iostream() { } + iostream(streambuf* sb, ostream*tied=NULL); +}; + +class _IO_istream_withassign : public istream { +public: + _IO_istream_withassign& operator=(istream&); + _IO_istream_withassign& operator=(_IO_istream_withassign& rhs) + { return operator= (static_cast (rhs)); } +}; + +class _IO_ostream_withassign : public ostream { +public: + _IO_ostream_withassign& operator=(ostream&); + _IO_ostream_withassign& operator=(_IO_ostream_withassign& rhs) + { return operator= (static_cast (rhs)); } +}; + +extern _IO_istream_withassign cin; +// clog->rdbuf() == cerr->rdbuf() +extern _IO_ostream_withassign cout, cerr; + +extern _IO_ostream_withassign clog +#if _G_CLOG_CONFLICT +__asm__ ("__IO_clog") +#endif +; + +struct Iostream_init { } ; // Compatibility hack for AT&T library. + +inline ios& dec(ios& i) +{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; } +inline ios& hex(ios& i) +{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; } +inline ios& oct(ios& i) +{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; } +} // extern "C++" + +#endif /*!_IOSTREAM_H*/ diff --git a/libio/iostream.texi b/libio/iostream.texi new file mode 100644 index 000000000000..54ccced6e71b --- /dev/null +++ b/libio/iostream.texi @@ -0,0 +1,1971 @@ +\input texinfo @c -*-Texinfo-*- +@c Copyright (c) 1993 Free Software Foundation, Inc. + +@c %**start of header +@setfilename iostream.info +@settitle The GNU C++ Iostream Library +@setchapternewpage odd +@c %**end of header + +@ifinfo +@format +START-INFO-DIR-ENTRY +* iostream: (iostream). The C++ input/output facility. +END-INFO-DIR-ENTRY +@end format + +This file describes libio, the GNU library for C++ iostreams and C stdio. + +libio includes software developed by the University of California, +Berkeley. + +Copyright (C) 1993 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions. +@end ifinfo + +@finalout +@syncodeindex fn cp +@syncodeindex vr cp + +@titlepage +@title The GNU C++ Iostream Library +@subtitle Reference Manual for @code{libio} Version 0.64 +@sp 3 +@author Per Bothner @hfill @code{bothner@@cygnus.com} +@author Cygnus Support @hfill @code{doc@@cygnus.com} +@page + +@vskip 0pt plus 1filll +Copyright @copyright{} 1993 Free Software Foundation, Inc. + +@code{libio} includes software developed by the University of +California, Berkeley. + +@code{libio} uses floating-point software written by David M. Gay, which +includes the following notice: + +@quotation +The author of this software is David M. Gay. + +Copyright (c) 1991 by AT&T. + +Permission to use, copy, modify, and distribute this software for any +purpose without fee is hereby granted, provided that this entire notice +is included in all copies of any software which is or includes a copy +or modification of this software and in all copies of the supporting +documentation for such software. + +THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED +WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY +REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY +OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. +@end quotation + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions. +@end titlepage + +@ifinfo +@node Top +@top The GNU C++ Iostream Library + +This file provides reference information on the GNU C++ iostream library +(@code{libio}), version 0.64. + +@menu +* Introduction:: +* Operators:: Operators and default streams. +* Streams:: Stream classes. +* Files and Strings:: Classes for files and strings. +* Streambuf:: Using the streambuf layer. +* Stdio:: C input and output. +* Index:: +@end menu +@end ifinfo + +@node Introduction +@chapter Introduction + +The iostream classes implement most of the features of AT&T version 2.0 +iostream library classes, and most of the features of the ANSI X3J16 +library draft (which is based on the AT&T design). + +This manual is meant as a reference; for tutorial material on iostreams, +see the corresponding section of any recent popular introduction to C++. + +@menu +* Copying:: Special GNU licensing terms for libio. +* Acknowledgements:: Contributors to GNU iostream. +@end menu + +@node Copying +@section Licensing terms for @code{libio} + +Since the @code{iostream} classes are so fundamental to standard C++, +the Free Software Foundation has agreed to a special exception to its +standard license, when you link programs with @code{libio.a}: + +@quotation +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. +@end quotation + +The code is under the @sc{gnu} General Public License (version 2) for +all other purposes than linking with this library; that means that you +can modify and redistribute the code as usual, but remember that if you +do, your modifications, and anything you link with the modified code, +must be available to others on the same terms. + +These functions are also available as part of the @code{libg++} +library; if you link with that library instead of @code{libio}, the +@sc{gnu} Library General Public License applies. + +@node Acknowledgements +@section Acknowledgements + +Per Bothner wrote most of the @code{iostream} library, but some portions +have their origins elsewhere in the free software community. Heinz +Seidl wrote the IO manipulators. The floating-point conversion software +is by David M. Gay of AT&T. Some code was derived from parts of BSD +4.4, which was written at the University of California, Berkeley. + +The iostream classes are found in the @code{libio} library. An early +version was originally distributed in @code{libg++}, and they are still +included there as well, for convenience if you need other @code{libg++} +classes. Doug Lea was the original author of @code{libg++}, and some of +the file-management code still in @code{libio} is his. + +Various people found bugs or offered suggestions. Hongjiu Lu worked +hard to use the library as the default stdio implementation for Linux, +and has provided much stress-testing of the library. + +@node Operators +@chapter Operators and Default Streams + +The @sc{gnu} iostream library, @file{libio}, implements the standard +input and output facilities for C++. These facilities are roughly +analogous (in their purpose and ubiquity, at least) with those defined +by the C @file{stdio} functions. + +Although these definitions come from a library, rather than being part +of the ``core language'', they are sufficiently central to be specified +in the latest working papers for C++. + +You can use two operators defined in this library for basic input and +output operations. They are familiar from any C++ introductory +textbook: @code{<<} for output, and @code{>>} for input. (Think of data +flowing in the direction of the ``arrows''.) + +These operators are often used in conjunction with three streams that +are open by default: + +@deftypevar ostream cout +The standard output stream, analogous to the C @code{stdout}. +@end deftypevar + +@deftypevar istream cin +The standard input stream, analogous to the C @code{stdin}. +@end deftypevar + +@deftypevar ostream cerr +An alternative output stream for errors, analogous to the C +@code{stderr}. +@end deftypevar + +@noindent +For example, this bare-bones C++ version of the traditional ``hello'' +program uses @code{<<} and @code{cout}: + +@example +#include + +int main(int argc, char **argv) +@{ + cout << "Well, hi there.\n"; + return 0; +@} +@end example + +Casual use of these operators may be seductive, but---other than in +writing throwaway code for your own use---it is not necessarily simpler +than managing input and output in any other language. For example, +robust code should check the state of the input and output streams +between operations (for example, using the method @code{good}). +@xref{States,,Checking the state of a stream}. You may also need to +adjust maximum input or output field widths, using manipulators like +@code{setw} or @code{setprecision}. + +@defop Operator ostream << +Write output to an open output stream of class @code{ostream}. +Defined by this library on any @var{object} of a C++ primitive type, and +on other classes of the library. You can overload the definition for any +of your own applications' classes. + +Returns a reference to the implied argument @code{*this} (the open stream it +writes on), permitting statements like +@example +cout << "The value of i is " << i << "\n"; +@end example +@end defop + +@defop Operator istream >> +Read input from an open input stream of class @code{istream}. Defined +by this library on primitive numeric, pointer, and string types; you can +extend the definition for any of your own applications' classes. + +Returns a reference to the implied argument @code{*this} (the open stream +it reads), permitting multiple inputs in one statement. +@end defop + +@node Streams +@chapter Stream Classes + +The previous chapter referred in passing to the classes @code{ostream} +and @code{istream}, for output and input respectively. These classes +share certain properties, captured in their base class @code{ios}. + +@menu +* Ios:: Shared properties. +* Ostream:: Managing output streams. +* Istream:: Managing input streams. +* Iostream:: Input and output together. +@end menu + +@node Ios +@section Shared properties: class @code{ios} + +The base class @code{ios} provides methods to test and manage the state +of input or output streams. + +@code{ios} delegates the job of actually reading and writing bytes to +the abstract class @code{streambuf}, which is designed to provide +buffered streams (compatible with C, in the @sc{gnu} implementation). +@xref{Streambuf,,Using the @code{streambuf} layer}, for information on +the facilities available at the @code{streambuf} level. + +@deftypefn Constructor {} ios::ios ([streambuf* @var{sb} @w{[, ostream*} @var{tie}]) +The @code{ios} constructor by default initializes a new @code{ios}, and +if you supply a @code{streambuf} @var{sb} to associate with it, sets the +state @code{good} in the new @code{ios} object. It also sets the +default properties of the new object. + +@ignore +@c FIXME--future: this (a) doesn't work, (b) is controversial at ANSI +An @code{ios} without a @code{streambuf} has the state @code{bad} until +you supply a @code{streambuf}; you can do that by assigning a new value +to the @code{ios} with @samp{=}. +@end ignore + +You can also supply an optional second argument @var{tie} to the +constructor: if present, it is an initial value for @code{ios::tie}, to +associate the new @code{ios} object with another stream. +@end deftypefn + +@deftypefn Destructor {} ios::~ios () +The @code{ios} destructor is virtual, permitting application-specific +behavior when a stream is closed---typically, the destructor frees any +storage associated with the stream and releases any other associated +objects. +@end deftypefn + +@c FIXME-future: Is @deftypefn really the best way of displaying these? + +@c FIXME-future: Undocumented: ios::_throw_failure, ios::exceptions; things +@c controlled by _STREAM_COMPAT; ios::Init; ios::_IO_fix_vtable. + +@menu +* States:: Checking the state of a stream. +* Format Control:: Choices in formatting. +* Manipulators:: Convenient ways of changing stream properties. +* Extending:: Extended data fields. +* Synchronization:: Synchronizing related streams. +* Streambuf from Ios:: Reaching the underlying streambuf. +@end menu + +@node States +@subsection Checking the state of a stream + +Use this collection of methods to test for (or signal) errors and other +exceptional conditions of streams: + +@deftypefn Method {ios::operator void*} () const +You can do a quick check on the state of the most recent operation on a +stream by examining a pointer to the stream itself. The pointer is +arbitrary except for its truth value; it is true if no failures have +occurred (@code{ios::fail} is not true). For example, you might ask for +input on @code{cin} only if all prior output operations succeeded: + +@example +if (cout) +@{ + // Everything OK so far + cin >> new_value; + @dots{} +@} +@end example +@end deftypefn + +@deftypefn Method {ios::operator !} () const +In case it is more convenient to check whether something has failed, the +operator @code{!} returns true if @code{ios::fail} is true (an operation +has failed). For example, +you might issue an error message if input failed: + +@example +if (!cin) +@{ + // Oops + cerr << "Eh?\n"; +@} +@end example +@end deftypefn + +@deftypefn Method iostate ios::rdstate () const +Return the state flags for this stream. The value is from the +enumeration @code{iostate}. You can test for any combination of + +@vtable @code +@item goodbit +There are no indications of exceptional states on this stream. + +@item eofbit +End of file. + +@item failbit +An operation has failed on this stream; this usually indicates bad +format of input. + +@item badbit +The stream is unusable. +@end vtable +@end deftypefn + +@deftypefn Method void ios::setstate (iostate @var{state}) +@findex ios::set +Set the state flag for this stream to @var{state} @emph{in addition to} +any state flags already set. Synonym (for upward compatibility): +@code{ios::set}. + +See @code{ios::clear} to set the stream state without regard to existing +state flags. See @code{ios::good}, @code{ios::eof}, @code{ios::fail}, +and @code{ios::bad}, to test the state. +@end deftypefn + +@deftypefn Method int ios::good () const +Test the state flags associated with this stream; true if no error +indicators are set. +@end deftypefn + +@deftypefn Method int ios::bad () const +Test whether a stream is marked as unusable. (Whether +@code{ios::badbit} is set.) +@end deftypefn + +@deftypefn Method int ios::eof () const +True if end of file was reached on this stream. (If @code{ios::eofbit} +is set.) +@end deftypefn + +@deftypefn Method int ios::fail () const +Test for any kind of failure on this stream: @emph{either} some +operation failed, @emph{or} the stream is marked as bad. (If either +@code{ios::failbit} or @code{ios::badbit} is set.) +@end deftypefn + +@deftypefn Method void ios::clear (iostate @var{state}) +@c FIXME-future: There is some complication to do with buffering and _throw_failure +Set the state indication for this stream to the argument @var{state}. +You may call @code{ios::clear} with no argument, in which case the state +is set to @code{good} (no errors pending). + +See @code{ios::good}, @code{ios::eof}, @code{ios::fail}, and +@code{ios::bad}, to test the state; see @code{ios::set} or +@code{ios::setstate} for an alternative way of setting the state. +@end deftypefn + +@node Format Control +@subsection Choices in formatting + +These methods control (or report on) settings for some details of +controlling streams, primarily to do with formatting output: + +@deftypefn Method char ios::fill () const +Report on the padding character in use. +@end deftypefn + +@deftypefn Method char ios::fill (char @var{padding}) +Set the padding character. You can also use the manipulator +@code{setfill}. @xref{Manipulators,,Changing stream properties in +expressions}. + +Default: blank. +@end deftypefn + +@deftypefn Method int ios::precision () const +Report the number of significant digits currently in use for output of +floating point numbers. + +Default: @code{6}. +@end deftypefn + +@deftypefn Method int ios::precision (int @var{signif}) +Set the number of significant digits (for input and output numeric +conversions) to @var{signif}. + +@findex setprecision +@cindex setting @code{ios::precision} +You can also use the manipulator @code{setprecision} for this purpose. +@xref{Manipulators,,Changing stream properties using manipulators}. +@end deftypefn + +@deftypefn Method int ios::width () const +Report the current output field width setting (the number of +characters to write on the next @samp{<<} output operation). + +Default: @code{0}, which means to use as many characters as necessary. +@end deftypefn + +@deftypefn Method int ios::width (int @var{num}) +Set the input field width setting to @var{num}. Return the +@emph{previous} value for this stream. + +@findex setw +@cindex setting @code{ios::width} +This value resets to zero (the default) every time you use @samp{<<}; it is +essentially an additional implicit argument to that operator. You can +also use the manipulator @code{setw} for this purpose. +@xref{Manipulators,,Changing stream properties using manipulators}. +@end deftypefn + +@need 2000 +@deftypefn Method fmtflags ios::flags () const +Return the current value of the complete collection of flags controlling +the format state. These are the flags and their meanings when set: + +@vtable @code +@item ios::dec +@itemx ios::oct +@itemx ios::hex +What numeric base to use in converting integers from internal to display +representation, or vice versa: decimal, octal, or hexadecimal, +respectively. (You can change the base using the manipulator +@code{setbase}, or any of the manipulators @code{dec}, @code{oct}, or +@code{hex}; @pxref{Manipulators,,Changing stream properties in +expressions}.) + +On input, if none of these flags is set, read numeric constants +according to the prefix: decimal if no prefix (or a @samp{.} suffix), +octal if a @samp{0} prefix is present, hexadecimal if a @samp{0x} prefix +is present. + +Default: @code{dec}. + +@item ios::fixed +Avoid scientific notation, and always show a fixed number of digits after +the decimal point, according to the output precision in effect. +Use @code{ios::precision} to set precision. + +@item ios::left +@itemx ios::right +@itemx ios::internal +Where output is to appear in a fixed-width field; left-justified, +right-justified, or with padding in the middle (e.g. between a numeric +sign and the associated value), respectively. + +@item ios::scientific +Use scientific (exponential) notation to display numbers. + +@item ios::showbase +Display the conventional prefix as a visual indicator of the conversion +base: no prefix for decimal, @samp{0} for octal, @samp{0x} for hexadecimal. + +@item ios::showpoint +Display a decimal point and trailing zeros after it to fill out numeric +fields, even when redundant. + +@item ios::showpos +Display a positive sign on display of positive numbers. + +@item ios::skipws +Skip white space. (On by default). + +@item ios::stdio +Flush the C @code{stdio} streams @code{stdout} and @code{stderr} after +each output operation (for programs that mix C and C++ output conventions). + +@item ios::unitbuf +Flush after each output operation. + +@item ios::uppercase +Use upper-case characters for the non-numeral elements in numeric +displays; for instance, @samp{0X7A} rather than @samp{0x7a}, or +@samp{3.14E+09} rather than @samp{3.14e+09}. +@end vtable +@end deftypefn + +@deftypefn Method fmtflags ios::flags (fmtflags @var{value}) +Set @var{value} as the complete collection of flags controlling the +format state. The flag values are described under @samp{ios::flags ()}. + +Use @code{ios::setf} or @code{ios::unsetf} to change one property at a +time. +@end deftypefn + +@deftypefn Method fmtflags ios::setf (fmtflags @var{flag}) +Set one particular flag (of those described for @samp{ios::flags ()}; +return the complete collection of flags @emph{previously} in effect. +(Use @code{ios::unsetf} to cancel.) +@end deftypefn + +@deftypefn Method fmtflags ios::setf (fmtflags @var{flag}, fmtflags @var{mask}) +Clear the flag values indicated by @var{mask}, then set any of them that +are also in @var{flag}. (Flag values are described for @samp{ios::flags +()}.) Return the complete collection of flags @emph{previously} in +effect. (See @code{ios::unsetf} for another way of clearing flags.) +@end deftypefn + +@deftypefn Method fmtflags ios::unsetf (fmtflags @var{flag}) +Make certain @var{flag} (a combination of flag values described for +@samp{ios::flags ()}) is not set for this stream; converse of +@code{ios::setf}. Returns the old values of those flags. +@c FIXME-future: should probably be fixed to give same result as setf. +@end deftypefn + +@node Manipulators +@subsection Changing stream properties using manipulators + +For convenience, @var{manipulators} provide a way to change certain +properties of streams, or otherwise affect them, in the middle of +expressions involving @samp{<<} or @samp{>>}. For example, you might +write + +@example +cout << "|" << setfill('*') << setw(5) << 234 << "|"; +@end example + +@noindent +to produce @samp{|**234|} as output. + +@deftypefn Manipulator {} ws +Skip whitespace. +@end deftypefn + +@deftypefn Manipulator {} flush +Flush an output stream. For example, @samp{cout << @dots{} <}. +@end deftypefn + +@deftypefn Manipulator {} setw (int @var{n}) +You can change the value of @code{ios::width} in @samp{<<} expressions +with the manipulator @samp{setw(@var{n})}; for example, + +@example +cout << setw(5) << 234; +@end example + +@noindent +prints @w{@samp{ 234}} with two leading blanks. Requires @file{#include +}. +@end deftypefn + +@deftypefn Manipulator {} setbase (int @var{base}) +Where @var{base} is one of @code{10} (decimal), @code{8} (octal), or +@code{16} (hexadecimal), change the base value for numeric +representations. Requires @file{#include }. +@end deftypefn + +@deftypefn Manipulator {} dec +Select decimal base; equivalent to @samp{setbase(10)}. +@end deftypefn + +@deftypefn Manipulator {} hex +Select hexadecimal base; equivalent to @samp{setbase(16)}. +@end deftypefn + +@deftypefn Manipulator {} oct +Select octal base; equivalent to @samp{setbase(8)}. +@end deftypefn + +@deftypefn Manipulator {} setfill (char @var{padding}) +Set the padding character, in the same way as @code{ios::fill}. +Requires @file{#include }. +@end deftypefn + +@node Extending +@subsection Extended data fields + +A related collection of methods allows you to extend this collection of +flags and parameters for your own applications, without risk of conflict +between them: + +@deftypefn Method {static fmtflags} ios::bitalloc () +Reserve a bit (the single bit on in the result) to use as a flag. Using +@code{bitalloc} guards against conflict between two packages that use +@code{ios} objects for different purposes. + +This method is available for upward compatibility, but is not in the +@sc{ansi} working paper. The number of bits available is limited; a +return value of @code{0} means no bit is available. +@end deftypefn + +@deftypefn Method {static int} ios::xalloc () +Reserve space for a long integer or pointer parameter. The result is a +unique nonnegative integer. You can use it as an index to +@code{ios::iword} or @code{ios::pword}. Use @code{xalloc} to arrange +for arbitrary special-purpose data in your @code{ios} objects, without +risk of conflict between packages designed for different purposes. +@end deftypefn + +@deftypefn Method long& ios::iword (int @var{index}) +Return a reference to arbitrary data, of long integer type, stored in an +@code{ios} instance. @var{index}, conventionally returned from +@code{ios::xalloc}, identifies what particular data you need. +@end deftypefn + +@deftypefn Method long ios::iword (int @var{index}) const +Return the actual value of a long integer stored in an @code{ios}. +@end deftypefn + +@deftypefn Method void*& ios::pword (int @var{index}) +Return a reference to an arbitrary pointer, stored in an @code{ios} +instance. @var{index}, originally returned from @code{ios::xalloc}, +identifies what particular pointer you need. +@end deftypefn + +@deftypefn Method void* ios::pword (int @var{index}) const +Return the actual value of a pointer stored in an @code{ios}. +@end deftypefn + +@node Synchronization +@subsection Synchronizing related streams + +You can use these methods to synchronize related streams with +one another: + +@deftypefn Method ostream* ios::tie () const +Report on what output stream, if any, is to be flushed before accessing +this one. A pointer value of @code{0} means no stream is tied. +@end deftypefn + +@deftypefn Method ostream* ios::tie (ostream* @var{assoc}) +Declare that output stream @var{assoc} must be flushed before accessing +this stream. +@end deftypefn + +@deftypefn Method int ios::sync_with_stdio ([int @var{switch}]) +Unless iostreams and C @code{stdio} are designed to work together, you +may have to choose between efficient C++ streams output and output +compatible with C @code{stdio}. Use @samp{ios::sync_with_stdio()} to +select C compatibility. + +The argument @var{switch} is a @sc{gnu} extension; use @code{0} as the +argument to choose output that is not necessarily compatible with C +@code{stdio}. The default value for @var{switch} is @code{1}. + +If you install the @code{stdio} implementation that comes with @sc{gnu} +@code{libio}, there are compatible input/output facilities for both C +and C++. In that situation, this method is unnecessary---but you may +still want to write programs that call it, for portability. +@end deftypefn + +@node Streambuf from Ios +@subsection Reaching the underlying @code{streambuf} + +Finally, you can use this method to access the underlying object: + +@deftypefn Method streambuf* ios::rdbuf () const +Return a pointer to the @code{streambuf} object that underlies this +@code{ios}. +@end deftypefn + +@node Ostream +@section Managing output streams: class @code{ostream} + +Objects of class @code{ostream} inherit the generic methods from +@code{ios}, and in addition have the following methods available. +Declarations for this class come from @file{iostream.h}. + +@deftypefn Constructor {} ostream::ostream () +The simplest form of the constructor for an @code{ostream} simply +allocates a new @code{ios} object. +@end deftypefn + +@deftypefn Constructor {} ostream::ostream (streambuf* @var{sb} @w{[, ostream} @var{tie}]) +This alternative constructor requires a first argument @var{sb} of type +@code{streambuf*}, to use an existing open stream for output. It also +accepts an optional second argument @var{tie}, to specify a related +@code{ostream*} as the initial value for @code{ios::tie}. + +If you give the @code{ostream} a @code{streambuf} explicitly, using +this constructor, the @var{sb} is @emph{not} destroyed (or deleted or +closed) when the @code{ostream} is destroyed. +@end deftypefn + +@menu +* Writing:: Writing on an ostream. +* Output Position:: Repositioning an ostream. +* Ostream Housekeeping:: Miscellaneous ostream utilities. +@end menu + +@node Writing +@subsection Writing on an @code{ostream} + +These methods write on an @code{ostream} (you may also use the operator +@code{<<}; @pxref{Operators,,Operators and Default Streams}). + +@deftypefn Method ostream& ostream::put (char @var{c}) +Write the single character @var{c}. +@end deftypefn + +@deftypefn Method ostream& ostream::write (@var{string}, int @var{length}) +Write @var{length} characters of a string to this @code{ostream}, +beginning at the pointer @var{string}. + +@var{string} may have any of these types: @code{char*}, @code{unsigned +char*}, @code{signed char*}. +@end deftypefn + +@deftypefn Method ostream& ostream::form (const char *@var{format}, ...) +A @sc{gnu} extension, similar to @code{fprintf(@var{file}, +@var{format}, ...)}. + +@var{format} is a @code{printf}-style format control string, which is used +to format the (variable number of) arguments, printing the result on +this @code{ostream}. See @code{ostream::vform} for a version that uses +an argument list rather than a variable number of arguments. +@end deftypefn + +@deftypefn Method ostream& ostream::vform (const char *@var{format}, va_list @var{args}) +A @sc{gnu} extension, similar to @code{vfprintf(@var{file}, +@var{format}, @var{args})}. + +@var{format} is a @code{printf}-style format control string, which is used +to format the argument list @var{args}, printing the result on +this @code{ostream}. See @code{ostream::form} for a version that uses a +variable number of arguments rather than an argument list. +@end deftypefn + +@node Output Position +@subsection Repositioning an @code{ostream} + +You can control the output position (on output streams that actually +support positions, typically files) with these methods: +@c FIXME-future: sort out which classes support this and which +@c don't; fstream, filebuf? And what is failure condition when not supported? + +@deftypefn Method streampos ostream::tellp () +Return the current write position in the stream. +@end deftypefn + +@deftypefn Method ostream& ostream::seekp (streampos @var{loc}) +Reset the output position to @var{loc} (which is usually the result of a +previous call to @code{ostream::tellp}). @var{loc} specifies an +absolute position in the output stream. +@end deftypefn + +@deftypefn Method ostream& ostream::seekp (streamoff @var{loc}, @var{rel}) +@findex ios::seekdir +Reset the output position to @var{loc}, relative to the beginning, end, +or current output position in the stream, as indicated by @var{rel} (a +value from the enumeration @code{ios::seekdir}): + +@vtable @code +@item beg +Interpret @var{loc} as an absolute offset from the beginning of the +file. + +@item cur +Interpret @var{loc} as an offset relative to the current output +position. + +@item end +Interpret @var{loc} as an offset from the current end of the output +stream. +@end vtable +@end deftypefn + +@node Ostream Housekeeping +@subsection Miscellaneous @code{ostream} utilities + +You may need to use these @code{ostream} methods for housekeeping: + +@deftypefn Method ostream& flush () +Deliver any pending buffered output for this @code{ostream}. +@end deftypefn + +@deftypefn Method int ostream::opfx () +@code{opfx} is a @dfn{prefix} method for operations on @code{ostream} +objects; it is designed to be called before any further processing. See +@code{ostream::osfx} for the converse. +@c FIXME-future: specify sometime which methods start with opfx. + +@code{opfx} tests that the stream is in state @code{good}, and if so +flushes any stream tied to this one. + +The result is @code{1} when @code{opfx} succeeds; else (if the stream state is +not @code{good}), the result is @code{0}. +@end deftypefn + +@deftypefn Method void ostream::osfx () +@code{osfx} is a @dfn{suffix} method for operations on @code{ostream} +objects; it is designed to be called at the conclusion of any processing. All +the @code{ostream} methods end by calling @code{osfx}. See +@code{ostream::opfx} for the converse. + +If the @code{unitbuf} flag is set for this stream, @code{osfx} flushes +any buffered output for it. + +If the @code{stdio} flag is set for this stream, @code{osfx} flushes any +output buffered for the C output streams @file{stdout} and @file{stderr}. +@end deftypefn + +@node Istream +@section Managing input streams: class @code{istream} + +Class @code{istream} objects are specialized for input; as for +@code{ostream}, they are derived from @code{ios}, so you can use any of +the general-purpose methods from that base class. Declarations for this +class also come from @file{iostream.h}. + +@deftypefn Constructor {} istream::istream () +When used without arguments, the @code{istream} constructor simply +allocates a new @code{ios} object and initializes the input counter (the +value reported by @code{istream::gcount}) to @code{0}. +@end deftypefn + +@deftypefn Constructor {} istream::istream (streambuf *@var{sb} @w{[, ostream} @var{tie}]) +You can also call the constructor with one or two arguments. The first +argument @var{sb} is a @code{streambuf*}; if you supply this pointer, +the constructor uses that @code{streambuf} for input. +You can use the second optional argument @var{tie} to specify a related +output stream as the initial value for @code{ios::tie}. + +If you give the @code{istream} a @code{streambuf} explicitly, using +this constructor, the @var{sb} is @emph{not} destroyed (or deleted or +closed) when the @code{ostream} is destroyed. +@end deftypefn + +@menu +* Char Input:: Reading one character. +* String Input:: Reading strings. +* Input Position:: Repositioning an istream. +* Istream Housekeeping:: Miscellaneous istream utilities. +@end menu + +@node Char Input +@subsection Reading one character + +Use these methods to read a single character from the input stream: + +@deftypefn Method int istream::get () +Read a single character (or @code{EOF}) from the input stream, returning +it (coerced to an unsigned char) as the result. +@end deftypefn + +@deftypefn Method istream& istream::get (char& @var{c}) +Read a single character from the input stream, into @code{&@var{c}}. +@end deftypefn + +@deftypefn Method int istream::peek () +Return the next available input character, but @emph{without} changing +the current input position. +@end deftypefn + +@node String Input +@subsection Reading strings + +Use these methods to read strings (for example, a line at a time) from +the input stream: + +@deftypefn Method istream& istream::get (char* @var{c}, int @var{len} @w{[, char} @var{delim}]) +Read a string from the input stream, into the array at @var{c}. + +The remaining arguments limit how much to read: up to @samp{len-1} +characters, or up to (but not including) the first occurrence in the +input of a particular delimiter character @var{delim}---newline +(@code{\n}) by default. (Naturally, if the stream reaches end of file +first, that too will terminate reading.) + +If @var{delim} was present in the input, it remains available as if +unread; to discard it instead, see @code{iostream::getline}. + +@code{get} writes @samp{\0} at the end of the string, regardless +of which condition terminates the read. +@end deftypefn + +@deftypefn Method istream& istream::get (streambuf& @var{sb} @w{[, char} @var{delim}]) +Read characters from the input stream and copy them on the +@code{streambuf} object @var{sb}. Copying ends either just before the +next instance of the delimiter character @var{delim} (newline @code{\n} +by default), or when either stream ends. If @var{delim} was present in +the input, it remains available as if unread. +@end deftypefn + +@deftypefn Method istream& istream::getline (@var{charptr}, int @var{len} @w{[, char} @var{delim}]) +Read a line from the input stream, into the array at @var{charptr}. +@var{charptr} may be any of three kinds of pointer: @code{char*}, +@code{unsigned char*}, or @code{signed char*}. + +The remaining arguments limit how much to read: up to (but not +including) the first occurrence in the input of a line delimiter +character @var{delim}---newline (@code{\n}) by default, or up to +@samp{len-1} characters (or to end of file, if that happens sooner). + +If @code{getline} succeeds in reading a ``full line'', it also discards +the trailing delimiter character from the input stream. (To preserve it +as available input, see the similar form of @code{iostream::get}.) + +If @var{delim} was @emph{not} found before @var{len} characters or end +of file, @code{getline} sets the @code{ios::fail} flag, as well as the +@code{ios::eof} flag if appropriate. + +@code{getline} writes a null character at the end of the string, regardless +of which condition terminates the read. +@end deftypefn + +@deftypefn Method istream& istream::read (@var{pointer}, int @var{len}) +Read @var{len} bytes into the location at @var{pointer}, unless the +input ends first. + +@var{pointer} may be of type @code{char*}, @code{void*}, @code{unsigned +char*}, or @code{signed char*}. + +If the @code{istream} ends before reading @var{len} bytes, @code{read} +sets the @code{ios::fail} flag. +@end deftypefn + +@deftypefn Method istream& istream::gets (char **@var{s} @w{[, char} @var{delim}]) +A @sc{gnu} extension, to read an arbitrarily long string +from the current input position to the next instance of the @var{delim} +character (newline @code{\n} by default). + +To permit reading a string of arbitrary length, @code{gets} allocates +whatever memory is required. Notice that the first argument @var{s} is +an address to record a character pointer, rather than the pointer +itself. +@end deftypefn + +@deftypefn Method istream& istream::scan (const char *format ...) +A @sc{gnu} extension, similar to @code{fscanf(@var{file}, +@var{format}, ...)}. The @var{format} is a @code{scanf}-style format +control string, which is used to read the variables in the remainder of +the argument list from the @code{istream}. +@end deftypefn + +@deftypefn Method istream& istream::vscan (const char *format, va_list args) +Like @code{istream::scan}, but takes a single @code{va_list} argument. +@end deftypefn + +@node Input Position +@subsection Repositioning an @code{istream} + +Use these methods to control the current input position: + +@deftypefn Method streampos istream::tellg () +Return the current read position, so that you can save it and return to +it later with @code{istream::seekg}. +@end deftypefn + +@deftypefn Method istream& istream::seekg (streampos @var{p}) +Reset the input pointer (if the input device permits it) to @var{p}, +usually the result of an earlier call to @code{istream::tellg}. +@end deftypefn + +@deftypefn Method istream& istream::seekg (streamoff @var{offset}, ios::seek_dir @var{ref}) +Reset the input pointer (if the input device permits it) to @var{offset} +characters from the beginning of the input, the current position, or the +end of input. Specify how to interpret @var{offset} with one of these +values for the second argument: + +@vtable @code +@item ios::beg +Interpret @var{loc} as an absolute offset from the beginning of the +file. + +@item ios::cur +Interpret @var{loc} as an offset relative to the current output +position. + +@item ios::end +Interpret @var{loc} as an offset from the current end of the output +stream. +@end vtable +@end deftypefn + +@node Istream Housekeeping +@subsection Miscellaneous @code{istream} utilities + +Use these methods for housekeeping on @code{istream} objects: + +@deftypefn Method int istream::gcount () +Report how many characters were read from this @code{istream} in the +last unformatted input operation. +@c FIXME! Define "unformatted input" somewhere... +@end deftypefn + +@deftypefn Method int istream::ipfx (int @var{keepwhite}) +Ensure that the @code{istream} object is ready for reading; check for +errors and end of file and flush any tied stream. @code{ipfx} skips +whitespace if you specify @code{0} as the @var{keepwhite} +argument, @emph{and} @code{ios::skipws} is set for this stream. + +To avoid skipping whitespace (regardless of the @code{skipws} setting on +the stream), use @code{1} as the argument. + +Call @code{istream::ipfx} to simplify writing your own methods for reading +@code{istream} objects. +@end deftypefn + +@deftypefn Method void istream::isfx () +A placeholder for compliance with the draft @sc{ansi} standard; this +method does nothing whatever. + +If you wish to write portable standard-conforming code on @code{istream} +objects, call @code{isfx} after any operation that reads from an +@code{istream}; if @code{istream::ipfx} has any special effects that +must be cancelled when done, @code{istream::isfx} will cancel them. +@end deftypefn + +@deftypefn Method istream& istream::ignore ([int @var{n}] @w{[, int} @var{delim}]) +Discard some number of characters pending input. The first optional +argument @var{n} specifies how many characters to skip. The second +optional argument @var{delim} specifies a ``boundary'' character: +@code{ignore} returns immediately if this character appears in the +input. + +By default, @var{delim} is @code{EOF}; that is, if you do not specify a +second argument, only the count @var{n} restricts how much to ignore +(while input is still available). + +If you do not specify how many characters to ignore, @code{ignore} +returns after discarding only one character. +@end deftypefn + +@deftypefn Method istream& istream::putback (char @var{ch}) +Attempts to back up one character, replacing the character backed-up +over by @var{ch}. Returns @code{EOF} if this is not allowed. Putting +back the most recently read character is always allowed. (This method +corresponds to the C function @code{ungetc}.) +@end deftypefn + +@deftypefn Method istream& istream::unget () +Attempt to back up one character. +@end deftypefn + +@node Iostream +@section Input and output together: class @code{iostream} + +If you need to use the same stream for input and output, you can use an +object of the class @code{iostream}, which is derived from @emph{both} +@code{istream} and @code{ostream}. + +The constructors for @code{iostream} behave just like the constructors +for @code{istream}. + +@deftypefn Constructor {} iostream::iostream () +When used without arguments, the @code{iostream} constructor simply +allocates a new @code{ios} object, and initializes the input counter +(the value reported by @code{istream::gcount}) to @code{0}. +@end deftypefn + +@deftypefn Constructor {} iostream::iostream (streambuf* @var{sb} @w{[, ostream*} @var{tie}]) +You can also call a constructor with one or two arguments. The first +argument @var{sb} is a @code{streambuf*}; if you supply this pointer, +the constructor uses that @code{streambuf} for input and output. + +You can use the optional second argument @var{tie} (an @code{ostream*}) +to specify a related output stream as the initial value for +@code{ios::tie}. +@end deftypefn + +@cindex @code{iostream} destructor +@cindex destructor for @code{iostream} +As for @code{ostream} and @code{istream}, @code{iostream} simply uses +the @code{ios} destructor. However, an @code{iostream} is not deleted by +its destructor. + +You can use all the @code{istream}, @code{ostream}, and @code{ios} +methods with an @code{iostream} object. + +@node Files and Strings +@chapter Classes for Files and Strings + +There are two very common special cases of input and output: using files, +and using strings in memory. + +@code{libio} defines four specialized classes for these cases: + +@ftable @code +@item ifstream +Methods for reading files. + +@item ofstream +Methods for writing files. + +@item istrstream +Methods for reading strings from memory. + +@item ostrstream +Methods for writing strings in memory. +@end ftable + +@menu +* Files:: Reading and writing files. +* Strings:: Reading and writing strings in memory. +@end menu + +@node Files +@section Reading and writing files + +These methods are declared in @file{fstream.h}. + +@findex ifstream +@cindex class @code{ifstream} +You can read data from class @code{ifstream} with any operation from class +@code{istream}. There are also a few specialized facilities: + +@deftypefn Constructor {} ifstream::ifstream () +Make an @code{ifstream} associated with a new file for input. (If you +use this version of the constructor, you need to call +@code{ifstream::open} before actually reading anything) +@end deftypefn + +@deftypefn Constructor {} ifstream::ifstream (int @var{fd}) +Make an @code{ifstream} for reading from a file that was already open, +using file descriptor @var{fd}. (This constructor is compatible with +other versions of iostreams for @sc{posix} systems, but is not part of +the @sc{ansi} working paper.) +@end deftypefn + +@deftypefn Constructor {} ifstream::ifstream (const char* @var{fname} @w{[, int} @var{mode} @w{[, int} @var{prot}]]) +Open a file @code{*@var{fname}} for this @code{ifstream} object. + +By default, the file is opened for input (with @code{ios::in} as +@var{mode}). If you use this constructor, the file will be closed when +the @code{ifstream} is destroyed. + +You can use the optional argument @var{mode} to specify how to open the +file, by combining these enumerated values (with @samp{|} bitwise or). +(These values are actually defined in class @code{ios}, so that all +file-related streams may inherit them.) Only some of these modes are +defined in the latest draft @sc{ansi} specification; if portability is +important, you may wish to avoid the others. + +@vtable @code +@item ios::in +Open for input. (Included in @sc{ansi} draft.) + +@item ios::out +Open for output. (Included in @sc{ansi} draft.) + +@item ios::ate +Set the initial input (or output) position to the end of the file. + +@item ios::app +Seek to end of file before each write. (Included in @sc{ansi} draft.) + +@item ios::trunc +Guarantee a fresh file; discard any contents that were previously +associated with it. + +@item ios::nocreate +Guarantee an existing file; fail if the specified file did not already +exist. + +@item ios::noreplace +Guarantee a new file; fail if the specified file already existed. + +@item ios::bin +Open as a binary file (on systems where binary and text files have different +properties, typically how @samp{\n} is mapped; included in @sc{ansi} draft). +@end vtable + +@noindent +The last optional argument @var{prot} is specific to Unix-like systems; +it specifies the file protection (by default @samp{644}). +@end deftypefn + +@deftypefn Method void ifstream::open (const char* @var{fname} @w{[, int} @var{mode} @w{[, int} @var{prot}]]) +Open a file explicitly after the associated @code{ifstream} object +already exists (for instance, after using the default constructor). The +arguments, options and defaults all have the same meanings as in the +fully specified @code{ifstream} constructor. +@end deftypefn + +@findex ostream +@cindex class @code{ostream} +You can write data to class @code{ofstream} with any operation from class +@code{ostream}. There are also a few specialized facilities: + +@deftypefn Constructor {} ofstream::ofstream () +Make an @code{ofstream} associated with a new file for output. +@end deftypefn + +@deftypefn Constructor {} ofstream::ofstream (int @var{fd}) +Make an @code{ofstream} for writing to a file that was already open, +using file descriptor @var{fd}. +@end deftypefn + +@deftypefn Constructor {} ofstream::ofstream (const char* @var{fname} @w{[, int} @var{mode} @w{[, int} @var{prot}]]) +Open a file @code{*@var{fname}} for this @code{ofstream} object. + +By default, the file is opened for output (with @code{ios::out} as @var{mode}). +You can use the optional argument @var{mode} to specify how to open the +file, just as described for @code{ifstream::ifstream}. + +The last optional argument @var{prot} specifies the file protection (by +default @samp{644}). +@end deftypefn + +@deftypefn Destructor {} ofstream::~ofstream () +The files associated with @code{ofstream} objects are closed when the +corresponding object is destroyed. +@end deftypefn + +@deftypefn Method void ofstream::open (const char* @var{fname} @w{[, int} @var{mode} @w{[, int} @var{prot}]]) +Open a file explicitly after the associated @code{ofstream} object +already exists (for instance, after using the default constructor). The +arguments, options and defaults all have the same meanings as in the +fully specified @code{ofstream} constructor. +@end deftypefn + +@findex fstream +@cindex class @code{fstream} +The class @code{fstream} combines the facilities of @code{ifstream} and +@code{ofstream}, just as @code{iostream} combines @code{istream} and +@code{ostream}. + +@c FIXME-future: say something about fstream constructor, maybe. + +@findex fstreambase +@cindex class @code{fstreambase} +The class @code{fstreambase} underlies both @code{ifstream} and +@code{ofstream}. They both inherit this additional method: + +@deftypefn Method void fstreambase::close () +Close the file associated with this object, and set @code{ios::fail} in +this object to mark the event. +@end deftypefn + +@node Strings +@section Reading and writing in memory + +@c FIXME!! Per, there's a lot of guesswork here---please check carefully! + +@findex istrstream +@cindex class @code{istrstream} +@findex ostrstream +@cindex class @code{ostrstream} +@findex strstream +@cindex class @code{strstream} +@findex strstreambase +@cindex class @code{strstreambase} +@findex strstreambuf +@cindex class @code{strstreambuf} +The classes @code{istrstream}, @code{ostrstream}, and @code{strstream} +provide some additional features for reading and writing strings in +memory---both static strings, and dynamically allocated strings. The +underlying class @code{strstreambase} provides some features common to +all three; @code{strstreambuf} underlies that in turn. + +@c FIXME-future: Document strstreambuf methods one day, when we document +@c streambuf more fully. + +@deftypefn Constructor {} istrstream::istrstream (const char* @var{str} @w{[, int} @var{size}]) +Associate the new input string class @code{istrstream} with an existing +static string starting at @var{str}, of size @var{size}. If you do not +specify @var{size}, the string is treated as a @code{NUL} terminated string. +@end deftypefn + +@deftypefn Constructor {} ostrstream::ostrstream () +Create a new stream for output to a dynamically managed string, which +will grow as needed. +@end deftypefn + +@deftypefn Constructor {} ostrstream::ostrstream (char* @var{str}, int @var{size} [,int @var{mode}]) +A new stream for output to a statically defined string of length +@var{size}, starting at @var{str}. You may optionally specify one of +the modes described for @code{ifstream::ifstream}; if you do not specify +one, the new stream is simply open for output, with mode @code{ios::out}. +@end deftypefn + +@deftypefn Method int ostrstream::pcount () +Report the current length of the string associated with this @code{ostrstream}. +@end deftypefn + +@deftypefn Method char* ostrstream::str () +A pointer to the string managed by this @code{ostrstream}. Implies +@samp{ostrstream::freeze()}. + +Note that if you want the string to be nul-terminated, +you must do that yourself (perhaps by writing ends to the stream). +@end deftypefn + +@deftypefn Method void ostrstream::freeze ([int @var{n}]) +If @var{n} is nonzero (the default), declare that the string associated +with this @code{ostrstream} is not to change dynamically; while frozen, +it will not be reallocated if it needs more space, and it will not be +deallocated when the @code{ostrstream} is destroyed. Use +@samp{freeze(1)} if you refer to the string as a pointer after creating +it via @code{ostrstream} facilities. + +@samp{freeze(0)} cancels this declaration, allowing a dynamically +allocated string to be freed when its @code{ostrstream} is destroyed. + +If this @code{ostrstream} is already static---that is, if it was created +to manage an existing statically allocated string---@code{freeze} is +unnecessary, and has no effect. +@end deftypefn + +@deftypefn Method int ostrstream::frozen () +Test whether @code{freeze(1)} is in effect for this string. +@end deftypefn + +@deftypefn Method strstreambuf* strstreambase::rdbuf () +A pointer to the underlying @code{strstreambuf}. +@end deftypefn + +@node Streambuf +@chapter Using the @code{streambuf} Layer + +The @code{istream} and @code{ostream} classes are meant to handle +conversion between objects in your program and their textual representation. + +By contrast, the underlying @code{streambuf} class is for transferring +raw bytes between your program, and input sources or output sinks. +Different @code{streambuf} subclasses connect to different kinds of +sources and sinks. + +The @sc{gnu} implementation of @code{streambuf} is still evolving; we +describe only some of the highlights. + +@menu +* Areas:: Areas in a streambuf. +* Overflow:: Simple output re-direction +* Formatting:: C-style formatting for streambuf objects. +* Stdiobuf:: Wrappers for C stdio. +* Procbuf:: Reading/writing from/to a pipe +* Backing Up:: Marking and returning to a position. +* Indirectbuf:: Forwarding I/O activity. +@end menu + +@node Areas +@section Areas of a @code{streambuf} + +Streambuf buffer management is fairly sophisticated (this is a +nice way to say ``complicated''). The standard protocol +has the following ``areas'': + +@itemize @bullet +@item +@cindex put area +The @dfn{put area} contains characters waiting for output. + +@item +@cindex get area +The @dfn{get area} contains characters available for reading. +@end itemize + +The @sc{gnu} @code{streambuf} design extends this, but the details are +still evolving. + +The following methods are used to manipulate these areas. +These are all protected methods, which are intended to be +used by virtual function in classes derived from @code{streambuf}. +They are also all ANSI/ISO-standard, and the ugly names +are traditional. +(Note that if a pointer points to the 'end' of an area, +it means that it points to the character after the area.) + +@deftypefn Method char* streambuf::pbase () const +Returns a pointer to the start of the put area. +@end deftypefn + +@deftypefn Method char* streambuf::epptr () const +Returns a pointer to the end of the put area. +@end deftypefn + +@deftypefn Method char* streambuf::pptr () const +If @code{pptr() < epptr ()}, the @code{pptr()} +returns a pointer to the current put position. +(In that case, the next write will +overwrite @code{*pptr()}, and increment @code{pptr()}.) +Otherwise, there is no put position available +(and the next character written will cause @code{streambuf::overflow} +to be called). +@end deftypefn + +@deftypefn Method void streambuf::pbump (int @var{N}) +Add @var{N} to the current put pointer. +No error checking is done. +@end deftypefn + +@deftypefn Method void streambuf::setp (char* @var{P}, char* @var{E}) +Sets the start of the put area to @var{P}, the end of the put area to @var{E}, +and the current put pointer to @var{P} (also). +@end deftypefn + +@deftypefn Method char* streambuf::eback () const +Returns a pointer to the start of the get area. +@end deftypefn + +@deftypefn Method char* streambuf::egptr () const +Returns a pointer to the end of the get area. +@end deftypefn + +@deftypefn Method char* streambuf::gptr () const +If @code{gptr() < egptr ()}, then @code{gptr()} +returns a pointer to the current get position. +(In that case the next read will read @code{*gptr()}, +and possibly increment @code{gptr()}.) +Otherwise, there is no read position available +(and the next read will cause @code{streambuf::underflow} +to be called). +@end deftypefn + +@deftypefn Method void streambuf:gbump (int @var{N}) +Add @var{N} to the current get pointer. +No error checking is done. +@end deftypefn + +@deftypefn Method void streambuf::setg (char* @var{B}, char* @var{P}, char* @var{E}) +Sets the start of the get area to @var{B}, the end of the get area to @var{E}, +and the current put pointer to @var{P}. +@end deftypefn + +@node Overflow +@section Simple output re-direction by redefining @code{overflow} + +Suppose you have a function @code{write_to_window} that +writes characters to a @code{window} object. If you want to use the +ostream function to write to it, here is one (portable) way to do it. +This depends on the default buffering (if any). + +@cartouche +@smallexample +#include +/* Returns number of characters successfully written to @var{win}. */ +extern int write_to_window (window* win, char* text, int length); + +class windowbuf : public streambuf @{ + window* win; + public: + windowbuf (window* w) @{ win = w; @} + int sync (); + int overflow (int ch); + // Defining xsputn is an optional optimization. + // (streamsize was recently added to ANSI C++, not portable yet.) + streamsize xsputn (char* text, streamsize n); +@}; + +int windowbuf::sync () +@{ streamsize n = pptr () - pbase (); + return (n && write_to_window (win, pbase (), n) != n) ? EOF : 0; +@} + +int windowbuf::overflow (int ch) +@{ streamsize n = pptr () - pbase (); + if (n && sync ()) + return EOF; + if (ch != EOF) + @{ + char cbuf[1]; + cbuf[0] = ch; + if (write_to_window (win, cbuf, 1) != 1) + return EOF; + @} + pbump (-n); // Reset pptr(). + return 0; +@} + +streamsize windowbuf::xsputn (char* text, streamsize n) +@{ return sync () == EOF ? 0 : write_to_window (win, text, n); @} + +int +main (int argc, char**argv) +@{ + window *win = ...; + windowbuf wbuf(win); + ostream wstr(&wbuf); + wstr << "Hello world!\n"; +@} +@end smallexample +@end cartouche + + + +@node Formatting +@section C-style formatting for @code{streambuf} objects + +The @sc{gnu} @code{streambuf} class supports @code{printf}-like +formatting and scanning. + +@deftypefn Method int streambuf::form (const char *@var{format}, ...) +Similar to @code{fprintf(@var{file}, @var{format}, ...)}. +The @var{format} is a @code{printf}-style format control string, which is used +to format the (variable number of) arguments, printing the result on +the @code{this} streambuf. The result is the number of characters printed. +@end deftypefn + +@deftypefn Method int streambuf::vform (const char *@var{format}, va_list @var{args}) +Similar to @code{vfprintf(@var{file}, @var{format}, @var{args})}. +The @var{format} is a @code{printf}-style format control string, which is used +to format the argument list @var{args}, printing the result on +the @code{this} streambuf. The result is the number of characters printed. +@end deftypefn + +@deftypefn Method int streambuf::scan (const char *@var{format}, ...) +Similar to @code{fscanf(@var{file}, @var{format}, ...)}. +The @var{format} is a @code{scanf}-style format control string, which is used +to read the (variable number of) arguments from the @code{this} streambuf. +The result is the number of items assigned, or @code{EOF} in case of +input failure before any conversion. +@end deftypefn + +@deftypefn Method int streambuf::vscan (const char *@var{format}, va_list @var{args}) +Like @code{streambuf::scan}, but takes a single @code{va_list} argument. +@end deftypefn + +@node Stdiobuf +@section Wrappers for C @code{stdio} + +A @dfn{stdiobuf} is a @code{streambuf} object that points to +a @code{FILE} object (as defined by @code{stdio.h}). +All @code{streambuf} operations on the @code{stdiobuf} are forwarded +to the @code{FILE}. Thus the @code{stdiobuf} object provides a +wrapper around a @code{FILE}, allowing use of @code{streambuf} +operations on a @code{FILE}. This can be useful when mixing +C code with C++ code. + +The pre-defined streams @code{cin}, @code{cout}, and @code{cerr} are +normally implemented as @code{stdiobuf} objects that point to +respectively @code{stdin}, @code{stdout}, and @code{stderr}. This is +convenient, but it does cost some extra overhead. + +If you set things up to use the implementation of @code{stdio} provided +with this library, then @code{cin}, @code{cout}, and @code{cerr} will be +set up to to use @code{stdiobuf} objects, since you get their benefits +for free. @xref{Stdio,,C Input and Output}. + +@ignore +@c FIXME-future: setbuf is not yet documented, hence this para is not useful. +Note that if you use @code{setbuf} to give a buffer to a @code{stdiobuf}, +that buffer will provide intermediate buffering in addition that +whatever is done by the @code{FILE}. +@end ignore + +@node Procbuf +@section Reading/writing from/to a pipe + +The @dfn{procbuf} class is a @sc{gnu} extension. It is derived from +@code{streambuf}. A @code{procbuf} can be @dfn{closed} (in which case +it does nothing), or @dfn{open} (in which case it allows communicating +through a pipe with some other program). + +@deftypefn Constructor {} procbuf::procbuf () +Creates a @code{procbuf} in a @dfn{closed} state. +@end deftypefn + +@deftypefn Method procbuf* procbuf::open (const char *@var{command}, int @var{mode}) +Uses the shell (@file{/bin/sh}) to run a program specified by @var{command}. + +If @var{mode} is @samp{ios::in}, standard output from the program is sent +to a pipe; you can read from the pipe by reading from the +@code{procbuf}. (This is similar to @w{@samp{popen(@var{command}, "r")}}.) + +If @var{mode} is @samp{ios::out}, output written written to the +@code{procbuf} is written to a pipe; the program is set up to read its +standard input from (the other end of) the pipe. (This is similar to +@w{@samp{popen(@var{command}, "w")}}.) + +The @code{procbuf} must start out in the @dfn{closed} state. +Returns @samp{*this} on success, and @samp{NULL} on failure. +@end deftypefn + +@deftypefn Constructor {} procbuf::procbuf (const char *@var{command}, int @var{mode}) +Calls @samp{procbuf::open (@var{command}, @var{mode})}. +@end deftypefn + +@deftypefn Method procbuf* procbuf::close () +Waits for the program to finish executing, +and then cleans up the resources used. +Returns @samp{*this} on success, and @samp{NULL} on failure. +@end deftypefn + +@deftypefn Destructor {} procbuf::~procbuf () +Calls @samp{procbuf::close}. +@end deftypefn + +@node Backing Up +@section Backing up + +The @sc{gnu} iostream library allows you to ask a @code{streambuf} to +remember the current position. This allows you to go back to this +position later, after reading further. You can back up arbitrary +amounts, even on unbuffered files or multiple buffers' worth, as long as +you tell the library in advance. This unbounded backup is very useful +for scanning and parsing applications. This example shows a typical +scenario: + +@cartouche +@smallexample +// Read either "dog", "hound", or "hounddog". +// If "dog" is found, return 1. +// If "hound" is found, return 2. +// If "hounddog" is found, return 3. +// If none of these are found, return -1. +int my_scan(streambuf* sb) +@{ + streammarker fence(sb); + char buffer[20]; + // Try reading "hounddog": + if (sb->sgetn(buffer, 8) == 8 + && strncmp(buffer, "hounddog", 8) == 0) + return 3; + // No, no "hounddog": Back up to 'fence' + sb->seekmark(fence); // + // ... and try reading "dog": + if (sb->sgetn(buffer, 3) == 3 + && strncmp(buffer, "dog", 3) == 0) + return 1; + // No, no "dog" either: Back up to 'fence' + sb->seekmark(fence); // + // ... and try reading "hound": + if (sb->sgetn(buffer, 5) == 5 + && strncmp(buffer, "hound", 5) == 0) + return 2; + // No, no "hound" either: Back up and signal failure. + sb->seekmark(fence); // Backup to 'fence' + return -1; +@} +@end smallexample +@end cartouche + +@deftypefn Constructor {} streammarker::streammarker (streambuf* @var{sbuf}) +Create a @code{streammarker} associated with @var{sbuf} +that remembers the current position of the get pointer. +@end deftypefn + +@deftypefn Method int streammarker::delta (streammarker& @var{mark2}) +Return the difference between the get positions corresponding +to @code{*this} and @var{mark2} (which must point into the same +@code{streambuffer} as @code{this}). +@end deftypefn + +@deftypefn Method int streammarker::delta () +Return the position relative to the streambuffer's current get position. +@end deftypefn + +@deftypefn Method int streambuf::seekmark (streammarker& @var{mark}) +Move the get pointer to where it (logically) was when @var{mark} +was constructed. +@end deftypefn + +@node Indirectbuf +@section Forwarding I/O activity + +An @dfn{indirectbuf} is one that forwards all of its I/O requests +to another streambuf. + +@ignore +@c FIXME-future: get_stream and put_stream are so far undocumented. +All get-related requests are sent to get_stream(). +All put-related requests are sent to put_stream(). +@end ignore + +An @code{indirectbuf} can be used to implement Common Lisp +synonym-streams and two-way-streams: + +@example +class synonymbuf : public indirectbuf @{ + Symbol *sym; + synonymbuf(Symbol *s) @{ sym = s; @} + virtual streambuf *lookup_stream(int mode) @{ + return coerce_to_streambuf(lookup_value(sym)); @} +@}; +@end example + +@node Stdio +@chapter C Input and Output + +@code{libio} is distributed with a complete implementation of the ANSI C +@code{stdio} facility. It is implemented using @code{streambuf} +objects. @xref{Stdiobuf,,Wrappers for C @code{stdio}}. + +The @code{stdio} package is intended as a replacement for the whatever +@code{stdio} is in your C library. +@ignore +@c FIXME-future: This is not useful unless we specify what problems. +It can co-exist with C libraries that have alternate implementations of +stdio, but there may be some problems. +@end ignore +Since @code{stdio} works best when you build @code{libc} to contain it, and +that may be inconvenient, it is not installed by default. + +Extensions beyond @sc{ansi}: + +@itemize @bullet +@item +A stdio @code{FILE} is identical to a streambuf. +Hence there is no need to worry about synchronizing C and C++ +input/output---they are by definition always synchronized. + +@item +If you create a new streambuf sub-class (in C++), you can use it as a +@code{FILE} from C. Thus the system is extensible using the standard +@code{streambuf} protocol. + +@item +You can arbitrarily mix reading and writing, without having to seek +in between. + +@item +Unbounded @code{ungetc()} buffer. +@end itemize + +@ignore +@c FIXME-future: Per says this is not ready to go public at v0.5 +@node Libio buffer management +@chapter Libio buffer management + +The libio user functions present an abstract sequence of characters, +that they read and write from. A number of buffers are used to go +between the user program and the abstract sequence. These buffers are +concrete arrays of characters that contain some sub-sequence of the +abstract sequence. + +The libio buffer management protocol is fairly complex. Its design is +based on the C++ @code{streambuf} protocol, so that the C++ +@code{streambuf} classes can be trivially implemented on top of the +libio protocol. + +The @dfn{write area} contains characters waiting for output. + +The @dfn{read area} contains characters available for reading. + +The @dfn{reserve area} is available to virtual methods. +Usually, the get and/or put areas are part of the reserve area. + +The @dfn{main get area} contains characters that have +been read in from the character source, but not yet +read by the application. + +The @dfn{backup area} contains previously read data that is being saved +because of a user request, or that have been "unread" (put back). +@end ignore + +@ignore +@c Per says this design is not finished +@node Streambuf internals +@chapter Streambuf internals + +@menu +* Buffer management:: +* Filebuf internals:: +@end menu + +@node Buffer management +@section Buffer management + +@subsection Areas + +NOTE: This chapter is due for an update. + +Streambuf buffer management is fairly sophisticated (this is a +nice way to say "complicated"). The standard protocol +has the following "areas": + +@itemize @bullet +@cindex put area +@item +The @dfn{put area} contains characters waiting for output. +@cindex get area +@item +The @dfn{get area} contains characters available for reading. +@cindex reserve area +@item +The @dfn{reserve area} is available to virtual methods. +Usually, the get and/or put areas are part of the reserve area. +@end itemize + +The @sc{gnu} @code{streambuf} design extends this by supporting two +get areas: +@itemize @bullet +@cindex main get area +@item +The @dfn{main get area} contains characters that have +been read in from the character source, but not yet +read by the application. +@cindex backup area +@item +The @dfn{backup area} contains previously read data that is being +saved because of a user request, or that have been "unread" (putback). +@end itemize + +The backup and the main get area are logically contiguous: That is, +the first character of the main get area follows the last character +of the backup area. + +The @dfn{current get area} is whichever one of the backup or +main get areas that is currently being read from. +The other of the two is the @dfn{non-current get area}. + +@subsection Pointers + +The following @code{char*} pointers define the various areas. + +@deftypefn Method char* streambuf::base () +The start of the reserve area. +@end deftypefn + +@deftypefn Method char* streambuf::ebuf () +The end of the reserve area. +@end deftypefn + +@deftypefn Method char* streambuf::Gbase () +The start of the main get area. +@end deftypefn + +@deftypefn Method char* streambuf::eGptr () +The end of the main get area. +@end deftypefn + +@deftypefn Method char* streambuf::Bbase () +The start of the backup area. +@end deftypefn + +@deftypefn Method char* streambuf::Bptr () +The start of the used part of the backup area. +The area (@code{Bptr()} .. @code{eBptr()}) contains data that has been +pushed back, while (@code{Bbase()} .. @code{eBptr()}) contains unused +space available for future putbacks. +@end deftypefn + +@deftypefn Method char* streambuf::eBptr () +The end of the backup area. +@end deftypefn + +@deftypefn Method char* streambuf::Nbase () +The start of the non-current get area (either @code{main_gbase} or @code{backup_gbase}). +@end deftypefn + +@deftypefn Method char* streambuf::eNptr () +The end of the non-current get area. +@end deftypefn + +@node Filebuf internals +@section Filebuf internals + +The @code{filebuf} is used a lot, so it is importamt that it be +efficient. It is also supports rather complex semantics. +so let us examine its implementation. + +@subsection Tied read and write pointers + +The streambuf model allows completely independent read and write pointers. +However, a @code{filebuf} has only a single logical pointer used +for both reads and writes. Since the @code{streambuf} protocol +uses @code{gptr()} for reading and @code{pptr()} for writing, +we map the logical file pointer into either @code{gptr()} or @code{pptr()} +at different times. + +@itemize @bullet +@item +Reading is allowed when @code{gptr() < egptr()}, which we call get mode. + +@item +Writing is allowed when @code{pptr() < epptr()}, which we call put mode. +@end itemize + +@noindent +A @code{filebuf} cannot be in get mode and put mode at the same time. + +We have up to two buffers: + +@itemize @bullet +@item +The backup area, defined by @code{Bbase()}, @code{Bptr()}, and @code{eBptr()}. +This can be empty. + +@item +The reserve area, which also contains the main get area. +For an unbuffered file, the (@code{shortbuf()}..@code{shortbuf()+1}) is used, +where @code{shortbuf()} points to a 1-byte buffer that is part of +the @code{filebuf}. +@end itemize + +@noindent +The file system's idea of the current position is @code{eGptr()}. + +Characters that have been written into a buffer but not yet written +out (flushed) to the file systems are those between @code{pbase()} +and @code{pptr()}. + +The end of the valid data bytes is: +@code{pptr() > eGptr() && pptr() < ebuf() ? pptr() : eGptr()}. + +If the @code{filebuf} is unbuffered or line buffered, +the @code{eptr()} is @code{pbase()}. This forces a call +to @code{overflow()} on each put of a character. +The logical @code{epptr()} is @code{epptr() ? ebuf() : NULL}. +(If the buffer is read-only, set @code{pbase()}, @code{pptr()}, +and @code{epptr()} to @code{NULL}. NOT!) +@end ignore + +@node Index +@unnumbered Index +@printindex cp + +@contents +@bye diff --git a/libio/iostreamP.h b/libio/iostreamP.h new file mode 100644 index 000000000000..c9c40cb6ba9a --- /dev/null +++ b/libio/iostreamP.h @@ -0,0 +1,26 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "streambuf.h" +#include "libioP.h" diff --git a/libio/iostrerror.c b/libio/iostrerror.c new file mode 100644 index 000000000000..65aa25d5e4e6 --- /dev/null +++ b/libio/iostrerror.c @@ -0,0 +1,12 @@ +/* This should be replaced by whatever namespace-clean + version of strerror you have available. */ + +#include "libioP.h" +extern char *strerror __P ((int)); + +char * +DEFUN(_IO_strerror, (errnum), + int errnum) +{ + return strerror(errnum); +} diff --git a/libio/ioungetc.c b/libio/ioungetc.c new file mode 100644 index 000000000000..033f652a0670 --- /dev/null +++ b/libio/ioungetc.c @@ -0,0 +1,35 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +int +DEFUN(_IO_ungetc, (c, fp), + int c AND _IO_FILE *fp) +{ + CHECK_FILE(fp, EOF); + if (c == EOF) + return EOF; + return _IO_sputbackc(fp, (unsigned char)c); +} diff --git a/libio/iovfprintf.c b/libio/iovfprintf.c new file mode 100644 index 000000000000..c41cbbf8abca --- /dev/null +++ b/libio/iovfprintf.c @@ -0,0 +1,885 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Actual printf innards. + * + * This code is large and complicated... + */ + +#include +#include "libioP.h" +#include +#ifdef __STDC__ +#include +#else +#include +#endif + +#ifndef _IO_USE_DTOA +int __cvt_double __P((double number, register int prec, int flags, int *signp, int fmtch, char *startp, char *endp)); +#endif + +/* + * Define FLOATING_POINT to get floating point. + */ +#ifndef NO_FLOATING_POINT +#define FLOATING_POINT +#endif + +/* end of configuration stuff */ + + +/* + * Helper "class" for `fprintf to unbuffered': creates a + * temporary buffer. */ + +struct helper_file +{ + struct _IO_FILE_plus _f; + _IO_FILE *_put_stream; +}; + +static int +DEFUN(_IO_helper_overflow, (fp, c), + _IO_FILE *fp AND int c) +{ + _IO_FILE *target = ((struct helper_file*)fp)->_put_stream; + int used = fp->_IO_write_ptr - fp->_IO_write_base; + if (used) + { + _IO_sputn(target, fp->_IO_write_base, used); + fp->_IO_write_ptr -= used; + } + return _IO_putc (c, fp); +} + +static struct _IO_jump_t _IO_helper_jumps = { + JUMP_INIT_DUMMY, + JUMP_INIT(finish, _IO_default_finish), + JUMP_INIT(overflow, _IO_helper_overflow), + JUMP_INIT(underflow, _IO_default_underflow), + JUMP_INIT(uflow, _IO_default_uflow), + JUMP_INIT(pbackfail, _IO_default_pbackfail), + JUMP_INIT(xsputn, _IO_default_xsputn), + JUMP_INIT(xsgetn, _IO_default_xsgetn), + JUMP_INIT(seekoff, _IO_default_seekoff), + JUMP_INIT(seekpos, _IO_default_seekpos), + JUMP_INIT(setbuf, _IO_default_setbuf), + JUMP_INIT(sync, _IO_default_sync), + JUMP_INIT(doallocate, _IO_default_doallocate), + JUMP_INIT(read, _IO_default_read), + JUMP_INIT(write, _IO_default_write), + JUMP_INIT(seek, _IO_default_seek), + JUMP_INIT(close, _IO_default_close), + JUMP_INIT(stat, _IO_default_stat) +}; + +static int +DEFUN(helper_vfprintf, (fp, fmt0, ap), + register _IO_FILE* fp AND char const *fmt0 AND _IO_va_list ap) +{ + char buf[_IO_BUFSIZ]; + struct helper_file helper; + register _IO_FILE *hp = (_IO_FILE*)&helper; + int result, to_flush; + + /* initialize helper */ + helper._put_stream = fp; + hp->_IO_write_base = buf; + hp->_IO_write_ptr = buf; + hp->_IO_write_end = buf+_IO_BUFSIZ; + hp->_IO_file_flags = _IO_MAGIC|_IO_NO_READS; + _IO_JUMPS(hp) = &_IO_helper_jumps; + + /* Now print to helper instead. */ + result = _IO_vfprintf(hp, fmt0, ap); + + /* Now flush anything from the helper to the fp. */ + if ((to_flush = hp->_IO_write_ptr - hp->_IO_write_base) > 0) + { + if (_IO_sputn(fp, hp->_IO_write_base, to_flush) != to_flush) + return EOF; + } + return result; +} + +#ifdef FLOATING_POINT + +#include "floatio.h" +#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */ +#define DEFPREC 6 +extern double modf __P((double, double*)); + +#else /* no FLOATING_POINT */ + +#define BUF 40 + +#endif /* FLOATING_POINT */ + + +/* + * Macros for converting digits to letters and vice versa + */ +#define to_digit(c) ((c) - '0') +#define is_digit(c) ((unsigned)to_digit(c) <= 9) +#define to_char(n) ((n) + '0') + +/* + * Flags used during conversion. + */ +#define LONGINT 0x01 /* long integer */ +#define LONGDBL 0x02 /* long double; unimplemented */ +#define SHORTINT 0x04 /* short integer */ +#define ALT 0x08 /* alternate form */ +#define LADJUST 0x10 /* left adjustment */ +#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */ +#define HEXPREFIX 0x40 /* add 0x or 0X prefix */ + +int +DEFUN(_IO_vfprintf, (fp, fmt0, ap), + register _IO_FILE* fp AND char const *fmt0 AND _IO_va_list ap) +{ + register const char *fmt; /* format string */ + register int ch; /* character from fmt */ + register int n; /* handy integer (short term usage) */ + register char *cp; /* handy char pointer (short term usage) */ + const char *fmark; /* for remembering a place in fmt */ + register int flags; /* flags as above */ + int ret; /* return value accumulator */ + int width; /* width from format (%8d), or 0 */ + int prec; /* precision from format (%.3d), or -1 */ + char sign; /* sign prefix (' ', '+', '-', or \0) */ +#ifdef FLOATING_POINT + int softsign; /* temporary negative sign for floats */ + double _double; /* double precision arguments %[eEfgG] */ +#ifndef _IO_USE_DTOA + int fpprec; /* `extra' floating precision in [eEfgG] */ +#endif +#endif + unsigned long _ulong; /* integer arguments %[diouxX] */ + enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ + int dprec; /* a copy of prec if [diouxX], 0 otherwise */ + int dpad; /* extra 0 padding needed for integers */ + int fieldsz; /* field size expanded by sign, dpad etc */ + /* The initialization of 'size' is to suppress a warning that + 'size' might be used unitialized. It seems gcc can't + quite grok this spaghetti code ... */ + int size = 0; /* size of converted field or string */ + char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ + char ox[2]; /* space for 0x hex-prefix */ + + /* + * BEWARE, these `goto error' on error, and PAD uses `n'. + */ +#define PRINT(ptr, len) \ + do { if (_IO_sputn(fp,ptr, len) != len) goto error; } while (0) +#define PAD_SP(howmany) if (_IO_padn(fp, ' ', howmany) < (howmany)) goto error; +#define PAD_0(howmany) if (_IO_padn(fp, '0', howmany) < (howmany)) goto error; + + /* + * To extend shorts properly, we need both signed and unsigned + * argument extraction methods. + */ +#define SARG() \ + (flags&LONGINT ? va_arg(ap, long) : \ + flags&SHORTINT ? (long)(short)va_arg(ap, int) : \ + (long)va_arg(ap, int)) +#define UARG() \ + (flags&LONGINT ? va_arg(ap, unsigned long) : \ + flags&SHORTINT ? (unsigned long)(unsigned short)va_arg(ap, int) : \ + (unsigned long)va_arg(ap, unsigned int)) + + /* optimise stderr (and other unbuffered Unix files) */ + if (fp->_IO_file_flags & _IO_UNBUFFERED) + return helper_vfprintf(fp, fmt0, ap); + + fmt = fmt0; + ret = 0; + + /* + * Scan the format for conversions (`%' character). + */ + for (;;) { + for (fmark = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++) + /* void */; + if ((n = fmt - fmark) != 0) { + PRINT(fmark, n); + ret += n; + } + if (ch == '\0') + goto done; + fmt++; /* skip over '%' */ + + flags = 0; + dprec = 0; +#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA) + fpprec = 0; +#endif + width = 0; + prec = -1; + sign = '\0'; + +rflag: ch = *fmt++; +reswitch: switch (ch) { + case ' ': + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (!sign) + sign = ' '; + goto rflag; + case '#': + flags |= ALT; + goto rflag; + case '*': + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + if ((width = va_arg(ap, int)) >= 0) + goto rflag; + width = -width; + /* FALLTHROUGH */ + case '-': + flags |= LADJUST; + flags &= ~ZEROPAD; /* '-' disables '0' */ + goto rflag; + case '+': + sign = '+'; + goto rflag; + case '.': + if ((ch = *fmt++) == '*') { + n = va_arg(ap, int); + prec = n < 0 ? -1 : n; + goto rflag; + } + n = 0; + while (is_digit(ch)) { + n = 10 * n + to_digit(ch); + ch = *fmt++; + } + prec = n < 0 ? -1 : n; + goto reswitch; + case '0': + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + if (!(flags & LADJUST)) + flags |= ZEROPAD; /* '-' disables '0' */ + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + n = 10 * n + to_digit(ch); + ch = *fmt++; + } while (is_digit(ch)); + width = n; + goto reswitch; +#ifdef FLOATING_POINT + case 'L': + flags |= LONGDBL; + goto rflag; +#endif + case 'h': + flags |= SHORTINT; + goto rflag; + case 'l': + flags |= LONGINT; + goto rflag; + case 'c': + *(cp = buf) = va_arg(ap, int); + size = 1; + sign = '\0'; + break; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + _ulong = SARG(); + if ((long)_ulong < 0) { + _ulong = -_ulong; + sign = '-'; + } + base = DEC; + goto number; +#ifdef FLOATING_POINT + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + _double = va_arg(ap, double); +#ifdef _IO_USE_DTOA + { + int fmt_flags = 0; + int fill = ' '; + if (flags & ALT) + fmt_flags |= _IO_SHOWPOINT; + if (flags & LADJUST) + fmt_flags |= _IO_LEFT; + else if (flags & ZEROPAD) + fmt_flags |= _IO_INTERNAL, fill = '0'; + n = _IO_outfloat(_double, fp, ch, width, + prec < 0 ? DEFPREC : prec, + fmt_flags, sign, fill); + if (n < 0) + goto error; + ret += n; + } + /* CHECK ERROR! */ + continue; +#else + /* + * don't do unrealistic precision; just pad it with + * zeroes later, so buffer size stays rational. + */ + if (prec > MAXFRACT) { + if ((ch != 'g' && ch != 'G') || (flags&ALT)) + fpprec = prec - MAXFRACT; + prec = MAXFRACT; + } else if (prec == -1) + prec = DEFPREC; + /* __cvt_double may have to round up before the + "start" of its buffer, i.e. + ``intf("%.2f", (double)9.999);''; + if the first character is still NUL, it did. + softsign avoids negative 0 if _double < 0 but + no significant digits will be shown. */ + cp = buf; + *cp = '\0'; + size = __cvt_double(_double, prec, flags, &softsign, + ch, cp, buf + sizeof(buf)); + if (softsign) + sign = '-'; + if (*cp == '\0') + cp++; + break; +#endif +#endif /* FLOATING_POINT */ + case 'n': + if (flags & LONGINT) + *va_arg(ap, long *) = ret; + else if (flags & SHORTINT) + *va_arg(ap, short *) = ret; + else + *va_arg(ap, int *) = ret; + continue; /* no output */ + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + _ulong = UARG(); + base = OCT; + goto nosign; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + /* NOSTRICT */ + _ulong = (unsigned long)va_arg(ap, void *); + base = HEX; + flags |= HEXPREFIX; + ch = 'x'; + goto nosign; + case 's': + if ((cp = va_arg(ap, char *)) == NULL) + cp = "(null)"; + if (prec >= 0) { + /* + * can't use strlen; can only look for the + * NUL in the first `prec' characters, and + * strlen() will go further. + */ + char *p = (char*)memchr(cp, 0, prec); + + if (p != NULL) { + size = p - cp; + if (size > prec) + size = prec; + } else + size = prec; + } else + size = strlen(cp); + sign = '\0'; + break; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + _ulong = UARG(); + base = DEC; + goto nosign; + case 'X': + case 'x': + _ulong = UARG(); + base = HEX; + /* leading 0x/X only if non-zero */ + if (flags & ALT && _ulong != 0) + flags |= HEXPREFIX; + + /* unsigned conversions */ +nosign: sign = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ +number: if ((dprec = prec) >= 0) + flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + cp = buf + BUF; + if (_ulong != 0 || prec != 0) { + char *xdigs; /* digits for [xX] conversion */ + /* + * unsigned mod is hard, and unsigned mod + * by a constant is easier than that by + * a variable; hence this switch. + */ + switch (base) { + case OCT: + do { + *--cp = to_char(_ulong & 7); + _ulong >>= 3; + } while (_ulong); + /* handle octal leading 0 */ + if (flags & ALT && *cp != '0') + *--cp = '0'; + break; + + case DEC: + /* many numbers are 1 digit */ + while (_ulong >= 10) { + *--cp = to_char(_ulong % 10); + _ulong /= 10; + } + *--cp = to_char(_ulong); + break; + + case HEX: + if (ch == 'X') + xdigs = "0123456789ABCDEF"; + else /* ch == 'x' || ch == 'p' */ + xdigs = "0123456789abcdef"; + do { + *--cp = xdigs[_ulong & 15]; + _ulong >>= 4; + } while (_ulong); + break; + + default: + cp = "bug in vform: bad base"; + goto skipsize; + } + } + size = buf + BUF - cp; + skipsize: + break; + default: /* "%?" prints ?, unless ? is NUL */ + if (ch == '\0') + goto done; + /* pretend it was %c with argument ch */ + cp = buf; + *cp = ch; + size = 1; + sign = '\0'; + break; + } + + /* + * All reasonable formats wind up here. At this point, + * `cp' points to a string which (if not flags&LADJUST) + * should be padded out to `width' places. If + * flags&ZEROPAD, it should first be prefixed by any + * sign or other prefix; otherwise, it should be blank + * padded before the prefix is emitted. After any + * left-hand padding and prefixing, emit zeroes + * required by a decimal [diouxX] precision, then print + * the string proper, then emit zeroes required by any + * leftover floating precision; finally, if LADJUST, + * pad with blanks. + */ + + /* + * compute actual size, so we know how much to pad. + */ +#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA) + fieldsz = size + fpprec; +#else + fieldsz = size; +#endif + dpad = dprec - size; + if (dpad < 0) + dpad = 0; + + if (sign) + fieldsz++; + else if (flags & HEXPREFIX) + fieldsz += 2; + fieldsz += dpad; + + /* right-adjusting blank padding */ + if ((flags & (LADJUST|ZEROPAD)) == 0) + PAD_SP(width - fieldsz); + + /* prefix */ + if (sign) { + PRINT(&sign, 1); + } else if (flags & HEXPREFIX) { + ox[0] = '0'; + ox[1] = ch; + PRINT(ox, 2); + } + + /* right-adjusting zero padding */ + if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) + PAD_0(width - fieldsz); + + /* leading zeroes from decimal precision */ + PAD_0(dpad); + + /* the string or number proper */ + PRINT(cp, size); + +#if defined(FLOATING_POINT) && !defined (_IO_USE_DTOA) + /* trailing f.p. zeroes */ + PAD_0(fpprec); +#endif + + /* left-adjusting padding (always blank) */ + if (flags & LADJUST) + PAD_SP(width - fieldsz); + + /* finally, adjust ret */ + ret += width > fieldsz ? width : fieldsz; + + } +done: + return ret; +error: + return EOF; + /* NOTREACHED */ +} + +#if defined(FLOATING_POINT) && !defined(_IO_USE_DTOA) + +static char *exponent(register char *p, register int exp, int fmtch) +{ + register char *t; + char expbuf[MAXEXP]; + + *p++ = fmtch; + if (exp < 0) { + exp = -exp; + *p++ = '-'; + } + else + *p++ = '+'; + t = expbuf + MAXEXP; + if (exp > 9) { + do { + *--t = to_char(exp % 10); + } while ((exp /= 10) > 9); + *--t = to_char(exp); + for (; t < expbuf + MAXEXP; *p++ = *t++); + } + else { + *p++ = '0'; + *p++ = to_char(exp); + } + return (p); +} + +static char * round(double fract, int *exp, + register char *start, register char *end, + char ch, int *signp) +{ + double tmp; + + if (fract) + (void)modf(fract * 10, &tmp); + else + tmp = to_digit(ch); + if (tmp > 4) + for (;; --end) { + if (*end == '.') + --end; + if (++*end <= '9') + break; + *end = '0'; + if (end == start) { + if (exp) { /* e/E; increment exponent */ + *end = '1'; + ++*exp; + } + else { /* f; add extra digit */ + *--end = '1'; + --start; + } + break; + } + } + /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */ + else if (*signp == '-') + for (;; --end) { + if (*end == '.') + --end; + if (*end != '0') + break; + if (end == start) + *signp = 0; + } + return (start); +} + +int __cvt_double(double number, register int prec, int flags, int *signp, + int fmtch, char *startp, char *endp) +{ + register char *p, *t; + register double fract; + int dotrim = 0, expcnt, gformat = 0; + double integer, tmp; + + expcnt = 0; + if (number < 0) { + number = -number; + *signp = '-'; + } else + *signp = 0; + + fract = modf(number, &integer); + + /* get an extra slot for rounding. */ + t = ++startp; + + /* + * get integer portion of number; put into the end of the buffer; the + * .01 is added for modf(356.0 / 10, &integer) returning .59999999... + */ + for (p = endp - 1; p >= startp && integer; ++expcnt) { + tmp = modf(integer / 10, &integer); + *p-- = to_char((int)((tmp + .01) * 10)); + } + switch (fmtch) { + case 'f': + case 'F': + /* reverse integer into beginning of buffer */ + if (expcnt) + for (; ++p < endp; *t++ = *p); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. + */ + if (prec || flags&ALT) + *t++ = '.'; + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, (int *)NULL, startp, + t - 1, (char)0, signp); + } + for (; prec--; *t++ = '0'); + break; + case 'e': + case 'E': +eformat: if (expcnt) { + *t++ = *++p; + if (prec || flags&ALT) + *t++ = '.'; + /* if requires more precision and some integer left */ + for (; prec && ++p < endp; --prec) + *t++ = *p; + /* + * if done precision and more of the integer component, + * round using it; adjust fract so we don't re-round + * later. + */ + if (!prec && ++p < endp) { + fract = 0; + startp = round((double)0, &expcnt, startp, + t - 1, *p, signp); + } + /* adjust expcnt for digit in front of decimal */ + --expcnt; + } + /* until first fractional digit, decrement exponent */ + else if (fract) { + /* adjust expcnt for digit in front of decimal */ + for (expcnt = -1;; --expcnt) { + fract = modf(fract * 10, &tmp); + if (tmp) + break; + } + *t++ = to_char((int)tmp); + if (prec || flags&ALT) + *t++ = '.'; + } + else { + *t++ = '0'; + if (prec || flags&ALT) + *t++ = '.'; + } + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, &expcnt, startp, + t - 1, (char)0, signp); + } + /* if requires more precision */ + for (; prec--; *t++ = '0'); + + /* unless alternate flag, trim any g/G format trailing 0's */ + if (gformat && !(flags&ALT)) { + while (t > startp && *--t == '0'); + if (*t == '.') + --t; + ++t; + } + t = exponent(t, expcnt, fmtch); + break; + case 'g': + case 'G': + /* a precision of 0 is treated as a precision of 1. */ + if (!prec) + ++prec; + /* + * ``The style used depends on the value converted; style e + * will be used only if the exponent resulting from the + * conversion is less than -4 or greater than the precision.'' + * -- ANSI X3J11 + */ + if (expcnt > prec || (!expcnt && fract && fract < .0001)) { + /* + * g/G format counts "significant digits, not digits of + * precision; for the e/E format, this just causes an + * off-by-one problem, i.e. g/G considers the digit + * before the decimal point significant and e/E doesn't + * count it as precision. + */ + --prec; + fmtch -= 2; /* G->E, g->e */ + gformat = 1; + goto eformat; + } + /* + * reverse integer into beginning of buffer, + * note, decrement precision + */ + if (expcnt) + for (; ++p < endp; *t++ = *p, --prec); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. If no digits yet, add in leading 0. + */ + if (prec || flags&ALT) { + dotrim = 1; + *t++ = '.'; + } + else + dotrim = 0; + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) { + /* If no integer part, don't count initial + * zeros as significant digits. */ + do { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } while(!tmp && !expcnt); + while (--prec && fract) { + fract = modf(fract * 10, &tmp); + *t++ = to_char((int)tmp); + } + } + if (fract) + startp = round(fract, (int *)NULL, startp, + t - 1, (char)0, signp); + } + /* alternate format, adds 0's for precision, else trim 0's */ + if (flags&ALT) + for (; prec--; *t++ = '0'); + else if (dotrim) { + while (t > startp && *--t == '0'); + if (*t != '.') + ++t; + } + } + return (t - startp); +} + +#endif /* defined(FLOATING_POINT) && !defined(_IO_USE_DTOA) */ diff --git a/libio/iovfscanf.c b/libio/iovfscanf.c new file mode 100644 index 000000000000..1220e0750b7f --- /dev/null +++ b/libio/iovfscanf.c @@ -0,0 +1,787 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* Extensively hacked for GNU iostream by Per Bothner 1991, 1992, 1993. + Changes copyright Free Software Foundation 1992, 1993. */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "%W% (Berkeley) %G%"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#ifdef __STDC__ +#include +#else +#include +#endif + +#ifndef NO_FLOATING_POINT +#define FLOATING_POINT +#endif + +#ifdef FLOATING_POINT +#include "floatio.h" +#define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */ +#else +#define BUF 40 +#endif + +/* + * Flags used during conversion. + */ +#define LONG 0x01 /* l: long or double */ +#define LONGDBL 0x02 /* L: long double; unimplemented */ +#define SHORT 0x04 /* h: short */ +#define SUPPRESS 0x08 /* suppress assignment */ +#define POINTER 0x10 /* weird %p pointer (`fake hex') */ +#define NOSKIP 0x20 /* do not skip blanks */ +#define WIDTH 0x40 /* width */ + +/* + * The following are used in numeric conversions only: + * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point; + * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. + */ +#define SIGNOK 0x40 /* +/- is (still) legal */ +#define NDIGITS 0x80 /* no digits detected */ + +#define DPTOK 0x100 /* (float) decimal point is still legal */ +#define EXPOK 0x200 /* (float) exponent (e+3, etc) still legal */ + +#define PFXOK 0x100 /* 0x prefix is (still) legal */ +#define NZDIGITS 0x200 /* no zero digits detected */ + +/* + * Conversion types. + */ +#define CT_CHAR 0 /* %c conversion */ +#define CT_CCL 1 /* %[...] conversion */ +#define CT_STRING 2 /* %s conversion */ +#define CT_INT 3 /* integer, i.e., strtol or strtoul */ +#define CT_FLOAT 4 /* floating, i.e., strtod */ + +#define u_char unsigned char +#define u_long unsigned long + +#ifdef __cplusplus +extern "C" { +#endif +extern u_long strtoul __P((const char*, char**, int)); +extern long strtol __P((const char*, char**, int)); +static const u_char *__sccl __P((char *tab, const u_char *fmt)); +#ifndef _IO_USE_DTOA +extern double atof(); +#endif +#ifdef __cplusplus +} +#endif + +/* If errp != NULL, *errp|=1 if we see a premature EOF; + *errp|=2 if we an invalid character. */ + +int +DEFUN(_IO_vfscanf, (fp, fmt0, ap, errp), + register _IO_FILE *fp AND char const *fmt0 + AND _IO_va_list ap AND int *errp) +{ + register const u_char *fmt = (const u_char *)fmt0; + register int c; /* character from format, or conversion */ + register _IO_ssize_t width; /* field width, or 0 */ + register char *p; /* points into all kinds of strings */ + register int n; /* handy integer */ + register int flags = 0; /* flags as defined above */ + register char *p0; /* saves original value of p when necessary */ + int nassigned; /* number of fields assigned */ + int nread; /* number of characters consumed from fp */ + /* Assignments to base and ccfn are just to suppress warnings from gcc.*/ + int base = 0; /* base argument to strtol/strtoul */ + typedef u_long (*strtoulfn) __P((const char*, char**, int)); + strtoulfn ccfn = 0; + /* conversion function (strtol/strtoul) */ + char ccltab[256]; /* character class table for %[...] */ + char buf[BUF]; /* buffer for numeric conversions */ + int seen_eof = 0; + + /* `basefix' is used to avoid `if' tests in the integer scanner */ + static short basefix[17] = + { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + + nassigned = 0; + nread = 0; + for (;;) { + c = *fmt++; + if (c == 0) + goto done; + if (isspace(c)) { + for (;;) { + c = _IO_getc(fp); + if (c == EOF) { + seen_eof++; + break; + } + if (!isspace(c)) { + _IO_ungetc (c, fp); + break; + } + nread++; + } + continue; + } + if (c != '%') + goto literal; + width = 0; + flags = 0; + /* + * switch on the format. continue if done; + * break once format type is derived. + */ +again: c = *fmt++; + switch (c) { + case '%': +literal: + n = _IO_getc(fp); + if (n == EOF) + goto eof_failure; + if (n != c) { + _IO_ungetc (n, fp); + goto match_failure; + } + nread++; + continue; + + case '*': + if (flags) goto control_failure; + flags = SUPPRESS; + goto again; + case 'l': + if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; + flags |= LONG; + goto again; + case 'L': + if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; + flags |= LONGDBL; + goto again; + case 'h': + if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; + flags |= SHORT; + goto again; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; + flags |= WIDTH; + width = width * 10 + c - '0'; + goto again; + + /* + * Conversions. + * Those marked `compat' are for 4.[123]BSD compatibility. + * + * (According to ANSI, E and X formats are supposed + * to the same as e and x. Sorry about that.) + */ + case 'D': /* compat */ + flags |= LONG; + /* FALLTHROUGH */ + case 'd': + c = CT_INT; + ccfn = (strtoulfn)strtol; + base = 10; + break; + + case 'i': + c = CT_INT; + ccfn = (strtoulfn)strtol; + base = 0; + break; + + case 'O': /* compat */ + flags |= LONG; + /* FALLTHROUGH */ + case 'o': + c = CT_INT; + ccfn = strtoul; + base = 8; + break; + + case 'u': + c = CT_INT; + ccfn = strtoul; + base = 10; + break; + + case 'X': + case 'x': + flags |= PFXOK; /* enable 0x prefixing */ + c = CT_INT; + ccfn = strtoul; + base = 16; + break; + +#ifdef FLOATING_POINT + case 'E': case 'F': + case 'e': case 'f': case 'g': + c = CT_FLOAT; + break; +#endif + + case 's': + c = CT_STRING; + break; + + case '[': + fmt = __sccl(ccltab, fmt); + flags |= NOSKIP; + c = CT_CCL; + break; + + case 'c': + flags |= NOSKIP; + c = CT_CHAR; + break; + + case 'p': /* pointer format is like hex */ + flags |= POINTER | PFXOK; + c = CT_INT; + ccfn = strtoul; + base = 16; + break; + + case 'n': + if (flags & SUPPRESS) /* ??? */ + continue; + if (flags & SHORT) + *va_arg(ap, short *) = nread; + else if (flags & LONG) + *va_arg(ap, long *) = nread; + else + *va_arg(ap, int *) = nread; + continue; + + /* + * Disgusting backwards compatibility hacks. XXX + */ + case '\0': /* compat */ + nassigned = EOF; + goto done; + + default: /* compat */ + if (isupper(c)) + flags |= LONG; + c = CT_INT; + ccfn = (strtoulfn)strtol; + base = 10; + break; + } + + /* + * We have a conversion that requires input. + */ + if (_IO_peekc(fp) == EOF) + goto eof_failure; + + /* + * Consume leading white space, except for formats + * that suppress this. + */ + if ((flags & NOSKIP) == 0) { + n = (unsigned char)*fp->_IO_read_ptr; + while (isspace(n)) { + fp->_IO_read_ptr++; + nread++; + n = _IO_peekc(fp); + if (n == EOF) + goto eof_failure; + } + /* Note that there is at least one character in + the buffer, so conversions that do not set NOSKIP + can no longer result in an input failure. */ + } + + /* + * Do the conversion. + */ + switch (c) { + + case CT_CHAR: + /* scan arbitrary characters (sets NOSKIP) */ + if (width == 0) /* FIXME! */ + width = 1; + if (flags & SUPPRESS) { + _IO_size_t sum = 0; + for (;;) { + n = fp->_IO_read_end - fp->_IO_read_ptr; + if (n < (int)width) { + sum += n; + width -= n; + fp->_IO_read_ptr += n; + if (__underflow(fp) == EOF) + if (sum == 0) + goto eof_failure; + else { + seen_eof++; + break; + } + } else { + sum += width; + fp->_IO_read_ptr += width; + break; + } + } + nread += sum; + } else { + _IO_size_t r = + + _IO_XSGETN (fp, (char*)va_arg(ap, char*), width); + if (r != width) + goto eof_failure; + nread += r; + nassigned++; + } + break; + + case CT_CCL: + /* scan a (nonempty) character class (sets NOSKIP) */ + if (width == 0) + width = ~0; /* `infinity' */ + /* take only those things in the class */ + if (flags & SUPPRESS) { + n = 0; + while (ccltab[(unsigned char)*fp->_IO_read_ptr]) { + n++, fp->_IO_read_ptr++; + if (--width == 0) + break; + if (_IO_peekc(fp) == EOF) { + if (n == 0) + goto eof_failure; + seen_eof++; + break; + } + } + if (n == 0) + goto match_failure; + } else { + p0 = p = va_arg(ap, char *); + while (ccltab[(unsigned char)*fp->_IO_read_ptr]) { + *p++ = *fp->_IO_read_ptr++; + if (--width == 0) + break; + if (_IO_peekc(fp) == EOF) { + if (p == p0) + goto eof_failure; + seen_eof++; + break; + } + } + n = p - p0; + if (n == 0) + goto match_failure; + *p = 0; + nassigned++; + } + nread += n; + break; + + case CT_STRING: + /* like CCL, but zero-length string OK, & no NOSKIP */ + if (width == 0) + width = ~0; + if (flags & SUPPRESS) { + n = 0; + while (!isspace((unsigned char)*fp->_IO_read_ptr)) { + n++, fp->_IO_read_ptr++; + if (--width == 0) + break; + if (_IO_peekc(fp) == EOF) { + seen_eof++; + break; + } + } + nread += n; + } else { + p0 = p = va_arg(ap, char *); + while (!isspace((unsigned char)*fp->_IO_read_ptr)) { + *p++ = *fp->_IO_read_ptr++; + if (--width == 0) + break; + if (_IO_peekc(fp) == EOF) { + seen_eof++; + break; + } + } + *p = 0; + nread += p - p0; + nassigned++; + } + continue; + + case CT_INT: + /* scan an integer as if by strtol/strtoul */ + if (width == 0 || width > sizeof(buf) - 1) + width = sizeof(buf) - 1; + flags |= SIGNOK | NDIGITS | NZDIGITS; + for (p = buf; width; width--) { + c = (unsigned char)*fp->_IO_read_ptr; + /* + * Switch on the character; `goto ok' + * if we accept it as a part of number. + */ + switch (c) { + + /* + * The digit 0 is always legal, but is + * special. For %i conversions, if no + * digits (zero or nonzero) have been + * scanned (only signs), we will have + * base==0. In that case, we should set + * it to 8 and enable 0x prefixing. + * Also, if we have not scanned zero digits + * before this, do not turn off prefixing + * (someone else will turn it off if we + * have scanned any nonzero digits). + */ + case '0': + if (base == 0) { + base = 8; + flags |= PFXOK; + } + if (flags & NZDIGITS) + flags &= ~(SIGNOK|NZDIGITS|NDIGITS); + else + flags &= ~(SIGNOK|PFXOK|NDIGITS); + goto ok; + + /* 1 through 7 always legal */ + case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + base = basefix[base]; + flags &= ~(SIGNOK | PFXOK | NDIGITS); + goto ok; + + /* digits 8 and 9 ok iff decimal or hex */ + case '8': case '9': + base = basefix[base]; + if (base <= 8) + break; /* not legal here */ + flags &= ~(SIGNOK | PFXOK | NDIGITS); + goto ok; + + /* letters ok iff hex */ + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + case 'a': case 'b': case 'c': + case 'd': case 'e': case 'f': + /* no need to fix base here */ + if (base <= 10) + break; /* not legal here */ + flags &= ~(SIGNOK | PFXOK | NDIGITS); + goto ok; + + /* sign ok only as first character */ + case '+': case '-': + if (flags & SIGNOK) { + flags &= ~SIGNOK; + goto ok; + } + break; + + /* x ok iff flag still set & 2nd char */ + case 'x': case 'X': + if (flags & PFXOK && p == buf + 1) { + base = 16; /* if %i */ + flags &= ~PFXOK; + goto ok; + } + break; + } + + /* + * If we got here, c is not a legal character + * for a number. Stop accumulating digits. + */ + break; + ok: + /* + * c is legal: store it and look at the next. + */ + *p++ = c; + fp->_IO_read_ptr++; + if (_IO_peekc(fp) == EOF) { + seen_eof++; + break; /* EOF */ + } + } + /* + * If we had only a sign, it is no good; push + * back the sign. If the number ends in `x', + * it was [sign] '0' 'x', so push back the x + * and treat it as [sign] '0'. + */ + if (flags & NDIGITS) { + if (p > buf) + (void) _IO_ungetc(*(u_char *)--p, fp); + goto match_failure; + } + c = ((u_char *)p)[-1]; + if (c == 'x' || c == 'X') { + --p; + (void) _IO_ungetc (c, fp); + } + if ((flags & SUPPRESS) == 0) { + u_long res; + + *p = 0; + res = (*ccfn)(buf, (char **)NULL, base); + if (flags & POINTER) + *va_arg(ap, void **) = (void *)res; + else if (flags & SHORT) + *va_arg(ap, short *) = res; + else if (flags & LONG) + *va_arg(ap, long *) = res; + else + *va_arg(ap, int *) = res; + nassigned++; + } + nread += p - buf; + break; + +#ifdef FLOATING_POINT + case CT_FLOAT: + /* scan a floating point number as if by strtod */ + if (width == 0 || width > sizeof(buf) - 1) + width = sizeof(buf) - 1; + flags |= SIGNOK | NDIGITS | DPTOK | EXPOK; + for (p = buf; width; width--) { + c = (unsigned char)*fp->_IO_read_ptr; + /* + * This code mimicks the integer conversion + * code, but is much simpler. + */ + switch (c) { + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': + flags &= ~(SIGNOK | NDIGITS); + goto fok; + + case '+': case '-': + if (flags & SIGNOK) { + flags &= ~SIGNOK; + goto fok; + } + break; + case '.': + if (flags & DPTOK) { + flags &= ~(SIGNOK | DPTOK); + goto fok; + } + break; + case 'e': case 'E': + /* no exponent without some digits */ + if ((flags&(NDIGITS|EXPOK)) == EXPOK) { + flags = + (flags & ~(EXPOK|DPTOK)) | + SIGNOK | NDIGITS; + goto fok; + } + break; + } + break; + fok: + *p++ = c; + fp->_IO_read_ptr++; + if (_IO_peekc(fp) == EOF) { + seen_eof++; + break; /* EOF */ + } + } + /* + * If no digits, might be missing exponent digits + * (just give back the exponent) or might be missing + * regular digits, but had sign and/or decimal point. + */ + if (flags & NDIGITS) { + if (flags & EXPOK) { + /* no digits at all */ + while (p > buf) + _IO_ungetc (*(u_char *)--p, fp); + goto match_failure; + } + /* just a bad exponent (e and maybe sign) */ + c = *(u_char *)--p; + if (c != 'e' && c != 'E') { + (void) _IO_ungetc (c, fp);/* sign */ + c = *(u_char *)--p; + } + (void) _IO_ungetc (c, fp); + } + if ((flags & SUPPRESS) == 0) { + double res; + *p = 0; +#ifdef _IO_USE_DTOA + res = _IO_strtod(buf, NULL); +#else + res = atof(buf); +#endif + if (flags & LONG) + *va_arg(ap, double *) = res; + else + *va_arg(ap, float *) = res; + nassigned++; + } + nread += p - buf; + break; +#endif /* FLOATING_POINT */ + } + } +eof_failure: + seen_eof++; +input_failure: + if (nassigned == 0) + nassigned = -1; +control_failure: +match_failure: + if (errp) + *errp |= 2; +done: + if (errp && seen_eof) + *errp |= 1; + return (nassigned); +} + +/* + * Fill in the given table from the scanset at the given format + * (just after `['). Return a pointer to the character past the + * closing `]'. The table has a 1 wherever characters should be + * considered part of the scanset. + */ +static const u_char * +DEFUN(__sccl, (tab, fmt), + register char *tab AND register const u_char *fmt) +{ + register int c, n, v; + + /* first `clear' the whole table */ + c = *fmt++; /* first char hat => negated scanset */ + if (c == '^') { + v = 1; /* default => accept */ + c = *fmt++; /* get new first char */ + } else + v = 0; /* default => reject */ + /* should probably use memset here */ + for (n = 0; n < 256; n++) + tab[n] = v; + if (c == 0) + return (fmt - 1);/* format ended before closing ] */ + + /* + * Now set the entries corresponding to the actual scanset + * to the opposite of the above. + * + * The first character may be ']' (or '-') without being special; + * the last character may be '-'. + */ + v = 1 - v; + for (;;) { + tab[c] = v; /* take character c */ +doswitch: + n = *fmt++; /* and examine the next */ + switch (n) { + + case 0: /* format ended too soon */ + return (fmt - 1); + + case '-': + /* + * A scanset of the form + * [01+-] + * is defined as `the digit 0, the digit 1, + * the character +, the character -', but + * the effect of a scanset such as + * [a-zA-Z0-9] + * is implementation defined. The V7 Unix + * scanf treats `a-z' as `the letters a through + * z', but treats `a-a' as `the letter a, the + * character -, and the letter a'. + * + * For compatibility, the `-' is not considerd + * to define a range if the character following + * it is either a close bracket (required by ANSI) + * or is not numerically greater than the character + * we just stored in the table (c). + */ + n = *fmt; + if (n == ']' || n < c) { + c = '-'; + break; /* resume the for(;;) */ + } + fmt++; + do { /* fill in the range */ + tab[++c] = v; + } while (c < n); +#if 1 /* XXX another disgusting compatibility hack */ + /* + * Alas, the V7 Unix scanf also treats formats + * such as [a-c-e] as `the letters a through e'. + * This too is permitted by the standard.... + */ + goto doswitch; +#else + c = *fmt++; + if (c == 0) + return (fmt - 1); + if (c == ']') + return (fmt); +#endif + break; + + case ']': /* end of scanset */ + return (fmt); + + default: /* just another character */ + c = n; + break; + } + } + /* NOTREACHED */ +} diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c new file mode 100644 index 000000000000..06d926d35903 --- /dev/null +++ b/libio/iovsprintf.c @@ -0,0 +1,40 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "strfile.h" + +int +DEFUN(_IO_vsprintf, (string, format, args), + char *string AND const char *format AND _IO_va_list args) +{ + _IO_strfile sf; + int ret; + _IO_init((_IO_FILE*)&sf, 0); + _IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps; + _IO_str_init_static ((_IO_FILE*)&sf, string, -1, string); + ret = _IO_vfprintf((_IO_FILE*)&sf, format, args); + _IO_putc('\0', (_IO_FILE*)&sf); + return ret; +} diff --git a/libio/iovsscanf.c b/libio/iovsscanf.c new file mode 100644 index 000000000000..529778098a55 --- /dev/null +++ b/libio/iovsscanf.c @@ -0,0 +1,37 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "strfile.h" + +int +DEFUN(_IO_vsscanf, (string, format, args), + const char *string AND const char *format AND _IO_va_list args) +{ + _IO_strfile sf; + _IO_init((_IO_FILE*)&sf, 0); + _IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps; + _IO_str_init_static ((_IO_FILE*)&sf, (char*)string, 0, NULL); + return _IO_vfscanf((_IO_FILE*)&sf, format, args, NULL); +} diff --git a/libio/isgetline.cc b/libio/isgetline.cc new file mode 100644 index 000000000000..add26638b203 --- /dev/null +++ b/libio/isgetline.cc @@ -0,0 +1,139 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include +#include "iostream.h" +#include + +istream& istream::getline(char* buf, int len, char delim) +{ + _gcount = 0; + if (len <= 0) + { + set(ios::failbit); + return *this; + } + int ch; + if (ipfx1()) + { + streambuf *sb = rdbuf(); + _gcount = _IO_getline(sb, buf, len - 1, delim, -1); + ch = sb->sbumpc(); + if (ch == EOF) + set (_gcount == 0 ? (ios::failbit|ios::eofbit) : ios::eofbit); + else if (ch != (unsigned char) delim) + { + set(ios::failbit); + sb->sungetc(); // Leave delimiter unread. + } + } + else + ch = EOF; + buf[_gcount] = '\0'; + if (ch == (unsigned char)delim) + _gcount++; // The delimiter is counted in the gcount(). + return *this; +} + +istream& istream::get(char* buf, int len, char delim) +{ + _gcount = 0; + if (len <= 0) + { + set(ios::failbit); + return *this; + } + if (ipfx1()) + { + streambuf *sbuf = rdbuf(); + long count = _IO_getline(sbuf, buf, len - 1, delim, -1); + if (count == 0 && sbuf->sgetc() == EOF) + set(ios::failbit|ios::eofbit); + else + _gcount = count; + } + buf[_gcount] = '\0'; + return *this; +} + + +// from Doug Schmidt + +#define CHUNK_SIZE 512 + +/* Reads an arbitrarily long input line terminated by a user-specified + TERMINATOR. Super-nifty trick using recursion avoids unnecessary calls + to NEW! */ + +char *_sb_readline (streambuf *sb, long& total, char terminator) +{ + char buf[CHUNK_SIZE]; + char *ptr; + int ch; + + _IO_size_t count = _IO_getline(sb, buf, CHUNK_SIZE, terminator, -1); + ch = sb->sbumpc(); + long old_total = total; + total += count; + if (ch != EOF && ch != terminator) { + total++; // Include ch in total. + ptr = _sb_readline(sb, total, terminator); + if (ptr) { + memcpy(ptr + old_total, buf, count); + ptr[old_total+count] = ch; + } + return ptr; + } + + ptr = new char[total+1]; + if (ptr != NULL) { + ptr[total] = '\0'; + memcpy(ptr + total - count, buf, count); + } + return ptr; +} + +/* Reads an arbitrarily long input line terminated by TERMINATOR. + This routine allocates its own memory, so the user should + only supply the address of a (char *). */ + +istream& istream::gets(char **s, char delim /* = '\n' */) +{ + if (ipfx1()) { + long size = 0; + streambuf *sb = rdbuf(); + *s = _sb_readline (sb, size, delim); + _gcount = *s ? size : 0; + if (sb->_flags & _IO_EOF_SEEN) { + set(ios::eofbit); + if (_gcount == 0) + set(ios::failbit); + } + } + else { + _gcount = 0; + *s = NULL; + } + return *this; +} diff --git a/libio/isgetsb.cc b/libio/isgetsb.cc new file mode 100644 index 000000000000..55617e649a0f --- /dev/null +++ b/libio/isgetsb.cc @@ -0,0 +1,59 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "iostream.h" +#include + +istream& istream::get(streambuf& sb, char delim /* = '\n' */) +{ + _gcount = 0; + if (ipfx1()) + { + register streambuf* isb = rdbuf(); + for (;;) + { + streamsize len = isb->_IO_read_end - isb->_IO_read_ptr; + if (len <= 0) + if (__underflow(isb) == EOF) + break; + else + len = isb->_IO_read_end - isb->_IO_read_ptr; + char *delimp = (char*)memchr((void*)isb->_IO_read_ptr, delim, len); + if (delimp != NULL) + len = delimp - isb->_IO_read_ptr; + int written = sb.sputn(isb->_IO_read_ptr, len); + isb->_IO_read_ptr += written; + _gcount += written; + if (written != len) + { + set(ios::failbit); + break; + } + if (delimp != NULL) + break; + } + } + return *this; +} diff --git a/libio/isscan.cc b/libio/isscan.cc new file mode 100644 index 000000000000..64d4bc682f82 --- /dev/null +++ b/libio/isscan.cc @@ -0,0 +1,45 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include +#include + +istream& istream::scan(const char *format ...) +{ + if (ipfx0()) { + va_list ap; + va_start(ap, format); + _strbuf->vscan(format, ap, this); + va_end(ap); + } + return *this; +} + +istream& istream::vscan(const char *format, _IO_va_list args) +{ + if (ipfx0()) + _strbuf->vscan(format, args, this); + return *this; +} diff --git a/libio/istream.h b/libio/istream.h new file mode 100644 index 000000000000..f54ec1de9a1c --- /dev/null +++ b/libio/istream.h @@ -0,0 +1,25 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include diff --git a/libio/libio.h b/libio/libio.h new file mode 100644 index 000000000000..c7aea0a6c245 --- /dev/null +++ b/libio/libio.h @@ -0,0 +1,267 @@ +/* +Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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 is part of the iostream library. Written by Per Bothner. */ + +#ifndef _IO_STDIO_H +#define _IO_STDIO_H + +#include <_G_config.h> +#define _IO_pos_t _G_fpos_t /* obsolete */ +#define _IO_fpos_t _G_fpos_t +#define _IO_size_t _G_size_t +#define _IO_ssize_t _G_ssize_t +#define _IO_off_t _G_off_t +#define _IO_pid_t _G_pid_t +#define _IO_uid_t _G_uid_t +#define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT +#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE +#define _IO_BUFSIZ _G_BUFSIZ +#define _IO_va_list _G_va_list + +#ifdef _G_NEED_STDARG_H +/* This define avoids name pollution if we're using GNU stdarg.h */ +#define __need___va_list +#include +#ifdef __GNUC_VA_LIST +#undef _IO_va_list +#define _IO_va_list __gnuc_va_list +#endif /* __GNUC_VA_LIST */ +#endif + +#ifndef __P +#if _G_HAVE_SYS_CDEFS +#include +#else +#ifdef __STDC__ +#define __P(protos) protos +#else +#define __P(protos) () +#endif +#endif +#endif /*!__P*/ + +/* For backward compatibility */ +#ifndef _PARAMS +#define _PARAMS(protos) __P(protos) +#endif /*!_PARAMS*/ + +#ifndef __STDC__ +#define const +#endif +#ifndef _G_NO_USE_DTOA +#define _IO_USE_DTOA +#else +#undef _IO_USE_DTOA +#endif +#define _IO_UNIFIED_JUMPTABLES 1 + +#if 0 +#ifdef _IO_NEED_STDARG_H +#include +#endif +#endif + +#ifndef EOF +#define EOF (-1) +#endif +#ifndef NULL +#ifdef __GNUG__ +#define NULL (__null) +#else +#if !defined(__cplusplus) +#define NULL ((void*)0) +#else +#define NULL (0) +#endif +#endif +#endif + +#define _IOS_INPUT 1 +#define _IOS_OUTPUT 2 +#define _IOS_ATEND 4 +#define _IOS_APPEND 8 +#define _IOS_TRUNC 16 +#define _IOS_NOCREATE 32 +#define _IOS_NOREPLACE 64 +#define _IOS_BIN 128 + +/* Magic numbers and bits for the _flags field. + The magic numbers use the high-order bits of _flags; + the remaining bits are abailable for variable flags. + Note: The magic numbers must all be negative if stdio + emulation is desired. */ + +#define _IO_MAGIC 0xFBAD0000 /* Magic number */ +#define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */ +#define _IO_MAGIC_MASK 0xFFFF0000 +#define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */ +#define _IO_UNBUFFERED 2 +#define _IO_NO_READS 4 /* Reading not allowed */ +#define _IO_NO_WRITES 8 /* Writing not allowd */ +#define _IO_EOF_SEEN 0x10 +#define _IO_ERR_SEEN 0x20 +#define _IO_DELETE_DONT_CLOSE 0x40 /* Don't call close(_fileno) on cleanup. */ +#define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/ +#define _IO_IN_BACKUP 0x100 +#define _IO_LINE_BUF 0x200 +#define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */ +#define _IO_CURRENTLY_PUTTING 0x800 +#define _IO_IS_APPENDING 0x1000 +#define _IO_IS_FILEBUF 0x2000 + +/* These are "formatting flags" matching the iostream fmtflags enum values. */ +#define _IO_SKIPWS 01 +#define _IO_LEFT 02 +#define _IO_RIGHT 04 +#define _IO_INTERNAL 010 +#define _IO_DEC 020 +#define _IO_OCT 040 +#define _IO_HEX 0100 +#define _IO_SHOWBASE 0200 +#define _IO_SHOWPOINT 0400 +#define _IO_UPPERCASE 01000 +#define _IO_SHOWPOS 02000 +#define _IO_SCIENTIFIC 04000 +#define _IO_FIXED 010000 +#define _IO_UNITBUF 020000 +#define _IO_STDIO 040000 +#define _IO_DONT_CLOSE 0100000 + +/* A streammarker remembers a position in a buffer. */ + +struct _IO_jump_t; struct _IO_FILE; + +struct _IO_marker { + struct _IO_marker *_next; + struct _IO_FILE *_sbuf; + /* If _pos >= 0 + it points to _buf->Gbase()+_pos. FIXME comment */ + /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */ + int _pos; +#if 0 + void set_streampos(streampos sp) { _spos = sp; } + void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } + public: + streammarker(streambuf *sb); + ~streammarker(); + int saving() { return _spos == -2; } + int delta(streammarker&); + int delta(); +#endif +}; + +struct _IO_FILE { +#if _G_USE_INT32_FLAGS + _G_int32_t _flags; /* High-order word is _IO_MAGIC; rest is flags. */ +#else + int _flags; +#endif +#define _IO_file_flags _flags + + /* The following pointers correspond to the C++ streambuf protocol. */ + /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ + char* _IO_read_ptr; /* Current read pointer */ + char* _IO_read_end; /* End of get area. */ + char* _IO_read_base; /* Start of putback+get area. */ + char* _IO_write_base; /* Start of put area. */ + char* _IO_write_ptr; /* Current put pointer. */ + char* _IO_write_end; /* End of put area. */ + char* _IO_buf_base; /* Start of reserve area. */ + char* _IO_buf_end; /* End of reserve area. */ + /* The following fields are used to support backing up and undo. */ + char *_IO_save_base; /* Pointer to start of non-current get area. */ + char *_IO_backup_base; /* Pointer to first valid character of backup area */ + char *_IO_save_end; /* Pointer to end of non-current get area. */ + + struct _IO_marker *_markers; + + struct _IO_FILE *_chain; + + int _fileno; + int _blksize; + _IO_off_t _offset; + +#define __HAVE_COLUMN /* temporary */ + /* 1+column number of pbase(); 0 is unknown. */ + unsigned short _cur_column; + char _unused; + char _shortbuf[1]; + + /* char* _save_gptr; char* _save_egptr; */ +}; + +#ifndef __cplusplus +typedef struct _IO_FILE _IO_FILE; +#endif + +struct _IO_FILE_plus; +extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_; +#define _IO_stdin ((_IO_FILE*)(&_IO_stdin_)) +#define _IO_stdout ((_IO_FILE*)(&_IO_stdout_)) +#define _IO_stderr ((_IO_FILE*)(&_IO_stderr_)) + +#ifdef __cplusplus +extern "C" { +#endif + +extern int __underflow __P((_IO_FILE*)); +extern int __uflow __P((_IO_FILE*)); +extern int __overflow __P((_IO_FILE*, int)); + +#define _IO_getc(_fp) \ + ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow(_fp) \ + : *(unsigned char*)(_fp)->_IO_read_ptr++) +#define _IO_peekc(_fp) \ + ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \ + && __underflow(_fp) == EOF ? EOF \ + : *(unsigned char*)(_fp)->_IO_read_ptr) + +#define _IO_putc(_ch, _fp) \ + (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \ + ? __overflow(_fp, (unsigned char)(_ch)) \ + : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch))) + +#define _IO_feof(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) +#define _IO_ferror(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) + +/* This one is for Emacs. */ +#define _IO_PENDING_OUTPUT_COUNT(_fp) \ + ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) + +extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*)); +extern int _IO_vfprintf __P((_IO_FILE*, const char*, _IO_va_list)); +extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t)); +extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t)); + +extern _IO_fpos_t _IO_seekoff __P((_IO_FILE*, _IO_off_t, int, int)); +extern _IO_fpos_t _IO_seekpos __P((_IO_FILE*, _IO_fpos_t, int)); + +extern void _IO_free_backup_area __P((_IO_FILE*)); + +#ifdef __cplusplus +} +#endif + +#endif /* _IO_STDIO_H */ diff --git a/libio/libioP.h b/libio/libioP.h new file mode 100644 index 000000000000..7efc519aad5b --- /dev/null +++ b/libio/libioP.h @@ -0,0 +1,497 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include +#ifndef errno +extern int errno; +#endif + +#include "iolibio.h" + +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__cplusplus) +/* All known AIX compilers implement these things (but don't always + define __STDC__). The RISC/OS MIPS compiler defines these things + in SVR4 mode, but does not define __STDC__. */ + +#define AND , +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(void) + +#else /* Not ANSI C. */ + +#define AND ; +#ifndef const /* some systems define it in header files for non-ansi mode */ +#define const +#endif +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() +#endif /* ANSI C. */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define _IO_seek_set 0 +#define _IO_seek_cur 1 +#define _IO_seek_end 2 + +/* THE JUMPTABLE FUNCTIONS. + + * The _IO_FILE type is used to implement the FILE type in GNU libc, + * as well as the streambuf class in GNU iostreams for C++. + * These are all the same, just used differently. + * An _IO_FILE (or FILE) object is allows followed by a pointer to + * a jump table (of pointers to functions). The pointer is accessed + * with the _IO_JUMPS macro. The jump table has a eccentric format, + * so as to be compatible with the layout of a C++ virtual function table. + * (as implemented by g++). When a pointer to a steambuf object is + * coerced to an (_IO_FILE*), then _IO_JUMPS on the result just + * happens to point to the virtual function table of the streambuf. + * Thus the _IO_JUMPS function table used for C stdio/libio does + * double duty as the virtual functiuon table for C++ streambuf. + * + * The entries in the _IO_JUMPS function table (and hence also the + * virtual functions of a streambuf) are described below. + * The first parameter of each function entry is the _IO_FILE/streambuf + * object being acted on (i.e. the 'this' parameter). + */ + +#define _IO_JUMPS(THIS) ((struct _IO_FILE_plus*)(THIS))->vtable +#ifdef _G_USING_THUNKS +#define JUMP_FIELD(TYPE, NAME) TYPE NAME +#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC(THIS) +#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC(THIS, X1) +#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC(THIS, X1, X2) +#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC(THIS, X1,X2, X3) +#define JUMP_INIT(NAME, VALUE) VALUE +#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT(dummy2, 0) +#else +/* These macros will change when we re-implement vtables to use "thunks"! */ +#define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME +#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn(THIS) +#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1) +#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1, X2) +#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1,X2, X3) +#define JUMP_INIT(NAME, VALUE) {0, 0, VALUE} +#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0) +#endif + +/* The 'finish' function does any final cleaning up of an _IO_FILE object. + It does not delete (free) it, but does everything else to finalize it/ + It matches the streambuf::~streambuf virtual destructor. */ +typedef void (*_IO_finish_t) __P((_IO_FILE*)); /* finalize */ +#define _IO_FINISH(FP) JUMP0(__finish, FP) + +/* The 'overflow' hook flushes the buffer. + The second argument is a character, or EOF. + It matches the streambuf::overflow virtual function. */ +typedef int (*_IO_overflow_t) __P((_IO_FILE*, int)); +#define _IO_OVERFLOW(FP, CH) JUMP1(__overflow, FP, CH) + +/* The 'underflow' hook tries to fills the get buffer. + It returns the next character (as an unsigned char) or EOF. The next + character remains in the get buffer, and the get postion is not changed. + It matches the streambuf::underflow virtual function. */ +typedef int (*_IO_underflow_t) __P((_IO_FILE*)); +#define _IO_UNDERFLOW(FP) JUMP0(__underflow, FP) + +/* The 'uflow' hook returns the next character in the input stream + (cast to unsigned char), and increments the read position; + EOF is returned on failure. + It matches the streambuf::uflow virtual function, which is not in the + cfront implementation, but was added to C++ by the ANSI/ISO committee. */ +#define _IO_UFLOW(FP) JUMP0(__uflow, FP) + +/* The 'pbackfail' hook handles backing up. + It matches the streambuf::pbackfail virtual function. */ +typedef int (*_IO_pbackfail_t) __P((_IO_FILE*, int)); +#define _IO_PBACKFAIL(FP, CH) JUMP1(__pbackfail, FP, CH) + +/* The 'xsputn' hook writes upto N characters from buffer DATA. + Returns the number of character actually written. + It matches the streambuf::xsputn virtual function. */ +typedef _IO_size_t (*_IO_xsputn_t) + __P((_IO_FILE *FP, const void *DATA, _IO_size_t N)); +#define _IO_XSPUTN(FP, DATA, N) JUMP2(__xsputn, FP, DATA, N) + +/* The 'xsgetn' hook reads upto N characters into buffer DATA. + Returns the number of character actually read. + It matches the streambuf::xsgetn virtual function. */ +typedef _IO_size_t (*_IO_xsgetn_t) __P((_IO_FILE*FP, void*DATA, _IO_size_t N)); +#define _IO_XSGETN(FP, DATA, N) JUMP2(__xsgetn, FP, DATA, N) + +/* The 'seekoff' hook moves the stream position to a new position + relative to the start of the file (if DIR==0), the current position + (MODE==1), or the end of the file (MODE==2). + It matches the streambuf::seekoff virtual function. + It is also used for the ANSI fseek function. */ +typedef _IO_fpos_t (*_IO_seekoff_t) + __P((_IO_FILE* FP, _IO_off_t OFF, int DIR, int MODE)); +#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3(__seekoff, FP, OFF, DIR, MODE) + +/* The 'seekpos' hook also moves the stream position, + but to an absolute position given by a fpos_t (seekpos). + It matches the streambuf::seekpos virtual function. + It is also used for the ANSI fgetpos and fsetpos functions. */ +/* The _IO_seek_cur and _IO_seek_end options are not allowed. */ +typedef _IO_fpos_t (*_IO_seekpos_t) __P((_IO_FILE*, _IO_fpos_t, int)); +#define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2(__seekpos, FP, POS, FLAGS) + +/* The 'setbuf' hook gives a buffer to the file. + It matches the streambuf::setbuf virtual function. */ +typedef _IO_FILE* (*_IO_setbuf_t) __P((_IO_FILE*, char *, _IO_ssize_t)); +#define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2(__setbuf, FP, BUFFER, LENGTH) + +/* The 'sync' hook attempts to synchronize the internal data structures + of the file with the external state. + It matches the streambuf::sync virtual function. */ +typedef int (*_IO_sync_t) __P((_IO_FILE*)); +#define _IO_SYNC(FP) JUMP0(__sync, FP) + +/* The 'doallocate' hook is used to tell the file to allocate a buffer. + It matches the streambuf::doallocate virtual function, which is not + in the ANSI/ISO C++ standard, but is part traditional implementations. */ +typedef int (*_IO_doallocate_t) __P((_IO_FILE*)); +#define _IO_DOALLOCATE(FP) JUMP0(__doallocate, FP) + +/* The following four hooks (sysread, syswrite, sysclose, sysseek, and + sysstat) are low-level hooks specific to this implementation. + There is no correspondance in the ANSI/ISO C++ standard library. + The hooks basically correspond to the Unix system functions + (read, write, close, lseek, and stat) except that a _IO_FILE* + parameter is used instead of a integer file descriptor; the default + implementation used for normal files just calls those functions. + The advantage of overriding these functions instead of the higher-level + ones (underflow, overflow etc) is that you can leave all the buffering + higher-level functions. */ + +/* The 'sysread' hook is used to read data from the external file into + an existing buffer. It generalizes the Unix read(2) function. + It matches the streambuf::sys_read virtual function, which is + specific to this implementaion. */ +typedef _IO_ssize_t (*_IO_read_t) __P((_IO_FILE*, void*, _IO_ssize_t)); +#define _IO_SYSREAD(FP, DATA, LEN) JUMP2(__read, FP, DATA, LEN) + +/* The 'syswrite' hook is used to write data from an existing buffer + to an external file. It generalizes the Unix write(2) function. + It matches the streambuf::sys_write virtual function, which is + specific to this implementaion. */ +typedef _IO_ssize_t (*_IO_write_t) __P((_IO_FILE*,const void*,_IO_ssize_t)); +#define _IO_SYSWRITE(FP, DATA, LEN) JUMP2(__write, FP, DATA, LEN) + +/* The 'sysseek' hook is used to re-position an external file. + It generalizes the Unix lseek(2) function. + It matches the streambuf::sys_seek virtual function, which is + specific to this implementaion. */ +typedef _IO_fpos_t (*_IO_seek_t) __P((_IO_FILE*, _IO_off_t, int)); +#define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2(__seek, FP, OFFSET, MODE) + +/* The 'sysclose' hook is used to finalize (close, finish up) an + external file. It generalizes the Unix close(2) function. + It matches the streambuf::sys_close virtual function, which is + specific to this implementation. */ +typedef int (*_IO_close_t) __P((_IO_FILE*)); /* finalize */ +#define _IO_SYSCLOSE(FP) JUMP0(__close, FP) + +/* The 'sysstat' hook is used to get information about an external file + into a struct stat buffer. It generalizes the Unix fstat(2) call. + It matches the streambuf::sys_stat virtual function, which is + specific to this implementaion. */ +typedef int (*_IO_stat_t) __P((_IO_FILE*, void*)); +#define _IO_SYSSTAT(FP, BUF) JUMP1(__stat, FP, BUF) + + +#define _IO_CHAR_TYPE char /* unsigned char ? */ +#define _IO_INT_TYPE int + +struct _IO_jump_t { + JUMP_FIELD(_G_size_t, __dummy); +#ifdef _G_USING_THUNKS + JUMP_FIELD(_G_size_t, __dummy2); +#endif + JUMP_FIELD(_IO_finish_t, __finish); + JUMP_FIELD(_IO_overflow_t, __overflow); + JUMP_FIELD(_IO_underflow_t, __underflow); + JUMP_FIELD(_IO_underflow_t, __uflow); + JUMP_FIELD(_IO_pbackfail_t, __pbackfail); + /* showmany */ + JUMP_FIELD(_IO_xsputn_t, __xsputn); + JUMP_FIELD(_IO_xsgetn_t, __xsgetn); + JUMP_FIELD(_IO_seekoff_t, __seekoff); + JUMP_FIELD(_IO_seekpos_t, __seekpos); + JUMP_FIELD(_IO_setbuf_t, __setbuf); + JUMP_FIELD(_IO_sync_t, __sync); + JUMP_FIELD(_IO_doallocate_t, __doallocate); + JUMP_FIELD(_IO_read_t, __read); + JUMP_FIELD(_IO_write_t, __write); + JUMP_FIELD(_IO_seek_t, __seek); + JUMP_FIELD(_IO_close_t, __close); + JUMP_FIELD(_IO_stat_t, __stat); +#if 0 + get_column; + set_column; +#endif +}; + +/* We always allocate an extra word following an _IO_FILE. + This contains a pointer to the function jump table used. + This is for compatibility with C++ streambuf; the word can + be used to smash to a pointer to a virtual function table. */ + +struct _IO_FILE_plus { + _IO_FILE file; + const struct _IO_jump_t *vtable; +}; + +/* Generic functions */ + +extern int _IO_switch_to_get_mode __P((_IO_FILE*)); +extern void _IO_init __P((_IO_FILE*, int)); +extern int _IO_sputbackc __P((_IO_FILE*, int)); +extern int _IO_sungetc __P((_IO_FILE*)); +extern void _IO_un_link __P((_IO_FILE*)); +extern void _IO_link_in __P((_IO_FILE *)); +extern void _IO_doallocbuf __P((_IO_FILE*)); +extern void _IO_unsave_markers __P((_IO_FILE*)); +extern void _IO_setb __P((_IO_FILE*, char*, char*, int)); +extern unsigned _IO_adjust_column __P((unsigned, const char *, int)); +#define _IO_sputn(__fp, __s, __n) _IO_XSPUTN(__fp, __s, __n) + +/* Marker-related function. */ + +extern void _IO_init_marker __P((struct _IO_marker *, _IO_FILE *)); +extern void _IO_remove_marker __P((struct _IO_marker*)); +extern int _IO_marker_difference __P((struct _IO_marker *, struct _IO_marker *)); +extern int _IO_marker_delta __P((struct _IO_marker *)); +extern int _IO_seekmark __P((_IO_FILE *, struct _IO_marker *, int)); + +/* Default jumptable functions. */ + +extern int _IO_default_underflow __P((_IO_FILE*)); +extern int _IO_default_uflow __P((_IO_FILE*)); +extern int _IO_default_doallocate __P((_IO_FILE*)); +extern void _IO_default_finish __P((_IO_FILE *)); +extern int _IO_default_pbackfail __P((_IO_FILE*, int)); +extern _IO_FILE* _IO_default_setbuf __P((_IO_FILE *, char*, _IO_ssize_t)); +extern _IO_size_t _IO_default_xsputn __P((_IO_FILE *, const void*, _IO_size_t)); +extern _IO_size_t _IO_default_xsgetn __P((_IO_FILE *, void*, _IO_size_t)); +extern _IO_fpos_t _IO_default_seekoff __P((_IO_FILE*, _IO_off_t, int, int)); +extern _IO_fpos_t _IO_default_seekpos __P((_IO_FILE*, _IO_fpos_t, int)); +extern _IO_ssize_t _IO_default_write __P((_IO_FILE*,const void*,_IO_ssize_t)); +extern _IO_ssize_t _IO_default_read __P((_IO_FILE*, void*, _IO_ssize_t)); +extern int _IO_default_stat __P((_IO_FILE*, void*)); +extern _IO_fpos_t _IO_default_seek __P((_IO_FILE*, _IO_off_t, int)); +extern int _IO_default_sync __P((_IO_FILE*)); +#define _IO_default_close ((_IO_close_t)_IO_default_sync) + +extern struct _IO_jump_t _IO_file_jumps; +extern struct _IO_jump_t _IO_streambuf_jumps; +extern struct _IO_jump_t _IO_proc_jumps; +extern struct _IO_jump_t _IO_str_jumps; +extern int _IO_do_write __P((_IO_FILE*, const char*, _IO_size_t)); +extern int _IO_flush_all __P((void)); +extern void _IO_cleanup __P((void)); +extern void _IO_flush_all_linebuffered __P((void)); + +#define _IO_do_flush(_f) \ + _IO_do_write(_f, (_f)->_IO_write_base, \ + (_f)->_IO_write_ptr-(_f)->_IO_write_base) +#define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING) +#define _IO_mask_flags(fp, f, mask) \ + ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask))) +#define _IO_setg(fp, eb, g, eg) ((fp)->_IO_read_base = (eb),\ + (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg)) +#define _IO_setp(__fp, __p, __ep) \ + ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr = __p, (__fp)->_IO_write_end = (__ep)) +#define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL) +#define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP) +#define _IO_have_markers(fp) ((fp)->_markers != NULL) +#define _IO_blen(fp) ((fp)->_IO_buf_end - (fp)->_IO_buf_base) + +/* Jumptable functions for files. */ + +extern int _IO_file_doallocate __P((_IO_FILE*)); +extern _IO_FILE* _IO_file_setbuf __P((_IO_FILE *, char*, _IO_ssize_t)); +extern _IO_fpos_t _IO_file_seekoff __P((_IO_FILE*, _IO_off_t, int, int)); +extern _IO_size_t _IO_file_xsputn __P((_IO_FILE*,const void*,_IO_size_t)); +extern int _IO_file_stat __P((_IO_FILE*, void*)); +extern int _IO_file_close __P((_IO_FILE*)); +extern int _IO_file_underflow __P((_IO_FILE *)); +extern int _IO_file_overflow __P((_IO_FILE *, int)); +#define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0) +extern void _IO_file_init __P((_IO_FILE*)); +extern _IO_FILE* _IO_file_fopen __P((_IO_FILE*, const char*, const char*)); +extern _IO_ssize_t _IO_file_write __P((_IO_FILE*,const void*,_IO_ssize_t)); +extern _IO_ssize_t _IO_file_read __P((_IO_FILE*, void*, _IO_ssize_t)); +extern int _IO_file_sync __P((_IO_FILE*)); +extern int _IO_file_close_it __P((_IO_FILE*)); +extern _IO_fpos_t _IO_file_seek __P((_IO_FILE *, _IO_off_t, int)); +extern void _IO_file_finish __P((_IO_FILE*)); + +/* Other file functions. */ +extern _IO_FILE* _IO_file_attach __P((_IO_FILE *, int)); + +/* Jumptable functions for proc_files. */ +extern _IO_FILE* _IO_proc_open __P((_IO_FILE*, const char*, const char *)); +extern int _IO_proc_close __P((_IO_FILE*)); + +/* Jumptable functions for strfiles. */ +extern int _IO_str_underflow __P((_IO_FILE*)); +extern int _IO_str_overflow __P((_IO_FILE *, int)); +extern int _IO_str_pbackfail __P((_IO_FILE*, int)); +extern _IO_fpos_t _IO_str_seekoff __P((_IO_FILE*,_IO_off_t,int,int)); + +/* Other strfile functions */ +extern void _IO_str_init_static __P((_IO_FILE *, char*, int, char*)); +extern void _IO_str_init_readonly __P((_IO_FILE *, const char*, int)); +extern _IO_ssize_t _IO_str_count __P ((_IO_FILE*)); + +extern _IO_size_t _IO_getline __P((_IO_FILE*,char*,_IO_size_t,int,int)); +extern _IO_ssize_t _IO_getdelim __P((char**, _IO_size_t*, int, _IO_FILE*)); +extern double _IO_strtod __P((const char *, char **)); +extern char * _IO_dtoa __P((double __d, int __mode, int __ndigits, + int *__decpt, int *__sign, char **__rve)); +extern int _IO_outfloat __P((double __value, _IO_FILE *__sb, int __type, + int __width, int __precision, int __flags, + int __sign_mode, int __fill)); + +extern _IO_FILE *_IO_list_all; +extern void (*_IO_cleanup_registration_needed) __P ((void)); + +#ifndef EOF +#define EOF (-1) +#endif +#ifndef NULL +#ifdef __GNUG__ +#define NULL (__null) +#else +#if !defined(__cplusplus) +#define NULL ((void*)0) +#else +#define NULL (0) +#endif +#endif +#endif + +#define FREE_BUF(_B) free(_B) +#define ALLOC_BUF(_S) (char*)malloc(_S) + +#ifndef OS_FSTAT +#define OS_FSTAT fstat +#endif +struct stat; +extern _IO_ssize_t _IO_read __P((int, void*, _IO_size_t)); +extern _IO_ssize_t _IO_write __P((int, const void*, _IO_size_t)); +extern _IO_off_t _IO_lseek __P((int, _IO_off_t, int)); +extern int _IO_close __P((int)); +extern int _IO_fstat __P((int, struct stat *)); + +/* Operations on _IO_fpos_t. + Normally, these are trivial, but we provide hooks for configurations + where an _IO_fpos_t is a struct. + Note that _IO_off_t must be an integral type. */ + +/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */ +#ifndef _IO_pos_BAD +#define _IO_pos_BAD ((_IO_fpos_t)(-1)) +#endif +/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */ +#ifndef _IO_pos_as_off +#define _IO_pos_as_off(__pos) ((_IO_off_t)(__pos)) +#endif +/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */ +#ifndef _IO_pos_adjust +#define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta)) +#endif +/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */ +#ifndef _IO_pos_0 +#define _IO_pos_0 ((_IO_fpos_t)0) +#endif + +#ifdef __cplusplus +} +#endif + +/* check following! */ +#define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \ + { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD} + +/* VTABLE_LABEL defines NAME as of the CLASS class. + CNLENGTH is strlen(#CLASS). */ +#ifdef __GNUC__ +#if _G_VTABLE_LABEL_HAS_LENGTH +#define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \ + extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS); +#else +#define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \ + extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS); +#endif +#endif /* __GNUC__ */ + +#if !defined(builtinbuf_vtable) && defined(__cplusplus) +#ifdef __GNUC__ +VTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10) +#else +#if _G_VTABLE_LABEL_HAS_LENGTH +#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf +#else +#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf +#endif +#endif +#endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */ + +#if defined(__STDC__) || defined(__cplusplus) +#define _IO_va_start(args, last) va_start(args, last) +#else +#define _IO_va_start(args, last) va_start(args) +#endif + +extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf; + +#if 1 +#define COERCE_FILE(FILE) /* Nothing */ +#else +/* This is part of the kludge for binary compatibility with old stdio. */ +#define COERCE_FILE(FILE) \ + (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \ + && (FILE) = *(FILE**)&((int*)fp)[1]) +#endif + +#ifdef EINVAL +#define MAYBE_SET_EINVAL errno = EINVAL +#else +#define MAYBE_SET_EINVAL /* nothing */ +#endif + +#ifdef DEBUG +#define CHECK_FILE(FILE,RET) \ + if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \ + else { COERCE_FILE(FILE); \ + if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ + { errno = EINVAL; return RET; }} +#else +#define CHECK_FILE(FILE,RET) \ + COERCE_FILE(FILE) +#endif diff --git a/libio/osform.cc b/libio/osform.cc new file mode 100644 index 000000000000..8c0011703da0 --- /dev/null +++ b/libio/osform.cc @@ -0,0 +1,54 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include +#include + +ostream& ostream::form(const char *format ...) +{ + if (opfx()) { + va_list ap; + va_start(ap, format); + _IO_vfprintf(rdbuf(), format, ap); + va_end(ap); + } + return *this; +} + +ostream& ostream::vform(const char *format, _IO_va_list args) +{ + if (opfx()) + _IO_vfprintf(rdbuf(), format, args); + return *this; +} + +ostream& ostream::operator<<(const void *p) +{ + if (opfx()) { + form("%p", p); + osfx(); + } + return *this; +} diff --git a/libio/ostream.h b/libio/ostream.h new file mode 100644 index 000000000000..f54ec1de9a1c --- /dev/null +++ b/libio/ostream.h @@ -0,0 +1,25 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include diff --git a/libio/outfloat.c b/libio/outfloat.c new file mode 100644 index 000000000000..a74b1a2c3e13 --- /dev/null +++ b/libio/outfloat.c @@ -0,0 +1,204 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +/* Format floating-point number and print them. + Return number of chars printed, or EOF on error. + + sign_mode == '+' : print "-" or "+" + sign_mode == ' ' : print "-" or " " + sign_mode == '\0' : print "-' or "" +*/ + +int +DEFUN(_IO_outfloat, (value, sb, type, width, precision, flags, + sign_mode, fill), + double value AND _IO_FILE *sb AND int type AND int width + AND int precision AND int flags AND int sign_mode AND int fill) +{ + int count = 0; +#define PUT(x) do {if (_IO_putc(x, sb) < 0) goto error; count++;} while (0) +#define PUTN(p, n) \ + do {int _n=n; count+=_n; if (_IO_sputn(sb, p,_n) != _n) goto error;} while(0) +#define PADN(fill, n) \ + do {int _n = n; count+=_n; if (_IO_padn(sb, fill, _n) != _n) goto error;} while (0) + int pad_kind = flags & (_IO_LEFT|_IO_RIGHT|_IO_INTERNAL); + int skip_zeroes = 0; + int show_dot = (flags & _IO_SHOWPOINT) != 0; + int decpt; + int sign; + int mode; + int exponent_size; + int print_sign; + int trailing_zeroes, useful_digits; + int padding, unpadded_width; + char *p; + char *exponent_start; + register int i; +#define EBUF_SIZE 12 +#define EBUF_END &ebuf[EBUF_SIZE] + char ebuf[EBUF_SIZE]; + char *end; + int exp = 0; + switch (type) + { + case 'f': + mode = 3; + break; + case 'e': + case 'E': + exp = type; + mode = 2; + if (precision != 999) + precision++; /* Add one to include digit before decimal point. */ + break; + case 'g': + case 'G': + exp = type == 'g' ? 'e' : 'E'; + if (precision == 0) precision = 1; + if (!(flags & _IO_SHOWPOINT)) + skip_zeroes = 1; + type = 'g'; + mode = 2; + break; + } + /* Do the actual convension */ + if (precision == 999 && mode != 3) + mode = 0; + p = _IO_dtoa(value, mode, precision, &decpt, &sign, &end); + useful_digits = end-p; + exponent_start = EBUF_END; + if (mode == 0) + precision = useful_digits; + /* Check if we need to emit an exponent. */ + if (mode != 3 && decpt != 9999) + { + i = decpt - 1; + if ((type != 'g' && type != 'F') || i < -4 || i >= precision) + { + /* Print the exponent into ebuf. + We write ebuf in reverse order (right-to-left). */ + char sign; + if (i >= 0) + sign = '+'; + else + sign = '-', i = -i; + /* Note: ANSI requires at least 2 exponent digits. */ + do { + *--exponent_start = (i % 10) + '0'; + i /= 10; + } while (i >= 10); + *--exponent_start = i + '0'; + *--exponent_start = sign; + *--exponent_start = exp; + } + } + exponent_size = EBUF_END - exponent_start; + if (mode == 1) + precision = 1; + /* If we print an exponent, always show just one digit before point. */ + if (exponent_size) + decpt = 1; + if (decpt == 9999) + { /* Infinity or NaN */ + decpt = useful_digits; + precision = 0; + show_dot = 0; + } + + /* dtoa truncates trailing zeroes. Set the variable trailing_zeroes to + the number of 0's we have to add (after the decimal point). */ + if (skip_zeroes) + trailing_zeroes = 0; + else if (type == 'f') + trailing_zeroes = useful_digits <= decpt ? precision + : precision-(useful_digits-decpt); + else if (exponent_size) /* 'e' 'E' or 'g' format using exponential notation*/ + trailing_zeroes = precision - useful_digits; + else /* 'g' format not using exponential notation. */ + trailing_zeroes = useful_digits <= decpt ? precision - decpt + : precision-useful_digits; + if (trailing_zeroes < 0) trailing_zeroes = 0; + + if (trailing_zeroes != 0 || useful_digits > decpt) + show_dot = 1; + if (sign_mode == 0) + print_sign = sign ? '-' : 0; + else if (sign_mode == '+') + print_sign = sign ? '-' : '+'; + else /* if (sign_mode == ' ') */ + print_sign = sign ? '-' : ' '; + + /* Calculate the width (before padding). */ + unpadded_width = + (print_sign != 0) + trailing_zeroes + exponent_size + show_dot + + useful_digits + + (decpt > useful_digits ? decpt - useful_digits + : decpt > 0 ? 0 : 1 - decpt); + + padding = width > unpadded_width ? width - unpadded_width : 0; + if (padding > 0 && pad_kind != _IO_LEFT && pad_kind != _IO_INTERNAL) + PADN(fill, padding); /* Default (right) adjust */ + if (print_sign) + PUT(print_sign); + if (pad_kind == _IO_INTERNAL && padding > 0) + PADN(fill, padding); + if (decpt > 0) + { + if (useful_digits >= decpt) + PUTN(p, decpt); + else + { + PUTN(p, useful_digits); + PADN('0', decpt-useful_digits); + } + if (show_dot) + { + PUT('.'); + /* Print digits after the decimal point. */ + if (useful_digits > decpt) + PUTN(p + decpt, useful_digits-decpt); + } + } + else + { + PUT('0'); + if (show_dot) + { + PUT('.'); + PADN('0', -decpt); + /* Print digits after the decimal point. */ + PUTN(p, useful_digits); + } + } + PADN('0', trailing_zeroes); + if (exponent_size) + PUTN(exponent_start, exponent_size); + if (pad_kind == _IO_LEFT && padding > 0) /* Left adjustment*/ + PADN(fill, padding); + return count; + error: + return EOF; +} diff --git a/libio/parsestream.cc b/libio/parsestream.cc new file mode 100644 index 000000000000..320afd06d9be --- /dev/null +++ b/libio/parsestream.cc @@ -0,0 +1,317 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include "libioP.h" +#include "parsestream.h" +#include + +streambuf* parsebuf::setbuf(char*, int) +{ + return NULL; +} + +int parsebuf::tell_in_line() +{ + return 0; +} + +int parsebuf::pbackfail(int c) +{ + if (c == EOF) + return 0; + if (seekoff(-1, ios::cur) == EOF) + return EOF; + return (unsigned char)c; +} + +char* parsebuf::current_line() { return NULL; } + +streampos parsebuf::seekoff(streamoff offset, _seek_dir dir, int) +{ + // Make offset relative to line start. + switch (dir) { + case ios::beg: + offset -= pos_at_line_start; + break; + case ios::cur: + offset += tell_in_line(); + break; + default: + return EOF; + } + if (offset < -1) + return EOF; + if (offset > _line_length + 1) + return EOF; + return seek_in_line(offset) + pos_at_line_start; +} + +// string_parsebuf invariants: +// The reserve ares (base() .. ebuf()) is always the entire string. +// The get area (eback() .. egptr()) is the extended current line +// (i.e. with the '\n' at either end, if these exist). + +string_parsebuf::string_parsebuf(char *buf, int len, + int delete_at_close /* = 0*/) +: parsebuf() +{ + setb(buf, buf+len, delete_at_close); + register char *ptr = buf; + while (ptr < ebuf() && *ptr != '\n') ptr++; + _line_length = ptr - buf; + setg(buf, buf, ptr); +} + +int string_parsebuf::underflow() +{ + register char* ptr = egptr(); // Point to end of current_line + do { + int i = right() - ptr; + if (i <= 0) + return EOF; + ptr++; i--; // Skip '\n'. + char *line_start = ptr; + while (ptr < right() && *ptr == '\n') ptr++; + setg(line_start-1, line_start, ptr + (ptr < right())); + pos_at_line_start = line_start - left(); + _line_length = ptr - line_start; + __line_number++; + } while (gptr() == ptr); + return *gptr(); +} + +char* string_parsebuf::current_line() +{ + char *ptr = eback(); + if (__line_number > 0) + ptr++; // Skip '\n' at end of previous line. + return ptr; +} + +int string_parsebuf::tell_in_line() +{ + int offset = gptr() - eback(); + if (__line_number > 0) + offset--; + return offset; +} + +int string_parsebuf::seek_in_line(int i) +{ + int delta = i - tell_in_line(); + gbump(delta); // FIXME: Needs error (bounds) checking! + return i; +} + +static const char NewLine[1] = { '\n' }; + +general_parsebuf::general_parsebuf(streambuf *buf, int delete_arg_buf) + : parsebuf() +{ + delete_buf = delete_arg_buf; + sbuf = buf; + int buf_size = 128; + char* buffer = ALLOC_BUF(buf_size); + setb(buffer, buffer+buf_size, 1); +// setg(buffer, buffer, buffer); +} + +general_parsebuf::~general_parsebuf() +{ + if (delete_buf) + delete sbuf; +} + +int general_parsebuf::underflow() +{ + register char *ptr = base(); + int has_newline = eback() < gptr() && gptr()[-1] == '\n'; + if (has_newline) + *ptr++ = '\n'; + register streambuf *sb = sbuf; + register int ch; + for (;;) { + ch = sb->sbumpc(); + if (ch == EOF) + break; + if (ptr == ebuf()) { + int old_size = ebuf() - base(); + char *new_buffer = new char[old_size * 2]; + memcpy(new_buffer, base(), old_size); + setb(new_buffer, new_buffer + 2 * old_size, 1); + ptr = new_buffer + old_size; + } + *ptr++ = ch; + if (ch == '\n') + break; + } + char *cur_pos = base() + has_newline; + pos_at_line_start += _line_length + 1; + _line_length = ptr - cur_pos; + if (ch != EOF || _line_length > 0) + __line_number++; + setg(base(), cur_pos, ptr); + return ptr == cur_pos ? EOF : cur_pos[0]; +} + +char* general_parsebuf::current_line() +{ + char* ret = base(); + if (__line_number > 1) + ret++; // Move past '\n' from end of previous line. + return ret; +} + +int general_parsebuf::tell_in_line() +{ + int off = gptr() - base(); + if (__line_number > 1) + off--; // Subtract 1 for '\n' from end of previous line. + return off; +} + +int general_parsebuf::seek_in_line(int i) +{ + if (__line_number == 0) + (void)general_parsebuf::underflow(); + if (__line_number > 1) + i++; // Add 1 for '\n' from end of previous line. + if (i < 0) i = 0; + int len = egptr() - eback(); + if (i > len) i = len; + setg(base(), base() + i, egptr()); + return i; +} + +func_parsebuf::func_parsebuf(CharReader func, void *argm) : parsebuf() +{ + read_func = func; + arg = argm; + buf_start = NULL; + buf_end = NULL; + setb((char*)NewLine, (char*)NewLine+1, 0); + setg((char*)NewLine, (char*)NewLine+1, (char*)NewLine+1); + backed_up_to_newline = 0; +} + +int func_parsebuf::tell_in_line() +{ + if (buf_start == NULL) + return 0; + if (egptr() != (char*)NewLine+1) + // Get buffer was line buffer. + return gptr() - buf_start; + if (backed_up_to_newline) + return -1; // Get buffer is '\n' preceding current line. + // Get buffer is '\n' following current line. + return (buf_end - buf_start) + (gptr() - (char*)NewLine); +} + +char* func_parsebuf::current_line() +{ + return buf_start; +} + +int func_parsebuf::seek_in_line(int i) +{ + if (i < 0) { + // Back up to preceding '\n'. + if (i < -1) i = -1; + backed_up_to_newline = 1; + setg((char*)NewLine, (char*)NewLine+(i+1), (char*)NewLine+1); + return i; + } + backed_up_to_newline = 0; + int line_length = buf_end-buf_start; + if (i <= line_length) { + setg(buf_start, buf_start+i, buf_end); + return i; + } + i -= line_length; + if (i > 0) i = 1; + setg((char*)NewLine, (char*)NewLine+i, (char*)NewLine+1); + return line_length + i; +} + +int func_parsebuf::underflow() +{ + retry: + if (gptr() < egptr()) + return *gptr(); + if (gptr() != (char*)NewLine+1) { + // Get buffer was line buffer. Move to following '\n'. + setg((char*)NewLine, (char*)NewLine, (char*)NewLine+1); + return *gptr(); + } + if (backed_up_to_newline) + // Get buffer was '\n' preceding current line. Move to current line. + backed_up_to_newline = 0; + else { + // Get buffer was '\n' following current line. Read new line. + if (buf_start) free(buf_start); + char *str = (*read_func)(arg); + buf_start = str; + if (str == NULL) + return EOF; + // Initially, _line_length == -1, so pos_at_line_start becomes 0. + pos_at_line_start += _line_length + 1; + _line_length = strlen(str); + buf_end = str + _line_length; + __line_number++; + } + setg(buf_start, buf_start, buf_end); + goto retry; +} + +#if 0 +size_t parsebuf::line_length() +{ + if (current_line_length == (size_t)(-1)) // Initial value; + (void)sgetc(); + return current_line_length; +} +#endif + +int parsebuf::seek_in_line(int i) +{ +#if 1 + abort(); + return i; // Suppress warnings. +#else + if (i > 0) { + size_t len = line_length(); + if ((unsigned)i > len) i = len; + } + else if (i < -1) i = -1; + int new_pos = seekoff(pos_at_line_start + i, ios::beg); + if (new_pos == EOF) + return tell_in_line(); + else return new_pos - pos_at_line_start; +#endif +} diff --git a/libio/parsestream.h b/libio/parsestream.h new file mode 100644 index 000000000000..326ab87a8090 --- /dev/null +++ b/libio/parsestream.h @@ -0,0 +1,156 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. + +Written by Per Bothner (bothner@cygnus.com). */ + +#ifndef PARSESTREAM_H +#define PARSESTREAM_H +#ifdef __GNUG__ +#pragma interface +#endif +#include "streambuf.h" + +extern "C++" { +// A parsebuf is a streambuf optimized for scanning text files. +// It keeps track of line and column numbers. +// It is guaranteed to remember the entire current line, +// as well the '\n'-s on either side of it (if they exist). +// You can arbitrarily seek (or unget) within this extended line. +// Other backward seeks are not supported. +// Normal read semantics are supported (and hence istream operators like >>). + +class parsebuf : public streambuf { + protected: + _IO_fpos_t pos_at_line_start; + long _line_length; + unsigned long __line_number; + char *buf_start; + char *buf_end; + + public: + parsebuf *chain; + + // Return column number (raw - don't handle tabs etc). + // Retult can be -1, meaning: at '\n' before current line. + virtual int tell_in_line(); + + // seek to (raw) column I in current line. + // Result is new (raw) column position - differs from I if unable to seek. + // Seek to -1 tries to seek to before previous LF. + virtual int seek_in_line(int i); + + // Note: there is no "current line" initially, until something is read. + + // Current line number, starting with 0. + // If tell_in_line()==-1, then line number of next line. + int line_number() { return __line_number; } + + // Length of current line, not counting either '\n'. + int line_length() { return _line_length; } + // Current line - not a copy, so file ops may trash it. + virtual char* current_line(); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + virtual streambuf* setbuf(char* p, int len); + protected: + parsebuf() { chain= NULL; + __line_number = 0; pos_at_line_start = 0; _line_length = -1; } + virtual int pbackfail(int c); +}; + +// A string_parsebuf is a parsebuf whose source is a fixed string. + +class string_parsebuf : public parsebuf { + public: + int do_delete; + string_parsebuf(char *str, int len, int delete_at_close=0); + virtual int underflow(); + virtual char* current_line(); + virtual int seek_in_line(int i); + virtual int tell_in_line(); + char *left() const { return base(); } + char *right() const { return ebuf(); } +// streampos seekoff(streamoff, _seek_dir, int); +}; + +// A func_parsebuf calls a given function to get new input. +// Each call returns an entire NUL-terminated line (without the '\n'). +// That line has been allocated with malloc(), not new. +// The interface is tailored to the GNU readline library. +// Example: +// char* DoReadLine(void* arg) +// { +// char *line = readline((char*)arg); /* 'arg' is used as prompt. */ +// if line == NULL) { putc('\n', stderr); return NULL; } +// if (line[0] != '\0') add_history(line); +// return line; +// } +// char PromptBuffer[100] = "> "; +// func_parsebuf my_stream(DoReadLine, PromptBuffer); + +typedef char *(*CharReader)(void *arg); +class istream; + +class func_parsebuf : public parsebuf { + public: + void *arg; + CharReader read_func; + int backed_up_to_newline; + func_parsebuf(CharReader func, void *argm = NULL); + int underflow(); + virtual int tell_in_line(); + virtual int seek_in_line(int i); + virtual char* current_line(); +}; + +// A general_parsebuf is a parsebuf which gets its input from some +// other streambuf. It explicitly buffers up an entire line. + +class general_parsebuf : public parsebuf { + public: + streambuf *sbuf; + int delete_buf; // Delete sbuf when destroying this. + general_parsebuf(streambuf *buf, int delete_arg_buf = 0); + int underflow(); + virtual int tell_in_line(); + virtual int seek_in_line(int i); + ~general_parsebuf(); + virtual char* current_line(); +}; + +#if 0 +class parsestream : public istream { + streammarker marks[2]; + short _first; // of the two marks; either 0 or 1 + int _lineno; + int first() { return _first; } + int second() { return 1-_first; } + int line_length() { marks[second].delta(marks[first]); } + int line_length() { marks[second].delta(marks[first]); } + int seek_in_line(int i); + int tell_in_line(); + int line_number(); +}; +#endif +} // extern "C++" +#endif /*!defined(PARSESTREAM_H)*/ diff --git a/libio/pfstream.cc b/libio/pfstream.cc new file mode 100644 index 000000000000..3fa93c958f8f --- /dev/null +++ b/libio/pfstream.cc @@ -0,0 +1,92 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include "libioP.h" +#include +#include + +ipfstream::ipfstream(const char *name, int mode, int prot) +{ + const char* p; + + // Look for '| command' (as used by ftp). + for (p = name; *p == ' ' || *p == '\t'; p++) ; + if (*p == '|') { + procbuf *pbuf = new procbuf(); + init(pbuf); + if (!pbuf->open(p+1, mode)) + set(ios::badbit); + return; + } + + // Look for 'command |' + while (*p) p++; // Point to last + while (p[-1] == ' ' || p[-1] == '\t' || p[-1] == '\n') p--; + if (p[-1] == '|') { + // Must remove the final '|'. + p--; +#if !defined (__GNUC__) || defined (__STRICT_ANSI__) + char *command = new char[p-name+1]; +#else + char command[p-name+1]; +#endif + memcpy(command, name, p-name); + command[p-name] = '\0'; + + procbuf *pbuf = new procbuf(); + if (pbuf->open(command, mode)) + set(ios::badbit); +#if !defined (__GNUC__) || defined (__STRICT_ANSI__) + delete command; +#endif + return; + } + + init(new filebuf()); + if (!rdbuf()->open(name, mode, prot)) + set(ios::badbit); +} + +opfstream::opfstream(const char *name, int mode, int prot) +{ + const char *p; + // Look for '| command'. + for (p = name; *p == ' ' || *p == '\t'; p++) ; + if (*p == '|') { + procbuf *pbuf = new procbuf(); + init(pbuf); + if (!pbuf->open(p+1, mode)) + set(ios::badbit); + } + else { + init(new filebuf()); + if (!rdbuf()->open(name, mode, prot)) + set(ios::badbit); + } +} diff --git a/libio/pfstream.h b/libio/pfstream.h new file mode 100644 index 000000000000..3c5458baaa93 --- /dev/null +++ b/libio/pfstream.h @@ -0,0 +1,59 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifndef _PFSTREAM_H +#define _PFSTREAM_H +#ifdef __GNUG__ +#pragma interface +#endif +#include + +extern "C++" { +// ipfstream foo("NAME") is like: ifstream foo("NAME"). However, +// if NAME starts *or ends* with a '|', the remainder of NAME is +// evaluated as a shell command (using a procbuf), and all input +// read from foo is whatever that shell writes to its standard output. +// E.g. ipfstream foo("|zcat foo.Z") or ipfstream foo("zcat foo.Z|") +// (These two forms are equivalent.) + +class ipfstream : public ifstream { + public: + ipfstream(const char *name, int mode=ios::in, int prot=0664); +}; + +// opfstream foo("NAME") is like: ofstream foo("NAME"). +// However, if NAME starts with a '|', the remainder of NAME is +// evaluated as a shell command (using a procbuf), and all output +// written to foo is piped to the standard input of that shell. +// E.g. opfstream foo("|more"); + +class opfstream : public ofstream { + public: + opfstream(const char *name, int mode=ios::out, int prot=0664); +}; +} // extern "C++" +#endif /*!_PFSTREAM_H*/ + diff --git a/libio/procbuf.cc b/libio/procbuf.cc new file mode 100644 index 000000000000..1c79ce4ce0f7 --- /dev/null +++ b/libio/procbuf.cc @@ -0,0 +1,55 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#define _POSIX_SOURCE +#include "libioP.h" +#include "procbuf.h" + +procbuf::procbuf(const char *command, int mode) : filebuf() +{ + _IO_proc_open(this, command, (mode & ios::in) ? "r" : "w"); +} + +procbuf *procbuf::open(const char *command, int mode) +{ + return (procbuf*)_IO_proc_open(this, command, (mode & ios::in) ? "r" : "w"); +} + +/* #define USE_SIGMASK */ + +int procbuf::sys_close() +{ + return _IO_proc_close(this); +} + +procbuf::~procbuf() +{ + close(); +} diff --git a/libio/procbuf.h b/libio/procbuf.h new file mode 100644 index 000000000000..b361a6a7c844 --- /dev/null +++ b/libio/procbuf.h @@ -0,0 +1,50 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifndef _PROCBUF_H +#define _PROCBUF_H +#ifdef __GNUG__ +#pragma interface +#endif + +#include + +extern "C++" { +class procbuf : public filebuf { + /* Following fields must match those in struct _IO_proc_file */ + _IO_pid_t _pid; + procbuf *_next; + public: + procbuf() : filebuf() { } + procbuf(const char *command, int mode); + procbuf* open(const char *command, int mode); + procbuf *close() { return (procbuf*)filebuf::close(); } + virtual int sys_close(); + ~procbuf(); +}; +} // extern "C++" + +#endif /* !_PROCBUF_H */ diff --git a/libio/sbform.cc b/libio/sbform.cc new file mode 100644 index 000000000000..c17bd08db15e --- /dev/null +++ b/libio/sbform.cc @@ -0,0 +1,40 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "streambuf.h" +#include + +int streambuf::vform(char const *fmt0, _IO_va_list ap) +{ + return _IO_vfprintf(this, fmt0, ap); +} +int streambuf::form(char const *format ...) +{ + va_list ap; + va_start(ap, format); + int count = _IO_vfprintf(this, format, ap); + va_end(ap); + return count; +} diff --git a/libio/sbgetline.cc b/libio/sbgetline.cc new file mode 100644 index 000000000000..700e2ec7afc3 --- /dev/null +++ b/libio/sbgetline.cc @@ -0,0 +1,31 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "streambuf.h" + +long streambuf::sgetline(char* buf, _IO_size_t n, char delim, int extract_delim) +{ + return _IO_getline(this, buf, n, delim, extract_delim); +} diff --git a/libio/sbscan.cc b/libio/sbscan.cc new file mode 100644 index 000000000000..c0ec35c53db6 --- /dev/null +++ b/libio/sbscan.cc @@ -0,0 +1,45 @@ + +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "streambuf.h" +#include + +int streambuf::vscan(char const *fmt0, _IO_va_list ap, ios* stream /* = NULL*/) +{ + int errcode = 0; + int count = _IO_vfscanf(this, fmt0, ap, &errcode); + if (stream) + stream->setstate((ios::iostate)errcode); + return count; +} +int streambuf::scan(char const *format ...) +{ + va_list ap; + va_start(ap, format); + int count = _IO_vfscanf(this, format, ap, NULL); + va_end(ap); + return count; +} diff --git a/libio/stdfiles.c b/libio/stdfiles.c new file mode 100644 index 000000000000..1d0ef85be90b --- /dev/null +++ b/libio/stdfiles.c @@ -0,0 +1,44 @@ +/* +Copyright (C) 1993, 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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 file provides definitions of _IO_stdin, _IO_stdout, and _IO_stderr + for C code. Compare stdstreams.cc. + (The difference is that here the vtable field is set to 0, + so the objects defined are not valid C++ objects. On the other + hand, we don't need a C++ compiler to build this file.) */ + +#include "libioP.h" + + +#define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ + struct _IO_FILE_plus NAME \ + = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_file_jumps} + +DEF_STDFILE(_IO_stdin_, 0, 0, _IO_NO_WRITES); +DEF_STDFILE(_IO_stdout_, 1, &_IO_stdin_.file, _IO_NO_READS); +DEF_STDFILE(_IO_stderr_, 2, &_IO_stdout_.file, + _IO_NO_READS+_IO_UNBUFFERED); + +_IO_FILE *_IO_list_all = &_IO_stderr_.file; diff --git a/libio/stdio/ChangeLog b/libio/stdio/ChangeLog new file mode 100644 index 000000000000..76ce5b7a8756 --- /dev/null +++ b/libio/stdio/ChangeLog @@ -0,0 +1,93 @@ +Thu May 1 11:03:45 1997 Brendan Kehoe + + * stdio.h (TMP_MAX): Wrap it with #ifndef for now, since it can + get defined by (e.g., HP/UX and AIX). + +Wed Mar 12 08:51:37 1997 Gavin Koch + + * stdio.h: Use _IO_va_list rather than _G_va_list. + +Wed Jun 14 21:41:50 1995 Jason Merrill + + * configure.in (LIBDIR): Set. + (MOSTLYCLEAN): Remove pic and stamp-picdir. + (stdio_objects): Also compile pic version. + + * Makefile.in (STDIO_OBJECTS): Remove getdelim.o. + +Wed May 10 03:05:53 1995 Jason Merrill + + * vsnprintf.c (vsnprintf): Update to use _IO_JUMPS. + + * Makefile.in (STDIO_OBJECTS): Fix typo. + +Tue Oct 18 17:15:09 1994 Per Bothner + + * getline.c, snprintf.c, vsnprintf.c: New files, providing + functionality of the GNU C C library. + * Makefile.in (STDIO_OBJECTS), configure.in: Add new files. + * stdio.h: Add new functions. + +Fri Oct 14 15:56:27 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdio.h: Added vfscanf, vscanf, vsscanf, #ifndef __STRICT_ANSI__. + +Tue Aug 23 16:17:25 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdio.h: Added comment, at hjl's request. + +Sun Aug 7 13:28:12 1994 H.J. Lu (hjl@nynexst.com) + + * stdio.h (getc, getchar, putc, putchar): New declarations. + Move macros after the declarations. + +Fri Aug 5 18:27:21 1994 H.J. Lu (hjl@nynexst.com) + + * clearerr.c, rewind.c, setfileno.c: + Add CHECK_FILE(fp, ) and remove COERCE_FILE(fp). + * feof.c, ferror.c, fgetc.c, fileno.c, fputc.c, getw.c, putw.c, + vfscanf.c: Add CHECK_FILE(fp, EOF) and remove COERCE_FILE(fp). + * freopen.c: Add CHECK_FILE(fp, NULL) and remove COERCE_FILE(fp). + * fseek.c, vfprintf.c: + Add CHECK_FILE(fp, -1) and remove COERCE_FILE(fp). + +Fri May 20 13:11:58 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * stdio.h: Rename _ARGS macro to __P for better gnlibc and + BSD compatibility. + +Fri Nov 26 13:26:35 1993 Per Bothner (bothner@kalessin.cygnus.com) + + Bunch of little changes, many from H.J. Lu . + * feof.c, setbuf.c, vprintf.c, vcanf.c: #include , + for error checking. + * fileno.c: #include libioP.h, not just libio.h. + * fputc.c: Fix typo. + * fseek.c, rewind.c: Use #include "...", not <...> ,for local files. + * getc.c, getchar.c, putc.c, putchar.c: New files, providing + non-macro versions of the standard macros. + * getw.c, putw.c, setfileno.c, setlinebuf.c: New files. + * Makefile.in (STDIO_OBJECTS): Add new files. + * vfscanf.c: Add missing new 4th arg to _IO_vfscanf call. + +Thu Oct 14 16:12:07 1993 Karen Christiansen (karen@deneb.cygnus.com) + + * configure.in: changed mv to mv -f + +Mon Oct 4 17:29:23 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * configure.in (stdio_renames): Add fgetpos, fsetpos, gets, + perror, setbuffer, ungetc. + * clearerr.c, ferror.c, fgetc.c, fileno.c, fputc.c, freopen.c, + fseek.c, popen.c, rewind.c, setbuf.c: New files. + * Makefile.in (STDIO_OBJECTS): Add new files. + * stdio.h: Use _IO_XXX instead of _G_XXX many places. + #include instead of <_stdio.h>, to get useful defs. + +Fri Aug 20 00:28:28 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * feof.c, vprintf.c, vscanf.c: Converted stub functions. + * configure.in (stdio_renamed): Removed feof. + Added sprintf sscanf vsscanf. + * ChangeLog.old: Copy of old libg++/iostream/stdio/ChangeLog. + diff --git a/libio/stdio/Makefile.in b/libio/stdio/Makefile.in new file mode 100644 index 000000000000..8df66a7c1930 --- /dev/null +++ b/libio/stdio/Makefile.in @@ -0,0 +1,23 @@ +srcdir = . + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +# These are compiled from the corresponding ../ioFOO.c files. +STDIO_RENAMED_OBJECTS = ... filled in by configure ... +# These are the files that a libc would want. +STDIO_OBJECTS = $(STDIO_RENAMED_OBJECTS) \ + clearerr.o fdopen.o feof.o ferror.o fgetc.o fileno.o \ + fputc.o freopen.o fseek.o getc.o getchar.o getline.o getw.o \ + popen.o putc.o putchar.o putw.o rewind.o \ + setbuf.o setfileno.o setlinebuf.o snprintf.o \ + vfprintf.o vfscanf.o vprintf.o vscanf.o vsnprintf.o + +CC_FOR_STDIO=$(CC) +CINCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. -D__USE_GNU + +nothing: + +stdio.list: stamp-picdir $(STDIO_OBJECTS) + @echo "$(STDIO_OBJECTS)" >stdio.list + diff --git a/libio/stdio/clearerr.c b/libio/stdio/clearerr.c new file mode 100644 index 000000000000..ee9780bdaf5e --- /dev/null +++ b/libio/stdio/clearerr.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +void +clearerr(fp) + FILE* fp; +{ + CHECK_FILE(fp, /*nothing*/); + _IO_clearerr(fp); +} diff --git a/libio/stdio/configure.in b/libio/stdio/configure.in new file mode 100644 index 000000000000..21e920acf47f --- /dev/null +++ b/libio/stdio/configure.in @@ -0,0 +1,48 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../configure. + +configdirs= +srctrigger=stdio.h +srcname="libio/stdio" +package_makefile_frag=../Make.pack + +# per-host: + +# per-target: + +LIBDIR=yes +TO_TOPDIR=../../ +ALL=nothing +MOSTLYCLEAN='*.o pic stamp-picdir core stdio.list' +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: + +# Certain files that are used to build a C library (such as fprintf.o) +# are compled from the same sources as the ioXXX versions (such as ioprintf.c). +# These lines add the appropriate rules. +# NOTE: We assume a C compiler that where -o with -c works. +# But these files are not built by default anyway ... + +# TODO: remove rename tmpfile tmpnam + +stdio_renames="fclose fflush fgetpos fgets fopen fprintf fputs fread \ + fscanf fsetpos ftell fwrite getdelim gets perror printf puts \ + scanf setbuffer setvbuf sprintf sscanf ungetc vsprintf vsscanf" +stdio_objects="" + +for file in $stdio_renames ; do + cat >>Makefile <tmp +mv -f tmp Makefile diff --git a/libio/stdio/fdopen.c b/libio/stdio/fdopen.c new file mode 100644 index 000000000000..83e026ec7f76 --- /dev/null +++ b/libio/stdio/fdopen.c @@ -0,0 +1,9 @@ +#include "libioP.h" + +_IO_FILE * +fdopen (fd, mode) + int fd; + const char *mode; +{ + return _IO_fdopen (fd, mode); +} diff --git a/libio/stdio/feof.c b/libio/stdio/feof.c new file mode 100644 index 000000000000..bd30c175f3cd --- /dev/null +++ b/libio/stdio/feof.c @@ -0,0 +1,34 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "stdio.h" + +int +feof(fp) + _IO_FILE* fp; +{ + CHECK_FILE(fp, EOF); + return _IO_feof(fp); +} diff --git a/libio/stdio/ferror.c b/libio/stdio/ferror.c new file mode 100644 index 000000000000..ef95d7cd29d8 --- /dev/null +++ b/libio/stdio/ferror.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +int +ferror(fp) + FILE* fp; +{ + CHECK_FILE(fp, EOF); + return _IO_ferror(fp); +} diff --git a/libio/stdio/fgetc.c b/libio/stdio/fgetc.c new file mode 100644 index 000000000000..cf6410a887fb --- /dev/null +++ b/libio/stdio/fgetc.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +int +fgetc(fp) + FILE *fp; +{ + CHECK_FILE(fp, EOF); + return _IO_getc(fp); +} diff --git a/libio/stdio/fileno.c b/libio/stdio/fileno.c new file mode 100644 index 000000000000..c0bc55ce9a1b --- /dev/null +++ b/libio/stdio/fileno.c @@ -0,0 +1,12 @@ +#include "libioP.h" +#include "stdio.h" + +int +fileno(fp) + _IO_FILE* fp; +{ + CHECK_FILE(fp, EOF); + if (!(fp->_flags & _IO_IS_FILEBUF)) + return EOF; + return _IO_fileno(fp); +} diff --git a/libio/stdio/fputc.c b/libio/stdio/fputc.c new file mode 100644 index 000000000000..e87b042bfba3 --- /dev/null +++ b/libio/stdio/fputc.c @@ -0,0 +1,11 @@ +#include "libioP.h" +#include "stdio.h" + +int +fputc(c, fp) + int c; + FILE *fp; +{ + CHECK_FILE(fp, EOF); + return _IO_putc(c, fp); +} diff --git a/libio/stdio/freopen.c b/libio/stdio/freopen.c new file mode 100644 index 000000000000..da3dc1d64118 --- /dev/null +++ b/libio/stdio/freopen.c @@ -0,0 +1,14 @@ +#include "libioP.h" +#include "stdio.h" + +FILE* +freopen(filename, mode, fp) + const char* filename; + const char* mode; + FILE* fp; +{ + CHECK_FILE(fp, NULL); + if (!(fp->_flags & _IO_IS_FILEBUF)) + return NULL; + return _IO_freopen(filename, mode, fp); +} diff --git a/libio/stdio/fseek.c b/libio/stdio/fseek.c new file mode 100644 index 000000000000..b80067da1c0a --- /dev/null +++ b/libio/stdio/fseek.c @@ -0,0 +1,12 @@ +#include "stdio.h" +#include "libioP.h" + +int +fseek(fp, offset, whence) + _IO_FILE* fp; + long int offset; + int whence; +{ + CHECK_FILE(fp, -1); + return _IO_fseek(fp, offset, whence); +} diff --git a/libio/stdio/getc.c b/libio/stdio/getc.c new file mode 100644 index 000000000000..9db0987f71c9 --- /dev/null +++ b/libio/stdio/getc.c @@ -0,0 +1,11 @@ +#include "libioP.h" +#include "stdio.h" + +#undef getc + +int +getc(stream) + FILE *stream; +{ + return _IO_getc (stream); +} diff --git a/libio/stdio/getchar.c b/libio/stdio/getchar.c new file mode 100644 index 000000000000..88610dc49e26 --- /dev/null +++ b/libio/stdio/getchar.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" + +#undef getchar + +int +getchar () +{ + return _IO_getc (stdin); +} diff --git a/libio/stdio/getline.c b/libio/stdio/getline.c new file mode 100644 index 000000000000..6f4b677086e8 --- /dev/null +++ b/libio/stdio/getline.c @@ -0,0 +1,13 @@ +#include "libioP.h" +#include "stdio.h" + +/* NOTE: This geline function is different from _IO_getline. */ + +_IO_ssize_t +getline (lineptr, linelen, fp) + char** lineptr; + size_t* linelen; + FILE* fp; +{ + return _IO_getdelim (lineptr, linelen, '\n', fp); +} diff --git a/libio/stdio/getw.c b/libio/stdio/getw.c new file mode 100644 index 000000000000..1dfafbc1d4f4 --- /dev/null +++ b/libio/stdio/getw.c @@ -0,0 +1,13 @@ +#include "libioP.h" +#include "stdio.h" + +int +getw(fp) + FILE *fp; +{ + int w; + _IO_size_t bytes_read; + CHECK_FILE(fp, EOF); + bytes_read = _IO_sgetn (fp, (char*)&w, sizeof(w)); + return sizeof(w) == bytes_read ? w : EOF; +} diff --git a/libio/stdio/popen.c b/libio/stdio/popen.c new file mode 100644 index 000000000000..9f9f3f72f58e --- /dev/null +++ b/libio/stdio/popen.c @@ -0,0 +1,23 @@ +#include "libioP.h" +#include "stdio.h" +#include + +FILE * +popen(command, mode) + const char *command; const char *mode; +{ + return _IO_popen(command, mode); +} + +int +pclose(fp) + FILE *fp; +{ +#if 0 + /* Does not actually test that stream was created by popen(). Instead, + it depends on the filebuf::sys_close() virtual to Do The Right Thing. */ + if (fp is not a proc_file) + return -1; +#endif + return _IO_fclose(fp); +} diff --git a/libio/stdio/putc.c b/libio/stdio/putc.c new file mode 100644 index 000000000000..2a3dcc368674 --- /dev/null +++ b/libio/stdio/putc.c @@ -0,0 +1,12 @@ +#include "libioP.h" +#include "stdio.h" + +#undef putc + +int +putc(c, stream) + int c; + FILE *stream; +{ + return _IO_putc(c, stream); +} diff --git a/libio/stdio/putchar.c b/libio/stdio/putchar.c new file mode 100644 index 000000000000..a0a972fb5396 --- /dev/null +++ b/libio/stdio/putchar.c @@ -0,0 +1,10 @@ +#include "libioP.h" +#include "stdio.h" +#undef putchar + +int +putchar(c) + int c; +{ + return _IO_putc(c, stdout); +} diff --git a/libio/stdio/putw.c b/libio/stdio/putw.c new file mode 100644 index 000000000000..fd73261359cf --- /dev/null +++ b/libio/stdio/putw.c @@ -0,0 +1,15 @@ +#include "libioP.h" +#include "stdio.h" + +#undef putw + +int +putw(w, fp) + int w; + FILE *fp; +{ + _IO_size_t written; + CHECK_FILE(fp, EOF); + written = _IO_sputn(fp, (const char *)&w, sizeof(w)); + return written == sizeof(w) ? 0 : EOF; +} diff --git a/libio/stdio/rewind.c b/libio/stdio/rewind.c new file mode 100644 index 000000000000..01fe20a75dd1 --- /dev/null +++ b/libio/stdio/rewind.c @@ -0,0 +1,10 @@ +#include "stdio.h" +#include "libioP.h" + +void +rewind(fp) + _IO_FILE* fp; +{ + CHECK_FILE(fp, ); + _IO_rewind(fp); +} diff --git a/libio/stdio/setbuf.c b/libio/stdio/setbuf.c new file mode 100644 index 000000000000..5002e3d0733b --- /dev/null +++ b/libio/stdio/setbuf.c @@ -0,0 +1,9 @@ +#include "libioP.h" +#include "stdio.h" + +void +setbuf (fp, buf) + FILE *fp; char *buf; +{ + _IO_setbuffer(fp, buf, _IO_BUFSIZ); +} diff --git a/libio/stdio/setfileno.c b/libio/stdio/setfileno.c new file mode 100644 index 000000000000..f7ccc6fdd666 --- /dev/null +++ b/libio/stdio/setfileno.c @@ -0,0 +1,17 @@ +/* Some known programs (xterm, pdksh?) non-portably change the _file + field of s struct _iobuf. This kludge allows the same "functionality". + This code is an undocumented feature for iostream/stdio. Use it at + your own risk. */ + +#include "libioP.h" +#include "stdio.h" + +void +setfileno(fp, fd) + _IO_FILE* fp; + int fd; +{ + CHECK_FILE(fp, ); + if ((fp->_flags & _IO_IS_FILEBUF) != 0) + fp->_fileno = fd; +} diff --git a/libio/stdio/setlinebuf.c b/libio/stdio/setlinebuf.c new file mode 100644 index 000000000000..c447f954e9fb --- /dev/null +++ b/libio/stdio/setlinebuf.c @@ -0,0 +1,11 @@ +#include "libioP.h" +#include "stdio.h" + +#undef setlinebuf + +void +setlinebuf (stream) + FILE *stream; +{ + _IO_setvbuf(stream, NULL, 1, 0); +} diff --git a/libio/stdio/snprintf.c b/libio/stdio/snprintf.c new file mode 100644 index 000000000000..5c70a4441127 --- /dev/null +++ b/libio/stdio/snprintf.c @@ -0,0 +1,51 @@ +/* +Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +#ifdef __STDC__ +#include +#else +#include +#endif + +int +snprintf +#ifdef __STDC__ + (char *string, _IO_size_t maxlen, const char *format, ...) +#else +(string, maxlen, format, va_alist) + char *string; + _IO_size_t maxlen; + char *format; + va_dcl +#endif +{ + int ret; + va_list args; + _IO_va_start(args, format); + ret = vsnprintf(string, maxlen, format, args); + va_end(args); + return ret; +} diff --git a/libio/stdio/stdio.h b/libio/stdio/stdio.h new file mode 100644 index 000000000000..d1c41300b415 --- /dev/null +++ b/libio/stdio/stdio.h @@ -0,0 +1,181 @@ +/* This is part of the iostream/stdio library, providing -*- C -*- I/O. + Define ANSI C stdio on top of C++ iostreams. + Copyright (C) 1991, 1994 Free Software Foundation + +This library 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 of the License, 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* + * ANSI Standard: 4.9 INPUT/OUTPUT + */ + +#ifndef _STDIO_H +#define _STDIO_H +#define _STDIO_USES_IOSTREAM + +#include + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL (void*)0 +#endif +#endif + +#ifndef EOF +#define EOF (-1) +#endif +#ifndef BUFSIZ +#define BUFSIZ 1024 +#endif + +#define _IOFBF 0 /* Fully buffered. */ +#define _IOLBF 1 /* Line buffered. */ +#define _IONBF 2 /* No buffering. */ + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + + /* define size_t. Crud in case has defined it. */ +#if !defined(_SIZE_T) && !defined(_T_SIZE_) && !defined(_T_SIZE) +#if !defined(__SIZE_T) && !defined(_SIZE_T_) && !defined(___int_size_t_h) +#if !defined(_GCC_SIZE_T) && !defined(_SIZET_) +#define _SIZE_T +#define _T_SIZE_ +#define _T_SIZE +#define __SIZE_T +#define _SIZE_T_ +#define ___int_size_t_h +#define _GCC_SIZE_T +#define _SIZET_ +typedef _IO_size_t size_t; +#endif +#endif +#endif + +typedef struct _IO_FILE FILE; +typedef _IO_fpos_t fpos_t; + +#define FOPEN_MAX _G_FOPEN_MAX +#define FILENAME_MAX _G_FILENAME_MAX +#ifndef TMP_MAX +#define TMP_MAX 999 /* Only limited by filename length */ +#endif + +#define L_ctermid 9 +#define L_cuserid 9 +#define P_tmpdir "/tmp" +#define L_tmpnam 20 + +/* For use by debuggers. These are linked in if printf or fprintf are used. */ +extern FILE *stdin, *stdout, *stderr; /* TODO */ + +#define stdin _IO_stdin +#define stdout _IO_stdout +#define stderr _IO_stderr + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __P +#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) +#define __P(args) args +#else +#define __P(args) () +#endif +#endif /*!__P*/ + +extern void clearerr __P((FILE*)); +extern int fclose __P((FILE*)); +extern int feof __P((FILE*)); +extern int ferror __P((FILE*)); +extern int fflush __P((FILE*)); +extern int fgetc __P((FILE *)); +extern int fgetpos __P((FILE* fp, fpos_t *pos)); +extern char* fgets __P((char*, int, FILE*)); +extern FILE* fopen __P((const char*, const char*)); +extern int fprintf __P((FILE*, const char* format, ...)); +extern int fputc __P((int, FILE*)); +extern int fputs __P((const char *str, FILE *fp)); +extern size_t fread __P((void*, size_t, size_t, FILE*)); +extern FILE* freopen __P((const char*, const char*, FILE*)); +extern int fscanf __P((FILE *fp, const char* format, ...)); +extern int fseek __P((FILE* fp, long int offset, int whence)); +extern int fsetpos __P((FILE* fp, const fpos_t *pos)); +extern long int ftell __P((FILE* fp)); +extern size_t fwrite __P((const void*, size_t, size_t, FILE*)); +extern int getc __P((FILE *)); +extern int getchar __P((void)); +extern char* gets __P((char*)); +extern void perror __P((const char *)); +extern int printf __P((const char* format, ...)); +extern int putc __P((int, FILE *)); +extern int putchar __P((int)); +extern int puts __P((const char *str)); +extern int remove __P((const char*)); +extern int rename __P((const char* _old, const char* _new)); +extern void rewind __P((FILE*)); +extern int scanf __P((const char* format, ...)); +extern void setbuf __P((FILE*, char*)); +extern void setlinebuf __P((FILE*)); +extern void setbuffer __P((FILE*, char*, int)); +extern int setvbuf __P((FILE*, char*, int mode, size_t size)); +extern int sprintf __P((char*, const char* format, ...)); +extern int sscanf __P((const char* string, const char* format, ...)); +extern FILE* tmpfile __P((void)); +extern char* tmpnam __P((char*)); +extern int ungetc __P((int c, FILE* fp)); +extern int vfprintf __P((FILE *fp, char const *fmt0, _IO_va_list)); +extern int vprintf __P((char const *fmt, _IO_va_list)); +extern int vsprintf __P((char* string, const char* format, _IO_va_list)); + +#ifndef __STRICT_ANSI__ +extern int vfscanf __P((FILE*, const char *, _IO_va_list)); +extern int vscanf __P((const char *, _IO_va_list)); +extern int vsscanf __P((const char *, const char *, _IO_va_list)); +#endif + +#if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE) +extern FILE *fdopen __P((int, const char *)); +extern int fileno __P((FILE*)); +extern FILE* popen __P((const char*, const char*)); +extern int pclose __P((FILE*)); +#endif + +#ifdef __USE_GNU +extern _IO_ssize_t getdelim __P ((char **, size_t *, int, FILE*)); +extern _IO_ssize_t getline __P ((char **, size_t *, FILE *)); + +extern int snprintf __P ((char *, size_t, const char *, ...)); +extern int vsnprintf __P ((char *, size_t, const char *, _IO_va_list)); +#endif + +extern int __underflow __P((struct _IO_FILE*)); +extern int __overflow __P((struct _IO_FILE*, int)); + +#define getc(fp) _IO_getc(fp) +#define putc(c, fp) _IO_putc(c, fp) +#define putchar(c) putc(c, stdout) +#define getchar() getc(stdin) + +#ifdef __cplusplus +} +#endif + +#endif /*!_STDIO_H*/ diff --git a/libio/stdio/vfprintf.c b/libio/stdio/vfprintf.c new file mode 100644 index 000000000000..fca620944529 --- /dev/null +++ b/libio/stdio/vfprintf.c @@ -0,0 +1,35 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" + +int +vfprintf(fp, format, args) + register _IO_FILE* fp; + char const *format; + _IO_va_list args; +{ + CHECK_FILE(fp, -1); + return _IO_vfprintf(fp, format, args); +} diff --git a/libio/stdio/vfscanf.c b/libio/stdio/vfscanf.c new file mode 100644 index 000000000000..1759ee5ee017 --- /dev/null +++ b/libio/stdio/vfscanf.c @@ -0,0 +1,36 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "stdio.h" + +int +vfscanf(fp, format, args) + register _IO_FILE* fp; + const char *format; + _IO_va_list args; +{ + CHECK_FILE(fp, EOF); + return _IO_vfscanf(fp, format, args, NULL); +} diff --git a/libio/stdio/vprintf.c b/libio/stdio/vprintf.c new file mode 100644 index 000000000000..784f0d9b8dfe --- /dev/null +++ b/libio/stdio/vprintf.c @@ -0,0 +1,33 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "stdio.h" + +int vprintf(format, args) + const char* format; + _IO_va_list args; +{ + return _IO_vfprintf(_IO_stdout, format, args); +} diff --git a/libio/stdio/vscanf.c b/libio/stdio/vscanf.c new file mode 100644 index 000000000000..4ef4b52a21c8 --- /dev/null +++ b/libio/stdio/vscanf.c @@ -0,0 +1,34 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "stdio.h" + +int +vscanf(format, args) + const char *format; + _IO_va_list args; +{ + return _IO_vfscanf(_IO_stdin, format, args, NULL); +} diff --git a/libio/stdio/vsnprintf.c b/libio/stdio/vsnprintf.c new file mode 100644 index 000000000000..8db41b76187f --- /dev/null +++ b/libio/stdio/vsnprintf.c @@ -0,0 +1,43 @@ +/* +Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "libioP.h" +#include "strfile.h" + +int +vsnprintf (string, maxlen, format, args) + char *string; + _IO_size_t maxlen; + const char *format; + _IO_va_list args; +{ + _IO_strfile sf; + int ret; + _IO_init((_IO_FILE*)&sf, 0); + _IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps; + _IO_str_init_static ((_IO_FILE*)&sf, string, maxlen - 1, string); + ret = _IO_vfprintf((_IO_FILE*)&sf, format, args); + *((_IO_FILE*)&sf)->_IO_write_ptr = '\0'; + return ret; +} diff --git a/libio/stdiostream.cc b/libio/stdiostream.cc new file mode 100644 index 000000000000..80db5e59bfd5 --- /dev/null +++ b/libio/stdiostream.cc @@ -0,0 +1,159 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include +#include "libioP.h" + +// A stdiobuf is "tied" to a FILE object (as used by the stdio package). +// Thus a stdiobuf is always synchronized with the corresponding FILE, +// though at the cost of some overhead. (If you use the implementation +// of stdio supplied with this library, you don't need stdiobufs.) +// This implementation inherits from filebuf, but implement the virtual +// functions sys_read/..., using the stdio functions fread/... instead +// of the low-level read/... system calls. This has the advantage that +// we get all of the nice filebuf semantics automatically, though +// with some overhead. + + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +stdiobuf::stdiobuf(FILE *f) : filebuf(fileno(f)) +{ + _file = f; + // Turn off buffer in stdiobuf. Instead, rely on buffering in (FILE). + // Thus the stdiobuf will be synchronized with the FILE. + setbuf(NULL, 0); +} + +stdiobuf::~stdiobuf() +{ + /* Only needed if we're buffered. Not buffered is the default. */ + _IO_do_flush((_IO_FILE*)this); +} + +streamsize stdiobuf::sys_read(char* buf, streamsize size) +{ + // A minor optimization, but it makes a noticable difference. + // A bigger optimization would be to write stdiobuf::underflow, + // but that has some modularity disadvantages. Re-evaluate that + // after we have gotten rid of the double indirection. FIXME + if (size == 1) + { + register ch = getc(_file); + if (ch == EOF) + return 0; + *buf = (char)ch; + return 1; + } + else + return fread(buf, 1, size, _file); +} + +streamsize stdiobuf::sys_write(const char *buf, streamsize n) +{ + _IO_ssize_t count = fwrite(buf, 1, n, _file); + if (_offset >= 0) + _offset += n; + return count; +} + +streampos stdiobuf::sys_seek(streamoff offset, _seek_dir dir) +{ + // Normally, equivalent to: fdir=dir + int fdir = + (dir == ios::beg) ? SEEK_SET : + (dir == ios::cur) ? SEEK_CUR : + (dir == ios::end) ? SEEK_END : + dir; + return fseek(_file, offset, fdir); +} + +int stdiobuf::sys_close() +{ + int status = fclose(_file); + _file = NULL; + return status; +} + +int stdiobuf::sync() +{ + if (_IO_do_flush((_IO_FILE*)this)) + return EOF; + if (!(xflags() & _IO_NO_WRITES)) + if (fflush(_file)) + return EOF; + return 0; +} + +int stdiobuf::overflow(int c /* = EOF*/) +{ + if (filebuf::overflow(c) == EOF) + return EOF; + if (c != EOF) + return c; + return fflush(_file); +} + +streamsize stdiobuf::xsputn(const char* s, streamsize n) +{ + if (buffered ()) + { + // The filebuf implementation of sputn loses. + return streambuf::xsputn(s, n); + } + else + return fwrite (s, 1, n, _file); +} + +void stdiobuf::buffered (int b) +{ + if (b) + { + if (_flags & _IO_UNBUFFERED) + { /* Was unbuffered, make it buffered. */ + _flags &= ~_IO_UNBUFFERED; + } + } + else + { + if (!(_flags & _IO_UNBUFFERED)) + { /* Was buffered, make it unbuffered. */ + setbuf(NULL, 0); + } + } +} diff --git a/libio/stdiostream.h b/libio/stdiostream.h new file mode 100644 index 000000000000..b973d7a39b62 --- /dev/null +++ b/libio/stdiostream.h @@ -0,0 +1,79 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifndef _STDIOSTREAM_H +#define _STDIOSTREAM_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include +#include + +extern "C++" { +class stdiobuf : public filebuf { + protected: + FILE *_file; + public: + FILE* stdiofile() const { return _file; } + stdiobuf(FILE *); + ~stdiobuf(); + int buffered () const { return _flags & _IO_UNBUFFERED ? 0 : 1; } + void buffered (int); + virtual streamsize sys_read(char*, streamsize); + virtual streampos sys_seek(streamoff, _seek_dir); + virtual streamsize sys_write(const char*, streamsize); + virtual int sys_close(); + virtual int sync(); + virtual int overflow(int c = EOF); + streamsize xsputn(const char* s, streamsize n); +}; + +class istdiostream : public istream +{ +private: + stdiobuf _file; +public: + istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); } + stdiobuf* rdbuf()/* const */ { return &_file; } + int buffered () const { return _file.buffered (); } + void buffered (int _i) { _file.buffered (_i); } +}; + +class ostdiostream : public ostream +{ +private: + stdiobuf _file; +public: + ostdiostream (FILE* __f) : ostream(), _file(__f) { init(&_file); } + stdiobuf* rdbuf() /* const */ { return &_file; } + int buffered () const { return _file.buffered (); } + void buffered (int _i) { _file.buffered (_i); } +}; +} // extern "C++" + +#endif /* !_STDIOSTREAM_H */ diff --git a/libio/stdstrbufs.cc b/libio/stdstrbufs.cc new file mode 100644 index 000000000000..8af259988a5d --- /dev/null +++ b/libio/stdstrbufs.cc @@ -0,0 +1,115 @@ +/* +Copyright (C) 1994 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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 file provides definitions of _IO_stdin, _IO_stdout, and _IO_stderr + for C++ code. Compare stdfiles.c. + (The difference is that here the vtable field is set to + point to builtinbuf's vtable, so the objects are effectively + of class builtinbuf.) */ + +#include "libioP.h" +#include + +#if !defined(filebuf_vtable) && defined(__cplusplus) +#ifdef __GNUC__ +extern char filebuf_vtable[] + asm (_G_VTABLE_LABEL_PREFIX +#if _G_VTABLE_LABEL_HAS_LENGTH + "7" +#endif + "filebuf"); +#else /* !__GNUC__ */ +#if _G_VTABLE_LABEL_HAS_LENGTH +#define filebuf_vtable _G_VTABLE_LABEL_PREFIX_ID##7filebuf +#else +#define filebuf_vtable _G_VTABLE_LABEL_PREFIX_ID##filebuf +#endif +extern char filebuf_vtable[]; +#endif /* !__GNUC__ */ +#endif /* !defined(filebuf_vtable) && defined(__cplusplus) */ + +#ifndef STD_VTABLE +#define STD_VTABLE (const struct _IO_jump_t *)filebuf_vtable +#endif + +#define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ + struct _IO_FILE_plus NAME = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), STD_VTABLE} + +DEF_STDFILE(_IO_stdin_, 0, 0, _IO_NO_WRITES); +DEF_STDFILE(_IO_stdout_, 1, &_IO_stdin_.file, _IO_NO_READS); +DEF_STDFILE(_IO_stderr_, 2, &_IO_stdout_.file, + _IO_NO_READS+_IO_UNBUFFERED); + +#ifdef _STDIO_USES_IOSTREAM +_IO_FILE *_IO_list_all = &_IO_stderr_.file; +#else /* !_STDIO_USES_IOSTREAM */ +#include "stdiostream.h" + +struct _IO_fake_stdiobuf { + struct { + _IO_FILE file; + const void *vtable; + } s; + FILE *stdio_file; +}; + +/* Define stdiobuf_vtable as a name for the virtual function table + of the stdiobuf class. */ +#ifndef stdiobuf_vtable +#ifdef __GNUC__ +extern struct _IO_jump_t stdiobuf_vtable + asm (_G_VTABLE_LABEL_PREFIX +#if _G_VTABLE_LABEL_HAS_LENGTH + "8" +#endif + "stdiobuf"); +#else /* !__GNUC__ */ +#if _G_VTABLE_LABEL_HAS_LENGTH +#define stdiobuf_vtable _G_VTABLE_LABEL_PREFIX_ID##8stdiobuf +#else +#define stdiobuf_vtable _G_VTABLE_LABEL_PREFIX_ID##stdiobuf +#endif +extern struct _IO_jump_t stdiobuf_vtable; +#endif /* !__GNUC__ */ +#endif /* !stdiobuf_vtable */ + +#if _IO_UNIFIED_JUMPTABLES +#define JUMP_PTR /* Nothing */ +#else +#define JUMP_PTR &_IO_streambuf_jumps, +#endif + +#define DEF_STDIOFILE(NAME, FD, FILE, FLAGS, CHAIN) \ + struct _IO_fake_stdiobuf NAME = \ + {{{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+_IO_UNBUFFERED+FLAGS, \ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, JUMP_PTR FD},\ + &stdiobuf_vtable}, FILE} + +DEF_STDIOFILE(_IO_stdin_buf, 0, stdin, _IO_NO_WRITES, &_IO_stderr_.file); +DEF_STDIOFILE(_IO_stdout_buf, 1, stdout, _IO_NO_READS, &_IO_stdin_buf.s.file); +DEF_STDIOFILE(_IO_stderr_buf, 2, stderr, _IO_NO_READS, &_IO_stdout_buf.s.file); + +_IO_FILE *_IO_list_all = &_IO_stderr_buf.s.file; +#endif /* !_STDIO_USES_IOSTREAM */ diff --git a/libio/stdstreams.cc b/libio/stdstreams.cc new file mode 100644 index 000000000000..a5889d738e22 --- /dev/null +++ b/libio/stdstreams.cc @@ -0,0 +1,153 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#include "libioP.h" +#include "streambuf.h" +#include + +// The ANSI draft requires that operations on cin/cout/cerr can be +// mixed with operations on stdin/stdout/stderr on a character by +// character basis. This normally requires that the streambuf's +// used by cin/cout/cerr be stdiostreams. However, if the stdio +// implementation is the one that is built using this library, +// then we don't need to, since in that case stdin/stdout/stderr +// are identical to _IO_stdin/_IO_stdout/_IO_stderr. + +#include "libio.h" + +#ifdef _STDIO_USES_IOSTREAM +#define CIN_SBUF _IO_stdin_ +#define COUT_SBUF _IO_stdout_ +#define CERR_SBUF _IO_stderr_ +static int use_stdiobuf = 0; +#else +#define CIN_SBUF _IO_stdin_buf +#define COUT_SBUF _IO_stdout_buf +#define CERR_SBUF _IO_stderr_buf +static int use_stdiobuf = 1; +#endif + +#define cin CIN +#define cout COUT +#define cerr CERR +#define clog CLOG +#include "iostream.h" +#undef cin +#undef cout +#undef cerr +#undef clog + +#ifdef __GNUG__ +#define PAD 0 /* g++ allows 0-length arrays. */ +#else +#define PAD 1 +#endif +struct _fake_istream { + struct myfields { +#ifdef __GNUC__ + _ios_fields *vb; /* pointer to virtual base class ios */ + _IO_ssize_t _gcount; +#else + /* This is supposedly correct for cfront. */ + _IO_ssize_t _gcount; + void *vptr; + _ios_fields *vb; /* pointer to virtual base class ios */ +#endif + } mine; + _ios_fields base; + char filler[sizeof(struct istream)-sizeof(struct _ios_fields)+PAD]; +}; +struct _fake_ostream { + struct myfields { +#ifndef __GNUC__ + void *vptr; +#endif + _ios_fields *vb; /* pointer to virtual base class ios */ + } mine; + _ios_fields base; + char filler[sizeof(struct ostream)-sizeof(struct _ios_fields)+PAD]; +}; + + +#ifdef _IO_NEW_STREAMS +#define STD_STR(SBUF, TIE, EXTRA_FLAGS) \ + (streambuf*)&SBUF, TIE, 0, ios::skipws|ios::dec|EXTRA_FLAGS, ' ',0,0,6 +#else +#define STD_STR(SBUF, TIE, EXTRA_FLAGS) \ + (streambuf*)&SBUF, TIE, 0, ios::dont_close|ios::dec|ios::skipws|EXTRA_FLAGS, ' ',0,0,6 +#endif + +#ifdef __GNUC__ +#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS, ASM) \ + _fake_ostream NAME ASM = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; +#define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ + _fake_istream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; +#else +#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ + _fake_ostream NAME = { {0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; +#define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ + _fake_istream NAME = {{0, 0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS)}}; +#endif + +OSTREAM_DEF(cout, COUT_SBUF, NULL, 0, ) +OSTREAM_DEF(cerr, CERR_SBUF,(ostream*)&cout, ios::unitbuf, ) +ISTREAM_DEF(cin, CIN_SBUF, (ostream*)&cout, 0) + +/* Only for (partial) compatibility with AT&T's library. */ +#if _G_CLOG_CONFLICT +OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, __asm__ ("__IO_clog")) +#else +OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, ) +#endif + +// Switches between using _IO_std{in,out,err} and __std{in,out,err}_buf +// for standard streams. This does not normally need to be called +// explicitly, but is provided for AT&T compatibility. + +int ios::sync_with_stdio(int new_state) +{ +#ifdef _STDIO_USES_IOSTREAM + // It is always synced. + return 0; +#else + if (new_state == use_stdiobuf) // The usual case now. + return use_stdiobuf; + if (new_state) { + cin.base._strbuf = (streambuf*)&_IO_stdin_buf; + cout.base._strbuf = (streambuf*)&_IO_stdout_buf; + cerr.base._strbuf = (streambuf*)&_IO_stderr_buf; + clog.base._strbuf = (streambuf*)&_IO_stderr_buf; + } else { + cin.base._strbuf = (streambuf*)_IO_stdin; + cout.base._strbuf = (streambuf*)_IO_stdout; + cerr.base._strbuf = (streambuf*)_IO_stderr; + clog.base._strbuf = (streambuf*)_IO_stderr; + } + int old_state = use_stdiobuf; + use_stdiobuf = new_state; + return old_state; +#endif +} diff --git a/libio/stream.cc b/libio/stream.cc new file mode 100644 index 000000000000..3440a0c9bdb4 --- /dev/null +++ b/libio/stream.cc @@ -0,0 +1,170 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include +#include +#include "libioP.h" +#include "stream.h" +#include "strstream.h" + +static char Buffer[_IO_BUFSIZ]; +#define EndBuffer (Buffer+_IO_BUFSIZ) +static char* next_chunk = Buffer; // Start of available part of Buffer. + +char* form(const char* format, ...) +{ + int space_left = EndBuffer - next_chunk; + // If less that 25% of the space is available start over. + if (space_left < (_IO_BUFSIZ>>2)) + next_chunk = Buffer; + char* buf = next_chunk; + + strstreambuf stream(buf, EndBuffer-buf-1, buf); + va_list ap; + va_start(ap, format); + int count = stream.vform(format, ap); + va_end(ap); + stream.sputc(0); + next_chunk = buf + stream.pcount(); + return buf; +} + +#define u_long unsigned long + +static char* itoa(unsigned long i, int size, int neg, int base) +{ + // Conservative estimate: If base==2, might need 8 characters + // for each input byte, but normally 3 is plenty. + int needed = size ? size + : (base >= 8 ? 3 : 8) * sizeof(unsigned long) + 2; + int space_left = EndBuffer - next_chunk; + if (space_left <= needed) + next_chunk = Buffer; // start over. + + char* buf = next_chunk; + + register char* ptr = buf+needed+1; + next_chunk = ptr; + + if (needed < (2+neg) || ptr > EndBuffer) + return NULL; + *--ptr = 0; + + if (i == 0) + *--ptr = '0'; + while (i != 0 && ptr > buf) { + int ch = i % base; + i = i / base; + if (ch >= 10) + ch += 'a' - 10; + else + ch += '0'; + *--ptr = ch; + } + if (neg) + *--ptr = '-'; + if (size == 0) + return ptr; + while (ptr > buf) + *--ptr = ' '; + return buf; +} + +char* dec(long i, int len /* = 0 */) +{ + if (i >= 0) return itoa((unsigned long)i, len, 0, 10); + else return itoa((unsigned long)(-i), len, 1, 10); +} +char* dec(int i, int len /* = 0 */) +{ + if (i >= 0) return itoa((unsigned long)i, len, 0, 10); + else return itoa((unsigned long)(-i), len, 1, 10); +} +char* dec(unsigned long i, int len /* = 0 */) +{ + return itoa(i, len, 0, 10); +} +char* dec(unsigned int i, int len /* = 0 */) +{ + return itoa(i, len, 0, 10); +} + +char* hex(long i, int len /* = 0 */) +{ + return itoa((unsigned long)i, len, 0, 16); +} +char* hex(int i, int len /* = 0 */) +{ + return itoa((unsigned long)i, len, 0, 16); +} +char* hex(unsigned long i, int len /* = 0 */) +{ + return itoa(i, len, 0, 16); +} +char* hex(unsigned int i, int len /* = 0 */) +{ + return itoa(i, len, 0, 16); +} + +char* oct(long i, int len /* = 0 */) +{ + return itoa((unsigned long)i, len, 0, 8); +} +char* oct(int i, int len /* = 0 */) +{ + return itoa((unsigned long)i, len, 0, 8); +} +char* oct(unsigned long i, int len /* = 0 */) +{ + return itoa(i, len, 0, 8); +} +char* oct(unsigned int i, int len /* = 0 */) +{ + return itoa(i, len, 0, 8); +} + +static char *str(const char* s, int len, int width) +{ + if (width < len) + width = len; + int space_left = EndBuffer - next_chunk; + if (space_left <= width + 1) + next_chunk = Buffer; // start over. + char* buf = next_chunk; + memset (buf, ' ', width - len); + memcpy (buf + width - len, s, len); + buf[width] = 0; + return buf; +} + +char* str(const char* s, int width) +{ + return str (s, strlen (s), width); +} + +char* chr(char ch, int width) +{ + char c = ch; + return str (&c, 1, width); +} diff --git a/libio/stream.h b/libio/stream.h new file mode 100644 index 000000000000..0859802ade69 --- /dev/null +++ b/libio/stream.h @@ -0,0 +1,59 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifndef _COMPAT_STREAM_H +#define _COMPAT_STREAM_H + +// Compatibility with old library. +// DO NOT USE THESE FUNCTIONS IN NEW CODE! +// They are obsolete, non-standard, and non-reentrant. + +#define _STREAM_COMPAT +#include + +extern "C++" { +extern char* form(const char*, ...); + +extern char* dec(long, int=0); +extern char* dec(int, int=0); +extern char* dec(unsigned long, int=0); +extern char* dec(unsigned int, int=0); + +extern char* hex(long, int=0); +extern char* hex(int, int=0); +extern char* hex(unsigned long, int=0); +extern char* hex(unsigned int, int=0); + +extern char* oct(long, int=0); +extern char* oct(int, int=0); +extern char* oct(unsigned long, int=0); +extern char* oct(unsigned int, int=0); + +char* chr(char ch, int width = 0); +char* str(const char* s, int width = 0); + +inline istream& WS(istream& str) { return ws(str); } +} // extern "C++" + +#endif /* !_COMPAT_STREAM_H */ diff --git a/libio/streambuf.cc b/libio/streambuf.cc new file mode 100644 index 000000000000..d66af097aa50 --- /dev/null +++ b/libio/streambuf.cc @@ -0,0 +1,343 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1991, 1992, 1993, 1995 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#define _STREAM_COMPAT +#ifdef __GNUG__ +#pragma implementation +#endif +#include "iostreamP.h" +#include +#include +#include +#ifndef errno +extern int errno; +#endif + +void streambuf::_un_link() { _IO_un_link(this); } + +void streambuf::_link_in() { _IO_link_in(this); } + +int streambuf::switch_to_get_mode() +{ return _IO_switch_to_get_mode(this); } + +void streambuf::free_backup_area() +{ _IO_free_backup_area(this); } + +#if 0 +int streambuf::switch_to_put_mode() +{ return _IO_:switch_to_put_mode(this); } +#endif + +int __overflow(streambuf* sb, int c) +{ + return sb->overflow(c); +} + +int streambuf::underflow() +{ return EOF; } + +int streambuf::uflow() +{ return _IO_default_uflow (this); } + +int streambuf::overflow(int /* = EOF */) +{ return EOF; } + +streamsize streambuf::xsputn(register const char* s, streamsize n) +{ return _IO_default_xsputn(this, s, n); } + +streamsize streambuf::xsgetn(char* s, streamsize n) +{ return _IO_default_xsgetn(this, s, n); } + +int streambuf::ignore(int n) +{ + register int more = n; + for (;;) { + int count = _IO_read_end - _IO_read_ptr; // Data available. + if (count > 0) { + if (count > more) + count = more; + _IO_read_ptr += count; + more -= count; + } + if (more == 0 || __underflow(this) == EOF) + break; + } + return n - more; +} + +int streambuf::sync() +{ + return 0; +} + +int streambuf::pbackfail(int c) +{ + return _IO_default_pbackfail(this, c); +} + +streambuf* streambuf::setbuf(char* p, int len) +{ + if (sync() == EOF) + return NULL; + if (p == NULL || len == 0) { + unbuffered(1); + setb(_shortbuf, _shortbuf+1, 0); + } + else { + unbuffered(0); + setb(p, p+len, 0); + } + setp(0, 0); + setg(0, 0, 0); + return this; +} + +streampos streambuf::seekpos(streampos pos, int mode) +{ + return seekoff(pos, ios::beg, mode); +} + +streampos streambuf::sseekpos(streampos pos, int mode) +{ + return _IO_seekpos (this, pos, mode); +} + +void streambuf::setb(char* b, char* eb, int a) +{ _IO_setb(this, b, eb, a); } + +int streambuf::doallocate() { return _IO_default_doallocate(this); } + +void streambuf::doallocbuf() { _IO_doallocbuf(this); } + +#if !_IO_UNIFIED_JUMPTABLES +/* The following are jump table entries that just call the virtual method */ + +static int _IO_sb_overflow(_IO_FILE *fp, int c) +{ return ((streambuf*)fp)->overflow(c); } +static int _IO_sb_underflow(_IO_FILE *fp) +{ return ((streambuf*)fp)->underflow(); } +static _IO_size_t _IO_sb_xsputn(_IO_FILE *fp, const void *s, _IO_size_t n) +{ return ((streambuf*)fp)->xsputn((const char*)s, n); } +static _IO_size_t _IO_sb_xsgetn(_IO_FILE *fp, void *s, _IO_size_t n) +{ return ((streambuf*)fp)->xsgetn((char*)s, n); } +static int _IO_sb_close(_IO_FILE *fp) +{ return ((streambuf*)fp)->sys_close(); } +static int _IO_sb_stat(_IO_FILE *fp, void *b) +{ return ((streambuf*)fp)->sys_stat(b); } +static int _IO_sb_doallocate(_IO_FILE *fp) +{ return ((streambuf*)fp)->doallocate(); } + +static _IO_pos_t _IO_sb_seekoff(_IO_FILE *fp, _IO_off_t pos, int dir, int mode) +{ + return ((streambuf*)fp)->seekoff(pos, (ios::seek_dir)dir, mode); +} + +static _IO_pos_t _IO_sb_seekpos(_IO_FILE *fp, _IO_pos_t pos, int mode) +{ + return ((streambuf*)fp)->seekpos(pos, mode); +} + +static int _IO_sb_pbackfail(_IO_FILE *fp, int ch) +{ return ((streambuf*)fp)->pbackfail(ch); } +static void _IO_sb_finish(_IO_FILE *fp) +{ ((streambuf*)fp)->~streambuf(); } +static _IO_ssize_t _IO_sb_read(_IO_FILE *fp, void *buf, _IO_ssize_t n) +{ return ((streambuf*)fp)->sys_read((char*)buf, n); } +static _IO_ssize_t _IO_sb_write(_IO_FILE *fp, const void *buf, _IO_ssize_t n) +{ return ((streambuf*)fp)->sys_write((const char*)buf, n); } +static int _IO_sb_sync(_IO_FILE *fp) +{ return ((streambuf*)fp)->sync(); } +static _IO_pos_t _IO_sb_seek(_IO_FILE *fp, _IO_off_t off, int dir) +{ return ((streambuf*)fp)->sys_seek(off, (_seek_dir)dir); } +static _IO_FILE* _IO_sb_setbuf(_IO_FILE *fp, char *buf, _IO_ssize_t n) +{ return ((streambuf*)fp)->setbuf(buf, n); } + +/* This callbacks in this jumptable just call the corresponding + virtual function, so that C functions can access (potentially user-defined) + streambuf-derived objects. + Contrast the builtinbuf class, which does the converse: Allow + C++ virtual calls to to be used on _IO_FILE objects that are builtin + (or defined by C code). */ + + +struct _IO_jump_t _IO_streambuf_jumps = { + JUMP_INIT_DUMMY, + JUMP_INIT(finish, _IO_sb_finish), + JUMP_INIT(overflow, _IO_sb_overflow), + JUMP_INIT(underflow, _IO_sb_underflow), + JUMP_INIT(uflow, _IO_default_uflow), + JUMP_INIT(pbackfail, _IO_sb_pbackfail), + JUMP_INIT(xsputn, _IO_sb_xsputn), + JUMP_INIT(xsgetn, _IO_sb_xsgetn), + JUMP_INIT(seekoff, _IO_sb_seekoff), + JUMP_INIT(seekpos, _IO_sb_seekpos), + JUMP_INIT(setbuf, _IO_sb_setbuf), + JUMP_INIT(sync, _IO_sb_sync), + JUMP_INIT(doallocate, _IO_sb_doallocate), + JUMP_INIT(read, _IO_sb_read), + JUMP_INIT(write, _IO_sb_write), + JUMP_INIT(seek, _IO_sb_seek), + JUMP_INIT(close, _IO_sb_close), + JUMP_INIT(stat, _IO_sb_stat) +}; +#endif + +streambuf::streambuf(int flags) +{ + _IO_init(this, flags); +#if !_IO_UNIFIED_JUMPTABLES + _jumps = &_IO_streambuf_jumps; +#endif +} + +streambuf::~streambuf() { _IO_default_finish(this); } + +streampos +streambuf::seekoff(streamoff, _seek_dir, int /*=ios::in|ios::out*/) +{ + return EOF; +} + +streampos +streambuf::sseekoff(streamoff o , _seek_dir d, int m /*=ios::in|ios::out*/) +{ + return _IO_seekoff (this, o, d, m); +} + +int streambuf::sputbackc(char c) +{ + return _IO_sputbackc(this, c); +} + +int streambuf::sungetc() +{ + return _IO_sungetc(this); +} + +#if 0 /* Work in progress */ +void streambuf::collumn(int c) +{ + if (c == -1) + _collumn = -1; + else + _collumn = c - (_IO_write_ptr - _IO_write_base); +} +#endif + + +int streambuf::get_column() +{ + if (_cur_column) + return _IO_adjust_column(_cur_column - 1, pbase(), pptr() - pbase()); + return -1; +} + +int streambuf::set_column(int i) +{ + _cur_column = i+1; + return 0; +} + +int streambuf::flush_all() { return _IO_flush_all (); } + +void streambuf::flush_all_linebuffered() +{ _IO_flush_all_linebuffered(); } + +int streambuf::sys_stat(void *) +{ +#ifdef EIO + errno = EIO; +#endif + return -1; +} + +streamsize streambuf::sys_read(char* /*buf*/, streamsize /*size*/) +{ + return 0; +} + +streamsize streambuf::sys_write(const char* /*buf*/, streamsize /*size*/) +{ + return 0; +} + +streampos streambuf::sys_seek(streamoff, _seek_dir) +{ + return EOF; +} + +int streambuf::sys_close() { return 0; /* Suceess; do nothing */ } + +streammarker::streammarker(streambuf *sb) +{ + _IO_init_marker(this, sb); +} + +streammarker::~streammarker() +{ + _IO_remove_marker(this); +} + +#define BAD_DELTA EOF + +int streammarker::delta(streammarker& other_mark) +{ + return _IO_marker_difference(this, &other_mark); +} + +int streammarker::delta() +{ + return _IO_marker_delta(this); +} + +int streambuf::seekmark(streammarker& mark, int delta /* = 0 */) +{ + return _IO_seekmark(this, &mark, delta); +} + +void streambuf::unsave_markers() +{ + _IO_unsave_markers(this); +} + +int ios::readable() { return !(rdbuf()->_flags & _IO_NO_READS); } +int ios::writable() { return !(rdbuf()->_flags & _IO_NO_WRITES); } +int ios::is_open() { return rdbuf() + && (rdbuf()->_flags & _IO_NO_READS+_IO_NO_WRITES) + != _IO_NO_READS+_IO_NO_WRITES; } + +#if defined(linux) +#define IO_CLEANUP +#endif + +#ifdef IO_CLEANUP + IO_CLEANUP +#else +struct __io_defs { + ~__io_defs() { _IO_cleanup (); } +}; +__io_defs io_defs__; +#endif diff --git a/libio/streambuf.h b/libio/streambuf.h new file mode 100644 index 000000000000..ea9a5478c260 --- /dev/null +++ b/libio/streambuf.h @@ -0,0 +1,475 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#ifndef _STREAMBUF_H +#define _STREAMBUF_H +#ifdef __GNUG__ +#pragma interface +#endif + +/* #define _G_IO_THROW */ /* Not implemented: ios::failure */ + +#define _IO_NEW_STREAMS // new optimizated stream representation + +extern "C" { +#include +} +//#include <_G_config.h> +#ifdef _IO_NEED_STDARG_H +#include +#endif +#ifndef _IO_va_list +#define _IO_va_list char * +#endif + +#ifndef EOF +#define EOF (-1) +#endif +#ifndef NULL +#ifdef __GNUG__ +#define NULL (__null) +#else +#define NULL (0) +#endif +#endif + +#ifndef _IO_wchar_t +#define _IO_wchar_t short +#endif + +extern "C++" { +class istream; /* Work-around for a g++ name mangling bug. Fixed in 2.6. */ +class ostream; class streambuf; + +// In case some header files defines these as macros. +#undef open +#undef close + +typedef _IO_off_t streamoff; +typedef _IO_fpos_t streampos; +typedef _IO_ssize_t streamsize; + +typedef unsigned long __fmtflags; +typedef unsigned char __iostate; + +struct _ios_fields +{ // The data members of an ios. + streambuf *_strbuf; + ostream* _tie; + int _width; + __fmtflags _flags; + _IO_wchar_t _fill; + __iostate _state; + __iostate _exceptions; + int _precision; + + void *_arrays; /* Support for ios::iword and ios::pword. */ +}; + +#define _IOS_GOOD 0 +#define _IOS_EOF 1 +#define _IOS_FAIL 2 +#define _IOS_BAD 4 + +#define _IO_INPUT 1 +#define _IO_OUTPUT 2 +#define _IO_ATEND 4 +#define _IO_APPEND 8 +#define _IO_TRUNC 16 +#define _IO_NOCREATE 32 +#define _IO_NOREPLACE 64 +#define _IO_BIN 128 + +#ifdef _STREAM_COMPAT +enum state_value { + _good = _IOS_GOOD, + _eof = _IOS_EOF, + _fail = _IOS_FAIL, + _bad = _IOS_BAD }; +enum open_mode { + input = _IO_INPUT, + output = _IO_OUTPUT, + atend = _IO_ATEND, + append = _IO_APPEND }; +#endif + +class ios : public _ios_fields { + ios& operator=(ios&); /* Not allowed! */ + ios (const ios&); /* Not allowed! */ + public: + typedef __fmtflags fmtflags; + typedef int iostate; + typedef int openmode; + typedef int streamsize; + enum io_state { + goodbit = _IOS_GOOD, + eofbit = _IOS_EOF, + failbit = _IOS_FAIL, + badbit = _IOS_BAD }; + enum open_mode { + in = _IO_INPUT, + out = _IO_OUTPUT, + ate = _IO_ATEND, + app = _IO_APPEND, + trunc = _IO_TRUNC, + nocreate = _IO_NOCREATE, + noreplace = _IO_NOREPLACE, + bin = _IOS_BIN, // Deprecated - ANSI uses ios::binary. + binary = _IOS_BIN }; + enum seek_dir { beg, cur, end}; + // ANSI: typedef enum seek_dir seekdir; etc + // NOTE: If adding flags here, before to update ios::bitalloc(). + enum { skipws=_IO_SKIPWS, + left=_IO_LEFT, right=_IO_RIGHT, internal=_IO_INTERNAL, + dec=_IO_DEC, oct=_IO_OCT, hex=_IO_HEX, + showbase=_IO_SHOWBASE, showpoint=_IO_SHOWPOINT, + uppercase=_IO_UPPERCASE, showpos=_IO_SHOWPOS, + scientific=_IO_SCIENTIFIC, fixed=_IO_FIXED, + unitbuf=_IO_UNITBUF, stdio=_IO_STDIO +#ifndef _IO_NEW_STREAMS + , dont_close=_IO_DONT_CLOSE // Don't delete streambuf on stream destruction +#endif + }; + enum { // Masks. + basefield=dec+oct+hex, + floatfield = scientific+fixed, + adjustfield = left+right+internal + }; + +#ifdef _IO_THROW + class failure : public xmsg { + ios* _stream; + public: + failure(ios* stream) { _stream = stream; } + failure(string cause, ios* stream) { _stream = stream; } + ios* rdios() const { return _stream; } + }; +#endif + + ostream* tie() const { return _tie; } + ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; } + + // Methods to change the format state. + _IO_wchar_t fill() const { return (_IO_wchar_t)_fill; } + _IO_wchar_t fill(_IO_wchar_t newf) + {_IO_wchar_t oldf = (_IO_wchar_t)_fill; _fill = (char)newf; return oldf;} + fmtflags flags() const { return _flags; } + fmtflags flags(fmtflags new_val) { + fmtflags old_val = _flags; _flags = new_val; return old_val; } + int precision() const { return _precision; } + int precision(int newp) { + unsigned short oldp = _precision; _precision = (unsigned short)newp; + return oldp; } + fmtflags setf(fmtflags val) { + fmtflags oldbits = _flags; + _flags |= val; return oldbits; } + fmtflags setf(fmtflags val, fmtflags mask) { + fmtflags oldbits = _flags; + _flags = (_flags & ~mask) | (val & mask); return oldbits; } + fmtflags unsetf(fmtflags mask) { + fmtflags oldbits = _flags; + _flags &= ~mask; return oldbits; } + int width() const { return _width; } + int width(int val) { int save = _width; _width = val; return save; } + +#ifdef _IO_THROW + void _throw_failure() const { throw new ios::failure(this); } +#else + void _throw_failure() const { } +#endif + void clear(iostate state = 0) { + _state = _strbuf ? state : state|badbit; + if (_state & _exceptions) _throw_failure(); } + void set(iostate flag) { _state |= flag; + if (_state & _exceptions) _throw_failure(); } + void setstate(iostate flag) { _state |= flag; // ANSI + if (_state & _exceptions) _throw_failure(); } + int good() const { return _state == 0; } + int eof() const { return _state & ios::eofbit; } + int fail() const { return _state & (ios::badbit|ios::failbit); } + int bad() const { return _state & ios::badbit; } + iostate rdstate() const { return _state; } + operator void*() const { return fail() ? (void*)0 : (void*)(-1); } + int operator!() const { return fail(); } + iostate exceptions() const { return _exceptions; } + void exceptions(iostate enable) { + _exceptions = enable; + if (_state & _exceptions) _throw_failure(); } + + streambuf* rdbuf() const { return _strbuf; } + streambuf* rdbuf(streambuf *_s) { + streambuf *_old = _strbuf; _strbuf = _s; clear (); return _old; } + + static int sync_with_stdio(int on); + static void sync_with_stdio() { sync_with_stdio(1); } + static fmtflags bitalloc(); + static int xalloc(); + void*& pword(int); + void* pword(int) const; + long& iword(int); + long iword(int) const; + +#ifdef _STREAM_COMPAT + void unset(state_value flag) { _state &= ~flag; } + void close(); + int is_open(); + int readable(); + int writable(); +#endif + + // Used to initialize standard streams. Not needed in this implementation. + class Init { + public: + Init () { } + }; + + protected: + inline ios(streambuf* sb = 0, ostream* tie_to = 0); + inline virtual ~ios(); + inline void init(streambuf* sb, ostream* tie = 0); +}; + +#if __GNUG__==1 +typedef int _seek_dir; +#else +typedef ios::seek_dir _seek_dir; +#endif + +// Magic numbers and bits for the _flags field. +// The magic numbers use the high-order bits of _flags; +// the remaining bits are abailable for variable flags. +// Note: The magic numbers must all be negative if stdio +// emulation is desired. + +// A streammarker remembers a position in a buffer. +// You are guaranteed to be able to seek back to it if it is saving(). +class streammarker : private _IO_marker { + friend class streambuf; + void set_offset(int offset) { _pos = offset; } + public: + streammarker(streambuf *sb); + ~streammarker(); + int saving() { return 1; } + int delta(streammarker&); + int delta(); +}; + +struct streambuf : public _IO_FILE { // protected?? + friend class ios; + friend class istream; + friend class ostream; + friend class streammarker; + const void *&_vtable() { return *(const void**)((_IO_FILE*)this + 1); } + protected: + static streambuf* _list_all; /* List of open streambufs. */ + _IO_FILE*& xchain() { return _chain; } + void _un_link(); + void _link_in(); + char* gptr() const + { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_ptr; } + char* pptr() const { return _IO_write_ptr; } + char* egptr() const + { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_end : _IO_read_end; } + char* epptr() const { return _IO_write_end; } + char* pbase() const { return _IO_write_base; } + char* eback() const + { return _IO_file_flags & _IO_IN_BACKUP ? _IO_save_base : _IO_read_base;} + char* base() const { return _IO_buf_base; } + char* ebuf() const { return _IO_buf_end; } + int blen() const { return _IO_buf_end - _IO_buf_base; } + void xput_char(char c) { *_IO_write_ptr++ = c; } + int xflags() { return _IO_file_flags; } + int xflags(int f) {int fl = _IO_file_flags; _IO_file_flags = f; return fl;} + void xsetflags(int f) { _IO_file_flags |= f; } + void xsetflags(int f, int mask) + { _IO_file_flags = (_IO_file_flags & ~mask) | (f & mask); } + void gbump(int n) + { _IO_file_flags & _IO_IN_BACKUP ? (_IO_save_base+=n):(_IO_read_ptr+=n);} + void pbump(int n) { _IO_write_ptr += n; } + void setb(char* b, char* eb, int a=0); + void setp(char* p, char* ep) + { _IO_write_base=_IO_write_ptr=p; _IO_write_end=ep; } + void setg(char* eb, char* g, char *eg) { + if (_IO_file_flags & _IO_IN_BACKUP) _IO_free_backup_area(this); + _IO_read_base = eb; _IO_read_ptr = g; _IO_read_end = eg; } + char *shortbuf() { return _shortbuf; } + + int in_backup() { return _flags & _IO_IN_BACKUP; } + // The start of the main get area: FIXME: wrong for write-mode filebuf? + char *Gbase() { return in_backup() ? _IO_save_base : _IO_read_base; } + // The end of the main get area: + char *eGptr() { return in_backup() ? _IO_save_end : _IO_read_end; } + // The start of the backup area: + char *Bbase() { return in_backup() ? _IO_read_base : _IO_save_base; } + char *Bptr() { return _IO_backup_base; } + // The end of the backup area: + char *eBptr() { return in_backup() ? _IO_read_end : _IO_save_end; } + char *Nbase() { return _IO_save_base; } + char *eNptr() { return _IO_save_end; } + int have_backup() { return _IO_save_base != NULL; } + int have_markers() { return _markers != NULL; } + void free_backup_area(); + void unsave_markers(); // Make all streammarkers !saving(). + int put_mode() { return _flags & _IO_CURRENTLY_PUTTING; } + int switch_to_get_mode(); + + streambuf(int flags=0); + public: + static int flush_all(); + static void flush_all_linebuffered(); // Flush all line buffered files. + virtual ~streambuf(); + virtual int overflow(int c = EOF); // Leave public for now + virtual int underflow(); // Leave public for now + virtual int uflow(); // Leave public for now + virtual int pbackfail(int c); +// virtual int showmany (); + virtual streamsize xsputn(const char* s, streamsize n); + virtual streamsize xsgetn(char* s, streamsize n); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out); + + streampos pubseekoff(streamoff o, _seek_dir d, int mode=ios::in|ios::out) + { return _IO_seekoff (this, o, d, mode); } + streampos pubseekpos(streampos pos, int mode = ios::in|ios::out) + { return _IO_seekpos (this, pos, mode); } + streampos sseekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + streampos sseekpos(streampos pos, int mode = ios::in|ios::out); + virtual streambuf* setbuf(char* p, int len); + virtual int sync(); + virtual int doallocate(); + + int seekmark(streammarker& mark, int delta = 0); + int sputbackc(char c); + int sungetc(); + int unbuffered() { return _flags & _IO_UNBUFFERED ? 1 : 0; } + int linebuffered() { return _flags & _IO_LINE_BUF ? 1 : 0; } + void unbuffered(int i) + { if (i) _flags |= _IO_UNBUFFERED; else _flags &= ~_IO_UNBUFFERED; } + void linebuffered(int i) + { if (i) _flags |= _IO_LINE_BUF; else _flags &= ~_IO_LINE_BUF; } + int allocate() { // For AT&T compatibility + if (base() || unbuffered()) return 0; + else return doallocate(); } + // Allocate a buffer if needed; use _shortbuf if appropriate. + void allocbuf() { if (base() == NULL) doallocbuf(); } + void doallocbuf(); + int in_avail() { return _IO_read_end - _IO_read_ptr; } + int out_waiting() { return _IO_write_ptr - _IO_write_base; } + streamsize sputn(const char* s, streamsize n) { return xsputn(s, n); } + streamsize padn(char pad, streamsize n) { return _IO_padn(this, pad, n); } + streamsize sgetn(char* s, streamsize n) { return _IO_sgetn(this, s, n); } + int ignore(int); + int get_column(); + int set_column(int); + long sgetline(char* buf, _IO_size_t n, char delim, int putback_delim); + int sputc(int c) { return _IO_putc(c, this); } + int sbumpc() { return _IO_getc(this); } + int sgetc() { return _IO_peekc(this); } + int snextc() { + if (_IO_read_ptr >= _IO_read_end && __underflow(this) == EOF) + return EOF; + else return _IO_read_ptr++, sgetc(); } + void stossc() { if (_IO_read_ptr < _IO_read_end) _IO_read_ptr++; } + int vscan(char const *fmt0, _IO_va_list ap, ios* stream = NULL); + int scan(char const *fmt0 ...); + int vform(char const *fmt0, _IO_va_list ap); + int form(char const *fmt0 ...); +#if 0 /* Work in progress */ + int column(); // Current column number (of put pointer). -1 is unknown. + void column(int c); // Set column number of put pointer to c. +#endif + virtual streamsize sys_read(char* buf, streamsize size); + virtual streamsize sys_write(const char*, streamsize); + virtual streampos sys_seek(streamoff, _seek_dir); + virtual int sys_close(); + virtual int sys_stat(void*); // Actually, a (struct stat*) +}; + +// A backupbuf is a streambuf with full backup and savepoints on reading. +// All standard streambufs in the GNU iostream library are backupbufs. + +class filebuf : public streambuf { + protected: + void init(); + public: + static const int openprot; // Non-ANSI AT&T-ism: Default open protection. + filebuf(); + filebuf(int fd); + filebuf(int fd, char* p, int len); +#if !_IO_UNIFIED_JUMPTABLES + static filebuf *__new(); +#endif + ~filebuf(); + filebuf* attach(int fd); + filebuf* open(const char *filename, const char *mode); + filebuf* open(const char *filename, ios::openmode mode, int prot = 0664); + virtual int underflow(); + virtual int overflow(int c = EOF); + int is_open() const { return _fileno >= 0; } + int fd() const { return is_open() ? _fileno : EOF; } + filebuf* close(); + virtual int doallocate(); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); + virtual streambuf* setbuf(char* p, int len); + streamsize xsputn(const char* s, streamsize n); + streamsize xsgetn(char* s, streamsize n); + virtual int sync(); + protected: // See documentation in filebuf.C. +// virtual int pbackfail(int c); + int is_reading() { return eback() != egptr(); } + char* cur_ptr() { return is_reading() ? gptr() : pptr(); } + /* System's idea of pointer */ + char* file_ptr() { return eGptr(); } + // Low-level operations (Usually invoke system calls.) + virtual streamsize sys_read(char* buf, streamsize size); + virtual streampos sys_seek(streamoff, _seek_dir); + virtual streamsize sys_write(const char*, streamsize); + virtual int sys_stat(void*); // Actually, a (struct stat*) + virtual int sys_close(); +#if 0 + virtual uflow; + virtual showmany; +#endif +}; + +inline void ios::init(streambuf* sb, ostream* tie_to) { + _state = sb ? ios::goodbit : ios::badbit; _exceptions=0; + _strbuf=sb; _tie = tie_to; _width=0; _fill=' '; +#ifdef _IO_NEW_STREAMS + _flags=ios::skipws|ios::dec; +#else + _flags=ios::skipws|ios::dec|ios::dont_close; +#endif + _precision=6; _arrays = 0; } + +inline ios::ios(streambuf* sb, ostream* tie_to) { init(sb, tie_to); } + +inline ios::~ios() { +#ifndef _IO_NEW_STREAMS + if (!(_flags & (unsigned int)ios::dont_close)) delete rdbuf(); +#endif + if (_arrays) delete [] _arrays; +} +} // extern "C++" +#endif /* _STREAMBUF_H */ diff --git a/libio/strfile.h b/libio/strfile.h new file mode 100644 index 000000000000..a24c9e0b65c9 --- /dev/null +++ b/libio/strfile.h @@ -0,0 +1,62 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include +#ifdef TODO +Merge into libio.h ? +#endif + +typedef void *(*_IO_alloc_type) __P((_IO_size_t)); +typedef void (*_IO_free_type) __P((void*)); + +struct _IO_str_fields +{ + _IO_alloc_type _allocate_buffer; + _IO_free_type _free_buffer; +}; + +/* This is needed for the Irix6 N32 ABI, which has a 64 bit off_t type, + but a 32 bit pointer type. In this case, we get 4 bytes of padding + after the vtable pointer. Putting them in a structure together solves + this problem. */ + +struct _IO_streambuf +{ + struct _IO_FILE _f; + const void *_vtable; +}; + +typedef struct _IO_strfile_ +{ + struct _IO_streambuf _sbf; + struct _IO_str_fields _s; +} _IO_strfile; + +/* dynamic: set when the array object is allocated (or reallocated) as + necessary to hold a character sequence that can change in length. */ +#define _IO_STR_DYNAMIC(FP) ((FP)->_s._allocate_buffer != (_IO_alloc_type)0) + +/* frozen: set when the program has requested that the array object not + be altered, reallocated, or freed. */ +#define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF) diff --git a/libio/strops.c b/libio/strops.c new file mode 100644 index 000000000000..3162cd966e06 --- /dev/null +++ b/libio/strops.c @@ -0,0 +1,290 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include "strfile.h" +#include "libioP.h" +#include + +#if 0 +/* The following definitions are for exposition only. + They map the terminlogy used in the ANSI/ISO C++ draft standard + to the implementation. */ + +/* allocated: set when a dynamic array object has been allocated, and + hence should be freed by the destructor for the strstreambuf object. */ +#define ALLOCATED(FP) ((FP)->_f._IO_buf_base && DYNAMIC(FP)) + +/* constant: set when the array object has const elements, + so the output sequence cannot be written. */ +#define CONSTANT(FP) ((FP)->_f._IO_file_flags & _IO_NO_WRITES) + +/* alsize: the suggested minimum size for a dynamic array object. */ +#define ALSIZE(FP) ??? /* not stored */ + +/* palloc: points to the function to call to allocate a dynamic array object.*/ +#define PALLOC(FP) \ + ((FP)->_s._allocate_buffer == default_alloc ? 0 : (FP)->_s._allocate_buffer) + +/* pfree: points to the function to call to free a dynamic array object. */ +#define PFREE(FP) \ + ((FP)->_s._free_buffer == default_free ? 0 : (FP)->_s._free_buffer) + +#endif + +#ifdef TODO +/* An "unbounded buffer" is when a buffer is supplied, but with no + specified length. An example is the buffer argument to sprintf. + */ +#endif + +void +DEFUN(_IO_str_init_static, (fp, ptr, size, pstart), + _IO_FILE *fp AND char *ptr AND int size AND char *pstart) +{ + if (size == 0) + size = strlen(ptr); + else if (size < 0) + { + /* If size is negative 'the characters are assumed to + continue indefinitely.' This is kind of messy ... */ + _G_int32_t s; + size = 512; + /* Try increasing powers of 2, as long as we don't wrap around. */ + for (; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; ) + size = s; + /* Try increasing size as much as we can without wrapping around. */ + for (s = size >> 1; s > 0; s >>= 1) + { + if (ptr + size + s > ptr) + size += s; + } + } + _IO_setb(fp, ptr, ptr+size, 0); + + fp->_IO_write_base = ptr; + fp->_IO_read_base = ptr; + fp->_IO_read_ptr = ptr; + if (pstart) + { + fp->_IO_write_ptr = pstart; + fp->_IO_write_end = ptr+size; + fp->_IO_read_end = pstart; + } + else + { + fp->_IO_write_ptr = ptr; + fp->_IO_write_end = ptr; + fp->_IO_read_end = ptr+size; + } + /* A null _allocate_buffer function flags the strfile as being static. */ + (((_IO_strfile*)(fp))->_s._allocate_buffer) = (_IO_alloc_type)0; +} + +void +DEFUN(_IO_str_init_readonly, (fp, ptr, size), + _IO_FILE *fp AND const char *ptr AND int size) +{ + _IO_str_init_static (fp, (char*)ptr, size, NULL); + fp->_IO_file_flags |= _IO_NO_WRITES; +} + +int +DEFUN(_IO_str_overflow, (fp, c), + register _IO_FILE* fp AND int c) +{ + int flush_only = c == EOF; + _IO_size_t pos; + if (fp->_flags & _IO_NO_WRITES) + return flush_only ? 0 : EOF; + if ((fp->_flags & _IO_TIED_PUT_GET) && !(fp->_flags & _IO_CURRENTLY_PUTTING)) + { + fp->_flags |= _IO_CURRENTLY_PUTTING; + fp->_IO_write_ptr = fp->_IO_read_ptr; + fp->_IO_read_ptr = fp->_IO_read_end; + } + pos = fp->_IO_write_ptr - fp->_IO_write_base; + if (pos >= _IO_blen(fp) + flush_only) + { + if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */ + return EOF; + else + { + char *new_buf; + char *old_buf = fp->_IO_buf_base; + _IO_size_t new_size = 2 * _IO_blen(fp) + 100; + new_buf + = (char*)(*((_IO_strfile*)fp)->_s._allocate_buffer)(new_size); + if (new_buf == NULL) + { + /* __ferror(fp) = 1; */ + return EOF; + } + if (fp->_IO_buf_base) + { + memcpy(new_buf, old_buf, _IO_blen(fp)); + (*((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base); + /* Make sure _IO_setb won't try to delete _IO_buf_base. */ + fp->_IO_buf_base = NULL; + } +#if 0 + if (lenp == &LEN(fp)) /* use '\0'-filling */ + memset(new_buf + pos, 0, blen() - pos); +#endif + _IO_setb(fp, new_buf, new_buf + new_size, 1); + fp->_IO_read_base = new_buf + (fp->_IO_read_base - old_buf); + fp->_IO_read_ptr = new_buf + (fp->_IO_read_ptr - old_buf); + fp->_IO_read_end = new_buf + (fp->_IO_read_end - old_buf); + fp->_IO_write_ptr = new_buf + (fp->_IO_write_ptr - old_buf); + + fp->_IO_write_base = new_buf; + fp->_IO_write_end = fp->_IO_buf_end; + } + } + + if (!flush_only) + *fp->_IO_write_ptr++ = (unsigned char) c; + if (fp->_IO_write_ptr > fp->_IO_read_end) + fp->_IO_read_end = fp->_IO_write_ptr; + return c; +} + +int +DEFUN(_IO_str_underflow, (fp), + register _IO_FILE* fp) +{ + if (fp->_IO_write_ptr > fp->_IO_read_end) + fp->_IO_read_end = fp->_IO_write_ptr; + if ((fp->_flags & _IO_TIED_PUT_GET) && (fp->_flags & _IO_CURRENTLY_PUTTING)) + { + fp->_flags &= ~_IO_CURRENTLY_PUTTING; + fp->_IO_read_ptr = fp->_IO_write_ptr; + fp->_IO_write_ptr = fp->_IO_write_end; + } + if (fp->_IO_read_ptr < fp->_IO_read_end) + return *fp->_IO_read_ptr; + else + return EOF; +} + +/* The size of the valid part of the buffer. */ + +_IO_ssize_t +DEFUN(_IO_str_count, (fp), + register _IO_FILE *fp) +{ + return (fp->_IO_write_ptr > fp->_IO_read_end ? fp->_IO_write_ptr + : fp->_IO_read_end) + - fp->_IO_read_base; +} + +_IO_pos_t +DEFUN(_IO_str_seekoff, (fp, offset, dir, mode), + register _IO_FILE *fp AND _IO_off_t offset AND int dir AND int mode) +{ + _IO_ssize_t cur_size = _IO_str_count(fp); + _IO_pos_t new_pos = EOF; + + /* Move the get pointer, if requested. */ + if (mode & _IOS_INPUT) + { + switch (dir) + { + case _IO_seek_end: + offset += cur_size; + break; + case _IO_seek_cur: + offset += fp->_IO_read_ptr - fp->_IO_read_base; + break; + default: /* case _IO_seek_set: */ + break; + } + if (offset < 0 || (_IO_size_t)offset > cur_size) + return EOF; + fp->_IO_read_ptr = fp->_IO_read_base + offset; + fp->_IO_read_end = fp->_IO_read_base + cur_size; + new_pos = offset; + } + + /* Move the put pointer, if requested. */ + if (mode & _IOS_OUTPUT) + { + switch (dir) + { + case _IO_seek_end: + offset += cur_size; + break; + case _IO_seek_cur: + offset += fp->_IO_write_ptr - fp->_IO_write_base; + break; + default: /* case _IO_seek_set: */ + break; + } + if (offset < 0 || (_IO_size_t)offset > cur_size) + return EOF; + fp->_IO_write_ptr = fp->_IO_write_base + offset; + new_pos = offset; + } + return new_pos; +} + +int +DEFUN(_IO_str_pbackfail, (fp, c), + register _IO_FILE *fp AND int c) +{ + if ((fp->_flags & _IO_NO_WRITES) && c != EOF) + return EOF; + return _IO_default_pbackfail(fp, c); +} + +void +DEFUN (_IO_str_finish, (fp), + register _IO_FILE* fp) +{ + if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF)) + (((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base); + fp->_IO_buf_base = NULL; + + _IO_default_finish(fp); +} + +struct _IO_jump_t _IO_str_jumps = { + JUMP_INIT_DUMMY, + JUMP_INIT(finish, _IO_str_finish), + JUMP_INIT(overflow, _IO_str_overflow), + JUMP_INIT(underflow, _IO_str_underflow), + JUMP_INIT(uflow, _IO_default_uflow), + JUMP_INIT(pbackfail, _IO_str_pbackfail), + JUMP_INIT(xsputn, _IO_default_xsputn), + JUMP_INIT(xsgetn, _IO_default_xsgetn), + JUMP_INIT(seekoff, _IO_str_seekoff), + JUMP_INIT(seekpos, _IO_default_seekpos), + JUMP_INIT(setbuf, _IO_default_setbuf), + JUMP_INIT(sync, _IO_default_sync), + JUMP_INIT(doallocate, _IO_default_doallocate), + JUMP_INIT(read, _IO_default_read), + JUMP_INIT(write, _IO_default_write), + JUMP_INIT(seek, _IO_default_seek), + JUMP_INIT(close, _IO_default_close), + JUMP_INIT(stat, _IO_default_stat) +}; diff --git a/libio/strstream.cc b/libio/strstream.cc new file mode 100644 index 000000000000..a32e811c9d94 --- /dev/null +++ b/libio/strstream.cc @@ -0,0 +1,116 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifdef __GNUG__ +#pragma implementation +#endif +#include "iostreamP.h" +#include "strstream.h" +#include + +static void* default_alloc(_IO_size_t size) +{ + return (void*)new char[size]; +} + +static void default_free(void* ptr) +{ + delete [] (char*)ptr; +} + +istrstream::istrstream(const char *cp, int n) +{ + __my_sb.init_readonly (cp, n); +} + +strstreambase::strstreambase(char *cp, int n, int mode) +: __my_sb (cp, n, + (mode == ios::app || mode == ios::ate) ? cp + strlen(cp) : cp) +{ + init (&__my_sb); +} + +char *strstreambuf::str() +{ + freeze(1); + return base(); +} + +_IO_ssize_t strstreambuf::pcount () { return _IO_write_ptr - _IO_write_base; } + +int strstreambuf::overflow(int c /* = EOF */) +{ + return _IO_str_overflow (this, c); +} + +int strstreambuf::underflow() +{ + return _IO_str_underflow(this); +} + + +void strstreambuf::init_dynamic(_IO_alloc_type alloc, _IO_free_type free, + int initial_size) + +{ + _s._allocate_buffer = alloc ? alloc : default_alloc; + _s._free_buffer = free ? free : default_free; + if (initial_size > 0) + { + char * buf = (char*)(*_s._allocate_buffer)(initial_size); + setb(buf, buf + initial_size, 1); + setp(buf, buf + initial_size); + setg(buf, buf, buf); + } +} + +void strstreambuf::init_static(char *ptr, int size, char *pstart) +{ + _IO_str_init_static (this, ptr, size, pstart); +} + +void strstreambuf::init_readonly (const char *ptr, int size) +{ + _IO_str_init_readonly (this, ptr, size); +} + +strstreambuf::~strstreambuf() +{ + if (_IO_buf_base && !(_flags & _IO_USER_BUF)) + (_s._free_buffer)(_IO_buf_base); + _IO_buf_base = NULL; +} + +streampos strstreambuf::seekoff(streamoff off, _seek_dir dir, + int mode /*=ios::in|ios::out*/) +{ + return _IO_str_seekoff (this, off, dir, mode); +} + +int strstreambuf::pbackfail(int c) +{ + return _IO_str_pbackfail (this, c); +} diff --git a/libio/strstream.h b/libio/strstream.h new file mode 100644 index 000000000000..d549b4547588 --- /dev/null +++ b/libio/strstream.h @@ -0,0 +1,113 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +/* Written by Per Bothner (bothner@cygnus.com). */ + +#ifndef __STRSTREAM_H +#define __STRSTREAM_H +#ifdef __GNUG__ +#pragma interface +#endif +#include +#include + +extern "C++" { +class strstreambuf : public streambuf +{ + struct _IO_str_fields _s; + friend class istrstream; + + void init_dynamic(_IO_alloc_type alloc, _IO_free_type free, + int initial_size = 0); + void init_static(char *ptr, int size, char *pstart); + void init_readonly(const char *ptr, int size); + protected: + virtual int overflow(int = EOF); + virtual int underflow(); + virtual int pbackfail(int c); + public: + virtual ~strstreambuf(); + strstreambuf() { init_dynamic(0, 0); } + strstreambuf(int initial_size) { init_dynamic(0, 0, initial_size); } + strstreambuf(void *(*alloc)(_IO_size_t), void (*free)(void*)) + { init_dynamic(alloc, free); } + strstreambuf(char *ptr, int size, char *pstart = NULL) + { init_static(ptr, size, pstart); } + strstreambuf(unsigned char *ptr, int size, unsigned char *pstart = NULL) + { init_static((char*)ptr, size, (char*)pstart); } + strstreambuf(const char *ptr, int size) + { init_readonly(ptr, size); } + strstreambuf(const unsigned char *ptr, int size) + { init_readonly((const char*)ptr, size); } + strstreambuf(signed char *ptr, int size, signed char *pstart = NULL) + { init_static((char*)ptr, size, (char*)pstart); } + strstreambuf(const signed char *ptr, int size) + { init_readonly((const char*)ptr, size); } + // Note: frozen() is always true if !_IO_STR_DYNAMIC(this). + int frozen() { return _flags & _IO_USER_BUF ? 1 : 0; } + void freeze(int n=1) + { if (_IO_STR_DYNAMIC(this)) + { if (n) _flags |= _IO_USER_BUF; else _flags &= ~_IO_USER_BUF; } } + _IO_ssize_t pcount(); + char *str(); + virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); +}; + +class strstreambase : virtual public ios { + protected: + strstreambuf __my_sb; + public: + strstreambuf* rdbuf() { return &__my_sb; } + protected: + strstreambase() { init (&__my_sb); } + strstreambase(char *cp, int n, int mode=ios::out); +}; + +class istrstream : public strstreambase, public istream { + public: + istrstream(const char*, int=0); +}; + +class ostrstream : public strstreambase, public ostream { + public: + ostrstream() { } + ostrstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){} + _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); } + char *str() { return ((strstreambuf*)_strbuf)->str(); } + void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); } + int frozen() { return ((strstreambuf*)_strbuf)->frozen(); } +}; + +class strstream : public strstreambase, public iostream { + public: + strstream() { } + strstream(char *cp, int n, int mode=ios::out) :strstreambase(cp,n,mode){} + _IO_ssize_t pcount() { return ((strstreambuf*)_strbuf)->pcount(); } + char *str() { return ((strstreambuf*)_strbuf)->str(); } + void freeze(int n = 1) { ((strstreambuf*)_strbuf)->freeze(n); } + int frozen() { return ((strstreambuf*)_strbuf)->frozen(); } +}; +} // extern "C++" + +#endif /*!__STRSTREAM_H*/ diff --git a/libio/tests/ChangeLog b/libio/tests/ChangeLog new file mode 100644 index 000000000000..cd9426605571 --- /dev/null +++ b/libio/tests/ChangeLog @@ -0,0 +1,140 @@ +Tue May 20 17:57:31 1997 Jeffrey A Law (law@cygnus.com) + + * tfformat.c (main): Only run half the testcases if SLOW_SIMULATOR + is defined. + +Sun May 18 17:15:32 1997 Jeffrey A Law (law@cygnus.com) + + * tfformat.c (main): Exit immediately if doubles are not + at least 64 bits wide. + +Fri May 16 19:31:29 1997 Bob Manson + + Fix testscases to use _G_int32_t appropriately. + +Thu May 1 17:35:43 1997 Jason Merrill + + * Makefile.in (tgetl, tFile, tiomisc, hounddog, putbackdog, + tiomanip, foo, foo+): Add $(CXXFLAGS). + (tfseek, twrseek, trdseek, tstdiomisc, tpopen): Add $(CFLAGS). + +Mon Apr 28 11:28:36 1997 Brendan Kehoe + + * tiomisc.cc (operator delete): Add throw spec. + +Sat Apr 26 13:40:17 1997 Bob Manson + + * Makefile.in: Change check to check-old. Add do-nothing + check target. + +Wed Apr 10 17:15:47 1996 Jason Merrill + + * Makefile.in (IOLIBS): Link with libstdc++. + +Tue Mar 12 11:45:14 1996 Per Bothner + + * tiomisc.cc (test_read_write_flush): New test for read/write/seek + on block end. From Luke Blanshard . + +Thu Jul 6 17:51:30 1995 Per Bothner + + * tiomisc.cc (getline_test3): New function. Test reading long lines. + * tiomisc.exp: Update for output from getline_test3. + +Wed May 10 03:06:51 1995 Jason Merrill + + * configure.in (X*INCLUDES): Renamed. + +Thu Apr 27 21:05:00 1995 Per Bothner + + * tiomisc.cc (test_destroy), tiomisc.exp: Add support for + _IO_NEW_STREAMS. + +Tue Apr 25 15:15:01 1995 Jim Wilson + + * tstdiomisc.c (t2): Use N not n in last SCAN macro call. + +Sun Feb 12 21:23:24 1995 Brendan Kehoe (brendan@lisa.cygnus.com) + + * Makefile.in (JUNK_TO_CLEAN): Also delete foo.dat from tiomisc. + +Sat Nov 5 14:37:36 1994 Per Bothner + + * tiomisc.cc (test_destroy): New test case from Jason Merrill. + * tiomisc.exp: Update. + + * Makefile.in (JUNK_TO_CLEAN): Add tstdiomisc. + +Thu Oct 13 16:47:30 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tiomisc.cc (reread_test): Remove bogus istream assignment. + +Wed Aug 31 13:59:56 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (CXX_FLAGS): Not used. Removed. + +Wed Aug 17 18:27:37 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tiomisc.cc (getline_test1, getline_test2, flush1_test): New tests, + * tiomisc.cc (reread_test): New tests, + +Wed Jun 22 13:44:19 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tstdiomisc.c: Add some sscanf tests. + * Makefile.in (check-tstdiomisc): Run diff with expected output. + * tstdiomisc.exp: New file. Expected output from tstdiomisc. + * Makefile.in (foo): New rule, for quick one-off tests. + +Fri May 6 14:10:24 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tFile.cc (t7): Revert Mar 4 change - I was confused. + +Sat Apr 2 04:41:41 1994 Andreas Schwab (schwab@issan.informatik.uni-dortmund.de) + + * Makefile.in (tfformat): Fix dependency. + +Fri Mar 4 17:40:14 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tFile.cc (t7): gcount after getline shouldn't include delimiter. + * tFile.cc (show_int, t12), tFile.exp: More integer formatting tests. + +Tue Feb 8 18:39:09 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tiomisc.cc, tiomisc.exp: New test case (for filebuf::attach) + from Joe Buck. + +Mon Jan 31 13:24:58 1994 Per Bothner (bothner@kalessin.cygnus.com) + + * tfformat.c (main): Fix fprintf format string (%s -> %d). + Bug reported by Jochen Voss . + +Sun Dec 19 15:29:00 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * tstdiomisc.c, Makefile.in: New tests. + +Thu Dec 2 22:56:21 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (JUNK_TO_CLEAN), configure.in (MOSTLYCLEAN): + Added, to cleanup after tests. + +Fri Nov 26 16:05:43 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * tiomisc.cc, tiomisc.exp: A (hopefully growing) collection + of small, random tests (mainly regression tests). + * tiomisc.cc (test1 and test2): Tests from Wilco van Hoogstraeten + to check for (now-fixed) bugs. + +Mon Oct 4 17:38:27 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * Makefile.in (IOSTDIOLIB): New macro. + +Fri Aug 27 12:22:10 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * tFile.cc (t7): Add test for buffer overflow. + +Fri Aug 20 00:23:53 1993 Per Bothner (bothner@kalessin.cygnus.com) + + Moved various tests over from old libg++/iostream/test. + * Makefile.in: Edit appropriately. + + diff --git a/libio/tests/Makefile.in b/libio/tests/Makefile.in new file mode 100644 index 000000000000..66e88dc64d66 --- /dev/null +++ b/libio/tests/Makefile.in @@ -0,0 +1,197 @@ +# Copyright (C) 1993 Free Software Foundation +# +# This file is part of the GNU IO 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, 675 Mass Ave, Cambridge, MA 02139, USA. + +srcdir = . + +CFLAGS = -g +C_FLAGS = $(CFLAGS) -I. -I.. -I$(srcdir) -I$(srcdir)/.. +CXXFLAGS = -g +CC = gcc +CXX = gcc + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +STDIO_LD_FLAGS = -u __cleanup + +#LIBS = ../../libg++.a + +#LIBSTDIO = ../stdio/libstdio++.a +#LIBIO = ../libio.a + +#STDIOLIBS = $(STDIO_LD_FLAGS) $(LIBSTDIO) $(LIBIO) $(LIBS) +STDIOLIBS = $(LIBSTDIO) $(LIBIO) $(LIBS) +IOLIBS = -L../../libstdc++ -lstdc++ +IOSTDIOLIB = ../libio.a ../../libiberty/libiberty.a + +DEPEND_SOURCES = $(srcdir)/*.C + +.PHONY: check check-old check-iostream check-stdio +check: + +check-old: check-iostream check-iostdio + + +# These are tests written in C++, that test the iostream facility. +check-iostream: check-tFile check-tiomisc \ + check-hounddog check-putbackdog check-tiomanip + +# These are tests written in C, that don't need C++. +# They test libio's emulation of stdio. +check-iostdio: check-tiformat check-tfformat check-tstdiomisc + +# check-stdio runs test programs that use stdio. +# These aren't run by default because there may be linker tricks needed +# to build them (if libc.a contains a competing stdio implementation). + +check-stdio: check-tfseek check-twrseek check-trdseek check-tpopen + +# See ${MOSTLYCLEAN} in configure.in +JUNK_TO_CLEAN = tFile tiomisc hounddog putbackdog tiomanip \ + t?format *.out streamfile ftmp* tstdiomisc foo.dat + +.PHONY: info +info: +.PHONY: clean-info +clean-info: +.PHONY: install-info +install-info: + +tst: tst.o + gcc -v -o tst tst.o $(STDIOLIBS) + +tgetl: tgetl.o + $(CXX) $(CXXFLAGS) -o tgetl tgetl.o $(IOLIBS) + +tFile: tFile.o + $(CXX) $(CXXFLAGS) -o tFile tFile.o $(IOLIBS) + +tiomisc: tiomisc.o + $(CXX) $(CXXFLAGS) -o tiomisc tiomisc.o $(IOLIBS) + +hounddog: hounddog.o + $(CXX) $(CXXFLAGS) -o hounddog hounddog.o $(IOLIBS) + +check-hounddog: hounddog + ./hounddog <$(srcdir)/hounddog.inp > hounddog.out 2>&1 + diff -c hounddog.out $(srcdir)/hounddog.exp + ./hounddog -b0 <$(srcdir)/hounddog.inp > hound-b0.out 2>&1 + diff -c hound-b0.out $(srcdir)/hounddog.exp + ./hounddog -b2 <$(srcdir)/hounddog.inp > hound-b2.out 2>&1 + diff -c hound-b2.out $(srcdir)/hounddog.exp + +putbackdog: putbackdog.o + $(CXX) $(CXXFLAGS) -o putbackdog putbackdog.o $(IOLIBS) + +check-putbackdog-regular: putbackdog + ./putbackdog <$(srcdir)/hounddog.inp > putback.out 2>&1 + diff -c putback.out $(srcdir)/hounddog.exp +check-putbackdog-nobuf: putbackdog + ./putbackdog -b0 <$(srcdir)/hounddog.inp > putback-b0.out 2>&1 + diff -c putback-b0.out $(srcdir)/hounddog.exp +check-putbackdog-buf2: putbackdog + ./putbackdog -b2 <$(srcdir)/hounddog.inp > putback-b2.out 2>&1 + diff -c putback-b2.out $(srcdir)/hounddog.exp +check-putbackdog: \ + check-putbackdog-regular check-putbackdog-nobuf check-putbackdog-buf2 + +tfseek: tfseek.o + $(CC) $(CFLAGS) -o tfseek tfseek.o $(STDIOLIBS) + +check-tfseek: tfseek + ./tfseek SEEK_SET fopen > tfseek-set-fopen.out 2>&1 + diff -c tfseek-set-fopen.out $(srcdir)/tfseek-set.exp + ./tfseek SEEK_SET freopen > tfseek-set-freopen.out 2>&1 + diff -c tfseek-set-freopen.out $(srcdir)/tfseek-set.exp + ./tfseek SEEK_CUR fopen > tfseek-cur-fopen.out 2>&1 + diff -c tfseek-cur-fopen.out $(srcdir)/tfseek-cur.exp + ./tfseek SEEK_CUR freopen > tfseek-cur-freopen.out 2>&1 + diff -c tfseek-cur-freopen.out $(srcdir)/tfseek-cur.exp + +twrseek: twrseek.o + $(CC) $(CFLAGS) -o twrseek twrseek.o $(STDIOLIBS) + +check-twrseek: twrseek + ./twrseek > twrseek.out 2>&1 + diff -c twrseek.out $(srcdir)/twrseek.exp + +trdseek: trdseek.o + $(CC) $(CFLAGS) -o trdseek -v trdseek.o $(STDIOLIBS) + +check-trdseek: trdseek + ./trdseek + +check-tFile-regular: tFile + ./tFile < $(srcdir)/tFile.inp > tFile.out 2>&1 + diff -c tFile.out $(srcdir)/tFile.exp +# Run tFile with cout.rdbuf() unbuffered. +check-tFile-nobuf: tFile + ./tFile -b0 < $(srcdir)/tFile.inp > tFile-buf0.out 2>&1 + diff -c tFile-buf0.out $(srcdir)/tFile.exp +# Run tFile with a 3-byte buffer for cout.rdbuf(). +check-tFile-buf3: tFile + ./tFile -b3 < $(srcdir)/tFile.inp > tFile-buf3.out 2>&1 + diff -c tFile-buf3.out $(srcdir)/tFile.exp +check-tFile: check-tFile-regular check-tFile-nobuf check-tFile-buf3 + +check-tiomisc: tiomisc + ./tiomisc >tiomisc.out 2>&1 + diff -c tiomisc.out $(srcdir)/tiomisc.exp + +tiomanip: tiomanip.o + $(CXX) $(CXXFLAGS) -o tiomanip tiomanip.o $(IOLIBS) +check-tiomanip: tiomanip + ./tiomanip >tiomanip.out 2>&1 + diff -c tiomanip.out $(srcdir)/tiomanip.exp + +tfformat: $(srcdir)/tfformat.c + $(CC) $(C_FLAGS) -DTEST_LIBIO -DTEST_EXACTNESS \ + -o tfformat $(srcdir)/tfformat.c $(IOSTDIOLIB) + +check-tfformat: tfformat + ./tfformat + +tiformat: $(srcdir)/tiformat.c + $(CC) $(C_FLAGS) -DTEST_LIBIO -o tiformat $(srcdir)/tiformat.c $(IOSTDIOLIB) + +check-tiformat: tiformat + ./tiformat + +tstdiomisc: tstdiomisc.o + $(CC) $(CFLAGS) -o tstdiomisc tstdiomisc.o $(IOSTDIOLIB) + +check-tstdiomisc: tstdiomisc + ./tstdiomisc >tstdiomisc.out 2>&1 + diff -c tstdiomisc.out $(srcdir)/tstdiomisc.exp + +tpopen: tpopen.o + $(CC) $(CFLAGS) -o tpopen tpopen.o $(STDIOLIBS) + +check-tpopen: tpopen + ./tpopen > tpopen.out 2>&1 + diff -c tpopen.out $(srcdir)/tpopen.exp + +trwseek: trwseek.o + $(CC) $(CFLAGS) -o trwseek trwseek.o $(STDIOLIBS) + +check-trwseek: trwseek + ./trwsseek TMP r+ k w o + +foo: foo.o + $(CXX) $(CXXFLAGS) -o foo foo.o $(STDIOLIBS) +foo+: foo+.o + $(CXX) $(CXXFLAGS) -o foo+ foo+.o $(IOLIBS) diff --git a/libio/tests/configure.in b/libio/tests/configure.in new file mode 100644 index 000000000000..f832adfb2363 --- /dev/null +++ b/libio/tests/configure.in @@ -0,0 +1,21 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../../configure. + +configdirs= +srctrigger=tFile.cc +srcname="test C++ input/output library" +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TO_TOPDIR=../../ +ALL=' ' +XCINCLUDES='-I. -I.. -I$(srcdir) -I$(srcdir)/..' +XCXXINCLUDES='-I. -I.. -I$(srcdir) -I$(srcdir)/..' +MOSTLYCLEAN='*.o core $(JUNK_TO_CLEAN)' +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: diff --git a/libio/tests/hounddog.cc b/libio/tests/hounddog.cc new file mode 100644 index 000000000000..29a923836476 --- /dev/null +++ b/libio/tests/hounddog.cc @@ -0,0 +1,85 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +#include +#include +#include + +// Read either "dog", "hound", or "hounddog". +// If "dog" is found, return 1. +// If "hound" is found, return 2. +// If "hounddog" is found, return 3. +// If non of these are found, return -1. +int my_scan(streambuf* sb) +{ + streammarker fence(sb); + char buffer[20]; + // Try reading "hounddog": + if (sb->sgetn(buffer, 8) == 8 && strncmp(buffer, "hounddog", 8) == 0) + return 3; + // No, no "hounddog": Backup to 'fence' ... + sb->seekmark(fence); + // ... and try reading "dog": + if (sb->sgetn(buffer, 3) == 3 && strncmp(buffer, "dog", 3) == 0) + return 1; + // No, no "dog" either: Backup to 'fence' ... + sb->seekmark(fence); + // ... and try reading "hound": + if (sb->sgetn(buffer, 5) == 5 && strncmp(buffer, "hound", 5) == 0) + return 2; + // No, no "hound" either: Backup to 'fence' and signal failure. + sb->seekmark(fence); // Backup to 'fence'.. + return -1; +} + +int main(int argc, char **argv) +{ + streambuf *sb = cin.rdbuf(); + if (argc > 1 && strncmp(argv[1], "-b", 2) == 0) { + streambuf *ret; + int buffer_size = atoi(&argv[1][2]); + if (buffer_size == 0) + ret = sb->setbuf(NULL, 0); + else + ret = sb->setbuf(new char[buffer_size], buffer_size); + if (ret != sb) + cerr << "Warning: cin.rdbuf()->setbuf failed!\n"; + } + for (;;) { + int code = my_scan(sb); + int ch = sb->sbumpc(); + if (code == -1 && ch == EOF) + break; + int n = 0; + while (ch != EOF && ch != '\n') { + n++; + ch = sb->sbumpc(); + }; + if (ch == EOF) { + cout << "[Unexpected EOF]\n"; + break; + } + cout << "Code: " << code << " followed by " << n << " chars\n"; + } +} diff --git a/libio/tests/hounddog.exp b/libio/tests/hounddog.exp new file mode 100644 index 000000000000..2060807b4312 --- /dev/null +++ b/libio/tests/hounddog.exp @@ -0,0 +1,7 @@ +Code: -1 followed by 6 chars +Code: 1 followed by 3 chars +Code: 2 followed by 0 chars +Code: -1 followed by 3 chars +Code: 3 followed by 4 chars +Code: 1 followed by 0 chars +Code: -1 followed by 3 chars diff --git a/libio/tests/hounddog.inp b/libio/tests/hounddog.inp new file mode 100644 index 000000000000..370371bc2032 --- /dev/null +++ b/libio/tests/hounddog.inp @@ -0,0 +1,7 @@ +hello! +doggie +hound +cat +hounddog rat +dog +foo diff --git a/libio/tests/putbackdog.cc b/libio/tests/putbackdog.cc new file mode 100644 index 000000000000..0e1ed61f5598 --- /dev/null +++ b/libio/tests/putbackdog.cc @@ -0,0 +1,97 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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. */ + +// Test streambuf::sputbackc + +#include +#include +#include + +// Read either "dog", "hound", or "hounddog". +// If "dog" is found, return 1. +// If "hound" is found, return 2. +// If "hounddog" is found, return 3. +// If non of these are found, return -1. + +void unget_string(streambuf *sb, char *str, int count) +{ + for (str += count; -- count >= 0; ) + sb->sputbackc(*--str); +} + +int my_scan(streambuf* sb) +{ + char buffer[20]; + // Try reading "hounddog": + int count; + count = sb->sgetn(buffer, 8); + if (count == 8 && strncmp(buffer, "hounddog", 8) == 0) + return 3; + // No, no "hounddog": Backup to 'fence' ... + unget_string(sb, buffer, count); + // ... and try reading "dog": + count = sb->sgetn(buffer, 3); + if (count == 3 && strncmp(buffer, "dog", 3) == 0) + return 1; + // No, no "dog" either: Backup to 'fence' ... + unget_string(sb, buffer, count); + // ... and try reading "hound": + count = sb->sgetn(buffer, 5); + if (count == 5 && strncmp(buffer, "hound", 5) == 0) + return 2; + // No, no "hound" either: Backup to 'fence' and signal failure. + unget_string(sb, buffer, count); + return -1; +} + +int main(int argc, char **argv) +{ + streambuf *sb = cin.rdbuf(); + if (argc > 1 && strncmp(argv[1], "-b", 2) == 0) { + streambuf *ret; + int buffer_size = atoi(&argv[1][2]); + if (buffer_size == 0) + ret = sb->setbuf(NULL, 0); + else + ret = sb->setbuf(new char[buffer_size], buffer_size); + if (ret != sb) + cerr << "Warning: cin.rdbuf()->setbuf failed!\n"; + } + for (;;) { + int code = my_scan(sb); + int ch = sb->sbumpc(); + if (code == -1 && ch == EOF) + break; + int n = 0; + while (ch != EOF && ch != '\n') { + n++; + ch = sb->sbumpc(); + }; + if (ch == EOF) { + cout << "[Unexpected EOF]\n"; + break; + } + cout << "Code: " << code << " followed by " << n << " chars\n"; + } +} diff --git a/libio/tests/tFile.cc b/libio/tests/tFile.cc new file mode 100644 index 000000000000..d8a1ee301fa6 --- /dev/null +++ b/libio/tests/tFile.cc @@ -0,0 +1,550 @@ +/* +Copyright (C) 1993 Free Software Foundation + +This file is part of the GNU IO 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 this library; 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 may look like C code, but it is really -*- C++ -*- + +/* + * a few tests for streams + * + */ + +#include +#include +#ifndef _OLD_STREAMS +#include +#include "unistd.h" +#endif +#include +#include + +#include +#include +#include +#include + +class record +{ +public: + char c; int i; double d; +}; + +ostream& operator<<(ostream& s, record& r) +{ + return(s << "(i = " << r.i << " c = " << r.c << " d = " << r.d << ")"); +} + +void t1() +{ + char ch; + + assert(cout.good()); + assert(cout.writable()); + assert(cout.is_open()); + cout << "Hello, world via cout\n"; + assert(cerr.good()); + assert(cerr.writable()); + assert(cerr.is_open()); + cerr << "Hello, world via cerr\n"; + + assert(cin.good()); + assert(cin.readable()); + assert(cin.is_open()); + + cout << "enter a char:"; cin >> ch; + cout.put('c'); cout.put(' '); cout.put('='); cout.put(' '); + cout.put('"'); cout.put(ch); cout << '"'; cout << char('\n'); + assert(cin.good()); + assert(cout.good()); +} + +void t2() +{ + int i; + short h; + long l; + float f; + double d; + char s[100]; + + cout << "enter three integers (short, int, long):"; + cin >> h; cin >> i; + // cin.scan("%ld", &l); + cin >> l; + cout << "first = " << h << " via dec = " << dec(h, 8) << "\n"; + cout << "second = " << i << form(" via form = %d = 0%o", i, i); + cout.form(" via cout.form = %d = 0x%x\n", i, i); + cout << "third = " << l << " via hex = " << hex(l) << "\n"; + assert(cin.good()); + assert(cout.good()); + + cout << "enter a float then a double:"; cin >> f; cin >> d; + cout << "first = " << f << "\n"; + cout << "second = " << d << "\n"; + assert(cin.good()); + assert(cout.good()); + + cout << "enter 5 characters separated with spaces:"; cin >> s; + cout << "first = " << s << "\n"; + cin.get(s, 100); + cout << "rest = " << s << "\n"; + + assert(cin.good()); + + cin.width(10); + cin >> s; + cin.clear(); + cout << "A 10-character buffer: " << s << endl; + + assert(cout.good()); + +} + +void t3() +{ + char ch; + cout << "\nMaking streams sout and sin..."; +#ifdef _OLD_STREAMS + ostream sout("streamfile", io_writeonly, a_create); +#else + ofstream sout("streamfile"); +#endif + assert(sout.good()); + assert(sout.is_open()); + assert(sout.writable()); + assert(!sout.readable()); + sout << "This file has one line testing output streams.\n"; + sout.close(); + assert(!sout.is_open()); +#ifdef _OLD_STREAMS + istream sin("streamfile", io_readonly, a_useonly); +#else + ifstream sin("streamfile"); +#endif + assert(sin.good()); + assert(sin.is_open()); + assert(!sin.writable()); + assert(sin.readable()); + cout << "contents of file:\n"; + while(sin >> ch) cout << ch; + sin.close(); + assert(!sin.is_open()); +} + + +void t4() +{ + char s[100]; + char ch; + int i; + + cout << "\nMaking File tf ... "; +#ifdef _OLD_STREAMS + File tf("tempfile", io_readwrite, a_create); +#else + fstream tf("tempfile", ios::in|ios::out|ios::trunc); +#endif + assert(tf.good()); + assert(tf.is_open()); + assert(tf.writable()); + assert(tf.readable()); + strcpy(s, "This is the first and only line of this file.\n"); +#ifdef _OLD_STREAMS + tf.put(s); + tf.seek(0); +#else + tf << s; + tf.rdbuf()->seekoff(0, ios::beg); +#endif + tf.get(s, 100); + assert(tf.good()); + cout << "first line of file:\n" << s << "\n"; + cout << "next char = "; + tf.get(ch); + cout << (int)ch; + cout.put('\n'); + assert(ch == 10); + strcpy(s, "Now there is a second line.\n"); + cout << "reopening tempfile, appending: " << s; +#ifdef _OLD_STREAMS + tf.open(tf.name(), io_appendonly, a_use); +#else + tf.close(); + tf.open("tempfile", ios::app); +#endif + assert(tf.good()); + assert(tf.is_open()); + assert(tf.writable()); + assert(!tf.readable()); +#ifdef _OLD_STREAMS + tf.put(s); + assert(tf.good()); + tf.open(tf.name(), io_readonly, a_use); +#else + tf << s; + assert(tf.good()); + tf.close(); + tf.open("tempfile", ios::in); +#endif + tf.raw(); + assert(tf.good()); + assert(tf.is_open()); + assert(!tf.writable()); + assert(tf.readable()); + cout << "First 10 chars via raw system read after reopen for input:\n"; + read(tf.filedesc(), s, 10); + assert(tf.good()); + for (i = 0; i < 10; ++ i) + cout.put(s[i]); + lseek(tf.filedesc(), 5, 0); + cout << "\nContents after raw lseek to pos 5:\n"; + while ( (tf.get(ch)) && (cout.put(ch)) ); +#ifdef _OLD_STREAMS + tf.remove(); +#else + tf.close(); + unlink("tempfile"); +#endif + assert(!tf.is_open()); +} + +void t5() +{ + record r; + int i; + cout << "\nMaking SFile rf..."; +#ifdef _OLD_STREAMS + SFile rf("recfile", sizeof(record), io_readwrite, a_create); +#else + SFile rf("recfile", sizeof(record), ios::in|ios::out|ios::trunc); +#endif + assert(rf.good()); + assert(rf.is_open()); + assert(rf.writable()); + assert(rf.readable()); + for (i = 0; i < 10; ++i) + { + r.c = i + 'a'; + r.i = i; + r.d = (double)(i) / 1000.0; + rf.put(&r); + } + assert(rf.good()); + cout << "odd elements of file in reverse order:\n"; + for (i = 9; i >= 0; i -= 2) + { + rf[i].get(&r); + assert(r.c == i + 'a'); + assert(r.i == i); + cout << r << "\n"; + } + assert(rf.good()); +#ifdef _OLD_STREAMS + rf.remove(); +#else + rf.close(); + unlink("recfile"); +#endif + assert(!rf.is_open()); +} + +void t6() +{ + cout << "\nMaking PlotFile pf ..."; + static const char plot_name[] = "plot.out"; + PlotFile pf(plot_name); + assert(pf.good()); + assert(pf.is_open()); + assert(pf.writable()); + assert(!pf.readable()); + pf.move(10,10); + pf.label("Test"); + pf.circle(300,300,200); + pf.line(100, 100, 500, 500); + assert(pf.good()); +#ifdef _OLD_STREAMS + cout << "(You may delete or attempt to plot " << pf.name() << ")\n"; +#else + cout << "(You may delete or attempt to plot " << plot_name << ")\n"; +#endif +} + +void t7() +{ + char ch; + static char t7_line1[] = "This is a string-based stream.\n"; + static char t7_line2[] = "With two lines.\n"; + char mybuf[60]; + char *bufp; +#ifdef _OLD_STREAMS + cout << "creating string-based ostream...\n"; + ostream strout(60, mybuf); +#else + cout << "creating ostrstream...\n"; + ostrstream strout(mybuf, 60); +#endif + assert(strout.good()); + assert(strout.writable()); + strout << t7_line1 << t7_line2 << ends; + assert(strout.good()); + cout << "with contents:\n"; + bufp = strout.str(); + assert(bufp == mybuf); + strout.rdbuf()->freeze(0); /* Should be a no-op */ + cout << mybuf; +#ifdef _OLD_STREAMS + cout << "using it to create string-based istream...\n"; + istream strin(strlen(mybuf), mybuf); +#else + cout << "using it to create istrstream...\n"; + istrstream strin(mybuf, strlen(mybuf)); +#endif + assert(strin.good()); + assert(strin.readable()); + cout << "with contents:\n"; +#ifndef _OLD_STREAMS + char line[100]; + strin.getline(line, 100); + int line1_len = strlen(t7_line1); + assert(strin.tellg() == line1_len); + int line_len = strin.gcount(); + assert(line_len == line1_len); + cout.write(line, line1_len - 1); + cout << endl; +#endif + while (strin.get(ch)) cout.put(ch); + + strstream str1; + strstream str2; + str1 << "Testing string-based stream using strstream.\n"; + str1.seekg(0); + for (;;) { + int i = str1.get(); + if (i == EOF) + break; + str2 << (char)i; + } + str2 << ends; + cout << str2.str(); + + // This should make it overflow. + strout << t7_line1; + assert (strout.bad()); +} + +void t8() +{ +#ifdef _OLD_STREAMS + cout << "\nThe following file open should generate error message:"; + cout.flush(); + File ef("shouldnotexist", io_readonly, a_useonly); +#else + ifstream ef("shouldnotexist"); +#endif + assert(!ef.good()); + assert(!ef.is_open()); +} + +void t9() +{ + char ch; + static char ffile_name[] = "ftmp"; + { + cout << "\nMaking filebuf streams fout and fin..."; + filebuf foutbuf; +#ifdef _OLD_STREAMS + foutbuf.open(ffile_name, output); +#else + foutbuf.open(ffile_name, ios::out); +#endif + ostream fout(&foutbuf); + assert(fout.good()); + assert(fout.is_open()); + assert(fout.writable()); + assert(!fout.readable()); + fout << "This file has one line testing output streams.\n"; +#ifdef _OLD_STREAMS + fout.close(); + assert(!fout.is_open()); +#endif + } + filebuf finbuf; +#ifdef _OLD_STREAMS + finbuf.open(ffile_name, input); +#else + finbuf.open(ffile_name, ios::in); +#endif + istream fin(&finbuf); + assert(fin.good()); + assert(fin.is_open()); + assert(!fin.writable()); + assert(fin.readable()); + cout << "contents of file:\n"; + while(fin >> ch) cout << ch; +#ifndef _OLD_STREAMS + cout << '\n'; +#endif + fin.close(); + assert(!fin.is_open()); +} + +void t10() +{ + int fileCnt = 3; + char *file_name_pattern = "ftmp%d"; + char current_file_name[50]; + ifstream inFile; + ofstream outFile; + char c; + int i; + + cout << '\n'; + + // Write some files. + for (i=0; i < fileCnt; i++) { + sprintf(current_file_name, file_name_pattern, i); + outFile.open(current_file_name, ios::out); + + if ( outFile.fail() ) + cerr << "File " << current_file_name + << " can't be opened for output" << endl; + else { + outFile << "This is line 1 of " << current_file_name << '\n'; + outFile << "This is line 2 of " << current_file_name << endl; + outFile.close(); + } + } + + // Now read the files back in, and write then out to cout. + for (i=0; i < fileCnt; i++) { + sprintf(current_file_name, file_name_pattern, i); + inFile.open(current_file_name, ios::in); + + + if ( inFile.fail() ) + cerr << "File " << current_file_name + << " can't be opened for input" << endl; + else { + while ( inFile.get (c)) + cout << c; + cout << endl; + inFile.close(); + } + } +} + +// Test form + +void t11() +{ + int count1, count2; + cout.form("%.2f+%.2f = %4.3e\n%n", 5.5, 6.25, 5.5+6.25, &count1); + char *text = "Previous line has12345"; + char text_length_to_use = strlen(text) - 5; + count2 = cout.rdbuf()->form("%-*.*s%3g characters\n", + text_length_to_use + 1, + text_length_to_use, + text, + (double)(count1-1)); + cout.form("%-*.*s%+d characters\n%n", + text_length_to_use + 1, text_length_to_use, text, + count2-1, &count1); + assert(count1 == 33); +} + +static void +show_int (long val) +{ + cout.setf(ios::showbase); + cout << dec; cout.width (8); cout << val << "(dec) = "; + cout << hex; cout.width (8); cout << (0xFFFF & val) << "(hex) = "; + cout << oct; cout.width (8); + cout << (0xFFFF & val) << "(oct) [showbase on]\n"; + cout.unsetf(ios::showbase); + cout << dec; cout.width (8); cout << val << "(dec) = "; + cout << hex; cout.width (8); cout << (0xFFFF & val) << "(hex) = "; + cout << oct; cout.width (8); + cout << (0xFFFF & val) << "(oct) [showbase off]\n"; +} + +void +t12 () +{ + ios::fmtflags old_flags = cout.setf(ios::showpos); + int fill = cout.fill('_'); + cout.unsetf(ios::uppercase); + cout.setf(ios::internal, ios::adjustfield); + show_int(34567); + show_int(-34567); + cout.setf(ios::right, ios::adjustfield); + show_int(0); + cout.setf(ios::uppercase); + cout.unsetf(ios::showpos); + show_int(34567); + cout.setf(ios::left, ios::adjustfield); + show_int(-34567); + cout.fill(fill); + show_int(0); + cout.setf(old_flags, + ios::adjustfield|ios::basefield + |ios::showbase|ios::showpos|ios::uppercase); +} + +main(int argc, char **argv) +{ + if (argc > 1 && strncmp(argv[1], "-b", 2) == 0) { + streambuf *sb = cout.rdbuf(); + streambuf *ret; + int buffer_size = atoi(&argv[1][2]); + if (buffer_size == 0) + ret = sb->setbuf(NULL, 0); + else + ret = sb->setbuf(new char[buffer_size], buffer_size); + if (ret != sb) + cerr << "Warning: cout.rdbuf()->setbuf failed!\n"; + } + t1(); + t2(); + t3(); + t4(); + t5(); + t6(); + t7(); + t9(); + t8(); + t10(); + t11(); + t12(); + + cout << "Final names & states:\n"; +#ifdef _OLD_STREAMS + cout << "cin: " << cin.name() << "\t" << cin.rdstate() << "\n"; + cout << "cout: " << cout.name() << "\t" << cout.rdstate() << "\n"; + cout << "cerr: " << cerr.name() << "\t" << cerr.rdstate() << "\n"; +#else + cout << "cin: " << "(stdin)" << "\t" << cin.rdstate() << "\n"; + cout << "cout: " << "(stdout)" << "\t" << cout.rdstate() << "\n"; + cout << "cerr: " << "(stderr)" << "\t" << cerr.rdstate() << "\n"; +#endif + cout << "\nend of test.\n"; +} diff --git a/libio/tests/tFile.exp b/libio/tests/tFile.exp new file mode 100644 index 000000000000..154cd24dc0bb --- /dev/null +++ b/libio/tests/tFile.exp @@ -0,0 +1,75 @@ +Hello, world via cout +Hello, world via cerr +enter a char:c = "a" +enter three integers (short, int, long):first = 123 via dec = 123 +second = 4567 via form = 4567 = 010727 via cout.form = 4567 = 0x11d7 +third = 89012 via hex = 15bb4 +enter a float then a double:first = 123.456 +second = -0.012 +enter 5 characters separated with spaces:first = 1 +rest = 2 3 4 5 +A 10-character buffer: abcdefghi + +Making streams sout and sin...contents of file: +Thisfilehasonelinetestingoutputstreams. +Making File tf ... first line of file: +This is the first and only line of this file. +next char = 10 +reopening tempfile, appending: Now there is a second line. +First 10 chars via raw system read after reopen for input: +This is th +Contents after raw lseek to pos 5: +is the first and only line of this file. +Now there is a second line. + +Making SFile rf...odd elements of file in reverse order: +(i = 9 c = j d = 0.009) +(i = 7 c = h d = 0.007) +(i = 5 c = f d = 0.005) +(i = 3 c = d d = 0.003) +(i = 1 c = b d = 0.001) + +Making PlotFile pf ...(You may delete or attempt to plot plot.out) +creating ostrstream... +with contents: +This is a string-based stream. +With two lines. +using it to create istrstream... +with contents: +This is a string-based stream. +With two lines. +Testing string-based stream using strstream. + +Making filebuf streams fout and fin...contents of file: +Thisfilehasonelinetestingoutputstreams. + +This is line 1 of ftmp0 +This is line 2 of ftmp0 + +This is line 1 of ftmp1 +This is line 2 of ftmp1 + +This is line 1 of ftmp2 +This is line 2 of ftmp2 + +5.50+6.25 = 1.175e+01 +Previous line has 21 characters +Previous line has +32 characters ++__34567(dec) = 0x__8707(hex) = _0103407(oct) [showbase on] ++__34567(dec) = ____8707(hex) = __103407(oct) [showbase off] +-__34567(dec) = 0x__78f9(hex) = __074371(oct) [showbase on] +-__34567(dec) = ____78f9(hex) = ___74371(oct) [showbase off] +______+0(dec) = _____0x0(hex) = _______0(oct) [showbase on] +______+0(dec) = _______0(hex) = _______0(oct) [showbase off] +___34567(dec) = __0X8707(hex) = _0103407(oct) [showbase on] +___34567(dec) = ____8707(hex) = __103407(oct) [showbase off] +-34567__(dec) = 0X78F9__(hex) = 074371__(oct) [showbase on] +-34567__(dec) = 78F9____(hex) = 74371___(oct) [showbase off] +0 (dec) = 0X0 (hex) = 0 (oct) [showbase on] +0 (dec) = 0 (hex) = 0 (oct) [showbase off] +Final names & states: +cin: (stdin) 0 +cout: (stdout) 0 +cerr: (stderr) 0 + +end of test. diff --git a/libio/tests/tFile.inp b/libio/tests/tFile.inp new file mode 100644 index 000000000000..5b821ef072be --- /dev/null +++ b/libio/tests/tFile.inp @@ -0,0 +1,5 @@ +a +123 4567 89012 +123.456 -1.2e-2 +1 2 3 4 5 +abcdefghijklmnop diff --git a/libio/tests/tfformat.c b/libio/tests/tfformat.c new file mode 100644 index 000000000000..29bac8b6b792 --- /dev/null +++ b/libio/tests/tfformat.c @@ -0,0 +1,4181 @@ +#ifdef TEST_LIBIO +#include +#else +#ifdef __cplusplus +#include +#else +#include +#endif +#endif /* !TEST_LIBIO */ + +/* Tests taken from Cygnus C library. */ + +typedef struct +{ + int line; + double value; + char *result; + char *format_string; +} sprint_double_type; + +sprint_double_type sprint_doubles[] = +{ +__LINE__, 30.3, "< +30.3>", "<%+15.10g>", +__LINE__, 10.0, "<10.00>", "<%5.2f>", + +__LINE__, 1.002121970718271e+05, "100212.19707 ", "%0-15.5f", +__LINE__, -1.002121970718271e+05, "-100212.19707 ", "%0-15.5f", +__LINE__, 1.002121970718271e+05, "000100212.19707", "%015.5f", +__LINE__, -1.002121970718271e+05, "-00100212.19707", "%015.5f", +__LINE__, 1.002121970718271e+05, "+00100212.19707", "%+015.5f", +__LINE__, -1.002121970718271e+05, "-00100212.19707", "%+015.5f", +__LINE__, 1.002121970718271e+05, " 00100212.19707", "% 015.5f", +__LINE__, -1.002121970718271e+05, "-00100212.19707", "% 015.5f", +__LINE__, 1.002121970718271e+05, "+100212.19707 ", "%+-15.5f", +__LINE__, -1.002121970718271e+05, "-100212.19707 ", "%+-15.5f", + +__LINE__, -1.002121970718271e+29, "-1.0E+29", "%.1E", +__LINE__, -1.002126048612756e-02, "-1.002126E-02", "%+#E", +__LINE__, -1.002653755271637e+00, "-1.00265", "%G", +__LINE__, -1.003238744365917e-23, "-0.00", "%4.2f", +__LINE__, -1.005084840877781e-29, " -0", "%4.f", +__LINE__, -1.005362549674427e+01, "-10.0536", "%#g", +__LINE__, -1.005915042991691e-17, "-1.00592E-17", "%G", +__LINE__, -1.007829874228503e-18, "-1.00783e-18", "%.7g", +__LINE__, -1.007829874228503e-18, "-1.007830e-18", "%#.7g", +__LINE__, -1.009390937771849e+15, "-1009390937771848.628657", "%+f", +__LINE__, -1.010679382726182e-29, "-0.0000000", "%.7f", +__LINE__, -1.010691853346650e+13, "-10106918533466.497934", "%+f", +__LINE__, -1.013412912122286e-22, "-1.01E-22", "%.2E", +__LINE__, -1.019269582113858e-25, " -0", "%4.0f", +__LINE__, -1.019886033368556e+24, "-1.019886E+24", "%+.7G", +__LINE__, -1.021037413548719e+02, "-102.103741", "%f", +__LINE__, -1.023833576089065e+26, "-1.023834E+26", "%+E", +__LINE__, -1.024736652408627e+10, "-10247366524.086265", "%+f", +__LINE__, -1.025439198495476e+09, "-1.02544e+09", "%+g", +__LINE__, -1.027080247585776e-04, "-0.0001027", "%6.7f", +__LINE__, -1.028096307262016e+18, "-1.0281E+18", "%3G", +__LINE__, -1.029604290697901e-02, "-0.010296", "%g", +__LINE__, -1.034347730570491e+16, "-10343477305704908.975059", "%+f", +__LINE__, -1.034663325049286e+22, "-1.0E+22", "%#.1E", +__LINE__, -1.034843152721857e-14, " -0", "%6.f", +__LINE__, -1.036082122299529e-29, "-1.04e-29", "%4.3g", +__LINE__, -1.037213662365954e-09, "-1e-09", "%3.e", +__LINE__, -1.038563976775690e-12, "-0.000000", "%f", +__LINE__, -1.040910158681323e-02, "-0.0104091", "%+G", +__LINE__, -1.044680094714482e-20, "-1.04468E-20", "%G", +__LINE__, -1.044990054091126e+24, "-1.044990E+24", "%+E", +__LINE__, -1.045693871096982e+11, "-1.045694e+11", "%+e", +__LINE__, -1.045714133591312e-04, "-0.000104571", "%+#3g", +__LINE__, -1.046215079103016e-15, "-1.04622e-15", "%g", +__LINE__, -1.046285293993789e-18, "-1.04629E-18", "%+4G", +__LINE__, -1.046306092899333e-06, "-0.00", "%0.2f", +__LINE__, -1.047308973649206e-22, "-1.05E-22", "%+1.3G", +__LINE__, -1.047369032507755e+01, "-1.047369E+01", "%E", +__LINE__, -1.048986365562919e-21, "-1.05E-21", "%+.2E", +__LINE__, -1.049530193156793e-17, "-1.04953E-17", "%+G", +__LINE__, -1.050073419263768e+25, "-1.05007e+25", "%g", +__LINE__, -1.051739652002504e-28, "-0.000000", "%+f", +__LINE__, -1.054493420082636e+21, "-1.0545e+21", "%#5.4e", +__LINE__, -1.055867291029098e+18, "-1.05587e+18", "%g", +__LINE__, -1.056514389757866e-16, "-1.05651E-16", "%5.6G", +__LINE__, -1.057180924868704e+15, "-1057180924868704", "%4.f", +__LINE__, -1.058455468395683e-23, "-1.05846e-23", "%g", +__LINE__, -1.062560982393212e+08, "-1.06256e+08", "%g", +__LINE__, -1.063365829241138e-10, "-1.063366e-10", "%+e", +__LINE__, -1.063568908667280e-19, "-1.06357E-19", "%+G", +__LINE__, -1.063734263253492e-13, "-0.000000", "%0f", +__LINE__, -1.064472689765495e-13, "-1E-13", "%4.0G", +__LINE__, -1.067192610000129e-25, "-1.06719E-25", "%G", +__LINE__, -1.068401334996592e-12, "-0.0000000", "%+.7f", +__LINE__, -1.069012628653724e-13, "-1.069013E-13", "%+.7G", +__LINE__, -1.069451976810790e+16, "-10694519768107904.056365", "%f", +__LINE__, -1.069568935323556e+17, "-1.06957e+17", "%g", +__LINE__, -1.071351044854107e-29, "-1.07135e-29", "%g", +__LINE__, -1.072274197526185e-21, "-1E-21", "%1.G", +__LINE__, -1.073875921752995e+23, "-1E+23", "%5.E", +__LINE__, -1.074835151152265e-12, "-1.0748e-12", "%1.5g", +__LINE__, -1.075171047088241e-19, "-1.07517E-19", "%#G", +__LINE__, -1.076258826412760e+22, "-1.076259e+22", "%+e", +__LINE__, -1.076365103160401e+06, "-1.07637E+06", "%+4.6G", +__LINE__, -1.076817750454633e+08, "-1e+08", "%4.g", +__LINE__, -1.078615405755685e-30, "-1e-30", "%4.g", +__LINE__, -1.078629622917468e-25, "-1.078630e-25", "%e", +__LINE__, -1.079352432833170e+11, "-107935243283", "%+2.f", +__LINE__, -1.081431147440215e+16, "-10814311474402147.439378", "%+f", +__LINE__, -1.083042116905339e-16, "-1.083e-16", "%.5g", +__LINE__, -1.085351710708553e-10, "-1.085e-10", "%1.4g", +__LINE__, -1.085796045618276e+07, "-1.085796e+07", "%e", +__LINE__, -1.087398259981007e+22, "-1.0874e+22", "%g", +__LINE__, -1.087986044402224e-11, "-1.087986e-11", "%e", +__LINE__, -1.090451848762709e-02, "-1.090452e-02", "%e", +__LINE__, -1.091463236899737e+11, "-1.091463E+11", "%#E", +__LINE__, -1.091617921737384e-29, "-1.09162e-29", "%3g", +__LINE__, -1.092049328579047e-17, "-1.092049E-17", "%E", +__LINE__, -1.093647615472090e+06, "-1093647.61547", "%6.5f", +__LINE__, -1.094133175602384e-08, "-1.1E-08", "%0.1E", +__LINE__, -1.095397916728214e-23, "-1e-23", "%6.e", +__LINE__, -1.098958790437321e+02, "-109.895879", "%+#f", +__LINE__, -1.100194638181594e-20, "-1.100195e-20", "%e", +__LINE__, -1.102174253534260e+05, "-1.1e+05", "%2.3g", +__LINE__, -1.102890180316350e-12, "-1.10289e-12", "%+g", +__LINE__, -1.105582337418378e+00, "-1.11", "%3.3g", +__LINE__, -1.110515122647056e+04, "-1.E+04", "%#0.G", +__LINE__, -1.111365895262625e-18, "-1e-18", "%0.g", +__LINE__, -1.112010622677495e+04, "-11120.1", "%g", +__LINE__, -1.112580043156699e-23, "-1.11258e-23", "%1g", +__LINE__, -1.112829057091303e+08, "-1.11283e+08", "%+2g", +__LINE__, -1.115019046200472e+18, "-1.1150190e+18", "%+#.7e", +__LINE__, -1.118078332268016e-13, "-1.12E-13", "%1.3G", +__LINE__, -1.119113571963886e+08, "-1.119114e+08", "%e", +__LINE__, -1.120102397563448e-15, "-1.12e-15", "%.4g", +__LINE__, -1.120707480791434e-19, "-1.12071e-19", "%g", +__LINE__, -1.124243676139007e-07, "-0.000000", "%f", +__LINE__, -1.125025214608798e+15, "-1.12503E+15", "%0G", +__LINE__, -1.126074395136447e+06, "-1E+06", "%+.0G", +__LINE__, -1.127203019940870e-06, "-0.000001", "%+#7f", +__LINE__, -1.130577648480677e+01, "-1.130578e+01", "%e", +__LINE__, -1.131469694425240e-11, "-1.13147e-11", "%#0.6g", +__LINE__, -1.132225023239752e+02, "-113.223", "%G", +__LINE__, -1.133702113050128e+20, "-1E+20", "%+3.E", +__LINE__, -1.135529466224404e-13, "-1.13553e-13", "%#g", +__LINE__, -1.137587210063004e+21, "-1e+21", "%.1g", +__LINE__, -1.140765637106361e-21, "-1.1e-21", "%+.1e", +__LINE__, -1.141182595083699e-18, "-0.000000", "%f", +__LINE__, -1.141695709120972e+00, "-1.1417", "%3G", +__LINE__, -1.143199141708028e+18, "-1143199141708027833", "%2.f", +__LINE__, -1.146712902056139e+21, "-1146712902056139071760.298975", "%f", +__LINE__, -1.146837903839073e-02, " -0.0", "%+5.1f", +__LINE__, -1.147363016107446e+10, "-1.14736e+10", "%+7g", +__LINE__, -1.149575523465052e+20, "-114957552346505220697.28140", "%+.5f", +__LINE__, -1.152748955392589e+13, "-1.15275E+13", "%G", +__LINE__, -1.152751106015483e-17, "-1E-17", "%+3.E", +__LINE__, -1.155539139258226e-18, "-1.2e-18", "%+.2g", +__LINE__, -1.157089280563492e+20, "-1.15709e+20", "%g", +__LINE__, -1.161217745859779e+19, "-1.161218E+19", "%E", +__LINE__, -1.162293536734798e+10, "-11622935367.347980", "%f", +__LINE__, -1.162629909468603e+20, "-1.16E+20", "%.3G", +__LINE__, -1.164979155838631e+24, "-1.16498E+24", "%G", +__LINE__, -1.165103052644816e-20, " -1e-20", "%+7.g", +__LINE__, -1.166448459023264e-08, "-0.000000", "%f", +__LINE__, -1.167694506705309e+28, "-1e+28", "%.1g", +__LINE__, -1.169901754818745e-28, "-0.000000", "%+f", +__LINE__, -1.170330336216446e+08, " -1e+08", "%7.g", +__LINE__, -1.170946623214213e-17, "-1.17095E-17", "%G", +__LINE__, -1.174581596799302e+27, "-1.174582e+27", "%+e", +__LINE__, -1.174763473995155e-28, "-1E-28", "%.1G", +__LINE__, -1.175885640508038e-23, "-1E-23", "%+.0E", +__LINE__, -1.177268411775439e-05, "-0.000012", "%#2.6f", +__LINE__, -1.177739669428001e-30, "-1.17774E-30", "%G", +__LINE__, -1.178059639880544e-02, "-0.0117806", "%+.7G", +__LINE__, -1.178793300854446e-13, "-1.2E-13", "%+#0.2G", +__LINE__, -1.179629345138058e-04, "-0.000118", "%0.3g", +__LINE__, -1.180730292213358e-25, "-1.18073e-25", "%g", +__LINE__, -1.180766261654697e+02, "-118.077", "%3g", +__LINE__, -1.181880261069391e-29, "-1.181880e-29", "%+#e", +__LINE__, -1.183752810063514e-09, "-1.18375e-09", "%#g", +__LINE__, -1.184191742443406e-21, "-1.184192e-21", "%e", +__LINE__, -1.184859760488406e-26, "-1.18486E-26", "%G", +__LINE__, -1.187276828720072e-29, "-1.18728E-29", "%G", +__LINE__, -1.187992907205195e-04, "-1.187993E-04", "%E", +__LINE__, -1.190586192763405e-28, "-1.E-28", "%#1.E", +__LINE__, -1.192104053032086e+02, "-119.21", "%G", +__LINE__, -1.192917884333569e+26, "-1.192918E+26", "%E", +__LINE__, -1.195900753509801e+22, "-1.1959e+22", "%g", +__LINE__, -1.196559413116537e-28, "-0.000000", "%6.6f", +__LINE__, -1.197534588732952e+12, "-1.19753e+12", "%#g", +__LINE__, -1.200279514790649e-25, "-0.0000", "%0.4f", +__LINE__, -1.203806667944635e+10, "-1.2038067E+10", "%5.7E", +__LINE__, -1.204344885974736e+07, "-1.204E+07", "%#2.4G", +__LINE__, -1.205668007693083e+00, "-1.20567", "%g", +__LINE__, -1.205898515218947e-11, "-1.2059e-11", "%+g", +__LINE__, -1.206787414909373e-05, "-1.2e-05", "%2.2g", +__LINE__, -1.207905830366447e+15, "-1.207906e+15", "%6.7g", +__LINE__, -1.208067010597729e-17, "-1.208067e-17", "%5e", +__LINE__, -1.210189135822574e+01, "-12", "%+2.0f", +__LINE__, -1.211560695948122e+10, "-1.21156e+10", "%+g", +__LINE__, -1.214003025273234e-18, "-1.214e-18", "%+g", +__LINE__, -1.214096815259005e+17, "-121409681525900459.142520", "%f", +__LINE__, -1.214699041716797e-14, "-1.2147E-14", "%G", +__LINE__, -1.215061611919443e+14, "-121506161191944.306310", "%+#f", +__LINE__, -1.217491221065185e+27, "-1.21749e+27", "%g", +__LINE__, -1.218538401534388e-11, "-1.218538e-11", "%#e", +__LINE__, -1.218810085883466e+16, "-1e+16", "%+.1g", +__LINE__, -1.219422688169801e+08, "-1.219423e+08", "%e", +__LINE__, -1.220473194407651e-14, "-1.2205E-14", "%1.5G", +__LINE__, -1.220824440193375e-02, "-0.012208", "%4f", +__LINE__, -1.221520240637007e+13, "-1.221520E+13", "%1E", +__LINE__, -1.221894719843486e+29, "-1.22189E+29", "%G", +__LINE__, -1.223020108610281e+25, "-1.22302E+25", "%G", +__LINE__, -1.223203206227728e-02, "-0.012232", "%G", +__LINE__, -1.225661737076919e-15, "-1.22566E-15", "%G", +__LINE__, -1.228147221003795e-08, "-1.22815E-08", "%G", +__LINE__, -1.228298534591771e+20, "-1.22830E+20", "%#G", +__LINE__, -1.228469080229780e-02, "-0.012285", "%0f", +__LINE__, -1.229161950699222e-09, "-1e-09", "%0.e", +__LINE__, -1.231294820136559e-17, "-1.231295E-17", "%1.7G", +__LINE__, -1.232588663406698e-21, "-1E-21", "%+0.G", +__LINE__, -1.233381256982191e-26, "-0.000000", "%f", +__LINE__, -1.233435864835578e+14, "-1.23344e+14", "%#g", +__LINE__, -1.237409567806099e-25, "-1.23741E-25", "%#G", +__LINE__, -1.238244697758558e-02, "-1.238245e-02", "%7e", +__LINE__, -1.239393163123284e+26, "-1.23939e+26", "%+g", +__LINE__, -1.240484781756132e-18, "-1E-18", "%4.E", +__LINE__, -1.241420286838750e+23, "-1E+23", "%2.E", +__LINE__, -1.243781122052343e-18, "-1.243781e-18", "%+e", +__LINE__, -1.244421506844779e+07, "-1.244422E+07", "%+6E", +__LINE__, -1.245754054764741e-21, "-1e-21", "%5.0g", +__LINE__, -1.245992228426733e-24, "-0.000000", "%f", +__LINE__, -1.246498277739883e-12, "-0.0000000", "%5.7f", +__LINE__, -1.247130891343776e-18, "-1.24713E-18", "%G", +__LINE__, -1.247309461703025e-03, "-0.0012473", "%#5.5G", +__LINE__, -1.248139162966407e-29, "-1.e-29", "%+#6.g", +__LINE__, -1.249756153623776e+08, "-1.249756e+08", "%e", +__LINE__, -1.250899983565585e-10, "-1.2509e-10", "%5g", +__LINE__, -1.250957368798327e+19, "-1.25096E+19", "%0G", +__LINE__, -1.252630814464822e-02, "-0.012526", "%+f", +__LINE__, -1.253076368257011e-28, "-0.000000", "%f", +__LINE__, -1.254243507039370e+01, "-1.254244e+01", "%e", +__LINE__, -1.257605614492298e-12, "-1.257606E-12", "%6.7G", +__LINE__, -1.258041911573120e+06, "-1258041.911573", "%+f", +__LINE__, -1.261670983426507e-25, "-0.00", "%.2f", +__LINE__, -1.263216883336562e-14, "-1.26322e-14", "%g", +__LINE__, -1.266846944498751e-15, "-1e-15", "%0.g", +__LINE__, -1.266977908502326e+06, "-1266978", "%+1.f", +__LINE__, -1.267006162870084e-23, "-1.267006e-23", "%e", +__LINE__, -1.269144609375931e+01, "-1.269145e+01", "%+e", +__LINE__, -1.269458714257904e+25, "-1.26946E+25", "%G", +__LINE__, -1.276697325772662e-02, "-0.0128", "%7.3G", +__LINE__, -1.278855081807602e+15, "-1278855081807601.87891", "%#0.5f", +__LINE__, -1.278966821639612e+20, "-1.278967E+20", "%3E", +__LINE__, -1.281942705258106e+03, "-1281.94", "%+G", +__LINE__, -1.282331291499203e+14, "-128233129149920.266343", "%+f", +__LINE__, -1.285125739341808e-28, "-1.28513e-28", "%g", +__LINE__, -1.285700693704978e+11, "-1.285701E+11", "%E", +__LINE__, -1.286574096459251e+28, "-1.287E+28", "%6.4G", +__LINE__, -1.287967889247240e+03, "-1287.97", "%G", +__LINE__, -1.288913808801319e-27, "-1.3e-27", "%7.1e", +__LINE__, -1.289147517760377e-18, "-1.289148E-18", "%E", +__LINE__, -1.289355006600107e+23, "-1.28936E+23", "%+G", +__LINE__, -1.291232014623979e+01, "-1.29123E+01", "%+.5E", +__LINE__, -1.293658562875966e-18, "-1.29366e-18", "%+g", +__LINE__, -1.294982911983638e-19, "-1.29498E-19", "%#G", +__LINE__, -1.296123363481695e-13, "-1.296123E-13", "%E", +__LINE__, -1.296632862070602e-20, "-1.29663e-20", "%+g", +__LINE__, -1.297801639022777e+23, "-129780163902277735132884.11777", "%#0.5f", +__LINE__, -1.297886574534611e+16, "-1.297887e+16", "%+e", +__LINE__, -1.300588216308401e+11, "-1.30e+11", "%.2e", +__LINE__, -1.301296100909062e-10, "-1.3013e-10", "%+g", +__LINE__, -1.303144244306468e-07, "-1.303144E-07", "%E", +__LINE__, -1.304096315024042e-20, "-1.3041E-20", "%+G", +__LINE__, -1.304817970675085e+16, "-1.304818E+16", "%+E", +__LINE__, -1.304870304632683e-15, " -1e-15", "%7.g", +__LINE__, -1.305213586757638e-18, "-1.30521e-18", "%g", +__LINE__, -1.306880734910465e-22, "-1.306881E-22", "%E", +__LINE__, -1.308964092631446e-23, "-1.30896e-23", "%g", +__LINE__, -1.312070555198201e+26, "-131207055519820126043839537", "%+7.f", +__LINE__, -1.312511609151056e-30, "-1.312512E-30", "%#E", +__LINE__, -1.313087359008389e-23, "-0.000000", "%+f", +__LINE__, -1.316948423042059e-02, "-1.316948E-02", "%+E", +__LINE__, -1.317080882577385e+29, "-1.317E+29", "%+.4G", +__LINE__, -1.317514598984346e+24, "-1.317515e+24", "%e", +__LINE__, -1.317817551125923e-21, "-1.31782E-21", "%+G", +__LINE__, -1.319603985988120e+29, "-131960398598811989856471882376.354188", "%f", +__LINE__, -1.328850458671907e+06, "-1e+06", "%.0e", +__LINE__, -1.328945346449817e-23, "-1.328945e-23", "%+e", +__LINE__, -1.330146584094221e-08, "-1e-08", "%+5.g", +__LINE__, -1.332609617892115e+00, "-1.33261", "%2.7G", +#ifndef __PCCNECV70__ +__LINE__, -1.332751724965715e+22, "-13327517249657150344432.920974", "%f", +__LINE__, -1.333194379353273e-19, "-0.000000", "%f", +__LINE__, -1.334304387932777e-06, "-1.334304e-06", "%e", +__LINE__, -1.334306581172082e-05, "-1.3e-05", "%+1.2g", +__LINE__, -1.335283510893438e-05, " -1E-05", "%7.G", +__LINE__, -1.337939692108373e+11, "-1.33794e+11", "%+4g", +__LINE__, -1.339117288874809e-03, "-0.001", "%1.3f", +__LINE__, -1.340100588141492e+27, "-1.340101E+27", "%E", +__LINE__, -1.341953272572953e-19, "-0.000000", "%+f", +__LINE__, -1.343058354301620e-02, "-1.343058e-02", "%e", +__LINE__, -1.346662720871543e+22, "-1.34666E+22", "%#G", +__LINE__, -1.354010578652210e-02, "-0.0135401", "%#g", +__LINE__, -1.354066549307666e-12, " -0", "%+6.f", +__LINE__, -1.355284719365947e+21, "-1.35528e+21", "%g", +__LINE__, -1.356326532145087e+29, "-1E+29", "%4.G", +__LINE__, -1.357278618897291e+19, "-13572786188972911780.581398", "%f", +__LINE__, -1.357537331348202e-10, "-0.000", "%+.3f", +__LINE__, -1.360011287595868e-10, "-0.000000", "%f", +__LINE__, -1.360506902899232e+16, "-13605069028992320.", "%#5.f", +__LINE__, -1.361102570277000e+10, "-1.3611E+10", "%G", +__LINE__, -1.362601255900219e+07, "-1.363E+07", "%.4G", +__LINE__, -1.366078182354771e+10, "-1.36608E+10", "%0G", +__LINE__, -1.366667926615127e+08, "-136666792.661513", "%f", +__LINE__, -1.367162823743231e-12, "-0.000000", "%#f", +__LINE__, -1.371523037550709e+09, "-1.37152e+09", "%+g", +__LINE__, -1.374328925986197e-17, "-1.37e-17", "%.2e", +__LINE__, -1.374995603898421e-26, "-1.375e-26", "%+g", +__LINE__, -1.376726539375688e+09, "-1.376727E+09", "%+E", +__LINE__, -1.378351117694958e-13, "-0.000000", "%f", +__LINE__, -1.378514699313619e-14, "-1.378515e-14", "%e", +__LINE__, -1.379347588942324e-23, "-1.4e-23", "%+.1e", +__LINE__, -1.380380583822272e-17, "-0.000000", "%+f", +__LINE__, -1.381658659947406e+19, "-1.38166e+19", "%g", +__LINE__, -1.382775316390237e+29, "-138277531639023653298181670834.3104", "%+#7.4f", +__LINE__, -1.383541138922400e+00, "-1.383541E+00", "%E", +__LINE__, -1.384625301445090e+01, "-13.8", "%+.3g", +__LINE__, -1.386844086284027e-13, "-1.38684E-13", "%+G", +__LINE__, -1.386930516448650e-28, "-1.386931E-28", "%E", +__LINE__, -1.387444896054260e-07, "-1.38744E-07", "%G", +__LINE__, -1.389685107980798e+22, "-1.38969E+22", "%G", +__LINE__, -1.390880300369347e+03, "-1390.880300", "%f", +__LINE__, -1.391423370198150e-17, "-1E-17", "%+2.G", +__LINE__, -1.394441767471218e-09, "-1.394442e-09", "%e", +__LINE__, -1.396275525062527e-20, "-1.39628E-20", "%G", +__LINE__, -1.397045957455157e+24, "-1E+24", "%.0E", +__LINE__, -1.397458546930799e+21, "-1397458546930798526375.383517", "%f", +__LINE__, -1.397584578988941e-14, "-1.39758e-14", "%5g", +__LINE__, -1.397789397300823e+09, "-1.398e+09", "%.4g", +__LINE__, -1.398167472294874e+21, "-1.398167E+21", "%+7E", +__LINE__, -1.398809636136688e-16, "-0.000000", "%+f", +__LINE__, -1.399545335304119e+26, "-139954533530411872277454676.805064", "%#5f", +__LINE__, -1.400102603335755e+20, "-140010260333575509150.705329", "%2f", +__LINE__, -1.401212746235235e+04, "-1.401213e+04", "%e", +__LINE__, -1.404409427681801e+07, "-1E+07", "%4.E", +__LINE__, -1.406018114263948e-25, "-1e-25", "%3.e", +__LINE__, -1.406245608096877e-06, "-1.4e-06", "%+.1e", +__LINE__, -1.410697254683835e-10, "-1.410697e-10", "%e", +__LINE__, -1.410739097553846e+25, "-1.410739E+25", "%+E", +__LINE__, -1.410850631189577e+04, "-14108.5", "%.6g", +__LINE__, -1.411680434455781e+28, "-14116804344557807304738616949.180141", "%f", +__LINE__, -1.413309465660099e-27, "-1.413309E-27", "%+#E", +__LINE__, -1.418468741386300e+09, "-1418468741.386300", "%f", +__LINE__, -1.420277110892909e+06, "-1.42028e+06", "%1g", +__LINE__, -1.420417889565590e-17, "-1.42E-17", "%.2E", +__LINE__, -1.421098212056305e+08, "-1.421098e+08", "%4e", +__LINE__, -1.421792812798986e-20, " -1E-20", "%7.G", +__LINE__, -1.423675488122461e+18, "-1423675488122461363.360571", "%f", +__LINE__, -1.423810545840653e+15, "-1E+15", "%3.E", +__LINE__, -1.424242673476368e-15, "-1.424243e-15", "%e", +__LINE__, -1.427847435688733e-01, "-1.427847E-01", "%E", +__LINE__, -1.433897734612555e-04, "-0.0001", "%3.g", +__LINE__, -1.434537754075696e-24, "-1.435E-24", "%+0.3E", +__LINE__, -1.434774864809324e-24, "-1E-24", "%2.E", +__LINE__, -1.435583851565142e-11, "-1E-11", "%.0E", +__LINE__, -1.438791024010112e+11, "-1.43879e+11", "%#.6g", +__LINE__, -1.439267565343777e+27, "-1.4e+27", "%2.1e", +__LINE__, -1.439440602670449e+02, "-143.944", "%G", +__LINE__, -1.439494412124925e+13, "-14394944121249.251268", "%f", +__LINE__, -1.440032823245152e+10, "-14400328232.451516", "%f", +__LINE__, -1.440174494009562e-08, "-0.000000", "%7f", +__LINE__, -1.440827804010568e+07, "-1.E+07", "%#6.1G", +__LINE__, -1.442760907195336e+09, "-1.44276E+09", "%+5G", +__LINE__, -1.444655304181403e+10, "-14446553041.814035", "%7f", +__LINE__, -1.444995766787036e+04, "-14450", "%5G", +__LINE__, -1.445078682874535e-13, "-1E-13", "%3.E", +__LINE__, -1.446781469662328e+01, "-14.4678", "%G", +__LINE__, -1.447795251395321e-04, "-0.000145", "%+f", +__LINE__, -1.448193079247108e-02, "-0.014", "%4.2G", +__LINE__, -1.449552967961345e+14, "-1E+14", "%1.E", +__LINE__, -1.451269763513571e+10, "-14512697635.135705", "%6f", +__LINE__, -1.451843176990292e+12, "-1e+12", "%1.g", +__LINE__, -1.452631405935931e+06, "-1.452631e+06", "%e", +__LINE__, -1.452753650285897e+21, "-1452753650285897091265.496783", "%5f", +__LINE__, -1.453811512433860e-05, "-1e-05", "%+6.g", +__LINE__, -1.454071430557372e+13, "-1.4541E+13", "%.4E", +__LINE__, -1.455956079562999e+03, "-1455.96", "%G", +__LINE__, -1.459712196146602e-17, "-1.45971e-17", "%g", +__LINE__, -1.461857733495947e-02, "-1.4619E-02", "%.4E", +__LINE__, -1.465257069090911e-11, "-1.465257E-11", "%+E", +__LINE__, -1.465306607257042e+05, "-146531", "%g", +__LINE__, -1.465857076315921e+20, "-1.46586E+20", "%+G", +__LINE__, -1.467919792051489e+16, "-1.46792e+16", "%2g", +__LINE__, -1.469271519834567e+20, "-146927151983456720785", "%+.0f", +__LINE__, -1.472961447442697e-28, "-1.47296e-28", "%#g", +__LINE__, -1.473385695190456e-12, "-1.473386E-12", "%E", +__LINE__, -1.485003089033267e-10, "-1.485E-10", "%2G", +__LINE__, -1.490541379072390e-18, "-1.490541E-18", "%4E", +__LINE__, -1.490683434793125e+22, "-14906834347931249951102.472551", "%#f", +__LINE__, -1.498356837215425e+20, "-1.49836E+20", "%#G", +__LINE__, -1.498677007818122e+14, "-1.49868E+14", "%+4G", +__LINE__, -1.502143197677119e+23, "-150214319767711934616727.", "%#7.f", +__LINE__, -1.503563770470753e-24, "-1.50356e-24", "%.6g", +__LINE__, -1.504643092793197e-18, "-1.504643e-18", "%+4e", +__LINE__, -1.507017706254022e-13, "-1.50702e-13", "%+g", +__LINE__, -1.507054033750081e-22, "-0.000000", "%f", +__LINE__, -1.508662346022339e+16, "-1.508662E+16", "%#E", +__LINE__, -1.509366882438902e+08, "-2e+08", "%4.g", +__LINE__, -1.511086567087967e+20, "-1.51109e+20", "%g", +__LINE__, -1.514959134622707e-18, "-0.000000", "%+f", +__LINE__, -1.515730120364204e+06, "-2E+06", "%0.G", +__LINE__, -1.516372763118606e-09, "-1.51637e-09", "%g", +__LINE__, -1.520610443546204e+27, "-1.52061e+27", "%g", +__LINE__, -1.522040655642012e+11, "-1.52204E+11", "%+2G", +__LINE__, -1.523772495014966e-24, "-2E-24", "%2.G", +__LINE__, -1.523980825983892e-05, "-0.000", "%2.3f", +__LINE__, -1.526696214603152e-03, "-0.0015267", "%+6.5G", +__LINE__, -1.528680540769583e+00, "-1.5287", "%0.5G", +__LINE__, -1.529951830525433e+08, "-1.529952e+08", "%+e", +__LINE__, -1.533052896559935e+05, "-153305", "%4.0f", +__LINE__, -1.533829640475152e-03, "-0.00153383", "%+#g", +__LINE__, -1.535617804643105e-30, "-1.535618e-30", "%e", +__LINE__, -1.537623698361821e+16, "-15376236983618207.7875719", "%4.7f", +__LINE__, -1.544994895330616e+24, "-1.54499e+24", "%g", +__LINE__, -1.545083356728403e+17, "-1.545083e+17", "%e", +__LINE__, -1.545684535393879e+12, "-1.55E+12", "%3.3G", +__LINE__, -1.545878334099427e+13, "-15458783340994.268762", "%1f", +__LINE__, -1.547697185980564e-18, "-1.5477e-18", "%.6g", +__LINE__, -1.548576527172579e-29, "-1.5E-29", "%2.2G", +__LINE__, -1.549712227835891e+08, "-1.549712e+08", "%#6.7g", +__LINE__, -1.550010819435335e-21, "-1.55001E-21", "%G", +__LINE__, -1.551412476164257e+14, "-1.551412E+14", "%E", +__LINE__, -1.553156638090030e+01, " -2E+01", "%7.G", +__LINE__, -1.553733233064355e-01, "-0.2", "%3.g", +__LINE__, -1.558391111609365e+00, "-1.558391", "%+f", +__LINE__, -1.562004019284766e+15, "-1.562E+15", "%6.5G", +__LINE__, -1.562195733239758e-16, "-0.000000", "%f", +__LINE__, -1.563953339012525e-14, "-1.56395E-14", "%1G", +__LINE__, -1.568317638534983e+18, "-1.56832E+18", "%1G", +__LINE__, -1.568546851135348e+04, "-15685.5", "%+#G", +__LINE__, -1.574297872228857e+18, "-1.574298e+18", "%e", +__LINE__, -1.575696460196291e-21, "-1.5757E-21", "%G", +__LINE__, -1.576324848379791e+25, "-1.57632E+25", "%+G", +__LINE__, -1.577524395140843e+06, "-1.5775E+06", "%.5G", +__LINE__, -1.585122856675091e+12, "-1585122856675.091452", "%f", +__LINE__, -1.586734674395556e-02, "-1.586735E-02", "%E", +__LINE__, -1.592602264315192e+22, "-1.5926E+22", "%G", +__LINE__, -1.594121556700562e+05, "-2E+05", "%+.0G", +__LINE__, -1.598538116193430e+22, "-1.59854e+22", "%+g", +__LINE__, -1.605647463222382e+18, "-1.6056E+18", "%.5G", +__LINE__, -1.610891449201191e+06, "-1.6109E+06", "%#6.4E", +__LINE__, -1.614593168166818e-05, "-1.61459E-05", "%G", +__LINE__, -1.615597722557325e-03, "-0.001616", "%f", +__LINE__, -1.616038022182124e-29, "-1.61604E-29", "%1G", +__LINE__, -1.618380771451625e-28, "-2e-28", "%+1.g", +__LINE__, -1.620287456872150e+10, "-1.620e+10", "%#7.3e", +__LINE__, -1.620469955611903e-29, "-0.000000", "%f", +__LINE__, -1.622580720690927e+20, "-1.622581E+20", "%+#E", +__LINE__, -1.622752500991079e-12, "-1.622753E-12", "%E", +__LINE__, -1.622771933776459e+08, "-1.6228E+08", "%+4.4E", +__LINE__, -1.623894567037391e+09, "-1.623895e+09", "%#e", +__LINE__, -1.624021408185354e-25, "-1.624E-25", "%.5G", +__LINE__, -1.624405320939366e-06, "-1.62441e-06", "%+#g", +__LINE__, -1.631236208958857e-25, "-1.631236e-25", "%#e", +__LINE__, -1.632165969536046e+20, "-1.63217E+20", "%G", +__LINE__, -1.632859596256475e+06, "-1.63286E+06", "%G", +__LINE__, -1.634371961703112e+06, "-1.634372E+06", "%+E", +__LINE__, -1.637230383641845e+24, "-1.63723e+24", "%#g", +__LINE__, -1.638081480475853e+17, "-1.63808e+17", "%+g", +__LINE__, -1.638279690467673e+14, "-163827969046767.325523", "%#f", +__LINE__, -1.640360249548215e-29, "-1.64036e-29", "%+6.6g", +__LINE__, -1.645691728060833e-30, "-1.64569e-30", "%g", +__LINE__, -1.648548965852592e-03, " -0", "%5.f", +__LINE__, -1.650100957771182e+21, "-1650100957771182308420.065965", "%+f", +__LINE__, -1.650957176011913e-02, "-0.016510", "%#4.5G", +__LINE__, -1.651165108095301e+29, "-165116510809530137038336761179.380119", "%f", +__LINE__, -1.657132845094847e-06, "-0.000002", "%f", +__LINE__, -1.657152146172541e+12, "-1.657152E+12", "%.7G", +__LINE__, -1.658377345516132e-06, "-0.00", "%.2f", +__LINE__, -1.658850468902324e+20, "-1.659e+20", "%.4g", +__LINE__, -1.661723557149830e+18, "-1.66172E+18", "%G", +__LINE__, -1.663570885140273e+14, "-166357088514027", "%2.f", +__LINE__, -1.665186944896906e+25, "-1.66519E+25", "%G", +__LINE__, -1.675910137717036e+22, "-2e+22", "%5.g", +__LINE__, -1.677447987675587e-15, "-1.67745E-15", "%G", +__LINE__, -1.677510590697220e+06, "-1677510.590697", "%5f", +__LINE__, -1.677658141289510e-18, "-2E-18", "%+5.G", +__LINE__, -1.678316848066192e-03, "-1.678317E-03", "%E", +__LINE__, -1.681506404024821e+24, "-1.68151E+24", "%G", +__LINE__, -1.688584243722160e+12, "-1.68858E+12", "%+#G", +__LINE__, -1.689468295411408e+28, "-1.68947E+28", "%+G", +__LINE__, -1.690746767470207e-11, "-1.69075E-11", "%G", +__LINE__, -1.692773960755248e-14, "-2E-14", "%4.E", +__LINE__, -1.693349092740995e-18, "-1.69335e-18", "%g", +__LINE__, -1.693642321808920e-26, "-1.69364E-26", "%G", +__LINE__, -1.694579128700042e-12, "-0.000000", "%f", +__LINE__, -1.695454897264717e-08, "-1.7E-08", "%+4.3G", +__LINE__, -1.695733278397589e+19, "-1.695733e+19", "%4e", +__LINE__, -1.699522534409388e-05, "-1.69952E-05", "%G", +__LINE__, -1.701752039544919e+00, "-2", "%.0f", +__LINE__, -1.702304998615036e+16, "-1.7023E+16", "%1G", +__LINE__, -1.703113580904556e-25, "-1.703114e-25", "%+e", +__LINE__, -1.705165515454546e+29, "-1.705166e+29", "%+e", +__LINE__, -1.707392568277288e-05, "-1.70739E-05", "%G", +__LINE__, -1.707477319256742e+09, "-1707477319.26", "%7.2f", +__LINE__, -1.709669107513969e-03, " -0.002", "%7.g", +__LINE__, -1.713284011412432e-24, "-1.713e-24", "%3.3e", +__LINE__, -1.715512203951086e-28, "-1.715512E-28", "%E", +__LINE__, -1.716880832248879e+13, "-1.71688e+13", "%+g", +__LINE__, -1.720722835740680e-15, "-1.7E-15", "%.1E", +__LINE__, -1.721855769574895e+07, "-17218557.695749", "%3f", +__LINE__, -1.722449437415368e+01, "-1.722449e+01", "%e", +__LINE__, -1.723218805116591e-29, "-2e-29", "%.0g", +__LINE__, -1.726129004920195e-05, "-1.72613E-05", "%0G", +__LINE__, -1.727400228037571e-28, "-0.0000000", "%2.7f", +__LINE__, -1.730008745782339e-23, "-1.73e-23", "%.4g", +__LINE__, -1.731875670201859e+09, "-1.73188E+09", "%G", +__LINE__, -1.732142976428085e+10, "-2E+10", "%+6.0E", +__LINE__, -1.732699651229194e-02, "-0.017327", "%5g", +__LINE__, -1.734772870736446e-12, "-0.000000", "%+f", +__LINE__, -1.738576887938331e+09, "-1.73858e+09", "%g", +__LINE__, -1.738759937912438e-08, "-1.73876e-08", "%+2g", +__LINE__, -1.739320154069143e-18, "-0.0000", "%1.4f", +__LINE__, -1.739870415800800e+16, "-1.73987e+16", "%g", +__LINE__, -1.741290506928618e+04, "-17412.9", "%G", +__LINE__, -1.742520800031913e+29, "-1.742521e+29", "%7e", +__LINE__, -1.747620095195231e+01, "-2e+01", "%+2.g", +__LINE__, -1.749860675924882e-21, "-1.74986E-21", "%G", +__LINE__, -1.752675363661431e-06, "-1.7527E-06", "%.5G", +__LINE__, -1.752871508059699e-06, " -0", "%7.f", +__LINE__, -1.755178530989839e+25, "-1.7551785e+25", "%1.7e", +__LINE__, -1.755566213249512e-07, "-1.755566e-07", "%.6e", +__LINE__, -1.756193485005071e-24, "-1.75619E-24", "%+2.6G", +__LINE__, -1.758501410496218e+03, "-1758.501", "%.7G", +__LINE__, -1.758795617219102e+20, "-1.75880E+20", "%#6G", +__LINE__, -1.760538679276709e+03, "-2e+03", "%+1.e", +__LINE__, -1.762660914833003e+27, "-1.76266E+27", "%G", +__LINE__, -1.765122691141907e+19, "-17651226911419071186.1", "%5.1f", +__LINE__, -1.765313277389086e-18, "-2E-18", "%+1.E", +__LINE__, -1.765821717148734e+19, "-1.76582E+19", "%G", +__LINE__, -1.767048687863149e-17, "-1.77E-17", "%+.3G", +__LINE__, -1.768661645451962e+18, "-1.77E+18", "%+.3G", +__LINE__, -1.769753257452233e+01, "-17.6975", "%G", +__LINE__, -1.770945665065531e+28, "-1.770946E+28", "%0.7G", +__LINE__, -1.776713865753894e-09, "-2e-09", "%1.g", +__LINE__, -1.778424845787448e+03, "-1.7784E+03", "%.4E", +__LINE__, -1.779060610701250e+06, "-1.779061E+06", "%E", +__LINE__, -1.781447182110762e-27, "-1.781447E-27", "%E", +__LINE__, -1.782655842123784e-13, "-2.E-13", "%#2.1G", +__LINE__, -1.783071018169166e+16, "-17830710181691664.217851", "%+f", +__LINE__, -1.784665985294415e+25, "-2E+25", "%3.G", +__LINE__, -1.787297600658096e+25, "-2E+25", "%+5.E", +__LINE__, -1.788200250255718e+12, "-1.7882E+12", "%2.4E", +__LINE__, -1.792860730579114e-09, "-1.79286E-09", "%G", +__LINE__, -1.793122797100936e+24, "-1.793123e+24", "%e", +__LINE__, -1.793761706915029e-25, "-0.000000", "%f", +__LINE__, -1.793947567431932e+22, "-1.79395e+22", "%g", +__LINE__, -1.796428035404303e-18, "-1.79643e-18", "%g", +__LINE__, -1.797113144273918e-16, "-1.79711E-16", "%.6G", +__LINE__, -1.798796767828424e-29, "-1.7988E-29", "%G", +__LINE__, -1.805004010633763e-11, "-1.805e-11", "%2.5g", +__LINE__, -1.806936269752338e-26, "-1.80694e-26", "%g", +__LINE__, -1.807122541760172e-10, "-1.80712e-10", "%g", +__LINE__, -1.808295407815630e-06, "-1.8083E-06", "%+G", +__LINE__, -1.813893236685959e+15, "-1813893236685959", "%0.f", +__LINE__, -1.816201530145367e+06, "-1816202", "%+2.f", +__LINE__, -1.822811219123512e+13, "-1.82281e+13", "%g", +__LINE__, -1.826276499170243e-25, "-2E-25", "%+3.G", +__LINE__, -1.832399287433839e-26, "-1.832399E-26", "%#4E", +__LINE__, -1.833597815584463e-18, "-0.000000", "%+3f", +__LINE__, -1.834165532712233e+28, "-1.834166E+28", "%.7G", +__LINE__, -1.837633147831083e+28, "-1.8376331e+28", "%.7e", +__LINE__, -1.839756716742518e-01, "-0.2", "%+0.G", +__LINE__, -1.840101206950368e-14, "-1.840101E-14", "%+E", +__LINE__, -1.842043645474877e+17, "-1.84204e+17", "%+g", +__LINE__, -1.842155892969934e+17, "-1.84216e+17", "%+g", +__LINE__, -1.843566073012842e-25, "-1.84357E-25", "%G", +__LINE__, -1.843976321320497e-02, "-0.02", "%+4.2f", +__LINE__, -1.845299931651554e+11, "-1.8453E+11", "%0.4E", +__LINE__, -1.846199038659889e-06, "-1.8462e-06", "%0.5g", +__LINE__, -1.847062180184169e-30, "-1.847062E-30", "%5E", +__LINE__, -1.847962158722201e-16, "-0.000000", "%f", +__LINE__, -1.849446376756582e+15, "-1.8E+15", "%2.2G", +__LINE__, -1.853168465523878e-24, "-2E-24", "%1.E", +__LINE__, -1.853601367230139e+10, "-1.853601e+10", "%e", +__LINE__, -1.857367903775364e+18, "-1.86E+18", "%1.3G", +__LINE__, -1.858332820633906e-05, "-0.000019", "%7f", +__LINE__, -1.860243811657223e-23, "-1.860244e-23", "%e", +__LINE__, -1.860660612539794e+08, "-1.86066e+08", "%+6.5e", +__LINE__, -1.861160816251124e-09, "-2E-09", "%1.G", +__LINE__, -1.862380636974688e-25, "-1.9E-25", "%.2G", +__LINE__, -1.864168808453004e+15, "-1.86417E+15", "%G", +__LINE__, -1.864273144411246e+07, "-1.86427e+07", "%g", +__LINE__, -1.864929236615802e-02, "-2e-02", "%+3.e", +__LINE__, -1.865010503480847e+19, "-2E+19", "%4.G", +__LINE__, -1.866276374553144e+22, "-1.866276e+22", "%e", +__LINE__, -1.870809567910649e+09, "-1.870810e+09", "%e", +__LINE__, -1.872555495839008e-13, "-1.872555E-13", "%3E", +__LINE__, -1.874465717110388e-22, "-1.874466E-22", "%E", +__LINE__, -1.874916306627632e+21, "-1874916306627632422987.517202", "%f", +__LINE__, -1.875804322194491e-23, "-0.000000", "%+f", +__LINE__, -1.876662099198587e-04, "-0.000187666", "%G", +__LINE__, -1.876775504795760e-25, "-1.87678e-25", "%0g", +__LINE__, -1.879343051002554e-20, " -0.", "%#6.f", +__LINE__, -1.881535445774717e-15, "-1.881535e-15", "%e", +__LINE__, -1.887515901404300e+00, "-1.888", "%2.4G", +__LINE__, -1.887730637149009e+17, "-1.887731E+17", "%E", +__LINE__, -1.889920303480086e+17, "-1.889920e+17", "%+e", +__LINE__, -1.891903478784091e+04, "-1.891903e+04", "%e", +__LINE__, -1.893550084305833e+16, "-1.89355e+16", "%g", +__LINE__, -1.894675230197676e+05, "-1.894675e+05", "%#e", +__LINE__, -1.898389624953187e-27, "-1.898390e-27", "%+e", +__LINE__, -1.899250044644046e+21, "-1899250044644046120367.875119", "%+4.6f", +__LINE__, -1.904187609804679e-02, "-1.90419E-02", "%0.5E", +__LINE__, -1.904452538421193e-04, "-2e-04", "%4.0e", +__LINE__, -1.904615326969061e-16, "-1.904615e-16", "%1.7g", +__LINE__, -1.907761255064750e+02, "-190.776126", "%f", +__LINE__, -1.910727641826707e-10, " -2e-10", "%7.g", +__LINE__, -1.913149279262051e+15, "-1.913149e+15", "%.7g", +__LINE__, -1.913235739298009e+28, "-1.913236e+28", "%e", +__LINE__, -1.913526822735271e+18, "-1.914e+18", "%.4g", +__LINE__, -1.913780977515583e+17, "-191378097751558335.9150", "%5.4f", +__LINE__, -1.917095456962182e-10, "-2E-10", "%4.G", +__LINE__, -1.918803033972851e+23, "-191880303397285132405158.947222", "%f", +__LINE__, -1.926420984801848e+16, "-19264209848018483.128840", "%+f", +__LINE__, -1.931905465942639e-10, "-1.93191e-10", "%g", +__LINE__, -1.932907105840252e+06, "-1.932907e+06", "%+#e", +__LINE__, -1.933091601918916e+15, "-1.933092E+15", "%#E", +__LINE__, -1.934296184983361e+09, "-1.9343e+09", "%1.6g", +__LINE__, -1.934637311832448e+11, "-1.93464e+11", "%+g", +__LINE__, -1.936201483262186e+12, "-2e+12", "%+6.g", +__LINE__, -1.939114661603911e+19, "-1.93911E+19", "%G", +__LINE__, -1.940478182124347e-13, "-0.000000", "%f", +__LINE__, -1.943218220654923e+08, "-2E+08", "%+5.0G", +__LINE__, -1.943526872455779e-30, "-1.9E-30", "%.1E", +__LINE__, -1.949869164681357e+19, "-1.949869e+19", "%#3e", +__LINE__, -1.954181060535402e+23, "-1.954181e+23", "%e", +__LINE__, -1.961581555579142e+14, "-1.962E+14", "%.3E", +__LINE__, -1.964535562036915e+07, "-1.96454E+07", "%G", +__LINE__, -1.969749653575926e+04, "-19697.5", "%.6g", +__LINE__, -1.973475369169053e+15, "-1.97348e+15", "%g", +__LINE__, -1.975658532866600e-21, "-2e-21", "%+1.2g", +__LINE__, -1.984050343831260e+09, "-1.984050E+09", "%E", +__LINE__, -1.984422410018571e+12, "-1.984422e+12", "%+4.7g", +__LINE__, -1.984878687667223e-22, "-0.000000", "%f", +__LINE__, -1.986116930967811e-28, "-1.98612e-28", "%g", +__LINE__, -1.986774457812683e+02, "-1.986774e+02", "%e", +__LINE__, -1.987274814938726e-04, "-0.000198727", "%g", +__LINE__, -1.987319200580415e+10, "-1.987319E+10", "%E", +__LINE__, -1.987980768698114e-19, "-0.000000", "%3f", +__LINE__, -1.994698965044602e-29, "-2E-29", "%+4.0G", +__LINE__, -1.997833122667050e+26, "-1.99783E+26", "%G", +__LINE__, -1.999453681184129e-10, "-0.00000", "%.5f", +__LINE__, -1.999897345839745e-16, "-1.9999e-16", "%g", +__LINE__, -2.003703825123989e-22, "-0.000000", "%f", +__LINE__, -2.004569188274957e-23, "-2.00457E-23", "%G", +__LINE__, -2.005911883189058e+07, "-2.00591E+07", "%G", +__LINE__, -2.006438312005722e-25, "-2.006e-25", "%0.4g", +__LINE__, -2.017322171210280e+18, "-2.01732E+18", "%+0G", +__LINE__, -2.017718635819594e-06, "-2.01772e-06", "%5g", +__LINE__, -2.019187445568160e-12, "-0.00", "%.2f", +__LINE__, -2.021022665608503e+25, "-20210226656085028551501636.684", "%2.3f", +__LINE__, -2.022720393474145e+07, "-2.02272E+07", "%#G", +__LINE__, -2.024506694471065e+23, "-2.02451E+23", "%G", +__LINE__, -2.024884686553821e-15, " -2e-15", "%7.g", +__LINE__, -2.027484636128966e-23, "-2.0275E-23", "%.5G", +__LINE__, -2.028185530467237e+21, "-2028185530467237374097.067", "%+4.3f", +__LINE__, -2.028388905566873e-09, "-0.000000", "%f", +__LINE__, -2.029856507431584e-17, "-2.02986E-17", "%G", +__LINE__, -2.029891733449167e+27, "-2029891733449166846270372843.7190875", "%3.7f", +__LINE__, -2.031933616694469e+14, "-2.031934E+14", "%#E", +__LINE__, -2.034011738471413e-10, "-2.03401E-10", "%#G", +__LINE__, -2.036087355975756e+29, "-203608735597575574161055556032.806635", "%+f", +__LINE__, -2.036355025137273e+09, "-2.036355E+09", "%#.7G", +__LINE__, -2.038423730536878e+12, "-2E+12", "%4.G", +__LINE__, -2.045209202278810e+23, "-2.045209e+23", "%+#e", +__LINE__, -2.046794083517423e-06, "-2.04679e-06", "%g", +__LINE__, -2.048042459678599e-19, "-0.000000", "%f", +__LINE__, -2.050526462096153e+18, "-2.05053e+18", "%+g", +__LINE__, -2.053583900249402e+13, "-2.053584e+13", "%0.7g", +__LINE__, -2.054342100957522e-23, "-2.05434E-23", "%#G", +__LINE__, -2.054793400141025e+11, "-205479340014.1", "%+2.1f", +__LINE__, -2.059200689196498e-11, "-0.000000", "%#f", +__LINE__, -2.060960692728114e-16, "-0.000000", "%+f", +__LINE__, -2.061417528654300e-30, "-2.06E-30", "%.3G", +__LINE__, -2.061513401198340e-29, "-2.06151e-29", "%7g", +__LINE__, -2.061846698845984e+27, "-2.061847E+27", "%E", +__LINE__, -2.063922242876789e-19, "-2.06392e-19", "%#g", +__LINE__, -2.065359431805529e+03, "-2065.359432", "%f", +__LINE__, -2.065529069992156e-04, "-0.000206553", "%+G", +__LINE__, -2.066082546490980e-25, "-2.06608e-25", "%5g", +__LINE__, -2.068394312095200e+17, "-2.068394e+17", "%e", +__LINE__, -2.071024178556425e-10, "-2.07102E-10", "%G", +__LINE__, -2.074401605950382e-22, "-2.07e-22", "%1.3g", +__LINE__, -2.074731895144874e-26, "-2.07473E-26", "%G", +__LINE__, -2.074895800882730e+18, "-2074895800882730068.082083", "%+f", +__LINE__, -2.077336220500764e-30, "-0", "%2.f", +__LINE__, -2.078067878561077e+09, "-2.0781e+09", "%0.5g", +__LINE__, -2.080497889634533e+15, "-2.080498E+15", "%4E", +__LINE__, -2.084717279367594e-21, "-2.08472e-21", "%+g", +__LINE__, -2.087827915301948e+29, "-2E+29", "%6.1G", +__LINE__, -2.090268686389680e+05, "-2.090269e+05", "%1e", +__LINE__, -2.092036176589720e+24, "-2.09204e+24", "%+g", +__LINE__, -2.093546373938615e-21, "-2.093546e-21", "%#e", +__LINE__, -2.101302069316682e+18, "-2.1013e+18", "%+7g", +__LINE__, -2.103463622286002e-13, "-2.103464E-13", "%E", +__LINE__, -2.105622845016732e+06, "-2105622.845017", "%1f", +__LINE__, -2.109999123037767e+28, "-2.11E+28", "%.2E", +__LINE__, -2.110317013992166e+04, "-21103.2", "%+g", +__LINE__, -2.112226142154618e+21, "-2112226142154617569702.", "%#6.f", +__LINE__, -2.112519484486528e+06, "-2.11252E+06", "%G", +__LINE__, -2.113439260812000e+23, "-2E+23", "%1.G", +__LINE__, -2.113465893194608e-15, "-2.1135E-15", "%.5G", +__LINE__, -2.113547784669409e+20, "-2.1135e+20", "%2.5g", +__LINE__, -2.114146001321822e+28, "-2.114146e+28", "%e", +__LINE__, -2.114509425574444e-30, " -0", "%4.f", +__LINE__, -2.114887421659561e-21, "-0.000000", "%+f", +__LINE__, -2.121120215127601e+21, "-2121120215127601404958.5683097", "%.7f", +__LINE__, -2.122555390665796e+06, "-2E+06", "%0.G", +__LINE__, -2.123468430242052e-27, "-0.000000", "%+f", +__LINE__, -2.123473598890635e+28, "-2.12347e+28", "%+g", +__LINE__, -2.124328049748190e-04, "-2.124328E-04", "%E", +__LINE__, -2.125633890999010e+28, "-2E+28", "%+5.G", +__LINE__, -2.125697963566045e+21, "-2.1257E+21", "%0G", +__LINE__, -2.127638109230109e+06, "-2.12764e+06", "%+6g", +__LINE__, -2.128456114617786e+07, "-2.128456E+07", "%E", +__LINE__, -2.128732742932824e-04, "-2.128733E-04", "%#E", +__LINE__, -2.129654381588404e+27, "-2129654381588404365999167566.7697564", "%+.7f", +__LINE__, -2.129792795009985e+20, "-2.12979e+20", "%g", +__LINE__, -2.131026925664619e-20, "-2e-20", "%.0e", +__LINE__, -2.132860730144188e-04, "-0.0002", "%5.g", +__LINE__, -2.133620979309562e+06, "-2e+06", "%3.e", +__LINE__, -2.133821423139120e-27, "-2.13382E-27", "%.6G", +__LINE__, -2.134253401425940e-07, "-0.000000", "%f", +__LINE__, -2.135469568156964e-29, "-2.135470E-29", "%+7E", +__LINE__, -2.135723595288365e-25, "-0.0", "%.1f", +__LINE__, -2.137642458920094e-09, "-2.13764e-09", "%g", +__LINE__, -2.143412361116583e+12, "-2.14341e+12", "%+g", +__LINE__, -2.144467087741129e-17, "-2.14447e-17", "%+g", +__LINE__, -2.145726966596964e-11, "-0.000000", "%2f", +__LINE__, -2.148318753042597e+08, "-2.14832E+08", "%5G", +__LINE__, -2.149932310549644e-19, "-2.14993e-19", "%g", +__LINE__, -2.150050917377646e-21, " -0", "%3.f", +__LINE__, -2.150854313643430e-16, "-0.000000", "%.6f", +__LINE__, -2.151071797121845e+00, "-2.15107", "%+g", +__LINE__, -2.158728406865981e+14, "-215872840686598.088666", "%7f", +__LINE__, -2.166062878011641e-23, "-2.166063e-23", "%e", +__LINE__, -2.167045002060684e+12, "-2.167045E+12", "%E", +__LINE__, -2.173752581051530e+20, "-217375258105153035259.604621", "%f", +__LINE__, -2.175599129057555e+24, "-2.175599E+24", "%E", +__LINE__, -2.176564454093042e-02, "-0.0217656", "%+G", +__LINE__, -2.181270774327071e-12, "-0.000000", "%#1f", +__LINE__, -2.184404769844158e-09, "-2.2E-09", "%+.2G", +__LINE__, -2.184881476334310e-07, "-2.18488e-07", "%g", +__LINE__, -2.189197211449684e-11, "-2E-11", "%.0G", +__LINE__, -2.189451286805190e+20, "-218945128680519029984", "%3.f", +__LINE__, -2.190642494146884e-27, " -0.", "%#4.f", +__LINE__, -2.194727956725854e+06, "-2.19E+06", "%.3G", +__LINE__, -2.196145868303877e+11, "-219614586830.387726", "%+5f", +__LINE__, -2.196397972262690e-16, "-0.000000", "%3f", +__LINE__, -2.202692843474668e-01, "-2.203e-01", "%.3e", +__LINE__, -2.204528684782451e-21, "-2.20453E-21", "%G", +__LINE__, -2.214926838821340e-16, "-2e-16", "%+2.g", +__LINE__, -2.215558986352773e+18, "-2215558986352773374", "%0.f", +__LINE__, -2.216976693056186e+27, "-2216976693056186498154147557.215765", "%f", +__LINE__, -2.217348422793322e+13, "-2.21735E+13", "%6G", +__LINE__, -2.217732695583920e-07, "-0", "%.0f", +__LINE__, -2.221185494767834e-14, "-2.22119e-14", "%g", +__LINE__, -2.224557193699609e-16, "-2.224557E-16", "%E", +__LINE__, -2.227417758704028e-18, "-0.000000", "%0f", +__LINE__, -2.231261655673006e-30, "-2.231262E-30", "%E", +__LINE__, -2.233081938836160e+21, "-2233081938836160240668.960", "%+6.3f", +__LINE__, -2.233158918439853e+05, "-223316", "%2G", +__LINE__, -2.233802298007898e-30, "-2.2338E-30", "%2G", +__LINE__, -2.233864858404732e+17, "-223386485840473181.241350", "%f", +__LINE__, -2.241242805107749e+14, "-2.24124E+14", "%G", +__LINE__, -2.244555498855249e+25, "-2.24456E+25", "%#G", +__LINE__, -2.248170665127481e-07, "-2.248171E-07", "%E", +__LINE__, -2.252558275567388e-13, "-2.25256e-13", "%g", +__LINE__, -2.256190083496001e+13, "-22561900834960.0136398", "%7.7f", +__LINE__, -2.259851596715945e+27, "-2.259852e+27", "%e", +__LINE__, -2.260461480001174e-21, "-0.000000", "%f", +__LINE__, -2.264128628428577e+22, "-2.26413e+22", "%1g", +__LINE__, -2.265914518399595e-04, "-0.000226591", "%G", +__LINE__, -2.266251557092826e+23, "-2.26625e+23", "%g", +__LINE__, -2.268592252572450e+19, "-2.268592e+19", "%2.6e", +__LINE__, -2.268597523847349e+11, "-2.2686e+11", "%g", +__LINE__, -2.268963106935546e+05, "-226896", "%+g", +__LINE__, -2.272527876808919e-24, "-0.000000", "%#f", +__LINE__, -2.273366440479073e+02, "-227.337", "%g", +__LINE__, -2.277858038556191e+25, "-2.28E+25", "%0.3G", +__LINE__, -2.282019915623415e+25, "-2E+25", "%5.E", +__LINE__, -2.283333247435650e-27, " -0", "%4.f", +__LINE__, -2.285230610829355e+23, "-2E+23", "%2.G", +__LINE__, -2.290900253402985e+23, "-2.2909E+23", "%G", +__LINE__, -2.293266953268186e+08, "-2.29327e+08", "%g", +__LINE__, -2.293489603164786e+23, "-229348960316478578391752.3076525", "%4.7f", +__LINE__, -2.294434667605481e+15, "-2.2944E+15", "%.5G", +__LINE__, -2.296607768466765e+21, "-2.29661E+21", "%G", +__LINE__, -2.297449967994012e+14, "-229744996799401.23542", "%+.5f", +__LINE__, -2.301162556466583e-01, "-0.230116", "%+#2g", +__LINE__, -2.301676246374004e+05, "-230168.", "%#g", +__LINE__, -2.301976724487835e-01, "-0.230198", "%5G", +__LINE__, -2.303269770571222e-15, "-2.303270e-15", "%.6e", +__LINE__, -2.306451480495636e+23, "-2.30645E+23", "%G", +__LINE__, -2.307659351219690e-17, "-0.000000", "%+3f", +__LINE__, -2.309009762339430e+16, "-2.30901E+16", "%G", +__LINE__, -2.309261751862100e+06, "-2309261.751862", "%+f", +__LINE__, -2.309504876918634e-26, " -2E-26", "%7.E", +__LINE__, -2.310910348147804e-26, "-2e-26", "%5.g", +__LINE__, -2.317173552252235e+05, "-231717.4", "%.7g", +__LINE__, -2.319517289618469e-23, "-2.31952E-23", "%+G", +__LINE__, -2.320103195142527e+08, "-2.320103E+08", "%+E", +__LINE__, -2.323523032125633e+24, "-2323523032125633491773442.07419", "%.5f", +__LINE__, -2.326279126614399e-16, "-0.000000", "%f", +__LINE__, -2.331393688620925e-09, "-2.33139e-09", "%#g", +__LINE__, -2.334233527512469e+01, " -23", "%6.0f", +__LINE__, -2.337418834112767e+24, " -2E+24", "%7.E", +__LINE__, -2.339455293612118e+12, "-2339455293612.1", "%+.1f", +__LINE__, -2.341930318143367e-18, "-2.E-18", "%#4.E", +__LINE__, -2.346107614950921e-17, "-0.00000", "%+2.5f", +__LINE__, -2.348356578807972e+23, "-2.34836e+23", "%g", +__LINE__, -2.351485855138244e+19, "-2.351486e+19", "%+e", +__LINE__, -2.362101647639198e-15, "-2.36210e-15", "%#g", +__LINE__, -2.369743873030115e+08, "-2e+08", "%.1g", +__LINE__, -2.371658164739356e+25, "-23716581647393559784120498.079574", "%f", +__LINE__, -2.372427847607163e+28, "-2.37243E+28", "%G", +__LINE__, -2.375465465294647e+11, "-2.375465e+11", "%e", +__LINE__, -2.377128971572195e-18, "-0.0", "%1.1f", +__LINE__, -2.380322448568089e-13, "-2.38032E-13", "%+#0G", +__LINE__, -2.385960728264882e+26, "-2E+26", "%.0E", +__LINE__, -2.387345744004747e+00, "-2.38735", "%G", +__LINE__, -2.390480023300201e+25, "-2.39048e+25", "%g", +__LINE__, -2.395420431930886e+23, "-2E+23", "%2.E", +__LINE__, -2.401144663870969e-10, "-2.e-10", "%#6.g", +__LINE__, -2.402787441215039e-08, "-2.40279e-08", "%g", +__LINE__, -2.402990830425278e+08, "-2.40299E+08", "%G", +__LINE__, -2.404213682932215e+08, "-2.40421e+08", "%2g", +__LINE__, -2.409385592298822e+21, "-2409385592298821876511.283335", "%7f", +__LINE__, -2.410798267658614e+13, "-2.4108e+13", "%+g", +__LINE__, -2.413180068271811e-24, "-0.000000", "%+f", +__LINE__, -2.413268457113495e+26, "-2.41327E+26", "%3.6G", +__LINE__, -2.415341832206007e-13, "-0.000000", "%+f", +__LINE__, -2.422519577068670e-08, "-0.0000000", "%.7f", +__LINE__, -2.422533651282808e+20, "-2.42253E+20", "%#G", +__LINE__, -2.422795006880671e+17, "-2.4228e+17", "%g", +__LINE__, -2.423483330202008e+20, "-2.42348e+20", "%g", +__LINE__, -2.431756009640369e-04, "-0.000243176", "%+#3g", +__LINE__, -2.431878622534173e-05, "-0.000024", "%f", +__LINE__, -2.432012113077180e+24, "-2.43201e+24", "%g", +__LINE__, -2.433843704470487e+07, "-24338437", "%4.f", +__LINE__, -2.435475755031956e+11, "-2.435476E+11", "%1E", +__LINE__, -2.438081888695437e-13, "-0.000000", "%f", +__LINE__, -2.438334590462860e+10, "-2.4E+10", "%5.2G", +__LINE__, -2.440223135334059e+17, "-2.44022e+17", "%g", +__LINE__, -2.444107281115317e-21, "-2.44411e-21", "%+g", +__LINE__, -2.444582273206171e-02, " -0.02", "%7.G", +__LINE__, -2.445234676352794e+23, "-2.44523e+23", "%#g", +__LINE__, -2.449185020984714e+08, "-2.E+08", "%#2.G", +__LINE__, -2.450646640466020e+22, "-2.45065E+22", "%5G", +__LINE__, -2.456840850262473e+13, "-24568408502625", "%0.f", +__LINE__, -2.464466865714499e-10, "-2e-10", "%6.g", +__LINE__, -2.466022088999151e+27, "-2.46602E+27", "%G", +__LINE__, -2.484398113119779e-04, "-2.484398E-04", "%E", +__LINE__, -2.484591850456328e+23, "-248459185045632846566832.085955", "%+f", +__LINE__, -2.488166252162446e-11, "-2.5E-11", "%4.2G", +__LINE__, -2.493507313049390e+24, "-2.49E+24", "%4.3G", +__LINE__, -2.500280281988428e+28, "-2.5E+28", "%.4G", +__LINE__, -2.500373956445372e-07, "-2.50037e-07", "%g", +__LINE__, -2.505566434769299e-12, "-2.5E-12", "%+#0.2G", +__LINE__, -2.508215917020758e+05, "-2.508216e+05", "%5e", +__LINE__, -2.519368094680315e-29, "-2.51937e-29", "%#0g", +__LINE__, -2.522266530587753e-11, "-2.52227e-11", "%+g", +__LINE__, -2.534492886372514e-06, "-2.53449E-06", "%0G", +__LINE__, -2.534617610955074e-02, "-0.03", "%0.2f", +__LINE__, -2.540551642835634e+26, "-3E+26", "%4.G", +__LINE__, -2.548210731830516e-26, "-0.000", "%2.3f", +__LINE__, -2.558868082397931e-11, "-3E-11", "%2.E", +__LINE__, -2.560062512991052e+11, "-2.56006E+11", "%+G", +__LINE__, -2.561274682814428e-05, "-0.000026", "%f", +__LINE__, -2.563424949397357e-02, " -0", "%6.f", +__LINE__, -2.577010939931465e+17, "-2.57701E+17", "%G", +__LINE__, -2.578224879294822e+10, "-3E+10", "%+4.1G", +__LINE__, -2.585655636750244e+13, "-2.585656e+13", "%+0.7g", +__LINE__, -2.585657986834408e+14, "-2.5857e+14", "%3.5g", +__LINE__, -2.586728929368101e+02, "-258.673", "%+g", +__LINE__, -2.591293023229468e+06, "-2591293.0232295", "%2.7f", +__LINE__, -2.592454222603538e-06, "-2.59245E-06", "%G", +__LINE__, -2.599399905869649e+02, "-259.939991", "%f", +__LINE__, -2.605382860307596e+12, "-2.60538E+12", "%2G", +__LINE__, -2.607507689402762e-01, "-0.260751", "%#.6g", +__LINE__, -2.612933252582967e+15, "-2.61293e+15", "%g", +__LINE__, -2.614337505491483e-14, "-2.61434E-14", "%.6G", +__LINE__, -2.618302263333671e+14, "-2.62e+14", "%3.3g", +__LINE__, -2.622998533972296e+00, "-3.", "%#0.g", +__LINE__, -2.623348319869643e-15, "-2.62335E-15", "%#G", +__LINE__, -2.626703132693163e+23, "-3E+23", "%+6.E", +__LINE__, -2.629610853765779e+25, "-2.62961E+25", "%+#G", +__LINE__, -2.632993880472784e+26, "-2.63299E+26", "%G", +__LINE__, -2.635651112327873e-20, "-2.63565E-20", "%1G", +__LINE__, -2.636003980473492e-23, "-2.636E-23", "%G", +__LINE__, -2.639316453244009e+10, "-26393164532.440094", "%#f", +__LINE__, -2.640517223417942e-28, "-2.641e-28", "%.3e", +__LINE__, -2.640625797147664e-22, "-2.640626E-22", "%E", +__LINE__, -2.644401262524378e-12, " -0.000", "%7.3f", +__LINE__, -2.651033203243637e-14, "-2.651033e-14", "%+e", +__LINE__, -2.652386470126594e-24, "-2.652386E-24", "%E", +__LINE__, -2.654281018623631e-12, "-0.00000", "%6.5f", +__LINE__, -2.655529742118827e+02, "-265.552974", "%f", +__LINE__, -2.658550833241620e+22, "-26585508332416196708436.473273", "%+f", +__LINE__, -2.660515890519100e+08, "-2.660516E+08", "%E", +__LINE__, -2.665025749266086e-24, "-2.66503E-24", "%G", +__LINE__, -2.666117105643095e-20, "-2.66612e-20", "%g", +__LINE__, -2.667051347741259e+11, "-3e+11", "%6.g", +__LINE__, -2.667207607243375e+04, "-26672.076072", "%+#f", +__LINE__, -2.667631877167590e+26, "-2.667632E+26", "%E", +__LINE__, -2.673817942962878e+13, "-2.673818e+13", "%+2.6e", +__LINE__, -2.674972907853507e+20, "-2.674973E+20", "%E", +__LINE__, -2.675830887404867e+14, "-2.675831E+14", "%E", +__LINE__, -2.682749918168908e+26, "-2.682750E+26", "%E", +__LINE__, -2.689222801942679e-03, "-0.0027", "%7.2G", +__LINE__, -2.692245629411156e+25, "-2.69225e+25", "%g", +__LINE__, -2.692606702464273e+11, "-2.69261e+11", "%g", +__LINE__, -2.693070822061136e-27, "-2.69307e-27", "%+g", +__LINE__, -2.694415515655336e-30, "-3E-30", "%+3.0E", +__LINE__, -2.694770057384739e+15, "-2.69477e+15", "%g", +__LINE__, -2.699998392329361e+01, "-27", "%+.2g", +__LINE__, -2.700151952281511e+23, "-270015195228151050343968.", "%+#5.f", +__LINE__, -2.707398527302841e-08, "-2.70740e-08", "%+#3g", +__LINE__, -2.711404950850030e-21, "-2.71E-21", "%.2E", +__LINE__, -2.714057739024281e-10, "-2.714e-10", "%.4g", +__LINE__, -2.717657632815414e-10, "-2.71766e-10", "%g", +__LINE__, -2.720875786430592e-09, "-2.7E-09", "%6.2G", +__LINE__, -2.725886730997891e+19, "-2.72589e+19", "%g", +__LINE__, -2.726089169748676e-09, "-2.72609E-09", "%+G", +__LINE__, -2.732907572038661e-30, "-2.73291E-30", "%G", +__LINE__, -2.737918050958789e+11, "-3e+11", "%1.g", +__LINE__, -2.739024251198484e-18, "-2.73902e-18", "%+g", +__LINE__, -2.742646144452305e+13, "-2.74265e+13", "%g", +__LINE__, -2.742911865386719e+06, "-3E+06", "%+5.G", +__LINE__, -2.759159275123811e-30, "-0.000000", "%+f", +__LINE__, -2.759794813930001e-21, "-2.75979e-21", "%+g", +__LINE__, -2.763243077558348e+20, "-2.7632E+20", "%+0.4E", +__LINE__, -2.770348477810209e-14, "-0.000000", "%2f", +__LINE__, -2.776074766292453e+05, "-277607", "%g", +__LINE__, -2.776610811432007e-07, "-2.77661E-07", "%6G", +__LINE__, -2.778673793270678e+23, "-3E+23", "%+4.E", +__LINE__, -2.782405168708350e+08, "-278240516.87084", "%.5f", +__LINE__, -2.783316149365198e-09, "-3E-09", "%5.0G", +__LINE__, -2.785436703085409e-27, "-2.78544E-27", "%#G", +__LINE__, -2.787479051660640e+21, "-2.78748e+21", "%g", +__LINE__, -2.789445406042450e-03, "-0.002789", "%+f", +__LINE__, -2.791104581836077e+05, "-279110.4581836", "%+7.7f", +__LINE__, -2.802078617775784e+04, "-28020.786", "%0.3f", +__LINE__, -2.804954315579055e+20, "-2.80495E+20", "%G", +__LINE__, -2.806575341862696e-05, "-2.80658E-05", "%G", +__LINE__, -2.807769556900402e-06, "-0.000003", "%+#f", +__LINE__, -2.808882056357941e-12, "-0.0", "%.1f", +__LINE__, -2.809386677339924e+10, "-2.8094E+10", "%6.5G", +__LINE__, -2.818404311437694e+19, "-3E+19", "%6.G", +__LINE__, -2.819463285551660e+01, "-28.1946", "%+G", +__LINE__, -2.821428853207724e-16, "-3e-16", "%6.g", +__LINE__, -2.824452750788444e+07, "-3e+07", "%+2.g", +__LINE__, -2.825430381094971e+28, "-3e+28", "%+.0e", +__LINE__, -2.830010928384944e-17, "-0", "%.0f", +__LINE__, -2.832505114479680e-09, "-0.000000", "%f", +__LINE__, -2.833246604950796e+13, "-2.83325E+13", "%G", +__LINE__, -2.833274073265017e+13, "-28332740732650.174564", "%f", +__LINE__, -2.835842581787797e+07, "-2.83584E+07", "%2G", +__LINE__, -2.839758384681983e-07, "-2.83976E-07", "%.6G", +__LINE__, -2.841077022753766e-09, "-3E-09", "%0.1G", +__LINE__, -2.845307294930682e+00, "-2.845307e+00", "%+1e", +__LINE__, -2.847420163874243e+19, "-2.8e+19", "%1.2g", +__LINE__, -2.848133715109881e-25, "-2.848134E-25", "%E", +__LINE__, -2.850208101288058e-06, "-2.8502E-06", "%+5.4E", +__LINE__, -2.853666525870413e+04, "-28536.665259", "%f", +__LINE__, -2.855661543202034e+21, "-2.85566e+21", "%g", +__LINE__, -2.859528889324159e-08, "-2.859529e-08", "%3e", +__LINE__, -2.860545310690251e+29, "-3e+29", "%.1g", +__LINE__, -2.863576633666884e-14, "-2.863577e-14", "%+5e", +__LINE__, -2.864115740396321e-14, "-2.86412e-14", "%g", +__LINE__, -2.864481979037153e+20, "-2.86E+20", "%3.3G", +__LINE__, -2.867582970177984e-18, "-0.000000", "%f", +__LINE__, -2.868237707901564e+25, "-3E+25", "%6.E", +__LINE__, -2.871741071402520e+13, "-3e+13", "%.1g", +__LINE__, -2.873724610073364e+18, "-2873724610073364438.278531", "%+#f", +__LINE__, -2.876433859770866e-25, "-2.87643e-25", "%g", +__LINE__, -2.877458587075737e-08, "-2.877E-08", "%+.4G", +__LINE__, -2.883349842927101e+24, "-2.883350E+24", "%2E", +__LINE__, -2.883749925642885e+09, "-2.883750e+09", "%e", +__LINE__, -2.883773835633003e-17, "-0.000000", "%+f", +__LINE__, -2.890389090491409e+24, "-2890389090491409262995148.310438", "%#1f", +__LINE__, -2.900848552225810e-11, "-0.000000", "%+f", +__LINE__, -2.911942123176400e+25, "-29119421231764004431852300", "%0.f", +__LINE__, -2.912904462180751e-18, "-2.9129E-18", "%6G", +__LINE__, -2.917717875075651e+26, "-3e+26", "%0.e", +__LINE__, -2.922293201084093e-26, "-2.922293E-26", "%E", +__LINE__, -2.925070319932451e-30, "-0.000000", "%f", +__LINE__, -2.926558572870874e+15, "-2.926559E+15", "%E", +__LINE__, -2.928781435877896e+26, "-2.928781e+26", "%+e", +__LINE__, -2.930178318110376e+28, "-2.930178E+28", "%E", +__LINE__, -2.930984661925819e+05, "-293098.5", "%.7G", +__LINE__, -2.932762424932762e-08, "-0.000000", "%#f", +__LINE__, -2.933415597492494e+10, "-29334155974.924943", "%+#2f", +__LINE__, -2.933564314850986e+29, "-2.93356E+29", "%7G", +__LINE__, -2.943224907893795e+10, "-2.943225E+10", "%+7E", +__LINE__, -2.945311540471221e+19, "-2.94531E+19", "%#G", +__LINE__, -2.945812356522847e+15, "-2.94581e+15", "%+g", +__LINE__, -2.945836999630957e+00, "-2.945837E+00", "%E", +__LINE__, -2.947798782726622e-01, "-0.29478", "%+g", +__LINE__, -2.948958405827917e+18, "-2.94896e+18", "%g", +__LINE__, -2.949790871798059e-11, "-2.94979E-11", "%G", +__LINE__, -2.950347806125225e-12, "-2.95035e-12", "%g", +__LINE__, -2.952781884599368e-29, "-2.952782E-29", "%+E", +__LINE__, -2.956801341442716e+06, "-2.9568E+06", "%G", +__LINE__, -2.957469310356540e-07, "-0.000", "%1.3f", +__LINE__, -2.960464869534870e-23, "-2.96046E-23", "%G", +__LINE__, -2.962339381825446e-07, "-0", "%1.f", +__LINE__, -2.971013180028710e+22, "-2.971e+22", "%3.5g", +__LINE__, -2.975167862441254e+07, "-2.97517e+07", "%g", +__LINE__, -2.976018424339993e+16, "-2.976018e+16", "%3e", +__LINE__, -2.979173094835454e+29, "-2.97917E+29", "%G", +__LINE__, -2.983135249987541e-03, "-0.00298314", "%+G", +__LINE__, -2.985142444917919e-24, "-2.985142E-24", "%+#7E", +__LINE__, -2.988680953635159e-14, "-0.0000000", "%2.7f", +__LINE__, -2.989629778079379e+04, "-29896.297781", "%f", +__LINE__, -2.991274275137276e+19, "-29912742751372762839.423558", "%+4f", +__LINE__, -2.991286396006024e-06, "-2.99129e-06", "%4g", +__LINE__, -2.993310397844811e+04, "-2.993310E+04", "%3.6E", +__LINE__, -2.994669852410861e-29, "-2.99467E-29", "%G", +__LINE__, -2.996082093034831e+27, "-2.996082e+27", "%1e", +__LINE__, -2.999783904575110e+16, "-2.999784E+16", "%#E", +__LINE__, -3.012019221956988e+25, "-3.012019E+25", "%E", +__LINE__, -3.014211917706622e-25, "-0.000000", "%+f", +__LINE__, -3.015149723683428e-19, "-3.01515E-19", "%G", +__LINE__, -3.022158478004638e-19, "-3.02216e-19", "%6g", +__LINE__, -3.022825518373900e-12, "-3.0228E-12", "%+.4E", +__LINE__, -3.025108924057340e-19, "-0.000000", "%f", +__LINE__, -3.026316824631967e+24, "-3026316824631966717618070.106255", "%1f", +__LINE__, -3.033074643529623e-13, "-3.03307e-13", "%g", +__LINE__, -3.035292960731141e+24, "-3035292960731141409524980.190326", "%f", +__LINE__, -3.043291272956732e-13, "-3.04329e-13", "%#g", +__LINE__, -3.045216723973715e-23, "-3.045e-23", "%.4g", +__LINE__, -3.047140976048835e+09, "-3.04714E+09", "%3.5E", +__LINE__, -3.047680278470886e+09, "-3.047680E+09", "%#E", +__LINE__, -3.048465807963461e+05, "-304847", "%g", +__LINE__, -3.050904753556756e+22, "-3.0509E+22", "%G", +__LINE__, -3.052845748999047e-13, "-3.05285e-13", "%g", +__LINE__, -3.053395231883620e-06, "-3E-06", "%2.G", +__LINE__, -3.054894203375445e-28, "-3e-28", "%2.g", +__LINE__, -3.055080347760755e-13, "-0", "%2.f", +__LINE__, -3.055513037393624e-29, "-3e-29", "%3.g", +__LINE__, -3.056198778208295e-06, "-3.0562e-06", "%g", +__LINE__, -3.057813660266980e-21, "-3E-21", "%1.G", +__LINE__, -3.059687036330998e-11, "-3.1E-11", "%#2.2G", +__LINE__, -3.061450385559094e-10, "-3.06145E-10", "%G", +__LINE__, -3.066605713361383e-27, "-0.000000", "%f", +__LINE__, -3.071590110813156e+22, "-3.07159E+22", "%G", +__LINE__, -3.073253864426931e+26, "-3.0733E+26", "%.5G", +__LINE__, -3.078998328596940e+07, "-3.079e+07", "%5.4g", +__LINE__, -3.082733887951920e+06, "-3.082734e+06", "%+6e", +__LINE__, -3.084365358064710e+24, "-3.084365E+24", "%#E", +__LINE__, -3.086948022123716e+25, "-30869480221237162176350921.072299", "%+f", +__LINE__, -3.088200214218024e-10, "-0", "%0.f", +__LINE__, -3.093442983942874e+08, "-309344298.394287", "%f", +__LINE__, -3.103573455403534e-09, "-3.103573E-09", "%#E", +__LINE__, -3.109178443120997e+07, "-31091784.431210", "%f", +__LINE__, -3.111494549914917e+28, "-3e+28", "%0.g", +__LINE__, -3.113384020517480e-17, " -0", "%+6.f", +__LINE__, -3.121622779718055e+14, "-312162277971805.491", "%+.3f", +__LINE__, -3.122780443843900e-01, "-0.312278", "%#g", +__LINE__, -3.122952438335638e-25, "-3.122952E-25", "%E", +__LINE__, -3.128970339463168e-18, "-3e-18", "%3.g", +__LINE__, -3.130862507719335e+10, "-3.130863e+10", "%3e", +__LINE__, -3.145960838955379e+03, "-3145.96", "%g", +__LINE__, -3.149362645138929e+21, "-3.14936e+21", "%g", +__LINE__, -3.150697168664913e+26, "-315069716866491322804222363.629378", "%+f", +__LINE__, -3.157946785041287e+05, "-3.1579e+05", "%.4e", +__LINE__, -3.158347006986809e-02, "-3.E-02", "%#.0E", +__LINE__, -3.159542871923388e+07, "-31595429", "%2.f", +__LINE__, -3.169997512351985e+15, "-3.169998E+15", "%6.7G", +__LINE__, -3.170971776544746e+07, "-31709717.765447", "%f", +__LINE__, -3.173246079104466e+19, "-3.173246E+19", "%1E", +__LINE__, -3.173581228658553e-02, "-0.03", "%+0.G", +__LINE__, -3.187598864929850e-07, "-3.18760E-07", "%#G", +__LINE__, -3.190525302270244e+08, "-3.190525e+08", "%+0.7g", +__LINE__, -3.191879884186422e+19, "-3.19E+19", "%.2E", +__LINE__, -3.197292604744926e+02, "-3.197293e+02", "%+e", +__LINE__, -3.203713337688838e-12, "-3.20371E-12", "%6G", +__LINE__, -3.204416889544914e-18, "-0.000000", "%+f", +__LINE__, -3.204494471917096e+09, "-3.20449e+09", "%g", +__LINE__, -3.211933195516720e+11, "-3.21193E+11", "%G", +__LINE__, -3.214544021431917e-24, "-0.000000", "%1f", +__LINE__, -3.215501229487004e-07, "-3e-07", "%3.e", +__LINE__, -3.232157492322707e-13, "-3.E-13", "%+#5.G", +__LINE__, -3.239074974455177e-05, "-3.239e-05", "%2.4g", +__LINE__, -3.243083730801156e-24, "-3.243084e-24", "%#e", +__LINE__, -3.243128583394124e+07, "-32431285.8339", "%6.4f", +__LINE__, -3.247997999770571e-08, "-3e-08", "%5.e", +__LINE__, -3.258251054563991e-15, "-3.2583E-15", "%.5G", +__LINE__, -3.259499053187446e+07, "-3.2595E+07", "%5.6G", +__LINE__, -3.261907782031174e+20, "-3.3e+20", "%.2g", +__LINE__, -3.263979380855122e+29, "-3.26398E+29", "%G", +__LINE__, -3.264166546402073e+06, "-3.26417E+06", "%5G", +__LINE__, -3.269357648926951e+01, "-3.E+01", "%#5.G", +__LINE__, -3.273523287028019e-30, "-3.27352e-30", "%g", +__LINE__, -3.274464331526264e-14, "-3e-14", "%.0g", +__LINE__, -3.276647049958546e+05, "-327664.7", "%+.1f", +__LINE__, -3.276853612008326e-04, "-3.276854e-04", "%e", +__LINE__, -3.288077788905925e+17, "-3.28808e+17", "%g", +__LINE__, -3.292054327509010e+21, "-3.29205e+21", "%+g", +__LINE__, -3.292086868337041e-16, " -0", "%7.f", +__LINE__, -3.299368070005327e-17, "-3E-17", "%5.G", +__LINE__, -3.307165537474566e-30, "-3e-30", "%+2.g", +__LINE__, -3.310556325973673e-17, "-3.31056E-17", "%G", +__LINE__, -3.315407318453138e-09, "-3.315407e-09", "%+#.6e", +__LINE__, -3.318402800998018e-09, "-3.3184E-09", "%+G", +__LINE__, -3.324277622889107e-04, "-0.000332428", "%G", +__LINE__, -3.326372457131185e+14, "-3.326372e+14", "%0e", +__LINE__, -3.333300611287597e+18, "-3.3E+18", "%4.2G", +__LINE__, -3.333608976277018e-25, "-3.33361e-25", "%g", +__LINE__, -3.333613056182724e-24, "-3.33361e-24", "%.5e", +__LINE__, -3.338505874378410e-26, "-0.00000", "%.5f", +__LINE__, -3.339838772519661e+24, "-3.3398E+24", "%0.5G", +__LINE__, -3.354802735583258e-27, "-3.3548E-27", "%G", +__LINE__, -3.356542080644329e+15, "-3356542080644329.129058", "%#f", +__LINE__, -3.360027692463026e-29, "-3.36003e-29", "%+g", +__LINE__, -3.361845657814323e+06, "-3361845.657814", "%f", +__LINE__, -3.363135493765816e-12, " -0", "%5.f", +__LINE__, -3.367383112102258e+19, "-33673831121022579360.158034", "%f", +__LINE__, -3.376798505037497e+03, "-3376.8", "%+3G", +__LINE__, -3.388170639372559e+09, "-3.388171e+09", "%+e", +__LINE__, -3.397304185715499e-12, "-3.397304e-12", "%+e", +__LINE__, -3.401559374016378e-13, "-3.40156e-13", "%g", +__LINE__, -3.402651870178825e+21, "-3.40265e+21", "%+g", +__LINE__, -3.410491213537530e+12, "-3.41049E+12", "%G", +__LINE__, -3.411695570460075e-01, "-3.411696e-01", "%e", +__LINE__, -3.417311435719220e+29, "-3.4E+29", "%3.1E", +__LINE__, -3.417581063208165e-23, " -0", "%+4.f", +__LINE__, -3.424005615113663e-28, "-0.000000", "%f", +__LINE__, -3.424793585094130e-12, "-0.000000", "%f", +__LINE__, -3.434733077762304e-05, "-3.43473e-05", "%g", +__LINE__, -3.436384988494743e+08, "-3.43638E+08", "%G", +__LINE__, -3.441082995163884e-21, "-0.000000", "%f", +__LINE__, -3.442868661576827e-23, "-3.442869e-23", "%#.7g", +__LINE__, -3.444337521046186e+13, "-3.44434E+13", "%#G", +__LINE__, -3.448230173418967e-28, "-3.44823E-28", "%#G", +__LINE__, -3.448523828225326e-21, "-3.4485e-21", "%.4e", +__LINE__, -3.449876796754720e-07, "-3.44988e-07", "%g", +__LINE__, -3.450163790411588e+25, "-34501637904115876054333966.749255", "%2f", +__LINE__, -3.450224454406567e-26, "-3.450224E-26", "%#1E", +__LINE__, -3.459930768422874e-28, "-3.46E-28", "%2.3G", +__LINE__, -3.460730505022601e-28, "-3.46073e-28", "%#g", +__LINE__, -3.462894265593946e-10, "-3.46289e-10", "%+#g", +__LINE__, -3.464808359229496e+05, "-346481", "%6.6G", +__LINE__, -3.467272303652620e-03, "-0.00346727", "%g", +__LINE__, -3.468252706910251e+10, "-3.5E+10", "%#7.2G", +__LINE__, -3.473623965680253e+27, "-3.47362e+27", "%g", +__LINE__, -3.474527926009729e+11, "-3.475E+11", "%.4G", +__LINE__, -3.476489048299929e+15, "-3.47649e+15", "%g", +__LINE__, -3.477809698895344e-09, "-0.000", "%+.3f", +__LINE__, -3.493008398637667e-28, " -0", "%+4.f", +__LINE__, -3.497441286691613e+07, "-3.49744e+07", "%g", +__LINE__, -3.500904660533358e+00, "-3.500905E+00", "%+1E", +__LINE__, -3.504996054364915e+25, "-3.505e+25", "%+g", +__LINE__, -3.507738629125434e-24, "-0.00", "%+4.2f", +__LINE__, -3.508557770253211e-04, "-3.508558e-04", "%#6e", +__LINE__, -3.516056824437550e+20, "-3.516057e+20", "%#e", +__LINE__, -3.521102917733367e+02, "-352.11", "%g", +__LINE__, -3.523948985825251e+10, "-3.52395e+10", "%+g", +__LINE__, -3.525281835697895e-15, "-3.525282e-15", "%e", +__LINE__, -3.534088845494570e-26, "-0.000000", "%2f", +__LINE__, -3.541002442741569e+01, "-35.410", "%3.3f", +__LINE__, -3.541126630345017e-19, "-3.541127e-19", "%e", +__LINE__, -3.545277845967514e-17, "-0.000000", "%f", +__LINE__, -3.560935430637329e-12, "-3.56094E-12", "%G", +__LINE__, -3.564234584447659e-23, "-3.56423E-23", "%G", +__LINE__, -3.576040378379921e-11, "-0.000000", "%+6f", +__LINE__, -3.578133580350674e-05, "-3.578134e-05", "%#e", +__LINE__, -3.584484015191491e-28, "-0.0", "%+2.1f", +__LINE__, -3.591961845146752e+27, "-3.59196E+27", "%G", +__LINE__, -3.602508380305001e+26, "-3.60251e+26", "%g", +__LINE__, -3.603113449808132e+04, "-36031.134498", "%+3.6f", +__LINE__, -3.605569849504628e+25, "-4E+25", "%6.G", +__LINE__, -3.611297754851416e+05, "-361129.775485", "%+f", +__LINE__, -3.613177909959201e-28, "-0.000000", "%f", +__LINE__, -3.616261225230595e-01, "-0.361626", "%3g", +__LINE__, -3.619203521536307e+09, "-3.6192E+09", "%G", +__LINE__, -3.619316709131723e-27, "-0.0000000", "%.7f", +__LINE__, -3.623100583082346e+28, "-3.6231E+28", "%+G", +__LINE__, -3.626582653589919e+21, "-3626582653589918603387.332041", "%f", +__LINE__, -3.626667540343067e-30, "-4.E-30", "%#.0G", +__LINE__, -3.633539220625861e-30, "-3.634E-30", "%+.3E", +__LINE__, -3.641655782149502e-11, "-3.64166E-11", "%G", +__LINE__, -3.644523594046571e+25, "-3.64452e+25", "%5g", +__LINE__, -3.645977605394108e+25, "-3.646e+25", "%+0.3e", +__LINE__, -3.647864582248812e+13, "-4E+13", "%4.G", +__LINE__, -3.655241667633056e-25, "-3.655242E-25", "%E", +__LINE__, -3.662603655433297e+23, "-3.662604e+23", "%e", +__LINE__, -3.668995445134158e+22, " -4E+22", "%7.G", +__LINE__, -3.670006666569412e-11, "-3.670007e-11", "%e", +__LINE__, -3.670510381138509e-24, "-3.670510e-24", "%e", +__LINE__, -3.671283003268254e-20, "-3.67128E-20", "%G", +__LINE__, -3.687760201176777e-13, "-3.68776E-13", "%G", +__LINE__, -3.687983982100676e-14, "-0.00", "%.2f", +__LINE__, -3.694808382827435e-12, "-3.694808E-12", "%#E", +__LINE__, -3.696158520838821e+28, "-3.69616E+28", "%3G", +__LINE__, -3.700911860811323e+18, "-3.70091e+18", "%+g", +__LINE__, -3.701328314738669e+24, "-3.70133e+24", "%g", +__LINE__, -3.707068461822151e-19, "-3.707068E-19", "%E", +__LINE__, -3.710679411506914e+25, "-3.71068e+25", "%g", +__LINE__, -3.713003840923896e-23, "-3.713e-23", "%7g", +__LINE__, -3.717028397747828e-28, "-3.71703e-28", "%g", +__LINE__, -3.728159642236442e+14, "-3.72816E+14", "%G", +__LINE__, -3.731956233637010e+21, "-3.73196E+21", "%G", +__LINE__, -3.742336623322610e+07, "-3.74234e+07", "%g", +__LINE__, -3.748328269630045e+04, "-37483.3", "%G", +__LINE__, -3.750803081283569e-27, "-3.7508E-27", "%+7G", +__LINE__, -3.752021500826652e-04, "-0.0004", "%.1G", +__LINE__, -3.755942257004103e-12, "-3.75594E-12", "%G", +__LINE__, -3.765921235889045e+03, " -4e+03", "%+7.g", +__LINE__, -3.772453135667801e-28, "-3.77245E-28", "%G", +__LINE__, -3.776384200230367e+27, "-3.776e+27", "%1.4g", +__LINE__, -3.787035870684945e-25, "-4E-25", "%+3.G", +__LINE__, -3.798616350818839e-29, "-3.7986164e-29", "%.7e", +__LINE__, -3.807178315238428e-15, "-0.000000", "%+#6f", +__LINE__, -3.822059837967635e+18, "-3822059837967634621.236357", "%6.6f", +__LINE__, -3.823553096022006e+12, "-3.82355e+12", "%g", +__LINE__, -3.839198115259428e-23, "-0.000000", "%f", +__LINE__, -3.846953640321746e+02, "-3.846954E+02", "%E", +__LINE__, -3.852230696542361e+08, "-3.8522e+08", "%#.5g", +__LINE__, -3.861139362195314e-25, "-3.86114E-25", "%2G", +__LINE__, -3.873388618099769e+09, "-3873388618", "%0.0f", +__LINE__, -3.874161550543817e+15, "-3.874162e+15", "%+e", +__LINE__, -3.874527935469425e+20, "-3.87E+20", "%3.3G", +__LINE__, -3.878069577893697e-30, "-3.878070E-30", "%#E", +__LINE__, -3.878852490397702e-20, "-3.87885e-20", "%g", +__LINE__, -3.879688342272101e-10, "-0.00", "%#4.2f", +__LINE__, -3.879797428399897e+03, "-3880", "%1.4g", +__LINE__, -3.881588804766756e+00, "-3.9", "%+4.2G", +__LINE__, -3.889377318111182e+01, "-38.8938", "%+.4f", +__LINE__, -3.893444523430385e-03, "-0.004", "%+2.g", +__LINE__, -3.894912141515856e+03, "-3894.91", "%+g", +__LINE__, -3.905279115773667e+04, "-39052.791158", "%f", +__LINE__, -3.905333955484919e-20, "-3.90533E-20", "%G", +__LINE__, -3.906559442060730e+27, "-3906559442060730447110472596.250474", "%f", +__LINE__, -3.909396469655334e-26, "-3.91E-26", "%.3G", +__LINE__, -3.920132491092364e+11, "-3.92013e+11", "%g", +__LINE__, -3.935651497471973e+27, "-3935651497471972604103029880", "%5.f", +__LINE__, -3.939742577853889e-03, "-0.004", "%5.G", +__LINE__, -3.943284017088198e+19, "-39432840170881981123.3", "%.1f", +__LINE__, -3.947452186327660e+09, "-3947452186.33", "%0.2f", +__LINE__, -3.951967237553488e+18, "-3951967237553488132.562052", "%f", +__LINE__, -3.953673427359789e-28, "-3.954E-28", "%3.4G", +__LINE__, -3.956044867371602e+23, "-4e+23", "%+6.1g", +__LINE__, -3.965038994251913e-20, "-3.96504e-20", "%g", +__LINE__, -3.970527677577937e+05, "-4.e+05", "%#0.1g", +__LINE__, -3.970717822164395e-20, "-3.970718e-20", "%6e", +__LINE__, -3.978063834438912e-19, "-3.97806E-19", "%G", +__LINE__, -3.982705395472599e+27, "-3.9827e+27", "%#.5g", +__LINE__, -3.983486821352571e-28, "-3.98349e-28", "%g", +__LINE__, -3.985470630230926e-14, "-4e-14", "%.2g", +__LINE__, -3.993095662863953e-16, "-3.993096e-16", "%e", +__LINE__, -4.006984141314271e-22, " -4e-22", "%7.2g", +__LINE__, -4.006984141314271e-22, "-4.0e-22", "%#7.2g", +__LINE__, -4.013226099863981e+06, "-4.013226E+06", "%+E", +__LINE__, -4.013702226581167e+00, "-4.0137022", "%+#3.7f", +__LINE__, -4.017598274642537e+11, "-4E+11", "%5.G", +__LINE__, -4.021385792825529e-09, " -4e-09", "%7.2g", +__LINE__, -4.024099064819937e-20, "-4.0241E-20", "%+G", +__LINE__, -4.026952473441366e+22, "-4.026952e+22", "%6.7g", +__LINE__, -4.027636677087866e+12, "-4.02764E+12", "%G", +__LINE__, -4.036506013049443e+17, "-4.03651e+17", "%0.6g", +__LINE__, -4.063191953523012e-06, " -0.0", "%6.1f", +__LINE__, -4.070953223475192e-23, "-4.07095E-23", "%G", +__LINE__, -4.072425833070524e+09, "-4.072426E+09", "%E", +__LINE__, -4.086025576759603e+12, "-4.086026e+12", "%e", +__LINE__, -4.086627783296081e-24, "-4.087E-24", "%.3E", +__LINE__, -4.086683676772144e+10, "-40866836767.721439", "%f", +__LINE__, -4.087336043219081e-10, "-0.", "%+#0.f", +__LINE__, -4.125162973336809e-26, "-4.125163E-26", "%.7G", +__LINE__, -4.150753797717075e-10, "-4.2e-10", "%.2g", +__LINE__, -4.152126152181912e+23, "-4.15213e+23", "%g", +__LINE__, -4.164458223079432e-07, "-4.164458E-07", "%E", +__LINE__, -4.170624866130099e+03, "-4170.624866", "%4.6f", +__LINE__, -4.171137277374942e-01, " -4E-01", "%+7.E", +__LINE__, -4.176067421901769e-25, "-4.17607E-25", "%G", +__LINE__, -4.179514418604771e+24, "-4.1795e+24", "%3.5g", +__LINE__, -4.196285183415621e+23, "-4.19629E+23", "%5G", +__LINE__, -4.198600486581023e+23, "-4E+23", "%+4.G", +__LINE__, -4.199020494598538e-16, "-0.000000", "%+f", +__LINE__, -4.207824153501688e-01, "-0.420782", "%G", +__LINE__, -4.219086441294006e-13, " -0", "%+4.f", +__LINE__, -4.223689582765525e+12, "-4.22369e+12", "%g", +__LINE__, -4.230213377391093e+04, "-42302.1", "%+2.6G", +__LINE__, -4.232495358100605e-02, "-0.042325", "%+f", +__LINE__, -4.235459662515940e-29, "-0.000000", "%f", +__LINE__, -4.240807508057296e-07, "-4e-07", "%0.g", +__LINE__, -4.248376819122346e-13, "-4.248377e-13", "%7e", +__LINE__, -4.251361939638334e-23, "-4.251362E-23", "%E", +__LINE__, -4.253044333568077e+24, "-4.253044e+24", "%4e", +__LINE__, -4.255728039119772e-30, "-4.25573E-30", "%2G", +__LINE__, -4.256502531648988e+02, "-425.65", "%G", +__LINE__, -4.260731632612400e-04, "-0", "%2.f", +__LINE__, -4.262037138254753e-25, "-4e-25", "%5.g", +__LINE__, -4.270910126379393e+00, "-4.2709", "%#7.4f", +__LINE__, -4.273844276097008e-09, " -0.", "%#4.f", +__LINE__, -4.280424136111831e+21, "-4.280E+21", "%.3E", +__LINE__, -4.284351940366486e-23, "-0.000000", "%+f", +__LINE__, -4.291747881693517e-29, "-4.3e-29", "%+#.2g", +__LINE__, -4.298346825232928e+04, "-42983.5", "%G", +__LINE__, -4.298879924365432e+28, "-42988799243654316484253286034.800112", "%f", +__LINE__, -4.302192665689887e-25, "-0.000000", "%f", +__LINE__, -4.303899568112784e+06, "-4E+06", "%1.G", +__LINE__, -4.307399960278190e-30, "-4.31e-30", "%.3g", +__LINE__, -4.341161949359232e+01, "-43.411619", "%+f", +__LINE__, -4.353334435604675e+17, " -4e+17", "%+7.g", +__LINE__, -4.354760231068195e+08, "-4e+08", "%2.e", +__LINE__, -4.363535913318519e+08, "-4.363536E+08", "%+7E", +__LINE__, -4.365389605557404e-29, "-4.365390e-29", "%e", +__LINE__, -4.369278570829168e-22, "-4.369279E-22", "%5E", +__LINE__, -4.372187639240662e-11, "-4.37219e-11", "%+g", +__LINE__, -4.374221079233858e-15, "-4.37422E-15", "%4.6G", +__LINE__, -4.374840292001664e-13, "-0.000000", "%+f", +__LINE__, -4.376554800103945e+16, "-43765548001039453.751559", "%f", +__LINE__, -4.376659235899513e+07, "-4.4E+07", "%0.2G", +__LINE__, -4.377316129868239e-06, "-4.37732E-06", "%+5G", +__LINE__, -4.380028480226885e+21, "-4e+21", "%1.0e", +__LINE__, -4.380434965450223e+16, "-43804349654502230.393405", "%f", +__LINE__, -4.392477080355168e-15, "-4E-15", "%+2.G", +__LINE__, -4.396120020536161e+17, "-439612002053616102.159594", "%#f", +__LINE__, -4.400993154571784e+13, "-44009931545717.844159", "%f", +__LINE__, -4.402873692051930e-26, "-4.4e-26", "%5.3g", +__LINE__, -4.405330274903779e+24, "-4405330274903779042006135.568954", "%+5f", +__LINE__, -4.406272291312090e+06, "-4.40627e+06", "%+g", +__LINE__, -4.407065949816988e-13, "-0.000000", "%f", +__LINE__, -4.408295597674563e-10, "-4.4083e-10", "%g", +__LINE__, -4.417553815178214e-30, "-4.41755E-30", "%G", +__LINE__, -4.428894120469459e+16, "-4.42889e+16", "%g", +__LINE__, -4.433747825142046e+04, "-4.433748e+04", "%#e", +__LINE__, -4.435051082856639e+11, "-4.43505E+11", "%G", +__LINE__, -4.445045573007259e-27, "-4.445e-27", "%.5g", +__LINE__, -4.447791368960968e-25, " -4e-25", "%+7.g", +__LINE__, -4.449691386526521e-11, "-4.44969e-11", "%g", +__LINE__, -4.451399093849402e+06, "-4.e+06", "%#0.e", +__LINE__, -4.453753130320864e-22, "-4E-22", "%6.E", +__LINE__, -4.455910780463539e+00, "-4", "%2.g", +__LINE__, -4.464935674747308e+25, "-4.46494e+25", "%g", +__LINE__, -4.469759565657550e-29, "-4.46976e-29", "%g", +__LINE__, -4.473254139442931e+14, "-4E+14", "%3.1G", +__LINE__, -4.480844704930373e-04, "-0.000448", "%5.6f", +__LINE__, -4.484177356024563e+19, "-4.484177E+19", "%E", +__LINE__, -4.488115678357666e-13, "-4.48812e-13", "%g", +__LINE__, -4.491545112281561e+12, "-4.491545E+12", "%E", +__LINE__, -4.492547433553077e-23, "-4.49255e-23", "%g", +__LINE__, -4.492701755830813e-05, "-0.000045", "%f", +__LINE__, -4.497405935096372e-02, "-4.497406e-02", "%e", +__LINE__, -4.502764260212887e+21, "-4.50276E+21", "%G", +__LINE__, -4.511984199938207e+29, "-451198419993820731832556703011.505306", "%f", +__LINE__, -4.514517861504637e-13, "-4.51452e-13", "%g", +__LINE__, -4.525577218881990e+24, "-4.5e+24", "%2.2g", +__LINE__, -4.549244580903896e-26, "-5E-26", "%2.G", +__LINE__, -4.569192488002113e-29, "-5E-29", "%3.G", +__LINE__, -4.572011438847734e+17, "-4.57e+17", "%#.3g", +__LINE__, -4.573010973514519e-08, "-4.57301e-08", "%+7g", +__LINE__, -4.584534976177852e-04, "-0.000458453", "%7g", +__LINE__, -4.584729895132228e-21, "-0.000000", "%4f", +__LINE__, -4.585259328217483e-30, "-4.58526E-30", "%+#4.6G", +__LINE__, -4.589603063610410e-04, "-4.589603E-04", "%+E", +__LINE__, -4.592428795671033e+22, " -5e+22", "%7.g", +__LINE__, -4.595683678223830e-20, " -0", "%5.f", +__LINE__, -4.602585606100101e+05, "-4.602586E+05", "%E", +__LINE__, -4.603375306660027e-08, "-5E-08", "%+6.G", +__LINE__, -4.611341343728034e-18, "-4.611341e-18", "%5e", +__LINE__, -4.613608487855863e+05, "-461361", "%6g", +__LINE__, -4.615997775774194e-24, "-4.61600e-24", "%#g", +__LINE__, -4.620310950564759e+23, "-462031095056475926696749", "%1.0f", +__LINE__, -4.620645693595563e-10, "-4.6206457e-10", "%.7e", +__LINE__, -4.621527706233292e-09, "-4.621528e-09", "%#e", +__LINE__, -4.625215210297273e-13, "-4.62522E-13", "%G", +__LINE__, -4.636755152220100e-29, "-0.000000", "%#f", +__LINE__, -4.641203877508087e+23, "-4.6412e+23", "%0g", +__LINE__, -4.648627249239175e+23, "-4.65E+23", "%+0.3G", +__LINE__, -4.662546890623409e-10, "-4.663E-10", "%.3E", +__LINE__, -4.664488650292317e-27, "-4.66449e-27", "%#g", +__LINE__, -4.668715685060282e+08, "-466871568.50603", "%.5f", +__LINE__, -4.673332851657081e-18, "-4.7e-18", "%#5.2g", +__LINE__, -4.683361436174074e+24, "-4.68e+24", "%#.2e", +__LINE__, -4.693748680461066e-01, "-0.469375", "%G", +__LINE__, -4.697110010549124e+23, "-4.69711E+23", "%G", +__LINE__, -4.710442739966989e+06, "-4.710443e+06", "%2e", +__LINE__, -4.713427678642280e-09, "-4.71343e-09", "%g", +__LINE__, -4.721999055940316e-04, "-4.721999e-04", "%#1e", +__LINE__, -4.724262200578540e+17, "-472426220057853996.081576", "%+f", +__LINE__, -4.733267644288093e+01, "-4.733268e+01", "%7e", +__LINE__, -4.742854711396110e-11, "-0.000000", "%f", +__LINE__, -4.757456106385936e+23, "-4.75746e+23", "%g", +__LINE__, -4.770895495642298e+27, "-4770895495642298200777986494.358629", "%2f", +__LINE__, -4.775073456318149e+29, "-4.775073E+29", "%#E", +__LINE__, -4.779997387204258e+17, "-4.78e+17", "%g", +__LINE__, -4.799264315770707e-23, "-4.799264E-23", "%+.7G", +__LINE__, -4.814277930599660e+10, "-5e+10", "%2.1g", +__LINE__, -4.818413387018612e+05, "-5e+05", "%.0g", +__LINE__, -4.818827195107612e-16, "-4.818827e-16", "%e", +__LINE__, -4.841524514024803e+21, "-4.84152E+21", "%G", +__LINE__, -4.860585077313477e+10, "-4.86059E+10", "%+G", +__LINE__, -4.870037451948589e+28, "-48700374519485887248038125107.996166", "%f", +__LINE__, -4.888835952705153e-28, "-4.888836E-28", "%+E", +__LINE__, -4.893523355754114e-19, "-4.893523e-19", "%.6e", +__LINE__, -4.906070260482585e+17, "-490607026048258454", "%+.0f", +__LINE__, -4.907734144101900e+25, "-5E+25", "%+.1G", +__LINE__, -4.917899547741841e-25, "-4.917900e-25", "%e", +__LINE__, -4.923348512538722e+25, "-49233485125387215219916470.232420", "%+.6f", +__LINE__, -4.926052630078460e-26, "-4.926053e-26", "%e", +__LINE__, -4.926751662051156e+14, "-4.927E+14", "%+5.3E", +__LINE__, -4.928017952199046e-12, "-0.000000", "%f", +__LINE__, -4.944296782981195e-21, "-4.9443E-21", "%1.5G", +__LINE__, -4.947320427183599e-19, "-4.947320e-19", "%.6e", +__LINE__, -4.968188938972135e+17, "-4.96819E+17", "%G", +__LINE__, -4.968756725758674e+05, "-496876", "%G", +__LINE__, -4.968788759793340e-26, "-4.97E-26", "%.3G", +__LINE__, -4.983904999913364e-24, "-5E-24", "%0.G", +__LINE__, -4.985209496522767e+23, "-4.985209e+23", "%e", +__LINE__, -4.987363880732866e+08, "-4.98736E+08", "%G", +__LINE__, -4.989754940144973e+05, "-498975.494014", "%f", +__LINE__, -4.998203870733718e-25, "-4.9982e-25", "%g", +__LINE__, -4.999153445016792e-27, "-5e-27", "%+1.e", +__LINE__, -5.002693488258108e+06, " -5e+06", "%+7.g", +__LINE__, -5.017958458603783e+05, "-5.0179585E+05", "%+.7E", +__LINE__, -5.028902178573363e-12, "-5.0289e-12", "%0g", +__LINE__, -5.032337536971444e+07, "-50323375.369714", "%f", +__LINE__, -5.036525516370473e-24, "-5.0365e-24", "%4.5g", +__LINE__, -5.038642321515756e+18, "-5038642321515755639.893541", "%f", +__LINE__, -5.051003516976770e-14, "-5.051E-14", "%+G", +__LINE__, -5.051196143816789e+27, "-5.0512e+27", "%g", +__LINE__, -5.057372886713786e+28, "-5.057373e+28", "%#e", +__LINE__, -5.057475029459727e+12, "-5.05748e+12", "%+g", +__LINE__, -5.068286816124670e-17, "-5.068E-17", "%5.3E", +__LINE__, -5.070475165759468e-12, "-0.000000", "%4.6f", +__LINE__, -5.081352543220476e+20, "-5.081E+20", "%.3E", +__LINE__, -5.084398319179363e+11, "-508439831917.936313", "%#f", +__LINE__, -5.085781220648484e+05, "-5.E+05", "%+#7.G", +__LINE__, -5.094941054632498e-24, "-5.09494E-24", "%+G", +__LINE__, -5.100059596310871e-10, "-5.10006e-10", "%3.6g", +__LINE__, -5.103072553594136e-01, "-0.5", "%+1.g", +__LINE__, -5.106319890388412e+08, "-5.106320e+08", "%4e", +__LINE__, -5.107120687977690e+09, "-5107120687.977690", "%f", +__LINE__, -5.119910716893161e-13, "-5.11991E-13", "%6G", +__LINE__, -5.127594569425709e-29, "-5.12759e-29", "%#g", +__LINE__, -5.130365585632797e+29, "-5.13037e+29", "%#g", +__LINE__, -5.131415638022112e+08, "-513141563.802211", "%0f", +__LINE__, -5.144703216335916e-23, "-5.1447e-23", "%g", +__LINE__, -5.152511923201882e-05, "-5.15251E-05", "%+G", +__LINE__, -5.165484448280190e-12, " -0.0", "%5.1f", +__LINE__, -5.179220760465737e-20, "-5e-20", "%+5.g", +__LINE__, -5.183005119662180e-10, "-5.183005E-10", "%+E", +__LINE__, -5.199587953258117e+13, "-5.19959e+13", "%6g", +__LINE__, -5.202041951844580e-25, "-0.000000", "%f", +__LINE__, -5.202836038621740e+00, "-5.20284", "%G", +__LINE__, -5.212204099528552e-11, "-5.2122e-11", "%.6g", +__LINE__, -5.225617726710534e+17, "-522561772671053414.995868", "%+f", +__LINE__, -5.230162003281426e+25, "-52301620032814257754694153.84578", "%+6.5f", +__LINE__, -5.251849429321286e-11, "-5.25185e-11", "%g", +__LINE__, -5.265174939930368e+23, "-5.265175E+23", "%1.6E", +__LINE__, -5.271218134351422e+21, "-5.27122e+21", "%+1g", +__LINE__, -5.273823357545750e+17, "-527382335754575048.980541", "%f", +__LINE__, -5.279848797214957e+11, "-527984879721.495659", "%0f", +__LINE__, -5.281551888625290e+11, "-5e+11", "%4.g", +__LINE__, -5.281780377142961e-24, "-5.28178e-24", "%g", +__LINE__, -5.292125782379512e+03, "-5292.125782", "%f", +__LINE__, -5.292401691410388e+15, "-5292401691410387.520875", "%f", +__LINE__, -5.305120752102265e-25, "-5.30512e-25", "%+#.5e", +__LINE__, -5.317975791704413e+16, "-5.31798e+16", "%+g", +__LINE__, -5.336522843607233e+27, "-5.33652e+27", "%#6g", +__LINE__, -5.342016438000917e-05, " -5e-05", "%+7.e", +__LINE__, -5.351122291549103e+06, "-5351122.291549", "%+0f", +__LINE__, -5.352043956303597e+00, "-5.35204", "%g", +__LINE__, -5.353582488767747e+09, "-5.354E+09", "%7.3E", +__LINE__, -5.383420177718380e+04, "-5e+04", "%1.e", +__LINE__, -5.384320189791882e-10, "-5.384320e-10", "%e", +__LINE__, -5.409487543257379e-12, "-5.40949E-12", "%G", +__LINE__, -5.418395794776773e+23, "-5.4184e+23", "%g", +__LINE__, -5.419918795921525e-09, "-0.000000", "%+f", +__LINE__, -5.422374157832442e+11, "-5.42237e+11", "%3g", +__LINE__, -5.426916951577001e-27, "-5.42692E-27", "%+G", +__LINE__, -5.430058833461779e+28, "-5.43006E+28", "%G", +__LINE__, -5.444433348653147e+23, "-5.444433E+23", "%E", +__LINE__, -5.446560186537024e+09, "-5.446560E+09", "%E", +__LINE__, -5.464243500152188e+27, "-5.46424E+27", "%G", +__LINE__, -5.464427517531742e+20, "-546442751753174249529.365625", "%f", +__LINE__, -5.465783705970954e+05, "-5E+05", "%1.E", +__LINE__, -5.475138077475789e-11, "-5e-11", "%.0e", +__LINE__, -5.475302250616576e+10, "-54753022506.1658", "%.4f", +__LINE__, -5.488964905442472e+09, "-5.48896e+09", "%g", +__LINE__, -5.492508526846316e-08, "-5.49251e-08", "%.6g", +__LINE__, -5.520533408804846e-15, "-5.520533e-15", "%e", +__LINE__, -5.532744688447266e+28, "-55327446884472664123677532188.594341", "%2.6f", +__LINE__, -5.535834653450131e-14, "-5.5e-14", "%0.1e", +__LINE__, -5.554344735392882e-02, "-5.554345E-02", "%+#E", +__LINE__, -5.555497334515501e-17, "-5.5555e-17", "%g", +__LINE__, -5.558304303221977e+14, "-555830430322197.699411", "%f", +__LINE__, -5.562210815777694e-05, "-5.562211E-05", "%#1E", +__LINE__, -5.564800722538402e-09, "-5.56480e-09", "%#.6g", +__LINE__, -5.567143271590439e-01, "-5.567143e-01", "%#e", +__LINE__, -5.568606044396186e+01, "-55.6861", "%4g", +__LINE__, -5.592027856401721e+12, "-5.592028e+12", "%.7g", +__LINE__, -5.592295342565443e+22, "-6.E+22", "%#3.G", +__LINE__, -5.600007421926053e+07, "-56000074.219261", "%1f", +__LINE__, -5.601444553155006e-12, "-5.60144E-12", "%G", +__LINE__, -5.605128912835080e-03, "-0.005605", "%+f", +__LINE__, -5.610950285679577e+19, "-5.61095E+19", "%G", +__LINE__, -5.622074657679467e+11, "-562207465767.946690", "%f", +__LINE__, -5.627358352391656e-01, "-0.6", "%1.g", +__LINE__, -5.627974317622488e-02, "-5.627974e-02", "%+e", +__LINE__, -5.629497696447229e+27, "-5.629E+27", "%+.4G", +__LINE__, -5.631383567258576e-29, "-5.63138e-29", "%0g", +__LINE__, -5.635241327177333e-18, "-5.63524E-18", "%G", +__LINE__, -5.644819783138381e+06, "-5.644820E+06", "%#E", +__LINE__, -5.648538459114833e+26, "-564853845911483265496144667.849876", "%+f", +__LINE__, -5.649004865848537e+00, "-5.649", "%g", +__LINE__, -5.653403316885170e+23, "-6E+23", "%2.0E", +__LINE__, -5.656109962244926e-18, "-0.000000", "%f", +__LINE__, -5.674988031695793e+22, "-5.674988E+22", "%+.7G", +__LINE__, -5.686380226400881e-22, "-0.000000", "%f", +__LINE__, -5.698840855829442e-14, "-5.69884E-14", "%G", +__LINE__, -5.707036642649580e+03, "-5707.036643", "%f", +__LINE__, -5.710344882278847e+11, "-5.71034E+11", "%+G", +__LINE__, -5.714852196401017e+19, "-5.71485E+19", "%+G", +__LINE__, -5.720153622156089e-22, "-5.72015E-22", "%G", +__LINE__, -5.722366011976922e+26, "-5.72237e+26", "%+g", +__LINE__, -5.722909928097404e+12, "-5.72291E+12", "%2G", +__LINE__, -5.725325961787777e-25, "-5.72533e-25", "%g", +__LINE__, -5.727138241052646e+19, "-5.72714e+19", "%+#g", +__LINE__, -5.734025840446336e+14, "-5.73403e+14", "%+g", +__LINE__, -5.736469106710259e-05, "-0.000057", "%.6f", +__LINE__, -5.755099153733116e-14, "-5.7551e-14", "%+g", +__LINE__, -5.758411844890947e-20, "-6E-20", "%+6.G", +__LINE__, -5.760350214122813e+03, "-5760.35", "%+g", +__LINE__, -5.768009192512392e-30, "-0", "%1.f", +__LINE__, -5.772343286693103e+07, "-5.77234E+07", "%G", +__LINE__, -5.776693265471852e-27, "-5.776693E-27", "%E", +__LINE__, -5.779682861172754e-28, "-5.779683e-28", "%e", +__LINE__, -5.789953490749936e+26, "-578995349074993637117358957.76656", "%5.5f", +__LINE__, -5.796771264754334e+04, "-57967.7", "%g", +__LINE__, -5.804788370597286e-02, "-5.80479E-02", "%+#1.5E", +__LINE__, -5.805343475329215e-13, "-5.80534e-13", "%g", +__LINE__, -5.809853913830122e+09, "-5809853914", "%+0.f", +__LINE__, -5.817313814570609e-30, " -0", "%7.0f", +__LINE__, -5.831708441750138e+00, "-5.83171", "%#g", +__LINE__, -5.846914550593652e+29, "-5.846915e+29", "%e", +__LINE__, -5.851455214762288e+04, "-58514.6", "%+G", +__LINE__, -5.855803663871393e-23, "-6E-23", "%5.E", +__LINE__, -5.858065129988470e+10, "-5.85807e+10", "%+g", +__LINE__, -5.863147168075411e-14, "-5.86315e-14", "%+g", +__LINE__, -5.878936740266680e-04, "-0.000587894", "%g", +__LINE__, -5.887654893386630e+25, "-58876548933866299506689756.526612", "%#f", +__LINE__, -5.889416409731902e-02, "-0.06", "%5.g", +__LINE__, -5.897630195029892e-18, "-5.897630E-18", "%#0.7G", +__LINE__, -5.898506808456422e-19, "-5.89851E-19", "%G", +__LINE__, -5.901768645393515e+29, "-5.90177E+29", "%+G", +__LINE__, -5.907529093570369e+10, "-59075290935.703695", "%f", +__LINE__, -5.910069365260240e+13, "-59100693652602.39849", "%+#5.5f", +__LINE__, -5.915678929676435e-07, "-0.000001", "%+f", +__LINE__, -5.922232380131716e-01, "-0.592223", "%+3f", +__LINE__, -5.923716473994306e+19, "-5.92372E+19", "%+#.6G", +__LINE__, -5.929950428920404e-15, "-5.929950e-15", "%+e", +__LINE__, -5.949552735665802e+26, "-5.94955e+26", "%#g", +__LINE__, -5.949977081310732e-02, "-0.059500", "%f", +__LINE__, -5.954520303889356e-07, "-5.954520E-07", "%5E", +__LINE__, -5.978861337429145e-13, "-6E-13", "%1.G", +__LINE__, -5.980539445081087e+15, "-5.98054E+15", "%.6G", +__LINE__, -5.981724990853490e-03, " -0.006", "%#7.g", +__LINE__, -5.989488907825821e+03, "-6E+03", "%.2G", +__LINE__, -5.998272294890842e+06, "-6.00E+06", "%4.2E", +__LINE__, -6.023775731455919e-29, "-6.023776e-29", "%e", +__LINE__, -6.028153126666870e-05, "-6.e-05", "%+#6.e", +__LINE__, -6.036200621484690e+25, "-6e+25", "%2.2g", +__LINE__, -6.036400640928137e-14, "-6.036401e-14", "%e", +__LINE__, -6.038198451098329e-20, "-6.038198e-20", "%1.7g", +__LINE__, -6.045778975641123e-15, "-6.04578E-15", "%G", +__LINE__, -6.046038904252073e+00, "-6.04604", "%g", +__LINE__, -6.082158462782175e-06, "-0.000006", "%+#f", +__LINE__, -6.106162726644904e+10, "-6.10616e+10", "%g", +__LINE__, -6.126345215489182e+10, "-6e+10", "%+1.g", +__LINE__, -6.131852309620571e+02, "-6e+02", "%4.e", +__LINE__, -6.134589313243809e-01, "-0.613459", "%+#f", +__LINE__, -6.142358153783462e-10, "-6.14236E-10", "%4G", +__LINE__, -6.151524334856263e+27, "-6151524334856262932191839354.345575", "%+6f", +__LINE__, -6.156818333724550e+04, "-6.e+04", "%#.1g", +__LINE__, -6.166172551433993e+24, "-6166172551433993120895138.4178", "%5.4f", +__LINE__, -6.169532428006014e-09, "-6.16953e-09", "%3g", +__LINE__, -6.172019382601770e-28, "-0.000000", "%+f", +__LINE__, -6.174496985807155e-09, "-6.1745E-09", "%G", +__LINE__, -6.186771845105751e+04, "-61867.7", "%G", +__LINE__, -6.200817973780066e+22, "-6.20082E+22", "%3G", +__LINE__, -6.218004335456301e-22, "-0.000000", "%+f", +__LINE__, -6.219009630546262e-18, "-6.22e-18", "%6.3g", +__LINE__, -6.242532875230618e-06, "-0.000006", "%7f", +__LINE__, -6.243612261280864e+14, "-6.24361e+14", "%.6g", +__LINE__, -6.243689597320126e+10, "-6e+10", "%.0e", +__LINE__, -6.244620667090527e+04, "-6e+04", "%6.e", +__LINE__, -6.250789625572054e-09, "-0.000000", "%+f", +__LINE__, -6.253537566219164e+01, "-63.", "%#1.f", +__LINE__, -6.284420289484166e+21, "-6.2844203e+21", "%7.7e", +__LINE__, -6.285939888202846e+27, "-6e+27", "%+.0g", +__LINE__, -6.290025777678105e+13, "-6E+13", "%2.E", +__LINE__, -6.291364254323924e+10, "-6.3E+10", "%3.2G", +__LINE__, -6.292428812164449e+15, "-6292428812164448.714839", "%.6f", +__LINE__, -6.292600606358002e+29, "-6.29260E+29", "%#G", +__LINE__, -6.292739629144148e-15, "-6.292740E-15", "%E", +__LINE__, -6.296471626465745e+28, "-6.29647E+28", "%G", +__LINE__, -6.299575066640315e+27, "-6.300E+27", "%.3E", +__LINE__, -6.315234679394876e-24, "-6E-24", "%2.G", +__LINE__, -6.320883246383228e-01, "-0.632088", "%2g", +__LINE__, -6.324938413548937e-11, "-6e-11", "%.1g", +__LINE__, -6.336312983176250e+04, "-6.336313e+04", "%e", +__LINE__, -6.341786787214541e+06, "-6.341787E+06", "%+7.6E", +__LINE__, -6.360189291106185e-15, "-0.0000000", "%#.7f", +__LINE__, -6.364818355457748e-15, "-0.0000000", "%1.7f", +__LINE__, -6.366291103431814e+04, "-63662.9", "%#G", +__LINE__, -6.366334042923153e-05, "-6.37e-05", "%5.3g", +__LINE__, -6.370477455143194e-12, "-0.000000", "%f", +__LINE__, -6.372829256546279e+23, "-6.37283E+23", "%G", +__LINE__, -6.375208490193110e-23, "-6.37521e-23", "%4.5e", +__LINE__, -6.382595100891736e-24, "-6.3826E-24", "%5G", +__LINE__, -6.396882421146790e-22, "-6.39688e-22", "%+g", +__LINE__, -6.407190354039938e+08, "-6.40719e+08", "%+g", +__LINE__, -6.408581541430886e-10, "-6.E-10", "%#0.0G", +__LINE__, -6.409206904981703e-03, "-0.006", "%+.0G", +__LINE__, -6.416106714707772e+26, "-641610671470777216285341637.558304", "%f", +__LINE__, -6.417436981761998e-04, "-0.000642", "%+#f", +__LINE__, -6.429997249673124e+11, "-642999724967.312414", "%#f", +__LINE__, -6.440827429825250e+16, "-6.44083E+16", "%G", +__LINE__, -6.444869858444955e+02, "-6e+02", "%6.g", +__LINE__, -6.471701890976228e-25, " -6e-25", "%7.1g", +__LINE__, -6.485393161670371e-12, "-6.485393e-12", "%.6e", +__LINE__, -6.487710907063584e+23, "-6.E+23", "%#3.E", +__LINE__, -6.492942931343439e-08, "-0.", "%+#2.0f", +__LINE__, -6.496010652113223e+18, "-6.49601e+18", "%g", +__LINE__, -6.502856921840228e+22, "-6.50286e+22", "%4g", +__LINE__, -6.523559906055000e-10, "-6.52356E-10", "%.6G", +__LINE__, -6.525899074126662e+04, "-6.5e+04", "%+.1e", +__LINE__, -6.532216801155521e-09, "-6.53222E-09", "%G", +__LINE__, -6.544601787025684e-27, "-0", "%+.0f", +__LINE__, -6.558968312132168e-01, " -1", "%+6.f", +__LINE__, -6.559654261655786e+08, "-6.559654e+08", "%e", +__LINE__, -6.566562622196495e-21, "-6.56656E-21", "%.6G", +__LINE__, -6.573486832071960e+04, "-65734.9", "%G", +__LINE__, -6.573806290918275e+13, "-6.57381E+13", "%G", +__LINE__, -6.578113771674787e+17, "-6.57811E+17", "%+#G", +__LINE__, -6.584106931007506e+15, "-6.584107E+15", "%E", +__LINE__, -6.590538844308877e+07, "-65905388.443089", "%f", +__LINE__, -6.593708834068371e-07, "-0.000001", "%f", +__LINE__, -6.597116446195875e+08, "-6.5971164e+08", "%#1.7e", +__LINE__, -6.605813542127091e-04, "-0.0007", "%+0.g", +__LINE__, -6.607491403866429e+07, "-7e+07", "%3.g", +__LINE__, -6.616499847522278e+09, "-6.61650E+09", "%+#G", +__LINE__, -6.618619768691332e+20, "-7E+20", "%2.G", +__LINE__, -6.626748168962331e-22, "-7.E-22", "%+#3.E", +__LINE__, -6.639335450348280e+12, "-6.63934e+12", "%g", +__LINE__, -6.643910144912576e-03, "-0.006644", "%f", +__LINE__, -6.650293872031870e-18, "-6.65029e-18", "%+#g", +__LINE__, -6.654903858656310e-21, "-0.000000", "%f", +__LINE__, -6.665834666726511e-12, "-6.665835E-12", "%E", +__LINE__, -6.666428729917570e-19, "-0.000000", "%+#f", +__LINE__, -6.668415789681128e+27, "-6.66842E+27", "%+G", +__LINE__, -6.675214676269601e-28, "-6.67521e-28", "%#g", +__LINE__, -6.679560072732262e+01, "-66.7956", "%#g", +__LINE__, -6.692325075457020e-19, "-0.000000", "%1f", +__LINE__, -6.697096655164652e+00, "-6.70", "%#.3g", +__LINE__, -6.712436135928394e-28, "-7e-28", "%0.g", +__LINE__, -6.720769486122685e-16, "-7e-16", "%0.e", +__LINE__, -6.727196898490600e+26, "-672719689849060031860972230.8", "%.1f", +__LINE__, -6.744132627576416e+02, "-674.413", "%6G", +__LINE__, -6.757705576425288e+28, "-6.7577056e+28", "%.7e", +__LINE__, -6.760554929237173e-02, "-0.067606", "%+f", +__LINE__, -6.763538810629361e+10, "-6.7635E+10", "%.4E", +__LINE__, -6.764712008860796e-29, "-6.76471E-29", "%+G", +__LINE__, -6.767299719678443e+04, "-67672.997197", "%f", +__LINE__, -6.768326491352134e+20, "-676832649135213415547.70", "%+.2f", +__LINE__, -6.771116968952891e+03, "-7E+03", "%3.1G", +__LINE__, -6.775218099238350e-30, "-7.e-30", "%+#6.g", +__LINE__, -6.782142689928918e-18, "-0.00", "%4.2f", +__LINE__, -6.795409770512149e+08, "-7E+08", "%+5.0G", +__LINE__, -6.820966157097271e+14, "-6.820966e+14", "%e", +__LINE__, -6.824972990592273e-22, "-0.00", "%+#1.2f", +__LINE__, -6.830452914741750e+29, "-6.8E+29", "%+7.2G", +__LINE__, -6.835797187132348e+10, "-6.8358E+10", "%+5G", +__LINE__, -6.837040829636343e-03, "-0.00683704", "%+g", +__LINE__, -6.852956218658224e+23, "-6.85296e+23", "%3g", +__LINE__, -6.854102607287217e-26, "-7e-26", "%5.e", +__LINE__, -6.865065870249438e+16, "-6.86507E+16", "%#G", +__LINE__, -6.884819522625523e-13, "-6.88482E-13", "%5G", +__LINE__, -6.916316600148513e-12, "-0.000000", "%f", +__LINE__, -6.925312418761560e-05, "-6.92531E-05", "%#G", +__LINE__, -6.929518694178331e+09, "-6929518694.178", "%#.3f", +__LINE__, -6.936008056682024e+02, "-6.936008E+02", "%E", +__LINE__, -6.944911117352400e+26, "-6.944911E+26", "%1.6E", +__LINE__, -6.945829492125162e+05, "-6.9e+05", "%+2.2g", +__LINE__, -6.946603162471856e-13, "-6.94660E-13", "%#G", +__LINE__, -6.947529440406653e+22, "-6.9475e+22", "%+6.5g", +__LINE__, -6.950167604854856e-30, "-0.000000", "%7f", +__LINE__, -6.958122319262799e-26, "-7E-26", "%+1.E", +__LINE__, -6.958978258390961e+16, "-6.95898E+16", "%+5.6G", +__LINE__, -6.963780466334008e-06, "-6.96378E-06", "%2G", +__LINE__, -6.965570896221966e+13, "-6.965571E+13", "%5E", +__LINE__, -6.967741871945064e-10, "-6.96774E-10", "%+#G", +__LINE__, -6.973815739524307e+19, "-69738157395243067782.076", "%6.3f", +__LINE__, -6.982714545008106e+13, "-6.98271e+13", "%g", +__LINE__, -6.985955885054476e+03, "-6985.96", "%6G", +__LINE__, -6.986415266835747e+18, "-6.98642e+18", "%#g", +__LINE__, -6.996461529596512e-08, "-7.0E-08", "%#.1E", +__LINE__, -7.000144914012241e-05, "-7.00014e-05", "%#g", +__LINE__, -7.001017894492730e-03, "-0.00700102", "%+#.6G", +__LINE__, -7.003690685875917e+20, "-7E+20", "%0.G", +__LINE__, -7.010454163965384e+00, "-7.010454e+00", "%+e", +__LINE__, -7.011493550018082e-26, " -0", "%7.f", +__LINE__, -7.018018443394008e+21, "-7.0E+21", "%+#1.1E", +__LINE__, -7.027253777387243e-05, "-7.02725E-05", "%+G", +__LINE__, -7.043679213677740e-17, "-0", "%1.f", +__LINE__, -7.051690489227881e-16, "-7.052e-16", "%0.4g", +__LINE__, -7.063422475274161e-16, "-7.063422E-16", "%E", +__LINE__, -7.065069592235558e-30, "-7.06507e-30", "%+#g", +__LINE__, -7.068265283935834e-29, "-7e-29", "%+5.e", +__LINE__, -7.068748224536295e-13, "-0.000000", "%f", +__LINE__, -7.069621910708177e-04, "-0.000707", "%1.3g", +__LINE__, -7.079725450964823e-12, "-0.000000", "%f", +__LINE__, -7.087255464668218e+17, "-7.1e+17", "%.1e", +__LINE__, -7.088715102009605e-09, "-7e-09", "%6.0g", +__LINE__, -7.090414916270137e-15, "-0.00000", "%.5f", +__LINE__, -7.091868311008428e-03, " -0.0", "%5.1f", +__LINE__, -7.094242165237718e+21, "-7.09424e+21", "%+g", +__LINE__, -7.094324305740325e-05, "-7E-05", "%+3.G", +__LINE__, -7.104544752289144e+04, "-71045.4", "%#g", +__LINE__, -7.105164644813694e-29, "-0.000000", "%+f", +__LINE__, -7.114513164219487e-12, "-7.11451e-12", "%+g", +__LINE__, -7.115778236604137e-12, "-7.11578E-12", "%G", +__LINE__, -7.126217683410162e-27, "-7.126218e-27", "%e", +__LINE__, -7.136214260967733e+28, "-71362142609677334803564008325.338364", "%f", +__LINE__, -7.143452595522573e+19, "-7.14345e+19", "%g", +__LINE__, -7.156042088843537e+27, "-7156042088843537207765166385.7977837", "%4.7f", +__LINE__, -7.173687683710490e+24, "-7.17369e+24", "%6g", +__LINE__, -7.190531162598206e+25, "-71905311625982060164119503", "%4.f", +__LINE__, -7.201301831373747e-09, "-7.2013e-09", "%g", +__LINE__, -7.209601436737306e+10, "-7.2096e+10", "%g", +__LINE__, -7.211058997356655e-06, "-7.211059E-06", "%E", +__LINE__, -7.226756177676272e-09, "-7.22676E-09", "%+G", +__LINE__, -7.230870817566419e+19, "-72308708175664193618.1040364", "%#.7f", +__LINE__, -7.231355992133345e-05, "-7.231356E-05", "%#E", +__LINE__, -7.245999575278407e-12, "-7.246e-12", "%g", +__LINE__, -7.247426403040390e-09, "-7.2474E-09", "%+4.5G", +__LINE__, -7.257348680308567e-12, "-7.3E-12", "%1.2G", +__LINE__, -7.258184256387366e-26, "-7.25818E-26", "%+2G", +__LINE__, -7.262633672900126e+10, "-7.26263e+10", "%#g", +__LINE__, -7.268887462426250e+03, "-7.268887e+03", "%+#e", +__LINE__, -7.275284494682963e+08, "-7.27528e+08", "%g", +__LINE__, -7.276335846256479e-07, " -0", "%4.f", +__LINE__, -7.312556378294452e+15, "-7.31256e+15", "%+6g", +__LINE__, -7.334763752442417e-15, "-0.0000", "%#.4f", +__LINE__, -7.354627097325888e-18, "-7E-18", "%0.E", +__LINE__, -7.360087573342401e-25, "-7.4E-25", "%6.2G", +__LINE__, -7.368533563361098e-29, "-7.4E-29", "%3.1E", +__LINE__, -7.379267723540596e-06, "-0.000007", "%f", +__LINE__, -7.384525781709565e-19, "-0.000000", "%+#f", +__LINE__, -7.388940868679677e-09, "-7.388941E-09", "%E", +__LINE__, -7.391602149099698e+00, "-7.391602E+00", "%E", +__LINE__, -7.393159340196723e+22, "-7.39316e+22", "%#2.6g", +__LINE__, -7.399783260198277e-16, "-7.39978E-16", "%G", +__LINE__, -7.405609590448331e-06, "-7.40561e-06", "%g", +__LINE__, -7.407396977847794e-11, "-7.40740E-11", "%#G", +__LINE__, -7.433716848698637e+20, "-7.43372e+20", "%+g", +__LINE__, -7.444176062769411e-01, "-0.744418", "%#g", +__LINE__, -7.448314697244012e+12, "-7448314697244.011739", "%f", +__LINE__, -7.449533988369018e+08, "-7.449534e+08", "%+#7e", +__LINE__, -7.465682839758801e-01, "-7E-01", "%4.E", +__LINE__, -7.466517843126368e-26, "-7.5E-26", "%.1E", +__LINE__, -7.471385785539900e+24, "-7471385785539899515583783.795591", "%f", +__LINE__, -7.478345583780341e+00, "-7.478346e+00", "%e", +__LINE__, -7.524759284626724e-06, "-7.52476e-06", "%2g", +__LINE__, -7.534831049342539e-19, "-7.53483E-19", "%G", +__LINE__, -7.540546673179273e+15, "-8e+15", "%.1g", +__LINE__, -7.543440436184003e-08, "-7.54344E-08", "%6G", +__LINE__, -7.558224240835564e-06, "-7.55822e-06", "%g", +__LINE__, -7.564132915154469e+23, "-756413291515446850610260.298708", "%+f", +__LINE__, -7.566590720355392e+15, "-7.566591e+15", "%1.6e", +__LINE__, -7.568565927479741e-01, "-7.568566e-01", "%#6e", +__LINE__, -7.615574141973305e-17, "-7.6156e-17", "%+.5g", +__LINE__, -7.641297631509318e-28, "-8e-28", "%+.1g", +__LINE__, -7.661227834163450e+09, "-7661227834.1634497", "%+#.7f", +__LINE__, -7.665934364070126e+11, "-766593436407.0", "%.1f", +__LINE__, -7.682500068463102e-27, "-0.000000", "%+#f", +__LINE__, -7.709363160273798e+15, "-7.70936e+15", "%g", +__LINE__, -7.712596019255238e+26, "-7.7e+26", "%.2g", +__LINE__, -7.730213358437991e+25, "-7.7e+25", "%6.2g", +__LINE__, -7.744420019068976e+05, "-7.74442E+05", "%.5E", +__LINE__, -7.745813181942296e+11, "-7.7458132e+11", "%+.7e", +__LINE__, -7.751004379716307e+16, "-7.751004e+16", "%e", +__LINE__, -7.759862226564527e-28, "-7.75986e-28", "%g", +__LINE__, -7.767838880221207e-27, "-7.76784e-27", "%g", +__LINE__, -7.776301142157532e-19, "-0", "%2.f", +__LINE__, -7.783944257077553e-14, "-8e-14", "%3.g", +__LINE__, -7.801587579382377e+28, "-8e+28", "%+0.g", +__LINE__, -7.806685979552780e+25, "-7.806686E+25", "%E", +__LINE__, -7.825968891331719e-05, "-7.82597E-05", "%G", +__LINE__, -7.826834158664018e+12, "-7.826834E+12", "%+#E", +__LINE__, -7.832536798726886e+24, "-7.83254E+24", "%#1G", +__LINE__, -7.840485340202362e-18, "-0.000000", "%.6f", +__LINE__, -7.843236212099233e+21, "-7.84324e+21", "%g", +__LINE__, -7.906644052019278e-13, "-7.906644E-13", "%E", +__LINE__, -7.908090440678874e-20, "-7.90809E-20", "%#G", +__LINE__, -7.917588593012283e+08, "-7.917589E+08", "%+E", +__LINE__, -7.929100086742454e+29, "-792910008674245414539427656563.930213", "%f", +__LINE__, -7.933235286034290e+26, "-7.933235E+26", "%E", +__LINE__, -7.943431966567875e-03, "-0.0079434", "%+.5g", +__LINE__, -7.950872643572970e-22, "-7.95087e-22", "%2g", +__LINE__, -7.971225555313069e-01, "-0.797123", "%f", +__LINE__, -7.978310272676090e-12, "-0.000000", "%#f", +__LINE__, -8.006805393896414e-29, "-8.00681E-29", "%G", +__LINE__, -8.006906303018830e+25, "-8.00691E+25", "%+G", +__LINE__, -8.008484654476057e+18, "-8.008485e+18", "%5.6e", +__LINE__, -8.008943512904249e+27, "-8008943512904249217854157905.0943", "%+.4f", +__LINE__, -8.016539743121665e+27, "-8.01654E+27", "%G", +__LINE__, -8.018247227006128e-05, " -8E-05", "%7.G", +__LINE__, -8.044391842561705e+21, "-8.04439e+21", "%g", +__LINE__, -8.081902305002036e-02, "-8.081902E-02", "%E", +__LINE__, -8.084193011936438e-03, "-0.0080842", "%+5.5g", +__LINE__, -8.105813534846529e-27, "-0.000000", "%f", +__LINE__, -8.128116892989251e+00, "-8.12812", "%G", +__LINE__, -8.136119035731877e+05, "-8e+05", "%+0.g", +__LINE__, -8.140584224052606e+14, "-8E+14", "%5.G", +__LINE__, -8.145928897003907e+13, "-8.15E+13", "%.3G", +__LINE__, -8.164495905907508e-02, "-0.081645", "%G", +__LINE__, -8.169602113313905e+20, "-8.16960e+20", "%#g", +__LINE__, -8.179181640418333e+24, "-8.E+24", "%#.1G", +__LINE__, -8.184324492264231e-18, "-8.18432E-18", "%G", +__LINE__, -8.186480473850516e-28, "-0.000000", "%+f", +__LINE__, -8.196858948158896e+07, "-8.1969E+07", "%.4E", +__LINE__, -8.213138534699043e-30, "-0.000000", "%f", +__LINE__, -8.221181368676532e-21, "-8.221181E-21", "%#1E", +__LINE__, -8.222605734191438e+16, "-8.22261E+16", "%+G", +__LINE__, -8.223925661091432e-14, "-8.223926e-14", "%0e", +__LINE__, -8.232281541044777e-01, "-0.823228", "%f", +__LINE__, -8.245536794508725e+22, "-8E+22", "%6.G", +__LINE__, -8.270687365305925e+25, "-82706873653059247430974210.146815", "%f", +__LINE__, -8.288978945738204e+11, "-8.28898e+11", "%5g", +__LINE__, -8.290628698333139e+02, "-829.063", "%+G", +__LINE__, -8.292416206056451e-16, "-8.29242e-16", "%+g", +__LINE__, -8.296322623746486e-13, "-8.29632E-13", "%0.6G", +__LINE__, -8.298321941376933e-16, "-0.000000", "%+f", +__LINE__, -8.302331258878365e+29, "-8.30233E+29", "%0G", +__LINE__, -8.309022429255061e+06, "-8309022.429255", "%+f", +__LINE__, -8.312786829254646e-23, "-8.312787e-23", "%e", +__LINE__, -8.313852965178063e-15, "-8.313853e-15", "%#7e", +__LINE__, -8.317529094827869e+16, "-8.31753E+16", "%2G", +__LINE__, -8.322847660882248e-17, "-0.000000", "%f", +__LINE__, -8.324060602752638e-30, "-8.32406e-30", "%#g", +__LINE__, -8.325043500735461e+27, "-8325043500735461066142306663.095951", "%#f", +__LINE__, -8.332432016286935e-02, "-0.0833243", "%g", +__LINE__, -8.334251670232117e-09, "-8.33425e-09", "%g", +__LINE__, -8.338076225141778e+02, "-833.808", "%g", +__LINE__, -8.338349587571534e-23, "-8.33835e-23", "%+2g", +__LINE__, -8.342420812231939e+23, "-834242081223193920891390.00745", "%+0.5f", +__LINE__, -8.347404637940894e+17, "-8.347405e+17", "%+e", +__LINE__, -8.367002601133880e-12, "-0.000000", "%#2.6f", +__LINE__, -8.368579538210858e-17, "-8.36858e-17", "%5g", +__LINE__, -8.392398522472401e-10, "-0.0000", "%.4f", +__LINE__, -8.393029677635258e-29, " -8E-29", "%7.G", +__LINE__, -8.393843230819225e-11, "-8.393843E-11", "%E", +__LINE__, -8.397239871789148e-11, "-8.39724e-11", "%g", +__LINE__, -8.402316358199041e-29, "-0.000", "%3.3f", +__LINE__, -8.402910159034304e-14, "-8.4e-14", "%+0.3g", +__LINE__, -8.414960962391726e+09, "-8414960962.391726", "%#f", +__LINE__, -8.417512471384889e-28, "-8.417512e-28", "%e", +__LINE__, -8.418719240222911e+21, "-8418719240222911182058.851409", "%f", +__LINE__, -8.421210956044195e-09, "-0.00000", "%.5f", +__LINE__, -8.422001733529095e+24, "-8E+24", "%0.G", +__LINE__, -8.443614453772469e+21, "-8.44361E+21", "%+G", +__LINE__, -8.445883044175737e-19, "-0", "%+1.f", +__LINE__, -8.460545304711022e-01, "-0.846055", "%G", +__LINE__, -8.470462532754567e+12, "-8.47E+12", "%6.3G", +__LINE__, -8.478488782426476e-07, "-8.478489E-07", "%E", +__LINE__, -8.478657582923923e+09, "-8.5e+09", "%.2g", +__LINE__, -8.482732098043366e+12, "-8482732098043", "%5.f", +__LINE__, -8.489112373854447e+07, "-8.489e+07", "%#3.3e", +__LINE__, -8.494153144629106e+02, "-849.415", "%+g", +__LINE__, -8.496331191616493e+28, "-8E+28", "%+6.G", +__LINE__, -8.503711894495339e+05, "-850371", "%g", +__LINE__, -8.505271893964268e+14, "-8.505272E+14", "%E", +__LINE__, -8.509873985358741e+15, "-9.e+15", "%#7.g", +__LINE__, -8.518336897898081e-20, "-8.51834E-20", "%G", +__LINE__, -8.529588044136128e+21, "-8.529588E+21", "%E", +__LINE__, -8.539706586811079e-23, "-8.53971E-23", "%G", +__LINE__, -8.545924619642008e+10, "-8.545925e+10", "%6e", +__LINE__, -8.572893681637353e+09, "-8.57289E+09", "%G", +__LINE__, -8.585483717692345e+29, "-8.58548E+29", "%+G", +__LINE__, -8.586092014292309e+27, "-8.59e+27", "%.2e", +__LINE__, -8.604716827086833e-26, "-8.60472e-26", "%g", +__LINE__, -8.621349224186615e-04, "-0.000862", "%f", +__LINE__, -8.626097065201103e-21, " -0", "%5.f", +__LINE__, -8.631700514212522e-16, "-8.631701E-16", "%+E", +__LINE__, -8.634703359975640e-09, "-0.000000", "%+5f", +__LINE__, -8.639393025443855e-17, "-8.63939e-17", "%g", +__LINE__, -8.640641942556812e-11, "-8.64064e-11", "%#g", +__LINE__, -8.646260250525495e-09, "-0.000", "%.3f", +__LINE__, -8.667322015806242e+09, "-8667322015.806242", "%+#f", +__LINE__, -8.690705655554451e+10, "-8.690706E+10", "%#E", +__LINE__, -8.714299893763934e-07, "-8.7143E-07", "%.5G", +__LINE__, -8.715729756264988e+27, "-8.71573E+27", "%+.6G", +__LINE__, -8.716518487180945e+16, "-9e+16", "%3.e", +__LINE__, -8.744404488756237e+25, "-87444044887562366596966967.335902", "%4f", +__LINE__, -8.754720498369242e+13, "-8.75472e+13", "%g", +__LINE__, -8.763198097931010e-19, "-8.76320e-19", "%#g", +__LINE__, -8.779007408852458e+28, "-8.77901E+28", "%G", +__LINE__, -8.794576202907937e+11, "-8.79458E+11", "%#2.6G", +__LINE__, -8.799091520612418e-11, "-8.799E-11", "%3.4G", +__LINE__, -8.799246265524921e+11, "-8.79925E+11", "%G", +__LINE__, -8.809010508550436e-04, "-8.8090E-04", "%.4E", +__LINE__, -8.817389999872653e-10, "-8.81739e-10", "%g", +__LINE__, -8.842022428985267e-28, "-8.842022E-28", "%E", +__LINE__, -8.851265987586864e-07, "-0.000001", "%f", +__LINE__, -8.861985131432196e+03, "-8861.985", "%+.7G", +__LINE__, -8.874449013455113e-29, "-8.874449e-29", "%e", +__LINE__, -8.878752609483453e+18, "-8.87875E+18", "%G", +__LINE__, -8.882501665315313e-04, "-0.00088825", "%+G", +__LINE__, -8.892056241505784e-14, "-8.89206E-14", "%G", +__LINE__, -8.895327674961603e-30, "-8.89533E-30", "%G", +__LINE__, -8.900059462213669e-30, "-8.900059E-30", "%+#E", +__LINE__, -8.957100548759815e+18, "-9e+18", "%3.0e", +__LINE__, -8.961352369869012e-30, "-8.961352e-30", "%+#2e", +__LINE__, -8.962296474587800e+02, "-896", "%4.f", +__LINE__, -8.962536469328530e-12, "-8.96254E-12", "%G", +__LINE__, -8.963299420391932e+21, "-8.9633e+21", "%g", +__LINE__, -8.967736672941522e-11, "-8.96774e-11", "%g", +__LINE__, -8.994077362462679e+11, "-8.9940774e+11", "%+#.7e", +__LINE__, -9.000452862345622e+15, "-9e+15", "%2.e", +__LINE__, -9.007489135361462e+07, "-9.0075E+07", "%+2.4E", +__LINE__, -9.036271805879910e+16, "-9.03627E+16", "%G", +__LINE__, -9.036319073700248e+22, "-9.03632e+22", "%1g", +__LINE__, -9.043207635989237e+11, "-9.043208e+11", "%#e", +__LINE__, -9.043856598625815e-26, "-9e-26", "%+1.g", +__LINE__, -9.052760561065698e+14, "-9.052761E+14", "%E", +__LINE__, -9.066480297957160e-06, "-9E-06", "%+1.G", +__LINE__, -9.070971376440752e-01, "-0.907097", "%g", +__LINE__, -9.073301831888273e+09, "-9.07330E+09", "%#G", +__LINE__, -9.091228662702147e+28, "-9E+28", "%4.G", +__LINE__, -9.093652024983832e+04, "-9.093652E+04", "%7.6E", +__LINE__, -9.098945831139295e-04, "-9.098946E-04", "%+1.6E", +__LINE__, -9.124981449916591e+05, "-912498", "%G", +__LINE__, -9.132038703003394e-02, "-0.0913204", "%#G", +__LINE__, -9.138271437433964e-04, "-0.000913827", "%5g", +__LINE__, -9.158186427463699e-04, "-0.000915819", "%g", +__LINE__, -9.160846358172526e+16, "-9.160846E+16", "%#E", +__LINE__, -9.160884330810163e+17, "-9E+17", "%+5.G", +__LINE__, -9.190271387375542e+21, "-9.19027e+21", "%+g", +__LINE__, -9.191651872412619e-04, "-9.191652E-04", "%E", +__LINE__, -9.196426161984341e-10, "-9E-10", "%4.G", +__LINE__, -9.201074139774962e+09, "-9E+09", "%4.G", +__LINE__, -9.223294284802762e+09, "-9.22329E+09", "%G", +__LINE__, -9.224740266754996e+02, "-9E+02", "%6.0G", +__LINE__, -9.231583780512302e-01, " -0.9", "%6.g", +__LINE__, -9.241998826543689e+07, "-92419988", "%1.f", +__LINE__, -9.243603351372128e+27, "-9.243603e+27", "%#e", +__LINE__, -9.255922697415071e+11, "-9.25592e+11", "%g", +__LINE__, -9.265734968114124e-02, "-0.092657", "%f", +__LINE__, -9.273132068521061e+11, "-9.27313E+11", "%G", +__LINE__, -9.276017912826685e+27, "-9.E+27", "%+#5.G", +__LINE__, -9.279781279788505e+17, "-9.27978E+17", "%7G", +__LINE__, -9.305057549822465e-19, "-9.30506E-19", "%5G", +__LINE__, -9.313182384508469e+18, "-9.31318E+18", "%G", +__LINE__, -9.313350925182641e-12, "-9.31E-12", "%.3G", +__LINE__, -9.362202657509130e+08, "-9e+08", "%.1g", +__LINE__, -9.367344757598381e+19, "-9.36734e+19", "%g", +__LINE__, -9.374222399774300e+26, "-9.37422e+26", "%4g", +__LINE__, -9.385734023305105e+02, "-9.385734e+02", "%+0e", +__LINE__, -9.392042570618909e+17, "-9.39204E+17", "%G", +__LINE__, -9.395742939311926e+20, "-939574293931192627837.8451", "%.4f", +__LINE__, -9.409066155962469e+09, "-9.40907E+09", "%#G", +__LINE__, -9.412851077799790e+23, "-9.412851E+23", "%E", +__LINE__, -9.431808019049818e+08, "-9.43181e+08", "%g", +__LINE__, -9.465236900519924e-27, "-9.46524e-27", "%g", +__LINE__, -9.478330386415852e+17, "-9.478330e+17", "%e", +__LINE__, -9.510393719697428e+15, "-9.51039E+15", "%+G", +__LINE__, -9.534229599909890e-09, "-0.000000", "%f", +__LINE__, -9.541731189284823e-17, "-1.E-16", "%+#7.G", +__LINE__, -9.548861908445902e+24, "-9548861908445902102471336.547751", "%f", +__LINE__, -9.578447281451794e+14, "-957844728145179", "%5.f", +__LINE__, -9.580512736933464e+11, "-9.58051E+11", "%G", +__LINE__, -9.596838169770637e-28, "-1E-27", "%+6.G", +__LINE__, -9.597528852877852e-22, "-1e-21", "%2.1g", +__LINE__, -9.599943658427051e+02, "-9.599944E+02", "%E", +__LINE__, -9.603227991185260e-14, "-1E-13", "%+0.E", +__LINE__, -9.606818733892343e+08, "-960681873.389", "%1.3f", +__LINE__, -9.617442692720937e+16, "-9.61744E+16", "%G", +__LINE__, -9.628685516961109e+29, "-9.62869e+29", "%3g", +__LINE__, -9.638354750455226e-11, "-0.000000", "%f", +__LINE__, -9.644266379029137e+16, "-96442663790291369.707575", "%f", +__LINE__, -9.645563533575482e+06, "-1E+07", "%1.G", +__LINE__, -9.645993536742941e-29, "-9.64599e-29", "%+g", +__LINE__, -9.647147223548563e+00, "-9.647147e+00", "%e", +__LINE__, -9.671225879906396e-11, "-0", "%0.f", +__LINE__, -9.675000471729906e-09, "-9.675000E-09", "%E", +__LINE__, -9.683992878297159e-26, "-9.68e-26", "%2.2e", +__LINE__, -9.695491325144765e+10, "-9.69549E+10", "%#G", +__LINE__, -9.695661526907136e-24, " -0.", "%#6.f", +__LINE__, -9.703124881970338e+07, "-9.703e+07", "%0.4g", +__LINE__, -9.707701257031864e+26, "-970770125703186437249314622.022212", "%f", +__LINE__, -9.709879792694702e+09, "-9.709880E+09", "%E", +__LINE__, -9.736052226907940e+26, "-9.73605e+26", "%+#g", +__LINE__, -9.745037157520795e+07, "-9.74504e+07", "%#5.6g", +__LINE__, -9.757293950670832e-29, "-9.757E-29", "%0.4G", +__LINE__, -9.762126832689880e+12, "-9.76213E+12", "%G", +__LINE__, -9.801328150341989e-01, " -1", "%7.G", +__LINE__, -9.837332964629669e-20, "-9.83733E-20", "%0G", +__LINE__, -9.837790327283010e+23, "-1E+24", "%.1G", +__LINE__, -9.839636176463729e+23, "-9.83964E+23", "%#6.5E", +__LINE__, -9.841454250618272e+11, "-9.84E+11", "%+2.3G", +__LINE__, -9.852920805249280e-12, "-9.852921e-12", "%.7g", +__LINE__, -9.854092850182351e+12, "-9.85409e+12", "%0g", +__LINE__, -9.866796026839712e+02, "-9.9E+02", "%#.1E", +__LINE__, -9.867413260289803e-21, "-1e-20", "%.1g", +__LINE__, -9.882136052131983e-08, "-9.88214e-08", "%g", +__LINE__, -9.882755697941866e+20, "-9.882756E+20", "%E", +__LINE__, -9.897275811087050e+20, "-9.9E+20", "%0.3G", +__LINE__, -9.899860651812364e-04, "-9.899861e-04", "%e", +__LINE__, -9.906754113555550e-11, "-9.90675e-11", "%3g", +__LINE__, -9.926067557389940e+11, "-9.92607E+11", "%G", +__LINE__, -9.929638609014063e+17, "-992963860901406292.214233", "%1f", +__LINE__, -9.941214552193284e-24, "-0.000000", "%+#f", +__LINE__, -9.942875240256573e+14, "-9.942875e+14", "%+1e", +__LINE__, -9.944492909695798e-01, "-9.944E-01", "%.3E", +__LINE__, -9.954710507359939e-27, "-1e-26", "%+0.2g", +__LINE__, -9.955410507742851e+03, "-9955.41", "%+G", +__LINE__, -9.974437672251590e+02, "-997.444", "%#G", +__LINE__, -9.975683165288929e-26, "-9.97568E-26", "%6G", +__LINE__, 1.003827370583415e+06, "1003827.370583", "%3f", +__LINE__, 1.004189065268560e-27, "1.004189E-27", "%.7G", +__LINE__, 1.005840059175462e-28, "+1.00584E-28", "%+G", +__LINE__, 1.006586790090557e-12, "0.000000", "%#f", +__LINE__, 1.007598594773359e+18, "1.0076E+18", "%G", +__LINE__, 1.007902307001894e+29, "1.0079e+29", "%g", +__LINE__, 1.008607405036580e-15, "1.00861E-15", "%6G", +__LINE__, 1.008769102466771e+16, "+1.00877E+16", "%+G", +__LINE__, 1.009545698372534e-08, "+1E-08", "%+0.0G", +__LINE__, 1.010173673945099e-12, "+1.01017e-12", "%+#0g", +__LINE__, 1.011375000606627e+09, "1011375000.606627", "%f", +__LINE__, 1.011944652221650e+15, "1011944652221649.98", "%3.2f", +__LINE__, 1.013057788090379e-21, "0.000000", "%#f", +__LINE__, 1.014525729953198e+15, "1.01453e+15", "%3g", +__LINE__, 1.016760538234615e-21, "+1.016761E-21", "%+3E", +__LINE__, 1.017052611781237e-29, "0.000000", "%f", +__LINE__, 1.018471223361229e+14, "1.01847E+14", "%G", +__LINE__, 1.021646959220873e+15, "1021646959220872.6", "%4.1f", +__LINE__, 1.022304833976590e+27, "1.0223e+27", "%g", +__LINE__, 1.022500312067325e-12, "1.0225e-12", "%6g", +__LINE__, 1.023019285462627e-20, "0.000000", "%f", +__LINE__, 1.024192579400824e+06, "1.02419e+06", "%g", +__LINE__, 1.024517953555766e-28, "1.02452E-28", "%G", +__LINE__, 1.026673589339585e+21, "1.02667E+21", "%G", +__LINE__, 1.027231090958880e-19, "1.E-19", "%#3.G", +__LINE__, 1.028249904956487e-27, "1E-27", "%5.G", +__LINE__, 1.028570144661448e-28, "+1.02857E-28", "%+G", +__LINE__, 1.028934898454705e-13, "+1.028935E-13", "%+E", +__LINE__, 1.029071053545906e-26, "1.029071E-26", "%E", +__LINE__, 1.032672895881148e-30, "+1.032673E-30", "%+E", +__LINE__, 1.033502358979511e+06, "1.0335E+06", "%.5G", +__LINE__, 1.036790427717847e+19, "1e+19", "%4.g", +__LINE__, 1.037022928821648e+03, "1037.02", "%5g", +__LINE__, 1.040551683941284e+14, "1.04055E+14", "%G", +__LINE__, 1.044499252101308e-17, "1.044499E-17", "%E", +__LINE__, 1.045791899570889e+15, "+1.04579e+15", "%+g", +__LINE__, 1.048730383198703e+28, "1.049e+28", "%.4g", +__LINE__, 1.050654419882509e-18, "0.000000", "%f", +__LINE__, 1.052600569262127e-27, "+0.000", "%+2.3f", +__LINE__, 1.053213014784149e+15, "1E+15", "%4.G", +__LINE__, 1.057553916225948e-15, "+0.000000", "%+4f", +__LINE__, 1.058191244482453e+19, "1.058e+19", "%.3e", +__LINE__, 1.058746269793972e-26, "+1.1E-26", "%+.2G", +__LINE__, 1.058793271960762e-01, "+1.058793E-01", "%+4E", +__LINE__, 1.058869592738370e-19, "1.05887e-19", "%3g", +__LINE__, 1.060402312803008e+15, "1060402312803008.229025", "%f", +__LINE__, 1.061106284763095e+00, "1.061106", "%0f", +__LINE__, 1.061180160987467e+09, "1e+09", "%2.g", +__LINE__, 1.061181537176067e-06, "+1.06118e-06", "%+g", +__LINE__, 1.065021381771174e+20, "1.06502e+20", "%g", +__LINE__, 1.065464040401130e-16, "1.065464e-16", "%e", +__LINE__, 1.065573419819459e-05, "0.00001", "%.5f", +__LINE__, 1.066107764306644e+13, "1.066108e+13", "%#e", +__LINE__, 1.071318759598956e+12, "1.071319e+12", "%e", +__LINE__, 1.071564727222321e+10, "1.072E+10", "%3.4G", +__LINE__, 1.074652481218139e+14, "1.0747E+14", "%.4E", +__LINE__, 1.078453684911309e-02, "0.0107845", "%g", +__LINE__, 1.078550811446675e-05, "1.07855e-05", "%g", +__LINE__, 1.078780494515273e-04, "0.000107878", "%4G", +__LINE__, 1.079467488876157e-16, "+1.079467E-16", "%+E", +__LINE__, 1.080529722917934e-20, "0.000000", "%f", +__LINE__, 1.082169127709439e+01, "10.8217", "%#5g", +__LINE__, 1.087241285590951e+22, "1E+22", "%4.G", +__LINE__, 1.091049208406195e-14, "0.0000", "%.4f", +__LINE__, 1.095316064213237e+16, "+1e+16", "%+0.g", +__LINE__, 1.095349083237975e-04, "1.095349e-04", "%5e", +__LINE__, 1.098002465452836e+12, "1098002465452.836205", "%f", +__LINE__, 1.098445764138997e+13, "1.09845E+13", "%G", +__LINE__, 1.099968047892474e-13, "1.1e-13", "%2.5g", +__LINE__, 1.101017598311363e-04, "0.000110102", "%G", +__LINE__, 1.102776332077817e+18, "1.103e+18", "%.3e", +__LINE__, 1.103734053887830e-01, "0.110373", "%f", +__LINE__, 1.105730106869006e-03, "0.00110573", "%g", +__LINE__, 1.106366781854058e-10, "1.10637e-10", "%g", +__LINE__, 1.107354763213839e+15, "1.107355e+15", "%6e", +__LINE__, 1.108151709609825e-10, "+1.10815E-10", "%+G", +__LINE__, 1.110054501993647e+21, "+1.11005E+21", "%+G", +__LINE__, 1.111574814737873e-17, "+1.112E-17", "%+1.4G", +__LINE__, 1.111865512360108e-15, "1E-15", "%.0G", +__LINE__, 1.112281568330498e-03, "1.112282e-03", "%.6e", +__LINE__, 1.112625415174238e+21, "+1.11263e+21", "%+g", +__LINE__, 1.112744974910395e-02, "0.011127", "%f", +__LINE__, 1.114726566979885e-10, "1.11473e-10", "%g", +__LINE__, 1.115395843055731e-20, "+0.000000", "%+6f", +__LINE__, 1.115983414693121e+15, "1.11598e+15", "%5.6g", +__LINE__, 1.116118842074266e+27, "1.116119e+27", "%e", +__LINE__, 1.118386983012328e+19, "11183869830123276400.968280", "%1f", +__LINE__, 1.119344607892718e-22, "1.119345e-22", "%e", +__LINE__, 1.120560837110279e-19, "0.000000", "%f", +__LINE__, 1.123620157906291e-02, "0.0112362", "%G", +__LINE__, 1.126804857639478e+29, "1.1268E+29", "%#0.5G", +__LINE__, 1.128962199461581e+11, "1.12896e+11", "%g", +__LINE__, 1.129878714246809e-16, "1E-16", "%0.0G", +__LINE__, 1.130331982972407e-06, "+0.", "%+#1.f", +__LINE__, 1.134167332070028e-16, "0", "%0.0f", +__LINE__, 1.134248080053598e-28, "0.000000", "%f", +__LINE__, 1.136023160708119e-10, "+0.000000", "%+1f", +__LINE__, 1.136167141059036e+23, "113616714105903593434732.101741", "%f", +__LINE__, 1.136439499920164e+10, "+1.13644E+10", "%+G", +__LINE__, 1.136859734932182e+24, "1.13686e+24", "%g", +__LINE__, 1.138985939448731e+09, "1.13899e+09", "%2g", +__LINE__, 1.139287324790407e-25, "1e-25", "%.1g", +__LINE__, 1.140559912153251e+06, "1.14056e+06", "%g", +__LINE__, 1.141318036027086e-26, "1.14132E-26", "%G", +__LINE__, 1.142586049368452e-20, "+1.14259E-20", "%+7.5E", +__LINE__, 1.143283863993333e-17, "1.143284E-17", "%3E", +__LINE__, 1.144637911632432e-28, "1.144638E-28", "%#3E", +__LINE__, 1.145791416532065e-10, "1.14579e-10", "%g", +__LINE__, 1.146958047315780e-17, "1.146958e-17", "%e", +__LINE__, 1.147898346886569e-08, "1E-08", "%3.0E", +__LINE__, 1.149724744965608e-14, "1.14972e-14", "%5g", +__LINE__, 1.155383721940441e-10, "1e-10", "%1.g", +__LINE__, 1.157066617729094e-02, "0", "%1.f", +__LINE__, 1.157893614537215e+05, "1.157894E+05", "%E", +__LINE__, 1.160476344451928e-19, "1.2e-19", "%.1e", +__LINE__, 1.161610499315966e-26, "1.161610E-26", "%E", +__LINE__, 1.162345042181490e+29, "116234504218148981813385489658.685401", "%5.6f", +__LINE__, 1.162376053722862e+23, "1.16238e+23", "%g", +__LINE__, 1.162996084782483e+18, "+1e+18", "%+0.g", +__LINE__, 1.163544861478966e+26, "1.16354E+26", "%G", +__LINE__, 1.167300137450931e+06, "1E+06", "%.0G", +__LINE__, 1.168693829096401e-30, "+1.16869e-30", "%+g", +__LINE__, 1.172791369381396e+15, "1.173E+15", "%.4G", +__LINE__, 1.174427110782028e-29, " 1E-29", "%7.G", +__LINE__, 1.179498322112450e+27, "1179498322112449759657692993.641831", "%f", +__LINE__, 1.179555606293547e+27, "1.17956e+27", "%3g", +__LINE__, 1.180815814881269e+06, "1.180816e+06", "%e", +__LINE__, 1.181494870072805e+20, "1.181495e+20", "%5e", +__LINE__, 1.181524119225619e+12, "+1181524119225.61917", "%+5.5f", +__LINE__, 1.182111212289243e-20, "1e-20", "%4.g", +__LINE__, 1.184503315019769e-27, "1.1845e-27", "%7g", +__LINE__, 1.186413646767670e+29, "1.18641e+29", "%g", +__LINE__, 1.186852938885004e-13, "1.18685e-13", "%4g", +__LINE__, 1.188837612473914e+05, "1e+05", "%.0g", +__LINE__, 1.190317482928293e-29, "1.190317e-29", "%e", +__LINE__, 1.190527491143987e+02, "1.190527E+02", "%E", +__LINE__, 1.191823062060233e-30, "1.2E-30", "%6.2G", +__LINE__, 1.191926974812428e-23, "1.2e-23", "%.2g", +__LINE__, 1.193549622366544e-25, "1E-25", "%4.1G", +__LINE__, 1.195517368629765e-21, "1.195517e-21", "%1.7g", +__LINE__, 1.195573061651289e-27, "1.19557e-27", "%#g", +__LINE__, 1.195806681188325e-03, "+0.00120", "%+#.3G", +__LINE__, 1.196842275192189e-28, "1.19684e-28", "%g", +__LINE__, 1.197307550969576e+04, "1.1973E+04", "%.4E", +__LINE__, 1.197608525847607e+15, "1197608525847606.8062805", "%4.7f", +__LINE__, 1.197801338159407e+04, "11978", "%5G", +__LINE__, 1.197813329735025e+27, "1.19781E+27", "%7G", +__LINE__, 1.199483904123253e-12, "1.19948e-12", "%g", +__LINE__, 1.199535292169766e-09, "1.199535e-09", "%e", +__LINE__, 1.201478067515135e+05, "120147.806752", "%f", +__LINE__, 1.202054662662158e+17, "1.20205E+17", "%#G", +__LINE__, 1.202111922368321e+07, "+1.202112E+07", "%+#E", +__LINE__, 1.202536892743791e-01, "0.120254", "%#g", +__LINE__, 1.205698674119882e-29, "1.2057E-29", "%G", +__LINE__, 1.208091664701942e-13, " 0.", "%#3.f", +__LINE__, 1.208942413954872e-17, "1.20894E-17", "%G", +__LINE__, 1.209704891496613e+10, "1.210e+10", "%2.3e", +__LINE__, 1.211355639334831e+29, "1E+29", "%.0G", +__LINE__, 1.211447553804203e+17, " 1E+17", "%7.E", +__LINE__, 1.212481583429790e-16, "1.212482e-16", "%e", +__LINE__, 1.212849001551862e+26, "121284900155186181613942153.4899157", "%6.7f", +__LINE__, 1.213057538677801e+06, "1213057.538678", "%#.6f", +__LINE__, 1.214609592911893e+25, "1.214610e+25", "%#e", +__LINE__, 1.216086266251665e+01, "1e+01", "%5.e", +__LINE__, 1.216468565931026e-22, "1.216469E-22", "%1E", +__LINE__, 1.216503126598765e+14, "+1E+14", "%+0.E", +__LINE__, 1.216641013695553e-14, "0.000000", "%f", +__LINE__, 1.223142246779504e-23, "0.000000", "%f", +__LINE__, 1.223884786443274e+08, "122388479", "%5.f", +__LINE__, 1.224012562770076e+29, "1.22401e+29", "%0g", +__LINE__, 1.225098157528297e+14, "1.22510e+14", "%#g", +__LINE__, 1.226306848505242e-22, "1.22631E-22", "%G", +__LINE__, 1.227487485547996e-08, "+1.22749e-08", "%+g", +__LINE__, 1.237206486909689e+02, "+123.721", "%+#.6g", +__LINE__, 1.240281126177077e-02, "+0.01", "%+3.g", +__LINE__, 1.241197211306994e-06, "1.241197E-06", "%E", +__LINE__, 1.241776311097410e+07, "1.241776E+07", "%E", +__LINE__, 1.245995986024999e-03, "0.001246", "%g", +__LINE__, 1.246082428199607e+03, "1246.082428", "%f", +__LINE__, 1.247021567954220e+05, " 1e+05", "%7.g", +__LINE__, 1.248140089618390e-30, "+1.24814E-30", "%+G", +__LINE__, 1.248403361652064e-30, "+0.000000", "%+f", +__LINE__, 1.251098538918842e-26, "+1.251099E-26", "%+E", +__LINE__, 1.251952633022061e+25, "1.25195e+25", "%g", +__LINE__, 1.253029705843461e-04, "+1.E-04", "%+#4.E", +__LINE__, 1.259562132729488e-09, "1e-09", "%1.e", +__LINE__, 1.261702205492260e-27, "0.000000", "%f", +__LINE__, 1.265910361926660e-19, "+1.265910e-19", "%+e", +__LINE__, 1.267411912651087e+12, "1.26741E+12", "%1G", +__LINE__, 1.267830718285980e-10, "1.26783e-10", "%g", +__LINE__, 1.268238378987517e-23, "1E-23", "%5.E", +__LINE__, 1.275543253354167e+10, "1.27554E+10", "%G", +__LINE__, 1.277255234454465e-10, "1.27726E-10", "%5G", +__LINE__, 1.280590949834150e-21, "1.280591E-21", "%E", +__LINE__, 1.285570453788242e-02, "1.285570E-02", "%E", +__LINE__, 1.287712130719031e+09, "1287712130.719031", "%#f", +__LINE__, 1.290142876187105e+29, "+1.290143E+29", "%+E", +__LINE__, 1.293129213191961e+21, "1.29313E+21", "%G", +__LINE__, 1.293317101334714e-23, "+0.000000", "%+f", +__LINE__, 1.294506813069071e-13, "0.0", "%3.1f", +__LINE__, 1.295576232685739e-22, "+0.000000", "%+f", +__LINE__, 1.296010470431800e-19, "+0.000000", "%+6f", +__LINE__, 1.298798231947674e+19, "1.2988E+19", "%2G", +__LINE__, 1.299521114379381e+09, "1.29952E+09", "%G", +__LINE__, 1.299847637892712e+24, "1.299848e+24", "%e", +__LINE__, 1.301269777843698e+29, "130126977784369834978406288428.232074", "%f", +__LINE__, 1.302911786437618e-15, " 0", "%6.f", +__LINE__, 1.303863159906719e+27, "1303863159906719415559450681", "%0.f", +__LINE__, 1.304396472326846e-12, "+1E-12", "%+1.0G", +__LINE__, 1.306180443528427e-30, "+1e-30", "%+.1g", +__LINE__, 1.308469138968514e+22, "1.30847E+22", "%0G", +__LINE__, 1.312700156826057e-11, "1.3127e-11", "%g", +__LINE__, 1.315364075120764e+21, "+1.31536E+21", "%+G", +__LINE__, 1.320376485288444e-09, "+1.3204E-09", "%+6.5G", +__LINE__, 1.321434154364635e-08, "1.32143e-08", "%1g", +__LINE__, 1.322777272579176e+19, "+1e+19", "%+3.e", +__LINE__, 1.322861663428564e+00, "1.322862E+00", "%#E", +__LINE__, 1.323566013489230e+14, "+1.323566E+14", "%+1E", +__LINE__, 1.327446904132973e-20, "+1.32745E-20", "%+4.6G", +__LINE__, 1.328226362528158e+19, "1e+19", "%2.g", +__LINE__, 1.329167460803610e+08, "1e+08", "%3.g", +__LINE__, 1.335371420823160e+14, "1.33537E+14", "%7G", +__LINE__, 1.336116185095935e-21, "0.000000", "%f", +__LINE__, 1.338766774704671e-22, "+1.33877e-22", "%+g", +__LINE__, 1.339199373014647e-12, "1E-12", "%1.E", +__LINE__, 1.344293357481519e+26, "134429335748151945750805680.290796", "%#2f", +__LINE__, 1.344328188122843e+29, "1.34433e+29", "%g", +__LINE__, 1.344382581316972e-05, "1E-05", "%5.0E", +__LINE__, 1.349835616116184e+11, "134983561611.6", "%2.1f", +__LINE__, 1.349955669989707e+20, "134995566998970728533.890906", "%7f", +__LINE__, 1.350230411093841e+20, "135023041109384145386.229648", "%f", +__LINE__, 1.353391369565576e+10, " 1E+10", "%7.1G", +__LINE__, 1.356889483699471e+22, "+1.35689E+22", "%+G", +__LINE__, 1.358141775798243e+24, "+1358141775798242578687791.137781", "%+f", +__LINE__, 1.358547541975523e-15, "1.35855e-15", "%g", +__LINE__, 1.363402539800791e+11, "1.3634E+11", "%G", +__LINE__, 1.363676837988798e+16, "+13636768379887982.4053", "%+2.4f", +__LINE__, 1.364592026494839e-24, "1.36459e-24", "%g", +__LINE__, 1.366664212399413e-09, "+1E-09", "%+6.G", +__LINE__, 1.367446193117463e-17, "1.3674e-17", "%2.4e", +__LINE__, 1.368681648785823e-18, "1.36868E-18", "%3G", +__LINE__, 1.370635189583606e+05, "1.370635E+05", "%E", +__LINE__, 1.371395540772186e-18, "+1.371396e-18", "%+e", +__LINE__, 1.371945318043159e+10, "1E+10", "%0.E", +__LINE__, 1.373780604772988e-21, "1e-21", "%3.g", +__LINE__, 1.374244970441862e-28, "0.000000", "%7.6f", +__LINE__, 1.375874695067149e-25, "1.37587E-25", "%#3G", +__LINE__, 1.377165614832621e+20, "1.37717E+20", "%#G", +__LINE__, 1.381541864946684e-09, "1.38154E-09", "%G", +__LINE__, 1.382901694835415e+00, "1.382902E+00", "%E", +__LINE__, 1.384250577530184e-21, "1.384e-21", "%.4g", +__LINE__, 1.385322753374640e-03, " 1E-03", "%6.E", +__LINE__, 1.387026156054724e+19, "1.387026E+19", "%E", +__LINE__, 1.388726735790498e-27, "+1.388727E-27", "%+E", +__LINE__, 1.388819105742044e+16, "1.38882e+16", "%g", +__LINE__, 1.389941086024951e-19, "0.000000", "%f", +__LINE__, 1.390101174785536e+25, "1.3901E+25", "%G", +__LINE__, 1.392210785638597e+24, "+1.39221E+24", "%+G", +__LINE__, 1.396148856283474e-26, "1.4e-26", "%7.3g", +__LINE__, 1.398153728631994e-21, "1.39815E-21", "%G", +__LINE__, 1.398332446762342e-14, "+1.39833E-14", "%+5G", +__LINE__, 1.400250919607987e+10, "1.40025E+10", "%G", +__LINE__, 1.400662469019739e+03, "1.E+03", "%#0.0E", +__LINE__, 1.401720273747805e-12, "0.000000", "%#f", +__LINE__, 1.402151358748719e+22, "1.402151e+22", "%e", +__LINE__, 1.402351913752357e-28, "1.40235E-28", "%#1.6G", +__LINE__, 1.403285877973810e+13, "+14032858779738.097255", "%+4f", +__LINE__, 1.404540981735861e+04, "14045.409817", "%4f", +__LINE__, 1.406420622355064e+19, "1.40642E+19", "%G", +__LINE__, 1.412552725962301e-29, "+1e-29", "%+1.e", +__LINE__, 1.413266982485044e+10, "1.41327e+10", "%g", +__LINE__, 1.413627189411456e+21, "1.41363E+21", "%0G", +__LINE__, 1.416647216002592e-25, "+0.000000", "%+#f", +__LINE__, 1.417107155080584e-10, "1e-10", "%1.e", +__LINE__, 1.418829895346648e+19, "14188298953466484952.912197", "%f", +__LINE__, 1.419404559267523e-11, "1.4194e-11", "%g", +__LINE__, 1.422421321425472e+15, "1.422421E+15", "%E", +__LINE__, 1.424858902008998e+18, "1.42486E+18", "%2.5E", +__LINE__, 1.428863051254205e+22, "1.428863e+22", "%e", +__LINE__, 1.429533727936725e-02, "0.0142953", "%g", +__LINE__, 1.430982219743369e-19, " 1E-19", "%6.G", +__LINE__, 1.431974118434703e+17, "1E+17", "%3.G", +__LINE__, 1.432418341970152e+16, "+1.432418e+16", "%+5e", +__LINE__, 1.433470281650523e+04, "14334.7", "%g", +__LINE__, 1.434446243424653e+24, " +1e+24", "%+7.g", +__LINE__, 1.435118019241039e+24, "+1e+24", "%+4.g", +__LINE__, 1.435691648420278e-01, "0.1435692", "%#4.7g", +__LINE__, 1.437569598098744e+27, "1.437570E+27", "%#E", +__LINE__, 1.437633484061726e-25, "+1.43763e-25", "%+7g", +__LINE__, 1.437866591230707e-13, "1.43787e-13", "%g", +__LINE__, 1.440593154445915e-01, "+0.144059", "%+1G", +__LINE__, 1.441368205977342e+16, "1.441368E+16", "%#E", +__LINE__, 1.441825266684367e+28, "1.44183e+28", "%g", +__LINE__, 1.442374183199456e+20, "1.442374E+20", "%E", +__LINE__, 1.445101893951061e-24, "0", "%0.f", +__LINE__, 1.446037835160094e-20, "+1.44604E-20", "%+2G", +__LINE__, 1.449245376093616e+04, "1.449245e+04", "%e", +__LINE__, 1.454126845620100e+09, "1.45413E+09", "%G", +__LINE__, 1.455764608801107e+09, "1.5e+09", "%6.1e", +__LINE__, 1.457176183149955e-12, "1.45718e-12", "%#g", +__LINE__, 1.458821535020046e-05, "1.45882e-05", "%#g", +__LINE__, 1.460179141161202e-19, "1.460179E-19", "%#E", +__LINE__, 1.461701055446198e-20, "1.461701e-20", "%#2.7g", +__LINE__, 1.462408181482172e+10, "1.4624082E+10", "%3.7E", +__LINE__, 1.463706296748154e+24, "1e+24", "%2.g", +__LINE__, 1.464891255780761e-19, "+1.46489e-19", "%+g", +__LINE__, 1.467903978945872e+25, "1.4679E+25", "%G", +__LINE__, 1.468585992857062e+22, "14685859928570619281629.205943", "%f", +__LINE__, 1.469803528668286e+29, "+1E+29", "%+6.G", +__LINE__, 1.469883002609266e-23, "1.E-23", "%#2.E", +__LINE__, 1.469941481858809e+08, "+146994148.185881", "%+f", +__LINE__, 1.470744493304611e+13, "1.47074e+13", "%g", +__LINE__, 1.471857261085004e+23, "1E+23", "%2.G", +__LINE__, 1.474419778873037e+06, "1474419.7789", "%#.4f", +__LINE__, 1.483134762223381e-03, "0", "%0.0f", +__LINE__, 1.483575501240724e-13, "1.48358e-13", "%g", +__LINE__, 1.486068112294452e+20, "1.486068e+20", "%e", +__LINE__, 1.488665528787761e-03, " +0", "%+4.f", +__LINE__, 1.492145267536713e+07, "14921452.675367", "%f", +__LINE__, 1.492589762884761e-01, "0.149259", "%f", +__LINE__, 1.494784286168215e+01, "1.494784E+01", "%E", +__LINE__, 1.495945331501655e+04, "1.5e+04", "%.2g", +__LINE__, 1.501383201904700e+14, "2e+14", "%1.g", +__LINE__, 1.501387105011959e-02, "0.0150139", "%g", +__LINE__, 1.505784488562271e+26, "1.50578e+26", "%5g", +__LINE__, 1.506367986495534e+10, "1.50637e+10", "%2g", +__LINE__, 1.507421710226296e+19, "1.507422E+19", "%#E", +__LINE__, 1.507960881206134e+16, "2e+16", "%.0g", +__LINE__, 1.508974301049424e+14, "+1.508974E+14", "%+E", +__LINE__, 1.509204025111090e-18, "1.509204E-18", "%E", +__LINE__, 1.511351799767759e+21, "1511351799767759462866.93397", "%.5f", +__LINE__, 1.511712197184520e-06, "+1.51171e-06", "%+1g", +__LINE__, 1.514703727491400e+02, "151.47", "%.5g", +__LINE__, 1.514855355408287e+04, "15148.6", "%g", +__LINE__, 1.516256896575301e+06, "1.516257e+06", "%.6e", +__LINE__, 1.517712083681069e+14, "1.51771e+14", "%0g", +__LINE__, 1.522102209167607e-18, "1.52210e-18", "%#g", +__LINE__, 1.526264862895663e-12, "0.000000", "%f", +__LINE__, 1.527165480858125e+10, "1.527e+10", "%.4g", +__LINE__, 1.528363280308369e+00, "+1.52836", "%+0G", +__LINE__, 1.529108490733420e-22, "1.529108E-22", "%E", +__LINE__, 1.529783364474522e+19, "15297833644745216119.531506", "%7f", +__LINE__, 1.530698363199346e-01, "0.1531", "%#.4f", +__LINE__, 1.531520796537450e+22, "1.53152E+22", "%G", +__LINE__, 1.533314559644813e+06, "+1533314.559645", "%+f", +__LINE__, 1.534682791112854e+01, "+15.3468", "%+0G", +__LINE__, 1.534714026386730e-11, "0.000000", "%f", +__LINE__, 1.537145729498115e+00, "1.537146E+00", "%E", +__LINE__, 1.538740040875751e-23, "1.538740E-23", "%E", +__LINE__, 1.546248240596482e-03, "0.001546", "%f", +__LINE__, 1.546808012239302e-09, "+1.54681E-09", "%+G", +__LINE__, 1.546903877359107e+06, "1.5e+06", "%.2g", +__LINE__, 1.550153973747718e-18, "2e-18", "%.0g", +__LINE__, 1.551703460384378e+00, "+1.5517", "%+.4f", +__LINE__, 1.553995673101369e+29, "1.554E+29", "%G", +__LINE__, 1.555477017531899e+28, "1.55548e+28", "%g", +__LINE__, 1.555548963448462e+12, "1555548963448.46227", "%6.5f", +__LINE__, 1.558702451007712e+16, "2e+16", "%5.1g", +__LINE__, 1.561641587723724e+29, "1.561642e+29", "%e", +__LINE__, 1.561868589559509e-05, "1.56187E-05", "%G", +__LINE__, 1.565229056438949e+13, "1.56523e+13", "%1.6g", +__LINE__, 1.570074406600442e+14, "+1.57007E+14", "%+4G", +__LINE__, 1.570951909913194e+13, "1.57095E+13", "%.6G", +__LINE__, 1.572186421520727e-30, "+1.57219e-30", "%+g", +__LINE__, 1.574374582066945e+12, "1.57e+12", "%5.2e", +__LINE__, 1.577789404823585e+12, "1.577789E+12", "%E", +__LINE__, 1.579641278389186e+04, "15796.413", "%7.3f", +__LINE__, 1.581602330975388e+17, "1.5816E+17", "%#.5G", +__LINE__, 1.587809692297490e-18, "+1.58781e-18", "%+2g", +__LINE__, 1.588672954832388e-05, "1.58867E-05", "%G", +__LINE__, 1.594548954259978e+25, "+1.595e+25", "%+.3e", +__LINE__, 1.596653742160718e+10, "15966537421.6072", "%.4f", +__LINE__, 1.597416186584641e+25, "1.59742e+25", "%g", +__LINE__, 1.597810706039500e-04, "0.000159781", "%g", +__LINE__, 1.601425691153542e+01, "16.0143", "%G", +__LINE__, 1.601491150913706e-15, "+1.60149e-15", "%+g", +__LINE__, 1.609357026469645e+02, "160.936", "%0g", +__LINE__, 1.611064881461188e+06, "+1.611065E+06", "%+E", +__LINE__, 1.611324319640770e-03, "0.00161132", "%G", +__LINE__, 1.613202907940803e+19, "1.6E+19", "%#.1E", +__LINE__, 1.613883500056636e-12, "0.000000", "%5f", +__LINE__, 1.618254213010772e+07, "16182542.130108", "%6f", +__LINE__, 1.620441271211248e-08, "1.62044E-08", "%0G", +__LINE__, 1.622548435024803e-01, "+0.162255", "%+5G", +__LINE__, 1.623740394555269e+19, "16237403945552689066.289531", "%3f", +__LINE__, 1.625774250389937e+18, "1.625774e+18", "%1e", +__LINE__, 1.626300864432426e-02, "0.016263", "%G", +__LINE__, 1.626351146877694e-11, "1.6263511e-11", "%2.7e", +__LINE__, 1.626568757587995e+25, "16265687575879949733348439.62220", "%6.5f", +__LINE__, 1.626717482094360e-28, "+1.626717e-28", "%+3e", +__LINE__, 1.630801585998995e-28, "1.6308e-28", "%0g", +__LINE__, 1.631827173682962e+03, "1632", "%1.4g", +__LINE__, 1.631907571243379e+18, "1631907571243378818.337533", "%f", +__LINE__, 1.632058420447239e-14, " +2E-14", "%+7.G", +__LINE__, 1.632847882621240e+18, "+1.63285E+18", "%+2G", +__LINE__, 1.637329146233172e-09, "+1.63733e-09", "%+g", +__LINE__, 1.638315287442427e-16, "+1.63832E-16", "%+G", +__LINE__, 1.641284849351445e+15, "1641284849351445.096488", "%f", +__LINE__, 1.644871927486929e+10, "2e+10", "%1.e", +__LINE__, 1.645917293047431e-19, "1.64592e-19", "%.6g", +__LINE__, 1.649201265647819e-07, "0.000000", "%f", +__LINE__, 1.650169065733559e+23, "165016906573355903731226.135278", "%3f", +__LINE__, 1.651217291298196e-30, "2E-30", "%4.G", +__LINE__, 1.652680660160331e+08, "2.e+08", "%#3.g", +__LINE__, 1.654171892948767e-15, "1.65417e-15", "%g", +__LINE__, 1.655435863725412e+17, "+1.655436e+17", "%+#e", +__LINE__, 1.656015606204101e+28, "+1.7E+28", "%+3.2G", +__LINE__, 1.656814723110478e-21, "+0.000000", "%+f", +__LINE__, 1.658632655199721e-19, "2.E-19", "%#4.G", +__LINE__, 1.659915061311444e+27, "1.66E+27", "%.3G", +__LINE__, 1.664258574522914e-29, "+1.664259E-29", "%+E", +__LINE__, 1.667662840654469e-28, "+2e-28", "%+0.g", +__LINE__, 1.673124993246863e-25, "+0.000000", "%+f", +__LINE__, 1.677788498058833e-20, "1.678e-20", "%.4g", +__LINE__, 1.681211731173386e-07, "1.68121e-07", "%0.6g", +__LINE__, 1.686341560076196e+02, "169", "%.0f", +__LINE__, 1.686507685287281e+08, "1.686508E+08", "%E", +__LINE__, 1.689500448795801e+03, "+1689.500449", "%+0f", +__LINE__, 1.690639426041009e-13, "2e-13", "%5.0g", +__LINE__, 1.691554939595928e+16, "+1.6916e+16", "%+.5g", +__LINE__, 1.698597126229626e-09, "1.699e-09", "%3.4g", +__LINE__, 1.700093083173516e+16, "17000930831735159", "%5.f", +__LINE__, 1.703653732982710e+13, "+1.70365e+13", "%+g", +__LINE__, 1.705353380573352e-16, "0.000000", "%f", +__LINE__, 1.705973328700179e-26, "1.70597e-26", "%5g", +__LINE__, 1.717797289369145e+22, "+1.717797E+22", "%+7E", +__LINE__, 1.722819196705361e-28, "1.722819E-28", "%1.7G", +__LINE__, 1.723775772891202e+01, "17.237758", "%f", +__LINE__, 1.723787102325353e-23, "0.000000", "%2f", +__LINE__, 1.724551301171870e-13, "0.000000", "%f", +__LINE__, 1.726098078655758e-20, "0.0000000", "%7.7f", +__LINE__, 1.726302822039762e+18, "+2E+18", "%+1.G", +__LINE__, 1.726659209108151e+18, "+1.72666E+18", "%+6G", +__LINE__, 1.728324925097269e-25, "1.728325e-25", "%7e", +__LINE__, 1.728357491215602e+02, "172.836", "%G", +__LINE__, 1.729612227517587e+22, "1.729612e+22", "%e", +__LINE__, 1.731753104740805e-06, "1.73175e-06", "%2g", +__LINE__, 1.736066279733589e+18, "+1.736066E+18", "%+3E", +__LINE__, 1.736626769480182e-19, "2e-19", "%.0g", +__LINE__, 1.737445267713118e-13, " 2e-13", "%7.g", +__LINE__, 1.739264683023077e+05, "173926.468302", "%f", +__LINE__, 1.739423702667596e-16, "+1.73942e-16", "%+g", +__LINE__, 1.741053616961658e-14, "1.74105E-14", "%G", +__LINE__, 1.741085952255057e+29, "1.7e+29", "%#.1e", +__LINE__, 1.743673705633426e+03, "2E+03", "%5.0G", +__LINE__, 1.750940899205665e+27, "1.75094e+27", "%g", +__LINE__, 1.753871003884151e-26, "0.", "%#.0f", +__LINE__, 1.755237470854478e-14, "1.755237e-14", "%4e", +__LINE__, 1.757491419837315e-03, "0.002", "%1.G", +__LINE__, 1.758657797688126e+26, "+1.75866E+26", "%+#G", +__LINE__, 1.760491452270889e+08, "1.76049E+08", "%G", +__LINE__, 1.760816275862939e-10, "2e-10", "%.1g", +__LINE__, 1.760905893493003e-22, "1.76e-22", "%.2e", +__LINE__, 1.762101125986743e-12, "2e-12", "%.0g", +__LINE__, 1.763855968659571e+27, "1.763856E+27", "%E", +__LINE__, 1.764595217341348e-13, "1.764595E-13", "%E", +__LINE__, 1.766737296048445e+08, "+1.77e+08", "%+.3g", +__LINE__, 1.769916386969961e-05, "+1.76992e-05", "%+g", +__LINE__, 1.773873506344176e-01, "1.773874e-01", "%e", +__LINE__, 1.775392554371421e+03, "+1775.39", "%+3.2f", +__LINE__, 1.776007623006870e+24, "1776007623006870161930237.372871", "%f", +__LINE__, 1.777418921678653e-27, " 0", "%6.f", +__LINE__, 1.780967607234234e-18, "1.780968E-18", "%E", +__LINE__, 1.782510583486435e+24, "+2e+24", "%+3.g", +__LINE__, 1.784002921603004e+14, "1.784E+14", "%G", +__LINE__, 1.784231151778382e+11, "1.7842E+11", "%.5G", +__LINE__, 1.785589091453195e+02, " 179.", "%#5.f", +__LINE__, 1.786402639400039e+19, "2e+19", "%0.g", +__LINE__, 1.786506485794647e-25, "2E-25", "%.1G", +__LINE__, 1.787513971482493e-04, "+0.000178751", "%+G", +__LINE__, 1.799765409320039e+23, "179976540932003885586710", "%6.0f", +__LINE__, 1.800451864218989e+08, "+1.80045e+08", "%+g", +__LINE__, 1.800743538258572e+04, " +18007", "%+7.f", +__LINE__, 1.801583764453362e+25, "1.8016e+25", "%0.5g", +__LINE__, 1.804502093739547e+14, "2e+14", "%2.g", +__LINE__, 1.805600104488678e-17, "1.805600E-17", "%E", +__LINE__, 1.811342448081048e+17, "1.811342e+17", "%.6e", +__LINE__, 1.812252160066930e+19, "2e+19", "%0.e", +__LINE__, 1.816287564395273e+02, "182", "%2.f", +__LINE__, 1.817097386762552e-13, "2E-13", "%3.1G", +__LINE__, 1.817881381387254e+06, "1.81788E+06", "%G", +__LINE__, 1.818416380830953e-30, "1.81842E-30", "%G", +__LINE__, 1.824788290177454e-23, "1.82479e-23", "%g", +__LINE__, 1.827832506678437e-18, "1.82783E-18", "%G", +__LINE__, 1.828048053242609e+01, "18.2805", "%g", +__LINE__, 1.828939681844203e-21, "1.82894E-21", "%.6G", +__LINE__, 1.829763900251753e+12, "1829763900251.752773", "%1f", +__LINE__, 1.833100407114602e-05, "0.000018", "%#f", +__LINE__, 1.833672780034284e-07, "1.833673e-07", "%e", +__LINE__, 1.834307692387540e+21, "2E+21", "%5.G", +__LINE__, 1.835119931666753e+14, "+1.835120e+14", "%+e", +__LINE__, 1.835956566920861e-26, "0.000000", "%#f", +__LINE__, 1.837784131899354e+22, "1.83778E+22", "%G", +__LINE__, 1.842867094224664e-09, "1.84287e-09", "%g", +__LINE__, 1.844234823805319e+28, "2E+28", "%1.G", +__LINE__, 1.844877682008962e+12, "1.84488e+12", "%g", +__LINE__, 1.846530424340488e-22, "1.846530e-22", "%#.7g", +__LINE__, 1.849111603036448e-08, "0.00", "%.2f", +__LINE__, 1.850158752678734e+04, "+18502", "%+.5G", +__LINE__, 1.851431391104701e-06, " +2e-06", "%+7.e", +__LINE__, 1.851487430609031e-04, "0.000185149", "%G", +__LINE__, 1.853171650128773e+03, "1853.17", "%G", +__LINE__, 1.854743263740068e-16, "1.854743E-16", "%6.6E", +__LINE__, 1.864399020932753e-11, "+0.000000", "%+f", +__LINE__, 1.865028568072397e-22, "1.86503E-22", "%.6G", +__LINE__, 1.868128423759223e+14, "1.86813E+14", "%4G", +__LINE__, 1.868453558435480e+21, "1.86845E+21", "%G", +__LINE__, 1.870663011627498e-06, "1.87E-06", "%.3G", +__LINE__, 1.873273487748907e+17, "+1.873273E+17", "%+E", +__LINE__, 1.878885220839805e-04, "0.000187889", "%G", +__LINE__, 1.879102515623569e+17, "1.8791e+17", "%g", +__LINE__, 1.889343972100858e-10, "2E-10", "%2.E", +__LINE__, 1.891833282879762e-24, "+2e-24", "%+.1g", +__LINE__, 1.895148778941240e-07, "0.000000", "%0f", +__LINE__, 1.896950834067578e-28, "+1.89695e-28", "%+#g", +__LINE__, 1.898464546986629e-05, "1.898465e-05", "%.7g", +__LINE__, 1.900851427578321e-19, "1.90085e-19", "%6g", +__LINE__, 1.901171344577750e+27, "1.901171e+27", "%7.7g", +__LINE__, 1.903563335316359e+02, "190.356", "%0g", +__LINE__, 1.903817306004701e-16, "+1.90e-16", "%+#6.2e", +__LINE__, 1.910606410246797e+21, "1.91061E+21", "%2.5E", +__LINE__, 1.912537759564710e+29, "1.91254E+29", "%G", +__LINE__, 1.913606675894566e+27, "1.91361E+27", "%7.6G", +__LINE__, 1.916473734025505e-05, " 2e-05", "%7.g", +__LINE__, 1.916507511720523e+23, "+2E+23", "%+.0E", +__LINE__, 1.917688262248837e-28, "1.918e-28", "%.4g", +__LINE__, 1.921375594217083e-12, "1.92138E-12", "%G", +__LINE__, 1.923916000932815e-25, "1.92392E-25", "%G", +__LINE__, 1.926303652776462e-01, "+0.2", "%+0.G", +__LINE__, 1.929411084211293e+21, "1.92941E+21", "%6G", +__LINE__, 1.929996820297491e-26, "1.93e-26", "%.6g", +__LINE__, 1.937301472034748e-29, "1.9373E-29", "%G", +__LINE__, 1.937301660220894e-11, "+1.9373E-11", "%+G", +__LINE__, 1.939038538587083e-02, "0.0193904", "%g", +__LINE__, 1.940575489112444e-09, "1.94058E-09", "%G", +__LINE__, 1.946550455606677e-26, "1.946550E-26", "%#1E", +__LINE__, 1.954250777559491e-14, "1.95425E-14", "%G", +__LINE__, 1.955646327688473e-16, "1.956E-16", "%#.3E", +__LINE__, 1.956999911995683e+20, "2E+20", "%2.G", +__LINE__, 1.959125254298784e-21, "1.95913E-21", "%#G", +__LINE__, 1.960330340481290e+26, "1.96033e+26", "%.6g", +__LINE__, 1.964156478075422e+01, "+19.6416", "%+g", +__LINE__, 1.964702507676036e+19, "2.0e+19", "%2.1e", +__LINE__, 1.965762191674409e-30, "2E-30", "%1.G", +__LINE__, 1.967492699686803e-29, "+1.967493E-29", "%+#E", +__LINE__, 1.970072604062236e-11, "+1.97007E-11", "%+G", +__LINE__, 1.975631055550387e+05, "197563.105555", "%.6f", +__LINE__, 1.975722425389177e+28, "+1.975722e+28", "%+5.6e", +__LINE__, 1.977938328895365e-05, " 2e-05", "%6.e", +__LINE__, 1.981950849019640e+13, "1.981951E+13", "%E", +__LINE__, 1.982543168856985e-26, "1.98254e-26", "%4g", +__LINE__, 1.984873317384181e-20, "1.98487E-20", "%4G", +__LINE__, 1.986146420877074e+02, "+1.986146e+02", "%+0e", +__LINE__, 1.986465942785167e-28, "1.98647e-28", "%g", +__LINE__, 1.988250323235468e-05, " +0", "%+7.f", +__LINE__, 1.989966623080645e-09, "1.989967e-09", "%e", +__LINE__, 1.991243122514519e+11, "199124312251", "%5.f", +__LINE__, 1.993287894645908e+25, "+1.993288E+25", "%+E", +__LINE__, 1.995172329888890e-30, "+1.99517e-30", "%+3g", +__LINE__, 1.997075127236432e+05, "1.997E+05", "%#.4G", +__LINE__, 2.000651599487290e+04, "2E+04", "%2.E", +__LINE__, 2.001429412876339e-28, "0.000000", "%6f", +__LINE__, 2.003535646264196e+03, " 2E+03", "%7.G", +__LINE__, 2.011751504116246e+06, "2E+06", "%2.G", +__LINE__, 2.016361237694652e-30, "2.01636e-30", "%4g", +__LINE__, 2.018266414065554e-08, "0.00", "%2.2f", +__LINE__, 2.020706780608565e+03, "2E+03", "%.0G", +__LINE__, 2.025098418552005e-16, "+2.025098E-16", "%+2E", +__LINE__, 2.026100592518976e-11, "2.026101e-11", "%6e", +__LINE__, 2.026167291572980e+11, "2.02617E+11", "%G", +__LINE__, 2.026782170272331e+07, "2.026782E+07", "%E", +__LINE__, 2.029133469449347e-06, " 2e-06", "%6.g", +__LINE__, 2.031191570768443e-20, "2.031192E-20", "%2.7G", +__LINE__, 2.031884221862863e-16, "2.031884e-16", "%e", +__LINE__, 2.032992924118323e+29, "203299292411832333016263874014.84", "%#0.2f", +__LINE__, 2.035799610097827e+28, "+20357996100978272835391180706.2104344", "%+3.7f", +__LINE__, 2.038008183612069e+25, "20380081836120691463065668", "%7.0f", +__LINE__, 2.041632205119365e-22, "+2.04163e-22", "%+g", +__LINE__, 2.042769811159352e-10, "2e-10", "%.1g", +__LINE__, 2.043034975847005e-08, "2.043035e-08", "%e", +__LINE__, 2.045930666285880e+26, "2.04593e+26", "%g", +__LINE__, 2.048377276651386e-21, "0.00000", "%2.5f", +__LINE__, 2.051785787301292e-23, "0.000000", "%f", +__LINE__, 2.055085792048183e-10, "0.000000", "%f", +__LINE__, 2.055783028451040e-21, "+0", "%+1.f", +__LINE__, 2.057641607509489e-17, "+2E-17", "%+2.G", +__LINE__, 2.058348703001600e-15, "2.05835E-15", "%#G", +__LINE__, 2.059594758787322e+24, "2.05959E+24", "%1G", +__LINE__, 2.062710740295018e+01, "20.6271", "%G", +__LINE__, 2.063240676447750e-11, "0.000000", "%f", +__LINE__, 2.063799238238917e-09, "+0.000000", "%+f", +__LINE__, 2.064564135160425e-17, "2.06456E-17", "%G", +__LINE__, 2.066363476927650e-05, "2.07E-05", "%.3G", +__LINE__, 2.066871450514214e-02, "+2.066871e-02", "%+e", +__LINE__, 2.067258256169148e+07, "2.06726e+07", "%g", +__LINE__, 2.068466590729350e-22, "0.0000", "%.4f", +__LINE__, 2.068779510112540e-26, "2.06878e-26", "%g", +__LINE__, 2.069258770387493e+19, "20692587703874929516.700831", "%3f", +__LINE__, 2.069547778447951e+26, "2.069548e+26", "%6e", +__LINE__, 2.070479507710941e-23, "2.07048E-23", "%G", +__LINE__, 2.071809640061785e+22, "2.071810E+22", "%E", +__LINE__, 2.073364463564950e-06, "2.07336e-06", "%g", +__LINE__, 2.073478953644888e-10, "+2.07E-10", "%+.3G", +__LINE__, 2.076039194312519e+12, "2.07604E+12", "%G", +__LINE__, 2.081490398946229e-07, "+2.08149e-07", "%+g", +__LINE__, 2.084941170287895e-07, "2.084941E-07", "%7E", +__LINE__, 2.087035885023382e-18, "+0.000000", "%+f", +__LINE__, 2.091025884363342e-09, "2.09103E-09", "%G", +__LINE__, 2.091830555397864e+08, "209183056", "%0.f", +__LINE__, 2.091998109232084e-22, "0.000000", "%#f", +__LINE__, 2.093406473464940e-17, "2.09341e-17", "%g", +__LINE__, 2.094646724039720e-26, "2.094647e-26", "%0.7g", +__LINE__, 2.095218667083208e-22, "2.09522e-22", "%.5e", +__LINE__, 2.096932364992728e-27, "2.1E-27", "%.2G", +__LINE__, 2.097012452732083e+17, "2.09701E+17", "%G", +__LINE__, 2.102022216908102e-07, "0.000000", "%f", +__LINE__, 2.104648382618938e-04, "0.00021", "%.3G", +__LINE__, 2.109159578853690e-19, "2.10916e-19", "%6g", +__LINE__, 2.111732624641178e-13, "+2.111733E-13", "%+7.7G", +__LINE__, 2.112676138351330e+21, " 2e+21", "%6.g", +__LINE__, 2.117332904051741e-09, "+0.000000", "%+f", +__LINE__, 2.118001353767757e-14, "2.118E-14", "%4.3E", +__LINE__, 2.119413720893955e+12, "2.119414E+12", "%.7G", +__LINE__, 2.119610992647014e+07, "+21196109.9265", "%+.4f", +__LINE__, 2.120504022069221e+25, "21205040220692210617414730.223", "%#.3f", +__LINE__, 2.120634617123718e-16, "2.120635e-16", "%#e", +__LINE__, 2.128702437175385e+12, "2128702437175.385", "%.3f", +__LINE__, 2.131148830213536e-12, "2.131149e-12", "%e", +__LINE__, 2.132682622145255e+04, "+21326.83", "%+#5.7G", +__LINE__, 2.133864841676473e-01, " +0.2", "%+6.g", +__LINE__, 2.133939058496273e+16, "2E+16", "%4.G", +__LINE__, 2.135087006806302e-24, "0.000000", "%f", +__LINE__, 2.138983961194584e-20, "+2.138984e-20", "%+7e", +__LINE__, 2.146534189669224e+17, "+2.147E+17", "%+.4G", +__LINE__, 2.147375595676503e+09, "2.147376e+09", "%e", +__LINE__, 2.152994986418075e+02, "2E+02", "%0.E", +__LINE__, 2.154127135896811e+06, "2.15E+06", "%2.3G", +__LINE__, 2.154613053892588e-29, "2.1546E-29", "%.4E", +__LINE__, 2.160830430730653e-12, "2.16083E-12", "%#G", +__LINE__, 2.161740591663027e+28, "2.161741e+28", "%e", +__LINE__, 2.167181665934011e-06, "2e-06", "%1.e", +__LINE__, 2.167348761729060e-04, "2.167349e-04", "%#e", +__LINE__, 2.170270852816708e-10, "2.17027E-10", "%0G", +__LINE__, 2.173048229189370e-06, "2.173e-06", "%.5g", +__LINE__, 2.175554537855024e+10, "2.17555E+10", "%G", +__LINE__, 2.177447372527968e-30, "+0.000000", "%+.6f", +__LINE__, 2.178591661569858e+05, "2.1786e+05", "%1.5g", +__LINE__, 2.184700207174818e-29, "0.000000", "%f", +__LINE__, 2.190817031437247e+03, "2.E+03", "%#3.0E", +__LINE__, 2.191396212145558e-01, "2.191E-01", "%6.3E", +__LINE__, 2.191786353372880e-23, "2.19179e-23", "%.5e", +__LINE__, 2.193471126151079e+19, "2.1935E+19", "%.4E", +__LINE__, 2.194750177630526e-15, "2.194750e-15", "%e", +__LINE__, 2.196145170358973e+05, "+219615", "%+g", +__LINE__, 2.199602360934320e-09, "2.19960E-09", "%#6.6G", +__LINE__, 2.202913988776998e+17, "+2.20291e+17", "%+g", +__LINE__, 2.207094560707703e-10, "2.207095e-10", "%e", +__LINE__, 2.207557214621658e-13, " 0", "%4.f", +__LINE__, 2.209428206272229e+13, "2.20943e+13", "%g", +__LINE__, 2.212662463615175e-11, " 0", "%4.0f", +__LINE__, 2.215732710968468e-30, "2E-30", "%.1G", +__LINE__, 2.218490841936778e-10, "2.21849e-10", "%2g", +__LINE__, 2.218850610567959e-01, "+0.221885", "%+G", +__LINE__, 2.220796939261542e-03, "0.002221", "%#f", +__LINE__, 2.221819894808024e+24, "2.2e+24", "%5.1e", +__LINE__, 2.223804993235507e+27, "2.223805e+27", "%1e", +__LINE__, 2.224715386046563e-17, "0.00000", "%#.5f", +__LINE__, 2.224864709983882e-16, "+2.224865e-16", "%+e", +__LINE__, 2.225764510969505e+16, "2.E+16", "%#4.G", +__LINE__, 2.233229189161284e-07, "+2.23323e-07", "%+6g", +__LINE__, 2.236522807209868e+17, "2.23652e+17", "%g", +__LINE__, 2.236641620849775e+20, "2E+20", "%0.G", +__LINE__, 2.237089952728626e-13, "2E-13", "%5.E", +__LINE__, 2.238531255563381e-11, " 2E-11", "%7.1G", +__LINE__, 2.242782296436871e+12, "2242782296436.871103", "%f", +__LINE__, 2.249177852069393e-02, "+2.249178E-02", "%+5E", +__LINE__, 2.250735782732076e+29, "+2.25074e+29", "%+g", +__LINE__, 2.257455203557544e-11, "+2e-11", "%+4.0g", +__LINE__, 2.258002527939529e+24, "2.258e+24", "%g", +__LINE__, 2.266955929448160e+20, "226695592944815960123.6056915", "%.7f", +__LINE__, 2.269019719123250e-23, "0.000000", "%f", +__LINE__, 2.269022332502809e+02, "+226.902233", "%+f", +__LINE__, 2.271165222038591e-03, "0.002", "%1.1g", +__LINE__, 2.273965946408021e+14, "+227396594640802.085507", "%+f", +__LINE__, 2.277221153386242e+22, "22772211533862418697538.032575", "%#f", +__LINE__, 2.280214920187521e-01, "0.2", "%2.G", +__LINE__, 2.280762993019740e+06, "2.28076E+06", "%G", +__LINE__, 2.283479263040833e-24, "+0.000000", "%+f", +__LINE__, 2.283686319235123e-07, "2.2837E-07", "%5.5G", +__LINE__, 2.285842617231066e-26, "0.000000", "%f", +__LINE__, 2.293145864755873e-02, "0.02", "%.0g", +__LINE__, 2.293439381531532e+03, "+2.293439E+03", "%+#1E", +__LINE__, 2.297972500660698e-22, "2.29797e-22", "%g", +__LINE__, 2.298725366073681e+23, "2.29873E+23", "%G", +__LINE__, 2.303151535483950e-29, "2.30315E-29", "%G", +__LINE__, 2.308565313657699e-25, " 0", "%4.f", +__LINE__, 2.309305373760733e-07, "2.309305E-07", "%E", +__LINE__, 2.309693761334710e-19, "2.30969e-19", "%g", +__LINE__, 2.312218220995774e-20, "+2.31222E-20", "%+.6G", +__LINE__, 2.313115729670525e+24, "2.31312E+24", "%G", +__LINE__, 2.315325159866773e-21, "2.315325E-21", "%E", +__LINE__, 2.316932917620091e-19, "0.000000", "%f", +__LINE__, 2.317548394633895e+13, "2.31755E+13", "%0G", +__LINE__, 2.318951465093612e+02, "+2.32e+02", "%+1.2e", +__LINE__, 2.319151794905482e-17, "+0.000000", "%+0f", +__LINE__, 2.319708617851078e-27, "0.000000", "%f", +__LINE__, 2.320019976591725e+20, "2e+20", "%.1g", +__LINE__, 2.322859962551666e+06, "2.32286e+06", "%g", +__LINE__, 2.326474568074649e-29, "2.326e-29", "%.4g", +__LINE__, 2.328400844172053e-07, "2.3284E-07", "%G", +__LINE__, 2.333695247698112e+16, "2.3337e+16", "%g", +__LINE__, 2.333717120257130e-19, "+0.000000", "%+f", +__LINE__, 2.334711793234782e-19, "2.33471E-19", "%5G", +__LINE__, 2.335524987281242e+02, "+233.55", "%+7.5g", +__LINE__, 2.335556767836369e-30, "2.34e-30", "%.3g", +__LINE__, 2.337696964360052e-10, "2.3377e-10", "%1g", +__LINE__, 2.337858249184500e-14, "2.337858E-14", "%5.6E", +__LINE__, 2.339984354781169e-14, "2.339984E-14", "%E", +__LINE__, 2.340849041430089e-04, "0.00023", "%0.2G", +__LINE__, 2.342388410373363e-24, "2.34239E-24", "%G", +__LINE__, 2.343933106737237e-22, "2.34393e-22", "%g", +__LINE__, 2.344870855713960e-08, "0.000000", "%.6f", +__LINE__, 2.347368965433808e+24, "2347368965433808352116785", "%4.f", +__LINE__, 2.349417462171421e-02, "+0.0234942", "%+G", +__LINE__, 2.351071111431207e+11, "235107111143.12", "%.2f", +__LINE__, 2.352756222810670e+19, "+2.e+19", "%+#4.g", +__LINE__, 2.355862529217003e-22, "2.355863e-22", "%#4e", +__LINE__, 2.356804045401445e-30, "2.3568E-30", "%G", +__LINE__, 2.362100710185559e-26, "2.3621e-26", "%g", +__LINE__, 2.368330779173562e-12, " 0", "%4.f", +__LINE__, 2.383329784369796e+22, "2.38333E+22", "%G", +__LINE__, 2.386845229536477e+01, "+23.868452", "%+#f", +__LINE__, 2.388207830036780e-05, "0.000024", "%f", +__LINE__, 2.391809468802907e+21, "+2.391809e+21", "%+e", +__LINE__, 2.395172908564692e-09, "+0.000000", "%+f", +__LINE__, 2.395447167030886e-29, "2.39545e-29", "%g", +__LINE__, 2.397292973389182e+16, "23972929733891823", "%6.f", +__LINE__, 2.401749832237687e-30, "2.401750E-30", "%E", +__LINE__, 2.403610502544347e-03, "0.00240361", "%4G", +__LINE__, 2.404676421776132e+17, "240467642177613206", "%6.f", +__LINE__, 2.406327689091479e+25, "2.406328e+25", "%e", +__LINE__, 2.407341999590511e-02, "0.024073", "%f", +__LINE__, 2.407352797581004e+05, "240735.", "%#g", +__LINE__, 2.407903467439017e+13, "2.4079E+13", "%G", +__LINE__, 2.407979635013539e+21, " +2E+21", "%+7.G", +__LINE__, 2.409513517930790e+29, "240951351793079027174826478585.600853", "%f", +__LINE__, 2.412530651221551e+10, "+2.41253E+10", "%+G", +__LINE__, 2.419943224673811e+00, "2.41994", "%#g", +__LINE__, 2.422474399040258e-15, "0.000000", "%f", +__LINE__, 2.426060206689458e+18, "2.42606E+18", "%1G", +__LINE__, 2.439982659679872e+14, "+2.439983E+14", "%+E", +__LINE__, 2.440528851375447e+13, "24405288513754.466173", "%f", +__LINE__, 2.441340473292679e+19, "2.44134E+19", "%G", +__LINE__, 2.443521636943916e+19, " 2.e+19", "%#7.g", +__LINE__, 2.445925211597624e-27, "2.445925E-27", "%E", +__LINE__, 2.446966179060722e+25, "2.446966e+25", "%5e", +__LINE__, 2.447714218717278e+11, "2e+11", "%1.e", +__LINE__, 2.448339744613286e+06, "2.4483e+06", "%3.5g", +__LINE__, 2.448772993496189e+03, "2448.77", "%G", +__LINE__, 2.448857654325229e+22, "+2.44886e+22", "%+g", +__LINE__, 2.450082452098890e-27, "2.4501E-27", "%#3.5G", +__LINE__, 2.451293602221637e+05, "245129.360222", "%f", +__LINE__, 2.454531490229426e+02, "245.453", "%G", +__LINE__, 2.458958369944980e+14, "2.5E+14", "%6.1E", +__LINE__, 2.463666680775038e+14, "+246366668077503.80", "%+#.2f", +__LINE__, 2.471582990960795e+05, "2.471583e+05", "%e", +__LINE__, 2.474107179274687e+22, "2.47411e+22", "%g", +__LINE__, 2.474332114849132e-08, "+2.47433e-08", "%+g", +__LINE__, 2.476956762431716e+18, "+2476956762431715919.348107", "%+#f", +__LINE__, 2.479091221850607e-22, "0.000000", "%f", +__LINE__, 2.479819586598431e-24, "2.47982e-24", "%g", +__LINE__, 2.480006174601455e-05, "2.48001E-05", "%G", +__LINE__, 2.482672677638334e-26, "+0.000000", "%+f", +__LINE__, 2.492816492208918e-14, " 0", "%7.f", +__LINE__, 2.492964173197140e-12, " 2e-12", "%7.g", +__LINE__, 2.494646635961173e+02, "249.465", "%g", +__LINE__, 2.494687818780545e+11, "249468781878.054546", "%#7f", +__LINE__, 2.510083560147301e-13, "+2.510084e-13", "%+#e", +__LINE__, 2.511186607989480e-30, "2.51E-30", "%.3G", +__LINE__, 2.514164516133643e-11, "2.51416e-11", "%g", +__LINE__, 2.517242520804735e+11, "2.517243e+11", "%e", +__LINE__, 2.518526126400833e-26, "2.51853e-26", "%g", +__LINE__, 2.520313416401176e+09, "2520313416.401176", "%5f", +__LINE__, 2.521653160738683e-29, "2.52165e-29", "%#g", +__LINE__, 2.521941342615338e-16, "2.52194e-16", "%g", +__LINE__, 2.523554774354461e-03, "+3E-03", "%+.0E", +__LINE__, 2.525434130825058e+06, "+2.525434E+06", "%+E", +__LINE__, 2.527616380113364e+02, "2.527616E+02", "%E", +__LINE__, 2.531871347913505e+09, "+2.53187E+09", "%+#G", +__LINE__, 2.532167428661069e+06, "2532167.428661", "%f", +__LINE__, 2.545585718405995e+14, "+2.54559E+14", "%+G", +__LINE__, 2.546305097286406e+10, "2.546305e+10", "%e", +__LINE__, 2.547467156069069e-30, "+0.00", "%+3.2f", +__LINE__, 2.548728793004506e-14, "2.54873E-14", "%G", +__LINE__, 2.560375602395090e+11, "256037560239.509032", "%0f", +__LINE__, 2.560555687476687e+03, "2561", "%.4g", +__LINE__, 2.561709077363443e-24, "+0.000000", "%+f", +__LINE__, 2.563763849675242e+10, "2.5637638E+10", "%.7E", +__LINE__, 2.567482414574355e+11, "+2.567482e+11", "%+e", +__LINE__, 2.571575046303674e-17, "3E-17", "%2.0E", +__LINE__, 2.572997971296986e+11, "257299797129.698593", "%f", +__LINE__, 2.578625935900331e+22, "25786259359003311786295.853381", "%f", +__LINE__, 2.579663282966370e+12, "2.579663e+12", "%e", +__LINE__, 2.593141782397610e-08, "0.000000", "%f", +__LINE__, 2.594386109584196e+04, "3.E+04", "%#6.0E", +__LINE__, 2.598069318007816e-22, "2.59807e-22", "%g", +__LINE__, 2.600910462290091e+09, "2.600910E+09", "%6E", +__LINE__, 2.602580183614458e-03, "2.602580e-03", "%e", +__LINE__, 2.606540360440264e+09, "+2606540360.4", "%+#0.1f", +__LINE__, 2.610016419698116e-21, "+3.e-21", "%+#3.g", +__LINE__, 2.612279323574882e-20, "2.61228E-20", "%G", +__LINE__, 2.614157324336453e-14, "2.61416e-14", "%g", +__LINE__, 2.614688721873993e-09, "2.61e-09", "%6.2e", +__LINE__, 2.616661104472416e-15, " 0", "%5.f", +__LINE__, 2.616742079283195e-09, " +3E-09", "%+7.E", +__LINE__, 2.618075304717427e+24, "2.618075e+24", "%e", +__LINE__, 2.624118573335769e+26, "262411857333576925555007619.550452", "%1f", +__LINE__, 2.625718894274227e+24, "+2625718894274227110940955.753904", "%+f", +__LINE__, 2.627081999477812e+03, "2627.081999", "%f", +__LINE__, 2.631061062224705e+14, "263106106222470.481626", "%f", +__LINE__, 2.631545877128814e+27, "+2.63155e+27", "%+g", +__LINE__, 2.632694395848818e-11, "2.63269e-11", "%g", +__LINE__, 2.636728891022008e-22, "+2.63673e-22", "%+#4g", +__LINE__, 2.638495675008130e-28, "+2.638496e-28", "%+e", +__LINE__, 2.639704195859799e-11, "0.", "%#.0f", +__LINE__, 2.641645264652665e-20, "0", "%0.f", +__LINE__, 2.642012075064497e-20, "3E-20", "%0.E", +__LINE__, 2.648725869006487e-29, " 3E-29", "%6.G", +__LINE__, 2.649060724417770e+12, "3E+12", "%3.G", +__LINE__, 2.651188545120166e-17, "0.000", "%.3f", +__LINE__, 2.652302152621621e+14, "2.7E+14", "%.2G", +__LINE__, 2.653309718412604e-28, "0.000000", "%f", +__LINE__, 2.658344750491858e-21, " 3e-21", "%6.g", +__LINE__, 2.664625074612594e+15, "3e+15", "%1.g", +__LINE__, 2.666953728270800e-15, "3e-15", "%0.e", +__LINE__, 2.674515419678877e-11, " 3E-11", "%6.E", +__LINE__, 2.680054917256578e+15, "2680054917256577.5", "%#2.1f", +__LINE__, 2.680495609883415e-11, "2.68E-11", "%#.3G", +__LINE__, 2.685757893641070e+23, "268575789364107020418259.70809", "%1.5f", +__LINE__, 2.695551226058178e+16, "26955512260581775.407786", "%f", +__LINE__, 2.696346377519671e+04, "+26963.5", "%+G", +__LINE__, 2.714262310601257e+17, "+2.714262E+17", "%+E", +__LINE__, 2.719227450016317e-01, "0.271923", "%G", +__LINE__, 2.724135433346056e-30, "+2.72414e-30", "%+g", +__LINE__, 2.725143224130276e+14, "272514322413027.576530", "%6f", +__LINE__, 2.729355189648310e-03, "+0.00273", "%+.5f", +__LINE__, 2.732872167724945e+11, "2.73287E+11", "%G", +__LINE__, 2.737709476435412e+17, "273770947643541218.141650", "%f", +__LINE__, 2.739299356074967e-15, "2.7E-15", "%.2G", +__LINE__, 2.740793612304798e-27, "2.740794E-27", "%.7G", +__LINE__, 2.742030156175960e+20, "2.74203e+20", "%2.6g", +__LINE__, 2.744455324096085e+11, "2.74446E+11", "%G", +__LINE__, 2.745179546531160e+07, "2.7452E+07", "%.5G", +__LINE__, 2.747470562525333e+04, "3E+04", "%2.E", +__LINE__, 2.750243314674629e+21, "2.75024E+21", "%#G", +__LINE__, 2.750250224436030e+20, "+2.750250e+20", "%+0.6e", +__LINE__, 2.752712858561084e-22, "2.752713e-22", "%e", +__LINE__, 2.756982987656667e-03, "0.002756983", "%#.7G", +__LINE__, 2.761841188479590e+13, "3e+13", "%1.g", +__LINE__, 2.769498440434419e+00, "+3e+00", "%+0.e", +__LINE__, 2.769993785786379e+10, "27699937857.863794", "%f", +__LINE__, 2.772900256376753e-06, "+2.7729E-06", "%+7.6G", +__LINE__, 2.774401482467457e-06, "2.8e-06", "%3.2g", +__LINE__, 2.777691370374757e-02, "+0.027777", "%+f", +__LINE__, 2.779836227365899e-09, "3e-09", "%5.0g", +__LINE__, 2.780481651765741e+01, "2.780482E+01", "%E", +__LINE__, 2.782228478714809e-26, "2.782228E-26", "%4.7G", +__LINE__, 2.790457781719376e+13, "+2.8e+13", "%+.2g", +__LINE__, 2.792026581166417e-30, " 3.e-30", "%#7.0g", +__LINE__, 2.792396278299615e-08, "0.00", "%#.2f", +__LINE__, 2.793658047689995e-10, "2.794e-10", "%#0.4g", +__LINE__, 2.795707358229888e-25, "0.000000", "%f", +__LINE__, 2.796253091758523e-06, "2.796E-06", "%.4G", +__LINE__, 2.796756564788716e-24, "2.796757e-24", "%e", +__LINE__, 2.798730444798773e-14, "2.79873e-14", "%g", +__LINE__, 2.799108397670447e-24, "3E-24", "%.0G", +__LINE__, 2.799389008872835e+06, "2799389.", "%#0.f", +__LINE__, 2.800413998518039e-14, "0.000000", "%f", +__LINE__, 2.803237602587100e+15, "+2803237602587100.418816", "%+5f", +__LINE__, 2.803474415574551e-04, "0.0002803", "%.7f", +__LINE__, 2.804957468647181e+25, "2.80496e+25", "%g", +__LINE__, 2.809345112788226e+09, "2809345112.788226", "%.6f", +__LINE__, 2.811518239408899e+10, "3e+10", "%1.g", +__LINE__, 2.813188439967416e-16, "0.0000000", "%5.7f", +__LINE__, 2.813497118051755e+08, "2.8135e+08", "%.5g", +__LINE__, 2.815748256510577e-29, "0.000000", "%2f", +__LINE__, 2.816076365485207e-01, "0.281608", "%0G", +__LINE__, 2.816083345772131e+24, "2.8161e+24", "%6.4e", +__LINE__, 2.818686957605178e+12, "2.8187E+12", "%.5G", +__LINE__, 2.821903538737691e+20, "2.8219E+20", "%G", +__LINE__, 2.823659589845680e+26, "2.82366e+26", "%2g", +__LINE__, 2.823685630865012e+22, "2.82369E+22", "%G", +__LINE__, 2.828826386007914e+21, "2.828826E+21", "%7E", +__LINE__, 2.830997901034349e+04, "+3e+04", "%+0.e", +__LINE__, 2.833886731091353e-26, "+2.833887e-26", "%+4e", +__LINE__, 2.839965144893913e+28, "28399651448939131626048038015.1421", "%.4f", +__LINE__, 2.840651452049947e-09, "2.841E-09", "%#.3E", +__LINE__, 2.843388001911757e-01, "0.284339", "%g", +__LINE__, 2.846122151080671e+14, "2.84612E+14", "%.5E", +__LINE__, 2.851257828837595e+05, "+285126", "%+5.f", +__LINE__, 2.853823884459520e+07, "+2.85382E+07", "%+G", +__LINE__, 2.853870068368765e-06, "2.854E-06", "%4.3E", +__LINE__, 2.856687358149867e+01, "+28.567", "%+6.5G", +__LINE__, 2.858946600073752e+06, "2.8589466e+06", "%3.7e", +__LINE__, 2.861525727138818e+24, "2.8615257e+24", "%2.7e", +__LINE__, 2.865104175886071e-24, "0.000000", "%f", +__LINE__, 2.870678920363198e-14, "2.87068E-14", "%G", +__LINE__, 2.873298537233691e+09, "+2.8733e+09", "%+g", +__LINE__, 2.877939609444375e-02, "0.028779", "%f", +__LINE__, 2.878253985341728e+13, "2.87825E+13", "%G", +__LINE__, 2.879299244903946e+29, "287929924490394597569320467301", "%0.f", +__LINE__, 2.885516225515485e-26, "0.000000", "%f", +__LINE__, 2.886013724129579e+20, "+3e+20", "%+4.g", +__LINE__, 2.887032786975506e-30, "0.000000", "%f", +__LINE__, 2.890415456531026e-29, "2.89042E-29", "%G", +__LINE__, 2.893177360548214e-13, "2.893E-13", "%#6.3E", +__LINE__, 2.895265536458195e+26, "2.89527e+26", "%5g", +__LINE__, 2.903844533810152e+23, "290384453381015195105874.23", "%.2f", +__LINE__, 2.909060558287504e+27, "2.90906e+27", "%g", +__LINE__, 2.911615480973172e-05, "2.91162E-05", "%3G", +__LINE__, 2.912692297221896e+09, "2912692297.221896", "%#f", +__LINE__, 2.913595662485813e-24, "2.9136E-24", "%G", +__LINE__, 2.915960840341896e-27, "0.000000", "%f", +__LINE__, 2.920451095973991e-16, "2.92e-16", "%2.2e", +__LINE__, 2.920528295810925e+06, "2.92053E+06", "%#G", +__LINE__, 2.921564671017147e+20, "2.921565E+20", "%#6E", +__LINE__, 2.921628350942189e+01, "2.921628E+01", "%E", +__LINE__, 2.921843377455232e+20, "2.921843E+20", "%#E", +__LINE__, 2.930156950319384e+29, "2.930E+29", "%1.3E", +__LINE__, 2.931229858895071e-30, "2.9e-30", "%4.2g", +__LINE__, 2.931753029689166e+20, "2.93175e+20", "%g", +__LINE__, 2.933023693079342e+15, "3.E+15", "%#.1G", +__LINE__, 2.933078733225520e+26, "2.93308E+26", "%G", +__LINE__, 2.933528170896643e-14, "+2.93353e-14", "%+g", +__LINE__, 2.938648437428148e+00, "2.938648e+00", "%e", +__LINE__, 2.940752238221344e+26, "+2.94075E+26", "%+G", +__LINE__, 2.942836470459675e+20, "2.9428e+20", "%6.4e", +__LINE__, 2.943218333254941e+29, "294321833325494086608387078740.634024", "%f", +__LINE__, 2.943690574007512e-27, "0.000000", "%f", +__LINE__, 2.945452907046501e+09, "+2.9455E+09", "%+.5G", +__LINE__, 2.946648725966953e+16, "29466487259669534.637396", "%4f", +__LINE__, 2.955119322417825e+29, "2.95512E+29", "%G", +__LINE__, 2.966481197538973e+24, "2.96648e+24", "%#g", +__LINE__, 2.969362862661362e+08, "+2.969363e+08", "%+7e", +__LINE__, 2.970062459990078e+21, "+2.97006E+21", "%+G", +__LINE__, 2.971059959019791e+10, " 3E+10", "%7.G", +__LINE__, 2.973020205606034e-29, "0.000000", "%f", +__LINE__, 2.977223210301426e+04, "2.977223e+04", "%#e", +__LINE__, 2.977467832772786e-26, "0.000000", "%f", +__LINE__, 2.981433606423384e+18, "2981433606423384397.032805", "%f", +__LINE__, 2.981615513287404e-17, "2.98162e-17", "%g", +__LINE__, 2.983880743847276e+19, " 3e+19", "%7.e", +__LINE__, 2.983927792297305e-28, "2.983928e-28", "%e", +__LINE__, 2.984807359492058e-17, " 0", "%2.f", +__LINE__, 2.985123412933032e+09, "+2.98512e+09", "%+g", +__LINE__, 2.991132955408629e-27, "+2.99113e-27", "%+4g", +__LINE__, 2.992345635923643e+19, "3E+19", "%4.G", +__LINE__, 2.993024238285395e-05, "2.99302e-05", "%2g", +__LINE__, 2.995303406756363e+16, "+2.995303E+16", "%+E", +__LINE__, 2.995492577854335e+19, "+29954925778543346481.797016", "%+f", +__LINE__, 2.996856271675341e-25, "+3e-25", "%+0.e", +__LINE__, 2.997813968112619e+12, "2.99781e+12", "%#5g", +__LINE__, 3.002097486457961e-17, "3.00210e-17", "%5.5e", +__LINE__, 3.006538123158692e+28, "+3.00654E+28", "%+#G", +__LINE__, 3.007293721729544e+04, "30072.937217", "%f", +__LINE__, 3.008301791944493e-07, "3.008e-07", "%.3e", +__LINE__, 3.011742184603817e-17, "3.011742E-17", "%#E", +__LINE__, 3.024641547299177e-30, "3.02464e-30", "%g", +__LINE__, 3.026525135110198e-28, "3e-28", "%.0e", +__LINE__, 3.026768160756558e+20, "3.02677E+20", "%G", +__LINE__, 3.031928829940975e+18, "3031928829940975234.1", "%0.1f", +__LINE__, 3.039787705138620e+24, "+3.E+24", "%+#5.G", +__LINE__, 3.039803824423916e-02, "0.030398", "%5f", +__LINE__, 3.041236293199133e-26, "3.04124e-26", "%g", +__LINE__, 3.045634954037886e+04, "30456.3", "%g", +__LINE__, 3.047528114241850e+25, "3e+25", "%0.e", +__LINE__, 3.047958193737501e-24, "3.04796E-24", "%#G", +__LINE__, 3.049537324414302e-16, "3.04954E-16", "%G", +__LINE__, 3.050500637681798e-30, "3.0505E-30", "%G", +__LINE__, 3.051769626625307e-01, "0.305177", "%f", +__LINE__, 3.057280201971847e+11, "+3.05728E+11", "%+.5E", +__LINE__, 3.060046173306881e-10, "+3.060046e-10", "%+e", +__LINE__, 3.069732667347204e+27, "+3069732667347204291274920251.453295", "%+f", +__LINE__, 3.075060836786916e-14, "0.000000", "%f", +__LINE__, 3.078175179670964e+13, "3.07818E+13", "%G", +__LINE__, 3.080305344303183e-21, "3.08031e-21", "%6g", +__LINE__, 3.088881497064043e+27, "+3.088881E+27", "%+3E", +__LINE__, 3.089196877931209e-20, "3.089197e-20", "%e", +__LINE__, 3.091400888880487e-08, "3e-08", "%2.e", +__LINE__, 3.093410684178904e+16, "3.09341e+16", "%g", +__LINE__, 3.104225344208216e-21, "0.000000", "%f", +__LINE__, 3.105843728248599e+13, "3.e+13", "%#.0g", +__LINE__, 3.106463071390893e-07, "0.0000", "%.4f", +__LINE__, 3.107784123569379e+02, "+310.778", "%+G", +__LINE__, 3.110605148983672e-20, "3.1106051E-20", "%.7E", +__LINE__, 3.111702418162670e-04, "0.00031117", "%.5G", +__LINE__, 3.117610675303153e-17, "3.11761e-17", "%g", +__LINE__, 3.123620125717981e+07, "3.1236e+07", "%2.5g", +__LINE__, 3.125648558809832e-24, "+3.125649E-24", "%+#0.6E", +__LINE__, 3.129025163659283e+10, "31290251636.592825", "%#f", +__LINE__, 3.130689119412709e-29, "+3.131E-29", "%+#.4G", +__LINE__, 3.135681222132527e+13, "3.13568E+13", "%G", +__LINE__, 3.138290485073330e-10, "3.13829E-10", "%G", +__LINE__, 3.141255250155306e-12, "3.14126E-12", "%G", +__LINE__, 3.143224520918429e+25, "3.14322E+25", "%#1G", +__LINE__, 3.144746921366173e-16, " 0", "%7.f", +__LINE__, 3.151336678241994e+19, "+3.15134E+19", "%+G", +__LINE__, 3.161752935716549e+24, "3.2E+24", "%2.1E", +__LINE__, 3.167106521258172e-10, "+3.167107e-10", "%+e", +__LINE__, 3.167266522824146e-04, "3E-04", "%3.E", +__LINE__, 3.169995217131489e+27, "3169995217131488907114089670.358226", "%f", +__LINE__, 3.172117220467692e-21, "3.1721E-21", "%.5G", +__LINE__, 3.173824170351611e+02, " 3e+02", "%6.e", +__LINE__, 3.186291452544739e-28, " 0", "%2.f", +__LINE__, 3.194750094186063e+03, "+3.194750E+03", "%+E", +__LINE__, 3.195001037118137e-20, "0", "%0.0f", +__LINE__, 3.199271564719560e+02, "319.927", "%g", +__LINE__, 3.212803450638544e+20, "3.2128e+20", "%.6g", +__LINE__, 3.214502877263883e+24, "3214502877263882840708220", "%2.f", +__LINE__, 3.214658414074286e-01, "+0.321466", "%+#g", +__LINE__, 3.217627975823673e+00, "3.217628", "%f", +__LINE__, 3.218257328710536e-07, "3.21826e-07", "%6.5e", +__LINE__, 3.221949479347008e+02, "322.194948", "%f", +__LINE__, 3.222862935507443e-14, "3.222863E-14", "%E", +__LINE__, 3.223750247261608e+19, "3.22375e+19", "%g", +__LINE__, 3.236030335782375e+05, "3.236030e+05", "%e", +__LINE__, 3.241078803072735e+19, "3.24108e+19", "%g", +__LINE__, 3.248069569167045e-06, "0.000003", "%#f", +__LINE__, 3.248148973717269e-15, "3.24815E-15", "%G", +__LINE__, 3.251150704311790e+25, "+3.25115e+25", "%+5g", +__LINE__, 3.254498593372140e+15, "+3.2545e+15", "%+g", +__LINE__, 3.254949399612861e-13, "+3.255E-13", "%+7.3E", +__LINE__, 3.255490928554106e-17, "3.255491e-17", "%e", +__LINE__, 3.262333894422112e+17, "326233389442211185.738074", "%0f", +__LINE__, 3.263923577545217e-24, "0.0000000", "%.7f", +__LINE__, 3.267125289609703e+23, "3.26713e+23", "%#.5e", +__LINE__, 3.267906049108331e+27, "3.267906E+27", "%6E", +__LINE__, 3.269885039157328e+14, "326988503915732.797722", "%f", +__LINE__, 3.296011393609953e-27, " 3E-27", "%7.E", +__LINE__, 3.296452164568996e+29, "3.296452E+29", "%E", +__LINE__, 3.296544736555325e+10, "+3.29654E+10", "%+.6G", +__LINE__, 3.301861835798572e+03, "3301.862", "%4.7g", +__LINE__, 3.311292283423002e+21, " 3E+21", "%6.G", +__LINE__, 3.314868440076262e-10, "3.3149E-10", "%.5G", +__LINE__, 3.318057982247451e-13, "3.3181e-13", "%0.5g", +__LINE__, 3.318139218410071e-22, "0.000000", "%f", +__LINE__, 3.326769904839351e-11, "+3.3268e-11", "%+0.4e", +__LINE__, 3.327483659787219e+27, "+3.32748e+27", "%+g", +__LINE__, 3.332666889640198e+17, "333266688964019763.830038", "%f", +__LINE__, 3.333807449377253e+10, "+3.33e+10", "%+.3g", +__LINE__, 3.334572302792625e-09, "3.334572E-09", "%E", +__LINE__, 3.337567126586765e-17, "0.0000000", "%#3.7f", +__LINE__, 3.340512607683786e-04, "+3E-04", "%+1.E", +__LINE__, 3.344911557516870e+04, "33449.1", "%G", +__LINE__, 3.346464302017296e+26, "+3.E+26", "%+#3.G", +__LINE__, 3.348503166628953e+00, "+3.348503e+00", "%+e", +__LINE__, 3.350025157778138e-19, "3.35003e-19", "%6g", +__LINE__, 3.352826233035342e+11, "335282623303.534200", "%7f", +__LINE__, 3.357174089765502e+10, "3.35717E+10", "%G", +__LINE__, 3.369253166475501e+03, "+3369.25", "%+G", +__LINE__, 3.371385975046735e+02, "337.", "%#.0f", +__LINE__, 3.372532650462104e-04, "+0.000", "%+.3f", +__LINE__, 3.376498162710442e-26, "3.376498e-26", "%e", +__LINE__, 3.383510307689135e-12, " 3e-12", "%7.0e", +__LINE__, 3.388427914080631e-04, "0.0003", "%2.4f", +__LINE__, 3.390757423408097e+29, "3.3908E+29", "%.4E", +__LINE__, 3.393963140962879e-11, "3.39396e-11", "%g", +__LINE__, 3.399245742994444e+24, "3.399246E+24", "%E", +__LINE__, 3.417690405546708e-26, "0.00000", "%4.5f", +__LINE__, 3.421159360472045e-30, "3.42116E-30", "%G", +__LINE__, 3.421973947898887e-06, "3.42197E-06", "%4G", +__LINE__, 3.425949002482817e-10, "+3.42595E-10", "%+G", +__LINE__, 3.428355150377972e+08, "3.42836E+08", "%G", +__LINE__, 3.445035158951526e+15, "3445035158951526.454985", "%f", +__LINE__, 3.447363996077534e+28, "+3e+28", "%+2.e", +__LINE__, 3.451571062654907e-03, "0.00345157", "%G", +__LINE__, 3.452787236877688e+09, "3.45279e+09", "%g", +__LINE__, 3.454114826574939e-22, "3.e-22", "%#3.e", +__LINE__, 3.455241965974631e-03, "0.003455", "%#f", +__LINE__, 3.456190496554365e-18, "3.E-18", "%#5.E", +__LINE__, 3.456804565717233e-19, "+0.000", "%+2.3f", +__LINE__, 3.457077651539715e-28, "3.457078E-28", "%E", +__LINE__, 3.472025705376229e+22, "3.472e+22", "%7.4g", +__LINE__, 3.473308270919079e+03, "3.473308e+03", "%e", +__LINE__, 3.474468013243007e-30, "3.47447e-30", "%g", +__LINE__, 3.477976957097698e+22, "3.47798e+22", "%g", +__LINE__, 3.501174631980057e-06, "4e-06", "%4.g", +__LINE__, 3.501808481702140e+20, "3.50181E+20", "%G", +__LINE__, 3.511760000705324e+14, "351176000070532.357000", "%f", +__LINE__, 3.511870226306087e+29, "3.51187e+29", "%.5e", +__LINE__, 3.518846859147841e+02, "+351.885", "%+G", +__LINE__, 3.521659149753418e+25, "35216591497534182053641416", "%5.f", +__LINE__, 3.521721228178747e+21, "4e+21", "%2.e", +__LINE__, 3.526696007281458e+22, "3.5267e+22", "%g", +__LINE__, 3.535631031379084e-11, "4e-11", "%5.0g", +__LINE__, 3.537219665456759e-01, "0.353722", "%f", +__LINE__, 3.537252728287785e-09, "3.537253E-09", "%E", +__LINE__, 3.542561277796815e-19, "3.542561E-19", "%E", +__LINE__, 3.548942336915745e+13, "3.54894E+13", "%.5E", +__LINE__, 3.574385715121768e-24, "3.57439E-24", "%#G", +__LINE__, 3.578068067760211e-13, "3.578068E-13", "%E", +__LINE__, 3.583296432862266e-13, "3.5833e-13", "%g", +__LINE__, 3.591567367115590e+19, "3.59157e+19", "%1g", +__LINE__, 3.594902312287635e-24, "3.5949E-24", "%G", +__LINE__, 3.602929486764515e+12, "3602929486764.514522", "%#f", +__LINE__, 3.606699462631472e-01, "+0.360670", "%+f", +__LINE__, 3.608605968319811e+17, "3.60861e+17", "%g", +__LINE__, 3.608780761567885e+24, "4e+24", "%0.e", +__LINE__, 3.623857274715022e-15, "3.62386E-15", "%1G", +__LINE__, 3.627346251764432e-22, "3.627e-22", "%.4g", +__LINE__, 3.652610391698086e-16, "0.000000", "%3f", +__LINE__, 3.657463146689917e-19, " 0", "%4.0f", +__LINE__, 3.658538858712938e-15, "4E-15", "%5.G", +__LINE__, 3.660337267266058e+16, "+36603372672660579.034698", "%+f", +__LINE__, 3.661588742065142e-01, "0.366159", "%g", +__LINE__, 3.662296387211376e-25, "0.000000", "%f", +__LINE__, 3.668511100303393e-29, "0.000000", "%7f", +__LINE__, 3.669499303661920e+06, "3.6695e+06", "%1.5g", +__LINE__, 3.676856420121343e-23, "3.6769e-23", "%0.4e", +__LINE__, 3.677197473476901e-19, "+3.6772e-19", "%+g", +__LINE__, 3.677281754506453e+12, "+3677281754506.452671", "%+f", +__LINE__, 3.678420802401506e-19, "3.67842E-19", "%G", +__LINE__, 3.679970245325769e+07, "3.67997e+07", "%g", +__LINE__, 3.682528947621349e+05, "4.e+05", "%#5.e", +__LINE__, 3.688257471304210e+22, "36882574713042104441740.320908", "%f", +__LINE__, 3.689129734472166e-01, "0.368913", "%0.6G", +__LINE__, 3.693483801463324e+12, "4E+12", "%3.E", +__LINE__, 3.694612396584729e-21, "+3.69461E-21", "%+G", +__LINE__, 3.706150073392112e-19, "0.000000", "%2f", +__LINE__, 3.706824819530577e+21, "3706824819530576853310.321894", "%f", +__LINE__, 3.709583789659276e+19, "+3.709584E+19", "%+#E", +__LINE__, 3.711137503697284e+22, "3.7111E+22", "%.5G", +__LINE__, 3.717307412969522e-22, "3.717307E-22", "%#E", +__LINE__, 3.717434999853808e+24, " 4E+24", "%6.G", +__LINE__, 3.720761662524312e+14, "+372076166252431.2285", "%+1.4f", +__LINE__, 3.721613815237707e-10, "3.72161e-10", "%g", +__LINE__, 3.725086467464346e+14, "3.72509E+14", "%G", +__LINE__, 3.727427083626536e-15, "+4E-15", "%+.0G", +__LINE__, 3.731138322599465e-13, "3.73114e-13", "%5g", +__LINE__, 3.732248129614146e-04, " 4E-04", "%7.E", +__LINE__, 3.744422223926118e-24, "3.744422E-24", "%E", +__LINE__, 3.745595428897916e+21, "+3745595428897916079336.027906", "%+f", +__LINE__, 3.751308304055989e-08, "+3.751308e-08", "%+e", +__LINE__, 3.755395417696132e-02, "0.037554", "%f", +__LINE__, 3.769103881505159e+09, "3.7691e+09", "%g", +__LINE__, 3.769535572757430e+00, "3.769536", "%6.7G", +__LINE__, 3.770823872348274e-28, "+0.000000", "%+f", +__LINE__, 3.771160653578178e+29, "3.77116e+29", "%g", +__LINE__, 3.776563752716444e-12, "4E-12", "%.0E", +__LINE__, 3.777953798674786e-28, "3.77795e-28", "%g", +__LINE__, 3.785994690686598e+28, "4E+28", "%5.G", +__LINE__, 3.787487488835162e+01, "+37.874875", "%+5f", +__LINE__, 3.788249311173359e-18, "3.788249E-18", "%E", +__LINE__, 3.798728360791314e-08, "3.798728E-08", "%2E", +__LINE__, 3.799038238867092e+05, "3.79904E+05", "%.5E", +__LINE__, 3.799822564549600e+06, "3.79982E+06", "%.5E", +__LINE__, 3.804862840499834e-16, "0", "%1.f", +__LINE__, 3.805375156822481e+12, "3805375156822.4814861", "%.7f", +__LINE__, 3.821612790153376e-17, "3.821613e-17", "%e", +__LINE__, 3.825193659558693e+14, "3.82519E+14", "%#G", +__LINE__, 3.834180638680996e+17, "+383418063868099565.638659", "%+f", +__LINE__, 3.834759760605814e-12, "3.83476E-12", "%G", +__LINE__, 3.839786235582770e+16, "+3.84e+16", "%+0.3g", +__LINE__, 3.843164462248778e+28, "3.84316e+28", "%#g", +__LINE__, 3.845599697858050e+22, "3.8456E+22", "%G", +__LINE__, 3.850147271017228e-21, "3.85e-21", "%.4g", +__LINE__, 3.850283557812101e+07, "3.85028E+07", "%G", +__LINE__, 3.854235609725703e+03, "3854.24", "%G", +__LINE__, 3.864901885489405e-15, "3.8649E-15", "%G", +__LINE__, 3.868630187629983e-24, "3.868630e-24", "%e", +__LINE__, 3.876764606134972e-03, "+3.8767646e-03", "%+#0.7e", +__LINE__, 3.884553592855422e+08, "+3.8845536e+08", "%+4.7e", +__LINE__, 3.887417494351062e+03, "3887.42", "%0g", +__LINE__, 3.887561018972304e+03, "3887.56", "%G", +__LINE__, 3.888554801724658e-24, "3.888555e-24", "%e", +__LINE__, 3.892806891909861e-01, "0.389281", "%f", +__LINE__, 3.914459791345755e+15, "+3.914460E+15", "%+E", +__LINE__, 3.918383209642759e+01, "39.1838", "%#G", +__LINE__, 3.923970658741865e-10, "3.92397E-10", "%G", +__LINE__, 3.928163650272335e+18, "3928163650272335161.162118", "%f", +__LINE__, 3.933053127721002e-20, "3.933053e-20", "%e", +__LINE__, 3.939306552155218e-29, "3.93931E-29", "%G", +__LINE__, 3.953007066379472e+07, "3.953007E+07", "%E", +__LINE__, 3.954924824986267e-01, "3.954925E-01", "%E", +__LINE__, 3.956156072067987e+15, "3.956E+15", "%0.4G", +__LINE__, 3.957756196797224e+22, "4.0E+22", "%4.1E", +__LINE__, 3.960011413261009e+27, "+3960011413261008783592842519.283295", "%+f", +__LINE__, 3.961789076323378e+20, "396178907632337828914.614875", "%f", +__LINE__, 3.961985468081708e-28, "3.96199E-28", "%1G", +__LINE__, 3.975007582283812e-27, "0.000000", "%0.6f", +__LINE__, 3.987586813142132e+15, "+3.98759e+15", "%+g", +__LINE__, 3.992250836957379e+21, "3.99225E+21", "%0G", +__LINE__, 3.992985048620057e+00, "3.9930", "%.4f", +__LINE__, 4.000000000000000e+02, "400.00", "%.2f", +__LINE__, 4.000145414240556e+14, "4.00015e+14", "%#6g", +__LINE__, 4.000774453529974e-25, "4E-25", "%.0E", +__LINE__, 4.002041494804383e+17, "4.002041E+17", "%E", +__LINE__, 4.005505415013214e+17, " 4E+17", "%6.2G", +__LINE__, 4.008960306876491e-28, "0.000", "%.3f", +__LINE__, 4.032337828117640e+16, "4.03234E+16", "%G", +__LINE__, 4.035414597530057e+26, "403541459753005682387083652.429283", "%f", +__LINE__, 4.037065874793069e-01, "0.403707", "%f", +__LINE__, 4.047856284449970e-14, "4.04786E-14", "%#G", +__LINE__, 4.049037221323070e-04, "4.049037e-04", "%e", +__LINE__, 4.053458853142009e-07, "4E-07", "%2.0E", +__LINE__, 4.056455443275955e-22, "4.056455e-22", "%e", +__LINE__, 4.058158020771355e-22, "4.05816e-22", "%#2g", +__LINE__, 4.067283508945137e+02, "+4.07e+02", "%+5.2e", +__LINE__, 4.072155715199509e+11, "4.072e+11", "%.4g", +__LINE__, 4.074643403755990e-22, "4e-22", "%0.g", +__LINE__, 4.077450352325251e+08, "4.1e+08", "%3.2g", +__LINE__, 4.081492619284916e-08, "4.081493E-08", "%E", +__LINE__, 4.083271801996951e-10, "4.083272E-10", "%#E", +__LINE__, 4.090188547940879e-15, "4.090189E-15", "%#E", +__LINE__, 4.091167728938537e-11, "4e-11", "%1.g", +__LINE__, 4.091916745541154e+15, "4091916745541153.588306", "%f", +__LINE__, 4.092366122921161e+23, "4E+23", "%0.E", +__LINE__, 4.094638368212577e-11, "4.09464E-11", "%#G", +__LINE__, 4.097148443124199e-16, "0.000000", "%f", +__LINE__, 4.101057893946401e+06, "4e+06", "%4.g", +__LINE__, 4.101209521231476e+28, "41012095212314756409455185348.633677", "%f", +__LINE__, 4.105683659045903e+05, "+4.E+05", "%+#1.G", +__LINE__, 4.111553717385758e-16, "4.11155e-16", "%g", +__LINE__, 4.112186409918593e+14, "+4.11219e+14", "%+g", +__LINE__, 4.117782144860865e+25, "4.117782E+25", "%5E", +__LINE__, 4.119420921722146e-27, "4.11942e-27", "%g", +__LINE__, 4.134953783635018e+14, "+4.1349538e+14", "%+.7e", +__LINE__, 4.136990822648468e+11, "4.136991E+11", "%E", +__LINE__, 4.140475788523046e+14, "+4E+14", "%+5.G", +__LINE__, 4.149589679915584e+24, "4.14959E+24", "%2G", +__LINE__, 4.151240342256744e-22, " 0", "%2.f", +__LINE__, 4.155533104307272e-04, "+0.000416", "%+f", +__LINE__, 4.155890511880097e+25, "4.155891e+25", "%e", +__LINE__, 4.159907901074450e-19, "4.159908E-19", "%7E", +__LINE__, 4.171899783464252e+18, "4E+18", "%.0E", +__LINE__, 4.177920266276382e-17, "+0.0000", "%+1.4f", +__LINE__, 4.181728014477237e-20, "4.18173e-20", "%.6g", +__LINE__, 4.203600495086497e-30, " 4E-30", "%6.G", +__LINE__, 4.211166112605717e-08, "4E-08", "%5.1G", +__LINE__, 4.219513437404614e+18, "+4E+18", "%+.0E", +__LINE__, 4.221426315236785e+08, "4.221426E+08", "%#E", +__LINE__, 4.226224756005934e-13, " 4.e-13", "%#7.g", +__LINE__, 4.226979046489921e-01, "4.226979e-01", "%#.6e", +__LINE__, 4.236283521629158e-08, "+4.23628E-08", "%+G", +__LINE__, 4.239850628514233e-07, "4.23985E-07", "%.6G", +__LINE__, 4.241177358638621e+04, "42411.773586", "%2f", +__LINE__, 4.245306724398964e-13, "0.000000", "%#f", +__LINE__, 4.246194290300334e+16, "42461942903003340.177293", "%2f", +__LINE__, 4.251238996137952e-05, "4.25124E-05", "%3G", +__LINE__, 4.262432542017438e+13, "42624325420174.375978", "%1f", +__LINE__, 4.266383084300715e+16, "4E+16", "%4.G", +__LINE__, 4.292963398931474e-11, "4.292963E-11", "%E", +__LINE__, 4.296530271399131e-29, "0.000000", "%6f", +__LINE__, 4.303753949741171e+19, "4.30375E+19", "%2G", +__LINE__, 4.303767633827431e-28, "4.30377e-28", "%g", +__LINE__, 4.316181911403991e-30, "4.3162e-30", "%#7.5g", +__LINE__, 4.318654697213126e-18, "4.31865e-18", "%g", +__LINE__, 4.320618603119499e+05, "432061.860312", "%3f", +__LINE__, 4.322443609118441e+21, "4.32244E+21", "%7.5E", +__LINE__, 4.322522446810708e-15, "4.32252e-15", "%.6g", +__LINE__, 4.334728493589115e-18, "0.000000", "%f", +__LINE__, 4.335342531476346e-19, "4.33534E-19", "%G", +__LINE__, 4.340579325084176e-30, "4.34058e-30", "%#0.6g", +__LINE__, 4.340775659883185e+04, "43407.756599", "%6f", +__LINE__, 4.361131891528634e-14, " 4E-14", "%6.G", +__LINE__, 4.366662624371249e-02, "+0.04", "%+4.g", +__LINE__, 4.369919308458348e+28, "+4.36992e+28", "%+2g", +__LINE__, 4.369930393192433e-24, "4.369930e-24", "%e", +__LINE__, 4.376283118322521e-01, "0.437628", "%g", +__LINE__, 4.386868840825930e+19, "4.3869E+19", "%.5G", +__LINE__, 4.389349113395235e+05, "+4.389349e+05", "%+e", +__LINE__, 4.392447466753053e-08, "+4.392E-08", "%+.4G", +__LINE__, 4.394068619246889e-13, "4.39407e-13", "%6g", +__LINE__, 4.404889573700147e-09, "4.404890E-09", "%E", +__LINE__, 4.410531039373014e+05, "+4.41e+05", "%+.2e", +__LINE__, 4.412466606726400e-08, " 0.0", "%6.1f", +__LINE__, 4.414693719279123e+17, "4.414694e+17", "%e", +__LINE__, 4.417050329080679e-01, "+0.441705", "%+g", +__LINE__, 4.419509841929196e-10, "4.4195098E-10", "%.7E", +__LINE__, 4.421012777695611e+07, "+4.42101E+07", "%+0.6G", +__LINE__, 4.426387732151208e+11, "4.42639e+11", "%g", +__LINE__, 4.439567017550398e+26, "4.439567E+26", "%E", +__LINE__, 4.446479816166258e-21, "4.446480e-21", "%0e", +__LINE__, 4.453486178424380e+05, "445348.617842", "%f", +__LINE__, 4.455733696043438e+06, "4.45573e+06", "%3g", +__LINE__, 4.455870606312063e+16, "4.45587e+16", "%g", +__LINE__, 4.458776435431700e+22, "4e+22", "%1.g", +__LINE__, 4.466448605584151e-30, "0.000000", "%f", +__LINE__, 4.471063097005706e+16, "4.47106E+16", "%G", +__LINE__, 4.482001890035190e-22, "+4.482E-22", "%+G", +__LINE__, 4.493246870093631e+05, "449325", "%1G", +__LINE__, 4.496089639281023e+17, "4.49609e+17", "%g", +__LINE__, 4.515066070117557e+15, "4.51507e+15", "%g", +__LINE__, 4.518296460916194e+24, "+4.5183E+24", "%+G", +__LINE__, 4.526548719445596e+02, "452.655", "%6.3f", +__LINE__, 4.532756455106440e-26, "4.53e-26", "%4.2e", +__LINE__, 4.534466782633055e-14, "4.53447E-14", "%G", +__LINE__, 4.541313061854649e-14, "4.54131E-14", "%G", +__LINE__, 4.541848265404338e+02, " 5E+02", "%7.G", +__LINE__, 4.546603085406363e-26, "5E-26", "%3.G", +__LINE__, 4.557349604829375e+28, "+45573496048293753446500886639.", "%+#1.f", +__LINE__, 4.560736449944898e-27, "4.56074e-27", "%g", +__LINE__, 4.563726230559341e-15, "+0.0", "%+2.1f", +__LINE__, 4.572650965532532e-26, "+5E-26", "%+4.G", +__LINE__, 4.574369572115099e-10, "+0.000000", "%+2.6f", +__LINE__, 4.576480601519729e+28, "+4.576481e+28", "%+e", +__LINE__, 4.587487640650499e+02, "+458.75", "%+3.2f", +__LINE__, 4.598365231538559e-27, "4.59837E-27", "%G", +__LINE__, 4.599348244725009e-28, "+4.5993482e-28", "%+#3.7e", +__LINE__, 4.599897524047587e+22, "45998975240475870052136.997401", "%#f", +__LINE__, 4.605415604725077e-25, "0.000000", "%f", +__LINE__, 4.613055015797716e+28, "4.613055E+28", "%E", +__LINE__, 4.618715275814238e-10, "4.618715E-10", "%E", +__LINE__, 4.619044579489540e-14, "0.00", "%.2f", +__LINE__, 4.633693310095410e-20, "+0.000000", "%+f", +__LINE__, 4.648505395281916e-28, "0.000000", "%f", +__LINE__, 4.651232770446398e+21, "4.65e+21", "%.2e", +__LINE__, 4.659743589975352e+28, "+4.65974e+28", "%+g", +__LINE__, 4.660181457075208e-13, "4.66018e-13", "%g", +__LINE__, 4.669787018529686e+20, "4.66979e+20", "%g", +__LINE__, 4.672649286126732e-21, "4.6726E-21", "%4.5G", +__LINE__, 4.675431901120643e-11, " 0", "%3.f", +__LINE__, 4.684404068169945e+26, "468440406816994503458317922.2", "%6.1f", +__LINE__, 4.685438834234642e+19, "5.E+19", "%#6.G", +__LINE__, 4.688915890732712e+00, "+5e+00", "%+2.e", +__LINE__, 4.692999432046297e+00, "4.692999E+00", "%E", +__LINE__, 4.708690772584701e+11, "4.70869e+11", "%g", +__LINE__, 4.711821455782105e-11, "+4.71182e-11", "%+1g", +__LINE__, 4.712413965116830e-01, "4.712414E-01", "%E", +__LINE__, 4.719504715401049e-08, "0.000000", "%f", +__LINE__, 4.719767896031655e+27, "4.71977e+27", "%#g", +__LINE__, 4.722493017411588e-05, "0.000047", "%4f", +__LINE__, 4.729482386761477e+08, "4.72948e+08", "%1g", +__LINE__, 4.730102169800602e-06, "0.000005", "%f", +__LINE__, 4.743951614209393e+24, "4.743952E+24", "%#E", +__LINE__, 4.746077075605921e-16, "4.746E-16", "%.3E", +__LINE__, 4.747802537919248e+24, "4747802537919247889419694", "%4.f", +__LINE__, 4.754727690703025e-26, "0", "%0.f", +__LINE__, 4.756952432926979e-29, " 0.", "%#3.f", +__LINE__, 4.758335147956709e+03, "4758.335148", "%f", +__LINE__, 4.760141880810268e-25, "4.760142e-25", "%e", +__LINE__, 4.767079423650815e-07, "5.E-07", "%#0.G", +__LINE__, 4.785662728343338e-28, "4.78566e-28", "%g", +__LINE__, 4.787146245774150e-13, "+4.78715E-13", "%+G", +__LINE__, 4.787415449888824e-17, "4.78742e-17", "%3g", +__LINE__, 4.794589807429657e-05, "4.79459E-05", "%6G", +__LINE__, 4.794948299666205e+08, "4.79495e+08", "%g", +__LINE__, 4.802292865915992e-04, "4.802293e-04", "%e", +__LINE__, 4.802513688198601e+07, "+4.8e+07", "%+2.3g", +__LINE__, 4.810456746192536e+06, "5E+06", "%0.0G", +__LINE__, 4.820631660081696e+20, "+4.82063E+20", "%+G", +__LINE__, 4.827865857270075e-20, "4.82787e-20", "%g", +__LINE__, 4.835054268490970e+21, "4835054268490970308391.752042", "%#f", +__LINE__, 4.838136770808465e-18, "4.83814E-18", "%G", +__LINE__, 4.839342397882353e-26, "4.839342E-26", "%E", +__LINE__, 4.845130210072029e-16, "0", "%1.f", +__LINE__, 4.845161043167169e-12, "+4.845e-12", "%+.4g", +__LINE__, 4.857425142494964e+01, "48.574251", "%f", +__LINE__, 4.858118337285513e-10, "+4.8581e-10", "%+.5g", +__LINE__, 4.867478343525339e-15, "+4.867478E-15", "%+E", +__LINE__, 4.886137001331278e-11, "0.000000", "%f", +__LINE__, 4.886835850687998e-20, " 0", "%6.0f", +__LINE__, 4.886880737482383e+26, "488688073748238327453918827.814050", "%4f", +__LINE__, 4.888812049144075e-22, "4.888812E-22", "%E", +__LINE__, 4.895869618002905e+02, "+489.587", "%+.7g", +__LINE__, 4.902046593298549e+09, " 5e+09", "%7.g", +__LINE__, 4.907918627564751e-05, "4.91e-05", "%.3g", +__LINE__, 4.916048355579009e+19, "49160483555790088772", "%2.f", +__LINE__, 4.917197806128638e+14, "+5e+14", "%+5.g", +__LINE__, 4.918303274189911e+13, "4.918303e+13", "%e", +__LINE__, 4.922687970321108e+26, "492268797032110771993984599.2485", "%0.4f", +__LINE__, 4.929263362431195e+14, "4.92926e+14", "%g", +__LINE__, 4.933385398543267e-17, "0.000000", "%#f", +__LINE__, 4.942367126455025e+00, " +5", "%+6.f", +__LINE__, 4.947687486717652e-04, "0.000495", "%.6f", +__LINE__, 4.960855200003128e-08, "+4.960855e-08", "%+e", +__LINE__, 4.968485435774085e-21, "0.0000", "%#2.4f", +__LINE__, 4.972088381506133e+01, "49.7", "%.1f", +__LINE__, 4.977561524480392e-15, "4.977562E-15", "%7E", +__LINE__, 4.984592111249502e-13, "5.0e-13", "%.1e", +__LINE__, 4.997502335602838e-14, "4.998e-14", "%6.4g", +__LINE__, 5.001731554335935e-09, "5.00173e-09", "%g", +__LINE__, 5.006231697107042e-17, "5.0062e-17", "%1.5g", +__LINE__, 5.008035801093423e+24, "5.008036E+24", "%#E", +__LINE__, 5.008756965733827e-28, "5.009E-28", "%.4G", +__LINE__, 5.009774027622812e+20, "+5.00977E+20", "%+G", +__LINE__, 5.010576312346293e+29, "5.01058E+29", "%G", +__LINE__, 5.012335250996786e+29, "5.012335e+29", "%.7g", +__LINE__, 5.012404365186907e+20, "5E+20", "%3.2G", +__LINE__, 5.024670103250229e-01, "+5.024670E-01", "%+E", +__LINE__, 5.025765369164560e+03, "5025.77", "%g", +__LINE__, 5.027173841003918e+11, "+5.02717E+11", "%+G", +__LINE__, 5.032093817639893e-26, "5e-26", "%3.e", +__LINE__, 5.039636818525848e-02, "0.050396", "%#f", +__LINE__, 5.040626671307691e+23, "5.040627E+23", "%E", +__LINE__, 5.040788233368296e-11, "+5.04079e-11", "%+g", +__LINE__, 5.040903321336150e-28, "5.0409E-28", "%G", +__LINE__, 5.042078512958994e+12, "5.04208E+12", "%G", +__LINE__, 5.045957900223303e+15, "5045957900223303", "%0.f", +__LINE__, 5.048298764352134e-14, "5.048299e-14", "%1e", +__LINE__, 5.048827326763192e+28, "50488273267631917917697137454.524636", "%f", +__LINE__, 5.049714558347361e-23, "5e-23", "%5.0g", +__LINE__, 5.051509904923853e+16, "50515099049238534", "%5.f", +__LINE__, 5.052789863743305e-10, "5.05279E-10", "%6G", +__LINE__, 5.057429728861999e-29, "0.000", "%#1.3f", +__LINE__, 5.075313093968501e-13, "+5.07531e-13", "%+g", +__LINE__, 5.075874503501582e+29, "5e+29", "%2.e", +__LINE__, 5.079468079020803e+01, "50.795", "%.5G", +__LINE__, 5.086214826494080e-28, " 0.0", "%4.1f", +__LINE__, 5.096054881114421e+13, "5.096e+13", "%.4g", +__LINE__, 5.099045274853458e-23, "5.09905E-23", "%0G", +__LINE__, 5.100248195124433e+00, "5.100248", "%f", +__LINE__, 5.101016114276598e-20, "5e-20", "%4.1g", +__LINE__, 5.103213528670269e+07, "51032135.286703", "%6f", +__LINE__, 5.108373625126768e+08, "+510837362.512677", "%+f", +__LINE__, 5.113097157183416e+07, "5.1131E+07", "%#.4E", +__LINE__, 5.114452611789777e+08, "+5.11445E+08", "%+G", +__LINE__, 5.117099184715288e-16, "5.1171E-16", "%G", +__LINE__, 5.119910534665511e-13, "+5.11991E-13", "%+G", +__LINE__, 5.121320931953720e+23, "+5.121321e+23", "%+#e", +__LINE__, 5.121900318443998e+06, "5.121900e+06", "%e", +__LINE__, 5.135698679084286e+00, "5.1357", "%2g", +__LINE__, 5.146355903104154e-10, "+5.14636E-10", "%+.6G", +__LINE__, 5.148754210958986e-24, "+5.148754e-24", "%+e", +__LINE__, 5.156238368448428e+26, "5e+26", "%5.g", +__LINE__, 5.159924520667922e-19, "+5E-19", "%+0.1G", +__LINE__, 5.159938266135425e-27, "0.000000", "%f", +__LINE__, 5.165915205175676e-01, "5.165915e-01", "%e", +__LINE__, 5.190205499401547e-11, "5e-11", "%2.1g", +__LINE__, 5.193260005542003e+26, "5.19326e+26", "%#g", +__LINE__, 5.194732077318269e+08, "519473207.731827", "%f", +__LINE__, 5.196394616633798e-19, "0", "%.0f", +__LINE__, 5.206753628035638e+19, "5.20675e+19", "%6.6g", +__LINE__, 5.207364136540851e-23, " 0.000", "%6.3f", +__LINE__, 5.210672737132108e-09, "5.21067E-09", "%G", +__LINE__, 5.211423933057123e-20, "+5.21142E-20", "%+G", +__LINE__, 5.219749528363367e-27, "5.219750e-27", "%e", +__LINE__, 5.228031587478653e-06, "+5.2E-06", "%+3.1E", +__LINE__, 5.229303095005359e-25, "+0.000000", "%+#f", +__LINE__, 5.234703511938320e-06, " 0", "%7.f", +__LINE__, 5.235655046937822e-20, "5.235655E-20", "%.6E", +__LINE__, 5.237924986002288e-01, "+0.52379", "%+.5f", +__LINE__, 5.249148093603826e+20, "5.24915E+20", "%0G", +__LINE__, 5.262680920244596e+16, "5.26268E+16", "%G", +__LINE__, 5.267944704715845e-06, "5.e-06", "%#3.g", +__LINE__, 5.268543533730505e-08, "5.26854E-08", "%G", +__LINE__, 5.275727269515247e-02, "0.0527573", "%.6g", +__LINE__, 5.279215316873723e+24, "5279215316873722585455652.733799", "%f", +__LINE__, 5.284326985680811e+16, "52843269856808108.286828", "%6f", +__LINE__, 5.286192957344040e-10, "5.3E-10", "%.1E", +__LINE__, 5.289451976001091e-23, "5.28945E-23", "%G", +__LINE__, 5.289512908209300e+09, "+5.289513e+09", "%+e", +__LINE__, 5.295696957972123e+11, "5.296E+11", "%#.3E", +__LINE__, 5.303584684011050e+16, "53035846840110503.208621", "%f", +__LINE__, 5.310315581980172e+23, "531031558198017172855998", "%4.f", +__LINE__, 5.317492728410062e-14, "5.31749e-14", "%7g", +__LINE__, 5.324506949499409e+18, "5.3245E+18", "%.5G", +__LINE__, 5.329238068668336e-20, "5e-20", "%4.g", +__LINE__, 5.336050125161774e+14, "5.33605e+14", "%g", +__LINE__, 5.349921315003169e-17, "5.34992E-17", "%.6G", +__LINE__, 5.355648481782587e-20, "5.355648e-20", "%e", +__LINE__, 5.358945557589489e-26, "+5e-26", "%+0.g", +__LINE__, 5.359638846465574e+21, "5.359639E+21", "%E", +__LINE__, 5.377048469393900e+14, "5.377E+14", "%.5G", +__LINE__, 5.387471194156434e+23, "5.387471E+23", "%.7G", +__LINE__, 5.401622578962497e-03, "+0.0054", "%+5.2g", +__LINE__, 5.406882732497444e-16, "5.406883E-16", "%E", +__LINE__, 5.421474560523198e-11, "+5.42147e-11", "%+g", +__LINE__, 5.440249323479418e-26, "5.44025E-26", "%7G", +__LINE__, 5.440922682921101e-05, "5e-05", "%.1g", +__LINE__, 5.444400103673185e-01, "0.54444", "%G", +__LINE__, 5.449339470916152e+09, "5449339470.9162", "%.4f", +__LINE__, 5.451583259558706e-15, "5.e-15", "%#4.e", +__LINE__, 5.460153018660573e+26, "+546015301866057267687892817.775719", "%+f", +__LINE__, 5.477591210511918e+08, "+5.47759E+08", "%+0.5E", +__LINE__, 5.481665401407188e-02, "5.481665e-02", "%e", +__LINE__, 5.482670784411319e-16, "5E-16", "%4.G", +__LINE__, 5.487494580636099e+12, "5.48749e+12", "%g", +__LINE__, 5.508630369473937e-10, "5.508630e-10", "%e", +__LINE__, 5.528898001438273e+20, "6e+20", "%4.g", +__LINE__, 5.530331734443152e-24, " 6e-24", "%6.g", +__LINE__, 5.531704398969656e-24, "0.000000", "%f", +__LINE__, 5.539906569043238e+05, "+553990.656904", "%+f", +__LINE__, 5.554571854756323e-08, "+0.00000", "%+4.5f", +__LINE__, 5.555155069925145e-28, "5.55516e-28", "%g", +__LINE__, 5.555302705075539e-08, "+5.5553e-08", "%+g", +__LINE__, 5.563805076159055e-05, "5.563805e-05", "%e", +__LINE__, 5.565063508995002e+07, "5.565E+07", "%.3E", +__LINE__, 5.566281664807526e-08, "5.56628E-08", "%G", +__LINE__, 5.575245679736338e-08, "5.575246e-08", "%e", +__LINE__, 5.578254777281501e-21, "0.", "%#.0f", +__LINE__, 5.582389275770848e-01, " 0.6", "%5.G", +__LINE__, 5.592215029176133e-04, "0.00056", "%.2g", +__LINE__, 5.593536789867047e-25, "5.59354e-25", "%g", +__LINE__, 5.605652054074862e-03, " 0.006", "%8.G", +__LINE__, 5.606982382643258e+20, "+5.60698E+20", "%+G", +__LINE__, 5.614646821116853e-18, "5.6E-18", "%.2G", +__LINE__, 5.625586848606565e-11, "+5.62559E-11", "%+G", +__LINE__, 5.626300428046732e+26, " 6e+26", "%7.g", +__LINE__, 5.638236626881086e-17, " 6E-17", "%6.G", +__LINE__, 5.645744817075691e+04, "5.645745E+04", "%E", +__LINE__, 5.651410004691736e+06, "6.E+06", "%#3.E", +__LINE__, 5.659582345929256e-11, "+0.000000", "%+f", +__LINE__, 5.670968861413510e+16, "+5.67097E+16", "%+G", +__LINE__, 5.672476851235796e+01, "+56.724769", "%+0f", +__LINE__, 5.674563779921248e+28, " 6E+28", "%6.0G", +__LINE__, 5.675558529939025e+19, "5.67556e+19", "%3g", +__LINE__, 5.676326888314589e-08, " 6e-08", "%7.g", +__LINE__, 5.677928507840897e-30, "5.67793e-30", "%0g", +__LINE__, 5.686622552402630e-15, "5.69E-15", "%1.3G", +__LINE__, 5.710441686922142e-14, "5.710442E-14", "%E", +__LINE__, 5.713234603280163e-21, "0.00000", "%0.5f", +__LINE__, 5.714968959046963e+12, "5.71497e+12", "%g", +__LINE__, 5.722025141555638e-23, "5.72e-23", "%.2e", +__LINE__, 5.725398571007033e-09, "5.7254E-09", "%.6G", +__LINE__, 5.751604813862738e+18, "6E+18", "%.1G", +__LINE__, 5.761025444751985e+20, "5.76103e+20", "%g", +__LINE__, 5.762315767948593e+15, "5.76232e+15", "%4g", +__LINE__, 5.764528858586032e-15, "5.764529E-15", "%6.7G", +__LINE__, 5.766408541535810e-07, " 6E-07", "%6.1G", +__LINE__, 5.771831571087174e-01, "0.577183", "%f", +__LINE__, 5.790102497364865e-15, "+5.790102e-15", "%+e", +__LINE__, 5.790222335547785e-08, "5.79022e-08", "%0.6g", +__LINE__, 5.794082127091130e+21, "5794082127091130018925.468903", "%f", +__LINE__, 5.804568463644165e+28, "5.80457e+28", "%g", +__LINE__, 5.827356651901066e+20, "582735665190106555400.006982", "%f", +__LINE__, 5.837553387436408e+18, "5.837553E+18", "%3E", +__LINE__, 5.844458110907209e+22, "5.84446e+22", "%g", +__LINE__, 5.851672125746866e-19, "5.85167e-19", "%g", +__LINE__, 5.868843476784172e-12, "5.868843e-12", "%1.7g", +__LINE__, 5.870854146748864e-04, "0.000587", "%2.3g", +__LINE__, 5.877787821470433e+01, "+58.77788", "%+#3.5f", +__LINE__, 5.881333514866498e+04, "5.881334E+04", "%E", +__LINE__, 5.908427816128965e+28, "+5.908428E+28", "%+E", +__LINE__, 5.918139800007388e+07, "59181398.000074", "%f", +__LINE__, 5.925587467475260e+21, "5925587467475259551008.548442", "%f", +__LINE__, 5.930403502679683e-22, "5.9304E-22", "%.6G", +__LINE__, 5.961572644847521e+02, "+596.157", "%+G", +__LINE__, 5.968917715225198e-21, "5.96892e-21", "%4g", +__LINE__, 5.982184454670110e-08, "0", "%0.f", +__LINE__, 5.988414319040855e+09, "6E+09", "%0.G", +__LINE__, 5.996263783103995e-10, "5.996264e-10", "%e", +__LINE__, 6.004634162276014e-18, "6.00463e-18", "%g", +__LINE__, 6.018734975519166e-08, "6.01873E-08", "%G", +__LINE__, 6.029071822986717e-14, "0.0000000", "%.7f", +__LINE__, 6.030392278117406e+23, "6.030392e+23", "%e", +__LINE__, 6.034553399237175e-27, "+6.03455e-27", "%+g", +__LINE__, 6.034938873443862e+24, "6034938873443861595546877.651941", "%f", +__LINE__, 6.038929148003457e-16, "6.03893e-16", "%g", +__LINE__, 6.039149626573702e-13, "6.0391E-13", "%3.5G", +__LINE__, 6.041247664739301e+29, "6.041248E+29", "%3E", +__LINE__, 6.044220746789781e+20, "+6.04422e+20", "%+g", +__LINE__, 6.045775647107433e+19, "6E+19", "%2.G", +__LINE__, 6.051917010461611e-05, "6.05192E-05", "%G", +__LINE__, 6.059773181566425e+17, "+605977318156642486", "%+5.f", +__LINE__, 6.082239575475813e+01, "+6E+01", "%+.1G", +__LINE__, 6.093984174629151e+18, "6.093984e+18", "%e", +__LINE__, 6.102368380479137e+22, "6.1E+22", "%.2G", +__LINE__, 6.103097446204007e+25, "61030974462040070704915706.301108", "%#0f", +__LINE__, 6.105244994410556e-24, "0.0000000", "%2.7f", +__LINE__, 6.110828906801633e-14, "+6.110829e-14", "%+3e", +__LINE__, 6.124439072468681e-30, "6.12444e-30", "%g", +__LINE__, 6.127714703273447e-15, "0", "%0.f", +__LINE__, 6.128539582408870e-15, "6.12854e-15", "%g", +__LINE__, 6.145470264744349e+24, "6145470264744348654062378.045637", "%f", +__LINE__, 6.159177701667455e+26, "615917770166745537352426254.074089", "%#f", +__LINE__, 6.159348213337442e+17, "6.15935e+17", "%g", +__LINE__, 6.161953891020492e-21, "0.000000", "%f", +__LINE__, 6.169474192777305e+29, "+6.169E+29", "%+.4G", +__LINE__, 6.198519761010651e-15, "+0", "%+1.f", +__LINE__, 6.201381824304919e-27, " 0", "%5.f", +__LINE__, 6.204387065736372e-18, "6.204387E-18", "%7E", +__LINE__, 6.209270088144063e-24, "0.000000", "%f", +__LINE__, 6.209871738353546e-20, "6.20987E-20", "%G", +__LINE__, 6.222733191871026e+14, "+6.22273e+14", "%+g", +__LINE__, 6.234670085354310e+04, "+62346.700854", "%+f", +__LINE__, 6.258389346602224e-09, "6E-09", "%.0G", +__LINE__, 6.263326582587503e+12, "6263326582588.", "%#5.f", +__LINE__, 6.272768026763922e+03, "+6272.77", "%+g", +__LINE__, 6.287747868625765e+00, "6E+00", "%.0E", +__LINE__, 6.297724027388795e-17, "+6E-17", "%+3.G", +__LINE__, 6.309940679156400e+27, "6.30994e+27", "%6.5e", +__LINE__, 6.312960327030170e+06, "+6.312960E+06", "%+E", +__LINE__, 6.317658179632976e+02, "+631.766", "%+g", +__LINE__, 6.321255960699571e-27, "0.000000", "%f", +__LINE__, 6.323069932833900e+03, "6323", "%.4G", +__LINE__, 6.337027835933034e+21, "6.33703e+21", "%#g", +__LINE__, 6.343583177899838e-03, "0.00634358", "%7G", +__LINE__, 6.347464241733904e-03, "6.e-03", "%#0.e", +__LINE__, 6.352038720353924e+07, "63520387.203539", "%f", +__LINE__, 6.355292378565109e+23, "+635529237856510942350496.407016", "%+f", +__LINE__, 6.377901944439164e-29, "0.000", "%2.3f", +__LINE__, 6.378660255554053e-04, "6.37866E-04", "%.5E", +__LINE__, 6.382838195255167e-18, "0.000000", "%f", +__LINE__, 6.391046303581911e+22, "6E+22", "%.0G", +__LINE__, 6.404812348309621e+22, "6.404812E+22", "%.7G", +__LINE__, 6.406154091357119e+16, "6.40615E+16", "%G", +__LINE__, 6.419414726557980e+21, "+6.41941e+21", "%+g", +__LINE__, 6.432166563008504e+10, " +6e+10", "%+7.g", +__LINE__, 6.438463704193190e+19, "6.438464e+19", "%e", +__LINE__, 6.445270237908565e+15, "+6.445270E+15", "%+E", +__LINE__, 6.445536770502964e+09, "6.446e+09", "%.3e", +__LINE__, 6.446614224811444e+28, "64466142248114444157636171439.662576", "%f", +__LINE__, 6.457046289718297e+18, "6457046289718297416.015957", "%4f", +__LINE__, 6.457682856890173e+01, "6.457683E+01", "%2E", +__LINE__, 6.471026352792729e-16, "+6.47103e-16", "%+g", +__LINE__, 6.474527749567342e+19, "6E+19", "%.1G", +__LINE__, 6.481178401781131e-24, "+6.48E-24", "%+6.3G", +__LINE__, 6.490736647261461e-15, "+6.49074e-15", "%+g", +__LINE__, 6.493196535069719e+23, "+6.4932E+23", "%+G", +__LINE__, 6.500296992935538e-20, "+0.0", "%+.1f", +__LINE__, 6.502867735895890e-19, "+0.000000", "%+6f", +__LINE__, 6.506627529164683e+14, "650662752916468", "%5.f", +__LINE__, 6.511909298966434e-15, "+6.51191E-15", "%+G", +__LINE__, 6.514463062693312e+01, "65.1446", "%G", +__LINE__, 6.520721469484543e+16, "6.52072E+16", "%G", +__LINE__, 6.528064508731680e-05, "6.528065E-05", "%7E", +__LINE__, 6.529007214194039e-24, "0.000000", "%f", +__LINE__, 6.537822760557410e-23, "0.000000", "%f", +__LINE__, 6.552222096390805e+29, "+6.55222E+29", "%+G", +__LINE__, 6.554569862717104e+12, "6.55457E+12", "%G", +__LINE__, 6.563440840359989e-30, "7E-30", "%4.G", +__LINE__, 6.586246985535526e+17, "6.58625E+17", "%#4G", +__LINE__, 6.593339522442827e+16, "6.6E+16", "%#4.1E", +__LINE__, 6.611179030024350e+02, "7E+02", "%4.E", +__LINE__, 6.617541638586767e-10, "6.617542E-10", "%E", +__LINE__, 6.619147920886991e-28, "7e-28", "%.1g", +__LINE__, 6.622304444772819e-21, "6.62230E-21", "%#4G", +__LINE__, 6.634766655157910e+12, "6634766655158", "%2.f", +__LINE__, 6.635639771921218e+25, "+6.63564E+25", "%+G", +__LINE__, 6.644575305929087e+17, "+6.64458e+17", "%+g", +__LINE__, 6.648697591328432e+04, "6.648698E+04", "%3E", +__LINE__, 6.665426012448100e+09, "6.66543E+09", "%G", +__LINE__, 6.675222780441723e-23, "6.67522e-23", "%1g", +__LINE__, 6.689765053880623e+00, "6.6898", "%.5g", +__LINE__, 6.693874943680238e+25, "7.e+25", "%#1.g", +__LINE__, 6.695033453546435e+19, "6.695033E+19", "%E", +__LINE__, 6.720131534244976e+03, "+6720.132", "%+.3f", +__LINE__, 6.725287004784564e+19, "+6.72529e+19", "%+g", +__LINE__, 6.743599626906313e-18, "0.0000000", "%7.7f", +__LINE__, 6.755534260704152e+29, "7.e+29", "%#5.e", +__LINE__, 6.761855244766418e-18, "6.8E-18", "%.2G", +__LINE__, 6.764974143681080e-02, "6.765E-02", "%2.3E", +__LINE__, 6.766924477711975e-17, "0.000000", "%4f", +__LINE__, 6.772195434106330e-19, "6.7722E-19", "%G", +__LINE__, 6.779433073319225e-23, "0.00", "%.2f", +__LINE__, 6.790317710068964e+05, "6.8e+05", "%.1e", +__LINE__, 6.791378160292960e+02, "679.137816", "%f", +__LINE__, 6.798381262104190e-27, "0.000000", "%f", +__LINE__, 6.804165939424860e-14, "7e-14", "%4.g", +__LINE__, 6.810668670623699e+11, "681066867062.369852", "%f", +__LINE__, 6.838942637635821e-17, "+6.84e-17", "%+.2e", +__LINE__, 6.868523988329111e-09, "+6.868524e-09", "%+e", +__LINE__, 6.873228061403223e-15, "6.873228E-15", "%3E", +__LINE__, 6.879370500093334e-12, "+0.000000", "%+f", +__LINE__, 6.891525498686674e-10, "7e-10", "%0.g", +__LINE__, 6.923027319286220e+21, "7.e+21", "%#1.g", +__LINE__, 6.923565533024560e-11, "+6.92357e-11", "%+g", +__LINE__, 6.931415640770737e-24, "+6.93142e-24", "%+g", +__LINE__, 6.936582619246057e+09, "6.936583e+09", "%7e", +__LINE__, 6.938661496670582e+05, "693866.1496671", "%2.7f", +__LINE__, 6.946115378286550e-25, "0.000000", "%f", +__LINE__, 6.955823211921219e-09, "6.95582e-09", "%g", +__LINE__, 6.962365243425770e+29, "696236524342577034474288666388.019919", "%7f", +__LINE__, 6.970432274812882e+05, "+7e+05", "%+1.0e", +__LINE__, 6.975784942897122e-13, "6.975785e-13", "%e", +__LINE__, 6.976786489904214e-07, "6.97679E-07", "%3G", +__LINE__, 6.985245976357042e-05, "0.00", "%.2f", +__LINE__, 6.993402879410720e-21, "6.9934e-21", "%g", +__LINE__, 7.012183985341519e+28, "+70121839853415188770213717362", "%+2.f", +__LINE__, 7.028670648856025e-15, "7.028671e-15", "%.7g", +__LINE__, 7.034042985683665e-03, " 0", "%2.f", +__LINE__, 7.044054273278726e+18, "7.044e+18", "%7.4g", +__LINE__, 7.049706744250734e-06, "7E-06", "%0.E", +__LINE__, 7.061982657056197e+13, "+7.061983e+13", "%+e", +__LINE__, 7.066873668945899e+21, "7.06687E+21", "%G", +__LINE__, 7.087941418633258e+26, "7.08794E+26", "%G", +__LINE__, 7.108268134631547e+22, "7.108268E+22", "%E", +__LINE__, 7.112095848565475e-19, "7.1121e-19", "%g", +__LINE__, 7.116326241291862e+16, "7.116326e+16", "%e", +__LINE__, 7.118854843597607e-22, "0.000000", "%f", +__LINE__, 7.121423043456375e-27, "0.000000", "%f", +__LINE__, 7.131415427096460e-03, "0.007131", "%3f", +__LINE__, 7.132023279679892e+22, "7.e+22", "%#3.e", +__LINE__, 7.146250280189992e-18, "0.000000", "%f", +__LINE__, 7.150059058390724e+03, "7150.06", "%g", +__LINE__, 7.161081578177381e-02, "+0.0716108", "%+G", +__LINE__, 7.164935125149336e-27, "7.2E-27", "%#6.2G", +__LINE__, 7.173125717489549e-10, "7.173126e-10", "%e", +__LINE__, 7.174199549624193e+00, "7.1741995", "%.7f", +__LINE__, 7.192493588077649e+27, "7.19249e+27", "%g", +__LINE__, 7.215209568601445e-06, "7.215210e-06", "%e", +__LINE__, 7.238322284100497e+03, "7238.3", "%.1f", +__LINE__, 7.239203871123613e+06, "7239204", "%4.f", +__LINE__, 7.245809072577019e-09, "+7.245809E-09", "%+E", +__LINE__, 7.256275686433336e+03, "7.256276e+03", "%e", +__LINE__, 7.265774291605193e+27, "+7.26577E+27", "%+G", +__LINE__, 7.287968172227119e-21, "+7.287968e-21", "%+e", +__LINE__, 7.306020169678527e+12, "7E+12", "%2.E", +__LINE__, 7.315587463572568e-04, "0.", "%#.0f", +__LINE__, 7.324627764547963e+09, "7.324628E+09", "%#E", +__LINE__, 7.331904966719081e-06, "+7.3319E-06", "%+G", +__LINE__, 7.334448152798243e-02, "0.07", "%0.g", +__LINE__, 7.334487195961240e-01, "+0.733449", "%+#g", +__LINE__, 7.381283575515707e+13, "7.381284E+13", "%E", +__LINE__, 7.394854567245476e-11, "0.000000", "%7f", +__LINE__, 7.401950211415377e-08, " 7e-08", "%6.e", +__LINE__, 7.409023867864680e+03, "7409.023868", "%#3f", +__LINE__, 7.411912956257733e-20, "7e-20", "%0.g", +__LINE__, 7.445275019272160e+11, "744527501927.2159511", "%.7f", +__LINE__, 7.450279765616891e-16, "7.45028e-16", "%.6g", +__LINE__, 7.467047411334495e+14, "7.46705E+14", "%G", +__LINE__, 7.485628870972725e+28, "7E+28", "%.0G", +__LINE__, 7.495391782588563e+11, "749539178258.856253", "%f", +__LINE__, 7.495824101611911e+06, "7.49582e+06", "%.6g", +__LINE__, 7.499759867592402e+20, "+749975986759240154100.3", "%+.1f", +__LINE__, 7.508983397140368e+04, "75089.8", "%g", +__LINE__, 7.512585199581016e-27, "7.512585E-27", "%.6E", +__LINE__, 7.516831372212545e-29, "+7.516831e-29", "%+e", +__LINE__, 7.525789465978582e+00, "7.52579", "%G", +__LINE__, 7.528655653725963e+06, "7.5287e+06", "%3.4e", +__LINE__, 7.533217421035612e+28, "75332174210356122046050586504.861712", "%f", +__LINE__, 7.534147071756384e+03, "7534.15", "%g", +__LINE__, 7.542648637430919e-25, "+0.000000", "%+#f", +__LINE__, 7.554380140947798e-15, " 8e-15", "%7.g", +__LINE__, 7.557366996007743e+25, " 8E+25", "%7.G", +__LINE__, 7.579228950138068e+08, "8e+08", "%3.e", +__LINE__, 7.579773904052487e-13, "0.000000", "%3f", +__LINE__, 7.580377544554059e+27, "7.58038e+27", "%#g", +__LINE__, 7.589615147875915e-15, "7.59E-15", "%.3G", +__LINE__, 7.593317194045158e-12, "+0.", "%+#1.f", +__LINE__, 7.605535657484387e-07, "7.60554E-07", "%G", +__LINE__, 7.609171121278006e-08, " 0", "%5.f", +__LINE__, 7.612033900317304e-14, "7.61203e-14", "%g", +__LINE__, 7.628040858080326e+23, "+7.62804e+23", "%+g", +__LINE__, 7.632109382948695e-01, "0.763211", "%#f", +__LINE__, 7.633415922627254e+28, "76334159226272539910951309138.908982", "%#f", +__LINE__, 7.636190400774419e+22, "+7.636190E+22", "%+E", +__LINE__, 7.636228368661314e-23, "0.000000", "%f", +__LINE__, 7.653292362739654e-17, "7.65329E-17", "%#G", +__LINE__, 7.664044705231460e+03, "7.664045E+03", "%5E", +__LINE__, 7.664257283149626e-05, "7.66426E-05", "%0G", +__LINE__, 7.668996632821614e-19, " 0.0", "%4.1f", +__LINE__, 7.674502669497263e-24, "7.6745e-24", "%g", +__LINE__, 7.681870119755193e+12, "+7.68187e+12", "%+#g", +__LINE__, 7.693453198401315e+02, "769.3453198", "%5.7f", +__LINE__, 7.705080073293603e-29, "7.705080E-29", "%1E", +__LINE__, 7.707244083934683e-07, "7.71E-07", "%2.3G", +__LINE__, 7.749445584970652e-17, "7.75E-17", "%6.3G", +__LINE__, 7.755369447889403e+09, "7.8e+09", "%#4.2g", +__LINE__, 7.760378169707072e-06, "7.76038e-06", "%g", +__LINE__, 7.763518882114968e-10, "0.000000", "%f", +__LINE__, 7.764720069569677e-18, "0.000000", "%0f", +__LINE__, 7.768821339438552e-03, "0.00776882", "%g", +__LINE__, 7.774767835990679e-29, "7.774768E-29", "%7E", +__LINE__, 7.805567188246987e-04, "0.000780557", "%2G", +__LINE__, 7.825157442935941e-26, "0.000000", "%f", +__LINE__, 7.833373563161910e+29, "+783337356316190991378789476584.643126", "%+f", +__LINE__, 7.875872661746674e-16, "7.875873E-16", "%E", +__LINE__, 7.880664458920439e-28, "7.881E-28", "%#0.3E", +__LINE__, 7.893084198630288e+18, "7893084198630288206", "%1.f", +__LINE__, 7.912222737877417e+04, "79122.2", "%G", +__LINE__, 7.913004582748724e-26, "0.000000", "%f", +__LINE__, 7.913749944463836e+17, "791374994446383617.230367", "%f", +__LINE__, 7.923881665760883e-24, "0.000000", "%f", +__LINE__, 7.926699779993694e-03, "0.007927", "%5.6f", +__LINE__, 7.941991860623354e-20, "7.941992e-20", "%e", +__LINE__, 7.942700358097138e+17, "794270035809713803.587329", "%2f", +__LINE__, 7.945451569935757e-16, "7.94545E-16", "%#4.6G", +__LINE__, 7.948277588625241e-04, "0", "%.0f", +__LINE__, 7.952265062569124e+21, "+7.95227e+21", "%+#g", +__LINE__, 7.959953534668040e+11, "8e+11", "%2.e", +__LINE__, 7.962059154424500e-22, "7.96206E-22", "%G", +__LINE__, 7.962856142535673e-26, "7.9629E-26", "%#.5G", +__LINE__, 7.966528574505771e+12, "7.96653e+12", "%g", +__LINE__, 8.006496880305429e-21, "8.0065E-21", "%G", +__LINE__, 8.023374861440542e+06, "+8023375", "%+6.f", +__LINE__, 8.041139717082990e-20, "8.04114e-20", "%g", +__LINE__, 8.044201752824126e+15, "8.04420E+15", "%.5E", +__LINE__, 8.044262927409321e-10, "+8E-10", "%+2.2G", +__LINE__, 8.058285708061202e+02, "+8.058286e+02", "%+e", +__LINE__, 8.104422320765144e+10, "8.10442e+10", "%#4g", +__LINE__, 8.104572628022330e-11, "0.000000", "%f", +__LINE__, 8.112156369917432e+15, "+8.11216E+15", "%+G", +__LINE__, 8.114566569709531e-18, "8.11457E-18", "%G", +__LINE__, 8.114795069552519e+13, "8.114795E+13", "%E", +__LINE__, 8.121382719830660e+03, "8121.382720", "%f", +__LINE__, 8.125179335533733e-12, "+8.125179e-12", "%+e", +__LINE__, 8.126383949107055e+19, "81263839491070548604.056967", "%f", +__LINE__, 8.129961701307842e-04, "+0.00081", "%+5.2g", +__LINE__, 8.143780077390936e+15, "8.14378E+15", "%G", +__LINE__, 8.149891507777399e+16, "+8E+16", "%+1.G", +__LINE__, 8.167395708830107e+03, "8167", "%3.f", +__LINE__, 8.167703619221975e+01, "81.677", "%G", +__LINE__, 8.178463030771759e+06, "+8.17846E+06", "%+G", +__LINE__, 8.188188531273697e+12, "8.18819E+12", "%G", +__LINE__, 8.189094866416537e+11, "+8E+11", "%+.1G", +__LINE__, 8.205086844365809e-18, "+8.205087E-18", "%+#E", +__LINE__, 8.205762333408320e-26, "0.000000", "%f", +__LINE__, 8.212370598174696e-10, "8.2124E-10", "%.5G", +__LINE__, 8.228054316085489e-14, "0.000000", "%3f", +__LINE__, 8.244313484402404e-16, "8.24431e-16", "%g", +__LINE__, 8.244472235472472e+19, "8.24447E+19", "%G", +__LINE__, 8.245421473302411e-09, "+8.2454e-09", "%+1.5g", +__LINE__, 8.252286626634840e-22, "8E-22", "%3.G", +__LINE__, 8.259969177912707e-19, "0.000000", "%f", +__LINE__, 8.265769991725211e+18, "8.26577e+18", "%.5e", +__LINE__, 8.293986939496488e+25, "8.3E+25", "%.1E", +__LINE__, 8.310348813512608e-23, "+8.31035e-23", "%+g", +__LINE__, 8.316951996533247e-20, "0.000000", "%f", +__LINE__, 8.318818016883803e+05, " 8e+05", "%6.1g", +__LINE__, 8.324896920131877e-13, "+8.324897e-13", "%+e", +__LINE__, 8.325228630004624e-03, "0.0083252", "%5.7f", +__LINE__, 8.332538660129034e+14, "8.3e+14", "%5.2g", +__LINE__, 8.343325212751775e+07, "8.34333e+07", "%#4g", +__LINE__, 8.363117398136236e+20, "+8.36e+20", "%+.3g", +__LINE__, 8.364181324448165e+27, "8.36418e+27", "%#g", +__LINE__, 8.372159259848738e+10, "8.37216e+10", "%4g", +__LINE__, 8.379252006152759e-26, "8.37925e-26", "%g", +__LINE__, 8.392670395720252e+09, "8392670395.720252", "%f", +__LINE__, 8.423360059147756e+05, "+842336.", "%+#G", +__LINE__, 8.425921213167943e+09, "8.425921e+09", "%1.7g", +__LINE__, 8.431664412515776e-16, "8.43166E-16", "%#G", +__LINE__, 8.448608859842500e+02, "844.861", "%1.3f", +__LINE__, 8.456292247478771e-14, "8.45629E-14", "%G", +__LINE__, 8.460077225296853e-04, "0.000846008", "%G", +__LINE__, 8.478635925746218e-10, "0.000000", "%f", +__LINE__, 8.492455774427448e+06, "8.49246e+06", "%g", +__LINE__, 8.494450528380746e-07, "8.494451e-07", "%e", +__LINE__, 8.516435842947605e-23, "+0.000000", "%+1f", +__LINE__, 8.519057789029134e-18, "0.000000", "%0f", +__LINE__, 8.522602111109066e+18, " 9.e+18", "%#7.g", +__LINE__, 8.529176788022152e-24, "8.529E-24", "%0.4G", +__LINE__, 8.534979605642793e-07, "0.000001", "%f", +__LINE__, 8.546859563634342e-07, "8.546860E-07", "%E", +__LINE__, 8.552370027054106e+12, "9e+12", "%.0g", +__LINE__, 8.561781328234041e+10, "8.56178e+10", "%4g", +__LINE__, 8.562688793145107e-20, "8.562689e-20", "%1.7g", +__LINE__, 8.573130147270046e-07, " 9E-07", "%7.G", +__LINE__, 8.584571984387802e-18, "8.5846e-18", "%.5g", +__LINE__, 8.596407996491291e+11, "8.596408E+11", "%#E", +__LINE__, 8.604843726850381e+10, " 9E+10", "%6.G", +__LINE__, 8.626884271938994e-23, "8.62688e-23", "%g", +__LINE__, 8.631140282429168e+24, "8631140282429168308908629.", "%#.0f", +__LINE__, 8.635194331917948e-16, "8.63519E-16", "%G", +__LINE__, 8.641417311588688e-24, "+0.000000", "%+f", +__LINE__, 8.649120264278466e+26, "8.65E+26", "%1.3G", +__LINE__, 8.649745523383894e+06, "8.649746e+06", "%e", +__LINE__, 8.654720740091021e+16, "8.65472e+16", "%g", +__LINE__, 8.655445556834509e-08, "9e-08", "%4.g", +__LINE__, 8.658954696751902e+06, "8.65895E+06", "%G", +__LINE__, 8.665712368800818e-10, "+8.66571E-10", "%+G", +__LINE__, 8.666937057116442e-10, "8.666937e-10", "%e", +__LINE__, 8.670981239765155e+05, "867098", "%G", +__LINE__, 8.679631934294932e-25, "+9.E-25", "%+#0.G", +__LINE__, 8.683595173050962e-21, "8.68360E-21", "%#G", +__LINE__, 8.684938704958039e+25, "8.684939E+25", "%E", +__LINE__, 8.686745463281227e-12, "8.686745E-12", "%5.7G", +__LINE__, 8.700227628706534e-12, "8.700228e-12", "%#e", +__LINE__, 8.705101179577200e+04, "87051.011796", "%#2f", +__LINE__, 8.707824829984700e-24, "9e-24", "%.1g", +__LINE__, 8.717654041009233e+21, "+9E+21", "%+6.0E", +__LINE__, 8.741736299906572e-11, "8.74174E-11", "%#0G", +__LINE__, 8.742228350419966e+18, "+8742228350419965821.060941", "%+f", +__LINE__, 8.743045146087558e-17, "+8.74305E-17", "%+2G", +__LINE__, 8.747820269457588e+18, "8.74782E+18", "%G", +__LINE__, 8.756274717008537e-28, "8.756275E-28", "%E", +__LINE__, 8.769782309254687e-24, "+8.769782E-24", "%+2.6E", +__LINE__, 8.788151659193398e-16, " 9E-16", "%6.E", +__LINE__, 8.789514812202340e-07, "9E-07", "%0.G", +__LINE__, 8.792657843164822e-07, "8.79266e-07", "%0g", +__LINE__, 8.810976223440985e+05, "881097.622344", "%f", +__LINE__, 8.822553973113614e+10, "8.82255E+10", "%G", +__LINE__, 8.839440421530611e-04, "0.000883944", "%G", +__LINE__, 8.842539073558434e-12, "0", "%1.f", +__LINE__, 8.882818021261782e-13, "+8.9e-13", "%+4.2g", +__LINE__, 8.899833909201039e+05, "8.8998E+05", "%.5G", +__LINE__, 8.903167498000181e-13, "9e-13", "%0.g", +__LINE__, 8.933727737932164e+09, "+8933727738", "%+4.f", +__LINE__, 8.946226267100711e+06, "8.946E+06", "%1.4G", +__LINE__, 8.953203780849794e-21, "8.9532E-21", "%G", +__LINE__, 8.959934262635649e+28, "+8.959934e+28", "%+e", +__LINE__, 8.969485341781558e-25, "0.000000", "%#f", +__LINE__, 8.970058187654221e+02, "897.005819", "%f", +__LINE__, 8.979846508565979e+02, "8.979847E+02", "%E", +__LINE__, 8.984561117901212e+01, "8.984561E+01", "%E", +__LINE__, 8.992157765875611e-12, "8.99216e-12", "%g", +__LINE__, 9.004487016708012e+01, "9.004487e+01", "%#e", +__LINE__, 9.007306978283218e-24, "9.007307e-24", "%e", +__LINE__, 9.014546375043562e+17, "901454637504356171.007203", "%#3f", +__LINE__, 9.028177786002161e-12, "9.02818E-12", "%G", +__LINE__, 9.029635986381795e-02, "0.09", "%.1g", +__LINE__, 9.032389962233431e-07, "+0.000001", "%+f", +__LINE__, 9.038466945070887e+10, "+9.038467E+10", "%+E", +__LINE__, 9.040166964322772e-27, "9.04017e-27", "%g", +__LINE__, 9.044627673694681e-11, "9.04463E-11", "%G", +__LINE__, 9.045906217628948e+17, "904590621762894819.823941", "%1f", +__LINE__, 9.051764975661710e+11, "9.05176e+11", "%#g", +__LINE__, 9.053142913711405e+29, "9.053143e+29", "%#e", +__LINE__, 9.073185209160657e-19, "+9.07319e-19", "%+g", +__LINE__, 9.074372574441451e+02, "907.437", "%g", +__LINE__, 9.084624602048136e+08, "9.084625E+08", "%E", +__LINE__, 9.088839346363631e+18, "9.09e+18", "%.2e", +__LINE__, 9.091945159170871e-15, "9.09195e-15", "%5g", +__LINE__, 9.115304318083716e+10, "9.115304e+10", "%e", +__LINE__, 9.115978352902710e+28, "9.11598E+28", "%G", +__LINE__, 9.121415008221017e-17, "9.E-17", "%#6.G", +__LINE__, 9.127270978060388e+18, "9.E+18", "%#5.G", +__LINE__, 9.143941729069086e+08, "9.143942E+08", "%#E", +__LINE__, 9.162740105978580e-19, " 9.E-19", "%#7.G", +__LINE__, 9.221509957559626e-18, "9.22151e-18", "%g", +__LINE__, 9.227419774250317e-28, " 0.", "%#3.f", +__LINE__, 9.230846660807540e-21, "0.000000", "%f", +__LINE__, 9.238091727277130e-06, "+0.00001", "%+.5f", +__LINE__, 9.244337357684406e+10, "9E+10", "%5.G", +__LINE__, 9.259179793993285e-19, " 9E-19", "%7.0G", +__LINE__, 9.274068541525759e-17, "9.274069e-17", "%e", +__LINE__, 9.283833535882367e+16, "9.28383e+16", "%#g", +__LINE__, 9.295693096364605e+11, "+9.295693E+11", "%+E", +__LINE__, 9.301820438602407e+05, "930182", "%G", +__LINE__, 9.322805251555376e-29, "9e-29", "%1.e", +__LINE__, 9.358443042421307e-27, "9.35844e-27", "%g", +__LINE__, 9.372658444745124e-23, "9.372658e-23", "%e", +__LINE__, 9.380302971355292e+05, "938030.3", "%.7g", +__LINE__, 9.381976354968076e-26, "+9.382E-26", "%+5.4G", +__LINE__, 9.391072061980585e-15, "9.391072E-15", "%E", +__LINE__, 9.403554117166546e-06, "0.000009", "%f", +__LINE__, 9.403712900426614e-28, "9.40371e-28", "%g", +__LINE__, 9.419046629820578e+03, "9419.046630", "%f", +__LINE__, 9.422344695378412e+22, "94223446953784115720509.362291", "%f", +__LINE__, 9.433327680467576e+01, "9.433328e+01", "%e", +__LINE__, 9.443975205260596e+20, "9.44398e+20", "%g", +__LINE__, 9.445134851965593e-04, "+9.445135E-04", "%+E", +__LINE__, 9.448403585149890e+24, "9e+24", "%0.g", +__LINE__, 9.463149430113036e+18, "9.46315e+18", "%g", +__LINE__, 9.465735160722534e+27, "+9465735160722534402566452627.070248", "%+f", +__LINE__, 9.495210794344892e-04, "0.000950", "%f", +__LINE__, 9.501916506373814e-25, "9.50192E-25", "%#G", +__LINE__, 9.514641335897739e+29, "9.51464E+29", "%G", +__LINE__, 9.524633436992819e-04, " 0.001", "%6.G", +__LINE__, 9.530925101873022e-18, "9.530925e-18", "%2e", +__LINE__, 9.557903833216979e-22, "9.557904E-22", "%E", +__LINE__, 9.587709102390903e-01, " 1", "%2.f", +__LINE__, 9.592723000828453e-02, "9.592723E-02", "%5E", +__LINE__, 9.603430008794172e+27, "9.60343e+27", "%g", +__LINE__, 9.622648414989433e-18, "9.622648e-18", "%1e", +__LINE__, 9.633326171289319e-23, "9.633326e-23", "%e", +__LINE__, 9.662064616152408e+19, "96620646161524081918.5146393", "%1.7f", +__LINE__, 9.668544846563163e-23, "9.668545e-23", "%e", +__LINE__, 9.691014191346685e+28, "9.69101E+28", "%G", +__LINE__, 9.693075414840598e+02, "+969.308", "%+G", +__LINE__, 9.695013453291907e-30, "9.695013e-30", "%5e", +__LINE__, 9.705983477801926e-24, "9.70598e-24", "%g", +__LINE__, 9.709022568030226e-17, "0.000000", "%f", +__LINE__, 9.715194901854826e+20, "9.715195e+20", "%e", +__LINE__, 9.721011821337717e+16, "1E+17", "%0.G", +__LINE__, 9.734895542899672e+14, "9.734896e+14", "%e", +__LINE__, 9.741486438769710e-29, " 1e-28", "%6.g", +__LINE__, 9.766657482315475e-24, "9.76666E-24", "%7G", +__LINE__, 9.767283293054552e-02, "0.09767", "%5.5f", +__LINE__, 9.769553159146005e-20, "9.76955E-20", "%G", +__LINE__, 9.777220880605434e-10, "0.00", "%4.2f", +__LINE__, 9.790290569034575e+20, "979029056903457473027.", "%#6.f", +__LINE__, 9.793128245822718e-01, "0.979313", "%G", +__LINE__, 9.804758536498200e+08, "980475853.650", "%.3f", +__LINE__, 9.816883664191066e-02, "0.1", "%.0g", +__LINE__, 9.836109821010300e+25, "9.83611e+25", "%g", +__LINE__, 9.846197559631225e+03, "1E+04", "%2.G", +__LINE__, 9.863289416819924e+12, "9.86329e+12", "%g", +__LINE__, 9.865893798657353e+12, "9.866e+12", "%0.4g", +__LINE__, 9.868248446640862e-15, "0.000000", "%#f", +__LINE__, 9.869973080775134e+04, "98699.7", "%G", +__LINE__, 9.899444006312953e+20, "1E+21", "%.1G", +__LINE__, 9.904083146074285e-08, "9.904083e-08", "%6e", +__LINE__, 9.909790408255471e+15, "9909790408255471.305665", "%f", +__LINE__, 9.930297455798394e-13, "+9.930297E-13", "%+5.6E", +__LINE__, 9.933314448709083e-15, "9.93331E-15", "%#.6G", +__LINE__, 9.938714530509870e+29, "9.938715e+29", "%e", +__LINE__, 9.953892603540162e+07, "9.95389E+07", "%G", +__LINE__, 9.962084643867200e+14, "+996208464386720.038419", "%+f", +__LINE__, 9.977706708809947e-09, "9.9777E-09", "%#.4E", +#endif +__LINE__, 9.978034352999867e+15, "9.978034e+15", "%2.6e", +__LINE__, 9.998315286730175e-30, "9.998315e-30", "%6e", + +0 +}; + +/* matches(s1, s2) is true if s1 is "approximately" equal to s2. + Any digits after the first required_precision digits do not have to match. + */ + +int required_precision = 13; + +#if defined(__STDC__) || defined(__cplusplus) +int matches(register char *result, register char *desired) +#else +int matches(result, desired) + register char *result; register char *desired; +#endif +{ + int digits_seen = 0; + for (;; result++, desired++) { + if (*result == *desired) { + if (*result == 0) + return 1; + else if (*result >= '0' && *result <= '9') + digits_seen++; + } + else if (digits_seen >= required_precision + && *result >= '0' && *result <= '9' + && *desired >= '0' && *desired <= '9') + continue; + else + return 0; + } +} + +extern void dump_stats(); + +int main() +{ + int errcount = 0; + int testcount = 0; + double d; +#define BSIZE 1024 + char buffer[BSIZE]; + sprint_double_type *dptr; + + /* This test demands more precision than a 32bit floating + point format can provide. So only run it if doubles + are last least 64bits wide. */ + if (sizeof (double) < 8) + exit (0); + +#if defined(__cplusplus) && !defined(TEST_LIBIO) + + strstream sstr(buffer, BSIZE, ios::in|ios::out); + + for (dptr = sprint_doubles; dptr->line; dptr++) + { + +#ifdef SLOW_SIMULATOR + /* We only run half the tests if we have a slow simulator to + avoid dejagnu timeouts. */ + if (testcount % 2) + { + testcount++; + continue; + } +#endif + + sstr.seekp(0); + sstr.form(dptr->format_string, dptr->value); + sstr << ends; + if (!matches(buffer, dptr->result)) + { + errcount++; + cerr << "Error in line " << dptr->line; + cerr << " using \"" << dptr->format_string; + cerr << "\". Result is \"" << buffer << "\"; should be: \""; + cerr << dptr->result << "\".\n"; + } + +#ifdef TEST_EXACTNESS + sstr.seekp(0); + sstr.form("%.999g", dptr->value); + sstr << ends; + + sstr.seekg(0); + sstr.scan("%lg", &d); + + if (dptr->value != d) + { + errcount++; + cerr << "Error in line " << dptr->line; + cerr << ". String is \"" << buffer << "\", value is " << d << ".\n"; + } +#endif + testcount++; + } + +#ifdef SLOW_SIMULATOR + testcount /= 2; +#endif + + if (errcount == 0) + { + cerr << "Encountered no errors in " << testcount << " tests.\n"; + return 0; + } + else + { + cerr << "Encountered " << errcount << " errors in " + << testcount << " tests.\n"; + return 1; + } +#else + for (dptr = sprint_doubles; dptr->line; dptr++) + { +#ifdef SLOW_SIMULATOR + /* We only run half the tests if we have a slow simulator to + avoid dejagnu timeouts. */ + if (testcount % 2) + { + testcount++; + continue; + } +#endif + + sprintf (buffer, dptr->format_string, dptr->value); + if (!matches(buffer, dptr->result)) + { + errcount++; + fprintf(stderr, + "Error in line %d using \"%s\". Result is \"%s\"; should be: \"%s\".\n", + dptr->line, dptr->format_string, buffer, dptr->result); + } + +#ifdef TEST_EXACTNESS + sprintf (buffer, "%.999g", dptr->value); + sscanf (buffer, "%lg", &d); + if (dptr->value != d) + { + errcount++; + fprintf (stderr, + "Error in line %d. String is \"%s\", value is %g.\n", + dptr->line, buffer, d); + } +#endif + testcount++; + } + +#ifdef SLOW_SIMULATOR + testcount /= 2; +#endif + + if (errcount == 0) + { + fprintf(stderr, "Encountered no errors in %d tests.\n", testcount); + return 0; + } + else + { + fprintf(stderr, "Encountered %d errors in %d tests.\n", + errcount, testcount); + return 1; + } +#endif +} diff --git a/libio/tests/tiformat.c b/libio/tests/tiformat.c new file mode 100644 index 000000000000..78d09cedc230 --- /dev/null +++ b/libio/tests/tiformat.c @@ -0,0 +1,5112 @@ +#ifdef TEST_LIBIO +#include +#else +#ifdef __cplusplus +#include +#else +#include +#endif +#endif /* !TEST_LIBIO */ +#include + +/* Tests taken from Cygnus C library. */ +typedef struct { + int line; + long value; + char *result; + char *format_string; +} sprint_int_type; + +sprint_int_type sprint_ints[] = +{ +__LINE__, 0x000838d2L, "838d2", "%.4x", +__LINE__, 0x0063be46L, "63BE46", "%-6X", +__LINE__, -0x1b236c0L, "-28456640", "%#0.d", +__LINE__, -0x0000003L, "-3", "% 0d", +__LINE__, 0x0000ed51L, "ed51", "%2.x", +__LINE__, -0x00001f2L, "-498", "%1ld", +__LINE__, 0x0ea3e927L, "EA3E927", "%+X", +__LINE__, 0xffbef8daL, "FFBEF8DA", "%5X", +__LINE__, 0x62ff9f56L, "62ff9f56", "%0x", +__LINE__, 0x00000ad2L, "AD2", "%.0X", +__LINE__, 0x00000000L, " ", "% 6.ld", +__LINE__, 0xffffffffL, "FFFFFFFF", "%1.4X", +__LINE__, 0x0000208cL, " 208C", "%5X", +__LINE__, 0x0000003cL, "3c", "%x", +__LINE__, 0xffff6177L, "0xffff6177", "%+#x", +__LINE__, 0xffffdc8dL, "ffffdc8d", "%+x", +__LINE__, 0x00000000L, "0", "%X", +__LINE__, 0x00002434L, "9268", "%0d", +__LINE__, 0xd2c72cdbL, "d2c72cdb", "%-x", +__LINE__, 0xfe38012bL, "0xfe38012b", "%+#7x", +__LINE__, 0x00000001L, "0001", "%#.4d", +__LINE__, -0x008525aL, "-0545370", "%06.7ld", +__LINE__, 0xffffffacL, "ffffffac", "%3.7x", +__LINE__, 0x007424d2L, "+7611602", "%+ld", +__LINE__, 0x00001a85L, "1A85", "%.4X", +__LINE__, -0x0000019L, "-25", "%3.d", +__LINE__, 0xfffffffeL, "fffffffe", "%-x", +__LINE__, -0x34473b2L, "-54817714", "% d", +__LINE__, 0x000000eaL, "234", "%1.ld", +__LINE__, -0x0000004L, "-4 ", "%-7.ld", +__LINE__, 0x00006c94L, "27796", "%0d", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, 0x00000619L, "619", "%1x", +__LINE__, 0x0000209cL, "8348", "%ld", +__LINE__, -0x327f8ffL, "-52951295", "%-0ld", +__LINE__, 0xffffff0bL, "FFFFFF0B", "%2.X", +__LINE__, 0xf199d6aeL, "F199D6AE", "%X", +__LINE__, 0x3ca5602eL, "1017471022", "%-1.ld", +__LINE__, -0xfb2080bL, "-263325707", "%3.5d", +__LINE__, 0x00001cb8L, "7352", "%d", +__LINE__, 0x00000000L, "0000000", "%3.7d", +__LINE__, 0xffffff40L, "FFFFFF40", "%+X", +__LINE__, 0x14664450L, "0x14664450", "%#x", +__LINE__, 0x0000002eL, "2e", "%1x", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, 0xffff606aL, "0XFFFF606A", "%#X", +__LINE__, 0xffffff33L, "0XFFFFFF33", "%#X", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, -0x0000012L, "-00018", "%-2.5d", +__LINE__, 0x0001fbe6L, "130022", "%1.d", +__LINE__, 0xfff59dd9L, "fff59dd9", "%+x", +__LINE__, 0x00000002L, "2", "%0.0d", +__LINE__, 0x00000fe1L, "fe1 ", "%-7.x", +__LINE__, 0x001f8f6aL, "1F8F6A", "%1.X", +__LINE__, 0x0000001bL, "000001B", "%04.7X", +__LINE__, 0x126a2609L, " 308946441", "% 4d", +__LINE__, 0xffffffe3L, "0XFFFFFFE3", "%+#.1X", +__LINE__, 0x1858f1c9L, "1858f1c9", "%.3x", +__LINE__, 0x003fc672L, "3fc672", "%1x", +__LINE__, 0x00c0bddcL, "12631516", "%#d", +__LINE__, 0x000006d6L, "1750", "%#d", +__LINE__, 0x000006a0L, "6A0", "%X", +__LINE__, 0x000007beL, "7BE", "%X", +__LINE__, -0x1c7cd1aL, "-29871386", "%ld", +__LINE__, 0x000000ccL, "204", "%ld", +__LINE__, 0x000002dbL, "731 ", "%-#5d", +__LINE__, 0xffff67adL, "FFFF67AD", "% X", +__LINE__, 0x00000008L, "8", "%d", +__LINE__, 0xffe07007L, "FFE07007", "%5X", +__LINE__, -0x0000001L, " -1", "% 7d", +__LINE__, 0xfffffffeL, "fffffffe", "%x", +__LINE__, 0x00027b68L, "+162664", "%+ld", +__LINE__, 0x0a7c1997L, "+175905175", "%+2ld", +__LINE__, 0xfe300896L, "fe300896", "%.4x", +__LINE__, 0x00000537L, "537", "%-0.x", +__LINE__, 0x3e981779L, "3e981779", "%.6x", +__LINE__, 0xfffff05eL, "FFFFF05E", "%1.0X", +__LINE__, -0x07bc0cfL, "-8110287", "%-7d", +__LINE__, -0x01371bcL, "-1274300", "%.7ld", +__LINE__, -0x0000013L, "-19", "%.2ld", +__LINE__, 0x000000d1L, "0xd1", "%#x", +__LINE__, -0x0000003L, "-3", "%-ld", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%4.1X", +__LINE__, 0x00000000L, "0", "%ld", +__LINE__, 0x0001c8afL, "116911", "%d", +__LINE__, 0x000048c3L, "48C3", "%X", +__LINE__, 0x00000079L, "0x0000079", "%-#0.7x", +__LINE__, 0x0000615aL, " 24922", "% d", +__LINE__, 0xfffffff5L, "fffffff5", "%x", +__LINE__, 0x00000308L, "0000308", "%+07.7x", +__LINE__, 0xfcadc983L, "fcadc983", "%x", +__LINE__, 0x00000097L, "151", "%#d", +__LINE__, 0x000001c5L, "453", "%0.2ld", +__LINE__, 0x00000000L, "00", "%-1.2x", +__LINE__, 0x00000001L, "+1", "%+02.d", +__LINE__, 0x01eb4354L, "1EB4354", "% X", +__LINE__, 0xffffa7d1L, "ffffa7d1", "%5.x", +__LINE__, 0x0003170eL, "0x3170e", "%#x", +__LINE__, 0x000001ceL, "1CE", "% .2X", +__LINE__, 0x3a2991fbL, "975802875", "%d", +__LINE__, -0xcdad8e2L, "-215668962", "%-d", +__LINE__, 0xfe0261c3L, "fe0261c3", "%x", +__LINE__, -0x0006ea7L, "-28327", "% ld", +__LINE__, 0x032854a3L, "0X32854A3", "% #6X", +__LINE__, 0x0000004bL, "4b", "%x", +__LINE__, 0xffff6ca3L, "FFFF6CA3", "%4.X", +__LINE__, 0x00000000L, "0", "%X", +__LINE__, 0x00611f04L, "611F04", "%.1X", +__LINE__, 0x00000000L, " 0", "%#6d", +__LINE__, 0x0002c711L, "2c711", "%-02.x", +__LINE__, -0x07a2fe4L, "-8007652", "%d", +__LINE__, -0x0000547L, "-1351", "%ld", +__LINE__, 0x00013954L, "0x13954", "%#x", +__LINE__, -0x00523b7L, "-336823", "%ld", +__LINE__, -0x00f6c6eL, "-1010798", "%6.ld", +__LINE__, 0xffea6427L, "FFEA6427", "%3X", +__LINE__, -0x0000005L, "-5", "%d", +__LINE__, -0x04fe618L, "-5236248", "% .7d", +__LINE__, 0xffa80a28L, "ffa80a28", "%-0x", +__LINE__, 0x00000047L, "71", "%ld", +__LINE__, 0x001dc6bbL, "1951419", "%#4ld", +__LINE__, 0x00000868L, " 2152", "%#6d", +__LINE__, 0x000002fbL, "2fb", "%x", +__LINE__, 0x00607fa0L, "6324128", "%4d", +__LINE__, 0xfffed161L, "fffed161", "%x", +__LINE__, 0x0001c6e4L, " 116452", "% 2.5d", +__LINE__, 0x0003dda8L, "3DDA8", "%4X", +__LINE__, 0xfffffff8L, "fffffff8", "%x", +__LINE__, 0xfacf664aL, "facf664a", "%x", +__LINE__, 0x000000c1L, "C1", "% 1X", +__LINE__, 0x0000839cL, " 839C", "%6X", +__LINE__, 0xfffff69aL, "FFFFF69A", "%X", +__LINE__, 0x000e5c2eL, "+941102", "%+d", +__LINE__, -0x0000004L, "-4", "%#d", +__LINE__, 0x00000000L, "00000", "%#.5ld", +__LINE__, 0xfffffffeL, "fffffffe", "%3.1x", +__LINE__, 0x0010ed68L, "1109352", "%-ld", +__LINE__, 0xffffffe9L, "ffffffe9", "%.6x", +__LINE__, 0x00000007L, " 7", "% 4.ld", +__LINE__, 0x0000cabaL, "51898", "%ld", +__LINE__, -0x0000119L, "-281", "% d", +__LINE__, 0x0c3012a9L, "204477097", "%03.6ld", +__LINE__, -0x001c98fL, "-117135", "%ld", +__LINE__, 0x000017b1L, "+6065", "%+d", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, -0x0000019L, "-25", "% .2d", +__LINE__, 0x0009ae28L, "9AE28", "%X", +__LINE__, 0xe861c4feL, "e861c4fe", "%7.x", +__LINE__, 0xffac88d3L, "FFAC88D3", "%X", +__LINE__, -0x00005dfL, "-01503", "%-5.5ld", +__LINE__, 0x0000013eL, "318", "%-0d", +__LINE__, 0x04b6f58fL, "4b6f58f", "%x", +__LINE__, 0xfffe3978L, "fffe3978", "%+0.6x", +__LINE__, 0x57ee5244L, "57ee5244", "%+7.4x", +__LINE__, 0xfffb5610L, "fffb5610", "% 6x", +__LINE__, 0x00000006L, " 6", "%#7d", +__LINE__, 0x0000000cL, "0x0000c", "%#.5x", +__LINE__, -0xec59362L, "-247829346", "%1.7d", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, -0x0007e4bL, "-32331", "% d", +__LINE__, 0x0ececa6fL, "248433263", "%0d", +__LINE__, 0x00000578L, " 578", "%+6.x", +__LINE__, -0x0000003L, "-3", "%ld", +__LINE__, 0x000002bbL, "2bb", "% 0x", +__LINE__, -0x0000006L, "-6", "%-ld", +__LINE__, 0x000002f9L, "761", "%d", +__LINE__, 0xffffd736L, "ffffd736", "%3.4x", +__LINE__, 0x0010ba79L, "1096313", "%7.4d", +__LINE__, -0x0001244L, "-4676", "%#.1d", +__LINE__, 0x00000dbeL, "DBE", "%1X", +__LINE__, -0x0000015L, "-21", "%-0.d", +__LINE__, 0xffffffffL, "0xffffffff", "%#x", +__LINE__, -0x6cdf4a3L, "-114160803", "%ld", +__LINE__, 0x00008ac9L, "8AC9", "%1X", +__LINE__, 0x00000000L, "00", "%.2X", +__LINE__, -0x2263dbaL, "-36060602", "%5.5d", +__LINE__, 0x00007da9L, "32169", "%0d", +__LINE__, 0xfffffff7L, "FFFFFFF7", "% 4.X", +__LINE__, 0xfbf36ccaL, "FBF36CCA", "%.1X", +__LINE__, 0x00000040L, "64", "%.0ld", +__LINE__, 0x0000001cL, " 28", "% d", +__LINE__, 0xfffffadbL, "0xfffffadb", "%#.5x", +__LINE__, 0x0eb95847L, "247027783", "%d", +__LINE__, 0xfffd7030L, "FFFD7030", "%+02X", +__LINE__, 0x00000005L, "00005", "%.5x", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%X", +__LINE__, 0x98975b15L, "98975B15", "%02X", +__LINE__, -0x0000034L, " -52", "%6ld", +__LINE__, 0xffd7d0ccL, "ffd7d0cc", "% 5.6x", +__LINE__, 0xffffffa6L, "FFFFFFA6", "%X", +__LINE__, 0xfff27132L, "fff27132", "%x", +__LINE__, -0x065b74dL, "-6666061", "%+6ld", +__LINE__, 0xf6ac99d6L, "0XF6AC99D6", "%#X", +__LINE__, 0xfffff4bdL, "FFFFF4BD", "%X", +__LINE__, 0xfffffb62L, "FFFFFB62", "%6X", +__LINE__, 0xf8434543L, "f8434543", "%-0x", +__LINE__, 0x0002b374L, "0x2b374", "%-#6x", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xffb5751dL, "ffb5751d", "%-3.x", +__LINE__, 0x34ea7347L, "887780167", "%d", +__LINE__, -0x008f457L, "-586839", "%0ld", +__LINE__, 0x00000001L, " 1", "%#4d", +__LINE__, 0xc32d7ad4L, "c32d7ad4", "%0x", +__LINE__, 0xfffffb80L, "FFFFFB80", "%-.2X", +__LINE__, 0x00000756L, "756 ", "%-6x", +__LINE__, 0xfffb020fL, "FFFB020F", "%+.2X", +__LINE__, -0xe68619fL, "-241721759", "%#1.6ld", +__LINE__, 0x180166cdL, "402745037", "%3.7ld", +__LINE__, -0x0000001L, "-1", "%+00d", +__LINE__, 0xfdbc3611L, "fdbc3611", "%x", +__LINE__, -0x000005bL, "-91", "%d", +__LINE__, 0xffffe77fL, "ffffe77f", "%x", +__LINE__, -0x0000019L, "-25", "%ld", +__LINE__, 0x00000016L, "22", "%#d", +__LINE__, -0x0000025L, "-37", "%ld", +__LINE__, 0xffffe43fL, "ffffe43f", "%x", +__LINE__, 0x000050a5L, "00050a5", "%.7x", +__LINE__, 0x0000000cL, " 12", "% 5.ld", +__LINE__, -0x001faffL, "-129791", "%4d", +__LINE__, 0x239d7cf2L, "597523698", "%0.7ld", +__LINE__, 0x04092183L, "4092183", "% 7X", +__LINE__, -0x0043498L, "-275608", "%-ld", +__LINE__, -0x0018dbeL, "-101822", "%d", +__LINE__, 0xff3e09c3L, "FF3E09C3", "%X", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, -0x15d57558L, "-366310744", "%+0.7ld", +__LINE__, 0x0004fb06L, "326406", "%0.0d", +__LINE__, 0x00000119L, "0X119", "%#X", +__LINE__, -0x14c53e19L, "-348470809", "%d", +__LINE__, 0x00000019L, "0000019", "% .7X", +__LINE__, -0x0000654L, "-1620", "%0.4ld", +__LINE__, -0xde5899bL, "-233146779", "%#.1d", +__LINE__, 0x0013c1f0L, "1294832", "%4.ld", +__LINE__, 0x0a9fe761L, "A9FE761", "%X", +__LINE__, -0x00000e5L, "-229", "%1ld", +__LINE__, 0x00000161L, "000353", "%.6ld", +__LINE__, 0x6b04e4bdL, "0x6b04e4bd", "%#7.0x", +__LINE__, -0x0000ef0L, "-3824 ", "%-6.ld", +__LINE__, -0x026306eL, "-2502766", "%ld", +__LINE__, 0x00000000L, "0", "%-X", +__LINE__, 0xfffffe1fL, "fffffe1f", "%-x", +__LINE__, 0x0003aecfL, " 241359", "% 2.1ld", +__LINE__, -0x0000014L, "-20", "%d", +__LINE__, 0x00000002L, "0002", "%-.4ld", +__LINE__, 0xfffff662L, "0XFFFFF662", "% #.6X", +__LINE__, 0x00000006L, "6", "%0x", +__LINE__, 0x0001f4c4L, " 128196", "% 0d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%5X", +__LINE__, 0x05605e38L, "90201656", "%ld", +__LINE__, 0xffffffdeL, "0XFFFFFFDE", "% #X", +__LINE__, 0x000001e0L, " 1e0", "%7.x", +__LINE__, 0x00000007L, "7", "%X", +__LINE__, 0x00000001L, "+1", "%+d", +__LINE__, 0xffffffe0L, "FFFFFFE0", "% X", +__LINE__, 0xffd7f77aL, "FFD7F77A", "%+00.1X", +__LINE__, 0xfffffffeL, "0xfffffffe", "%-#x", +__LINE__, 0x01b0a63bL, "1b0a63b", "%x", +__LINE__, -0x06554b7L, "-6640823", "%d", +__LINE__, 0xfffffff8L, "fffffff8", "%x", +__LINE__, 0x00000b2dL, "b2d", "%x", +__LINE__, -0x2664ba2L, "-40258466", "%-d", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%X", +__LINE__, -0x0000552L, " -1362", "%6.2ld", +__LINE__, 0x00000009L, " 00009", "%6.5x", +__LINE__, 0x00035c72L, "220274", "%05.ld", +__LINE__, -0x014d09dL, "-1364125", "%d", +__LINE__, -0x0000002L, " -2", "% 4d", +__LINE__, 0x00000001L, "1", "%+X", +__LINE__, 0x00000028L, "28", "%X", +__LINE__, 0xf25c9eb2L, "F25C9EB2", "%7.X", +__LINE__, -0x7ae4b62L, "-128863074", "%d", +__LINE__, 0x00630d87L, "630D87", "%2X", +__LINE__, 0x000000f8L, "F8", "%-X", +__LINE__, 0xfffffff9L, "FFFFFFF9", "%X", +__LINE__, -0x0000007L, "-7", "%0d", +__LINE__, -0x2518fcdL, "-38899661", "% 3ld", +__LINE__, 0xfffff4b4L, "FFFFF4B4", "%-5X", +__LINE__, 0x01cc36c8L, "30160584", "%ld", +__LINE__, 0xffffffffL, "ffffffff", "%-x", +__LINE__, 0x0000000bL, " 11", "%6.ld", +__LINE__, 0x00010d55L, " 68949", "% d", +__LINE__, -0x0c01306L, "-12587782", "% 6.1ld", +__LINE__, 0x001719d7L, "1513943", "%.1ld", +__LINE__, -0x0000002L, " -2", "%+3.ld", +__LINE__, 0x0000018eL, "398", "%d", +__LINE__, 0x000000a6L, "0xa6", "%-#3x", +__LINE__, 0x00006f66L, " 28518", "% #d", +__LINE__, 0x0000032aL, "32A", "%X", +__LINE__, -0x0000145L, "-325", "%0d", +__LINE__, 0xffffffffL, "ffffffff", "%2.x", +__LINE__, 0x00287171L, "2650481", "%ld", +__LINE__, 0x0000004bL, "+75", "%+02.ld", +__LINE__, 0xfffffff8L, "fffffff8", "%-0x", +__LINE__, 0x00000064L, "64", "% X", +__LINE__, 0xfffffca2L, "fffffca2", "%0x", +__LINE__, 0x000010b6L, "10b6", "% .0x", +__LINE__, -0x003806fL, "-229487", "%7d", +__LINE__, -0x00000b7L, "-183", "%3ld", +__LINE__, 0xffffe5baL, "FFFFE5BA", "%0X", +__LINE__, 0x001f0da8L, "1f0da8", "%+x", +__LINE__, 0x000ce185L, "844165", "%0ld", +__LINE__, 0x00000c96L, "3222", "%0d", +__LINE__, -0x0013099L, "-77977", "%1.ld", +__LINE__, -0x5f3c47aL, "-99861626", "%.6ld", +__LINE__, 0x00000cbfL, " CBF", "%+5.X", +__LINE__, -0x0000001L, "-1", "%+ld", +__LINE__, 0x0d793bc3L, "d793bc3", "%6.x", +__LINE__, 0xfffffffdL, "0xfffffffd", "%+#x", +__LINE__, -0x0000070L, " -112", "%6.d", +__LINE__, 0xfffffb3fL, "FFFFFB3F", "%.7X", +__LINE__, 0x037dfc78L, "0X37DFC78", "%#X", +__LINE__, 0x00009ba5L, "39845", "%3ld", +__LINE__, 0x0000004aL, "4a", "%0x", +__LINE__, 0xffffff81L, "ffffff81", "%5.5x", +__LINE__, -0x86ef222L, "-141488674", "%ld", +__LINE__, -0xac5531eL, "-180704030", "% 4ld", +__LINE__, 0x00002493L, "2493", "%+X", +__LINE__, 0xffffffffL, "FFFFFFFF", "%1.3X", +__LINE__, 0x0005c875L, "378997", "%.0ld", +__LINE__, 0x0301d345L, "50451269", "%d", +__LINE__, 0xfff6b589L, "fff6b589", "%2.4x", +__LINE__, -0x00001dbL, "-475 ", "%-7.0d", +__LINE__, 0x0000d1e7L, "0x000d1e7", "%#2.7x", +__LINE__, 0xf4c4d2bbL, "f4c4d2bb", "%.6x", +__LINE__, 0x00c89f54L, "13147988", "%ld", +__LINE__, -0x6599253cL, "-1704535356", "%+ld", +__LINE__, 0xab7d61eaL, "ab7d61ea", "% x", +__LINE__, 0x00000006L, "6", "%1ld", +__LINE__, 0xffff5ab7L, "ffff5ab7", "%0x", +__LINE__, -0x1cfeca5bL, "-486459995", "%#ld", +__LINE__, 0x000000f3L, " f3", "% 6.x", +__LINE__, -0x0000021L, "-33", "%d", +__LINE__, 0xfe7246acL, "fe7246ac", "%-5.x", +__LINE__, 0x00000017L, "00017", "%-.5X", +__LINE__, -0x0cc250aL, "-13378826", "%0.0d", +__LINE__, -0x00010aeL, "-04270", "%#.5ld", +__LINE__, -0x7952c8bL, "-127216779", "% ld", +__LINE__, 0x0002a53eL, "173374", "%4.0d", +__LINE__, 0x03801bbfL, "3801BBF", "%0X", +__LINE__, 0x0368645fL, "+57173087", "%+#0.6ld", +__LINE__, 0x0000002fL, "47", "%d", +__LINE__, 0x00000003L, "3", "%x", +__LINE__, 0x000005f7L, "5F7", "%0X", +__LINE__, -0x06e5e76L, "-7233142", "% 0.1ld", +__LINE__, 0x053da936L, "53da936", "%1.4x", +__LINE__, -0x0df0c2fL, "-14617647", "%.5ld", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%-0X", +__LINE__, 0x000104bfL, "104BF", "%X", +__LINE__, 0x000353fcL, "353FC", "%X", +__LINE__, 0x182a18dcL, "+405412060", "%+ld", +__LINE__, 0x0000000eL, " 14", "% 2d", +__LINE__, -0x0000091L, "-145", "%+ld", +__LINE__, 0x0029a9d6L, "2730454", "%d", +__LINE__, 0x00009d57L, "009d57", "% .6x", +__LINE__, 0x4c4d4f79L, "1280135033", "%5.ld", +__LINE__, -0x000075bL, "-1883", "% 03d", +__LINE__, -0x001b718L, "-112408", "%+d", +__LINE__, 0xfffaaf57L, "FFFAAF57", "%+1X", +__LINE__, 0x00f44e52L, "F44E52", "% 4X", +__LINE__, 0x00000002L, "0X2", "%#X", +__LINE__, 0x000a85e9L, "A85E9", "%+0X", +__LINE__, 0xffff70bbL, "ffff70bb", "%6x", +__LINE__, 0x00004e15L, "4e15", "%x", +__LINE__, 0x000eeb60L, " 977760", "% ld", +__LINE__, 0xfffffff1L, "fffffff1", "%0x", +__LINE__, -0x294d7e2L, "-43309026", "% 02.d", +__LINE__, 0x0001aaebL, "0109291", "%02.7ld", +__LINE__, 0x000a01fcL, "0xa01fc", "%-#.5x", +__LINE__, 0x002c3c30L, "+2898992", "%+#d", +__LINE__, 0x015667aeL, "+22439854", "%+5ld", +__LINE__, -0x05af42bL, "-5960747", "%+d", +__LINE__, 0x0000be36L, "be36", "%+2x", +__LINE__, 0x005e3f67L, "5e3f67", "% x", +__LINE__, -0x0000020L, "-32", "% ld", +__LINE__, -0x0003617L, "-13847", "% d", +__LINE__, 0x00000014L, "14 ", "%-4.X", +__LINE__, 0x00000001L, "001", "%0.3d", +__LINE__, 0xfffffea9L, "fffffea9", "%3.x", +__LINE__, 0xe447099eL, "E447099E", "%0X", +__LINE__, 0x00049c71L, "302193", "%d", +__LINE__, 0x76356ed3L, "0x76356ed3", "%#4.1x", +__LINE__, 0x00000005L, " 0X5", "%#5X", +__LINE__, 0x00004da2L, "0x004da2", "%#1.6x", +__LINE__, 0xffdfb36cL, "FFDFB36C", "%4X", +__LINE__, 0xffffe3c5L, "FFFFE3C5", "%+4.X", +__LINE__, 0x00000006L, "6", "%0x", +__LINE__, -0x914ff17L, "-152370967", "% .5ld", +__LINE__, -0x0000002L, "-2", "%0ld", +__LINE__, 0xffffff36L, "FFFFFF36", "% 2X", +__LINE__, -0x0bb1598L, "-12260760", "%-ld", +__LINE__, 0x00006db5L, "28085", "%0.5ld", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, -0x0000001L, "-1", "%0ld", +__LINE__, 0x0fa37e79L, "FA37E79", "%1.X", +__LINE__, -0x00000acL, "-172", "%.2d", +__LINE__, 0xffffffd8L, "ffffffd8", "%.7x", +__LINE__, -0x000a513L, "-42259", "%ld", +__LINE__, 0x00001294L, "4756", "%2ld", +__LINE__, -0x56bae0b4L, "-1455087796", "%.1ld", +__LINE__, 0x3b26d5faL, "3b26d5fa", "%x", +__LINE__, 0xff657013L, "ff657013", "%x", +__LINE__, -0x00005f5L, "-1525", "%0.0ld", +__LINE__, -0x0000001L, " -1", "% 7d", +__LINE__, -0x02396b2L, "-2332338", "%d", +__LINE__, -0x0000003L, "-000003", "%+7.6d", +__LINE__, 0xfd3ec7c1L, "fd3ec7c1", "% 3.4x", +__LINE__, -0x076e338L, "-7791416", "%0.d", +__LINE__, -0x000015eL, "-350", "%3ld", +__LINE__, 0x0a0f0b71L, "a0f0b71", "%x", +__LINE__, 0xfffe00baL, "FFFE00BA", "%X", +__LINE__, 0x00036bd8L, " 36bd8", "% 06.x", +__LINE__, 0xfffff2dfL, "0XFFFFF2DF", "%#2.6X", +__LINE__, 0x004687fbL, "4622331", "%ld", +__LINE__, -0x0000331L, " -817", "%+6.d", +__LINE__, 0xfcd5b090L, "fcd5b090", "%+0x", +__LINE__, 0x0334f94cL, "334F94C", "%.6X", +__LINE__, 0x00000bceL, "3022", "%.3ld", +__LINE__, 0xf28d9dddL, "f28d9ddd", "%x", +__LINE__, 0x00003a79L, " 14969", "% ld", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%.7X", +__LINE__, 0x0043d7feL, "43D7FE", "%X", +__LINE__, -0x0000b82L, "-2946", "%-ld", +__LINE__, -0x00e29d8L, "-928216", "%d", +__LINE__, 0xffffffecL, "ffffffec", "%-x", +__LINE__, 0x0aeaf557L, "0xaeaf557", "%-#x", +__LINE__, 0x00c07fe6L, "C07FE6", "%X", +__LINE__, 0x307414d8L, "307414d8", "% 0x", +__LINE__, -0x045ef67L, "-4583271", "%d", +__LINE__, 0x0000024aL, " 0000586", "% .7d", +__LINE__, 0xfffffc42L, "fffffc42", "%x", +__LINE__, 0xfc38c249L, "fc38c249", "%5.x", +__LINE__, -0x000d096L, "-53398", "%-d", +__LINE__, -0x213a345L, "-34841413", "%ld", +__LINE__, -0x0000130L, "-304", "%ld", +__LINE__, -0x000efd1L, "-61393", "%ld", +__LINE__, 0xfffff867L, "FFFFF867", "%2X", +__LINE__, 0x00113ed0L, "0x113ed0", "%-#7x", +__LINE__, 0x00000677L, " 1655", "% 3.ld", +__LINE__, 0x0000002fL, "2f", "%x", +__LINE__, 0xfffffd38L, "fffffd38", "%-4x", +__LINE__, -0x000b3ccL, "-46028", "%1.2d", +__LINE__, 0x45da719bL, "45DA719B", "%+0X", +__LINE__, -0x000a454L, " -42068", "%7.3ld", +__LINE__, 0x01cc7c30L, " 30178352", "% d", +__LINE__, -0x05ae80eL, "-5957646", "%#.4ld", +__LINE__, 0x000000b9L, "185", "%d", +__LINE__, 0x003fcaf4L, "4180724", "%1.ld", +__LINE__, 0x02da1b74L, "2DA1B74", "%X", +__LINE__, 0xffffffd9L, "FFFFFFD9", "%X", +__LINE__, 0x00064359L, "64359 ", "%-6X", +__LINE__, 0x000000f0L, "240", "%ld", +__LINE__, -0x01715e5L, "-1512933", "%ld", +__LINE__, 0xc8f6e118L, "0XC8F6E118", "%#X", +__LINE__, 0xfffffd8fL, "FFFFFD8F", "%X", +__LINE__, 0x0000176dL, "5997 ", "%-6d", +__LINE__, 0x00003cabL, "0x3cab", "%#0.3x", +__LINE__, 0x00000001L, " 1", "% d", +__LINE__, 0xfffff610L, "0XFFFFF610", "%#X", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%5.7X", +__LINE__, 0x00000001L, "1", "%0x", +__LINE__, 0x00000001L, "00001", "%.5ld", +__LINE__, -0x0000d51L, "-3409", "%d", +__LINE__, -0x08639eeL, "-8796654", "%ld", +__LINE__, 0x00003121L, "12577", "%#1.2ld", +__LINE__, 0x0000004eL, "78", "%d", +__LINE__, 0xfffff64fL, "fffff64f", "%-x", +__LINE__, 0x0000002aL, "2a", "%0x", +__LINE__, 0x00000020L, "20", "%x", +__LINE__, -0x00000b8L, "-184", "%#ld", +__LINE__, 0x0000000aL, "10", "%-#d", +__LINE__, 0x00000364L, "868", "%.1ld", +__LINE__, 0x00d1f9b6L, "D1F9B6", "%0.X", +__LINE__, 0x008cfda1L, "8CFDA1", "% 6.X", +__LINE__, 0xffd58cceL, "FFD58CCE", "%X", +__LINE__, 0x00000008L, "0000008", "%6.7ld", +__LINE__, 0x00000318L, " 318", "%4X", +__LINE__, 0x000172d8L, "94936", "%2ld", +__LINE__, -0x056ccbfL, "-5688511", "%ld", +__LINE__, 0x000000c7L, "+000199", "%+0.6d", +__LINE__, 0x00000002L, "0X2", "%-#X", +__LINE__, 0xfffff634L, "FFFFF634", "%.1X", +__LINE__, -0x00001f3L, "-499", "%-ld", +__LINE__, -0x000081bL, "-2075", "%-d", +__LINE__, 0x000000b5L, "181", "%0d", +__LINE__, 0xfe961ee8L, "fe961ee8", "%0x", +__LINE__, 0x000028a2L, "10402", "%d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%.4X", +__LINE__, -0x000058aL, "-1418", "%.3ld", +__LINE__, 0x00001cebL, "1CEB", "%X", +__LINE__, 0x00000021L, "21", "% X", +__LINE__, 0x00000002L, "2", "%0d", +__LINE__, -0x2f9bbf5L, "-49921013", "%.4ld", +__LINE__, 0x00000e91L, "03729", "%#.5ld", +__LINE__, 0xf1116740L, "f1116740", "%2x", +__LINE__, 0x00014f72L, "14F72", "%X", +__LINE__, 0xfffffcedL, "FFFFFCED", "%X", +__LINE__, 0xffffffffL, "ffffffff", "%.5x", +__LINE__, 0x0017cf0cL, " 1560332", "% 0ld", +__LINE__, 0x0000000aL, "A", "% X", +__LINE__, 0xff3a39d4L, "ff3a39d4", "%x", +__LINE__, 0xfffef05fL, "FFFEF05F", "%X", +__LINE__, 0xfedfe708L, "fedfe708", "%03.0x", +__LINE__, 0x000345a0L, "345A0", "% X", +__LINE__, -0x1ed5b6f7L, "-517322487", "%d", +__LINE__, 0xd2d56c22L, "D2D56C22", "%0.X", +__LINE__, 0x00002cbfL, "2CBF", "%.2X", +__LINE__, 0x00000db4L, "db4", "%3x", +__LINE__, -0x000b154L, "-45396", "%d", +__LINE__, 0x002bf4c7L, "2BF4C7", "%X", +__LINE__, 0x6954abf4L, "+1767156724", "%+d", +__LINE__, 0xfffffffbL, "fffffffb", "%x", +__LINE__, -0x29e0050eL, "-702547214", "%-0ld", +__LINE__, -0x0014989L, "-84361", "%-#0.3ld", +__LINE__, 0x001a557cL, "+1725820", "%+6.5d", +__LINE__, -0x56689a81L, "-1449695873", "%.2d", +__LINE__, 0x00000016L, " 16", "%05.X", +__LINE__, 0x0001da1eL, " 121374", "% d", +__LINE__, -0x04deac7L, "-5106375", "%03.4d", +__LINE__, 0x000012b1L, "4785", "%d", +__LINE__, 0x0009a116L, "9a116", "%-x", +__LINE__, -0x0000003L, "-000003", "%4.6ld", +__LINE__, 0x00000000L, "", "%.0x", +__LINE__, 0x0000000aL, " A", "% 3X", +__LINE__, 0xfffffff0L, "0xfffffff0", "%-#0.1x", +__LINE__, 0x00000086L, "86", "%0X", +__LINE__, 0x0000001fL, "31", "%-d", +__LINE__, 0x0386f706L, "59176710", "%3.6ld", +__LINE__, 0xffe437aeL, "0XFFE437AE", "%#X", +__LINE__, 0x0e5405c6L, "e5405c6", "%-x", +__LINE__, 0xfffdee46L, "FFFDEE46", "%+X", +__LINE__, 0xff861e9dL, "FF861E9D", "%5.X", +__LINE__, 0xfffff570L, "FFFFF570", "%-X", +__LINE__, 0x045c90bdL, "45c90bd", "%0x", +__LINE__, 0x000000aaL, "AA", "%+X", +__LINE__, -0x747262eL, "-122103342", "%0ld", +__LINE__, 0xffffad89L, "FFFFAD89", "%X", +__LINE__, 0x00000018L, "18", "%0.2X", +__LINE__, 0x00057a2dL, " 358957", "% #7.d", +__LINE__, 0x73a0e21dL, "1939923485", "%ld", +__LINE__, -0x00021e1L, "-8673", "%0d", +__LINE__, 0x000000e9L, " 233", "% 06.3ld", +__LINE__, 0xffffcc0dL, "ffffcc0d", "%x", +__LINE__, 0x00000052L, "52", "%x", +__LINE__, 0x01c155afL, "1C155AF", "%.5X", +__LINE__, 0xffffffffL, "ffffffff", "%0.x", +__LINE__, -0x00400a4L, "-262308", "%-d", +__LINE__, -0x0000001L, "-0000001", "%#.7ld", +__LINE__, 0x01fb9c99L, "1fb9c99", "% 03.5x", +__LINE__, 0xffffffffL, "ffffffff", "%6.x", +__LINE__, 0xff5e5eeaL, "FF5E5EEA", "%X", +__LINE__, 0x0000000fL, "F", "%+0X", +__LINE__, 0xfffffe3aL, "fffffe3a", "% x", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%-X", +__LINE__, -0x0000007L, "-7", "%0ld", +__LINE__, -0x002f635L, "-194101", "%d", +__LINE__, -0x0000005L, "-5", "%ld", +__LINE__, -0x0000059L, "-89", "%0ld", +__LINE__, -0x1ccda96L, "-30202518", "%d", +__LINE__, -0x0000002L, "-2", "%-d", +__LINE__, 0xffffffdaL, "0XFFFFFFDA", "%#X", +__LINE__, 0x00036cc5L, "224453", "%#d", +__LINE__, 0x00000010L, "+16", "%+ld", +__LINE__, 0x0b6039c7L, "190855623", "%d", +__LINE__, -0x0000002L, "-002", "%#.3d", +__LINE__, 0xfff3e746L, "FFF3E746", "%-4X", +__LINE__, 0x0361b3deL, "361B3DE", "% 04X", +__LINE__, 0xffffe6a2L, "ffffe6a2", "%-x", +__LINE__, 0x00032790L, "0x0032790", "%#7.7x", +__LINE__, 0xffe33b4eL, "ffe33b4e", "%-0x", +__LINE__, -0x0094663L, "-607843", "%.3ld", +__LINE__, -0x00a3efaL, "-671482", "%4d", +__LINE__, 0x000000e6L, " 00E6", "%7.4X", +__LINE__, 0x000125cbL, "125CB", "%+X", +__LINE__, 0x0000b97eL, "b97e", "%x", +__LINE__, -0x0000039L, "-57", "%+ld", +__LINE__, 0xffffe39aL, "ffffe39a", "%5.4x", +__LINE__, 0xffffffffL, "ffffffff", "%6.1x", +__LINE__, -0xdee910cL, "-233738508", "%-#2d", +__LINE__, -0x14044930L, "-335825200", "%6.ld", +__LINE__, 0x00a81259L, "a81259", "%x", +__LINE__, 0x020e74c6L, "20E74C6", "%X", +__LINE__, -0x00000fbL, "-251", "%01.d", +__LINE__, 0x034ceb45L, "34CEB45", "%5.X", +__LINE__, 0xfeacb66aL, "feacb66a", "% x", +__LINE__, 0x00003eb6L, "3EB6", "% X", +__LINE__, 0x000009efL, "9ef", "% x", +__LINE__, 0xf9d9dd07L, "F9D9DD07", "%0X", +#ifndef __PCCNECV70__ + +__LINE__, 0x000154d7L, "087255", "%.6ld", +__LINE__, -0x000036eL, "-878", "%-ld", +__LINE__, -0x0007dccL, "-32204", "% d", +__LINE__, 0x000019dcL, "6620", "%d", +__LINE__, 0xffffff6eL, "FFFFFF6E", "%2X", +__LINE__, 0x00000016L, "0x16", "%-#x", +__LINE__, 0xffdb3e96L, "ffdb3e96", "%+.5x", +__LINE__, 0xffffffefL, "FFFFFFEF", "% 04.X", +__LINE__, 0xffffffffL, "FFFFFFFF", "%5X", +__LINE__, 0x000c08cdL, "C08CD", "%-X", +__LINE__, 0x18de71eeL, "18de71ee", "%x", +__LINE__, 0xffffffffL, "ffffffff", "% x", +__LINE__, -0x00025bdL, "-009661", "%#.6d", +__LINE__, 0x2f05de14L, " 788913684", "% 6.4ld", +__LINE__, 0x0c99cf86L, "211406726", "%.5d", +__LINE__, 0x09e6a21dL, " 166109725", "% 0d", +__LINE__, -0x013da65L, "-1301093", "%+ld", +__LINE__, 0x000003d0L, " 976", "% 4.2d", +__LINE__, -0xef9e3ccL, "-251257804", "%-7.0d", +__LINE__, 0x0000000cL, "+12", "%+00ld", +__LINE__, 0xffffffe2L, "ffffffe2", "%x", +__LINE__, 0x000000feL, "fe", "%-x", +__LINE__, 0xfffffc5fL, "fffffc5f", "%x", +__LINE__, -0x0005c55L, "-23637", "%d", +__LINE__, -0x0111ff2L, "-1122290", "% 7.d", +__LINE__, -0x1a1746e5L, "-437733093", "%.4ld", +__LINE__, 0x00001007L, "004103", "%00.6d", +__LINE__, 0xffffffe1L, "ffffffe1", "%x", +__LINE__, 0x0000d80fL, "55311", "%d", +__LINE__, 0x00000004L, "4", "%+X", +__LINE__, 0xfffffffdL, "fffffffd", "%6x", +__LINE__, -0x2afbcc3cL, "-721144892", "%4.6ld", +__LINE__, 0x00377f96L, "377F96", "%6.X", +__LINE__, 0xffffffc8L, "FFFFFFC8", "%0X", +__LINE__, 0x007ed9d1L, "8313297", "%-3d", +__LINE__, 0x00000000L, "0", "%-X", +__LINE__, 0x001e122dL, "1970733", "%01.d", +__LINE__, -0x000029bL, "-667", "%ld", +__LINE__, -0x002f563L, "-193891", "% 2.5d", +__LINE__, 0xfffffffeL, "fffffffe", "%+3.7x", +__LINE__, 0xfff7658cL, "fff7658c", "%x", +__LINE__, -0x0006d08L, "-0027912", "%7.7ld", +__LINE__, 0x00000080L, "80", "%X", +__LINE__, 0x0000078fL, " 1935", "% 6ld", +__LINE__, 0xfffffffbL, "FFFFFFFB", "% X", +__LINE__, 0x000000aeL, " AE", "%7.X", +__LINE__, -0x000d6aaL, "-54954", "%-ld", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%6.X", +__LINE__, 0x000003bfL, "+959", "%+d", +__LINE__, -0x7242d04bL, "-1916981323", "% ld", +__LINE__, 0xf0e6546fL, "F0E6546F", "% .7X", +__LINE__, 0x047e196aL, "75372906", "%ld", +__LINE__, 0x0240174eL, "240174E", "%+0X", +__LINE__, -0x0000006L, "-006", "%.3ld", +__LINE__, 0x00068aacL, "428716", "%#ld", +__LINE__, 0xffffffa1L, "ffffffa1", "%0x", +__LINE__, 0x000adab3L, "adab3", "%x", +__LINE__, -0x00000aeL, "-0000174", "%7.7ld", +__LINE__, 0x0f0a8f4bL, "f0a8f4b", "% x", +__LINE__, 0xfee229bcL, "fee229bc", "%x", +__LINE__, -0x275b8455L, "-660309077", "%.2ld", +__LINE__, -0xca4b2a5L, "-212120229", "%d", +__LINE__, 0x000000b5L, " 181", "%04.d", +__LINE__, 0xfff213f2L, "FFF213F2", "%X", +__LINE__, 0x00000003L, "3", "%-X", +__LINE__, 0x0ebb978bL, "247175051", "%.6ld", +__LINE__, 0xffffffcaL, "FFFFFFCA", "%X", +__LINE__, -0x0000003L, "-03", "%+0.2d", +__LINE__, -0x178ff86L, "-24706950", "%+d", +__LINE__, 0x0000003cL, " 60", "%7.ld", +__LINE__, -0x001012dL, "-65837", "%.5d", +__LINE__, 0x03673fd2L, "3673fd2", "%.5x", +__LINE__, -0x001fe74L, "-130676", "%#0.6ld", +__LINE__, 0x004f6226L, "4f6226", "%-0x", +__LINE__, 0xfffffa0fL, "fffffa0f", "%7x", +__LINE__, 0xfffffff8L, "fffffff8", "%-.6x", +__LINE__, -0x0000001L, "-1", "%#d", +__LINE__, 0xffffe43dL, "ffffe43d", "%7x", +__LINE__, 0x00009d47L, "0040263", "%7.7ld", +__LINE__, 0xff0fc79fL, "FF0FC79F", "%-4.X", +__LINE__, 0x2d610907L, "2d610907", "%x", +__LINE__, -0x00002deL, "-734", "%04d", +__LINE__, 0x0000036bL, " 36B", "%7.1X", +__LINE__, 0x00000002L, "2", "%.0x", +__LINE__, -0x1f577b3eL, "-525826878", "%d", +__LINE__, 0x0000002dL, "45", "%#ld", +__LINE__, 0xfffffffbL, "fffffffb", "%x", +__LINE__, -0x0000004L, "-4", "%-.0d", +__LINE__, 0x00016ba4L, "16ba4", "%x", +__LINE__, -0x1ad853d5L, "-450384853", "% 0ld", +__LINE__, 0x00366899L, "366899", "%2.x", +__LINE__, 0x1659158bL, "1659158B", "%X", +__LINE__, 0x000076c7L, "76c7", "%x", +__LINE__, 0x00000674L, "674", "%0x", +__LINE__, 0x016c9d8aL, "+23895434", "%+ld", +__LINE__, 0xfffffc43L, "FFFFFC43", "%0X", +__LINE__, 0xfff249d2L, "fff249d2", "%-2.x", +__LINE__, 0xffffffddL, "ffffffdd", "%5x", +__LINE__, 0xffffa7efL, "FFFFA7EF", "%0.3X", +__LINE__, 0x030d4d06L, "30d4d06", "%x", +__LINE__, -0x0e4694bL, "-14969163", "%d", +__LINE__, 0x00000078L, "120", "%.3ld", +__LINE__, -0x16c1273eL, "-381757246", "%0d", +__LINE__, 0xffffd183L, "FFFFD183", "% 0X", +__LINE__, -0x2dfdaddL, "-48224989", "%ld", +__LINE__, -0x5767fe5cL, "-1466433116", "%ld", +__LINE__, 0x01bea036L, "29270070", "%#4.3d", +__LINE__, 0x00000027L, "27", "%-x", +__LINE__, 0x0004d183L, "4D183", "%X", +__LINE__, 0xffdaf9c8L, "FFDAF9C8", "%.7X", +__LINE__, 0xfffffd95L, "fffffd95", "%x", +__LINE__, -0x0059acbL, "-367307", "%00.d", +__LINE__, 0x017d8db4L, "17d8db4", "% 05.x", +__LINE__, 0x0001f084L, "001F084", "%5.7X", +__LINE__, 0x00000006L, " 6", "% ld", +__LINE__, 0x011b0802L, "18548738", "%.3ld", +__LINE__, 0x00000006L, " 6", "%#3.d", +__LINE__, 0xffffffffL, "ffffffff", "%6x", +__LINE__, 0x00000001L, "1", "% x", +__LINE__, 0x00000750L, " 01872", "% .5d", +__LINE__, 0xfffffff9L, "fffffff9", "%x", +__LINE__, -0x00f842cL, "-1016876", "%+d", +__LINE__, -0x001dcf0L, "-122096", "%-0d", +__LINE__, 0x000000c9L, "0XC9", "% #3X", +__LINE__, 0x1e368e86L, "1e368e86", "%7x", +__LINE__, -0x0001157L, "-4439", "% 03.4d", +__LINE__, 0xfff91e87L, "FFF91E87", "%3.5X", +__LINE__, 0x00000006L, "6", "%x", +__LINE__, 0x00000bcaL, "3018", "%ld", +__LINE__, 0x00495ff6L, "495ff6", "%01.0x", +__LINE__, -0x0267f7aL, "-2523002", "% #5d", +__LINE__, 0x00000060L, "96", "%-d", +__LINE__, 0x000850c6L, "544966", "%#.1d", +__LINE__, 0x00231457L, "231457", "%-6.4X", +__LINE__, 0x0000000bL, "11", "%-d", +__LINE__, 0x000003bdL, "957", "%#d", +__LINE__, 0xfd51d970L, "FD51D970", "%+.7X", +__LINE__, 0x000007bfL, "1983", "%-ld", +__LINE__, 0x000034b2L, "34B2", "%0.X", +__LINE__, 0x0000c18dL, "C18D", "%0.X", +__LINE__, 0xffffbb83L, "ffffbb83", "% 3x", +__LINE__, 0x000001d0L, "0x1d0", "%#x", +__LINE__, -0x003c784L, "-247684", "%#ld", +__LINE__, 0x0210cffaL, "210CFFA", "%X", +__LINE__, -0x33093a1L, "-53515169", "% 0d", +__LINE__, 0x00000001L, " 1", "% #ld", +__LINE__, 0xffffaa53L, "ffffaa53", "%-4.5x", +__LINE__, 0x2935c056L, "691388502", "%1.d", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, 0x000013d1L, "0X013D1", "%+#2.5X", +__LINE__, -0x000035cL, "-860", "%-.2d", +__LINE__, 0x00000000L, " ", "%-4.X", +__LINE__, -0x0000147L, "-327", "%d", +__LINE__, 0x0a317eb0L, "171015856", "%.7d", +__LINE__, 0x00000003L, "3", "%ld", +__LINE__, 0x000001d6L, "1d6", "%-x", +__LINE__, 0x18185214L, "404247060", "%-.2ld", +__LINE__, 0x00574140L, "0574140", "%.7X", +__LINE__, 0x00002ea5L, "02ea5", "%.5x", +__LINE__, 0x00000005L, "5", "% x", +__LINE__, 0xffc47ed6L, "ffc47ed6", "%-x", +__LINE__, 0x0001f5daL, "0X1F5DA", "%#X", +__LINE__, 0xfffffcc9L, "fffffcc9", "% x", +__LINE__, 0x02586c98L, "2586C98", "%X", +__LINE__, -0x0000036L, "-54", "% ld", +__LINE__, 0x00064b57L, "412503", "%1.5d", +__LINE__, -0x0000007L, "-7", "%#0.0ld", +__LINE__, 0x00023a03L, "145923", "%ld", +__LINE__, -0x0000065L, "-101", "%+#d", +__LINE__, 0x00000208L, "208", "%X", +__LINE__, 0x00e97728L, "15300392", "%-ld", +__LINE__, 0x0000030aL, "+778", "%+d", +__LINE__, 0xf4d7deeeL, "F4D7DEEE", "%+X", +__LINE__, -0x000009aL, "-154", "%+.3ld", +__LINE__, 0x000002c0L, "+704", "%+ld", +__LINE__, 0x0067ec23L, "67ec23", "%x", +__LINE__, 0x005ca7fcL, "+6072316", "%+d", +__LINE__, 0xfffff5f1L, "fffff5f1", "%x", +__LINE__, 0x00000601L, " 0X601", "%#7.2X", +__LINE__, -0x0000057L, "-87", "% ld", +__LINE__, -0x0000078L, " -120", "%7.d", +__LINE__, -0x000001fL, "-31 ", "%-6d", +__LINE__, 0x0160c000L, "23117824", "%ld", +__LINE__, -0x0000007L, "-7", "%0ld", +__LINE__, 0xfffffffeL, "fffffffe", "%+x", +__LINE__, 0x5b6ef898L, "5b6ef898", "%+0x", +__LINE__, 0x0009bfb6L, "638902", "%d", +__LINE__, -0x0000145L, " -325", "%#6.0d", +__LINE__, -0x508c048L, "-84459592", "%-5.ld", +__LINE__, 0x00000002L, " 0x2", "% #4x", +__LINE__, 0x0001486eL, "84078", "%#d", +__LINE__, 0x006ac76aL, "6997866", "%.6d", +__LINE__, 0xffffff98L, "FFFFFF98", "%X", +__LINE__, 0xfffffe08L, "fffffe08", "%6.x", +__LINE__, -0x24ef47eL, "-38728830", "%1.6ld", +__LINE__, 0x39d1b2dbL, "39D1B2DB", "% X", +__LINE__, 0xfffc9ce2L, "0xfffc9ce2", "%#x", +__LINE__, 0x59485e14L, "1497914900", "%#4ld", +__LINE__, 0x000022ebL, "22EB", "%3.X", +__LINE__, 0xfa410352L, "FA410352", "%-X", +__LINE__, -0x4a342f0L, "-77808368", "% ld", +__LINE__, 0xef5825a4L, "EF5825A4", "%.6X", +__LINE__, 0x01b0185aL, "0x1b0185a", "% #x", +__LINE__, -0x0004290L, "-17040", "%.3d", +__LINE__, -0x10f88659L, "-284722777", "%+6.2ld", +__LINE__, 0x00003216L, "12822", "%-d", +__LINE__, 0x4a31a219L, "1244766745", "%d", +__LINE__, 0xffffffb5L, "FFFFFFB5", "%-X", +__LINE__, 0x0000d586L, "D586", "%-2.X", +__LINE__, 0x00008496L, "33942", "%1.d", +__LINE__, -0x0000011L, "-17", "%1ld", +__LINE__, 0x0000003cL, "3C", "%2.X", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%.3X", +__LINE__, 0x0000152aL, "152A", "%X", +__LINE__, 0xfffe876eL, "FFFE876E", "%X", +__LINE__, -0x0003874L, "-14452", "%-ld", +__LINE__, -0x004918aL, "-299402", "%#.6d", +__LINE__, -0x000000cL, "-12", "%-d", +__LINE__, 0xffffd812L, "FFFFD812", "%+X", +__LINE__, -0x000000cL, "-12", "%0d", +__LINE__, -0x0000229L, "-553", "%0d", +__LINE__, 0x00002ab8L, "2AB8", "%4.X", +__LINE__, 0x0000004bL, "+75", "%+ld", +__LINE__, 0x001c3178L, " 1847672", "% ld", +__LINE__, -0x0000006L, "-6", "%.0ld", +__LINE__, 0x0003be65L, "245349", "%ld", +__LINE__, -0x0000001L, "-1", "%#1ld", +__LINE__, 0x0000007fL, "+127", "%+ld", +__LINE__, 0x0000020eL, "526 ", "%-5ld", +__LINE__, 0x00000002L, "2", "%d", +__LINE__, 0x03bd0873L, "0X3BD0873", "%#X", +__LINE__, 0x00093a52L, "604754", "%-2d", +__LINE__, -0x00823fcL, "-0533500", "%+.7ld", +__LINE__, 0x00000000L, " ", "%4.X", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, 0xfff09edeL, "fff09ede", "%-x", +__LINE__, 0x01e28c24L, "31624228", "%ld", +__LINE__, 0x00001dccL, "1DCC", "%X", +__LINE__, -0x0f0ea0dL, "-15788557", "%-00.ld", +__LINE__, 0xffff73a1L, "FFFF73A1", "%X", +__LINE__, -0x0004040L, "-16448", "%+#d", +__LINE__, 0x0073b158L, "0x73b158", "%#7x", +__LINE__, 0xfffff8ffL, "FFFFF8FF", "% 5X", +__LINE__, -0x0000004L, "-4", "%0d", +__LINE__, 0xffff56a3L, "ffff56a3", "%1.6x", +__LINE__, -0x0000041L, "-65", "%0d", +__LINE__, 0x00000009L, "+0000009", "%+2.7d", +__LINE__, 0xffffe13dL, "0XFFFFE13D", "%+#2.X", +__LINE__, -0x00002ceL, "-00718", "%.5ld", +__LINE__, 0xffc53e28L, "ffc53e28", "%03.4x", +__LINE__, 0x00000005L, "0X5", "%#X", +__LINE__, 0x00000004L, "4", "%x", +__LINE__, 0xe21b35ebL, "e21b35eb", "%-x", +__LINE__, -0x0000098L, "-152", "%-ld", +__LINE__, 0xffffff81L, "FFFFFF81", "%2X", +__LINE__, 0x00000003L, "00003", "%.5ld", +__LINE__, 0xfffffffcL, "fffffffc", "%+x", +__LINE__, 0x000491f5L, "299509", "%1.ld", +__LINE__, 0xf06bfd7dL, "F06BFD7D", "%X", +__LINE__, -0x0000006L, "-6", "%0d", +__LINE__, -0x0a4af7dL, "-10792829", "%-0d", +__LINE__, -0x11a74efL, "-18511087", "%ld", +__LINE__, 0x2dc95e17L, "768171543", "%-1.d", +__LINE__, -0x0000001L, "-1", "%#ld", +__LINE__, 0x00000033L, "51", "%-#d", +__LINE__, 0x002d0219L, "2949657", "%ld", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%2.4X", +__LINE__, 0x00000f20L, "+3872", "%+ld", +__LINE__, -0x0000047L, "-071", "%4.3ld", +__LINE__, 0x00000010L, " 16", "%6d", +__LINE__, 0x00000000L, "0", "%0d", +__LINE__, 0xffffff57L, "FFFFFF57", "%X", +__LINE__, -0x0000700L, "-1792", "%-#d", +__LINE__, -0x0000064L, "-100", "%-ld", +__LINE__, 0xff26d49aL, "FF26D49A", "%-0X", +__LINE__, -0x0000006L, "-6", "%.1ld", +__LINE__, 0x1391edc5L, "1391edc5", "%.1x", +__LINE__, 0x0000014aL, "330", "%-#ld", +__LINE__, 0x07ecd1e1L, "7ecd1e1", "%6x", +__LINE__, -0xa2b8898L, "-170625176", "%3.d", +__LINE__, 0x00035287L, "0x35287", "%#.0x", +__LINE__, 0x00000000L, "00000", "%0.5X", +__LINE__, -0x0000153L, "-339", "%d", +__LINE__, 0x0000ad6eL, " 44398", "% 0.d", +__LINE__, 0x00000001L, "1", "%-X", +__LINE__, -0x000000dL, "-13 ", "%-6.2d", +__LINE__, -0x01bff8aL, "-1834890", "%d", +__LINE__, 0x000a0fa8L, "+659368", "%+ld", +__LINE__, 0xac044dc0L, "ac044dc0", "%.0x", +__LINE__, 0x0003a729L, "239401", "%ld", +__LINE__, -0x00004f0L, "-1264", "%+ld", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0x00000012L, "12", "% x", +__LINE__, 0xffff770bL, "ffff770b", "%7.1x", +__LINE__, 0xd7458572L, "d7458572", "%x", +__LINE__, 0x01f1b4f9L, "1f1b4f9", "% 0x", +__LINE__, 0xfffb2198L, "0XFFFB2198", "% #1.X", +__LINE__, 0x00ef6189L, " 15688073", "% ld", +__LINE__, -0x3f0ae63L, "-66104931", "% #d", +__LINE__, -0x0006075L, "-24693", "%ld", +__LINE__, 0x000000a1L, "161", "%d", +__LINE__, 0xfffffffcL, "fffffffc", "%3.2x", +__LINE__, 0xff6b4125L, "FF6B4125", "%+5.X", +__LINE__, 0x00000001L, " 1", "%6.d", +__LINE__, -0x0000001L, "-1", "%+0d", +__LINE__, -0x000096cL, "-2412", "%0.4d", +__LINE__, 0x00039c6fL, "236655", "%.0d", +__LINE__, 0x3625286cL, "908404844", "%.1d", +__LINE__, 0xfffffffaL, "fffffffa", "%x", +__LINE__, 0x00000000L, "0", "%X", +__LINE__, 0x00c34353L, "12796755", "%#.4d", +__LINE__, 0x000002dfL, "735", "%ld", +__LINE__, 0xffff38faL, "FFFF38FA", "%5.1X", +__LINE__, -0x000002aL, "-42", "%0.d", +__LINE__, 0x0000077eL, "1918", "%ld", +__LINE__, 0x000001f7L, "503", "%ld", +__LINE__, 0x00000004L, "4", "%ld", +__LINE__, 0x0021fb02L, "2226946", "%d", +__LINE__, 0x007c858dL, "8160653", "%-0d", +__LINE__, -0x0000109L, "-265", "%.0d", +__LINE__, 0xfffffffaL, "fffffffa", "% x", +__LINE__, 0x0097932dL, "97932d", "%+x", +__LINE__, 0xfffbbd03L, "fffbbd03", "%-.5x", +__LINE__, -0x0000005L, "-5", "%0d", +__LINE__, 0x03ee3a95L, "65944213", "%ld", +__LINE__, -0x0000002L, " -00002", "%7.5d", +__LINE__, 0xea1a4e54L, "EA1A4E54", "%X", +__LINE__, -0x000a9d6L, "-43478", "%+d", +__LINE__, -0x0fd8d65L, "-16616805", "%5ld", +__LINE__, 0x00000001L, "1", "%-d", +__LINE__, 0x00000072L, "72", "%2.X", +__LINE__, 0xffffff94L, "FFFFFF94", "%X", +__LINE__, 0x00000d2aL, "D2A", "%+X", +__LINE__, 0xffff614fL, "ffff614f", "%x", +__LINE__, -0x0000018L, "-24", "%ld", +__LINE__, 0x0000003bL, "059", "%2.3d", +__LINE__, 0x0000001aL, "1A", "%0X", +__LINE__, -0x0000109L, "-265", "%02ld", +__LINE__, 0x00000f9dL, "3997", "%#1d", +__LINE__, 0x0000001bL, "1b", "%x", +__LINE__, 0xffffff07L, "ffffff07", "%x", +__LINE__, 0xfff1a425L, "0xfff1a425", "%#x", +__LINE__, 0x00000005L, "5", "%-1d", +__LINE__, -0x53a6efdL, "-87715581", "%ld", +__LINE__, 0x042f37dbL, "42F37DB", "%6.X", +__LINE__, 0x00053bd5L, "+342997", "%+5ld", +__LINE__, 0xffffffffL, "ffffffff", "% x", +__LINE__, 0xffffffefL, "FFFFFFEF", "%6.X", +__LINE__, -0x10ec29aL, "-17744538", "%+2.d", +__LINE__, 0x01dcc901L, "1dcc901", "%x", +__LINE__, 0x0007dc68L, "515176", "%-3.d", +__LINE__, -0x0000062L, "-0098", "%#2.4d", +__LINE__, 0x00000000L, " ", "%3.0X", +__LINE__, -0x00000deL, "-222", "%ld", +__LINE__, 0x000c1fb8L, "C1FB8", "%0X", +__LINE__, 0x0005bf58L, "5BF58", "%X", +__LINE__, -0x000dd1bL, "-56603", "%-03.1d", +__LINE__, 0x00000b14L, "B14", "%+3.X", +__LINE__, 0x00000799L, "799", "%-x", +__LINE__, 0xfffffffaL, "fffffffa", "%x", +__LINE__, 0x00000003L, "0x00003", "% #7.5x", +__LINE__, -0x002b9f1L, "-178673", "%+d", +__LINE__, -0x001b817L, "-112663", "%0d", +__LINE__, 0xf6f98533L, "f6f98533", "%.1x", +__LINE__, 0x00338ffcL, "3379196", "%d", +__LINE__, 0x0409e9b5L, "0X409E9B5", "%#X", +__LINE__, 0x00b8e98eL, " 12118414", "% 0d", +__LINE__, -0x002a8f6L, "-174326", "%ld", +__LINE__, 0x13bb9722L, "331061026", "%0d", +__LINE__, 0x00063c71L, "63c71", "%x", +__LINE__, 0xfffffe37L, "FFFFFE37", "%.1X", +__LINE__, 0xffff7b3eL, "ffff7b3e", "%+.1x", +__LINE__, 0x005eeab1L, "5eeab1", "%+x", +__LINE__, 0xffc69e99L, "ffc69e99", "%x", +__LINE__, -0x000005cL, " -92", "%5ld", +__LINE__, 0x07d8fa8aL, "7d8fa8a", "%x", +__LINE__, 0x00030e0aL, "200202", "%-4.1d", +__LINE__, 0x00001dc1L, "1DC1", "%.0X", +__LINE__, 0x00000008L, "8", "%0ld", +__LINE__, -0x01b5397L, "-1790871", "%3.d", +__LINE__, 0x27fbb4b5L, "27fbb4b5", "%x", +__LINE__, -0xe3fdcfcL, "-239066364", "%4ld", +__LINE__, 0x0008bcb1L, "8bcb1", "%0x", +__LINE__, 0xffff039eL, "ffff039e", "%.6x", +__LINE__, 0x000d0bd4L, "d0bd4", "%-x", +__LINE__, 0x00000000L, "+0", "%+d", +__LINE__, -0x2a49ea4L, "-44342948", "%1d", +__LINE__, -0x0000055L, "-85", "%0d", +__LINE__, -0x0000a05L, "-2565", "%3.3ld", +__LINE__, -0x000000bL, "-11 ", "%-4d", +__LINE__, 0xfff30444L, "FFF30444", "%7.X", +__LINE__, 0x0000003fL, "63", "%-0d", +__LINE__, 0x00046779L, "46779", "%X", +__LINE__, 0x000028d7L, " 0X28D7", "%#7.X", +__LINE__, 0x00000019L, " 19", "%5x", +__LINE__, 0x0032291dL, "3287325", "%2.ld", +__LINE__, 0x00057afaL, "57AFA", "%X", +__LINE__, 0xfffe8c64L, "fffe8c64", "%3.4x", +__LINE__, -0x624110d6L, "-1648431318", "%+6d", +__LINE__, 0x0000001aL, " 26", "% 5.d", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%6.X", +__LINE__, 0x00199490L, "1676432", "%-1d", +__LINE__, -0xfff8265L, "-268403301", "%-0ld", +__LINE__, 0x0000000eL, "e", "%-x", +__LINE__, 0x00c38aecL, "c38aec", "%x", +__LINE__, -0x00658f4L, "-415988", "%#ld", +__LINE__, 0x0066ac4eL, "6728782", "%0d", +__LINE__, 0xc4a808d5L, "c4a808d5", "%x", +__LINE__, 0x00000000L, " 0", "%6.1x", +__LINE__, 0x00066d24L, "66d24", "%x", +__LINE__, 0x00002117L, "2117", "%X", +__LINE__, 0xfe06fdf4L, "FE06FDF4", "%0X", +__LINE__, 0xfffffff9L, "fffffff9", "%x", +__LINE__, 0x1c6bb795L, "+476821397", "%+d", +__LINE__, 0xfffffba4L, "FFFFFBA4", "%X", +__LINE__, 0xfffd7d44L, "fffd7d44", "%0x", +__LINE__, 0x0019dd17L, "1694999", "%d", +__LINE__, 0x6475851eL, "0x6475851e", "% #7.x", +__LINE__, -0x00330d5L, "-209109", "%0ld", +__LINE__, 0x009f53f7L, "09F53F7", "%+6.7X", +__LINE__, -0x00172f9L, " -94969", "%7.5ld", +__LINE__, 0xffffffdcL, "FFFFFFDC", "%X", +__LINE__, -0x013bdecL, "-1293804", "%+#2ld", +__LINE__, 0xfff845c0L, "fff845c0", "%+7.x", +__LINE__, -0x0fbe712L, "-16508690", "%.7d", +__LINE__, 0xffffe13fL, "ffffe13f", "%x", +__LINE__, 0xbbc19951L, "BBC19951", "%-4X", +__LINE__, -0x28d6d1bL, "-42822939", "%#d", +__LINE__, -0x93cda6bL, "-154983019", "%-d", +__LINE__, 0xffc93342L, "FFC93342", "%7.X", +__LINE__, 0x072ac8b3L, " 120244403", "% ld", +__LINE__, 0xfff8d17bL, "FFF8D17B", "% X", +__LINE__, 0x00000da5L, "DA5", "%0.X", +__LINE__, 0x055ad3acL, "0x55ad3ac", "%#1x", +__LINE__, 0x00000e5aL, " 3674", "% .4ld", +__LINE__, 0xffffff79L, "FFFFFF79", "%+X", +__LINE__, 0xffffe167L, "ffffe167", "%+5x", +__LINE__, 0x0000fa50L, "0064080", "%.7ld", +__LINE__, 0x00000001L, "1", "%-d", +__LINE__, 0xfffffffeL, "fffffffe", "%x", +__LINE__, 0x000009acL, " 2476", "% #2.ld", +__LINE__, 0x00000e78L, "0003704", "%.7ld", +__LINE__, -0x000dfc3L, "-57283", "%6.d", +__LINE__, 0x00000ee0L, "EE0", "%0X", +__LINE__, -0x293703b3L, "-691471283", "%ld", +__LINE__, 0x000073e8L, " 73e8", "%6x", +__LINE__, 0xffffdffdL, "ffffdffd", "%5.5x", +__LINE__, 0x00000004L, "4", "%+00.x", +__LINE__, 0x00000008L, "0X8", "%#X", +__LINE__, 0x0003044cL, "3044c", "%0x", +__LINE__, 0xffc2095eL, "FFC2095E", "%0X", +__LINE__, 0x00000aacL, "0002732", "%-.7ld", +__LINE__, 0xffffff79L, "FFFFFF79", "%+1.X", +__LINE__, 0x53a0f94aL, " 1403058506", "% 2.4ld", +__LINE__, 0x000e928dL, "e928d", "%x", +__LINE__, 0x0024127aL, "2364026", "%5.d", +__LINE__, 0x000f7c1cL, " 1014812", "% 2.d", +__LINE__, -0x000003dL, "-61 ", "%-#4ld", +__LINE__, -0x0000122L, "-290", "%+ld", +__LINE__, 0x00000006L, "+6", "%+0d", +__LINE__, 0x00000129L, " 000129", "%7.6X", +__LINE__, 0x15d873e5L, " 366506981", "% 5.7d", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, 0x038d6110L, "+59597072", "%+d", +__LINE__, 0x0f46ccc3L, "256298179", "%-1.4d", +__LINE__, 0xfe434d21L, "fe434d21", "%x", +__LINE__, -0x179797d7L, "-395810775", "%d", +__LINE__, 0xe35807bfL, "e35807bf", "%x", +__LINE__, 0x00000003L, " +3", "%+7d", +__LINE__, 0x017e699eL, "25061790", "%#ld", +__LINE__, -0x0000029L, "-41", "%d", +__LINE__, 0xffffff11L, "ffffff11", "%1.x", +__LINE__, -0x0001bf6L, "-7158", "%+0ld", +__LINE__, 0xffffff4bL, "FFFFFF4B", "%4X", +__LINE__, -0x0000040L, "-64", "%ld", +__LINE__, 0x000034d6L, "+13526", "%+ld", +__LINE__, 0xffffffa7L, "ffffffa7", "%x", +__LINE__, 0xfffffe8eL, "fffffe8e", "%+.3x", +__LINE__, 0x00000000L, "0", "%0.1d", +__LINE__, -0x007cdf1L, "-511473", "%ld", +__LINE__, 0xfffffeefL, "FFFFFEEF", "%-X", +__LINE__, 0x00002d91L, "2d91", "%x", +__LINE__, -0x000025bL, "-603", "%#ld", +__LINE__, -0x000001bL, "-27", "%-ld", +__LINE__, 0x042b6752L, "42B6752", "%+X", +__LINE__, -0x75afb0a6L, "-1974448294", "% ld", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, 0x00000542L, " 1346", "%6d", +__LINE__, -0x0000010L, "-16", "%+0d", +__LINE__, 0xfffed8f7L, "FFFED8F7", "%5.X", +__LINE__, 0x0541852eL, "541852e", "% 2.x", +__LINE__, 0xff22aec3L, "ff22aec3", "% .1x", +__LINE__, 0x5e34b745L, "1580513093", "%ld", +__LINE__, 0xfffffff3L, "fffffff3", "%x", +__LINE__, 0x0eda7b86L, "+249199494", "%+.3d", +__LINE__, 0xffffe40fL, "ffffe40f", "%+x", +__LINE__, -0x0003484L, "-13444", "%-1.5ld", +__LINE__, 0x0000334bL, " 13131", "%6.ld", +__LINE__, -0x0000149L, "-329", "%ld", +__LINE__, 0x00000001L, " 001", "% 5.3x", +__LINE__, 0xffeaa035L, "ffeaa035", "%+3.5x", +__LINE__, 0x00211dffL, "2170367", "%ld", +__LINE__, 0x007e91f4L, "7e91f4", "%x", +__LINE__, 0xfffffffcL, "0xfffffffc", "%+#5x", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%6.X", +__LINE__, 0x0156a9b5L, "156a9b5", "%x", +__LINE__, 0xfffffe58L, "fffffe58", "%+x", +__LINE__, 0xffff8c66L, "FFFF8C66", "%.0X", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, 0x00000005L, " 5", "%7.d", +__LINE__, -0x0000002L, "-2", "%ld", +__LINE__, 0x000076b9L, " 30393", "% ld", +__LINE__, 0x00003824L, "3824", "%4X", +__LINE__, 0x00000cdfL, " CDF", "% 7X", +__LINE__, 0x017c9e8fL, "17C9E8F", "%-X", +__LINE__, -0x20f582dL, "-34560045", "%-.5d", +__LINE__, 0x0000732eL, " 29486", "% 7.ld", +__LINE__, 0xffffffffL, "FFFFFFFF", "%+0X", +__LINE__, 0xf379a4a2L, "F379A4A2", "% .7X", +__LINE__, -0x0000028L, "-40", "%-d", +__LINE__, 0xe73cf79eL, "e73cf79e", "%x", +__LINE__, 0x00000002L, " 2", "%7ld", +__LINE__, -0x00029b1L, "-10673", "%-#1.ld", +__LINE__, -0x0002a58L, "-10840", "%3.d", +__LINE__, 0x00000002L, "2", "%-X", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%X", +__LINE__, -0x000003aL, " -58", "%5ld", +__LINE__, 0x0245ef3bL, "245ef3b", "%.3x", +__LINE__, 0x00026ccaL, "158922", "%-06.3ld", +__LINE__, 0x01016fd3L, "16871379", "%-d", +__LINE__, 0x000016fcL, "5884", "%0ld", +__LINE__, -0x00007fbL, " -2043", "%7.3d", +__LINE__, 0xfff73d3cL, "fff73d3c", "%0x", +__LINE__, -0x0000110L, "-272", "% 04.3d", +__LINE__, 0x0000000eL, " 014", "% 04ld", +__LINE__, -0x0000039L, "-57", "%.0ld", +__LINE__, 0x00000c95L, "c95", "%0x", +__LINE__, 0xffff3b2eL, "ffff3b2e", "%x", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%X", +__LINE__, 0x00000015L, "21", "%.1d", +__LINE__, 0x0000000cL, "+12", "%+ld", +__LINE__, 0x00000000L, "0", "%+X", +__LINE__, 0xfffc9a14L, "fffc9a14", "%-.5x", +__LINE__, 0x0000003cL, "60", "%.2ld", +__LINE__, -0x0000023L, " -35", "%6.d", +__LINE__, 0x00000740L, "1856", "%ld", +__LINE__, 0x00000160L, "160", "% 3.X", +__LINE__, 0x00000006L, " 6", "%5.X", +__LINE__, -0x0000677L, "-1655", "%.3ld", +__LINE__, 0x12709c7eL, "12709C7E", "%.7X", +__LINE__, 0x0000090fL, "+2319", "%+#d", +__LINE__, 0xffffffe0L, "0xffffffe0", "%#4.1x", +__LINE__, 0x00132ce0L, "1256672", "%ld", +__LINE__, 0x00000059L, "59", "%+X", +__LINE__, -0x0000017L, "-23", "%0d", +__LINE__, -0x01fade6L, "-2076134", "%-4.3ld", +__LINE__, 0x000df3faL, "914426", "%.5ld", +__LINE__, 0xfffffd0fL, "fffffd0f", "%7x", +__LINE__, -0x000c212L, "-49682", "%0.1ld", +__LINE__, 0xffff8bcbL, "FFFF8BCB", "%.3X", +__LINE__, 0x0000000aL, "a", "% x", +__LINE__, 0x00000021L, "21", "%x", +__LINE__, -0x0000040L, "-64", "% 1ld", +__LINE__, 0x00000009L, " 9", "%6.ld", +__LINE__, -0x0000d67L, "-3431", "% 5.3d", +__LINE__, 0x03a85f1bL, "61366043", "%ld", +__LINE__, 0x00000035L, "000053", "%0.6d", +__LINE__, 0xfffda5cbL, "fffda5cb", "%+x", +__LINE__, 0xffffff78L, "FFFFFF78", "%-7.0X", +__LINE__, 0xfffffd6dL, "fffffd6d", "%7.x", +__LINE__, 0xfffffc08L, "fffffc08", "%7.3x", +__LINE__, 0x00003335L, " 13109", "% #d", +__LINE__, -0x0000002L, " -2", "%5.d", +__LINE__, -0x13767a48L, "-326531656", "%+ld", +__LINE__, 0x00000be5L, "3045", "%4.0ld", +__LINE__, 0xfffdb28cL, "FFFDB28C", "%X", +__LINE__, 0x00127118L, "1208600", "%ld", +__LINE__, 0x00000086L, " 134", "% ld", +__LINE__, 0x0002214cL, "2214c", "%+x", +__LINE__, 0x0000a0c2L, " a0c2", "%5.0x", +__LINE__, -0x000007cL, "-124", "%ld", +__LINE__, 0x0000012aL, "00298", "%3.5d", +__LINE__, 0xfd4f1257L, "FD4F1257", "%+2.X", +__LINE__, 0xffffd8aaL, "ffffd8aa", "%5x", +__LINE__, -0x00000a7L, "-167", "%+ld", +__LINE__, -0x0009c69L, "-40041", "%0.0ld", +__LINE__, 0x02230418L, "35849240", "%-0.6ld", +__LINE__, 0x00000000L, " 0", "%6x", +__LINE__, 0xfffff184L, "fffff184", "%02.5x", +__LINE__, -0x0ae967bL, "-11441787", "%d", +__LINE__, 0x0015de3aL, "1433146", "%-5.3d", +__LINE__, -0x0071e93L, "-466579", "%1.ld", +__LINE__, 0xfffff8bdL, "fffff8bd", "%+x", +__LINE__, -0x00000e4L, "-228", "%+ld", +__LINE__, 0x000001d8L, " 472", "% .3ld", +__LINE__, 0x00315faaL, "315faa", "%-0x", +__LINE__, 0x00000e59L, "e59", "%0x", +__LINE__, -0x0000005L, "-5", "%ld", +__LINE__, 0x000018ecL, "6380", "%ld", +__LINE__, 0xfffffff9L, "fffffff9", "%5.2x", +__LINE__, -0xe7cfd39L, "-243072313", "%-d", +__LINE__, 0x0002c30bL, "2C30B", "%1.2X", +__LINE__, 0x0000007aL, "7A", "%X", +__LINE__, 0xf604ecb2L, "F604ECB2", "%2X", +__LINE__, -0x05f602cL, "-6250540", "%d", +__LINE__, 0xffff9c86L, "ffff9c86", "%2.x", +__LINE__, -0x00d7f55L, "-884565", "%#d", +__LINE__, 0xd2a37824L, "D2A37824", "%4X", +__LINE__, 0x00000000L, "", "%-.0x", +__LINE__, 0x000d4b51L, "0d4b51", "%3.6x", +__LINE__, 0x000ecd97L, "ecd97", "% x", +__LINE__, -0x0000018L, "-024", "%+04ld", +__LINE__, -0x009f292L, "-651922", "%ld", +__LINE__, -0x0002da9L, "-11689", "%-0ld", +__LINE__, -0x000a218L, "-41496", "%4.5d", +__LINE__, 0xffff85acL, "FFFF85AC", "% 04.X", +__LINE__, -0x0d9ffbeL, "-14286782", "%0d", +__LINE__, 0xfb18cc8eL, "fb18cc8e", "%x", +__LINE__, 0xffffe5d3L, "FFFFE5D3", "%-X", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, -0x0000006L, "-6", "% d", +__LINE__, 0x0002fc62L, "2fc62", "% 03.x", +__LINE__, 0x00000000L, "00", "%.2d", +__LINE__, -0x00000fdL, " -253", "%6ld", +__LINE__, -0x000000bL, "-11", "%d", +__LINE__, -0x00042a3L, "-17059", "% 6d", +__LINE__, 0x00000002L, "2", "% X", +__LINE__, -0x61ead93eL, "-1642780990", "%-0d", +__LINE__, 0xf2e61f6dL, "f2e61f6d", "%-.4x", +__LINE__, 0xffd31b93L, "ffd31b93", "%x", +__LINE__, -0x0000008L, "-8", "%ld", +__LINE__, 0xffffffffL, "ffffffff", "%00x", +__LINE__, 0x000000fbL, "+000251", "%+2.6d", +__LINE__, 0x00000015L, " 15", "%4.X", +__LINE__, 0x06ec6d96L, "6EC6D96", "%+2.X", +__LINE__, 0xffff1df7L, "0xffff1df7", "% #1x", +__LINE__, -0x000004bL, "-75", "%-ld", +__LINE__, 0x00000008L, "8", "%#.0d", +__LINE__, 0x00001355L, "4949", "%3.4ld", +__LINE__, -0x00000f7L, "-247", "%d", +__LINE__, 0x0000001fL, "31", "%.2ld", +__LINE__, 0x0000d556L, "D556", "%-X", +__LINE__, 0xffffd5a5L, "ffffd5a5", "% x", +__LINE__, -0x0000e34L, "-3636", "%#d", +__LINE__, -0x0000007L, "-7", "%d", +__LINE__, 0x01ba10a4L, "1ba10a4", "%x", +__LINE__, 0xfffff759L, "FFFFF759", "% X", +__LINE__, -0x80d0adbL, "-135072475", "%d", +__LINE__, 0x0002bf61L, "2bf61", "%x", +__LINE__, 0xffff008bL, "FFFF008B", "%-7X", +__LINE__, 0x00000e72L, "E72", "%X", +__LINE__, -0x00000eaL, "-234", "%0ld", +__LINE__, -0x0007b9dL, "-0031645", "%0.7ld", +__LINE__, 0x0001baaaL, "0X1BAAA", "%#4X", +__LINE__, 0x0000a57fL, " a57f", "%6.x", +__LINE__, -0x21a73726L, "-564606758", "%ld", +__LINE__, 0x06f45c9fL, "0x6f45c9f", "%#.3x", +__LINE__, 0x00018e5dL, "101981", "%-d", +__LINE__, 0x0001e69aL, "124570", "%-d", +__LINE__, -0x0000d26L, " -3366", "% 07.d", +__LINE__, 0x00000000L, "+", "%+0.ld", +__LINE__, 0x00003916L, "14614", "%ld", +__LINE__, 0xfffffd8fL, "fffffd8f", "%-3.x", +__LINE__, 0x00000011L, "11", "%x", +__LINE__, 0x000000e7L, "E7", "%X", +__LINE__, 0xfdf9d89bL, "FDF9D89B", "%X", +__LINE__, 0x00000a7cL, "a7c", "%x", +__LINE__, 0x0000003fL, "00003F", "%.6X", +__LINE__, 0xffffe729L, "FFFFE729", "%X", +__LINE__, 0xfffffffeL, "fffffffe", "% .6x", +__LINE__, -0x0000a4bL, "-2635", "%+d", +__LINE__, 0xffffff50L, "ffffff50", "%0.7x", +__LINE__, 0xfaf57e8bL, "faf57e8b", "% 4.x", +__LINE__, -0x0000056L, "-86", "%ld", +__LINE__, 0x08ed2a4dL, "8ed2a4d", "%4x", +__LINE__, 0xff8d9081L, "FF8D9081", "%+0.X", +__LINE__, 0x002730a1L, "2568353", "%4d", +__LINE__, 0xffff9564L, "ffff9564", "%x", +__LINE__, -0x0000006L, " -6", "%4ld", +__LINE__, -0x19890310L, "-428409616", "%0ld", +__LINE__, 0xd2ce636cL, "d2ce636c", "%+x", +__LINE__, -0x00001feL, "-510", "%d", +__LINE__, 0x00000006L, "0000006", "%+0.7x", +__LINE__, 0xffffffc2L, "0XFFFFFFC2", "%-#.5X", +__LINE__, -0x00000fdL, "-253", "%+d", +__LINE__, 0x000216aaL, "0x216aa", "%#x", +__LINE__, 0xffe36c66L, "ffe36c66", "%x", +__LINE__, 0x00000002L, "2", "%x", +__LINE__, -0x0000025L, "-37", "% d", +__LINE__, 0x0000007eL, "126", "%d", +__LINE__, 0x0003c1f9L, "+246265", "%+ld", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, -0x00539e7L, "-342503", "%06.ld", +__LINE__, 0x00000d42L, " 3394", "%#6.ld", +__LINE__, 0xf73b7c4eL, "F73B7C4E", "%X", +__LINE__, 0x00000022L, "22", "%.1x", +__LINE__, 0xffffa883L, "FFFFA883", "%X", +__LINE__, 0x016ec247L, "16ec247", "%x", +__LINE__, 0x00000019L, "19", "%+X", +__LINE__, 0x0000665aL, "665A", "% 2.X", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%-5.X", +__LINE__, 0x008e3fbcL, "8E3FBC", "%X", +__LINE__, 0xfffffffaL, "FFFFFFFA", "%X", +__LINE__, 0x1b806597L, "461399447", "%.2d", +__LINE__, 0x00000366L, "0000870", "%#1.7ld", +__LINE__, 0x0001d92eL, "1d92e", "%x", +__LINE__, 0x000104ceL, "104CE", "%-X", +__LINE__, 0xfffffe4cL, "fffffe4c", "%x", +__LINE__, 0x000000e9L, "E9", "%X", +__LINE__, 0x000a855cL, " 689500", "% d", +__LINE__, 0x00000075L, "75", "% X", +__LINE__, -0x0000026L, "-38", "%ld", +__LINE__, 0xfffff169L, "fffff169", "%-04.2x", +__LINE__, 0xffffff6fL, "ffffff6f", "%x", +__LINE__, 0x00000003L, "0x3", "%#x", +__LINE__, 0x00623babL, "6437803", "%.0d", +__LINE__, -0x2260224cL, "-576725580", "%ld", +__LINE__, 0xe7e7a998L, "E7E7A998", "%.1X", +__LINE__, 0x00000005L, "5", "%X", +__LINE__, 0x0000b560L, "0xb560", "%#x", +__LINE__, 0xfe11854dL, "fe11854d", "%-.5x", +__LINE__, 0x00190014L, "1638420", "%ld", +__LINE__, 0x0001d22aL, "0X1D22A", "%-#X", +__LINE__, 0x00000c16L, "c16", "%2x", +__LINE__, 0x00000d1aL, "3354", "%#d", +__LINE__, 0x000165f6L, "91638", "%d", +__LINE__, 0xfffff557L, "0XFFFFF557", "%#X", +__LINE__, 0x00000588L, " 588", "%07.X", +__LINE__, 0xf4a72708L, "f4a72708", "%x", +__LINE__, 0xfff1cba9L, "0xfff1cba9", "% #2.5x", +__LINE__, 0x000333a4L, "209828", "%d", +__LINE__, 0x0000179bL, "179B", "% 2.X", +__LINE__, 0x00000460L, "1120", "%0ld", +__LINE__, 0xffffff89L, "FFFFFF89", "%X", +__LINE__, -0x0000012L, "-18", "%ld", +__LINE__, 0x00004fe0L, "20448", "%0.d", +__LINE__, 0x00532e77L, "532e77", "%00.x", +__LINE__, 0xf7b92efeL, "f7b92efe", "%0x", +__LINE__, -0x0000243L, "-579", "%+1.d", +__LINE__, 0x34894bb7L, "+881413047", "%+d", +__LINE__, 0xfffaa189L, "FFFAA189", "% 6X", +__LINE__, -0x0000579L, "-1401", "%+ld", +__LINE__, 0x005acb12L, "5acb12", "%5.0x", +__LINE__, 0xffff890aL, "FFFF890A", "%X", +__LINE__, 0x010dff2fL, "10DFF2F", "%.7X", +__LINE__, 0x00005a7fL, "23167", "%#ld", +__LINE__, 0x000005e3L, "1507", "%#3d", +__LINE__, -0xa815bcbL, "-176249803", "%d", +__LINE__, 0xffffffffL, "ffffffff", "%+x", +__LINE__, 0xfffe0ff7L, "fffe0ff7", "%3x", +__LINE__, 0xffffffffL, "0XFFFFFFFF", "%#2.1X", +__LINE__, -0x1cc5ea52L, "-482732626", "%6.d", +__LINE__, 0x000425edL, "+0271853", "%+.7d", +__LINE__, 0x00000001L, "1", "%+x", +__LINE__, -0x48f2a72L, "-76491378", "%7.0d", +__LINE__, 0xfffffff7L, "FFFFFFF7", "% 0X", +__LINE__, 0xfd8ffc0aL, "fd8ffc0a", "%.1x", +__LINE__, 0x0001f56dL, " 1F56D", "%+7.2X", +__LINE__, 0x000000dbL, " DB", "%6.X", +__LINE__, 0xffffffc2L, "ffffffc2", "%x", +__LINE__, 0x00000001L, "001", "%03ld", +__LINE__, 0xffd89f58L, "ffd89f58", "% 0.x", +__LINE__, 0xfe1a72fcL, "fe1a72fc", "%x", +__LINE__, 0xfffff9b6L, "FFFFF9B6", "%X", +__LINE__, 0x00243633L, "243633", "%X", +__LINE__, 0x00821bc7L, "+8526791", "%+#0ld", +__LINE__, 0xfe63f348L, "0XFE63F348", "%#3X", +__LINE__, 0xff729f19L, "ff729f19", "%4x", +__LINE__, 0xffff570fL, "FFFF570F", "%+X", +__LINE__, 0x00a57a42L, "10844738", "%6.3d", +__LINE__, 0xfe4a3ed0L, "FE4A3ED0", "%6.X", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, 0x000001bbL, "01bb", "% .4x", +__LINE__, 0x02b4a1e9L, "2b4a1e9", "%-7.x", +__LINE__, 0x31750683L, "31750683", "%x", +__LINE__, 0x00001cd7L, "7383", "%#ld", +__LINE__, 0x0000079dL, "1949", "%d", +__LINE__, 0xffb8ff3bL, "FFB8FF3B", "%X", +__LINE__, 0x00a768b6L, "0A768B6", "%-6.7X", +__LINE__, 0x1c665b48L, "0X1C665B48", "% #X", +__LINE__, -0x000037dL, "-000893", "%3.6d", +__LINE__, 0x29890443L, "29890443", "%+0x", +__LINE__, 0x000000e5L, "e5 ", "%-4x", +__LINE__, 0xfff2b5faL, "FFF2B5FA", "%X", +__LINE__, -0x5d32c2bL, "-97725483", "%05ld", +__LINE__, -0x00016c5L, " -05829", "%+#7.5ld", +__LINE__, 0x00000644L, "644", "%X", +__LINE__, -0x018c027L, "-1622055", "%+.1d", +__LINE__, 0x0000013cL, "0x13c", "%#x", +__LINE__, 0x00000009L, "+9", "%+#ld", +__LINE__, 0x00000000L, "0", "%ld", +__LINE__, -0x018eb19L, "-1633049", "%4.3ld", +__LINE__, 0xfffff429L, "FFFFF429", "% X", +__LINE__, 0x0032de67L, "32DE67", "%X", +__LINE__, 0x0016bdfaL, " 1490426", "% .2ld", +__LINE__, 0x00000065L, "65", "%+.0X", +__LINE__, 0x00000072L, " 72", "%+4.2X", +__LINE__, 0x00075119L, "75119", "%2x", +__LINE__, 0x000000b8L, "b8", "%x", +__LINE__, 0x000000d0L, "d0", "%x", +__LINE__, 0x000000b9L, "b9", "%x", +__LINE__, 0x003fda9dL, " 4184733", "% #3.d", +__LINE__, 0x00029a24L, "170532", "%4.d", +__LINE__, -0x132a337dL, "-321532797", "% ld", +__LINE__, 0x0000047aL, "0X47A", "%-#X", +__LINE__, 0x00000000L, "0", "%-ld", +__LINE__, -0x0d9750bL, "-14251275", "% ld", +__LINE__, 0x00029d6cL, "29d6c", "%x", +__LINE__, 0xfb060cc0L, "fb060cc0", "%x", +__LINE__, 0xffffd524L, "0XFFFFD524", "%#X", +__LINE__, 0xffffff30L, "ffffff30", "%-5x", +__LINE__, 0x00001650L, "0005712", "%#0.7d", +__LINE__, 0x0000b702L, "0B702", "%03.5X", +__LINE__, 0x000003c1L, "3c1", "% .1x", +__LINE__, -0x0290412L, "-2688018", "%d", +__LINE__, -0x00008bfL, "-2239", "%#d", +__LINE__, -0x0000001L, "-1", "%d", +__LINE__, 0x0001d750L, "1D750", "%-X", +__LINE__, 0x006eee92L, "6EEE92", "%-X", +__LINE__, 0xff812b02L, "ff812b02", "%0x", +__LINE__, 0xfffffeacL, "FFFFFEAC", "%+0X", +__LINE__, 0x000003a5L, "3a5", "%x", +__LINE__, -0x15270ceeL, "-354880750", "%2.ld", +__LINE__, 0x06b686d2L, "6b686d2", "%0x", +__LINE__, 0xffe9cdccL, "ffe9cdcc", "%x", +__LINE__, 0x0ecb168eL, "ecb168e", "%x", +__LINE__, 0x00000051L, "51", "%-X", +__LINE__, -0x0018860L, "-100448", "%-0d", +__LINE__, 0x8f08b82bL, "0x8f08b82b", "%-#.5x", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, 0x0000000eL, "e", "%+01x", +__LINE__, 0x04cf15bcL, " 80680380", "% #ld", +__LINE__, 0x50006e8aL, "50006e8a", "%x", +__LINE__, 0x0002f669L, "194153", "%0d", +__LINE__, 0x000000a6L, " 166", "% 5.ld", +__LINE__, -0x04036bbL, "-4208315", "%7.5d", +__LINE__, 0x00070deaL, "70DEA", "%+X", +__LINE__, 0x00000964L, "0x964", "%#x", +__LINE__, 0x0000004dL, "0x4d", "% #3.x", +__LINE__, -0x0000001L, "-1", "%-0d", +__LINE__, 0x0000043eL, "1086", "%ld", +__LINE__, -0x0000001L, "-1", "%-d", +__LINE__, 0x00000000L, "+0", "%+d", +__LINE__, 0xfffe68d9L, "FFFE68D9", "%7.X", +__LINE__, -0x0169199L, "-1479065", "%#.5ld", +__LINE__, -0x000003dL, "-61", "%ld", +__LINE__, 0x00000001L, "+1", "%+.1d", +__LINE__, 0x0001a65dL, "1a65d", "%.5x", +__LINE__, 0x00000141L, "+000321", "%+#5.6ld", +__LINE__, 0x00000000L, " 0", "%4x", +__LINE__, 0x00000408L, "1032", "%-2.3ld", +__LINE__, 0xffffffedL, "FFFFFFED", "%-X", +__LINE__, 0xfe832351L, "FE832351", "% .4X", +__LINE__, 0x003a421bL, "3A421B", "%-X", +__LINE__, -0x53ed7f25L, "-1408073509", "%ld", +__LINE__, -0x0000003L, "-0003", "%-5.4ld", +__LINE__, 0x00000ad0L, " 2768", "%7d", +__LINE__, 0xfffaf30bL, "FFFAF30B", "%X", +__LINE__, 0x006349d3L, " 6506963", "% 6.2ld", +__LINE__, 0x07f0146aL, "7f0146a", "%+3.4x", +__LINE__, -0x0000002L, " -2", "% 3.ld", +__LINE__, -0x26e94f3L, "-40801523", "%-#ld", +__LINE__, -0x0000004L, " -004", "%7.3d", +__LINE__, 0xfffe8cc9L, "FFFE8CC9", "%0X", +__LINE__, 0x00000018L, " 18", "%5.x", +__LINE__, -0x4941de83L, "-1229053571", "% 0.5ld", +__LINE__, 0x00000000L, " 0", "%6ld", +__LINE__, 0xfffffffeL, "0XFFFFFFFE", "%-#X", +__LINE__, -0x0142ae1L, "-1321697", "%4.ld", +__LINE__, -0x0319e7fL, "-3251839", "%0ld", +__LINE__, 0x000004ffL, " 4FF", "%7.2X", +__LINE__, -0x0001c3eL, "-7230", "%#.2ld", +__LINE__, 0xffffe522L, "ffffe522", "%x", +__LINE__, 0x0001d1cbL, "+119243", "%+.3ld", +__LINE__, 0xfad19d52L, "FAD19D52", "%+X", +__LINE__, 0x00002a7cL, " 10876", "% 0.ld", +__LINE__, 0x00001449L, "1449", "%X", +__LINE__, 0x000732b8L, "471736", "%d", +__LINE__, -0x211a496eL, "-555370862", "%ld", +__LINE__, -0x0000004L, "-4", "%1.d", +__LINE__, 0x0295c03dL, "43368509", "%5.ld", +__LINE__, 0x01fa5722L, "33183522", "%0ld", +__LINE__, 0xfffbff62L, "0xfffbff62", "%#x", +__LINE__, 0x000000f5L, " 245", "% 2.d", +__LINE__, 0x000000a0L, "160", "%-d", +__LINE__, 0x0000000fL, "15", "%.2ld", +__LINE__, 0x0bf5f077L, "+200667255", "%+ld", +__LINE__, -0x14d3e5aL, "-21839450", "%#2.3d", +__LINE__, -0x21cbe656L, "-567010902", "%ld", +__LINE__, 0x000002b9L, "697", "%ld", +__LINE__, 0xfffff9b0L, "FFFFF9B0", "%X", +__LINE__, 0x007fd9c7L, "8378823", "%3.4d", +__LINE__, 0x00036d06L, "36d06", "%x", +__LINE__, 0xffde8052L, "FFDE8052", "%4.6X", +__LINE__, 0x0000000dL, "13", "%#d", +__LINE__, 0x68157d93L, "68157d93", "%x", +__LINE__, 0x00000005L, "5", "%1x", +__LINE__, 0xfffffff4L, "FFFFFFF4", "%X", +__LINE__, 0xf5bbf7e9L, "f5bbf7e9", "%+.1x", +__LINE__, 0x0be98f98L, "BE98F98", "%X", +__LINE__, 0x00000122L, "00122", "%.5X", +__LINE__, -0x0000936L, "-2358", "%+#3.0ld", +__LINE__, 0xfd230f09L, "FD230F09", "%-7X", +__LINE__, 0x00000089L, "137", "%ld", +__LINE__, 0x00000078L, " 120", "%7d", +__LINE__, -0x68ef2b6bL, "-1760504683", "%-ld", +__LINE__, 0xc24480bbL, "C24480BB", "%+4X", +__LINE__, 0xfefe36a2L, "FEFE36A2", "%0X", +__LINE__, -0x35344baL, "-55788730", "%7.d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%+.6X", +__LINE__, -0x0000f40L, "-3904", "% ld", +__LINE__, 0xfffffffbL, "FFFFFFFB", "%X", +__LINE__, 0x58b37c4bL, "58b37c4b", "%2.2x", +__LINE__, 0x000000e2L, "226", "%#ld", +__LINE__, 0xfff5ebdeL, "fff5ebde", "%-7.1x", +__LINE__, 0x0c6ea9beL, "208579006", "%-ld", +__LINE__, 0xff708c74L, "FF708C74", "% 4.X", +__LINE__, 0x00000000L, " 0", "% 3X", +__LINE__, 0x00000004L, " 4", "%03.d", +__LINE__, 0x0919be7cL, "+152682108", "%+6.d", +__LINE__, 0x00d4fd1eL, "13958430", "%0d", +__LINE__, 0xfe77a69eL, "fe77a69e", "%-7.x", +__LINE__, 0x284ded44L, "676195652", "%-#2ld", +__LINE__, -0x00006e6L, "-1766", "% ld", +__LINE__, -0x7dac7eaL, "-131778538", "%.0ld", +__LINE__, 0x0003c50fL, "247055", "%#d", +__LINE__, 0xfffffffcL, "fffffffc", "%-x", +__LINE__, 0xfe0f0d1fL, "fe0f0d1f", "% 5.1x", +__LINE__, 0x00000009L, "9", "%0ld", +__LINE__, -0x0175cc1L, "-1531073", "%-04.d", +__LINE__, 0x000e4da2L, " 937378", "% 4.ld", +__LINE__, 0x00000762L, "762", "%-0.X", +__LINE__, 0x005211bfL, "5211bf", "%-x", +__LINE__, 0xfffffffbL, "fffffffb", "%+2.6x", +__LINE__, 0x00008862L, "34914", "%ld", +__LINE__, 0xfffc9754L, "fffc9754", "%+x", +__LINE__, 0x0000716eL, "716E", "%X", +__LINE__, 0x000000a8L, "a8", "%x", +__LINE__, 0xffff84f5L, "ffff84f5", "%0x", +__LINE__, 0x00005032L, "5032", "%x", +__LINE__, 0xffe242b4L, "ffe242b4", "%6x", +__LINE__, 0x002df9bdL, "3013053", "%ld", +__LINE__, 0xffffe267L, "FFFFE267", "%.5X", +__LINE__, 0xffffffc7L, "0xffffffc7", "%#x", +__LINE__, -0x1727c38L, "-24280120", "%d", +__LINE__, 0x01308072L, "1308072", "%x", +__LINE__, -0x5883c7cL, "-92814460", "%+ld", +__LINE__, 0x000030adL, "30ad", "%x", +__LINE__, 0xffffffffL, "FFFFFFFF", "%X", +__LINE__, -0x2090a708L, "-546350856", "% d", +__LINE__, 0x0024e6b4L, "2418356", "%#ld", +__LINE__, 0x02db71acL, "2DB71AC", "% 6.3X", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%2.7X", +__LINE__, -0x000074eL, " -1870", "%7.ld", +__LINE__, -0x0011d84L, "-73092", "%d", +__LINE__, 0x00160723L, "160723", "%1.3x", +__LINE__, 0x00412929L, "4270377", "%-d", +__LINE__, -0x0008fc6L, "-36806", "% d", +__LINE__, 0x00000002L, "2", "%d", +__LINE__, 0x0eb67ffaL, "eb67ffa", "%.4x", +__LINE__, 0x05b86c3cL, "95972412", "%4.4d", +__LINE__, 0xffffca9cL, "FFFFCA9C", "% 4.X", +__LINE__, 0x0007d571L, "7d571", "%-0x", +__LINE__, -0x000239bL, "-09115", "%5.5d", +__LINE__, -0x0000155L, " -341", "%5.3ld", +__LINE__, 0x00000034L, "34", "%x", +__LINE__, -0x0000051L, "-81", "%.1ld", +__LINE__, 0x309bbbe0L, "309bbbe0", "%x", +__LINE__, 0x0075be1eL, " 7716382", "% #ld", +__LINE__, 0x000002d5L, "2d5", "%x", +__LINE__, 0x006b466dL, "6B466D", "%-0X", +__LINE__, 0x01d6c30fL, "1D6C30F", "%4.X", +__LINE__, 0x00000003L, " 3", "%07.x", +__LINE__, 0xfffcc102L, "FFFCC102", "%6.X", +__LINE__, 0xffffffffL, "0XFFFFFFFF", "%#X", +__LINE__, 0xfffffffeL, "fffffffe", "%+x", +__LINE__, 0x00000005L, "5", "%ld", +__LINE__, 0xff060284L, "ff060284", "%x", +__LINE__, 0x007a3325L, "7A3325", "%-X", +__LINE__, 0xf5f595bdL, "F5F595BD", "%0X", +__LINE__, 0xfffa3a10L, "FFFA3A10", "%0X", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, -0x15078f9L, "-22051065", "%7d", +__LINE__, -0x0000002L, "-000002", "%.6d", +__LINE__, 0x00000036L, "54", "%1.1ld", +__LINE__, -0xbbecf6aL, "-197054314", "%ld", +__LINE__, 0x0000043dL, "43D", "%X", +__LINE__, 0xfffffffaL, "0xfffffffa", "% #6.x", +__LINE__, 0x016759f8L, "23550456", "%0.ld", +__LINE__, 0x000052d2L, "+21202", "%+6.2d", +__LINE__, -0x007d232L, "-512562", "%ld", +__LINE__, 0x00240be0L, "2362336", "%.1d", +__LINE__, -0x0000001L, "-1", "%0d", +__LINE__, 0xfffffffaL, "FFFFFFFA", "%X", +__LINE__, -0x0000e88L, "-3720", "%ld", +__LINE__, 0xfffffa9bL, "FFFFFA9B", "%.5X", +__LINE__, 0x09296eebL, "153710315", "%-1.0d", +__LINE__, 0x001f46fcL, "0X1F46FC", "%#X", +__LINE__, 0x00000006L, "6", "%X", +__LINE__, 0xffffff87L, "0XFFFFFF87", "%+#X", +__LINE__, 0x00000469L, "0469", "%04X", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, 0x00000000L, "", "%.0ld", +__LINE__, -0x52bc137L, "-86753591", "%-#3ld", +__LINE__, -0x2bddb08L, "-45996808", "%-3.d", +__LINE__, 0x041367f7L, "41367F7", "%+X", +__LINE__, -0x0018eb5L, "-102069", "%+ld", +__LINE__, -0x0000537L, "-1335", "%#ld", +__LINE__, -0x6f159ff4L, "-1863688180", "%+1.d", +__LINE__, 0x00112ac8L, "0X112AC8", "%#6.3X", +__LINE__, 0x00000000L, " ", "%3.d", +__LINE__, 0x0008afe8L, "08afe8", "%+3.6x", +__LINE__, 0x00000015L, "21", "%ld", +__LINE__, -0x02b7130L, "-2847024", "% #2.4d", +__LINE__, 0xffffffd0L, "FFFFFFD0", "%X", +__LINE__, -0x6970fa1L, "-110563233", "%+#.4ld", +__LINE__, 0x06387dccL, "0X6387DCC", "%-#X", +__LINE__, 0xffffd506L, "ffffd506", "%+6x", +__LINE__, -0x00fe5cdL, "-1041869", "%-#7d", +__LINE__, -0x0c35bf6L, "-12803062", "%-03d", +__LINE__, -0x0020d89L, "-134537", "%#d", +__LINE__, -0x0c7aed3L, "-13086419", "%-ld", +__LINE__, -0x000362aL, "-13866", "%#.4ld", +__LINE__, -0x02d05f0L, "-2950640", "%#ld", +__LINE__, 0x02de1321L, "0x2de1321", "%#7.x", +__LINE__, 0xffb56428L, "0xffb56428", "%#x", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%X", +__LINE__, 0xf072292dL, "F072292D", "%.5X", +__LINE__, -0x0f4b0f2L, "-16036082", "%.5ld", +__LINE__, 0x01b81885L, "28842117", "%5d", +__LINE__, -0x009cfa6L, "-642982", "%d", +__LINE__, 0xfffffffdL, "0XFFFFFFFD", "%-#.5X", +__LINE__, 0x0dc97a66L, "DC97A66", "%2.X", +__LINE__, 0x000000beL, "190", "%.0d", +__LINE__, 0xffffe1c7L, "FFFFE1C7", "% X", +__LINE__, 0x01883b9aL, "1883b9a", "%3x", +__LINE__, 0xffffdde1L, "ffffdde1", "%+x", +__LINE__, 0x2f1b4e32L, "+790318642", "%+ld", +__LINE__, 0x000129aaL, "129aa", "%x", +__LINE__, -0x00092c2L, "-37570", "%d", +__LINE__, 0x00070fbdL, "70fbd", "%x", +__LINE__, -0x00000eaL, "-234", "%+4ld", +__LINE__, 0xfffffffeL, "fffffffe", "%x", +__LINE__, 0x0091c7f7L, "91C7F7", "% .3X", +__LINE__, -0x0c14fe2L, "-12668898", "%d", +__LINE__, -0x0017c15L, "-97301", "%d", +__LINE__, -0x00005d0L, "-0001488", "%5.7d", +__LINE__, 0x0114c36eL, "18137966", "%0d", +__LINE__, 0xffffffffL, "ffffffff", "%+x", +__LINE__, 0x0ac76e78L, "180842104", "%d", +__LINE__, 0x001976cdL, " 1668813", "% 4.ld", +__LINE__, -0x0642319L, "-6562585", "% d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%X", +__LINE__, -0x035019dL, "-3473821", "%.7d", +__LINE__, -0x0000061L, "-97", "%#3.d", +__LINE__, 0x0000001fL, " 31", "% 6.1ld", +__LINE__, -0x0000024L, "-36", "%d", +__LINE__, 0x000b3785L, "735109", "%ld", +__LINE__, 0xfffffda9L, "fffffda9", "%-x", +__LINE__, 0x00254832L, "2443314", "%-ld", +__LINE__, 0xfffffd40L, "FFFFFD40", "%0X", +__LINE__, -0x0006105L, "-24837", "%+#d", +__LINE__, 0x00000006L, "+6", "%+d", +__LINE__, 0xffd40fd8L, "ffd40fd8", "%3.x", +__LINE__, -0x000988eL, "-39054", "%03d", +__LINE__, 0x0005ad8bL, "5AD8B", "%0.0X", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, 0xfe1f59b7L, "fe1f59b7", "%4.x", +__LINE__, -0x0000022L, "-34", "%#d", +__LINE__, 0x0018e3e9L, "18E3E9", "% X", +__LINE__, 0xffffff25L, "FFFFFF25", "%2.X", +__LINE__, -0x00002c6L, "-710", "%1.ld", +__LINE__, 0x00009765L, "38757", "%5ld", +__LINE__, 0xfe197646L, "FE197646", "%-X", +__LINE__, 0x00000001L, " 1", "%+5.x", +__LINE__, -0x0000002L, "-2", "%#ld", +__LINE__, 0x0072f6beL, "72F6BE", "%1X", +__LINE__, -0x000f06dL, "-61549", "%-d", +__LINE__, 0x00000001L, " 1", "%5X", +__LINE__, 0x328cba28L, " 848083496", "% 2.ld", +__LINE__, 0x0000cddcL, "cddc", "%.1x", +__LINE__, 0xfffffff9L, "fffffff9", "%7x", +__LINE__, 0x00baf511L, "BAF511", "%-5.6X", +__LINE__, 0x00000001L, " 1", "%4.ld", +__LINE__, 0x0001e4b0L, "+124080", "%+ld", +__LINE__, -0x07548f3L, "-7686387", "% 6.d", +__LINE__, -0x01b14eaL, "-1774826", "% #0d", +__LINE__, -0x000005cL, "-92 ", "%-04ld", +__LINE__, -0x00000aeL, "-174", "%+.3ld", +__LINE__, 0x0000008cL, "0X8C", "%+#X", +__LINE__, 0x14c02360L, "14C02360", "%.6X", +__LINE__, 0xfffffff6L, "FFFFFFF6", "%X", +__LINE__, 0x009f4ee5L, "9f4ee5", "%x", +__LINE__, 0x00000035L, "35", "%X", +__LINE__, -0x00000ebL, "-235", "%ld", +__LINE__, 0x1552ced8L, "1552CED8", "%04X", +__LINE__, 0x0000002aL, " 2A", "%5X", +__LINE__, 0xffffffffL, "ffffffff", "% x", +__LINE__, -0xdec0db2L, "-233573810", "%d", +__LINE__, 0x001e2ef0L, "1978096", "%2.d", +__LINE__, 0xffffef24L, "ffffef24", "%.5x", +__LINE__, 0xfffe6a6cL, "fffe6a6c", "%+x", +__LINE__, -0x0000004L, "-4", "% ld", +__LINE__, 0xfe3c6743L, "fe3c6743", "%.1x", +__LINE__, 0x0000033dL, "829", "%0ld", +__LINE__, -0x00006a0L, " -1696", "% 7.ld", +__LINE__, 0xffffffdbL, "ffffffdb", "%0.0x", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%3.3X", +__LINE__, -0x0000004L, "-4", "%#ld", +__LINE__, 0x00b32b56L, "B32B56", "%X", +__LINE__, 0xffffffffL, "0xffffffff", "%+#x", +__LINE__, 0x01cd1a48L, "1cd1a48", "%+7x", +__LINE__, 0xffffffdaL, "ffffffda", "%x", +__LINE__, 0x1886509eL, "1886509E", "% X", +__LINE__, 0x000000ebL, "235", "%0d", +__LINE__, 0xfffffff4L, "fffffff4", "%0x", +__LINE__, 0x00000547L, "547", "% X", +__LINE__, 0x000017e6L, "17e6", "%-2.x", +__LINE__, 0x00001dc4L, "7620", "%d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%3.0X", +__LINE__, 0xffff93faL, "0XFFFF93FA", "%#X", +__LINE__, 0xfffffe1cL, "FFFFFE1C", "%-X", +__LINE__, 0x00000000L, "", "% .0x", +__LINE__, 0x000000a1L, "A1", "%X", +__LINE__, 0xffffffffL, "0xffffffff", "%#x", +__LINE__, -0x0001460L, "-05216", "%+#.5d", +__LINE__, 0x00000001L, "1 ", "%-6.x", +__LINE__, 0xfffd5324L, "FFFD5324", "%+2.6X", +__LINE__, 0x00000007L, " 07", "%06.2d", +__LINE__, 0x00000003L, "3", "%-X", +__LINE__, 0xfffffdb7L, "0XFFFFFDB7", "%+#X", +__LINE__, 0xfffff4ccL, "fffff4cc", "%0x", +__LINE__, 0x00000000L, "0 ", "%-5X", +__LINE__, 0x00758c96L, "758C96", "%X", +__LINE__, -0x0000001L, "-1", "%-ld", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, 0x03f03cafL, "66075823", "%.2ld", +__LINE__, 0x0000a87cL, "a87c", "%1.x", +__LINE__, 0x00000034L, "34", "%X", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0x00010167L, "10167", "%x", +__LINE__, -0x00007ceL, "-1998 ", "%-6ld", +__LINE__, 0x00000001L, "1", "%.0d", +__LINE__, 0x00d94ceeL, "14241006", "%ld", +__LINE__, -0x0000008L, "-8", "% d", +__LINE__, -0x71520839L, "-1901201465", "%+0d", +__LINE__, 0x0000035aL, "35a", "%-x", +__LINE__, 0xfffd2f68L, "FFFD2F68", "%-X", +__LINE__, 0x0006ea53L, "453203", "%1d", +__LINE__, 0x000000dfL, "DF", "% 1X", +__LINE__, 0xfffffffeL, "fffffffe", "% 7x", +__LINE__, 0x00000156L, "156", "% X", +__LINE__, 0x00037ac9L, " 228041", "% ld", +__LINE__, 0xffffffdeL, "FFFFFFDE", "%0.5X", +__LINE__, 0x00000025L, "37", "%-0.ld", +__LINE__, -0x4133686L, "-68368006", "%2ld", +__LINE__, -0x000003bL, "-59", "%.2ld", +__LINE__, 0xfffff910L, "fffff910", "% 00.0x", +__LINE__, 0xff9ec802L, "FF9EC802", "%2.6X", +__LINE__, 0x00000008L, "0X8", "%#1X", +__LINE__, 0xfffffff7L, "FFFFFFF7", "%-X", +__LINE__, 0x0029a4daL, "2729178", "%04.ld", +__LINE__, 0x007d1588L, "8197512", "%#d", +__LINE__, 0x0007e86dL, "518253", "%0d", +__LINE__, 0xfffffff9L, "fffffff9", "%x", +__LINE__, 0x00000002L, "002", "%.3d", +__LINE__, 0x00006ec1L, "6EC1", "%2X", +__LINE__, 0x0000300cL, "12300", "%-d", +__LINE__, -0x0000002L, "-2", "%+ld", +__LINE__, -0x0000002L, "-2", "%ld", +__LINE__, -0x00015d5L, "-005589", "%#.6ld", +__LINE__, 0x00000041L, "65", "%d", +__LINE__, 0x00000229L, "0000229", "% 0.7x", +__LINE__, 0xfffffffbL, "fffffffb", "%03.x", +__LINE__, 0x00093262L, "0602722", "%.7d", +__LINE__, -0x00037b4L, "-14260", "%-0ld", +__LINE__, 0xfffffffcL, "fffffffc", "%-x", +__LINE__, 0xf24cb3e6L, "f24cb3e6", "%1x", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xfffffffbL, "FFFFFFFB", "%0X", +__LINE__, 0x00000031L, "0000049", "%00.7ld", +__LINE__, 0x00000bb3L, "BB3", "%.1X", +__LINE__, -0x0000001L, "-0001", "%+#4.4ld", +__LINE__, -0x0000001L, "-1", "% d", +__LINE__, 0x00022c0cL, "22c0c", "%-x", +__LINE__, 0xffffffd4L, "ffffffd4", "%x", +__LINE__, 0x000729c6L, "469446", "%3.d", +__LINE__, 0xb180feaeL, "b180feae", "%3.x", +__LINE__, 0x124fac15L, "307211285", "%-0ld", +__LINE__, -0x0000004L, "-4", "%ld", +__LINE__, 0x0000006aL, "106", "%#d", +__LINE__, 0x0000297fL, "297F", "%+3X", +__LINE__, 0x0000000eL, "14", "%0ld", +__LINE__, 0x00000027L, "27", "%0.1X", +__LINE__, 0xffeb98ebL, "ffeb98eb", "% 05.2x", +__LINE__, 0xfffff19bL, "FFFFF19B", "%+X", +__LINE__, 0x00025992L, "154002", "%6.6d", +__LINE__, 0x00000040L, " 040", "%6.3X", +__LINE__, 0x00000a9eL, " 0a9e", "%5.4x", +__LINE__, 0x00c7f2ccL, "c7f2cc", "%x", +__LINE__, 0x000325e6L, " 325E6", "%6.X", +__LINE__, -0x69faad3L, "-111127251", "%d", +__LINE__, -0x059a307L, "-5874439", "% ld", +__LINE__, 0xfffffff6L, "0xfffffff6", "%#0.0x", +__LINE__, 0x0030fdf3L, "30fdf3", "%x", +__LINE__, 0x00007343L, "+29507", "%+#2d", +__LINE__, 0x0003cf4bL, "0X3CF4B", "% #.2X", +__LINE__, 0x00000433L, "+1075", "%+0ld", +__LINE__, 0xfffffffdL, "fffffffd", "%+.3x", +__LINE__, 0x0ae30c4eL, "ae30c4e", "%+00x", +__LINE__, 0x0002540fL, "02540f", "%-.6x", +__LINE__, -0x0000001L, " -01", "% #5.2ld", +__LINE__, 0xffffffe7L, "0xffffffe7", "% #5.x", +__LINE__, 0x0000005bL, "91", "%d", +__LINE__, 0x00001f9bL, "8091", "%.4ld", +__LINE__, 0xfffff315L, "fffff315", "%4.x", +__LINE__, -0x130eec41L, "-319745089", "% ld", +__LINE__, 0xfff8fe13L, "FFF8FE13", "%X", +__LINE__, -0x0000004L, "-00004", "%5.5d", +__LINE__, 0x00000669L, "669", "%0X", +__LINE__, -0x0000004L, "-4", "%d", +__LINE__, 0xf5e81496L, "F5E81496", "% 6X", +__LINE__, -0x0000001L, "-1", "% 0d", +__LINE__, 0xfffffff7L, "fffffff7", "%x", +__LINE__, 0x000001deL, "478", "%d", +__LINE__, 0x0000623eL, "25150", "%5.0d", +__LINE__, 0xffffffa8L, "FFFFFFA8", "%+X", +__LINE__, -0x0000117L, "-279", "% ld", +__LINE__, -0x0000517L, "-1303", "%d", +__LINE__, 0xfffff9d5L, "fffff9d5", "% x", +__LINE__, 0x000001ccL, "1CC", "%-X", +__LINE__, 0x0000019aL, "0000410", "%.7d", +__LINE__, 0x00000003L, "3 ", "%-06X", +__LINE__, 0x00000009L, "0x9", "%#0x", +__LINE__, 0xfd544610L, "0XFD544610", "% #X", +__LINE__, 0xfffffffcL, "fffffffc", "%+x", +__LINE__, 0x00009437L, "37943", "%ld", +__LINE__, -0x00b5ea6L, "-745126", "%d", +__LINE__, 0xffffffd8L, "ffffffd8", "%6x", +__LINE__, 0x00002a2dL, "10797", "%.3ld", +__LINE__, 0x00275238L, "2576952", "%0ld", +__LINE__, 0xfff90a34L, "FFF90A34", "%-7X", +__LINE__, 0xfffffffeL, "FFFFFFFE", "% .7X", +__LINE__, -0xb3b673eL, "-188442430", "% ld", +__LINE__, 0xfffff67aL, "0xfffff67a", "%#0.x", +__LINE__, 0x0000dff6L, " dff6", "%+7.x", +__LINE__, 0xffee46e3L, "ffee46e3", "%x", +__LINE__, 0x00001a66L, " 0006758", "% 7.7d", +__LINE__, 0x0002b475L, "2B475", "%.4X", +__LINE__, 0x0002090dL, "002090d", "%.7x", +__LINE__, -0x0057838L, "-358456", "%#ld", +__LINE__, 0x00000004L, "0x4", "%#x", +__LINE__, 0x0574cb62L, "91540322", "%#7d", +__LINE__, -0x0054388L, "-344968", "% #d", +__LINE__, 0x000421c2L, "421C2", "% X", +__LINE__, 0x00000003L, "3", "%0d", +__LINE__, 0xffffe2e2L, "ffffe2e2", "% 5.x", +__LINE__, 0x00000021L, "+33", "%+d", +__LINE__, -0x0020033L, "-131123", "%ld", +__LINE__, -0x0000001L, " -1", "%4.ld", +__LINE__, 0x000000fdL, "000fd", "%3.5x", +__LINE__, 0x023e4337L, "37634871", "%1d", +__LINE__, 0x6e823d96L, "6E823D96", "% X", +__LINE__, 0xfff0e133L, "fff0e133", "%x", +__LINE__, -0x000deccL, "-57036", "%3d", +__LINE__, 0x004397b8L, "4429752", "%0d", +__LINE__, -0x0000023L, " -35", "%6d", +__LINE__, 0xffe701caL, "FFE701CA", "%3X", +__LINE__, 0x000c0319L, "+787225", "%+.6d", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xfffffe1dL, "FFFFFE1D", "%X", +__LINE__, 0xfffffb33L, "fffffb33", "%x", +__LINE__, 0x02b5e30aL, "45474570", "%d", +__LINE__, 0x000074ebL, "29931", "%03.ld", +__LINE__, -0x4e42e310L, "-1313006352", "%-0.d", +__LINE__, -0x000007bL, "-123", "%d", +__LINE__, 0x00000160L, " 352", "% d", +__LINE__, -0x16af31ecL, "-380580332", "%#ld", +__LINE__, -0x000006eL, "-000110", "%07ld", +__LINE__, 0x232699a0L, "232699a0", "%7.x", +__LINE__, 0x00f9b8e5L, "+16365797", "%+0d", +__LINE__, 0x0000000cL, "C", "%X", +__LINE__, 0xfffffd4fL, "FFFFFD4F", "%X", +__LINE__, 0xffffe7bbL, "FFFFE7BB", "%.7X", +__LINE__, -0x0000163L, "-355", "%d", +__LINE__, 0x00070315L, " 459541", "% #2.d", +__LINE__, -0x7d5c12aL, "-131449130", "% 6.ld", +__LINE__, 0xffffffb2L, "FFFFFFB2", "%X", +__LINE__, -0x0004aadL, "-19117", "%+6.4ld", +__LINE__, 0x00115586L, "1136006", "%0d", +__LINE__, -0x0000021L, "-33", "%d", +__LINE__, 0x093ce01eL, "93ce01e", "% 5x", +__LINE__, 0x00672135L, "672135", "% x", +__LINE__, 0x05f4abd5L, "0x5f4abd5", "%+#6.x", +__LINE__, -0x0448b03L, "-4492035", "%-0.2ld", +__LINE__, 0x00000000L, "0", "%#x", +__LINE__, 0x1987217eL, "428286334", "%d", +__LINE__, 0x000010f6L, "10f6", "%-x", +__LINE__, 0x0000177aL, "177a", "%1x", +__LINE__, 0xfffffefdL, "FFFFFEFD", "%7X", +__LINE__, -0x095cbf8L, "-9817080", "%-5ld", +__LINE__, 0x0000008aL, "138", "%2.0ld", +__LINE__, 0xfffe80adL, "fffe80ad", "%0x", +__LINE__, -0x1a4c8f7L, "-27576567", "%d", +__LINE__, 0x00000000L, "0", "%-x", +__LINE__, 0x0000a82bL, "43051", "%-ld", +__LINE__, 0x000000ebL, "235", "%2.3ld", +__LINE__, -0x0002747L, "-10055", "%d", +__LINE__, 0x00000319L, "0X319", "%#X", +__LINE__, 0xfffffcfeL, "FFFFFCFE", "% X", +__LINE__, 0x00050f0eL, "50f0e", "%-1x", +__LINE__, -0x398e09eL, "-60350622", "%0.7ld", +__LINE__, 0x00000000L, " ", "%2.ld", +__LINE__, 0x00000049L, "00049", "% .5X", +__LINE__, -0x00000ddL, " -221", "%+#5ld", +__LINE__, 0xf6db2facL, "f6db2fac", "%-07x", +__LINE__, 0x0000004fL, "4F", "% .0X", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xfd07f692L, "fd07f692", "%x", +__LINE__, 0xdb98bde0L, "db98bde0", "%x", +__LINE__, 0x00000271L, "0271", "% 3.4x", +__LINE__, -0x000115aL, "-4442", "%#1.ld", +__LINE__, 0x0002f5f2L, "194034", "%ld", +__LINE__, -0x0000152L, " -338", "%+7ld", +__LINE__, 0x00059336L, "365366", "%d", +__LINE__, 0xfffffff6L, "fffffff6", "%-7x", +__LINE__, 0xfb916c51L, "fb916c51", "%-x", +__LINE__, 0xffff413dL, "FFFF413D", "%-X", +__LINE__, 0xf2576910L, "F2576910", "%-4.X", +__LINE__, 0xfffc7730L, "fffc7730", "%5.x", +__LINE__, 0x000002e6L, "+742", "%+1d", +__LINE__, -0x00001bfL, "-447", "%3d", +__LINE__, 0x000002e1L, "2E1", "%-X", +__LINE__, 0x00000096L, "150", "%#0ld", +__LINE__, 0x000002bdL, "701", "%d", +__LINE__, -0x0053386L, "-340870", "%#d", +__LINE__, 0xfffdb076L, "FFFDB076", "%X", +__LINE__, 0x00004dc5L, " +19909", "%+07.ld", +__LINE__, 0x00000f7aL, " F7A", "%4X", +__LINE__, 0x02405000L, " 37769216", "% ld", +__LINE__, 0xfffce68dL, "fffce68d", "%0x", +__LINE__, -0x35b3af2L, "-56310514", "%-ld", +__LINE__, -0x0238631L, "-2328113", "%.4d", +__LINE__, -0x000001eL, "-030", "%.3ld", +__LINE__, 0xffffffddL, "FFFFFFDD", "%.4X", +__LINE__, 0x0013f6acL, "13f6ac", "%02.x", +__LINE__, 0xfffffffaL, "fffffffa", "%+07.x", +__LINE__, -0x000192bL, " -6443", "%6.d", +__LINE__, 0x0000058bL, "+1419", "%+d", +__LINE__, 0x00001391L, "5009", "%ld", +__LINE__, -0x0041a57L, "-268887", "%1ld", +__LINE__, 0xfffff266L, "0xfffff266", "%+#6.6x", +__LINE__, 0x0000018bL, " 395", "%6.ld", +__LINE__, 0x009ae24dL, "+10150477", "%+ld", +__LINE__, 0x0000007eL, "7E", "%X", +__LINE__, 0xfffffd53L, "FFFFFD53", "% 0X", +__LINE__, 0x000002faL, "2FA", "%-1.3X", +__LINE__, 0x000000a4L, "164", "%0d", +__LINE__, 0x00001833L, "6195", "%ld", +__LINE__, -0x0000001L, "-1", "%d", +__LINE__, 0xf2fcbd9bL, "F2FCBD9B", "%+0.2X", +__LINE__, 0x00004a8aL, "4A8A", "%X", +__LINE__, -0x10695cdaL, "-275340506", "%d", +__LINE__, 0x00000037L, "37", "%X", +__LINE__, 0x00082d5cL, "82D5C", "%+0.5X", +__LINE__, 0xfffffe01L, "fffffe01", "% 5.3x", +__LINE__, 0x000005eaL, "05EA", "% 1.4X", +__LINE__, 0x0e0b8826L, "e0b8826", "%2x", +__LINE__, -0x0000161L, "-353", "%+d", +__LINE__, 0x19e3014aL, "19E3014A", "%+5X", +__LINE__, 0x00000140L, "140", "%x", +__LINE__, 0xffff84b9L, "FFFF84B9", "%X", +__LINE__, -0x0005776L, "-22390", "%+5ld", +__LINE__, 0x0162ad61L, "162AD61", "% X", +__LINE__, 0x00002395L, "2395", "%X", +__LINE__, 0x003702ecL, "3605228", "%5.2d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%7X", +__LINE__, 0x00001778L, "0x1778", "%#5.x", +__LINE__, 0xc52bef7fL, "C52BEF7F", "%X", +__LINE__, 0xfffffec4L, "FFFFFEC4", "%X", +__LINE__, 0x00000006L, "6", "%X", +__LINE__, 0x00000000L, "000", "%03.3x", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xffff6c46L, "FFFF6C46", "% 2.2X", +__LINE__, -0x1506098L, "-22044824", "%01.d", +__LINE__, 0x03415cafL, "3415caf", "%x", +__LINE__, -0x00007b4L, "-1972", "%#4.4d", +__LINE__, -0x00158c9L, "-88265", "%03.4d", +__LINE__, 0x6947c336L, "1766310710", "%.6d", +__LINE__, 0x0000017cL, "17C", "% 0X", +__LINE__, -0x00001b7L, "-439", "% 0ld", +__LINE__, 0x06a7575aL, "6A7575A", "%-.0X", +__LINE__, 0x000b3459L, "734297", "%ld", +__LINE__, -0x395d8ddL, "-60152029", "%ld", +__LINE__, 0x00036bb3L, "224179", "%-6.d", +__LINE__, 0xffff14ffL, "FFFF14FF", "%X", +__LINE__, -0x15910e4fL, "-361827919", "%-0d", +__LINE__, -0x0000004L, "-4", "%#d", +__LINE__, 0xf7f7adacL, "F7F7ADAC", "% 3.X", +__LINE__, 0xffffff74L, "FFFFFF74", "%0X", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, -0x000007bL, "-123 ", "%-7.d", +__LINE__, -0x000002cL, "-44", "%d", +__LINE__, -0x000002bL, " -43", "%5d", +__LINE__, 0x0000ae5fL, "44639", "%d", +__LINE__, 0x003cbc63L, "3CBC63", "%X", +__LINE__, 0xfffffffcL, "0XFFFFFFFC", "%#5.7X", +__LINE__, 0x0003e044L, "3E044", "%X", +__LINE__, -0x0000c46L, "-3142", "%.1d", +__LINE__, 0xff18f4bbL, "FF18F4BB", "%0X", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%.1X", +__LINE__, -0x01c0f27L, "-1838887", "%0d", +__LINE__, -0x1242901fL, "-306352159", "%.4ld", +__LINE__, 0x1775c10aL, "393593098", "%6.ld", +__LINE__, 0x00000001L, " 1", "%03.d", +__LINE__, 0xfff1fd30L, "0xfff1fd30", "%#x", +__LINE__, 0x00000191L, "191", "%0.X", +__LINE__, 0x2e597178L, "777613688", "%2.ld", +__LINE__, -0x4ef0cf3L, "-82775283", "%+.6ld", +__LINE__, -0x0000085L, " -133", "%6.d", +__LINE__, 0x0000014dL, "333 ", "%-5ld", +__LINE__, -0xc03bd74L, "-201571700", "%07.6ld", +__LINE__, -0x000000aL, "-10", "%d", +__LINE__, 0x01f5e86eL, "32893038", "%#2.ld", +__LINE__, 0x00000033L, "0X33", "% #X", +__LINE__, 0x0087c797L, " 8898455", "% 7.d", +__LINE__, -0x0001205L, "-4613", "%5d", +__LINE__, 0x00000192L, " 192", "%7.X", +__LINE__, 0x000e6c00L, "945152", "%6.1ld", +__LINE__, 0x00018629L, " 99881", "% d", +__LINE__, -0x04739c6L, "-4667846", "%-01.3ld", +__LINE__, 0x00001f42L, "8002", "%d", +__LINE__, 0x00000cafL, "3247", "%d", +__LINE__, -0x4992e24L, "-77147684", "%#.6d", +__LINE__, 0x0000001dL, "1d", "%-0x", +__LINE__, 0x14d79f03L, "349675267", "%0ld", +__LINE__, 0x00000dd4L, " 03540", "%#6.5ld", +__LINE__, 0x0005f30eL, "0X5F30E", "%#X", +__LINE__, 0x00000157L, "157", "%X", +__LINE__, -0x9281698L, "-153622168", "%d", +__LINE__, -0x000004aL, "-74", "%d", +__LINE__, -0x0010c9eL, "-68766", "%-0d", +__LINE__, 0x00000059L, "00089", "%.5ld", +__LINE__, -0x06959e3L, "-6904291", "% 4.d", +__LINE__, 0xfbea12b1L, "0XFBEA12B1", "%+#X", +__LINE__, 0xffffdfb1L, "FFFFDFB1", "%2.6X", +__LINE__, 0x0434faacL, "434faac", "%.5x", +__LINE__, 0xffffffffL, "ffffffff", "% x", +__LINE__, 0x00000b32L, "B32", "%0X", +__LINE__, 0x00000047L, "71", "%.1d", +__LINE__, 0x00070befL, " 0461807", "% .7d", +__LINE__, 0x00000038L, "38", "% 0x", +__LINE__, 0x00000000L, " 0", "%6X", +__LINE__, 0xfff9c011L, "FFF9C011", "%2X", +__LINE__, 0xfffffffeL, "fffffffe", "%7x", +__LINE__, 0xfffffff9L, "FFFFFFF9", "%X", +__LINE__, -0x016a095L, "-1482901", "%4.0ld", +__LINE__, -0x000001cL, "-28", "% ld", +__LINE__, 0xfffd6133L, "0xfffd6133", "%#x", +__LINE__, 0x000004a4L, "0x4a4", "%#x", +__LINE__, 0x000003c2L, "0962", "%.4d", +__LINE__, -0x000323bL, "-12859", "%+#d", +__LINE__, 0x0f620237L, "F620237", "%X", +__LINE__, 0x00007863L, "007863", "%.6X", +__LINE__, 0x0000002cL, " 44", "% #ld", +__LINE__, 0xfffffff0L, "fffffff0", "%03.6x", +__LINE__, 0xffff6346L, "FFFF6346", "%1.X", +__LINE__, 0x00063188L, "63188", "% x", +__LINE__, 0xfffff91cL, "fffff91c", "%-.3x", +__LINE__, 0x004cd0b4L, "4CD0B4", "%-2.X", +__LINE__, 0x06b4d739L, "112514873", "%0.1d", +__LINE__, -0x0009bebL, "-39915", "%.2d", +__LINE__, 0x0000831bL, "33563", "%d", +__LINE__, 0x00000001L, "1", "%X", +__LINE__, -0x942d76bL, "-155375467", "% #0ld", +__LINE__, 0xffff2a95L, "FFFF2A95", "%2X", +__LINE__, 0x00548d5eL, "5541214", "%.3ld", +__LINE__, 0x0b5e1a01L, "B5E1A01", "% .7X", +__LINE__, 0xfffffc22L, "fffffc22", "%6x", +__LINE__, -0x0000dd7L, "-3543", "%-.3ld", +__LINE__, 0xfffff834L, "FFFFF834", "%X", +__LINE__, 0x0365f762L, "57014114", "%ld", +__LINE__, -0x0000003L, "-3", "%d", +__LINE__, 0x3bd998a3L, "1004116131", "%d", +__LINE__, 0xfffff6c9L, "FFFFF6C9", "%+X", +__LINE__, 0xffffded9L, "FFFFDED9", "%-.1X", +__LINE__, -0x00fbb5aL, "-1031002", "% 1.0d", +__LINE__, 0xffffffb7L, "ffffffb7", "%6.x", +__LINE__, 0xff1b8ac3L, "FF1B8AC3", "%-X", +__LINE__, 0xfffffff2L, "FFFFFFF2", "%00.X", +__LINE__, -0x000013dL, " -317", "%05.d", +__LINE__, 0x0000f5e2L, "+62946", "%+0.2ld", +__LINE__, 0x16ac6358L, "16ac6358", "%x", +__LINE__, 0xffff8728L, "FFFF8728", "%+X", +__LINE__, -0x0014a6dL, "-084589", "%0.6ld", +__LINE__, 0xfc904514L, "FC904514", "%+0X", +__LINE__, 0x00000004L, "4", "%ld", +__LINE__, 0xffffffe0L, "ffffffe0", "%+x", +__LINE__, -0x0a0ffddL, "-10551261", "%+02d", +__LINE__, -0x0000bbcL, "-3004", "%+d", +__LINE__, 0x00000006L, " +6", "%+7ld", +__LINE__, 0x17afa6e5L, "397387493", "%ld", +__LINE__, 0xfffff6bfL, "fffff6bf", "%+04.4x", +__LINE__, 0x000001dcL, "01dc", "% 02.4x", +__LINE__, 0x0000000eL, " 14", "% d", +__LINE__, 0xfffffff9L, "0XFFFFFFF9", "%#4.X", +__LINE__, 0x0000005dL, "93", "%0d", +__LINE__, -0x004fa05L, "-0326149", "%.7d", +__LINE__, -0x0000018L, "-24", "%ld", +__LINE__, 0xfffff7ebL, "FFFFF7EB", "%X", +__LINE__, 0x0072b044L, " 7516228", "% .7ld", +__LINE__, 0xffffffedL, "0xffffffed", "%#x", +__LINE__, 0x0010364dL, "10364D", "%X", +__LINE__, 0xfff90469L, "0XFFF90469", "%#X", +__LINE__, 0x000001b4L, " 436", "% 0d", +__LINE__, 0x00000000L, "0", "% X", +__LINE__, 0xfffffff3L, "fffffff3", "%x", +__LINE__, 0x19335d40L, "19335d40", "%6x", +__LINE__, 0x00039c24L, "236580", "%ld", +__LINE__, 0x000021f7L, "8695", "%0.4ld", +__LINE__, -0x057b406L, "-5747718", "%d", +__LINE__, -0x017b371L, "-1553265", "%#ld", +__LINE__, 0x0003e405L, "254981", "%2.d", +__LINE__, 0x00000001L, "1", "%-.1x", +__LINE__, 0x000000aeL, "AE", "%.1X", +__LINE__, 0xffd85825L, "ffd85825", "%-7.x", +__LINE__, 0xfffad763L, "fffad763", "%x", +__LINE__, 0x002431d4L, "2372052", "%6.ld", +__LINE__, 0x00000003L, "000003", "%-05.6d", +__LINE__, 0xffffffebL, "0xffffffeb", "%#x", +__LINE__, 0xff8cf3b0L, "ff8cf3b0", "%x", +__LINE__, 0xfe88d2ffL, "0xfe88d2ff", "%+#.2x", +__LINE__, 0xffffff6bL, "ffffff6b", "%6.3x", +__LINE__, 0xfffffffeL, "fffffffe", "%-x", +__LINE__, 0xe998945aL, "e998945a", "%2.x", +__LINE__, 0x03b9c50fL, "3B9C50F", "%+X", +__LINE__, 0xffffffffL, "FFFFFFFF", "%3.7X", +__LINE__, 0x000024efL, "24ef", "%+x", +__LINE__, 0xfffffc04L, "FFFFFC04", "%X", +__LINE__, 0x0d4bef7cL, " 223080316", "% .1ld", +__LINE__, -0xc33f3bcL, "-204731324", "%.5ld", +__LINE__, 0xffffffffL, "0XFFFFFFFF", "%#2X", +__LINE__, 0x0000e493L, "e493", "%x", +__LINE__, 0x000001b4L, "1b4", "%x", +__LINE__, 0xffffffd6L, "0xffffffd6", "% #1x", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, -0x0000f28L, "-3880", "%ld", +__LINE__, 0x00000277L, "631", "%-1ld", +__LINE__, 0x00000001L, " 1", "%2x", +__LINE__, -0x0ff4d2cL, "-16731436", "%#ld", +__LINE__, 0x0bb80344L, "196608836", "%00ld", +__LINE__, 0xffffffdcL, "FFFFFFDC", "%X", +__LINE__, 0x00000484L, "1156", "%ld", +__LINE__, 0x00000341L, "341", "%-.2x", +__LINE__, 0x0000ee62L, "ee62", "%x", +__LINE__, 0xfffffe20L, "fffffe20", "%+x", +__LINE__, -0x00076ebL, "-30443", "%.2d", +__LINE__, 0x2c4a7407L, "2c4a7407", "% x", +__LINE__, 0x00000000L, " ", "%3.X", +__LINE__, 0xffffff60L, "ffffff60", "% 4.x", +__LINE__, 0x000e4cf2L, "+937202", "%+.5ld", +__LINE__, 0x00000008L, " 00008", "%06.5X", +__LINE__, 0x0002f612L, "194066", "%d", +__LINE__, 0xfffffc96L, "fffffc96", "%-3.3x", +__LINE__, -0x0000001L, "-1", "% ld", +__LINE__, 0x00000000L, " ", "% 6.0X", +__LINE__, 0xfffffff5L, "fffffff5", "%3.x", +__LINE__, 0x0bfd63a1L, "201155489", "%d", +__LINE__, -0x1547c214L, "-357024276", "%ld", +__LINE__, 0x00000004L, "4", "%#0.d", +__LINE__, -0x000f2f3L, "-62195", "%.2d", +__LINE__, 0xfff843ddL, "FFF843DD", "%X", +__LINE__, 0x00966e36L, "9858614", "%.0ld", +__LINE__, 0x0000782eL, "0X782E", "% #X", +__LINE__, 0x00bd36c0L, "12400320", "%ld", +__LINE__, 0x00000000L, "00", "% .2X", +__LINE__, 0x00000000L, "0", "%1X", +__LINE__, 0x0003f416L, "3f416 ", "%-6.x", +__LINE__, -0x00b74bdL, "-750781", "% ld", +__LINE__, 0x0000138aL, "138a", "% x", +__LINE__, 0x024df7f0L, "24DF7F0", "% 0.6X", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%X", +__LINE__, -0x0003284L, "-12932 ", "%-07.ld", +__LINE__, 0x000094d3L, "94d3", "%x", +__LINE__, 0x000000bfL, "bf", "%.2x", +__LINE__, 0x00000000L, "00000", "%-1.5X", +__LINE__, -0x04899b8L, "-4757944", "%d", +__LINE__, 0x2b51bf20L, "+726777632", "%+d", +__LINE__, -0x000000dL, "-13", "%.2d", +__LINE__, 0x04f78fbdL, "4F78FBD", "% 7.X", +__LINE__, 0x00011684L, "71300", "%5.d", +__LINE__, 0x0000539dL, "21405", "%0d", +__LINE__, 0x00000008L, "000008", "%-3.6X", +__LINE__, 0xfc7a2cdcL, "fc7a2cdc", "%2.3x", +__LINE__, 0xffc21da1L, "ffc21da1", "%x", +__LINE__, 0x00000273L, "273", "%x", +__LINE__, 0x00000000L, "0", "%#X", +__LINE__, -0x31cd6b9L, "-52221625", "% d", +__LINE__, 0xfffffff8L, "FFFFFFF8", "%.0X", +__LINE__, 0x00000002L, "2", "%#ld", +__LINE__, 0x00e8922cL, "15241772", "%d", +__LINE__, 0xfeb19ea7L, "FEB19EA7", "%0.1X", +__LINE__, 0x00003931L, "014641", "%06ld", +__LINE__, 0x00000015L, "0X00015", "%#.5X", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%1.X", +__LINE__, 0xfff17103L, "0XFFF17103", "% #X", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%+X", +__LINE__, 0x00000002L, "00002", "%.5x", +__LINE__, 0x00001617L, " 5655", "% 7.d", +__LINE__, -0x0000010L, "-000016", "%00.6d", +__LINE__, 0x000000b0L, "B0", "% X", +__LINE__, 0xfc9362b2L, "FC9362B2", "%-X", +__LINE__, 0xfc3d8276L, "fc3d8276", "% 1x", +__LINE__, 0x00001405L, "5125", "%#d", +__LINE__, 0x02250183L, " 35979651", "% ld", +__LINE__, 0xffc9b007L, "ffc9b007", "% 4.x", +__LINE__, 0x00000311L, "785", "%0d", +__LINE__, 0x0004d273L, " 316019", "% d", +__LINE__, 0x00000001L, "1", "%1.x", +__LINE__, 0xffff240fL, "FFFF240F", "%4.X", +__LINE__, 0x0049cfdaL, "+4837338", "%+ld", +__LINE__, 0x012f6dd5L, "12F6DD5", "% 6.2X", +__LINE__, 0x00000002L, "0x2", "%#2.0x", +__LINE__, 0xfffd834aL, "FFFD834A", "%.6X", +__LINE__, 0xfe2a40f8L, "0XFE2A40F8", "%#X", +__LINE__, 0xffffffebL, "ffffffeb", "%x", +__LINE__, -0x00ac5cbL, "-705995", "%d", +__LINE__, -0x3021108cL, "-807473292", "% .4d", +__LINE__, -0x0000035L, "-53", "%-ld", +__LINE__, -0x1a36475L, "-27485301", "% d", +__LINE__, -0x0000011L, "-17", "%d", +__LINE__, 0x000001a3L, "000419", "%.6ld", +__LINE__, 0x0030a0a8L, "3186856", "%.5ld", +__LINE__, 0x00000019L, "25", "%d", +__LINE__, 0xf32deac1L, "F32DEAC1", "%06.2X", +__LINE__, -0x0000004L, " -00004", "%7.5ld", +__LINE__, 0x00000000L, "0", "%ld", +__LINE__, 0x0006bf19L, "442137", "%#0.d", +__LINE__, 0x566f6c44L, "1450142788", "%1.6d", +__LINE__, 0xfffffc10L, "fffffc10", "%.2x", +__LINE__, -0x000e04dL, "-57421", "%+0d", +__LINE__, 0x00000000L, "0000000", "%+.7X", +__LINE__, 0x00b5c74dL, " 11913037", "% ld", +__LINE__, -0x028dfe2L, "-2678754", "%05.1d", +__LINE__, 0xfffffee0L, "fffffee0", "%0x", +__LINE__, -0x030c077L, "-3194999", "%-.6d", +__LINE__, 0x00055ca1L, "055ca1", "%-.6x", +__LINE__, 0x00000000L, " ", "%7.X", +__LINE__, 0xfffffe3bL, "FFFFFE3B", "%X", +__LINE__, 0xffffffffL, "FFFFFFFF", "% 3X", +__LINE__, 0x00000857L, "2135", "%-#1.d", +__LINE__, -0x00546a2L, "-345762", "%0.5d", +__LINE__, 0x0000000bL, "0xb ", "%-#6x", +__LINE__, 0x00000d2bL, "d2b ", "%-4.0x", +__LINE__, 0x0ae02b9eL, "AE02B9E", "%X", +__LINE__, 0xfffffa7bL, "fffffa7b", "%-2.x", +__LINE__, 0x00000001L, "1", "%X", +__LINE__, 0x000006adL, "01709", "%05.5ld", +__LINE__, -0x0000102L, "-258", "%-0.ld", +__LINE__, 0x00000000L, "0", "%.1X", +__LINE__, -0x01daa95L, "-1944213", "%-1ld", +__LINE__, 0x02b99040L, "2B99040", "%2.X", +__LINE__, 0x1b3d5621L, "1B3D5621", "%X", +__LINE__, 0x0312d16bL, "51564907", "%-1.7ld", +__LINE__, 0x000aa76cL, " 698220", "% 2d", +__LINE__, 0x00000000L, "0", "%ld", +__LINE__, 0xfff8a4ecL, "FFF8A4EC", "%-X", +__LINE__, 0xffffe06dL, "ffffe06d", "%x", +__LINE__, 0x00000003L, "3", "% x", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xd3e244ddL, "D3E244DD", "%+5X", +__LINE__, 0x000028b3L, " 28b3", "% 5.x", +__LINE__, 0x0001acebL, "109803", "%6d", +__LINE__, 0xfffbc5caL, "0xfffbc5ca", "%-#5x", +__LINE__, 0x00000097L, " 151", "% 7ld", +__LINE__, 0x00001fccL, "+8140", "%+d", +__LINE__, 0xffffffffL, "ffffffff", "%0x", +__LINE__, -0x00052a9L, "-21161", "%ld", +__LINE__, 0xfffffc76L, "FFFFFC76", "%.1X", +__LINE__, -0x2acb012L, "-44871698", "%0.1ld", +__LINE__, 0xffffff81L, "ffffff81", "%x", +__LINE__, -0x0018394L, "-99220", "%-ld", +__LINE__, 0x0000001bL, "1B", "%X", +__LINE__, 0x00000033L, "51", "%1d", +__LINE__, 0xffec37e5L, "FFEC37E5", "%-1X", +__LINE__, -0x000000aL, " -10", "%#5.d", +__LINE__, -0x0000412L, "-1042", "%ld", +__LINE__, 0x000cd0b1L, "cd0b1 ", "%-7.5x", +__LINE__, 0x0b445370L, "B445370", "%+2.0X", +__LINE__, 0xfffffff3L, "0XFFFFFFF3", "%-#X", +__LINE__, 0xffff9f33L, "FFFF9F33", "%5.X", +__LINE__, 0x00010a1eL, "10A1E", "%-2X", +__LINE__, -0xede156fL, "-249435503", "% 7.1ld", +__LINE__, 0xfc6d63aaL, "fc6d63aa", "% .6x", +__LINE__, 0x0000311cL, " 12572", "% ld", +__LINE__, 0x00001f8aL, "8074", "%00.d", +__LINE__, 0x00000199L, "199", "%-X", +__LINE__, 0xfffffc60L, "FFFFFC60", "%+3X", +__LINE__, -0x000022cL, "-556", "%+0ld", +__LINE__, 0x021d8407L, "35488775", "%-#.7ld", +__LINE__, 0x0000020fL, "527", "%d", +__LINE__, -0x000064bL, "-1611", "%#ld", +__LINE__, -0x0c15aefL, "-12671727", "%d", +__LINE__, -0x1f1a6881L, "-521824385", "%ld", +__LINE__, 0xffffc115L, "ffffc115", "% x", +__LINE__, 0x00000017L, " 23", "% #ld", +__LINE__, 0x00000dc1L, "DC1 ", "%-4X", +__LINE__, 0x000002caL, "2CA", "%X", +__LINE__, 0x000f052cL, " 984364", "%7.d", +__LINE__, 0x0000005aL, "0090", "%0.4d", +__LINE__, -0x001e463L, "-124003", "% 4.ld", +__LINE__, 0x00000001L, "0000001", "%+.7X", +__LINE__, 0x00000bfbL, "0000bfb", "%5.7x", +__LINE__, 0x0002484bL, "149579", "%#1d", +__LINE__, 0x0043ba18L, "4438552", "%-ld", +__LINE__, 0x000078f8L, "0X78F8", "%#X", +__LINE__, 0x00000001L, " 1", "%4d", +__LINE__, 0x0cedaeedL, "CEDAEED", "%X", +__LINE__, 0x00000003L, "+3", "%+ld", +__LINE__, 0xfffffffbL, "FFFFFFFB", "%7.4X", +__LINE__, 0x00000169L, "361", "%ld", +__LINE__, 0x00003c7aL, "+15482", "%+ld", +__LINE__, -0x0159d93L, "-1416595", "% 0.0d", +__LINE__, 0x0000775cL, "+30556", "%+3.d", +__LINE__, 0x10284768L, "+271075176", "%+0.0ld", +__LINE__, -0xf8b610eL, "-260792590", "%0d", +__LINE__, 0xfdd8d369L, "fdd8d369", "%-.3x", +__LINE__, 0x000c9495L, "+824469", "%+ld", +__LINE__, -0x000003fL, " -063", "%7.3d", +__LINE__, -0x000073bL, "-1851", "%+03.ld", +__LINE__, 0xfffe4e23L, "0xfffe4e23", "%#.5x", +__LINE__, 0x0081788cL, "81788c", "%5x", +__LINE__, -0x015f888L, "-1439880", "%+1d", +__LINE__, -0x31d64b4L, "-52257972", "%0.2d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%6.5X", +__LINE__, -0x0000072L, "-114", "%+.1d", +__LINE__, -0x00000e1L, "-225", "%ld", +__LINE__, 0x000006a8L, "0x6a8", "%+#x", +__LINE__, 0xfffe673aL, "fffe673a", "%01.x", +__LINE__, 0xfff2ee0dL, "FFF2EE0D", "%-X", +__LINE__, 0x0290320aL, "43004426", "%0ld", +__LINE__, -0xeb7a832L, "-246917170", "% ld", +__LINE__, 0x02ae9265L, "2ae9265", "%1.x", +__LINE__, 0xffffffd2L, "ffffffd2", "%+2.x", +__LINE__, 0x00e6e858L, "0xe6e858", "%#0.x", +__LINE__, 0x00000c4aL, "+3146", "%+3.1d", +__LINE__, -0x6943c1aL, "-110378010", "% 0ld", +__LINE__, 0x0167b119L, "167b119", "%0x", +__LINE__, 0xfffffffeL, "fffffffe", "%+x", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%X", +__LINE__, 0x000b861eL, "755230", "%ld", +__LINE__, 0x0000015bL, "347", "%-#ld", +__LINE__, 0xfffffffaL, "0XFFFFFFFA", "%#X", +__LINE__, 0x000de9e5L, "911845", "%d", +__LINE__, 0x00000001L, "01", "%.2d", +__LINE__, 0x000007a5L, "1957", "%0d", +__LINE__, 0x0000000fL, "f", "%x", +__LINE__, 0x00c38cbfL, " 12815551", "% .2d", +__LINE__, -0x7bd1b6eL, "-129833838", "% d", +__LINE__, -0x000013cL, "-316", "%0d", +__LINE__, 0x00001aadL, "1AAD", "%-0X", +__LINE__, 0x0034f903L, "3471619", "%00d", +__LINE__, 0xff925717L, "ff925717", "%4x", +__LINE__, 0x00000002L, "02", "%.2d", +__LINE__, 0x00000f34L, "F34", "%+X", +__LINE__, 0xffffeefeL, "FFFFEEFE", "%X", +__LINE__, 0xfffeecb4L, "FFFEECB4", "% 2.X", +__LINE__, 0x00034421L, "214049", "%0ld", +__LINE__, 0x00000000L, " 0", "%+6X", +__LINE__, -0x0000062L, "-98", "%-#2d", +__LINE__, -0x0000557L, "-1367", "%-4.4d", +__LINE__, 0xffffe17cL, "FFFFE17C", "%X", +__LINE__, 0x00000097L, "00097", "%.5X", +__LINE__, 0xfffcb278L, "FFFCB278", "%0.7X", +__LINE__, -0x0000001L, "-0001 ", "%-7.4d", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, 0x000002c4L, "708", "%d", +__LINE__, 0x04946f45L, "4946F45", "%-2.X", +__LINE__, 0x000000ffL, "00ff", "% 2.4x", +__LINE__, 0x00073307L, "471815", "%3ld", +__LINE__, 0x0085b7b6L, "+8763318", "%+ld", +__LINE__, -0x0000002L, "-2", "%1ld", +__LINE__, -0x0000001L, "-1", "%-2d", +__LINE__, -0x00000b5L, " -181", "%7ld", +__LINE__, -0x0412486L, "-4269190", "%+2.1ld", +__LINE__, 0xffffffffL, "ffffffff", "%0x", +__LINE__, 0x0000006dL, "6d", "%x", +__LINE__, 0x000000daL, "218", "%-.3ld", +__LINE__, 0xfffffcfeL, "fffffcfe", "%x", +__LINE__, 0x652e60c7L, "652E60C7", "%7.7X", +__LINE__, 0x00000035L, " 53", "% #2d", +__LINE__, 0x000000fcL, "FC", "%-X", +__LINE__, 0x00000019L, " 25", "% ld", +__LINE__, 0xfffffcf4L, "fffffcf4", "%6x", +__LINE__, 0xffffff41L, "ffffff41", "%x", +__LINE__, 0x00000034L, " 52", "%3.ld", +__LINE__, 0xffffffb2L, "ffffffb2", "%-x", +__LINE__, -0x6dc43e7cL, "-1841577596", "% .2ld", +__LINE__, 0x00000004L, "4", "%d", +__LINE__, -0x000023bL, "-571", "%ld", +__LINE__, -0x000004dL, "-77", "%ld", +__LINE__, 0x0000e3baL, "58298", "%.0ld", +__LINE__, 0xfffffff2L, "fffffff2", "%0.0x", +__LINE__, -0x0000020L, "-32", "%ld", +__LINE__, 0xffffb33eL, "0XFFFFB33E", "%-#X", +__LINE__, 0x00000000L, " ", "% 4.x", +__LINE__, 0xffd96f92L, "FFD96F92", "%X", +__LINE__, 0x0000002eL, " 46", "% 0ld", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, -0x5008ba3L, "-83921827", "%+d", +__LINE__, 0xfdc1df3dL, "FDC1DF3D", "%0X", +__LINE__, 0xfc7410e5L, "fc7410e5", "%7x", +__LINE__, 0xfffffffaL, "FFFFFFFA", "% 6.X", +__LINE__, 0x00000000L, "0", "%X", +__LINE__, -0x040fd4eL, "-4259150", "% 05.d", +__LINE__, 0x0000003bL, " 59", "%3.2d", +__LINE__, 0xff776dd8L, "ff776dd8", "%x", +__LINE__, 0x0000055bL, "+1371", "%+#2d", +__LINE__, 0x00004841L, "4841", "%.1x", +__LINE__, 0x0229d710L, "36296464", "%-.2ld", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xfffe8376L, "fffe8376", "%0x", +__LINE__, 0x000a7b83L, "a7b83", "%x", +__LINE__, 0x0000000dL, " 013", "%#7.3d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%5.0X", +__LINE__, 0x00000704L, " 0x704", "%#7.0x", +__LINE__, 0xfff970b9L, "FFF970B9", "%.1X", +__LINE__, -0x000b60aL, "-46602", "%+d", +__LINE__, 0x00000000L, " 00000", "%6.5x", +__LINE__, 0x00000003L, "3", "%X", +__LINE__, 0x0000c14bL, "c14b", "%0x", +__LINE__, 0x066d7860L, "107837536", "%-d", +__LINE__, 0x00000013L, " 13", "%4.x", +__LINE__, 0xfff96f18L, "FFF96F18", "%4X", +__LINE__, 0xffffff30L, "FFFFFF30", "%X", +__LINE__, 0xffffffffL, "FFFFFFFF", "% .7X", +__LINE__, -0x72a9e985L, "-1923737989", "%2.d", +__LINE__, 0x00000002L, "0x2", "%#x", +__LINE__, 0x0000050eL, "50e", "%2.3x", +__LINE__, 0x0000605cL, "24668", "%4.1d", +__LINE__, 0xffffff3eL, "ffffff3e", "%x", +__LINE__, -0x0000010L, "-16", "%-2d", +__LINE__, 0x000061aaL, "61AA", "%X", +__LINE__, 0x000c2ec3L, "C2EC3", "%0X", +__LINE__, -0x0000001L, "-1", "%-0d", +__LINE__, 0x00130e17L, "+1248791", "%+.6ld", +__LINE__, 0x000000efL, "EF", "%-X", +__LINE__, -0x0000001L, " -1", "%+5ld", +__LINE__, 0x0000989dL, "39069", "%d", +__LINE__, 0x00000000L, "0", "%-x", +__LINE__, 0x00000417L, "417", "%X", +__LINE__, 0x00005e86L, "5E86", "%+X", +__LINE__, -0x0007c08L, "-31752", "%ld", +__LINE__, 0x00da8e0fL, "DA8E0F", "%2.2X", +__LINE__, -0x3ee095ecL, "-1054905836", "% 0d", +__LINE__, 0xfffdb5a3L, "fffdb5a3", "%x", +__LINE__, 0xffffff83L, "FFFFFF83", "%X", +__LINE__, 0xfff8efd7L, "0xfff8efd7", "%#x", +__LINE__, 0x00000020L, " 32", "% d", +__LINE__, 0xfff7c002L, "fff7c002", "%.7x", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, 0x00000000L, " 000", "%05.3X", +__LINE__, 0xfff190eeL, "FFF190EE", "%X", +__LINE__, 0x00000a6cL, " 2668", "%#6.ld", +__LINE__, 0x00037024L, "37024", "%x", +__LINE__, 0xfffec37fL, "FFFEC37F", "%X", +__LINE__, 0x007ee9bbL, "8317371", "%#0.ld", +__LINE__, 0x00000122L, "290", "%ld", +__LINE__, -0x0013b5fL, "-80735", "%ld", +__LINE__, 0xfffffff6L, "FFFFFFF6", "%X", +__LINE__, -0x0000c16L, "-0003094", "%-00.7d", +__LINE__, -0x00010edL, "-4333", "%ld", +__LINE__, 0x00000007L, " 0X007", "%#6.3X", +__LINE__, 0x0053781eL, " 5470238", "% 2d", +__LINE__, 0xffff03e9L, "0XFFFF03E9", "%+#7.3X", +__LINE__, 0xfffffdc2L, "0xfffffdc2", "% #4.x", +__LINE__, -0x00018e1L, "-6369", "%d", +__LINE__, 0xf3a4abc6L, "F3A4ABC6", "%-.2X", +__LINE__, 0xfff64a27L, "FFF64A27", "%7.7X", +__LINE__, 0x00195ae5L, "195AE5", "%+03.X", +__LINE__, 0xfff8849aL, "fff8849a", "%.1x", +__LINE__, -0x001b045L, "-110661", "%+ld", +__LINE__, 0x01e8a106L, "32022790", "%7.ld", +__LINE__, 0x0008ee94L, "8EE94", "%X", +__LINE__, 0xfffcdabcL, "FFFCDABC", "%X", +__LINE__, 0xfda75cd2L, "fda75cd2", "%x", +__LINE__, 0x00fd505aL, "fd505a", "%x", +__LINE__, 0x00003748L, "3748", "%+x", +__LINE__, 0xffffffe5L, "ffffffe5", "% 3.6x", +__LINE__, -0x1d1c4045L, "-488390725", "%d", +__LINE__, 0xfffffff9L, "0xfffffff9", "%#x", +__LINE__, -0x0000001L, "-1", "%-#ld", +__LINE__, 0x00000191L, "191", "%X", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%-X", +__LINE__, -0x0000006L, "-6", "%ld", +__LINE__, 0x00000033L, " 33", "% 4x", +__LINE__, -0x0159a14L, "-1415700", "% ld", +__LINE__, 0x000001c3L, "00001c3", "%07x", +__LINE__, 0xffffe9e2L, "ffffe9e2", "%-x", +__LINE__, 0x5b19abd9L, "0x5b19abd9", "%-#x", +__LINE__, 0xffff1baeL, "0xffff1bae", "%#x", +__LINE__, 0x00000001L, "+1", "%+d", +__LINE__, 0x006a23c7L, "6A23C7", "%2.X", +__LINE__, 0x000008a4L, " 8a4", "% 4.1x", +__LINE__, 0xfffffcd9L, "fffffcd9", "%.1x", +__LINE__, 0x0000121bL, "121B", "%X", +__LINE__, 0x001231aaL, "1192362", "%7.d", +__LINE__, -0x008026dL, "-524909", "%4.2d", +__LINE__, 0x192ea594L, "422487444", "%ld", +__LINE__, 0x0001a800L, "108544", "%0d", +__LINE__, 0x000062f1L, "62f1", "%.4x", +__LINE__, 0xff8b39b0L, "ff8b39b0", "% x", +__LINE__, 0x00000001L, "0x1", "%+#x", +__LINE__, 0x0000144aL, "5194", "%ld", +__LINE__, 0x00002599L, "9625", "%d", +__LINE__, 0xffa0a2efL, "ffa0a2ef", "%0x", +__LINE__, 0xff6712e1L, "FF6712E1", "%0X", +__LINE__, 0x0007ebb3L, "519091", "%1ld", +__LINE__, 0x0000000fL, "15 ", "%-4.ld", +__LINE__, -0x0000096L, "-150", "%2.ld", +__LINE__, 0x0000004fL, "4F", "%.2X", +__LINE__, 0xfffffc29L, "fffffc29", "%-4.x", +__LINE__, 0x00000019L, "19", "%x", +__LINE__, 0x00000c4eL, "c4e", "%x", +__LINE__, 0x0000006bL, " 0006B", "%6.5X", +__LINE__, 0x00c8d2c6L, "c8d2c6", "%.0x", +__LINE__, -0x256fb8deL, "-628078814", "%ld", +__LINE__, 0x4f51fcf4L, "4F51FCF4", "%+X", +__LINE__, 0x000f000eL, "983054", "%1.ld", +__LINE__, 0xfffff03fL, "fffff03f", "%x", +__LINE__, 0x0000001dL, " 1D", "%05.X", +__LINE__, 0x0072ea14L, "72ea14", "%x", +__LINE__, -0xc6098b9L, "-207657145", "%-7d", +__LINE__, 0x00000a76L, "2678", "%3ld", +__LINE__, 0xfff84db3L, "FFF84DB3", "%X", +__LINE__, 0x0fb52870L, "fb52870", "%+x", +__LINE__, 0x08bc170aL, "0x8bc170a", "%#x", +__LINE__, 0xfffeeb00L, "fffeeb00", "%0.5x", +__LINE__, 0x000ece95L, "970389", "%d", +__LINE__, 0x00000000L, "0", "%0X", +__LINE__, 0x07f98e8aL, "7f98e8a", "% x", +__LINE__, 0x000499ebL, " 499eb", "% 6.x", +__LINE__, 0xffffffffL, "FFFFFFFF", "%-X", +__LINE__, 0x0aa45e86L, "178544262", "%#.2d", +__LINE__, 0xff73387dL, "FF73387D", "%03.X", +__LINE__, 0xfffffb51L, "FFFFFB51", "%.3X", +__LINE__, 0xffffffdcL, "ffffffdc", "%6.x", +__LINE__, 0xffffffedL, "FFFFFFED", "%-X", +__LINE__, 0x0001c4c2L, "1c4c2", "%0.3x", +__LINE__, -0x0000001L, "-0000001", "%-#.7d", +__LINE__, 0x00000007L, "7", "%0.x", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, 0xffffd000L, "ffffd000", "%4.3x", +__LINE__, 0x00000030L, "48", "%2.d", +__LINE__, -0x6c121ceL, "-113320398", "%.5ld", +__LINE__, 0x000001edL, "1ED", "% 3.X", +__LINE__, 0xfffff0f3L, "FFFFF0F3", "%+.6X", +__LINE__, 0xffffffecL, "ffffffec", "%x", +__LINE__, 0x002d5ab8L, "0x2d5ab8", "%-#x", +__LINE__, 0x0026acffL, "2534655", "%0ld", +__LINE__, 0x01d90cd7L, "+31001815", "%+.2ld", +__LINE__, -0x1f7abc0L, "-33008576", "%7.6d", +__LINE__, 0xfc5babccL, "fc5babcc", "%x", +__LINE__, -0x9b74892L, "-163006610", "% .6d", +__LINE__, 0x03931d84L, "59972996", "%0.d", +__LINE__, 0x07d261ceL, "131228110", "%#ld", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0x00000002L, "2", "%+X", +__LINE__, -0x0000604L, "-1540", "%+d", +__LINE__, 0x00000000L, " ", "%7.x", +__LINE__, 0x00000001L, "1", "%.0X", +__LINE__, -0x0005a8eL, "-23182", "% d", +__LINE__, 0x03fb2730L, "3fb2730", "%7.x", +__LINE__, 0xffffff03L, "ffffff03", "%x", +__LINE__, 0x00000000L, " ", "%-#3.d", +__LINE__, 0x04025a4bL, "0X4025A4B", "%+#X", +__LINE__, -0x0000001L, " -1", "%4.d", +__LINE__, 0xfffe00a3L, "FFFE00A3", "%+X", +__LINE__, -0x1b26e3c8L, "-455533512", "% ld", +__LINE__, 0x000017e5L, "6117", "%d", +__LINE__, -0x0e4f3b6L, "-15004598", "%0ld", +__LINE__, 0x00000034L, "52", "%ld", +__LINE__, 0x0000024cL, " 24C", "%4X", +__LINE__, 0xfffedf65L, "FFFEDF65", "%-0X", +__LINE__, -0x000ff1fL, "-65311", "%+#d", +__LINE__, 0x00000007L, " 7", "%7.x", +__LINE__, 0x018656aeL, "18656ae", "%3.7x", +__LINE__, -0x0000004L, "-4", "%d", +__LINE__, 0x7081292dL, "1887512877", "%d", +__LINE__, 0x87d3e48cL, "87d3e48c", "%-x", +__LINE__, 0xf99c516eL, "0xf99c516e", "% #7.4x", +__LINE__, 0xfffffffaL, "FFFFFFFA", "%-1X", +__LINE__, -0x000001dL, "-29", "%#ld", +__LINE__, -0x0000001L, "-1", "%+ld", +__LINE__, 0x28ab3350L, " 682308432", "% 1d", +__LINE__, -0x0000006L, "-6", "%ld", +__LINE__, 0xfffffffbL, "FFFFFFFB", "%.5X", +__LINE__, -0x0000007L, "-7", "%#d", +__LINE__, -0x0000328L, " -808", "%6.ld", +__LINE__, -0x29386f00L, "-691564288", "%.3d", +__LINE__, -0x059f38aL, "-5895050", "%.4ld", +__LINE__, 0xfffff888L, "FFFFF888", "%3X", +__LINE__, 0xffffffdfL, "ffffffdf", "%0.0x", +__LINE__, -0xb4fc354L, "-189776724", "%2d", +__LINE__, 0x00058c07L, "363527", "%1.d", +__LINE__, 0x0a256162L, "a256162", "%x", +__LINE__, -0x05c87b0L, "-6064048", "%0ld", +__LINE__, 0xfffffda1L, "fffffda1", "%x", +__LINE__, 0x000034b7L, "13495", "%d", +__LINE__, -0x6d1a8918L, "-1830455576", "%.1d", +__LINE__, 0x00022290L, "139920", "%05ld", +__LINE__, 0x00000000L, "0", "%-x", +__LINE__, -0x1f8eafceL, "-529444814", "%4.d", +__LINE__, -0x7bf32808L, "-2079533064", "% ld", +__LINE__, 0x0000023cL, "23c", "% x", +__LINE__, 0x00000039L, "39", "%X", +__LINE__, -0x000556dL, "-21869", "%ld", +__LINE__, -0x00000caL, "-202", "%ld", +__LINE__, 0x00002e28L, "11816", "%-d", +__LINE__, 0x00000011L, "17", "%-ld", +__LINE__, 0xfffffffbL, "FFFFFFFB", "%-X", +__LINE__, 0xfffdd67fL, "0XFFFDD67F", "%#X", +__LINE__, -0x000003dL, "-61", "%d", +__LINE__, 0x0000bfceL, "0XBFCE", "%-#5.2X", +__LINE__, 0xfffffffcL, "fffffffc", "%x", +__LINE__, -0x00aea17L, "-715287", "%.5d", +__LINE__, -0x02fce89L, "-3133065", "%0d", +__LINE__, 0x007f6ed1L, "7F6ED1", "%6X", +__LINE__, 0xffffffffL, "FFFFFFFF", "%X", +__LINE__, -0x0002761L, "-10081", "%#6.2d", +__LINE__, 0x003be8d8L, "3BE8D8", "%-X", +__LINE__, 0x00000901L, " 2305", "%6.d", +__LINE__, 0x00049916L, "0301334", "%3.7ld", +__LINE__, 0x0678ffeaL, "0X678FFEA", "%#4X", +__LINE__, 0xffffffffL, "ffffffff", "%+.0x", +__LINE__, -0x31d2ec61L, "-835906657", "%.0d", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%0X", +__LINE__, -0x0015588L, "-87432", "%d", +__LINE__, 0xffffff3eL, "ffffff3e", "%.4x", +__LINE__, 0x0000000aL, "10", "%d", +__LINE__, -0x0000003L, "-3", "%2.1ld", +__LINE__, -0x000d29aL, "-53914", "%ld", +__LINE__, -0x04ccbe0L, "-5032928", "%2.2ld", +__LINE__, 0x0357c2a5L, "357c2a5", "% 7.x", +__LINE__, 0x00000009L, " 9", "% 1.ld", +__LINE__, -0x005908dL, "-364685", "%0d", +__LINE__, -0x0000de6L, "-3558", "%0ld", +__LINE__, 0x2d395e6bL, "+758734443", "%+6d", +__LINE__, 0x001aba58L, "1ABA58", "% X", +__LINE__, 0x0ceba5abL, "0XCEBA5AB", "%#.1X", +__LINE__, -0x01a8575L, "-1738101", "% 2ld", +__LINE__, 0x0000000dL, "13", "%#ld", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, 0x4b856407L, "4b856407", "%5x", +__LINE__, 0x006f333cL, "6F333C", "%-X", +__LINE__, 0x000000d0L, "d0", "%x", +__LINE__, 0x2ecf0d4eL, "2ecf0d4e", "%0x", +__LINE__, -0x0000188L, "-0000392", "%#1.7ld", +__LINE__, -0x0000037L, "-55", "%d", +__LINE__, 0xfffffff1L, "FFFFFFF1", "% .1X", +__LINE__, 0x00000001L, "0x1", "%#3x", +__LINE__, 0x000005edL, "5ED", "%3X", +__LINE__, 0x031183a3L, "31183A3", "%X", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, -0x0018695L, "-99989", "%-0.5ld", +__LINE__, -0x0000001L, "-01", "%0.2ld", +__LINE__, 0x00007822L, "7822", "%+x", +__LINE__, 0x00000000L, "0", "% x", +__LINE__, 0xfda2461aL, "FDA2461A", "%X", +__LINE__, 0x065c50efL, "106713327", "%2.ld", +__LINE__, 0x00000a81L, "a81", "% 0x", +__LINE__, -0x000022eL, "-558", "%.0ld", +__LINE__, 0x00013d2fL, "81199", "%.2ld", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%+X", +__LINE__, 0x000015f9L, "5625", "%04.ld", +__LINE__, 0x0ab575a2L, "179664290", "%0d", +__LINE__, 0x0024d07fL, "0X24D07F", "%#X", +__LINE__, 0x07ee35e1L, "7EE35E1", "%+X", +__LINE__, -0x00c114cL, "-790860", "%#ld", +__LINE__, 0x00003be3L, " 15331", "%07.d", +__LINE__, 0xfff87570L, "FFF87570", "%4.0X", +__LINE__, -0x14eab419L, "-350925849", "%-ld", +__LINE__, -0x000001bL, "-27", "%ld", +__LINE__, 0x167ce2eaL, "0x167ce2ea", "%#0.x", +__LINE__, -0x00009bcL, "-002492", "% 3.6d", +__LINE__, 0xfffffdb9L, "0XFFFFFDB9", "%#7.X", +__LINE__, 0x008b2b9dL, "8B2B9D", "% X", +__LINE__, 0x000cfec3L, "CFEC3", "% 05X", +__LINE__, 0x05970be6L, "5970be6", "%x", +__LINE__, 0x00002780L, "010112", "%2.6d", +__LINE__, 0x00000005L, "+5", "%+d", +__LINE__, 0xfffffffbL, "0xfffffffb", "%#3.x", +__LINE__, 0x00000001L, "1 ", "%-#5.ld", +__LINE__, -0x0000017L, "-23", "%ld", +__LINE__, -0x023b943L, "-2341187", "%d", +__LINE__, 0x0000000dL, "13", "%ld", +__LINE__, 0x00025a03L, "25a03", "% .5x", +__LINE__, 0x3e1ebe24L, "3e1ebe24", "% x", +__LINE__, 0x0000013aL, "0x13a", "%#5.0x", +__LINE__, 0xfff6f5b3L, "FFF6F5B3", "%4.X", +__LINE__, -0x0000a8aL, "-2698", "%.3d", +__LINE__, 0x0009dd5fL, "9dd5f", "%x", +__LINE__, 0x000003c7L, " 3C7", "%04.2X", +__LINE__, 0x1bcfa2f2L, "1bcfa2f2", "%+1.x", +__LINE__, 0x0001b4f4L, "1b4f4", "%+1.x", +__LINE__, 0x1bc19a90L, "465672848", "%#d", +__LINE__, 0xffffffffL, "ffffffff", "%+06x", +__LINE__, -0x0000a88L, "-2696", "%3.d", +__LINE__, 0x00084a19L, "84A19", "%-X", +__LINE__, 0xffe1fc8fL, "FFE1FC8F", "%0.1X", +__LINE__, -0x0000a3aL, "-2618", "%5d", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, -0x5c6183dL, "-96868413", "%+ld", +__LINE__, -0x0000001L, "-1", "%-d", +__LINE__, 0x0000faa8L, "64168", "%05.d", +__LINE__, 0x003913efL, "3740655", "%ld", +__LINE__, 0x0dde330aL, "232665866", "%#ld", +__LINE__, 0xfcfb1a7bL, "FCFB1A7B", "%+X", +__LINE__, 0x07b1a81fL, " 129083423", "% 0d", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, 0x00000070L, " 112", "%5ld", +__LINE__, 0xffff74d9L, "ffff74d9", "%x", +__LINE__, -0x001ab93L, "-109459", "%03.d", +__LINE__, 0x0eb6b497L, "EB6B497", "%+X", +__LINE__, 0x07adbac2L, "128826050", "%#0.4d", +__LINE__, 0xff747068L, "FF747068", "%6.X", +__LINE__, -0x190ce98fL, "-420276623", "%06.6ld", +__LINE__, -0x0000007L, "-7", "%.0d", +__LINE__, 0x0001240fL, "1240f", "% 3x", +__LINE__, 0x267ae4a0L, "645588128", "%-#ld", +__LINE__, -0x0000001L, "-1", "% ld", +__LINE__, -0x0000066L, "-00102", "%.5ld", +__LINE__, 0x868fa035L, "868fa035", "%x", +__LINE__, 0x00000000L, " ", "%-4.ld", +__LINE__, 0xfffffe72L, "FFFFFE72", "%4.4X", +__LINE__, 0x00a6b4f4L, "10925300", "%#ld", +__LINE__, -0x0000002L, "-2", "%00.1d", +__LINE__, -0x00000a3L, "-163", "%ld", +__LINE__, 0xfffffffeL, "fffffffe", "% 3.x", +__LINE__, 0xffe25941L, "ffe25941", "% x", +__LINE__, 0x0000a20fL, "41487", "%ld", +__LINE__, -0x000009bL, "-155", "%#.3ld", +__LINE__, 0x000c5dc1L, "810433", "%4.ld", +__LINE__, 0x00003ec4L, "16068", "%ld", +__LINE__, 0x000002f3L, "0755", "%04ld", +__LINE__, 0xffffff28L, "FFFFFF28", "%.5X", +__LINE__, -0x08450ffL, "-8671487", "%-3.0ld", +__LINE__, 0x00000092L, "92", "%x", +__LINE__, -0x0000317L, "-791", "%d", +__LINE__, 0x0000000dL, "d", "%x", +__LINE__, 0x00000036L, "36", "%x", +__LINE__, -0x112693fL, "-17983807", "%ld", +__LINE__, 0x00004226L, "16934", "%0.d", +__LINE__, 0x000001baL, " 442", "% ld", +__LINE__, 0xfffffffcL, "0XFFFFFFFC", "%#4X", +__LINE__, 0xffdb3d23L, "0xffdb3d23", "% #x", +__LINE__, 0x039eb84dL, "39EB84D", "%+.6X", +__LINE__, 0xffffc7daL, "ffffc7da", "%0x", +__LINE__, 0xfffffdb6L, "FFFFFDB6", "%6X", +__LINE__, 0x001b75b0L, "1799600", "%ld", +__LINE__, 0xfffffca2L, "FFFFFCA2", "%-X", +__LINE__, 0xffffffbaL, "ffffffba", "%7.4x", +__LINE__, -0x000124eL, "-4686", "%3.ld", +__LINE__, -0x000bec0L, "-48832", "% 0d", +__LINE__, 0xfffffca0L, "fffffca0", "%2.x", +__LINE__, 0x00b2a462L, "11707490", "%ld", +__LINE__, 0x0745a647L, "745a647", "%+4.x", +__LINE__, 0xfffffbacL, "0XFFFFFBAC", "%#3.X", +__LINE__, -0x0000002L, "-2", "%-0.1d", +__LINE__, 0x0006cfdbL, "446427", "%#5.d", +__LINE__, -0x0000001L, "-1", "%d", +__LINE__, 0x043b134eL, "43B134E", "%X", +__LINE__, -0x0000015L, "-21", "%ld", +__LINE__, -0x0000114L, "-276", "%0d", +__LINE__, -0x0004d4aL, "-19786", "%-d", +__LINE__, -0x000001cL, "-28", "%ld", +__LINE__, -0x0cb89fcL, "-13339132", "%ld", +__LINE__, 0xffffffcfL, "ffffffcf", "%x", +__LINE__, 0xf6d2387aL, "f6d2387a", "%-x", +__LINE__, -0x00000cdL, "-205", "%#ld", +__LINE__, 0x00000000L, "0", "%#x", +__LINE__, 0xfffffc81L, "fffffc81", "%x", +__LINE__, 0x00000000L, " 0", "% ld", +__LINE__, 0x00024fb5L, "24fb5", "%x", +__LINE__, 0x000012faL, "12FA", "%X", +__LINE__, 0x0318ce7cL, "51957372", "%0d", +__LINE__, 0x02280a99L, "2280a99", "%-x", +__LINE__, 0xffffff5cL, "FFFFFF5C", "%2.X", +__LINE__, -0x000002eL, " -46", "%7ld", +__LINE__, -0x04a73e8L, "-4879336", "%4ld", +__LINE__, 0x000007f3L, "7f3", "% 1.3x", +__LINE__, 0x00000114L, "0x114", "%#x", +__LINE__, 0x0000030cL, "30c", "%-x", +__LINE__, 0x001dd0ddL, "0x1dd0dd", "%+#5.5x", +__LINE__, 0xfff23de3L, "fff23de3", "%-x", +__LINE__, -0x0178f9cL, "-1544092", "%d", +__LINE__, 0x02ded8daL, "2DED8DA", "%X", +__LINE__, -0x0991672L, "-10032754", "%3.d", +__LINE__, 0x6943c150L, "6943c150", "%x", +__LINE__, 0xffffc25dL, "FFFFC25D", "%4X", +__LINE__, 0x00000c9cL, " 0003228", "% .7d", +__LINE__, 0xffffffdfL, "FFFFFFDF", "% 6.X", +__LINE__, 0x0001a145L, " 1a145", "%6.0x", +__LINE__, 0xffdc832fL, "0xffdc832f", "%#.1x", +__LINE__, 0x00699f7bL, "699f7b", "%x", +__LINE__, 0xf9575268L, "F9575268", "%+0X", +__LINE__, 0x04eb4783L, "82528131", "%-ld", +__LINE__, -0x0000023L, "-35", "%0ld", +__LINE__, -0x012b08aL, "-1224842", "%0d", +__LINE__, 0xffffb587L, "FFFFB587", "%X", +__LINE__, 0xffffffe9L, "ffffffe9", "%x", +__LINE__, 0x006b5596L, " 7034262", "% 0d", +__LINE__, 0x004d0d2aL, "+5049642", "%+ld", +__LINE__, -0x002a099L, "-172185", "%d", +__LINE__, 0x00000224L, "548", "%ld", +__LINE__, 0x03e0cca8L, "65064104", "%d", +__LINE__, -0x7bb389dL, "-129710237", "%.3ld", +__LINE__, 0xffc630f5L, "ffc630f5", "%-07.0x", +__LINE__, 0xfffffff8L, "FFFFFFF8", "%X", +__LINE__, 0x0030225bL, "3154523", "%#d", +__LINE__, 0xff7f4e28L, "ff7f4e28", "%+4.x", +__LINE__, 0x14ee154dL, "+351147341", "%+ld", +__LINE__, 0x00000003L, "03", "%.2d", +__LINE__, 0xfe0359d6L, "fe0359d6", "%x", +__LINE__, 0x002b71c3L, "2847171", "%d", +__LINE__, 0x055c4d4aL, "55C4D4A", "%-X", +__LINE__, 0xfffb17d2L, "fffb17d2", "% .0x", +__LINE__, 0x00000002L, "2", "%x", +__LINE__, 0x000018e1L, "18E1", "%1.1X", +__LINE__, 0x00000331L, "817", "%0d", +__LINE__, -0x0000982L, "-2434 ", "%-06.ld", +__LINE__, -0x0000168L, "-0000360", "%.7ld", +__LINE__, 0xffffffe9L, "FFFFFFE9", "%-0.4X", +__LINE__, 0xe42084efL, "E42084EF", "%X", +__LINE__, 0x000000aaL, "aa", "%x", +__LINE__, -0xe8b98b5L, "-244029621", "%+d", +__LINE__, -0x00000d9L, "-217", "%+2.d", +__LINE__, 0x0000027bL, "27B", "%+.0X", +__LINE__, 0x002e52dbL, "3035867", "%-ld", +__LINE__, -0x00e2ba8L, "-928680", "%0.2ld", +__LINE__, 0x003b74d8L, "3B74D8", "%X", +__LINE__, -0x000006fL, "-111", "%+ld", +__LINE__, 0xf8507e22L, "0XF8507E22", "%-#X", +__LINE__, 0x0629f4c0L, "103412928", "%-ld", +__LINE__, -0x000002dL, "-45", "%0d", +__LINE__, -0x0001db0L, "-7600", "%d", +__LINE__, -0x00001bbL, " -443", "%5.ld", +__LINE__, 0xffffd2b9L, "ffffd2b9", "%+x", +__LINE__, 0xffffe685L, "0XFFFFE685", "%#0.7X", +__LINE__, 0x0000a4ceL, "A4CE", "% X", +__LINE__, 0xffffffffL, "FFFFFFFF", "%X", +__LINE__, 0x0000000cL, "C", "% X", +__LINE__, 0xfff59369L, "FFF59369", "%7X", +__LINE__, 0x00000156L, " 156", "%5.X", +__LINE__, 0x02833aa9L, "+42154665", "%+2d", +__LINE__, 0x0004a8f3L, "+305395", "%+d", +__LINE__, 0x01a09267L, "1A09267", "%0.3X", +__LINE__, 0x000004f1L, "4f1", "%x", +__LINE__, 0x00000005L, "5", "%x", +__LINE__, 0x00000119L, " 0281", "% #2.4ld", +__LINE__, -0x0001a2aL, "-6698", "%ld", +__LINE__, 0xa3633a57L, "A3633A57", "%7X", +__LINE__, -0x10bd2970L, "-280832368", "%-d", +__LINE__, 0xffff9c38L, "ffff9c38", "%x", +__LINE__, 0xffdbe81eL, "ffdbe81e", "%+6.7x", +__LINE__, 0xffffffe7L, "FFFFFFE7", "%-3.0X", +__LINE__, 0x0002f6d6L, "2f6d6", "%5.x", +__LINE__, 0xffffffffL, "ffffffff", "% x", +__LINE__, 0xffc2c07aL, "ffc2c07a", "%0.x", +__LINE__, 0xfcc0e13aL, "FCC0E13A", "%X", +__LINE__, 0x0000000dL, "d", "% x", +__LINE__, 0x0016cac8L, "16CAC8", "%-0.3X", +__LINE__, 0x00945dc1L, "9723329", "%2d", +__LINE__, 0xf19a1cd1L, "F19A1CD1", "%-X", +__LINE__, 0x00000003L, "+3", "%+ld", +__LINE__, 0x00000773L, "1907", "%ld", +__LINE__, 0x000263e6L, "263e6", "%-x", +__LINE__, -0x0238b55L, "-2329429", "%d", +__LINE__, 0x00006c56L, "6C56", "%X", +__LINE__, 0x0000f34bL, "62283", "%#.0ld", +__LINE__, -0x1620e21L, "-23203361", "%0ld", +__LINE__, 0xf9257d6aL, "f9257d6a", "%2x", +__LINE__, -0x00ed463L, "-971875", "%03.d", +__LINE__, 0x02bb94c6L, "45847750", "%d", +__LINE__, 0xffffd20cL, "0XFFFFD20C", "%#X", +__LINE__, 0x000087d8L, "34776", "%.0d", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%+7.X", +__LINE__, -0x0009cd5L, "-40149", "%-ld", +__LINE__, 0xfffff85eL, "FFFFF85E", "% 0.7X", +__LINE__, -0x0000006L, " -6", "%+#6.ld", +__LINE__, 0x007ff453L, "0x7ff453", "%-#1.x", +__LINE__, 0xffffffe6L, "FFFFFFE6", "%2X", +__LINE__, 0x0000001fL, "0X1F", "%#4X", +__LINE__, -0x001c157L, "-115031", "%.3ld", +__LINE__, 0x00096e06L, "617990", "%3.1ld", +__LINE__, 0x0f77271dL, "259467037", "%d", +__LINE__, -0x0001403L, "-5123", "%d", +__LINE__, 0xffffff8aL, "ffffff8a", "%x", +__LINE__, -0x000010fL, "-271", "%1.ld", +__LINE__, 0xe573cc4aL, "E573CC4A", "%0X", +__LINE__, -0x0000d88L, "-3464", "%-d", +__LINE__, 0x0000000eL, "14", "%#ld", +__LINE__, -0x000345bL, "-13403", "%#d", +__LINE__, 0x00000602L, "602", "%+x", +__LINE__, 0x00000011L, "17", "%#d", +__LINE__, -0x0000002L, "-2", "%+d", +__LINE__, 0x030fe6e6L, "51373798", "%d", +__LINE__, 0x00000007L, "007", "%.3X", +__LINE__, 0x0001abe0L, "0X1ABE0", "%+#.4X", +__LINE__, 0xfffffdb7L, "fffffdb7", "%-6x", +__LINE__, 0xffffff8dL, "FFFFFF8D", "% 02.2X", +__LINE__, 0xfff12126L, "FFF12126", "%X", +__LINE__, 0x0208e32dL, "34136877", "%.2d", +__LINE__, 0x11c04b55L, "297814869", "%ld", +__LINE__, 0xff1e5ca3L, "0xff1e5ca3", "%#x", +__LINE__, 0xf9643f09L, "f9643f09", "%x", +__LINE__, -0x003c6daL, "-247514", "%4d", +__LINE__, 0xff69d0e7L, "FF69D0E7", "%-X", +__LINE__, 0x00006ae9L, "0x6ae9", "%#x", +__LINE__, -0x005aefeL, "-372478", "%d", +__LINE__, 0x0000000dL, "00013", "%3.5ld", +__LINE__, 0x00cc185cL, "CC185C", "%X", +__LINE__, 0x3dd14d9fL, "3DD14D9F", "%1.4X", +__LINE__, -0x4cc2ad3L, "-80489171", "%1.d", +__LINE__, 0xfffff79eL, "fffff79e", "%x", +__LINE__, 0xfffeeb03L, "fffeeb03", "%-1x", +__LINE__, -0x0b1b15cL, "-11645276", "%0ld", +__LINE__, -0x06b558dL, "-7034253", "%ld", +__LINE__, 0xfffffe61L, "fffffe61", "%x", +__LINE__, -0x0000002L, "-2", "%d", +__LINE__, -0x0000162L, "-000354", "%-5.6d", +__LINE__, 0x01a23780L, "27408256", "%d", +__LINE__, 0xffff3a9bL, "ffff3a9b", "% x", +__LINE__, 0xfffffdc7L, "0xfffffdc7", "%#4.5x", +__LINE__, 0x00000000L, "00", "%.2X", +__LINE__, -0x0000006L, "-6", "%0ld", +__LINE__, -0x16072c6L, "-23098054", "%#5ld", +__LINE__, -0x07152b8L, "-7426744", "%01ld", +__LINE__, 0x0000d6c6L, "0x0d6c6", "%#1.5x", +__LINE__, 0x00000f7cL, "000f7c", "%+04.6x", +__LINE__, 0x00000bd0L, "3024", "%4ld", +__LINE__, 0x0000295eL, "0x295e", "%#x", +__LINE__, 0x00002e38L, "11832", "%.5d", +__LINE__, -0xa2f5de4L, "-170876388", "%#d", +__LINE__, -0x001aa36L, "-109110", "%-#d", +__LINE__, 0x03012091L, "3012091", "%+2.5X", +__LINE__, -0x00009edL, "-002541", "%-0.6ld", +__LINE__, 0x0000001dL, "1d", "%x", +__LINE__, 0xffffe315L, "FFFFE315", "%+4X", +__LINE__, 0x0000716bL, "716B", "%X", +__LINE__, 0xfffb8315L, "0xfffb8315", "%+#x", +__LINE__, 0x00000132L, "132 ", "%-7.3x", +__LINE__, 0x00000000L, "+0000000", "%+1.7d", +__LINE__, 0xe16d27abL, "E16D27AB", "%X", +__LINE__, 0xffffffe5L, "ffffffe5", "%+x", +__LINE__, -0x000ab9dL, "-43933", "%ld", +__LINE__, 0xffd042d6L, "ffd042d6", "%2x", +__LINE__, 0xffffff9bL, "ffffff9b", "%x", +__LINE__, 0x000000fbL, "0xfb", "% #1.x", +__LINE__, 0x0000000fL, " 15", "%#3ld", +__LINE__, 0xfffba2d8L, "0XFFFBA2D8", "%-#0.X", +__LINE__, 0xfffffff8L, "0XFFFFFFF8", "% #X", +__LINE__, 0x00000000L, " ", "%4.ld", +__LINE__, 0x00000002L, "2", "%+x", +__LINE__, 0xfffff314L, "FFFFF314", "%-X", +__LINE__, 0x00000000L, " 0", "% ld", +__LINE__, -0x0000007L, "-07", "%3.2ld", +__LINE__, 0xffffdd80L, "FFFFDD80", "%.6X", +__LINE__, -0x000001bL, "-27", "%-ld", +__LINE__, -0x0000258L, "-600", "%-0d", +__LINE__, 0x00016377L, "16377", "%3X", +__LINE__, 0x00000001L, "1", "%X", +__LINE__, -0xac5d314L, "-180736788", "%d", +__LINE__, -0x000036eL, "-878", "% ld", +__LINE__, 0xfe346af4L, "fe346af4", "%.5x", +__LINE__, 0xffffffe1L, "ffffffe1", "%-7.6x", +__LINE__, -0x0a1df07L, "-10608391", "%#.5d", +__LINE__, 0x000000c9L, " 0XC9", "%+#5.X", +__LINE__, 0xfffffffeL, "fffffffe", "%x", +__LINE__, 0xfffffff8L, "fffffff8", "%+x", +__LINE__, -0x4517255L, "-72446549", "%.6ld", +__LINE__, 0xfffa3670L, "FFFA3670", "%-6X", +__LINE__, 0xffffffe0L, "ffffffe0", "%2.x", +__LINE__, 0xffffffffL, "ffffffff", "%0x", +__LINE__, 0x0000230dL, "8973", "%#.1d", +__LINE__, 0x00000238L, "238", "%0X", +__LINE__, 0xfffce5abL, "FFFCE5AB", "%-X", +__LINE__, 0x0000002cL, "2C", "%X", +__LINE__, 0x00000001L, " 1", "%4.ld", +__LINE__, 0xffffff8dL, "FFFFFF8D", "%-X", +__LINE__, 0x00069c69L, "433257", "%06d", +__LINE__, 0xfffffb8dL, "0xfffffb8d", "%#x", +__LINE__, 0x000d6a2dL, "879149", "%5.5d", +__LINE__, -0x0001fcbL, " -8139", "%7.ld", +__LINE__, 0xfff86937L, "fff86937", "%-0x", +__LINE__, 0x00059cf9L, "367865", "%#.0ld", +__LINE__, 0x02c5d87aL, "46520442", "%3.ld", +__LINE__, 0x00000571L, "1393", "%ld", +__LINE__, 0x0003c73fL, "+247615", "%+4ld", +__LINE__, 0x0000004fL, "4f", "% 0x", +__LINE__, 0x00000000L, "0", "%-ld", +__LINE__, -0x0e5850fL, "-15041807", "% ld", +__LINE__, -0x0000002L, " -0002", "%7.4d", +__LINE__, 0xfffffd1bL, "fffffd1b", "%05x", +__LINE__, 0x0000041cL, " 1052", "% #0.ld", +__LINE__, -0x0000030L, "-48", "%d", +__LINE__, -0x0013593L, "-79251", "% #d", +__LINE__, 0x00000001L, "1", "%+X", +__LINE__, 0x0000056bL, " 56b", "%4.x", +__LINE__, -0x0000004L, "-4 ", "%-3d", +__LINE__, -0x0000003L, "-3", "% ld", +__LINE__, 0xffff7c14L, "0XFFFF7C14", "%#X", +__LINE__, 0x02f63dd8L, "49692120", "%.7ld", +__LINE__, -0x03c51c9L, "-3953097", "%+d", +__LINE__, 0x00ded685L, "14603909", "%5.ld", +__LINE__, 0xffffffbaL, "ffffffba", "%x", +__LINE__, 0x000370e8L, "225512", "%#ld", +__LINE__, 0x00000003L, "3", "%X", +__LINE__, -0x0024a64L, "-150116", "%7.d", +__LINE__, 0xff486ca1L, "ff486ca1", "%x", +__LINE__, 0x000001cfL, "1CF", "% X", +__LINE__, -0x0002d7eL, "-11646", "%-0d", +__LINE__, 0x0a594c65L, "a594c65", "%.4x", +__LINE__, -0x0000002L, "-0002", "%-5.4ld", +__LINE__, 0x00000000L, "", "%00.ld", +__LINE__, 0x00058bc4L, "58BC4", "%3X", +__LINE__, 0x0002cf8eL, " 184206", "% 0ld", +__LINE__, 0x000009c7L, "+2503", "%+4.ld", +__LINE__, 0xed0c984dL, "ED0C984D", "%X", +__LINE__, -0x0000058L, "-088", "%#.3ld", +__LINE__, 0x0076083dL, "0X76083D", "%#6X", +__LINE__, -0x0000001L, "-1", "%#d", +__LINE__, -0x6bf1777L, "-113186679", "%#ld", +__LINE__, -0x000011fL, "-287", "%ld", +__LINE__, 0x001b0e7dL, "1B0E7D", "%-4X", +__LINE__, 0x000007acL, " 1964", "%5.ld", +__LINE__, 0x00000005L, "5", "%0.d", +__LINE__, -0x00003baL, "-954", "%4.0ld", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%X", +__LINE__, 0x00000019L, "19", "%x", +__LINE__, 0xffffffe0L, "ffffffe0", "%-.6x", +__LINE__, 0x0000012aL, " 298", "% d", +__LINE__, 0x00002c74L, "2c74", "% 4.3x", +__LINE__, 0x000002d5L, "725", "%d", +__LINE__, 0x0001c9a9L, "1c9a9", "%-02x", +__LINE__, 0xffc928c8L, "ffc928c8", "%x", +__LINE__, -0x03ae51fL, "-3859743", "% #ld", +__LINE__, 0x0000526dL, "526d", "%x", +__LINE__, -0x00028f0L, "-10480", "%5ld", +__LINE__, -0x49b4262L, "-77283938", "%+02.0d", +__LINE__, 0x028d37f0L, "0x28d37f0", "%+#x", +__LINE__, 0xd66e0af9L, "D66E0AF9", "%03.X", +__LINE__, -0x00c7707L, "-816903", "%0d", +__LINE__, -0x00000d0L, "-208", "%-.1ld", +__LINE__, 0x0000c328L, "49960", "%d", +__LINE__, 0x34cb86f1L, "34CB86F1", "%X", +__LINE__, 0x000000f6L, "F6", "%+X", +__LINE__, 0x0a3407ecL, "0xa3407ec", "%-#x", +__LINE__, 0x00007ebcL, "32444", "%#3.d", +__LINE__, 0xfffd3d65L, "fffd3d65", "%x", +__LINE__, 0x0007bc82L, "0507010", "%0.7d", +__LINE__, 0x0005bb93L, "375699", "%ld", +__LINE__, 0x0ec11cc8L, "0XEC11CC8", "%+#6.2X", +__LINE__, 0xfffff9c6L, "fffff9c6", "%.5x", +__LINE__, 0xff05ab70L, "0XFF05AB70", "%-#.3X", +__LINE__, 0x2328b716L, "589870870", "%d", +__LINE__, 0x00001a79L, "6777", "%.1d", +__LINE__, 0xfffee573L, "fffee573", "%0.1x", +__LINE__, -0x0000929L, " -2345", "%7.d", +__LINE__, 0xffffff9aL, "FFFFFF9A", "%2.X", +__LINE__, 0xfffffe60L, "fffffe60", "%.5x", +__LINE__, 0xfffffcd2L, "fffffcd2", "%.7x", +__LINE__, 0x00000001L, " 001", "%6.3X", +__LINE__, 0x00011e9cL, "+73372", "%+0ld", +__LINE__, 0x0000002aL, "2a", "% x", +__LINE__, 0xffffffffL, "ffffffff", "%.7x", +__LINE__, -0x0008ee8L, "-36584", "%ld", +__LINE__, 0x0000001cL, "28", "%-d", +__LINE__, 0x000abedaL, "704218", "%d", +__LINE__, 0x001347f7L, "1347f7", "%3.0x", +__LINE__, 0x0000023eL, "574", "%3.3ld", +__LINE__, 0x00000000L, "0", "%-ld", +__LINE__, -0x0016de0L, "-93664", "%0ld", +__LINE__, 0xffffff45L, "FFFFFF45", "% X", +__LINE__, 0x02dfb08cL, "48214156", "%#ld", +__LINE__, 0x003d73a2L, "3d73a2", "%6.x", +__LINE__, 0x00147da7L, "1342887", "%#d", +__LINE__, -0x5ff0f1eL, "-100601630", "%-01ld", +__LINE__, -0x000000bL, "-11", "%ld", +__LINE__, 0x00000168L, " 168", "%+6.x", +__LINE__, 0xffffc28eL, "ffffc28e", "%0x", +__LINE__, -0x00003a2L, "-930", "%ld", +__LINE__, 0x0002e56fL, " 189807", "% 1.ld", +__LINE__, 0x51abf44fL, "0x51abf44f", "%#.7x", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, 0x9581268fL, "9581268F", "%+X", +__LINE__, 0xffffff3bL, "FFFFFF3B", "%X", +__LINE__, 0x000083d4L, " 33748", "% #d", +__LINE__, 0x00000001L, "1", "%x", +__LINE__, -0x000e51fL, "-58655", "%.0ld", +__LINE__, 0x0003eacbL, "256715", "%6ld", +__LINE__, 0x02be09dbL, " 46008795", "% 0.ld", +__LINE__, 0xfffffffbL, "FFFFFFFB", "% X", +__LINE__, 0x000084f5L, " 34037", "%6ld", +__LINE__, -0x1127f99L, "-17989529", "%#d", +__LINE__, 0x5f6512deL, "5f6512de", "%.7x", +__LINE__, 0x00000001L, "1", "%x", +__LINE__, 0xfff74ab5L, "fff74ab5", "%x", +__LINE__, 0x0eebeb94L, "250342292", "%4.ld", +__LINE__, 0x0001b846L, "0x1b846", "%#1x", +__LINE__, 0x001e8c32L, "1E8C32", "%2X", +__LINE__, -0x0dae932L, "-14346546", "%5.1d", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, -0x0000042L, "-66", "%ld", +__LINE__, 0xffffff51L, "FFFFFF51", "%0.1X", +__LINE__, 0x00000043L, "43", "%x", +__LINE__, 0x04c21f39L, " 79830841", "% 0ld", +__LINE__, 0x0000061eL, "1566", "%03.3d", +__LINE__, -0x0000003L, "-3", "%+d", +__LINE__, 0x015b32dbL, " 22754011", "% .4d", +__LINE__, 0xfffff181L, "FFFFF181", "%-X", +__LINE__, 0x000017ecL, "0X17EC", "%#X", +__LINE__, 0x000d703eL, "880702", "%#ld", +__LINE__, -0x6d7533a0L, "-1836397472", "%ld", +__LINE__, 0x0000008aL, " 138", "% d", +__LINE__, -0x7368794bL, "-1936226635", "%+#d", +__LINE__, 0x0000000dL, "0XD", "%#X", +__LINE__, 0x0000030dL, "30D", "% X", +__LINE__, 0xfffff9feL, "FFFFF9FE", "%5X", +__LINE__, 0x00001bb2L, "7090", "%d", +__LINE__, 0x041d2a0cL, "41D2A0C", "%0X", +__LINE__, 0x00012aeeL, " 76526", "% d", +__LINE__, 0x0000055fL, "55f", "%.1x", +__LINE__, 0xffffffffL, "0XFFFFFFFF", "%#1X", +__LINE__, 0x07b0a971L, "+129018225", "%+.2ld", +__LINE__, 0xfffffff8L, "FFFFFFF8", "%4X", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, 0x00000038L, "+56", "%+2ld", +__LINE__, 0xfffffc2fL, "fffffc2f", "%+7.x", +__LINE__, 0x00004477L, "0x4477", "% #x", +__LINE__, 0x0000000dL, "0XD", "%+#3X", +__LINE__, 0xf5bf37b1L, "F5BF37B1", "%1.X", +__LINE__, 0x1a96f431L, "446100529", "%d", +__LINE__, 0x0037edf3L, "+3665395", "%+#4.5ld", +__LINE__, 0x0007f2aaL, "520874", "%0ld", +__LINE__, -0x00051a3L, "-20899", "%+#1.ld", +__LINE__, 0x0000037fL, "37F", "%0X", +__LINE__, 0xffffffb4L, "ffffffb4", "%x", +__LINE__, -0xd984c00L, "-228084736", "%+06ld", +__LINE__, 0xffffe1beL, "FFFFE1BE", "%X", +__LINE__, 0xfff20d48L, "FFF20D48", "%+6.0X", +__LINE__, 0x000028b7L, "0x028b7", "%-#7.5x", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, 0x03f37945L, "66287941", "%d", +__LINE__, 0xffffffedL, "0XFFFFFFED", "%+#6.4X", +__LINE__, 0x0000f046L, "f046", "%x", +__LINE__, 0xe9772b51L, "E9772B51", "%-1.X", +__LINE__, 0xfffffffeL, "fffffffe", "% x", +__LINE__, 0xfffffffaL, "0xfffffffa", "%#x", +__LINE__, 0x00000015L, "15", "%-X", +__LINE__, 0x0000003cL, "60", "%#ld", +__LINE__, 0x3103952dL, "822318381", "%0.ld", +__LINE__, 0x17ba68bbL, "398092475", "%2d", +__LINE__, 0x000006c4L, "+1732", "%+.2d", +__LINE__, 0x00000043L, "67", "%#d", +__LINE__, 0x0043fb55L, "4455253", "%.1ld", +__LINE__, 0x00004b76L, "4b76", "% 0x", +__LINE__, 0xfff4c56bL, "FFF4C56B", "%7X", +__LINE__, 0x00766055L, "766055", "%+5x", +__LINE__, -0x000009fL, "-159", "%+d", +__LINE__, 0xffff063fL, "ffff063f", "%-2x", +__LINE__, 0x00808fc8L, "808fc8", "%x", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, 0x000000f1L, "00000f1", "%+02.7x", +__LINE__, 0x00000002L, "2", "%X", +__LINE__, 0x00000000L, "000", "%03d", +__LINE__, 0xe63f73b2L, "E63F73B2", "% 1X", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%5.1X", +__LINE__, 0x0d3fa38bL, "222274443", "%1d", +__LINE__, 0x00000000L, "0", "% X", +__LINE__, 0x00000001L, " 1", "%04.ld", +__LINE__, 0x00000046L, "46", "%0X", +__LINE__, 0x0000761fL, " 30239", "% ld", +__LINE__, -0x0002517L, "-9495", "%+d", +__LINE__, 0x00000156L, "156", "% 0x", +__LINE__, 0x1c55eba2L, "1c55eba2", "%.6x", +__LINE__, 0x005af80dL, "5af80d", "%.6x", +__LINE__, 0x0000002eL, "46", "%d", +__LINE__, -0x0007c0fL, "-31759", "%ld", +__LINE__, 0xffffe924L, "FFFFE924", "%7X", +__LINE__, 0x00000174L, "372", "%ld", +__LINE__, 0xffffffc9L, "0xffffffc9", "%-#x", +__LINE__, 0x00000020L, "+000032", "%+07d", +__LINE__, 0xffffe5d9L, "FFFFE5D9", "%4.5X", +__LINE__, 0xffffffa3L, "FFFFFFA3", "%+.3X", +__LINE__, 0x00000a03L, "+2563", "%+2d", +__LINE__, 0x001b58caL, "+1792202", "%+4d", +__LINE__, 0xffffffc9L, "0xffffffc9", "%+#5x", +__LINE__, -0x0000003L, "-3", "% d", +__LINE__, 0xfffffffcL, "fffffffc", "%+0x", +__LINE__, -0x0000002L, "-02", "%.2d", +__LINE__, 0x000243fbL, "148475", "%-ld", +__LINE__, 0x00000001L, "1", "%0d", +__LINE__, -0x0000672L, "-1650", "%ld", +__LINE__, -0x0005413L, "-0021523", "% 7.7d", +__LINE__, 0x00000017L, "0X17", "%#X", +__LINE__, 0x00000e48L, "3656", "%0d", +__LINE__, 0xffe79b38L, "ffe79b38", "%-x", +__LINE__, 0xffffff15L, "FFFFFF15", "%+6.1X", +__LINE__, 0xfff0272cL, "fff0272c", "%-.5x", +__LINE__, -0x00b706fL, "-749679", "%1.ld", +__LINE__, 0x0176aeecL, "176AEEC", "%.1X", +__LINE__, -0x00005a1L, "-1441", "% 0ld", +__LINE__, -0x0000002L, "-00002", "%.5d", +__LINE__, -0xd2e6f5dL, "-221146973", "%1ld", +__LINE__, -0x0000001L, " -001", "%5.3ld", +__LINE__, 0x00000001L, " 1", "%05.ld", +__LINE__, 0x0000749eL, "+29854", "%+#d", +__LINE__, 0x00000005L, "5", "%d", +__LINE__, 0xfa7128b0L, "fa7128b0", "%1.x", +__LINE__, 0xffffbbb4L, "0XFFFFBBB4", "%#.1X", +__LINE__, 0x0006862fL, "427567", "%d", +__LINE__, 0x00000002L, "2", "%X", +__LINE__, 0x000005d4L, "5d4", "% x", +__LINE__, 0x001387e1L, "1279969", "%-05.0ld", +__LINE__, -0x0035a56L, "-219734", "%ld", +__LINE__, -0x4064ecc6L, "-1080356038", "%ld", +__LINE__, 0x0000360dL, "13837", "%0ld", +__LINE__, -0xea1a85bL, "-245475419", "%-.2ld", +__LINE__, 0xffffff2dL, "FFFFFF2D", "%X", +__LINE__, 0x00000004L, " 0004", "%7.4x", +__LINE__, 0x00f72ffdL, "F72FFD", "%-X", +__LINE__, 0x00000fa2L, "fa2 ", "%-5x", +__LINE__, 0x05ae1f9aL, "95297434", "%#ld", +__LINE__, 0x0000bf2eL, "48942", "%3.d", +__LINE__, 0x00000000L, " ", "%1.X", +__LINE__, 0x01bcb097L, "29143191", "%ld", +__LINE__, 0x0000009cL, "156 ", "%-4.0d", +__LINE__, 0xfffffffeL, "fffffffe", "% x", +__LINE__, 0x00000001L, "1 ", "%-6.d", +__LINE__, 0xffffffefL, "ffffffef", "%7.x", +__LINE__, 0xfffffec1L, "fffffec1", "%.5x", +__LINE__, -0x000000fL, "-15", "%-1d", +__LINE__, -0x0008426L, "-33830", "%0ld", +__LINE__, 0x005be0aeL, "5BE0AE", "% X", +__LINE__, 0x00000009L, " 9", "%+7X", +__LINE__, -0x0007e18L, "-32280", "%+0.d", +__LINE__, 0x01697ba1L, " 23690145", "% 5.ld", +__LINE__, -0x0012042L, "-073794", "%7.6d", +__LINE__, 0x04e9bd0dL, "4e9bd0d", "%-2x", +__LINE__, 0xffffffd9L, "FFFFFFD9", "%.2X", +__LINE__, -0x01b9632L, "-1807922", "%.6ld", +__LINE__, 0x000000cdL, "205", "%1.ld", +__LINE__, 0x00000000L, " ", "% .0d", +__LINE__, 0xff17bbb1L, "ff17bbb1", "%x", +__LINE__, -0x00146d7L, "-83671", "%+1.ld", +__LINE__, 0xfffff144L, "fffff144", "%x", +__LINE__, 0x000f8dbeL, "F8DBE", "%3.X", +__LINE__, -0x000381cL, "-14364", "%d", +__LINE__, 0x0000001eL, " 30", "%4.1d", +__LINE__, 0x00000016L, "22", "%-0d", +__LINE__, 0x00000002L, "+02", "%+1.2ld", +__LINE__, 0x0000e803L, "59395", "%d", +__LINE__, 0xb4c2448dL, "b4c2448d", "%-7x", +__LINE__, 0x000e697dL, "944509", "%ld", +__LINE__, 0xfffe6e32L, "0XFFFE6E32", "%#X", +__LINE__, 0x00000190L, " 190", "%+5.X", +__LINE__, -0x03a2219L, "-3809817", "%#6.ld", +__LINE__, -0x000003cL, "-60 ", "%-#4.ld", +__LINE__, 0x00000000L, " ", "% 03.ld", +__LINE__, -0x074f922L, "-7665954", "%ld", +__LINE__, -0x00000f0L, "-240", "%-ld", +__LINE__, 0xfffe42d2L, "0XFFFE42D2", "%#X", +__LINE__, 0x000000ddL, "DD", "%X", +__LINE__, 0x00359abeL, "359ABE", "%.1X", +__LINE__, 0xffec7bdfL, "FFEC7BDF", "%0.1X", +__LINE__, 0x0ecddcbaL, "248372410", "%-#3.d", +__LINE__, 0x00ad0dbcL, "11341244", "%ld", +__LINE__, -0x0000001L, "-1", "%-d", +__LINE__, 0x00050841L, "50841", "% .5x", +__LINE__, 0x01d359e7L, "1d359e7", "%1.x", +__LINE__, 0xff9efaa3L, "FF9EFAA3", "%X", +__LINE__, 0x0007ea10L, "+518672", "%+ld", +__LINE__, -0x000671cL, "-26396", "%1d", +__LINE__, 0xffffff91L, "0xffffff91", "%#4.4x", +__LINE__, 0x00000000L, "+", "%+0.0ld", +__LINE__, -0x002c53eL, "-181566", "%3.d", +__LINE__, 0xffffff56L, "ffffff56", "%x", +__LINE__, 0xfffff589L, "FFFFF589", "%+X", +__LINE__, 0x00024d13L, "24D13", "%-5.2X", +__LINE__, 0x00000000L, " 0", "%6.1d", +__LINE__, 0x00a64f33L, "A64F33", "%4.4X", +__LINE__, 0xffebb57aL, "FFEBB57A", "%5.4X", +__LINE__, 0xfff3b4a0L, "fff3b4a0", "%2.x", +__LINE__, 0xffffffd9L, "FFFFFFD9", "%.2X", +__LINE__, 0x00d37b84L, "13859716", "%d", +__LINE__, 0x00001e85L, "0001E85", "%0.7X", +__LINE__, -0x756148fL, "-123081871", "% 7.d", +__LINE__, -0x0319339L, "-3248953", "%+#.4d", +__LINE__, -0x00798b8L, "-497848", "%#5ld", +__LINE__, -0x0000039L, "-57", "%0d", +__LINE__, -0x000b1d7L, "-45527", "%+0.ld", +__LINE__, 0xff811fbaL, "FF811FBA", "%+X", +__LINE__, 0x00000042L, " 66", "% ld", +__LINE__, 0xfffffe31L, "0XFFFFFE31", "%#X", +__LINE__, 0x00000073L, "115", "%ld", +__LINE__, 0x45091a39L, "0x45091a39", "%+#3.x", +__LINE__, 0x001270f5L, "1270f5", "%-5.6x", +__LINE__, 0xfffd91fdL, "fffd91fd", "%x", +__LINE__, -0x0817badL, "-8485805", "%#ld", +__LINE__, -0x32ad55fL, "-53138783", "%0d", +__LINE__, 0x00003e57L, "15959", "%0ld", +__LINE__, -0x0048756L, "-296790", "%2.6d", +__LINE__, 0xff90f45fL, "FF90F45F", "% X", +__LINE__, 0x0000e454L, "0e454", "% .5x", +__LINE__, 0xfffffffcL, "fffffffc", "%x", +__LINE__, 0xfffffff7L, "FFFFFFF7", "%-2X", +__LINE__, 0xffdabf0eL, "FFDABF0E", "%+X", +__LINE__, 0xffffffffL, "0XFFFFFFFF", "%#1X", +__LINE__, 0x01516650L, "1516650", "% x", +__LINE__, 0xffffff51L, "FFFFFF51", "%X", +__LINE__, 0x000000eaL, "234", "%00.d", +__LINE__, 0x06db60caL, "115040458", "%5.d", +__LINE__, 0x00000f01L, " 3841", "% d", +__LINE__, 0x00000009L, "9", "%x", +__LINE__, 0x299b3ba0L, "299b3ba0", "%6.7x", +__LINE__, 0x0067f298L, "67f298", "%-2.6x", +__LINE__, 0xfffffff5L, "FFFFFFF5", "% 2X", +__LINE__, 0x00102ff9L, "102FF9", "%-.0X", +__LINE__, 0xffc22393L, "0xffc22393", "% #6x", +__LINE__, 0x00007db5L, "32181", "%-2ld", +__LINE__, 0x0000b0a3L, "0xb0a3", "%#0x", +__LINE__, 0x001ceebbL, "1CEEBB", "%-3.4X", +__LINE__, 0x00025101L, "0x25101", "%#x", +__LINE__, -0x0000001L, "-1", "%0ld", +__LINE__, 0xffffd846L, "FFFFD846", "%+2.3X", +__LINE__, 0x00001d79L, " 7545", "% 0.1ld", +__LINE__, -0x0000002L, " -2", "%5d", +__LINE__, 0xf93b9fdcL, "f93b9fdc", "%5x", +__LINE__, 0xffff0021L, "FFFF0021", "%6X", +__LINE__, 0x00007cf9L, "7cf9", "%3.1x", +__LINE__, -0x0000002L, "-2", "%d", +__LINE__, 0x00001d84L, "1d84", "%0x", +__LINE__, -0x033201eL, "-3350558", "%-2.0d", +__LINE__, 0xfff8a6fbL, "FFF8A6FB", "%+.7X", +__LINE__, 0x00006fffL, " 28671", "% ld", +__LINE__, -0x02a274aL, "-2762570", "%d", +__LINE__, -0x0006628L, "-26152", "%00ld", +__LINE__, 0x00000011L, "11", "%-x", +__LINE__, -0x0000ed9L, "-3801", "%0.ld", +__LINE__, 0xfc5b725dL, "FC5B725D", "%X", +__LINE__, 0x3530bd4eL, "892386638", "%7.d", +__LINE__, 0x03bb4ff7L, "62607351", "%#4.7ld", +__LINE__, 0x00009f86L, "9f86", "%x", +__LINE__, 0x0000e727L, "59175", "%1d", +__LINE__, 0xfffffdf2L, "0XFFFFFDF2", "%#X", +__LINE__, 0x00e60dbfL, "0XE60DBF", "% #1.X", +__LINE__, 0xffffffffL, "FFFFFFFF", "%+X", +__LINE__, 0x0a16f44eL, "0XA16F44E", "%#.0X", +__LINE__, 0x0001f97cL, "1f97c", "% x", +__LINE__, 0x0000000dL, "13", "%#0ld", +__LINE__, 0x0000002aL, "42", "%0ld", +__LINE__, 0x00000007L, " +7", "%+5ld", +__LINE__, 0xffffff7fL, "FFFFFF7F", "%-X", +__LINE__, 0x000006a6L, "1702", "%ld", +__LINE__, 0xfaff2fb1L, "faff2fb1", "% x", +__LINE__, 0xffff94abL, "ffff94ab", "%x", +__LINE__, 0x011d611bL, "0X11D611B", "%#2.3X", +__LINE__, 0x00000000L, " +000", "%+#5.3ld", +__LINE__, -0x87fcc37L, "-142593079", "%+d", +__LINE__, -0x0417424L, "-4289572", "%+d", +__LINE__, 0x03fabc0cL, "3fabc0c", "%x", +__LINE__, 0xfffff880L, "fffff880", "%-x", +__LINE__, 0x000002d7L, "2d7", "%-02.x", +__LINE__, 0x00003e82L, "16002", "%#d", +__LINE__, -0x0003713L, "-14099", "% 5d", +__LINE__, -0x0000027L, "-39", "%ld", +__LINE__, 0x00013098L, "0077976", "%01.7d", +__LINE__, -0x000000cL, "-12", "%ld", +__LINE__, -0x00000c0L, "-192", "% ld", +__LINE__, 0xffbe9285L, "FFBE9285", "%3.X", +__LINE__, 0x00000046L, "46", "%x", +__LINE__, 0x00000000L, " ", "%+4.x", +__LINE__, 0x00011e72L, "73330", "%2.3d", +__LINE__, -0x5276dd7L, "-86470103", "%d", +__LINE__, 0x00000013L, "19", "%-02.ld", +__LINE__, 0x384118a7L, "0X384118A7", "%-#X", +__LINE__, 0x00000000L, "0", "% #X", +__LINE__, 0x00000009L, "9", "%#ld", +__LINE__, 0x00021145L, "135493", "%-ld", +__LINE__, 0xff188a0cL, "FF188A0C", "%1.X", +__LINE__, 0xffffffd5L, "ffffffd5", "%0x", +__LINE__, 0xfffffffeL, "FFFFFFFE", "% 0X", +__LINE__, 0xffff74a3L, "ffff74a3", "%x", +__LINE__, 0x01d5a2f8L, "1d5a2f8", "%-0.x", +__LINE__, 0xfffffef6L, "fffffef6", "%+06.x", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, 0x00000000L, "+0", "%+ld", +__LINE__, 0xfffffffcL, "fffffffc", "%4.x", +__LINE__, -0x0000344L, "-0836", "% .4d", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%0X", +__LINE__, 0x000a3121L, "667937", "%#4.4ld", +__LINE__, 0x0001e211L, "0X1E211", "%#X", +__LINE__, 0x00000c8bL, "00C8B", "%05X", +__LINE__, 0xfffffffeL, "fffffffe", "%+0x", +__LINE__, 0x001a53ceL, "1725390", "%d", +__LINE__, 0x0000057fL, "57f ", "%-7.x", +__LINE__, -0x0073e4dL, "-474701", "%#ld", +__LINE__, -0x0000002L, " -2", "% 3.d", +__LINE__, 0x482dc404L, "482DC404", "%X", +__LINE__, 0x0000011cL, "11c", "%-.1x", +__LINE__, 0x00000c12L, " 3090", "%5.3ld", +__LINE__, 0xfffe1068L, "FFFE1068", "%-.4X", +__LINE__, -0x0055e88L, "-351880", "%ld", +__LINE__, 0x000c9cefL, "+826607", "%+d", +__LINE__, 0xffffffe3L, "ffffffe3", "%0x", +__LINE__, -0x0000ee9L, "-3817", "%#ld", +__LINE__, 0xff1f6daaL, "FF1F6DAA", "%X", +__LINE__, 0xfffffc4eL, "FFFFFC4E", "%5.2X", +__LINE__, -0x000040aL, "-1034", "%d", +__LINE__, -0x0000085L, "-00133", "% 01.5d", +__LINE__, -0x126c797cL, "-309098876", "%5.ld", +__LINE__, 0x00000039L, " 57", "% d", +__LINE__, 0xfffffff6L, "0xfffffff6", "%#5.x", +__LINE__, 0xfffffff4L, "fffffff4", "%7.6x", +__LINE__, 0x00000003L, "3", "%ld", +__LINE__, 0x0000f8aeL, "f8ae", "%.0x", +__LINE__, 0x003ca1cfL, "3973583", "%#3.7d", +__LINE__, 0x14687009L, "0x14687009", "%+#3x", +__LINE__, 0xfffff1f7L, "0xfffff1f7", "%#4.5x", +__LINE__, 0xfffff17aL, "fffff17a", "%3.x", +__LINE__, 0x0011ea18L, "1174040", "%ld", +__LINE__, -0x0000019L, "-25", "%03.d", +__LINE__, 0x00015d72L, "0X15D72", "%-#X", +__LINE__, 0xffde4a41L, "ffde4a41", "%x", +__LINE__, 0x00006f1fL, "28447", "%d", +__LINE__, 0xffffffbdL, "0xffffffbd", "%#.1x", +__LINE__, 0x000013b9L, "13B9", "%0X", +__LINE__, -0x00001b9L, "-00441", "%1.5d", +__LINE__, 0x00000001L, "000001", "%-.6d", +__LINE__, 0x7b602d8fL, "+2069900687", "%+0ld", +__LINE__, 0x0005e323L, "+385827", "%+ld", +__LINE__, 0x00002fceL, "2FCE", "%+0X", +__LINE__, 0x0000000eL, "0014", "%.4d", +__LINE__, 0xffffffd6L, "0XFFFFFFD6", "%#4.X", +__LINE__, 0x037bf361L, "58454881", "%5.ld", +__LINE__, 0xffffffffL, "FFFFFFFF", "%-7.5X", +__LINE__, -0x016d4dcL, "-1496284", "%6ld", +__LINE__, 0x0005be9aL, "0x5be9a", "%-#.5x", +__LINE__, 0xffffffffL, "ffffffff", "%1x", +__LINE__, 0x00000055L, " 85", "% 7.d", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, -0x0135392L, "-1266578", "% ld", +__LINE__, 0x00850f26L, "8720166", "%d", +__LINE__, 0xffffee39L, "ffffee39", "%0x", +__LINE__, 0x000000ddL, "221", "%ld", +__LINE__, 0x00000000L, " ", "%6.d", +__LINE__, 0x000000d8L, "d8", "%x", +__LINE__, 0x000007ecL, "002028", "%4.6ld", +__LINE__, 0x0dab4e67L, "0XDAB4E67", "%#X", +__LINE__, 0xfffd7c95L, "FFFD7C95", "% 4X", +__LINE__, 0x0009302dL, "9302D", "%3.1X", +__LINE__, 0x00000003L, " 3", "% d", +__LINE__, 0x0000082fL, "82f", "%-x", +__LINE__, 0x0652517fL, "652517F", "%-.2X", +__LINE__, -0x1fd8f4e3L, "-534312163", "%d", +__LINE__, 0x00000176L, "176", "%-x", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, 0x0000001aL, "1A", "%X", +__LINE__, -0x0005740L, "-22336", "% 0ld", +__LINE__, 0xffffffffL, "ffffffff", "%6x", +__LINE__, 0x1b273b80L, "0x1b273b80", "%#x", +__LINE__, 0x00000065L, "65", "%X", +__LINE__, 0x6a62138aL, "1784812426", "%2ld", +__LINE__, 0x000001a2L, "1A2", "%X", +__LINE__, -0x002aafdL, "-174845", "%02.ld", +__LINE__, 0x00000014L, "20", "%d", +__LINE__, -0x00000c7L, " -199", "%7.0ld", +__LINE__, 0xff545bfdL, "ff545bfd", "%-x", +__LINE__, -0x002beb9L, "-179897", "%02.2ld", +__LINE__, -0x00000dfL, "-223", "% 02.d", +__LINE__, -0x000d569L, "-54633", "%1.ld", +__LINE__, 0x0000000eL, "14", "%d", +__LINE__, -0x0077407L, "-488455", "% ld", +__LINE__, 0x0001be09L, "114185", "%ld", +__LINE__, -0x0000514L, "-01300", "%+05.5d", +__LINE__, 0xf1fb397fL, "f1fb397f", "%+x", +__LINE__, 0xfdb6707cL, "FDB6707C", "%X", +__LINE__, 0x03cad111L, "3cad111", "%5.x", +__LINE__, -0x022e72fL, "-2287407", "%d", +__LINE__, -0xda35f48L, "-228810568", "%d", +__LINE__, -0x02d1fd4L, "-2957268", "%1.3d", +__LINE__, 0x0000005fL, "+95", "%+2d", +__LINE__, 0xfffbf8a1L, "FFFBF8A1", "%4.2X", +__LINE__, 0x0000071eL, " 71e", "%6.x", +__LINE__, 0x000cc8a5L, "+837797", "%+03ld", +__LINE__, 0x000eebe9L, " EEBE9", "%6.X", +__LINE__, -0x2896b204L, "-680964612", "%d", +__LINE__, -0x09553f8L, "-9786360", "%d", +__LINE__, 0x000015d3L, "5587", "%0d", +__LINE__, 0x0000056dL, " 56d", "%+4.x", +__LINE__, -0x00624adL, "-402605", "% ld", +__LINE__, 0xfea64ba5L, "0xfea64ba5", "%#1x", +__LINE__, 0x004f35c6L, "5191110", "%-ld", +__LINE__, -0x1441fe4L, "-21241828", "%d", +__LINE__, 0xffffff95L, "FFFFFF95", "%X", +__LINE__, 0xfffecf81L, "FFFECF81", "%-2.X", +__LINE__, -0x00002bbL, "-699", "%-d", +__LINE__, -0x0000c29L, "-3113", "% 02ld", +__LINE__, 0x000026a3L, " 9891", "% .4d", +__LINE__, 0x00000003L, "3", "%-x", +__LINE__, 0x000007dbL, "+02011", "%+.5ld", +__LINE__, 0xfff99558L, "FFF99558", "%.1X", +__LINE__, 0x0000fce6L, "64742", "%4.0d", +__LINE__, 0x000b7ea2L, "753314", "%ld", +__LINE__, 0x13e5df30L, "0X13E5DF30", "%#2.X", +__LINE__, 0x006761c4L, "06761C4", "%6.7X", +__LINE__, 0xffffff78L, "FFFFFF78", "%0.X", +__LINE__, 0xfffff1c0L, "0xfffff1c0", "% #x", +__LINE__, -0x034af1cL, "-3452700", "% 06.1d", +__LINE__, 0x000000deL, "0000222", "%2.7ld", +__LINE__, 0x000003d8L, "0x3d8", "%#4.x", +__LINE__, -0x001a1d1L, "-106961", "%3.1d", +__LINE__, -0x0000002L, "-2", "% d", +__LINE__, 0x00001de6L, "+7654", "%+0ld", +__LINE__, 0x00000001L, "001", "%#.3d", +__LINE__, -0x53dacf9fL, "-1406848927", "%ld", +__LINE__, 0xfffffffcL, "fffffffc", "%3.3x", +__LINE__, -0x00950e8L, "-610536", "%3.6ld", +__LINE__, 0xff14ade9L, "FF14ADE9", "%6X", +__LINE__, 0x012f5284L, "0X12F5284", "% #5X", +__LINE__, 0x00005a21L, " 5a21", "%5x", +__LINE__, 0x00000638L, "1592", "%2.4ld", +__LINE__, -0x063017bL, "-6488443", "%ld", +__LINE__, 0x00000000L, "0", "% X", +__LINE__, 0xfffe8ef2L, "FFFE8EF2", "%+0X", +__LINE__, -0x0001c96L, "-7318", "%.3d", +__LINE__, 0x0000ca7dL, "51837", "%ld", +__LINE__, 0x00000001L, "1", "%+1x", +__LINE__, 0xfffff7bcL, "FFFFF7BC", "%X", +__LINE__, -0x03d15e2L, "-4003298", "%ld", +__LINE__, 0xfffffffeL, "fffffffe", "% x", +__LINE__, 0x00066183L, "+418179", "%+7.1ld", +__LINE__, 0xffffef2eL, "ffffef2e", "%-2.x", +__LINE__, 0x00000000L, " 000", "%04.3x", +__LINE__, -0x000000fL, "-15", "% d", +__LINE__, -0x00001f5L, "-501", "%d", +__LINE__, 0x0c67f159L, "c67f159", "%6.2x", +__LINE__, -0x0000006L, "-6", "%.1d", +__LINE__, 0x00000005L, "0X5", "%+#1X", +__LINE__, -0x0000002L, " -2", "%6.ld", +__LINE__, 0xeb2183ecL, "eb2183ec", "% x", +__LINE__, -0x5e12a322L, "-1578279714", "%d", +__LINE__, 0x00000001L, "0x1", "%#x", +__LINE__, -0x0001ea4L, "-7844", "%0d", +__LINE__, -0x19955a3L, "-26826147", "%d", +__LINE__, 0x000002a6L, "2A6", "%2.X", +__LINE__, 0x00000002L, "2", "%X", +__LINE__, 0xfffffeecL, "fffffeec", "%0.4x", +__LINE__, 0xfffffffcL, "fffffffc", "%0x", +__LINE__, 0xffdfe740L, "FFDFE740", "% X", +__LINE__, -0x0b0b3e7L, "-11580391", "%.1d", +__LINE__, 0x8e01077cL, "8E01077C", "%5.7X", +__LINE__, 0x3b6b6d55L, "996896085", "%1.1d", +__LINE__, 0x000016afL, "5807", "%ld", +__LINE__, -0x0004900L, "-18688", "%d", +__LINE__, 0xfffd77bcL, "FFFD77BC", "%X", +__LINE__, 0x004cbd74L, "5029236", "%0d", +__LINE__, 0x00000003L, " 00003", "%6.5d", +__LINE__, 0x0004720fL, "4720f", "% x", +__LINE__, 0x0e44535dL, "e44535d", "%4x", +__LINE__, 0xfffffff9L, "FFFFFFF9", "%3.3X", +__LINE__, -0x0000005L, "-5", "%-d", +__LINE__, 0x000001a6L, "00001A6", "%1.7X", +__LINE__, 0x0000004aL, "4A", "%-2.X", +__LINE__, 0xfffff249L, "FFFFF249", "%X", +__LINE__, 0x00004345L, "4345", "%x", +__LINE__, 0x0197041dL, "197041d", "%+0x", +__LINE__, 0x0000019aL, " 19a", "% 6.x", +__LINE__, 0xfff98376L, "FFF98376", "%X", +__LINE__, 0xfc536c41L, "FC536C41", "%X", +__LINE__, -0x0008d91L, "-36241", "% d", +__LINE__, 0xf058d69dL, "f058d69d", "%4.x", +__LINE__, -0x00013efL, "-5103", "%d", +__LINE__, -0x0000003L, "-3", "%00ld", +__LINE__, -0x09e80f0L, "-10387696", "%+07ld", +__LINE__, -0x0222c15L, "-2239509", "%#0.4ld", +__LINE__, 0x00000004L, "4", "%0ld", +__LINE__, -0x02c6b0dL, "-2910989", "% 0ld", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%-4X", +__LINE__, 0xffffff3dL, "FFFFFF3D", "%-.0X", +__LINE__, -0x0000015L, "-21", "%0d", +__LINE__, 0x131dfc90L, "+320732304", "%+d", +__LINE__, 0xffffffffL, "ffffffff", "%+x", +__LINE__, 0x000035c8L, "13768", "%0ld", +__LINE__, 0x00000033L, "0x0033", "%#.4x", +__LINE__, 0x0ce7e8c1L, "0xce7e8c1", "%#.7x", +__LINE__, 0xfc18b5d2L, "FC18B5D2", "%+.3X", +__LINE__, 0x00000015L, "21", "%d", +__LINE__, 0x001a5e7cL, "1a5e7c", "%05x", +__LINE__, -0x000fbf0L, "-64496", "%ld", +__LINE__, -0x000a4f7L, "-042231", "%+2.6d", +__LINE__, -0x0000002L, "-002", "%3.3ld", +__LINE__, 0x00728878L, "728878", "%0X", +__LINE__, -0x0000002L, "-2", "%#.1ld", +__LINE__, -0x00002efL, "-751", "%-0ld", +__LINE__, 0xfffffff7L, "fffffff7", "%.3x", +__LINE__, 0x00491867L, "0491867", "%.7X", +__LINE__, 0x00000d4dL, "3405", "%-ld", +__LINE__, 0x00234e86L, "234E86", "%0X", +__LINE__, -0x000001bL, "-27", "%ld", +__LINE__, 0x00275255L, "2576981", "%.5ld", +__LINE__, 0xfeacc214L, "0XFEACC214", "%-#3.X", +__LINE__, -0x0001ce5L, "-7397", "%+#2.2ld", +__LINE__, 0x089ddb6aL, "144563050", "%d", +__LINE__, 0x003d5a95L, "3D5A95", "%1X", +__LINE__, 0x002f0b6dL, "3083117", "%d", +__LINE__, 0x1e79e228L, "511304232", "%ld", +__LINE__, 0xfffffe6bL, "FFFFFE6B", "%+0X", +__LINE__, -0x5104ff3L, "-84955123", "%.4ld", +__LINE__, 0xfffff1deL, "FFFFF1DE", "%X", +__LINE__, 0x000000cfL, "+207", "%+.1ld", +__LINE__, -0x16ad0164L, "-380436836", "%+5.d", +__LINE__, 0x001fefa6L, "2092966", "%ld", +__LINE__, 0x00000000L, "00", "%-.2d", +__LINE__, 0x00195f45L, "195f45", "%+0x", +__LINE__, 0x00000001L, " 1", "%3.ld", +__LINE__, -0x00001c9L, "-457", "% ld", +__LINE__, 0x0002479eL, "149406", "%#ld", +__LINE__, 0x001ab18bL, "1749387", "%04d", +__LINE__, 0x00000045L, "69", "%ld", +__LINE__, 0xfbb13f7dL, "fbb13f7d", "%.2x", +__LINE__, 0x03ddc208L, "3ddc208", "%x", +__LINE__, 0x00000007L, "000007", "%#.6d", +__LINE__, 0x00000000L, "0", "%01X", +__LINE__, -0x0023110L, "-143632", "%+0.3d", +__LINE__, 0x00000006L, "06", "%#.2d", +__LINE__, 0xffff9ec9L, "ffff9ec9", "%7x", +__LINE__, -0x08afb12L, "-9108242", "% #0.ld", +__LINE__, 0x00000004L, "4", "%X", +__LINE__, 0x00059684L, "59684", "%x", +__LINE__, 0xfff8d8f5L, "FFF8D8F5", "%X", +__LINE__, 0x00b7027dL, "+11993725", "%+0.7ld", +__LINE__, 0x0000d814L, "55316", "%0ld", +__LINE__, 0x03c95a08L, "3c95a08", "%3x", +__LINE__, -0x0b65f9aL, "-11952026", "%d", +__LINE__, 0xfd956021L, "fd956021", "%0x", +__LINE__, 0x000000edL, "ed", "%0x", +__LINE__, -0x006a80cL, "-436236", "%.6ld", +__LINE__, 0xfedb109dL, "fedb109d", "%x", +__LINE__, 0x00000001L, "1", "%X", +__LINE__, 0x00b3eb71L, " 11791217", "% d", +__LINE__, 0x00000016L, "16", "%0X", +__LINE__, 0x000001dbL, " 475", "% ld", +__LINE__, 0x00465eafL, "4611759", "%0d", +__LINE__, 0x0001b423L, "1B423", "%0X", +__LINE__, 0x05df95eaL, "5df95ea", "%+.5x", +__LINE__, 0x0000000eL, " 14", "%7ld", +__LINE__, 0xffffb89eL, "ffffb89e", "%+x", +__LINE__, 0x01259918L, " 19241240", "% d", +__LINE__, -0x0000f8dL, "-003981", "%+#.6d", +__LINE__, 0x00054ae0L, "54AE0", "%X", +__LINE__, -0x4589ed4L, "-72916692", "% ld", +__LINE__, 0x01017516L, "1017516", "%6X", +__LINE__, 0xfffb9f15L, "FFFB9F15", "%.2X", +__LINE__, 0x005f8394L, "5F8394", "%.2X", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, -0x0000001L, " -1", "%7.1ld", +__LINE__, 0x004367afL, "4417455", "%4.ld", +__LINE__, 0xffffff86L, "ffffff86", "%4.5x", +__LINE__, -0x0000d17L, "-3351", "%2.0ld", +__LINE__, 0xffffff31L, "ffffff31", "%.6x", +__LINE__, -0x0000001L, "-1", "%ld", +__LINE__, -0x3d785fabL, "-1031298987", "%d", +__LINE__, -0x0000002L, "-2", "%-0ld", +__LINE__, 0x0000019cL, "412", "%d", +__LINE__, -0x0006f54L, "-28500", "%d", +__LINE__, 0xfffe3524L, "FFFE3524", "% 6.2X", +__LINE__, -0x128d3c00L, "-311245824", "%2d", +__LINE__, -0x3be71293L, "-1004999315", "%d", +__LINE__, 0x0000659dL, "26013", "%d", +__LINE__, 0x2d947538L, "+764704056", "%+5d", +__LINE__, 0xffa2a420L, "FFA2A420", "%0X", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, 0x04477c14L, "4477c14", "%.6x", +__LINE__, -0x06e145bL, "-7214171", "%d", +__LINE__, 0x00009c01L, "39937", "%-.1d", +__LINE__, 0xffde174bL, "ffde174b", "% 0x", +__LINE__, 0x0001fbaeL, "1FBAE", "%01.X", +__LINE__, -0x06b8406L, "-7046150", "%d", +__LINE__, 0x000005b8L, "005b8", "%05x", +__LINE__, -0x02d780bL, "-2979851", "%1d", +__LINE__, 0x00209e26L, "2137638", "%2d", +__LINE__, 0x0000041aL, "41A", "%0X", +__LINE__, 0x2a77f42cL, "2A77F42C", "%02X", +__LINE__, 0x13b6ee14L, "+330755604", "%+0d", +__LINE__, -0x0000002L, "-2 ", "%-6.d", +__LINE__, -0x0001eeeL, "-7918", "% #2.ld", +__LINE__, 0xffffffffL, "FFFFFFFF", "% .5X", +__LINE__, 0x20d11927L, "20d11927", "% 0.x", +__LINE__, -0x0018690L, "-99984", "% ld", +__LINE__, 0x000002a0L, "2A0", "%-0X", +__LINE__, -0x0000511L, "-1297", "%+d", +__LINE__, 0x0e782f31L, "242757425", "%-0.ld", +__LINE__, 0x2ce06da0L, "752905632", "%#0ld", +__LINE__, 0x00000062L, "62 ", "%-07x", +__LINE__, -0x015d9d8L, "-1432024", "% 7d", +__LINE__, 0xc9125ea8L, "c9125ea8", "%x", +__LINE__, 0x00000006L, "6", "%.0ld", +__LINE__, 0x0000019cL, "19c", "%x", +__LINE__, 0x00000000L, " ", "%6.d", +__LINE__, 0x00043e89L, "278153", "%0ld", +__LINE__, 0x3e422abdL, "1044523709", "%ld", +__LINE__, 0x0220a75dL, "35694429", "%#7.6d", +__LINE__, 0x0000c21cL, "C21C", "% X", +__LINE__, 0x000074abL, "29867", "%d", +__LINE__, 0x056b22aaL, "56B22AA", "%+0.X", +__LINE__, 0xfffffff9L, "FFFFFFF9", "%X", +__LINE__, 0x00000000L, "0", "%X", +__LINE__, 0xf094a4f4L, "f094a4f4", "%+4.x", +__LINE__, -0x1dad0244L, "-497877572", "%d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%.1X", +__LINE__, 0xfffffe2dL, "fffffe2d", "%7.x", +__LINE__, 0x0000042bL, "0x42b", "%#x", +__LINE__, -0x0000001L, "-1", "% d", +__LINE__, 0x00e77ef5L, " 15171317", "% 7.ld", +__LINE__, 0x00006210L, " 25104", "% 06d", +__LINE__, 0x0011187aL, "1120378", "%-ld", +__LINE__, -0x000000bL, "-11", "% #ld", +__LINE__, 0x14cfaff0L, "14cfaff0", "%-2.3x", +__LINE__, 0xffff74eaL, "FFFF74EA", "%3.X", +__LINE__, 0x000bfb9dL, "bfb9d", "%x", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%X", +__LINE__, 0x00014500L, "0X14500", "%#4.X", +__LINE__, -0x0000001L, "-1", "%#1d", +__LINE__, -0x0000024L, "-36", "%-0d", +__LINE__, -0x6528828L, "-106072104", "%d", +__LINE__, 0x00000075L, " 117", "% #d", +__LINE__, 0xff027d67L, "ff027d67", "%0x", +__LINE__, 0x0012b8b3L, "12b8b3", "%0.1x", +__LINE__, 0x1070147bL, "275780731", "%.6ld", +__LINE__, 0xffffe88eL, "FFFFE88E", "%1.3X", +__LINE__, 0xfffffc0dL, "fffffc0d", "%00.6x", +__LINE__, 0xffd889f5L, "ffd889f5", "%x", +__LINE__, 0x00000470L, "1136", "%0ld", +__LINE__, 0x000297f8L, "169976", "%ld", +__LINE__, 0xfffffffeL, "fffffffe", "%+1x", +__LINE__, 0x0000064aL, "64a", "%x", +__LINE__, -0x3d71e43bL, "-1030874171", "%1.d", +__LINE__, -0x0000004L, "-4 ", "%-3.d", +__LINE__, 0xfffff132L, "FFFFF132", "%0.0X", +__LINE__, 0x37b6356fL, "37b6356f", "%-x", +__LINE__, 0xffffff7aL, "FFFFFF7A", "%.0X", +__LINE__, 0x00023553L, "23553", "%x", +__LINE__, 0x39a4c29fL, "39a4c29f", "%+5.x", +__LINE__, 0xffffffccL, "ffffffcc", "%x", +__LINE__, 0x0003a83bL, "239675", "%#6ld", +__LINE__, 0x00000002L, "2", "%0x", +__LINE__, -0x09b4e8cL, "-10178188", "%+03.ld", +__LINE__, 0x00000002L, "0000002", "%-#.7ld", +__LINE__, 0x00000b5eL, "2910", "%-04ld", +__LINE__, -0x0000254L, "-596", "%+0d", +__LINE__, 0x00000001L, "1", "%+1.x", +__LINE__, 0xf8290d3eL, "0XF8290D3E", "% #X", +__LINE__, 0x00000035L, "035", "%3.3X", +__LINE__, 0x00131d7dL, "131D7D ", "%-7.6X", +__LINE__, 0xffdbb36aL, "0xffdbb36a", "%#.6x", +__LINE__, 0xc7275816L, "c7275816", "%04.x", +__LINE__, 0x00bae994L, "12249492", "%0ld", +__LINE__, 0x00000002L, "+2", "%+0.0ld", +__LINE__, 0xffffffffL, "ffffffff", "%0x", +__LINE__, 0xffffffe0L, "ffffffe0", "%x", +__LINE__, 0x00000036L, "36", "%.0X", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%1X", +__LINE__, 0xffffffc8L, "ffffffc8", "%+x", +__LINE__, 0xe71c3689L, "e71c3689", "%x", +__LINE__, 0x00000007L, "7 ", "%-3.ld", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, 0x00030400L, "030400", "%-4.6x", +__LINE__, 0xbd8c6fa7L, "BD8C6FA7", "%-6X", +__LINE__, 0x00000233L, "0000563", "%.7ld", +__LINE__, 0xfef92e35L, "fef92e35", "%x", +__LINE__, 0xffff2172L, "ffff2172", "%3x", +__LINE__, 0x00001233L, "1233", "% X", +__LINE__, -0x000d2e1L, "-53985", "%-0d", +__LINE__, -0x3ba8cb5bL, "-1000917851", "%0d", +__LINE__, -0x4fefb9aL, "-83819418", "%5.ld", +__LINE__, 0xffffe9ebL, "FFFFE9EB", "%X", +__LINE__, 0x1e472dc3L, "507981251", "%ld", +__LINE__, -0x0077046L, "-487494", "%0d", +__LINE__, 0x0002c4c9L, "+181449", "%+7.d", +__LINE__, 0xfffffe63L, "fffffe63", "%x", +__LINE__, 0xfff5a6dbL, "FFF5A6DB", "%X", +__LINE__, 0x00174442L, "174442", "%-5.0X", +__LINE__, 0x017891d9L, "17891D9", "%+5.X", +__LINE__, 0x0261966bL, "261966B", "%-X", +__LINE__, -0x3e58614dL, "-1045979469", "%ld", +__LINE__, 0x002c4c41L, "+2903105", "%+01ld", +__LINE__, 0x0000000cL, "012", "%#.3d", +__LINE__, 0x0380f73aL, "58783546", "%ld", +__LINE__, 0x000002c7L, "0000711", "%2.7ld", +__LINE__, 0x00000002L, " 002", "% 04ld", +__LINE__, 0x00687ca0L, "687CA0", "%X", +__LINE__, 0x0000058aL, "1418", "%0ld", +__LINE__, -0x0000642L, "-1602", "% ld", +__LINE__, 0x0001f4f1L, "1F4F1", "%X", +__LINE__, 0x0026d6fcL, "+2545404", "%+4.ld", +__LINE__, 0x05dd423cL, "+98386492", "%+#ld", +__LINE__, 0x0000782cL, "0782C", "%3.5X", +__LINE__, 0xf67d91f8L, "f67d91f8", "%-x", +__LINE__, 0xffffcf2dL, "ffffcf2d", "%+0x", +__LINE__, -0x00af8a6L, "-719014", "%0ld", +__LINE__, -0xe606ef9L, "-241200889", "%ld", +__LINE__, 0xfe9d87f7L, "fe9d87f7", "%+x", +__LINE__, 0x00000d44L, "d44", "% 1.x", +__LINE__, 0x008716f5L, "8716f5", "%2x", +__LINE__, 0x000027d4L, "27D4", "% X", +__LINE__, 0xfdfd92eaL, "FDFD92EA", "%-.4X", +__LINE__, 0xfffe764fL, "FFFE764F", "%X", +__LINE__, 0xff699032L, "ff699032", "%3.x", +__LINE__, 0xffffffffL, "FFFFFFFF", "%-3X", +__LINE__, -0x368ba995L, "-915122581", "%+#.6ld", +__LINE__, 0xffffffffL, "ffffffff", "%0x", +__LINE__, 0x0000035eL, " 862", "% 1d", +__LINE__, 0xfe703e67L, "fe703e67", "%07.0x", +__LINE__, 0xfffffffeL, "fffffffe", "%4.x", +__LINE__, 0x000e20cfL, "e20cf", "%0x", +__LINE__, 0x000063b5L, "0X63B5", "%-#X", +__LINE__, 0xfffffffaL, "fffffffa", "%+2.x", +__LINE__, 0xffffffffL, "FFFFFFFF", "%2.X", +__LINE__, 0xfdfd69daL, "FDFD69DA", "%.0X", +__LINE__, 0x00002f61L, "0x2f61", "%#3.x", +__LINE__, 0x00000009L, "9", "%x", +__LINE__, 0xffffff86L, "ffffff86", "%6x", +__LINE__, 0xffffffe4L, "ffffffe4", "%0x", +__LINE__, 0x0062e73bL, "+6481723", "%+0ld", +__LINE__, -0x2b059130L, "-721785136", "%+d", +__LINE__, -0x0000073L, "-115", "%d", +__LINE__, 0xf596efcfL, "f596efcf", "%x", +__LINE__, 0x0002f1cbL, "2F1CB", "%0X", +__LINE__, -0x0000635L, "-01589", "%.5ld", +__LINE__, 0xfffa011aL, "FFFA011A", "%0X", +__LINE__, 0x00000047L, " 47", "%4X", +__LINE__, 0xfffffbc0L, "FFFFFBC0", "%5.2X", +__LINE__, 0x00000015L, "15", "% X", +__LINE__, 0x002a87a6L, "2a87a6", "%.1x", +__LINE__, -0x000069cL, "-1692", "%+ld", +__LINE__, 0xfffffffdL, "fffffffd", "%+x", +__LINE__, 0xfeda51f5L, "FEDA51F5", "%0X", +__LINE__, 0x001781a4L, "1781a4", "%-0x", +__LINE__, 0xe77358d4L, "e77358d4", "%+0x", +__LINE__, 0x00000084L, " 84", "%3.x", +__LINE__, 0xffff0cb2L, "FFFF0CB2", "%+5.X", +__LINE__, 0x0009fa17L, "653847", "%0.0ld", +__LINE__, -0x0000c92L, "-3218", "%d", +__LINE__, 0x0004ebbbL, "4ebbb", "%x", +__LINE__, 0x2e72568cL, "+779245196", "%+#ld", +__LINE__, 0xffae86a7L, "ffae86a7", "%.7x", +__LINE__, 0xffdf3f04L, "ffdf3f04", "%x", +__LINE__, 0x000000c7L, "199", "%2.d", +__LINE__, -0x0004a55L, "-19029", "%ld", +__LINE__, 0x00564ef9L, "5656313", "%.6ld", +__LINE__, 0xffffc205L, "ffffc205", "%+.0x", +__LINE__, -0x135085d0L, "-324044240", "%#.5d", +__LINE__, 0xfffffffeL, "fffffffe", "%-7x", +__LINE__, -0x0000003L, "-3", "%.1ld", +__LINE__, 0xffda9e0bL, "ffda9e0b", "%+0x", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, 0xffffffdaL, "ffffffda", "%.6x", +__LINE__, 0x5efdb3d1L, "+1593684945", "%+0d", +__LINE__, -0x00000caL, "-202", "% 4.d", +__LINE__, -0x0014433L, "-82995", "%.3d", +__LINE__, -0x0000002L, "-000002", "% .6ld", +__LINE__, 0x24aac879L, "615172217", "%.7d", +__LINE__, -0x1db3c1dL, "-31144989", "%+#4ld", +__LINE__, 0x000945adL, "0x945ad", "%#1x", +__LINE__, 0x0000000aL, "10", "%#.1ld", +__LINE__, -0x002a2e5L, "-172773", "%d", +__LINE__, 0xfffffff3L, "FFFFFFF3", "%5X", +__LINE__, 0x0000000eL, "e", "%+x", +__LINE__, 0x335333dcL, "861090780", "%6.d", +__LINE__, 0xfffa16f4L, "FFFA16F4", "%6X", +__LINE__, 0xffffc727L, "ffffc727", "%+2.x", +__LINE__, 0x00000273L, "273", "%x", +__LINE__, -0x000000fL, "-15", "%-0d", +__LINE__, 0x00065fbdL, "417725", "%5.1d", +__LINE__, 0x00000ed5L, "3797", "%d", +__LINE__, 0x30a40024L, "30A40024", "%3.7X", +__LINE__, 0x00000054L, "84", "%ld", +__LINE__, 0x00000515L, "01301", "%.5ld", +__LINE__, 0x00000897L, "+02199", "%+.5d", +__LINE__, -0x0001bccL, "-7116", "% ld", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%7X", +__LINE__, 0x00000013L, "0X13", "%#X", +__LINE__, 0xffffffffL, "0xffffffff", "% #x", +__LINE__, 0x00000006L, "6", "%ld", +__LINE__, -0x00000c3L, "-195", "%1.ld", +__LINE__, -0x005291eL, "-338206", "%+d", +__LINE__, 0xffb437a7L, "FFB437A7", "%-0X", +__LINE__, 0xff8335cbL, "ff8335cb", "%x", +__LINE__, 0x0000006aL, "6A", "%2X", +__LINE__, -0x004f629L, "-325161", "% .4d", +__LINE__, 0x003698efL, "3578095", "%0ld", +__LINE__, 0x6b5cdf3aL, "6b5cdf3a", "%-x", +__LINE__, 0xe9bc5c21L, "e9bc5c21", "%+x", +__LINE__, -0x0000001L, " -1", "%+6.ld", +__LINE__, 0xfffeffc8L, "FFFEFFC8", "%6.X", +__LINE__, 0xff070a73L, "ff070a73", "%+.7x", +__LINE__, 0x0023f8aeL, "2357422", "%07.4ld", +__LINE__, 0x00000000L, "0", "%X", +__LINE__, 0x00000016L, "16", "%0X", +__LINE__, -0x000005aL, " -90", "%4d", +__LINE__, 0x00000116L, "116", "% .3x", +__LINE__, 0xfffed024L, "fffed024", "%-x", +__LINE__, 0xfb907950L, "fb907950", "%.0x", +__LINE__, 0x0101a1e5L, "101a1e5", "%x", +__LINE__, -0x09e7684L, "-10385028", "%-#ld", +__LINE__, 0xffffffffL, "ffffffff", "%1x", +__LINE__, 0xfffffff6L, "fffffff6", "%x", +__LINE__, 0x00000078L, "78", "%x", +__LINE__, 0xe6bca9c9L, "0XE6BCA9C9", "%#.5X", +__LINE__, -0x0000010L, "-16", "%d", +__LINE__, -0x1348f685L, "-323548805", "%d", +__LINE__, 0x4dd85797L, "1306023831", "%ld", +__LINE__, -0x0000080L, "-128", "%.2d", +__LINE__, -0xaed13a7L, "-183309223", "%+ld", +__LINE__, -0x000002fL, "-47", "% d", +__LINE__, -0x679911fL, "-108630303", "%ld", +__LINE__, 0xfffff221L, "FFFFF221", "% .7X", +__LINE__, 0x0007476cL, "7476c", "%x", +__LINE__, 0xffffe02aL, "0xffffe02a", "%#7x", +__LINE__, 0x00000ebbL, "0XEBB", "%#X", +__LINE__, 0xffffffffL, "0XFFFFFFFF", "%-#X", +__LINE__, 0x00281896L, "281896", "%+1.x", +__LINE__, 0x0000085dL, " 0X85D", "%#6.3X", +__LINE__, 0x000112bfL, "112BF", "%X", +__LINE__, 0xf5518fbfL, "F5518FBF", "% X", +__LINE__, -0x00c945bL, "-824411", "%ld", +__LINE__, 0x00001b43L, "0x1b43", "%-#x", +__LINE__, -0x5872a246L, "-1483907654", "%#7.7ld", +__LINE__, 0x00001f96L, "8086", "%#d", +__LINE__, 0xfffffff9L, "FFFFFFF9", "%X", +__LINE__, -0x006e244L, "-451140", "% .3d", +__LINE__, -0x0382188L, "-3678600", "%0.2ld", +__LINE__, 0x00000006L, "6", "%-x", +__LINE__, 0x00000036L, "54 ", "%-5.d", +__LINE__, -0x0000439L, " -1081", "%#6.3ld", +__LINE__, 0xfff911c6L, "FFF911C6", "%X", +__LINE__, -0x03454dcL, "-3429596", "%d", +__LINE__, -0x0363e8dL, "-3554957", "%-.2ld", +__LINE__, 0x00000000L, "000", "%.3X", +__LINE__, -0x59bb030fL, "-1505428239", "%0ld", +__LINE__, 0x073c94d8L, "121410776", "%-d", +__LINE__, -0x001ef94L, "-126868", "%5.1ld", +__LINE__, 0xfff65fc5L, "FFF65FC5", "%0X", +__LINE__, 0xfffffff4L, "fffffff4", "%-x", +__LINE__, 0x00001d83L, "07555", "%5.5d", +__LINE__, 0x0012b40aL, "1225738", "%ld", +__LINE__, -0x0000006L, "-6", "%0ld", +__LINE__, 0xfffffffcL, "fffffffc", "%06.0x", +__LINE__, -0x0000002L, "-00002", "%#.5ld", +__LINE__, 0xf9932c1dL, "f9932c1d", "%-x", +__LINE__, -0x46a31d9L, "-74068441", "%.3ld", +__LINE__, 0x000987e9L, "987E9", "%1X", +__LINE__, 0x0000000fL, "15", "%-ld", +__LINE__, -0x0001c4dL, "-7245", "%ld", +__LINE__, -0x007deeeL, "-515822", "%2.6d", +__LINE__, 0xffffffa2L, "FFFFFFA2", "%.6X", +__LINE__, 0x00000001L, "1", "%-ld", +__LINE__, 0xfc106bdeL, "fc106bde", "%.4x", +__LINE__, 0x0002f1f8L, "0x2f1f8", "%#7.x", +__LINE__, -0x06a290bL, "-6957323", "%-ld", +__LINE__, -0x0000037L, " -55", "%4ld", +__LINE__, 0x0000152eL, "5422", "%2.d", +__LINE__, 0xfffffcb2L, "0XFFFFFCB2", "%#3.X", +__LINE__, 0x1b7ca086L, "1b7ca086", "%+x", +__LINE__, 0x00000001L, "1", "%ld", +__LINE__, 0x006775fcL, "6775fc", "%3.2x", +__LINE__, 0x0000000eL, "0XE", "%#3.X", +__LINE__, 0xffffffffL, "0xffffffff", "%+#4.x", +__LINE__, 0x00001246L, "1246", "%X", +__LINE__, 0xffffaed6L, "ffffaed6", "%2x", +__LINE__, -0x3a2dec78L, "-976088184", "% 0ld", +__LINE__, 0x0001423bL, "1423b", "%01x", +__LINE__, 0x00000007L, " 0X7", "%#4.X", +__LINE__, 0x01a7ff5aL, "27787098", "%.4ld", +__LINE__, -0x0020d05L, "-134405", "%-d", +__LINE__, 0xffffff9aL, "ffffff9a", "%-.1x", +__LINE__, 0xffff3557L, "ffff3557", "%x", +__LINE__, 0x08828e35L, "8828e35", "%+.1x", +__LINE__, 0x000006b2L, "001714", "%04.6ld", +__LINE__, 0x00000013L, "19", "%.0ld", +__LINE__, -0x00341a5L, "-213413", "%#d", +__LINE__, -0x0000043L, "-67", "%d", +__LINE__, -0x074dce3L, "-7658723", "%.1d", +__LINE__, -0x16de2df3L, "-383659507", "% ld", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0x00000ce7L, "ce7", "% 2.1x", +__LINE__, 0xffecd377L, "ffecd377", "% 0x", +__LINE__, 0xa4e8465cL, "a4e8465c", "% x", +__LINE__, 0x000005e8L, "1512", "%d", +__LINE__, 0x00000513L, "1299", "%d", +__LINE__, 0xffffffb8L, "FFFFFFB8", "%X", +__LINE__, 0x00000003L, "00003", "%3.5x", +__LINE__, -0x0000003L, "-3 ", "%-3.ld", +__LINE__, 0xad53f01dL, "ad53f01d", "%0x", +__LINE__, 0x0f1c1daeL, "253500846", "%-#.0d", +__LINE__, 0xff1753c0L, "0xff1753c0", "%#3.x", +__LINE__, -0x00389c5L, "-231877", "%d", +__LINE__, 0x0000016eL, "00016E", "%.6X", +__LINE__, -0x54d3310fL, "-1423126799", "%-d", +__LINE__, 0x00000005L, "0X5", "%#.1X", +__LINE__, 0xfffffffdL, "0XFFFFFFFD", "%#5.3X", +__LINE__, 0xfffffe0eL, "fffffe0e", "%-x", +__LINE__, 0xa3c02157L, "a3c02157", "%.5x", +__LINE__, 0x00005765L, "22373", "%d", +__LINE__, -0x12668cdL, "-19294413", "%+ld", +__LINE__, -0x66544daL, "-107300058", "%2d", +__LINE__, 0x8646c605L, "0X8646C605", "% #X", +__LINE__, 0x000001f5L, "1F5", "%X", +__LINE__, 0x01b33ae4L, "28523236", "%5ld", +__LINE__, 0x000007ceL, "7ce", "%3.x", +__LINE__, 0x00000355L, "355", "%X", +__LINE__, 0x000001ceL, "1CE", "% X", +__LINE__, 0xfffffccdL, "fffffccd", "%7.0x", +__LINE__, -0x0000001L, "-1", "%0ld", +__LINE__, 0x000640b6L, "640b6", "%5.x", +__LINE__, 0x0038c4ecL, "3720428", "%5.4d", +__LINE__, -0x0f10b5eL, "-15797086", "%2ld", +__LINE__, 0x256c815fL, "256c815f", "%4.x", +__LINE__, 0x00000682L, " 1666", "%6ld", +__LINE__, -0x00000abL, "-171", "%2ld", +__LINE__, 0x00000003L, "3", "%0d", +__LINE__, 0x063f5075L, "63F5075", "%X", +__LINE__, 0xff83b5d0L, "FF83B5D0", "%7.X", +__LINE__, 0xffffffecL, "ffffffec", "%x", +__LINE__, 0xffb551c4L, "0XFFB551C4", "% #4.X", +__LINE__, -0x071f057L, "-7467095", "%3.7d", +__LINE__, 0x00634879L, "6506617", "%#ld", +__LINE__, 0x000001d7L, "471", "%d", +__LINE__, 0x00a7da92L, "A7DA92", "% .4X", +__LINE__, 0x00000003L, "3 ", "%-2.ld", +__LINE__, -0x0000004L, "-0004", "%.4d", +__LINE__, -0x01dea32L, "-1960498", "% #7.d", +__LINE__, 0x53c4159fL, "53C4159F", "%1.7X", +__LINE__, -0x1ad7904L, "-28145924", "%#d", +__LINE__, -0x0000a85L, "-2693", "%ld", +__LINE__, -0x0000c7dL, "-3197", "%d", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%+0X", +__LINE__, 0x00000004L, "00004", "%1.5d", +__LINE__, 0x0000b761L, "46945", "%5ld", +__LINE__, -0x0ee3b2cL, "-15612716", "%.6d", +__LINE__, 0x0677a73dL, "677a73d", "% x", +__LINE__, -0x5f96020L, "-100229152", "% d", +__LINE__, 0x00000000L, " 0", "%#7X", +__LINE__, -0x5d1cb5bL, "-97635163", "% ld", +__LINE__, -0x00a8d8bL, "-691595", "%-0ld", +__LINE__, 0xffffffa2L, "FFFFFFA2", "%X", +__LINE__, 0xffffffc9L, "FFFFFFC9", "%X", +__LINE__, 0x0b180d35L, "B180D35", "%X", +__LINE__, 0xfc0b94ceL, "fc0b94ce", "%.1x", +__LINE__, 0x0012cd7bL, "12CD7B", "% X", +__LINE__, -0x02f1da8L, "-3087784", "%ld", +__LINE__, -0x000a6f9L, "-42745", "%-ld", +__LINE__, -0x000006dL, "-109 ", "%-6d", +__LINE__, 0x00000001L, "+1", "%+0d", +__LINE__, 0x00000001L, "1", "%1d", +__LINE__, 0xfffffff8L, "fffffff8", "%5.x", +__LINE__, -0x00fc4d7L, "-1033431", "%+0.5ld", +__LINE__, 0xffff41b4L, "0xffff41b4", "%#x", +__LINE__, -0x0000d37L, "-3383", "%ld", +__LINE__, 0xffc4e405L, "ffc4e405", "%7x", +__LINE__, 0xffffffb0L, "FFFFFFB0", "%04X", +__LINE__, -0x0054477L, "-345207", "%01.ld", +__LINE__, 0x00512778L, "0x512778", "%#3.0x", +__LINE__, 0x00000007L, " 7", "%7.d", +__LINE__, 0x00000008L, " 00008", "% .5ld", +__LINE__, 0x000053fdL, "21501", "%.4ld", +__LINE__, 0x0000370cL, "370c", "%2x", +__LINE__, -0x44670a7L, "-71725223", "%3d", +__LINE__, 0x00000064L, " 64", "%+5x", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%X", +__LINE__, 0xf7bbf094L, "f7bbf094", "%3x", +__LINE__, 0xfffeb268L, "FFFEB268", "%X", +__LINE__, 0x00001ef0L, "1ef0", "%4.x", +__LINE__, 0x05ad9aa4L, " 95263396", "% 0.ld", +__LINE__, 0xf294dca7L, "F294DCA7", "% 4.X", +__LINE__, -0x0000003L, "-000003", "%.6d", +__LINE__, 0xfff57471L, "fff57471", "% x", +__LINE__, 0x0a848cfdL, "176459005", "%d", +__LINE__, -0x000002eL, "-46", "%.0d", +__LINE__, 0x00000051L, " +81", "%+5d", +__LINE__, -0x000072bL, "-0001835", "%06.7d", +__LINE__, -0x0000002L, " -2", "%+#6ld", +__LINE__, 0x00000003L, "3", "%x", +__LINE__, 0xfffd1799L, "FFFD1799", "%6.X", +__LINE__, 0x00000005L, "5", "%ld", +__LINE__, 0x0052138bL, "5378955", "%#7.7ld", +__LINE__, 0x000000c0L, " 192", "% 7ld", +__LINE__, 0x005b26cdL, "5B26CD", "%X", +__LINE__, -0x008df17L, "-581399", "%.4ld", +__LINE__, 0xfffffad8L, "fffffad8", "%-x", +__LINE__, 0x000006a9L, "6a9", "%.0x", +__LINE__, -0x003b7f9L, "-243705", "%+0ld", +__LINE__, 0x005d7ea4L, "6127268", "%ld", +__LINE__, -0x003cceaL, "-249066", "%+.0ld", +__LINE__, 0x0000846fL, "846F", "%X", +__LINE__, 0x00004f79L, "4F79", "%4.X", +__LINE__, 0xe3e1409cL, "E3E1409C", "%-X", +__LINE__, 0x07cce2f4L, "7CCE2F4", "%2.X", +__LINE__, 0x004bcc8bL, "4967563", "%-.5ld", +__LINE__, 0x7d49665eL, "2101962334", "%ld", +__LINE__, 0xfffffffcL, "FFFFFFFC", "%.5X", +__LINE__, 0x0000019eL, "+000414", "%+.6d", +__LINE__, 0x000027efL, "10223", "%d", +__LINE__, -0x0000261L, "-609", "%3ld", +__LINE__, -0x000000eL, "-14", "% 2.ld", +__LINE__, 0xff3ba3c7L, "ff3ba3c7", "%+5.7x", +__LINE__, 0xffffffc4L, "FFFFFFC4", "%-1.X", +__LINE__, 0xfffc5a70L, "0xfffc5a70", "%#4.4x", +__LINE__, 0x0000d156L, " 53590", "% d", +__LINE__, -0x0486258L, "-4743768", "%0ld", +__LINE__, 0x00000000L, " ", "% 2.d", +__LINE__, 0x04a0ef9fL, "77655967", "%0.6ld", +__LINE__, 0xffffffffL, "FFFFFFFF", "%X", +__LINE__, 0x00000019L, "0000019", "%.7x", +__LINE__, -0x0058d3aL, "-363834", "%ld", +__LINE__, 0xfffff6b3L, "fffff6b3", "%x", +__LINE__, 0xfffffff5L, "FFFFFFF5", "%.0X", +__LINE__, 0x005e1fcbL, "5E1FCB", "%+6X", +__LINE__, 0xffc3c866L, "0xffc3c866", "%-#.4x", +__LINE__, 0x00000003L, "3", "%X", +__LINE__, 0xffa2e961L, "FFA2E961", "%7.4X", +__LINE__, 0x00000029L, "41", "%d", +__LINE__, -0x0000035L, "-53", "%d", +__LINE__, 0x0001b033L, "110643", "%ld", +__LINE__, 0x004dd51bL, "5100827", "%-2ld", +__LINE__, -0x000252dL, "-9517", "% d", +__LINE__, 0xffffdeb2L, "ffffdeb2", "%4.x", +__LINE__, 0xffe94eabL, "0xffe94eab", "%#x", +__LINE__, 0xf921edf6L, "f921edf6", "%4.2x", +__LINE__, 0x0007df97L, "515991", "%4.ld", +__LINE__, 0x00709bc5L, "709BC5", "%0X", +__LINE__, -0x0000001L, "-1", "%d", +__LINE__, 0xfffffffbL, "FFFFFFFB", "%7.3X", +__LINE__, -0x0063f74L, "-409460", "%+05.0d", +__LINE__, 0xfffffe9aL, "FFFFFE9A", "%.2X", +__LINE__, -0x0001ce2L, "-7394", "%.4d", +__LINE__, 0x000038c5L, "14533", "%ld", +__LINE__, 0x000000adL, "000ad", "% 5.5x", +__LINE__, 0xffffbcc4L, "ffffbcc4", "%-5x", +__LINE__, 0x00000000L, "0", "% X", +__LINE__, 0x00372877L, "372877", "%.6X", +__LINE__, 0xffffffd7L, "FFFFFFD7", "%1.X", +__LINE__, 0xfa58b14bL, "fa58b14b", "%x", +__LINE__, 0xfffffd9fL, "FFFFFD9F", "%0.7X", +__LINE__, 0x00000710L, "+1808", "%+#.2ld", +__LINE__, 0x00000006L, " 6", "%5.0ld", +__LINE__, 0x0fba9706L, "263886598", "%-6.3d", +__LINE__, 0xffff420aL, "ffff420a", "%-2x", +__LINE__, 0x14b9a825L, "14b9a825", "%x", +__LINE__, 0x0077ffe4L, "77FFE4", "%+.2X", +__LINE__, 0x00067108L, "422152 ", "%-7.ld", +__LINE__, 0x00000001L, " 00001", "%6.5X", +__LINE__, 0x00000000L, "0", "%ld", +__LINE__, -0x0000001L, " -1", "% 7ld", +__LINE__, 0x01ddc7a3L, "31311779", "%d", +__LINE__, -0x2a92f9bL, "-44642203", "% 3ld", +__LINE__, 0xfffffff9L, "fffffff9", "%4.6x", +__LINE__, 0x0279a274L, "279a274", "%x", +__LINE__, 0x2e37ed8eL, "775417230", "%d", +__LINE__, 0x5ba59f58L, "1537580888", "%-ld", +__LINE__, 0xffffffe0L, "ffffffe0", "%x", +__LINE__, 0x3110ae47L, "0X3110AE47", "%+#X", +__LINE__, 0x000e00b9L, "917689", "%d", +__LINE__, 0x0000002eL, " 0046", "% 7.4d", +__LINE__, 0x00000363L, " 867", "%7.d", +__LINE__, -0x000000bL, "-0011", "% 0.4d", +__LINE__, 0x000349c8L, " 349C8", "% 7.X", +__LINE__, -0x01358f1L, "-1267953", "%d", +__LINE__, -0x0039d3cL, "-236860", "%-.3d", +__LINE__, 0xffd6de19L, "ffd6de19", "%04.0x", +__LINE__, -0x0003c54L, "-0015444", "%1.7d", +__LINE__, -0x0000e17L, "-3607", "%d", +__LINE__, 0xff0fa3a9L, "ff0fa3a9", "%+3x", +__LINE__, 0x00000009L, "0000009", "%1.7x", +__LINE__, 0xfffffc81L, "FFFFFC81", "% X", +__LINE__, -0x4ef2df5L, "-82783733", "%ld", +__LINE__, 0x00000013L, "19", "%-ld", +__LINE__, 0x00000000L, " 0", "%#7x", +__LINE__, -0x3b9485fdL, "-999589373", "%1.d", +__LINE__, -0x0000006L, "-00006", "%6.5d", +__LINE__, 0x0000003fL, "+63", "%+ld", +__LINE__, 0x000004c5L, "1221", "%1.d", +__LINE__, 0x003f8a8cL, "4164236", "%d", +__LINE__, -0x000001eL, "-30", "%-#3d", +__LINE__, 0xfff9d230L, "FFF9D230", "%+07.3X", +__LINE__, 0x0147cf17L, "147cf17", "% x", +__LINE__, 0xffffffebL, "ffffffeb", "%x", +__LINE__, 0x0000007dL, "00125", "%.5ld", +__LINE__, 0x000fff56L, "1048406", "%#3d", +__LINE__, 0x064307a0L, " 105056160", "% 0.3ld", +__LINE__, 0x007d2860L, "8202336", "%-.2d", +__LINE__, 0x00a05711L, "a05711", "%x", +__LINE__, 0x179a7f9eL, "0x179a7f9e", "%+#.3x", +__LINE__, 0x00000003L, "3", "%X", +__LINE__, -0x0001d7dL, "-7549", "%#5d", +__LINE__, 0x0025d3f2L, "+2479090", "%+2.d", +__LINE__, -0x0000001L, "-1", "%#ld", +__LINE__, 0xfffffdd5L, "fffffdd5", "%.7x", +__LINE__, 0x003462b9L, "3433145", "%d", +__LINE__, 0x00005a81L, "23169", "%d", +__LINE__, 0xfffffcdbL, "fffffcdb", "%-x", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, 0xfff22085L, "fff22085", "%x", +__LINE__, 0x00016d72L, " 93554", "% d", +__LINE__, -0x0000002L, "-2", "%0ld", +__LINE__, 0xfffffd21L, "fffffd21", "% 0x", +__LINE__, 0x00000931L, "2353", "%ld", +__LINE__, 0x00010021L, "10021", "%5.1X", +__LINE__, -0x000007eL, "-126", "%1.0ld", +__LINE__, 0xfffffff8L, "fffffff8", "%01.x", +__LINE__, -0x001d148L, "-119112", "%d", +__LINE__, -0x0000008L, "-8", "%ld", +__LINE__, -0x000038eL, "-910", "% ld", +__LINE__, 0x0039e3e5L, "3793893", "%0.1d", +__LINE__, 0x0038fb8eL, "38FB8E", "%.2X", +__LINE__, -0x002dafaL, "-187130", "%ld", +__LINE__, -0xbec275bL, "-200025947", "%ld", +__LINE__, 0x1a32f999L, "1A32F999", "%05.4X", +__LINE__, 0x0000002fL, "2f", "%x", +__LINE__, -0x0001a5bL, "-6747", "%+3.ld", +__LINE__, 0x00000762L, " 1890", "%7.ld", +__LINE__, 0x000000c2L, "000194", "%0.6ld", +__LINE__, 0xffff002bL, "FFFF002B", "%.4X", +__LINE__, -0x0019daeL, "-105902", "% .2d", +__LINE__, 0x0000125fL, "125f", "%+1x", +__LINE__, -0x000b688L, " -46728", "%#7.d", +__LINE__, 0x000401caL, "401ca", "%0x", +__LINE__, 0x00000192L, "402", "%#ld", +__LINE__, 0xffffffffL, "ffffffff", "%x", +__LINE__, 0x1e505a0cL, "0X1E505A0C", "%#1.3X", +__LINE__, 0x000f8f6cL, "1019756", "%d", +__LINE__, 0x0004a296L, "4a296", "%5.2x", +__LINE__, 0x00000003L, "3", "% x", +__LINE__, -0x000d44cL, "-54348", "%#ld", +__LINE__, 0x00009ae2L, "39650", "%-d", +__LINE__, 0xffffff3aL, "FFFFFF3A", "% .7X", +__LINE__, 0x0042350bL, "4338955", "%d", +__LINE__, 0x000071afL, "71af", "%+.4x", +__LINE__, 0x00000001L, "0x1", "%#0x", +__LINE__, 0x00000033L, "00051", "%3.5d", +__LINE__, 0x00000001L, "1", "%X", +__LINE__, -0xebfb0e7L, "-247443687", "%+3ld", +__LINE__, 0x00000027L, "27 ", "%-07.X", +__LINE__, -0x0004837L, "-18487", "%01d", +__LINE__, 0x1a8c53daL, "1A8C53DA", "%X", +__LINE__, -0x0bdb8a9L, "-12433577", "%d", +__LINE__, -0x0000098L, "-152", "%#ld", +__LINE__, -0x003b554L, "-243028", "%d", +__LINE__, 0x000000cbL, "00000CB", "%+.7X", +__LINE__, 0xfffffedaL, "FFFFFEDA", "%X", +__LINE__, -0x0000010L, "-16", "%-#d", +__LINE__, 0x00000006L, "+6", "%+d", +__LINE__, 0x003c294aL, "+3942730", "%+4.ld", +__LINE__, 0x00000009L, "9", "%ld", +__LINE__, 0xfbbdd2bcL, "FBBDD2BC", "% X", +__LINE__, 0x71c86678L, "+1908958840", "%+0.6ld", +__LINE__, -0x0b49bffL, "-11836415", "% 6.ld", +__LINE__, 0xfff416beL, "fff416be", "%3.x", +__LINE__, 0x00000077L, "+119", "%+d", +__LINE__, 0xfff1cfaaL, "FFF1CFAA", "% 0.2X", +__LINE__, 0xfffffffbL, "fffffffb", "% x", +__LINE__, 0x0000127eL, "4734", "%d", +__LINE__, 0x00107ad2L, "107ad2", "%+2.6x", +__LINE__, 0x0006b8e9L, "440553", "%-#d", +__LINE__, 0x0000eb6fL, "eb6f", "% x", +__LINE__, 0x00001f18L, "7960", "%0d", +__LINE__, 0xfffff225L, "fffff225", "%1.5x", +__LINE__, 0xfffffff9L, "fffffff9", "%+6.x", +__LINE__, 0x000005b9L, "01465", "%.5ld", +__LINE__, 0xfffc26b8L, "FFFC26B8", "% X", +__LINE__, 0x540d580dL, "0X540D580D", "%+#X", +__LINE__, 0x05ad7094L, "5AD7094", "% 4.7X", +__LINE__, -0x000019bL, "-411", "% d", +__LINE__, 0x00000006L, "000006", "%6.6ld", +__LINE__, 0x0000026aL, "+618", "%+ld", +__LINE__, 0x0000000bL, "11", "%ld", +__LINE__, -0x26985d5L, "-40469973", "%#.0ld", +__LINE__, 0x0000007dL, "7D", "%+02.0X", +__LINE__, -0x0079ddfL, "-0499167", "%+.7ld", +__LINE__, 0x0000375fL, "14175", "%0d", +__LINE__, -0x18de7f99L, "-417234841", "%ld", +__LINE__, -0x00507ccL, "-329676", "%.0d", +__LINE__, 0x000029d5L, "29D5", "%-2.1X", +__LINE__, 0x0000328cL, "328C", "%-3.X", +__LINE__, 0x016f6234L, "24076852", "%3.ld", +__LINE__, 0xfffffffcL, "0XFFFFFFFC", "%#.5X", +__LINE__, 0xfe6163caL, "FE6163CA", "%5.X", +__LINE__, 0xffffffc2L, "FFFFFFC2", "%X", +__LINE__, 0x00000087L, "+135", "%+ld", +__LINE__, 0x00310166L, "310166", "% x", +__LINE__, 0x00e8c871L, "15255665", "%d", +__LINE__, 0x000005eeL, "1518", "%ld", +__LINE__, 0xfcb24306L, "FCB24306", "%X", +__LINE__, 0x0000000bL, " 11", "%5ld", +__LINE__, 0x006d11d0L, "0x6d11d0", "%#.0x", +__LINE__, 0x0010d416L, "1102870", "%#6.5d", +__LINE__, -0x0047cb3L, "-294067", "%.3d", +__LINE__, 0x000000c0L, "c0", "%x", +__LINE__, 0xffffffffL, "FFFFFFFF", "%+X", +__LINE__, -0x000000aL, "-10", "%d", +__LINE__, -0x0000007L, "-7", "% ld", +__LINE__, 0xfffffffeL, "FFFFFFFE", "%-X", +__LINE__, 0x00000014L, "0x14", "%-#3.1x", +__LINE__, 0x00003319L, "3319", "% x", +__LINE__, 0x00000000L, "00", "%+#.2X", +__LINE__, -0x0000009L, "-9", "% ld", +__LINE__, -0x0000001L, "-1 ", "%-3ld", +__LINE__, 0x00262909L, "2500873", "%.5ld", +__LINE__, 0x33e76560L, "33e76560", "%7.0x", +__LINE__, -0x0000002L, "-2", "%ld", +__LINE__, 0x00035ee9L, "35EE9", "%-3.X", +__LINE__, -0x0000235L, "-565", "%+4.ld", +__LINE__, -0x3ea63c5L, "-65692613", "%d", +__LINE__, 0x00000003L, "3", "%ld", +__LINE__, -0x003362fL, "-210479", "% d", +__LINE__, -0x1a819f8aL, "-444702602", "%.7d", +__LINE__, 0x027a4668L, "41567848", "%d", +__LINE__, 0x0002b025L, "2b025", "%x", +__LINE__, -0x0000001L, "-001", "%.3ld", +__LINE__, 0xfffffff0L, "fffffff0", "%-0x", +__LINE__, -0x0000d4fL, "-3407", "%-ld", +__LINE__, 0x00000146L, " 326", "% 1.d", +__LINE__, -0x0000006L, "-6", "%d", +__LINE__, 0xffffffffL, "FFFFFFFF", "%06.4X", +__LINE__, 0x376fddaeL, "+930078126", "%+#0ld", +__LINE__, 0x006d9da3L, "6d9da3", "%1.x", +__LINE__, -0x0000f28L, "-3880", "%3.2ld", +__LINE__, 0x0006962cL, " 431660", "% 5d", +__LINE__, 0x000011dbL, " 4571", "%6.ld", +__LINE__, 0xffffffa8L, "ffffffa8", "%+x", +__LINE__, 0x0d886db3L, "D886DB3", "%.7X", +__LINE__, 0x00000000L, "000000", "%2.6ld", +__LINE__, 0xfffff6b6L, "FFFFF6B6", "% X", +__LINE__, -0x0739068L, "-7573608", "%+6.ld", +__LINE__, 0xfba62553L, "0XFBA62553", "%#X", +__LINE__, -0x4474bc5L, "-71781317", "%-2ld", +__LINE__, 0xffffff95L, "FFFFFF95", "% 2.X", +__LINE__, -0x1d0e1caL, "-30466506", "%+.0d", +__LINE__, -0x000f3aaL, "-62378", "%ld", +__LINE__, 0x00000026L, "26", "%1x", +__LINE__, 0x001c5400L, "1856512", "%-#d", +__LINE__, 0x03808442L, "3808442", "%X", +__LINE__, -0x0000081L, "-129", "%+#ld", +__LINE__, 0x000004aeL, " 1198", "% 3.4d", +__LINE__, -0x7f4ed54L, "-133492052", "%d", +__LINE__, 0x00000000L, "+0", "%+ld", +__LINE__, 0x00000000L, "0", "%+x", +__LINE__, 0x004c7e46L, "5013062", "%.0d", +__LINE__, -0x647d7a65L, "-1685944933", "%0.2d", +__LINE__, 0x00003b59L, "15193", "%-#1d", +__LINE__, 0xfff3e64dL, "FFF3E64D", "%-X", +__LINE__, 0x00007022L, "28706", "%-d", +__LINE__, 0xc28d0ad8L, "c28d0ad8", "%+x", +__LINE__, -0x005c208L, "-377352", "% ld", +__LINE__, 0x00cfbadcL, "13613788", "%d", +__LINE__, 0x000016eaL, "5866", "%0d", +__LINE__, 0x00000029L, "29", "%X", +__LINE__, 0xffe16813L, "0XFFE16813", "%+#X", +__LINE__, 0x00000004L, "4", "%0X", +__LINE__, -0x0000096L, " -150", "%5d", +__LINE__, 0x00027ac7L, "162503", "%ld", +__LINE__, -0x0075de0L, "-482784", "%d", +__LINE__, 0x005fcff6L, "6279158", "%d", +__LINE__, 0xffffffefL, "FFFFFFEF", "%3X", +__LINE__, 0x267b05ecL, "645596652", "%4ld", +__LINE__, 0xa487b724L, "a487b724", "%x", +__LINE__, 0x01da2a11L, "31074833", "%-.0ld", +__LINE__, 0xffffffffL, "FFFFFFFF", "%X", +__LINE__, 0x0000037aL, "37a", "%x", +__LINE__, 0x003d0314L, "+3998484", "%+#1d", +__LINE__, 0x0000011bL, " 283", "%5.2d", +__LINE__, 0x094f6066L, "94f6066", "%x", +__LINE__, 0x00000004L, "4", "%X", +__LINE__, -0x102e14bdL, "-271455421", "% 7.ld", +__LINE__, 0x000048daL, "0018650", "%07ld", +__LINE__, -0x24ae0390L, "-615383952", "%0.6d", +__LINE__, 0xffff5159L, "0XFFFF5159", "%#0X", +__LINE__, 0xfffd38c3L, "fffd38c3", "%x", +__LINE__, 0xfffff9eaL, "FFFFF9EA", "%-X", +__LINE__, -0x000fd28L, "-64808", "% ld", +__LINE__, 0x002c1bf4L, "2890740", "%-.1d", +__LINE__, 0x00d00ee7L, "D00EE7", "%0.4X", +__LINE__, 0x00000cf9L, "3321", "%0d", +__LINE__, -0x0000001L, "-1", "%-#ld", +__LINE__, 0xfffffd75L, "FFFFFD75", "%.2X", +__LINE__, 0x00000012L, "18", "%-d", +__LINE__, 0xfd44b4b2L, "fd44b4b2", "%+5.x", +__LINE__, -0x001c53fL, "-116031", "%-#6.d", +__LINE__, 0x000ff6fdL, "ff6fd", "%2x", +__LINE__, 0x00000001L, "1", "%0d", +__LINE__, 0x0120b478L, "120B478", "%.7X", +__LINE__, 0x0145591eL, "145591E", "%1.4X", +__LINE__, 0x001f99b9L, "1F99B9", "%.1X", +__LINE__, 0xffffd078L, "ffffd078", "%-1.5x", +__LINE__, 0xffffff1aL, "FFFFFF1A", "%-4.6X", +__LINE__, 0xfffffffaL, "fffffffa", "%x", +__LINE__, -0x00000b9L, "-185", "%3ld", +__LINE__, 0x00001cf0L, "7408", "%-ld", +__LINE__, 0xffffffffL, "FFFFFFFF", "%X", +__LINE__, 0x00151f30L, "151F30", "%X", +__LINE__, -0x0000103L, "-259", "%d", +__LINE__, -0x000303fL, "-12351", "%d", +__LINE__, 0x000002caL, "714", "%ld", +__LINE__, -0x0000c55L, "-3157", "%1d", +__LINE__, 0x00000691L, "01681", "%#.5ld", +__LINE__, 0x00230537L, "2295095", "%#d", +__LINE__, 0x032a1faaL, "53092266", "%.4d", +__LINE__, 0x000050d7L, "20695", "%d", +__LINE__, -0x0c7ad4cL, "-13086028", "%#.4ld", +__LINE__, -0x00009d9L, "-2521", "%+d", +__LINE__, 0xfffffffeL, "fffffffe", "%0x", +__LINE__, 0xffdec2d9L, "FFDEC2D9", "%5.1X", +__LINE__, -0x000563cL, "-22076", "%-.2ld", +__LINE__, 0x0073b36aL, "0x73b36a", "%-#x", +__LINE__, 0xfffffffdL, "fffffffd", "%x", +__LINE__, 0x0193ba5aL, "193ba5a", "%1.x", +__LINE__, 0x00d147b5L, "13715381", "%2.d", +__LINE__, 0xffffff10L, "ffffff10", "%4x", +__LINE__, 0x000648d5L, "648d5", "%1.3x", +__LINE__, 0x00000011L, "11", "%X", +__LINE__, 0xff259f5bL, "0xff259f5b", "% #.1x", +__LINE__, 0x00000175L, "175", "%x", +__LINE__, 0x00000000L, "0", "%ld", +__LINE__, 0x00000015L, "21", "%#ld", +__LINE__, 0xfffffffeL, "fffffffe", "%-x", +__LINE__, 0x00000013L, " 19", "% 0ld", +__LINE__, -0x0000001L, "-0000001", "% 5.7ld", +__LINE__, 0x0000139dL, "139D", "%X", +__LINE__, 0x0041ad18L, "41ad18", "%-.6x", +__LINE__, -0x00000f9L, "-249", "% 3.d", +__LINE__, 0x00000076L, "118", "%ld", +__LINE__, 0x000006f8L, "1784", "%d", +__LINE__, -0x0000005L, "-5", "%ld", +__LINE__, -0x00008e7L, "-2279", "%+ld", +__LINE__, 0x00003f77L, "3F77", "%+0X", +__LINE__, 0x000ca3f8L, "0XCA3F8", "%+#X", +__LINE__, -0x00004bfL, "-001215", "%#5.6ld", +__LINE__, 0x319129abL, "0x319129ab", "%+#x", +__LINE__, -0x0000002L, "-2", "%ld", +__LINE__, -0x0f6686eL, "-16148590", "%.6ld", +__LINE__, 0x0329576bL, "53041003", "%2.d", +__LINE__, -0x000179eL, "-6046", "%d", +__LINE__, 0x000002ccL, "+716", "%+1.3ld", +__LINE__, 0xfffffff7L, "0xfffffff7", "% #x", +__LINE__, 0x0016eb40L, "1502016", "%ld", +__LINE__, 0x00000003L, "3", "%-0ld", +__LINE__, 0x0023e0d6L, "23E0D6", "%-05.X", +__LINE__, 0xffffa6a4L, "0XFFFFA6A4", "%#X", +__LINE__, 0x00087664L, "87664", "% .2x", +__LINE__, -0x0000002L, " -2", "%3.ld", +__LINE__, 0x003ad85dL, "3AD85D", "%X", +__LINE__, 0x00002f20L, "12064", "%ld", +__LINE__, 0x02030bfcL, "2030BFC", "%02.3X", +__LINE__, 0xfffff36aL, "FFFFF36A", "%X", +__LINE__, 0xfe0729ffL, "0xfe0729ff", "% #.0x", +__LINE__, 0xfec15164L, "FEC15164", "%0.2X", +__LINE__, -0x00169ecL, "-92652", "%+d", +__LINE__, 0x006d7990L, "0x6d7990", "%#x", +__LINE__, 0xffcc89e6L, "ffcc89e6", "%x", +__LINE__, 0x002d7ccaL, "2981066", "%7.7ld", +__LINE__, -0x1649692bL, "-373909803", "%#ld", +__LINE__, 0x00664f47L, "664f47", "%+6.x", +__LINE__, 0x00000000L, "0", "% X", +__LINE__, 0x00000047L, "000047", "%.6X", +__LINE__, 0x00000007L, "0000007", "%.7ld", +__LINE__, 0x00000030L, "30", "%-x", +__LINE__, -0x25bcbabbL, "-633125563", "% ld", +__LINE__, 0xfe11c031L, "FE11C031", "%4.6X", +__LINE__, -0x0000001L, "-0000001", "%.7d", +__LINE__, 0x00b56d84L, "11890052", "%ld", +__LINE__, -0x0000b01L, "-0002817", "%+07.7ld", +__LINE__, 0xffffe4adL, "ffffe4ad", "% 0.0x", +__LINE__, 0x007760fcL, "7760fc", "%+x", +__LINE__, 0xffef44d8L, "FFEF44D8", "%X", +__LINE__, 0xfcb6862eL, "fcb6862e", "%+x", +__LINE__, -0x0000001L, "-1", "%0d", +__LINE__, 0xffffffe6L, "FFFFFFE6", "%3.1X", +__LINE__, 0xff816e27L, "FF816E27", "% 6.X", +__LINE__, 0x00006415L, "25621", "%ld", +__LINE__, -0xfae5449L, "-263083081", "%0ld", +__LINE__, 0x00000001L, " 1", "% 0d", +__LINE__, 0x00000009L, " 9", "%2.X", +__LINE__, 0x002d7e18L, "2981400", "%7d", +__LINE__, -0x00000fcL, "-0000252", "%-#.7d", +__LINE__, 0x00000003L, "3", "%0x", +__LINE__, 0x0d46e47fL, "222749823", "%ld", +__LINE__, 0xfffcbc52L, "FFFCBC52", "%+X", +__LINE__, 0x00000000L, "0", "%-X", +__LINE__, 0xfffff0e5L, "fffff0e5", "%x", +__LINE__, 0xffffffd9L, "FFFFFFD9", "%07X", +__LINE__, 0x000004eeL, "4ee", "%0x", +__LINE__, 0xffffffffL, "ffffffff", "%0x", +__LINE__, -0x0008cb4L, "-036020", "%+3.6ld", +__LINE__, 0x0000dadaL, "0xdada", "%#0.x", +__LINE__, 0x0000001aL, "26 ", "%-4d", +__LINE__, -0x000000cL, " -12", "%04.d", +__LINE__, 0x0000025cL, " 25c", "%7.x", +__LINE__, 0xfe9b091eL, "FE9B091E", "%X", +__LINE__, 0x00000002L, " 2", "%07.ld", +__LINE__, -0x0004930L, "-18736", "% 6.d", +__LINE__, 0xffffffe9L, "FFFFFFE9", "%X", +__LINE__, 0x00000003L, " 3", "%2.ld", +__LINE__, 0x00000e00L, "3584", "%.4d", +__LINE__, 0xffff38c2L, "ffff38c2", "%0.x", +__LINE__, 0xffffffffL, "FFFFFFFF", "% .3X", +__LINE__, 0xff7c1b2fL, "FF7C1B2F", "%-3.2X", +__LINE__, -0x0000005L, "-5", "%2d", +__LINE__, 0x00098775L, "98775", "%x", +__LINE__, 0x000015ffL, " 15FF", "%6.X", +__LINE__, 0xfffbe3efL, "FFFBE3EF", "%0.3X", +__LINE__, -0x0000048L, "-72", "%ld", +__LINE__, 0x0001488aL, "84106", "%d", +__LINE__, 0x00000001L, "1", "%x", +__LINE__, -0x0000002L, "-2", "%-0.0ld", +__LINE__, -0x0000001L, "-1", "%-d", +__LINE__, 0x0006616fL, "6616f", "%x", +__LINE__, 0x3657856dL, "911705453", "%6.d", +__LINE__, -0x0007222L, "-0029218", "%.7d", +__LINE__, 0x00041606L, "267782", "%04.5d", +__LINE__, 0x00000001L, " 1", "%2.ld", +__LINE__, 0x00000219L, "219", "%0x", +__LINE__, 0x0ae0184cL, "ae0184c", "%x", +__LINE__, 0x00003a7dL, " 14973", "%7.ld", +__LINE__, 0xffffffffL, "0XFFFFFFFF", "%#X", +__LINE__, -0x0000002L, "-2", "%0ld", +__LINE__, 0x00002cdfL, "11487", "%0ld", +__LINE__, -0x000000cL, "-12", "%d", +__LINE__, -0x000000eL, "-14", "%-#2d", +__LINE__, 0x00000371L, "881", "%#ld", +__LINE__, 0x000015beL, " 5566", "%5.ld", +__LINE__, 0x01525b91L, "22174609", "%#0.0ld", +__LINE__, 0xff8fc22fL, "FF8FC22F", "% X", +__LINE__, -0x0007f7bL, "-32635", "%4.ld", +__LINE__, 0x00007bcaL, "7bca", "%x", +__LINE__, -0x0000582L, "-1410", "%ld", +__LINE__, 0x00000047L, " +71", "%+04.2d", +__LINE__, 0xf8a8dce2L, "f8a8dce2", "%+.6x", +__LINE__, -0x000de2eL, "-56878", "%.0d", +__LINE__, 0x019c03c1L, "0X19C03C1", "%#X", +__LINE__, -0x0f3a43eL, "-15967294", "%ld", +__LINE__, 0x00009e87L, "40583", "%#5.1d", +__LINE__, 0x000000b8L, "184", "%0ld", +__LINE__, -0x000befeL, "-48894", "%2ld", +__LINE__, -0x002ee1aL, "-192026", "%.2d", +__LINE__, 0x00004fd8L, "4fd8", "%x", +__LINE__, 0x0006d57bL, "447867", "%2d", +__LINE__, 0xfffffa9cL, "FFFFFA9C", "%-X", +__LINE__, 0x0000000fL, "15", "%ld", +__LINE__, 0x0005deb2L, "5DEB2", "% X", +__LINE__, 0x00000007L, "7", "%X", +__LINE__, 0xffffffc8L, "0XFFFFFFC8", "% #.1X", +__LINE__, 0xfffff62fL, "FFFFF62F", "%X", +__LINE__, -0x1a935bbaL, "-445864890", "% 3.5d", +__LINE__, 0x000b34b4L, "0x0b34b4", "%-#3.6x", +__LINE__, 0xfffff430L, "FFFFF430", "%X", +__LINE__, 0x00000b5fL, "+0002911", "%+#.7d", +__LINE__, 0x00000007L, " 7", "%3ld", +__LINE__, 0xffffffd8L, "FFFFFFD8", "% .7X", +__LINE__, 0xfffff544L, "FFFFF544", "%0X", +__LINE__, -0x353667b9L, "-892757945", "%d", +__LINE__, 0x00000058L, "0x00058", "%+#.5x", +__LINE__, 0x39dbcc4aL, "+970705994", "%+0.6ld", +__LINE__, 0xfffffffdL, "fffffffd", "% 01x", +__LINE__, 0x00b1c28eL, "+11649678", "%+0ld", +__LINE__, 0x000066c2L, "0X66C2", "%-#4X", +__LINE__, 0x007171a2L, "+7434658", "%+07.ld", +__LINE__, -0x0000001L, "-1", "%-d", +__LINE__, 0x00000ae0L, "+2784", "%+0d", +__LINE__, 0x13786a57L, "326658647", "%#5d", +__LINE__, -0x0000001L, "-1", "%2.ld", +__LINE__, -0x0168a16L, "-1477142", "%d", +__LINE__, 0x12df7dd6L, "316636630", "%ld", +__LINE__, 0x00000000L, "000000", "%1.6d", +__LINE__, 0x266da2a9L, "644719273", "%ld", +__LINE__, 0x0000004aL, "74", "%d", +__LINE__, 0x000102ffL, "00102FF", "%+06.7X", +__LINE__, 0x17916237L, "0x17916237", "%#5x", +__LINE__, -0x0003cbbL, "-0015547", "%-.7d", +__LINE__, 0xe7da2010L, "e7da2010", "%2.4x", +__LINE__, 0xfffffff3L, "fffffff3", "% .7x", +__LINE__, 0xfc9b64f8L, "FC9B64F8", "% 7.X", +__LINE__, 0x000001afL, "431", "%0d", +__LINE__, 0xffc81796L, "0xffc81796", "%#.5x", +__LINE__, 0x057a1fbcL, "+91889596", "%+04d", +__LINE__, 0x00001ae1L, "6881", "%ld", +__LINE__, 0xfffffff6L, "fffffff6", "%3.0x", +__LINE__, -0x6b7d5dbL, "-112711131", "%-06.1d", +__LINE__, 0x008e8a5cL, " 8e8a5c", "%7.0x", +__LINE__, 0xfe07a9bdL, "fe07a9bd", "%.1x", +__LINE__, -0x00278e6L, "-162022", "%0ld", +__LINE__, 0xf98709f5L, "F98709F5", "%X", +__LINE__, -0x00000c9L, "-201", "% 1.d", +__LINE__, -0x000001dL, "-00029", "%+2.5ld", +__LINE__, 0x00000030L, " 48", "% d", +__LINE__, 0xffd753f4L, "FFD753F4", "%0X", +__LINE__, 0xfffffffdL, "FFFFFFFD", "%X", +__LINE__, 0x0000a765L, "a765", "%x", +__LINE__, 0x0026e2c8L, "26E2C8", "%-0X", +__LINE__, -0x00003ebL, "-1003", "%3.1ld", +__LINE__, 0x015d53caL, "22893514", "%0ld", +__LINE__, -0x0000020L, "-32", "%ld", +__LINE__, -0x03558ddL, "-3496157", "%1.0ld", +__LINE__, -0x000007fL, "-127", "%1.d", +__LINE__, 0xffffc737L, "0xffffc737", "%+#x", +__LINE__, 0x0000a70dL, " a70d", "%6.x", +__LINE__, 0x01ea0e31L, "0X1EA0E31", "% #1.X", +__LINE__, 0x00b5f406L, "0X0B5F406", "%-#.7X", +__LINE__, 0x0e58fa9aL, "240712346", "%.2d", +__LINE__, 0xf43ff8a9L, "f43ff8a9", "%+0.6x", +__LINE__, -0x5d0d3d3L, "-97571795", "%.3ld", +__LINE__, -0x000027aL, "-634", "%0d", +__LINE__, 0xffcef248L, "FFCEF248", "%07.X", +__LINE__, 0x000002dcL, "2dc", "%0x", +__LINE__, -0x31fa6c1L, "-52405953", "%.2d", +__LINE__, 0x00000014L, "14", "%X", +__LINE__, -0x0282f98L, "-2633624", "%ld", +__LINE__, 0x00005f55L, "24405", "%#d", +__LINE__, -0x0000004L, "-4", "%d", +__LINE__, 0x00000001L, "1", "%+x", +__LINE__, 0x013f47ceL, "13f47ce", "%0.x", +__LINE__, 0x00143fceL, "1327054", "%.3d", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, 0x00001f9aL, "1F9A", "% X", +__LINE__, 0x00000cf5L, "cf5", "%x", +__LINE__, 0xffea9c24L, "ffea9c24", "%x", +__LINE__, 0xf09f85a7L, "F09F85A7", "%X", +__LINE__, 0x00001e04L, "7684", "%ld", +__LINE__, 0xffffc82aL, "ffffc82a", "%7x", +__LINE__, -0x0000a77L, "-2679", "% d", +__LINE__, 0x0019a859L, "+1681497", "%+2.6ld", +__LINE__, -0x00002d7L, "-727", "%ld", +__LINE__, 0x00011b82L, "72578", "%-#ld", +__LINE__, 0x00000c32L, "3122", "%ld", +__LINE__, -0x0000337L, "-823", "%1.d", +__LINE__, 0x00000004L, "4", "%1ld", +__LINE__, 0x0000062cL, "1580", "%.1ld", +__LINE__, 0xffffffd3L, "FFFFFFD3", "% X", +__LINE__, -0x07b1bf8L, "-8068088", "%#d", +__LINE__, 0xfffffff9L, "fffffff9", "%x", +__LINE__, 0x159e6cfbL, "159e6cfb", "%0.x", +__LINE__, 0x0001148dL, "1148d", "%-.1x", +__LINE__, 0x003373b7L, "3371959", "%#.0d", +__LINE__, 0x00001af2L, "1af2", "%.4x", +__LINE__, -0x0000001L, "-000001", "%+.6ld", +__LINE__, -0x00001a3L, "-419", "%d", +__LINE__, 0xfdb232e7L, "fdb232e7", "%5.4x", +__LINE__, -0x000000dL, "-13", "%d", +__LINE__, 0x98ec1c74L, "98ec1c74", "% 3x", +__LINE__, 0xfffffff8L, "fffffff8", "%+1.4x", +__LINE__, -0x0000d58L, "-3416", "%+#0ld", +__LINE__, -0x65d1973L, "-106764659", "%.6d", +__LINE__, -0x0737641L, "-7566913", "%-d", +__LINE__, 0x0000037cL, "37c", "%+0x", +__LINE__, 0x0000012cL, "0000300", "%#3.7d", +__LINE__, 0x00c12d9bL, "12660123", "%1.5ld", +__LINE__, 0xe7e5e77dL, "e7e5e77d", "%6x", +__LINE__, 0x1fe0e820L, "1FE0E820", "%-4X", +__LINE__, 0xc85a793aL, "C85A793A", "%X", +__LINE__, 0x05f9fe2cL, "100269612", "%#ld", +__LINE__, 0x00000032L, "0X32", "%+#4.1X", +__LINE__, 0xfab4ce81L, "fab4ce81", "%3.x", +__LINE__, -0x0000009L, "-9", "%2.d", +__LINE__, 0xffff8d2eL, "ffff8d2e", "% 6x", +__LINE__, 0xfffffffeL, "0xfffffffe", "%#x", +__LINE__, 0x02960f60L, "2960f60", "%1.x", +__LINE__, 0x34cf3cbcL, " 885996732", "% 5ld", +__LINE__, -0x000006eL, "-110", "% d", +__LINE__, -0x0000001L, "-1", "%-.0d", +__LINE__, 0x000000b1L, " B1", "%+7X", +__LINE__, 0xfffff5b4L, "FFFFF5B4", "%01.7X", +__LINE__, 0x00000086L, "86", "%0X", +__LINE__, 0x00074367L, " 74367", "% 6x", +__LINE__, 0x001000d7L, "+1048791", "%+ld", +__LINE__, 0x00000f35L, " 3893", "% d", +__LINE__, -0x00000e1L, "-225", "%d", +__LINE__, 0xffff6694L, "FFFF6694", "%6.X", +__LINE__, 0x00019cf7L, "19cf7", "%0.x", +__LINE__, 0x00000046L, "0046", "%+.4X", +__LINE__, -0x000001fL, "-31", "%ld", +__LINE__, 0xfff25859L, "fff25859", "%6x", +__LINE__, 0x21884061L, "562577505", "%#ld", +__LINE__, 0x01448b7aL, "1448B7A", "%0.1X", +__LINE__, 0xffffffc0L, "ffffffc0", "%x", +__LINE__, 0xfffffed5L, "fffffed5", "% 1.0x", +__LINE__, 0x0e349767L, "E349767", "%.5X", +__LINE__, 0x00000330L, "816", "%0d", +__LINE__, -0x0000016L, "-22", "%d", +__LINE__, 0xffff9babL, "FFFF9BAB", "%X", +__LINE__, 0xffffee4eL, "ffffee4e", "%x", +__LINE__, 0x0026beebL, "2539243", "%6.d", +__LINE__, 0x00002c6cL, "11372", "%.2d", +__LINE__, -0x000002cL, "-44", "%ld", +__LINE__, -0x001dcfaL, "-122106", "% d", +__LINE__, 0x0001683cL, "92220", "%#4.ld", +__LINE__, 0x09b51fc9L, "9b51fc9", "%+.7x", +__LINE__, 0x0000001dL, "29", "%0ld", +__LINE__, -0x83f17e5L, "-138352613", "%ld", +__LINE__, 0xfa4e2c1bL, "fa4e2c1b", "%x", +__LINE__, 0x000001f3L, "499", "%0ld", +__LINE__, 0xffff03e4L, "ffff03e4", "%x", +__LINE__, 0x000000acL, "+0172", "%+.4ld", +__LINE__, 0x03c3903bL, "63148091", "%00d", +__LINE__, 0x0000000dL, "13", "%#d", +__LINE__, 0x0000002eL, "0X2E", "%#X", +__LINE__, 0x00006b2dL, "6B2D", "%X", +__LINE__, 0x0000010bL, " 0010b", "%7.5x", +__LINE__, 0x0000017aL, " 17a", "%4x", +__LINE__, 0xfffffffbL, "fffffffb", "%+x", +__LINE__, 0xffffac6aL, "ffffac6a", "%-.3x", +__LINE__, -0x0005870L, "-22640", "%0d", +__LINE__, 0x189c17bcL, "189c17bc", "%x", +__LINE__, -0x01bbc38L, "-1817656", "%#6.ld", +__LINE__, -0x3382b55L, "-54012757", "%d", +__LINE__, -0x0000007L, "-7", "%-ld", +__LINE__, -0x000c74bL, "-51019", "%ld", +__LINE__, 0x0001a6f2L, "+108274", "%+#1.ld", +__LINE__, 0x00077448L, "77448", "%x", +__LINE__, 0x00000000L, "0", "%x", +__LINE__, 0xfffff056L, "FFFFF056", "%.3X", +__LINE__, -0x6f3f9451L, "-1866437713", "%-#3.0ld", +__LINE__, 0x000000acL, "AC", "%X", +__LINE__, 0xffc8752fL, "ffc8752f", "%-x", +__LINE__, 0xfffffe6dL, "FFFFFE6D", "%2.X", +__LINE__, -0x377f1a5L, "-58192293", "% .2d", +__LINE__, -0x0000294L, "-660", "%d", +__LINE__, 0xfffffffeL, "fffffffe", "%-x", +__LINE__, 0xfffcbbe8L, "0xfffcbbe8", "%-#4.x", +__LINE__, 0x0022e510L, "+2286864", "%+ld", +__LINE__, 0xfffffe2aL, "FFFFFE2A", "%0.3X", +__LINE__, 0xfe29f7c0L, "fe29f7c0", "%x", +__LINE__, 0xfffe957eL, "FFFE957E", "%X", +__LINE__, 0x000080f8L, "33016", "%ld", +__LINE__, 0x0003ee2cL, " 257580", "%7d", +__LINE__, 0x000003a1L, "929", "%d", +__LINE__, 0x0000021fL, "21f", "%+x", +__LINE__, 0xffffffffL, "ffffffff", "%.5x", +__LINE__, -0x040a988L, "-4237704", "%-d", +__LINE__, 0x027c8b69L, "41716585", "%ld", +__LINE__, 0x00000003L, "3", "%-X", +__LINE__, -0x0000368L, " -872", "%7.d", +__LINE__, 0x00000d3cL, "3388", "%0.2d", +__LINE__, -0x33734ccL, "-53949644", "%2ld", +__LINE__, 0x000003dbL, "3DB", "%X", +__LINE__, -0x00f154dL, "-988493", "%5d", +__LINE__, 0x0000000bL, " 11", "%4.ld", +__LINE__, 0x00000067L, "103", "%-ld", +__LINE__, -0x0199fceL, "-1679310", "%4d", +__LINE__, 0x02b6266bL, "2b6266b", "% x", +__LINE__, -0x006b39dL, "-439197", "%+d", +__LINE__, 0x00000007L, "7", "%ld", +__LINE__, 0x0141fc98L, "21101720", "%0ld", +__LINE__, -0x0008420L, "-33824", "%d", +__LINE__, 0x0011622bL, "1139243", "%6ld", +__LINE__, 0x0000001bL, "27", "%-d", +__LINE__, -0x0030935L, "-198965", "%3d", +__LINE__, 0x0000001fL, " 1f", "%4.x", +__LINE__, -0x10782a19L, "-276310553", "%#ld", +__LINE__, -0x007eac4L, "-518852", "%06.ld", +__LINE__, 0x0bc4c681L, "197445249", "%6ld", +__LINE__, 0x000000f5L, "245", "%.3ld", +__LINE__, 0x00000197L, "197", "%X", +__LINE__, 0xfffffeabL, "FFFFFEAB", "% X", +__LINE__, 0x00000f05L, "F05", "%+X", +__LINE__, 0xffe1b785L, "0xffe1b785", "%#x", +__LINE__, -0x02d3581L, "-2962817", "%05d", +__LINE__, 0xffffb994L, "FFFFB994", "%X", +__LINE__, 0x03d139a3L, "64043427", "%ld", +__LINE__, -0x0000002L, " -2", "%+4.d", +__LINE__, -0x043da83L, "-4446851", "%#ld", +__LINE__, -0x6aad891L, "-111859857", "%7.ld", +__LINE__, 0x00003e68L, "15976", "%-4.5ld", +__LINE__, 0xffe4d3eeL, "FFE4D3EE", "%X", +__LINE__, 0x00000002L, "000002", "%4.6ld", +__LINE__, 0xffffee32L, "ffffee32", "%4x", +__LINE__, 0x0cb7dd25L, "cb7dd25", "%3x", +__LINE__, 0xf773d422L, "F773D422", "%X", +__LINE__, -0x0b590f7L, "-11899127", "%#d", +__LINE__, -0x0002c45L, "-11333", "%-#5ld", +__LINE__, -0x1efc9e4L, "-32492004", "%ld", +__LINE__, -0x0003b9cL, "-15260", "%d", +__LINE__, 0x000001b6L, "0X1B6", "%#4X", +__LINE__, 0x3ce93ec3L, "1021918915", "%.6d", +__LINE__, 0xffffffffL, "ffffffff", "%-x", +__LINE__, 0xfffaf0e4L, "fffaf0e4", "%2.x", +__LINE__, 0x00000002L, "0x2", "%#x", +__LINE__, 0x0000e806L, "e806", "%4x", +__LINE__, 0xfffffff0L, "fffffff0", "% 2.x", +__LINE__, 0xfffffc0eL, "fffffc0e", "%+.4x", +__LINE__, 0xfd45716eL, "FD45716E", "%.4X", +__LINE__, 0xfff96fdaL, "FFF96FDA", "%-X", +__LINE__, 0xff99d08aL, "FF99D08A", "%.5X", +__LINE__, 0x00000002L, "2", "%-00.d", +__LINE__, -0x000000fL, " -15", "%6.ld", +__LINE__, -0x00d321cL, "-864796", "%#1ld", +__LINE__, 0xff19ff8dL, "ff19ff8d", "%1.5x", +__LINE__, 0x00000000L, "0000000", "%-.7x", +__LINE__, 0x0000f50dL, " F50D", "%5X", +__LINE__, 0x00001688L, " 5768", "%7.ld", +__LINE__, 0x00000157L, "343", "%2ld", +__LINE__, 0xfffffffdL, "0xfffffffd", "%+#3x", +__LINE__, 0x00000d52L, "3410", "%ld", +__LINE__, 0x00000003L, "3", "%d", +__LINE__, 0x0001c6d2L, "01c6d2", "%.6x", +__LINE__, 0x242d65d2L, "606954962", "%#7.ld", +__LINE__, 0x00000e9fL, "0000E9F", "%5.7X", +__LINE__, 0x0002d785L, "2D785", "%0X", +__LINE__, 0x00000167L, "167", "%0X", +__LINE__, 0xfffff5e5L, "fffff5e5", "% x", +__LINE__, 0xffb69a04L, "0xffb69a04", "%#0.x", +__LINE__, 0xfffa012eL, "FFFA012E", "%X", +__LINE__, 0x0000001aL, "0x1a", "% #x", +__LINE__, 0xfffb26d3L, "fffb26d3", "%+x", +__LINE__, -0x00003e6L, " -998", "%7ld", +__LINE__, 0x00000004L, "4", "%-d", +__LINE__, 0xfffffd76L, "0XFFFFFD76", "%#7X", +__LINE__, 0x00000035L, "53", "%ld", +__LINE__, 0xffc6c190L, "0XFFC6C190", "%#X", +__LINE__, 0xffffffe2L, "ffffffe2", "%7.0x", +__LINE__, 0x03ff1b87L, "67050375", "%2.d", +__LINE__, 0x00020c47L, "0X20C47", "%#X", +__LINE__, 0x00000000L, "0", "%d", +__LINE__, 0x0000000eL, "0X000E", "% #.4X", +__LINE__, -0x00035cdL, "-13773", "%+2.d", +__LINE__, 0x00005eecL, "5eec", "%1x", +__LINE__, 0x001da0ffL, "1941759", "%0d", +__LINE__, 0xf8a9e96aL, "f8a9e96a", "%+x", +__LINE__, -0x0000120L, "-288 ", "%-#6.d", +__LINE__, 0x00000000L, "0", "%-X", +__LINE__, 0x0000152eL, "152E", "%+X", +__LINE__, -0x0001077L, "-4215", "% 0d", +__LINE__, 0xffffffd7L, "FFFFFFD7", "%0X", +__LINE__, 0xfffe097dL, "FFFE097D", "%2X", +__LINE__, 0xcb982712L, "cb982712", "%x", +__LINE__, 0xfff39f2eL, "FFF39F2E", "%.5X", +__LINE__, -0x0058caeL, "-363694", "%+.1d", +__LINE__, -0x000002bL, "-043", "%#1.3d", +__LINE__, -0x001e989L, "-125321", "%1d", +__LINE__, 0x00959ecdL, "9805517", "%d", +__LINE__, 0xf49df846L, "F49DF846", "%+3X", +__LINE__, 0xfffffffdL, "fffffffd", "%+.5x", +__LINE__, -0x000ac76L, "-44150", "%3.ld", +__LINE__, 0x00000028L, " 0028", "%06.4x", +__LINE__, 0x000003e8L, "3E8", "%-02X", +__LINE__, 0x00000012L, "012", "%.3X", +__LINE__, 0x00000006L, "0X6", "%#X", +__LINE__, 0x00ef8479L, "+15697017", "%+0.6d", +__LINE__, 0xffffffe8L, "FFFFFFE8", "%-X", +__LINE__, 0x773a90f7L, "773a90f7", "%3.5x", +__LINE__, 0x00096d44L, "96D44", "%-X", +__LINE__, -0x08a3d96L, "-9059734", "%ld", +__LINE__, -0x000001aL, "-26", "%00.ld", +__LINE__, 0x32f57585L, "32f57585", "% x", +__LINE__, 0x2825f175L, "2825F175", "%X", +__LINE__, 0x000054ffL, "21759", "%-2d", +__LINE__, -0x0266cdcL, "-2518236", "%ld", +__LINE__, 0x0000031dL, "0X31D", "%+#4X", +__LINE__, 0x0003fc99L, "3fc99", "%x", +__LINE__, -0x0064624L, "-411172", "%-#d", +__LINE__, 0x0001b2d9L, "111321", "%-ld", +__LINE__, -0x000007cL, "-124", "%#d", +__LINE__, 0xfffffffaL, "FFFFFFFA", "%+X", +__LINE__, -0x007a5b8L, "-501176", "%+ld", +__LINE__, 0x0213b583L, "213B583", "%2.X", +__LINE__, 0xfff12e51L, "FFF12E51", "%+X", +__LINE__, 0x00052403L, "0336899", "%-0.7d", +__LINE__, 0xffffffffL, "ffffffff", "%-04.4x", +__LINE__, 0x00000010L, "0010", "%0.4X", +__LINE__, 0xffffffb5L, "FFFFFFB5", "%-1.3X", +__LINE__, -0x0000001L, "-1", "%d", +__LINE__, 0x0003a2d1L, "3a2d1", "% x", +__LINE__, 0x00000424L, "1060", "%0ld", +__LINE__, -0x0000078L, "-120", "%1d", +__LINE__, 0x00000000L, "0", "%ld", +__LINE__, 0x00000414L, "1044", "%ld", +__LINE__, 0x00000072L, "0x072", "%#5.3x", +__LINE__, 0x0000007aL, "7A", "% X", +__LINE__, 0x081542a3L, "135611043", "%0d", +__LINE__, 0xfffb4ce6L, "fffb4ce6", "%4.6x", +__LINE__, 0x00002ab2L, "2ab2", "%-1x", +__LINE__, 0x00000000L, " 0", "% 2x", +__LINE__, 0xfffffa59L, "FFFFFA59", "%2.X", +__LINE__, 0xffffe22bL, "ffffe22b", "%-x", +__LINE__, 0xfffffd52L, "FFFFFD52", "%+.2X", +__LINE__, 0x0000039fL, "927", "%-d", +__LINE__, 0x0002dea6L, "2dea6", "%0x", +__LINE__, 0x000216dbL, "136923", "%ld", +__LINE__, 0x00000013L, "19", "%0d", +__LINE__, 0x000047ccL, "18380", "%2.2ld", +__LINE__, -0x0007d10L, "-32016", "%d", +__LINE__, 0xff9af906L, "FF9AF906", "%0X", +__LINE__, 0x02cfa224L, "+47161892", "%+0.7d", +__LINE__, -0x0000022L, "-34", "%1.d", +__LINE__, 0xfffffff0L, "FFFFFFF0", "%-4X", +__LINE__, 0x00000029L, " 41", "%6.ld", +__LINE__, 0xffffff76L, "ffffff76", "%x", +__LINE__, 0x00000000L, "0", "%+X", +__LINE__, 0x00000001L, "1", "%d", +__LINE__, 0xfff6de5aL, "FFF6DE5A", "%X", +__LINE__, 0x00000002L, "2", "%ld", +__LINE__, 0x00000025L, "25", "%+x", +__LINE__, 0xfffffffbL, "FFFFFFFB", "%5.0X", +__LINE__, 0x0011bbb5L, "1162165", "%0.0ld", +__LINE__, 0xfffcdc96L, "0XFFFCDC96", "%#X", +__LINE__, 0x00008f5fL, "8f5f", "%3.1x", +__LINE__, 0xffa0fa5dL, "0XFFA0FA5D", "%#X", +__LINE__, 0x00004534L, "4534", "% 0X", +__LINE__, 0xfffffff9L, "fffffff9", "%.2x", +__LINE__, 0xffeeae50L, "ffeeae50", "%-x", +__LINE__, 0x00002964L, " 0010596", "% 0.7d", +__LINE__, 0x000021c9L, " 21c9", "%6x", +__LINE__, 0x00000001L, " 1", "% d", +__LINE__, 0x0002abd8L, "+175064", "%+d", +__LINE__, 0xffffffadL, "FFFFFFAD", "%+0X", +__LINE__, 0x00000003L, "3", "%ld", +__LINE__, 0x0c036da3L, " 201551267", "% .3d", +__LINE__, -0x004343cL, "-275516", "%+ld", +__LINE__, 0x00000003L, "003", "% .3x", +__LINE__, 0xffffe34eL, "ffffe34e", "%x", +__LINE__, 0x0000e118L, "e118", "%x", +__LINE__, -0x007d945L, "-514373", "%+#0ld", +__LINE__, 0x277f1cc5L, "277f1cc5", "% x", +__LINE__, 0x00003befL, "03bef", "% 0.5x", +__LINE__, 0xfffffcb9L, "fffffcb9", "%x", +__LINE__, 0x0003311aL, "209178", "%ld", +__LINE__, 0x00000000L, " ", "%3.ld", +__LINE__, 0x05942225L, "5942225", "%x", +__LINE__, 0xfffceb4cL, "FFFCEB4C", "%-X", +__LINE__, 0xffd08633L, "ffd08633", "%2.x", +__LINE__, -0x0000001L, " -1", "%6d", +__LINE__, 0x000fdb12L, "1039122", "%d", +__LINE__, 0x00000003L, "3", "% 0X", +__LINE__, -0x2fd5bf1L, "-50158577", "% 5.ld", +__LINE__, -0x0089a03L, "-563715", "%-d", +__LINE__, 0xfffffffeL, "FFFFFFFE", "% X", +__LINE__, 0x29fdb2baL, "29fdb2ba", "% 0x", +__LINE__, 0x0000008fL, "8F", "% X", +__LINE__, 0x00000003L, "3", "%ld", +__LINE__, 0xffc58445L, "FFC58445", "%.2X", +__LINE__, -0x00023f6L, "-9206", "%+d", +__LINE__, 0x00000011L, "11", "%X", +__LINE__, -0x0000003L, "-0000003", "%-.7d", +__LINE__, -0x0000003L, "-3", "%#ld", +__LINE__, 0x001242d9L, "1242D9", "%X", +__LINE__, -0x48d0c81L, "-76352641", "%7.d", +__LINE__, -0x001b675L, "-112245", "%#ld", +__LINE__, 0x00000003L, "3", "%-d", +__LINE__, 0xfff93fdfL, "0XFFF93FDF", "% #X", +__LINE__, 0x001a9414L, "1741844", "%#ld", +__LINE__, 0x0001fd86L, "130438", "%ld", +__LINE__, 0x010f37a8L, "17774504", "%4.7d", +__LINE__, 0x00382838L, "0382838", "%3.7X", +__LINE__, -0x47fd56c2L, "-1207785154", "%ld", +__LINE__, 0x001981ddL, "1981dd", "%x", +__LINE__, 0xffffefbaL, "ffffefba", "% 06.x", +__LINE__, -0x3f402b29L, "-1061169961", "%+#ld", +__LINE__, -0x395aae44L, "-962244164", "%-1d", +__LINE__, 0x1fa39f42L, "530816834", "%#d", +__LINE__, -0x000358dL, "-13709", "%d", +__LINE__, -0xdc17b8fL, "-230783887", "%ld", +__LINE__, -0x23c41583L, "-600053123", "%+3.d", +__LINE__, 0xfffffc16L, "fffffc16", "%x", +__LINE__, 0x003f1364L, "4133732", "%7.ld", +__LINE__, 0xffffe691L, "FFFFE691", "%07X", +__LINE__, 0x07b31d71L, "129178993", "%.7d", +__LINE__, -0x0019732L, "-104242", "% ld", +__LINE__, 0x02428167L, "0x2428167", "%#x", +__LINE__, -0x06c1ecdL, "-7085773", "%.7ld", +__LINE__, 0xfb01cb4eL, "fb01cb4e", "%x", +__LINE__, 0x00005a41L, "+23105", "%+ld", +__LINE__, 0xfffffff4L, "FFFFFFF4", "%-5.X", +__LINE__, 0x00000005L, " 5", "%4.ld", +__LINE__, 0xf4ab4b2dL, "F4AB4B2D", "%0.X", +__LINE__, -0x000fce3L, "-64739", "%+#3.ld", +__LINE__, 0x000076eaL, " 30442", "%6.2ld", +__LINE__, 0x00000cb9L, " cb9", "%4.x", +__LINE__, 0x002f43efL, "3097583", "%1.1ld", +__LINE__, 0xf5bd0105L, "F5BD0105", "%+X", +__LINE__, 0x0037954aL, "3642698", "%d", +__LINE__, 0xfffffff7L, "0XFFFFFFF7", "%-#X", +__LINE__, 0xffffcedfL, "0xffffcedf", "%#6.7x", +__LINE__, 0xfffffde4L, "FFFFFDE4", "%2.4X", +__LINE__, 0x01a6f103L, "1a6f103", "%5.x", +__LINE__, 0x00000191L, " 191", "%7.0X", +__LINE__, 0x00000003L, "03", "% .2X", +__LINE__, -0xd4e3219L, "-223228441", "%6.ld", +__LINE__, 0x00b0efbdL, "11595709", "%d", +__LINE__, -0x00000eaL, "-234", "%#3d", +__LINE__, 0x00000be8L, "BE8 ", "%-5X", +__LINE__, 0xffffffffL, "ffffffff", "%5.3x", +__LINE__, -0x267f8c6L, "-40368326", "%d", +__LINE__, 0x000006edL, "6ED", "%X", +__LINE__, 0xfdd6c9b6L, "FDD6C9B6", "%X", +__LINE__, 0x0007ac29L, "7ac29", "%-x", +__LINE__, 0x00000014L, "14", "%2x", +__LINE__, 0x123ca563L, "+305964387", "%+ld", +__LINE__, 0x00000004L, " 4", "%5.d", +__LINE__, 0xffff877aL, "ffff877a", "%x", +__LINE__, -0x00003e7L, "-999", "%+0.3d", +__LINE__, 0x0a68ba6eL, "a68ba6e", "%3.1x", +__LINE__, 0xfe29c810L, "FE29C810", "%+X", +#endif + +__LINE__, 0x00000000L, "0", "%o", +__LINE__, 0000000123L, "123", "%o", +__LINE__, 0000123456L, "0123456", "%#o", +__LINE__, 0000123456L, "00123456", "%#.8o", +__LINE__, 0000123456L, " 00123456", "%#10.8o", +__LINE__, 0x00000123L, "0x00123", "%#07x", + +0, +}; + +int main() +{ + int errcount = 0; + int testcount = 0; +#define BSIZE 1024 + char buffer[BSIZE]; + sprint_int_type *iptr; +#if defined(__cplusplus) && !defined(TEST_LIBIO) + + ostrstream sstr(buffer, BSIZE); + + for (iptr = sprint_ints; iptr->line; iptr++) { + sstr.seekp(0); + sstr.form(iptr->format_string, iptr->value); + sstr << ends; + if (strcmp(buffer, iptr->result) != 0) { + errcount++; + cerr << "Error in line " << iptr->line; + cerr << " using \"" << iptr->format_string; + cerr << "\". Result is \"" << buffer << "\"; should be: \""; + cerr << iptr->result << "\".\n"; + } + testcount++; + } + + + if (errcount == 0) { + cerr << "Encountered no errors in " << testcount << " tests.\n"; + return 0; + } + else { + cerr << "Encountered " << errcount << " errors in " + << testcount << " tests.\n"; + return 1; + } +#else + for (iptr = sprint_ints; iptr->line; iptr++) + { + if (sizeof(int)==2) + { + /* Cheezy, but effective. */ + char buf[30]; + int len = strlen(iptr->format_string); + + strcpy(buf, iptr->format_string); + if(buf[len-2] != 'l') { + buf[len] = buf[len-1]; + buf[len-1] = 'l'; + buf[len+1] = 0; + } + sprintf(buffer, buf, iptr->value); + } + else + { + sprintf(buffer, iptr->format_string, iptr->value); + } + if (strcmp(buffer, iptr->result) != 0) { + errcount++; + fprintf(stderr, + "Error in line %d using \"%s\". Result is \"%s\"; should be: \"%s\".\n", + iptr->line, iptr->format_string, buffer, iptr->result); + fprintf(stderr,"%ld\n",iptr->value); + } + testcount++; + } + + if (errcount == 0) { + fprintf(stderr, "Encountered no errors in %d tests.\n", testcount); + return 0; + } + else { + fprintf(stderr, "Encountered %d errors in %d tests.\n", + errcount, testcount); + return 1; + } +#endif +} diff --git a/libio/tests/tiomanip.cc b/libio/tests/tiomanip.cc new file mode 100644 index 000000000000..b7dd08a4618e --- /dev/null +++ b/libio/tests/tiomanip.cc @@ -0,0 +1,35 @@ +// test the parametrized manipulators + +#include +#include + +main() +{ +#ifdef _G_NO_TEMPLATES + cerr << "(IO manipulators are not supported with this compiler)\n"); + exit(-1); +#else + + cout << dec << 1234 << ' ' + << hex << 1234 << ' ' + << oct << 1234 << endl; + + //SMANIP x = setw(4); + //operator<<(cout, x); + + cout + << "(" + << dec << setw(4) << setfill('*') + << 12 << ")\n"; + + cout << "(" << 12 << ")\n"; + + cout << setiosflags(ios::internal); + cout << "(" << setw(6) << -12 << ")\n"; + + exit(0); +#endif +} + + + diff --git a/libio/tests/tiomanip.exp b/libio/tests/tiomanip.exp new file mode 100644 index 000000000000..7a0a7ea5cb21 --- /dev/null +++ b/libio/tests/tiomanip.exp @@ -0,0 +1,4 @@ +1234 4d2 2322 +(**12) +(12) +(-***12) diff --git a/libio/tests/tiomisc.cc b/libio/tests/tiomisc.cc new file mode 100644 index 000000000000..207a3f16e2b4 --- /dev/null +++ b/libio/tests/tiomisc.cc @@ -0,0 +1,236 @@ +/* Random regression tests etc. */ + +#include +#include +#include +#include +#include +#include +#include + +#define BUF_SIZE 4096 + +void +test1 () +{ + fstream f; + char buf[BUF_SIZE]; + + f.setbuf( buf, BUF_SIZE ); +} + +void +test2 ( ) +{ + char string[BUF_SIZE]; + ostrstream s( string, BUF_SIZE ); + + s << "Bla bla bla " << 55 << ' ' << 3.23 << '\0' << endl; + cout << "Test2: " << string << endl; +} + + +/* Test case from Joe Buck . */ + +class special_ofstream : public ofstream { +public: + special_ofstream() : ofstream() {} + special_ofstream(int fd) : ofstream(fd) {} + special_ofstream(const char *name, int mode=ios::out, int prot=0664) { + open(name,mode,prot); + } + void open(const char *name, int mode=ios::out, int prot=0664); +}; + +void special_ofstream::open(const char* name, int mode, int prot) { + if (strcmp(name, "") == 0) { + rdbuf()->attach(1); + } + else if (strcmp(name, "") == 0) { + rdbuf()->attach(2); + setf(unitbuf); + } + else ofstream::open(name,mode,prot); +} + +void +test3 () +{ + { + special_ofstream o(""); + o << "Hello\n"; + // o is destructed now. This should not close cout + } + { + special_ofstream o(""); + o << "Line 2\n"; + } +} + +void +getline_test1 () +{ + char buf[1000]; + char data[] = "#include \n#include \n"; + istrstream infile(data, strlen(data)); + infile.getline(buf,1000); + infile.getline(buf,1000); + + cout << buf << '\n'; +} + +// test istream::getline on readng overlong lines. +void +getline_test2 () +{ + char data[] = "Line one.\nline 2.\n"; + char line[100]; + istrstream strin(data, strlen(data)); + strin.getline(line, 10); + cout << "line: " << line << ", count: " << strin.gcount () << "\n"; +} + +void +getline_test3 () +{ + char data[] = "123456789\nabcdefghijkl.\n"; + char line[10]; + istrstream strin(data, strlen(data)); + strin.getline(line, 10); + cout << "line: " << line << ", count: " << strin.gcount () << "\n"; + strin.getline(line, 10); + cout << "line: " << line << ", count: " << strin.gcount () << "\n"; + assert (!strin.good()); + strin.clear (); + strin.getline(line, 10); + cout << "line: " << line << ", count: " << strin.gcount () << "\n"; +} + +class A : private ostream +{ +public: + A(streambuf* s); + ostream::flush; +}; +A::A(streambuf* s) +: ostream(s) +{ +} + +void +flush1_test() +{ + A os(cout.rdbuf()); + os.flush(); +} + +void +reread_test () +{ // This is PR 5486. + int tag_char; + char *fname = "Makefile"; + int mode = O_RDONLY; + filebuf file_p; + + int fd = ::open(fname, mode, 0666); + file_p.attach(fd); + + istream d_istream(&file_p); + + // Read a character from the stream, save it and put it back. + tag_char = d_istream.get(); + int save_char = tag_char; + d_istream.putback((char) tag_char); + + // Uncomment then next statement and the next get will be EOF. + streampos pos = d_istream.tellg(); + + // Re-read the first character + tag_char = d_istream.get(); + + cout << "reread_test: " << (char)save_char << " " << (char)tag_char << "\n"; + cout.flush(); + +} + +void *danger_pointer; +void operator delete (void *p) throw() +{ + if (p) + { + if (p == danger_pointer) + fprintf (stderr, "maybe deleted\n"); + + free (p); + } +} + +struct my_ostream: virtual public ios, public ostream +{ + my_ostream (ostream &s): ios (s.rdbuf()) { } +}; + +void +test_destroy () +{ + ofstream fstr ("foo.dat"); + my_ostream wa (fstr); + + /* Check that sure wa.rdbuf() is only freed once. */ + danger_pointer = wa.rdbuf (); + + wa << "Hi there" << endl; +#ifdef _IO_NEW_STREAMS + fprintf (stderr, "maybe deleted\n"); +#endif +} + +/* Submitted by Luke Blanshard . + + In certain circumstances, the library will write past the end of the + buffer it has allocated for a file: You must read from the file, + exactly enough bytes that the read pointer is at the end of the + buffer. Then you must write to the file, at the same place you just + finished reading from. + + "Your patch looks great, and you're welcome to use the test code for any + purpose whatever. I hereby renounce my implicit copyright on it." */ + +void +test_read_write_flush () +{ + fstream f; + char buf[8192]; + + for ( int index=0; index < sizeof buf; ++index ) + buf[index] = (index+1)&63? 'x' : '\n'; + + f.open( "foo.dat", ios::in|ios::out|ios::trunc ); + f.write( buf, sizeof buf ); + + f.seekg( 0, ios::beg ); + f.read( buf, sizeof buf ); + +// f.seekp( sizeof buf, ios::beg ); // Present or absent, bug still happens. + f.write( "a", 1 ); + + if ( f.rdbuf()->_IO_write_ptr > f.rdbuf()->_IO_buf_end ) + cerr << "test_read_write_flush: it's broken.\n"; + else + cout << "test_read_write_flush: the problem isn't showing itself.\n"; +} + +int main( ) +{ + test1 (); + test2 (); + test3 (); + getline_test1 (); + getline_test2 (); + getline_test3 (); + flush1_test (); + reread_test (); + test_destroy (); + test_read_write_flush (); + return 0; +} diff --git a/libio/tests/tiomisc.exp b/libio/tests/tiomisc.exp new file mode 100644 index 000000000000..26a3acd33fb1 --- /dev/null +++ b/libio/tests/tiomisc.exp @@ -0,0 +1,11 @@ +Test2: Bla bla bla 55 3.23 +Hello +Line 2 +#include +line: Line one., count: 10 +line: 123456789, count: 10 +line: abcdefghi, count: 9 +line: jkl., count: 5 +reread_test: # # +maybe deleted +test_read_write_flush: the problem isn't showing itself. diff --git a/libio/tests/tstdiomisc.c b/libio/tests/tstdiomisc.c new file mode 100644 index 000000000000..cd8e88fd6cec --- /dev/null +++ b/libio/tests/tstdiomisc.c @@ -0,0 +1,43 @@ +#ifndef STDIO_H +#define STDIO_H +#endif +#include STDIO_H + +void +t1 () +{ + int n = -1; + sscanf ("abc ", "abc %n", &n); + printf ("t1: count=%d\n", n); +} + +void +t2 () +{ + int n; + long N; + int retval; +#define SCAN(INPUT, FORMAT, VAR) \ + VAR = -1; \ + retval = sscanf (INPUT, FORMAT, &VAR); \ + printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \ + INPUT, FORMAT, retval, (long)VAR); + + SCAN ("12345", "%ld", N); + SCAN ("12345", "%llllld", N); + SCAN ("12345", "%LLLLLd", N); + SCAN ("test ", "%*s%n", n); + SCAN ("test ", "%2*s%n", n); + SCAN ("12 ", "%l2d", n); + SCAN ("12 ", "%2ld", N); +} + +int +main () +{ + t1 (); + t2 (); + + fflush (stdout); + return 0; +} diff --git a/libio/tests/tstdiomisc.exp b/libio/tests/tstdiomisc.exp new file mode 100644 index 000000000000..b8ee02dcd6a3 --- /dev/null +++ b/libio/tests/tstdiomisc.exp @@ -0,0 +1,8 @@ +t1: count=5 +sscanf ("12345", "%ld", &x) => 1, x = 12345 +sscanf ("12345", "%llllld", &x) => 0, x = -1 +sscanf ("12345", "%LLLLLd", &x) => 0, x = -1 +sscanf ("test ", "%*s%n", &x) => 0, x = 4 +sscanf ("test ", "%2*s%n", &x) => 0, x = -1 +sscanf ("12 ", "%l2d", &x) => 0, x = -1 +sscanf ("12 ", "%2ld", &x) => 1, x = 12 diff --git a/libio/testsuite/ChangeLog b/libio/testsuite/ChangeLog new file mode 100644 index 000000000000..351cbb93dac0 --- /dev/null +++ b/libio/testsuite/ChangeLog @@ -0,0 +1,49 @@ +Fri Jun 27 18:19:21 1997 Bob Manson + + * lib/libio.exp(libio_init): New procedure. + (test_libio): Link with a status wrapper if necessary. Strip + leading newlines before comparing output. Look for a multilib + libiberty directory. + +Tue Jun 3 15:17:31 1997 Bob Manson + + * lib/libio.exp: Don't use global exec_output variable; the output + is returned from remote_load instead. + +Tue May 20 17:59:31 1997 Jeffrey A Law (law@cygnus.com) + + * lib/libio.exp: If "slow_simulator" is set, then add + -DSLOW_SIMULATOR to the compiler's arguments. + +Fri May 16 19:33:39 1997 Bob Manson + + * lib/libio.exp: Name the executables after the testcases. + + * libio.tests/tiomisc.exp: Turn off warnings when conpiling. + +Thu May 1 17:01:47 1997 Bob Manson + + * lib/libio.exp: Link in libiberty.a. + +Tue Apr 29 16:34:37 1997 Mike Stump + + * testsuite/lib/libio.exp: Fixup so that we always have the same + number of testcases, and so that we have meaningful testcase + names. + +Tue Apr 29 13:08:41 1997 Bob Manson + + * lib/libio.exp: Add support for --tool_opts. + +Mon Apr 28 11:26:06 1997 Bob Manson + + * Makefile.in: Removed clean rule, as it is added by configure. + Remove a lot of unused rules. + +Sun Apr 27 15:02:48 1997 Brendan Kehoe + + * Makefile.in (clean): Add empty rule for now. + +Sat Apr 26 13:41:44 1997 Bob Manson + + * New DejaGnu-style testsuite. diff --git a/libio/testsuite/Makefile.in b/libio/testsuite/Makefile.in new file mode 100644 index 000000000000..3b88456da7be --- /dev/null +++ b/libio/testsuite/Makefile.in @@ -0,0 +1,89 @@ +# Copyright (C) 1997 Free Software Foundation +# +# This file is part of the GNU IO 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, 675 Mass Ave, Cambridge, MA 02139, USA. + +srcdir = libio.tests + +CFLAGS = -g +C_FLAGS = $(CFLAGS) -I. -I.. -I$(srcdir) -I$(srcdir)/.. +CXXFLAGS = -g +CC = gcc +CXX = gcc + +EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \ + echo $${rootme}/../../expect/expect ; \ + else echo expect ; fi` + +RUNTEST = $(RUNTEST_FOR_TARGET) + +RUNTESTFLAGS = + +RUNTEST_FOR_TARGET = `\ + if [ -f $${srcdir}/../../dejagnu/runtest ]; then \ + echo $${srcdir}/../../dejagnu/runtest; \ + else \ + if [ "$(host_canonical)" = "$(target_canonical)" ]; then \ + echo runtest; \ + else \ + t='$(program_transform_name)'; echo runtest | sed -e '' $$t; \ + fi; \ + fi` + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +# See ${MOSTLYCLEAN} in configure.in +JUNK_TO_CLEAN = tFile tiomisc hounddog putbackdog tiomanip \ + t?format *.out streamfile ftmp* tstdiomisc foo.dat + +.PHONY: info +info: +.PHONY: clean-info +clean-info: +.PHONY: install-info +install-info: + +check: site.exp all just-check + +site.exp: ./config.status Makefile + @echo "Making a new config file..." + -@rm -f ./tmp? + @touch site.exp + -@mv site.exp site.bak + @echo "## these variables are automatically generated by make ##" > ./tmp0 + @echo "# Do not edit here. If you wish to override these values" >> ./tmp0 + @echo "# add them to the last section" >> ./tmp0 + @echo "set host_alias $(host_alias)" >> ./tmp0 + @echo "set host_triplet ${host_canonical}" >> ./tmp0 + @echo "set target_alias $(target_alias)" >> ./tmp0 + @echo "set target_triplet ${target_canonical}" >> ./tmp0 + @echo "set build_triplet ${build_canonical}" >> ./tmp0 + @echo "set srcdir ${srcdir}" >> ./tmp0 + @echo "set tool libio" >> ./tmp0 + @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0 + @cat ./tmp0 > site.exp + @cat site.bak | sed \ + -e '1,/^## All variables above are.*##/ d' >> site.exp + -@rm -f ./tmp? + +just-check: + rootme=`pwd`; export rootme; \ + srcdir=${srcdir} ; export srcdir ; \ + EXPECT=${EXPECT} ; export EXPECT ; \ + if [ -f $${rootme}/../../expect/expect ] ; then \ + TCL_LIBRARY=$${srcdir}/../../tcl/library ; \ + export TCL_LIBRARY ; fi ; \ + $(RUNTEST) $(RUNTESTFLAGS) diff --git a/libio/testsuite/config/default.exp b/libio/testsuite/config/default.exp new file mode 100644 index 000000000000..90967cccc18a --- /dev/null +++ b/libio/testsuite/config/default.exp @@ -0,0 +1 @@ +load_lib "standard.exp" diff --git a/libio/testsuite/configure.in b/libio/testsuite/configure.in new file mode 100644 index 000000000000..f1bea6a866bf --- /dev/null +++ b/libio/testsuite/configure.in @@ -0,0 +1,21 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../../configure. + +configdirs= +srctrigger=libio.tests/hounddog.exp +srcname="test C++ input/output library, dejagnu style" +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +TO_TOPDIR=../../ +ALL=' ' +XCINCLUDES='-I. -I.. -I$(srcdir) -I$(srcdir)/..' +XCXXINCLUDES='-I. -I.. -I$(srcdir) -I$(srcdir)/..' +MOSTLYCLEAN='*.o core $(JUNK_TO_CLEAN)' +(. ${srcdir}/../config.shared) >${package_makefile_frag} + +# post-target: diff --git a/libio/testsuite/lib/libio.exp b/libio/testsuite/lib/libio.exp new file mode 100644 index 000000000000..22bd3b9c8ffa --- /dev/null +++ b/libio/testsuite/lib/libio.exp @@ -0,0 +1,164 @@ +# Copyright (C) 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 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. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-lib-g++@prep.ai.mit.edu + +# This file was written by Bob Manson. (manson@cygnus.com) + +load_lib "libgloss.exp" + +global base_dir + +proc libio_init { args } { + global wrapper_file; + global wrap_compile_flags; + set wrapper_file ""; + set wrap_compile_flags ""; + if [target_info exists needs_status_wrapper] { + set result [build_wrapper "testglue.o"]; + if { $result != "" } { + set wrapper_file [lindex $result 0]; + set wrap_compile_flags [lindex $result 1]; + } else { + warning "Status wrapper failed to build." + } + } +} +# +# Run the test specified by srcfile and resultfile. compile_args and +# exec_args are additional arguments to be passed in when compiling and +# running the testcase, respectively. +# + +proc test_libio { srcfile compile_args inpfile resultfile exec_args } { + global LIBIO + global srcdir subdir objdir + global TOOL_OPTIONS + global wrapper_file wrap_compile_flags; + + if { $inpfile != "" } { + set inpfile "$srcdir/../tests/$inpfile" + } + + set args "" + lappend args "additional_flags=-O3"; + lappend args "additional_flags=-I.. -I$srcdir/.." + lappend args "additional_flags=$wrap_compile_flags"; + lappend args "libs=$wrapper_file"; + if { $compile_args != "" } { + lappend args "additional_flags=$compile_args" + } + + if [regexp "\.cc$" $srcfile] { + lappend args "additional_flags=-nostdinc++" + lappend args "additional_flags=[g++_include_flags]"; + lappend args "additional_flags=[g++_link_flags]"; + lappend args "libs=-lstdc++" + } else { + if [info exists LIBIO] { + lappend args "libdir=$LIBIO" + } else { + lappend args "additional_flags=[libio_link_flags]"; + } + lappend args "libs=-lio" + } + + if [target_info exists slow_simulator] then { + lappend args "additional_flags=-DSLOW_SIMULATOR" + } + + if [info exists TOOL_OPTIONS] { + lappend args "additional_options=$TOOL_OPTIONS" + } + + set gp [get_multilibs]; + if { $gp != "" } { + if [file exists $gp/libiberty/libiberty.a] { + lappend args "libdir=$gp/libiberty"; + set found_libiberty 1; + } + } + if ![info exists found_libiberty] { + set lib [lookfor_file "$objdir" "libiberty/libiberty.a"]; + if { $lib != "" } { + lappend args "libdir=[file dirname $lib]"; + } + } + lappend args "libs=-liberty" + lappend args "debug"; + + set errname "$srcfile" + set srcfile "$srcdir/../tests/$srcfile" + regsub "\\..*$" "[file tail $srcfile]" "" executable + set executable "$objdir/$executable" + + if { [target_compile $srcfile $executable executable $args] != "" } { + fail "$errname compilation $exec_args"; + setup_xfail "*-*-*" + fail "$errname execution $exec_args" + if { $resultfile != "" } { + setup_xfail "*-*-*" + fail "$errname output $exec_args" + } + return; + } + pass "$errname compilation $exec_args" + + set result [libio_load $executable $exec_args $inpfile]; + set status [lindex $result 0]; + set output [lindex $result 1]; + if { $status == "unsupported" } { + unsupported "target does not support loading $srcfile" + return; + } + if { $status != "pass" } { + $status "$errname execution $exec_args" + setup_xfail "*-*-*" + fail "$errname output $exec_args" + return; + } + pass "$errname execution $exec_args" + + if { $resultfile != "" } { + set id [open $srcdir/../tests/$resultfile r]; + set expected "" + append expected [read $id]; + verbose "expected is $expected" + verbose "actual is $output" + regsub -all "\r" $output "" output + regsub "\n+$" $expected "" expected + regsub "\n+$" $output "" output + regsub "^\n+" $expected "" expected + regsub "^\n+" $output "" output + if { $expected == $output } { + pass "$errname output $exec_args" + } else { + fail "$errname output $exec_args" + } + close $id; + } +} + +# +# libio_version -- extract and print the version number of libio +# +proc default_libio_version {} { + global LIBIO +} + +proc default_libio_start { } { +} diff --git a/libio/testsuite/libio.tests/hounddog.exp b/libio/testsuite/libio.tests/hounddog.exp new file mode 100644 index 000000000000..b51f9f0a4d39 --- /dev/null +++ b/libio/testsuite/libio.tests/hounddog.exp @@ -0,0 +1,3 @@ +test_libio hounddog.cc "" hounddog.inp hounddog.exp "" +test_libio hounddog.cc "" hounddog.inp hounddog.exp "-b0" +test_libio hounddog.cc "" hounddog.inp hounddog.exp "-b2" diff --git a/libio/testsuite/libio.tests/putbackdog.exp b/libio/testsuite/libio.tests/putbackdog.exp new file mode 100644 index 000000000000..30d91a8a5b8d --- /dev/null +++ b/libio/testsuite/libio.tests/putbackdog.exp @@ -0,0 +1,3 @@ +test_libio putbackdog.cc "" hounddog.inp hounddog.exp "" +test_libio putbackdog.cc "" hounddog.inp hounddog.exp "-b0" +test_libio putbackdog.cc "" hounddog.inp hounddog.exp "-b2" diff --git a/libio/testsuite/libio.tests/tFile.exp b/libio/testsuite/libio.tests/tFile.exp new file mode 100644 index 000000000000..f190916d8636 --- /dev/null +++ b/libio/testsuite/libio.tests/tFile.exp @@ -0,0 +1,3 @@ +test_libio tFile.cc "" tFile.inp tFile.exp "" +test_libio tFile.cc "" tFile.inp tFile.exp "-b0" +test_libio tFile.cc "" tFile.inp tFile.exp "-b3" diff --git a/libio/testsuite/libio.tests/tfformat.exp b/libio/testsuite/libio.tests/tfformat.exp new file mode 100644 index 000000000000..f0f7113c3199 --- /dev/null +++ b/libio/testsuite/libio.tests/tfformat.exp @@ -0,0 +1 @@ +test_libio tfformat.c "-DTEST_LIBIO -DTEST_EXACTNESS" "" "" "" diff --git a/libio/testsuite/libio.tests/tiformat.exp b/libio/testsuite/libio.tests/tiformat.exp new file mode 100644 index 000000000000..f2d14db5236e --- /dev/null +++ b/libio/testsuite/libio.tests/tiformat.exp @@ -0,0 +1 @@ +test_libio tiformat.c "-DTEST_LIBIO" "" "" "" diff --git a/libio/testsuite/libio.tests/tiomanip.exp b/libio/testsuite/libio.tests/tiomanip.exp new file mode 100644 index 000000000000..856cefc3cd05 --- /dev/null +++ b/libio/testsuite/libio.tests/tiomanip.exp @@ -0,0 +1 @@ +test_libio tiomanip.cc "" "" tiomanip.exp "" diff --git a/libio/testsuite/libio.tests/tiomisc.exp b/libio/testsuite/libio.tests/tiomisc.exp new file mode 100644 index 000000000000..71309951bb07 --- /dev/null +++ b/libio/testsuite/libio.tests/tiomisc.exp @@ -0,0 +1 @@ +test_libio tiomisc.cc "-w" "" tiomisc.exp "" diff --git a/libio/testsuite/libio.tests/tstdiomisc.exp b/libio/testsuite/libio.tests/tstdiomisc.exp new file mode 100644 index 000000000000..01dae9ffe1a6 --- /dev/null +++ b/libio/testsuite/libio.tests/tstdiomisc.exp @@ -0,0 +1 @@ +test_libio tstdiomisc.c "" "" tstdiomisc.exp "" diff --git a/libstdc++/ChangeLog b/libstdc++/ChangeLog new file mode 100644 index 000000000000..48eb5543a189 --- /dev/null +++ b/libstdc++/ChangeLog @@ -0,0 +1,823 @@ +Wed Jul 30 10:59:00 1997 Benjamin Kosnik + + * stlinst.cc: Add instantiation file for + __default_alloc_template and + __malloc_alloc_template<0> + +Sun Jun 1 17:03:40 1997 Jason Merrill + + * std/bastring.cc (find_last_of): Correct handling of POS. + (find_last_not_of): Likewise. + +Thu May 1 17:37:10 1997 Jason Merrill + + * Makefile.in ($(SHLIB)): Add $(LIBCXXFLAGS). + +Wed Apr 30 12:06:23 1997 Jason Merrill + + * Makefile.in (IO_DIR): Remove $(MULTIBUILDTOP). + (LIBIBERTY_DIR): Likewise. + * configure.in: Don't turn on multilib here. + +Fri Apr 25 16:09:15 1997 Bob Manson + + * testsuite/libstdc++.tests/test.exp, testsuite/lib/libstdc++.exp, + testsuite/configure.in, testsuite/Makefile.in, + testsuite/config/default.exp, testsuite/ChangeLog: New files. + + * configure.in: Add new testsuite directory to be configured. + +Tue Apr 22 19:03:39 1997 Alexandre Oliva + + * Makefile.in (install): Fix handling of mshlink. + +Fri Apr 4 03:25:13 1997 Ulrich Drepper + + * Makefile.in (IO_DIR): Prepend $(MULTIBUILDTOP) to + support multilib build. + (LIBIBERTY_DIR): Likewise. + + * configure.in: Enable multilibing by default. + Update multilib template to read config-ml.in. + +Wed Mar 12 16:09:34 1997 Jason Merrill + + * configure.in (XCXXINCLUDES): Add the STL directory. + +Thu Jan 23 08:08:43 1997 Brendan Kehoe + + * stdexcept: Delete dtors for all of the error classes, to match + their removal in the Apr 1995 WP. + (class overflow_error): Define missing class, added in May 1996 WP. + +Mon Nov 18 16:57:25 1996 Jason Merrill + + * Makefile.in (stuff[12]): More rules for my own evil purposes. + (CXXFLAGS, CFLAGS): Use -O instead of -O3 so debugging works. + +Wed Oct 16 13:47:45 1996 Jason Merrill + + * config/irix5.ml: Do link against the math library. + * configure.in: Support shared libs on Irix 6. + +Fri Oct 11 18:06:09 1996 Jason Merrill + + * config/linux.ml: Lose version overrides. + + * Makefile.in (MSHLINK): Defaults to .so.2.x + (mshlink): Indirect rule for making it. + +Tue Sep 24 17:58:31 1996 Jason Merrill + + * Remove new, typeinfo, exception, stddef*. + * Move public headers from std/*.h to *. + +Sun Sep 22 05:35:55 1996 Jason Merrill + + * Makefile.in: Remove new, exception, typeinfo handling. + * exceptioni.cc, newi.cc, typeinfoi.cc, std/exception.h, std/new.h, + std/typeinfo.h, new.h: Remove. + * typeinfo, new, exception: Refer to the files with .h in gcc. + +Fri Sep 20 14:39:19 1996 Jason Merrill + + * Makefile.in: Remove references to stl.list. + * configure.in (configdirs): Remove stl. + +Sat Sep 14 09:42:08 1996 Jason Merrill + + * Makefile.in (stuff): Convenience for me. + + * std/bastring.h: Remove kludge obsoleted by new overloading code. + +Fri Sep 6 16:43:21 1996 Jason Merrill + + * typeinfoi.cc (__dynamic_cast): Fix static_cast. + (__rtti_si): Likewise. + (dcast): Likewise. + +Thu Aug 29 17:06:23 1996 Michael Meissner + + * configure.in (i[345]86-*-*): Recognize i686 for pentium pro. + +Tue Jul 23 14:27:44 1996 Mike Stump + + * Makefile.in (exceptioni.o): Use -fexceptions now. + +Mon Jun 17 13:57:24 1996 Per Bothner + + * std/bastring.h (class basic_string::remove): Add casts. + + * configure.in: Use EXTRA_DISTCLEAN rather than DISTCLEAN. + +Fri Jun 7 14:09:20 1996 Jason Merrill + + * typeinfoi.cc (BUILTIN): Align typeinfo object like a pointer. + +Wed May 29 16:48:35 1996 Mike Stump + + * exceptioni.cc (__throw_bad_exception): Add. + * std/exception.h (bad_exception): Add. + * std/typeinfo.h: Remove leftovers of bad_cast_object. + +Mon May 6 14:04:42 1996 Jason Merrill + + * std/complext.h: s/FLOAT/_FLT/g. + +Thu May 2 17:26:24 1996 Mike Stump + + * exceptioni.cc (uncaught_exception): New routine. + * std/exception.h: Declare it. + +Thu Apr 25 13:20:57 1996 Jason Merrill + + * Makefile.in (typeinfoi.o, stdexcepti.o): Use default rule. + +Wed Apr 24 18:38:24 1996 Mike Stump + + * exceptioni.cc: Add #pragma implementation. + * std/exception.h: Add #pragma interface. Moved exception from + stdexcept. + * std/stdexcept.h: Moved exception to exception. Fix all constructor + arguments to take strings to match ANSI. Moved bad_cast and bad_typeid + to typeinfo. + * std/typeinfo.h: Moved bad_cast and bad_typeid from stdexcept. + +Wed Apr 24 10:43:07 1996 Doug Evans + + * Makefile.in (newi.o,cstringi.o,stddefi.o,cstdlibi.o,cmathi.o): Add + rules for SunOS VPATH. + +Fri Apr 19 17:24:51 1996 Jason Merrill + + * Version 2.8.0b3. + +Wed Apr 10 14:38:05 1996 Jason Merrill + + * typeinfoi.cc (base_info): Pack the latter three fields into 32 bits. + +Tue Apr 9 15:49:38 1996 Jason Merrill + + * typeinfoi.cc: Add 'const'. + (__class_type_info): Now just one pointer to an array of structs, + rather than four pointers to arrays. + + * typeinfoi.cc (__throw_type_match_rtti): Check for conversion to + void* before conversion to base*. + (dcast): Handle downcasting to X* given other X subobjects in + the most derived type. Ack. + +Mon Apr 8 15:20:32 1996 Ian Lance Taylor + + * configure.in: Permit --enable-shared to specify a list of + directories. + +Sun Apr 7 22:50:53 1996 Jason Merrill + + * typeinfoi.cc (__rtti_array): New entry point. + +Sat Apr 6 14:41:18 1996 Jason Merrill + + * exceptioni.cc (__throw_bad_cast): New entry point for compiler. + * typeinfoi.cc: Remove __bad_cast_object. + + * typeinfoi.cc: Add nodes for unsigned builtins. + +Fri Apr 5 18:16:22 1996 Jason Merrill + + * typeinfoi.cc, std/typeinfo.h: Total overhaul. Move most + everything out of the header, move name field into type_info, add + single-inheritance case, rewrite pointer handling, add new + compiler interface. Compare addresses to check for equality. + +Wed Mar 27 11:54:08 1996 Jason Merrill + + * Version 2.8.0b2. + +Fri Mar 8 13:56:18 1996 Jason Merrill + + * std/[cs]inst.h: Remove. + +Thu Mar 7 07:29:00 1996 Lee Iverson + + * Makefile.in (install): Restore deleted chdir to stl subdir. + +Thu Mar 7 15:02:58 1996 Jason Merrill + + * std/complext.h: Fix __attribute__ usage. + +Wed Feb 28 10:00:24 1996 Jason Merrill + + * Version 2.8.0b1. + +Mon Feb 26 17:26:26 1996 Jason Merrill + + * std/cstring.h: New approach to changing signatures of string + manipulation functions. Still disabled. + +Tue Feb 20 18:29:30 1996 Jason Merrill + + * std/complext.h (__doapl, __doami, __doaml, __doadv): Helper + templates to implement +=, -=, *= and /=, respectively, since + member function templates do not apply to class specializations. + * std/{f,d,ld}complex.h, std/complext.cc, cinst.cc: Adjust. + + * std/bastring.h: The representation class is now a nested class. + * std/bastring.cc: Add templates for static data members. + * sinst.cc: Don't provide specializations for static data members. + * std/string.h: Use default template parameters. + + * Makefile.in (CXXFLAGS): Remove -pedantic -ansi. + (CFLAGS): Ditto. + +Wed Feb 14 14:39:07 1996 Jason Merrill + + * std/bastring.cc (check_realloc): Fix for sizeof (charT) > 1. + From John Hickin . + +Wed Jan 10 11:05:04 1996 Jason Merrill + + * std/bastring.h (insert): Fix iterator handling. + From Joe Buck . + +Mon Jan 8 11:48:03 1996 Jason Merrill + + * std/bastring.h (max_size): Fix for sizeof (charT) > 1. + * std/bastring.cc (replace): Use it. + + * std/bastring.cc (rfind): Fix for n > length (). + +Tue Dec 19 15:13:08 1995 Jason Merrill + + * config/aix.ml (SHFLAGS): Add -Wl,-unix. + +Mon Dec 18 12:48:25 1995 Mike Stump + + * Makefile.in (exceptioni.o): Compile with -fhandle-exceptions, so + we can unwind through unexpected on machines that don't have a + working __unwind_function. + +Sun Dec 17 00:28:31 1995 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (install): Make sure shared libraries + are installed with mode 555. + +Mon Nov 27 15:01:56 1995 Jason Merrill + + * Makefile.in (install): Make shared library links relative. + (install): Break up -sf into -s -f. + ({M,}SHLINK): Ditto. + +Sun Nov 26 22:48:06 1995 Jason Merrill + + * queue: Include instead of . + +Sat Nov 25 11:33:13 1995 Doug Evans + + * Makefile.in (install): Fix setting of rootme. + +Tue Nov 21 14:20:34 1995 Ian Lance Taylor + + * configure.in: Check ${with_cross_host} rather than comparing + ${host} and ${target}. + +Tue Nov 14 01:50:52 1995 Doug Evans + + * Makefile.in (IO_DIR): Delete MULTITOP, MULTISUBDIR. + (LIBIBERTY_DIR): Likewise. + (INSTALLDIR): Delete MULTISUBDIR. + * configure.in: Delete call to cfg-ml-com.in. Call config-ml.in + instead of cfg-ml-pos.in. + (XCXXINCLUDES): Delete MULTITOP. + * stl/configure.in (XCXXINCLUDES): Delete MULTITOP. + (config-ml.in): Call instead of cfg-ml-pos.in. + +Sun Nov 12 16:44:25 1995 Per Bothner + + * Makefile.in (VERSION): Set to 2.7.1. + +Thu Nov 9 17:39:28 1995 Jason Merrill + + * config/{aix,dec-osf,irix5,linux,sol2shm}.ml: Remove LDLIBS defn; + no longer needed now that make check sets LD_LIBRARY_PATH. + +Wed Nov 8 19:46:35 1995 Brendan Kehoe + + * std/bastring.h: Wrap with #ifndef/#define/#endif. + * std/cassert.h: Likewise. + * std/cinst.h: Likewise. + * std/complext.h: Likewise. + * std/dcomplex.h: Likewise. + * std/fcomplex.h: Likewise. + * std/ldcomplex.h: Likewise. + * std/sinst.h: Likewise. + +Wed Nov 8 16:15:48 1995 Jason Merrill + + * std/bastring.cc (getline): Update to September 95 WP. Now we + don't set failbit when reading an empty line. + +Tue Nov 7 16:09:04 1995 Jason Merrill + + * std/bastring.cc (new): Fix for sizeof (charT) != 1. + +Sat Nov 4 17:37:16 1995 Jason Merrill + + * std/complext.cc (operator / (FLOAT, const complex&)): + Reimplement along the lines of the other operator / templates. + From John Eaton . + +Sat Nov 4 13:33:50 1995 Per Bothner + + * configure.in (DISTCLEAN): New, to add target-mkfrag. + +Tue Oct 31 13:59:32 1995 Jason Merrill + + * std/bastring.h: Use size_t for the reference count. + * std/bastring.cc (create): Set selfish. + From Joe Buck (jbuck@synopsys.com). + +Mon Oct 30 23:09:48 1995 Per Bothner + + * configure.in: Don't bother changing LIBIBERTY for cross, + now that we are using target-libiberty instead. + * Makefile.in (LIBIBERTY_DIR): Simplify. + (LIBIBERTY): Remove. + +Wed Oct 11 14:56:49 1995 Brendan Kehoe + + * config/sol2shm.ml: New files with -rpath. + * configure (*-*-solaris*): Use sol2shm.ml. + +Thu Sep 28 09:26:52 1995 Jason Merrill + + * std/straits.h (compare, copy, move, set): Fix for non-char charT's. + * std/bastring.h (basic_string::remove): Fix for non-char charT's. + +Tue Sep 26 15:22:56 1995 Jason Merrill + + * config/irix5.ml: Pass -rpath to links. + +Fri Sep 15 00:17:47 1995 Jason Merrill + + * config/linux.ml: Conform to Linux shared library numbering + scheme. + * Makefile.in: Ditto. + +Tue Sep 12 00:28:56 1995 Mike Stump + + * typeinfoi.cc: (__pointer_type_info::__rtti_match): Moved from + the headerfile, include all sorts of pointer conversions from 15.3 + para 2. + * std/typeinfo.h (__pointer_type_info::__rtti_match): Moved from here. + +Mon Sep 11 23:27:59 1995 Mike Stump + + * std/typeinfo.h (__pointer_type_info::__rtti_match): We no longer + have to dereference the object pointer, as the pointer is always + passed directly. + +Mon Sep 11 19:29:51 1995 Mike Stump + + * std/typeinfo.h (__pointer_type_info::__rtti_match): Define so + that pointer conversions can happen on catch type matching. + * typeinfoi.cc (__throw_type_match_rtti): Arrange for __rtti_match + to be used on pointers. + +Tue Sep 5 14:49:19 1995 Jason Merrill + + * string.h: Remove for now. + +Thu Aug 31 14:14:01 1995 Jason Merrill + + * std/bastring.cc (operator>>): Simplify and fix. + (resize): Fix order of arguments to append. + (getline): Simplify and fix. + +Thu Aug 24 17:44:09 1995 Jason Merrill + + * std/cstdlib.h (abs): Provide default implementation for peons + without labs. + +Tue Aug 22 08:43:07 1995 Jason Merrill + + * std/cstdlib.h: Comment out definition of div(long,long) for now, + since not all targets have ldiv. + +Mon Aug 21 11:46:03 1995 Jason Merrill + + * std/cmath.h: Wrap abs(double) with #if ! _G_MATH_H_INLINES. + + * stl.h: Add, for compatibility with ObjectSpace STL. + + * std/complext.cc (operator /): Use abs instead of fabs. + + * std/bastring.h (replace): Update single-character replace method + as per my proposal. + + * std/cmath.h: Add abs(float), abs(double) and abs(long double). + Add commented-out declarations for other float and long double + math functions. + + * std/cstdlib.h: Add abs(long) and div(long,long). + + * Makefile.in (install): Make shared library executable and + non-writable. Tidy. + (OBJS): Add cstdlibi.o and cmathi.o. + + * Rename implementation files to have different basenames. + +Mon Aug 21 00:57:03 1995 Jeffrey A. Law + + * Makefile.in (install): Use "cd stl"; no need for $(srcdir) + prefix because we're already in $(srcdir). + +Tue Jul 25 18:41:29 1995 Per Bothner + + * std/stddef.h: Remove obsolete definition of enum capacity. + +Sat Jul 22 13:37:01 1995 Doug Evans + + * Makefile.in (IO_DIR): Add multilib support. + (LIBIBERTY, LIBIBERTY_OBJS, INSTALLDIR, stdlist): Likewise. + (libiberty.a, install): Likewise. + * configure.in: Likewise. + (XCXXINCLUDES): Likewise. + * stl/configure.in: Likewise. + (XCXXINCLUDES): Likewise. + +Mon Jul 17 09:29:31 1995 Brendan Kehoe + + * Makefile.in (typeinfo.o, stdexcept.o): Put an else for the if + stmt checking PICFLAG. + (stmp-string, bigstmp-string, stmp-complex, bigstmp-complex): Likewise. + +Wed Jun 28 17:05:29 1995 Jason Merrill + + * std/*.h: Wrap with extern "C++". + + * std/ciso646.h: Don't worry about #undefing the keywords. + +Mon Jun 26 19:05:38 1995 Jason Merrill + + * std/bastring.h (operator!=): If they've included the STL + function.h, don't overload the operator templates that it defines. + +Fri Jun 23 16:54:17 1995 Jason Merrill + + * Makefile.in (SHLINK): Force link. + (install): Ditto. + + * std/bastring.h (terminate): Never reallocate. + (alloc): No longer const. + + * std/bastring.cc (create): Always allocate an extra byte. + (check_realloc): Always leave room for an extra byte. + (*find*): Add missing 'const'. + + * Makefile.in (SHARLIB): Provide a default value. + +Tue Jun 20 16:29:52 1995 Jason Merrill + + * std/cstring.h: Don't bother tweaking prototypes for now. When + we do, we will use new-style casts. + +Fri Jun 16 13:57:53 1995 Jason Merrill + + * Makefile.in (VERSION): Update to 2.7.0. + + * config/aix.ml: Build both shared and archive libraries. + +Wed Jun 14 21:44:21 1995 Jason Merrill + + * configure.in (frags): Use linux.ml for Linux/ELF. + * config/linux.ml: New file. + +Wed Jun 14 17:56:23 1995 Niclas Andersson + + * configure.in: Use xiberty when building cross-compiler. + +Wed Jun 14 12:57:47 1995 Jason Merrill + + * std/*complex*, std/cinst.h, cinst.cc: Pass by reference to const + rather than by value. + * std/*complex*: Add member functions real() and imag(). + +Sat Jun 10 12:14:38 1995 Jason Merrill + + * Makefile.in (bigstmp-string): Call main string object cstrmain.o + instead of cstring.o. + +Wed Jun 7 11:15:15 1995 Jason Merrill + + * std/cstring.h: Use #include_next to pick up . + + * string.h: New file. + + * Makefile.in (MOSTLYCLEAN_JUNK): Remove piclist. + + * configure.in (MOSTLYCLEAN): Remove stamp-picdir. + +Mon Jun 5 18:36:39 1995 Jason Merrill + + * config/*.ml: Build both shared and archive libraries. + + * configure.in (MOSTLYCLEAN): Remove pic. + (frags): Use toplevel pic frags. + + * Makefile.in (piclist): New rule. + (SHLIB): Use it. + (stl.list): Removed. + (typeinfo.o): Also build pic version. + (stdexcept.o): Ditto. + (*stmp-*): Ditto. + +Tue May 30 12:01:14 1995 Jason Merrill + + * std/{complext,{f,d,ld}complex}.h: To declare specializations, + use friend declarations in the class body... + * std/cinst.h: ...rather than macro hackery. + + * Makefile.in (stdlist): Renamed from list. + + * cstdarg: Don't define __CSTDARG__. + * complex.h: Similarly. + +Tue May 9 19:31:20 1995 Jason Merrill + + * std/bastring.cc (operator>>): Use an int to store the return value + of streambuf::sbumpc. + (getline): Ditto. + * std/bastring.* (replace): Reverse size_t and charT arguments. + + * configure.in (enable_shared): Support enable_shared under AIX. + + * Makefile.in (SHARLIB): New variable and rule for building an + archive library containing a single shared object (for AIX). + +Mon May 8 01:43:19 1995 Jason Merrill + + * std/bastring.h (remove): Forgot one. + (empty): And this. + Disable copy-on-write if someone takes an iterator. + + * std/bastring.cc (getline): Avoid resizing down if unnecessary. + (operator>>): Don't use private methods. + +Sun May 7 02:39:56 1995 Jason Merrill + + * std/bastring.h (insert, replace): Fix. + * std/bastring.cc (find_*_of): Fix. + +Fri May 5 01:45:10 1995 Jason Merrill + + * std/bastring.h: Add iterator remove fn. Remove evil default + arguments. + + * std/*complex*, std/cinst.h, cinst.cc: s/__complex/complex/g. + complex is now specialized. Lose _*_complex in favor of + 'explicit' constructors. + * std/complex.h: Lose typedef of complex. + * std/fcomplex.h: New file. + * std/complext.cc (operator<<): Accept more input forms. + + * std/bastring.h: Add iterator insert fns. + +Thu May 4 02:30:04 1995 Jason Merrill + + * std/bastring.*: Update to current draft. + + * std/bastring.*: Reorganize so that the pointer in a string + object points to the data rather than the bsrep object, for + debugging. + +Tue Apr 25 17:15:09 1995 Jason Merrill + + * configure.in: Update to stay in sync with config.shared. + +Mon Apr 24 13:08:46 1995 Jason Merrill + + * std/complext.h: Declare hypot. Declare appropriate functions const. + +Wed Apr 12 15:26:25 1995 Jason Merrill + + * Makefile.in (typeinfo.o): Don't use $<. + (stdexcept.o): Ditto. + +Sat Apr 8 15:35:00 1995 Mike Stump + + * std/typeinfo.h: Move bad_cast, bad_typeid and __bad_cast_object + from here to stdexcept. + * std/stdexcept.h: Ditto. + * Makefile.in (stdexcept.o): Added rule to build typeinfo.o with + -frtti to support matching of thrown objects with rtti info for + bad_cast. + +Mon Apr 3 18:13:14 1995 Jason Merrill + + * typeinfo: New file. + + * Makefile.in (HEADERS): Add typeinfo. + +Mon Apr 3 15:06:58 1995 Mike Stump + + * Makefile.in (typeinfo.o): Added rule to build typeinfo.o with + -frtti to support matching of thrown objects with rtti info for + bad_cast. + +Wed Mar 29 15:56:06 1995 Mike Stump + + * typeinfo.cc: (__throw_type_match_rtti): Added to support + matching of thrown objects with rtti info. + +Thu Mar 23 18:42:30 1995 Jason Merrill + + * Makefile.in (HEADERS): Add stdexcept. + +Sun Mar 12 01:25:27 1995 Jason Merrill + + * std/typeinfo.h: Add return statements to dummy methods. + +Wed Mar 8 16:09:50 1995 Jason Merrill + + * config/dec-osf.ml: Use -rpath flag. + +Fri Feb 17 18:16:46 1995 Jason Merrill + + * std/typeinfo.h: Add copyright header. + + * Makefile.in (CXXFLAGS): Add a bunch of warning options to keep + me honest. + +Thu Feb 16 00:04:49 1995 Jason Merrill + + * Makefile.in, config/*.ml: Generate shared library on most hosts + as libstdc++.so.$(VERSION), with a symlink to libstdc++.so, so that + multiple versions can coexist. + +Fri Feb 10 02:59:39 1995 Jason Merrill + + * std/exception.h: {set_,}{terminate,unexpected} have C++ linkage. + + * Makefile.in: Allow string and complex to be split up either by + individual function or into I/O and non-I/O. Default to the + latter. + +Wed Feb 8 02:39:47 1995 Jason Merrill + + * std/bastring.h: Start thinking about throwing exceptions. + + * typeinfo.cc: Remove private functions; defining them to call + abort () just delays errors until runtime. Define + __bad_cast_object. + + * std/exception.h: Standard exceptions are now defined in + stdexcept.h. This header now contains declarations of terminate() + et al. + * exception.cc: Move code from libg++/src/except.c here. + * std/typeinfo.h: Define RTTI-related exceptions here. + * stdexcept{,.cc},std/stdexcept.h: New files. + +Mon Feb 6 18:51:31 1995 Jason Merrill + + * Makefile.in (HEADERS): Resurrect, add new STL header names. + (install): Install extensionless headers again. + * extensionless headers: Resurrect, add new STL headers. + Currently only forward to std/whatever or stl/whatever. + +Mon Jan 30 13:53:22 1995 Jason Merrill + + * std/bastring.h (basic_string (charT, size_t)): Mark explicit. + + * Makefile.in (install): Set rootme when installing stl headers. + Only install *.* from std. + +Wed Jan 25 02:29:30 1995 Jason Merrill + + * std/bastring.h (operator=): grab before releasing. + +Mon Jan 23 19:54:02 1995 Ronald F. Guilmette + + * Makefile.in (install): Also install STL headers. + +Mon Jan 23 04:09:35 1995 Jason Merrill + + * Makefile.in (list): Set $rootme before calling make. + +Wed Jan 11 19:24:47 1995 Jason Merrill + + * typeinfo.cc (__rtti_match): Don't try to do pointer arithmetic + with a void *. + + * move all headers into std subdirectory and update files accordingly. + +Thu Jan 5 01:51:49 1995 Jason Merrill + + * bastring.ccI (basic_string (size_t, capacity)): s/reserve/::reserve/. + +Wed Jan 4 17:27:32 1995 Jason Merrill + + * exception: s/string/__string/g. + + * configure.in (MOSTLYCLEAN): Add so_locations. + + * bastring.ccI (basic_string (size_t, capacity)): Fix thinko. + (various find functions): Ditto. + +Fri Dec 30 18:04:00 1994 Mike Stump + + * typeinfo.h: Add support for the built-in type bool. + +Fri Dec 30 14:57:02 1994 Mike Stump + + * typeinfo.{cc, h}: Guard against multiple inclusions, and add #p i/i. + +Fri Dec 2 17:56:05 1994 Mike Stump + + * libg++ 2.6.2 released. + + * typeinfo.{cc, h} (__rtti_match): Change interface to compiler + for dynamic_casting to gear up for exception handling's use of + rtti for argument matching. + +Tue Nov 29 16:49:32 1994 Per Bothner + + * configure.in (configdirs): Add stl. + * Makefile.in: Build stl, and merge .o files from it. + +Thu Nov 17 15:30:57 1994 Jason Merrill + + * bastring.hI: Add iterator, const_iterator, begin() and end() to + basic_string. + +Mon Nov 7 16:50:33 1994 Jason Merrill + + * Makefile.in, configure.in, config/*.ml, tests/Makefile.in, + tests/configure.in: Various changes to handle --enable-shared. + +Fri Nov 4 19:13:33 1994 Mike Stump + + * exception{,.cc}: Added to support catching bad_cast's. + +Thu Nov 3 17:42:13 1994 Mike Stump + + * typeinfo.h (type_info::{name, before}): Add to match draft. + +Thu Nov 3 00:56:34 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * Makefile.in (LIBIBERTY_OBJS): Add strerror.o. + +Mon Oct 31 15:33:06 1994 Kung Hsu (kung@mexican.cygnus.com) + + * typeinfo.cc: Fix a bug in the final return. + * typeinfo.cc: Fix the ANSI header version number. + * typeinfo.h: ditto. + +Fri Oct 28 14:23:12 1994 Mike Stump + + * type_info.{cc,h}: Rename to typeinfo to better match current draft. + +Wed Oct 26 11:13:53 1994 Kung Hsu (kung@mexican.cygnus.com) + + * type_info.h: new header file for rtti. + * type_info.cc: new code file for rtti. + * Makefile.in: change to include type_info.o in libstdc++ for rtti. + +Sat Oct 15 16:09:51 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * libg++ 2.6.1 released. + + * cinst.hI: Also declare instantiations of out-of-line functions. + +Fri Oct 14 15:00:09 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * configure.in (CXXINCLUDES): Use {} to wrap variable name. + * tests/configure.in (CXXINCLUDES): Ditto. + + * cinst.hI: Declare instantiations of two-argument functions so + overload resolution will work. + * complext.hI: Always include cinst.hI. + + * bastring.ccI (operator>>): Tweak. + +Tue Oct 11 17:07:49 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * stddef*: Do the #pragma i/i thang. + + * bastring.hI (basic_string::put_at): Use operator[]. + (basic_string::terminate): Don't necessarily copy the rep. + + * bastring.ccI (operator>>): Avoid shrinking and then re-expanding + the string. + + * bastring.*I, sinst.cc: Only allow allocation policy control if + _G_ALLOC_CONTROL is defined. + + * Makefile.in (libstdc++.a): Depend on iostream.list and libiberty.a. + (../libio/iostream.list): New rule. + (../libiberty/libiberty.a): New rule. + (OBJS): Add stddef.o. + +Sat Oct 8 23:59:45 1994 Jason Merrill (jason@phydeaux.cygnus.com) + + * *: First checkin. diff --git a/libstdc++/Makefile.in b/libstdc++/Makefile.in new file mode 100644 index 000000000000..0858516fda50 --- /dev/null +++ b/libstdc++/Makefile.in @@ -0,0 +1,307 @@ +# Copyright (C) 1994, 1995 Free Software Foundation + +# This file is part of the GNU ANSI C++ 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 this library; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +VERSION = 2.8.0 + +OBJS = cstringi.o stdexcepti.o cstdlibi.o cmathi.o stlinst.o +SUBLIBS = $(STAMP)-string $(STAMP)-complex + +# C++ headers with no extension +HEADERS= cassert cctype cerrno cfloat ciso646 climits clocale cmath complex \ + csetjmp csignal cstdarg cstddef cstdio cstdlib cstring ctime \ + cwchar cwctype string stdexcept \ + algorithm deque list map queue set stack vector utility functional \ + iterator memory numeric + +ARLIB = libstdc++.a +SHLIB = libstdc++.so.$(VERSION) +SHARLIB = libstdc++-sh.a +SHLINK = libstdc++.so +MSHLINK = libstdc++.so.`echo $(VERSION) | sed 's/\([0-9][.][0-9]\).*/\1/'` +SHFLAGS = +SHDEPS = + +STAMP = bigstmp + +LIBS = $(ARLIB) + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +IO_DIR = ../libio +LIBIBERTY_DIR = ../libiberty + +LIBIBERTY_OBJS = `cat $(LIBIBERTY_DIR)/needed-list` strerror.o + +tooldir = $(exec_prefix)/$(target) +INSTALLDIR = $(libdir) + +MOSTLYCLEAN_JUNK = *stmp-* tlib*.a *.s *.ii stdlist piclist +CLEAN_JUNK = $(LIBS) + +# Remove these for public releases. +CXXFLAGS = -g -O -Wpointer-arith -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -Winline -Wwrite-strings +CFLAGS = -g -O -Wpointer-arith -Wnested-externs + +.PHONY: libs +libs: $(LIBS) + +stdlist: $(IO_DIR)/iostream.list $(OBJS) $(SUBLIBS) $(LIBIBERTY_DIR)/libiberty.a + -rm -f tlist + touch tlist + echo *.o >> tlist + for f in `cat $(IO_DIR)/iostream.list` ; do \ + echo "$(IO_DIR)/$$f" >> tlist ; \ + done + for f in $(LIBIBERTY_OBJS) ; do \ + echo "$(LIBIBERTY_DIR)/$$f" >> tlist ; \ + done + mv tlist stdlist + +piclist: stdlist + -rm -f tlist + cp stdlist tlist + if [ -n "$(PICFLAG)" ]; then \ + sed 's,\([A-Za-z_]*\.o\),pic/\1,g' tlist > tlist2 ; \ + mv tlist2 tlist ; \ + else true ; fi + mv tlist piclist + +$(ARLIB): stdlist + -rm -f t$(ARLIB) + $(AR) $(AR_FLAGS) t$(ARLIB) `cat stdlist` + mv t$(ARLIB) $(ARLIB) + $(RANLIB) $(ARLIB) + +$(SHLIB): piclist + $(CXX) $(LIBCXXFLAGS) $(SHFLAGS) -shared -o $(SHLIB) `cat piclist` $(SHDEPS) + +$(SHARLIB): $(SHLIB) + -rm -f t$(SHARLIB) + $(AR) $(AR_FLAGS) t$(SHARLIB) $(SHLIB) + mv t$(SHARLIB) $(SHARLIB) + $(RANLIB) $(SHARLIB) + +$(SHLINK): + ln -s -f $(SHLIB) $(SHLINK) + +mshlink: + @$(MAKE) $(MSHLINK) "SHLINK=$(MSHLINK)" + +$(IO_DIR)/iostream.list: force + cd $(IO_DIR) ; $(MAKE) $(FLAGS_TO_PASS) iostream.list + +$(LIBIBERTY_DIR)/libiberty.a: + cd $(LIBIBERTY_DIR) ; $(MAKE) $(FLAGS_TO_PASS) + +STRFUNCS = REP MAIN TRAITS ADDSS ADDPS ADDCS ADDSP ADDSC \ + EQSS EQPS EQSP NESS NEPS NESP LTSS LTPS LTSP GTSS GTPS GTSP \ + LESS LEPS LESP GESS GEPS GESP +STRIO = EXTRACT INSERT GETLINE + +# These are here for SunOS VPATH. +cstringi.o: cstringi.cc +cstdlibi.o: cstdlibi.cc +cmathi.o: cmathi.cc +stdexcepti.o: stdexcepti.cc +stlinst.o: stlinst.cc + +# Later do wide strings, too. +stmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \ + ${srcdir}/std/bastring.cc ${srcdir}/std/straits.h + for name in $(STRFUNCS) $(STRIO); do \ + echo c$${name}; \ + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DC -D$${name} ${srcdir}/sinst.cc \ + -o pic/c$${name}.o; \ + else true ; fi; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + $(COMPILE.cc) -DC -D$${name} ${srcdir}/sinst.cc -o c$${name}.o; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + done + touch stmp-string + +bigstmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \ + ${srcdir}/std/bastring.cc ${srcdir}/std/straits.h + echo cstring + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DC \ + `for N in $(STRFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/sinst.cc -o pic/cstrmain.o; \ + else true ; fi + $(COMPILE.cc) -DC `for N in $(STRFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/sinst.cc -o cstrmain.o + echo cstrio + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DC \ + `for N in $(STRIO); do echo " -D$${N}"; done` \ + $(srcdir)/sinst.cc -o pic/cstrio.o; \ + else true ; fi + $(COMPILE.cc) -DC `for N in $(STRIO); do echo " -D$${N}"; done` \ + $(srcdir)/sinst.cc -o cstrio.o + touch bigstmp-string + +COMFUNCS = MAIN ADDCC ADDCF ADDFC SUBCC SUBCF SUBFC MULCC MULCF MULFC DIVCC \ + DIVCF DIVFC PLUS MINUS EQCC EQCF EQFC NECC NECF NEFC ABS ARG POLAR \ + CONJ NORM COS COSH EXP LOG POWCC POWCF POWCI POWFC SIN SINH SQRT +COMIO = EXTRACT INSERT + +stmp-complex: ${srcdir}/cinst.cc ${srcdir}/std/complext.h \ + ${srcdir}/std/complext.cc ${srcdir}/std/dcomplex.h \ + ${srcdir}/std/ldcomplex.h + for N in $(COMFUNCS) $(COMIO); do \ + echo f$${N}; \ + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DF -D$${N} $(srcdir)/cinst.cc \ + -o pic/f$${N}.o; \ + else true ; fi; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + $(COMPILE.cc) -DF -D$${N} ${srcdir}/cinst.cc -o f$${N}.o; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + echo d$${N}; \ + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DD -D$${N} $(srcdir)/cinst.cc \ + -o pic/d$${N}.o; \ + else true ; fi; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + $(COMPILE.cc) -DD -D$${N} ${srcdir}/cinst.cc -o d$${N}.o; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + echo ld$${N}; \ + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DLD -D$${N} $(srcdir)/cinst.cc \ + -o pic/ld$${N}.o; \ + else true ; fi; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + $(COMPILE.cc) -DLD -D$${N} ${srcdir}/cinst.cc -o ld$${N}.o; \ + if [ $$? -eq 0 ]; then true; else exit 1; fi; \ + done + touch stmp-complex + +bigstmp-complex: ${srcdir}/cinst.cc ${srcdir}/std/complext.h \ + ${srcdir}/std/complext.cc ${srcdir}/std/dcomplex.h \ + ${srcdir}/std/ldcomplex.h + echo fcomplex + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DF \ + `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o pic/fcomplex.o; \ + else true ; fi + $(COMPILE.cc) -DF `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o fcomplex.o + echo fcomio + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DF \ + `for N in $(COMIO); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o pic/fcomio.o; \ + else true ; fi + $(COMPILE.cc) -DF `for N in $(COMIO); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o fcomio.o + echo dcomplex + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DD \ + `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o pic/dcomplex.o; \ + else true ; fi + $(COMPILE.cc) -DD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o dcomplex.o + echo dcomio + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DD \ + `for N in $(COMIO); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o pic/dcomio.o; \ + else true ; fi + $(COMPILE.cc) -DD `for N in $(COMIO); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o dcomio.o + echo ldcomplex + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DLD \ + `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o pic/ldcomplex.o; \ + else true ; fi + $(COMPILE.cc) -DLD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o ldcomplex.o + echo ldcomio + if [ -n "$(PICFLAG)" ]; then \ + $(COMPILE.cc) $(PICFLAG) -DLD \ + `for N in $(COMIO); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o pic/ldcomio.o; \ + else true ; fi + $(COMPILE.cc) -DLD `for N in $(COMIO); do echo " -D$${N}"; done` \ + $(srcdir)/cinst.cc -o ldcomio.o + touch bigstmp-complex + +.PHONY: install +install: + rootme=`pwd`/ ; export rootme ; \ + if [ -z "$(MULTISUBDIR)" ]; then \ + cd $(srcdir); \ + for FILE in $(HEADERS) *.h std/*.*; do \ + rm -f $(gxx_includedir)/$$FILE ; \ + $(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE ; \ + chmod a-x $(gxx_includedir)/$$FILE ; \ + done ; \ + cd stl; \ + for FILE in *.h; do \ + rm -f $(gxx_includedir)/$$FILE ; \ + $(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE ; \ + chmod a-x $(gxx_includedir)/$$FILE ; \ + done ; \ + else true ; \ + fi + rootme=`pwd`/ ; export rootme ; \ + for FILE in $(LIBS) ; do \ + rm -f $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + if [ $$FILE = $(SHLINK) ] ; then \ + ln -s -f $(SHLIB) $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + elif [ $$FILE = mshlink ]; then \ + for FILE in $(MSHLINK) ; do \ + rm -f $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + ln -s -f $$FILE $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + done; \ + elif [ $$FILE = $(SHLIB) ]; then \ + $(INSTALL_PROGRAM) $$FILE $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + : On the HP, shared libraries must be mode 555. ;\ + chmod 555 $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + else \ + $(INSTALL_DATA) $$FILE $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + $(RANLIB) $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + chmod a-x $(INSTALLDIR)$(MULTISUBDIR)/$$FILE ; \ + fi ; \ + done + @rootme=`pwd`/ ; export rootme ; \ + $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install + +.PHONY: force +force: + +.PHONY: stuff +stuff: + $(MAKE) clean + $(MAKE) -C ../libio c++clean + $(MAKE) -C ../libg++ clean + $(MAKE) check + $(MAKE) -C ../libio check + $(MAKE) -C ../libg++ check + +stuff1: + $(MAKE) clean + $(MAKE) -C ../libio c++clean + $(MAKE) -C ../libg++ clean + +stuff2: + $(MAKE) check + $(MAKE) -C ../libio check + $(MAKE) -C ../libg++ check diff --git a/libstdc++/NEWS b/libstdc++/NEWS new file mode 100644 index 000000000000..7ffcd56a8f0c --- /dev/null +++ b/libstdc++/NEWS @@ -0,0 +1,13 @@ +SUMMARY OF RECENT MAJOR CHANGES to LIBSTDC++. +(Also check ../libio/NEWS.) + +*** Noteworthy changes in libstdc++ version 2.8.0: + +* The STL implementation in libstdc++ is now only slightly modified from + the HP distribution, thanks to improved template support in gcc 2.8.0. + +* The string representation class is now nested in the basic_string + template, since this is supported in the new gcc. + +* As a result of these and other changes, libstc++ 2.8.0 is not binary + compatible with previous releases of libstdc++. diff --git a/libstdc++/algorithm b/libstdc++/algorithm new file mode 100644 index 000000000000..472d24166401 --- /dev/null +++ b/libstdc++/algorithm @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __ALGORITHM__ +#define __ALGORITHM__ +#include +#endif diff --git a/libstdc++/cassert b/libstdc++/cassert new file mode 100644 index 000000000000..b4165bfae7fe --- /dev/null +++ b/libstdc++/cassert @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CASSERT__ +#define __CASSERT__ +#include +#endif diff --git a/libstdc++/cctype b/libstdc++/cctype new file mode 100644 index 000000000000..e2765aed50a6 --- /dev/null +++ b/libstdc++/cctype @@ -0,0 +1,7 @@ +// The -*- C++ -*- character type header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CCTYPE__ +#define __CCTYPE__ +#include +#endif diff --git a/libstdc++/cerrno b/libstdc++/cerrno new file mode 100644 index 000000000000..ce493469597e --- /dev/null +++ b/libstdc++/cerrno @@ -0,0 +1,7 @@ +// The -*- C++ -*- error number header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CERRNO__ +#define __CERRNO__ +#include +#endif diff --git a/libstdc++/cfloat b/libstdc++/cfloat new file mode 100644 index 000000000000..cf59eadfb793 --- /dev/null +++ b/libstdc++/cfloat @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CFLOAT__ +#define __CFLOAT__ +#include +#endif diff --git a/libstdc++/cinst.cc b/libstdc++/cinst.cc new file mode 100644 index 000000000000..d28235dd2b50 --- /dev/null +++ b/libstdc++/cinst.cc @@ -0,0 +1,155 @@ +// Instantiation file for the -*- C++ -*- complex number classes. +// Copyright (C) 1994 Free Software Foundation + +#ifdef F +typedef float f; +#endif +#ifdef D +typedef double f; +#endif +#ifdef LD +typedef long double f; +#endif + +#if defined (MAIN) && defined (__GNUG__) +#ifdef F +#pragma implementation "fcomplex" +#endif +#ifdef D +#pragma implementation "dcomplex" +#endif +#ifdef LD +#pragma implementation "ldcomplex" +#endif +#endif + +#if 0 +#define _G_NO_EXTERN_TEMPLATES +#endif +#include + +typedef complex c; +typedef const c& ccr; + +#ifdef MAIN +template class complex; +template c& __doapl (c*, ccr); +template c& __doaml (c*, ccr); +template c& __doami (c*, ccr); +template c& __doadv (c*, ccr); +#endif + +#ifdef ADDCC +template c operator+ (ccr, ccr); +#endif +#ifdef ADDCF +template c operator+ (ccr, f); +#endif +#ifdef ADDFC +template c operator+ (f, ccr); +#endif +#ifdef SUBCC +template c operator- (ccr, ccr); +#endif +#ifdef SUBCF +template c operator- (ccr, f); +#endif +#ifdef SUBFC +template c operator- (f, ccr); +#endif +#ifdef MULCC +template c operator* (ccr, ccr); +#endif +#ifdef MULCF +template c operator* (ccr, f); +#endif +#ifdef MULFC +template c operator* (f, ccr); +#endif +#ifdef DIVCC +template c operator/ (ccr, ccr); +#endif +#ifdef DIVCF +template c operator/ (ccr, f); +#endif +#ifdef DIVFC +template c operator/ (f, ccr); +#endif +#ifdef PLUS +template c operator+ (ccr); +#endif +#ifdef MINUS +template c operator- (ccr); +#endif +#ifdef EQCC +template bool operator== (ccr, ccr); +#endif +#ifdef EQCF +template bool operator== (ccr, f); +#endif +#ifdef EQFC +template bool operator== (f, ccr); +#endif +#ifdef NECC +template bool operator!= (ccr, ccr); +#endif +#ifdef NECF +template bool operator!= (ccr, f); +#endif +#ifdef NEFC +template bool operator!= (f, ccr); +#endif +#ifdef ABS +template f abs (ccr); +#endif +#ifdef ARG +template f arg (ccr); +#endif +#ifdef POLAR +template c polar (f, f); +#endif +#ifdef CONJ +template c conj (ccr); +#endif +#ifdef NORM +template f norm (ccr); +#endif +#ifdef COS +template c cos (ccr); +#endif +#ifdef COSH +template c cosh (ccr); +#endif +#ifdef EXP +template c exp (ccr); +#endif +#ifdef LOG +template c log (ccr); +#endif +#ifdef POWCC +template c pow (ccr, ccr); +#endif +#ifdef POWCF +template c pow (ccr, f); +#endif +#ifdef POWCI +template c pow (ccr, int); +#endif +#ifdef POWFC +template c pow (f, ccr); +#endif +#ifdef SIN +template c sin (ccr); +#endif +#ifdef SINH +template c sinh (ccr); +#endif +#ifdef SQRT +template c sqrt (ccr); +#endif +#ifdef EXTRACT +template istream& operator>> (istream&, complex&); +#endif +#ifdef INSERT +template ostream& operator<< (ostream&, complex); +#endif diff --git a/libstdc++/ciso646 b/libstdc++/ciso646 new file mode 100644 index 000000000000..4d8200d73dc6 --- /dev/null +++ b/libstdc++/ciso646 @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CISO646__ +#define __CISO646__ +#include +#endif diff --git a/libstdc++/climits b/libstdc++/climits new file mode 100644 index 000000000000..1b29b3af01ec --- /dev/null +++ b/libstdc++/climits @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CLIMITS__ +#define __CLIMITS__ +#include +#endif diff --git a/libstdc++/clocale b/libstdc++/clocale new file mode 100644 index 000000000000..b67cf31c9d2e --- /dev/null +++ b/libstdc++/clocale @@ -0,0 +1,7 @@ +// The -*- C++ -*- locale support header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CLOCALE__ +#define __CLOCALE__ +#include +#endif diff --git a/libstdc++/cmath b/libstdc++/cmath new file mode 100644 index 000000000000..b18ea0b428c6 --- /dev/null +++ b/libstdc++/cmath @@ -0,0 +1,76 @@ +// The -*- C++ -*- math functions header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CMATH__ +#define __CMATH__ +#include <_G_config.h> +#include + +#ifdef __GNUG__ +#pragma interface "cmath" +#endif + +extern "C++" { +#if 0 +float acos (float); +float asin (float); +float atan (float); +float atan2(float, float); +float ceil (float); +float cos (float); +float cosh (float); +float exp (float); +float fabs (float); +float floor(float); +float fmod (float, float); +float frexp(float, int*); +float modf (float, float*); +float ldexp(float, int); +float log (float); +float log10(float); +float pow (float, float); +float pow (float, int); +float sin (float); +float sinh (float); +float sqrt (float); +float tan (float); +float tanh (float); +#endif + +inline float abs (float x) { return fabs (x); } +#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */ +inline double abs (double x) { return fabs (x); } +#endif + +#if 0 +double pow(double, int); + +long double acos (long double); +long double asin (long double); +long double atan (long double); +long double atan2(long double, long double); +long double ceil (long double); +long double cos (long double); +long double cosh (long double); +long double exp (long double); +long double fabs (long double); +long double floor(long double); +long double frexp(long double, int*); +long double fmod (long double, long double); +long double frexp(long double, int*); +long double log (long double); +long double log10(long double); +long double modf (long double, long double*); +long double pow (long double, long double); +long double pow (long double, int); +long double sin (long double); +long double sinh (long double); +long double sqrt (long double); +long double tan (long double); +long double tanh (long double); +#endif +inline long double abs (long double x) { return fabs (x); } + +} // extern "C++" + +#endif diff --git a/libstdc++/cmathi.cc b/libstdc++/cmathi.cc new file mode 100644 index 000000000000..afd740f013e9 --- /dev/null +++ b/libstdc++/cmathi.cc @@ -0,0 +1,7 @@ +// Implementation file for the -*- C++ -*- math functions header. +// This file is part of the GNU ANSI C++ Library. + +#ifdef __GNUG__ +#pragma implementation "cmath" +#endif +#include diff --git a/libstdc++/complex b/libstdc++/complex new file mode 100644 index 000000000000..bfdd352b4623 --- /dev/null +++ b/libstdc++/complex @@ -0,0 +1,18 @@ +// Main header for the -*- C++ -*- complex number classes. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __COMPLEX__ +#define __COMPLEX__ + +#include + +extern "C++" { +#define __STD_COMPLEX + +// ANSI complex types +typedef complex float_complex; +typedef complex double_complex; +typedef complex long_double_complex; +} + +#endif diff --git a/libstdc++/complex.h b/libstdc++/complex.h new file mode 100644 index 000000000000..2e88de854a68 --- /dev/null +++ b/libstdc++/complex.h @@ -0,0 +1,6 @@ +// -*- C++ -*- backward compatiblity header. +// Copyright (C) 1994 Free Software Foundation + +#ifndef __COMPLEX_H__ +#include +#endif diff --git a/libstdc++/config/aix.ml b/libstdc++/config/aix.ml new file mode 100644 index 000000000000..cd968705e705 --- /dev/null +++ b/libstdc++/config/aix.ml @@ -0,0 +1,8 @@ +# AIX has wierd shared/non-shared libraries. + +ARLIB = libstdc++-ar.a +SHLINK = libstdc++.a +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +DEPLIBS = ../$(SHLIB) +SHDEPS = -lm +SHFLAGS = -Wl,-unix diff --git a/libstdc++/config/dec-osf.ml b/libstdc++/config/dec-osf.ml new file mode 100644 index 000000000000..618c6c89fad8 --- /dev/null +++ b/libstdc++/config/dec-osf.ml @@ -0,0 +1,6 @@ +# We don't need -fpic on the alpha, so let's install both the shared and +# non-shared versions. + +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +DEPLIBS = ../$(SHLIB) +SHDEPS = -lm diff --git a/libstdc++/config/elf.ml b/libstdc++/config/elf.ml new file mode 100644 index 000000000000..2a5f336fe5e8 --- /dev/null +++ b/libstdc++/config/elf.ml @@ -0,0 +1,8 @@ +# Elf without shared libm -- we have to link with the archive library, even +# for programs that don't use complex. + +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHFLAGS = -h $(SHLIB) +DEPLIBS = ../$(SHLIB) +LDLIBS = -L.. -lstdc++ -lm +MLDLIBS = -L.. -lstdc++ -lm diff --git a/libstdc++/config/elfshlibm.ml b/libstdc++/config/elfshlibm.ml new file mode 100644 index 000000000000..fe2bf3f93bd3 --- /dev/null +++ b/libstdc++/config/elfshlibm.ml @@ -0,0 +1,6 @@ +# Elf with shared libm, so we can link it into the shared libstdc++. + +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHFLAGS = -h $(SHLIB) +SHDEPS = -lm +DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/hpux.ml b/libstdc++/config/hpux.ml new file mode 100644 index 000000000000..1531fe867f11 --- /dev/null +++ b/libstdc++/config/hpux.ml @@ -0,0 +1,6 @@ +# HPUX uses the .sl suffix for shared libraries. + +SHLIB = libstdc++.sl +LIBS = $(ARLIB) $(SHLIB) +DEPLIBS = ../$(SHLIB) +SHFLAGS = $(PICFLAG) diff --git a/libstdc++/config/irix5.ml b/libstdc++/config/irix5.ml new file mode 100644 index 000000000000..6b3344579545 --- /dev/null +++ b/libstdc++/config/irix5.ml @@ -0,0 +1,6 @@ +# We don't need -fpic on IRIX, so let's install both the shared and +# non-shared versions. + +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +DEPLIBS = ../$(SHLIB) +SHDEPS = -lm diff --git a/libstdc++/config/linux.ml b/libstdc++/config/linux.ml new file mode 100644 index 000000000000..7e6eecee80cb --- /dev/null +++ b/libstdc++/config/linux.ml @@ -0,0 +1,6 @@ +# Elf with shared libm, so we can link it into the shared libstdc++. + +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) mshlink +SHFLAGS = -Wl,-soname,$(MSHLINK) +SHDEPS = -lm +DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/sol2shm.ml b/libstdc++/config/sol2shm.ml new file mode 100644 index 000000000000..f02650ce0abb --- /dev/null +++ b/libstdc++/config/sol2shm.ml @@ -0,0 +1,6 @@ +# Solaris2 with shared libm, so we can link it into the shared libstdc++. + +LIBS = $(ARLIB) $(SHLIB) $(SHLINK) +SHFLAGS = -h $(SHLIB) +SHDEPS = -lm +DEPLIBS = ../$(SHLIB) diff --git a/libstdc++/config/sunos4.ml b/libstdc++/config/sunos4.ml new file mode 100644 index 000000000000..0abc13ce0a18 --- /dev/null +++ b/libstdc++/config/sunos4.ml @@ -0,0 +1,9 @@ +# SunOS doesn't provide a shared libm, so we have to link with the archive +# library, even for programs that don't use complex. +# SunOS requires a version number in shared library filenames. + +LIBS = $(ARLIB) $(SHLIB) +SHFLAGS = $(PICFLAG) +DEPLIBS = ../$(SHLIB) +LDLIBS = -L.. -lstdc++ -lm +MLDLIBS = -L.. -lstdc++ -lm diff --git a/libstdc++/configure.in b/libstdc++/configure.in new file mode 100644 index 000000000000..942c261f9dd3 --- /dev/null +++ b/libstdc++/configure.in @@ -0,0 +1,85 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../configure. + +configdirs="tests testsuite" +srctrigger=sinst.cc +srcname="ANSI C++ library" +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +echo "# Warning: this fragment is automatically generated" > temp.mt +frags= + +# If they didn't specify --enable-shared, don't generate shared libs. +case "${enable_shared}" in + yes) shared=yes ;; + no) shared=no ;; + *libstdc++*) shared=yes ;; + *) shared=no ;; +esac + +if [ "${shared}" = "yes" ]; then + case "${target}" in + hppa*-*-*) frags=../../config/mh-papic ;; + i[3456]86-*-*) frags=../../config/mh-x86pic ;; + *-*-*) frags=../../config/mh-${target_cpu}pic ;; + esac + case "${target}" in + *-dec-osf*) frags="${frags} dec-osf.ml";; + *-*-hpux*) frags="${frags} hpux.ml" ;; + *-*-irix[56]*) frags="${frags} irix5.ml" ;; + *-*-linux*aout*) ;; + *-*-linux*) frags="${frags} linux.ml" ;; + *-*-sysv4*) frags="${frags} elf.ml" ;; + *-*-solaris*) frags="${frags} sol2shm.ml" ;; + *-*-sunos4*) frags="${frags} sunos4.ml" ;; + *-*-aix*) frags="${frags} aix.ml" ;; + esac +fi + +for frag in ${frags}; do + frag=${srcdir}/config/$frag + if [ -f ${frag} ]; then + echo "Appending ${frag} to target-mkfrag" + echo "# Following fragment copied from ${frag}" >> temp.mt + cat ${frag} >> temp.mt + fi +done + +target_makefile_frag=target-mkfrag +${moveifchange} temp.mt target-mkfrag + +LIBDIR=yes +TO_TOPDIR=../ +ALL='libs' +XCXXINCLUDES="-I${srcdir} -I${srcdir}/stl -I${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio" +MOSTLYCLEAN='*.o pic stamp-picdir core so_locations $(MOSTLYCLEAN_JUNK)' +CLEAN='$(CLEAN_JUNK)' +EXTRA_DISTCLEAN='target-mkfrag' + +(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} + +# post-target: + +# If cross-compiling, we install in $(tooldir). +if [ -n "${with_cross_host}" ] ; then + rm -f Makefile.tem + sed \ + -e 's|INSTALLDIR.*=.*$|INSTALLDIR = $(tooldir)/lib|' \ + Makefile >Makefile.tem + mv -f Makefile.tem Makefile +fi + +if [ "${srcdir}" = "." ] ; then + if [ "${with_target_subdir}" != "." ] ; then + . ${with_multisrctop}../../config-ml.in + else + . ${with_multisrctop}../config-ml.in + fi +else + . ${srcdir}/../config-ml.in +fi diff --git a/libstdc++/csetjmp b/libstdc++/csetjmp new file mode 100644 index 000000000000..4bba048dcb5e --- /dev/null +++ b/libstdc++/csetjmp @@ -0,0 +1,8 @@ +// The -*- C++ -*- setjmp/longjmp header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSETJMP__ +#define __CSETJMP__ +#include +#endif + diff --git a/libstdc++/csignal b/libstdc++/csignal new file mode 100644 index 000000000000..6febfb7b2ed5 --- /dev/null +++ b/libstdc++/csignal @@ -0,0 +1,7 @@ +// The -*- C++ -*- signal handling header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSIGNAL__ +#define __CSIGNAL__ +#include +#endif diff --git a/libstdc++/cstdarg b/libstdc++/cstdarg new file mode 100644 index 000000000000..324f5a1c19b1 --- /dev/null +++ b/libstdc++/cstdarg @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDARG__ +#define __CSTDARG__ +#include +#endif diff --git a/libstdc++/cstddef b/libstdc++/cstddef new file mode 100644 index 000000000000..db5cbe400374 --- /dev/null +++ b/libstdc++/cstddef @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDDEF__ +#define __CSTDDEF__ +#include +#endif diff --git a/libstdc++/cstdio b/libstdc++/cstdio new file mode 100644 index 000000000000..1fe1456b5bdf --- /dev/null +++ b/libstdc++/cstdio @@ -0,0 +1,7 @@ +// The -*- C++ -*- standard I/O header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDIO__ +#define __CSTDIO__ +#include +#endif diff --git a/libstdc++/cstdlib b/libstdc++/cstdlib new file mode 100644 index 000000000000..e7c1a5160a56 --- /dev/null +++ b/libstdc++/cstdlib @@ -0,0 +1,23 @@ +// The -*- C++ -*- standard library header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDLIB__ +#define __CSTDLIB__ +#include + +#ifdef __GNUG__ +#pragma interface "cstdlib" +#endif + +extern "C++" { + +#if _G_HAS_LABS +inline long abs(long x) { return labs (x); } +#else +inline long abs(long x) { return x >= 0 ? x : -x; } +#endif +//inline ldiv_t div(long x, long y) { return ldiv (x, y); } + +} // extern "C++" + +#endif diff --git a/libstdc++/cstdlibi.cc b/libstdc++/cstdlibi.cc new file mode 100644 index 000000000000..abbfa03464a5 --- /dev/null +++ b/libstdc++/cstdlibi.cc @@ -0,0 +1,7 @@ +// Implementation file for the -*- C++ -*- standard library header. +// This file is part of the GNU ANSI C++ Library. + +#ifdef __GNUG__ +#pragma implementation "cstdlib" +#endif +#include diff --git a/libstdc++/cstring b/libstdc++/cstring new file mode 100644 index 000000000000..d8d03a765b65 --- /dev/null +++ b/libstdc++/cstring @@ -0,0 +1,96 @@ +// The -*- C++ -*- null-terminated string header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTRING__ +#define __CSTRING__ + +#include + +#if 0 // Let's not bother with this just yet. +#include + +#ifdef __GNUG__ +#pragma interface "cstring" +#endif + +// The ANSI C prototypes for these functions have a const argument type and +// non-const return type, so we can't use them. + +extern "C++" { +extern inline const char * +_G_strchr (const char *s, int c) +{ + return strchr (s, c); +} + +extern inline char * +_G_strchr (char *s, int c) +{ + return const_cast (strchr (s, c)); +} + +extern inline const char * +_G_strpbrk (const char *s1, const char *s2) +{ + return strpbrk (s1, s2); +} + +extern inline char * +_G_strpbrk (char *s1, const char *s2) +{ + return const_cast (strpbrk (s1, s2)); +} + +extern inline const char * +_G_strrchr (const char *s, int c) +{ + return strrchr (s, c); +} + +extern inline char * +_G_strrchr (char *s, int c) +{ + return const_cast (strrchr (s, c)); +} + +extern inline const char * +_G_strstr (const char *s1, const char *s2) +{ + return strstr (s1, s2); +} + +extern inline char * +_G_strstr (char *s1, const char *s2) +{ + return const_cast (strstr (s1, s2)); +} + +extern inline const void * +_G_memchr (const void *s, int c, size_t n) +{ + return memchr (s, c, n); +} + +extern inline void * +_G_memchr (void *s, int c, size_t n) +{ + return const_cast (memchr (s, c, n)); +} +} // extern "C++" + +// Lose any vendor macros for these functions. +#undef strchr +#undef strpbrk +#undef strrchr +#undef strstr +#undef memchr + +// Ewww, namespace pollution. Anyone have a better idea? +#define strchr _G_strchr +#define strpbrk _G_strpbrk +#define strrchr _G_strrchr +#define strstr _G_strstr +#define memchr _G_memchr +#endif // 0 + +#endif // !defined (__CSTRING__) diff --git a/libstdc++/cstringi.cc b/libstdc++/cstringi.cc new file mode 100644 index 000000000000..2676febc9b0f --- /dev/null +++ b/libstdc++/cstringi.cc @@ -0,0 +1,7 @@ +// Implementation file for the -*- C++ -*- null-terminated string header. +// This file is part of the GNU ANSI C++ Library. + +#ifdef __GNUG__ +#pragma implementation "cstring" +#endif +#include diff --git a/libstdc++/ctime b/libstdc++/ctime new file mode 100644 index 000000000000..0184da5929f3 --- /dev/null +++ b/libstdc++/ctime @@ -0,0 +1,7 @@ +// The -*- C++ -*- time header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CTIME__ +#define __CTIME__ +#include +#endif diff --git a/libstdc++/cwchar b/libstdc++/cwchar new file mode 100644 index 000000000000..1674c12b61f0 --- /dev/null +++ b/libstdc++/cwchar @@ -0,0 +1,7 @@ +// The -*- C++ -*- wide character header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CWCHAR__ +#define __CWCHAR__ +#include +#endif diff --git a/libstdc++/cwctype b/libstdc++/cwctype new file mode 100644 index 000000000000..81122012bd04 --- /dev/null +++ b/libstdc++/cwctype @@ -0,0 +1,7 @@ +// The -*- C++ -*- wide character type header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CWCTYPE__ +#define __CWCTYPE__ +#include +#endif diff --git a/libstdc++/deque b/libstdc++/deque new file mode 100644 index 000000000000..bdc14299a045 --- /dev/null +++ b/libstdc++/deque @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __DEQUE__ +#define __DEQUE__ +#include +#endif diff --git a/libstdc++/functional b/libstdc++/functional new file mode 100644 index 000000000000..ee8b7f20202e --- /dev/null +++ b/libstdc++/functional @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __FUNCTIONAL__ +#define __FUNCTIONAL__ +#include +#endif diff --git a/libstdc++/iterator b/libstdc++/iterator new file mode 100644 index 000000000000..a0fa054c5ec6 --- /dev/null +++ b/libstdc++/iterator @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __ITERATOR__ +#define __ITERATOR__ +#include +#endif diff --git a/libstdc++/list b/libstdc++/list new file mode 100644 index 000000000000..475d8443d167 --- /dev/null +++ b/libstdc++/list @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __LIST__ +#define __LIST__ +#include +#endif diff --git a/libstdc++/map b/libstdc++/map new file mode 100644 index 000000000000..0127b9db250f --- /dev/null +++ b/libstdc++/map @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __MAP__ +#define __MAP__ +#include +#endif diff --git a/libstdc++/memory b/libstdc++/memory new file mode 100644 index 000000000000..8328720db6d5 --- /dev/null +++ b/libstdc++/memory @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __MEMORY__ +#define __MEMORY__ +#include +#endif diff --git a/libstdc++/numeric b/libstdc++/numeric new file mode 100644 index 000000000000..dcb88737f171 --- /dev/null +++ b/libstdc++/numeric @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __NUMERIC__ +#define __NUMERIC__ +#include +#endif diff --git a/libstdc++/queue b/libstdc++/queue new file mode 100644 index 000000000000..e71ce343067c --- /dev/null +++ b/libstdc++/queue @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __QUEUE__ +#define __QUEUE__ +#include +#endif diff --git a/libstdc++/set b/libstdc++/set new file mode 100644 index 000000000000..0353285fe502 --- /dev/null +++ b/libstdc++/set @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __SET__ +#define __SET__ +#include +#endif diff --git a/libstdc++/sinst.cc b/libstdc++/sinst.cc new file mode 100644 index 000000000000..b8856fcd063b --- /dev/null +++ b/libstdc++/sinst.cc @@ -0,0 +1,132 @@ +// Instantiation file for the -*- C++ -*- string classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. + +#ifdef __GNUG__ +#ifdef TRAITS +#ifdef C +#pragma implementation "std/straits.h" +#endif +#endif +#endif + +#include + +#ifdef C +typedef char c; +#endif +#ifdef W +typedef wchar_t c; +#endif + +#ifdef TRAITS +template class string_char_traits ; +#endif + +typedef basic_string s; + +#ifdef MAIN +template class basic_string ; +#endif + +#ifdef ADDSS +template s operator+ (const s&, const s&); +#endif +#ifdef ADDPS +template s operator+ (const c*, const s&); +#endif +#ifdef ADDCS +template s operator+ (c, const s&); +#endif +#ifdef ADDSP +template s operator+ (const s&, const c*); +#endif +#ifdef ADDSC +template s operator+ (const s&, c); +#endif +#ifdef EQSS +template bool operator== (const s&, const s&); +#endif +#ifdef EQPS +template bool operator== (const c*, const s&); +#endif +#ifdef EQSP +template bool operator== (const s&, const c*); +#endif +#ifdef NESS +template bool operator!= (const s&, const s&); +#endif +#ifdef NEPS +template bool operator!= (const c*, const s&); +#endif +#ifdef NESP +template bool operator!= (const s&, const c*); +#endif +#ifdef LTSS +template bool operator< (const s&, const s&); +#endif +#ifdef LTPS +template bool operator< (const c*, const s&); +#endif +#ifdef LTSP +template bool operator< (const s&, const c*); +#endif +#ifdef GTSS +template bool operator> (const s&, const s&); +#endif +#ifdef GTPS +template bool operator> (const c*, const s&); +#endif +#ifdef GTSP +template bool operator> (const s&, const c*); +#endif +#ifdef LESS +template bool operator<= (const s&, const s&); +#endif +#ifdef LEPS +template bool operator<= (const c*, const s&); +#endif +#ifdef LESP +template bool operator<= (const s&, const c*); +#endif +#ifdef GESS +template bool operator>= (const s&, const s&); +#endif +#ifdef GEPS +template bool operator>= (const c*, const s&); +#endif +#ifdef GESP +template bool operator>= (const s&, const c*); +#endif +#ifdef EXTRACT +template istream& operator>> (istream&, s&); +#endif // EXTRACT +#ifdef INSERT +template ostream& operator<< (ostream&, const s&); +#endif // INSERT +#ifdef GETLINE +template istream& getline (istream&, s&, c); +#endif diff --git a/libstdc++/stack b/libstdc++/stack new file mode 100644 index 000000000000..dfe0c51e1813 --- /dev/null +++ b/libstdc++/stack @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __STACK__ +#define __STACK__ +#include +#endif diff --git a/libstdc++/std/bastring.cc b/libstdc++/std/bastring.cc new file mode 100644 index 000000000000..155656ae5d04 --- /dev/null +++ b/libstdc++/std/bastring.cc @@ -0,0 +1,514 @@ +// Member templates for the -*- C++ -*- string classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. + +#include +#include + +extern "C++" { +template +inline void * basic_string ::Rep:: +operator new (size_t s, size_t extra) +{ + return ::operator new (s + extra * sizeof (charT)); +} + +template +inline size_t basic_string ::Rep:: +#if _G_ALLOC_CONTROL +default_frob (size_t s) +#else +frob_size (size_t s) +#endif +{ + size_t i = 16; + while (i < s) i *= 2; + return i; +} + +template +inline basic_string ::Rep * basic_string ::Rep:: +create (size_t extra) +{ + extra = frob_size (extra + 1); + Rep *p = new (extra) Rep; + p->res = extra; + p->ref = 1; + p->selfish = false; + return p; +} + +template +charT * basic_string ::Rep:: +clone () +{ + Rep *p = Rep::create (len); + p->copy (0, data (), len); + p->len = len; + return p->data (); +} + +template +inline bool basic_string ::Rep:: +#ifdef _G_ALLOC_CONTROL +default_excess (size_t s, size_t r) +#else +excess_slop (size_t s, size_t r) +#endif +{ + return 2 * (s <= 16 ? 16 : s) < r; +} + +template +inline bool basic_string :: +check_realloc (size_t s) const +{ + s += sizeof (charT); + return (rep ()->ref > 1 + || s > capacity () + || Rep::excess_slop (s, capacity ())); +} + +template +void basic_string :: +alloc (size_t size, bool save) +{ + if (! check_realloc (size)) + return; + + Rep *p = Rep::create (size); + + if (save) + { + p->copy (0, data (), length ()); + p->len = length (); + } + else + p->len = 0; + + repup (p); +} + +template +basic_string & basic_string :: +replace (size_t pos1, size_t n1, + const basic_string& str, size_t pos2, size_t n2) +{ + const size_t len2 = str.length (); + + if (pos1 == 0 && n1 >= length () && pos2 == 0 && n2 >= len2) + return operator= (str); + + OUTOFRANGE (pos2 > len2); + + if (n2 > len2 - pos2) + n2 = len2 - pos2; + + return replace (pos1, n1, str.data () + pos2, n2); +} + +template +inline void basic_string ::Rep:: +copy (size_t pos, const charT *s, size_t n) +{ + if (n) + traits::copy (data () + pos, s, n); +} + +template +inline void basic_string ::Rep:: +move (size_t pos, const charT *s, size_t n) +{ + if (n) + traits::move (data () + pos, s, n); +} + +template +basic_string & basic_string :: +replace (size_t pos, size_t n1, const charT* s, size_t n2) +{ + const size_t len = length (); + OUTOFRANGE (pos > len); + if (n1 > len - pos) + n1 = len - pos; + LENGTHERROR (len - n1 > max_size () - n2); + size_t newlen = len - n1 + n2; + + if (check_realloc (newlen)) + { + Rep *p = Rep::create (newlen); + p->copy (0, data (), pos); + p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); + p->copy (pos, s, n2); + repup (p); + } + else + { + rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); + rep ()->copy (pos, s, n2); + } + rep ()->len = newlen; + + return *this; +} + +template +inline void basic_string ::Rep:: +set (size_t pos, const charT c, size_t n) +{ + traits::set (data () + pos, c, n); +} + +template +basic_string & basic_string :: +replace (size_t pos, size_t n1, size_t n2, charT c) +{ + const size_t len = length (); + OUTOFRANGE (pos > len); + if (n1 > len - pos) + n1 = len - pos; + LENGTHERROR (len - n1 > max_size () - n2); + size_t newlen = len - n1 + n2; + + if (check_realloc (newlen)) + { + Rep *p = Rep::create (newlen); + p->copy (0, data (), pos); + p->copy (pos + n2, data () + pos + n1, len - (pos + n1)); + p->set (pos, c, n2); + repup (p); + } + else + { + rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1)); + rep ()->set (pos, c, n2); + } + rep ()->len = newlen; + + return *this; +} + +template +void basic_string :: +resize (size_t n, charT c) +{ + LENGTHERROR (n > max_size ()); + + if (n > length ()) + append (n - length (), c); + else + remove (n); +} + +template +size_t basic_string :: +copy (charT* s, size_t n, size_t pos) +{ + OUTOFRANGE (pos > length ()); + + if (n > length () - pos) + n = length () - pos; + + traits::copy (s, data () + pos, n); + return n; +} + +template +size_t basic_string :: +find (const charT* s, size_t pos, size_t n) const +{ + size_t xpos = pos; + for (; xpos + n <= length (); ++xpos) + if (traits::eq (data () [xpos], *s) + && traits::compare (data () + xpos, s, n) == 0) + return xpos; + return npos; +} + +template +inline size_t basic_string :: +_find (const charT* ptr, charT c, size_t xpos, size_t len) +{ + for (; xpos < len; ++xpos) + if (traits::eq (ptr [xpos], c)) + return xpos; + return npos; +} + +template +size_t basic_string :: +find (charT c, size_t pos) const +{ + return _find (data (), c, pos, length ()); +} + +template +size_t basic_string :: +rfind (const charT* s, size_t pos, size_t n) const +{ + if (n > length ()) + return npos; + + size_t xpos = length () - n; + if (xpos > pos) + xpos = pos; + + for (++xpos; xpos-- > 0; ) + if (traits::eq (data () [xpos], *s) + && traits::compare (data () + xpos, s, n) == 0) + return xpos; + return npos; +} + +template +size_t basic_string :: +rfind (charT c, size_t pos) const +{ + if (1 > length ()) + return npos; + + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + + for (++xpos; xpos-- > 0; ) + if (traits::eq (data () [xpos], c)) + return xpos; + return npos; +} + +template +size_t basic_string :: +find_first_of (const charT* s, size_t pos, size_t n) const +{ + size_t xpos = pos; + for (; xpos < length (); ++xpos) + if (_find (s, data () [xpos], 0, n) != npos) + return xpos; + return npos; +} + +template +size_t basic_string :: +find_last_of (const charT* s, size_t pos, size_t n) const +{ + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + for (; xpos; --xpos) + if (_find (s, data () [xpos], 0, n) != npos) + return xpos; + return npos; +} + +template +size_t basic_string :: +find_first_not_of (const charT* s, size_t pos, size_t n) const +{ + size_t xpos = pos; + for (; xpos < length (); ++xpos) + if (_find (s, data () [xpos], 0, n) == npos) + return xpos; + return npos; +} + +template +size_t basic_string :: +find_first_not_of (charT c, size_t pos) const +{ + size_t xpos = pos; + for (; xpos < length (); ++xpos) + if (traits::ne (data () [xpos], c)) + return xpos; + return npos; +} + +template +size_t basic_string :: +find_last_not_of (const charT* s, size_t pos, size_t n) const +{ + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + for (; xpos; --xpos) + if (_find (s, data () [xpos], 0, n) == npos) + return xpos; + return npos; +} + +template +size_t basic_string :: +find_last_not_of (charT c, size_t pos) const +{ + size_t xpos = length () - 1; + if (xpos > pos) + xpos = pos; + for (; xpos; --xpos) + if (traits::ne (data () [xpos], c)) + return xpos; + return npos; +} + +template +int basic_string :: +compare (const basic_string& str, size_t pos, size_t n) const +{ + OUTOFRANGE (pos > length ()); + + size_t rlen = length () - pos; + if (rlen > n) + rlen = n; + if (rlen > str.length ()) + rlen = str.length (); + int r = traits::compare (data () + pos, str.data (), rlen); + if (r != 0) + return r; + if (rlen == n) + return 0; + return (length () - pos) - str.length (); +} + +template +int basic_string :: +compare (const charT* s, size_t pos, size_t n) const +{ + OUTOFRANGE (pos > length ()); + + size_t rlen = length () - pos; + if (rlen > n) + rlen = n; + int r = traits::compare (data () + pos, s, rlen); + if (r != 0) + return r; + return (length () - pos) - n; +} + +#include + +template +istream & +operator>> (istream &is, basic_string &s) +{ + int w = is.width (0); + if (is.ipfx0 ()) + { + register streambuf *sb = is.rdbuf (); + s.resize (0); + while (1) + { + int ch = sb->sbumpc (); + if (ch == EOF) + { + is.setstate (ios::eofbit); + break; + } + else if (traits::is_del (ch)) + { + sb->sungetc (); + break; + } + s += ch; + if (--w == 1) + break; + } + } + + is.isfx (); + if (s.length () == 0) + is.setstate (ios::failbit); + + return is; +} + +template +ostream & +operator<< (ostream &o, const basic_string & s) +{ + return o.write (s.data (), s.length ()); +} + +template +istream& +getline (istream &is, basic_string & s, charT delim) +{ + if (is.ipfx1 ()) + { + _IO_size_t count = 0; + streambuf *sb = is.rdbuf (); + s.resize (0); + + while (1) + { + int ch = sb->sbumpc (); + if (ch == EOF) + { + is.setstate (count == 0 + ? (ios::failbit|ios::eofbit) + : ios::eofbit); + break; + } + + ++count; + + if (ch == delim) + break; + + s += ch; + + if (s.length () == s.npos - 1) + { + is.setstate (ios::failbit); + break; + } + } + } + + // We need to be friends with istream to do this. + // is._gcount = count; + is.isfx (); + + return is; +} + +template +basic_string ::Rep +basic_string::nilRep = { 0, 0, 1 }; + +template +const basic_string ::size_type +basic_string ::npos; + +#ifdef _G_ALLOC_CONTROL +template +bool (*basic_string ::Rep::excess_slop) (size_t, size_t) + = basic_string ::Rep::default_excess; + +template +size_t (*basic_string ::Rep::frob_size) (size_t) + = basic_string ::Rep::default_frob; +#endif + +} // extern "C++" diff --git a/libstdc++/std/bastring.h b/libstdc++/std/bastring.h new file mode 100644 index 000000000000..5a2605bd0506 --- /dev/null +++ b/libstdc++/std/bastring.h @@ -0,0 +1,560 @@ +// Main templates for the -*- C++ -*- string classes. +// Copyright (C) 1994, 1995 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. + +#ifndef __BASTRING__ +#define __BASTRING__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include +#include + +#if _G_USE_EXCEPTIONS + +#include +#define OUTOFRANGE(cond) \ + do { if (!(cond)) throw out_of_range (#cond); } while (0) +#define LENGTHERROR(cond) \ + do { if (!(cond)) throw length_error (#cond); } while (0) + +#else + +#include +#define OUTOFRANGE(cond) assert (!(cond)) +#define LENGTHERROR(cond) assert (!(cond)) + +#endif + +extern "C++" { +class istream; class ostream; + +// #include + +template > +class basic_string +{ +private: + struct Rep { + size_t len, res, ref; + bool selfish; + + charT* data () { return reinterpret_cast(this + 1); } + charT& operator[] (size_t s) { return data () [s]; } + charT* grab () { if (selfish) return clone (); ++ref; return data (); } + void release () { if (--ref == 0) delete this; } + + inline static void * operator new (size_t, size_t); + inline static Rep* create (size_t); + charT* clone (); + + inline void copy (size_t, const charT *, size_t); + inline void move (size_t, const charT *, size_t); + inline void set (size_t, const charT, size_t); + +#if _G_ALLOC_CONTROL + // These function pointers allow you to modify the allocation policy used + // by the string classes. By default they expand by powers of two, but + // this may be excessive for space-critical applications. + + // Returns true if ALLOCATED is too much larger than LENGTH + static bool (*excess_slop) (size_t length, size_t allocated); + inline static bool default_excess (size_t, size_t); + + // Returns a good amount of space to allocate for a string of length LENGTH + static size_t (*frob_size) (size_t length); + inline static size_t default_frob (size_t); +#else + inline static bool excess_slop (size_t, size_t); + inline static size_t frob_size (size_t); +#endif + + private: + Rep &operator= (const Rep &); + }; + +public: +// types: + typedef traits traits_type; + typedef charT value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef charT& reference; + typedef const charT& const_reference; + typedef charT* pointer; + typedef const charT* const_pointer; + typedef pointer iterator; + typedef const_pointer const_iterator; +#if 0 + typedef reverse_iterator reverse_iterator; + typedef reverse_iterator const_reverse_iterator; +#endif + static const size_type npos = static_cast(-1); + +private: + Rep *rep () const { return reinterpret_cast(dat) - 1; } + void repup (Rep *p) { rep ()->release (); dat = p->data (); } + +public: + const charT* data () const + { return rep ()->data(); } + size_type length () const + { return rep ()->len; } + size_type size () const + { return rep ()->len; } + size_type capacity () const + { return rep ()->res; } + size_type max_size () const + { return (npos - 1)/sizeof (charT); } // XXX + bool empty () const + { return size () == 0; } + +// _lib.string.cons_ construct/copy/destroy: + basic_string& operator= (const basic_string& str) + { + if (&str != this) { rep ()->release (); dat = str.rep ()->grab (); } + return *this; + } + + explicit basic_string (): dat (nilRep.grab ()) { } + basic_string (const basic_string& str): dat (str.rep ()->grab ()) { } + basic_string (const basic_string& str, size_type pos, size_type n = npos) + : dat (nilRep.grab ()) { assign (str, pos, n); } + basic_string (const charT* s, size_type n) + : dat (nilRep.grab ()) { assign (s, n); } + basic_string (const charT* s) + : dat (nilRep.grab ()) { assign (s); } + basic_string (size_type n, charT c) + : dat (nilRep.grab ()) { assign (n, c); } +#if 0 + template + basic_string(InputIterator begin, InputIterator end, + Allocator& = Allocator()); +#endif + + ~basic_string () + { rep ()->release (); } + + void swap (basic_string &s) { charT *d = dat; dat = s.dat; s.dat = d; } + + basic_string& append (const basic_string& str, size_type pos = 0, + size_type n = npos) + { return replace (length (), 0, str, pos, n); } + basic_string& append (const charT* s, size_type n) + { return replace (length (), 0, s, n); } + basic_string& append (const charT* s) + { return append (s, traits::length (s)); } + basic_string& append (size_type n, charT c) + { return replace (length (), 0, n, c); } +#if 0 + template + basic_string& append(InputIterator first, InputIterator last); +#endif + + basic_string& assign (const basic_string& str, size_type pos = 0, + size_type n = npos) + { return replace (0, npos, str, pos, n); } + basic_string& assign (const charT* s, size_type n) + { return replace (0, npos, s, n); } + basic_string& assign (const charT* s) + { return assign (s, traits::length (s)); } + basic_string& assign (size_type n, charT c) + { return replace (0, npos, n, c); } +#if 0 + template + basic_string& assign(InputIterator first, InputIterator last); +#endif + + basic_string& operator= (const charT* s) + { return assign (s); } + basic_string& operator= (charT c) + { return assign (1, c); } + + basic_string& operator+= (const basic_string& rhs) + { return append (rhs); } + basic_string& operator+= (const charT* s) + { return append (s); } + basic_string& operator+= (charT c) + { return append (1, c); } + + basic_string& insert (size_type pos1, const basic_string& str, + size_type pos2 = 0, size_type n = npos) + { return replace (pos1, 0, str, pos2, n); } + basic_string& insert (size_type pos, const charT* s, size_type n) + { return replace (pos, 0, s, n); } + basic_string& insert (size_type pos, const charT* s) + { return insert (pos, s, traits::length (s)); } + basic_string& insert (size_type pos, size_type n, charT c) + { return replace (pos, 0, n, c); } + iterator insert(iterator p, charT c) + { size_type pos = p - begin (); insert (pos, 1, c); return pos +begin (); } + iterator insert(iterator p, size_type n, charT c) + { size_type pos = p - begin (); insert (pos, n, c); return pos +begin (); } +#if 0 + template + void insert(iterator p, InputIterator first, InputIterator last); +#endif + + basic_string& remove (size_type pos = 0, size_type n = npos) + { return replace (pos, n, (size_type)0, (charT)0); } + basic_string& remove (iterator pos) + { return replace (pos - begin (), 1, (size_type)0, (charT)0); } + basic_string& remove (iterator first, iterator last) + { return replace (first - begin (), last - first, (size_type)0, (charT)0);} + + basic_string& replace (size_type pos1, size_type n1, const basic_string& str, + size_type pos2 = 0, size_type n2 = npos); + basic_string& replace (size_type pos, size_type n1, const charT* s, + size_type n2); + basic_string& replace (size_type pos, size_type n1, const charT* s) + { return replace (pos, n1, s, traits::length (s)); } + basic_string& replace (size_type pos, size_type n1, size_type n2, charT c); + basic_string& replace (size_type pos, size_type n, charT c) + { return replace (pos, n, 1, c); } + basic_string& replace (iterator i1, iterator i2, const basic_string& str) + { return replace (i1 - begin (), i2 - i1, str); } + basic_string& replace (iterator i1, iterator i2, const charT* s, size_type n) + { return replace (i1 - begin (), i2 - i1, s, n); } + basic_string& replace (iterator i1, iterator i2, const charT* s) + { return replace (i1 - begin (), i2 - i1, s); } + basic_string& replace (iterator i1, iterator i2, size_type n, charT c) + { return replace (i1 - begin (), i2 - i1, n, c); } +#if 0 + template + basic_string& replace(iterator i1, iterator i2, + InputIterator j1, InputIterator j2); +#endif + +private: + static charT eos () { return traits::eos (); } + void unique () { if (rep ()->ref > 1) alloc (capacity (), true); } + void selfish () { unique (); rep ()->selfish = true; } + +public: + charT operator[] (size_type pos) const + { + if (pos == length ()) + return eos (); + return data ()[pos]; + } + + reference operator[] (size_type pos) + { unique (); return (*rep ())[pos]; } + + reference at (size_type pos) + { + OUTOFRANGE (pos >= length ()); + return (*this)[pos]; + } + const_reference at (size_type pos) const + { + OUTOFRANGE (pos >= length ()); + return data ()[pos]; + } + +private: + void terminate () const + { traits::assign ((*rep ())[length ()], eos ()); } + +public: + const charT* c_str () const + { terminate (); return data (); } + void resize (size_type n, charT c); + void resize (size_type n) + { resize (n, eos ()); } + void reserve (size_type) { } + + size_type copy (charT* s, size_type n, size_type pos = 0); + + size_type find (const basic_string& str, size_type pos = 0) const + { return find (str.data(), pos, str.length()); } + size_type find (const charT* s, size_type pos, size_type n) const; + size_type find (const charT* s, size_type pos = 0) const + { return find (s, pos, traits::length (s)); } + size_type find (charT c, size_type pos = 0) const; + + size_type rfind (const basic_string& str, size_type pos = npos) const + { return rfind (str.data(), pos, str.length()); } + size_type rfind (const charT* s, size_type pos, size_type n) const; + size_type rfind (const charT* s, size_type pos = npos) const + { return rfind (s, pos, traits::length (s)); } + size_type rfind (charT c, size_type pos = npos) const; + + size_type find_first_of (const basic_string& str, size_type pos = 0) const + { return find_first_of (str.data(), pos, str.length()); } + size_type find_first_of (const charT* s, size_type pos, size_type n) const; + size_type find_first_of (const charT* s, size_type pos = 0) const + { return find_first_of (s, pos, traits::length (s)); } + size_type find_first_of (charT c, size_type pos = 0) const + { return find (c, pos); } + + size_type find_last_of (const basic_string& str, size_type pos = npos) const + { return find_last_of (str.data(), pos, str.length()); } + size_type find_last_of (const charT* s, size_type pos, size_type n) const; + size_type find_last_of (const charT* s, size_type pos = npos) const + { return find_last_of (s, pos, traits::length (s)); } + size_type find_last_of (charT c, size_type pos = npos) const + { return rfind (c, pos); } + + size_type find_first_not_of (const basic_string& str, size_type pos = 0) const + { return find_first_not_of (str.data(), pos, str.length()); } + size_type find_first_not_of (const charT* s, size_type pos, size_type n) const; + size_type find_first_not_of (const charT* s, size_type pos = 0) const + { return find_first_not_of (s, pos, traits::length (s)); } + size_type find_first_not_of (charT c, size_type pos = 0) const; + + size_type find_last_not_of (const basic_string& str, size_type pos = npos) const + { return find_last_not_of (str.data(), pos, str.length()); } + size_type find_last_not_of (const charT* s, size_type pos, size_type n) const; + size_type find_last_not_of (const charT* s, size_type pos = npos) const + { return find_last_not_of (s, pos, traits::length (s)); } + size_type find_last_not_of (charT c, size_type pos = npos) const; + + basic_string substr (size_type pos = 0, size_type n = npos) const + { return basic_string (*this, pos, n); } + + int compare (const basic_string& str, size_type pos = 0, size_type n = npos) const; + // There is no 'strncmp' equivalent for charT pointers. + int compare (const charT* s, size_type pos, size_type n) const; + int compare (const charT* s, size_type pos = 0) const + { return compare (s, pos, traits::length (s)); } + + iterator begin () { selfish (); return &(*this)[0]; } + iterator end () { selfish (); return &(*this)[length ()]; } + const_iterator begin () const { return &(*rep ())[0]; } + const_iterator end () const { return &(*rep ())[length ()]; } + +#if 0 + reverse_iterator rbegin() { return reverse_iterator (end ()); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator (end ()); } + reverse_iterator rend() { return reverse_iterator (begin ()); } + const_reverse_iterator rend() const + { return const reverse_iterator (begin ()); } +#endif + +private: + void alloc (size_type size, bool save); + static size_type _find (const charT* ptr, charT c, size_type xpos, size_type len); + inline bool check_realloc (size_type s) const; + + static Rep nilRep; + charT *dat; +}; + +template +inline basic_string +operator+ (const basic_string & lhs, + const basic_string & rhs) +{ + basic_string str (lhs); + str.append (rhs); + return str; +} + +template +inline basic_string +operator+ (const charT* lhs, const basic_string & rhs) +{ + basic_string str (lhs); + str.append (rhs); + return str; +} + +template +inline basic_string +operator+ (charT lhs, const basic_string & rhs) +{ + basic_string str (1, lhs); + str.append (rhs); + return str; +} + +template +inline basic_string +operator+ (const basic_string & lhs, const charT* rhs) +{ + basic_string str (lhs); + str.append (rhs); + return str; +} + +template +inline basic_string +operator+ (const basic_string & lhs, charT rhs) +{ + basic_string str (lhs); + str.append (1, rhs); + return str; +} + +template +inline bool +operator== (const basic_string & lhs, + const basic_string & rhs) +{ + return (lhs.compare (rhs) == 0); +} + +template +inline bool +operator== (const charT* lhs, const basic_string & rhs) +{ + return (rhs.compare (lhs) == 0); +} + +template +inline bool +operator== (const basic_string & lhs, const charT* rhs) +{ + return (lhs.compare (rhs) == 0); +} + +template +inline bool +operator!= (const charT* lhs, const basic_string & rhs) +{ + return (rhs.compare (lhs) != 0); +} + +template +inline bool +operator!= (const basic_string & lhs, const charT* rhs) +{ + return (lhs.compare (rhs) != 0); +} + +template +inline bool +operator< (const basic_string & lhs, + const basic_string & rhs) +{ + return (lhs.compare (rhs) < 0); +} + +template +inline bool +operator< (const charT* lhs, const basic_string & rhs) +{ + return (rhs.compare (lhs) > 0); +} + +template +inline bool +operator< (const basic_string & lhs, const charT* rhs) +{ + return (lhs.compare (rhs) < 0); +} + +template +inline bool +operator> (const charT* lhs, const basic_string & rhs) +{ + return (rhs.compare (lhs) < 0); +} + +template +inline bool +operator> (const basic_string & lhs, const charT* rhs) +{ + return (lhs.compare (rhs) > 0); +} + +template +inline bool +operator<= (const charT* lhs, const basic_string & rhs) +{ + return (rhs.compare (lhs) >= 0); +} + +template +inline bool +operator<= (const basic_string & lhs, const charT* rhs) +{ + return (lhs.compare (rhs) <= 0); +} + +template +inline bool +operator>= (const charT* lhs, const basic_string & rhs) +{ + return (rhs.compare (lhs) <= 0); +} + +template +inline bool +operator>= (const basic_string & lhs, const charT* rhs) +{ + return (lhs.compare (rhs) >= 0); +} + +template +inline bool +operator!= (const basic_string & lhs, + const basic_string & rhs) +{ + return (lhs.compare (rhs) != 0); +} + +template +inline bool +operator> (const basic_string & lhs, + const basic_string & rhs) +{ + return (lhs.compare (rhs) > 0); +} + +template +inline bool +operator<= (const basic_string & lhs, + const basic_string & rhs) +{ + return (lhs.compare (rhs) <= 0); +} + +template +inline bool +operator>= (const basic_string & lhs, + const basic_string & rhs) +{ + return (lhs.compare (rhs) >= 0); +} + +class istream; class ostream; +template istream& +operator>> (istream&, basic_string &); +template ostream& +operator<< (ostream&, const basic_string &); +template istream& +getline (istream&, basic_string &, charT delim = '\n'); + +} // extern "C++" + +#endif diff --git a/libstdc++/std/complext.cc b/libstdc++/std/complext.cc new file mode 100644 index 000000000000..d50bf0871f61 --- /dev/null +++ b/libstdc++/std/complext.cc @@ -0,0 +1,273 @@ +// Member templates for the -*- C++ -*- complex number classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#include + +extern "C++" { +template complex +cos (const complex& x) +{ + return complex (cos (real (x)) * cosh (imag (x)), + - sin (real (x)) * sinh (imag (x))); +} + +template complex +cosh (const complex& x) +{ + return complex (cosh (real (x)) * cos (imag (x)), + sinh (real (x)) * sin (imag (x))); +} + +template complex +exp (const complex& x) +{ + return polar (FLOAT (exp (real (x))), imag (x)); +} + +template complex +log (const complex& x) +{ + return complex (log (abs (x)), arg (x)); +} + +template complex +pow (const complex& x, const complex& y) +{ + FLOAT logr = log (abs (x)); + FLOAT t = arg (x); + + return polar (FLOAT (exp (logr * real (y) - imag (y) * t)), + FLOAT (imag (y) * logr + real (y) * t)); +} + +template complex +pow (const complex& x, FLOAT y) +{ + return exp (FLOAT (y) * log (x)); +} + +template complex +pow (FLOAT x, const complex& y) +{ + return exp (y * FLOAT (log (x))); +} + +template complex +sin (const complex& x) +{ + return complex (sin (real (x)) * cosh (imag (x)), + cos (real (x)) * sinh (imag (x))); +} + +template complex +sinh (const complex& x) +{ + return complex (sinh (real (x)) * cos (imag (x)), + cosh (real (x)) * sin (imag (x))); +} + +#include + +template istream& +operator >> (istream& is, complex& x) +{ + FLOAT re, im = 0; + char ch = 0; + + if (is.ipfx0 ()) + { + if (is.peek () == '(') + is >> ch; + is >> re; + if (ch == '(') + { + is >> ch; + if (ch == ',') + is >> im >> ch; + } + } + is.isfx (); + + if (ch != 0 && ch != ')') + is.setstate (ios::failbit); + else if (is.good ()) + x = complex (re, im); + + return is; +} + +template ostream& +operator << (ostream& os, const complex& x) +{ + return os << '(' << real (x) << ',' << imag (x) << ')'; +} + +// The code below is adapted from f2c's libF77, and is subject to this +// copyright: + +/**************************************************************** +Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories and Bellcore. + +Permission to use, copy, modify, and distribute this software +and its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the names of AT&T Bell Laboratories or +Bellcore or any of their entities not be used in advertising or +publicity pertaining to distribution of the software without +specific, written prior permission. + +AT&T and Bellcore disclaim all warranties with regard to this +software, including all implied warranties of merchantability +and fitness. In no event shall AT&T or Bellcore be liable for +any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether +in an action of contract, negligence or other tortious action, +arising out of or in connection with the use or performance of +this software. +****************************************************************/ + +template complex& +__doadv (complex* ths, const complex& y) +{ + FLOAT ar = abs (y.re); + FLOAT ai = abs (y.im); + FLOAT nr, ni; + FLOAT t, d; + if (ar <= ai) + { + t = y.re / y.im; + d = y.im * (1 + t*t); + nr = (ths->re * t + ths->im) / d; + ni = (ths->im * t - ths->re) / d; + } + else + { + t = y.im / y.re; + d = y.re * (1 + t*t); + nr = (ths->re + ths->im * t) / d; + ni = (ths->im - ths->re * t) / d; + } + ths->re = nr; + ths->im = ni; + return *ths; +} + +template complex +operator / (const complex& x, const complex& y) +{ + FLOAT ar = abs (real (y)); + FLOAT ai = abs (imag (y)); + FLOAT nr, ni; + FLOAT t, d; + if (ar <= ai) + { + t = real (y) / imag (y); + d = imag (y) * (1 + t*t); + nr = (real (x) * t + imag (x)) / d; + ni = (imag (x) * t - real (x)) / d; + } + else + { + t = imag (y) / real (y); + d = real (y) * (1 + t*t); + nr = (real (x) + imag (x) * t) / d; + ni = (imag (x) - real (x) * t) / d; + } + return complex (nr, ni); +} + +template complex +operator / (FLOAT x, const complex& y) +{ + FLOAT ar = abs (real (y)); + FLOAT ai = abs (imag (y)); + FLOAT nr, ni; + FLOAT t, d; + if (ar <= ai) + { + t = real (y) / imag (y); + d = imag (y) * (1 + t*t); + nr = x * t / d; + ni = -x / d; + } + else + { + t = imag (y) / real (y); + d = real (y) * (1 + t*t); + nr = x / d; + ni = -x * t / d; + } + return complex (nr, ni); +} + +template complex +pow (const complex& xin, int y) +{ + if (y == 0) + return complex (1.0); + complex r (1.0); + complex x (xin); + if (y < 0) + { + y = -y; + x = 1/x; + } + for (;;) + { + if (y & 1) + r *= x; + if (y >>= 1) + x *= x; + else + return r; + } +} + +template complex +sqrt (const complex& x) +{ + FLOAT r = abs (x); + FLOAT nr, ni; + if (r == 0.0) + nr = ni = r; + else if (real (x) > 0) + { + nr = sqrt (0.5 * (r + real (x))); + ni = imag (x) / nr / 2; + } + else + { + ni = sqrt (0.5 * (r - real (x))); + if (imag (x) < 0) + ni = - ni; + nr = imag (x) / ni / 2; + } + return complex (nr, ni); +} +} // extern "C++" diff --git a/libstdc++/std/complext.h b/libstdc++/std/complext.h new file mode 100644 index 000000000000..57976f002ce2 --- /dev/null +++ b/libstdc++/std/complext.h @@ -0,0 +1,423 @@ +// The template and inlines for the -*- C++ -*- complex number classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __COMPLEXT__ +#define __COMPLEXT__ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include + +#if ! defined (__GNUG__) && ! defined (__attribute__) +#define __attribute__(foo) /* Ignore. */ +#endif + +class istream; +class ostream; + +extern "C++" { +template +class complex +{ +public: + complex (_FLT r = 0, _FLT i = 0): re (r), im (i) { } + complex& operator += (const complex&); + complex& operator -= (const complex&); + complex& operator *= (const complex&); + complex& operator /= (const complex&); + _FLT real () const { return re; } + _FLT imag () const { return im; } +private: + _FLT re, im; + + friend complex& __doapl (complex *, const complex&); + friend complex& __doami (complex *, const complex&); + friend complex& __doaml (complex *, const complex&); + friend complex& __doadv (complex *, const complex&); + + // These functions are specified as friends for purposes of name injection; + // they do not actually reference private members. + friend _FLT real (const complex&) __attribute__ ((const)); + friend _FLT imag (const complex&) __attribute__ ((const)); + friend complex operator + (const complex&, const complex&) __attribute__ ((const)); + friend complex operator + (const complex&, _FLT) __attribute__ ((const)); + friend complex operator + (_FLT, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, _FLT) __attribute__ ((const)); + friend complex operator - (_FLT, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, _FLT) __attribute__ ((const)); + friend complex operator * (_FLT, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, _FLT) __attribute__ ((const)); + friend complex operator / (_FLT, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, _FLT) __attribute__ ((const)); + friend bool operator == (_FLT, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, _FLT) __attribute__ ((const)); + friend bool operator != (_FLT, const complex&) __attribute__ ((const)); + friend complex polar (_FLT, _FLT) __attribute__ ((const)); + friend complex pow (const complex&, const complex&) __attribute__ ((const)); + friend complex pow (const complex&, _FLT) __attribute__ ((const)); + friend complex pow (const complex&, int) __attribute__ ((const)); + friend complex pow (_FLT, const complex&) __attribute__ ((const)); + friend istream& operator>> (istream&, complex&); + friend ostream& operator<< (ostream&, const complex&); +}; + +// Declare specializations. +class complex; +class complex; +class complex; + +template +inline complex<_FLT>& +__doapl (complex<_FLT>* ths, const complex<_FLT>& r) +{ + ths->re += r.re; + ths->im += r.im; + return *ths; +} +template +inline complex<_FLT>& +complex<_FLT>::operator += (const complex<_FLT>& r) +{ + return __doapl (this, r); +} + +template +inline complex<_FLT>& +__doami (complex<_FLT>* ths, const complex<_FLT>& r) +{ + ths->re -= r.re; + ths->im -= r.im; + return *ths; +} +template +inline complex<_FLT>& +complex<_FLT>::operator -= (const complex<_FLT>& r) +{ + return __doami (this, r); +} + +template +inline complex<_FLT>& +__doaml (complex<_FLT>* ths, const complex<_FLT>& r) +{ + _FLT f = ths->re * r.re - ths->im * r.im; + ths->im = ths->re * r.im + ths->im * r.re; + ths->re = f; + return *ths; +} +template +inline complex<_FLT>& +complex<_FLT>::operator *= (const complex<_FLT>& r) +{ + return __doaml (this, r); +} + +template complex<_FLT>& + __doadv (complex<_FLT>* ths, const complex<_FLT>& r); + +template +inline complex<_FLT>& +complex<_FLT>::operator /= (const complex<_FLT>& r) +{ + return __doadv (this, r); +} + +template inline _FLT +imag (const complex<_FLT>& x) __attribute__ ((const)); + +template inline _FLT +imag (const complex<_FLT>& x) +{ + return x.imag (); +} + +template inline _FLT +real (const complex<_FLT>& x) __attribute__ ((const)); + +template inline _FLT +real (const complex<_FLT>& x) +{ + return x.real (); +} + +template inline complex<_FLT> +operator + (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline complex<_FLT> +operator + (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return complex<_FLT> (real (x) + real (y), imag (x) + imag (y)); +} + +template inline complex<_FLT> +operator + (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template inline complex<_FLT> +operator + (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) + y, imag (x)); +} + +template inline complex<_FLT> +operator + (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline complex<_FLT> +operator + (_FLT x, const complex<_FLT>& y) +{ + return complex<_FLT> (x + real (y), imag (y)); +} + +template inline complex<_FLT> +operator - (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline complex<_FLT> +operator - (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return complex<_FLT> (real (x) - real (y), imag (x) - imag (y)); +} + +template inline complex<_FLT> +operator - (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template inline complex<_FLT> +operator - (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) - y, imag (x)); +} + +template inline complex<_FLT> +operator - (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline complex<_FLT> +operator - (_FLT x, const complex<_FLT>& y) +{ + return complex<_FLT> (x - real (y), - imag (y)); +} + +template inline complex<_FLT> +operator * (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline complex<_FLT> +operator * (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return complex<_FLT> (real (x) * real (y) - imag (x) * imag (y), + real (x) * imag (y) + imag (x) * real (y)); +} + +template inline complex<_FLT> +operator * (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template inline complex<_FLT> +operator * (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) * y, imag (x) * y); +} + +template inline complex<_FLT> +operator * (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline complex<_FLT> +operator * (_FLT x, const complex<_FLT>& y) +{ + return complex<_FLT> (x * real (y), x * imag (y)); +} + +template complex<_FLT> +operator / (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template complex<_FLT> +operator / (const complex<_FLT>& x, _FLT y) +{ + return complex<_FLT> (real (x) / y, imag (x) / y); +} + +template inline complex<_FLT> +operator + (const complex<_FLT>& x) __attribute__ ((const)); + +template inline complex<_FLT> +operator + (const complex<_FLT>& x) +{ + return x; +} + +template inline complex<_FLT> +operator - (const complex<_FLT>& x) __attribute__ ((const)); + +template inline complex<_FLT> +operator - (const complex<_FLT>& x) +{ + return complex<_FLT> (-real (x), -imag (x)); +} + +template inline bool +operator == (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline bool +operator == (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return real (x) == real (y) && imag (x) == imag (y); +} + +template inline bool +operator == (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template inline bool +operator == (const complex<_FLT>& x, _FLT y) +{ + return real (x) == y && imag (x) == 0; +} + +template inline bool +operator == (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline bool +operator == (_FLT x, const complex<_FLT>& y) +{ + return x == real (y) && imag (y) == 0; +} + +template inline bool +operator != (const complex<_FLT>& x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline bool +operator != (const complex<_FLT>& x, const complex<_FLT>& y) +{ + return real (x) != real (y) || imag (x) != imag (y); +} + +template inline bool +operator != (const complex<_FLT>& x, _FLT y) __attribute__ ((const)); + +template inline bool +operator != (const complex<_FLT>& x, _FLT y) +{ + return real (x) != y || imag (x) != 0; +} + +template inline bool +operator != (_FLT x, const complex<_FLT>& y) __attribute__ ((const)); + +template inline bool +operator != (_FLT x, const complex<_FLT>& y) +{ + return x != real (y) || imag (y) != 0; +} + +// Some targets don't provide a prototype for hypot when -ansi. +extern "C" double hypot (double, double) __attribute__ ((const)); + +template inline _FLT +abs (const complex<_FLT>& x) __attribute__ ((const)); + +template inline _FLT +abs (const complex<_FLT>& x) +{ + return hypot (real (x), imag (x)); +} + +template inline _FLT +arg (const complex<_FLT>& x) __attribute__ ((const)); + +template inline _FLT +arg (const complex<_FLT>& x) +{ + return atan2 (imag (x), real (x)); +} + +template inline complex<_FLT> +polar (_FLT r, _FLT t) __attribute__ ((const)); + +template inline complex<_FLT> +polar (_FLT r, _FLT t) +{ + return complex<_FLT> (r * cos (t), r * sin (t)); +} + +template inline complex<_FLT> +conj (const complex<_FLT>& x) __attribute__ ((const)); + +template inline complex<_FLT> +conj (const complex<_FLT>& x) +{ + return complex<_FLT> (real (x), -imag (x)); +} + +template inline _FLT +norm (const complex<_FLT>& x) __attribute__ ((const)); + +template inline _FLT +norm (const complex<_FLT>& x) +{ + return real (x) * real (x) + imag (x) * imag (x); +} + +// Declarations of templates in complext.ccI + +template complex<_FLT> + operator / (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + operator / (_FLT, const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + cos (const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + cosh (const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + exp (const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + log (const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + pow (const complex<_FLT>&, const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + pow (const complex<_FLT>&, _FLT) __attribute__ ((const)); +template complex<_FLT> + pow (const complex<_FLT>&, int) __attribute__ ((const)); +template complex<_FLT> + pow (_FLT, const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + sin (const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + sinh (const complex<_FLT>&) __attribute__ ((const)); +template complex<_FLT> + sqrt (const complex<_FLT>&) __attribute__ ((const)); + +template istream& operator >> (istream&, complex<_FLT>&); +template ostream& operator << (ostream&, const complex<_FLT>&); +} // extern "C++" + +// Specializations and such + +#include +#include +#include + +#endif diff --git a/libstdc++/std/dcomplex.h b/libstdc++/std/dcomplex.h new file mode 100644 index 000000000000..fde3f09ca5c1 --- /dev/null +++ b/libstdc++/std/dcomplex.h @@ -0,0 +1,94 @@ +// The -*- C++ -*- double_complex class. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __DCOMPLEX__ +#define __DCOMPLEX__ + +#ifdef __GNUG__ +#pragma interface "dcomplex" +#endif + +extern "C++" { +class complex +{ +public: + complex (double r = 0, double i = 0): re (r), im (i) { } + complex (const complex& r): re (r.real ()), im (r.imag ()) { } + explicit complex (const complex& r); + + complex& operator+= (const complex& r) { return __doapl (this, r); } + complex& operator-= (const complex& r) { return __doami (this, r); } + complex& operator*= (const complex& r) { return __doaml (this, r); } + complex& operator/= (const complex& r) { return __doadv (this, r); } + + double real () const { return re; } + double imag () const { return im; } +private: + double re, im; + + friend complex& __doapl (complex *, const complex&); + friend complex& __doami (complex *, const complex&); + friend complex& __doaml (complex *, const complex&); + friend complex& __doadv (complex *, const complex&); + + // These functions are specified as friends for purposes of name injection; + // they do not actually reference private members. + friend double real (const complex& x) { return x.real (); } + friend double imag (const complex& x) { return x.imag (); } + friend complex operator + (const complex&, const complex&) __attribute__ ((const)); + friend complex operator + (const complex&, double) __attribute__ ((const)); + friend complex operator + (double, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, double) __attribute__ ((const)); + friend complex operator - (double, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, double) __attribute__ ((const)); + friend complex operator * (double, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, double) __attribute__ ((const)); + friend complex operator / (double, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, double) __attribute__ ((const)); + friend bool operator == (double, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, double) __attribute__ ((const)); + friend bool operator != (double, const complex&) __attribute__ ((const)); + friend complex polar (double, double) __attribute__ ((const)); + friend complex pow (const complex&, const complex&) __attribute__ ((const)); + friend complex pow (const complex&, double) __attribute__ ((const)); + friend complex pow (const complex&, int) __attribute__ ((const)); + friend complex pow (double, const complex&) __attribute__ ((const)); + friend istream& operator>> (istream&, complex&); + friend ostream& operator<< (ostream&, const complex&); +}; + +inline complex::complex (const complex& r) +: re (r.real ()), im (r.imag ()) +{ } +} // extern "C++" + +#endif diff --git a/libstdc++/std/fcomplex.h b/libstdc++/std/fcomplex.h new file mode 100644 index 000000000000..3a389e08a76a --- /dev/null +++ b/libstdc++/std/fcomplex.h @@ -0,0 +1,90 @@ +// The -*- C++ -*- float_complex class. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __FCOMPLEX__ +#define __FCOMPLEX__ + +#ifdef __GNUG__ +#pragma interface "fcomplex" +#endif + +extern "C++" { +class complex +{ +public: + complex (float r = 0, float i = 0): re (r), im (i) { } + explicit complex (const complex& r); + explicit complex (const complex& r); + + complex& operator+= (const complex& r) { return __doapl (this, r); } + complex& operator-= (const complex& r) { return __doami (this, r); } + complex& operator*= (const complex& r) { return __doaml (this, r); } + complex& operator/= (const complex& r) { return __doadv (this, r); } + + float real () const { return re; } + float imag () const { return im; } +private: + float re, im; + + friend complex& __doapl (complex *, const complex&); + friend complex& __doami (complex *, const complex&); + friend complex& __doaml (complex *, const complex&); + friend complex& __doadv (complex *, const complex&); + + // These functions are specified as friends for purposes of name injection; + // they do not actually reference private members. + friend float real (const complex& x) { return x.real (); } + friend float imag (const complex& x) { return x.imag (); } + friend complex operator + (const complex&, const complex&) __attribute__ ((const)); + friend complex operator + (const complex&, float) __attribute__ ((const)); + friend complex operator + (float, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, float) __attribute__ ((const)); + friend complex operator - (float, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, float) __attribute__ ((const)); + friend complex operator * (float, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, float) __attribute__ ((const)); + friend complex operator / (float, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, float) __attribute__ ((const)); + friend bool operator == (float, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, float) __attribute__ ((const)); + friend bool operator != (float, const complex&) __attribute__ ((const)); + friend complex polar (float, float) __attribute__ ((const)); + friend complex pow (const complex&, const complex&) __attribute__ ((const)); + friend complex pow (const complex&, float) __attribute__ ((const)); + friend complex pow (const complex&, int) __attribute__ ((const)); + friend complex pow (float, const complex&) __attribute__ ((const)); + friend istream& operator>> (istream&, complex&); + friend ostream& operator<< (ostream&, const complex&); +}; +} // extern "C++" + +#endif diff --git a/libstdc++/std/ldcomplex.h b/libstdc++/std/ldcomplex.h new file mode 100644 index 000000000000..9feb30326bd2 --- /dev/null +++ b/libstdc++/std/ldcomplex.h @@ -0,0 +1,98 @@ +// The -*- C++ -*- long_double_complex class. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification in the 27 May 1994 +// C++ working paper, ANSI document X3J16/94-0098. + +#ifndef __LDCOMPLEX__ +#define __LDCOMPLEX__ + +#ifdef __GNUG__ +#pragma interface "ldcomplex" +#endif + +extern "C++" { +class complex +{ +public: + complex (long double r = 0, long double i = 0): re (r), im (i) { } + complex (const complex& r): re (r.real ()), im (r.imag ()) { } + complex (const complex& r): re (r.real ()), im (r.imag ()) { } + + complex& operator+= (const complex& r) { return __doapl (this, r); } + complex& operator-= (const complex& r) { return __doami (this, r); } + complex& operator*= (const complex& r) { return __doaml (this, r); } + complex& operator/= (const complex& r) { return __doadv (this, r); } + + long double real () const { return re; } + long double imag () const { return im; } +private: + long double re, im; + + friend complex& __doapl (complex *, const complex&); + friend complex& __doami (complex *, const complex&); + friend complex& __doaml (complex *, const complex&); + friend complex& __doadv (complex *, const complex&); + + // These functions are specified as friends for purposes of name injection; + // they do not actually reference private members. + friend long double real (const complex& x) { return x.real (); } + friend long double imag (const complex& x) { return x.imag (); } + friend complex operator + (const complex&, const complex&) __attribute__ ((const)); + friend complex operator + (const complex&, long double) __attribute__ ((const)); + friend complex operator + (long double, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, const complex&) __attribute__ ((const)); + friend complex operator - (const complex&, long double) __attribute__ ((const)); + friend complex operator - (long double, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, const complex&) __attribute__ ((const)); + friend complex operator * (const complex&, long double) __attribute__ ((const)); + friend complex operator * (long double, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, const complex&) __attribute__ ((const)); + friend complex operator / (const complex&, long double) __attribute__ ((const)); + friend complex operator / (long double, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, const complex&) __attribute__ ((const)); + friend bool operator == (const complex&, long double) __attribute__ ((const)); + friend bool operator == (long double, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, const complex&) __attribute__ ((const)); + friend bool operator != (const complex&, long double) __attribute__ ((const)); + friend bool operator != (long double, const complex&) __attribute__ ((const)); + friend complex polar (long double, long double) __attribute__ ((const)); + friend complex pow (const complex&, const complex&) __attribute__ ((const)); + friend complex pow (const complex&, long double) __attribute__ ((const)); + friend complex pow (const complex&, int) __attribute__ ((const)); + friend complex pow (long double, const complex&) __attribute__ ((const)); + friend istream& operator>> (istream&, complex&); + friend ostream& operator<< (ostream&, const complex&); +}; + +inline complex::complex (const complex& r) +: re (r.real ()), im (r.imag ()) +{ } + +inline complex::complex (const complex& r) +: re (r.real ()), im (r.imag ()) +{ } +} // extern "C++" + +#endif diff --git a/libstdc++/std/straits.h b/libstdc++/std/straits.h new file mode 100644 index 000000000000..c80e7ab7a681 --- /dev/null +++ b/libstdc++/std/straits.h @@ -0,0 +1,161 @@ +// Character traits template for the -*- C++ -*- string classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. + +#ifndef __STRING_CHAR_TRAITS__ +#define __STRING_CHAR_TRAITS__ + +#ifdef __GNUG__ +// For string_char_traits +#pragma interface "std/straits.h" +#endif + +#include + +extern "C++" { +template +struct string_char_traits { + typedef charT char_type; // for users to acquire the basic character type + + // constraints + + static void assign (char_type& c1, const char_type& c2) + { c1 = c2; } + static bool eq (const char_type& c1, const char_type& c2) + { return (c1 == c2); } + static bool ne (const char_type& c1, const char_type& c2) + { return !(c1 == c2); } + static bool lt (const char_type& c1, const char_type& c2) + { return (c1 < c2); } + static char_type eos () { return char_type(); } // the null character + static bool is_del(char_type a) { return 0; } + // characteristic function for delimiters of charT + + // speed-up functions + + static int compare (const char_type* s1, const char_type* s2, size_t n) + { + size_t i; + for (i = 0; i < n; ++i) + if (ne (s1[i], s2[i])) + return lt (s1[i], s2[i]) ? -1 : 1; + + return 0; + } + + static size_t length (const char_type* s) + { + size_t l = 0; + while (ne (*s++, eos ())) + ++l; + return l; + } + + static char_type* copy (char_type* s1, const char_type* s2, size_t n) + { + for (; n--; ) + assign (s1[n], s2[n]); + return s1; + } + + static char_type* move (char_type* s1, const char_type* s2, size_t n) + { + char_type a[n]; + size_t i; + for (i = 0; i < n; ++i) + assign (a[i], s2[i]); + for (i = 0; i < n; ++i) + assign (s1[i], a[i]); + return s1; + } + + static char_type* set (char_type* s1, const char_type& c, size_t n) + { + for (; n--; ) + assign (s1[n], c); + return s1; + } +}; + +class istream; +class ostream; +#include +#include + +struct string_char_traits { + typedef char char_type; + + static void assign (char_type& c1, const char_type& c2) + { c1 = c2; } + static bool eq (const char_type & c1, const char_type& c2) + { return (c1 == c2); } + static bool ne (const char_type& c1, const char_type& c2) + { return (c1 != c2); } + static bool lt (const char_type& c1, const char_type& c2) + { return (c1 < c2); } + static char_type eos () { return 0; } + static bool is_del(char_type a) { return isspace(a); } + + static int compare (const char_type* s1, const char_type* s2, size_t n) + { return memcmp (s1, s2, n); } + static size_t length (const char_type* s) + { return strlen (s); } + static char_type* copy (char_type* s1, const char_type* s2, size_t n) + { return (char_type*) memcpy (s1, s2, n); } + static char_type* move (char_type* s1, const char_type* s2, size_t n) + { return (char_type*) memmove (s1, s2, n); } + static char_type* set (char_type* s1, const char_type& c, size_t n) + { return (char_type*) memset (s1, c, n); } +}; + +#if 0 +#include +struct string_char_traits { + typedef wchar_t char_type; + + static void assign (char_type& c1, const char_type& c2) + { c1 = c2; } + static bool eq (const char_type & c1, const char_type& c2) + { return (c1 == c2); } + static bool ne (const char_type& c1, const char_type& c2) + { return (c1 != c2); } + static bool lt (const char_type& c1, const char_type& c2) + { return (c1 < c2); } + static char_type eos () { return 0; } + static bool is_del(char_type a) { return iswspace(a); } + + static int compare (const char_type* s1, const char_type* s2, size_t n) + { return wmemcmp (s1, s2, n); } + static size_t length (const char_type* s) + { return wcslen (s); } + static char_type* copy (char_type* s1, const char_type* s2, size_t n) + { return wmemcpy (s1, s2, n); } + static char_type* set (char_type* s1, const char_type& c, size_t n) + { return wmemset (s1, c, n); } +}; +#endif +} // extern "C++" +#endif diff --git a/libstdc++/stdexcept b/libstdc++/stdexcept new file mode 100644 index 000000000000..96be4d283b3d --- /dev/null +++ b/libstdc++/stdexcept @@ -0,0 +1,93 @@ +// Methods for Exception Support for -*- C++ -*- +// Copyright (C) 1994, 1995, 1997 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; 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. + +// Written by Mike Stump based upon the specification in the 20 September 1994 +// C++ working paper, ANSI document X3J16/94-0158. + +#ifndef __STDEXCEPT__ +#define __STDEXCEPT__ + +#ifdef __GNUG__ +#pragma interface "stdexcept" +#endif + +#include +#include + +extern "C++" { + +class logic_error : public exception { + string _what; +public: + logic_error(const string& what_arg): _what (what_arg) { } + virtual const char* what () const { return _what.c_str (); } +}; + +class domain_error : public logic_error { +public: + domain_error (const string& what_arg): logic_error (what_arg) { } +}; + +class invalid_argument : public logic_error { +public: + invalid_argument (const string& what_arg): logic_error (what_arg) { } +}; + +class length_error : public logic_error { +public: + length_error (const string& what_arg): logic_error (what_arg) { } +}; + +class out_of_range : public logic_error { +public: + out_of_range (const string& what_arg): logic_error (what_arg) { } +}; + +class runtime_error : public exception { + string _what; +public: + runtime_error(const string& what_arg): _what (what_arg) { } + virtual const char* what () const { return _what.c_str (); } +protected: + runtime_error(): exception () { } +}; + +class range_error : public runtime_error { +public: + range_error (const string& what_arg): runtime_error (what_arg) { } +}; + +class overflow_error : public runtime_error { +public: + overflow_error (const string& what_arg): runtime_error (what_arg) { } +}; + +class underflow_error : public runtime_error { +public: + underflow_error (const string& what_arg): runtime_error (what_arg) { } +}; + +} // extern "C++" + +#endif diff --git a/libstdc++/stdexcepti.cc b/libstdc++/stdexcepti.cc new file mode 100644 index 000000000000..1ab8d8890439 --- /dev/null +++ b/libstdc++/stdexcepti.cc @@ -0,0 +1,8 @@ +// Implementation file for Exception Support for -*- C++ -*- +// This file is part of the GNU ANSI C++ Library. + +#ifdef __GNUG__ +#pragma implementation "stdexcept" +#endif + +#include diff --git a/libstdc++/stl.h b/libstdc++/stl.h new file mode 100644 index 000000000000..4b270742c9cf --- /dev/null +++ b/libstdc++/stl.h @@ -0,0 +1,15 @@ +// -*- C++ -*- compatibility header. +// This file is part of the GNU ANSI C++ Library. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/libstdc++/stl/ChangeLog b/libstdc++/stl/ChangeLog new file mode 100644 index 000000000000..b519b1811f35 --- /dev/null +++ b/libstdc++/stl/ChangeLog @@ -0,0 +1,192 @@ +Tue Aug 5 17:06:01 1997 Jason Merrill + + * deque.h, function.h, hashtable.h, list.h, rope.h, ropeimpl.h, + tree.h: Update to July 31 SGI release. + +Fri Jul 18 10:06:56 1997 Jason Merrill + + * algo.h, defalloc.h, hashtable.h, rope.h, ropeimpl.h, slist.h: + Update to June 30 SGI release. + +Fri Jul 04 02:17:15 1997 Ulrich Drepper + + * tree.h (rb_tree): Reverse order of member initializations + to prevent warnings. + +Sun Jun 15 18:17:21 1997 Jason Merrill + + * *.h: Update to 6/13 SGI release. + +Fri May 23 10:56:18 1997 Jason Merrill + + * stl_config.h: Add support for exceptions with g++. + + * *.h: Update to 5/8 SGI release. + +Thu Apr 24 19:00:23 1997 Jason Merrill + + * *.h: Update to 3/24 SGI release. + +Wed Feb 19 18:19:18 1997 Jason Merrill + + * *.h: Update to 2/18 SGI release. + + * bool.h: Lose. + +Mon Feb 10 16:33:23 1997 Jason Merrill + + * alloc.h: Don't define __USE_MALLOC for g++. + * bool.h: Lose g++ case. + + * *.h: Update to 2/4 SGI release. + +Mon Jan 13 14:39:16 1997 Jason Merrill + + * *.h: Update to 1/8 SGI release. + +Mon Sep 30 17:56:43 1996 Jason Merrill + + * alloc.h (__unlock): Never use __lock_release. + +Fri Sep 27 19:03:06 1996 Jason Merrill + + * alloc.h (__default_alloc_template): lock is a friend. + +Thu Sep 19 20:10:37 1996 Jason Merrill + + Propagate these changes to new STL code: + * tree.h: Rearrange member initializers in rb_tree constructors. + * vector.h (insert): Cast iterator difference to size_type to + avoid warning. + + * *.h: Update to SGI snapshot (fixed). + * *.c, Makefile.in, configure.in: Removed. + +Sat Sep 14 09:43:06 1996 Jason Merrill + + * deque.h, list.h, tree.h: Remove kludge obsoleted by new + overloading code. + +Sat Aug 10 14:59:50 1996 Jason Merrill + + * tempbuf.cc (__stl_temp_buffer): Align like a pointer. + +Wed Jun 26 13:00:44 1996 Jason Merrill + + * iterator.h: Add default template parameters. + +Wed Apr 24 10:45:22 1996 Doug Evans + + * Makefile.in (tempbuf.o,random.o): Add rules for SunOS VPATH. + +Fri Apr 5 17:52:31 1996 Per Bothner + + * configure.in (EXTRA_MOSTLYCLEAN): New, to remove stl.list. + +Fri Mar 22 14:58:30 1996 Jason Merrill + + Propagate these changes to new STL code: + * tree.h: Rearrange member initializers in rb_tree constructors. + * vector.h (insert): Cast iterator difference to size_type to + avoid warning. + +Sun Mar 10 07:49:03 1996 Jason Merrill + + * deque.h (distance_type): Add overload for g++. + From Joe Buck. + +Thu Feb 22 14:07:12 1996 Jason Merrill + + * bool.h: Revert. + * algo.h bvector.h deque.h function.h iterator.h list.h + pair.h stack.h tree.h vector.h: Wrap #include with + #ifndef __GNUG__. + * defalloc.h list.h deque.h tree.h: Use __GNUG__ to control + workarounds. + +Wed Feb 21 17:13:02 1996 Jason Merrill + + * bool.h (TRUE, FALSE): Define for people expecting the bool.h + from libg++. Is this a good idea? + +Tue Feb 20 18:40:02 1996 Jason Merrill + + * algo.h bool.h bvector.h defalloc.h deque.h function.h heap.h + iterator.h list.h map.h pair.h random.cc stack.h tree.c tree.h + vector.h: Revert to HP release with workarounds for missing + overloading functionality. + * Makefile.in (STL_OBJECTS): Remove tree.o. + +Thu Nov 9 17:05:23 1995 Jason Merrill + + * algo.h algobase.h bvector.h defalloc.h deque.h function.h heap.h + iterator.h list.h map.h multimap.h multiset.h pair.h projectn.h + set.h stack.h tempbuf.h tree.h vector.h: Wrap #include + with #ifndef __GNUG__. + +Thu Nov 2 17:05:44 1995 Jason Merrill + + * deque.h (deque::insert): Fix merge typo. + * vector.h (value_type): Lose. + +Thu Nov 2 14:33:47 1995 Per Bothner + + * algo.h, algobase.h, deque.h, function.h, list.h, pair.h, random.cc: + Merge in Oct 31 1995 release from HP. + +Fri Aug 11 17:11:12 1995 Per Bothner + + * list.h: Avoid duplicate construction and destruction of list_nodes. + Patch from Klamer Schutte . + +Fri Aug 11 16:45:18 1995 Per Bothner + + * algo.h, algobase.h, deque.h: Merged in Jul 12 1995 release from HP. + +Mon Jun 5 18:38:56 1995 Jason Merrill + + * Makefile.in (stl.list): Depend on stamp-picdir. + +Wed May 17 02:30:47 1995 Jason Merrill + + * tree.h: Rearrange member initializers in rb_tree constructors. + + * Update to HP's February 7, 1995 release. + +Fri May 5 10:45:31 1995 Mike Stump + + * random.cc (seed): Move `for' decl out of `for' statement. + +Wed Apr 26 13:09:16 1995 Jason Merrill + + * configure.in (XCXXINCLUDES): Rename. + +Wed Mar 29 19:24:56 1995 Jason Merrill + + * tree.h (insert): Return a value. + + * vector.h (insert): Cast iterator difference to size_type to + avoid warning. + +Sun Feb 12 09:12:17 1995 Mike Stump + + * tree.h (rb_tree::max_size): Add definition when using GNU + workaround. + +Thu Jan 12 01:37:42 1995 deanm@medulla.LABS.TEK.COM (Dean Messing) + + * configure.in (LIBDIR): Set to yes. + +Fri Dec 30 18:26:20 1994 Mike Stump + + * iterator.h: Add default template parameters where possible. + +Fri Dec 30 16:29:39 1994 Mike Stump + + * algo.h: Change rand to __rand to fix make check on linux systems. + +Tue Nov 29 15:30:30 1994 Per Bothner + + * Initial check-in, based on HP's October 21, 1994. + + diff --git a/libstdc++/stl/README b/libstdc++/stl/README new file mode 100644 index 000000000000..81bc7cf06ab7 --- /dev/null +++ b/libstdc++/stl/README @@ -0,0 +1,16 @@ +This directory contains an SGI release of the C++ Standard Template +Library, slightly modified to work with g++ (version 2.8.0 or newer). + +Note that this is based on a pre-Draft Standard for C++. +Things are likely to change. For example, the header file names +are very likely to change. The Allocator interface will change. Etc, etc. +CYGNUS MAKES NO COMMITTMENT (yet) TO SUPPORT BACKWARD COMPATIBILITY FOR STL. + +For examples if things that should work, look in the ../tests directory. + +DOCUMENTATION: +See http://www.sgi.com/Technology/STL/ or http://www.dinkumware.com/ +on the World-Wide Web. + + --Jason Merrill +Cygnus Support jason@cygnus.com diff --git a/libstdc++/stl/algo.h b/libstdc++/stl/algo.h new file mode 100644 index 000000000000..69f43c17a64c --- /dev/null +++ b/libstdc++/stl/algo.h @@ -0,0 +1,2665 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_ALGO_H +#define __SGI_STL_ALGO_H + +#include +#include +#include +#include +#include + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma set woff 1209 +#endif + +template +inline const T& __median(const T& a, const T& b, const T& c) { + if (a < b) + if (b < c) + return b; + else if (a < c) + return c; + else + return a; + else if (a < c) + return a; + else if (b < c) + return c; + else + return b; +} + +template +inline const T& __median(const T& a, const T& b, const T& c, Compare comp) { + if (comp(a, b)) + if (comp(b, c)) + return b; + else if (comp(a, c)) + return c; + else + return a; + else if (comp(a, c)) + return a; + else if (comp(b, c)) + return c; + else + return b; +} + +template +Function for_each(InputIterator first, InputIterator last, Function f) { + for ( ; first != last; ++first) + f(*first); + return f; +} + +template +InputIterator find(InputIterator first, InputIterator last, const T& value) { + while (first != last && *first != value) ++first; + return first; +} + +template +InputIterator find_if(InputIterator first, InputIterator last, + Predicate pred) { + while (first != last && !pred(*first)) ++first; + return first; +} + +template +ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last) { + if (first == last) return last; + ForwardIterator next = first; + while(++next != last) { + if (*first == *next) return first; + first = next; + } + return last; +} + +template +ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last, + BinaryPredicate binary_pred) { + if (first == last) return last; + ForwardIterator next = first; + while(++next != last) { + if (binary_pred(*first, *next)) return first; + first = next; + } + return last; +} + +template +void count(InputIterator first, InputIterator last, const T& value, + Size& n) { + for ( ; first != last; ++first) + if (*first == value) + ++n; +} + +template +void count_if(InputIterator first, InputIterator last, Predicate pred, + Size& n) { + for ( ; first != last; ++first) + if (pred(*first)) + ++n; +} + +#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION + +template +iterator_traits::difference_type +count(InputIterator first, InputIterator last, const T& value) { + iterator_traits::difference_type n = 0; + for ( ; first != last; ++first) + if (*first == value) + ++n; + return n; +} + +template +iterator_traits::difference_type +count_if(InputIterator first, InputIterator last, Predicate pred) { + iterator_traits::difference_type n = 0; + for ( ; first != last; ++first) + if (pred(*first)) + ++n; + return n; +} + + +#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + +template +ForwardIterator1 __search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + Distance1*, Distance2*) { + Distance1 d1 = 0; + distance(first1, last1, d1); + Distance2 d2 = 0; + distance(first2, last2, d2); + + if (d1 < d2) return last1; + + ForwardIterator1 current1 = first1; + ForwardIterator2 current2 = first2; + + while (current2 != last2) + if (*current1 == *current2) { + ++current1; + ++current2; + } + else { + if (d1 == d2) + return last1; + else { + current1 = ++first1; + current2 = first2; + --d1; + } + } + return first1; +} + +template +inline ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2) +{ + return __search(first1, last1, first2, last2, distance_type(first1), + distance_type(first2)); +} + +template +ForwardIterator1 __search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate binary_pred, Distance1*, Distance2*) { + Distance1 d1 = 0; + distance(first1, last1, d1); + Distance2 d2 = 0; + distance(first2, last2, d2); + + if (d1 < d2) return last1; + + ForwardIterator1 current1 = first1; + ForwardIterator2 current2 = first2; + + while (current2 != last2) + if (binary_pred(*current1, *current2)) { + ++current1; + ++current2; + } + else { + if (d1 == d2) + return last1; + else { + current1 = ++first1; + current2 = first2; + --d1; + } + } + return first1; +} + +template +inline ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2, ForwardIterator2 last2, + BinaryPredicate binary_pred) { + return __search(first1, last1, first2, last2, binary_pred, + distance_type(first1), distance_type(first2)); +} + +template +ForwardIterator2 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, + ForwardIterator2 first2) { + for ( ; first1 != last1; ++first1, ++first2) + iter_swap(first1, first2); + return first2; +} + +template +OutputIterator transform(InputIterator first, InputIterator last, + OutputIterator result, UnaryOperation op) { + for ( ; first != last; ++first, ++result) + *result = op(*first); + return result; +} + +template +OutputIterator transform(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, OutputIterator result, + BinaryOperation binary_op) { + for ( ; first1 != last1; ++first1, ++first2, ++result) + *result = binary_op(*first1, *first2); + return result; +} + +template +void replace(ForwardIterator first, ForwardIterator last, const T& old_value, + const T& new_value) { + for ( ; first != last; ++first) + if (*first == old_value) *first = new_value; +} + +template +void replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, + const T& new_value) { + for ( ; first != last; ++first) + if (pred(*first)) *first = new_value; +} + +template +OutputIterator replace_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& old_value, + const T& new_value) { + for ( ; first != last; ++first, ++result) + *result = *first == old_value ? new_value : *first; + return result; +} + +template +OutputIterator replace_copy_if(Iterator first, Iterator last, + OutputIterator result, Predicate pred, + const T& new_value) { + for ( ; first != last; ++first, ++result) + *result = pred(*first) ? new_value : *first; + return result; +} + +template +void generate(ForwardIterator first, ForwardIterator last, Generator gen) { + for ( ; first != last; ++first) + *first = gen(); +} + +template +OutputIterator generate_n(OutputIterator first, Size n, Generator gen) { + for ( ; n > 0; --n, ++first) + *first = gen(); + return first; +} + +template +OutputIterator remove_copy(InputIterator first, InputIterator last, + OutputIterator result, const T& value) { + for ( ; first != last; ++first) + if (*first != value) { + *result = *first; + ++result; + } + return result; +} + +template +OutputIterator remove_copy_if(InputIterator first, InputIterator last, + OutputIterator result, Predicate pred) { + for ( ; first != last; ++first) + if (!pred(*first)) { + *result = *first; + ++result; + } + return result; +} + +template +ForwardIterator remove(ForwardIterator first, ForwardIterator last, + const T& value) { + first = find(first, last, value); + ForwardIterator next = first; + return first == last ? first : remove_copy(++next, last, first, value); +} + +template +ForwardIterator remove_if(ForwardIterator first, ForwardIterator last, + Predicate pred) { + first = find_if(first, last, pred); + ForwardIterator next = first; + return first == last ? first : remove_copy_if(++next, last, first, pred); +} + +template +ForwardIterator __unique_copy(InputIterator first, InputIterator last, + ForwardIterator result, forward_iterator_tag) { + *result = *first; + while (++first != last) + if (*result != *first) *++result = *first; + return ++result; +} + +template +inline BidirectionalIterator __unique_copy(InputIterator first, + InputIterator last, + BidirectionalIterator result, + bidirectional_iterator_tag) { + return __unique_copy(first, last, result, forward_iterator_tag()); +} + +template +inline RandomAccessIterator __unique_copy(InputIterator first, + InputIterator last, + RandomAccessIterator result, + random_access_iterator_tag) { + return __unique_copy(first, last, result, forward_iterator_tag()); +} + +template +OutputIterator __unique_copy(InputIterator first, InputIterator last, + OutputIterator result, T*) { + T value = *first; + *result = value; + while (++first != last) + if (value != *first) { + value = *first; + *++result = value; + } + return ++result; +} + +template +inline OutputIterator __unique_copy(InputIterator first, InputIterator last, + OutputIterator result, + output_iterator_tag) { + return __unique_copy(first, last, result, value_type(first)); +} + +template +inline OutputIterator unique_copy(InputIterator first, InputIterator last, + OutputIterator result) { + if (first == last) return result; + return __unique_copy(first, last, result, iterator_category(result)); +} +template +ForwardIterator __unique_copy(InputIterator first, InputIterator last, + ForwardIterator result, + BinaryPredicate binary_pred, + forward_iterator_tag) { + *result = *first; + while (++first != last) + if (!binary_pred(*result, *first)) *++result = *first; + return ++result; +} + +template +inline BidirectionalIterator __unique_copy(InputIterator first, + InputIterator last, + BidirectionalIterator result, + BinaryPredicate binary_pred, + bidirectional_iterator_tag) { + return __unique_copy(first, last, result, binary_pred, + forward_iterator_tag()); +} + +template +inline RandomAccessIterator __unique_copy(InputIterator first, + InputIterator last, + RandomAccessIterator result, + BinaryPredicate binary_pred, + random_access_iterator_tag) { + return __unique_copy(first, last, result, binary_pred, + forward_iterator_tag()); +} + +template +OutputIterator __unique_copy(InputIterator first, InputIterator last, + OutputIterator result, + BinaryPredicate binary_pred, T*) { + T value = *first; + *result = value; + while (++first != last) + if (!binary_pred(value, *first)) { + value = *first; + *++result = value; + } + return ++result; +} + +template +inline OutputIterator __unique_copy(InputIterator first, InputIterator last, + OutputIterator result, + BinaryPredicate binary_pred, + output_iterator_tag) { + return __unique_copy(first, last, result, binary_pred, value_type(first)); +} + +template +inline OutputIterator unique_copy(InputIterator first, InputIterator last, + OutputIterator result, + BinaryPredicate binary_pred) { + if (first == last) return result; + return __unique_copy(first, last, result, binary_pred, + iterator_category(result)); +} + +template +ForwardIterator unique(ForwardIterator first, ForwardIterator last) { + first = adjacent_find(first, last); + return unique_copy(first, last, first); +} + +template +ForwardIterator unique(ForwardIterator first, ForwardIterator last, + BinaryPredicate binary_pred) { + first = adjacent_find(first, last, binary_pred); + return unique_copy(first, last, first, binary_pred); +} + +template +void __reverse(BidirectionalIterator first, BidirectionalIterator last, + bidirectional_iterator_tag) { + while (true) + if (first == last || first == --last) + return; + else + iter_swap(first++, last); +} + +template +void __reverse(RandomAccessIterator first, RandomAccessIterator last, + random_access_iterator_tag) { + while (first < last) iter_swap(first++, --last); +} + +template +inline void reverse(BidirectionalIterator first, BidirectionalIterator last) { + __reverse(first, last, iterator_category(first)); +} + +template +OutputIterator reverse_copy(BidirectionalIterator first, + BidirectionalIterator last, + OutputIterator result) { + while (first != last) { + --last; + *result = *last; + ++result; + } + return result; +} + +template +void __rotate(ForwardIterator first, ForwardIterator middle, + ForwardIterator last, Distance*, forward_iterator_tag) { + for (ForwardIterator i = middle; ;) { + iter_swap(first, i); + ++first; + ++i; + if (first == middle) { + if (i == last) return; + middle = i; + } + else if (i == last) + i = middle; + } +} + +template +void __rotate(BidirectionalIterator first, BidirectionalIterator middle, + BidirectionalIterator last, Distance*, + bidirectional_iterator_tag) { + reverse(first, middle); + reverse(middle, last); + reverse(first, last); +} + +template +EuclideanRingElement __gcd(EuclideanRingElement m, EuclideanRingElement n) +{ + while (n != 0) { + EuclideanRingElement t = m % n; + m = n; + n = t; + } + return m; +} + +template +void __rotate_cycle(RandomAccessIterator first, RandomAccessIterator last, + RandomAccessIterator initial, Distance shift, T*) { + T value = *initial; + RandomAccessIterator ptr1 = initial; + RandomAccessIterator ptr2 = ptr1 + shift; + while (ptr2 != initial) { + *ptr1 = *ptr2; + ptr1 = ptr2; + if (last - ptr2 > shift) + ptr2 += shift; + else + ptr2 = first + (shift - (last - ptr2)); + } + *ptr1 = value; +} + +template +void __rotate(RandomAccessIterator first, RandomAccessIterator middle, + RandomAccessIterator last, Distance*, + random_access_iterator_tag) { + Distance n = __gcd(last - first, middle - first); + while (n--) + __rotate_cycle(first, last, first + n, middle - first, + value_type(first)); +} + +template +inline void rotate(ForwardIterator first, ForwardIterator middle, + ForwardIterator last) { + if (first == middle || middle == last) return; + __rotate(first, middle, last, distance_type(first), + iterator_category(first)); +} + +template +OutputIterator rotate_copy(ForwardIterator first, ForwardIterator middle, + ForwardIterator last, OutputIterator result) { + return copy(first, middle, copy(middle, last, result)); +} + +template +void __random_shuffle(RandomAccessIterator first, RandomAccessIterator last, + Distance*) { + if (first == last) return; + for (RandomAccessIterator i = first + 1; i != last; ++i) +#ifdef __STL_NO_DRAND48 + iter_swap(i, first + Distance(rand() % ((i - first) + 1))); +#else + iter_swap(i, first + Distance(lrand48() % ((i - first) + 1))); +#endif +} + +template +inline void random_shuffle(RandomAccessIterator first, + RandomAccessIterator last) { + __random_shuffle(first, last, distance_type(first)); +} + +template +void random_shuffle(RandomAccessIterator first, RandomAccessIterator last, + RandomNumberGenerator& rand) { + if (first == last) return; + for (RandomAccessIterator i = first + 1; i != last; ++i) + iter_swap(i, first + rand((i - first) + 1)); +} + +template +OutputIterator random_sample_n(ForwardIterator first, ForwardIterator last, + OutputIterator out, const Distance n) +{ + Distance remaining = 0; + distance(first, last, remaining); + Distance m = min(n, remaining); + + while (m > 0) { +#ifdef __STL_NO_DRAND48 + if (rand() % remaining < m) { +#else + if (lrand48() % remaining < m) { +#endif + *out = *first; + ++out; + --m; + } + + --remaining; + ++first; + } + return out; +} + +template +OutputIterator random_sample_n(ForwardIterator first, ForwardIterator last, + OutputIterator out, const Distance n, + RandomNumberGenerator& rand) +{ + Distance remaining = 0; + distance(first, last, remaining); + Distance m = min(n, remaining); + + while (m > 0) { + if (rand(remaining) < m) { + *out = *first; + ++out; + --m; + } + + --remaining; + ++first; + } + return out; +} + +template +RandomAccessIterator __random_sample(InputIterator first, InputIterator last, + RandomAccessIterator out, + const Distance n) +{ + Distance m = 0; + Distance t = n; + for ( ; first != last && m < n; ++m, ++first) + out[m] = *first; + + while (first != last) { + ++t; +#ifdef __STL_NO_DRAND48 + Distance M = rand() % t; +#else + Distance M = lrand48() % t; +#endif + if (M < n) + out[M] = *first; + ++first; + } + + return out + m; +} + +template +RandomAccessIterator __random_sample(InputIterator first, InputIterator last, + RandomAccessIterator out, + RandomNumberGenerator& rand, + const Distance n) +{ + Distance m = 0; + Distance t = n; + for ( ; first != last && m < n; ++m, ++first) + out[m] = *first; + + while (first != last) { + ++t; + Distance M = rand(t); + if (M < n) + out[M] = *first; + ++first; + } + + return out + m; +} + +template +inline RandomAccessIterator +random_sample(InputIterator first, InputIterator last, + RandomAccessIterator out_first, RandomAccessIterator out_last) +{ + return __random_sample(first, last, out_first, out_last - out_first); +} + +template +inline RandomAccessIterator +random_sample(InputIterator first, InputIterator last, + RandomAccessIterator out_first, RandomAccessIterator out_last, + RandomNumberGenerator& rand) +{ + return __random_sample(first, last, out_first, rand, out_last - out_first); +} + + + +template +BidirectionalIterator partition(BidirectionalIterator first, + BidirectionalIterator last, Predicate pred) { + while (true) { + while (true) + if (first == last) + return first; + else if (pred(*first)) + ++first; + else + break; + --last; + while (true) + if (first == last) + return first; + else if (!pred(*last)) + --last; + else + break; + iter_swap(first, last); + ++first; + } +} + +template +ForwardIterator __inplace_stable_partition(ForwardIterator first, + ForwardIterator last, + Predicate pred, Distance len) { + if (len == 1) return pred(*first) ? last : first; + ForwardIterator middle = first; + advance(middle, len / 2); + ForwardIterator + first_cut = __inplace_stable_partition(first, middle, pred, len / 2); + ForwardIterator + second_cut = __inplace_stable_partition(middle, last, pred, + len - len / 2); + rotate(first_cut, middle, second_cut); + len = 0; + distance(middle, second_cut, len); + advance(first_cut, len); + return first_cut; +} + +template +ForwardIterator __stable_partition_adaptive(ForwardIterator first, + ForwardIterator last, + Predicate pred, Distance len, + Pointer buffer, + Distance buffer_size) { + if (len <= buffer_size) { + ForwardIterator result1 = first; + Pointer result2 = buffer; + for ( ; first != last ; ++first) + if (pred(*first)) { + *result1 = *first; + ++result1; + } + else { + *result2 = *first; + ++result2; + } + copy(buffer, result2, result1); + return result1; + } + else { + ForwardIterator middle = first; + advance(middle, len / 2); + ForwardIterator first_cut = + __stable_partition_adaptive(first, middle, pred, len / 2, + buffer, buffer_size); + ForwardIterator second_cut = + __stable_partition_adaptive(middle, last, pred, len - len / 2, + buffer, buffer_size); + + rotate(first_cut, middle, second_cut); + len = 0; + distance(middle, second_cut, len); + advance(first_cut, len); + return first_cut; + } +} + +template +inline ForwardIterator __stable_partition_aux(ForwardIterator first, + ForwardIterator last, + Predicate pred, T*, Distance*) { + temporary_buffer buf(first, last); + if (buf.size() > 0) + return __stable_partition_adaptive(first, last, pred, + Distance(buf.requested_size()), + buf.begin(), buf.size()); + else + return __inplace_stable_partition(first, last, pred, + Distance(buf.requested_size())); +} + +template +inline ForwardIterator stable_partition(ForwardIterator first, + ForwardIterator last, + Predicate pred) { + if (first == last) + return first; + else + return __stable_partition_aux(first, last, pred, + value_type(first), distance_type(first)); +} + +template +RandomAccessIterator __unguarded_partition(RandomAccessIterator first, + RandomAccessIterator last, + T pivot) { + while (1) { + while (*first < pivot) ++first; + --last; + while (pivot < *last) --last; + if (!(first < last)) return first; + iter_swap(first, last); + ++first; + } +} + +template +RandomAccessIterator __unguarded_partition(RandomAccessIterator first, + RandomAccessIterator last, + T pivot, Compare comp) { + while (1) { + while (comp(*first, pivot)) ++first; + --last; + while (comp(pivot, *last)) --last; + if (!(first < last)) return first; + iter_swap(first, last); + ++first; + } +} + +const int __stl_threshold = 16; + + +template +void __unguarded_linear_insert(RandomAccessIterator last, T value) { + RandomAccessIterator next = last; + --next; + while (value < *next) { + *last = *next; + last = next; + --next; + } + *last = value; +} + +template +void __unguarded_linear_insert(RandomAccessIterator last, T value, + Compare comp) { + RandomAccessIterator next = last; + --next; + while (comp(value , *next)) { + *last = *next; + last = next; + --next; + } + *last = value; +} + +template +inline void __linear_insert(RandomAccessIterator first, + RandomAccessIterator last, T*) { + T value = *last; + if (value < *first) { + copy_backward(first, last, last + 1); + *first = value; + } else + __unguarded_linear_insert(last, value); +} + +template +inline void __linear_insert(RandomAccessIterator first, + RandomAccessIterator last, T*, Compare comp) { + T value = *last; + if (comp(value, *first)) { + copy_backward(first, last, last + 1); + *first = value; + } else + __unguarded_linear_insert(last, value, comp); +} + +template +void __insertion_sort(RandomAccessIterator first, RandomAccessIterator last) { + if (first == last) return; + for (RandomAccessIterator i = first + 1; i != last; ++i) + __linear_insert(first, i, value_type(first)); +} + +template +void __insertion_sort(RandomAccessIterator first, + RandomAccessIterator last, Compare comp) { + if (first == last) return; + for (RandomAccessIterator i = first + 1; i != last; ++i) + __linear_insert(first, i, value_type(first), comp); +} + +template +void __unguarded_insertion_sort_aux(RandomAccessIterator first, + RandomAccessIterator last, T*) { + for (RandomAccessIterator i = first; i != last; ++i) + __unguarded_linear_insert(i, T(*i)); +} + +template +inline void __unguarded_insertion_sort(RandomAccessIterator first, + RandomAccessIterator last) { + __unguarded_insertion_sort_aux(first, last, value_type(first)); +} + +template +void __unguarded_insertion_sort_aux(RandomAccessIterator first, + RandomAccessIterator last, + T*, Compare comp) { + for (RandomAccessIterator i = first; i != last; ++i) + __unguarded_linear_insert(i, T(*i), comp); +} + +template +inline void __unguarded_insertion_sort(RandomAccessIterator first, + RandomAccessIterator last, + Compare comp) { + __unguarded_insertion_sort_aux(first, last, value_type(first), comp); +} + +template +void __final_insertion_sort(RandomAccessIterator first, + RandomAccessIterator last) { + if (last - first > __stl_threshold) { + __insertion_sort(first, first + __stl_threshold); + __unguarded_insertion_sort(first + __stl_threshold, last); + } else + __insertion_sort(first, last); +} + +template +void __final_insertion_sort(RandomAccessIterator first, + RandomAccessIterator last, Compare comp) { + if (last - first > __stl_threshold) { + __insertion_sort(first, first + __stl_threshold, comp); + __unguarded_insertion_sort(first + __stl_threshold, last, comp); + } else + __insertion_sort(first, last, comp); +} + +template +Size __lg(Size n) { + Size k; + for (k = 0; n != 1; n = n / 2) ++k; + return k; +} + +template +void __introsort_loop(RandomAccessIterator first, + RandomAccessIterator last, T*, + Size depth_limit) { + while (last - first > __stl_threshold) { + if (depth_limit == 0) { + partial_sort(first, last, last); + return; + } + --depth_limit; + RandomAccessIterator cut = __unguarded_partition + (first, last, T(__median(*first, *(first + (last - first)/2), + *(last - 1)))); + __introsort_loop(cut, last, value_type(first), depth_limit); + last = cut; + } +} + +template +void __introsort_loop(RandomAccessIterator first, + RandomAccessIterator last, T*, + Size depth_limit, Compare comp) { + while (last - first > __stl_threshold) { + if (depth_limit == 0) { + partial_sort(first, last, last, comp); + return; + } + --depth_limit; + RandomAccessIterator cut = __unguarded_partition + (first, last, T(__median(*first, *(first + (last - first)/2), + *(last - 1), comp)), comp); + __introsort_loop(cut, last, value_type(first), depth_limit, comp); + last = cut; + } +} + +template +inline void sort(RandomAccessIterator first, RandomAccessIterator last) { + if (first != last) { + __introsort_loop(first, last, value_type(first), __lg(last - first) * 2); + __final_insertion_sort(first, last); + } +} + +template +inline void sort(RandomAccessIterator first, RandomAccessIterator last, + Compare comp) { + if (first != last) { + __introsort_loop(first, last, value_type(first), __lg(last - first) * 2, + comp); + __final_insertion_sort(first, last, comp); + } +} + + +template +void __inplace_stable_sort(RandomAccessIterator first, + RandomAccessIterator last) { + if (last - first < 15) { + __insertion_sort(first, last); + return; + } + RandomAccessIterator middle = first + (last - first) / 2; + __inplace_stable_sort(first, middle); + __inplace_stable_sort(middle, last); + __merge_without_buffer(first, middle, last, middle - first, last - middle); +} + +template +void __inplace_stable_sort(RandomAccessIterator first, + RandomAccessIterator last, Compare comp) { + if (last - first < 15) { + __insertion_sort(first, last, comp); + return; + } + RandomAccessIterator middle = first + (last - first) / 2; + __inplace_stable_sort(first, middle, comp); + __inplace_stable_sort(middle, last, comp); + __merge_without_buffer(first, middle, last, middle - first, + last - middle, comp); +} + +template +void __merge_sort_loop(RandomAccessIterator1 first, + RandomAccessIterator1 last, + RandomAccessIterator2 result, Distance step_size) { + Distance two_step = 2 * step_size; + + while (last - first >= two_step) { + result = merge(first, first + step_size, + first + step_size, first + two_step, result); + first += two_step; + } + + step_size = min(Distance(last - first), step_size); + merge(first, first + step_size, first + step_size, last, result); +} + +template +void __merge_sort_loop(RandomAccessIterator1 first, + RandomAccessIterator1 last, + RandomAccessIterator2 result, Distance step_size, + Compare comp) { + Distance two_step = 2 * step_size; + + while (last - first >= two_step) { + result = merge(first, first + step_size, + first + step_size, first + two_step, result, comp); + first += two_step; + } + step_size = min(Distance(last - first), step_size); + + merge(first, first + step_size, first + step_size, last, result, comp); +} + +const int __stl_chunk_size = 7; + +template +void __chunk_insertion_sort(RandomAccessIterator first, + RandomAccessIterator last, Distance chunk_size) { + while (last - first >= chunk_size) { + __insertion_sort(first, first + chunk_size); + first += chunk_size; + } + __insertion_sort(first, last); +} + +template +void __chunk_insertion_sort(RandomAccessIterator first, + RandomAccessIterator last, + Distance chunk_size, Compare comp) { + while (last - first >= chunk_size) { + __insertion_sort(first, first + chunk_size, comp); + first += chunk_size; + } + __insertion_sort(first, last, comp); +} + +template +void __merge_sort_with_buffer(RandomAccessIterator first, + RandomAccessIterator last, + Pointer buffer, Distance*) { + Distance len = last - first; + Pointer buffer_last = buffer + len; + + Distance step_size = __stl_chunk_size; + __chunk_insertion_sort(first, last, step_size); + + while (step_size < len) { + __merge_sort_loop(first, last, buffer, step_size); + step_size *= 2; + __merge_sort_loop(buffer, buffer_last, first, step_size); + step_size *= 2; + } +} + +template +void __merge_sort_with_buffer(RandomAccessIterator first, + RandomAccessIterator last, Pointer buffer, + Distance*, Compare comp) { + Distance len = last - first; + Pointer buffer_last = buffer + len; + + Distance step_size = __stl_chunk_size; + __chunk_insertion_sort(first, last, step_size, comp); + + while (step_size < len) { + __merge_sort_loop(first, last, buffer, step_size, comp); + step_size *= 2; + __merge_sort_loop(buffer, buffer_last, first, step_size, comp); + step_size *= 2; + } +} + +template +void __stable_sort_adaptive(RandomAccessIterator first, + RandomAccessIterator last, Pointer buffer, + Distance buffer_size) { + Distance len = (last - first + 1) / 2; + RandomAccessIterator middle = first + len; + if (len > buffer_size) { + __stable_sort_adaptive(first, middle, buffer, buffer_size); + __stable_sort_adaptive(middle, last, buffer, buffer_size); + } else { + __merge_sort_with_buffer(first, middle, buffer, (Distance*)0); + __merge_sort_with_buffer(middle, last, buffer, (Distance*)0); + } + __merge_adaptive(first, middle, last, Distance(middle - first), + Distance(last - middle), buffer, buffer_size); +} + +template +void __stable_sort_adaptive(RandomAccessIterator first, + RandomAccessIterator last, Pointer buffer, + Distance buffer_size, Compare comp) { + Distance len = (last - first + 1) / 2; + RandomAccessIterator middle = first + len; + if (len > buffer_size) { + __stable_sort_adaptive(first, middle, buffer, buffer_size, + comp); + __stable_sort_adaptive(middle, last, buffer, buffer_size, + comp); + } else { + __merge_sort_with_buffer(first, middle, buffer, (Distance*)0, comp); + __merge_sort_with_buffer(middle, last, buffer, (Distance*)0, comp); + } + __merge_adaptive(first, middle, last, Distance(middle - first), + Distance(last - middle), buffer, buffer_size, + comp); +} + +template +inline void __stable_sort_aux(RandomAccessIterator first, + RandomAccessIterator last, T*, Distance*) { + temporary_buffer buf(first, last); + if (buf.begin() == 0) + __inplace_stable_sort(first, last); + else + __stable_sort_adaptive(first, last, buf.begin(), Distance(buf.size())); +} + +template +inline void __stable_sort_aux(RandomAccessIterator first, + RandomAccessIterator last, T*, Distance*, + Compare comp) { + temporary_buffer buf(first, last); + if (buf.begin() == 0) + __inplace_stable_sort(first, last, comp); + else + __stable_sort_adaptive(first, last, buf.begin(), Distance(buf.size()), + comp); +} + +template +inline void stable_sort(RandomAccessIterator first, + RandomAccessIterator last) { + __stable_sort_aux(first, last, value_type(first), distance_type(first)); +} + +template +inline void stable_sort(RandomAccessIterator first, + RandomAccessIterator last, Compare comp) { + __stable_sort_aux(first, last, value_type(first), distance_type(first), + comp); +} + +template +void __partial_sort(RandomAccessIterator first, RandomAccessIterator middle, + RandomAccessIterator last, T*) { + make_heap(first, middle); + for (RandomAccessIterator i = middle; i < last; ++i) + if (*i < *first) + __pop_heap(first, middle, i, T(*i), distance_type(first)); + sort_heap(first, middle); +} + +template +inline void partial_sort(RandomAccessIterator first, + RandomAccessIterator middle, + RandomAccessIterator last) { + __partial_sort(first, middle, last, value_type(first)); +} + +template +void __partial_sort(RandomAccessIterator first, RandomAccessIterator middle, + RandomAccessIterator last, T*, Compare comp) { + make_heap(first, middle, comp); + for (RandomAccessIterator i = middle; i < last; ++i) + if (comp(*i, *first)) + __pop_heap(first, middle, i, T(*i), comp, distance_type(first)); + sort_heap(first, middle, comp); +} + +template +inline void partial_sort(RandomAccessIterator first, + RandomAccessIterator middle, + RandomAccessIterator last, Compare comp) { + __partial_sort(first, middle, last, value_type(first), comp); +} + +template +RandomAccessIterator __partial_sort_copy(InputIterator first, + InputIterator last, + RandomAccessIterator result_first, + RandomAccessIterator result_last, + Distance*, T*) { + if (result_first == result_last) return result_last; + RandomAccessIterator result_real_last = result_first; + while(first != last && result_real_last != result_last) { + *result_real_last = *first; + ++result_real_last; + ++first; + } + make_heap(result_first, result_real_last); + while (first != last) { + if (*first < *result_first) + __adjust_heap(result_first, Distance(0), + Distance(result_real_last - result_first), T(*first)); + ++first; + } + sort_heap(result_first, result_real_last); + return result_real_last; +} + +template +inline RandomAccessIterator +partial_sort_copy(InputIterator first, InputIterator last, + RandomAccessIterator result_first, + RandomAccessIterator result_last) { + return __partial_sort_copy(first, last, result_first, result_last, + distance_type(result_first), value_type(first)); +} + +template +RandomAccessIterator __partial_sort_copy(InputIterator first, + InputIterator last, + RandomAccessIterator result_first, + RandomAccessIterator result_last, + Compare comp, Distance*, T*) { + if (result_first == result_last) return result_last; + RandomAccessIterator result_real_last = result_first; + while(first != last && result_real_last != result_last) { + *result_real_last = *first; + ++result_real_last; + ++first; + } + make_heap(result_first, result_real_last, comp); + while (first != last) { + if (comp(*first, *result_first)) + __adjust_heap(result_first, Distance(0), + Distance(result_real_last - result_first), T(*first), + comp); + ++first; + } + sort_heap(result_first, result_real_last, comp); + return result_real_last; +} + +template +inline RandomAccessIterator +partial_sort_copy(InputIterator first, InputIterator last, + RandomAccessIterator result_first, + RandomAccessIterator result_last, Compare comp) { + return __partial_sort_copy(first, last, result_first, result_last, comp, + distance_type(result_first), value_type(first)); +} + +template +void __nth_element(RandomAccessIterator first, RandomAccessIterator nth, + RandomAccessIterator last, T*) { + while (last - first > 3) { + RandomAccessIterator cut = __unguarded_partition + (first, last, T(__median(*first, *(first + (last - first)/2), + *(last - 1)))); + if (cut <= nth) + first = cut; + else + last = cut; + } + __insertion_sort(first, last); +} + +template +inline void nth_element(RandomAccessIterator first, RandomAccessIterator nth, + RandomAccessIterator last) { + __nth_element(first, nth, last, value_type(first)); +} + +template +void __nth_element(RandomAccessIterator first, RandomAccessIterator nth, + RandomAccessIterator last, T*, Compare comp) { + while (last - first > 3) { + RandomAccessIterator cut = __unguarded_partition + (first, last, T(__median(*first, *(first + (last - first)/2), + *(last - 1), comp)), comp); + if (cut <= nth) + first = cut; + else + last = cut; + } + __insertion_sort(first, last, comp); +} + +template +inline void nth_element(RandomAccessIterator first, RandomAccessIterator nth, + RandomAccessIterator last, Compare comp) { + __nth_element(first, nth, last, value_type(first), comp); +} + +template +ForwardIterator __lower_bound(ForwardIterator first, ForwardIterator last, + const T& value, Distance*, + forward_iterator_tag) { + Distance len = 0; + distance(first, last, len); + Distance half; + ForwardIterator middle; + + while (len > 0) { + half = len / 2; + middle = first; + advance(middle, half); + if (*middle < value) { + first = middle; + ++first; + len = len - half - 1; + } else + len = half; + } + return first; +} + +template +inline ForwardIterator __lower_bound(ForwardIterator first, + ForwardIterator last, + const T& value, Distance*, + bidirectional_iterator_tag) { + return __lower_bound(first, last, value, (Distance*)0, + forward_iterator_tag()); +} + +template +RandomAccessIterator __lower_bound(RandomAccessIterator first, + RandomAccessIterator last, const T& value, + Distance*, random_access_iterator_tag) { + Distance len = last - first; + Distance half; + RandomAccessIterator middle; + + while (len > 0) { + half = len / 2; + middle = first + half; + if (*middle < value) { + first = middle + 1; + len = len - half - 1; + } else + len = half; + } + return first; +} + +template +inline ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, + const T& value) { + return __lower_bound(first, last, value, distance_type(first), + iterator_category(first)); +} + +template +ForwardIterator __lower_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp, Distance*, + forward_iterator_tag) { + Distance len = 0; + distance(first, last, len); + Distance half; + ForwardIterator middle; + + while (len > 0) { + half = len / 2; + middle = first; + advance(middle, half); + if (comp(*middle, value)) { + first = middle; + ++first; + len = len - half - 1; + } else + len = half; + } + return first; +} + +template +inline ForwardIterator __lower_bound(ForwardIterator first, + ForwardIterator last, + const T& value, Compare comp, Distance*, + bidirectional_iterator_tag) { + return __lower_bound(first, last, value, comp, (Distance*)0, + forward_iterator_tag()); +} + +template +RandomAccessIterator __lower_bound(RandomAccessIterator first, + RandomAccessIterator last, + const T& value, Compare comp, Distance*, + random_access_iterator_tag) { + Distance len = last - first; + Distance half; + RandomAccessIterator middle; + + while (len > 0) { + half = len / 2; + middle = first + half; + if (comp(*middle, value)) { + first = middle + 1; + len = len - half - 1; + } else + len = half; + } + return first; +} + +template +inline ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) { + return __lower_bound(first, last, value, comp, distance_type(first), + iterator_category(first)); +} + +template +ForwardIterator __upper_bound(ForwardIterator first, ForwardIterator last, + const T& value, Distance*, + forward_iterator_tag) { + Distance len = 0; + distance(first, last, len); + Distance half; + ForwardIterator middle; + + while (len > 0) { + half = len / 2; + middle = first; + advance(middle, half); + if (value < *middle) + len = half; + else { + first = middle; + ++first; + len = len - half - 1; + } + } + return first; +} + +template +inline ForwardIterator __upper_bound(ForwardIterator first, + ForwardIterator last, + const T& value, Distance*, + bidirectional_iterator_tag) { + return __upper_bound(first, last, value, (Distance*)0, + forward_iterator_tag()); +} + +template +RandomAccessIterator __upper_bound(RandomAccessIterator first, + RandomAccessIterator last, const T& value, + Distance*, random_access_iterator_tag) { + Distance len = last - first; + Distance half; + RandomAccessIterator middle; + + while (len > 0) { + half = len / 2; + middle = first + half; + if (value < *middle) + len = half; + else { + first = middle + 1; + len = len - half - 1; + } + } + return first; +} + +template +inline ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, + const T& value) { + return __upper_bound(first, last, value, distance_type(first), + iterator_category(first)); +} + +template +ForwardIterator __upper_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp, Distance*, + forward_iterator_tag) { + Distance len = 0; + distance(first, last, len); + Distance half; + ForwardIterator middle; + + while (len > 0) { + half = len / 2; + middle = first; + advance(middle, half); + if (comp(value, *middle)) + len = half; + else { + first = middle; + ++first; + len = len - half - 1; + } + } + return first; +} + +template +inline ForwardIterator __upper_bound(ForwardIterator first, + ForwardIterator last, + const T& value, Compare comp, Distance*, + bidirectional_iterator_tag) { + return __upper_bound(first, last, value, comp, (Distance*)0, + forward_iterator_tag()); +} + +template +RandomAccessIterator __upper_bound(RandomAccessIterator first, + RandomAccessIterator last, + const T& value, Compare comp, Distance*, + random_access_iterator_tag) { + Distance len = last - first; + Distance half; + RandomAccessIterator middle; + + while (len > 0) { + half = len / 2; + middle = first + half; + if (comp(value, *middle)) + len = half; + else { + first = middle + 1; + len = len - half - 1; + } + } + return first; +} + +template +inline ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, + const T& value, Compare comp) { + return __upper_bound(first, last, value, comp, distance_type(first), + iterator_category(first)); +} + +template +pair +__equal_range(ForwardIterator first, ForwardIterator last, const T& value, + Distance*, forward_iterator_tag) { + Distance len = 0; + distance(first, last, len); + Distance half; + ForwardIterator middle, left, right; + + while (len > 0) { + half = len / 2; + middle = first; + advance(middle, half); + if (*middle < value) { + first = middle; + ++first; + len = len - half - 1; + } else if (value < *middle) + len = half; + else { + left = lower_bound(first, middle, value); + advance(first, len); + right = upper_bound(++middle, first, value); + return pair(left, right); + } + } + return pair(first, first); +} + +template +inline pair +__equal_range(ForwardIterator first, ForwardIterator last, const T& value, + Distance*, bidirectional_iterator_tag) { + return __equal_range(first, last, value, (Distance*)0, + forward_iterator_tag()); +} + +template +pair +__equal_range(RandomAccessIterator first, RandomAccessIterator last, + const T& value, Distance*, random_access_iterator_tag) { + Distance len = last - first; + Distance half; + RandomAccessIterator middle, left, right; + + while (len > 0) { + half = len / 2; + middle = first + half; + if (*middle < value) { + first = middle + 1; + len = len - half - 1; + } else if (value < *middle) + len = half; + else { + left = lower_bound(first, middle, value); + right = upper_bound(++middle, first + len, value); + return pair(left, + right); + } + } + return pair(first, first); +} + +template +inline pair +equal_range(ForwardIterator first, ForwardIterator last, const T& value) { + return __equal_range(first, last, value, distance_type(first), + iterator_category(first)); +} + +template +pair +__equal_range(ForwardIterator first, ForwardIterator last, const T& value, + Compare comp, Distance*, forward_iterator_tag) { + Distance len = 0; + distance(first, last, len); + Distance half; + ForwardIterator middle, left, right; + + while (len > 0) { + half = len / 2; + middle = first; + advance(middle, half); + if (comp(*middle, value)) { + first = middle; + ++first; + len = len - half - 1; + } else if (comp(value, *middle)) + len = half; + else { + left = lower_bound(first, middle, value, comp); + advance(first, len); + right = upper_bound(++middle, first, value, comp); + return pair(left, right); + } + } + return pair(first, first); +} + +template +inline pair +__equal_range(ForwardIterator first, ForwardIterator last, const T& value, + Compare comp, Distance*, bidirectional_iterator_tag) { + return __equal_range(first, last, value, comp, (Distance*)0, + forward_iterator_tag()); +} + +template +pair +__equal_range(RandomAccessIterator first, RandomAccessIterator last, + const T& value, Compare comp, Distance*, + random_access_iterator_tag) { + Distance len = last - first; + Distance half; + RandomAccessIterator middle, left, right; + + while (len > 0) { + half = len / 2; + middle = first + half; + if (comp(*middle, value)) { + first = middle + 1; + len = len - half - 1; + } else if (comp(value, *middle)) + len = half; + else { + left = lower_bound(first, middle, value, comp); + right = upper_bound(++middle, first + len, value, comp); + return pair(left, + right); + } + } + return pair(first, first); +} + +template +inline pair +equal_range(ForwardIterator first, ForwardIterator last, const T& value, + Compare comp) { + return __equal_range(first, last, value, comp, distance_type(first), + iterator_category(first)); +} + +template +bool binary_search(ForwardIterator first, ForwardIterator last, + const T& value) { + ForwardIterator i = lower_bound(first, last, value); + return i != last && !(value < *i); +} + +template +bool binary_search(ForwardIterator first, ForwardIterator last, const T& value, + Compare comp) { + ForwardIterator i = lower_bound(first, last, value, comp); + return i != last && !comp(value, *i); +} + +template +OutputIterator merge(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if (*first2 < *first1) { + *result = *first2; + ++first2; + } + else { + *result = *first1; + ++first1; + } + ++result; + } + return copy(first2, last2, copy(first1, last1, result)); +} + +template +OutputIterator merge(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result, Compare comp) { + while (first1 != last1 && first2 != last2) { + if (comp(*first2, *first1)) { + *result = *first2; + ++first2; + } + else { + *result = *first1; + ++first1; + } + ++result; + } + return copy(first2, last2, copy(first1, last1, result)); +} + +template +void __merge_without_buffer(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, + Distance len1, Distance len2) { + if (len1 == 0 || len2 == 0) return; + if (len1 + len2 == 2) { + if (*middle < *first) iter_swap(first, middle); + return; + } + BidirectionalIterator first_cut = first; + BidirectionalIterator second_cut = middle; + Distance len11 = 0; + Distance len22 = 0; + if (len1 > len2) { + len11 = len1 / 2; + advance(first_cut, len11); + second_cut = lower_bound(middle, last, *first_cut); + distance(middle, second_cut, len22); + } else { + len22 = len2 / 2; + advance(second_cut, len22); + first_cut = upper_bound(first, middle, *second_cut); + distance(first, first_cut, len11); + } + rotate(first_cut, middle, second_cut); + BidirectionalIterator new_middle = first_cut; + advance(new_middle, len22); + __merge_without_buffer(first, first_cut, new_middle, len11, len22); + __merge_without_buffer(new_middle, second_cut, last, len1 - len11, + len2 - len22); +} + +template +void __merge_without_buffer(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, + Distance len1, Distance len2, Compare comp) { + if (len1 == 0 || len2 == 0) return; + if (len1 + len2 == 2) { + if (comp(*middle, *first)) iter_swap(first, middle); + return; + } + BidirectionalIterator first_cut = first; + BidirectionalIterator second_cut = middle; + Distance len11 = 0; + Distance len22 = 0; + if (len1 > len2) { + len11 = len1 / 2; + advance(first_cut, len11); + second_cut = lower_bound(middle, last, *first_cut, comp); + distance(middle, second_cut, len22); + } else { + len22 = len2 / 2; + advance(second_cut, len22); + first_cut = upper_bound(first, middle, *second_cut, comp); + distance(first, first_cut, len11); + } + rotate(first_cut, middle, second_cut); + BidirectionalIterator new_middle = first_cut; + advance(new_middle, len22); + __merge_without_buffer(first, first_cut, new_middle, len11, len22, comp); + __merge_without_buffer(new_middle, second_cut, last, len1 - len11, + len2 - len22, comp); +} + +template +BidirectionalIterator1 __rotate_adaptive(BidirectionalIterator1 first, + BidirectionalIterator1 middle, + BidirectionalIterator1 last, + Distance len1, Distance len2, + BidirectionalIterator2 buffer, + Distance buffer_size) { + BidirectionalIterator2 buffer_end; + if (len1 > len2 && len2 <= buffer_size) { + buffer_end = copy(middle, last, buffer); + copy_backward(first, middle, last); + return copy(buffer, buffer_end, first); + } else if (len1 <= buffer_size) { + buffer_end = copy(first, middle, buffer); + copy(middle, last, first); + return copy_backward(buffer, buffer_end, last); + } else { + rotate(first, middle, last); + advance(first, len2); + return first; + } +} + +template +BidirectionalIterator3 __merge_backward(BidirectionalIterator1 first1, + BidirectionalIterator1 last1, + BidirectionalIterator2 first2, + BidirectionalIterator2 last2, + BidirectionalIterator3 result) { + if (first1 == last1) return copy_backward(first2, last2, result); + if (first2 == last2) return copy_backward(first1, last1, result); + --last1; + --last2; + while (true) { + if (*last2 < *last1) { + *--result = *last1; + if (first1 == last1) return copy_backward(first2, ++last2, result); + --last1; + } else { + *--result = *last2; + if (first2 == last2) return copy_backward(first1, ++last1, result); + --last2; + } + } +} + +template +BidirectionalIterator3 __merge_backward(BidirectionalIterator1 first1, + BidirectionalIterator1 last1, + BidirectionalIterator2 first2, + BidirectionalIterator2 last2, + BidirectionalIterator3 result, + Compare comp) { + if (first1 == last1) return copy_backward(first2, last2, result); + if (first2 == last2) return copy_backward(first1, last1, result); + --last1; + --last2; + while (true) { + if (comp(*last2, *last1)) { + *--result = *last1; + if (first1 == last1) return copy_backward(first2, ++last2, result); + --last1; + } else { + *--result = *last2; + if (first2 == last2) return copy_backward(first1, ++last1, result); + --last2; + } + } +} + +template +void __merge_adaptive(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, Distance len1, Distance len2, + Pointer buffer, Distance buffer_size) { + if (len1 <= len2 && len1 <= buffer_size) { + Pointer end_buffer = copy(first, middle, buffer); + merge(buffer, end_buffer, middle, last, first); + } else if (len2 <= buffer_size) { + Pointer end_buffer = copy(middle, last, buffer); + __merge_backward(first, middle, buffer, end_buffer, last); + } else { + BidirectionalIterator first_cut = first; + BidirectionalIterator second_cut = middle; + Distance len11 = 0; + Distance len22 = 0; + if (len1 > len2) { + len11 = len1 / 2; + advance(first_cut, len11); + second_cut = lower_bound(middle, last, *first_cut); + distance(middle, second_cut, len22); + } else { + len22 = len2 / 2; + advance(second_cut, len22); + first_cut = upper_bound(first, middle, *second_cut); + distance(first, first_cut, len11); + } + BidirectionalIterator new_middle = + __rotate_adaptive(first_cut, middle, second_cut, len1 - len11, + len22, buffer, buffer_size); + __merge_adaptive(first, first_cut, new_middle, len11, len22, buffer, + buffer_size); + __merge_adaptive(new_middle, second_cut, last, len1 - len11, + len2 - len22, buffer, buffer_size); + } +} + +template +void __merge_adaptive(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, Distance len1, Distance len2, + Pointer buffer, Distance buffer_size, Compare comp) { + if (len1 <= len2 && len1 <= buffer_size) { + Pointer end_buffer = copy(first, middle, buffer); + merge(buffer, end_buffer, middle, last, first, comp); + } else if (len2 <= buffer_size) { + Pointer end_buffer = copy(middle, last, buffer); + __merge_backward(first, middle, buffer, end_buffer, last, comp); + } else { + BidirectionalIterator first_cut = first; + BidirectionalIterator second_cut = middle; + Distance len11 = 0; + Distance len22 = 0; + if (len1 > len2) { + len11 = len1 / 2; + advance(first_cut, len11); + second_cut = lower_bound(middle, last, *first_cut, comp); + distance(middle, second_cut, len22); + } else { + len22 = len2 / 2; + advance(second_cut, len22); + first_cut = upper_bound(first, middle, *second_cut, comp); + distance(first, first_cut, len11); + } + BidirectionalIterator new_middle = + __rotate_adaptive(first_cut, middle, second_cut, len1 - len11, + len22, buffer, buffer_size); + __merge_adaptive(first, first_cut, new_middle, len11, len22, buffer, + buffer_size, comp); + __merge_adaptive(new_middle, second_cut, last, len1 - len11, + len2 - len22, buffer, buffer_size, comp); + } +} + +template +inline void __inplace_merge_aux(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, T*, Distance*) { + Distance len1 = 0; + distance(first, middle, len1); + Distance len2 = 0; + distance(middle, last, len2); + + temporary_buffer buf(first, last); + if (buf.begin() == 0) + __merge_without_buffer(first, middle, last, len1, len2); + else + __merge_adaptive(first, middle, last, len1, len2, + buf.begin(), Distance(buf.size())); +} + +template +inline void __inplace_merge_aux(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, T*, Distance*, + Compare comp) { + Distance len1 = 0; + distance(first, middle, len1); + Distance len2 = 0; + distance(middle, last, len2); + + temporary_buffer buf(first, last); + if (buf.begin() == 0) + __merge_without_buffer(first, middle, last, len1, len2, comp); + else + __merge_adaptive(first, middle, last, len1, len2, + buf.begin(), Distance(buf.size()), + comp); +} + +template +inline void inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last) { + if (first == middle || middle == last) return; + __inplace_merge_aux(first, middle, last, value_type(first), + distance_type(first)); +} + +template +inline void inplace_merge(BidirectionalIterator first, + BidirectionalIterator middle, + BidirectionalIterator last, Compare comp) { + if (first == middle || middle == last) return; + __inplace_merge_aux(first, middle, last, value_type(first), + distance_type(first), comp); +} + +template +bool includes(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + while (first1 != last1 && first2 != last2) + if (*first2 < *first1) + return false; + else if(*first1 < *first2) + ++first1; + else + ++first1, ++first2; + + return first2 == last2; +} + +template +bool includes(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, Compare comp) { + while (first1 != last1 && first2 != last2) + if (comp(*first2, *first1)) + return false; + else if(comp(*first1, *first2)) + ++first1; + else + ++first1, ++first2; + + return first2 == last2; +} + +template +OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) { + if (*first1 < *first2) { + *result = *first1; + ++first1; + } + else if (*first2 < *first1) { + *result = *first2; + ++first2; + } + else { + *result = *first1; + ++first1; + ++first2; + } + ++result; + } + return copy(first2, last2, copy(first1, last1, result)); +} + +template +OutputIterator set_union(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result, Compare comp) { + while (first1 != last1 && first2 != last2) { + if (comp(*first1, *first2)) { + *result = *first1; + ++first1; + } + else if (comp(*first2, *first1)) { + *result = *first2; + ++first2; + } + else { + *result = *first1; + ++first1; + ++first2; + } + ++result; + } + return copy(first2, last2, copy(first1, last1, result)); +} + +template +OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) + if (*first1 < *first2) + ++first1; + else if (*first2 < *first1) + ++first2; + else { + *result = *first1; + ++first1; + ++first2; + ++result; + } + return result; +} + +template +OutputIterator set_intersection(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result, Compare comp) { + while (first1 != last1 && first2 != last2) + if (comp(*first1, *first2)) + ++first1; + else if (comp(*first2, *first1)) + ++first2; + else { + *result = *first1; + ++first1; + ++first2; + ++result; + } + return result; +} + +template +OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) + if (*first1 < *first2) { + *result = *first1; + ++first1; + ++result; + } + else if (*first2 < *first1) + ++first2; + else { + ++first1; + ++first2; + } + return copy(first1, last1, result); +} + +template +OutputIterator set_difference(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result, Compare comp) { + while (first1 != last1 && first2 != last2) + if (comp(*first1, *first2)) { + *result = *first1; + ++first1; + ++result; + } + else if (comp(*first2, *first1)) + ++first2; + else { + ++first1; + ++first2; + } + return copy(first1, last1, result); +} + +template +OutputIterator set_symmetric_difference(InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result) { + while (first1 != last1 && first2 != last2) + if (*first1 < *first2) { + *result = *first1; + ++first1; + ++result; + } + else if (*first2 < *first1) { + *result = *first2; + ++first2; + ++result; + } + else { + ++first1; + ++first2; + } + return copy(first2, last2, copy(first1, last1, result)); +} + +template +OutputIterator set_symmetric_difference(InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + InputIterator2 last2, + OutputIterator result, Compare comp) { + while (first1 != last1 && first2 != last2) + if (comp(*first1, *first2)) { + *result = *first1; + ++first1; + ++result; + } + else if (comp(*first2, *first1)) { + *result = *first2; + ++first2; + ++result; + } + else { + ++first1; + ++first2; + } + return copy(first2, last2, copy(first1, last1, result)); +} + +template +ForwardIterator max_element(ForwardIterator first, ForwardIterator last) { + if (first == last) return first; + ForwardIterator result = first; + while (++first != last) + if (*result < *first) result = first; + return result; +} + +template +ForwardIterator max_element(ForwardIterator first, ForwardIterator last, + Compare comp) { + if (first == last) return first; + ForwardIterator result = first; + while (++first != last) + if (comp(*result, *first)) result = first; + return result; +} + +template +ForwardIterator min_element(ForwardIterator first, ForwardIterator last) { + if (first == last) return first; + ForwardIterator result = first; + while (++first != last) + if (*first < *result) result = first; + return result; +} + +template +ForwardIterator min_element(ForwardIterator first, ForwardIterator last, + Compare comp) { + if (first == last) return first; + ForwardIterator result = first; + while (++first != last) + if (comp(*first, *result)) result = first; + return result; +} + +template +bool next_permutation(BidirectionalIterator first, + BidirectionalIterator last) { + if (first == last) return false; + BidirectionalIterator i = first; + ++i; + if (i == last) return false; + i = last; + --i; + + for(;;) { + BidirectionalIterator ii = i; + --i; + if (*i < *ii) { + BidirectionalIterator j = last; + while (!(*i < *--j)); + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first) { + reverse(first, last); + return false; + } + } +} + +template +bool next_permutation(BidirectionalIterator first, BidirectionalIterator last, + Compare comp) { + if (first == last) return false; + BidirectionalIterator i = first; + ++i; + if (i == last) return false; + i = last; + --i; + + for(;;) { + BidirectionalIterator ii = i; + --i; + if (comp(*i, *ii)) { + BidirectionalIterator j = last; + while (!comp(*i, *--j)); + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first) { + reverse(first, last); + return false; + } + } +} + +template +bool prev_permutation(BidirectionalIterator first, + BidirectionalIterator last) { + if (first == last) return false; + BidirectionalIterator i = first; + ++i; + if (i == last) return false; + i = last; + --i; + + for(;;) { + BidirectionalIterator ii = i; + --i; + if (*ii < *i) { + BidirectionalIterator j = last; + while (!(*--j < *i)); + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first) { + reverse(first, last); + return false; + } + } +} + +template +bool prev_permutation(BidirectionalIterator first, BidirectionalIterator last, + Compare comp) { + if (first == last) return false; + BidirectionalIterator i = first; + ++i; + if (i == last) return false; + i = last; + --i; + + for(;;) { + BidirectionalIterator ii = i; + --i; + if (comp(*ii, *i)) { + BidirectionalIterator j = last; + while (!comp(*--j, *i)); + iter_swap(i, j); + reverse(ii, last); + return true; + } + if (i == first) { + reverse(first, last); + return false; + } + } +} + +template +T accumulate(InputIterator first, InputIterator last, T init) { + for ( ; first != last; ++first) + init = init + *first; + return init; +} + +template +T accumulate(InputIterator first, InputIterator last, T init, + BinaryOperation binary_op) { + for ( ; first != last; ++first) + init = binary_op(init, *first); + return init; +} + +template +T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init) { + for ( ; first1 != last1; ++first1, ++first2) + init = init + (*first1 * *first2); + return init; +} + +template +T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, BinaryOperation1 binary_op1, + BinaryOperation2 binary_op2) { + for ( ; first1 != last1; ++first1, ++first2) + init = binary_op1(init, binary_op2(*first1, *first2)); + return init; +} + +template +OutputIterator __partial_sum(InputIterator first, InputIterator last, + OutputIterator result, T*) { + T value = *first; + while (++first != last) { + value = value + *first; + *++result = value; + } + return ++result; +} + +template +OutputIterator partial_sum(InputIterator first, InputIterator last, + OutputIterator result) { + if (first == last) return result; + *result = *first; + return __partial_sum(first, last, result, value_type(first)); +} + +template +OutputIterator __partial_sum(InputIterator first, InputIterator last, + OutputIterator result, T*, + BinaryOperation binary_op) { + T value = *first; + while (++first != last) { + value = binary_op(value, *first); + *++result = value; + } + return ++result; +} + +template +OutputIterator partial_sum(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op) { + if (first == last) return result; + *result = *first; + return __partial_sum(first, last, result, value_type(first), binary_op); +} + +template +OutputIterator __adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result, T*) { + T value = *first; + while (++first != last) { + T tmp = *first; + *++result = tmp - value; + value = tmp; + } + return ++result; +} + +template +OutputIterator adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result) { + if (first == last) return result; + *result = *first; + return __adjacent_difference(first, last, result, value_type(first)); +} + +template +OutputIterator __adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result, T*, + BinaryOperation binary_op) { + T value = *first; + while (++first != last) { + T tmp = *first; + *++result = binary_op(tmp, value); + value = tmp; + } + return ++result; +} + +template +OutputIterator adjacent_difference(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation binary_op) { + if (first == last) return result; + *result = *first; + return __adjacent_difference(first, last, result, value_type(first), + binary_op); +} + +// Returns x ** n, where n >= 0. Note that "multiplication" +// is required to be associative, but not necessarily commutative. + +template +T power(T x, Integer n, MonoidOperation op) { + if (n == 0) + return identity_element(op); + else { + while (n % 2 == 0) { + n /= 2; + x = op(x, x); + } + + T result = x; + n /= 2; + while (n != 0) { + x = op(x, x); + if (n % 2 != 0) + result = op(result, x); + n /= 2; + } + return result; + } +} + +template +inline T power(T x, Integer n) { + return power(x, n, multiplies()); +} + + +template +void iota(ForwardIterator first, ForwardIterator last, T value) { + while (first != last) *first++ = value++; +} + +template +bool __is_heap(RandomAccessIterator first, RandomAccessIterator last, + Distance*) +{ + const Distance n = last - first; + + Distance parent = 0; + for (Distance child = 1; child < n; ++child) { + if (first[parent] < first[child]) + return false; + if (child % 2 == 0) + ++parent; + } + return true; +} + +template +inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last) +{ + return __is_heap(first, last, distance_type(first)); +} + + +template +bool __is_heap(RandomAccessIterator first, RandomAccessIterator last, + StrictWeakOrdering comp, + Distance*) +{ + const Distance n = last - first; + + Distance parent = 0; + for (Distance child = 1; child < n; ++child) { + if (comp(first[parent], first[child])) + return false; + if (child % 2 == 0) + ++parent; + } + return true; +} + +template +inline bool is_heap(RandomAccessIterator first, RandomAccessIterator last, + StrictWeakOrdering comp) +{ + return __is_heap(first, last, comp, distance_type(first)); +} + + +template +bool is_sorted(ForwardIterator first, ForwardIterator last) +{ + if (first == last) + return true; + + ForwardIterator next = first; + for (++next; next != last; first = next, ++next) { + if (*next < *first) + return false; + } + + return true; +} + +template +bool is_sorted(ForwardIterator first, ForwardIterator last, + StrictWeakOrdering comp) +{ + if (first == last) + return true; + + ForwardIterator next = first; + for (++next; next != last; first = next, ++next) { + if (comp(*next, *first)) + return false; + } + + return true; +} + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma reset woff 1209 +#endif + +#endif /* __SGI_STL_ALGO_H */ diff --git a/libstdc++/stl/algobase.h b/libstdc++/stl/algobase.h new file mode 100644 index 000000000000..0a17f48b2e79 --- /dev/null +++ b/libstdc++/stl/algobase.h @@ -0,0 +1,841 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef _SGI_STL_ALGOBASE_H +#define _SGI_STL_ALGOBASE_H + +#include +#include +#include +#include +#include +#include +#include + +template +inline void __iter_swap(ForwardIterator1 a, ForwardIterator2 b, T*) { + T tmp = *a; + *a = *b; + *b = tmp; +} + +template +inline void iter_swap(ForwardIterator1 a, ForwardIterator2 b) { + __iter_swap(a, b, value_type(a)); +} + +template +inline void swap(T& a, T& b) { + T tmp = a; + a = b; + b = tmp; +} + +#ifdef __BORLANDC__ +#include +#else + +template +inline const T& min(const T& a, const T& b) { + return b < a ? b : a; +} + +template +inline const T& max(const T& a, const T& b) { + return a < b ? b : a; +} + +#endif + +template +inline const T& min(const T& a, const T& b, Compare comp) { + return comp(b, a) ? b : a; +} + +template +inline const T& max(const T& a, const T& b, Compare comp) { + return comp(a, b) ? b : a; +} + +template +inline void __distance(InputIterator first, InputIterator last, Distance& n, + input_iterator_tag) { + while (first != last) { ++first; ++n; } +} + +template +inline void __distance(ForwardIterator first, ForwardIterator last, + Distance& n, + forward_iterator_tag) { + while (first != last) { ++first; ++n; } +} + +template +inline void __distance(BidirectionalIterator first, BidirectionalIterator last, + Distance& n, bidirectional_iterator_tag) { + while (first != last) { ++first; ++n; } +} + +template +inline void __distance(RandomAccessIterator first, RandomAccessIterator last, + Distance& n, random_access_iterator_tag) { + n += last - first; +} + +template +inline void distance(InputIterator first, InputIterator last, Distance& n) { + __distance(first, last, n, iterator_category(first)); +} + +#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION + +template +inline iterator_traits::difference_type +__distance(InputIterator first, InputIterator last, input_iterator_tag) { + iterator_traits::difference_type n = 0; + while (first != last) { + ++first; ++n; + } + return n; +} + +template +inline iterator_traits::difference_type +__distance(ForwardIterator first, ForwardIterator last, forward_iterator_tag) { + return __distance(first, last, input_iterator_tag()); +} + +template +inline iterator_traits::difference_type +__distance(BidirectionalIterator first, BidirectionalIterator last, + bidirectional_iterator_tag) { + return __distance(first, last, input_iterator_tag()); +} + +template +inline iterator_traits::difference_type +__distance(RandomAccessIterator first, RandomAccessIterator last, + random_access_iterator_tag) { + return last - first; +} + +template +inline iterator_traits::difference_type +distance(InputIterator first, InputIterator last) { + return __distance(first, last, + iterator_traits::iterator_category()); +} + +#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + +template +inline void __advance(InputIterator& i, Distance n, input_iterator_tag) { + while (n--) ++i; +} + +template +inline void __advance(ForwardIterator& i, Distance n, forward_iterator_tag) { + while (n--) ++i; +} + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma set woff 1183 +#endif + +template +inline void __advance(BidirectionalIterator& i, Distance n, + bidirectional_iterator_tag) { + if (n >= 0) + while (n--) ++i; + else + while (n++) --i; +} + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma reset woff 1183 +#endif + +template +inline void __advance(RandomAccessIterator& i, Distance n, + random_access_iterator_tag) { + i += n; +} + +template +inline void advance(InputIterator& i, Distance n) { + __advance(i, n, iterator_category(i)); +} + +template +inline OutputIterator __copy(InputIterator first, InputIterator last, + OutputIterator result, input_iterator_tag) +{ + for ( ; first != last; ++result, ++first) + *result = *first; + return result; +} + +template +inline OutputIterator __copy(InputIterator first, InputIterator last, + OutputIterator result, forward_iterator_tag) +{ + return __copy(first, last, result, input_iterator_tag()); +} + +template +inline OutputIterator __copy(InputIterator first, InputIterator last, + OutputIterator result, bidirectional_iterator_tag) +{ + return __copy(first, last, result, input_iterator_tag()); +} + +template +inline OutputIterator +__copy_d(RandomAccessIterator first, RandomAccessIterator last, + OutputIterator result, Distance*) +{ + for (Distance n = last - first; n > 0; --n, ++result, ++first) + *result = *first; + return result; +} + +template +inline OutputIterator +__copy(RandomAccessIterator first, RandomAccessIterator last, + OutputIterator result, random_access_iterator_tag) +{ + return __copy_d(first, last, result, distance_type(first)); +} + +template +struct __copy_dispatch +{ + OutputIterator operator()(InputIterator first, InputIterator last, + OutputIterator result) { + return __copy(first, last, result, iterator_category(first)); + } +}; + +#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION + +template +inline T* __copy_t(const T* first, const T* last, T* result, __true_type) { + memmove(result, first, sizeof(T) * (last - first)); + return result + (last - first); +} + +template +inline T* __copy_t(const T* first, const T* last, T* result, __false_type) { + return __copy_d(first, last, result, (ptrdiff_t*) 0); +} + +template +struct __copy_dispatch +{ + T* operator()(T* first, T* last, T* result) { + return __copy_t(first, last, result, + __type_traits::has_trivial_assignment_operator()); + } +}; + +template +struct __copy_dispatch +{ + T* operator()(const T* first, const T* last, T* result) { + return __copy_t(first, last, result, + __type_traits::has_trivial_assignment_operator()); + } +}; + +#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + +template +inline OutputIterator copy(InputIterator first, InputIterator last, + OutputIterator result) +{ + return __copy_dispatch()(first, last, result); +} + +inline char* copy(const char* first, const char* last, char* result) { + memmove(result, first, last - first); + return result + (last - first); +} + +inline wchar_t* copy(const wchar_t* first, const wchar_t* last, + wchar_t* result) { + memmove(result, first, sizeof(wchar_t) * (last - first)); + return result + (last - first); +} + +template +inline BidirectionalIterator2 __copy_backward(BidirectionalIterator1 first, + BidirectionalIterator1 last, + BidirectionalIterator2 result) { + while (first != last) *--result = *--last; + return result; +} + + +template +struct __copy_backward_dispatch +{ + BidirectionalIterator2 operator()(BidirectionalIterator1 first, + BidirectionalIterator1 last, + BidirectionalIterator2 result) { + return __copy_backward(first, last, result); + } +}; + +#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION + +template +inline T* __copy_backward_t(const T* first, const T* last, T* result, + __true_type) { + const ptrdiff_t N = last - first; + memmove(result - N, first, sizeof(T) * N); + return result - N; +} + +template +inline T* __copy_backward_t(const T* first, const T* last, T* result, + __false_type) { + return __copy_backward(first, last, result); +} + +template +struct __copy_backward_dispatch +{ + T* operator()(T* first, T* last, T* result) { + return + __copy_backward_t(first, last, result, + __type_traits::has_trivial_assignment_operator()); + } +}; + +template +struct __copy_backward_dispatch +{ + T* operator()(const T* first, const T* last, T* result) { + return + __copy_backward_t(first, last, result, + __type_traits::has_trivial_assignment_operator()); + } +}; + +#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + +template +inline BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, + BidirectionalIterator1 last, + BidirectionalIterator2 result) { + return __copy_backward_dispatch()(first, last, + result); +} + +template +OutputIterator __copy_n(InputIterator first, Size count, + OutputIterator result, + input_iterator_tag) { + for ( ; count > 0; --count, ++first, ++result) + *result = *first; + return result; +} + +template +inline OutputIterator __copy_n(ForwardIterator first, Size count, + OutputIterator result, + forward_iterator_tag) { + return __copy_n(first, count, result, input_iterator_tag()); +} + +template +inline OutputIterator __copy_n(BidirectionalIterator first, Size count, + OutputIterator result, + bidirectional_iterator_tag) { + return __copy_n(first, count, result, input_iterator_tag()); +} + +template +inline OutputIterator __copy_n(RandomAccessIterator first, Size count, + OutputIterator result, + random_access_iterator_tag) { + return copy(first, first + count, result); +} + +template +inline OutputIterator copy_n(InputIterator first, Size count, + OutputIterator result) { + return __copy_n(first, count, result, iterator_category(first)); +} + +template +void fill(ForwardIterator first, ForwardIterator last, const T& value) { + for ( ; first != last; ++first) + *first = value; +} + +template +OutputIterator fill_n(OutputIterator first, Size n, const T& value) { + for ( ; n > 0; --n, ++first) + *first = value; + return first; +} + +template +pair mismatch(InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2) { + while (first1 != last1 && *first1 == *first2) { + ++first1; + ++first2; + } + return pair(first1, first2); +} + +template +pair mismatch(InputIterator1 first1, + InputIterator1 last1, + InputIterator2 first2, + BinaryPredicate binary_pred) { + while (first1 != last1 && binary_pred(*first1, *first2)) { + ++first1; + ++first2; + } + return pair(first1, first2); +} + +template +inline bool equal(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2) { + for ( ; first1 != last1; ++first1, ++first2) + if (*first1 != *first2) + return false; + return true; +} + +template +inline bool equal(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, BinaryPredicate binary_pred) { + for ( ; first1 != last1; ++first1, ++first2) + if (!binary_pred(*first1, *first2)) + return false; + return true; +} + +template +bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) { + for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) { + if (*first1 < *first2) + return true; + if (*first2 < *first1) + return false; + } + return first1 == last1 && first2 != last2; +} + +template +bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + Compare comp) { + for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) { + if (comp(*first1, *first2)) + return true; + if (comp(*first2, *first1)) + return false; + } + return first1 == last1 && first2 != last2; +} + +inline bool +lexicographical_compare(const unsigned char* first1, + const unsigned char* last1, + const unsigned char* first2, + const unsigned char* last2) +{ + const size_t len1 = last1 - first1; + const size_t len2 = last2 - first2; + const int result = memcmp(first1, first2, min(len1, len2)); + return result != 0 ? result < 0 : len1 < len2; +} + +inline bool lexicographical_compare(const char* first1, const char* last1, + const char* first2, const char* last2) +{ +#if CHAR_MAX == SCHAR_MAX + return lexicographical_compare((const signed char*) first1, + (const signed char*) last1, + (const signed char*) first2, + (const signed char*) last2); +#else + return lexicographical_compare((const unsigned char*) first1, + (const unsigned char*) last1, + (const unsigned char*) first2, + (const unsigned char*) last2); +#endif +} + +template +int lexicographical_compare_3way(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2) +{ + while (first1 != last1 && first2 != last2) { + if (*first1 < *first2) return -1; + if (*first2 < *first1) return 1; + ++first1; ++first2; + } + if (first2 == last2) { + return !(first1 == last1); + } else { + return -1; + } +} + +inline int +lexicographical_compare_3way(const unsigned char* first1, + const unsigned char* last1, + const unsigned char* first2, + const unsigned char* last2) +{ + const int len1 = last1 - first1; + const int len2 = last2 - first2; + const int result = memcmp(first1, first2, min(len1, len2)); + return result == 0 ? len1 - len2 : result; +} + +inline int lexicographical_compare_3way(const char* first1, const char* last1, + const char* first2, const char* last2) +{ +#if CHAR_MAX == SCHAR_MAX + return lexicographical_compare_3way( + (const signed char*) first1, + (const signed char*) last1, + (const signed char*) first2, + (const signed char*) last2); +#else + return lexicographical_compare_3way((const unsigned char*) first1, + (const unsigned char*) last1, + (const unsigned char*) first2, + (const unsigned char*) last2); +#endif +} + +template +inline void destroy(T* pointer) { + pointer->~T(); +} + +template +inline void construct(T1* p, const T2& value) { + new (p) T1(value); +} + +template +inline void +__destroy_aux(ForwardIterator first, ForwardIterator last, __false_type) { + for ( ; first < last; ++first) + destroy(&*first); +} + +template +inline void __destroy_aux(ForwardIterator, ForwardIterator, __true_type) { +} + +template +inline void __destroy(ForwardIterator first, ForwardIterator last, T*) { + __destroy_aux(first, last, __type_traits::has_trivial_destructor()); +} + +template +inline void destroy(ForwardIterator first, ForwardIterator last) { + __destroy(first, last, value_type(first)); +} + +inline void destroy(char*, char*) {} +inline void destroy(wchar_t*, wchar_t*) {} + +// Valid if copy construction is equivalent to assignment, and if the +// destructor is trivial. +template +inline ForwardIterator +__uninitialized_copy_aux(InputIterator first, InputIterator last, + ForwardIterator result, + __true_type) { + return copy(first, last, result); +} + +template +ForwardIterator +__uninitialized_copy_aux(InputIterator first, InputIterator last, + ForwardIterator result, + __false_type) { + ForwardIterator cur = result; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for ( ; first != last; ++first, ++cur) + construct(&*cur, *first); + return cur; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(result, cur); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + + +template +inline ForwardIterator +__uninitialized_copy(InputIterator first, InputIterator last, + ForwardIterator result, T*) { + return __uninitialized_copy_aux(first, last, result, + __type_traits::is_POD_type()); +} + +template +inline ForwardIterator + uninitialized_copy(InputIterator first, InputIterator last, + ForwardIterator result) { + return __uninitialized_copy(first, last, result, value_type(result)); +} + +inline char* uninitialized_copy(const char* first, const char* last, + char* result) { + memmove(result, first, last - first); + return result + (last - first); +} + +inline wchar_t* uninitialized_copy(const wchar_t* first, const wchar_t* last, + wchar_t* result) { + memmove(result, first, sizeof(wchar_t) * (last - first)); + return result + (last - first); +} + +template +ForwardIterator __uninitialized_copy_n(InputIterator first, Size count, + ForwardIterator result, + input_iterator_tag) { + ForwardIterator cur = result; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for ( ; count > 0 ; --count, ++first, ++cur) + construct(&*cur, *first); + return cur; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(result, cur); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +template +inline ForwardIterator +__uninitialized_copy_n(ForwardIterator1 first, Size count, + ForwardIterator result, + forward_iterator_tag) { + return __uninitialized_copy_n(first, count, result, input_iterator_tag()); +} + +template +inline ForwardIterator +__uninitialized_copy_n(BidirectionalIterator first, Size count, + ForwardIterator result, + bidirectional_iterator_tag) { + return __uninitialized_copy_n(first, count, result, input_iterator_tag()); +} + +template +inline ForwardIterator +__uninitialized_copy_n(RandomAccessIterator first, Size count, + ForwardIterator result, + random_access_iterator_tag) { + return uninitialized_copy(first, first + count, result); +} + +template +inline ForwardIterator uninitialized_copy_n(InputIterator first, Size count, + ForwardIterator result) { + return __uninitialized_copy_n(first, count, result, + iterator_category(first)); +} + +// Valid if copy construction is equivalent to assignment, and if the +// destructor is trivial. +template +inline void +__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last, + const T& x, __true_type) +{ + fill(first, last, x); +} + +template +void +__uninitialized_fill_aux(ForwardIterator first, ForwardIterator last, + const T& x, __false_type) +{ + ForwardIterator cur = first; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for ( ; cur != last; ++cur) + construct(&*cur, x); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(first, cur); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +template +inline void __uninitialized_fill(ForwardIterator first, ForwardIterator last, + const T& x, T1*) { + __uninitialized_fill_aux(first, last, x, + __type_traits::is_POD_type()); +} + +template +inline void uninitialized_fill(ForwardIterator first, ForwardIterator last, + const T& x) { + __uninitialized_fill(first, last, x, value_type(first)); +} + +// Valid if copy construction is equivalent to assignment, and if the +// destructor is trivial. +template +inline ForwardIterator +__uninitialized_fill_n_aux(ForwardIterator first, Size n, + const T& x, __true_type) { + return fill_n(first, n, x); +} + +template +ForwardIterator +__uninitialized_fill_n_aux(ForwardIterator first, Size n, + const T& x, __false_type) { + ForwardIterator cur = first; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for ( ; n > 0; --n, ++cur) + construct(&*cur, x); + return cur; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(first, cur); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +template +inline ForwardIterator __uninitialized_fill_n(ForwardIterator first, Size n, + const T& x, T1*) { + return __uninitialized_fill_n_aux(first, n, x, + __type_traits::is_POD_type()); +} + +template +inline ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, + const T& x) { + return __uninitialized_fill_n(first, n, x, value_type(first)); +} + +// Copies [first1, last1) into [result, result + (last1 - first1)), and +// copies [first2, last2) into +// [result, result + (last1 - first1) + (last2 - first2)). + +template +inline ForwardIterator +__uninitialized_copy_copy(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + ForwardIterator result) { + ForwardIterator mid = uninitialized_copy(first1, last1, result); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + return uninitialized_copy(first2, last2, mid); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(result, mid); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +// Fills [result, mid) with x, and copies [first, last) into +// [mid, mid + (last - first)). +template +inline ForwardIterator +__uninitialized_fill_copy(ForwardIterator result, ForwardIterator mid, + const T& x, + InputIterator first, InputIterator last) { + uninitialized_fill(result, mid, x); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + return uninitialized_copy(first, last, mid); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(result, mid); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and +// fills [first2 + (last1 - first1), last2) with x. +template +inline void +__uninitialized_copy_fill(InputIterator first1, InputIterator last1, + ForwardIterator first2, ForwardIterator last2, + const T& x) { + ForwardIterator mid2 = uninitialized_copy(first1, last1, first2); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_fill(mid2, last2, x); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(first2, mid2); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +#endif /* _SGI_STL_ALGOBASE_H */ diff --git a/libstdc++/stl/alloc.h b/libstdc++/stl/alloc.h new file mode 100644 index 000000000000..917ce8fdb801 --- /dev/null +++ b/libstdc++/stl/alloc.h @@ -0,0 +1,674 @@ +/* + * Copyright (c) 1996-1997 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __ALLOC_H +#define __ALLOC_H + +#include + +#ifdef __SUNPRO_CC +# define __PRIVATE public + // Extra access restrictions prevent us from really making some things + // private. +#else +# define __PRIVATE private +#endif + +#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG +# define __USE_MALLOC +#endif + + +// This implements some standard node allocators. These are +// NOT the same as the allocators in the C++ draft standard or in +// in the original STL. They do not encapsulate different pointer +// types; indeed we assume that there is only one pointer type. +// The allocation primitives are intended to allocate individual objects, +// not larger arenas as with the original STL allocators. + +#if 0 +# include +# define __THROW_BAD_ALLOC throw bad_alloc +#elif !defined(__THROW_BAD_ALLOC) +# include +# define __THROW_BAD_ALLOC cerr << "out of memory" << endl; exit(1) +#endif + +#ifndef __ALLOC +# define __ALLOC alloc +#endif +#ifdef __STL_WIN32THREADS +# include +// This must precede stl_config.h +#endif + +#include +#include +#include +#include +#ifndef __RESTRICT +# define __RESTRICT +#endif + +#if !defined(_PTHREADS) && !defined(_NOTHREADS) \ + && !defined(__STL_SGI_THREADS) && !defined(__STL_WIN32THREADS) +# define _NOTHREADS +#endif + +# ifdef _PTHREADS + // POSIX Threads + // This is dubious, since this is likely to be a high contention + // lock. Performance may not be adequate. +# include +# define __NODE_ALLOCATOR_LOCK \ + if (threads) pthread_mutex_lock(&__node_allocator_lock) +# define __NODE_ALLOCATOR_UNLOCK \ + if (threads) pthread_mutex_unlock(&__node_allocator_lock) +# define __NODE_ALLOCATOR_THREADS true +# define __VOLATILE volatile // Needed at -O3 on SGI +# endif +# ifdef __STL_WIN32THREADS + // The lock needs to be initialized by constructing an allocator + // objects of the right type. We do that here explicitly for alloc. +# define __NODE_ALLOCATOR_LOCK \ + EnterCriticalSection(&__node_allocator_lock) +# define __NODE_ALLOCATOR_UNLOCK \ + LeaveCriticalSection(&__node_allocator_lock) +# define __NODE_ALLOCATOR_THREADS true +# define __VOLATILE volatile // may not be needed +# endif /* WIN32THREADS */ +# ifdef __STL_SGI_THREADS + // This should work without threads, with sproc threads, or with + // pthreads. It is suboptimal in all cases. + // It is unlikely to even compile on nonSGI machines. +# include +# define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \ + { __lock(&__node_allocator_lock); } +# define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \ + { __unlock(&__node_allocator_lock); } +# define __NODE_ALLOCATOR_THREADS true +# define __VOLATILE volatile // Needed at -O3 on SGI +# endif +# ifdef _NOTHREADS +// Thread-unsafe +# define __NODE_ALLOCATOR_LOCK +# define __NODE_ALLOCATOR_UNLOCK +# define __NODE_ALLOCATOR_THREADS false +# define __VOLATILE +# endif + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma set woff 1174 +#endif + +// Malloc-based allocator. Typically slower than default alloc below. +// Typically thread-safe and more storage efficient. +#ifdef __STL_STATIC_TEMPLATE_MEMBER_BUG +# ifdef __DECLARE_GLOBALS_HERE + void (* __malloc_alloc_oom_handler)() = 0; + // g++ 2.7.2 does not handle static template data members. +# else + extern void (* __malloc_alloc_oom_handler)(); +# endif +#endif + +template +class __malloc_alloc_template { + +private: + +static void *oom_malloc(size_t); + +static void *oom_realloc(void *, size_t); + +#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG + static void (* __malloc_alloc_oom_handler)(); +#endif + +public: + +static void * allocate(size_t n) +{ + void *result = malloc(n); + if (0 == result) result = oom_malloc(n); + return result; +} + +static void deallocate(void *p, size_t /* n */) +{ + free(p); +} + +static void * reallocate(void *p, size_t /* old_sz */, size_t new_sz) +{ + void * result = realloc(p, new_sz); + if (0 == result) result = oom_realloc(p, new_sz); + return result; +} + +static void (* set_malloc_handler(void (*f)()))() +{ + void (* old)() = __malloc_alloc_oom_handler; + __malloc_alloc_oom_handler = f; + return(old); +} + +}; + +// malloc_alloc out-of-memory handling + +#ifndef __STL_STATIC_TEMPLATE_MEMBER_BUG +template +void (* __malloc_alloc_template::__malloc_alloc_oom_handler)() = 0; +#endif + +template +void * __malloc_alloc_template::oom_malloc(size_t n) +{ + void (* my_malloc_handler)(); + void *result; + + for (;;) { + my_malloc_handler = __malloc_alloc_oom_handler; + if (0 == my_malloc_handler) { __THROW_BAD_ALLOC; } + (*my_malloc_handler)(); + result = malloc(n); + if (result) return(result); + } +} + +template +void * __malloc_alloc_template::oom_realloc(void *p, size_t n) +{ + void (* my_malloc_handler)(); + void *result; + + for (;;) { + my_malloc_handler = __malloc_alloc_oom_handler; + if (0 == my_malloc_handler) { __THROW_BAD_ALLOC; } + (*my_malloc_handler)(); + result = realloc(p, n); + if (result) return(result); + } +} + +typedef __malloc_alloc_template<0> malloc_alloc; + +template +class simple_alloc { + +public: + static T *allocate(size_t n) + { return 0 == n? 0 : (T*) Alloc::allocate(n * sizeof (T)); } + static T *allocate(void) + { return (T*) Alloc::allocate(sizeof (T)); } + static void deallocate(T *p, size_t n) + { if (0 != n) Alloc::deallocate(p, n * sizeof (T)); } + static void deallocate(T *p) + { Alloc::deallocate(p, sizeof (T)); } +}; + +// Allocator adaptor to check size arguments for debugging. +// Reports errors using assert. Checking can be disabled with +// NDEBUG, but it's far better to just use the underlying allocator +// instead when no checking is desired. +// There is some evidence that this can confuse Purify. +template +class debug_alloc { + +private: + +enum {extra = 8}; // Size of space used to store size. Note + // that this must be large enough to preserve + // alignment. + +public: + +static void * allocate(size_t n) +{ + char *result = (char *)Alloc::allocate(n + extra); + *(size_t *)result = n; + return result + extra; +} + +static void deallocate(void *p, size_t n) +{ + char * real_p = (char *)p - extra; + assert(*(size_t *)real_p == n); + Alloc::deallocate(real_p, n + extra); +} + +static void * reallocate(void *p, size_t old_sz, size_t new_sz) +{ + char * real_p = (char *)p - extra; + assert(*(size_t *)real_p == old_sz); + char * result = (char *) + Alloc::reallocate(real_p, old_sz + extra, new_sz + extra); + *(size_t *)result = new_sz; + return result + extra; +} + + +}; + + +# ifdef __USE_MALLOC + +typedef malloc_alloc alloc; +typedef malloc_alloc single_client_alloc; + +# else + + +// Default node allocator. +// With a reasonable compiler, this should be roughly as fast as the +// original STL class-specific allocators, but with less fragmentation. +// Default_alloc_template parameters are experimental and MAY +// DISAPPEAR in the future. Clients should just use alloc for now. +// +// Important implementation properties: +// 1. If the client request an object of size > __MAX_BYTES, the resulting +// object will be obtained directly from malloc. +// 2. In all other cases, we allocate an object of size exactly +// ROUND_UP(requested_size). Thus the client has enough size +// information that we can return the object to the proper free list +// without permanently losing part of the object. +// + +// The first template parameter specifies whether more than one thread +// may use this allocator. It is safe to allocate an object from +// one instance of a default_alloc and deallocate it with another +// one. This effectively transfers its ownership to the second one. +// This may have undesirable effects on reference locality. +// The second parameter is unreferenced and serves only to allow the +// creation of multiple default_alloc instances. +// Node that containers built on different allocator instances have +// different types, limiting the utility of this approach. +#ifdef __SUNPRO_CC +// breaks if we make these template class members: + enum {__ALIGN = 8}; + enum {__MAX_BYTES = 128}; + enum {__NFREELISTS = __MAX_BYTES/__ALIGN}; +#endif + +template +class __default_alloc_template { + +private: + // Really we should use static const int x = N + // instead of enum { x = N }, but few compilers accept the former. +# ifndef __SUNPRO_CC + enum {__ALIGN = 8}; + enum {__MAX_BYTES = 128}; + enum {__NFREELISTS = __MAX_BYTES/__ALIGN}; +# endif + static size_t ROUND_UP(size_t bytes) { + return (((bytes) + __ALIGN-1) & ~(__ALIGN - 1)); + } +__PRIVATE: + union obj { + union obj * free_list_link; + char client_data[1]; /* The client sees this. */ + }; +private: +# ifdef __SUNPRO_CC + static obj * __VOLATILE free_list[]; + // Specifying a size results in duplicate def for 4.1 +# else + static obj * __VOLATILE free_list[__NFREELISTS]; +# endif + static size_t FREELIST_INDEX(size_t bytes) { + return (((bytes) + __ALIGN-1)/__ALIGN - 1); + } + + // Returns an object of size n, and optionally adds to size n free list. + static void *refill(size_t n); + // Allocates a chunk for nobjs of size size. nobjs may be reduced + // if it is inconvenient to allocate the requested number. + static char *chunk_alloc(size_t size, int &nobjs); + + // Chunk allocation state. + static char *start_free; + static char *end_free; + static size_t heap_size; + +# ifdef __STL_SGI_THREADS + static volatile unsigned long __node_allocator_lock; + static void __lock(volatile unsigned long *); + static inline void __unlock(volatile unsigned long *); +# endif + +# ifdef _PTHREADS + static pthread_mutex_t __node_allocator_lock; +# endif + +# ifdef __STL_WIN32THREADS + static CRITICAL_SECTION __node_allocator_lock; + static bool __node_allocator_lock_initialized; + + public: + __default_alloc_template() { + // This assumes the first constructor is called before threads + // are started. + if (!__node_allocator_lock_initialized) { + InitializeCriticalSection(&__node_allocator_lock); + __node_allocator_lock_initialized = true; + } + } + private: +# endif + + class lock { + public: + lock() { __NODE_ALLOCATOR_LOCK; } + ~lock() { __NODE_ALLOCATOR_UNLOCK; } + }; + friend class lock; + +public: + + /* n must be > 0 */ + static void * allocate(size_t n) + { + obj * __VOLATILE * my_free_list; + obj * __RESTRICT result; + + if (n > __MAX_BYTES) { + return(malloc_alloc::allocate(n)); + } + my_free_list = free_list + FREELIST_INDEX(n); + // Acquire the lock here with a constructor call. + // This ensures that it is released in exit or during stack + // unwinding. + /*REFERENCED*/ + lock lock_instance; + result = *my_free_list; + if (result == 0) { + void *r = refill(ROUND_UP(n)); + return r; + } + *my_free_list = result -> free_list_link; + return (result); + }; + + /* p may not be 0 */ + static void deallocate(void *p, size_t n) + { + obj *q = (obj *)p; + obj * __VOLATILE * my_free_list; + + if (n > __MAX_BYTES) { + malloc_alloc::deallocate(p, n); + return; + } + my_free_list = free_list + FREELIST_INDEX(n); + // acquire lock + /*REFERENCED*/ + lock lock_instance; + q -> free_list_link = *my_free_list; + *my_free_list = q; + // lock is released here + } + + static void * reallocate(void *p, size_t old_sz, size_t new_sz); + +} ; + +typedef __default_alloc_template<__NODE_ALLOCATOR_THREADS, 0> alloc; +typedef __default_alloc_template single_client_alloc; + + + +/* We allocate memory in large chunks in order to avoid fragmenting */ +/* the malloc heap too much. */ +/* We assume that size is properly aligned. */ +/* We hold the allocation lock. */ +template +char* +__default_alloc_template::chunk_alloc(size_t size, int& nobjs) +{ + char * result; + size_t total_bytes = size * nobjs; + size_t bytes_left = end_free - start_free; + + if (bytes_left >= total_bytes) { + result = start_free; + start_free += total_bytes; + return(result); + } else if (bytes_left >= size) { + nobjs = bytes_left/size; + total_bytes = size * nobjs; + result = start_free; + start_free += total_bytes; + return(result); + } else { + size_t bytes_to_get = 2 * total_bytes + ROUND_UP(heap_size >> 4); + // Try to make use of the left-over piece. + if (bytes_left > 0) { + obj * __VOLATILE * my_free_list = + free_list + FREELIST_INDEX(bytes_left); + + ((obj *)start_free) -> free_list_link = *my_free_list; + *my_free_list = (obj *)start_free; + } + start_free = (char *)malloc(bytes_to_get); + if (0 == start_free) { + int i; + obj * __VOLATILE * my_free_list, *p; + // Try to make do with what we have. That can't + // hurt. We do not try smaller requests, since that tends + // to result in disaster on multi-process machines. + for (i = size; i <= __MAX_BYTES; i += __ALIGN) { + my_free_list = free_list + FREELIST_INDEX(i); + p = *my_free_list; + if (0 != p) { + *my_free_list = p -> free_list_link; + start_free = (char *)p; + end_free = start_free + i; + return(chunk_alloc(size, nobjs)); + // Any leftover piece will eventually make it to the + // right free list. + } + } + start_free = (char *)malloc_alloc::allocate(bytes_to_get); + // This should either throw an + // exception or remedy the situation. Thus we assume it + // succeeded. + } + heap_size += bytes_to_get; + end_free = start_free + bytes_to_get; + return(chunk_alloc(size, nobjs)); + } +} + + +/* Returns an object of size n, and optionally adds to size n free list.*/ +/* We assume that n is properly aligned. */ +/* We hold the allocation lock. */ +template +void* __default_alloc_template::refill(size_t n) +{ + int nobjs = 20; + char * chunk = chunk_alloc(n, nobjs); + obj * __VOLATILE * my_free_list; + obj * result; + obj * current_obj, * next_obj; + int i; + + if (1 == nobjs) return(chunk); + my_free_list = free_list + FREELIST_INDEX(n); + + /* Build free list in chunk */ + result = (obj *)chunk; + *my_free_list = next_obj = (obj *)(chunk + n); + for (i = 1; ; i++) { + current_obj = next_obj; + next_obj = (obj *)((char *)next_obj + n); + if (nobjs - 1 == i) { + current_obj -> free_list_link = 0; + break; + } else { + current_obj -> free_list_link = next_obj; + } + } + return(result); +} + +template +void* +__default_alloc_template::reallocate(void *p, + size_t old_sz, + size_t new_sz) +{ + void * result; + size_t copy_sz; + + if (old_sz > __MAX_BYTES && new_sz > __MAX_BYTES) { + return(realloc(p, new_sz)); + } + if (ROUND_UP(old_sz) == ROUND_UP(new_sz)) return(p); + result = allocate(new_sz); + copy_sz = new_sz > old_sz? old_sz : new_sz; + memcpy(result, p, copy_sz); + deallocate(p, old_sz); + return(result); +} + +#ifdef _PTHREADS + template + pthread_mutex_t + __default_alloc_template::__node_allocator_lock + = PTHREAD_MUTEX_INITIALIZER; +#endif + +#ifdef __STL_WIN32THREADS + template CRITICAL_SECTION + __default_alloc_template::__node_allocator_lock; + + template bool + __default_alloc_template::__node_allocator_lock_initialized + = false; +#endif + +#ifdef __STL_SGI_THREADS +#include +#include +// Somewhat generic lock implementations. We need only test-and-set +// and some way to sleep. These should work with both SGI pthreads +// and sproc threads. They may be useful on other systems. +template +volatile unsigned long +__default_alloc_template::__node_allocator_lock = 0; + +#if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) || defined(__GNUC__) +# define __test_and_set(l,v) test_and_set(l,v) +#endif + +template +void +__default_alloc_template::__lock(volatile unsigned long *lock) +{ + const unsigned low_spin_max = 30; // spin cycles if we suspect uniprocessor + const unsigned high_spin_max = 1000; // spin cycles for multiprocessor + static unsigned spin_max = low_spin_max; + unsigned my_spin_max; + static unsigned last_spins = 0; + unsigned my_last_spins; + static struct timespec ts = {0, 1000}; + unsigned junk; +# define __ALLOC_PAUSE junk *= junk; junk *= junk; junk *= junk; junk *= junk + int i; + + if (!__test_and_set((unsigned long *)lock, 1)) { + return; + } + my_spin_max = spin_max; + my_last_spins = last_spins; + for (i = 0; i < my_spin_max; i++) { + if (i < my_last_spins/2 || *lock) { + __ALLOC_PAUSE; + continue; + } + if (!__test_and_set((unsigned long *)lock, 1)) { + // got it! + // Spinning worked. Thus we're probably not being scheduled + // against the other process with which we were contending. + // Thus it makes sense to spin longer the next time. + last_spins = i; + spin_max = high_spin_max; + return; + } + } + // We are probably being scheduled against the other process. Sleep. + spin_max = low_spin_max; + for (;;) { + if (!__test_and_set((unsigned long *)lock, 1)) { + return; + } + nanosleep(&ts, 0); + } +} + +template +inline void +__default_alloc_template::__unlock(volatile unsigned long *lock) +{ +# if defined(__GNUC__) && __mips >= 3 + asm("sync"); + *lock = 0; +# elif __mips >= 3 && (defined (_ABIN32) || defined(_ABI64)) + __lock_release(lock); +# else + *lock = 0; + // This is not sufficient on many multiprocessors, since + // writes to protected variables and the lock may be reordered. +# endif +} +#endif + +template +char *__default_alloc_template::start_free = 0; + +template +char *__default_alloc_template::end_free = 0; + +template +size_t __default_alloc_template::heap_size = 0; + +template +__default_alloc_template::obj * __VOLATILE +__default_alloc_template ::free_list[ +# ifdef __SUNPRO_CC + __NFREELISTS +# else + __default_alloc_template::__NFREELISTS +# endif +] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; +// The 16 zeros are necessary to make version 4.1 of the SunPro +// compiler happy. Otherwise it appears to allocate too little +// space for the array. + +# ifdef __STL_WIN32THREADS + // Create one to get critical section initialized. + // We do this onece per file, but only the first constructor + // does anything. + static alloc __node_allocator_dummy_instance; +# endif + +#endif /* ! __USE_MALLOC */ + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma reset woff 1174 +#endif + +#endif /* __NODE_ALLOC_H */ diff --git a/libstdc++/stl/bvector.h b/libstdc++/stl/bvector.h new file mode 100644 index 000000000000..27878799aea4 --- /dev/null +++ b/libstdc++/stl/bvector.h @@ -0,0 +1,585 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +// vector is replaced by bit_vector at present because partial +// specialization is not yet implemented. + +#ifndef __SGI_STL_BVECTOR_H +#define __SGI_STL_BVECTOR_H + +#include +#include +#include + + +#define __WORD_BIT (int(CHAR_BIT*sizeof(unsigned int))) + +class bit_vector { +public: + typedef bool value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + class iterator; + class const_iterator; + + class reference { + friend class iterator; + friend class const_iterator; + protected: + unsigned int* p; + unsigned int mask; + reference(unsigned int* x, unsigned int y) : p(x), mask(y) {} + public: + reference() : p(0), mask(0) {} + operator bool() const { return !(!(*p & mask)); } + reference& operator=(bool x) { + if (x) + *p |= mask; + else + *p &= ~mask; + return *this; + } + reference& operator=(const reference& x) { return *this = bool(x); } + bool operator==(const reference& x) const { + return bool(*this) == bool(x); + } + bool operator<(const reference& x) const { + return bool(*this) < bool(x); + } + void flip() { *p ^= mask; } + }; + + typedef bool const_reference; + + typedef reference bit_reference; + typedef const_reference bit_const_reference; + + class iterator : public random_access_iterator { + friend class bit_vector; + friend class const_iterator; + public: + typedef bit_reference reference; + protected: + unsigned int* p; + unsigned int offset; + void bump_up() { + if (offset++ == __WORD_BIT - 1) { + offset = 0; + ++p; + } + } + void bump_down() { + if (offset-- == 0) { + offset = __WORD_BIT - 1; + --p; + } + } + public: + iterator() : p(0), offset(0) {} + iterator(unsigned int* x, unsigned int y) : p(x), offset(y) {} + reference operator*() const { return reference(p, 1U << offset); } + iterator& operator++() { + bump_up(); + return *this; + } + iterator operator++(int) { + iterator tmp = *this; + bump_up(); + return tmp; + } + iterator& operator--() { + bump_down(); + return *this; + } + iterator operator--(int) { + iterator tmp = *this; + bump_down(); + return tmp; + } + iterator& operator+=(difference_type i) { + difference_type n = i + offset; + p += n / __WORD_BIT; + n = n % __WORD_BIT; + if (n < 0) { + offset = n + __WORD_BIT; + --p; + } else + offset = n; + return *this; + } + iterator& operator-=(difference_type i) { + *this += -i; + return *this; + } + iterator operator+(difference_type i) const { + iterator tmp = *this; + return tmp += i; + } + iterator operator-(difference_type i) const { + iterator tmp = *this; + return tmp -= i; + } + difference_type operator-(iterator x) const { + return __WORD_BIT * (p - x.p) + offset - x.offset; + } + reference operator[](difference_type i) { return *(*this + i); } + bool operator==(const iterator& x) const { + return p == x.p && offset == x.offset; + } + bool operator!=(const iterator& x) const { + return p != x.p || offset != x.offset; + } + bool operator<(iterator x) const { + return p < x.p || (p == x.p && offset < x.offset); + } + }; + + class const_iterator : public random_access_iterator + { + friend class bit_vector; + public: + typedef bit_const_reference reference; + protected: + unsigned int* p; + unsigned int offset; + void bump_up() { + if (offset++ == __WORD_BIT - 1) { + offset = 0; + ++p; + } + } + void bump_down() { + if (offset-- == 0) { + offset = __WORD_BIT - 1; + --p; + } + } + public: + const_iterator() : p(0), offset(0) {} + const_iterator(unsigned int* x, unsigned int y) : p(x), offset(y) {} + const_iterator(const iterator& x) : p(x.p), offset(x.offset) {} + const_reference operator*() const { + return bit_vector::reference(p, 1U << offset); + } + const_iterator& operator++() { + bump_up(); + return *this; + } + const_iterator operator++(int) { + const_iterator tmp = *this; + bump_up(); + return tmp; + } + const_iterator& operator--() { + bump_down(); + return *this; + } + const_iterator operator--(int) { + const_iterator tmp = *this; + bump_down(); + return tmp; + } + const_iterator& operator+=(difference_type i) { + difference_type n = i + offset; + p += n / __WORD_BIT; + n = n % __WORD_BIT; + if (n < 0) { + offset = n + __WORD_BIT; + --p; + } else + offset = n; + return *this; + } + const_iterator& operator-=(difference_type i) { + *this += -i; + return *this; + } + const_iterator operator+(difference_type i) const { + const_iterator tmp = *this; + return tmp += i; + } + const_iterator operator-(difference_type i) const { + const_iterator tmp = *this; + return tmp -= i; + } + difference_type operator-(const_iterator x) const { + return __WORD_BIT * (p - x.p) + offset - x.offset; + } + const_reference operator[](difference_type i) { + return *(*this + i); + } + bool operator==(const const_iterator& x) const { + return p == x.p && offset == x.offset; + } + bool operator!=(const const_iterator& x) const { + return p != x.p || offset != x.offset; + } + bool operator<(const_iterator x) const { + return p < x.p || (p == x.p && offset < x.offset); + } + }; + + typedef reverse_iterator const_reverse_iterator; + typedef reverse_iterator + reverse_iterator; + +protected: + typedef simple_alloc data_allocator; + iterator start; + iterator finish; + unsigned int* end_of_storage; + unsigned int* bit_alloc(size_type n) { + return data_allocator::allocate((n + __WORD_BIT - 1)/__WORD_BIT); + } + void deallocate() { + if (start.p) + data_allocator::deallocate(start.p, end_of_storage - start.p); + } + void initialize(size_type n) { + unsigned int* q = bit_alloc(n); + end_of_storage = q + (n + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + finish = start + n; + } + void insert_aux(iterator position, bool x) { + if (finish.p != end_of_storage) { + copy_backward(position, finish, finish + 1); + *position = x; + ++finish; + } else { + size_type len = size() ? 2 * size() : __WORD_BIT; + unsigned int* q = bit_alloc(len); + iterator i = copy(begin(), position, iterator(q, 0)); + *i++ = x; + finish = copy(position, end(), i); + deallocate(); + end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } + } + +#ifdef __STL_MEMBER_TEMPLATES + template + void initialize_range(InputIterator first, InputIterator last, + input_iterator_tag) { + start = iterator(); + finish = iterator(); + end_of_storage = 0; + for ( ; first != last; ++first) + push_back(*first); + } + + template + void initialize_range(ForwardIterator first, ForwardIterator last, + forward_iterator_tag) { + size_type n = 0; + distance(first, last, n); + initialize(n); + copy(first, last, start); + } + + template + void initialize_range(BidirectionalIterator first, + BidirectionalIterator last, + bidirectional_iterator_tag) { + initialize_range(first, last, forward_iterator_tag()); + } + + template + void initialize_range(RandomAccessIterator first, + RandomAccessIterator last, + random_access_iterator_tag) { + initialize_range(first, last, forward_iterator_tag()); + } + + template + void insert_range(iterator pos, + InputIterator first, InputIterator last, + input_iterator_tag) { + for ( ; first != last; ++first) { + pos = insert(pos, *first); + ++pos; + } + } + + template + void insert_range(iterator position, + ForwardIterator first, ForwardIterator last, + forward_iterator_tag) { + if (first != last) { + size_type n = 0; + distance(first, last, n); + if (capacity() - size() >= n) { + copy_backward(position, end(), finish + n); + copy(first, last, position); + finish += n; + } + else { + size_type len = size() + max(size(), n); + unsigned int* q = bit_alloc(len); + iterator i = copy(begin(), position, iterator(q, 0)); + i = copy(first, last, i); + finish = copy(position, end(), i); + deallocate(); + end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } + } + } + + template + void insert_range(iterator pos, + BidirectionalIterator first, BidirectionalIterator last, + bidirectional_iterator_tag) { + insert_range(pos, first, last, forward_iterator_tag()); + } + + template + void insert_range(iterator pos, + RandomAccessIterator first, RandomAccessIterator last, + random_access_iterator_tag) { + insert_range(pos, first, last, forward_iterator_tag()); + } + +#endif /* __STL_MEMBER_TEMPLATES */ + + typedef bit_vector self; +public: + iterator begin() { return start; } + const_iterator begin() const { return start; } + iterator end() { return finish; } + const_iterator end() const { return finish; } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + size_type size() const { return size_type(end() - begin()); } + size_type max_size() const { return size_type(-1); } + size_type capacity() const { + return size_type(const_iterator(end_of_storage, 0) - begin()); + } + bool empty() const { return begin() == end(); } + reference operator[](size_type n) { return *(begin() + n); } + const_reference operator[](size_type n) const { return *(begin() + n); } + bit_vector() : start(iterator()), finish(iterator()), end_of_storage(0) {} + bit_vector(size_type n, bool value) { + initialize(n); + fill(start.p, end_of_storage, value ? ~0 : 0); + } + bit_vector(int n, bool value) { + initialize(n); + fill(start.p, end_of_storage, value ? ~0 : 0); + } + bit_vector(long n, bool value) { + initialize(n); + fill(start.p, end_of_storage, value ? ~0 : 0); + } + explicit bit_vector(size_type n) { + initialize(n); + fill(start.p, end_of_storage, 0); + } + bit_vector(const self& x) { + initialize(x.size()); + copy(x.begin(), x.end(), start); + } + +#ifdef __STL_MEMBER_TEMPLATES + template + bit_vector(InputIterator first, InputIterator last) { + initialize_range(first, last, iterator_category(first)); + } +#else /* __STL_MEMBER_TEMPLATES */ + bit_vector(const_iterator first, const_iterator last) { + size_type n = 0; + distance(first, last, n); + initialize(n); + copy(first, last, start); + } + bit_vector(const bool* first, const bool* last) { + size_type n = 0; + distance(first, last, n); + initialize(n); + copy(first, last, start); + } +#endif /* __STL_MEMBER_TEMPLATES */ + + ~bit_vector() { deallocate(); } + self& operator=(const self& x) { + if (&x == this) return *this; + if (x.size() > capacity()) { + deallocate(); + initialize(x.size()); + } + copy(x.begin(), x.end(), begin()); + finish = begin() + x.size(); + return *this; + } + void reserve(size_type n) { + if (capacity() < n) { + unsigned int* q = bit_alloc(n); + finish = copy(begin(), end(), iterator(q, 0)); + deallocate(); + start = iterator(q, 0); + end_of_storage = q + (n + __WORD_BIT - 1)/__WORD_BIT; + } + } + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(end() - 1); } + const_reference back() const { return *(end() - 1); } + void push_back(bool x) { + if (finish.p != end_of_storage) + *finish++ = x; + else + insert_aux(end(), x); + } + void swap(bit_vector& x) { + ::swap(start, x.start); + ::swap(finish, x.finish); + ::swap(end_of_storage, x.end_of_storage); + } + iterator insert(iterator position, bool x = bool()) { + size_type n = position - begin(); + if (finish.p != end_of_storage && position == end()) + *finish++ = x; + else + insert_aux(position, x); + return begin() + n; + } + +#ifdef __STL_MEMBER_TEMPLATES + template void insert(iterator position, + InputIterator first, + InputIterator last) { + insert_range(position, first, last, iterator_category(first)); + } +#else /* __STL_MEMBER_TEMPLATES */ + void insert(iterator position, const_iterator first, + const_iterator last) { + if (first == last) return; + size_type n = 0; + distance(first, last, n); + if (capacity() - size() >= n) { + copy_backward(position, end(), finish + n); + copy(first, last, position); + finish += n; + } else { + size_type len = size() + max(size(), n); + unsigned int* q = bit_alloc(len); + iterator i = copy(begin(), position, iterator(q, 0)); + i = copy(first, last, i); + finish = copy(position, end(), i); + deallocate(); + end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } + } + + void insert(iterator position, const bool* first, const bool* last) { + if (first == last) return; + size_type n = 0; + distance(first, last, n); + if (capacity() - size() >= n) { + copy_backward(position, end(), finish + n); + copy(first, last, position); + finish += n; + } else { + size_type len = size() + max(size(), n); + unsigned int* q = bit_alloc(len); + iterator i = copy(begin(), position, iterator(q, 0)); + i = copy(first, last, i); + finish = copy(position, end(), i); + deallocate(); + end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } + } +#endif /* __STL_MEMBER_TEMPLATES */ + + void insert(iterator position, size_type n, bool x) { + if (n == 0) return; + if (capacity() - size() >= n) { + copy_backward(position, end(), finish + n); + fill(position, position + n, x); + finish += n; + } else { + size_type len = size() + max(size(), n); + unsigned int* q = bit_alloc(len); + iterator i = copy(begin(), position, iterator(q, 0)); + fill_n(i, n, x); + finish = copy(position, end(), i + n); + deallocate(); + end_of_storage = q + (len + __WORD_BIT - 1)/__WORD_BIT; + start = iterator(q, 0); + } + } + + void insert(iterator pos, int n, bool x) { insert(pos, (size_type)n, x); } + void insert(iterator pos, long n, bool x) { insert(pos, (size_type)n, x); } + + void pop_back() { --finish; } + void erase(iterator position) { + if (position + 1 != end()) + copy(position + 1, end(), position); + --finish; + } + void erase(iterator first, iterator last) { + finish = copy(last, end(), first); + } + void resize(size_type new_size, bool x = bool()) { + if (new_size < size()) + erase(begin() + new_size, end()); + else + insert(end(), new_size - size(), x); + } + void clear() { erase(begin(), end()); } +}; + +inline bool operator==(const bit_vector& x, const bit_vector& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +inline bool operator<(const bit_vector& x, const bit_vector& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +inline void swap(bit_vector::reference x, bit_vector::reference y) { + bool tmp = x; + x = y; + y = tmp; +} + +#undef __WORD_BIT + +#endif /* __SGI_STL_BVECTOR_H */ diff --git a/libstdc++/stl/defalloc.h b/libstdc++/stl/defalloc.h new file mode 100644 index 000000000000..e7d24d38c84c --- /dev/null +++ b/libstdc++/stl/defalloc.h @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +// +// Inclusion of this file is DEPRECATED. +// This is the original HP default allocator. +// DO NOT USE THIS FILE unless you have an old container implementation +// that requires an allocator with the HP-style interface. +// SGI STL uses a different allocator interface. +// SGI-style allocators are not parametrized with respect to +// the object type; they traffic in void * pointers. +// This file is not included by any other SGI STL header. +// + +#ifndef DEFALLOC_H +#define DEFALLOC_H + +#include +#include +#include +#include +#include +#include + + +template +inline T* allocate(ptrdiff_t size, T*) { + set_new_handler(0); + T* tmp = (T*)(::operator new((size_t)(size * sizeof(T)))); + if (tmp == 0) { + cerr << "out of memory" << endl; + exit(1); + } + return tmp; +} + + +template +inline void deallocate(T* buffer) { + ::operator delete(buffer); +} + +template +class allocator { +public: + typedef T value_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + pointer allocate(size_type n) { + return ::allocate((difference_type)n, (pointer)0); + } + void deallocate(pointer p) { ::deallocate(p); } + pointer address(reference x) { return (pointer)&x; } + const_pointer const_address(const_reference x) { + return (const_pointer)&x; + } + size_type init_page_size() { + return max(size_type(1), size_type(4096/sizeof(T))); + } + size_type max_size() const { + return max(size_type(1), size_type(UINT_MAX/sizeof(T))); + } +}; + +class allocator { +public: + typedef void* pointer; +}; + + + +#endif diff --git a/libstdc++/stl/deque.h b/libstdc++/stl/deque.h new file mode 100644 index 000000000000..6685abffe7ce --- /dev/null +++ b/libstdc++/stl/deque.h @@ -0,0 +1,1452 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_DEQUE_H +#define __SGI_STL_DEQUE_H + +/* Class invariants: + * For any nonsingular iterator i: + * i.node is the address of an element in the map array. The + * contents of i.node is a pointer to the beginning of a node. + * i.first == *(i.node) + * i.last == i.first + node_size + * i.cur is a pointer in the range [i.first, i.last). NOTE: + * the implication of this is that i.cur is always a dereferenceable + * pointer, even if i is a past-the-end iterator. + * Start and Finish are always nonsingular iterators. NOTE: this means + * that an empty deque must have one node, and that a deque + * with N elements, where N is the buffer size, must have two nodes. + * For every node other than start.node and finish.node, every element + * in the node is an initialized object. If start.node == finish.node, + * then [start.cur, finish.cur) are initialized objects, and + * the elements outside that range are uninitialized storage. Otherwise, + * [start.cur, start.last) and [finish.first, finish.cur) are initialized + * objects, and [start.first, start.cur) and [finish.cur, finish.last) + * are uninitialized storage. + * [map, map + map_size) is a valid, non-empty range. + * [start.node, finish.node] is a valid range contained within + * [map, map + map_size). + * A pointer in the range [map, map + map_size) points to an allocated + * node if and only if the pointer is in the range [start.node, finish.node]. + */ + + +/* + * In previous versions of deque, node_size was fixed by the + * implementation. In this version, however, users can select + * the node size. Deque has three template parameters; the third, + * a number of type size_t, is the number of elements per node. + * If the third template parameter is 0 (which is the default), + * then deque will use a default node size. + * + * The only reason for using an alternate node size is if your application + * requires a different performance tradeoff than the default. If, + * for example, your program contains many deques each of which contains + * only a few elements, then you might want to save memory (possibly + * by sacrificing some speed) by using smaller nodes. + * + * Unfortunately, some compilers have trouble with non-type template + * parameters; stl_config.h defines __STL_NON_TYPE_TMPL_PARAM_BUG if + * that is the case. If your compiler is one of them, then you will + * not be able to use alternate node sizes; you will have to use the + * default value. + */ + +#include +#include +#include + +// Note: this function is simply a kludge to work around several compilers' +// bugs in handling constant expressions. +inline size_t __deque_buf_size(size_t n, size_t sz) +{ + return n != 0 ? n : (sz < 512 ? size_t(512 / sz) : size_t(1)); +} + +#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG +template +struct __deque_iterator { + typedef __deque_iterator iterator; + typedef __deque_iterator const_iterator; + static size_t buffer_size() {return __deque_buf_size(BufSiz, sizeof(T)); } +#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */ +template +struct __deque_iterator { + typedef __deque_iterator iterator; + typedef __deque_iterator const_iterator; + static size_t buffer_size() {return __deque_buf_size(0, sizeof(T)); } +#endif + + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef pointer* map_pointer; + + typedef __deque_iterator self; + + pointer cur; + pointer first; + pointer last; + map_pointer node; + + __deque_iterator(pointer x, map_pointer y) + : cur(x), first(*y), last(*y + buffer_size()), node(y) {} + __deque_iterator() : cur(0), first(0), last(0), node(0) {} + __deque_iterator(const iterator& x) + : cur(x.cur), first(x.first), last(x.last), node(x.node) {} + + Ref operator*() const { return *cur; } + + difference_type operator-(const self& x) const { + return buffer_size() * (node - x.node - 1) + + (cur - first) + (x.last - x.cur); + } + + self& operator++() { + ++cur; + if (cur == last) { + set_node(node + 1); + cur = first; + } + return *this; + } + self operator++(int) { + self tmp = *this; + ++*this; + return tmp; + } + + self& operator--() { + if (cur == first) { + set_node(node - 1); + cur = last; + } + --cur; + return *this; + } + self operator--(int) { + self tmp = *this; + --*this; + return tmp; + } + + self& operator+=(difference_type n) { + difference_type offset = n + (cur - first); + if (offset >= 0 && offset < buffer_size()) + cur += n; + else { + difference_type node_offset = + offset > 0 ? offset / buffer_size() + : -difference_type((-offset - 1) / buffer_size()) - 1; + set_node(node + node_offset); + cur = first + (offset - node_offset * buffer_size()); + } + return *this; + } + + self operator+(difference_type n) const { + self tmp = *this; + return tmp += n; + } + + self& operator-=(difference_type n) { return *this += -n; } + + self operator-(difference_type n) const { + self tmp = *this; + return tmp -= n; + } + + Ref operator[](difference_type n) const { return *(*this + n); } + + bool operator==(const self& x) const { return cur == x.cur; } + bool operator!=(const self& x) const { return !(*this == x); } + bool operator<(const self& x) const { + return (node == x.node) ? (cur < x.cur) : (node < x.node); + } + + void set_node(map_pointer new_node) { + node = new_node; + first = *new_node; + last = first + buffer_size(); + } +}; + +#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG + +template +inline random_access_iterator_tag +iterator_category(const __deque_iterator&) { + return random_access_iterator_tag(); +} + +template +inline T* value_type(const __deque_iterator&) { return 0; } + +template +inline ptrdiff_t* distance_type(const __deque_iterator&) { + return 0; +} + +#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */ + +template +inline random_access_iterator_tag +iterator_category(const __deque_iterator&) { + return random_access_iterator_tag(); +} + +template +inline T* value_type(const __deque_iterator&) { return 0; } + +template +inline ptrdiff_t* distance_type(const __deque_iterator&) { + return 0; +} + +#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ + + +// See __deque_buf_size(). The only reason that the default value is 0 +// is as a workaround for bugs in the way that some compilers handle +// constant expressions. +template +class deque { +public: // Basic types + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +public: // Iterators +#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG + typedef __deque_iterator iterator; + typedef __deque_iterator const_iterator; +#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */ + typedef __deque_iterator iterator; + typedef __deque_iterator const_iterator; +#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ + typedef reverse_iterator + const_reverse_iterator; + typedef reverse_iterator + reverse_iterator; + +protected: // Internal typedefs + typedef pointer* map_pointer; + typedef simple_alloc data_allocator; + typedef simple_alloc map_allocator; + + static size_type buffer_size() { + return __deque_buf_size(BufSiz, sizeof(value_type)); + } + static size_type initial_map_size() { return 8; } + +protected: // Data members + iterator start; + iterator finish; + + map_pointer map; + size_type map_size; + +public: // Basic accessors + iterator begin() { return start; } + iterator end() { return finish; } + const_iterator begin() const { return start; } + const_iterator end() const { return finish; } + + reverse_iterator rbegin() { return reverse_iterator(finish); } + reverse_iterator rend() { return reverse_iterator(start); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(finish); + } + const_reverse_iterator rend() const { + return const_reverse_iterator(start); + } + + reference operator[](size_type n) { return start[n]; } + const_reference operator[](size_type n) const { return start[n]; } + + reference front() { return *start; } + reference back() { + iterator tmp = finish; + --tmp; + return *tmp; + } + const_reference front() const { return *start; } + const_reference back() const { + const_iterator tmp = finish; + --tmp; + return *tmp; + } + + size_type size() const { return finish - start;; } + size_type max_size() const { return size_type(-1); } + bool empty() const { return finish == start; } + +public: // Constructor, destructor. + deque() + : start(), finish(), map(0), map_size(0) + { + create_map_and_nodes(0); + } + + deque(const deque& x) + : start(), finish(), map(0), map_size(0) + { + create_map_and_nodes(x.size()); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_copy(x.begin(), x.end(), start); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_map_and_nodes(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + + deque(size_type n, const value_type& value) + : start(), finish(), map(0), map_size(0) { + fill_initialize(n, value); + } + + deque(int n, const value_type& value) + : start(), finish(), map(0), map_size(0) { + fill_initialize(n, value); + } + + deque(long n, const value_type& value) + : start(), finish(), map(0), map_size(0) { + fill_initialize(n, value); + } + + explicit deque(size_type n) + : start(), finish(), map(0), map_size(0) { + fill_initialize(n, value_type()); + } + +#ifdef __STL_MEMBER_TEMPLATES + + template + deque(InputIterator first, InputIterator last) + : start(), finish(), map(0), map_size(0) + { + range_initialize(first, last, iterator_category(first)); + } + +#else /* __STL_MEMBER_TEMPLATES */ + + deque(const value_type* first, const value_type* last) + : start(), finish(), map(0), map_size(0) + { + create_map_and_nodes(last - first); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_copy(first, last, start); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_map_and_nodes(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + + deque(const_iterator first, const_iterator last) + : start(), finish(), map(0), map_size(0) + { + create_map_and_nodes(last - first); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_copy(first, last, start); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_map_and_nodes(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + +#endif /* __STL_MEMBER_TEMPLATES */ + + ~deque() { + destroy(start, finish); + destroy_map_and_nodes(); + } + + deque& operator= (const deque& x) { + const size_type len = size(); + if (&x != this) { + if (len >= x.size()) + erase(copy(x.begin(), x.end(), start), finish); + else { + const_iterator mid = x.begin() + len; + copy(x.begin(), mid, start); + insert(finish, mid, x.end()); + } + } + return *this; + } + + void swap(deque& x) { + ::swap(start, x.start); + ::swap(finish, x.finish); + ::swap(map, x.map); + ::swap(map_size, x.map_size); + } + +public: // push_* and pop_* + + void push_back(const value_type& t) { + if (finish.cur != finish.last - 1) { + construct(finish.cur, t); + ++finish.cur; + } + else + push_back_aux(t); + } + + void push_front(const value_type& t) { + if (start.cur != start.first) { + construct(start.cur - 1, t); + --start.cur; + } + else + push_front_aux(t); + } + + void pop_back() { + if (finish.cur != finish.first) { + --finish.cur; + destroy(finish.cur); + } + else + pop_back_aux(); + } + + void pop_front() { + if (start.cur != start.last - 1) { + destroy(start.cur); + ++start.cur; + } + else + pop_front_aux(); + } + +public: // Insert + + iterator insert(iterator position, const value_type& x) { + if (position.cur == start.cur) { + push_front(x); + return start; + } + else if (position.cur == finish.cur) { + push_back(x); + iterator tmp = finish; + --tmp; + return tmp; + } + else { + return insert_aux(position, x); + } + } + + iterator insert(iterator position) { return insert(position, value_type()); } + + void insert(iterator pos, size_type n, const value_type& x); + + void insert(iterator pos, int n, const value_type& x) { + insert(pos, (size_type) n, x); + } + void insert(iterator pos, long n, const value_type& x) { + insert(pos, (size_type) n, x); + } + +#ifdef __STL_MEMBER_TEMPLATES + + template + void insert(iterator pos, InputIterator first, InputIterator last) { + insert(pos, first, last, iterator_category(first)); + } + +#else /* __STL_MEMBER_TEMPLATES */ + + void insert(iterator pos, const value_type* first, const value_type* last); + void insert(iterator pos, const_iterator first, const_iterator last); + +#endif /* __STL_MEMBER_TEMPLATES */ + + void resize(size_type new_size, const value_type& x) { + const size_type len = size(); + if (new_size < len) + erase(start + new_size, finish); + else + insert(finish, new_size - len, x); + } + + void resize(size_type new_size) { resize(new_size, value_type()); } + +public: // Erase + void erase(iterator pos) { + iterator next = pos; + ++next; + if (pos - start < size() / 2) { + copy_backward(start, pos, next); + pop_front(); + } + else { + copy(next, finish, pos); + pop_back(); + } + } + + void erase(iterator first, iterator last); + void clear(); + +protected: // Internal construction/destruction + + void create_map_and_nodes(size_type num_elements); + void destroy_map_and_nodes(); + void fill_initialize(size_type n, const value_type& value); + +#ifdef __STL_MEMBER_TEMPLATES + + template + void range_initialize(InputIterator first, InputIterator last, + input_iterator_tag); + + template + void range_initialize(ForwardIterator first, ForwardIterator last, + forward_iterator_tag); + + template + void range_initialize(BidirectionalIterator first, + BidirectionalIterator last, + bidirectional_iterator_tag) { + range_initialize(first, last, forward_iterator_tag()); + } + + template + void range_initialize(RandomAccessIterator first, RandomAccessIterator last, + random_access_iterator_tag) { + range_initialize(first, last, forward_iterator_tag()); + } + +#endif /* __STL_MEMBER_TEMPLATES */ + +protected: // Internal push_* and pop_* + + void push_back_aux(const value_type& t); + void push_front_aux(const value_type& t); + void pop_back_aux(); + void pop_front_aux(); + +protected: // Internal insert functions + +#ifdef __STL_MEMBER_TEMPLATES + + template + void insert(iterator pos, InputIterator first, InputIterator last, + input_iterator_tag); + + template + void insert(iterator pos, ForwardIterator first, ForwardIterator last, + forward_iterator_tag); + + template + void insert(iterator pos, + BidirectionalIterator first, BidirectionalIterator last, + bidirectional_iterator_tag) { + insert(pos, first, last, forward_iterator_tag()); + } + + template + void insert(iterator pos, + RandomAccessIterator first, RandomAccessIterator last, + random_access_iterator_tag) { + insert(pos, first, last, forward_iterator_tag()); + } +#endif /* __STL_MEMBER_TEMPLATES */ + + iterator insert_aux(iterator pos, const value_type& x); + void insert_aux(iterator pos, size_type n, const value_type& x); + +#ifdef __STL_MEMBER_TEMPLATES + + template + void insert_aux(iterator pos, ForwardIterator first, ForwardIterator last, + size_type n); + +#else /* __STL_MEMBER_TEMPLATES */ + + void insert_aux(iterator pos, + const value_type* first, const value_type* last, + size_type n); + + void insert_aux(iterator pos, const_iterator first, const_iterator last, + size_type n); + +#endif /* __STL_MEMBER_TEMPLATES */ + + iterator reserve_elements_at_front(size_type n) { + size_type vacancies = start.cur - start.first; + if (n > vacancies) + new_elements_at_front(n - vacancies); + return start - n; + } + + iterator reserve_elements_at_back(size_type n) { + size_type vacancies = (finish.last - finish.cur) - 1; + if (n > vacancies) + new_elements_at_back(n - vacancies); + return finish + n; + } + + void new_elements_at_front(size_type new_elements); + void new_elements_at_back(size_type new_elements); + + void destroy_nodes_at_front(iterator before_start); + void destroy_nodes_at_back(iterator after_finish); + +protected: // Allocation of map and nodes + + // Makes sure the map has space for new nodes. Does not actually + // add the nodes. Can invalidate map pointers. (And consequently, + // deque iterators.) + + void reserve_map_at_back (size_type nodes_to_add = 1) { + if (nodes_to_add + 1 > map_size - (finish.node - map)) + reallocate_map(nodes_to_add, false); + } + + void reserve_map_at_front (size_type nodes_to_add = 1) { + if (nodes_to_add > start.node - map) + reallocate_map(nodes_to_add, true); + } + + void reallocate_map(size_type nodes_to_add, bool add_at_front); + + pointer allocate_node() { return data_allocator::allocate(buffer_size()); } + void deallocate_node(pointer n) { + data_allocator::deallocate(n, buffer_size()); + } + +#ifdef __STL_NON_TYPE_TMPL_PARAM_BUG +public: + bool operator==(const deque& x) const { + return size() == x.size() && equal(begin(), end(), x.begin()); + } + bool operator!=(const deque& x) const { + return size() != x.size() || !equal(begin(), end(), x.begin()); + } + bool operator<(const deque& x) const { + return lexicographical_compare(begin(), end(), x.begin(), x.end()); + } +#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ +}; + +// Non-inline member functions + +template +void deque::insert(iterator pos, + size_type n, const value_type& x) { + if (pos.cur == start.cur) { + iterator new_start = reserve_elements_at_front(n); + uninitialized_fill(new_start, start, x); + start = new_start; + } + else if (pos.cur == finish.cur) { + iterator new_finish = reserve_elements_at_back(n); + uninitialized_fill(finish, new_finish, x); + finish = new_finish; + } + else + insert_aux(pos, n, x); +} + +#ifndef __STL_MEMBER_TEMPLATES + +template +void deque::insert(iterator pos, + const value_type* first, + const value_type* last) { + size_type n = last - first; + if (pos.cur == start.cur) { + iterator new_start = reserve_elements_at_front(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif + uninitialized_copy(first, last, new_start); + start = new_start; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_front(new_start); + throw; + } +# endif + } + else if (pos.cur == finish.cur) { + iterator new_finish = reserve_elements_at_back(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif + uninitialized_copy(first, last, finish); + finish = new_finish; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_back(new_finish); + throw; + } +# endif + } + else + insert_aux(pos, first, last, n); +} + +template +void deque::insert(iterator pos, + const_iterator first, + const_iterator last) +{ + size_type n = last - first; + if (pos.cur == start.cur) { + iterator new_start = reserve_elements_at_front(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif + uninitialized_copy(first, last, new_start); + start = new_start; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_front(new_start); + throw; + } +# endif + } + else if (pos.cur == finish.cur) { + iterator new_finish = reserve_elements_at_back(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif + uninitialized_copy(first, last, finish); + finish = new_finish; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_back(new_finish); + throw; + } +# endif + } + else + insert_aux(pos, first, last, n); +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +template +void deque::erase(iterator first, iterator last) { + if (first == start && last == finish) + clear(); + else { + difference_type n = last - first; + difference_type elems_before = first - start; + if (elems_before < (size() - n) / 2) { + copy_backward(start, first, last); + iterator new_start = start + n; + destroy(start, new_start); + for (map_pointer cur = start.node; cur < new_start.node; ++cur) + data_allocator::deallocate(*cur, buffer_size()); + start = new_start; + } + else { + copy(last, finish, first); + iterator new_finish = finish - n; + destroy(new_finish, finish); + for (map_pointer cur = new_finish.node + 1; cur <= finish.node; ++cur) + data_allocator::deallocate(*cur, buffer_size()); + finish = new_finish; + } + } +} + +template +void deque::clear() { + for (map_pointer node = start.node + 1; node < finish.node; ++node) { + destroy(*node, *node + buffer_size()); + data_allocator::deallocate(*node, buffer_size()); + } + + if (start.node != finish.node) { + destroy(start.cur, start.last); + destroy(finish.first, finish.cur); + data_allocator::deallocate(finish.first, buffer_size()); + } + else + destroy(start.cur, finish.cur); + + finish = start; +} + +template +void deque::create_map_and_nodes(size_type num_elements) { + size_type num_nodes = num_elements / buffer_size() + 1; + + map_size = max(initial_map_size(), num_nodes + 2); + map = map_allocator::allocate(map_size); + + map_pointer nstart = map + (map_size - num_nodes) / 2; + map_pointer nfinish = nstart + num_nodes - 1; + + map_pointer cur; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for (cur = nstart; cur <= nfinish; ++cur) + *cur = allocate_node(); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + for (map_pointer n = nstart; n < cur; ++n) + deallocate_node(*n); + map_allocator::deallocate(map, map_size); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + + start.set_node(nstart); + finish.set_node(nfinish); + start.cur = start.first; + finish.cur = finish.first + num_elements % buffer_size(); +} + +// This is only used as a cleanup function in catch clauses. +template +void deque::destroy_map_and_nodes() { + for (map_pointer cur = start.node; cur <= finish.node; ++cur) + deallocate_node(*cur); + map_allocator::deallocate(map, map_size); +} + + +template +void deque::fill_initialize(size_type n, + const value_type& value) { + create_map_and_nodes(n); + map_pointer cur; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for (cur = start.node; cur < finish.node; ++cur) + uninitialized_fill(*cur, *cur + buffer_size(), value); + uninitialized_fill(finish.first, finish.cur, value); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + for (map_pointer n = start.node; n < cur; ++n) + destroy(*cur, *cur + buffer_size()); + destroy_map_and_nodes(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +#ifdef __STL_MEMBER_TEMPLATES + +template +template +void deque::range_initialize(InputIterator first, + InputIterator last, + input_iterator_tag) { + create_map_and_nodes(0); + for ( ; first != last; ++first) + push_back(*first); +} + +template +template +void deque::range_initialize(ForwardIterator first, + ForwardIterator last, + forward_iterator_tag) { + size_type n = 0; + distance(first, last, n); + create_map_and_nodes(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_copy(first, last, start); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_map_and_nodes(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +// Called only if finish.cur == finish.last - 1. +template +void deque::push_back_aux(const value_type& t) { + value_type t_copy = t; + reserve_map_at_back(); + *(finish.node + 1) = allocate_node(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + construct(finish.cur, t_copy); + finish.set_node(finish.node + 1); + finish.cur = finish.first; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + deallocate_node(*(finish.node + 1)); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +// Called only if start.cur == start.first. +template +void deque::push_front_aux(const value_type& t) { + value_type t_copy = t; + reserve_map_at_front(); + *(start.node - 1) = allocate_node(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + start.set_node(start.node - 1); + start.cur = start.last - 1; + construct(start.cur, t_copy); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + start.set_node(start.node + 1); + start.cur = start.first; + deallocate_node(*(start.node - 1)); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +// Called only if finish.cur == finish.first. +template +void deque:: pop_back_aux() { + deallocate_node(finish.first); + finish.set_node(finish.node - 1); + finish.cur = finish.last - 1; + destroy(finish.cur); +} + +// Called only if start.cur == start.last - 1. Note that if the deque +// has at least one element (a necessary precondition for this member +// function), and if start.cur == start.last, then the deque must have +// at least two nodes. +template +void deque::pop_front_aux() { + destroy(start.cur); + deallocate_node(start.first); + start.set_node(start.node + 1); + start.cur = start.first; +} + +#ifdef __STL_MEMBER_TEMPLATES + +template +template +void deque::insert(iterator pos, + InputIterator first, InputIterator last, + input_iterator_tag) { + copy(first, last, inserter(*this, pos)); +} + +template +template +void deque::insert(iterator pos, + ForwardIterator first, + ForwardIterator last, + forward_iterator_tag) { + size_type n = 0; + distance(first, last, n); + if (pos.cur == start.cur) { + iterator new_start = reserve_elements_at_front(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif + uninitialized_copy(first, last, new_start); + start = new_start; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_front(new_start); + throw; + } +# endif + } + else if (pos.cur == finish.cur) { + iterator new_finish = reserve_elements_at_back(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif + uninitialized_copy(first, last, finish); + finish = new_finish; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_back(new_finish); + throw; + } +# endif + } + else + insert_aux(pos, first, last, n); +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +template +deque::iterator +deque::insert_aux(iterator pos, const value_type& x) { + difference_type index = pos - start; + value_type x_copy = x; + if (index < size() / 2) { + push_front(front()); + iterator front1 = start; + ++front1; + iterator front2 = front1; + ++front2; + pos = start + index; + iterator pos1 = pos; + ++pos1; + copy(front2, pos1, front1); + } + else { + push_back(back()); + iterator back1 = finish; + --back1; + iterator back2 = back1; + --back2; + pos = start + index; + copy_backward(pos, back2, back1); + } + *pos = x_copy; + return pos; +} + +template +void deque::insert_aux(iterator pos, + size_type n, const value_type& x) { + const difference_type elems_before = pos - start; + size_type length = size(); + value_type x_copy = x; + if (elems_before < length / 2) { + iterator new_start = reserve_elements_at_front(n); + iterator old_start = start; + pos = start + elems_before; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_before >= n) { + iterator start_n = start + n; + uninitialized_copy(start, start_n, new_start); + start = new_start; + copy(start_n, pos, old_start); + fill(pos - n, pos, x_copy); + } + else { + __uninitialized_copy_fill(start, pos, new_start, start, x_copy); + start = new_start; + fill(old_start, pos, x_copy); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_front(new_start); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + else { + iterator new_finish = reserve_elements_at_back(n); + iterator old_finish = finish; + const difference_type elems_after = length - elems_before; + pos = finish - elems_after; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_after > n) { + iterator finish_n = finish - n; + uninitialized_copy(finish_n, finish, finish); + finish = new_finish; + copy_backward(pos, finish_n, old_finish); + fill(pos, pos + n, x_copy); + } + else { + __uninitialized_fill_copy(finish, pos + n, x_copy, pos, finish); + finish = new_finish; + fill(pos, old_finish, x_copy); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_back(new_finish); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +} + +#ifdef __STL_MEMBER_TEMPLATES + +template +template +void deque::insert_aux(iterator pos, + ForwardIterator first, + ForwardIterator last, + size_type n) +{ + const difference_type elems_before = pos - start; + size_type length = size(); + if (elems_before < length / 2) { + iterator new_start = reserve_elements_at_front(n); + iterator old_start = start; + pos = start + elems_before; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_before >= n) { + iterator start_n = start + n; + uninitialized_copy(start, start_n, new_start); + start = new_start; + copy(start_n, pos, old_start); + copy(first, last, pos - n); + } + else { + ForwardIterator mid = first; + advance(mid, n - elems_before); + __uninitialized_copy_copy(start, pos, first, mid, new_start); + start = new_start; + copy(mid, last, old_start); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_front(new_start); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + else { + iterator new_finish = reserve_elements_at_back(n); + iterator old_finish = finish; + const difference_type elems_after = length - elems_before; + pos = finish - elems_after; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_after > n) { + iterator finish_n = finish - n; + uninitialized_copy(finish_n, finish, finish); + finish = new_finish; + copy_backward(pos, finish_n, old_finish); + copy(first, last, pos); + } + else { + ForwardIterator mid = first; + advance(mid, elems_after); + __uninitialized_copy_copy(mid, last, pos, finish, finish); + finish = new_finish; + copy(first, mid, pos); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_back(new_finish); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +} + +#else /* __STL_MEMBER_TEMPLATES */ + +template +void deque::insert_aux(iterator pos, + const value_type* first, + const value_type* last, + size_type n) +{ + const difference_type elems_before = pos - start; + size_type length = size(); + if (elems_before < length / 2) { + iterator new_start = reserve_elements_at_front(n); + iterator old_start = start; + pos = start + elems_before; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_before >= n) { + iterator start_n = start + n; + uninitialized_copy(start, start_n, new_start); + start = new_start; + copy(start_n, pos, old_start); + copy(first, last, pos - n); + } + else { + const value_type* mid = first + (n - elems_before); + __uninitialized_copy_copy(start, pos, first, mid, new_start); + start = new_start; + copy(mid, last, old_start); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_front(new_start); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + else { + iterator new_finish = reserve_elements_at_back(n); + iterator old_finish = finish; + const difference_type elems_after = length - elems_before; + pos = finish - elems_after; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_after > n) { + iterator finish_n = finish - n; + uninitialized_copy(finish_n, finish, finish); + finish = new_finish; + copy_backward(pos, finish_n, old_finish); + copy(first, last, pos); + } + else { + const value_type* mid = first + elems_after; + __uninitialized_copy_copy(mid, last, pos, finish, finish); + finish = new_finish; + copy(first, mid, pos); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_back(new_finish); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +} + +template +void deque::insert_aux(iterator pos, + const_iterator first, + const_iterator last, + size_type n) +{ + const difference_type elems_before = pos - start; + size_type length = size(); + if (elems_before < length / 2) { + iterator new_start = reserve_elements_at_front(n); + iterator old_start = start; + pos = start + elems_before; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_before >= n) { + iterator start_n = start + n; + uninitialized_copy(start, start_n, new_start); + start = new_start; + copy(start_n, pos, old_start); + copy(first, last, pos - n); + } + else { + const_iterator mid = first + (n - elems_before); + __uninitialized_copy_copy(start, pos, first, mid, new_start); + start = new_start; + copy(mid, last, old_start); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_front(new_start); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + else { + iterator new_finish = reserve_elements_at_back(n); + iterator old_finish = finish; + const difference_type elems_after = length - elems_before; + pos = finish - elems_after; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (elems_after > n) { + iterator finish_n = finish - n; + uninitialized_copy(finish_n, finish, finish); + finish = new_finish; + copy_backward(pos, finish_n, old_finish); + copy(first, last, pos); + } + else { + const_iterator mid = first + elems_after; + __uninitialized_copy_copy(mid, last, pos, finish, finish); + finish = new_finish; + copy(first, mid, pos); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy_nodes_at_back(new_finish); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +template +void deque::new_elements_at_front(size_type new_elements) { + size_type new_nodes = (new_elements + buffer_size() - 1) / buffer_size(); + reserve_map_at_front(new_nodes); + size_type i; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for (i = 1; i <= new_nodes; ++i) + *(start.node - i) = allocate_node(); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + for (size_type j = 1; j < i; ++j) + deallocate_node(*(start.node - j)); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +template +void deque::new_elements_at_back(size_type new_elements) { + size_type new_nodes = (new_elements + buffer_size() - 1) / buffer_size(); + reserve_map_at_back(new_nodes); + size_type i; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for (i = 1; i <= new_nodes; ++i) + *(finish.node + i) = allocate_node(); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + for (size_type j = 1; j < i; ++j) + deallocate_node(*(finish.node + j)); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + +template +void deque::destroy_nodes_at_front(iterator before_start) { + for (map_pointer n = before_start.node; n < start.node; ++n) + deallocate_node(*n); +} + +template +void deque::destroy_nodes_at_back(iterator after_finish) { + for (map_pointer n = after_finish.node; n > finish.node; --n) + deallocate_node(*n); +} + +template +void deque::reallocate_map(size_type nodes_to_add, + bool add_at_front) { + size_type old_num_nodes = finish.node - start.node + 1; + size_type new_num_nodes = old_num_nodes + nodes_to_add; + + map_pointer new_nstart; + if (map_size > 2 * new_num_nodes) { + new_nstart = map + (map_size - new_num_nodes) / 2 + + (add_at_front ? nodes_to_add : 0); + if (new_nstart < start.node) + copy(start.node, finish.node + 1, new_nstart); + else + copy_backward(start.node, finish.node + 1, new_nstart + old_num_nodes); + } + else { + size_type new_map_size = map_size + max(map_size, nodes_to_add) + 2; + + map_pointer new_map = map_allocator::allocate(new_map_size); + new_nstart = new_map + (new_map_size - new_num_nodes) / 2 + + (add_at_front ? nodes_to_add : 0); + copy(start.node, finish.node + 1, new_nstart); + map_allocator::deallocate(map, map_size); + + map = new_map; + map_size = new_map_size; + } + + start.set_node(new_nstart); + finish.set_node(new_nstart + old_num_nodes - 1); +} + + +// Nonmember functions. + +#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG + +template +bool operator==(const deque& x, + const deque& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +bool operator<(const deque& x, + const deque& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */ + + +#endif /* __SGI_STL_DEQUE_H */ + diff --git a/libstdc++/stl/function.h b/libstdc++/stl/function.h new file mode 100644 index 000000000000..e4f4713235b9 --- /dev/null +++ b/libstdc++/stl/function.h @@ -0,0 +1,634 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_FUNCTION_H +#define __SGI_STL_FUNCTION_H + +#include +#include + +template +inline bool operator!=(const T& x, const T& y) { + return !(x == y); +} + +template +inline bool operator>(const T& x, const T& y) { + return y < x; +} + +template +inline bool operator<=(const T& x, const T& y) { + return !(y < x); +} + +template +inline bool operator>=(const T& x, const T& y) { + return !(x < y); +} + +template +struct unary_function { + typedef Arg argument_type; + typedef Result result_type; +}; + +template +struct binary_function { + typedef Arg1 first_argument_type; + typedef Arg2 second_argument_type; + typedef Result result_type; +}; + +template +struct plus : public binary_function { + T operator()(const T& x, const T& y) const { return x + y; } +}; + +template +struct minus : public binary_function { + T operator()(const T& x, const T& y) const { return x - y; } +}; + +template +struct multiplies : public binary_function { + T operator()(const T& x, const T& y) const { return x * y; } +}; + +template +struct divides : public binary_function { + T operator()(const T& x, const T& y) const { return x / y; } +}; + +template inline T identity_element(plus) { return T(0); } + +template inline T identity_element(multiplies) { return T(1); } + +template +struct modulus : public binary_function { + T operator()(const T& x, const T& y) const { return x % y; } +}; + +template +struct negate : public unary_function { + T operator()(const T& x) const { return -x; } +}; + +template +struct equal_to : public binary_function { + bool operator()(const T& x, const T& y) const { return x == y; } +}; + +template +struct not_equal_to : public binary_function { + bool operator()(const T& x, const T& y) const { return x != y; } +}; + +template +struct greater : public binary_function { + bool operator()(const T& x, const T& y) const { return x > y; } +}; + +template +struct less : public binary_function { + bool operator()(const T& x, const T& y) const { return x < y; } +}; + +template +struct greater_equal : public binary_function { + bool operator()(const T& x, const T& y) const { return x >= y; } +}; + +template +struct less_equal : public binary_function { + bool operator()(const T& x, const T& y) const { return x <= y; } +}; + +template +struct logical_and : public binary_function { + bool operator()(const T& x, const T& y) const { return x && y; } +}; + +template +struct logical_or : public binary_function { + bool operator()(const T& x, const T& y) const { return x || y; } +}; + +template +struct logical_not : public unary_function { + bool operator()(const T& x) const { return !x; } +}; + +template +class unary_negate + : public unary_function { +protected: + Predicate pred; +public: + explicit unary_negate(const Predicate& x) : pred(x) {} + bool operator()(const argument_type& x) const { return !pred(x); } +}; + +template +inline unary_negate not1(const Predicate& pred) { + return unary_negate(pred); +} + +template +class binary_negate + : public binary_function { +protected: + Predicate pred; +public: + explicit binary_negate(const Predicate& x) : pred(x) {} + bool operator()(const first_argument_type& x, + const second_argument_type& y) const { + return !pred(x, y); + } +}; + +template +inline binary_negate not2(const Predicate& pred) { + return binary_negate(pred); +} + +template +class binder1st + : public unary_function { +protected: + Operation op; + typename Operation::first_argument_type value; +public: + binder1st(const Operation& x, + const typename Operation::first_argument_type& y) + : op(x), value(y) {} + result_type operator()(const argument_type& x) const { + return op(value, x); + } +}; + +template +inline binder1st bind1st(const Operation& op, const T& x) { + typedef typename Operation::first_argument_type arg1_type; + return binder1st(op, arg1_type(x)); +} + +template +class binder2nd + : public unary_function { +protected: + Operation op; + typename Operation::second_argument_type value; +public: + binder2nd(const Operation& x, + const typename Operation::second_argument_type& y) + : op(x), value(y) {} + result_type operator()(const argument_type& x) const { + return op(x, value); + } +}; + +template +inline binder2nd bind2nd(const Operation& op, const T& x) { + typedef typename Operation::second_argument_type arg2_type; + return binder2nd(op, arg2_type(x)); +} + +template +class unary_compose : public unary_function { +protected: + Operation1 op1; + Operation2 op2; +public: + unary_compose(const Operation1& x, const Operation2& y) : op1(x), op2(y) {} + result_type operator()(const argument_type& x) const { + return op1(op2(x)); + } +}; + +template +inline unary_compose compose1(const Operation1& op1, + const Operation2& op2) { + return unary_compose(op1, op2); +} + +template +class binary_compose + : public unary_function { +protected: + Operation1 op1; + Operation2 op2; + Operation3 op3; +public: + binary_compose(const Operation1& x, const Operation2& y, + const Operation3& z) : op1(x), op2(y), op3(z) { } + result_type operator()(const argument_type& x) const { + return op1(op2(x), op3(x)); + } +}; + +template +inline binary_compose +compose2(const Operation1& op1, const Operation2& op2, const Operation3& op3) { + return binary_compose(op1, op2, op3); +} + +template +class pointer_to_unary_function : public unary_function { +protected: + Result (*ptr)(Arg); +public: + pointer_to_unary_function() {} + explicit pointer_to_unary_function(Result (*x)(Arg)) : ptr(x) {} + Result operator()(Arg x) const { return ptr(x); } +}; + +template +inline pointer_to_unary_function ptr_fun(Result (*x)(Arg)) { + return pointer_to_unary_function(x); +} + +template +class pointer_to_binary_function : public binary_function { +protected: + Result (*ptr)(Arg1, Arg2); +public: + pointer_to_binary_function() {} + explicit pointer_to_binary_function(Result (*x)(Arg1, Arg2)) : ptr(x) {} + Result operator()(Arg1 x, Arg2 y) const { return ptr(x, y); } +}; + +template +inline pointer_to_binary_function +ptr_fun(Result (*x)(Arg1, Arg2)) { + return pointer_to_binary_function(x); +} + +template +struct identity : public unary_function { + const T& operator()(const T& x) const { return x; } +}; + +template +struct select1st : public unary_function { + const typename Pair::first_type& operator()(const Pair& x) const + { + return x.first; + } +}; + +template +struct select2nd : public unary_function { + const typename Pair::second_type& operator()(const Pair& x) const + { + return x.second; + } +}; + +template +struct project1st : public binary_function { + Arg1 operator()(const Arg1& x, const Arg2&) const { return x; } +}; + +template +struct project2nd : public binary_function { + Arg2 operator()(const Arg1&, const Arg2& y) const { return y; } +}; + +template +struct constant_void_fun +{ + typedef Result result_type; + result_type val; + constant_void_fun(const result_type& v) : val(v) {} + const result_type& operator()() const { return val; } +}; + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template +#else +template +#endif +struct constant_unary_fun : public unary_function { + result_type val; + constant_unary_fun(const result_type& v) : val(v) {} + const result_type& operator()(const argument_type&) const { return val; } +}; + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template +#else +template +#endif +struct constant_binary_fun : public binary_function { + result_type val; + constant_binary_fun(const result_type& v) : val(v) {} + const result_type& operator()(const first_argument_type&, + const second_argument_type&) const { + return val; + } +}; + +template +inline constant_void_fun constant0(const Result& val) +{ + return constant_void_fun(val); +} + +template +inline constant_unary_fun constant1(const Result& val) +{ + return constant_unary_fun(val); +} + +template +inline constant_binary_fun constant2(const Result& val) +{ + return constant_binary_fun(val); +} + +// Note: this code assumes that int is 32 bits. +class subtractive_rng : public unary_function { +private: + unsigned int table[55]; + size_t index1; + size_t index2; +public: + unsigned int operator()(unsigned int limit) { + index1 = (index1 + 1) % 55; + index2 = (index2 + 1) % 55; + table[index1] = table[index1] - table[index2]; + return table[index1] % limit; + } + + void initialize(unsigned int seed) + { + unsigned int k = 1; + table[54] = seed; + size_t i; + for (i = 0; i < 54; i++) { + size_t ii = (21 * (i + 1) % 55) - 1; + table[ii] = k; + k = seed - k; + seed = table[ii]; + } + for (int loop = 0; loop < 4; loop++) { + for (i = 0; i < 55; i++) + table[i] = table[i] - table[(1 + i + 30) % 55]; + } + index1 = 0; + index2 = 31; + } + + subtractive_rng(unsigned int seed) { initialize(seed); } + subtractive_rng() { initialize(161803398u); } +}; + + +// Adaptor function objects: pointers to member functions. + +// There are a total of 16 = 2^4 function objects in this family. +// (1) Member functions taking no arguments vs member functions taking +// one argument. +// (2) Call through pointer vs call through reference. +// (3) Member function with void return type vs member function with +// non-void return type. +// (4) Const vs non-const member function. + +// Note that choice (4) is not present in the 8/97 draft C++ standard, +// which only allows these adaptors to be used with non-const functions. +// This is likely to be recified before the standard becomes final. +// Note also that choice (3) is nothing more than a workaround: according +// to the draft, compilers should handle void and non-void the same way. +// This feature is not yet widely implemented, though. You can only use +// member functions returning void if your compiler supports partial +// specialization. + +// All of this complexity is in the function objects themselves. You can +// ignore it by using the helper function mem_fun, mem_fun_ref, +// mem_fun1, and mem_fun1_ref, which create whichever type of adaptor +// is appropriate. + + +template +class mem_fun_t : public unary_function { +public: + explicit mem_fun_t(S (T::*pf)()) : f(pf) {} + S operator()(T* p) const { return (p->*f)(); } +private: + S (T::*f)(); +}; + +template +class const_mem_fun_t : public unary_function { +public: + explicit const_mem_fun_t(S (T::*pf)() const) : f(pf) {} + S operator()(const T* p) const { return (p->*f)(); } +private: + S (T::*f)() const; +}; + + +template +class mem_fun_ref_t : public unary_function { +public: + explicit mem_fun_ref_t(S (T::*pf)()) : f(pf) {} + S operator()(T& r) const { return (r.*f)(); } +private: + S (T::*f)(); +}; + +template +class const_mem_fun_ref_t : public unary_function { +public: + explicit const_mem_fun_ref_t(S (T::*pf)() const) : f(pf) {} + S operator()(const T& r) const { return (r.*f)(); } +private: + S (T::*f)() const; +}; + +template +class mem_fun1_t : public binary_function { +public: + explicit mem_fun1_t(S (T::*pf)(A)) : f(pf) {} + S operator()(T* p, A x) const { return (p->*f)(x); } +private: + S (T::*f)(A); +}; + +template +class const_mem_fun1_t : public binary_function { +public: + explicit const_mem_fun1_t(S (T::*pf)(A) const) : f(pf) {} + S operator()(const T* p, A x) const { return (p->*f)(x); } +private: + S (T::*f)(A) const; +}; + +template +class mem_fun1_ref_t : public binary_function { +public: + explicit mem_fun1_ref_t(S (T::*pf)(A)) : f(pf) {} + S operator()(T& r, A x) const { return (r.*f)(x); } +private: + S (T::*f)(A); +}; + +template +class const_mem_fun1_ref_t : public binary_function { +public: + explicit const_mem_fun1_ref_t(S (T::*pf)(A) const) : f(pf) {} + S operator()(const T& r, A x) const { return (r.*f)(x); } +private: + S (T::*f)(A) const; +}; + +#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION + +template +class mem_fun_t : public unary_function { +public: + explicit mem_fun_t(void (T::*pf)()) : f(pf) {} + void operator()(T* p) const { (p->*f)(); } +private: + void (T::*f)(); +}; + +template +class const_mem_fun_t : public unary_function { +public: + explicit const_mem_fun_t(void (T::*pf)() const) : f(pf) {} + void operator()(const T* p) const { (p->*f)(); } +private: + void (T::*f)() const; +}; + +template +class mem_fun_ref_t : public unary_function { +public: + explicit mem_fun_ref_t(void (T::*pf)()) : f(pf) {} + void operator()(T& r) const { (r.*f)(); } +private: + void (T::*f)(); +}; + +template +class const_mem_fun_ref_t : public unary_function { +public: + explicit const_mem_fun_ref_t(void (T::*pf)() const) : f(pf) {} + void operator()(const T& r) const { (r.*f)(); } +private: + void (T::*f)() const; +}; + +template +class mem_fun1_t : public binary_function { +public: + explicit mem_fun1_t(void (T::*pf)(A)) : f(pf) {} + void operator()(T* p, A x) const { (p->*f)(x); } +private: + void (T::*f)(A); +}; + +template +class const_mem_fun1_t : public binary_function { +public: + explicit const_mem_fun1_t(void (T::*pf)(A) const) : f(pf) {} + void operator()(const T* p, A x) const { (p->*f)(x); } +private: + void (T::*f)(A) const; +}; + +template +class mem_fun1_ref_t : public binary_function { +public: + explicit mem_fun1_ref_t(void (T::*pf)(A)) : f(pf) {} + void operator()(T& r, A x) const { (r.*f)(x); } +private: + void (T::*f)(A); +}; + +template +class const_mem_fun1_ref_t : public binary_function { +public: + explicit const_mem_fun1_ref_t(void (T::*pf)(A) const) : f(pf) {} + void operator()(const T& r, A x) const { (r.*f)(x); } +private: + void (T::*f)(A) const; +}; + +#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + +// Mem_fun adaptor helper functions. There are only four: +// mem_fun, mem_fun_ref, mem_fun1, mem_fun1_ref. + +template +inline mem_fun_t mem_fun(S (T::*f)()) { + return mem_fun_t(f); +} + +template +inline const_mem_fun_t mem_fun(S (T::*f)() const) { + return const_mem_fun_t(f); +} + +template +inline mem_fun_ref_t mem_fun_ref(S (T::*f)()) { + return mem_fun_ref_t(f); +} + +template +inline const_mem_fun_ref_t mem_fun_ref(S (T::*f)() const) { + return const_mem_fun_ref_t(f); +} + +template +inline mem_fun1_t mem_fun1(S (T::*f)(A)) { + return mem_fun1_t(f); +} + +template +inline const_mem_fun1_t mem_fun1(S (T::*f)(A) const) { + return const_mem_fun1_t(f); +} + +template +inline mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A)) { + return mem_fun1_ref_t(f); +} + +template +inline const_mem_fun1_ref_t mem_fun1_ref(S (T::*f)(A) const) { + return const_mem_fun1_ref_t(f); +} + +#endif /* __SGI_STL_FUNCTION_H */ diff --git a/libstdc++/stl/hash_map.h b/libstdc++/stl/hash_map.h new file mode 100644 index 000000000000..c52b9936e7b2 --- /dev/null +++ b/libstdc++/stl/hash_map.h @@ -0,0 +1,319 @@ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef __SGI_STL_HASH_MAP_H +#define __SGI_STL_HASH_MAP_H + +#ifndef __SGI_STL_HASHTABLE_H +#include +#endif /* __SGI_STL_HASHTABLE_H */ + + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , + class EqualKey = equal_to, + class Alloc = alloc> +#else +template +#endif +class hash_map +{ +private: + typedef hashtable, Key, HashFcn, + select1st >, EqualKey, Alloc> ht; + ht rep; + +public: + typedef ht::key_type key_type; + typedef ht::value_type value_type; + typedef ht::hasher hasher; + typedef ht::key_equal key_equal; + typedef T data_type; + + typedef ht::size_type size_type; + typedef ht::difference_type difference_type; + typedef ht::pointer pointer; + typedef ht::const_pointer const_pointer; + typedef ht::reference reference; + typedef ht::const_reference const_reference; + + typedef ht::iterator iterator; + typedef ht::const_iterator const_iterator; + + hasher hash_funct() const { return rep.hash_funct(); } + key_equal key_eq() const { return rep.key_eq(); } + +public: + hash_map() : rep(100, hasher(), key_equal()) {} + explicit hash_map(size_type n) : rep(n, hasher(), key_equal()) {} + hash_map(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {} + hash_map(size_type n, const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + hash_map(InputIterator f, InputIterator l) + : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); } + template + hash_map(InputIterator f, InputIterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); } + template + hash_map(InputIterator f, InputIterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_unique(f, l); } + template + hash_map(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_unique(f, l); } + +#else + hash_map(const value_type* f, const value_type* l) + : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_map(const value_type* f, const value_type* l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_map(const value_type* f, const value_type* l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_unique(f, l); } + hash_map(const value_type* f, const value_type* l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_unique(f, l); } + + hash_map(const_iterator f, const_iterator l) + : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_map(const_iterator f, const_iterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_map(const_iterator f, const_iterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_unique(f, l); } + hash_map(const_iterator f, const_iterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_unique(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + +public: + size_type size() const { return rep.size(); } + size_type max_size() const { return rep.max_size(); } + bool empty() const { return rep.empty(); } + void swap(hash_map& hs) { rep.swap(hs.rep); } + friend bool operator==(const hash_map&, + const hash_map&); + + iterator begin() { return rep.begin(); } + iterator end() { return rep.end(); } + const_iterator begin() const { return rep.begin(); } + const_iterator end() const { return rep.end(); } + +public: + pair insert(const value_type& obj) + { return rep.insert_unique(obj); } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator f, InputIterator l) { rep.insert_unique(f,l); } +#else + void insert(const value_type* f, const value_type* l) { + rep.insert_unique(f,l); + } + void insert(const_iterator f, const_iterator l) { rep.insert_unique(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + pair insert_noresize(const value_type& obj) + { return rep.insert_unique_noresize(obj); } + + iterator find(const key_type& key) { return rep.find(key); } + const_iterator find(const key_type& key) const { return rep.find(key); } + + T& operator[](const key_type& key) + { + return rep.find_or_insert(value_type(key, T())).second; + } + + size_type count(const key_type& key) const { return rep.count(key); } + + pair equal_range(const key_type& key) + { return rep.equal_range(key); } + pair equal_range(const key_type& key) const + { return rep.equal_range(key); } + + size_type erase(const key_type& key) {return rep.erase(key); } + void erase(iterator it) { rep.erase(it); } + void erase(iterator f, iterator l) { rep.erase(f, l); } + void clear() { rep.clear(); } + +public: + void resize(size_type hint) { rep.resize(hint); } + size_type bucket_count() const { return rep.bucket_count(); } + size_type max_bucket_count() const { return rep.max_bucket_count(); } + size_type elems_in_bucket(size_type n) const + { return rep.elems_in_bucket(n); } +}; + +template +inline bool operator==(const hash_map& hm1, + const hash_map& hm2) +{ + return hm1.rep == hm2.rep; +} + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , + class EqualKey = equal_to, + class Alloc = alloc> +#else +template +#endif +class hash_multimap +{ +private: + typedef hashtable, Key, HashFcn, + select1st >, EqualKey, Alloc> ht; + ht rep; + +public: + typedef ht::key_type key_type; + typedef ht::value_type value_type; + typedef ht::hasher hasher; + typedef ht::key_equal key_equal; + typedef T data_type; + + typedef ht::size_type size_type; + typedef ht::difference_type difference_type; + typedef ht::pointer pointer; + typedef ht::const_pointer const_pointer; + typedef ht::reference reference; + typedef ht::const_reference const_reference; + + typedef ht::iterator iterator; + typedef ht::const_iterator const_iterator; + + hasher hash_funct() const { return rep.hash_funct(); } + key_equal key_eq() const { return rep.key_eq(); } + +public: + hash_multimap() : rep(100, hasher(), key_equal()) {} + explicit hash_multimap(size_type n) : rep(n, hasher(), key_equal()) {} + hash_multimap(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {} + hash_multimap(size_type n, const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + hash_multimap(InputIterator f, InputIterator l) + : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); } + template + hash_multimap(InputIterator f, InputIterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); } + template + hash_multimap(InputIterator f, InputIterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_equal(f, l); } + template + hash_multimap(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_equal(f, l); } + +#else + hash_multimap(const value_type* f, const value_type* l) + : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multimap(const value_type* f, const value_type* l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multimap(const value_type* f, const value_type* l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_equal(f, l); } + hash_multimap(const value_type* f, const value_type* l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_equal(f, l); } + + hash_multimap(const_iterator f, const_iterator l) + : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multimap(const_iterator f, const_iterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multimap(const_iterator f, const_iterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_equal(f, l); } + hash_multimap(const_iterator f, const_iterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_equal(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + +public: + size_type size() const { return rep.size(); } + size_type max_size() const { return rep.max_size(); } + bool empty() const { return rep.empty(); } + void swap(hash_multimap& hs) { rep.swap(hs.rep); } + friend bool operator==(const hash_multimap&, + const hash_multimap&); + + iterator begin() { return rep.begin(); } + iterator end() { return rep.end(); } + const_iterator begin() const { return rep.begin(); } + const_iterator end() const { return rep.end(); } + +public: + iterator insert(const value_type& obj) { return rep.insert_equal(obj); } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator f, InputIterator l) { rep.insert_equal(f,l); } +#else + void insert(const value_type* f, const value_type* l) { + rep.insert_equal(f,l); + } + void insert(const_iterator f, const_iterator l) { rep.insert_equal(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + iterator insert_noresize(const value_type& obj) + { return rep.insert_equal_noresize(obj); } + + iterator find(const key_type& key) { return rep.find(key); } + const_iterator find(const key_type& key) const { return rep.find(key); } + + size_type count(const key_type& key) const { return rep.count(key); } + + pair equal_range(const key_type& key) + { return rep.equal_range(key); } + pair equal_range(const key_type& key) const + { return rep.equal_range(key); } + + size_type erase(const key_type& key) {return rep.erase(key); } + void erase(iterator it) { rep.erase(it); } + void erase(iterator f, iterator l) { rep.erase(f, l); } + void clear() { rep.clear(); } + +public: + void resize(size_type hint) { rep.resize(hint); } + size_type bucket_count() const { return rep.bucket_count(); } + size_type max_bucket_count() const { return rep.max_bucket_count(); } + size_type elems_in_bucket(size_type n) const + { return rep.elems_in_bucket(n); } +}; + +template +inline bool operator==(const hash_multimap& hm1, + const hash_multimap& hm2) +{ + return hm1.rep == hm2.rep; +} + +#endif /* __SGI_STL_HASH_MAP_H */ diff --git a/libstdc++/stl/hash_set.h b/libstdc++/stl/hash_set.h new file mode 100644 index 000000000000..2c7125eb7e51 --- /dev/null +++ b/libstdc++/stl/hash_set.h @@ -0,0 +1,306 @@ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef __SGI_STL_HASH_SET_H +#define __SGI_STL_HASH_SET_H + +#ifndef __SGI_STL_HASHTABLE_H +#include +#endif /* __SGI_STL_HASHTABLE_H */ + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , + class EqualKey = equal_to, + class Alloc = alloc> +#else +template +#endif +class hash_set +{ +private: + typedef hashtable, + EqualKey, Alloc> ht; + ht rep; + +public: + typedef ht::key_type key_type; + typedef ht::value_type value_type; + typedef ht::hasher hasher; + typedef ht::key_equal key_equal; + + typedef ht::size_type size_type; + typedef ht::difference_type difference_type; + typedef ht::const_pointer pointer; + typedef ht::const_pointer const_pointer; + typedef ht::const_reference reference; + typedef ht::const_reference const_reference; + + typedef ht::const_iterator iterator; + typedef ht::const_iterator const_iterator; + + hasher hash_funct() const { return rep.hash_funct(); } + key_equal key_eq() const { return rep.key_eq(); } + +public: + hash_set() : rep(100, hasher(), key_equal()) {} + explicit hash_set(size_type n) : rep(n, hasher(), key_equal()) {} + hash_set(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {} + hash_set(size_type n, const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + hash_set(InputIterator f, InputIterator l) + : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); } + template + hash_set(InputIterator f, InputIterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); } + template + hash_set(InputIterator f, InputIterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_unique(f, l); } + template + hash_set(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_unique(f, l); } +#else + + hash_set(const value_type* f, const value_type* l) + : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_set(const value_type* f, const value_type* l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_set(const value_type* f, const value_type* l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_unique(f, l); } + hash_set(const value_type* f, const value_type* l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_unique(f, l); } + + hash_set(const_iterator f, const_iterator l) + : rep(100, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_set(const_iterator f, const_iterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_unique(f, l); } + hash_set(const_iterator f, const_iterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_unique(f, l); } + hash_set(const_iterator f, const_iterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_unique(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + +public: + size_type size() const { return rep.size(); } + size_type max_size() const { return rep.max_size(); } + bool empty() const { return rep.empty(); } + void swap(hash_set& hs) { rep.swap(hs.rep); } + friend bool operator==(const hash_set&, + const hash_set&); + + iterator begin() const { return rep.begin(); } + iterator end() const { return rep.end(); } + +public: + pair insert(const value_type& obj) + { + pair p = rep.insert_unique(obj); + return pair(p.first, p.second); + } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator f, InputIterator l) { rep.insert_unique(f,l); } +#else + void insert(const value_type* f, const value_type* l) { + rep.insert_unique(f,l); + } + void insert(const_iterator f, const_iterator l) {rep.insert_unique(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + pair insert_noresize(const value_type& obj) + { + pair p = rep.insert_unique_noresize(obj); + return pair(p.first, p.second); + } + + iterator find(const key_type& key) const { return rep.find(key); } + + size_type count(const key_type& key) const { return rep.count(key); } + + pair equal_range(const key_type& key) const + { return rep.equal_range(key); } + + size_type erase(const key_type& key) {return rep.erase(key); } + void erase(iterator it) { rep.erase(it); } + void erase(iterator f, iterator l) { rep.erase(f, l); } + void clear() { rep.clear(); } + +public: + void resize(size_type hint) { rep.resize(hint); } + size_type bucket_count() const { return rep.bucket_count(); } + size_type max_bucket_count() const { return rep.max_bucket_count(); } + size_type elems_in_bucket(size_type n) const + { return rep.elems_in_bucket(n); } +}; + +template +inline bool operator==(const hash_set& hs1, + const hash_set& hs2) +{ + return hs1.rep == hs2.rep; +} + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , + class EqualKey = equal_to, + class Alloc = alloc> +#else +template +#endif +class hash_multiset +{ +private: + typedef hashtable, + EqualKey, Alloc> ht; + ht rep; + +public: + typedef ht::key_type key_type; + typedef ht::value_type value_type; + typedef ht::hasher hasher; + typedef ht::key_equal key_equal; + + typedef ht::size_type size_type; + typedef ht::difference_type difference_type; + typedef ht::const_pointer pointer; + typedef ht::const_pointer const_pointer; + typedef ht::const_reference reference; + typedef ht::const_reference const_reference; + + typedef ht::const_iterator iterator; + typedef ht::const_iterator const_iterator; + + hasher hash_funct() const { return rep.hash_funct(); } + key_equal key_eq() const { return rep.key_eq(); } + +public: + hash_multiset() : rep(100, hasher(), key_equal()) {} + explicit hash_multiset(size_type n) : rep(n, hasher(), key_equal()) {} + hash_multiset(size_type n, const hasher& hf) : rep(n, hf, key_equal()) {} + hash_multiset(size_type n, const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + hash_multiset(InputIterator f, InputIterator l) + : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); } + template + hash_multiset(InputIterator f, InputIterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); } + template + hash_multiset(InputIterator f, InputIterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_equal(f, l); } + template + hash_multiset(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_equal(f, l); } +#else + + hash_multiset(const value_type* f, const value_type* l) + : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multiset(const value_type* f, const value_type* l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multiset(const value_type* f, const value_type* l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_equal(f, l); } + hash_multiset(const value_type* f, const value_type* l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_equal(f, l); } + + hash_multiset(const_iterator f, const_iterator l) + : rep(100, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multiset(const_iterator f, const_iterator l, size_type n) + : rep(n, hasher(), key_equal()) { rep.insert_equal(f, l); } + hash_multiset(const_iterator f, const_iterator l, size_type n, + const hasher& hf) + : rep(n, hf, key_equal()) { rep.insert_equal(f, l); } + hash_multiset(const_iterator f, const_iterator l, size_type n, + const hasher& hf, const key_equal& eql) + : rep(n, hf, eql) { rep.insert_equal(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + +public: + size_type size() const { return rep.size(); } + size_type max_size() const { return rep.max_size(); } + bool empty() const { return rep.empty(); } + void swap(hash_multiset& hs) { rep.swap(hs.rep); } + friend bool operator==(const hash_multiset&, + const hash_multiset&); + + iterator begin() const { return rep.begin(); } + iterator end() const { return rep.end(); } + +public: + iterator insert(const value_type& obj) { return rep.insert_equal(obj); } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator f, InputIterator l) { rep.insert_equal(f,l); } +#else + void insert(const value_type* f, const value_type* l) { + rep.insert_equal(f,l); + } + void insert(const_iterator f, const_iterator l) { rep.insert_equal(f, l); } +#endif /*__STL_MEMBER_TEMPLATES */ + iterator insert_noresize(const value_type& obj) + { return rep.insert_equal_noresize(obj); } + + iterator find(const key_type& key) const { return rep.find(key); } + + size_type count(const key_type& key) const { return rep.count(key); } + + pair equal_range(const key_type& key) const + { return rep.equal_range(key); } + + size_type erase(const key_type& key) {return rep.erase(key); } + void erase(iterator it) { rep.erase(it); } + void erase(iterator f, iterator l) { rep.erase(f, l); } + void clear() { rep.clear(); } + +public: + void resize(size_type hint) { rep.resize(hint); } + size_type bucket_count() const { return rep.bucket_count(); } + size_type max_bucket_count() const { return rep.max_bucket_count(); } + size_type elems_in_bucket(size_type n) const + { return rep.elems_in_bucket(n); } +}; + +template +inline bool operator==(const hash_multiset& hs1, + const hash_multiset& hs2) +{ + return hs1.rep == hs2.rep; +} + + +#endif /* __SGI_STL_HASH_SET_H */ diff --git a/libstdc++/stl/hashtable.h b/libstdc++/stl/hashtable.h new file mode 100644 index 000000000000..420d7a8545a8 --- /dev/null +++ b/libstdc++/stl/hashtable.h @@ -0,0 +1,1013 @@ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef __SGI_STL_HASHTABLE_H +#define __SGI_STL_HASHTABLE_H + +// Hashtable class, used to implement the hashed associative containers +// hash_set, hash_map, hash_multiset, and hash_multimap. + + +#include +#include +#include +#include + + +template struct hash { }; + +inline size_t __stl_hash_string(const char* s) +{ + unsigned long h = 0; + for ( ; *s; ++s) + h = 5*h + *s; + + return size_t(h); +} + +struct hash +{ + size_t operator()(const char* s) const { return __stl_hash_string(s); } +}; + +struct hash +{ + size_t operator()(const char* s) const { return __stl_hash_string(s); } +}; + +struct hash { + size_t operator()(char x) const { return x; } +}; +struct hash { + size_t operator()(unsigned char x) const { return x; } +}; +struct hash { + size_t operator()(unsigned char x) const { return x; } +}; +struct hash { + size_t operator()(short x) const { return x; } +}; +struct hash { + size_t operator()(unsigned short x) const { return x; } +}; +struct hash { + size_t operator()(int x) const { return x; } +}; +struct hash { + size_t operator()(unsigned int x) const { return x; } +}; +struct hash { + size_t operator()(long x) const { return x; } +}; +struct hash { + size_t operator()(unsigned long x) const { return x; } +}; + +template +struct __hashtable_node +{ + __hashtable_node* next; + Value val; +}; + +template +class hashtable; + +template +struct __hashtable_iterator; + +template +struct __hashtable_const_iterator; + +template +struct __hashtable_iterator { + typedef hashtable + hashtable; + typedef __hashtable_iterator + iterator; + typedef __hashtable_const_iterator + const_iterator; + typedef __hashtable_node node; + + typedef forward_iterator_tag iterator_category; + typedef Value value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef Value& reference; + typedef const Value& const_reference; + typedef Value* pointer; + + node* cur; + hashtable* ht; + + __hashtable_iterator(node* n, hashtable* tab) : cur(n), ht(tab) {} + __hashtable_iterator() {} + reference operator*() const { return cur->val; } + iterator& operator++(); + iterator operator++(int); + bool operator==(const iterator& it) const { return cur == it.cur; } + bool operator!=(const iterator& it) const { return cur != it.cur; } +}; + + +template +struct __hashtable_const_iterator { + typedef hashtable + hashtable; + typedef __hashtable_iterator + iterator; + typedef __hashtable_const_iterator + const_iterator; + typedef __hashtable_node node; + + typedef forward_iterator_tag iterator_category; + typedef Value value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef Value& reference; + typedef const Value& const_reference; + typedef Value* pointer; + + const node* cur; + const hashtable* ht; + + __hashtable_const_iterator(const node* n, const hashtable* tab) + : cur(n), ht(tab) {} + __hashtable_const_iterator() {} + __hashtable_const_iterator(const iterator& it) : cur(it.cur), ht(it.ht) {} + const_reference operator*() const { return cur->val; } + const_iterator& operator++(); + const_iterator operator++(int); + bool operator==(const const_iterator& it) const { return cur == it.cur; } + bool operator!=(const const_iterator& it) const { return cur != it.cur; } +}; + +// Note: assumes long is at least 32 bits. +static const int __stl_num_primes = 28; +static const unsigned long __stl_prime_list[__stl_num_primes] = +{ + 53, 97, 193, 389, 769, + 1543, 3079, 6151, 12289, 24593, + 49157, 98317, 196613, 393241, 786433, + 1572869, 3145739, 6291469, 12582917, 25165843, + 50331653, 100663319, 201326611, 402653189, 805306457, + 1610612741, 3221225473, 4294967291 +}; + +inline unsigned long __stl_next_prime(unsigned long n) +{ + const unsigned long* first = __stl_prime_list; + const unsigned long* last = __stl_prime_list + __stl_num_primes; + const unsigned long* pos = lower_bound(first, last, n); + return pos == last ? *(last - 1) : *pos; +} + + +template +class hashtable { +public: + typedef Key key_type; + typedef Value value_type; + typedef HashFcn hasher; + typedef EqualKey key_equal; + + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + hasher hash_funct() const { return hash; } + key_equal key_eq() const { return equals; } + +private: + hasher hash; + key_equal equals; + ExtractKey get_key; + + typedef __hashtable_node node; + typedef simple_alloc node_allocator; + + vector buckets; + size_type num_elements; + +public: + typedef __hashtable_iterator + iterator; + + typedef __hashtable_const_iterator + const_iterator; + + friend struct + __hashtable_iterator; + friend struct + __hashtable_const_iterator; + +public: + hashtable(size_type n, + const HashFcn& hf, + const EqualKey& eql, + const ExtractKey& ext) + : hash(hf), equals(eql), get_key(ext), num_elements(0) + { + initialize_buckets(n); + } + + hashtable(size_type n, + const HashFcn& hf, + const EqualKey& eql) + : hash(hf), equals(eql), get_key(ExtractKey()), num_elements(0) + { + initialize_buckets(n); + } + + hashtable(const hashtable& ht) + : hash(ht.hash), equals(ht.equals), get_key(ht.get_key), num_elements(0) + { + copy_from(ht); + } + + hashtable& operator= (const hashtable& ht) + { + if (&ht != this) { + clear(); + hash = ht.hash; + equals = ht.equals; + get_key = ht.get_key; + copy_from(ht); + } + return *this; + } + + ~hashtable() { clear(); } + + size_type size() const { return num_elements; } + size_type max_size() const { return size_type(-1); } + bool empty() const { return size() == 0; } + + void swap(hashtable& ht) + { + ::swap(hash, ht.hash); + ::swap(equals, ht.equals); + ::swap(get_key, ht.get_key); + buckets.swap(ht.buckets); + ::swap(num_elements, ht.num_elements); + } + + iterator begin() + { + for (size_type n = 0; n < buckets.size(); ++n) + if (buckets[n]) + return iterator(buckets[n], this); + return end(); + } + + iterator end() { return iterator(0, this); } + + const_iterator begin() const + { + for (size_type n = 0; n < buckets.size(); ++n) + if (buckets[n]) + return const_iterator(buckets[n], this); + return end(); + } + + const_iterator end() const { return const_iterator(0, this); } + + friend bool operator== (const hashtable&, + const hashtable&); + +public: + + size_type bucket_count() const { return buckets.size(); } + + size_type max_bucket_count() const + { return __stl_prime_list[__stl_num_primes - 1]; } + + size_type elems_in_bucket(size_type bucket) const + { + size_type result = 0; + for (node* cur = buckets[bucket]; cur; cur = cur->next) + result += 1; + return result; + } + + pair insert_unique(const value_type& obj) + { + resize(num_elements + 1); + return insert_unique_noresize(obj); + } + + iterator insert_equal(const value_type& obj) + { + resize(num_elements + 1); + return insert_equal_noresize(obj); + } + + pair insert_unique_noresize(const value_type& obj); + iterator insert_equal_noresize(const value_type& obj); + +#ifdef __STL_MEMBER_TEMPLATES + template + void insert_unique(InputIterator f, InputIterator l) + { + insert_unique(f, l, iterator_category(f)); + } + + template + void insert_equal(InputIterator f, InputIterator l) + { + insert_equal(f, l, iterator_category(f)); + } + + template + void insert_unique(InputIterator f, InputIterator l, + input_iterator_tag) + { + for ( ; f != l; ++f) + insert_unique(*f); + } + + template + void insert_equal(InputIterator f, InputIterator l, + input_iterator_tag) + { + for ( ; f != l; ++f) + insert_equal(*f); + } + + template + void insert_unique(ForwardIterator f, ForwardIterator l, + forward_iterator_tag) + { + size_type n = 0; + distance(f, l, n); + resize(num_elements + n); + for ( ; n > 0; --n, ++f) + insert_unique_noresize(*f); + } + + template + void insert_equal(ForwardIterator f, ForwardIterator l, + forward_iterator_tag) + { + size_type n = 0; + distance(f, l, n); + resize(num_elements + n); + for ( ; n > 0; --n, ++f) + insert_equal_noresize(*f); + } + + template + void insert_unique(BidirectionalIterator f, BidirectionalIterator l, + bidirectional_iterator_tag) + { + insert_unique(f, l, forward_iterator_tag()); + } + + template + void insert_equal(BidirectionalIterator f, BidirectionalIterator l, + bidirectional_iterator_tag) + { + insert_equal(f, l, forward_iterator_tag()); + } + + template + void insert_unique(RandomAccessIterator f, RandomAccessIterator l, + random_access_iterator_tag) + { + insert_unique(f, l, forward_iterator_tag()); + } + + template + void insert_equal(RandomAccessIterator f, RandomAccessIterator l, + random_access_iterator_tag) + { + insert_equal(f, l, forward_iterator_tag()); + } + +#else /* __STL_MEMBER_TEMPLATES */ + void insert_unique(const value_type* f, const value_type* l) + { + size_type n = l - f; + resize(num_elements + n); + for ( ; n > 0; --n, ++f) + insert_unique_noresize(*f); + } + + void insert_equal(const value_type* f, const value_type* l) + { + size_type n = l - f; + resize(num_elements + n); + for ( ; n > 0; --n, ++f) + insert_equal_noresize(*f); + } + + void insert_unique(const_iterator f, const_iterator l) + { + size_type n = 0; + distance(f, l, n); + resize(num_elements + n); + for ( ; n > 0; --n, ++f) + insert_unique_noresize(*f); + } + + void insert_equal(const_iterator f, const_iterator l) + { + size_type n = 0; + distance(f, l, n); + resize(num_elements + n); + for ( ; n > 0; --n, ++f) + insert_equal_noresize(*f); + } +#endif /*__STL_MEMBER_TEMPLATES */ + + reference find_or_insert(const value_type& obj); + + iterator find(const key_type& key) + { + size_type n = bkt_num_key(key); + node* first; + for ( first = buckets[n]; + first && !equals(get_key(first->val), key); + first = first->next) + {} + return iterator(first, this); + } + + const_iterator find(const key_type& key) const + { + size_type n = bkt_num_key(key); + const node* first; + for ( first = buckets[n]; + first && !equals(get_key(first->val), key); + first = first->next) + {} + return const_iterator(first, this); + } + + size_type count(const key_type& key) const + { + const size_type n = bkt_num_key(key); + size_type result = 0; + + for (const node* cur = buckets[n]; cur; cur = cur->next) + if (equals(get_key(cur->val), key)) + ++result; + return result; + } + + pair equal_range(const key_type& key); + pair equal_range(const key_type& key) const; + + size_type erase(const key_type& key); + void erase(const iterator& it); + void erase(iterator first, iterator last); + + void erase(const const_iterator& it); + void erase(const_iterator first, const_iterator last); + + void resize(size_type num_elements_hint); + void clear(); + +private: + size_type next_size(size_type n) const { return __stl_next_prime(n); } + + void initialize_buckets(size_type n) + { + const size_type n_buckets = next_size(n); + buckets.reserve(n_buckets); + buckets.insert(buckets.end(), n_buckets, (node*) 0); + num_elements = 0; + } + + size_type bkt_num_key(const key_type& key) const + { + return bkt_num_key(key, buckets.size()); + } + + size_type bkt_num(const value_type& obj) const + { + return bkt_num_key(get_key(obj)); + } + + size_type bkt_num_key(const key_type& key, size_t n) const + { + return hash(key) % n; + } + + size_type bkt_num(const value_type& obj, size_t n) const + { + return bkt_num_key(get_key(obj), n); + } + + node* new_node(const value_type& obj) + { + node* n = node_allocator::allocate(); + n->next = 0; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + construct(&n->val, obj); + return n; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + node_allocator::deallocate(n); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + + void delete_node(node* n) + { + destroy(&n->val); + node_allocator::deallocate(n); + } + + void erase_bucket(const size_type n, node* first, node* last); + void erase_bucket(const size_type n, node* last); + + void copy_from(const hashtable& ht); + +}; + +template +__hashtable_iterator& +__hashtable_iterator::operator++() +{ + const node* old = cur; + cur = cur->next; + if (!cur) { + size_type bucket = ht->bkt_num(old->val); + while (!cur && ++bucket < ht->buckets.size()) + cur = ht->buckets[bucket]; + } + return *this; +} + +template +inline __hashtable_iterator +__hashtable_iterator::operator++(int) +{ + iterator tmp = *this; + ++*this; + return tmp; +} + +template +__hashtable_const_iterator& +__hashtable_const_iterator::operator++() +{ + const node* old = cur; + cur = cur->next; + if (!cur) { + size_type bucket = ht->bkt_num(old->val); + while (!cur && ++bucket < ht->buckets.size()) + cur = ht->buckets[bucket]; + } + return *this; +} + +template +inline __hashtable_const_iterator +__hashtable_const_iterator::operator++(int) +{ + const_iterator tmp = *this; + ++*this; + return tmp; +} + + +template +inline forward_iterator_tag +iterator_category(const __hashtable_iterator&) +{ + return forward_iterator_tag(); +} + +template +inline V* value_type(const __hashtable_iterator&) +{ + return (V*) 0; +} + +template +inline hashtable::difference_type* +distance_type(const __hashtable_iterator&) +{ + return (hashtable::difference_type*) 0; +} + +template +inline forward_iterator_tag +iterator_category(const __hashtable_const_iterator&) +{ + return forward_iterator_tag(); +} + +template +inline V* +value_type(const __hashtable_const_iterator&) +{ + return (V*) 0; +} + +template +inline hashtable::difference_type* +distance_type(const __hashtable_const_iterator&) +{ + return (hashtable::difference_type*) 0; +} + +template +bool operator==(const hashtable& ht1, + const hashtable& ht2) +{ + typedef hashtable::node node; + if (ht1.buckets.size() != ht2.buckets.size()) + return false; + for (int n = 0; n < ht1.buckets.size(); ++n) { + node* cur1 = ht1.buckets[n]; + node* cur2 = ht2.buckets[n]; + for ( ; cur1 && cur2 && cur1->val == cur2->val; + cur1 = cur1->next, cur2 = cur2->next) + {} + if (cur1 || cur2) + return false; + } + return true; +} + +template +pair::iterator, bool> +hashtable::insert_unique_noresize(const value_type& obj) +{ + const size_type n = bkt_num(obj); + node* first = buckets[n]; + + for (node* cur = first; cur; cur = cur->next) + if (equals(get_key(cur->val), get_key(obj))) + return pair(iterator(cur, this), false); + + node* tmp = new_node(obj); + tmp->next = first; + buckets[n] = tmp; + ++num_elements; + return pair(iterator(tmp, this), true); +} + +template +hashtable::iterator +hashtable::insert_equal_noresize(const value_type& obj) +{ + const size_type n = bkt_num(obj); + node* first = buckets[n]; + + for (node* cur = first; cur; cur = cur->next) + if (equals(get_key(cur->val), get_key(obj))) { + node* tmp = new_node(obj); + tmp->next = cur->next; + cur->next = tmp; + ++num_elements; + return iterator(tmp, this); + } + + node* tmp = new_node(obj); + tmp->next = first; + buckets[n] = tmp; + ++num_elements; + return iterator(tmp, this); +} + +template +hashtable::reference +hashtable::find_or_insert(const value_type& obj) +{ + resize(num_elements + 1); + + size_type n = bkt_num(obj); + node* first = buckets[n]; + + for (node* cur = first; cur; cur = cur->next) + if (equals(get_key(cur->val), get_key(obj))) + return cur->val; + + node* tmp = new_node(obj); + tmp->next = first; + buckets[n] = tmp; + ++num_elements; + return tmp->val; +} + +template +pair::iterator, + hashtable::iterator> +hashtable::equal_range(const key_type& key) +{ + typedef pair pii; + const size_type n = bkt_num_key(key); + + for (node* first = buckets[n]; first; first = first->next) { + if (equals(get_key(first->val), key)) { + for (node* cur = first->next; cur; cur = cur->next) + if (!equals(get_key(cur->val), key)) + return pii(iterator(first, this), iterator(cur, this)); + for (size_type m = n + 1; m < buckets.size(); ++m) + if (buckets[m]) + return pii(iterator(first, this), + iterator(buckets[m], this)); + return pii(iterator(first, this), end()); + } + } + return pii(end(), end()); +} + +template +pair::const_iterator, + hashtable::const_iterator> +hashtable::equal_range(const key_type& key) const +{ + typedef pair pii; + const size_type n = bkt_num_key(key); + + for (const node* first = buckets[n] ; first; first = first->next) { + if (equals(get_key(first->val), key)) { + for (const node* cur = first->next; cur; cur = cur->next) + if (!equals(get_key(cur->val), key)) + return pii(const_iterator(first, this), + const_iterator(cur, this)); + for (size_type m = n + 1; m < buckets.size(); ++m) + if (buckets[m]) + return pii(const_iterator(first, this), + const_iterator(buckets[m], this)); + return pii(const_iterator(first, this), end()); + } + } + return pii(end(), end()); +} + +template +hashtable::size_type +hashtable::erase(const key_type& key) +{ + const size_type n = bkt_num_key(key); + node* first = buckets[n]; + size_type erased = 0; + + if (first) { + node* cur = first; + node* next = cur->next; + while (next) { + if (equals(get_key(next->val), key)) { + cur->next = next->next; + delete_node(next); + next = cur->next; + ++erased; + --num_elements; + } + else { + cur = next; + next = cur->next; + } + } + if (equals(get_key(first->val), key)) { + buckets[n] = first->next; + delete_node(first); + ++erased; + --num_elements; + } + } + return erased; +} + +template +void hashtable::erase(const iterator& it) +{ + if (node* const p = it.cur) { + const size_type n = bkt_num(p->val); + node* cur = buckets[n]; + + if (cur == p) { + buckets[n] = cur->next; + delete_node(cur); + --num_elements; + } + else { + node* next = cur->next; + while (next) { + if (next == p) { + cur->next = next->next; + delete_node(next); + --num_elements; + break; + } + else { + cur = next; + next = cur->next; + } + } + } + } +} + +template +void hashtable::erase(iterator first, iterator last) +{ + size_type f_bucket = first.cur ? bkt_num(first.cur->val) : buckets.size(); + size_type l_bucket = last.cur ? bkt_num(last.cur->val) : buckets.size(); + + if (first.cur == last.cur) + return; + else if (f_bucket == l_bucket) + erase_bucket(f_bucket, first.cur, last.cur); + else { + erase_bucket(f_bucket, first.cur, 0); + for (size_type n = f_bucket + 1; n < l_bucket; ++n) + erase_bucket(n, 0); + if (l_bucket != buckets.size()) + erase_bucket(l_bucket, last.cur); + } +} + +template +inline void +hashtable::erase(const_iterator first, + const_iterator last) +{ + erase(iterator(const_cast(first.cur), + const_cast(first.ht)), + iterator(const_cast(last.cur), + const_cast(last.ht))); +} + +template +inline void +hashtable::erase(const const_iterator& it) +{ + erase(iterator(const_cast(it.cur), + const_cast(it.ht))); +} + +template +void hashtable::resize(size_type num_elements_hint) +{ + const size_type old_n = buckets.size(); + if (num_elements_hint > old_n) { + const size_type n = next_size(num_elements_hint); + if (n > old_n) { + vector tmp(n, (node*) 0); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for (size_type bucket = 0; bucket < old_n; ++bucket) { + node* first = buckets[bucket]; + while (first) { + size_type new_bucket = bkt_num(first->val, n); + buckets[bucket] = first->next; + first->next = tmp[new_bucket]; + tmp[new_bucket] = first; + first = buckets[bucket]; + } + } + buckets.swap(tmp); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + for (size_type bucket = 0; bucket < tmp.size(); ++bucket) { + while (tmp[bucket]) { + node* next = tmp[bucket]->next; + delete_node(tmp[bucket]); + tmp[bucket] = next; + } + } + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + } +} + +template +void hashtable::erase_bucket(const size_type n, + node* first, node* last) +{ + node* cur = buckets[n]; + if (cur == first) + erase_bucket(n, last); + else { + node* next; + for (next = cur->next; next != first; cur = next, next = cur->next) + ; + while (next) { + cur->next = next->next; + delete_node(next); + next = cur->next; + --num_elements; + } + } +} + +template +void +hashtable::erase_bucket(const size_type n, node* last) +{ + node* cur = buckets[n]; + while (cur != last) { + node* next = cur->next; + delete_node(cur); + cur = next; + buckets[n] = cur; + --num_elements; + } +} + +template +void hashtable::clear() +{ + for (size_type i = 0; i < buckets.size(); ++i) { + node* cur = buckets[i]; + while (cur != 0) { + node* next = cur->next; + delete_node(cur); + cur = next; + } + buckets[i] = 0; + } + num_elements = 0; +} + + +template +void hashtable::copy_from(const hashtable& ht) +{ + buckets.clear(); + buckets.reserve(ht.buckets.size()); + buckets.insert(buckets.end(), ht.buckets.size(), (node*) 0); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + for (size_type i = 0; i < ht.buckets.size(); ++i) { + if (const node* cur = ht.buckets[i]) { + node* copy = new_node(cur->val); + buckets[i] = copy; + + for (node* next = cur->next; next; cur = next, next = cur->next) { + copy->next = new_node(next->val); + copy = copy->next; + } + } + } + num_elements = ht.num_elements; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ +} + + +#endif /* __SGI_STL_HASHTABLE_H */ diff --git a/libstdc++/stl/heap.h b/libstdc++/stl/heap.h new file mode 100644 index 000000000000..b24afafadd6d --- /dev/null +++ b/libstdc++/stl/heap.h @@ -0,0 +1,204 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef __SGI_STL_HEAP_H +#define __SGI_STL_HEAP_H + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma set woff 1209 +#endif + +template +void __push_heap(RandomAccessIterator first, Distance holeIndex, + Distance topIndex, T value) { + Distance parent = (holeIndex - 1) / 2; + while (holeIndex > topIndex && *(first + parent) < value) { + *(first + holeIndex) = *(first + parent); + holeIndex = parent; + parent = (holeIndex - 1) / 2; + } + *(first + holeIndex) = value; +} + +template +inline void __push_heap_aux(RandomAccessIterator first, + RandomAccessIterator last, Distance*, T*) { + __push_heap(first, Distance((last - first) - 1), Distance(0), + T(*(last - 1))); +} + +template +inline void push_heap(RandomAccessIterator first, RandomAccessIterator last) { + __push_heap_aux(first, last, distance_type(first), value_type(first)); +} + +template +void __push_heap(RandomAccessIterator first, Distance holeIndex, + Distance topIndex, T value, Compare comp) { + Distance parent = (holeIndex - 1) / 2; + while (holeIndex > topIndex && comp(*(first + parent), value)) { + *(first + holeIndex) = *(first + parent); + holeIndex = parent; + parent = (holeIndex - 1) / 2; + } + *(first + holeIndex) = value; +} + +template +inline void __push_heap_aux(RandomAccessIterator first, + RandomAccessIterator last, Compare comp, + Distance*, T*) { + __push_heap(first, Distance((last - first) - 1), Distance(0), + T(*(last - 1)), comp); +} + +template +inline void push_heap(RandomAccessIterator first, RandomAccessIterator last, + Compare comp) { + __push_heap_aux(first, last, comp, distance_type(first), value_type(first)); +} + +template +void __adjust_heap(RandomAccessIterator first, Distance holeIndex, + Distance len, T value) { + Distance topIndex = holeIndex; + Distance secondChild = 2 * holeIndex + 2; + while (secondChild < len) { + if (*(first + secondChild) < *(first + (secondChild - 1))) + secondChild--; + *(first + holeIndex) = *(first + secondChild); + holeIndex = secondChild; + secondChild = 2 * (secondChild + 1); + } + if (secondChild == len) { + *(first + holeIndex) = *(first + (secondChild - 1)); + holeIndex = secondChild - 1; + } + __push_heap(first, holeIndex, topIndex, value); +} + +template +inline void __pop_heap(RandomAccessIterator first, RandomAccessIterator last, + RandomAccessIterator result, T value, Distance*) { + *result = *first; + __adjust_heap(first, Distance(0), Distance(last - first), value); +} + +template +inline void __pop_heap_aux(RandomAccessIterator first, + RandomAccessIterator last, T*) { + __pop_heap(first, last - 1, last - 1, T(*(last - 1)), distance_type(first)); +} + +template +inline void pop_heap(RandomAccessIterator first, RandomAccessIterator last) { + __pop_heap_aux(first, last, value_type(first)); +} + +template +void __adjust_heap(RandomAccessIterator first, Distance holeIndex, + Distance len, T value, Compare comp) { + Distance topIndex = holeIndex; + Distance secondChild = 2 * holeIndex + 2; + while (secondChild < len) { + if (comp(*(first + secondChild), *(first + (secondChild - 1)))) + secondChild--; + *(first + holeIndex) = *(first + secondChild); + holeIndex = secondChild; + secondChild = 2 * (secondChild + 1); + } + if (secondChild == len) { + *(first + holeIndex) = *(first + (secondChild - 1)); + holeIndex = secondChild - 1; + } + __push_heap(first, holeIndex, topIndex, value, comp); +} + +template +inline void __pop_heap(RandomAccessIterator first, RandomAccessIterator last, + RandomAccessIterator result, T value, Compare comp, + Distance*) { + *result = *first; + __adjust_heap(first, Distance(0), Distance(last - first), value, comp); +} + +template +inline void __pop_heap_aux(RandomAccessIterator first, + RandomAccessIterator last, T*, Compare comp) { + __pop_heap(first, last - 1, last - 1, T(*(last - 1)), comp, + distance_type(first)); +} + +template +inline void pop_heap(RandomAccessIterator first, RandomAccessIterator last, + Compare comp) { + __pop_heap_aux(first, last, value_type(first), comp); +} + +template +void __make_heap(RandomAccessIterator first, RandomAccessIterator last, T*, + Distance*) { + if (last - first < 2) return; + Distance len = last - first; + Distance parent = (len - 2)/2; + + while (true) { + __adjust_heap(first, parent, len, T(*(first + parent))); + if (parent == 0) return; + parent--; + } +} + +template +inline void make_heap(RandomAccessIterator first, RandomAccessIterator last) { + __make_heap(first, last, value_type(first), distance_type(first)); +} + +template +void __make_heap(RandomAccessIterator first, RandomAccessIterator last, + Compare comp, T*, Distance*) { + if (last - first < 2) return; + Distance len = last - first; + Distance parent = (len - 2)/2; + + while (true) { + __adjust_heap(first, parent, len, T(*(first + parent)), comp); + if (parent == 0) return; + parent--; + } +} + +template +inline void make_heap(RandomAccessIterator first, RandomAccessIterator last, + Compare comp) { + __make_heap(first, last, comp, value_type(first), distance_type(first)); +} + +template +void sort_heap(RandomAccessIterator first, RandomAccessIterator last) { + while (last - first > 1) pop_heap(first, last--); +} + +template +void sort_heap(RandomAccessIterator first, RandomAccessIterator last, + Compare comp) { + while (last - first > 1) pop_heap(first, last--, comp); +} + +#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) +#pragma reset woff 1209 +#endif + +#endif /* __SGI_STL_HEAP_H */ diff --git a/libstdc++/stl/iterator.h b/libstdc++/stl/iterator.h new file mode 100644 index 000000000000..bdd2260596ac --- /dev/null +++ b/libstdc++/stl/iterator.h @@ -0,0 +1,598 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_ITERATOR_H +#define __SGI_STL_ITERATOR_H + +#include +#include +#include + +struct input_iterator_tag {}; +struct output_iterator_tag {}; +struct forward_iterator_tag {}; +struct bidirectional_iterator_tag {}; +struct random_access_iterator_tag {}; + +template struct input_iterator { + typedef input_iterator_tag iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef T* pointer; + typedef T& reference; +}; + +struct output_iterator { + typedef output_iterator_tag iterator_category; +}; + +template struct forward_iterator { + typedef forward_iterator_tag iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef T* pointer; + typedef T& reference; +}; + + +template struct bidirectional_iterator { + typedef bidirectional_iterator_tag iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef T* pointer; + typedef T& reference; +}; + +template struct random_access_iterator { + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef T* pointer; + typedef T& reference; +}; + +#if 0 +template +struct iterator { + typedef Category iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef Pointer pointer; + typedef Reference reference; +}; +#endif + +#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION + +template +struct iterator_traits { + typedef typename Iterator::iterator_category iterator_category; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; +}; + +template +struct iterator_traits { + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef T& reference; +}; + +#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + +template +inline input_iterator_tag +iterator_category(const input_iterator&) { + return input_iterator_tag(); +} + +inline output_iterator_tag iterator_category(const output_iterator&) { + return output_iterator_tag(); +} + +template +inline forward_iterator_tag +iterator_category(const forward_iterator&) { + return forward_iterator_tag(); +} + +template +inline bidirectional_iterator_tag +iterator_category(const bidirectional_iterator&) { + return bidirectional_iterator_tag(); +} + +template +inline random_access_iterator_tag +iterator_category(const random_access_iterator&) { + return random_access_iterator_tag(); +} + +template +inline random_access_iterator_tag iterator_category(const T*) { + return random_access_iterator_tag(); +} + +template +inline T* value_type(const input_iterator&) { + return (T*)(0); +} + +template +inline T* value_type(const forward_iterator&) { + return (T*)(0); +} + +template +inline T* value_type(const bidirectional_iterator&) { + return (T*)(0); +} + +template +inline T* value_type(const random_access_iterator&) { + return (T*)(0); +} + +template +inline T* value_type(const T*) { return (T*)(0); } + +template +inline Distance* distance_type(const input_iterator&) { + return (Distance*)(0); +} + +template +inline Distance* distance_type(const forward_iterator&) { + return (Distance*)(0); +} + +template +inline Distance* +distance_type(const bidirectional_iterator&) { + return (Distance*)(0); +} + +template +inline Distance* +distance_type(const random_access_iterator&) { + return (Distance*)(0); +} + +template +inline ptrdiff_t* distance_type(const T*) { return (ptrdiff_t*)(0); } + +template +class back_insert_iterator { +protected: + Container* container; +public: + typedef output_iterator_tag iterator_category; + + explicit back_insert_iterator(Container& x) : container(&x) {} + back_insert_iterator& + operator=(const typename Container::value_type& value) { + container->push_back(value); + return *this; + } + back_insert_iterator& operator*() { return *this; } + back_insert_iterator& operator++() { return *this; } + back_insert_iterator& operator++(int) { return *this; } +}; + +template +inline output_iterator_tag +iterator_category(const back_insert_iterator&) +{ + return output_iterator_tag(); +} + +template +inline back_insert_iterator back_inserter(Container& x) { + return back_insert_iterator(x); +} + +template +class front_insert_iterator { +protected: + Container* container; +public: + typedef output_iterator_tag iterator_category; + + explicit front_insert_iterator(Container& x) : container(&x) {} + front_insert_iterator& + operator=(const typename Container::value_type& value) { + container->push_front(value); + return *this; + } + front_insert_iterator& operator*() { return *this; } + front_insert_iterator& operator++() { return *this; } + front_insert_iterator& operator++(int) { return *this; } +}; + +template +inline output_iterator_tag +iterator_category(const front_insert_iterator&) +{ + return output_iterator_tag(); +} + +template +inline front_insert_iterator front_inserter(Container& x) { + return front_insert_iterator(x); +} + +template +class insert_iterator { +protected: + Container* container; + typename Container::iterator iter; +public: + typedef output_iterator_tag iterator_category; + + insert_iterator(Container& x, typename Container::iterator i) + : container(&x), iter(i) {} + insert_iterator& + operator=(const typename Container::value_type& value) { + iter = container->insert(iter, value); + ++iter; + return *this; + } + insert_iterator& operator*() { return *this; } + insert_iterator& operator++() { return *this; } + insert_iterator& operator++(int) { return *this; } +}; + +template +inline output_iterator_tag +iterator_category(const insert_iterator&) +{ + return output_iterator_tag(); +} + +template +inline insert_iterator inserter(Container& x, Iterator i) { + typedef typename Container::iterator iter; + return insert_iterator(x, iter(i)); +} + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template +#else +template +#endif +class reverse_bidirectional_iterator { + typedef reverse_bidirectional_iterator self; + friend bool operator==(const self& x, const self& y); +protected: + BidirectionalIterator current; +public: + typedef bidirectional_iterator_tag iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef T* pointer; + typedef Reference reference; + + reverse_bidirectional_iterator() {} + explicit reverse_bidirectional_iterator(BidirectionalIterator x) + : current(x) {} + BidirectionalIterator base() { return current; } + Reference operator*() const { + BidirectionalIterator tmp = current; + return *--tmp; + } + self& operator++() { + --current; + return *this; + } + self operator++(int) { + self tmp = *this; + --current; + return tmp; + } + self& operator--() { + ++current; + return *this; + } + self operator--(int) { + self tmp = *this; + ++current; + return tmp; + } +}; + + +template +inline bidirectional_iterator_tag +iterator_category(const reverse_bidirectional_iterator&) { + return bidirectional_iterator_tag(); +} + +template +inline T* +value_type(const reverse_bidirectional_iterator&) { + return (T*) 0; +} + +template +inline Distance* +distance_type(const reverse_bidirectional_iterator&) { + return (Distance*) 0; +} + +template +inline bool operator==( + const reverse_bidirectional_iterator& x, + const reverse_bidirectional_iterator& y) { + return x.current == y.current; +} + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template +#else +template +#endif +class reverse_iterator { + typedef reverse_iterator + self; + friend bool operator==(const self& x, const self& y); + friend bool operator<(const self& x, const self& y); + friend Distance operator-(const self& x, const self& y); + friend self operator+(Distance n, const self& x); +protected: + RandomAccessIterator current; +public: + typedef random_access_iterator_tag iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef T* pointer; + typedef Reference reference; + + reverse_iterator() {} + explicit reverse_iterator(RandomAccessIterator x) : current(x) {} + RandomAccessIterator base() { return current; } + Reference operator*() const { return *(current - 1); } + self& operator++() { + --current; + return *this; + } + self operator++(int) { + self tmp = *this; + --current; + return tmp; + } + self& operator--() { + ++current; + return *this; + } + self operator--(int) { + self tmp = *this; + ++current; + return tmp; + } + self operator+(Distance n) const { + return self(current - n); + } + self& operator+=(Distance n) { + current -= n; + return *this; + } + self operator-(Distance n) const { + return self(current + n); + } + self& operator-=(Distance n) { + current += n; + return *this; + } + Reference operator[](Distance n) { return *(*this + n); } +}; + +template +inline random_access_iterator_tag +iterator_category(const reverse_iterator&) { + return random_access_iterator_tag(); +} + +template +inline T* value_type(const reverse_iterator&) { + return (T*) 0; +} + +template +inline Distance* distance_type(const reverse_iterator&) { + return (Distance*) 0; +} + + +template +inline bool operator==(const reverse_iterator& x, + const reverse_iterator& y) { + return x.current == y.current; +} + +template +inline bool operator<(const reverse_iterator& x, + const reverse_iterator& y) { + return y.current < x.current; +} + +template +inline Distance operator-(const reverse_iterator& x, + const reverse_iterator& y) { + return y.current - x.current; +} + +template +inline reverse_iterator +operator+(Distance n, + const reverse_iterator& x) { + return reverse_iterator + (x.current - n); +} + + +template +class raw_storage_iterator { +protected: + ForwardIterator iter; +public: + typedef output_iterator_tag iterator_category; + + explicit raw_storage_iterator(ForwardIterator x) : iter(x) {} + raw_storage_iterator& operator*() { return *this; } + raw_storage_iterator& operator=(const T& element) { + construct(&*iter, element); + return *this; + } + raw_storage_iterator& operator++() { + ++iter; + return *this; + } + raw_storage_iterator operator++(int) { + raw_storage_iterator tmp = *this; + ++iter; + return tmp; + } +}; + +template +inline output_iterator_tag +iterator_category(const raw_storage_iterator&) +{ + return output_iterator_tag(); +} + +template +class istream_iterator { +friend bool operator==(const istream_iterator& x, + const istream_iterator& y); +protected: + istream* stream; + T value; + bool end_marker; + void read() { + end_marker = (*stream) ? true : false; + if (end_marker) *stream >> value; + end_marker = (*stream) ? true : false; + } +public: + typedef input_iterator_tag iterator_category; + typedef T value_type; + typedef Distance difference_type; + typedef T* pointer; + typedef T& reference; + + istream_iterator() : stream(&cin), end_marker(false) {} + istream_iterator(istream& s) : stream(&s) { read(); } + const T& operator*() const { return value; } + istream_iterator& operator++() { + read(); + return *this; + } + istream_iterator operator++(int) { + istream_iterator tmp = *this; + read(); + return tmp; + } +}; + +template +inline input_iterator_tag +iterator_category(const istream_iterator&) { + return input_iterator_tag(); +} + +template +inline T* value_type(const istream_iterator&) { return (T*) 0; } + +template +inline Distance* distance_type(const istream_iterator&) { + return (Distance*) 0; +} + +template +bool operator==(const istream_iterator& x, + const istream_iterator& y) { + return x.stream == y.stream && x.end_marker == y.end_marker || + x.end_marker == false && y.end_marker == false; +} + +template +class ostream_iterator { +protected: + ostream* stream; + const char* string; +public: + typedef output_iterator_tag iterator_category; + + ostream_iterator(ostream& s) : stream(&s), string(0) {} + ostream_iterator(ostream& s, const char* c) : stream(&s), string(c) {} + ostream_iterator& operator=(const T& value) { + *stream << value; + if (string) *stream << string; + return *this; + } + ostream_iterator& operator*() { return *this; } + ostream_iterator& operator++() { return *this; } + ostream_iterator& operator++(int) { return *this; } +}; + +template +inline output_iterator_tag +iterator_category(const ostream_iterator&) { + return output_iterator_tag(); +} + +#endif /* __SGI_STL_ITERATOR_H */ diff --git a/libstdc++/stl/list.h b/libstdc++/stl/list.h new file mode 100644 index 000000000000..b26692b5c82a --- /dev/null +++ b/libstdc++/stl/list.h @@ -0,0 +1,624 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_LIST_H +#define __SGI_STL_LIST_H + +#include +#include +#include +#include + +template +struct __list_node { + typedef void* void_pointer; + void_pointer next; + void_pointer prev; + T data; +}; + +template +struct __list_iterator { + typedef __list_iterator iterator; + typedef __list_iterator const_iterator; + typedef __list_iterator self; + + typedef bidirectional_iterator_tag iterator_category; + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef __list_node* link_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + link_type node; + + __list_iterator(link_type x) : node(x) {} + __list_iterator() {} + __list_iterator(const iterator& x) : node(x.node) {} + + bool operator==(const self& x) const { return node == x.node; } + bool operator!=(const self& x) const { return node != x.node; } + Ref operator*() const { return (*node).data; } + + self& operator++() { + node = (link_type)((*node).next); + return *this; + } + self operator++(int) { + self tmp = *this; + ++*this; + return tmp; + } + self& operator--() { + node = (link_type)((*node).prev); + return *this; + } + self operator--(int) { + self tmp = *this; + --*this; + return tmp; + } +}; + + +template +inline bidirectional_iterator_tag +iterator_category(const __list_iterator&) { + return bidirectional_iterator_tag(); +} + +template +inline T* +value_type(const __list_iterator&) { + return 0; +} + +template +inline ptrdiff_t* +distance_type(const __list_iterator&) { + return 0; +} + + +template +class list { +protected: + typedef void* void_pointer; + typedef __list_node list_node; + typedef simple_alloc list_node_allocator; +public: + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef list_node* link_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +public: + typedef __list_iterator iterator; + typedef __list_iterator const_iterator; + + typedef reverse_bidirectional_iterator + const_reverse_iterator; + typedef reverse_bidirectional_iterator + reverse_iterator; + +protected: + link_type get_node() { return list_node_allocator::allocate(); } + void put_node(link_type p) { list_node_allocator::deallocate(p); } + + link_type create_node(const T& x) { + link_type p = get_node(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + construct(&p->data, x); + return p; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + put_node(p); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + void destroy_node(link_type p) { + destroy(&p->data); + put_node(p); + } + +protected: + void empty_initialize() { + node = get_node(); + node->next = node; + node->prev = node; + } + + void fill_initialize(size_type n, const T& value) { + empty_initialize(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + insert(begin(), n, value); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + put_node(node); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + +#ifdef __STL_MEMBER_TEMPLATES + template + void range_initialize(InputIterator first, InputIterator last) { + empty_initialize(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + insert(begin(), first, last); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + put_node(node); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +#else /* __STL_MEMBER_TEMPLATES */ + void range_initialize(const T* first, const T* last) { + empty_initialize(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + insert(begin(), first, last); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + put_node(node); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + void range_initialize(const_iterator first, const_iterator last) { + empty_initialize(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + insert(begin(), first, last); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + put_node(node); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +#endif /* __STL_MEMBER_TEMPLATES */ + +protected: + link_type node; + +public: + list() { empty_initialize(); } + + iterator begin() { return (link_type)((*node).next); } + const_iterator begin() const { return (link_type)((*node).next); } + iterator end() { return node; } + const_iterator end() const { return node; } + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + bool empty() const { return node->next == node; } + size_type size() const { + size_type result = 0; + distance(begin(), end(), result); + return result; + } + size_type max_size() const { return size_type(-1); } + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(--end()); } + const_reference back() const { return *(--end()); } + void swap(list& x) { ::swap(node, x.node); } + iterator insert(iterator position, const T& x) { + link_type tmp = create_node(x); + tmp->next = position.node; + tmp->prev = position.node->prev; + (link_type(position.node->prev))->next = tmp; + position.node->prev = tmp; + return tmp; + } + iterator insert(iterator position) { return insert(position, T()); } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(iterator position, InputIterator first, InputIterator last); +#else /* __STL_MEMBER_TEMPLATES */ + void insert(iterator position, const T* first, const T* last); + void insert(iterator position, + const_iterator first, const_iterator last); +#endif /* __STL_MEMBER_TEMPLATES */ + void insert(iterator pos, size_type n, const T& x); + void insert(iterator pos, int n, const T& x) { + insert(pos, (size_type)n, x); + } + void insert(iterator pos, long n, const T& x) { + insert(pos, (size_type)n, x); + } + + void push_front(const T& x) { insert(begin(), x); } + void push_back(const T& x) { insert(end(), x); } + void erase(iterator position) { + (link_type(position.node->prev))->next = position.node->next; + (link_type(position.node->next))->prev = position.node->prev; + destroy_node(position.node); + } + void erase(iterator first, iterator last); + void resize(size_type new_size, const T& x); + void resize(size_type new_size) { resize(new_size, T()); } + void clear(); + + void pop_front() { erase(begin()); } + void pop_back() { + iterator tmp = end(); + erase(--tmp); + } + list(size_type n, const T& value) { fill_initialize(n, value); } + list(int n, const T& value) { fill_initialize(n, value); } + list(long n, const T& value) { fill_initialize(n, value); } + explicit list(size_type n) { fill_initialize(n, T()); } + +#ifdef __STL_MEMBER_TEMPLATES + template + list(InputIterator first, InputIterator last) { + range_initialize(first, last); + } + +#else /* __STL_MEMBER_TEMPLATES */ + list(const T* first, const T* last) { range_initialize(first, last); } + list(const_iterator first, const_iterator last) { + range_initialize(first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + list(const list& x) { + range_initialize(x.begin(), x.end()); + } + ~list() { + clear(); + put_node(node); + } + list& operator=(const list& x); + +protected: + void transfer(iterator position, iterator first, iterator last) { + if (position != last) { + (*(link_type((*last.node).prev))).next = position.node; + (*(link_type((*first.node).prev))).next = last.node; + (*(link_type((*position.node).prev))).next = first.node; + link_type tmp = link_type((*position.node).prev); + (*position.node).prev = (*last.node).prev; + (*last.node).prev = (*first.node).prev; + (*first.node).prev = tmp; + } + } + +public: + void splice(iterator position, list& x) { + if (!x.empty()) + transfer(position, x.begin(), x.end()); + } + void splice(iterator position, list&, iterator i) { + iterator j = i; + ++j; + if (position == i || position == j) return; + transfer(position, i, j); + } + void splice(iterator position, list&, iterator first, iterator last) { + if (first != last) + transfer(position, first, last); + } + void remove(const T& value); + void unique(); + void merge(list& x); + void reverse(); + void sort(); + +#ifdef __STL_MEMBER_TEMPLATES + template void remove_if(Predicate); + template void unique(BinaryPredicate); + template void merge(list&, StrictWeakOrdering); + template void sort(StrictWeakOrdering); +#endif /* __STL_MEMBER_TEMPLATES */ + + friend bool operator== (const list& x, const list& y); +}; + +template +inline bool operator==(const list& x, const list& y) { + typedef list::link_type link_type; + link_type e1 = x.node; + link_type e2 = y.node; + link_type n1 = (link_type) e1->next; + link_type n2 = (link_type) e2->next; + for ( ; n1 != e1 && n2 != e2 ; + n1 = (link_type) n1->next, n2 = (link_type) n2->next) + if (n1->data != n2->data) + return false; + return n1 == e1 && n2 == e2; +} + +template +inline bool operator<(const list& x, const list& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +#ifdef __STL_MEMBER_TEMPLATES + +template template +void list::insert(iterator position, + InputIterator first, InputIterator last) { + for ( ; first != last; ++first) + insert(position, *first); +} + +#else /* __STL_MEMBER_TEMPLATES */ + +template +void list::insert(iterator position, const T* first, const T* last) { + for ( ; first != last; ++first) + insert(position, *first); +} + +template +void list::insert(iterator position, + const_iterator first, const_iterator last) { + for ( ; first != last; ++first) + insert(position, *first); +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +template +void list::insert(iterator position, size_type n, const T& x) { + for ( ; n > 0; --n) + insert(position, x); +} + +template +void list::erase(iterator first, iterator last) { + while (first != last) erase(first++); +} + +template +void list::resize(size_type new_size, const T& x) +{ + size_type len = size(); + if (new_size < len) { + iterator f; + if (new_size < len / 2) { + f = begin(); + advance(f, new_size); + } + else { + f = end(); + advance(f, difference_type(len) - difference_type(new_size)); + } + erase(f, end()); + } + else + insert(end(), new_size - len, x); +} + +template +void list::clear() +{ + link_type cur = (link_type) node->next; + while (cur != node) { + link_type tmp = cur; + cur = (link_type) cur->next; + destroy_node(tmp); + } + node->next = node; + node->prev = node; +} + +template +list& list::operator=(const list& x) { + if (this != &x) { + iterator first1 = begin(); + iterator last1 = end(); + const_iterator first2 = x.begin(); + const_iterator last2 = x.end(); + while (first1 != last1 && first2 != last2) *first1++ = *first2++; + if (first2 == last2) + erase(first1, last1); + else + insert(last1, first2, last2); + } + return *this; +} + +template +void list::remove(const T& value) { + iterator first = begin(); + iterator last = end(); + while (first != last) { + iterator next = first; + ++next; + if (*first == value) erase(first); + first = next; + } +} + +template +void list::unique() { + iterator first = begin(); + iterator last = end(); + if (first == last) return; + iterator next = first; + while (++next != last) { + if (*first == *next) + erase(next); + else + first = next; + next = first; + } +} + +template +void list::merge(list& x) { + iterator first1 = begin(); + iterator last1 = end(); + iterator first2 = x.begin(); + iterator last2 = x.end(); + while (first1 != last1 && first2 != last2) + if (*first2 < *first1) { + iterator next = first2; + transfer(first1, first2, ++next); + first2 = next; + } + else + ++first1; + if (first2 != last2) transfer(last1, first2, last2); +} + +template +void list::reverse() { + if (node->next == node || link_type(node->next)->next == node) return; + iterator first = begin(); + ++first; + while (first != end()) { + iterator old = first; + ++first; + transfer(begin(), old, first); + } +} + +template +void list::sort() { + if (node->next == node || link_type(node->next)->next == node) return; + list carry; + list counter[64]; + int fill = 0; + while (!empty()) { + carry.splice(carry.begin(), *this, begin()); + int i = 0; + while(i < fill && !counter[i].empty()) { + counter[i].merge(carry); + carry.swap(counter[i++]); + } + carry.swap(counter[i]); + if (i == fill) ++fill; + } + + for (int i = 1; i < fill; ++i) counter[i].merge(counter[i-1]); + swap(counter[fill-1]); +} + +#ifdef __STL_MEMBER_TEMPLATES + +template template +void list::remove_if(Predicate pred) { + iterator first = begin(); + iterator last = end(); + while (first != last) { + iterator next = first; + ++next; + if (pred(*first)) erase(first); + first = next; + } +} + +template template +void list::unique(BinaryPredicate binary_pred) { + iterator first = begin(); + iterator last = end(); + if (first == last) return; + iterator next = first; + while (++next != last) { + if (binary_pred(*first, *next)) + erase(next); + else + first = next; + next = first; + } +} + +template template +void list::merge(list& x, StrictWeakOrdering comp) { + iterator first1 = begin(); + iterator last1 = end(); + iterator first2 = x.begin(); + iterator last2 = x.end(); + while (first1 != last1 && first2 != last2) + if (comp(*first2, *first1)) { + iterator next = first2; + transfer(first1, first2, ++next); + first2 = next; + } + else + ++first1; + if (first2 != last2) transfer(last1, first2, last2); +} + +template template +void list::sort(StrictWeakOrdering comp) { + if (node->next == node || link_type(node->next)->next == node) return; + list carry; + list counter[64]; + int fill = 0; + while (!empty()) { + carry.splice(carry.begin(), *this, begin()); + int i = 0; + while(i < fill && !counter[i].empty()) { + counter[i].merge(carry, comp); + carry.swap(counter[i++]); + } + carry.swap(counter[i]); + if (i == fill) ++fill; + } + + for (int i = 1; i < fill; ++i) counter[i].merge(counter[i-1], comp); + swap(counter[fill-1]); +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +#endif /* __SGI_STL_LIST_H */ diff --git a/libstdc++/stl/map.h b/libstdc++/stl/map.h new file mode 100644 index 000000000000..5c9d6b1bf3bb --- /dev/null +++ b/libstdc++/stl/map.h @@ -0,0 +1,188 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_MAP_H +#define __SGI_STL_MAP_H + +#include + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , class Alloc = alloc> +#else +template +#endif +class map { +public: + +// typedefs: + + typedef Key key_type; + typedef T data_type; + typedef pair value_type; + typedef Compare key_compare; + + class value_compare + : public binary_function { + friend class map; + protected : + Compare comp; + value_compare(Compare c) : comp(c) {} + public: + bool operator()(const value_type& x, const value_type& y) const { + return comp(x.first, y.first); + } + }; + +private: + typedef rb_tree, key_compare, Alloc> rep_type; + rep_type t; // red-black tree representing map +public: + typedef rep_type::pointer pointer; + typedef rep_type::reference reference; + typedef rep_type::const_reference const_reference; + typedef rep_type::iterator iterator; + typedef rep_type::const_iterator const_iterator; + typedef rep_type::reverse_iterator reverse_iterator; + typedef rep_type::const_reverse_iterator const_reverse_iterator; + typedef rep_type::size_type size_type; + typedef rep_type::difference_type difference_type; + + // allocation/deallocation + + map() : t(Compare()) {} + explicit map(const Compare& comp) : t(comp) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + map(InputIterator first, InputIterator last) + : t(Compare()) { t.insert_unique(first, last); } + + template + map(InputIterator first, InputIterator last, const Compare& comp) + : t(comp) { t.insert_unique(first, last); } +#else + map(const value_type* first, const value_type* last) + : t(Compare()) { t.insert_unique(first, last); } + map(const value_type* first, const value_type* last, const Compare& comp) + : t(comp) { t.insert_unique(first, last); } + + map(const_iterator first, const_iterator last) + : t(Compare()) { t.insert_unique(first, last); } + map(const_iterator first, const_iterator last, const Compare& comp) + : t(comp) { t.insert_unique(first, last); } +#endif /* __STL_MEMBER_TEMPLATES */ + + map(const map& x) : t(x.t) {} + map& operator=(const map& x) + { + t = x.t; + return *this; + } + + // accessors: + + key_compare key_comp() const { return t.key_comp(); } + value_compare value_comp() const { return value_compare(t.key_comp()); } + iterator begin() { return t.begin(); } + const_iterator begin() const { return t.begin(); } + iterator end() { return t.end(); } + const_iterator end() const { return t.end(); } + reverse_iterator rbegin() { return t.rbegin(); } + const_reverse_iterator rbegin() const { return t.rbegin(); } + reverse_iterator rend() { return t.rend(); } + const_reverse_iterator rend() const { return t.rend(); } + bool empty() const { return t.empty(); } + size_type size() const { return t.size(); } + size_type max_size() const { return t.max_size(); } + T& operator[](const key_type& k) { + return (*((insert(value_type(k, T()))).first)).second; + } + void swap(map& x) { t.swap(x.t); } + + // insert/erase + + pair insert(const value_type& x) { return t.insert_unique(x); } + iterator insert(iterator position, const value_type& x) { + return t.insert_unique(position, x); + } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator first, InputIterator last) { + t.insert_unique(first, last); + } +#else + void insert(const value_type* first, const value_type* last) { + t.insert_unique(first, last); + } + void insert(const_iterator first, const_iterator last) { + t.insert_unique(first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + + void erase(iterator position) { t.erase(position); } + size_type erase(const key_type& x) { return t.erase(x); } + void erase(iterator first, iterator last) { t.erase(first, last); } + void clear() { t.clear(); } + + // map operations: + + iterator find(const key_type& x) { return t.find(x); } + const_iterator find(const key_type& x) const { return t.find(x); } + size_type count(const key_type& x) const { return t.count(x); } + iterator lower_bound(const key_type& x) {return t.lower_bound(x); } + const_iterator lower_bound(const key_type& x) const { + return t.lower_bound(x); + } + iterator upper_bound(const key_type& x) {return t.upper_bound(x); } + const_iterator upper_bound(const key_type& x) const { + return t.upper_bound(x); + } + + pair equal_range(const key_type& x) { + return t.equal_range(x); + } + pair equal_range(const key_type& x) const { + return t.equal_range(x); + } + friend bool operator==(const map&, const map&); + friend bool operator<(const map&, const map&); +}; + +template +inline bool operator==(const map& x, + const map& y) { + return x.t == y.t; +} + +template +inline bool operator<(const map& x, + const map& y) { + return x.t < y.t; +} + +#endif /* __SGI_STL_MAP_H */ + diff --git a/libstdc++/stl/multimap.h b/libstdc++/stl/multimap.h new file mode 100644 index 000000000000..f15880af39d9 --- /dev/null +++ b/libstdc++/stl/multimap.h @@ -0,0 +1,182 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_MULTIMAP_H +#define __SGI_STL_MULTIMAP_H + +#include + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , class Alloc = alloc> +#else +template +#endif +class multimap { +public: + +// typedefs: + + typedef Key key_type; + typedef T data_type; + typedef pair value_type; + typedef Compare key_compare; + + class value_compare : public binary_function { + friend class multimap; + protected: + Compare comp; + value_compare(Compare c) : comp(c) {} + public: + bool operator()(const value_type& x, const value_type& y) const { + return comp(x.first, y.first); + } + }; + +private: + typedef rb_tree, key_compare, Alloc> rep_type; + rep_type t; // red-black tree representing multimap +public: + typedef rep_type::pointer pointer; + typedef rep_type::reference reference; + typedef rep_type::const_reference const_reference; + typedef rep_type::iterator iterator; + typedef rep_type::const_iterator const_iterator; + typedef rep_type::reverse_iterator reverse_iterator; + typedef rep_type::const_reverse_iterator const_reverse_iterator; + typedef rep_type::size_type size_type; + typedef rep_type::difference_type difference_type; + +// allocation/deallocation + + multimap() : t(Compare()) { } + explicit multimap(const Compare& comp) : t(comp) { } + +#ifdef __STL_MEMBER_TEMPLATES + template + multimap(InputIterator first, InputIterator last) + : t(Compare()) { t.insert_equal(first, last); } + + template + multimap(InputIterator first, InputIterator last, const Compare& comp) + : t(comp) { t.insert_equal(first, last); } +#else + multimap(const value_type* first, const value_type* last) + : t(Compare()) { t.insert_equal(first, last); } + multimap(const value_type* first, const value_type* last, + const Compare& comp) + : t(comp) { t.insert_equal(first, last); } + + multimap(const_iterator first, const_iterator last) + : t(Compare()) { t.insert_equal(first, last); } + multimap(const_iterator first, const_iterator last, const Compare& comp) + : t(comp) { t.insert_equal(first, last); } +#endif /* __STL_MEMBER_TEMPLATES */ + + multimap(const multimap& x) : t(x.t) { } + multimap& + operator=(const multimap& x) { + t = x.t; + return *this; + } + + // accessors: + + key_compare key_comp() const { return t.key_comp(); } + value_compare value_comp() const { return value_compare(t.key_comp()); } + iterator begin() { return t.begin(); } + const_iterator begin() const { return t.begin(); } + iterator end() { return t.end(); } + const_iterator end() const { return t.end(); } + reverse_iterator rbegin() { return t.rbegin(); } + const_reverse_iterator rbegin() const { return t.rbegin(); } + reverse_iterator rend() { return t.rend(); } + const_reverse_iterator rend() const { return t.rend(); } + bool empty() const { return t.empty(); } + size_type size() const { return t.size(); } + size_type max_size() const { return t.max_size(); } + void swap(multimap& x) { t.swap(x.t); } + + // insert/erase + + iterator insert(const value_type& x) { return t.insert_equal(x); } + iterator insert(iterator position, const value_type& x) { + return t.insert_equal(position, x); + } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator first, InputIterator last) { + t.insert_equal(first, last); + } +#else + void insert(const value_type* first, const value_type* last) { + t.insert_equal(first, last); + } + void insert(const_iterator first, const_iterator last) { + t.insert_equal(first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + void erase(iterator position) { t.erase(position); } + size_type erase(const key_type& x) { return t.erase(x); } + void erase(iterator first, iterator last) { t.erase(first, last); } + void clear() { t.clear(); } + + // multimap operations: + + iterator find(const key_type& x) { return t.find(x); } + const_iterator find(const key_type& x) const { return t.find(x); } + size_type count(const key_type& x) const { return t.count(x); } + iterator lower_bound(const key_type& x) {return t.lower_bound(x); } + const_iterator lower_bound(const key_type& x) const { + return t.lower_bound(x); + } + iterator upper_bound(const key_type& x) {return t.upper_bound(x); } + const_iterator upper_bound(const key_type& x) const { + return t.upper_bound(x); + } + pair equal_range(const key_type& x) { + return t.equal_range(x); + } + pair equal_range(const key_type& x) const { + return t.equal_range(x); + } + friend bool operator==(const multimap&, const multimap&); + friend bool operator<(const multimap&, const multimap&); +}; + +template +inline bool operator==(const multimap& x, + const multimap& y) { + return x.t == y.t; +} + +template +inline bool operator<(const multimap& x, + const multimap& y) { + return x.t < y.t; +} + +#endif /* __SGI_STL_MULTIMAP_H */ diff --git a/libstdc++/stl/multiset.h b/libstdc++/stl/multiset.h new file mode 100644 index 000000000000..3df4557b18f1 --- /dev/null +++ b/libstdc++/stl/multiset.h @@ -0,0 +1,167 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_MULTISET_H +#define __SGI_STL_MULTISET_H + +#include + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , class Alloc = alloc> +#else +template +#endif +class multiset { +public: + // typedefs: + + typedef Key key_type; + typedef Key value_type; + typedef Compare key_compare; + typedef Compare value_compare; +private: + typedef rb_tree, key_compare, Alloc> rep_type; + rep_type t; // red-black tree representing multiset +public: + typedef rep_type::const_pointer pointer; + typedef rep_type::const_reference reference; + typedef rep_type::const_reference const_reference; + typedef rep_type::const_iterator iterator; + typedef rep_type::const_iterator const_iterator; + typedef rep_type::const_reverse_iterator reverse_iterator; + typedef rep_type::const_reverse_iterator const_reverse_iterator; + typedef rep_type::size_type size_type; + typedef rep_type::difference_type difference_type; + + // allocation/deallocation + + multiset() : t(Compare()) {} + explicit multiset(const Compare& comp) : t(comp) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + multiset(InputIterator first, InputIterator last) + : t(Compare()) { t.insert_equal(first, last); } + template + multiset(InputIterator first, InputIterator last, const Compare& comp) + : t(comp) { t.insert_equal(first, last); } +#else + multiset(const value_type* first, const value_type* last) + : t(Compare()) { t.insert_equal(first, last); } + multiset(const value_type* first, const value_type* last, + const Compare& comp) + : t(comp) { t.insert_equal(first, last); } + + multiset(const_iterator first, const_iterator last) + : t(Compare()) { t.insert_equal(first, last); } + multiset(const_iterator first, const_iterator last, const Compare& comp) + : t(comp) { t.insert_equal(first, last); } +#endif /* __STL_MEMBER_TEMPLATES */ + + multiset(const multiset& x) : t(x.t) {} + multiset& + operator=(const multiset& x) { + t = x.t; + return *this; + } + + // accessors: + + key_compare key_comp() const { return t.key_comp(); } + value_compare value_comp() const { return t.key_comp(); } + iterator begin() const { return t.begin(); } + iterator end() const { return t.end(); } + reverse_iterator rbegin() const { return t.rbegin(); } + reverse_iterator rend() const { return t.rend(); } + bool empty() const { return t.empty(); } + size_type size() const { return t.size(); } + size_type max_size() const { return t.max_size(); } + void swap(multiset& x) { t.swap(x.t); } + + // insert/erase + iterator insert(const value_type& x) { + return t.insert_equal(x); + } + iterator insert(iterator position, const value_type& x) { + return t.insert_equal((rep_type::iterator&)position, x); + } + +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator first, InputIterator last) { + t.insert_equal(first, last); + } +#else + void insert(const value_type* first, const value_type* last) { + t.insert_equal(first, last); + } + void insert(const_iterator first, const_iterator last) { + t.insert_equal(first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + void erase(iterator position) { + t.erase((rep_type::iterator&)position); + } + size_type erase(const key_type& x) { + return t.erase(x); + } + void erase(iterator first, iterator last) { + t.erase((rep_type::iterator&)first, + (rep_type::iterator&)last); + } + void clear() { t.clear(); } + + // multiset operations: + + iterator find(const key_type& x) const { return t.find(x); } + size_type count(const key_type& x) const { return t.count(x); } + iterator lower_bound(const key_type& x) const { + return t.lower_bound(x); + } + iterator upper_bound(const key_type& x) const { + return t.upper_bound(x); + } + pair equal_range(const key_type& x) const { + return t.equal_range(x); + } + friend bool operator==(const multiset&, const multiset&); + friend bool operator<(const multiset&, const multiset&); +}; + +template +inline bool operator==(const multiset& x, + const multiset& y) { + return x.t == y.t; +} + +template +inline bool operator<(const multiset& x, + const multiset& y) { + return x.t < y.t; +} + +#endif /* __SGI_STL_MULTISET_H */ diff --git a/libstdc++/stl/pair.h b/libstdc++/stl/pair.h new file mode 100644 index 000000000000..ca20d8baf8af --- /dev/null +++ b/libstdc++/stl/pair.h @@ -0,0 +1,63 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef PAIR_H +#define PAIR_H + +#include + +template +struct pair { + typedef T1 first_type; + typedef T2 second_type; + + T1 first; + T2 second; + pair() : first(T1()), second(T2()) {} + pair(const T1& a, const T2& b) : first(a), second(b) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + pair(const pair& p) : first(p.first), second(p.second) {} +#endif +}; + +template +inline bool operator==(const pair& x, const pair& y) { + return x.first == y.first && x.second == y.second; +} + +template +inline bool operator<(const pair& x, const pair& y) { + return x.first < y.first || (!(y.first < x.first) && x.second < y.second); +} + +template +inline pair make_pair(const T1& x, const T2& y) { + return pair(x, y); +} + +#endif diff --git a/libstdc++/stl/pthread_alloc.h b/libstdc++/stl/pthread_alloc.h new file mode 100644 index 000000000000..a2aeaa1290e9 --- /dev/null +++ b/libstdc++/stl/pthread_alloc.h @@ -0,0 +1,344 @@ +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __PTHREAD_ALLOC_H +#define __PTHREAD_ALLOC_H + +// Pthread-specific node allocator. +// This is similar to the default allocator, except that free-list +// information is kept separately for each thread, avoiding locking. +// This should be reasonably fast even in the presence of threads. +// The down side is that storage may not be well-utilized. +// It is not an error to allocate memory in thread A and deallocate +// it n thread B. But this effectively transfers ownership of the memory, +// so that it can only be reallocated by thread B. Thus this can effectively +// result in a storage leak if it's done on a regular basis. +// It can also result in frequent sharing of +// cache lines among processors, with potentially serious performance +// consequences. + + +#include +#include +#include +#include +#include +#ifndef __RESTRICT +# define __RESTRICT +#endif + +// Note that this class has nonstatic members. We instantiate it once +// per thread. +template +class __pthread_alloc_template { + +private: + enum {ALIGN = 8}; + enum {MAX_BYTES = 128}; // power of 2 + enum {NFREELISTS = MAX_BYTES/ALIGN}; + + union obj { + union obj * free_list_link; + char client_data[ALIGN]; /* The client sees this. */ + }; + + // Per instance state + obj* volatile free_list[NFREELISTS]; + __pthread_alloc_template* next; // Free list link + + static size_t ROUND_UP(size_t bytes) { + return (((bytes) + ALIGN-1) & ~(ALIGN - 1)); + } + static size_t FREELIST_INDEX(size_t bytes) { + return (((bytes) + ALIGN-1)/ALIGN - 1); + } + + // Returns an object of size n, and optionally adds to size n free list. + void *refill(size_t n); + // Allocates a chunk for nobjs of size size. nobjs may be reduced + // if it is inconvenient to allocate the requested number. + static char *chunk_alloc(size_t size, int &nobjs); + + // Chunk allocation state. And other shared state. + // Protected by chunk_allocator_lock. + static pthread_mutex_t chunk_allocator_lock; + static char *start_free; + static char *end_free; + static size_t heap_size; + static __pthread_alloc_template* free_allocators; + static pthread_key_t key; + static bool key_initialized; + // Pthread key under which allocator is stored. + // Allocator instances that are currently unclaimed by any thread. + static void destructor(void *instance); + // Function to be called on thread exit to reclaim allocator + // instance. + static __pthread_alloc_template *new_allocator(); + // Return a recycled or new allocator instance. + static __pthread_alloc_template *get_allocator_instance(); + // ensure that the current thread has an associated + // allocator instance. + class lock { + public: + lock () { pthread_mutex_lock(&chunk_allocator_lock); } + ~lock () { pthread_mutex_unlock(&chunk_allocator_lock); } + }; + friend class lock; + + +public: + + __pthread_alloc_template() : next(0) + { + memset((void *)free_list, 0, NFREELISTS * sizeof(obj *)); + } + + /* n must be > 0 */ + static void * allocate(size_t n) + { + obj * volatile * my_free_list; + obj * __RESTRICT result; + __pthread_alloc_template* a; + + if (n > MAX_BYTES) { + return(malloc(n)); + } + if (!key_initialized || + !(a = (__pthread_alloc_template*) + pthread_getspecific(key))) { + a = get_allocator_instance(); + } + my_free_list = a -> free_list + FREELIST_INDEX(n); + result = *my_free_list; + if (result == 0) { + void *r = a -> refill(ROUND_UP(n)); + return r; + } + *my_free_list = result -> free_list_link; + return (result); + }; + + /* p may not be 0 */ + static void deallocate(void *p, size_t n) + { + obj *q = (obj *)p; + obj * volatile * my_free_list; + __pthread_alloc_template* a; + + if (n > MAX_BYTES) { + free(p); + return; + } + if (!key_initialized || + !(a = (__pthread_alloc_template*) + pthread_getspecific(key))) { + a = get_allocator_instance(); + } + my_free_list = a->free_list + FREELIST_INDEX(n); + q -> free_list_link = *my_free_list; + *my_free_list = q; + } + + static void * reallocate(void *p, size_t old_sz, size_t new_sz); + +} ; + +typedef __pthread_alloc_template pthread_alloc; + + +template +void __pthread_alloc_template::destructor(void * instance) +{ + __pthread_alloc_template* a = + (__pthread_alloc_template*)instance; + a -> next = free_allocators; + free_allocators = a; +} + +template +__pthread_alloc_template* +__pthread_alloc_template::new_allocator() +{ + if (0 != free_allocators) { + __pthread_alloc_template* result = free_allocators; + free_allocators = free_allocators -> next; + return result; + } else { + return new __pthread_alloc_template; + } +} + +template +__pthread_alloc_template* +__pthread_alloc_template::get_allocator_instance() +{ + __pthread_alloc_template* result; + if (!key_initialized) { + /*REFERENCED*/ + lock lock_instance; + if (!key_initialized) { + if (pthread_key_create(&key, destructor)) { + abort(); // failed + } + key_initialized = true; + } + } + result = new_allocator(); + if (pthread_setspecific(key, result)) abort(); + return result; +} + +/* We allocate memory in large chunks in order to avoid fragmenting */ +/* the malloc heap too much. */ +/* We assume that size is properly aligned. */ +template +char *__pthread_alloc_template +::chunk_alloc(size_t size, int &nobjs) +{ + { + char * result; + size_t total_bytes; + size_t bytes_left; + /*REFERENCED*/ + lock lock_instance; // Acquire lock for this routine + + total_bytes = size * nobjs; + bytes_left = end_free - start_free; + if (bytes_left >= total_bytes) { + result = start_free; + start_free += total_bytes; + return(result); + } else if (bytes_left >= size) { + nobjs = bytes_left/size; + total_bytes = size * nobjs; + result = start_free; + start_free += total_bytes; + return(result); + } else { + size_t bytes_to_get = 2 * total_bytes + ROUND_UP(heap_size >> 4); + // Try to make use of the left-over piece. + if (bytes_left > 0) { + __pthread_alloc_template* a = + (__pthread_alloc_template*)pthread_getspecific(key); + obj * volatile * my_free_list = + a->free_list + FREELIST_INDEX(bytes_left); + + ((obj *)start_free) -> free_list_link = *my_free_list; + *my_free_list = (obj *)start_free; + } +# ifdef _SGI_SOURCE + // Try to get memory that's aligned on something like a + // cache line boundary, so as to avoid parceling out + // parts of the same line to different threads and thus + // possibly different processors. + { + const int cache_line_size = 128; // probable upper bound + bytes_to_get &= ~(cache_line_size-1); + start_free = (char *)memalign(cache_line_size, bytes_to_get); + if (0 == start_free) { + start_free = (char *)malloc_alloc::allocate(bytes_to_get); + } + } +# else /* !SGI_SOURCE */ + start_free = (char *)malloc_alloc::allocate(bytes_to_get); +# endif + heap_size += bytes_to_get; + end_free = start_free + bytes_to_get; + } + } + // lock is released here + return(chunk_alloc(size, nobjs)); +} + + +/* Returns an object of size n, and optionally adds to size n free list.*/ +/* We assume that n is properly aligned. */ +/* We hold the allocation lock. */ +template +void *__pthread_alloc_template +::refill(size_t n) +{ + int nobjs = 128; + char * chunk = chunk_alloc(n, nobjs); + obj * volatile * my_free_list; + obj * result; + obj * current_obj, * next_obj; + int i; + + if (1 == nobjs) { + return(chunk); + } + my_free_list = free_list + FREELIST_INDEX(n); + + /* Build free list in chunk */ + result = (obj *)chunk; + *my_free_list = next_obj = (obj *)(chunk + n); + for (i = 1; ; i++) { + current_obj = next_obj; + next_obj = (obj *)((char *)next_obj + n); + if (nobjs - 1 == i) { + current_obj -> free_list_link = 0; + break; + } else { + current_obj -> free_list_link = next_obj; + } + } + return(result); +} + +template +void *__pthread_alloc_template +::reallocate(void *p, size_t old_sz, size_t new_sz) +{ + void * result; + size_t copy_sz; + + if (old_sz > MAX_BYTES && new_sz > MAX_BYTES) { + return(realloc(p, new_sz)); + } + if (ROUND_UP(old_sz) == ROUND_UP(new_sz)) return(p); + result = allocate(new_sz); + copy_sz = new_sz > old_sz? old_sz : new_sz; + memcpy(result, p, copy_sz); + deallocate(p, old_sz); + return(result); +} + +template +__pthread_alloc_template * +__pthread_alloc_template::free_allocators = 0; + +template +pthread_key_t __pthread_alloc_template::key; + +template +bool __pthread_alloc_template::key_initialized = false; + +template +pthread_mutex_t __pthread_alloc_template::chunk_allocator_lock += PTHREAD_MUTEX_INITIALIZER; + +template +char *__pthread_alloc_template +::start_free = 0; + +template +char *__pthread_alloc_template +::end_free = 0; + +template +size_t __pthread_alloc_template +::heap_size = 0; + + +#endif /* __NODE_ALLOC_H */ diff --git a/libstdc++/stl/rope.h b/libstdc++/stl/rope.h new file mode 100644 index 000000000000..105eb05d0cc6 --- /dev/null +++ b/libstdc++/stl/rope.h @@ -0,0 +1,2055 @@ +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef _ROPE_H +# define _ROPE_H + +# include +# include +# include +# include +# include +# include +# include +# ifdef __GC +# define __GC_CONST const +# else +# define __GC_CONST // constant except for deallocation +# endif +# ifdef __STL_SGI_THREADS +# include +# endif + +// The end-of-C-string character. +// This is what the draft standard says it should be. +template +inline charT __eos(charT*) { return charT(); } + +// Test for basic character types. +// For basic character types leaves having a trailing eos. +template +inline bool __is_basic_char_type(charT* c) { return false; } +template +inline bool __is_one_byte_char_type(charT* c) { return false; } + +inline bool __is_basic_char_type(char* c) { return true; } +inline bool __is_one_byte_char_type(char* c) { return true; } +inline bool __is_basic_char_type(wchar_t* c) { return true; } + +// Store an eos iff charT is a basic character type. +// Do not reference __eos if it isn't. +template +inline void __cond_store_eos(charT& c) {} + +inline void __cond_store_eos(char& c) { c = 0; } +inline void __cond_store_eos(wchar_t& c) { c = 0; } + + +// rope is a sequence of charT. +// Ropes appear to be mutable, but update operations +// really copy enough of the data structure to leave the original +// valid. Thus ropes can be logically copied by just copying +// a pointer value. +// The __eos function is used for those functions that +// convert to/from C-like strings to detect the end of the string. +// __compare is used as the character comparison function. +template +class char_producer { + public: + virtual ~char_producer() {}; + virtual void operator()(size_t start_pos, size_t len, charT* buffer) + = 0; + // Buffer should really be an arbitrary output iterator. + // That way we could flatten directly into an ostream, etc. + // This is thoroughly impossible, since iterator types don't + // have runtime descriptions. +}; + +// Sequence buffers: +// +// Sequence must provide an append operation that appends an +// array to the sequence. Sequence buffers are useful only if +// appending an entire array is cheaper than appending element by element. +// This is true for many string representations. +// This should perhaps inherit from ostream +// and be implemented correspondingly, so that they can be used +// for formatted. For the sake of portability, we don't do this yet. +// +// For now, sequence buffers behave as output iterators. But they also +// behave a little like basic_ostringstream and a +// little like containers. + +template +// The 3rd parameter works around a common compiler bug. +class sequence_buffer : public output_iterator { + public: +# ifndef __TYPEDEF_WORKAROUND + typedef typename sequence::value_type value_type; +# else + typedef v value_type; +# endif + protected: + sequence *prefix; + value_type buffer[buf_sz]; + size_t buf_count; + public: + void flush() { + prefix->append(buffer, buffer + buf_count); + buf_count = 0; + } + ~sequence_buffer() { flush(); } + sequence_buffer() : prefix(0), buf_count(0) {} + sequence_buffer(const sequence_buffer & x) { + prefix = x.prefix; + buf_count = x.buf_count; + copy(x.buffer, x.buffer + x.buf_count, buffer); + } + sequence_buffer(sequence_buffer & x) { + x.flush(); + prefix = x.prefix; + buf_count = 0; + } + sequence_buffer(sequence& s) : prefix(&s), buf_count(0) {} + sequence_buffer& operator= (sequence_buffer& x) { + x.flush(); + prefix = x.prefix; + buf_count = 0; + return *this; + } + sequence_buffer& operator= (const sequence_buffer& x) { + prefix = x.prefix; + buf_count = x.buf_count; + copy(x.buffer, x.buffer + x.buf_count, buffer); + return *this; + } + void push_back(value_type x) + { + if (buf_count < buf_sz) { + buffer[buf_count] = x; + ++buf_count; + } else { + flush(); + buffer[0] = x; + buf_count = 1; + } + } + void append(value_type *s, size_t len) + { + if (len + buf_count <= buf_sz) { + size_t i, j; + for (i = buf_count, j = 0; j < len; i++, j++) { + buffer[i] = s[j]; + } + buf_count += len; + } else if (0 == buf_count) { + prefix->append(s, s + len); + } else { + flush(); + append(s, len); + } + } + sequence_buffer& write(value_type *s, size_t len) + { + append(s, len); + return *this; + } + sequence_buffer& put(value_type x) + { + push_back(x); + return *this; + } + sequence_buffer& operator=(const value_type& rhs) + { + push_back(rhs); + return *this; + } + sequence_buffer& operator*() { return *this; } + sequence_buffer& operator++() { return *this; } + sequence_buffer& operator++(int) { return *this; } +}; + +// The following should be treated as private, at least for now. +template +class __rope_char_consumer { + public: + // If we had member templates, these should not be virtual. + // For now we need to use run-time parametrization where + // compile-time would do. Hence this should all be private + // for now. + // The symmetry with char_producer is accidental and temporary. + virtual ~__rope_char_consumer() {}; + virtual bool operator()(const charT* buffer, size_t len) = 0; +}; + +// +// What follows should really be local to rope. Unfortunately, +// that doesn't work, since it makes it impossible to define generic +// equality on rope iterators. According to the draft standard, the +// template parameters for such an equality operator cannot be inferred +// from the occurence of a member class as a parameter. +// (SGI compilers in fact allow this, but the result wouldn't be +// portable.) +// Similarly, some of the static member functions are member functions +// only to avoid polluting the global namespace, and to circumvent +// restrictions on type inference for template functions. +// + +template class rope; +template struct __rope_RopeConcatenation; +template struct __rope_RopeLeaf; +template struct __rope_RopeFunction; +template struct __rope_RopeSubstring; +template class __rope_iterator; +template class __rope_const_iterator; +template class __rope_charT_ref_proxy; +template class __rope_charT_ptr_proxy; + +// +// The internal data structure for representing a rope. This is +// private to the implementation. A rope is really just a pointer +// to one of these. +// +// A few basic functions for manipulating this data structure +// are members of RopeBase. Most of the more complex algorithms +// are implemented as rope members. +// +// Some of the static member functions of RopeBase have identically +// named functions in rope that simply invoke the RopeBase versions. +// + +template +struct __rope_RopeBase { + typedef rope my_rope; + typedef simple_alloc<__rope_RopeConcatenation, Alloc> CAlloc; + typedef simple_alloc<__rope_RopeLeaf, Alloc> LAlloc; + typedef simple_alloc<__rope_RopeFunction, Alloc> FAlloc; + typedef simple_alloc<__rope_RopeSubstring, Alloc> SAlloc; + public: + enum { max_rope_depth = 45 }; + enum {leaf, concat, substringfn, function} tag:8; + bool is_balanced:8; + unsigned char depth; + size_t size; + __GC_CONST charT * c_string; + /* Flattened version of string, if needed. */ + /* typically 0. */ + /* If it's not 0, then the memory is owned */ + /* by this node. */ + /* In the case of a leaf, this may point to */ + /* the same memory as the data field. */ +# ifndef __GC +# if defined(__STL_WIN32THREADS) + long refcount; // InterlockedIncrement wants a long * +# else + size_t refcount; +# endif + // We count references from rope instances + // and references from other rope nodes. We + // do not count const_iterator references. + // Iterator references are counted so that rope modifications + // can be detected after the fact. + // Generally function results are counted, i.e. + // a pointer returned by a function is included at the + // point at which the pointer is returned. + // The recipient should decrement the count if the + // result is not needed. + // Generally function arguments are not reflected + // in the reference count. The callee should increment + // the count before saving the argument someplace that + // will outlive the call. +# endif +# ifndef __GC +# ifdef __STL_SGI_THREADS + // Reference counting with multiple threads and no + // hardware or thread package support is pretty awful. + // Mutexes are normally too expensive. + // We'll assume a COMPARE_AND_SWAP(destp, old, new) + // operation, which might be cheaper. +# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) +# define __add_and_fetch(l,v) add_then_test((unsigned long *)l,v) +# endif + void init_refcount_lock() {} + void incr_refcount () + { + __add_and_fetch(&refcount, 1); + } + size_t decr_refcount () + { + return __add_and_fetch(&refcount, (size_t)(-1)); + } +# elif defined(__STL_WIN32THREADS) + void init_refcount_lock() {} + void incr_refcount () + { + InterlockedIncrement(&refcount); + } + size_t decr_refcount () + { + return InterlockedDecrement(&refcount); + } +# elif defined(_PTHREADS) + // This should be portable, but performance is expected + // to be quite awful. This really needs platform specific + // code. + pthread_mutex_t refcount_lock; + void init_refcount_lock() { + pthread_mutex_init(&refcount_lock, 0); + } + void incr_refcount () + { + pthread_mutex_lock(&refcount_lock); + ++refcount; + pthread_mutex_unlock(&refcount_lock); + } + size_t decr_refcount () + { + size_t result; + pthread_mutex_lock(&refcount_lock); + result = --refcount; + pthread_mutex_unlock(&refcount_lock); + return result; + } +# else + void init_refcount_lock() {} + void incr_refcount () + { + ++refcount; + } + size_t decr_refcount () + { + --refcount; + return refcount; + } +# endif +# else + void incr_refcount () {} +# endif + static void free_string(charT *, size_t len); + // Deallocate data section of a leaf. + // This shouldn't be a member function. + // But its hard to do anything else at the + // moment, because it's templatized w.r.t. + // an allocator. + // Does nothing if __GC is defined. +# ifndef __GC + void free_c_string(); + void free_tree(); + // Deallocate t. Assumes t is not 0. + void unref_nonnil() + { + if (0 == decr_refcount()) free_tree(); + } + void ref_nonnil() + { + incr_refcount(); + } + static void unref(__rope_RopeBase* t) + { + if (0 != t) { + t -> unref_nonnil(); + } + } + static void ref(__rope_RopeBase* t) + { + if (0 != t) t -> incr_refcount(); + } +# else /* __GC */ + void unref_nonnil() {} + void ref_nonnil() {} + static void unref(__rope_RopeBase* t) {} + static void ref(__rope_RopeBase* t) {} + static void fn_finalization_proc(void * tree, void *); +# endif + + // The data fields of leaves are allocated with some + // extra space, to accomodate future growth and for basic + // character types, to hold a trailing eos character. + enum { alloc_granularity = 8 }; + static size_t rounded_up_size(size_t n) { + size_t size_with_eos; + + if (__is_basic_char_type((charT *)0)) { + size_with_eos = (n + 1) * sizeof(charT); + } else { + size_with_eos = n * sizeof(charT); + } +# ifdef __GC + return size_with_eos; +# else + // Allow slop for in-place expansion. + return (size_with_eos + alloc_granularity-1) + &~ (alloc_granularity-1); +# endif + } +}; + +template +struct __rope_RopeLeaf : public __rope_RopeBase { + public: // Apparently needed by VC++ + __GC_CONST charT* data; /* Not necessarily 0 terminated. */ + /* The allocated size is */ + /* rounded_up_size(size), except */ + /* in the GC case, in which it */ + /* doesn't matter. */ +}; + +template +struct __rope_RopeConcatenation : public __rope_RopeBase { + public: + __rope_RopeBase* left; + __rope_RopeBase* right; +}; + +template +struct __rope_RopeFunction : public __rope_RopeBase { + public: + char_producer* fn; +# ifndef __GC + bool delete_when_done; // Char_producer is owned by the + // rope and should be explicitly + // deleted when the rope becomes + // inaccessible. +# else + // In the GC case, we either register the rope for + // finalization, or not. Thus the field is unnecessary; + // the information is stored in the collector data structures. +# endif +}; +// Substring results are usually represented using just +// concatenation nodes. But in the case of very long flat ropes +// or ropes with a functional representation that isn't practical. +// In that case, we represent the result as a special case of +// RopeFunction, whose char_producer points back to the rope itself. +// In all cases except repeated substring operations and +// deallocation, we treat the result as a RopeFunction. +template +struct __rope_RopeSubstring: public __rope_RopeFunction, + public char_producer { + public: + __rope_RopeBase * base; // not 0 + size_t start; + virtual ~__rope_RopeSubstring() {} + virtual void operator()(size_t start_pos, size_t req_len, + charT *buffer) { + switch(base -> tag) { + case function: + case substringfn: + { + char_producer *fn = + ((__rope_RopeFunction *)base) -> fn; + __stl_assert(start_pos + req_len <= size); + __stl_assert(start + size <= base -> size); + (*fn)(start_pos + start, req_len, buffer); + } + break; + case leaf: + { + __GC_CONST charT * s = + ((__rope_RopeLeaf *)base) -> data; + uninitialized_copy_n(s + start_pos + start, req_len, + buffer); + } + break; + default: + __stl_assert(false); + } + } + __rope_RopeSubstring(__rope_RopeBase * b, size_t s, size_t l) : + base(b), start(s) { +# ifndef __GC + refcount = 1; + init_refcount_lock(); + base -> ref_nonnil(); +# endif + size = l; + tag = substringfn; + depth = 0; + c_string = 0; + fn = this; + } +}; + + +// Self-destructing pointers to RopeBase. +// These are not conventional smart pointers. Their +// only purpose in life is to ensure that unref is called +// on the pointer either at normal exit or if an exception +// is raised. It is the caller's responsibility to +// adjust reference counts when these pointers are initialized +// or assigned to. (This convention significantly reduces +// the number of potentially expensive reference count +// updates.) +#ifndef __GC + template + struct __rope_self_destruct_ptr { + __rope_RopeBase * ptr; + ~__rope_self_destruct_ptr() { __rope_RopeBase::unref(ptr); } +# ifdef __STL_USE_EXCEPTIONS + __rope_self_destruct_ptr() : ptr(0) {}; +# else + __rope_self_destruct_ptr() {}; +# endif + __rope_self_destruct_ptr(__rope_RopeBase * p) : ptr(p) {} + __rope_RopeBase & operator*() { return *ptr; } + __rope_RopeBase * operator->() { return ptr; } + operator __rope_RopeBase *() { return ptr; } + __rope_self_destruct_ptr & operator= (__rope_RopeBase * x) + { ptr = x; return *this; } + }; +#endif + +// unwind-protect +# ifdef __STL_USE_EXCEPTIONS +# define __STL_TRY try { +# define __STL_UNWIND(action) } catch(...) { action; throw; } +# define __STL_ALWAYS(action) action; } catch(...) { action; throw; } +# else +# define __STL_TRY { +# define __STL_UNWIND(action) } +# define __STL_ALWAYS(action) action; } +# endif +// Dereferencing a nonconst iterator has to return something +// that behaves almost like a reference. It's not possible to +// return an actual reference since assignment requires extra +// work. And we would get into the same problems as with the +// CD2 version of basic_string. +template +class __rope_charT_ref_proxy { + friend class rope; + friend class __rope_iterator; + friend class __rope_charT_ptr_proxy; +# ifdef __GC + typedef __rope_RopeBase * self_destruct_ptr; +# else + typedef __rope_self_destruct_ptr self_destruct_ptr; +# endif + typedef __rope_RopeBase RopeBase; + typedef rope my_rope; + size_t pos; + charT current; + bool current_valid; + my_rope * root; // The whole rope. + public: + __rope_charT_ref_proxy(my_rope * r, size_t p) : + pos(p), root(r), current_valid(false) {} + __rope_charT_ref_proxy(my_rope * r, size_t p, + charT c) : + pos(p), root(r), current(c), current_valid(true) {} + operator charT () const; + __rope_charT_ref_proxy& operator= (charT c); + __rope_charT_ptr_proxy operator& () const; + __rope_charT_ref_proxy& operator= (const __rope_charT_ref_proxy& c) { + return operator=((charT)c); + } +}; + +template +class __rope_charT_ptr_proxy { + friend class __rope_charT_ref_proxy; + size_t pos; + charT current; + bool current_valid; + rope * root; // The whole rope. + public: + __rope_charT_ptr_proxy(const __rope_charT_ref_proxy & x) : + pos(x.pos), root(x.root), current_valid(x.current_valid), + current(x.current) {} + __rope_charT_ptr_proxy(const __rope_charT_ptr_proxy & x) : + pos(x.pos), root(x.root), current_valid(x.current_valid), + current(x.current) {} + __rope_charT_ptr_proxy() {} + __rope_charT_ptr_proxy(charT * x) : root(0), pos(0) { + __stl_assert(0 == x); + } + __rope_charT_ptr_proxy& operator= (const __rope_charT_ptr_proxy& x) { + pos = x.pos; + current = x.current; + current_valid = x.current_valid; + root = x.root; + return *this; + } + friend bool operator== + (const __rope_charT_ptr_proxy & x, + const __rope_charT_ptr_proxy & y); + __rope_charT_ref_proxy operator *() const { + if (current_valid) { + return __rope_charT_ref_proxy(root, pos, current); + } else { + return __rope_charT_ref_proxy(root, pos); + } + } +}; + +// Rope iterators: +// Unlike in the C version, we cache only part of the stack +// for rope iterators, since they must be efficiently copyable. +// When we run out of cache, we have to reconstruct the iterator +// value. +// Pointers from iterators are not included in reference counts. +// Iterators are assumed to be thread private. Ropes can +// be shared. + +template +class __rope_iterator_base: + public random_access_iterator { + friend class rope; + public: + typedef __rope_RopeBase RopeBase; + // Borland doesnt want this to be protected. + protected: + enum { path_cache_len = 4 }; // Must be <= 9. + enum { iterator_buf_len = 15 }; + size_t current_pos; + RopeBase * root; // The whole rope. + size_t leaf_pos; // Starting position for current leaf + __GC_CONST charT * buf_start; + // Buffer possibly + // containing current char. + __GC_CONST charT * buf_ptr; + // Pointer to current char in buffer. + // != 0 ==> buffer valid. + __GC_CONST charT * buf_end; + // One past last valid char in buffer. + // What follows is the path cache. We go out of our + // way to make this compact. + // Path_end contains the bottom section of the path from + // the root to the current leaf. + const RopeBase * path_end[path_cache_len]; + int leaf_index; // Last valid pos in path_end; + // path_end[0] ... path_end[leaf_index-1] + // point to concatenation nodes. + unsigned char path_directions; + // (path_directions >> i) & 1 is 1 + // iff we got from path_end[leaf_index - i - 1] + // to path_end[leaf_index - i] by going to the + // right. Assumes path_cache_len <= 9. + charT tmp_buf[iterator_buf_len]; + // Short buffer for surrounding chars. + // This is useful primarily for + // RopeFunctions. We put the buffer + // here to avoid locking in the + // multithreaded case. + // The cached path is generally assumed to be valid + // only if the buffer is valid. + static void setbuf(__rope_iterator_base &x); + // Set buffer contents given + // path cache. + static void setcache(__rope_iterator_base &x); + // Set buffer contents and + // path cache. + static void setcache_for_incr(__rope_iterator_base &x); + // As above, but assumes path + // cache is valid for previous posn. + __rope_iterator_base() {} + __rope_iterator_base(RopeBase * root, size_t pos): + root(root), current_pos(pos), buf_ptr(0) {} + __rope_iterator_base(const __rope_iterator_base& x) { + if (0 != x.buf_ptr) { + *this = x; + } else { + current_pos = x.current_pos; + root = x.root; + buf_ptr = 0; + } + } + void incr(size_t n); + void decr(size_t n); + public: + size_t index() const { return current_pos; } +}; + +template class __rope_iterator; + +template +class __rope_const_iterator : public __rope_iterator_base { + friend class rope; + protected: + __rope_const_iterator(const RopeBase * root, size_t pos): + __rope_iterator_base( + const_cast(root), pos) + // Only nonconst iterators modify root ref count + {} + + public: + __rope_const_iterator() {}; + __rope_const_iterator(const __rope_const_iterator & x) : + __rope_iterator_base(x) { } + __rope_const_iterator(const __rope_iterator & x); + __rope_const_iterator(const rope &r, size_t pos) : + __rope_iterator_base(r.tree_ptr, pos) {} + __rope_const_iterator& operator= (const __rope_const_iterator & x) { + if (0 != x.buf_ptr) { + *this = x; + } else { + current_pos = x.current_pos; + root = x.root; + buf_ptr = 0; + } + return(*this); + } + const charT& operator*() { + if (0 == buf_ptr) setcache(*this); + return *buf_ptr; + } + __rope_const_iterator& operator++() { + __GC_CONST charT * next; + if (0 != buf_ptr && (next = buf_ptr + 1) < buf_end) { + buf_ptr = next; + ++current_pos; + } else { + incr(1); + } + return *this; + } + __rope_const_iterator& operator+=(ptrdiff_t n) { + if (n >= 0) { + incr(n); + } else { + decr(-n); + } + return *this; + } + __rope_const_iterator& operator--() { + decr(1); + return *this; + } + __rope_const_iterator& operator-=(ptrdiff_t n) { + if (n >= 0) { + decr(n); + } else { + incr(-n); + } + return *this; + } + __rope_const_iterator operator++(int) { + size_t old_pos = current_pos; + incr(1); + return __rope_const_iterator(root, old_pos); + // This makes a subsequent dereference expensive. + // Perhaps we should instead copy the iterator + // if it has a valid cache? + } + __rope_const_iterator operator--(int) { + size_t old_pos = current_pos; + decr(1); + return __rope_const_iterator(root, old_pos); + } + friend __rope_const_iterator operator- + (const __rope_const_iterator & x, + ptrdiff_t n); + friend __rope_const_iterator operator+ + (const __rope_const_iterator & x, + ptrdiff_t n); + friend __rope_const_iterator operator+ + (ptrdiff_t n, + const __rope_const_iterator & x); + charT operator[](size_t n) { + return rope::fetch(root, current_pos + n); + } + friend bool operator== + (const __rope_const_iterator & x, + const __rope_const_iterator & y); + friend bool operator< + (const __rope_const_iterator & x, + const __rope_const_iterator & y); + friend ptrdiff_t operator- + (const __rope_const_iterator & x, + const __rope_const_iterator & y); +}; + +template +class __rope_iterator : public __rope_iterator_base { + friend class rope; + protected: + rope * root_rope; + // root is treated as a cached version of this, + // and is used to detect changes to the underlying + // rope. + // Root is included in the reference count. + // This is necessary so that we can detect changes reliably. + // Unfortunately, it requires careful bookkeeping for the + // nonGC case. + __rope_iterator(rope * r, size_t pos): + __rope_iterator_base(r -> tree_ptr, pos), + root_rope(r) { + RopeBase::ref(root); + } + void check(); + public: + rope& container() { return *root_rope; } + __rope_iterator() { + root = 0; // Needed for reference counting. + }; + __rope_iterator(const __rope_iterator & x) : + __rope_iterator_base(x) { + root_rope = x.root_rope; + RopeBase::ref(root); + } + __rope_iterator(rope& r, size_t pos); + ~__rope_iterator() { + RopeBase::unref(root); + } + __rope_iterator& operator= (const __rope_iterator & x) { + RopeBase *old = root; + + RopeBase::ref(x.root); + if (0 != x.buf_ptr) { + *this = x; + } else { + current_pos = x.current_pos; + root = x.root; + root_rope = x.root_rope; + buf_ptr = 0; + } + RopeBase::unref(old); + return(*this); + } + __rope_charT_ref_proxy operator*() { + check(); + if (0 == buf_ptr) { + return __rope_charT_ref_proxy(root_rope, current_pos); + } else { + return __rope_charT_ref_proxy(root_rope, + current_pos, *buf_ptr); + } + } + __rope_iterator& operator++() { + incr(1); + return *this; + } + __rope_iterator& operator+=(difference_type n) { + if (n >= 0) { + incr(n); + } else { + decr(-n); + } + return *this; + } + __rope_iterator& operator--() { + decr(1); + return *this; + } + __rope_iterator& operator-=(difference_type n) { + if (n >= 0) { + decr(n); + } else { + incr(-n); + } + return *this; + } + __rope_iterator operator++(int) { + size_t old_pos = current_pos; + incr(1); + return __rope_iterator(root_rope, old_pos); + } + __rope_iterator operator--(int) { + size_t old_pos = current_pos; + decr(1); + return __rope_iterator(root_rope, old_pos); + } + __rope_charT_ref_proxy operator[](ptrdiff_t n) { + return __rope_charT_ref_proxy(root_rope, current_pos + n); + } + friend bool operator== + (const __rope_iterator & x, + const __rope_iterator & y); + friend bool operator< + (const __rope_iterator & x, + const __rope_iterator & y); + friend ptrdiff_t operator- + (const __rope_iterator & x, + const __rope_iterator & y); + friend __rope_iterator operator- + (const __rope_iterator & x, + ptrdiff_t n); + friend __rope_iterator operator+ + (const __rope_iterator & x, + ptrdiff_t n); + friend __rope_iterator operator+ + (ptrdiff_t n, + const __rope_iterator & x); + +}; + +template +class rope { + public: + typedef charT value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef const charT& const_reference; + typedef const charT* const_pointer; + typedef __rope_iterator iterator; + typedef __rope_const_iterator const_iterator; + typedef __rope_charT_ref_proxy reference; + typedef __rope_charT_ptr_proxy pointer; + + friend class __rope_iterator; + friend class __rope_const_iterator; + friend struct __rope_RopeBase; + friend class __rope_iterator_base; + friend class __rope_charT_ptr_proxy; + friend class __rope_charT_ref_proxy; + friend struct __rope_RopeSubstring; + + protected: + typedef __GC_CONST charT * cstrptr; +# ifdef __STL_SGI_THREADS + static cstrptr atomic_swap(cstrptr *p, cstrptr q) { +# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) + return (cstrptr) test_and_set((unsigned long *)p, + (unsigned long)q); +# else + return (cstrptr) __test_and_set((unsigned long *)p, + (unsigned long)q); +# endif + } +# elif defined(__STL_WIN32THREADS) + static cstrptr atomic_swap(cstrptr *p, cstrptr q) { + return (cstrptr) InterlockedExchange((LPLONG)p, (LONG)q); + } +# elif defined(_PTHREADS) + // This should be portable, but performance is expected + // to be quite awful. This really needs platform specific + // code. + static pthread_mutex_t swap_lock; + static cstrptr atomic_swap(cstrptr *p, cstrptr q) { + pthread_mutex_lock(&swap_lock); + cstrptr result = *p; + *p = q; + pthread_mutex_unlock(&swap_lock); + return result; + } +# else + static cstrptr atomic_swap(cstrptr *p, cstrptr q) { + cstrptr result = *p; + *p = q; + return result; + } +# endif + + static charT empty_c_str[1]; + + typedef simple_alloc<__rope_RopeConcatenation, Alloc> CAlloc; + typedef simple_alloc<__rope_RopeLeaf, Alloc> LAlloc; + typedef simple_alloc<__rope_RopeFunction, Alloc> FAlloc; + typedef simple_alloc<__rope_RopeSubstring, Alloc> SAlloc; + static bool is0(charT c) { return c == __eos((charT *)0); } + enum { copy_max = 23 }; + // For strings shorter than copy_max, we copy to + // concatenate. + + typedef __rope_RopeBase RopeBase; + typedef __rope_RopeConcatenation RopeConcatenation; + typedef __rope_RopeLeaf RopeLeaf; + typedef __rope_RopeFunction RopeFunction; + typedef __rope_RopeSubstring RopeSubstring; + + // The only data member of a rope: + RopeBase *tree_ptr; + + // Retrieve a character at the indicated position. + static charT fetch(RopeBase * r, size_type pos); + +# ifndef __GC + // Obtain a pointer to the character at the indicated position. + // The pointer can be used to change the character. + // If such a pointer cannot be produced, as is frequently the + // case, 0 is returned instead. + // (Returns nonzero only if all nodes in the path have a refcount + // of 1.) + static charT * fetch_ptr(RopeBase * r, size_type pos); +# endif + + static bool apply_to_pieces( + // should be template parameter + __rope_char_consumer& c, + const RopeBase * r, + size_t begin, size_t end); + // begin and end are assumed to be in range. + +# ifndef __GC + static void unref(RopeBase* t) + { + RopeBase::unref(t); + } + static void ref(RopeBase* t) + { + RopeBase::ref(t); + } +# else /* __GC */ + static void unref(RopeBase* t) {} + static void ref(RopeBase* t) {} +# endif + + +# ifdef __GC + typedef __rope_RopeBase * self_destruct_ptr; +# else + typedef __rope_self_destruct_ptr self_destruct_ptr; +# endif + + // Result is counted in refcount. + static RopeBase * substring(RopeBase * base, + size_t start, size_t endp1); + + static RopeBase * concat_char_iter(RopeBase * r, + const charT *iter, size_t slen); + // Concatenate rope and char ptr, copying s. + // Should really take an arbitrary iterator. + // Result is counted in refcount. + static RopeBase * destr_concat_char_iter(RopeBase * r, + const charT *iter, size_t slen) + // As above, but one reference to r is about to be + // destroyed. Thus the pieces may be recycled if all + // relevent reference counts are 1. +# ifdef __GC + // We can't really do anything since refcounts are unavailable. + { return concat_char_iter(r, iter, slen); } +# else + ; +# endif + + static RopeBase * concat(RopeBase *left, RopeBase *right); + // General concatenation on RopeBase. Result + // has refcount of 1. Adjusts argument refcounts. + + public: + void apply_to_pieces( size_t begin, size_t end, + __rope_char_consumer& c) const { + apply_to_pieces(c, tree_ptr, begin, end); + } + + + protected: + + static size_t rounded_up_size(size_t n) { + return RopeBase::rounded_up_size(n); + } + + static size_t allocated_capacity(size_t n) { + if (__is_basic_char_type((charT *)0)) { + return rounded_up_size(n) - 1; + } else { + return rounded_up_size(n); + } + } + + // s should really be an arbitrary input iterator. + // Adds a trailing NULL for basic char types. + static charT * alloc_copy(const charT *s, size_t size) + { + charT * result = (charT *) + Alloc::allocate(rounded_up_size(size)); + + uninitialized_copy_n(s, size, result); + __cond_store_eos(result[size]); + return(result); + } + + // Basic constructors for rope tree nodes. + // These return tree nodes with a 0 reference count. + static RopeLeaf * RopeLeaf_from_char_ptr(__GC_CONST charT *s, + size_t size); + // Takes ownership of its argument. + // Result has refcount 1. + // In the nonGC, basic_char_type case it assumes that s + // is eos-terminated. + // In the nonGC case, it was allocated from Alloc with + // rounded_up_size(size). + + // Concatenation of nonempty strings. + // Always builds a concatenation node. + // Rebalances if the result is too deep. + // Result has refcount 1. + // Does not increment left and right ref counts even though + // they are referenced. + static RopeBase * tree_concat(RopeBase * left, RopeBase * right); + + // Result has refcount 1. + // If delete_fn is true, then fn is deleted when the rope + // becomes inaccessible. + static RopeFunction * RopeFunction_from_fn + (char_producer *fn, size_t size, + bool delete_fn); + + // Concatenation helper functions + static RopeLeaf * leaf_concat_char_iter + (RopeLeaf * r, const charT * iter, size_t slen); + // Concatenate by copying leaf. + // should take an arbitrary iterator + // result has refcount 1. +# ifndef __GC + static RopeLeaf * destr_leaf_concat_char_iter + (RopeLeaf * r, const charT * iter, size_t slen); + // A version that potentially clobbers r if r -> refcount == 1. +# endif + + // A helper function for exponentiating strings. + // This uses a nonstandard refcount convention. + // The result has refcount 0. + struct concat_fn; + friend struct rope::concat_fn; + + struct concat_fn + : binary_function { + RopeBase * operator() (RopeBase * x, RopeBase *y) { + RopeBase * result; + x -> ref_nonnil(); + y -> ref_nonnil(); + __STL_TRY + result = tree_concat(x, y); +# ifndef __GC + result -> refcount = 0; +# endif + __STL_UNWIND(unref(x); unref(y)); + return result; + // In the nonGC case, x and y must remain accessible through + // the result. Use of concat could result on a memory leak. + } + }; + + friend RopeBase* identity_element(concat_fn) { return 0; } + + static size_t char_ptr_len(const charT * s); + // slightly generalized strlen + + rope(RopeBase *t) : tree_ptr(t) { } + + + // Copy r to the CharT buffer. + // Returns buffer + r -> size. + // Assumes that buffer is uninitialized. + static charT * flatten(RopeBase * r, charT * buffer); + + // Again, with explicit starting position and length. + // Assumes that buffer is uninitialized. + static charT * flatten(RopeBase * r, + size_t start, size_t len, + charT * buffer); + + static const unsigned long min_len[RopeBase::max_rope_depth + 1]; + + static bool is_balanced(RopeBase *r) + { return (r -> size >= min_len[r -> depth]); } + + static bool is_almost_balanced(RopeBase *r) + { return (r -> depth == 0 || + r -> size >= min_len[r -> depth - 1]); } + + static bool is_roughly_balanced(RopeBase *r) + { return (r -> depth <= 1 || + r -> size >= min_len[r -> depth - 2]); } + + // Assumes the result is not empty. + static RopeBase * concat_and_set_balanced(RopeBase *left, + RopeBase *right) + { + RopeBase * result = concat(left, right); + if (is_balanced(result)) result -> is_balanced = true; + return result; + } + + // The basic rebalancing operation. Logically copies the + // rope. The result has refcount of 1. The client will + // usually decrement the reference count of r. + // The result isd within height 2 of balanced by the above + // definition. + static RopeBase * balance(RopeBase * r); + + // Add all unbalanced subtrees to the forest of balanceed trees. + // Used only by balance. + static void add_to_forest(RopeBase *r, RopeBase **forest); + + // Add r to forest, assuming r is already balanced. + static void add_leaf_to_forest(RopeBase *r, RopeBase **forest); + + // Print to stdout, exposing structure + static void dump(RopeBase * r, int indent = 0); + + // Return -1, 0, or 1 if x < y, x == y, or x > y resp. + static int compare(const RopeBase *x, const RopeBase *y); + + public: + bool empty() const { return 0 == tree_ptr; } + + // Comparison member function. This is public only for those + // clients that need a ternary comparison. Others + // should use the comparison operators below. + int compare(const rope &y) const { + return compare(tree_ptr, y.tree_ptr); + } + + rope(const charT *s) + { + size_t len = char_ptr_len(s); + + if (0 == len) { + tree_ptr = 0; + } else { + tree_ptr = RopeLeaf_from_char_ptr(alloc_copy(s, len), len); +# ifndef __GC + __stl_assert(1 == tree_ptr -> refcount); +# endif + } + } + + rope(const charT *s, size_t len) + { + if (0 == len) { + tree_ptr = 0; + } else { + tree_ptr = RopeLeaf_from_char_ptr(alloc_copy(s, len), len); + } + } + + rope(const charT *s, charT *e) + { + size_t len = e - s; + + if (0 == len) { + tree_ptr = 0; + } else { + tree_ptr = RopeLeaf_from_char_ptr(alloc_copy(s, len), len); + } + } + + rope(const const_iterator& s, const const_iterator& e) + { + tree_ptr = substring(s.root, s.current_pos, e.current_pos); + } + + rope(const iterator& s, const iterator& e) + { + tree_ptr = substring(s.root, s.current_pos, e.current_pos); + } + + rope(charT c) + { + charT * buf = (charT *)Alloc::allocate(rounded_up_size(1)); + + construct(buf, c); + tree_ptr = RopeLeaf_from_char_ptr(buf, 1); + } + + rope(size_t n, charT c); + + // Should really be templatized with respect to the iterator type + // and use sequence_buffer. (It should perhaps use sequence_buffer + // even now.) + rope(const charT *i, const charT *j) + { + if (i == j) { + tree_ptr = 0; + } else { + size_t len = j - i; + tree_ptr = RopeLeaf_from_char_ptr(alloc_copy(i, len), len); + } + } + + rope() + { + tree_ptr = 0; + } + + // Construct a rope from a function that can compute its members + rope(char_producer *fn, size_t len, bool delete_fn) + { + tree_ptr = RopeFunction_from_fn(fn, len, delete_fn); + } + + rope(const rope &x) + { + tree_ptr = x.tree_ptr; + ref(tree_ptr); + } + + ~rope() + { + unref(tree_ptr); + } + + rope& operator=(const rope& x) + { + RopeBase *old = tree_ptr; + tree_ptr = x.tree_ptr; + ref(tree_ptr); + unref(old); + return(*this); + } + + void push_back(charT x) + { + RopeBase *old = tree_ptr; + tree_ptr = concat_char_iter(tree_ptr, &x, 1); + unref(old); + } + + void pop_back() + { + RopeBase *old = tree_ptr; + tree_ptr = substring(tree_ptr, 0, tree_ptr -> size - 1); + unref(old); + } + + charT back() const + { + return fetch(tree_ptr, tree_ptr -> size - 1); + } + + void push_front(const charT& x) + { + RopeBase *old = tree_ptr; + charT *buf = alloc_copy(&x, 1); + RopeBase *left; + + __STL_TRY + left = RopeLeaf_from_char_ptr(buf, 1); + __STL_UNWIND(RopeBase::free_string(buf, 1)) + __STL_TRY + tree_ptr = concat(left, tree_ptr); + unref(old); + __STL_ALWAYS(unref(left)) + } + + void pop_front() + { + RopeBase *old = tree_ptr; + tree_ptr = substring(tree_ptr, 1, tree_ptr -> size); + unref(old); + } + + charT front() const + { + return fetch(tree_ptr, 0); + } + + void balance() + { + RopeBase *old = tree_ptr; + tree_ptr = balance(tree_ptr); + unref(old); + } + + void copy(charT * buffer) const { + destroy(buffer, buffer + size()); + flatten(tree_ptr, buffer); + } + + // This is the copy function from the standard, but + // with the arguments reordered to make it consistent with the + // rest of the interface. + // Note that this guaranteed not to compile if the draft standard + // order is assumed. + size_type copy(size_type pos, size_type n, charT *buffer) const { + size_t sz = size(); + size_t len = (pos + n > sz? sz - pos : n); + + destroy(buffer, buffer + len); + flatten(tree_ptr, pos, len, buffer); + return len; + } + + // Print to stdout, exposing structure. May be useful for + // performance debugging. + void dump() { + dump(tree_ptr); + } + + // Convert to 0 terminated string in new allocated memory. + // Embedded 0s in the input do not terminate the copy. + const charT * c_str() const; + + // As above, but lso use the flattened representation as the + // the new rope representation. + const charT * replace_with_c_str(); + + // Reclaim memory for the c_str generated flattened string. + // Intentionally undocumented, since it's hard to say when this + // is safe for multiple threads. + void delete_c_str () { + if (0 == tree_ptr) return; + if (RopeBase::leaf == tree_ptr -> tag + && ((RopeLeaf *)tree_ptr) -> data == tree_ptr -> c_string) { + // Representation shared + return; + } +# ifndef __GC + tree_ptr -> free_c_string(); +# endif + tree_ptr -> c_string = 0; + } + + charT operator[] (size_type pos) const { + return fetch(tree_ptr, pos); + } + + charT at(size_type pos) const { + // if (pos >= size()) throw out_of_range; + return (*this)[pos]; + } + + const_iterator begin() const { + return(const_iterator(tree_ptr, 0)); + } + + // An easy way to get a const iterator from a non-const container. + const_iterator const_begin() const { + return(const_iterator(tree_ptr, 0)); + } + + const_iterator end() const { + return(const_iterator(tree_ptr, size())); + } + + const_iterator const_end() const { + return(const_iterator(tree_ptr, size())); + } + + size_type size() const { + return(0 == tree_ptr? 0 : tree_ptr -> size); + } + + size_type length() const { + return size(); + } + + size_type max_size() const { + return min_len[RopeBase::max_rope_depth-1] - 1; + // Guarantees that the result can be sufficirntly + // balanced. Longer ropes will probably still work, + // but it's harder to make guarantees. + } + + typedef reverse_iterator const_reverse_iterator; + + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + + const_reverse_iterator const_rbegin() const { + return const_reverse_iterator(end()); + } + + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + const_reverse_iterator const_rend() const { + return const_reverse_iterator(begin()); + } + + friend rope operator+ (const rope &left, + const rope &right); + + friend rope operator+ (const rope &left, + const charT* right); + + friend rope operator+ (const rope &left, + charT right); + + // The symmetric cases are intentionally omitted, since they're presumed + // to be less common, and we don't handle them as well. + + // The following should really be templatized. + // The first argument should be an input iterator or + // forward iterator with value_type charT. + rope& append(const charT* iter, size_t n) { + RopeBase* result = destr_concat_char_iter(tree_ptr, iter, n); + unref(tree_ptr); + tree_ptr = result; + return *this; + } + + rope& append(const charT* c_string) { + size_t len = char_ptr_len(c_string); + append(c_string, len); + return(*this); + } + + rope& append(const charT* s, const charT* e) { + RopeBase* result = + destr_concat_char_iter(tree_ptr, s, e - s); + unref(tree_ptr); + tree_ptr = result; + return *this; + } + + rope& append(const_iterator s, const_iterator e) { + __stl_assert(s.root == e.root); + self_destruct_ptr appendee(substring(s.root, s.current_pos, + e.current_pos)); + RopeBase* result = concat(tree_ptr, (RopeBase *)appendee); + unref(tree_ptr); + tree_ptr = result; + return *this; + } + + rope& append(charT c) { + RopeBase* result = destr_concat_char_iter(tree_ptr, &c, 1); + unref(tree_ptr); + tree_ptr = result; + return *this; + } + + rope& append() { return append(charT()); } + + rope& append(const rope& y) { + RopeBase* result = concat(tree_ptr, y.tree_ptr); + unref(tree_ptr); + tree_ptr = result; + return *this; + } + + rope& append(size_t n, charT c) { + rope last(n, c); + return append(last); + } + + void swap(rope& b) { + RopeBase * tmp = tree_ptr; + tree_ptr = b.tree_ptr; + b.tree_ptr = tmp; + } + + + protected: + // Result is included in refcount. + static RopeBase * replace(RopeBase *old, size_t pos1, + size_t pos2, RopeBase *r) { + if (0 == old) { ref(r); return r; } + self_destruct_ptr left(substring(old, 0, pos1)); + self_destruct_ptr right(substring(old, pos2, old -> size)); + RopeBase * result; + + if (0 == r) { + result = concat(left, right); + } else { + self_destruct_ptr left_result(concat(left, r)); + result = concat(left_result, right); + } + return result; + } + + public: + void insert(size_t p, const rope& r) { + RopeBase * result = replace(tree_ptr, p, p, + r.tree_ptr); + unref(tree_ptr); + tree_ptr = result; + } + + void insert(size_t p, size_t n, charT c) { + rope r(n,c); + insert(p, r); + } + + void insert(size_t p, const charT * i, size_t n) { + self_destruct_ptr left(substring(tree_ptr, 0, p)); + self_destruct_ptr right(substring(tree_ptr, p, size())); + self_destruct_ptr left_result(concat_char_iter(left, i, n)); + RopeBase * result = + concat(left_result, right); + unref(tree_ptr); + tree_ptr = result; + } + + void insert(size_t p, const charT * c_string) { + insert(p, c_string, char_ptr_len(c_string)); + } + + void insert(size_t p, charT c) { + insert(p, &c, 1); + } + + void insert(size_t p) { + charT c = charT(); + insert(p, &c, 1); + } + + void insert(size_t p, const charT *i, const charT *j) { + rope r(i, j); + insert(p, r); + } + + void insert(size_t p, const const_iterator& i, + const const_iterator& j) { + rope r(i, j); + insert(p, r); + } + + void insert(size_t p, const iterator& i, + const iterator& j) { + rope r(i, j); + insert(p, r); + } + + // (position, length) versions of replace operations: + + void replace(size_t p, size_t n, const rope& r) { + RopeBase * result = replace(tree_ptr, p, p + n, + r.tree_ptr); + unref(tree_ptr); + tree_ptr = result; + } + + void replace(size_t p, size_t n, const charT *i, size_t i_len) { + rope r(i, i_len); + replace(p, n, r); + } + + void replace(size_t p, size_t n, charT c) { + rope r(c); + replace(p, n, r); + } + + void replace(size_t p, size_t n, const charT *c_string) { + rope r(c_string); + replace(p, n, r); + } + + void replace(size_t p, size_t n, const charT *i, const charT *j) { + rope r(i, j); + replace(p, n, r); + } + + void replace(size_t p, size_t n, + const const_iterator& i, const const_iterator& j) { + rope r(i, j); + replace(p, n, r); + } + + void replace(size_t p, size_t n, + const iterator& i, const iterator& j) { + rope r(i, j); + replace(p, n, r); + } + + // Single character variants: + void replace(size_t p, charT c) { + iterator i(this, p); + *i = c; + } + + void replace(size_t p, const rope& r) { + replace(p, 1, r); + } + + void replace(size_t p, const charT *i, size_t i_len) { + replace(p, 1, i, i_len); + } + + void replace(size_t p, const charT *c_string) { + replace(p, 1, c_string); + } + + void replace(size_t p, const charT *i, const charT *j) { + replace(p, 1, i, j); + } + + void replace(size_t p, const const_iterator& i, + const const_iterator& j) { + replace(p, 1, i, j); + } + + void replace(size_t p, const iterator& i, + const iterator& j) { + replace(p, 1, i, j); + } + + // Erase, (position, size) variant. + void erase(size_t p, size_t n) { + RopeBase * result = replace(tree_ptr, p, p + n, 0); + unref(tree_ptr); + tree_ptr = result; + } + + // Erase, single character + void erase(size_t p) { + erase(p, p + 1); + } + + // Insert, iterator variants. + iterator insert(const iterator& p, const rope& r) + { insert(p.index(), r); return p; } + iterator insert(const iterator& p, size_t n, charT c) + { insert(p.index(), n, c); return p; } + iterator insert(const iterator& p, charT c) + { insert(p.index(), c); return p; } + iterator insert(const iterator& p ) + { insert(p.index()); return p; } + iterator insert(const iterator& p, const charT *c_string) + { insert(p.index(), c_string); return p; } + iterator insert(const iterator& p, const charT *i, size_t n) + { insert(p.index(), i, n); return p; } + iterator insert(const iterator& p, const charT *i, const charT *j) + { insert(p.index(), i, j); return p; } + iterator insert(const iterator& p, + const const_iterator& i, const const_iterator& j) + { insert(p.index(), i, j); return p; } + iterator insert(const iterator& p, + const iterator& i, const iterator& j) + { insert(p.index(), i, j); return p; } + + // Replace, range variants. + void replace(const iterator& p, const iterator& q, + const rope& r) + { replace(p.index(), q.index() - p.index(), r); } + void replace(const iterator& p, const iterator& q, charT c) + { replace(p.index(), q.index() - p.index(), c); } + void replace(const iterator& p, const iterator& q, + const charT * c_string) + { replace(p.index(), q.index() - p.index(), c_string); } + void replace(const iterator& p, const iterator& q, + const charT *i, size_t n) + { replace(p.index(), q.index() - p.index(), i, n); } + void replace(const iterator& p, const iterator& q, + const charT *i, const charT *j) + { replace(p.index(), q.index() - p.index(), i, j); } + void replace(const iterator& p, const iterator& q, + const const_iterator& i, const const_iterator& j) + { replace(p.index(), q.index() - p.index(), i, j); } + void replace(const iterator& p, const iterator& q, + const iterator& i, const iterator& j) + { replace(p.index(), q.index() - p.index(), i, j); } + + // Replace, iterator variants. + void replace(const iterator& p, const rope& r) + { replace(p.index(), r); } + void replace(const iterator& p, charT c) + { replace(p.index(), c); } + void replace(const iterator& p, const charT * c_string) + { replace(p.index(), c_string); } + void replace(const iterator& p, const charT *i, size_t n) + { replace(p.index(), i, n); } + void replace(const iterator& p, const charT *i, const charT *j) + { replace(p.index(), i, j); } + void replace(const iterator& p, const_iterator i, const_iterator j) + { replace(p.index(), i, j); } + void replace(const iterator& p, iterator i, iterator j) + { replace(p.index(), i, j); } + + // Iterator and range variants of erase + void erase(const iterator &p, const iterator &q) + { erase(p.index(), q.index() - p.index()); } + void erase(const iterator &p) + { erase(p.index(), 1); } + + rope substr(size_t start, size_t len = 1) const { + return rope( + substring(tree_ptr, start, start + len)); + } + + rope substr(iterator start, iterator end) const { + return rope( + substring(tree_ptr, start.index(), end.index())); + } + + rope substr(iterator start) const { + size_t pos = start.index(); + return rope( + substring(tree_ptr, pos, pos + 1)); + } + + rope substr(const_iterator start, const_iterator end) const { + // This might eventually take advantage of the cache in the + // iterator. + return rope + (substring(tree_ptr, start.index(), end.index())); + } + + rope substr(const_iterator start) { + size_t pos = start.index(); + return rope(substring(tree_ptr, pos, pos + 1)); + } + + size_type find(charT c, size_type pos = 0) const; + size_type find(charT *s, size_type pos = 0) const { + const_iterator result = search(const_begin() + pos, const_end(), + s, s + char_ptr_len(s)); + return result.index(); + } + + iterator mutable_begin() { + return(iterator(this, 0)); + } + + iterator mutable_end() { + return(iterator(this, size())); + } + + typedef reverse_iterator reverse_iterator; + + reverse_iterator mutable_rbegin() { + return reverse_iterator(mutable_end()); + } + + reverse_iterator mutable_rend() { + return reverse_iterator(mutable_begin()); + } + + reference mutable_reference_at(size_type pos) { + return reference(this, pos); + } + +# ifdef __STD_STUFF + reference operator[] (size_type pos) { + return charT_ref_proxy(this, pos); + } + + reference at(size_type pos) { + // if (pos >= size()) throw out_of_range; + return (*this)[pos]; + } + + void resize(size_type n, charT c) {} + void resize(size_type n) {} + void reserve(size_type res_arg = 0) {} + size_type capacity() const { + return max_size(); + } + + // Stuff below this line is dangerous because it's error prone. + // I would really like to get rid of it. + // copy function with funny arg ordering. + size_type copy(charT *buffer, size_type n, size_type pos = 0) + const { + return copy(pos, n, buffer); + } + + iterator end() { return mutable_end(); } + + iterator begin() { return mutable_begin(); } + + reverse_iterator rend() { return mutable_rend(); } + + reverse_iterator rbegin() { return mutable_rbegin(); } + +# else + + const_iterator end() { return const_end(); } + + const_iterator begin() { return const_begin(); } + + const_reverse_iterator rend() { return const_rend(); } + + const_reverse_iterator rbegin() { return const_rbegin(); } + +# endif + +}; + +template +inline bool operator== (const __rope_const_iterator & x, + const __rope_const_iterator & y) { + return (x.current_pos == y.current_pos && x.root == y.root); +} + +template +inline bool operator< (const __rope_const_iterator & x, + const __rope_const_iterator & y) { + return (x.current_pos < y.current_pos); +} + +template +inline ptrdiff_t operator-(const __rope_const_iterator & x, + const __rope_const_iterator & y) { + return x.current_pos - y.current_pos; +} + +template +inline __rope_const_iterator +operator-(const __rope_const_iterator & x, + ptrdiff_t n) { + return __rope_const_iterator(x.root, x.current_pos - n); +} + +template +inline __rope_const_iterator +operator+(const __rope_const_iterator & x, + ptrdiff_t n) { + return __rope_const_iterator(x.root, x.current_pos + n); +} + +template +inline __rope_const_iterator +operator+(ptrdiff_t n, + const __rope_const_iterator & x) { + return __rope_const_iterator(x.root, x.current_pos + n); +} + +template +inline bool operator== (const __rope_iterator & x, + const __rope_iterator & y) { + return (x.current_pos == y.current_pos && x.root_rope == y.root_rope); +} + +template +inline bool operator< (const __rope_iterator & x, + const __rope_iterator & y) { + return (x.current_pos < y.current_pos); +} + +template +inline ptrdiff_t operator-(const __rope_iterator & x, + const __rope_iterator & y) { + return x.current_pos - y.current_pos; +} + +template +inline __rope_iterator +operator-(const __rope_iterator & x, + ptrdiff_t n) { + return __rope_iterator(x.root_rope, x.current_pos - n); +} + +template +inline __rope_iterator +operator+(const __rope_iterator & x, + ptrdiff_t n) { + return __rope_iterator(x.root_rope, x.current_pos + n); +} + +template +inline __rope_iterator +operator+(ptrdiff_t n, + const __rope_iterator & x) { + return __rope_iterator(x.root_rope, x.current_pos + n); +} + +template +inline +rope +operator+ (const rope &left, + const rope &right) +{ + return rope + (rope::concat(left.tree_ptr, right.tree_ptr)); + // Inlining this should make it possible to keep left and + // right in registers. +} + +template +inline +rope& +operator+= (rope &left, + const rope &right) +{ + left.append(right); + return left; +} + +template +inline +rope +operator+ (const rope &left, + const charT* right) { + size_t rlen = rope::char_ptr_len(right); + return rope + (rope::concat_char_iter(left.tree_ptr, right, rlen)); +} + +template +inline +rope& +operator+= (rope &left, + const charT* right) { + left.append(right); + return left; +} + +template +inline +rope +operator+ (const rope &left, charT right) { + return rope + (rope::concat_char_iter(left.tree_ptr, &right, 1)); +} + +template +inline +rope& +operator+= (rope &left, charT right) { + left.append(right); + return left; +} + +template +bool +operator< (const rope &left, const rope &right) { + return left.compare(right) < 0; +} + +template +bool +operator== (const rope &left, const rope &right) { + return left.compare(right) == 0; +} + +template +inline bool operator== (const __rope_charT_ptr_proxy & x, + const __rope_charT_ptr_proxy & y) { + return (x.pos == y.pos && x.root == y.root); +} + +template +ostream& operator<< (ostream& o, const rope& r); + +typedef rope crope; +typedef rope wrope; + +inline crope::reference __mutable_reference_at(crope& c, size_t i) +{ + return c.mutable_reference_at(i); +} + +inline wrope::reference __mutable_reference_at(wrope& c, size_t i) +{ + return c.mutable_reference_at(i); +} + +inline void swap(crope x, crope y) { x.swap(y); } +inline void swap(wrope x, wrope y) { x.swap(y); } + +// Hash functions should probably be revisited later: +struct hash +{ + size_t operator()(const crope& str) const + { + size_t sz = str.size(); + + if (0 == sz) return 0; + return 13*str[0] + 5*str[sz - 1] + sz; + } +}; + +struct hash +{ + size_t operator()(const wrope& str) const + { + size_t sz = str.size(); + + if (0 == sz) return 0; + return 13*str[0] + 5*str[sz - 1] + sz; + } +}; + +# include +# endif /* _ROPE_H */ diff --git a/libstdc++/stl/ropeimpl.h b/libstdc++/stl/ropeimpl.h new file mode 100644 index 000000000000..b90bc08928b9 --- /dev/null +++ b/libstdc++/stl/ropeimpl.h @@ -0,0 +1,1510 @@ +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#if defined(_MSC_VER) +# include +#else +# include +#endif + +// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf +// if necessary. Assumes path_end[leaf_index] and leaf_pos are correct. +// Results in a valid buf_ptr if the iterator can be legitimately +// dereferenced. +template +void __rope_iterator_base::setbuf +(__rope_iterator_base &x) +{ + const RopeBase * leaf = x.path_end[x.leaf_index]; + size_t leaf_pos = x.leaf_pos; + size_t pos = x.current_pos; + + switch(leaf -> tag) { + case RopeBase::leaf: + x.buf_start = ((__rope_RopeLeaf *)leaf) -> data; + x.buf_ptr = x.buf_start + (pos - leaf_pos); + x.buf_end = x.buf_start + leaf -> size; + break; + case RopeBase::function: + case RopeBase::substringfn: + { + size_t len = iterator_buf_len; + size_t buf_start_pos = leaf_pos; + size_t leaf_end = leaf_pos + leaf -> size; + char_producer *fn = + ((__rope_RopeFunction *)leaf) -> fn; + + if (buf_start_pos + len <= pos) { + buf_start_pos = pos - len/4; + if (buf_start_pos + len > leaf_end) { + buf_start_pos = leaf_end - len; + } + } + if (buf_start_pos + len > leaf_end) { + len = leaf_end - buf_start_pos; + } + (*fn)(buf_start_pos - leaf_pos, len, x.tmp_buf); + x.buf_ptr = x.tmp_buf + (pos - buf_start_pos); + x.buf_start = x.tmp_buf; + x.buf_end = x.tmp_buf + len; + } + break; + default: + __stl_assert(0); + } +} + +// Set path and buffer inside a rope iterator. We assume that +// pos and root are already set. +template +void __rope_iterator_base::setcache +(__rope_iterator_base &x) +{ + const RopeBase * path[RopeBase::max_rope_depth+1]; + const RopeBase * curr_rope; + int curr_depth = -1; /* index into path */ + size_t curr_start_pos = 0; + size_t pos = x.current_pos; + unsigned char dirns = 0; // Bit vector indicating right turns in the path + + __stl_assert(pos <= x.root -> size); + if (pos >= x.root -> size) { + x.buf_ptr = 0; + return; + } + curr_rope = x.root; + if (0 != curr_rope -> c_string) { + /* Treat the root as a leaf. */ + x.buf_start = curr_rope -> c_string; + x.buf_end = curr_rope -> c_string + curr_rope -> size; + x.buf_ptr = curr_rope -> c_string + pos; + x.path_end[0] = curr_rope; + x.leaf_index = 0; + x.leaf_pos = 0; + return; + } + for(;;) { + ++curr_depth; + __stl_assert(curr_depth <= RopeBase::max_rope_depth); + path[curr_depth] = curr_rope; + switch(curr_rope -> tag) { + case RopeBase::leaf: + case RopeBase::function: + case RopeBase::substringfn: + x.leaf_pos = curr_start_pos; + goto done; + case RopeBase::concat: + { + __rope_RopeConcatenation *c = + (__rope_RopeConcatenation *)curr_rope; + RopeBase * left = c -> left; + size_t left_len = left -> size; + + dirns <<= 1; + if (pos >= curr_start_pos + left_len) { + dirns |= 1; + curr_rope = c -> right; + curr_start_pos += left_len; + } else { + curr_rope = left; + } + } + break; + } + } + done: + // Copy last section of path into path_end. + { + int i = -1; + int j = curr_depth + 1 - path_cache_len; + + if (j < 0) j = 0; + while (j <= curr_depth) { + x.path_end[++i] = path[j++]; + } + x.leaf_index = i; + } + x.path_directions = dirns; + setbuf(x); +} + +// Specialized version of the above. Assumes that +// the path cache is valid for the previous position. +template +void __rope_iterator_base::setcache_for_incr +(__rope_iterator_base &x) +{ + int current_index = x.leaf_index; + const RopeBase * current_node = x.path_end[current_index]; + size_t len = current_node -> size; + size_t node_start_pos = x.leaf_pos; + unsigned char dirns = x.path_directions; + __rope_RopeConcatenation * c; + + __stl_assert(x.current_pos <= x.root -> size); + if (x.current_pos - node_start_pos < len) { + /* More stuff in this leaf, we just didn't cache it. */ + setbuf(x); + return; + } + __stl_assert(node_start_pos + len == x.current_pos); + // node_start_pos is starting position of last_node. + while (--current_index >= 0) { + if (!(dirns & 1) /* Path turned left */) break; + current_node = x.path_end[current_index]; + c = (__rope_RopeConcatenation *)current_node; + // Otherwise we were in the right child. Thus we should pop + // the concatenation node. + node_start_pos -= c -> left -> size; + dirns >>= 1; + } + if (current_index < 0) { + // We underflowed the cache. Punt. + setcache(x); + return; + } + current_node = x.path_end[current_index]; + c = (__rope_RopeConcatenation *)current_node; + // current_node is a concatenation node. We are positioned on the first + // character in its right child. + // node_start_pos is starting position of current_node. + node_start_pos += c -> left -> size; + current_node = c -> right; + x.path_end[++current_index] = current_node; + dirns |= 1; + while (RopeBase::concat == current_node -> tag) { + ++current_index; + if (path_cache_len == current_index) { + int i; + for (i = 0; i < path_cache_len-1; i++) { + x.path_end[i] = x.path_end[i+1]; + } + --current_index; + } + current_node = + ((__rope_RopeConcatenation *)current_node) -> left; + x.path_end[current_index] = current_node; + dirns <<= 1; + // node_start_pos is unchanged. + } + x.leaf_index = current_index; + x.leaf_pos = node_start_pos; + x.path_directions = dirns; + setbuf(x); +} + +template +void __rope_iterator_base::incr(size_t n) { + current_pos += n; + if (0 != buf_ptr) { + size_t chars_left = buf_end - buf_ptr; + if (chars_left > n) { + buf_ptr += n; + } else if (chars_left == n) { + buf_ptr += n; + setcache_for_incr(*this); + } else { + buf_ptr = 0; + } + } +} + +template +void __rope_iterator_base::decr(size_t n) { + if (0 != buf_ptr) { + size_t chars_left = buf_ptr - buf_start; + if (chars_left >= n) { + buf_ptr -= n; + } else { + buf_ptr = 0; + } + } + current_pos -= n; +} + +template +void __rope_iterator::check() { + if (root_rope -> tree_ptr != root) { + // Rope was modified. Get things fixed up. + RopeBase::unref(root); + root = root_rope -> tree_ptr; + RopeBase::ref(root); + buf_ptr = 0; + } +} + +template +inline __rope_const_iterator::__rope_const_iterator +(const __rope_iterator & x) +: __rope_iterator_base(x) { } + +template +inline __rope_iterator::__rope_iterator +(rope& r, size_t pos) + : __rope_iterator_base(r.tree_ptr, pos), root_rope(&r) { + RopeBase::ref(root); +} + +template +inline size_t rope::char_ptr_len(const charT *s) +{ + const charT *p = s; + + while (!is0(*p)) { ++p; } + return(p - s); +} + +template +rope::RopeLeaf * +rope::RopeLeaf_from_char_ptr(__GC_CONST charT *s, size_t size) +{ + RopeLeaf *t = LAlloc::allocate(); + + t -> tag = RopeBase::leaf; + if (__is_basic_char_type((charT *)0)) { + // already eos terminated. + t -> c_string = s; + } else { + t -> c_string = 0; + } + t -> is_balanced = true; + t -> depth = 0; + t -> size = size; + t -> data = s; +# ifndef __GC + t -> refcount = 1; + t -> init_refcount_lock(); +# endif + return (t); +} + +# ifdef __GC +template +void __rope_RopeBase::fn_finalization_proc(void * tree, void *) +{ + delete ((__rope_RopeFunction *)tree) -> fn; +} +# endif + +template +rope::RopeFunction * +rope::RopeFunction_from_fn +(char_producer *fn, size_t size, bool delete_fn) +{ + if (0 == size) return 0; + RopeFunction *t = FAlloc::allocate(); + t -> tag = RopeBase::function; + t -> c_string = 0; + t -> is_balanced = true; + t -> depth = 0; + t -> size = size; + t -> fn = fn; +# ifdef __GC + if (delete_fn) { + GC_REGISTER_FINALIZER(t, RopeBase::fn_finalization_proc, 0, 0, 0); + } +# else + t -> delete_when_done = delete_fn; + t -> refcount = 1; + t -> init_refcount_lock(); +# endif + return (t); +} + +#ifndef __GC + +template +inline void __rope_RopeBase::free_c_string() +{ + charT * cstr = c_string; + if (0 != cstr) { + size_t sz = size + 1; + destroy(cstr, cstr + sz); + Alloc::deallocate(cstr, sz); + } +} + +template +inline void __rope_RopeBase::free_string(charT* s, size_t n) +{ + if (!__is_basic_char_type((charT *)0)) { + destroy(s, s + n); + } + Alloc::deallocate(s, rounded_up_size(n)); +} + +template +void __rope_RopeBase::free_tree() +{ + switch(tag) { + case leaf: + { + __rope_RopeLeaf * l = + (__rope_RopeLeaf *)this; + charT * d = l -> data; + + if (d != c_string) { + free_c_string(); + } + free_string(d, size); + LAlloc::deallocate(l); + } + break; + case concat: + { + __rope_RopeConcatenation * c = + (__rope_RopeConcatenation *)this; + __rope_RopeBase * left = c -> left; + __rope_RopeBase * right = c -> right; + free_c_string(); + left -> unref_nonnil(); + right -> unref_nonnil(); + CAlloc::deallocate(c); + } + break; + case function: + { + __rope_RopeFunction * fn = + (__rope_RopeFunction *)this; + free_c_string(); + if ( fn -> delete_when_done) { + delete fn -> fn; + } + FAlloc::deallocate(fn); + break; + } + case substringfn: + { + __rope_RopeSubstring * ss = + (__rope_RopeSubstring *)this; + __rope_RopeBase *base = ss -> base; + free_c_string(); + base -> unref_nonnil(); + SAlloc::deallocate(ss); + break; + } + } +} +#else + +template +inline void __rope_RopeBase::free_string(charT* s, size_t n) +{} + +#endif + + +// Concatenate a C string onto a leaf rope by copying the rope data. +// Used for short ropes. +template +rope::RopeLeaf * +rope::leaf_concat_char_iter + (RopeLeaf * r, const charT * iter, size_t len) +{ + size_t old_len = r -> size; + charT * new_data = (charT *) + Alloc::allocate(rounded_up_size(old_len + len)); + RopeLeaf * result; + + uninitialized_copy_n(r -> data, old_len, new_data); + uninitialized_copy_n(iter, len, new_data + old_len); + __cond_store_eos(new_data[old_len + len]); + __STL_TRY + result = RopeLeaf_from_char_ptr(new_data, old_len + len); + __STL_UNWIND(RopeBase::free_string(new_data, old_len + len)); + return result; +} + +#ifndef __GC +// As above, but it's OK to clobber original if refcount is 1 +template +rope::RopeLeaf * +rope::destr_leaf_concat_char_iter + (RopeLeaf * r, const charT * iter, size_t len) +{ + __stl_assert(r -> refcount >= 1); + if (r -> refcount > 1) return leaf_concat_char_iter(r, iter, len); + size_t old_len = r -> size; + if (allocated_capacity(old_len) >= old_len + len) { + // The space has been partially initialized for the standard + // character types. But that doesn't matter for those types. + uninitialized_copy_n(iter, len, r -> data + old_len); + if (__is_basic_char_type((charT *)0)) { + __cond_store_eos(r -> data[old_len + len]); + __stl_assert(r -> c_string == r -> data); + } else if (r -> c_string != r -> data && 0 != r -> c_string) { + r -> free_c_string(); + r -> c_string = 0; + } + r -> size = old_len + len; + __stl_assert(r -> refcount == 1); + r -> refcount = 2; + return r; + } else { + RopeLeaf * result = leaf_concat_char_iter(r, iter, len); + __stl_assert(result -> refcount == 1); + return result; + } +} +#endif + +// Assumes left and right are not 0. +// Result has ref count 1. +template +rope::RopeBase * +rope::tree_concat (RopeBase * left, RopeBase * right) +{ + RopeConcatenation * result = CAlloc::allocate(); + unsigned char child_depth = left -> depth; + size_t rsize; + + result -> tag = RopeBase::concat; + result -> c_string = 0; + result -> is_balanced = false; + result -> size = rsize = left -> size + right -> size; + if (right -> depth > child_depth) child_depth = right -> depth; + unsigned char depth = child_depth + 1; + result -> depth = depth; + result -> left = left; + result -> right = right; +# ifndef __GC + result -> refcount = 1; + result -> init_refcount_lock(); +# endif + if (depth > 20 && (rsize < 1000 || depth > RopeBase::max_rope_depth)) { + RopeBase * balanced; + + __STL_TRY + balanced = balance(result); +# ifndef __GC + if (result != balanced) { + __stl_assert(1 == result -> refcount + && 1 == balanced -> refcount); + } +# endif + __STL_ALWAYS(result -> unref_nonnil()); + return balanced; + } else { + return result; + } +} + +template +rope::RopeBase * rope::concat_char_iter + (RopeBase * r, const charT *s, size_t slen) +{ + RopeBase *result; + if (0 == slen) { + ref(r); + return r; + } + if (0 == r) return RopeLeaf_from_char_ptr(alloc_copy(s, slen), slen); + if (RopeBase::leaf == r -> tag && r -> size + slen <= copy_max) { + result = leaf_concat_char_iter((RopeLeaf *)r, s, slen); +# ifndef __GC + __stl_assert(1 == result -> refcount); +# endif + return result; + } + if (RopeBase::concat == r -> tag + && RopeBase::leaf == ((RopeConcatenation *)r) -> right -> tag) { + RopeLeaf *right = (RopeLeaf *)(((RopeConcatenation *)r) -> right); + if (right -> size + slen <= copy_max) { + RopeBase * left = ((RopeConcatenation *)r) -> left; + left -> ref_nonnil(); + __STL_TRY + result = tree_concat(left, + leaf_concat_char_iter((RopeLeaf *)right, + s, slen)); + __STL_UNWIND(unref(left)); +# ifndef __GC + __stl_assert(1 == result -> refcount); +# endif + return result; + } + } + __STL_TRY + r -> ref_nonnil(); + result = tree_concat(r, RopeLeaf_from_char_ptr(alloc_copy(s, slen), + slen)); + __STL_UNWIND(unref(r)); +# ifndef __GC + __stl_assert(1 == result -> refcount); +# endif + return result; +} + +#ifndef __GC +template +rope::RopeBase * rope +::destr_concat_char_iter + (RopeBase * r, const charT *s, size_t slen) +{ + RopeBase *result; + if (0 == r) return RopeLeaf_from_char_ptr(alloc_copy(s, slen), slen); + size_t count = r -> refcount; + size_t orig_size = r -> size; + __stl_assert(count >= 1); + if (count > 1) return concat_char_iter(r, s, slen); + if (0 == slen) { + r -> refcount = 2; // One more than before + return r; + } + if (orig_size + slen <= copy_max && RopeBase::leaf == r -> tag) { + result = destr_leaf_concat_char_iter((RopeLeaf *)r, s, slen); + return result; + } + if (RopeBase::concat == r -> tag) { + RopeLeaf *right = (RopeLeaf *)(((RopeConcatenation *)r) -> right); + if (RopeBase::leaf == right -> tag + && right -> size + slen <= copy_max) { + RopeBase * new_right = destr_leaf_concat_char_iter(right, s, slen); + if (right == new_right) { + __stl_assert(new_right -> refcount == 2); + new_right -> refcount = 1; + } else { + __stl_assert(new_right -> refcount >= 1); + right -> unref_nonnil(); + } + __stl_assert(r -> refcount == 1); + r -> refcount = 2; // One more than before. + ((RopeConcatenation *)r) -> right = new_right; + r -> size = orig_size + slen; + if (0 != r -> c_string) { + r -> free_c_string(); + r -> c_string = 0; + } + return r; + } + } + charT * cpy = alloc_copy(s, slen); + r -> ref_nonnil(); + __STL_TRY + result = tree_concat(r, RopeLeaf_from_char_ptr(cpy, slen)); + __STL_UNWIND(unref(r); RopeBase::free_string(cpy,slen)) + __stl_assert(1 == result -> refcount); + return result; +} +#endif /* !__GC */ + +template +rope::RopeBase * +rope::concat(RopeBase * left, RopeBase * right) +{ + if (0 == left) { + ref(right); + return right; + } + if (0 == right) { + left -> ref_nonnil(); + return left; + } + if (RopeBase::leaf == right -> tag) { + if (RopeBase::leaf == left -> tag) { + if (right -> size + left -> size <= copy_max) { + return leaf_concat_char_iter((RopeLeaf *)left, + ((RopeLeaf *)right) -> data, + right -> size); + } + } else if (RopeBase::concat == left -> tag + && RopeBase::leaf == + ((RopeConcatenation *)left) -> right -> tag) { + RopeLeaf * leftright = + (RopeLeaf *)(((RopeConcatenation *)left) -> right); + if (leftright -> size + right -> size <= copy_max) { + RopeBase * leftleft = ((RopeConcatenation *)left) -> left; + RopeBase * rest = leaf_concat_char_iter(leftright, + ((RopeLeaf *)right) -> data, + right -> size); + leftleft -> ref_nonnil(); + __STL_TRY + return(tree_concat(leftleft, rest)); + __STL_UNWIND(unref(left); unref(rest)) + } + } + } + left -> ref_nonnil(); + right -> ref_nonnil(); + return(tree_concat(left, right)); +} + +template +rope::RopeBase * +rope::substring(RopeBase * base, size_t start, size_t endp1) +{ + if (0 == base) return 0; + size_t len = base -> size; + size_t adj_endp1; + const size_t lazy_threshold = 128; + + if (endp1 >= len) { + if (0 == start) { + base -> ref_nonnil(); + return base; + } else { + adj_endp1 = len; + } + } else { + adj_endp1 = endp1; + } + switch(base -> tag) { + case RopeBase::concat: + { + RopeConcatenation *c = (RopeConcatenation *)base; + RopeBase *left = c -> left; + RopeBase *right = c -> right; + size_t left_len = left -> size; + RopeBase * result; + + if (adj_endp1 <= left_len) { + return substring(left, start, endp1); + } else if (start >= left_len) { + return substring(right, start - left_len, + adj_endp1 - left_len); + } + self_destruct_ptr left_result(substring(left, start, + left_len)); + self_destruct_ptr right_result( + substring(right, 0, endp1 - left_len)); + result = concat(left_result, right_result); +# ifndef __GC + __stl_assert(1 == result -> refcount); +# endif + return result; + } + case RopeBase::leaf: + { + RopeLeaf * l = (RopeLeaf *)base; + RopeLeaf * result; + __GC_CONST charT *section; + size_t result_len; + if (start >= adj_endp1) return 0; + result_len = adj_endp1 - start; + if (result_len > lazy_threshold) goto lazy; +# ifdef __GC + section = l -> data + start; + result = RopeLeaf_from_char_ptr(section, result_len); + result -> c_string = 0; // Not eos terminated. +# else + section = alloc_copy(l -> data + start, result_len); + // We should sometimes create substring node instead. + __STL_TRY + result = RopeLeaf_from_char_ptr(section, result_len); + __STL_UNWIND(RopeBase::free_string(section, result_len)) +# endif + return result; + } + case RopeBase::substringfn: + // Avoid introducing mutiple layers of substring nodes. + { + RopeSubstring *old = (RopeSubstring *)base; + size_t result_len; + if (start >= adj_endp1) return 0; + result_len = adj_endp1 - start; + if (result_len > lazy_threshold) { + RopeSubstring * space = SAlloc::allocate(); + RopeSubstring * result = + new(space) RopeSubstring(old -> base, + start + old -> start, + adj_endp1 - start); + return result; + } // else fall through: + } + case RopeBase::function: + { + RopeFunction * f = (RopeFunction *)base; + charT *section; + size_t result_len; + if (start >= adj_endp1) return 0; + result_len = adj_endp1 - start; + + if (result_len > lazy_threshold) goto lazy; + section = (charT *) + Alloc::allocate(rounded_up_size(result_len)); + __STL_TRY + (*(f -> fn))(start, result_len, section); + __STL_UNWIND(RopeBase::free_string(section, result_len)); + __cond_store_eos(section[result_len]); + return RopeLeaf_from_char_ptr(section, result_len); + } + } + /*NOTREACHED*/ + __stl_assert(false); + lazy: + { + // Create substring node. + RopeSubstring * space = SAlloc::allocate(); + RopeSubstring * result = new(space) RopeSubstring(base, start, + adj_endp1 - start); + return result; + } +} + +template +class __rope_flatten_char_consumer : public __rope_char_consumer { + private: + charT * buf_ptr; + public: + charT * buffer; + __rope_flatten_char_consumer(charT * buffer) { + buf_ptr = buffer; + }; + ~__rope_flatten_char_consumer() {} + bool operator() (const charT* leaf, size_t n) { + uninitialized_copy_n(leaf, n, buf_ptr); + buf_ptr += n; + return true; + } +}; + +template +class __rope_find_char_char_consumer : public __rope_char_consumer { + private: + charT pattern; + public: + size_t count; // Number of nonmatching characters + __rope_find_char_char_consumer(charT p) : pattern(p), count(0) {} + ~__rope_find_char_char_consumer() {} + bool operator() (const charT* leaf, size_t n) { + size_t i; + for (i = 0; i < n; i++) { + if (leaf[i] == pattern) { + count += i; return false; + } + } + count += n; return true; + } +}; + +template +class __rope_insert_char_consumer : public __rope_char_consumer { + private: + typedef ostream insert_ostream; + insert_ostream & o; + public: + charT * buffer; + __rope_insert_char_consumer(insert_ostream & writer) : o(writer) {}; + ~__rope_insert_char_consumer() { }; + // Caller is presumed to own the ostream + bool operator() (const charT* leaf, size_t n); + // Returns true to continue traversal. +}; + +template +bool __rope_insert_char_consumer::operator() + (const charT * leaf, size_t n) +{ + size_t i; + // We assume that formatting is set up correctly for each element. + for (i = 0; i < n; i++) o << leaf[i]; + return true; +} + +inline bool __rope_insert_char_consumer::operator() + (const char * leaf, size_t n) +{ + size_t i; + for (i = 0; i < n; i++) o.put(leaf[i]); + return true; +} + +#if !defined(_MSC_VER) && !defined(__BORLANDC__) +// I couldn't get this to work work with the VC++ version of basic_ostream. +inline bool __rope_insert_char_consumer::operator() + (const wchar_t * leaf, size_t n) +{ + size_t i; + for (i = 0; i < n; i++) o.put(leaf[i]); + return true; +} +#endif /* !_MSC_VER && !BORLAND */ + +template +bool rope::apply_to_pieces( + __rope_char_consumer& c, + const RopeBase * r, + size_t begin, size_t end) +{ + if (0 == r) return true; + switch(r -> tag) { + case RopeBase::concat: + { + RopeConcatenation *conc = (RopeConcatenation *)r; + RopeBase *left = conc -> left; + size_t left_len = left -> size; + if (begin < left_len) { + size_t left_end = min(left_len, end); + if (!apply_to_pieces(c, left, begin, left_end)) { + return false; + } + } + if (end > left_len) { + RopeBase *right = conc -> right; + size_t right_start = max(left_len, begin); + if (!apply_to_pieces(c, right, + right_start - left_len, + end - left_len)) { + return false; + } + } + } + return true; + case RopeBase::leaf: + { + RopeLeaf * l = (RopeLeaf *)r; + return c(l -> data + begin, end - begin); + } + case RopeBase::function: + case RopeBase::substringfn: + { + RopeFunction * f = (RopeFunction *)r; + size_t len = end - begin; + bool result; + charT * buffer = (charT *) + Alloc::allocate(len * sizeof(charT)); + __STL_TRY + (*(f -> fn))(begin, end, buffer); + result = c(buffer, len); + __STL_ALWAYS(Alloc::deallocate(buffer, len * sizeof(charT))) + return result; + } + default: + __stl_assert(false); + /*NOTREACHED*/ + return false; + } +} + +inline void __rope_fill(ostream& o, size_t n) +{ + char f = cout.fill(); + size_t i; + + for (i = 0; i < n; i++) o.put(f); +} + + +template inline bool __rope_is_simple(charT *c) { return false; } +inline bool __rope_is_simple(char * c) { return true; } +inline bool __rope_is_simple(wchar_t * c) { return true; } + + +template +ostream& operator<< (ostream& o, const rope& r) +{ + size_t w = o.width(); + bool left = o.flags() & ios::left; + size_t pad_len; + size_t rope_len = r.size(); + __rope_insert_char_consumer c(o); + bool is_simple = __rope_is_simple((charT *)0); + + if (rope_len < w) { + pad_len = w - rope_len; + } else { + pad_len = 0; + } + if (!is_simple) o.width(w/rope_len); + __STL_TRY + if (is_simple && !left && pad_len > 0) { + __rope_fill(o, pad_len); + } + r.apply_to_pieces(0, r.size(), c); + if (is_simple && left && pad_len > 0) { + __rope_fill(o, pad_len); + } + __STL_ALWAYS(if (!is_simple) o.width(w)) + return o; +} + +template +charT * +rope::flatten(RopeBase * r, + size_t start, size_t len, + charT * buffer) +{ + __rope_flatten_char_consumer c(buffer); + apply_to_pieces(c, r, start, start + len); + return(buffer + len); +} + +template +size_t +rope::find(charT pattern, size_t start) const +{ + __rope_find_char_char_consumer c(pattern); + apply_to_pieces(c, tree_ptr, start, size()); + return start + c.count; +} + +template +charT * +rope::flatten(RopeBase * r, charT * buffer) +{ + if (0 == r) return buffer; + switch(r -> tag) { + case RopeBase::concat: + { + RopeConcatenation *c = (RopeConcatenation *)r; + RopeBase *left = c -> left; + RopeBase *right = c -> right; + charT * rest = flatten(left, buffer); + return flatten(right, rest); + } + case RopeBase::leaf: + { + RopeLeaf * l = (RopeLeaf *)r; + return copy_n(l -> data, l -> size, buffer); + } + case RopeBase::function: + case RopeBase::substringfn: + // We dont yet do anything with substring nodes. + // This needs to be fixed before ropefiles will work well. + { + RopeFunction * f = (RopeFunction *)r; + (*(f -> fn))(0, f -> size, buffer); + return buffer + f -> size; + } + default: + __stl_assert(false); + /*NOTREACHED*/ + return 0; + } +} + + +// This needs work for charT != char +template +void +rope::dump(RopeBase * r, int indent) +{ + for (int i = 0; i < indent; i++) putchar(' '); + if (0 == r) { + printf("NULL\n"); return; + } + if (RopeBase::concat == r -> tag) { + RopeConcatenation *c = (RopeConcatenation *)r; + RopeBase *left = c -> left; + RopeBase *right = c -> right; + +# ifdef __GC + printf("Concatenation %p (depth = %d, len = %ld, %s balanced)\n", + r, r -> depth, r -> size, r -> is_balanced? "" : "not"); +# else + printf("Concatenation %p (rc = %ld, depth = %d, len = %ld, %s balanced)\n", + r, r -> refcount, r -> depth, r -> size, + r -> is_balanced? "" : "not"); +# endif + dump(left, indent + 2); + dump(right, indent + 2); + return; + } else { + char * kind; + + switch (r -> tag) { + case RopeBase::leaf: + kind = "Leaf"; + break; + case RopeBase::function: + kind = "Function"; + break; + case RopeBase::substringfn: + kind = "Function representing substring"; + break; + default: + kind = "(corrupted kind field!)"; + } +# ifdef __GC + printf("%s %p (depth = %d, len = %ld) ", + kind, r, r -> depth, r -> size); +# else + printf("%s %p (rc = %ld, depth = %d, len = %ld) ", + kind, r, r -> refcount, r -> depth, r -> size); +# endif + if (__is_one_byte_char_type((charT *)0)) { + const int max_len = 40; + self_destruct_ptr prefix(substring(r, 0, max_len)); + charT buffer[max_len + 1]; + bool too_big = r -> size > prefix-> size; + + flatten(prefix, buffer); + buffer[prefix -> size] = __eos((charT *)0); + printf("%s%s\n", (char *)buffer, too_big? "...\n" : "\n"); + } else { + printf("\n"); + } + } +} + +template +const unsigned long +rope::min_len[__rope_RopeBase::max_rope_depth + 1] = { +/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21, +/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377, +/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181, +/* 18 */6765, /* 19 */10946, /* 20 */17711, /* 21 */28657, /* 22 */46368, +/* 23 */75025, /* 24 */121393, /* 25 */196418, /* 26 */317811, +/* 27 */514229, /* 28 */832040, /* 29 */1346269, /* 30 */2178309, +/* 31 */3524578, /* 32 */5702887, /* 33 */9227465, /* 34 */14930352, +/* 35 */24157817, /* 36 */39088169, /* 37 */63245986, /* 38 */102334155, +/* 39 */165580141, /* 40 */267914296, /* 41 */433494437, +/* 42 */701408733, /* 43 */1134903170, /* 44 */1836311903, +/* 45 */2971215073 }; +// These are Fibonacci numbers < 2**32. + +template +rope::RopeBase * +rope::balance(RopeBase *r) +{ + RopeBase * forest[RopeBase::max_rope_depth + 1]; + RopeBase * result = 0; + int i; + // Inariant: + // The concatenation of forest in descending order is equal to r. + // forest[i].size >= min_len[i] + // forest[i].depth = i + // References from forest are included in refcount. + + for (i = 0; i <= RopeBase::max_rope_depth; ++i) forest[i] = 0; + __STL_TRY + add_to_forest(r, forest); + for (i = 0; i <= RopeBase::max_rope_depth; ++i) if (0 != forest[i]) { +# ifndef __GC + self_destruct_ptr old(result); +# endif + result = concat(forest[i], result); + forest[i] -> unref_nonnil(); + } + __STL_UNWIND(for(i = 0; i <= RopeBase::max_rope_depth; i++) + unref(forest[i])) + if (result -> depth > RopeBase::max_rope_depth) abort(); + return(result); +} + + +template +void +rope::add_to_forest(RopeBase *r, RopeBase **forest) +{ + if (r -> is_balanced) { + add_leaf_to_forest(r, forest); + return; + } + __stl_assert(r -> tag == RopeBase::concat); + { + RopeConcatenation *c = (RopeConcatenation *)r; + + add_to_forest(c -> left, forest); + add_to_forest(c -> right, forest); + } +} + + +template +void +rope::add_leaf_to_forest(RopeBase *r, RopeBase **forest) +{ + self_destruct_ptr insertee(r); // included in refcount + self_destruct_ptr too_tiny(0); // included in refcount + int i; // forest[0..i-1] is empty + size_t s = insertee -> size; + + ref(r); + for (i = 0; s >= min_len[i+1]/* not this bucket */; ++i) { + if (0 != forest[i]) { +# ifndef __GC + self_destruct_ptr old(too_tiny); +# endif + too_tiny = concat_and_set_balanced(forest[i], too_tiny); + forest[i] -> unref_nonnil(); + forest[i] = 0; + } + } + { +# ifndef __GC + self_destruct_ptr old(insertee); +# endif + insertee = concat_and_set_balanced(too_tiny, insertee); + } + unref(too_tiny); // too_tiny is dead. + too_tiny = 0; // Needed for exception safety. + __stl_assert(is_almost_balanced(insertee)); + __stl_assert(insertee -> depth <= r -> depth + 1); + for (;; ++i) { + if (0 != forest[i]) { +# ifndef __GC + self_destruct_ptr old(insertee); +# endif + insertee = concat_and_set_balanced(forest[i], insertee); + forest[i] -> unref_nonnil(); + forest[i] = 0; + __stl_assert(is_almost_balanced(insertee)); + } + __stl_assert(min_len[i] <= insertee -> size); + __stl_assert(forest[i] == 0); + if (i == RopeBase::max_rope_depth + || insertee -> size < min_len[i+1]) { + forest[i] = insertee; + insertee = 0; + // refcount is OK since insertee is now dead. + return; + } + } +} + +template +charT +rope::fetch(RopeBase *r, size_type i) +{ + __GC_CONST charT * cstr = r -> c_string; + + __stl_assert(i < r -> size); + if (0 != cstr) return cstr[i]; + for(;;) { + switch(r -> tag) { + case RopeBase::concat: + { + RopeConcatenation *c = (RopeConcatenation *)r; + RopeBase *left = c -> left; + size_t left_len = left -> size; + + if (i >= left_len) { + i -= left_len; + r = c -> right; + } else { + r = left; + } + } + break; + case RopeBase::leaf: + { + RopeLeaf * l = (RopeLeaf *)r; + return l -> data[i]; + } + case RopeBase::function: + case RopeBase::substringfn: + { + RopeFunction * f = (RopeFunction *)r; + charT result; + + (*(f -> fn))(i, 1, &result); + return result; + } + } + } +} + +# ifndef __GC +// Return a uniquely referenced character slot for the given +// position, or 0 if that's not possible. +template +charT* +rope::fetch_ptr(RopeBase *r, size_type i) +{ + RopeBase * clrstack[RopeBase::max_rope_depth]; + size_t csptr = 0; + + for(;;) { + if (r -> refcount > 1) return 0; + switch(r -> tag) { + case RopeBase::concat: + { + RopeConcatenation *c = (RopeConcatenation *)r; + RopeBase *left = c -> left; + size_t left_len = left -> size; + + if (c -> c_string != 0) clrstack[csptr++] = c; + if (i >= left_len) { + i -= left_len; + r = c -> right; + } else { + r = left; + } + } + break; + case RopeBase::leaf: + { + RopeLeaf * l = (RopeLeaf *)r; + if (l -> c_string != l -> data && l -> c_string != 0) + clrstack[csptr++] = l; + while (csptr > 0) { + -- csptr; + RopeBase * d = clrstack[csptr]; + d -> free_c_string(); + d -> c_string = 0; + } + return l -> data + i; + } + case RopeBase::function: + case RopeBase::substringfn: + return 0; + } + } +} +# endif /* __GC */ + +// The following could be implemented trivially using +// lexicographical_compare_3way. +// We do a little more work to avoid dealing with rope iterators for +// flat strings. +template +int +rope::compare (const RopeBase *left, const RopeBase *right) +{ + size_t left_len; + size_t right_len; + + if (0 == right) return 0 != left; + if (0 == left) return -1; + left_len = left -> size; + right_len = right -> size; + if (RopeBase::leaf == left -> tag) { + RopeLeaf *l = (RopeLeaf *) left; + if (RopeBase::leaf == right -> tag) { + RopeLeaf *r = (RopeLeaf *) right; + return lexicographical_compare_3way( + l -> data, l -> data + left_len, + r -> data, r -> data + right_len); + } else { + const_iterator rstart(right, 0); + const_iterator rend(right, right_len); + return lexicographical_compare_3way( + l -> data, l -> data + left_len, + rstart, rend); + } + } else { + const_iterator lstart(left, 0); + const_iterator lend(left, left_len); + if (RopeBase::leaf == right -> tag) { + RopeLeaf *r = (RopeLeaf *) right; + return lexicographical_compare_3way( + lstart, lend, + r -> data, r -> data + right_len); + } else { + const_iterator rstart(right, 0); + const_iterator rend(right, right_len); + return lexicographical_compare_3way( + lstart, lend, + rstart, rend); + } + } +} + +// Assignment to reference proxies. +template +__rope_charT_ref_proxy& +__rope_charT_ref_proxy::operator= (charT c) { + RopeBase * old = root -> tree_ptr; +# ifndef __GC + // First check for the case in which everything is uniquely + // referenced. In that case we can do this destructively. + charT * charT_ptr = my_rope::fetch_ptr(old, pos); + if (0 != charT_ptr) { + *charT_ptr = c; + return *this; + } +# endif + self_destruct_ptr left(my_rope::substring(old, 0, pos)); + self_destruct_ptr right(my_rope::substring(old, pos+1, old -> size)); + self_destruct_ptr result_left(my_rope::destr_concat_char_iter(left, &c, 1)); +# ifndef __GC + __stl_assert(left == result_left || 1 == result_left -> refcount); +# endif + RopeBase * result = + my_rope::concat(result_left, right); +# ifndef __GC + __stl_assert(1 <= result -> refcount); + RopeBase::unref(old); +# endif + root -> tree_ptr = result; + return *this; +} + +template +inline __rope_charT_ref_proxy::operator charT () const +{ + if (current_valid) { + return current; + } else { + return my_rope::fetch(root->tree_ptr, pos); + } +} +template +__rope_charT_ptr_proxy +__rope_charT_ref_proxy::operator& () const { + return __rope_charT_ptr_proxy(*this); +} + +template +rope::rope(size_t n, charT c) +{ + RopeBase * result; + const size_t exponentiate_threshold = 32; + size_t exponent; + size_t rest; + charT *rest_buffer; + RopeBase * remainder; + + if (0 == n) { tree_ptr = 0; return; } + exponent = n / exponentiate_threshold; + rest = n % exponentiate_threshold; + if (0 == rest) { + remainder = 0; + } else { + rest_buffer = (charT *)Alloc::allocate(rounded_up_size(rest)); + uninitialized_fill_n(rest_buffer, rest, c); + __cond_store_eos(rest_buffer[rest]); + __STL_TRY + remainder = RopeLeaf_from_char_ptr(rest_buffer, rest); + __STL_UNWIND(RopeBase::free_string(rest_buffer, rest)) + } + __STL_TRY + if (exponent != 0) { + charT * base_buffer = + (charT *)Alloc::allocate( + rounded_up_size(exponentiate_threshold)); + self_destruct_ptr base_leaf; + uninitialized_fill_n(base_buffer, exponentiate_threshold, c); + __cond_store_eos(base_buffer[exponentiate_threshold]); + __STL_TRY + base_leaf = RopeLeaf_from_char_ptr(base_buffer, + exponentiate_threshold); + __STL_UNWIND(RopeBase::free_string(base_buffer, exponentiate_threshold)) + if (1 == exponent) { + result = base_leaf; +# ifndef __GC + __stl_assert(1 == result -> refcount); + result -> refcount = 2; // will be decremented when base_leaf disappears +# endif + } else { + result = power((RopeBase *)base_leaf, exponent, concat_fn()); +# ifndef __GC + __stl_assert(0 == result -> refcount); + result -> refcount = 1; +# endif + } + if (0 != remainder) { +# ifndef __GC + __stl_assert(1 == remainder -> refcount); +# endif + result = tree_concat(result, remainder); + } + // All partial results computed by power must be used. + } else { + result = remainder; + } + __STL_UNWIND(unref(remainder)); +# ifndef __GC + __stl_assert(0 == result || 1 == result -> refcount); +# endif + tree_ptr = result; +} + +template charT rope::empty_c_str[1]; + +# ifdef _PTHREADS + template + pthread_mutex_t rope::swap_lock = PTHREAD_MUTEX_INITIALIZER; +# endif + +template +const charT * rope::c_str() const { + if (0 == tree_ptr) { + empty_c_str[0] = __eos((charT *)0); // Possibly redundant, + // but probably fast. + return empty_c_str; + } + __GC_CONST charT * old_c_string = tree_ptr -> c_string; + if (0 != old_c_string) return(old_c_string); + size_t s = size(); + charT * result = (charT *)Alloc::allocate((s + 1)*sizeof(charT)); + flatten(tree_ptr, result); + result[s] = __eos((charT *)0); +# ifdef __GC + tree_ptr -> c_string = result; +# else + if ((old_c_string = atomic_swap(&(tree_ptr -> c_string), result)) != 0) { + // It must have been added in the interim. Hence it had to have been + // separately allocated. Deallocate the old copy, since we just + // replaced it. + destroy(old_c_string, old_c_string + s + 1); + Alloc::deallocate(old_c_string, s + 1); + } +# endif + return(result); +} + +template +const charT * rope::replace_with_c_str() { + if (0 == tree_ptr) { + empty_c_str[0] = __eos((charT *)0); + return empty_c_str; + } + __GC_CONST charT * old_c_string = tree_ptr -> c_string; + if (RopeBase::leaf == tree_ptr -> tag && 0 != old_c_string) { + return(old_c_string); + } + size_t s = size(); + charT * result = (charT *)Alloc::allocate(rounded_up_size(s)); + flatten(tree_ptr, result); + result[s] = __eos((charT *)0); + tree_ptr -> unref_nonnil(); + tree_ptr = RopeLeaf_from_char_ptr(result, s); + return(result); +} + +// Algorithm specializations. More should be added. + +#ifndef _MSC_VER +// I couldn't get this to work with VC++ +template +void +__rope_rotate(__rope_iterator first, + __rope_iterator middle, + __rope_iterator last) { + __stl_assert(first.container() == middle.container() + && middle.container() == last.container()); + rope& r(first.container()); + rope prefix = r.substr(0, first.index()); + rope suffix = r.substr(last.index(), r.size() - last.index()); + rope part1 = r.substr(middle.index(), + last.index() - middle.index()); + rope part2 = r.substr(first.index(), + middle.index() - first.index()); + r = prefix; + r += part1; + r += part2; + r += suffix; +} + +inline void rotate(__rope_iterator first, + __rope_iterator middle, + __rope_iterator last) { + __rope_rotate(first, middle, last); +} + +# if 0 +// Probably not useful for several reasons: +// - for SGIs 7.1 compiler and probably some others, +// this forces lots of rope instantiations, creating a +// code bloat and compile time problem. (Fixed in 7.2.) +// - wchar_t is 4 bytes wide on most UNIX platforms, making it unattractive +// for unicode strings. Unsigned short may be a better character +// type. +inline void rotate(__rope_iterator first, + __rope_iterator middle, + __rope_iterator last) { + __rope_rotate(first, middle, last); +} +# endif +#endif /* _MSC_VER */ diff --git a/libstdc++/stl/set.h b/libstdc++/stl/set.h new file mode 100644 index 000000000000..6a79a625653f --- /dev/null +++ b/libstdc++/stl/set.h @@ -0,0 +1,167 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_SET_H +#define __SGI_STL_SET_H + +#include + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , class Alloc = alloc> +#else +template +#endif +class set { +public: + // typedefs: + + typedef Key key_type; + typedef Key value_type; + typedef Compare key_compare; + typedef Compare value_compare; +private: + typedef rb_tree, key_compare, Alloc> rep_type; + rep_type t; // red-black tree representing set +public: + typedef rep_type::const_pointer pointer; + typedef rep_type::const_reference reference; + typedef rep_type::const_reference const_reference; + typedef rep_type::const_iterator iterator; + typedef rep_type::const_iterator const_iterator; + typedef rep_type::const_reverse_iterator reverse_iterator; + typedef rep_type::const_reverse_iterator const_reverse_iterator; + typedef rep_type::size_type size_type; + typedef rep_type::difference_type difference_type; + + // allocation/deallocation + + set() : t(Compare()) {} + explicit set(const Compare& comp) : t(comp) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + set(InputIterator first, InputIterator last) + : t(Compare()) { t.insert_unique(first, last); } + + template + set(InputIterator first, InputIterator last, const Compare& comp) + : t(comp) { t.insert_unique(first, last); } +#else + set(const value_type* first, const value_type* last) + : t(Compare()) { t.insert_unique(first, last); } + set(const value_type* first, const value_type* last, const Compare& comp) + : t(comp) { t.insert_unique(first, last); } + + set(const_iterator first, const_iterator last) + : t(Compare()) { t.insert_unique(first, last); } + set(const_iterator first, const_iterator last, const Compare& comp) + : t(comp) { t.insert_unique(first, last); } +#endif /* __STL_MEMBER_TEMPLATES */ + + set(const set& x) : t(x.t) {} + set& operator=(const set& x) { + t = x.t; + return *this; + } + + // accessors: + + key_compare key_comp() const { return t.key_comp(); } + value_compare value_comp() const { return t.key_comp(); } + iterator begin() const { return t.begin(); } + iterator end() const { return t.end(); } + reverse_iterator rbegin() const { return t.rbegin(); } + reverse_iterator rend() const { return t.rend(); } + bool empty() const { return t.empty(); } + size_type size() const { return t.size(); } + size_type max_size() const { return t.max_size(); } + void swap(set& x) { t.swap(x.t); } + + // insert/erase + typedef pair pair_iterator_bool; + pair insert(const value_type& x) { + pair p = t.insert_unique(x); + return pair(p.first, p.second); + } + iterator insert(iterator position, const value_type& x) { + return t.insert_unique((rep_type::iterator&)position, x); + } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(InputIterator first, InputIterator last) { + t.insert_unique(first, last); + } +#else + void insert(const_iterator first, const_iterator last) { + t.insert_unique(first, last); + } + void insert(const value_type* first, const value_type* last) { + t.insert_unique(first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + void erase(iterator position) { + t.erase((rep_type::iterator&)position); + } + size_type erase(const key_type& x) { + return t.erase(x); + } + void erase(iterator first, iterator last) { + t.erase((rep_type::iterator&)first, + (rep_type::iterator&)last); + } + void clear() { t.clear(); } + + // set operations: + + iterator find(const key_type& x) const { return t.find(x); } + size_type count(const key_type& x) const { return t.count(x); } + iterator lower_bound(const key_type& x) const { + return t.lower_bound(x); + } + iterator upper_bound(const key_type& x) const { + return t.upper_bound(x); + } + pair equal_range(const key_type& x) const { + return t.equal_range(x); + } + friend bool operator==(const set&, const set&); + friend bool operator<(const set&, const set&); +}; + +template +inline bool operator==(const set& x, + const set& y) { + return x.t == y.t; +} + +template +inline bool operator<(const set& x, + const set& y) { + return x.t < y.t; +} + +#endif /* __SGI_STL_SET_H */ diff --git a/libstdc++/stl/slist.h b/libstdc++/stl/slist.h new file mode 100644 index 000000000000..bb99920185f9 --- /dev/null +++ b/libstdc++/stl/slist.h @@ -0,0 +1,729 @@ +/* + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef __SGI_STL_SLIST_H +#define __SGI_STL_SLIST_H + +#include +#include + +struct __slist_node_base +{ + __slist_node_base* next; +}; + +inline __slist_node_base* __slist_make_link(__slist_node_base* prev_node, + __slist_node_base* new_node) +{ + new_node->next = prev_node->next; + prev_node->next = new_node; + return new_node; +} + +inline __slist_node_base* __slist_previous(__slist_node_base* head, + const __slist_node_base* node) +{ + while (head && head->next != node) + head = head->next; + return head; +} + +inline const __slist_node_base* __slist_previous(const __slist_node_base* head, + const __slist_node_base* node) +{ + while (head && head->next != node) + head = head->next; + return head; +} + +inline void __slist_splice_after(__slist_node_base* pos, + __slist_node_base* before_first, + __slist_node_base* before_last) +{ + if (pos != before_first && pos != before_last) { + __slist_node_base* first = before_first->next; + __slist_node_base* after = pos->next; + before_first->next = before_last->next; + pos->next = first; + before_last->next = after; + } +} + +inline __slist_node_base* __slist_reverse(__slist_node_base* node) +{ + __slist_node_base* result = node; + node = node->next; + result->next = 0; + while(node) { + __slist_node_base* next = node->next; + node->next = result; + result = node; + node = next; + } + return result; +} + +template +struct __slist_node : public __slist_node_base +{ + T data; +}; + +struct __slist_iterator_base +{ + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef forward_iterator_tag iterator_category; + + __slist_node_base* node; + + __slist_iterator_base(__slist_node_base* x) : node(x) {} + void incr() { node = node->next; } + + bool operator==(const __slist_iterator_base& x) const { + return node == x.node; + } + bool operator!=(const __slist_iterator_base& x) const { + return node != x.node; + } +}; + +template +struct __slist_iterator : public __slist_iterator_base +{ + typedef __slist_iterator iterator; + typedef __slist_iterator const_iterator; + typedef __slist_iterator self; + + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef __slist_node list_node; + + __slist_iterator(list_node* x) : __slist_iterator_base(x) {} + __slist_iterator() : __slist_iterator_base(0) {} + __slist_iterator(const iterator& x) : __slist_iterator_base(x.node) {} + + Ref operator*() const { return ((list_node*) node)->data; } + self& operator++() + { + incr(); + return *this; + } + self operator++(int) + { + self tmp = *this; + incr(); + return tmp; + } +}; + +inline ptrdiff_t* +distance_type(const __slist_iterator_base&) +{ + return 0; +} + +inline forward_iterator_tag +iterator_category(const __slist_iterator_base&) +{ + return forward_iterator_tag(); +} + +template +inline T* +value_type(const __slist_iterator&) { + return 0; +} + +inline size_t __slist_size(__slist_node_base* node) +{ + size_t result = 0; + for ( ; node != 0; node = node->next) + ++result; + return result; +} + +template +class slist +{ +public: + typedef T value_type; + typedef value_type* pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + typedef __slist_iterator iterator; + typedef __slist_iterator const_iterator; + +private: + typedef __slist_node list_node; + typedef __slist_node_base list_node_base; + typedef __slist_iterator_base iterator_base; + typedef simple_alloc list_node_allocator; + + static list_node* create_node(const value_type& x) { + list_node* node = list_node_allocator::allocate(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + construct(&node->data, x); + node->next = 0; + return node; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + list_node_allocator::deallocate(node); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + + static void destroy_node(list_node* node) { + destroy(&node->data); + list_node_allocator::deallocate(node); + } + + void fill_initialize(size_type n, const value_type& x) { + head.next = 0; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + _insert_after_fill(&head, n, x); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + +#ifdef __STL_MEMBER_TEMPLATES + template + void range_initialize(InputIterator first, InputIterator last) { + head.next = 0; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + _insert_after_range(&head, first, last); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +#else /* __STL_MEMBER_TEMPLATES */ + void range_initialize(const value_type* first, const value_type* last) { + head.next = 0; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + _insert_after_range(&head, first, last); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + void range_initialize(const_iterator first, const_iterator last) { + head.next = 0; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + _insert_after_range(&head, first, last); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + clear(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +#endif /* __STL_MEMBER_TEMPLATES */ + +private: + list_node_base head; + +public: + slist() { head.next = 0; } + + slist(size_type n, const value_type& x) { fill_initialize(n, x); } + slist(int n, const value_type& x) { fill_initialize(n, x); } + slist(long n, const value_type& x) { fill_initialize(n, x); } + explicit slist(size_type n) { fill_initialize(n, value_type()); } + +#ifdef __STL_MEMBER_TEMPLATES + template + slist(InputIterator first, InputIterator last) { + range_initialize(first, last); + } + +#else /* __STL_MEMBER_TEMPLATES */ + slist(const_iterator first, const_iterator last) { + range_initialize(first, last); + } + slist(const value_type* first, const value_type* last) { + range_initialize(first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + + slist(const slist& L) { range_initialize(L.begin(), L.end()); } + + slist& operator= (const slist& L); + + ~slist() { clear(); } + +public: + + iterator begin() { return iterator((list_node*)head.next); } + const_iterator begin() const { return const_iterator((list_node*)head.next);} + + iterator end() { return iterator(0); } + const_iterator end() const { return const_iterator(0); } + + size_type size() const { return __slist_size(head.next); } + + size_type max_size() const { return size_type(-1); } + + bool empty() const { return head.next == 0; } + + void swap(slist& L) + { + list_node_base* tmp = head.next; + head.next = L.head.next; + L.head.next = tmp; + } + +public: + friend bool operator==(const slist& L1, const slist& L2); + +public: + + reference front() { return ((list_node*) head.next)->data; } + const_reference front() const { return ((list_node*) head.next)->data; } + void push_front(const value_type& x) { + __slist_make_link(&head, create_node(x)); + } + void pop_front() { + list_node* node = (list_node*) head.next; + head.next = node->next; + destroy_node(node); + } + + iterator previous(const_iterator pos) { + return iterator((list_node*) __slist_previous(&head, pos.node)); + } + const_iterator previous(const_iterator pos) const { + return const_iterator((list_node*) __slist_previous(&head, pos.node)); + } + +private: + list_node* _insert_after(list_node_base* pos, const value_type& x) { + return (list_node*) (__slist_make_link(pos, create_node(x))); + } + + void _insert_after_fill(list_node_base* pos, + size_type n, const value_type& x) { + for (size_type i = 0; i < n; ++i) + pos = __slist_make_link(pos, create_node(x)); + } + +#ifdef __STL_MEMBER_TEMPLATES + template + void _insert_after_range(list_node_base* pos, InIter first, InIter last) { + while (first != last) { + pos = __slist_make_link(pos, create_node(*first)); + ++first; + } + } +#else /* __STL_MEMBER_TEMPLATES */ + void _insert_after_range(list_node_base* pos, + const_iterator first, const_iterator last) { + while (first != last) { + pos = __slist_make_link(pos, create_node(*first)); + ++first; + } + } + void _insert_after_range(list_node_base* pos, + const value_type* first, const value_type* last) { + while (first != last) { + pos = __slist_make_link(pos, create_node(*first)); + ++first; + } + } +#endif /* __STL_MEMBER_TEMPLATES */ + + void erase_after(list_node_base* pos) { + list_node* next = (list_node*) (pos->next); + pos->next = next->next; + destroy_node(next); + } + + void erase_after(list_node_base* before_first, list_node_base* last_node) { + list_node* cur = (list_node*) (before_first->next); + while (cur != last_node) { + list_node* tmp = cur; + cur = (list_node*) cur->next; + destroy_node(tmp); + } + before_first->next = last_node; + } + + +public: + + iterator insert_after(iterator pos, const value_type& x) { + return iterator(_insert_after(pos.node, x)); + } + + iterator insert_after(iterator pos) { + return insert_after(pos, value_type()); + } + + void insert_after(iterator pos, size_type n, const value_type& x) { + _insert_after_fill(pos.node, n, x); + } + void insert_after(iterator pos, int n, const value_type& x) { + _insert_after_fill(pos.node, (size_type) n, x); + } + void insert_after(iterator pos, long n, const value_type& x) { + _insert_after_fill(pos.node, (size_type) n, x); + } + +#ifdef __STL_MEMBER_TEMPLATES + template + void insert_after(iterator pos, InIter first, InIter last) { + _insert_after_range(pos.node, first, last); + } +#else /* __STL_MEMBER_TEMPLATES */ + void insert_after(iterator pos, const_iterator first, const_iterator last) { + _insert_after_range(pos.node, first, last); + } + void insert_after(iterator pos, + const value_type* first, const value_type* last) { + _insert_after_range(pos.node, first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + + iterator insert(iterator pos, const value_type& x) { + return iterator(_insert_after(__slist_previous(&head, pos.node), x)); + } + + iterator insert(iterator pos) { + return iterator(_insert_after(__slist_previous(&head, pos.node), + value_type())); + } + + void insert(iterator pos, size_type n, const value_type& x) { + _insert_after_fill(__slist_previous(&head, pos.node), n, x); + } + void insert(iterator pos, int n, const value_type& x) { + _insert_after_fill(__slist_previous(&head, pos.node), (size_type) n, x); + } + void insert(iterator pos, long n, const value_type& x) { + _insert_after_fill(__slist_previous(&head, pos.node), (size_type) n, x); + } + +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(iterator pos, InIter first, InIter last) { + _insert_after_range(__slist_previous(&head, pos.node), first, last); + } +#else /* __STL_MEMBER_TEMPLATES */ + void insert(iterator pos, const_iterator first, const_iterator last) { + _insert_after_range(__slist_previous(&head, pos.node), first, last); + } + void insert(iterator pos, const value_type* first, const value_type* last) { + _insert_after_range(__slist_previous(&head, pos.node), first, last); + } +#endif /* __STL_MEMBER_TEMPLATES */ + + +public: + void erase_after(iterator pos) { erase_after(pos.node); } + void erase_after(iterator before_first, iterator last) { + erase_after(before_first.node, last.node); + } + + void erase(iterator pos) { erase_after(__slist_previous(&head, pos.node)); } + void erase(iterator first, iterator last) { + erase_after(__slist_previous(&head, first.node), last.node); + } + + void resize(size_type new_size, const T& x); + void resize(size_type new_size) { resize(new_size, T()); } + void clear() { erase_after(&head, 0); } + +public: + // Moves the range [before_first + 1, before_last + 1) to *this, + // inserting it immediately after pos. This is constant time. + void splice_after(iterator pos, + iterator before_first, iterator before_last) + { + if (before_first != before_last) + __slist_splice_after(pos.node, before_first.node, before_last.node); + } + + // Moves the element that follows prev to *this, inserting it immediately + // after pos. This is constant time. + void splice_after(iterator pos, iterator prev) + { + __slist_splice_after(pos.node, prev.node, prev.node->next); + } + + + // Linear in distance(begin(), pos), and linear in L.size(). + void splice(iterator pos, slist& L) { + if (L.head.next) + __slist_splice_after(__slist_previous(&head, pos.node), + &L.head, + __slist_previous(&L.head, 0)); + } + + // Linear in distance(begin(), pos), and in distance(L.begin(), i). + void splice(iterator pos, slist& L, iterator i) { + __slist_splice_after(__slist_previous(&head, pos.node), + __slist_previous(&L.head, i.node), + i.node); + } + + // Linear in distance(begin(), pos), in distance(L.begin(), first), + // and in distance(first, last). + void splice(iterator pos, slist& L, iterator first, iterator last) + { + if (first != last) + __slist_splice_after(__slist_previous(&head, pos.node), + __slist_previous(&L.head, first.node), + __slist_previous(first.node, last.node)); + } + +public: + void reverse() { if (head.next) head.next = __slist_reverse(head.next); } + + void remove(const T& val); + void unique(); + void merge(slist& L); + void sort(); + +#ifdef __STL_MEMBER_TEMPLATES + template void remove_if(Predicate pred); + template void unique(BinaryPredicate pred); + template void merge(slist&, StrictWeakOrdering); + template void sort(StrictWeakOrdering comp); +#endif /* __STL_MEMBER_TEMPLATES */ +}; + +template +slist& slist::operator=(const slist& L) +{ + if (&L != this) { + list_node_base* p1 = &head; + list_node* n1 = (list_node*) head.next; + const list_node* n2 = (const list_node*) L.head.next; + while (n1 && n2) { + n1->data = n2->data; + p1 = n1; + n1 = (list_node*) n1->next; + n2 = (const list_node*) n2->next; + } + if (n2 == 0) + erase_after(p1, 0); + else + _insert_after_range(p1, + const_iterator((list_node*)n2), const_iterator(0)); + } + return *this; +} + +template +bool operator==(const slist& L1, const slist& L2) +{ + typedef typename slist::list_node list_node; + list_node* n1 = (list_node*) L1.head.next; + list_node* n2 = (list_node*) L2.head.next; + while (n1 && n2 && n1->data == n2->data) { + n1 = (list_node*) n1->next; + n2 = (list_node*) n2->next; + } + return n1 == 0 && n2 == 0; +} + +template +inline bool operator<(const slist& L1, const slist& L2) +{ + return lexicographical_compare(L1.begin(), L1.end(), L2.begin(), L2.end()); +} + +template +void slist::resize(size_type len, const T& x) +{ + list_node_base* cur = &head; + while (cur->next != 0 && len > 0) { + --len; + cur = cur->next; + } + if (cur->next) + erase_after(cur, 0); + else + _insert_after_fill(cur, len, x); +} + +template +void slist::remove(const T& val) +{ + list_node_base* cur = &head; + while (cur && cur->next) { + if (((list_node*) cur->next)->data == val) + erase_after(cur); + else + cur = cur->next; + } +} + +template +void slist::unique() +{ + list_node_base* cur = head.next; + if (cur) { + while (cur->next) { + if (((list_node*)cur)->data == ((list_node*)(cur->next))->data) + erase_after(cur); + else + cur = cur->next; + } + } +} + +template +void slist::merge(slist& L) +{ + list_node_base* n1 = &head; + while (n1->next && L.head.next) { + if (((list_node*) L.head.next)->data < ((list_node*) n1->next)->data) + __slist_splice_after(n1, &L.head, L.head.next); + n1 = n1->next; + } + if (L.head.next) { + n1->next = L.head.next; + L.head.next = 0; + } +} + +template +void slist::sort() +{ + if (head.next && head.next->next) { + slist carry; + slist counter[64]; + int fill = 0; + while (!empty()) { + __slist_splice_after(&carry.head, &head, head.next); + int i = 0; + while (i < fill && !counter[i].empty()) { + counter[i].merge(carry); + carry.swap(counter[i]); + ++i; + } + carry.swap(counter[i]); + if (i == fill) + ++fill; + } + + for (int i = 1; i < fill; ++i) + counter[i].merge(counter[i-1]); + this->swap(counter[fill-1]); + } +} + +#ifdef __STL_MEMBER_TEMPLATES + +template +template void slist::remove_if(Predicate pred) +{ + list_node_base* cur = &head; + while (cur->next) { + if (pred(((list_node*) cur->next)->data)) + erase_after(cur); + else + cur = cur->next; + } +} + +template template +void slist::unique(BinaryPredicate pred) +{ + list_node* cur = (list_node*) head.next; + if (cur) { + while (cur->next) { + if (pred(((list_node*)cur)->data, ((list_node*)(cur->next))->data)) + erase_after(cur); + else + cur = (list_node*) cur->next; + } + } +} + +template template +void slist::merge(slist& L, StrictWeakOrdering comp) +{ + list_node_base* n1 = &head; + while (n1->next && L.head.next) { + if (comp(((list_node*) L.head.next)->data, + ((list_node*) n1->next)->data)) + __slist_splice_after(n1, &L.head, L.head.next); + n1 = n1->next; + } + if (L.head.next) { + n1->next = L.head.next; + L.head.next = 0; + } +} + +template template +void slist::sort(StrictWeakOrdering comp) +{ + if (head.next && head.next->next) { + slist carry; + slist counter[64]; + int fill = 0; + while (!empty()) { + __slist_splice_after(&carry.head, &head, head.next); + int i = 0; + while (i < fill && !counter[i].empty()) { + counter[i].merge(carry, comp); + carry.swap(counter[i]); + ++i; + } + carry.swap(counter[i]); + if (i == fill) + ++fill; + } + + for (int i = 1; i < fill; ++i) + counter[i].merge(counter[i-1], comp); + this->swap(counter[fill-1]); + } +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +#endif /* __SGI_STL_SLIST_H */ diff --git a/libstdc++/stl/stack.h b/libstdc++/stl/stack.h new file mode 100644 index 000000000000..cc025bb70e18 --- /dev/null +++ b/libstdc++/stl/stack.h @@ -0,0 +1,171 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef STACK_H +#define STACK_H + +#include +#include +#include +#include + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template > +#else +template +#endif +class stack { + friend bool operator==(const stack& x, + const stack& y); + friend bool operator<(const stack& x, + const stack& y); +public: + typedef typename Sequence::value_type value_type; + typedef typename Sequence::size_type size_type; +protected: + Sequence c; +public: + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + value_type& top() { return c.back(); } + const value_type& top() const { return c.back(); } + void push(const value_type& x) { c.push_back(x); } + void pop() { c.pop_back(); } +}; + +template +bool operator==(const stack& x, const stack& y) { + return x.c == y.c; +} + +template +bool operator<(const stack& x, const stack& y) { + return x.c < y.c; +} + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template > +#else +template +#endif +class queue { +friend bool operator==(const queue& x, const queue& y); +friend bool operator<(const queue& x, const queue& y); +public: + typedef typename Sequence::value_type value_type; + typedef typename Sequence::size_type size_type; +protected: + Sequence c; +public: + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + value_type& front() { return c.front(); } + const value_type& front() const { return c.front(); } + value_type& back() { return c.back(); } + const value_type& back() const { return c.back(); } + void push(const value_type& x) { c.push_back(x); } + void pop() { c.pop_front(); } +}; + +template +bool operator==(const queue& x, const queue& y) { + return x.c == y.c; +} + +template +bool operator<(const queue& x, const queue& y) { + return x.c < y.c; +} + +#ifndef __STL_LIMITED_DEFAULT_TEMPLATES +template , + class Compare = less > +#else +template +#endif +class priority_queue { +public: + typedef typename Sequence::value_type value_type; + typedef typename Sequence::size_type size_type; +protected: + Sequence c; + Compare comp; +public: + priority_queue() : c() {} + explicit priority_queue(const Compare& x) : c(), comp(x) {} + +#ifdef __STL_MEMBER_TEMPLATES + template + priority_queue(InputIterator first, InputIterator last, const Compare& x) + : c(first, last), comp(x) { make_heap(c.begin(), c.end(), comp); } + template + priority_queue(InputIterator first, InputIterator last) + : c(first, last) { make_heap(c.begin(), c.end(), comp); } +#else /* __STL_MEMBER_TEMPLATES */ + priority_queue(const value_type* first, const value_type* last, + const Compare& x) : c(first, last), comp(x) { + make_heap(c.begin(), c.end(), comp); + } + priority_queue(const value_type* first, const value_type* last) + : c(first, last) { make_heap(c.begin(), c.end(), comp); } +#endif /* __STL_MEMBER_TEMPLATES */ + + bool empty() const { return c.empty(); } + size_type size() const { return c.size(); } + const value_type& top() const { return c.front(); } + void push(const value_type& x) { +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + c.push_back(x); + push_heap(c.begin(), c.end(), comp); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + c.clear(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + void pop() { +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + pop_heap(c.begin(), c.end(), comp); + c.pop_back(); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + c.clear(); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +}; + +// no equality is provided + +#endif diff --git a/libstdc++/stl/stl_config.h b/libstdc++/stl/stl_config.h new file mode 100644 index 000000000000..fa29fdd32539 --- /dev/null +++ b/libstdc++/stl/stl_config.h @@ -0,0 +1,170 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * Copyright (c) 1997 + * Silicon Graphics + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef __STL_CONFIG_H +# define __STL_CONFIG_H + +// What this file does. +// (1) Defines bool, true, and false if the compiler doesn't do so already. +// (2) Defines __STL_NO_DRAND48 if the compiler's standard library does +// not support the drand48() function. +// (3) Defines __STL_STATIC_TEMPLATE_MEMBER_BUG if the compiler can't +// handle static members of template classes. +// (4) Defines 'typename' as a null macro if the compiler does not support +// the typename keyword. +// (5) Defines __STL_CLASS_PARTIAL_SPECIALIZATION if the compiler +// supports partial specialization of template classes. +// (6) Defines __STL_MEMBER_TEMPLATES if the compiler supports +// template members of classes. +// (7) Defines 'explicit' as a null macro if the compiler does not support +// the explicit keyword. +// (8) Defines __STL_LIMITED_DEFAULT_TEMPLATES if the compiler is +// unable to handle default template parameters that depend on +// previous template parameters. +// (9) Defines __STL_NON_TYPE_TMPL_PARAM_BUG if the compiler has +// trouble performing function template argument deduction for +// non-type template parameters. +// (10) Defines __STL_USE_EXCEPTIONS if the compiler (in the current +// compilation mode) supports exceptions. +// (11) Defines __STL_SGI_THREADS if this is being compiled on an SGI +// compiler, and if the user hasn't selected pthreads or no threads +// instead. +// (12) Defines __STL_WIN32THREADS if this is being compiled on a +// WIN32 compiler in multithreaded mode. +// (13) Defines __stl_assert either as a test or as a null macro, +// depending on whether or not __STL_ASSERTIONS is defined. + +# if defined(__sgi) && !defined(__GNUC__) +# if !defined(_BOOL) +# define __STL_NEED_BOOL +# endif +# if !defined(_TYPENAME_IS_KEYWORD) +# define __STL_NEED_TYPENAME +# endif +# ifdef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES +# define __STL_CLASS_PARTIAL_SPECIALIZATION +# endif +# ifdef _MEMBER_TEMPLATES +# define __STL_MEMBER_TEMPLATES +# endif +# if !defined(_EXPLICIT_IS_KEYWORD) +# define __STL_NEED_EXPLICIT +# endif +# ifdef __EXCEPTIONS +# define __STL_USE_EXCEPTIONS +# endif +# if !defined(_NOTHREADS) && !defined(_PTHREADS) +# define __STL_SGI_THREADS +# endif +# endif + +# ifdef __GNUC__ +# if 0 && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)) +# define __STL_STATIC_TEMPLATE_MEMBER_BUG +# define __STL_NEED_TYPENAME +# define __STL_NEED_EXPLICIT +# else +# define __STL_CLASS_PARTIAL_SPECIALIZATION +# endif +# ifdef __EXCEPTIONS +# define __STL_USE_EXCEPTIONS +# endif +# endif + +# if defined(__SUNPRO_CC) +# define __STL_NEED_BOOL +# define __STL_NEED_TYPENAME +# define __STL_NEED_EXPLICIT +# define __STL_USE_EXCEPTIONS +# endif + +# if defined(__COMO__) +# define __STL_MEMBER_TEMPLATES +# define __STL_CLASS_PARTIAL_SPECIALIZATION +# define __STL_USE_EXCEPTIONS +# endif + +# if defined(_MSC_VER) +# if _MSC_VER > 1000 +# include +# else +# define __STL_NEED_BOOL +# endif +# define __STL_NO_DRAND48 +# define __STL_NEED_TYPENAME +# if _MSC_VER < 1100 +# define __STL_NEED_EXPLICIT +# endif +# define __STL_NON_TYPE_TMPL_PARAM_BUG +# ifdef _CPPUNWIND +# define __STL_USE_EXCEPTIONS +# endif +# ifdef _MT +# define __STL_WIN32THREADS +# endif +# endif + +# if defined(__BORLANDC__) +# define __STL_NO_DRAND48 +# define __STL_NEED_TYPENAME +# define __STL_LIMITED_DEFAULT_TEMPLATES +# define __STL_NON_TYPE_TMPL_PARAM_BUG +# ifdef _CPPUNWIND +# define __STL_USE_EXCEPTIONS +# endif +# ifdef __MT__ +# define __STL_WIN32THREADS +# endif +# endif + + +# if defined(__STL_NEED_BOOL) + typedef int bool; +# define true 1 +# define false 0 +# undef __STL_NEED_BOOL +# endif + +# ifdef __STL_NEED_TYPENAME +# define typename +# undef __STL_NEED_TYPENAME +# endif + +# ifdef __STL_NEED_EXPLICIT +# define explicit +# undef __STL_NEED_EXPLICIT +# endif + +#ifdef __STL_ASSERTIONS +# include +# define __stl_assert(expr) \ + if (!(expr)) { fprintf(stderr, "%s:%d STL assertion failure: %s\n", \ + __FILE__, __LINE__, # expr); abort(); } +#else +# define __stl_assert(expr) +#endif + +#endif /* __STL_CONFIG_H */ diff --git a/libstdc++/stl/tempbuf.h b/libstdc++/stl/tempbuf.h new file mode 100644 index 000000000000..18d995252d8a --- /dev/null +++ b/libstdc++/stl/tempbuf.h @@ -0,0 +1,121 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_TEMPBUF_H +#define __SGI_STL_TEMPBUF_H + +#include +#include +#include +#include +#include + +template +pair get_temporary_buffer(ptrdiff_t len, T*) { + if (len > ptrdiff_t(INT_MAX / sizeof(T))) + len = INT_MAX / sizeof(T); + + while (len > 0) { + T* tmp = (T*) malloc((size_t)len * sizeof(T)); + if (tmp != 0) + return pair(tmp, len); + len /= 2; + } + + return pair((T*)0, 0); +} + +template +void return_temporary_buffer(T* p) { + free(p); +} + +template ::value_type */> +class temporary_buffer { +private: + ptrdiff_t original_len; + ptrdiff_t len; + T* buffer; + + void allocate_buffer() { + original_len = len; + buffer = 0; + + if (len > (ptrdiff_t)(INT_MAX / sizeof(T))) + len = INT_MAX / sizeof(T); + + while (len > 0) { + buffer = (T*) malloc(len * sizeof(T)); + if (buffer) + break; + len /= 2; + } + } + + void initialize_buffer(const T&, __true_type) {} + void initialize_buffer(const T& val, __false_type) { + uninitialized_fill_n(buffer, len, val); + } + +public: + ptrdiff_t size() const { return len; } + ptrdiff_t requested_size() const { return original_len; } + T* begin() { return buffer; } + T* end() { return buffer + len; } + + temporary_buffer(ForwardIterator first, ForwardIterator last) { +#ifdef __STL_USE_EXCEPTIONS + try { +#endif + len = 0; + distance(first, last, len); + allocate_buffer(); + if (len > 0) + initialize_buffer(*first, + __type_traits::has_trivial_default_constructor()); +#ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + free(buffer); + buffer = 0; + len = 0; + throw; + } +#endif + } + + ~temporary_buffer() { + destroy(buffer, buffer + len); + free(buffer); + } + +private: + temporary_buffer(const temporary_buffer&) {} + void operator=(const temporary_buffer&) {} +}; + +#endif /* __SGI_STL_TEMPBUF_H */ diff --git a/libstdc++/stl/tree.h b/libstdc++/stl/tree.h new file mode 100644 index 000000000000..0429c1a421df --- /dev/null +++ b/libstdc++/stl/tree.h @@ -0,0 +1,1085 @@ +/* + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + */ + +#ifndef __SGI_STL_TREE_H +#define __SGI_STL_TREE_H + +/* + +Red-black tree class, designed for use in implementing STL +associative containers (set, multiset, map, and multimap). The +insertion and deletion algorithms are based on those in Cormen, +Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990), +except that + +(1) the header cell is maintained with links not only to the root +but also to the leftmost node of the tree, to enable constant time +begin(), and to the rightmost node of the tree, to enable linear time +performance when used with the generic set algorithms (set_union, +etc.); + +(2) when a node being deleted has two children its successor node is +relinked into its place, rather than copied, so that the only +iterators invalidated are those referring to the deleted node. + +*/ + +#include +#include +#include +#include + + +typedef bool __rb_tree_color_type; +const __rb_tree_color_type __rb_tree_red = false; +const __rb_tree_color_type __rb_tree_black = true; + +struct __rb_tree_node_base +{ + typedef __rb_tree_color_type color_type; + typedef __rb_tree_node_base* base_ptr; + + color_type color; + base_ptr parent; + base_ptr left; + base_ptr right; + + static base_ptr minimum(base_ptr x) + { + while (x->left != 0) x = x->left; + return x; + } + + static base_ptr maximum(base_ptr x) + { + while (x->right != 0) x = x->right; + return x; + } +}; + +template +struct __rb_tree_node : public __rb_tree_node_base +{ + typedef __rb_tree_node* link_type; + Value value_field; +}; + + +struct __rb_tree_base_iterator +{ + typedef __rb_tree_node_base::base_ptr base_ptr; + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + base_ptr node; + + void increment() + { + if (node->right != 0) { + node = node->right; + while (node->left != 0) + node = node->left; + } + else { + base_ptr y = node->parent; + while (node == y->right) { + node = y; + y = y->parent; + } + if (node->right != y) + node = y; + } + } + + void decrement() + { + if (node->color == __rb_tree_red && + node->parent->parent == node) + node = node->right; + else if (node->left != 0) { + base_ptr y = node->left; + while (y->right != 0) + y = y->right; + node = y; + } + else { + base_ptr y = node->parent; + while (node == y->left) { + node = y; + y = y->parent; + } + node = y; + } + } +}; + +template +struct __rb_tree_iterator : public __rb_tree_base_iterator +{ + typedef Value value_type; + typedef Value& reference; + typedef const Value& const_reference; + typedef Value* pointer; + typedef __rb_tree_iterator iterator; + typedef __rb_tree_iterator const_iterator; + typedef __rb_tree_iterator self; + typedef __rb_tree_node* link_type; + + __rb_tree_iterator() {} + __rb_tree_iterator(link_type x) { node = x; } + __rb_tree_iterator(const iterator& it) { node = it.node; } + + Ref operator*() const { return link_type(node)->value_field; } + + self& operator++() { increment(); return *this; } + self operator++(int) { + self tmp = *this; + increment(); + return tmp; + } + + self& operator--() { decrement(); return *this; } + self operator--(int) { + self tmp = *this; + decrement(); + return tmp; + } +}; + +inline bool operator==(const __rb_tree_base_iterator& x, + const __rb_tree_base_iterator& y) { + return x.node == y.node; +} + +inline bool operator!=(const __rb_tree_base_iterator& x, + const __rb_tree_base_iterator& y) { + return x.node != y.node; +} + +inline bidirectional_iterator_tag +iterator_category(const __rb_tree_base_iterator&) { + return bidirectional_iterator_tag(); +} + +inline __rb_tree_base_iterator::difference_type* +distance_type(const __rb_tree_base_iterator&) { + return (__rb_tree_base_iterator::difference_type*) 0; +} + +template +inline Value* value_type(const __rb_tree_iterator&) { + return (Value*) 0; +} + +inline void +__rb_tree_rotate_left(__rb_tree_node_base* x, __rb_tree_node_base*& root) +{ + __rb_tree_node_base* y = x->right; + x->right = y->left; + if (y->left !=0) + y->left->parent = x; + y->parent = x->parent; + + if (x == root) + root = y; + else if (x == x->parent->left) + x->parent->left = y; + else + x->parent->right = y; + y->left = x; + x->parent = y; +} + +inline void +__rb_tree_rotate_right(__rb_tree_node_base* x, __rb_tree_node_base*& root) +{ + __rb_tree_node_base* y = x->left; + x->left = y->right; + if (y->right != 0) + y->right->parent = x; + y->parent = x->parent; + + if (x == root) + root = y; + else if (x == x->parent->right) + x->parent->right = y; + else + x->parent->left = y; + y->right = x; + x->parent = y; +} + +inline void +__rb_tree_rebalance(__rb_tree_node_base* x, __rb_tree_node_base*& root) +{ + x->color = __rb_tree_red; + while (x != root && x->parent->color == __rb_tree_red) { + if (x->parent == x->parent->parent->left) { + __rb_tree_node_base* y = x->parent->parent->right; + if (y && y->color == __rb_tree_red) { + x->parent->color = __rb_tree_black; + y->color = __rb_tree_black; + x->parent->parent->color = __rb_tree_red; + x = x->parent->parent; + } + else { + if (x == x->parent->right) { + x = x->parent; + __rb_tree_rotate_left(x, root); + } + x->parent->color = __rb_tree_black; + x->parent->parent->color = __rb_tree_red; + __rb_tree_rotate_right(x->parent->parent, root); + } + } + else { + __rb_tree_node_base* y = x->parent->parent->left; + if (y && y->color == __rb_tree_red) { + x->parent->color = __rb_tree_black; + y->color = __rb_tree_black; + x->parent->parent->color = __rb_tree_red; + x = x->parent->parent; + } + else { + if (x == x->parent->left) { + x = x->parent; + __rb_tree_rotate_right(x, root); + } + x->parent->color = __rb_tree_black; + x->parent->parent->color = __rb_tree_red; + __rb_tree_rotate_left(x->parent->parent, root); + } + } + } + root->color = __rb_tree_black; +} + +inline __rb_tree_node_base* +__rb_tree_rebalance_for_erase(__rb_tree_node_base* z, + __rb_tree_node_base*& root, + __rb_tree_node_base*& leftmost, + __rb_tree_node_base*& rightmost) +{ + __rb_tree_node_base* y = z; + __rb_tree_node_base* x = 0; + __rb_tree_node_base* x_parent = 0; + if (y->left == 0) // z has at most one non-null child. y == z. + x = y->right; // x might be null. + else + if (y->right == 0) // z has exactly one non-null child. y == z. + x = y->left; // x is not null. + else { // z has two non-null children. Set y to + y = y->right; // z's successor. x might be null. + while (y->left != 0) + y = y->left; + x = y->right; + } + if (y != z) { // relink y in place of z. y is z's successor + z->left->parent = y; + y->left = z->left; + if (y != z->right) { + x_parent = y->parent; + if (x) x->parent = y->parent; + y->parent->left = x; // y must be a left child + y->right = z->right; + z->right->parent = y; + } + else + x_parent = y; + if (root == z) + root = y; + else if (z->parent->left == z) + z->parent->left = y; + else + z->parent->right = y; + y->parent = z->parent; + ::swap(y->color, z->color); + y = z; + // y now points to node to be actually deleted + } + else { // y == z + x_parent = y->parent; + if (x) x->parent = y->parent; + if (root == z) + root = x; + else + if (z->parent->left == z) + z->parent->left = x; + else + z->parent->right = x; + if (leftmost == z) + if (z->right == 0) // z->left must be null also + leftmost = z->parent; + // makes leftmost == header if z == root + else + leftmost = __rb_tree_node_base::minimum(x); + if (rightmost == z) + if (z->left == 0) // z->right must be null also + rightmost = z->parent; + // makes rightmost == header if z == root + else // x == z->left + rightmost = __rb_tree_node_base::maximum(x); + } + if (y->color != __rb_tree_red) { + while (x != root && (x == 0 || x->color == __rb_tree_black)) + if (x == x_parent->left) { + __rb_tree_node_base* w = x_parent->right; + if (w->color == __rb_tree_red) { + w->color = __rb_tree_black; + x_parent->color = __rb_tree_red; + __rb_tree_rotate_left(x_parent, root); + w = x_parent->right; + } + if ((w->left == 0 || w->left->color == __rb_tree_black) && + (w->right == 0 || w->right->color == __rb_tree_black)) { + w->color = __rb_tree_red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->right == 0 || w->right->color == __rb_tree_black) { + if (w->left) w->left->color = __rb_tree_black; + w->color = __rb_tree_red; + __rb_tree_rotate_right(w, root); + w = x_parent->right; + } + w->color = x_parent->color; + x_parent->color = __rb_tree_black; + if (w->right) w->right->color = __rb_tree_black; + __rb_tree_rotate_left(x_parent, root); + break; + } + } else { // same as above, with right <-> left. + __rb_tree_node_base* w = x_parent->left; + if (w->color == __rb_tree_red) { + w->color = __rb_tree_black; + x_parent->color = __rb_tree_red; + __rb_tree_rotate_right(x_parent, root); + w = x_parent->left; + } + if ((w->right == 0 || w->right->color == __rb_tree_black) && + (w->left == 0 || w->left->color == __rb_tree_black)) { + w->color = __rb_tree_red; + x = x_parent; + x_parent = x_parent->parent; + } else { + if (w->left == 0 || w->left->color == __rb_tree_black) { + if (w->right) w->right->color = __rb_tree_black; + w->color = __rb_tree_red; + __rb_tree_rotate_left(w, root); + w = x_parent->left; + } + w->color = x_parent->color; + x_parent->color = __rb_tree_black; + if (w->left) w->left->color = __rb_tree_black; + __rb_tree_rotate_right(x_parent, root); + break; + } + } + if (x) x->color = __rb_tree_black; + } + return y; +} + +template +class rb_tree { +protected: + typedef void* void_pointer; + typedef __rb_tree_node_base* base_ptr; + typedef __rb_tree_node rb_tree_node; + typedef simple_alloc rb_tree_node_allocator; + typedef __rb_tree_color_type color_type; +public: + typedef Key key_type; + typedef Value value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef rb_tree_node* link_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; +protected: + link_type get_node() { return rb_tree_node_allocator::allocate(); } + void put_node(link_type p) { rb_tree_node_allocator::deallocate(p); } + + link_type create_node(const value_type& x) { + link_type tmp = get_node(); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + construct(&tmp->value_field, x); + return tmp; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + put_node(tmp); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + + link_type clone_node(link_type x) { + link_type tmp = create_node(x->value_field); + tmp->color = x->color; + tmp->left = 0; + tmp->right = 0; + return tmp; + } + + void destroy_node(link_type p) { + destroy(&p->value_field); + put_node(p); + } + +protected: + size_type node_count; // keeps track of size of tree + link_type header; + Compare key_compare; + + link_type& root() const { return (link_type&) header->parent; } + link_type& leftmost() const { return (link_type&) header->left; } + link_type& rightmost() const { return (link_type&) header->right; } + + static link_type& left(link_type x) { return (link_type&)(x->left); } + static link_type& right(link_type x) { return (link_type&)(x->right); } + static link_type& parent(link_type x) { return (link_type&)(x->parent); } + static reference value(link_type x) { return x->value_field; } + static const Key& key(link_type x) { return KeyOfValue()(value(x)); } + static color_type& color(link_type x) { return (color_type&)(x->color); } + + static link_type& left(base_ptr x) { return (link_type&)(x->left); } + static link_type& right(base_ptr x) { return (link_type&)(x->right); } + static link_type& parent(base_ptr x) { return (link_type&)(x->parent); } + static reference value(base_ptr x) { return ((link_type)x)->value_field; } + static const Key& key(base_ptr x) { return KeyOfValue()(value(link_type(x)));} + static color_type& color(base_ptr x) { return (color_type&)(link_type(x)->color); } + + static link_type minimum(link_type x) { + return (link_type) __rb_tree_node_base::minimum(x); + } + static link_type maximum(link_type x) { + return (link_type) __rb_tree_node_base::maximum(x); + } + +public: + typedef __rb_tree_iterator iterator; + typedef __rb_tree_iterator const_iterator; + + typedef reverse_bidirectional_iterator + reverse_iterator; + typedef reverse_bidirectional_iterator + const_reverse_iterator; +private: + iterator __insert(base_ptr x, base_ptr y, const value_type& v); + link_type __copy(link_type x, link_type p); + void __erase(link_type x); + void init() { + header = get_node(); + color(header) = __rb_tree_red; // used to distinguish header from + // root, in iterator.operator++ + root() = 0; + leftmost() = header; + rightmost() = header; + } +public: + // allocation/deallocation + rb_tree(const Compare& comp = Compare()) + : key_compare(comp), node_count(0) { init(); } + + rb_tree(const rb_tree& x) + : key_compare(x.key_compare), node_count(0) { + header = get_node(); + color(header) = __rb_tree_red; + if (x.root() == 0) { + root() = 0; + leftmost() = header; + rightmost() = header; + } + else { +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + root() = __copy(x.root(), header); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + put_node(header); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + leftmost() = minimum(root()); + rightmost() = maximum(root()); + } + node_count = x.node_count; + } + ~rb_tree() { + clear(); + put_node(header); + } + rb_tree& + operator=(const rb_tree& x); + +public: + // accessors: + Compare key_comp() const { return key_compare; } + iterator begin() { return leftmost(); } + const_iterator begin() const { return leftmost(); } + iterator end() { return header; } + const_iterator end() const { return header; } + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + bool empty() const { return node_count == 0; } + size_type size() const { return node_count; } + size_type max_size() const { return size_type(-1); } + + void swap(rb_tree& t) { + ::swap(header, t.header); + ::swap(node_count, t.node_count); + ::swap(key_compare, t.key_compare); + } + +public: + // insert/erase + pair insert_unique(const value_type& x); + iterator insert_equal(const value_type& x); + + iterator insert_unique(iterator position, const value_type& x); + iterator insert_equal(iterator position, const value_type& x); + +#ifdef __STL_MEMBER_TEMPLATES + template + void insert_unique(InputIterator first, InputIterator last); + template + void insert_equal(InputIterator first, InputIterator last); +#else /* __STL_MEMBER_TEMPLATES */ + void insert_unique(const_iterator first, const_iterator last); + void insert_unique(const value_type* first, const value_type* last); + void insert_equal(const_iterator first, const_iterator last); + void insert_equal(const value_type* first, const value_type* last); +#endif /* __STL_MEMBER_TEMPLATES */ + + void erase(iterator position); + size_type erase(const key_type& x); + void erase(iterator first, iterator last); + void erase(const key_type* first, const key_type* last); + void clear() { + if (node_count != 0) { + __erase(root()); + leftmost() = header; + root() = 0; + rightmost() = header; + node_count = 0; + } + } + +public: + // set operations: + iterator find(const key_type& x); + const_iterator find(const key_type& x) const; + size_type count(const key_type& x) const; + iterator lower_bound(const key_type& x); + const_iterator lower_bound(const key_type& x) const; + iterator upper_bound(const key_type& x); + const_iterator upper_bound(const key_type& x) const; + pair equal_range(const key_type& x); + pair equal_range(const key_type& x) const; + +public: + // Debugging. + bool __rb_verify() const; +}; + +template +inline bool operator==(const rb_tree& x, + const rb_tree& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +inline bool operator<(const rb_tree& x, + const rb_tree& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + +template +rb_tree& +rb_tree:: +operator=(const rb_tree& x) { + if (this != &x) { + // Note that Key may be a constant type. + clear(); + node_count = 0; + key_compare = x.key_compare; + if (x.root() == 0) { + root() = 0; + leftmost() = header; + rightmost() = header; + } + else { + root() = __copy(x.root(), header); + leftmost() = minimum(root()); + rightmost() = maximum(root()); + node_count = x.node_count; + } + } + return *this; +} + +template +rb_tree::iterator +rb_tree:: +__insert(base_ptr x_, base_ptr y_, const Value& v) { + link_type x = (link_type) x_; + link_type y = (link_type) y_; + link_type z; + + if (y == header || x != 0 || key_compare(KeyOfValue()(v), key(y))) { + z = create_node(v); + left(y) = z; // also makes leftmost() = z when y == header + if (y == header) { + root() = z; + rightmost() = z; + } + else if (y == leftmost()) + leftmost() = z; // maintain leftmost() pointing to min node + } + else { + z = create_node(v); + right(y) = z; + if (y == rightmost()) + rightmost() = z; // maintain rightmost() pointing to max node + } + parent(z) = y; + left(z) = 0; + right(z) = 0; + __rb_tree_rebalance(z, header->parent); + ++node_count; + return iterator(z); +} + +template +rb_tree::iterator +rb_tree::insert_equal(const Value& v) +{ + link_type y = header; + link_type x = root(); + while (x != 0) { + y = x; + x = key_compare(KeyOfValue()(v), key(x)) ? left(x) : right(x); + } + return __insert(x, y, v); +} + + +template +pair::iterator, bool> +rb_tree::insert_unique(const Value& v) +{ + link_type y = header; + link_type x = root(); + bool comp = true; + while (x != 0) { + y = x; + comp = key_compare(KeyOfValue()(v), key(x)); + x = comp ? left(x) : right(x); + } + iterator j = iterator(y); + if (comp) + if (j == begin()) + return pair(__insert(x, y, v), true); + else + --j; + if (key_compare(key(j.node), KeyOfValue()(v))) + return pair(__insert(x, y, v), true); + return pair(j, false); +} + + +template +rb_tree::iterator +rb_tree::insert_unique(iterator position, + const Val& v) { + if (position.node == header->left) // begin() + if (size() > 0 && key_compare(KeyOfValue()(v), key(position.node))) + return __insert(position.node, position.node, v); + // first argument just needs to be non-null + else + return insert_unique(v).first; + else if (position.node == header) // end() + if (key_compare(key(rightmost()), KeyOfValue()(v))) + return __insert(0, rightmost(), v); + else + return insert_unique(v).first; + else { + iterator before = position; + --before; + if (key_compare(key(before.node), KeyOfValue()(v)) + && key_compare(KeyOfValue()(v), key(position.node))) + if (right(before.node) == 0) + return __insert(0, before.node, v); + else + return __insert(position.node, position.node, v); + // first argument just needs to be non-null + else + return insert_unique(v).first; + } +} + +template +rb_tree::iterator +rb_tree::insert_equal(iterator position, + const Val& v) { + if (position.node == header->left) // begin() + if (size() > 0 && key_compare(KeyOfValue()(v), key(position.node))) + return __insert(position.node, position.node, v); + // first argument just needs to be non-null + else + return insert_equal(v); + else if (position.node == header) // end() + if (!key_compare(KeyOfValue()(v), key(rightmost()))) + return __insert(0, rightmost(), v); + else + return insert_equal(v); + else { + iterator before = position; + --before; + if (!key_compare(KeyOfValue()(v), key(before.node)) + && !key_compare(key(position.node), KeyOfValue()(v))) + if (right(before.node) == 0) + return __insert(0, before.node, v); + else + return __insert(position.node, position.node, v); + // first argument just needs to be non-null + else + return insert_equal(v); + } +} + +#ifdef __STL_MEMBER_TEMPLATES + +template template +void rb_tree::insert_equal(II first, II last) { + for ( ; first != last; ++first) + insert_equal(*first); +} + +template template +void rb_tree::insert_unique(II first, II last) { + for ( ; first != last; ++first) + insert_unique(*first); +} + +#else /* __STL_MEMBER_TEMPLATES */ + +template +void +rb_tree::insert_equal(const V* first, const V* last) { + for ( ; first != last; ++first) + insert_equal(*first); +} + +template +void +rb_tree::insert_equal(const_iterator first, + const_iterator last) { + for ( ; first != last; ++first) + insert_equal(*first); +} + +template +void +rb_tree::insert_unique(const V* first, const V* last) { + for ( ; first != last; ++first) + insert_unique(*first); +} + +template +void +rb_tree::insert_unique(const_iterator first, + const_iterator last) { + for ( ; first != last; ++first) + insert_unique(*first); +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +template +inline void +rb_tree::erase(iterator position) { + link_type y = (link_type) __rb_tree_rebalance_for_erase(position.node, + header->parent, + header->left, + header->right); + destroy_node(y); + --node_count; +} + +template +rb_tree::size_type +rb_tree::erase(const Key& x) { + pair p = equal_range(x); + size_type n = 0; + distance(p.first, p.second, n); + erase(p.first, p.second); + return n; +} + +template +rb_tree::link_type +rb_tree::__copy(link_type x, link_type p) { + // structural copy. x and p must be non-null. + link_type top = clone_node(x); + top->parent = p; + +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + if (x->right) + top->right = __copy(right(x), top); + p = top; + x = left(x); + + while (x != 0) { + link_type y = clone_node(x); + p->left = y; + y->parent = p; + if (x->right) + y->right = __copy(right(x), y); + p = y; + x = left(x); + } +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + __erase(top); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + + return top; +} + +template +void rb_tree::__erase(link_type x) { + // erase without rebalancing + while (x != 0) { + __erase(right(x)); + link_type y = left(x); + destroy_node(x); + x = y; + } +} + +template +void rb_tree::erase(iterator first, + iterator last) { + if (first == begin() && last == end()) + clear(); + else + while (first != last) erase(first++); +} + +template +void rb_tree::erase(const Key* first, + const Key* last) { + while (first != last) erase(*first++); +} + +template +rb_tree::iterator +rb_tree::find(const Key& k) { + link_type y = header; // Last node which is not less than k. + link_type x = root(); // Current node. + + while (x != 0) + if (!key_compare(key(x), k)) + y = x, x = left(x); + else + x = right(x); + + iterator j = iterator(y); + return (j == end() || key_compare(k, key(j.node))) ? end() : j; +} + +template +rb_tree::const_iterator +rb_tree::find(const Key& k) const { + link_type y = header; /* Last node which is not less than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) { + if (!key_compare(key(x), k)) + y = x, x = left(x); + else + x = right(x); + } + const_iterator j = const_iterator(y); + return (j == end() || key_compare(k, key(j.node))) ? end() : j; +} + +template +rb_tree::size_type +rb_tree::count(const Key& k) const { + pair p = equal_range(k); + size_type n = 0; + distance(p.first, p.second, n); + return n; +} + +template +rb_tree::iterator +rb_tree::lower_bound(const Key& k) { + link_type y = header; /* Last node which is not less than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + if (!key_compare(key(x), k)) + y = x, x = left(x); + else + x = right(x); + + return iterator(y); +} + +template +rb_tree::const_iterator +rb_tree::lower_bound(const Key& k) const { + link_type y = header; /* Last node which is not less than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + if (!key_compare(key(x), k)) + y = x, x = left(x); + else + x = right(x); + + return const_iterator(y); +} + +template +rb_tree::iterator +rb_tree::upper_bound(const Key& k) { + link_type y = header; /* Last node which is greater than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + if (key_compare(k, key(x))) + y = x, x = left(x); + else + x = right(x); + + return iterator(y); +} + +template +rb_tree::const_iterator +rb_tree::upper_bound(const Key& k) const { + link_type y = header; /* Last node which is greater than k. */ + link_type x = root(); /* Current node. */ + + while (x != 0) + if (key_compare(k, key(x))) + y = x, x = left(x); + else + x = right(x); + + return const_iterator(y); +} + +template +inline pair::iterator, + rb_tree::iterator> +rb_tree::equal_range(const Key& k) { + return pair(lower_bound(k), upper_bound(k)); +} + +template +inline pair::const_iterator, + rb_tree::const_iterator> +rb_tree::equal_range(const Key& k) const { + return pair(lower_bound(k), upper_bound(k)); +} + +inline int __black_count(__rb_tree_node_base* node, __rb_tree_node_base* root) +{ + if (node == 0) + return 0; + else { + int bc = node->color == __rb_tree_black ? 1 : 0; + if (node == root) + return bc; + else + return bc + __black_count(node->parent, root); + } +} + +template +bool +rb_tree::__rb_verify() const +{ + if (node_count == 0 || begin() == end()) + return node_count == 0 && begin() == end() && + header->left == header && header->right == header; + + int len = __black_count(leftmost(), root()); + for (const_iterator it = begin(); it != end(); ++it) { + link_type x = (link_type) it.node; + link_type L = left(x); + link_type R = right(x); + + if (x->color == __rb_tree_red) + if ((L && L->color == __rb_tree_red) || + (R && R->color == __rb_tree_red)) + return false; + + if (L && key_compare(key(x), key(L))) + return false; + if (R && key_compare(key(R), key(x))) + return false; + + if (!L && !R && __black_count(x, root()) != len) + return false; + } + + if (leftmost() != __rb_tree_node_base::minimum(root())) + return false; + if (rightmost() != __rb_tree_node_base::maximum(root())) + return false; + + return true; +} + +#endif /* __SGI_STL_TREE_H */ diff --git a/libstdc++/stl/type_traits.h b/libstdc++/stl/type_traits.h new file mode 100644 index 000000000000..6ca0137709dc --- /dev/null +++ b/libstdc++/stl/type_traits.h @@ -0,0 +1,227 @@ +/* + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __TYPE_TRAITS_H +#define __TYPE_TRAITS_H + +#include + +/* +This header file provides a framework for allowing compile time dispatch +based on type attributes. This is useful when writing template code. +For example, when making a copy of an array of an unknown type, it helps +to know if the type has a trivial copy constructor or not, to help decide +if a memcpy can be used. + +The class template __type_traits provides a series of typedefs each of +which is either __true_type or __false_type. The argument to +__type_traits can be any type. The typedefs within this template will +attain their correct values by one of these means: + 1. The general instantiation contain conservative values which work + for all types. + 2. Specializations may be declared to make distinctions between types. + 3. Some compilers (such as the Silicon Graphics N32 and N64 compilers) + will automatically provide the appropriate specializations for all + types. + +EXAMPLE: + +//Copy an array of elements which have non-trivial copy constructors +template void copy(T* source,T* destination,int n,__false_type); +//Copy an array of elements which have trivial copy constructors. Use memcpy. +template void copy(T* source,T* destination,int n,__true_type); + +//Copy an array of any type by using the most efficient copy mechanism +template inline void copy(T* source,T* destination,int n) { + copy(source,destination,n,__type_traits::has_trivial_copy_constructor()); +} +*/ + + +struct __true_type { +}; + +struct __false_type { +}; + +template +struct __type_traits { + typedef __true_type this_dummy_member_must_be_first; + /* Do not remove this member. It informs a compiler which + automatically specializes __type_traits that this + __type_traits template is special. It just makes sure that + things work if an implementation is using a template + called __type_traits for something unrelated. */ + + /* The following restrictions should be observed for the sake of + compilers which automatically produce type specific specializations + of this class: + - You may reorder the members below if you wish + - You may remove any of the members below if you wish + - You must not rename members without making the corresponding + name change in the compiler + - Members you add will be treated like regular members unless + you add the appropriate support in the compiler. */ + + + typedef __false_type has_trivial_default_constructor; + typedef __false_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __false_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; + + + +// Provide some specializations. This is harmless for compilers that +// have built-in __types_traits support, and essential for compilers +// that don't. + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION + +template +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +struct __type_traits { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ + + +#endif /* __TYPE_TRAITS_H */ diff --git a/libstdc++/stl/vector.h b/libstdc++/stl/vector.h new file mode 100644 index 000000000000..bb6a404766ba --- /dev/null +++ b/libstdc++/stl/vector.h @@ -0,0 +1,544 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * 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. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * 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. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +#ifndef __SGI_STL_VECTOR_H +#define __SGI_STL_VECTOR_H + +#include +#include +#include + +template +class vector { +public: + typedef T value_type; + typedef value_type* pointer; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef reverse_iterator const_reverse_iterator; + typedef reverse_iterator + reverse_iterator; +protected: + typedef simple_alloc data_allocator; + iterator start; + iterator finish; + iterator end_of_storage; + void insert_aux(iterator position, const T& x); + void deallocate() { + if (start) data_allocator::deallocate(start, end_of_storage - start); + } +public: + iterator begin() { return start; } + const_iterator begin() const { return start; } + iterator end() { return finish; } + const_iterator end() const { return finish; } + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + size_type size() const { return size_type(end() - begin()); } + size_type max_size() const { return size_type(-1); } + size_type capacity() const { return size_type(end_of_storage - begin()); } + bool empty() const { return begin() == end(); } + reference operator[](size_type n) { return *(begin() + n); } + const_reference operator[](size_type n) const { return *(begin() + n); } + vector() : start(0), finish(0), end_of_storage(0) {} + vector(size_type n, const T& value) { + start = allocate_and_fill(n, value); + finish = start + n; + end_of_storage = finish; + } + explicit vector(size_type n) { + start = allocate_and_fill(n, T()); + finish = start + n; + end_of_storage = finish; + } + vector(const vector& x) { + start = allocate_and_copy(x.end() - x.begin(), x.begin(), x.end()); + finish = start + (x.end() - x.begin()); + end_of_storage = finish; + } +#ifdef __STL_MEMBER_TEMPLATES + template + vector(InputIterator first, InputIterator last) : + start(0), finish(0), end_of_storage(0) { + range_initialize(first, last, iterator_category(first)); + } +#else /* __STL_MEMBER_TEMPLATES */ + vector(const_iterator first, const_iterator last) { + size_type n = 0; + distance(first, last, n); + start = allocate_and_copy(n, first, last); + finish = start + n; + end_of_storage = finish; + } +#endif /* __STL_MEMBER_TEMPLATES */ + ~vector() { + destroy(start, finish); + deallocate(); + } + vector& operator=(const vector& x); + void reserve(size_type n) { + if (capacity() < n) { + const size_type old_size = size(); + const iterator tmp = allocate_and_copy(n, start, finish); + destroy(start, finish); + deallocate(); + start = tmp; + finish = tmp + old_size; + end_of_storage = start + n; + } + } + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(end() - 1); } + const_reference back() const { return *(end() - 1); } + void push_back(const T& x) { + if (finish != end_of_storage) { + construct(finish, x); + ++finish; + } else + insert_aux(end(), x); + } + void swap(vector& x) { + ::swap(start, x.start); + ::swap(finish, x.finish); + ::swap(end_of_storage, x.end_of_storage); + } + iterator insert(iterator position, const T& x) { + size_type n = position - begin(); + if (finish != end_of_storage && position == end()) { + construct(finish, x); + ++finish; + } else + insert_aux(position, x); + return begin() + n; + } + iterator insert(iterator position) { return insert(position, T()); } +#ifdef __STL_MEMBER_TEMPLATES + template + void insert(iterator position, InputIterator first, InputIterator last) { + range_insert(position, first, last, iterator_category(first)); + } +#else /* __STL_MEMBER_TEMPLATES */ + void insert(iterator position, + const_iterator first, const_iterator last); +#endif /* __STL_MEMBER_TEMPLATES */ + void insert (iterator position, size_type n, const T& x); + void pop_back() { + --finish; + destroy(finish); + } + void erase(iterator position) { + if (position + 1 != end()) + copy(position + 1, finish, position); + --finish; + destroy(finish); + } + void erase(iterator first, iterator last) { + iterator i = copy(last, finish, first); + destroy(i, finish); + finish = finish - (last - first); + } + void resize(size_type new_size, const T& x) { + if (new_size < size()) + erase(begin() + new_size, end()); + else + insert(end(), new_size - size(), x); + } + void resize(size_type new_size) { resize(new_size, T()); } + void clear() { erase(begin(), end()); } + +protected: + iterator allocate_and_fill(size_type n, const T& x) { + iterator result = data_allocator::allocate(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_fill_n(result, n, x); + return result; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + data_allocator::deallocate(result, n); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } + +#ifdef __STL_MEMBER_TEMPLATES + template + iterator allocate_and_copy(size_type n, + ForwardIterator first, ForwardIterator last) { + iterator result = data_allocator::allocate(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_copy(first, last, result); + return result; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + data_allocator::deallocate(result, n); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +#else /* __STL_MEMBER_TEMPLATES */ + iterator allocate_and_copy(size_type n, + const_iterator first, const_iterator last) { + iterator result = data_allocator::allocate(n); +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + uninitialized_copy(first, last, result); + return result; +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + data_allocator::deallocate(result, n); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + } +#endif /* __STL_MEMBER_TEMPLATES */ + + +#ifdef __STL_MEMBER_TEMPLATES + template + void range_initialize(InputIterator first, InputIterator last, + input_iterator_tag) { + for ( ; first != last; ++first) + push_back(*first); + } + + // This function is only called by the constructor. We have to worry + // about resource leaks, but not about maintaining invariants. + template + void range_initialize(ForwardIterator first, ForwardIterator last, + forward_iterator_tag) { + size_type n = 0; + distance(first, last, n); + start = allocate_and_copy(n, first, last); + finish = start + n; + end_of_storage = finish; + } + + template + void range_initialize(BidirectionalIterator first, + BidirectionalIterator last, + bidirectional_iterator_tag) { + range_initialize(first, last, forward_iterator_tag()); + } + + template + void range_initialize(RandomAccessIterator first, + RandomAccessIterator last, + random_access_iterator_tag) { + range_initialize(first, last, forward_iterator_tag()); + } + + template + void range_insert(iterator pos, + InputIterator first, InputIterator last, + input_iterator_tag); + + template + void range_insert(iterator pos, + ForwardIterator first, ForwardIterator last, + forward_iterator_tag); + + template + void range_insert(iterator pos, + BidirectionalIterator first, BidirectionalIterator last, + bidirectional_iterator_tag) { + range_insert(pos, first, last, forward_iterator_tag()); + } + + template + void range_insert(iterator pos, + RandomAccessIterator first, RandomAccessIterator last, + random_access_iterator_tag) { + range_insert(pos, first, last, forward_iterator_tag()); + } +#endif /* __STL_MEMBER_TEMPLATES */ +}; + +template +inline bool operator==(const vector& x, const vector& y) { + return x.size() == y.size() && equal(x.begin(), x.end(), y.begin()); +} + +template +inline bool operator<(const vector& x, const vector& y) { + return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); +} + + + +template +vector& vector::operator=(const vector& x) { + if (&x != this) { + if (x.size() > capacity()) { + const iterator tmp = allocate_and_copy(x.end() - x.begin(), + x.begin(), x.end()); + destroy(start, finish); + deallocate(); + start = tmp; + end_of_storage = start + (x.end() - x.begin()); + } + else if (size() >= x.size()) { + iterator i = copy(x.begin(), x.end(), begin()); + destroy(i, finish); + } + else { + copy(x.begin(), x.begin() + size(), start); + uninitialized_copy(x.begin() + size(), x.end(), finish); + } + finish = start + x.size(); + } + return *this; +} + +template +void vector::insert_aux(iterator position, const T& x) { + if (finish != end_of_storage) { + construct(finish, *(finish - 1)); + ++finish; + T x_copy = x; + copy_backward(position, finish - 2, finish - 1); + *position = x_copy; + } + else { + const size_type old_size = size(); + const size_type len = old_size != 0 ? 2 * old_size : 1; + const iterator new_start = data_allocator::allocate(len); + iterator new_finish = new_start; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + new_finish = uninitialized_copy(start, position, new_start); + construct(new_finish, x); + ++new_finish; + new_finish = uninitialized_copy(position, finish, new_finish); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(new_start, new_finish); + data_allocator::deallocate(new_start, len); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + destroy(begin(), end()); + deallocate(); + start = new_start; + finish = new_finish; + end_of_storage = new_start + len; + } +} + +template +void vector::insert(iterator position, size_type n, const T& x) { + if (n != 0) { + if (size_type (end_of_storage - finish) >= n) { + T x_copy = x; + const size_type elems_after = finish - position; + const iterator old_finish = finish; + if (elems_after > n) { + uninitialized_copy(finish - n, finish, finish); + finish += n; + copy_backward(position, old_finish - n, old_finish); + fill(position, position + n, x_copy); + } + else { + uninitialized_fill_n(finish, n - elems_after, x_copy); + finish += n - elems_after; + uninitialized_copy(position, old_finish, finish); + finish += elems_after; + fill(position, old_finish, x_copy); + } + } + else { + const size_type old_size = size(); + const size_type len = old_size + max(old_size, n); + const iterator new_start = data_allocator::allocate(len); + iterator new_finish = new_start; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + new_finish = uninitialized_copy(start, position, new_start); + new_finish = uninitialized_fill_n(new_finish, n, x); + new_finish = uninitialized_copy(position, finish, new_finish); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(new_start, new_finish); + data_allocator::deallocate(new_start, len); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + destroy(start, finish); + deallocate(); + start = new_start; + finish = new_finish; + end_of_storage = new_start + len; + } + } +} + +#ifdef __STL_MEMBER_TEMPLATES + +template template +void vector::range_insert(iterator pos, + InputIterator first, InputIterator last, + input_iterator_tag) { + for ( ; first != last; ++first) { + pos = insert(pos, *first); + ++pos; + } +} + +template template +void vector::range_insert(iterator position, + ForwardIterator first, + ForwardIterator last, + forward_iterator_tag) { + if (first != last) { + size_type n = 0; + distance(first, last, n); + if (size_type (end_of_storage - finish) >= n) { + const size_type elems_after = finish - position; + const iterator old_finish = finish; + if (elems_after > n) { + uninitialized_copy(finish - n, finish, finish); + finish += n; + copy_backward(position, old_finish - n, old_finish); + copy(first, last, position); + } + else { + ForwardIterator mid = first; + advance(mid, elems_after); + uninitialized_copy(mid, last, finish); + finish += n - elems_after; + uninitialized_copy(position, old_finish, finish); + finish += elems_after; + copy(first, mid, position); + } + } + else { + const size_type old_size = size(); + const size_type len = old_size + max(old_size, n); + const iterator new_start = data_allocator::allocate(len); + iterator new_finish = new_start; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + new_finish = uninitialized_copy(start, position, new_start); + new_finish = uninitialized_copy(first, last, new_finish); + new_finish = uninitialized_copy(position, finish, new_finish); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(new_start, new_finish); + data_allocator::deallocate(new_start, len); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + destroy(start, finish); + deallocate(); + start = new_start; + finish = new_finish; + end_of_storage = new_start + len; + } + } +} + +#else /* __STL_MEMBER_TEMPLATES */ + +template +void vector::insert(iterator position, + const_iterator first, + const_iterator last) { + if (first != last) { + size_type n = 0; + distance(first, last, n); + if (end_of_storage - finish >= n) { + const size_type elems_after = finish - position; + const iterator old_finish = finish; + if (elems_after > n) { + uninitialized_copy(finish - n, finish, finish); + finish += n; + copy_backward(position, old_finish - n, old_finish); + copy(first, last, position); + } + else { + uninitialized_copy(first + elems_after, last, finish); + finish += n - elems_after; + uninitialized_copy(position, old_finish, finish); + finish += elems_after; + copy(first, first + elems_after, position); + } + } + else { + const size_type old_size = size(); + const size_type len = old_size + max(old_size, n); + const iterator new_start = data_allocator::allocate(len); + iterator new_finish = new_start; +# ifdef __STL_USE_EXCEPTIONS + try { +# endif /* __STL_USE_EXCEPTIONS */ + new_finish = uninitialized_copy(start, position, new_start); + new_finish = uninitialized_copy(first, last, new_finish); + new_finish = uninitialized_copy(position, finish, new_finish); +# ifdef __STL_USE_EXCEPTIONS + } + catch(...) { + destroy(new_start, new_finish); + data_allocator::deallocate(new_start, len); + throw; + } +# endif /* __STL_USE_EXCEPTIONS */ + destroy(start, finish); + deallocate(); + start = new_start; + finish = new_finish; + end_of_storage = new_start + len; + } + } +} + +#endif /* __STL_MEMBER_TEMPLATES */ + +#endif /* __SGI_STL_VECTOR_H */ diff --git a/libstdc++/stlinst.cc b/libstdc++/stlinst.cc new file mode 100644 index 000000000000..dc55ce322747 --- /dev/null +++ b/libstdc++/stlinst.cc @@ -0,0 +1,8 @@ +// Instantiation file for the -*- C++ -*- Standard Library allocator templates +// This file is part of the GNU ANSI C++ Library. + +#include + +template class __default_alloc_template; + +template class __malloc_alloc_template<0>; diff --git a/libstdc++/string b/libstdc++/string new file mode 100644 index 000000000000..fa6f1abaa70c --- /dev/null +++ b/libstdc++/string @@ -0,0 +1,13 @@ +// Main header for the -*- C++ -*- string classes. + +#ifndef __STRING__ +#define __STRING__ + +#include + +extern "C++" { +typedef basic_string string; +// typedef basic_string wstring; +} // extern "C++" + +#endif diff --git a/libstdc++/tests/ChangeLog b/libstdc++/tests/ChangeLog new file mode 100644 index 000000000000..7f884a126e54 --- /dev/null +++ b/libstdc++/tests/ChangeLog @@ -0,0 +1,87 @@ +Wed Jun 11 11:00:10 1997 Jason Merrill + + * tmap.cc: Explicitly instantiate allocator classes. + * tvector.cc, tlist.cc: Likewise. + +Fri May 16 18:38:05 1997 Bob Manson + + * tcomplex.cc (main): If we're using short doubles, compensate for + roundoff in result of pow(a,b). + +Thu May 1 17:37:53 1997 Jason Merrill + + * configure.in (CHECK): Add $(CXXFLAGS). + * Makefile.in (tcomplex): Add $(CXXFLAGS). + +Fri Apr 25 16:07:46 1997 Bob Manson + + * configure.in: Change "check" to "check-old". Add do-nothing + check target. + +Sun Nov 3 12:44:48 1996 Jason Merrill + + * tstring.cc: Treat string literals as const. + +Tue Sep 24 18:00:20 1996 Jason Merrill + + * tstring.cc, tcomplex.cc: Remove gratuitous uses of std/. + +Mon Jun 17 14:05:50 1996 Per Bothner + + * tlist.cc (test_splice): New test. + +Fri Mar 22 16:08:36 1996 Jason Merrill + + * Makefile.in (VERSION): 2.8.0. + + * tlist.cc, tmap.cc, tvector.cc: Remove explicit instantiation + directive. + +Sat Nov 18 19:52:26 1995 Mike Stump + + * Makefile.in: Update version to 2.7.1. + +Tue May 9 19:36:54 1995 Jason Merrill + + * tstring.cc (decltest): Adjust single-character test. + +Fri May 5 14:35:19 1995 Jason Merrill + + * tcomplex.*: Update to reflect that operator<< now + accepts more forms of input. + +Thu Apr 27 15:34:58 1995 Brendan Kehoe (brendan@lisa.cygnus.com) + + * configure.in: Update to stay in sync with config.shared. + +Thu Feb 16 00:08:28 1995 Jason Merrill + + * Makefile.in (VERSION, SHLIB): Define. + +Tue Jan 24 02:36:24 1995 Jason Merrill + + * Makefile.in (CXXFLAGS): Don't set. + +Mon Jan 23 04:12:10 1995 Jason Merrill + + * tlist.cc (plus): Remove. + +Thu Jan 19 19:41:07 1995 Jason Merrill + + * Makefile.in: Don't set LD_LIBRARY_PATH. Users will have to set + it themselves. + +Mon Jan 16 13:57:34 1995 Jason Merrill + + * Makefile.in: Update to reflect header movement. + +Wed Dec 14 19:55:45 1994 Per Bothner + + * configure.in: Fix quoting problem. Reported nu H.J.Lu. + +Tue Nov 29 16:46:56 1994 Per Bothner + + * Makefile.in, configure.in: Re-write to avoid duplication. + * {tvector,tmap,tlist}.{cc,exp}, configure.in: New tests for STL. + + diff --git a/libstdc++/tests/Makefile.in b/libstdc++/tests/Makefile.in new file mode 100644 index 000000000000..8c3a9ef2f383 --- /dev/null +++ b/libstdc++/tests/Makefile.in @@ -0,0 +1,35 @@ +# Copyright (C) 1994 Free Software Foundation + +# This file is part of the GNU ANSI C++ 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 this library; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +VERSION = 2.8.0 +SHLIB = libstdc++.so.$(VERSION) + +DEPLIBS = ../libstdc++.a +LDLIBS = -L.. -lstdc++ +MDEPLIBS = $(DEPLIBS) +MLDLIBS = $(LDLIBS) -lm + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +tcomplex.o: ${srcdir}/../std/complext.h ${srcdir}/../std/dcomplex.h +tcomplex: tcomplex.o $(MDEPLIBS) + $(CXX) $(CXXFLAGS) -o tcomplex tcomplex.o $(MLDLIBS) + +tstring.o: ${srcdir}/../std/bastring.h + +# NOTE: Rules for following tests are generated by $(srcdir)/configure.in !!! + diff --git a/libstdc++/tests/configure.in b/libstdc++/tests/configure.in new file mode 100644 index 000000000000..ebcef8635233 --- /dev/null +++ b/libstdc++/tests/configure.in @@ -0,0 +1,50 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../../configure. + +configdirs= +srctrigger=tcomplex.cc +srcname="tests for ANSI C++ library" +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +target_makefile_frag=../target-mkfrag + +TO_TOPDIR=../../ +ALL=' ' +XCXXINCLUDES="-I${srcdir}/.. -I${srcdir}/../stl -I${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio" +SIMPLE_TESTS='tstring tlist tmap tvector' +TESTS="tcomplex ${SIMPLE_TESTS}" +MOSTLYCLEAN="*.o core ${TESTS} *.out" +(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} + +# post-target: + +CHECK="" + +for TEST in ${SIMPLE_TESTS} ; do + echo "${TEST}: ${TEST}.o" '$(DEPLIBS) + $(CXX) $(CXXFLAGS) -o' "${TEST} ${TEST}.o" '$(LDLIBS) +' >> Makefile +done + +for TEST in ${TESTS} ; do + echo ".PHONY: check-${TEST}" >>Makefile + if [ -f ${srcdir}/${TEST}.inp ] ; then + echo "check-${TEST}: ${TEST}" '$(srcdir)'"/${TEST}.inp + ./${TEST} < "'$(srcdir)'"/${TEST}.inp > ${TEST}.out 2>&1" >>Makefile + else + echo "check-${TEST}: ${TEST} + ./${TEST} > ${TEST}.out 2>&1" >>Makefile + fi + echo ' diff -c $(srcdir)/'"${TEST}.exp ${TEST}.out" >>Makefile + CHECK="${CHECK} check-${TEST}" +done +echo " +check: +check-old: ${CHECK}" >>Makefile + + diff --git a/libstdc++/tests/tcomplex.cc b/libstdc++/tests/tcomplex.cc new file mode 100644 index 000000000000..5311f0d8b7a1 --- /dev/null +++ b/libstdc++/tests/tcomplex.cc @@ -0,0 +1,151 @@ +// Tests for the -*- C++ -*- complex number classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include + +// to test near-equality + +const double eps = 0.000001; + +static void close_enough(const double_complex& a, const double_complex& b) +{ + assert(fabs(real(a) - real(b)) < eps && + fabs(imag(a) - imag(b)) < eps); +} + + +void test3(double_complex& a, double_complex& b, double_complex& c) +{ + + close_enough(-(-a) , a); + close_enough((a + b) , (b + a)); + close_enough((a + (-b)) , (a - b)); + close_enough((a * b) , (b * a)); + close_enough((a * (-b)) , -(a * b)); + close_enough((a / (-b)) , -(a / b)); + close_enough((a - b) , -(b - a)); + close_enough((a + (b + c)) , ((a + b) + c)); + close_enough((a * (b * c)) , ((a * b) * c)); + close_enough((a * (b + c)) , ((a * b) + (a * c))); + close_enough(((a - b) + b) , a); + close_enough(((a + b) - b) , a); + close_enough(((a * b) / b) , a); + close_enough(((a / b) * b) , a); + + + double_complex x = a; + x *= b; + close_enough(x , (a * b)); + x += c; + close_enough(x , ((a * b) + c)); + x -= a; + close_enough(x , (((a * b) + c) - a)); + x /= b; + close_enough(x , ((((a * b) + c) - a) / b)); + +} + +main() +{ + double_complex one = 1.0; + double_complex i (0.0, 1.0); + double_complex neg_one = -1.0; + + cout << "double_complex one = " << one << "\n"; + cout << "i = " << i << "\n"; + cout << "neg_one = " << neg_one << "\n"; + cout << "sqrt(neg_one) = " << sqrt(neg_one) << "\n"; + + double_complex a (2.0, 3.0); + double_complex b (4.0, 5.0); + + cout << "a = " << a << "\n"; + cout << "b = " << b << "\n"; + + cout << "a + one = " << (a + one) << "\n"; + (close_enough((a+one), double_complex(3.0, 3.0))); + cout << "a - one = " << (a - one) << "\n"; + (close_enough((a-one), double_complex(1.0, 3.0))); + cout << "a * one = " << (a * one) << "\n"; + (close_enough((a*one), a)); + cout << "a / one = " << (a / one) << "\n"; + (close_enough((a/one), a)); + + cout << "a + b = " << (a + b) << "\n"; + (close_enough((a+b), double_complex(6.0, 8.0))); + cout << "a - b = " << (a - b) << "\n"; + (close_enough((a-b), double_complex(-2.0, -2.0))); + cout << "a * b = " << (a * b) << "\n"; + (close_enough((a*b), double_complex(-7.0, 22.0))); + cout << "a / b = " << (a / b) << "\n"; + (close_enough((a/b), double_complex(0.5609760976, 0.0487804878))); + + double_complex c; + + c = a; cout << "c = a; c += b = " << (c += b) << "\n"; + c = a; cout << "c = a; c -= b = " << (c -= b) << "\n"; + c = a; cout << "c = a; c *= b = " << (c *= b) << "\n"; + c = a; cout << "c = a; c /= b = " << (c /= b) << "\n"; + + cout << "-a = " << (-a) << "\n"; + cout << "real(a) = " << real(a) << "\n"; + assert(real(a) == 2.0); + cout << "imag(a) = " << imag(a) << "\n"; + assert(imag(a) == 3.0); + cout << "conj(a) = " << conj(a) << "\n"; + assert(conj(a) == double_complex(2.0, -3.0)); + cout << "norm(a) = " << norm(a) << "\n"; + assert(norm(a) == 13.0); + + cout << "abs(a) = " << abs(a) << "\n"; + cout << "arg(a) = " << arg(a) << "\n"; + cout << "cos(a) = " << cos(a) << "\n"; + cout << "sin(a) = " << sin(a) << "\n"; + cout << "cosh(a) = " << cosh(a) << "\n"; + cout << "sinh(a) = " << sinh(a) << "\n"; + cout << "log(a) = " << log(a) << "\n"; + cout << "exp(a) = " << exp(a) << "\n"; + cout << "sqrt(a) = " << sqrt(a) << "\n"; + cout << "pow(a, 2) = " << pow(a, 2) << "\n"; + { + double_complex p = pow(a, b); + if(sizeof(float)==sizeof(double)) { + long w = (long)(p.imag()*100000); + if (w==-98642) + p=double_complex(-0.753046,-0.986429); + } + cout << "pow(a, b) = " << p << "\n"; + } + + double_complex d (10, 20); + double_complex e = pow(a, 2); + + test3(one, one, one); + test3(a, a, a); + test3(a, b, d); + test3(e, i, b); + test3(d, d, i); + + cout << "enter a complex number in form a or (a) or (a, b): "; + cin >> c; + cout << "number = " << c << "\n"; + + cout << "\nEnd of test\n"; + return 0; +} diff --git a/libstdc++/tests/tcomplex.exp b/libstdc++/tests/tcomplex.exp new file mode 100644 index 000000000000..5bef15cd3769 --- /dev/null +++ b/libstdc++/tests/tcomplex.exp @@ -0,0 +1,37 @@ +double_complex one = (1,0) +i = (0,1) +neg_one = (-1,0) +sqrt(neg_one) = (0,1) +a = (2,3) +b = (4,5) +a + one = (3,3) +a - one = (1,3) +a * one = (2,3) +a / one = (2,3) +a + b = (6,8) +a - b = (-2,-2) +a * b = (-7,22) +a / b = (0.560976,0.0487805) +c = a; c += b = (6,8) +c = a; c -= b = (-2,-2) +c = a; c *= b = (-7,22) +c = a; c /= b = (0.560976,0.0487805) +-a = (-2,-3) +real(a) = 2 +imag(a) = 3 +conj(a) = (2,-3) +norm(a) = 13 +abs(a) = 3.60555 +arg(a) = 0.982794 +cos(a) = (-4.18963,-9.10923) +sin(a) = (9.1545,-4.16891) +cosh(a) = (-3.72455,0.511823) +sinh(a) = (-3.59056,0.530921) +log(a) = (1.28247,0.982794) +exp(a) = (-7.31511,1.04274) +sqrt(a) = (1.67415,0.895977) +pow(a, 2) = (-5,12) +pow(a, b) = (-0.753046,-0.986429) +enter a complex number in form a or (a) or (a, b): number = (1.2,-34) + +End of test diff --git a/libstdc++/tests/tcomplex.inp b/libstdc++/tests/tcomplex.inp new file mode 100644 index 000000000000..c4e1d84660f2 --- /dev/null +++ b/libstdc++/tests/tcomplex.inp @@ -0,0 +1 @@ +(1.2, -34) diff --git a/libstdc++/tests/tlist.cc b/libstdc++/tests/tlist.cc new file mode 100644 index 000000000000..8a8be91c05f6 --- /dev/null +++ b/libstdc++/tests/tlist.cc @@ -0,0 +1,165 @@ +/* + test/demo of generic lists +*/ + +#include + +#define tassert(ex) {if ((ex)) cerr << #ex << "\n"; \ + else _assert(#ex, __FILE__,__LINE__); } + +#include +#include "list.h" +#include "algo.h" + +bool int_compare(int a, int b) +{ + return a < b; +} + +int inc(int x) +{ + return x + 1; +} + +void print(list& l) +{ + for (list::iterator it = l.begin(); it != l.end(); it++) + cout << *it << " "; + cout << "\n"; +} + +int is_odd(int x) +{ + return x & 1; +} + +int is_even(int x) +{ + return (x & 1) == 0; +} + +void sequence(list& a, int lo, int hi) +{ + back_insert_iterator > it(a); + while (lo <= hi) + *it++ = lo++; +} + +int old_rand = 9999; + +int get_rand() +{ + old_rand = ((long)old_rand * (long)1243) % (long)971; + return old_rand; +} + +void randseq(list& a, int n) +{ + back_insert_iterator > it(a); + while (--n >= 0) + *it++ = get_rand() % 50; +} + +int array1 [] = { 9, 16, 36 }; +int array2 [] = { 1, 4 }; + +int test_splice () +{ + list l1 (array1, array1 + 3); + list l2 (array2, array2 + 2); + list::iterator i1 = l1.begin (); + l1.splice (i1, l2); + list::iterator i2 = l1.begin (); + while (i2 != l1.end ()) + cout << *i2++ << endl; + return 0; +} + +main() +{ + list a; int i; + list::iterator it, bit; + sequence(a, 1, 20); + cout << "\nlist a = sequence(1, 20);\n"; print(a); + for (it = a.begin (), i = 0; it != a.end (); it++, i++) + assert (*it == i + 1); + list b; + randseq(b, 20); + cout << "\nlist b = randseq(20);\n"; print(b); + list c; + c.insert (c.end(), a.begin(), a.end()); + c.insert (c.end(), b.begin(), b.end()); + cout << "\nlist c = a and b;\n"; print(c); + + list d; + for (it = a.begin(); it != a.end(); it++) + d.insert(d.end (), inc(*it)); + cout << "\nlist d = map(inc, a);\n"; print(d); + + list e; + back_insert_iterator > e_insertor (e); + reverse_copy (a.begin(), a.end (), e_insertor); + cout << "\nlist e = reverse(a);\n"; print(e); + + list f; + for (it = a.begin(); it != a.end(); it++) + if (is_odd (*it)) + f.insert(f.end (), *it); + cout << "\nlist f = select(is_odd, a);\n"; print(f); + list ff; + for (it = f.begin(); it != f.end(); it++) + if (is_even (*it)) + ff.insert(ff.end (), *it); + assert(ff.empty()); + + int red = 0; + for (it = a.begin(); it != a.end(); it++) + red += *it; + cout << "\nint red = a.reduce(plus, 0);\n"; cout << red; + it = a.begin(); ++it; ++it; + int second = *it; + cout << "\nint second = a[2];\n"; cout << second; + list g; + for (it = a.begin(), bit = b.begin(); it != a.end () && bit != b.end (); ) + g.insert (g.end (), *it++ + *bit++); + cout << "\nlist g = combine(plus, a, b);\n"; print(g); +#if 1 + for (it = g.begin(); it != g.end(); ) + { + bit = it++; + if (is_odd (*bit)) + g.erase (bit); + } +#else + g.remove_if (is_odd); +#endif + cout << "\ng.del(is_odd);\n"; print(g); + + ff.erase (ff.begin (), ff.end()); + for (it = g.begin(); it != g.end(); it++) + if (is_odd (*it)) + ff.insert (ff.end (), *it); + assert(ff.empty()); + + b.sort(); + for (it = b.begin(); bit = it++, it != b.end (); ) assert (*it >= *bit); + cout << "\nb.sort(int_compare);\n"; print(b); + + list h; + back_insert_iterator > h_insertor (h); + merge (a.begin (), a.end (), b.begin (), b.end (), h_insertor, int_compare); + cout << "\nlist h = merge(a, b, int_compare);\n"; print(h); + for (it = h.begin(); bit = it++, it != h.end (); ) assert (*it >= *bit); + + cout << "\nh via iterator:\n"; + for (it = h.begin(); it != h.end (); it++) + cout << *it << ", "; + cout << "\n"; + + test_splice (); + + cout << "\ndone\n"; +} + +template class __malloc_alloc_template<0>; +template class __default_alloc_template; diff --git a/libstdc++/tests/tlist.exp b/libstdc++/tests/tlist.exp new file mode 100644 index 000000000000..65f7806826f6 --- /dev/null +++ b/libstdc++/tests/tlist.exp @@ -0,0 +1,44 @@ + +list a = sequence(1, 20); +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 + +list b = randseq(20); +28 27 5 17 44 6 9 40 15 26 49 35 15 48 13 27 25 25 9 6 + +list c = a and b; +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 28 27 5 17 44 6 9 40 15 26 49 35 15 48 13 27 25 25 9 6 + +list d = map(inc, a); +2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + +list e = reverse(a); +20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 + +list f = select(is_odd, a); +1 3 5 7 9 11 13 15 17 19 + +int red = a.reduce(plus, 0); +210 +int second = a[2]; +3 +list g = combine(plus, a, b); +29 29 8 21 49 12 16 48 24 36 60 47 28 62 28 43 42 43 28 26 + +g.del(is_odd); +8 12 16 48 24 36 60 28 62 28 42 28 26 + +b.sort(int_compare); +5 6 6 9 9 13 15 15 17 25 25 26 27 27 28 35 40 44 48 49 + +list h = merge(a, b, int_compare); +1 2 3 4 5 5 6 6 6 7 8 9 9 9 10 11 12 13 13 14 15 15 15 16 17 17 18 19 20 25 25 26 27 27 28 35 40 44 48 49 + +h via iterator: +1, 2, 3, 4, 5, 5, 6, 6, 6, 7, 8, 9, 9, 9, 10, 11, 12, 13, 13, 14, 15, 15, 15, 16, 17, 17, 18, 19, 20, 25, 25, 26, 27, 27, 28, 35, 40, 44, 48, 49, +1 +4 +9 +16 +36 + +done diff --git a/libstdc++/tests/tmap.cc b/libstdc++/tests/tmap.cc new file mode 100644 index 000000000000..2c164c932a97 --- /dev/null +++ b/libstdc++/tests/tmap.cc @@ -0,0 +1,69 @@ +#include +#include +#include +#include + +int SIZE; + +#if 0 +/* Crashes compiler */ +#define int_less less +#else +struct int_less { + bool operator() (int x, int y) const { return x < y; } +}; +struct str_less { + bool operator() (char* x, char* y) const { return strcmp(x,y) < 0; } +}; +#endif + +#if 0 +void add(int x[], int y[], map& a) +{ + for (int i = 0; i < SIZE; ++i) a[x[i]] = y[i]; +} +#endif + +int +main(int argv, char** argc) +{ +#if 0 + if (argv > 1) + { + SIZE = abs(atoi(argc[1])); + SIZE &= ~1; + } + else + SIZE = 100; + nums = new int[SIZE]; + odds = new int[SIZE]; + perm = new int[SIZE]; +#endif + + map my_map; + + map phones; + + my_map[4] = 40; + my_map[2] = 20; + + // The (char*) is needed because g++ doesn't + // convert char[] to char* in this context. + phones[(char*)"tom"] = 2345; + phones[(char*)"dick"] = 5678; + phones[(char*)"harry"] = 7654; + + cout << "2 -> " << my_map[2] << endl; + cout << "4 -> " << my_map[4] << endl; + + map::iterator it = my_map.begin(); + for ( ; it != my_map.end(); it++) + cout << "my_map[" << (*it).first << "] = " << (*it).second << endl; + + map::iterator pit = phones.begin(); + for ( ; pit != phones.end(); pit++) + cout << "phones[" << (*pit).first << "] = " << (*pit).second << endl; +} + +template class __malloc_alloc_template<0>; +template class __default_alloc_template; diff --git a/libstdc++/tests/tmap.exp b/libstdc++/tests/tmap.exp new file mode 100644 index 000000000000..b7b5df249fb0 --- /dev/null +++ b/libstdc++/tests/tmap.exp @@ -0,0 +1,7 @@ +2 -> 20 +4 -> 40 +my_map[2] = 20 +my_map[4] = 40 +phones[dick] = 5678 +phones[harry] = 7654 +phones[tom] = 2345 diff --git a/libstdc++/tests/tstring.cc b/libstdc++/tests/tstring.cc new file mode 100644 index 000000000000..d4f65c55b6e0 --- /dev/null +++ b/libstdc++/tests/tstring.cc @@ -0,0 +1,189 @@ +// Tests for the -*- C++ -*- string classes. +// Copyright (C) 1994 Free Software Foundation + +// This file is part of the GNU ANSI C++ 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 this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include +#include +#include +#include + +string X = "Hello"; +string Y = "world"; +string N = "123"; +string c; +const char* s = ","; + +void decltest() +{ + string x; + cout << "an empty string:" << x << "\n"; + assert(x == ""); + + string y = "Hello"; + cout << "A string initialized to Hello:" << y << "\n"; + assert(y == "Hello"); + + if (y[y.length()-1] == 'o') + y = y + '\n'; + assert(y == "Hello\n"); + y = "Hello"; + + string a = y; + cout << "A string initialized to previous string:" << a << "\n"; + assert(a == "Hello"); + assert(a == y); + + string b (a, 1, 2); + cout << "A string initialized to (previous string, 1, 2):" << b << "\n"; + assert(b == "el"); + + char ch = '@'; + string z (1, ch); + cout << "A string initialized to @:" << z << "\n"; + assert (z == "@"); + + string n ("20"); + cout << "A string initialized to 20:" << n << "\n"; + assert(n == "20"); + + int i = atoi(n.c_str ()); + double f = atof(n.c_str ()); + cout << "n = " << n << " atoi(n) = " << i << " atof(n) = " << f << "\n"; + assert(i == 20); + assert(f == 20); + +} + +void cattest() +{ + string x = X; + string y = Y; + string z = x + y; + cout << "z = x + y = " << z << "\n"; + assert(z == "Helloworld"); + + x += y; + cout << "x += y; x = " << x << "\n"; + assert(x == "Helloworld"); + + y = Y; + x = X; + y.insert (0, x); + cout << "y.insert (0, x); y = " << y << "\n"; + assert(y == "Helloworld"); + + y = Y; + x = X; + x = x + y + x; + cout << "x = x + y + x; x = " << x << "\n"; + assert(x == "HelloworldHello"); + + y = Y; + x = X; + x = y + x + x; + cout << "x = y + x + x; x = " << x << "\n"; + assert(x == "worldHelloHello"); + + x = X; + y = Y; + z = x + s + ' ' + y.substr (y.find ('w'), 1) + y.substr (y.find ('w') + 1) + "."; + cout << "z = x + s + + y.substr (y.find (w), 1) + y.substr (y.find (w) + 1) + . = " << z << "\n"; + assert(z == "Hello, world."); +} + +void comparetest() +{ + string x = X; + string y = Y; + string n = N; + string z = x + y; + + assert(x != y); + assert(x == "Hello"); + assert(x != z.substr (0, 4)); + assert(x.compare (y) < 0); + assert(x.compare (z.substr (0, 6)) < 0); + + assert(x.find ("lo") == 3); + assert(x.find ("l", 2) == 2); + assert(x.rfind ("l") == 3); +} + +void substrtest() +{ + string x = X; + + char ch = x[0]; + cout << "ch = x[0] = " << ch << "\n"; + assert(ch == 'H'); + + string z = x.substr (2, 3); + cout << "z = x.substr (2, 3) = " << z << "\n"; + assert(z == "llo"); + + x.replace (2, 2, "r"); + cout << "x.replace (2, 2, r); x = " << x << "\n"; + assert(x == "Hero"); + + x = X; + x.replace (0, 1, 'j'); + cout << "x.replace (0, 1, 'j'); x = " << x << "\n"; + assert(x == "jello"); +} + +void iotest() +{ + string z; + cout << "enter a word:"; + cin >> z; + cout << "word =" << z << " "; + cout << "length = " << z.length() << "\n"; +} + +void identitytest(string a, string b) +{ + string x = a; + string y = b; + x += b; + y.insert (0, a); + assert((a + b) == x); + assert((a + b) == y); + assert(x == y); + + assert((a + b + a) == (a + (b + a))); + + x.remove (x.rfind (b)); + assert(x == a); + + y.replace (0, y.rfind (b), b); + assert(y == (b + b)); + y.replace (y.find (b), b.length (), a); + assert(y == (a + b)); +} + +int main() +{ + decltest(); + cattest(); + comparetest(); + substrtest(); + identitytest(X, X); + identitytest(X, Y); + identitytest(X+Y+N+X+Y+N, "A string that will be used in identitytest but is otherwise just another useless string."); + iotest(); + cout << "\nEnd of test\n"; + return 0; +} diff --git a/libstdc++/tests/tstring.exp b/libstdc++/tests/tstring.exp new file mode 100644 index 000000000000..3333ab1231d3 --- /dev/null +++ b/libstdc++/tests/tstring.exp @@ -0,0 +1,20 @@ +an empty string: +A string initialized to Hello:Hello +A string initialized to previous string:Hello +A string initialized to (previous string, 1, 2):el +A string initialized to @:@ +A string initialized to 20:20 +n = 20 atoi(n) = 20 atof(n) = 20 +z = x + y = Helloworld +x += y; x = Helloworld +y.insert (0, x); y = Helloworld +x = x + y + x; x = HelloworldHello +x = y + x + x; x = worldHelloHello +z = x + s + + y.substr (y.find (w), 1) + y.substr (y.find (w) + 1) + . = Hello, world. +ch = x[0] = H +z = x.substr (2, 3) = llo +x.replace (2, 2, r); x = Hero +x.replace (0, 1, 'j'); x = jello +enter a word:word =abcdefghijklmnopqrstuvwxyz length = 26 + +End of test diff --git a/libstdc++/tests/tstring.inp b/libstdc++/tests/tstring.inp new file mode 100644 index 000000000000..b0883f382e1a --- /dev/null +++ b/libstdc++/tests/tstring.inp @@ -0,0 +1 @@ +abcdefghijklmnopqrstuvwxyz diff --git a/libstdc++/tests/tvector.cc b/libstdc++/tests/tvector.cc new file mode 100644 index 000000000000..8b5f8091cf68 --- /dev/null +++ b/libstdc++/tests/tvector.cc @@ -0,0 +1,23 @@ +#include +#include +#include + +main () +{ + cout << "Fill of C array:\n"; + char x[50]; + fill (x, x+50, '/'); + fill (x+1, x+49, '*'); + copy (x, x+50, ostream_iterator(cout)); + + cout << "\nFill of vector:\n"; + + vector cvec; + cvec.insert (cvec.begin(), 50, '/'); + fill (cvec.begin()+1, cvec.end()-1, '-'); + copy (cvec.begin(), cvec.end(), ostream_iterator(cout)); + cout << endl; +} + +template class __malloc_alloc_template<0>; +template class __default_alloc_template; diff --git a/libstdc++/tests/tvector.exp b/libstdc++/tests/tvector.exp new file mode 100644 index 000000000000..84a9d1bf3a4d --- /dev/null +++ b/libstdc++/tests/tvector.exp @@ -0,0 +1,4 @@ +Fill of C array: +/************************************************/ +Fill of vector: +/------------------------------------------------/ diff --git a/libstdc++/testsuite/ChangeLog b/libstdc++/testsuite/ChangeLog new file mode 100644 index 000000000000..b49367e9d4cb --- /dev/null +++ b/libstdc++/testsuite/ChangeLog @@ -0,0 +1,54 @@ +Wed Aug 6 18:43:23 1997 Jason Merrill + + * lib/libstdc++.exp: Remove libio_link_flags. + +Thu Jul 17 14:54:58 1997 Brendan Kehoe + + * lib/libstdc++.exp (base_dir): Move from here... + (test_libstdc++): To here. + (LIBSTDCPP): Delete unused global decl. + +Tue Jun 17 01:46:49 1997 Bob Manson + + * lib/libstdc++.exp: Strip off leading LFs from both the pattern + being matched against and the output from the board. Find the + correct multilib libstdc++ to link with. Use g++_link_flags + and libio_link_flags. Link in the status wrapper if needed. + (libstdc++_init): New procedure. + +Tue Jun 3 17:16:39 1997 Bob Manson + + * lib/libstdc++.exp: Don't use global exec_output variable; the + output is returned from remote_load instead. + +Tue Apr 29 17:20:05 1997 Mike Stump + + * lib/libstdc++.exp: Fixup so that $compile_args works better. + * libstdc++.tests/test.exp: Also run with -O. + +Tue Apr 29 16:34:37 1997 Mike Stump + + * testsuite/lib/libstdc++.exp: Fixup so that we always have the + same number of testcases, and so that we have meaningful testcase + names. + +Tue Apr 29 13:05:14 1997 Bob Manson + + * lib/libstdc++.exp: Add support for --tool_opts. + +Mon Apr 28 11:10:25 1997 Bob Manson + + * Makefile.in: Add comment so target Makefile fragments get added. + Removed clean rule, because it is added by configure. + + * configure.in (TESTS): Add. + +Sun Apr 27 15:03:10 1997 Brendan Kehoe + + * Makefile.in (clean): Add empty rule for now. + +Fri Apr 25 18:59:14 1997 Bob Manson + + * lib/libstdc++.exp(test_libstdc++): Return on error. Generate a + FAIL if the compile fails. Remove CRs from the output from the + testcase. diff --git a/libstdc++/testsuite/Makefile.in b/libstdc++/testsuite/Makefile.in new file mode 100644 index 000000000000..9ead33e22fcf --- /dev/null +++ b/libstdc++/testsuite/Makefile.in @@ -0,0 +1,66 @@ +# Copyright (C) 1997 Free Software Foundation +# +# This file is part of the GNU IO 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, 675 Mass Ave, Cambridge, MA 02139, USA. + +srcdir = libstdc++.tests + +EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \ + echo $${rootme}/../../expect/expect ; \ + else echo expect ; fi` + +RUNTEST = `if [ -f $${srcdir}/../../dejagnu/runtest ] ; then \ + echo $${srcdir}/../../dejagnu/runtest ; \ + else echo runtest; fi` +RUNTESTFLAGS = + +#### package, host, target, and site dependent Makefile fragments come in here. +## + +.PHONY: all +all: + +.PHONY: check +check: site.exp all just-check + +site.exp: ./config.status Makefile + @echo "Making a new config file..." + -@rm -f ./tmp? + @touch site.exp + -@mv site.exp site.bak + @echo "## these variables are automatically generated by make ##" > ./tmp0 + @echo "# Do not edit here. If you wish to override these values" >> ./tmp0 + @echo "# add them to the last section" >> ./tmp0 + @echo "set host_alias $(host_alias)" >> ./tmp0 + @echo "set host_triplet ${host_canonical}" >> ./tmp0 + @echo "set target_alias $(target_alias)" >> ./tmp0 + @echo "set target_triplet ${target_canonical}" >> ./tmp0 + @echo "set build_triplet ${build_canonical}" >> ./tmp0 + @echo "set srcdir ${srcdir}" >> ./tmp0 + @echo "set tool libstdc++" >> ./tmp0 + @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0 + @cat ./tmp0 > site.exp + @cat site.bak | sed \ + -e '1,/^## All variables above are.*##/ d' >> site.exp + -@rm -f ./tmp? + +just-check: + rootme=`pwd`; export rootme; \ + srcdir=${srcdir} ; export srcdir ; \ + EXPECT=${EXPECT} ; export EXPECT ; \ + if [ -f $${rootme}/../../expect/expect ] ; then \ + TCL_LIBRARY=$${srcdir}/../../tcl/library ; \ + export TCL_LIBRARY ; fi ; \ + $(RUNTEST) $(RUNTESTFLAGS) diff --git a/libstdc++/testsuite/config/default.exp b/libstdc++/testsuite/config/default.exp new file mode 100644 index 000000000000..90967cccc18a --- /dev/null +++ b/libstdc++/testsuite/config/default.exp @@ -0,0 +1 @@ +load_lib "standard.exp" diff --git a/libstdc++/testsuite/configure.in b/libstdc++/testsuite/configure.in new file mode 100644 index 000000000000..21a6c8c59b6b --- /dev/null +++ b/libstdc++/testsuite/configure.in @@ -0,0 +1,23 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../../configure. + +configdirs= +srctrigger=configure.in +srcname="tests for ANSI C++ library, dejagnu style" +package_makefile_frag=Make.pack + +# per-host: + +# per-target: + +target_makefile_frag=../target-mkfrag + +TO_TOPDIR=../../ +ALL=' ' +XCXXINCLUDES="-I${srcdir}/.. -I${srcdir}/../stl -I${TO_TOPDIR}libio -I${srcdir}/${TO_TOPDIR}libio" +TESTS="tcomplex tstring tlist tmap tvector" +MOSTLYCLEAN="*.o core ${TESTS} *.out" +(. ${srcdir}/${TO_TOPDIR}libio/config.shared) >${package_makefile_frag} + +# post-target: diff --git a/libstdc++/testsuite/lib/libstdc++.exp b/libstdc++/testsuite/lib/libstdc++.exp new file mode 100644 index 000000000000..588f72a3a94f --- /dev/null +++ b/libstdc++/testsuite/lib/libstdc++.exp @@ -0,0 +1,165 @@ +# Copyright (C) 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 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. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-lib-g++@prep.ai.mit.edu + +# This file was written by Bob Manson. (manson@cygnus.com) + +load_lib "libgloss.exp" + +global tmpdir + +if ![info exists tmpdir] { + set tmpdir "/tmp" +} + +# +# Build the status wrapper library as needed. +# +proc libstdc++_init { args } { + global wrapper_file; + global wrap_compile_flags; + set wrapper_file ""; + set wrap_compile_flags ""; + if [target_info exists needs_status_wrapper] { + set result [build_wrapper "testglue.o"]; + if { $result != "" } { + set wrapper_file [lindex $result 0]; + set wrap_compile_flags [lindex $result 1]; + } else { + warning "Status wrapper failed to build." + } + } +} +# +# Run the test specified by srcfile and resultfile. compile_args and +# exec_args are additional arguments to be passed in when compiling and +# running the testcase, respectively. +# + +proc test_libstdc++ { options srcfile compile_args inpfile resultfile exec_args } { + global base_dir + global LIBSTDCPP + global srcdir subdir objdir + global TOOL_OPTIONS + + if [info exists LIBSTDCPP] { + set libstdcpp $LIBSTDCPP; + } else { + set gp [get_multilibs]; + if { $gp != "" } { + if [file exists "$gp/libstdc++/libstdc++.a"] { + set libstdcpp "-L$gp/libstdc++ -lstdc++"; + } + } + if ![info exists libstdcpp] { + set libstdcpp [findfile $base_dir/../../libstdc++/libstdc++.a "-L$base_dir/../../libstdc++ -lstdc++" -lstdc++] + } + } + + verbose "using LIBSTDCPP = $libstdcpp" 2 + set args "" + if { $compile_args != "" } { + lappend args "additional_flags=$compile_args" + } + lappend args "incdir=.." + lappend args "incdir=$srcdir/.." + lappend args "incdir=$srcdir/../stl" + lappend args "incdir=." + if [info exists TOOL_OPTIONS] { + lappend args "additional_flags=$TOOL_OPTIONS" + } + + global wrapper_file wrap_compile_flags; + # We have to include libio, for _G_config.h. + lappend args "additional_flags=$wrap_compile_flags"; + lappend args "libs=$wrapper_file"; + lappend args "libs=$libstdcpp"; + lappend args "additional_flags=[libio_include_flags]" + lappend args "additional_flags=[g++_link_flags]" + lappend args debug + + regsub "^.*/(\[^/.\]+)\[.\]\[^/]*$" "$srcfile" "\\1" out + set executable "${objdir}/$out" + set errname "[file tail $srcfile]" + if { $compile_args != "" } { + set errname "$errname $compile_args" + } + + if { [target_compile $srcfile "$executable" executable $args] != "" } { + fail "$errname compilation" + setup_xfail "*-*-*" + fail "$errname execution" + setup_xfail "*-*-*" + fail "$errname output" + return; + } + pass "$errname compilation" + + set result [libstdc++_load $executable "$exec_args" "$inpfile"]; + set status [lindex $result 0]; + set output [lindex $result 1]; + $status "$errname execution" + if { $status != "pass" } { + setup_xfail "*-*-*" + fail "$errname output" + return; + } + + verbose "resultfile is $resultfile" + set id [open $resultfile r]; + set expected "" + append expected [read $id]; + regsub -all "\r" "$output" "" output; + regsub "\n*$" $expected "" expected + regsub "\n*$" $output "" output + regsub "^\n*" $expected "" expected + regsub "^\n*" $output "" output + regsub -all "\[ \t\]\[ \t\]*" $expected " " expected + regsub -all "\[ \t\]*\n\n*" $expected "\n" expected + regsub -all "\[ \t\]\[ \t\]*" $output " " output + regsub -all "\[ \t\]*\n\n*" $output "\n" output + verbose "expected is $expected" + verbose "actual is $output" + set passed 0; + if {$options == "regexp_match"} { + if [regexp $expected $output] { + set passed 1; + } + } else { + if { $expected == $output } { + set passed 1; + } + } + if { $passed == 1 } { + pass "$errname output" + } else { + clone_output "expected was $expected" + clone_output "output was $output" + fail "$errname output" + } + close $id; +} + +# +# libstdc++_version -- extract and print the version number of libstdc++p +# +proc default_libstdc++_version {} { +} + +proc default_libstdc++_start { } { +} diff --git a/libstdc++/testsuite/libstdc++.tests/test.exp b/libstdc++/testsuite/libstdc++.tests/test.exp new file mode 100644 index 000000000000..7368cfb282e8 --- /dev/null +++ b/libstdc++/testsuite/libstdc++.tests/test.exp @@ -0,0 +1,34 @@ +global srcdir subdir + +catch "glob -nocomplain $srcdir/$subdir/../../tests/*.exp" srcfiles +verbose "srcfiles are $srcfiles" + +set prefix "" +foreach x $srcfiles { + regsub "\\.exp$" $x "" prefix + set bname [file tail $prefix] + set args "" + if [file exists $srcdir/$subdir/${bname}.arg] { + set id [open "$srcdir/$subdir/${bname}.arg" r]; + set args [read -nonewline $id]; + close $id; + } + if [file exists $srcdir/$subdir/${bname}.xpo] { + set resfile "$srcdir/$subdir/${bname}.xpo" + set options "regexp_match" + } else { + set resfile "${prefix}.exp" + set options "" + } + + if [file exists ${prefix}.inp] { + set inpfile ${prefix}.inp + } else { + set inpfile "" + } + + verbose "inpfile is $inpfile" + + test_libstdc++ $options "${prefix}.cc" "" $inpfile $resfile $args + test_libstdc++ $options "${prefix}.cc" "-O" $inpfile $resfile $args +} diff --git a/libstdc++/utility b/libstdc++/utility new file mode 100644 index 000000000000..fb79aa782746 --- /dev/null +++ b/libstdc++/utility @@ -0,0 +1,8 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __UTILITY__ +#define __UTILITY__ +#include +#include +#endif diff --git a/libstdc++/vector b/libstdc++/vector new file mode 100644 index 000000000000..79f735937517 --- /dev/null +++ b/libstdc++/vector @@ -0,0 +1,7 @@ +// -*- C++ -*- forwarding header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __VECTOR__ +#define __VECTOR__ +#include +#endif diff --git a/ltconfig b/ltconfig new file mode 100755 index 000000000000..7bba4e6b37f7 --- /dev/null +++ b/ltconfig @@ -0,0 +1,1064 @@ +#! /bin/sh + +# ltconfig - Create a system-specific libtool. +# When updating this script, search for LINENUM and fix line number refs. +# Generated automatically from ltconfig.in by configure. +# Copyright (C) 1996, 1997, Free Software Foundation, Inc. +# Gordon Matzigkeit , 1996 +# +# This file 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A lot of this script is taken from autoconf-2.10. + +# The name of this program. +progname=`echo "$0" | sed 's%^.*/%%'` + +# Constants: +PROGRAM=ltconfig +PACKAGE=libtool +VERSION=1.0 +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' +rm="rm -f" + +help="Try \`$progname --help' for more information." + +# Global variables: +can_build_shared=yes +enable_shared=yes +# All known linkers require a `.a' archive for static linking. +enable_static=yes +ltmain= +silent= +srcdir= +ac_config_guess= +ac_config_sub= +host= +nonopt= +verify_host=yes +with_gcc=no +with_gnu_ld=no + +old_AR="$AR" +old_CC="$CC" +old_CFLAGS="$CFLAGS" +old_CPPFLAGS="$CPPFLAGS" +old_LD="$LD" +old_LN_S="$LN_S" +old_RANLIB="$RANLIB" + +test -z "$AR" && AR=ar + +# Parse the command line options. +args= +prev= +for option +do + case "$option" in + -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$option" + prev= + continue + fi + + case "$option" in + --help) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + if test -z "$ltmain"; then + ltmain="$option" + elif test -z "$host"; then +# FIXME This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 +# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then +# echo "$progname: warning \`$option' is not a valid host type" 1>&2 +# fi + host="$option" + else + echo "$progname: too many arguments" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac +done + +if test -z "$ltmain"; then + echo "$progname: you must specify a LTMAIN file" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +if test -f "$ltmain"; then : +else + echo "$progname: warning: \`$ltmain' does not exist" 1>&2 +fi + +# Quote any args containing shell metacharacters. +ltconfig_args= +for arg +do + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ltconfig_args="$ltconfig_args '$arg'" ;; + *) ltconfig_args="$ltconfig_args $arg" ;; + esac +done + +# A relevant subset of AC_INIT. + +# 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 +# 5 compiler messages saved in config.log +# 6 checking for... messages and results +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>>./config.log + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; fi + +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 + +if test -z "$srcdir"; then + # Assume the source directory is the same one as the path to ltmain.sh. + srcdir=`echo "$ltmain" | sed 's%/[^/]*$%%'` + test "$srcdir" = "$ltmain" && srcdir=. +fi + +if test "$verify_host" = yes; then + # Check for config.guess and config.sub. + ac_aux_dir= + for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/config.guess; then + ac_aux_dir=$ac_dir + break + fi + done + if test -z "$ac_aux_dir"; then + echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 + echo "$help" 1>&2 + exit 1 + fi + ac_config_guess=$ac_aux_dir/config.guess + ac_config_sub=$ac_aux_dir/config.sub + + # Make sure we can run config.sub. + if $ac_config_sub sun4 >/dev/null 2>&1; then : + else + echo "$progname: cannot run $ac_config_sub" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + echo $ac_n "checking host system type""... $ac_c" 1>&6 + + host_alias=$host + case "$host_alias" in + "") + if host_alias=`$ac_config_guess`; then : + else + echo "$progname: cannot guess host type; you must specify one" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac + host=`$ac_config_sub $host_alias` + echo "$ac_t""$host" 1>&6 + +elif test -z "$host"; then + echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 + echo "$help" 1>&2 + exit 1 +else + host_alias=$host +fi + +# Transform *-*-linux* to *-*-linux-gnu*, to support old configure scripts. +case "$host" in +*-*-linux-gnu*) ;; +*-*-linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR cru $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' + +# If RANLIB is not set, then run the test. +if test "${RANLIB+set}" != "set"; then + result=no + + echo $ac_n "checking for ranlib... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/ranlib; then + RANLIB="ranlib" + result="ranlib" + break + fi + done + IFS="$save_ifs" + + echo $ac_t "$result" 1>&6 +fi + +if test -n "$RANLIB"; then + old_archive_cmds="$old_archive_cmds;\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds;\$RANLIB \$oldlib" +fi + +# Check to see if we are using GCC. +if test "$with_gcc" != yes || test -z "$CC"; then + # If CC is not set, then try to find GCC or a usable CC. + if test -z "$CC"; then + echo $ac_n "checking for gcc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + for dir in $PATH; do + IFS="$save_ifs" + test -z "$dir" && dir=. + if test -f $dir/gcc; then + CC="gcc" + break + fi + done + IFS="$save_ifs" + + if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 + else + echo "$ac_t""no" 1>&6 + fi + fi + + # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". + if test -z "$CC"; then + echo $ac_n "checking for cc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}:" + cc_rejected=no + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/cc; then + if test "$dir/cc" = "/usr/ucb/cc"; then + cc_rejected=yes + continue + fi + CC="cc" + break + fi + done + IFS="$save_ifs" + if test $cc_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same name, so the bogon will be chosen + # first if we set CC to just the name; use the full file name. + shift + set dummy "$dir/cc" "$@" + shift + CC="$@" + fi + fi + + if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 + else + echo "$ac_t""no" 1>&6 + fi + + if test -z "$CC"; then + echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 + exit 1 + fi + fi + + # Now see if the compiler is really GCC. + with_gcc=no + echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 + + trap "$rm conftest.c; exit 1" 1 2 15 + $rm conftest.c + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + with_gcc=yes + fi + $rm conftest.c + echo $ac_t "$with_gcc" 1>&6 +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 +pic_flag= +profile_flag_pattern= +special_shlib_compile_flags= +wl= +link_static_flag= + +if test "$with_gcc" = yes; then + pic_flag='-fPIC' + profile_flag_pattern='-pg?' + wl='-Wl,' + link_static_flag='-static' +else + # PORTME Check for PIC flags for the system compiler. + case "$host_os" in + aix3* | aix4*) + # FIXME All rs/6000 code is PIC, but is there any non-rs/6000 AIX platform? + pic_flag= + link_static_flag='-bnso -bI:/lib/syscalls.exp' + ;; + + hpux9* | hpux10*) + # FIXME is there a better link_static_flag that works with the bundled CC? + wl='-Wl,' + link_static_flag='${wl}-a ${wl}archive' + pic_flag='+Z' + ;; + + irix5* | irix6*) + wl='-Wl,' + link_static_flag='-non_shared' + # PIC (with -KPIC) is the default. + pic_flag= + ;; + + osf3* | osf4*) + # FIXME - pic_flag is probably required for hppa*-osf* and i860-osf* + wl='-Wl,' + link_static_flag='-non_shared' + ;; + + sco3.2v5*) + pic_flag='-Kpic' + link_static_flag='-dn' + special_shlib_compile_flags='-belf' + ;; + + solaris2*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + sunos4*) + pic_flag='-PIC' + link_static_flag='-Bstatic' + wl='-Qoption ld ' + ;; + + *) + can_build_shared=no + ;; + esac +fi + +case "$host_cpu" in +rs6000 | powerpc | powerpcle) + # Yippee! All RS/6000 and PowerPC code is position-independent. + pic_flag= + ;; +esac + +if test -n "$pic_flag"; then + echo $ac_t "$pic_flag" 1>&6 + pic_flag=" $pic_flag" +else + echo $ac_t none 1>&6 +fi + +# Check for any special shared library compilation flags. +if test -n "$special_shlib_compile_flags"; then + echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : + else + echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 + can_build_shared=no + fi +fi + +# See if we are using a broken GCC collect2 program. +if test "$with_gcc" = yes; then + echo $ac_n "checking for broken GCC collect2... $ac_c" 1>&6 + + # FIXME: Run a test here, instead of relying on the canonical system name. + case "$host_os" in + aix3*) + can_build_shared=no + echo $ac_t yes 1>&6 + echo "$progname: to build shared libraries, set the CC env variable to \`xlc' and reconfigure" 1>&2 + ;; + *) + echo $ac_t no 1>&6 + ;; + esac +fi + +echo $ac_n "checking for $compiler option to statically link programs... $ac_c" 1>&6 +if test -n "$link_static_flag"; then + echo $ac_t "$link_static_flag" 1>&6 +else + echo $ac_t none 1>&6 +fi + +if test -z "$LN_S"; then + # Check to see if we can use ln -s, or we need hard links. + echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 + rm -f conftestdata + if ln -s X conftestdata 2>/dev/null; then + rm -f conftestdata + LN_S="ln -s" + else + LN_S=ln + fi + if test "$LN_S" = "ln -s"; then + echo "$ac_t"yes 1>&6 + else + echo "$ac_t"no 1>&6 + fi +fi + +if test "$with_gnu_ld" != yes || test -z "$LD"; then + if test -z "$LD"; then + if test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld... $ac_c" 1>&6 + else + echo $ac_n "checking for non-GNU ld... $ac_c" 1>&6 + fi + + 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/ld"; then + LD="$ac_dir/ld" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$LD" -v 2>&1 < /dev/null | egrep '(GNU ld|with BFD)' > /dev/null; then + test "$with_gnu_ld" = yes && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" + + if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 + else + echo "$ac_t""no" 1>&6 + fi + + if test -z "$LD"; then + echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 + exit 1 + fi + fi + + echo $ac_n "checking whether we are using GNU ld... $ac_c" 1>&6 + # I'd rather use --version here, but apparently some GNU ld's only accept -v. + if $LD -v 2>&1 /dev/null; then + with_gnu_ld=yes + fi + echo $ac_t "$with_gnu_ld" 1>&6 +fi + +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 + +allow_undefined_flag= +archive_cmds= +export_dynamic_flag= +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_runpath_var=no +hardcode_shlibpath_var=unsupported +runpath_var= + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # See if GNU ld supports shared libraries. + + case "$host_os" in + sunos4*) + ld_shlibs=yes + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + archive_cmds='$cc -shared ${wl}-soname $wl$soname -o $lib$libobjs$deplibs' + hardcode_libdir_flag_spec='${wl}-rpath $wl$libdir' + export_dynamic_flag='${wl}-export-dynamic' + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case "$host_os" in + aix3*) + allow_undefined_flag=unsupported + archive_cmds='/usr/ucb/nm$libobjs | egrep \" [BD] \" | sed \"s/^.* //\" > $lib.exp;$LD -o $objdir/$soname$libobjs -bE:$lib.exp -T512 -H512 -bM:SRE -lc$deplibs;$AR cru $lib $objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + ;; + + aix4*) + allow_undefined_flag=unsupported + archive_cmds='/bin/nm -B$libobjs | egrep \" [BD] \" | sed \"s/^.* //\" > $lib.exp;$cc -o $objdir/$soname$libobjs ${wl}-bE:$lib.exp ${wl}-bM:SRE ${wl}-bnoentry$deplibs;$AR cru $lib $objdir/$soname' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # doesn't break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs /usr/lib/c++rt0.o' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 don't have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3, at last, uses gcc -shared to do shared libraries. + freebsd3*) + archive_cmds='$CC -shared -o $lib$libobjs$deplibs' + hardcode_direct=yes + hardcode_minusL=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + archive_cmds='$rm $objdir/$soname;$LD -b +s +b $install_libdir -o $objdir/$soname$libobjs$deplibs;mv $objdir/$soname $lib' + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + + hpux10*) + archive_cmds='$LD -b +h $soname +s +b $install_libdir -o $lib$libobjs$deplibs' + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + + irix5* | irix6*) + archive_cmds='$LD -shared -o $lib -soname $soname -set_version $verstring$libobjs -lc$deplibs' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + ;; + + netbsd* | openbsd*) + # Tested with NetBSD 1.2 ld + archive_cmds='$LD -Bshareable -o $lib$libobjs$deplibs' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + osf3* | osf4*) + allow_undefined_flag=' -expect_unresolved' + archive_cmds='$LD -shared${allow_undefined_flag} -o $lib -soname $soname -set_version $verstring$libobjs -lc$deplibs' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -o $lib$libobjs$deplibs' + hardcode_direct=yes + ;; + + solaris2*) + archive_cmds='$LD -G -z text -h $soname -o $lib$libobjs$deplibs' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bstatic -o $lib$libobjs' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + can_build_shared=no + ;; + esac +fi +echo $ac_t "$ld_shlibs" 1>&6 + +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test "$hardcode_runpath_var" = yes; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && \ + test "$hardcode_minus_L" != no && \ + test "$hardcode_shlibpath_var" != no; then + + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +elif test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" != yes; then + # We can't hardcode anything. + hardcode_action=unsupported +else + # We can only hardcode existing directories. + hardcode_action=relink +fi +echo $ac_t "$hardcode_action" 1>&6 +test "$hardcode_action" = unsupported && can_build_shared=no + + +reload_flag= +reload_cmds='$LD$reload_flag -o $output$reload_objs' +echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 +# PORTME Some linker may need a different reload flag. +reload_flag='-r' +echo $ac_t "$reload_flag" +test -n "$reload_flag" && reload_flag=" $reload_flag" + +# PORTME Fill in your ld.so characteristics +library_names_spec= +soname_spec= +postinstall_cmds= +finish_cmds= +shlibpath_var= +version_type=none +dynamic_linker="$host_os ld.so" + +echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 +case "$host_os" in +aix3* | aix4*) + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='$libname.so.$major' + ;; + +freebsd2* | freebsd3*) + version_type=sunos + library_names_spec='$libname.so.$versuffix $libname.so' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +gnu*) + version_type=sunos + library_names_spec='$libname.so.$versuffix' + shlibpath_var=LD_LIBRARY_PATH + ;; + +hpux9* | hpux10*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + shlibpath_var=SHLIB_PATH + library_names_spec='$libname.sl.$versuffix $libname.sl.$major $libname.sl' + soname_spec='$libname.sl.$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6*) + version_type=osf + soname_spec='$libname.so' + library_names_spec='$libname.so.$versuffix $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + + if test -f /lib/ld.so.1; then + dynamic_linker='GNU ld.so' + else + # Only the GNU ld.so supports shared libraries on MkLinux. + case "$host_cpu" in + powerpc*) dynamic_linker=no ;; + *) dynamic_linker='Linux ld.so' ;; + esac + fi + ;; + +netbsd* | openbsd*) + version_type=sunos + library_names_spec='$libname.so.$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +osf3* | osf4*) + version_type=osf + soname_spec='$libname.so' + library_names_spec='$libname.so.$versuffix $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sco3.2v5*) + version_type=osf + soname_spec='$libname.so.$major' + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris2*) + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname.so.$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t""$dynamic_linker" +test "$dynamic_linker" = no && can_build_shared=no + +# FIXME need to add library stripping features +# strip -x works for most platforms, though not for static libraries on NetBSD +# HP-UX requires "-r" for library stripping +striplib= +old_striplib= + +#echo $ac_n "checking for static library strip program... $ac_c" 1>&6 +#if test -n "$old_striplib"; then +# echo $ac_t "$old_striplib" 1>&6 +#else +# echo $ac_t none 1>&6 +#fi + +#if test "$can_build_shared" = yes; then +# echo $ac_n "checking for shared library strip program... $ac_c" 1>&6 +# +# if test -n "$striplib"; then +# echo $ac_t "$striplib" 1>&6 +# else +# echo $ac_t none 1>&6 +# fi +#fi + +# Report the consequences. +echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 + +echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace. +case "$host_os" in +aix*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds;\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +esac + +echo "$ac_t""$enable_shared" 1>&6 + +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes + +echo "checking whether to build static libraries... $enable_static" 1>&6 + +ofile=libtool +trap "$rm $ofile; exit 1" 1 2 15 +echo creating $ofile +rm -fr $ofile +cat < $ofile +#! /bin/sh + +# libtool - Provide generalized library-building support services. +# +# Generated automatically by $PROGRAM - GNU $PACKAGE $VERSION +# This program was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# CC="$old_CC" CFLAGS="$old_CFLAGS" CPPFLAGS="$old_CPPFLAGS" \\ +# LD="$old_LD" RANLIB="$old_RANLIB" LN_S="$old_LN_S" \\ +# $0$ltconfig_args +# +# Compiler and other test output produced by $progname, useful for +# debugging $progname, is in ./config.log if it exists. + +# The version of $progname that generated this script. +LTCONFIG_VERSION="$VERSION" + +# Whether or not to build libtool libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build old-style libraries. +build_old_libs=$enable_static + +# The host system. +host_alias="$host_alias" +host="$host" + +# The archiver. +AR='$AR' + +# The linker used to build libraries. +LD='$LD' + +# Whether we need hard or soft links. +LN_S='$LN_S' + +# How to create reloadable object files. +reload_flag='$reload_flag' +reload_cmds='$reload_cmds' + +# How to pass a linker flag through the compiler. +wl='$wl' + +# Additional compiler flags for building library objects. +pic_flag='$pic_flag' + +# Compiler flag to prevent dynamic linking. +link_static_flag='$link_static_flag' + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag='$export_dynamic_flag' + +# Pattern to match compiler flags for creating libNAME_p libraries: +profile_flag_pattern='$profile_flag_pattern' + +# Library versioning type. +version_type=$version_type + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec='$library_names_spec' + +# The coded name of the library, if different from the real name. +soname_spec='$soname_spec' + +# Commands used to build and install an old-style archive. +RANLIB='$RANLIB' +old_archive_cmds='$old_archive_cmds' +old_postinstall_cmds='$old_postinstall_cmds' + +# Commands used to build and install a shared archive. +archive_cmds='$archive_cmds' +postinstall_cmds='$postinstall_cmds' + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag='$allow_undefined_flag' + +# Commands used to finish a libtool library installation in a directory. +finish_cmds='$finish_cmds' + +# How to strip a library file. +striplib='$striplib' +old_striplib='$old_striplib' + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec='$hardcode_libdir_flag_spec' + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator='$hardcode_libdir_separator' + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using RUNPATH_VAR=DIR during linking hardcodes DIR into the +# resulting binary. +hardcode_runpath_var=$hardcode_runpath_var + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +EOF + +# Detect if we are using a relative or absolute path to ltmain.sh. +case "$ltmain" in +/*) cat <> $ofile +# Execute the libtool backend. +. $ltmain +EOF2 + ;; +*) cat <> $ofile +# Find the path to this script. +thisdir=\`echo "\$0" | sed -e 's%/[^/]*\$%%'\` +test "X\$0" = "X\$thisdir" && thisdir=. + +# Execute the libtool backend. +. \$thisdir/$ltmain +EOF3 + ;; +esac + +echo 'exit 1' >> $ofile + +chmod +x $ofile +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/ltmain.sh b/ltmain.sh new file mode 100644 index 000000000000..cda618977f0f --- /dev/null +++ b/ltmain.sh @@ -0,0 +1,1819 @@ +# ltmain.sh - Provide generalized library-building support services. +# Generated automatically from ltmain.sh.in by configure. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Gordon Matzigkeit , 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 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# The name of this program. +progname=`echo "$0" | sed 's%^.*/%%'` + +# Constants. +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.0 + +default_mode= +help="Try \`$progname --help' for more information." +magic="%%%MAGIC variable%%%" +mkdir="mkdir" +mv="mv -f" +objdir=.libs +rm="rm -f" + +if test "$LTCONFIG_VERSION" != "$VERSION"; then + echo "$progname: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + echo "$progname: not configured to build any kind of library" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show=echo +show_help= + +# Parse our command line options once, thoroughly. +while test $# -gt 0 +do + arg="$1" + shift + + case "$arg" in + -*=*) optarg=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$arg" + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case "$arg" in + --help) + show_help=yes + ;; + + --version) + echo "$PROGRAM (GNU $PACKAGE) $VERSION" + exit 0 + ;; + + --dry-run | -n) + run=: + ;; + + --features) + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + -*) + echo "$progname: unrecognized option \`$arg'" 1>&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + + +if test -n "$prevopt"; then + echo "$progname: option \`$prevopt' requires an argument" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + case "$nonopt" in + *cc) + mode=link + for arg + do + case "$arg" in + -c) + mode=compile + break + ;; + esac + done + ;; + *install*|cp) + mode=install + ;; + *rm) + mode=uninstall + ;; + *.la) + mode=dlname + ;; + *) + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + echo "$progname: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + echo "$progname: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$progname --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case "$mode" in + # libtool compile mode + compile) + progname="$progname: compile" + # Get the compilation command and the source file. + base_compile="$nonopt" + lastarg= + srcfile= + + for arg + do + # Quote any args containing shell metacharacters. + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*|*\"*) + quote_arg="'$arg'" ;; + *) quote_arg="$arg" ;; + esac + + base_compile="$base_compile$lastarg" + srcfile="$quote_arg" + lastarg=" $srcfile" + done + + # Get the name of the library object. + libobj=`echo "$srcfile" | sed -e 's%^.*/%%'` + + # Recognize several different file suffixes. + xform='[cCFSf]' + case "$libobj" in + *.c++) xform='c++' ;; + *.cc) xform=cc ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform='for' ;; + esac + + libobj=`echo "$libobj" | sed -e "s/\.$xform$/.lo/"` + + case "$libobj" in + *.lo) obj=`echo "$libobj" | sed -e 's/\.lo$/.o/'` ;; + *) + echo "$progname: cannot determine name of library object from \`$srcfile'" 1>&2 + exit 1 + ;; + esac + + if test -z "$base_compile"; then + echo "$progname: you must specify a compilation command" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + $run $rm $obj $libobj + trap "$run $rm $obj $libobj; exit 1" 1 2 15 + else + $run $rm $libobj + trap "$run $rm $libobj; exit 1" 1 2 15 + fi + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # All platforms use -DPIC, to notify preprocessed assembler code. + $show "$base_compile$pic_flag -DPIC $srcfile" + if $run eval "$base_compile$pic_flag -DPIC $srcfile"; then : + else + test -n "$obj" && $run $rm $obj + exit 1 + fi + + # If we have no pic_flag, then copy the object into place and finish. + if test -z "$pic_flag"; then + $show "$LN_S $obj $libobj" + $run $LN_S $obj $libobj + exit $? + fi + + # Just move the object, then go on to compile the next one + $show "$mv $obj $libobj" + $run $mv $obj $libobj || exit 1 + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + $show "$base_compile $srcfile" + if $run eval "$base_compile $srcfile"; then : + else + $run $rm $obj $libobj + exit 1 + fi + fi + + # Create an invalid libtool object if no PIC, so that we don't accidentally + # link it into a program. + if test "$build_libtool_libs" != yes; then + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + fi + + exit 0 + ;; + + # libtool link mode + link) + progname="$progname: link" + # Go through the arguments, transforming them on the way. + cc="$nonopt" + args="$cc" + allow_undefined=no + compile_command="$cc" + finalize_command="$cc" + compile_shlibpath= + finalize_shlibpath= + deplibs= + export_dynamic=no + hardcode_libdirs= + install_libdir= + libobjs= + link_against_libtool_libs= + link_static= + ltlibs= + objs= + prev= + prevarg= + perm_rpath= + temp_rpath= + vinfo= + + # We need to know -static, to get the right output filenames. + for arg + do + case "$arg" in + -static) + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + for arg + do + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + args="$args $arg" + ;; + esac + + eval "$prev=\$arg" + prev= + + continue + fi + + args="$args $arg" + prevarg="$arg" + + case "$arg" in + -allow-undefined) allow_undefined=yes ;; + + -export-dynamic) + export_dynamic=yes + compile_command="$compile_command $export_dynamic_flag" + finalize_command="$finalize_command $export_dynamic_flag" + continue + ;; + + -L*) + dir=`echo "$arg" | sed 's%^-L\(.*\)$%\1%'` + case "$dir" in + /*) + ;; + *) + echo "$progname: \`-L$dir' cannot specify a relative directory" 1>&2 + exit 1 + ;; + esac + deplibs="$deplibs $arg" + ;; + + -l*) deplibs="$deplibs $arg" ;; + + -o) prev=output ;; + + -rpath) + prev=install_libdir + continue + ;; + + -static) + link_static="`eval echo \"$link_static_flag\"`" + compile_command="$compile_command $link_static" + continue + ;; + + -version-file) + echo "$progname: \`-version-file' has been replaced by \`-version-info'" 1>&2 + echo "$help" 1>&2 + exit 1 + ;; + + -version-info) + prev=vinfo + continue + ;; + + -*) cc="$cc $arg" ;; # Some other compiler flag. + + *.o) + # A standard object. + objs="$objs $arg" + ;; + + *.a) + # Find the relevant object directory and library name. + file=`echo "$arg" | sed 's%^.*/%%'` + dir=`echo "$arg" | sed 's%/[^/]*$%/%'` + test "$dir" = "$arg" && dir= + + # Standard archive. + objs="$objs $arg" + ;; + + *.lo) + # A library object. + libobjs="$libobjs $arg" + ;; + + *.la) + # A libtool-controlled library. + + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if egrep "^# Generated by $PROGRAM" $arg >/dev/null 2>&1; then : + else + echo "$progname: \`$arg' is not a valid libtool archive" 1>&2 + exit 1 + fi + + # If there is no directory component, then add one. + case "$arg" in + */*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$libdir"; then + echo "$progname: \`$arg' contains no -rpath information" 1>&2 + exit 1 + fi + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + echo "$progname: cannot find name of link library for \`$arg'" 1>&2 + exit 1 + fi + + # Find the relevant object directory and library name. + name=`echo "$arg" | sed 's%^.*/%%; s/\.la$//; s/^lib//'` + dir=`echo "$arg" | sed 's%/[^/]*$%%'` + if test "$dir" = "$arg"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + + if test "$build_libtool_libs" = yes && test -n "$library_names"; then + link_against_libtool_libs="$link_against_libtool_libs $arg" + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + "* $dir *") ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + # Put the magic libdir with the hardcode flag. + hardcode_libdirs="$libdir" + libdir="@HARDCODE_LIBDIRS@" + else + # Just accumulate the libdirs. + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + libdir= + fi + fi + + if test -n "$libdir"; then + hardcode_libdir_flag=`eval echo \"$hardcode_libdir_flag_spec\"` + compile_command="$compile_command $hardcode_libdir_flag" + finalize_command="$finalize_command $hardcode_libdir_flag" + fi + elif test "$hardcode_runpath_var" = yes; then + # Do the same for the permanent run path. + case "$perm_rpath " in + "* $libdir *") ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + + + case "$hardcode_action" in + immediate) + if test "$hardcode_direct" = no; then + compile_command="$compile_command $dir/$linklib" + elif test "$hardcode_minus_L" = no; then + compile_command="$compile_command -L$dir -l$name" + elif test "$hardcode_shlibpath_var" = no; then + compile_shlibpath="$compile_shlibpath$dir:" + compile_command="$compile_command -l$name" + fi + ;; + + relink) + # We need an absolute path. + case "$dir" in + /*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + echo "$progname: cannot determine absolute directory name of \`$dir'" 1>&2 + exit 1 + fi + dir="$absdir" + ;; + esac + + if test "$hardcode_direct" = yes; then + compile_command="$compile_command $dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + compile_command="$compile_command -L$dir -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + compile_shlibpath="$compile_shlibpath$dir:" + compile_command="$compile_command -l$name" + fi + ;; + + *) + echo "$progname: \`$hardcode_action' is an unknown hardcode action" 1>&2 + exit 1 + ;; + esac + + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + finalize_command="$finalize_command $libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + finalize_command="$finalize_command -L$libdir -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + finalize_shlibpath="$finalize_shlibpath$libdir:" + finalize_command="$finalize_command -l$name" + else + # We can't seem to hardcode it, guess we'll fake it. + finalize_command="$finalize_command -L$libdir -l$name" + fi + else + # Transform directly to old archives if we don't build new libraries. + if test -n "$pic_flag" && test -z "$old_library"; then + echo "$progname: cannot find static library for \`$arg'" 1>&2 + exit 1 + fi + test -n "$old_library" && linklib="$old_library" + compile_command="$compile_command $dir/$linklib" + finalize_command="$finalize_command $dir/$linklib" + fi + continue + ;; + + *) + echo "$progname: unknown file suffix for \`$arg'" 1>&2 + echo "$help" 1>&2 + exit 1 + ;; + esac + + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + done + + if test -n "$prev"; then + echo "$progname: the \`$prevarg' option requires an argument" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + # Substitute the hardcoded libdirs into the compile commands. + if test "$hardcode_libdir_colon_separated" = yes; then + compile_command=`echo "$compile_command" | sed "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` + finalize_command=`echo "$finalize_command" | sed "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` + fi + + oldlib= + oldobjs= + case "$output" in + "") + echo "$progname: you must specify an output file" 1>&2 + echo "$help" 1>&2 + exit 1 + ;; + + */*) + echo "$progname: output file \`$output' must have no directory components" 1>&2 + exit 1 + ;; + + *.la) + libname=`echo "$output" | sed 's/\.la$//'` + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + current=0 + revision=0 + age=0 + + if test -n "$objs"; then + echo "$progname: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 + exit 1 + fi + + # How the heck are we supposed to write a wrapper for a shared library? + if test -n "$link_against_libtool_libs"; then + echo "$progname: libtool library \`$output' may not depend on uninstalled libraries:$link_against_libtool_libs" 1>&2 + exit 1 + fi + + if test -z "$install_libdir"; then + echo "$progname: you must specify an installation directory with \`-rpath'" 1>&2 + exit 1 + fi + + # Parse the version information argument. + IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' + set dummy $vinfo + IFS="$save_ifs" + + if test -n "$5"; then + echo "$progname: too many parameters to \`-version-info'" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + test -n "$2" && current="$2" + test -n "$3" && revision="$3" + test -n "$4" && age="$4" + + # Check that each of the things are valid numbers. + case "$current" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + echo "$progname: CURRENT \`$current' is not a nonnegative integer" 1>&2 + echo "$progname: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$revision" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + echo "$progname: REVISION \`$revision' is not a nonnegative integer" 1>&2 + echo "$progname: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$age" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + echo "$progname: AGE \`$age' is not a nonnegative integer" 1>&2 + echo "$progname: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test $age -gt $current; then + echo "$progname: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + echo "$progname: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + version_vars="version_type current age revision" + case "$version_type" in + none) ;; + + linux) + version_vars="$version_vars major versuffix" + major=`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + version_vars="$version_vars versuffix verstring" + major=`expr $current - $age` + versuffix="$current.$age.$revision" + verstring="$versuffix" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test $loop != 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + version_vars="$version_vars major versuffix" + major="$current" + versuffix="$current.$revision" + ;; + + *) + echo "$progname: unknown library version type \`$version_type'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Create the output directory, or remove our outputs if we need to. + if test -d $objdir; then + $show "$rm $objdir/$libname.*" + $run $rm $objdir/$libname.* + else + $show "$mkdir $objdir" + $run $mkdir $objdir || exit $? + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + echo "$progname: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + fi + else + # Clear the flag. + allow_undefined_flag= + fi + + if test "$build_libtool_libs" = yes; then + # Get the real and link names of the library. + library_names=`eval echo \"$library_names_spec\"` + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + soname=`eval echo \"$soname_spec\"` + else + soname="$realname" + fi + + lib="$objdir/$realname" + linknames= + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are PIC. + test -z "$pic_flag" && libobjs=`echo "$libobjs " | sed 's/\.lo /.o /g; s/ $//g'` + + # Do each of the archive commands. + cmds=`eval echo \"$archive_cmds\"` + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Create links to the real library. + for link in $linknames; do + $show "(cd $objdir && $LN_S $realname $link)" + $run eval "(cd $objdir && $LN_S $realname $link)" || exit $? + done + + # If -export-dynamic was specified, set the dlname. + if test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + *.lo | *.o) + if test -n "$link_against_libtool_libs"; then + echo "$progname: error: cannot link libtool libraries into reloadable objects" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + echo "$progname: warning: \`-l' and \`-L' are ignored while creating objects" 1>&2 + fi + + if test -n "$install_libdir"; then + echo "$progname: warning: \`-rpath' is ignored while creating objects" 1>&2 + fi + + if test -n "$vinfo"; then + echo "$progname: warning: \`-version-info' is ignored while creating objects" 1>&2 + fi + + case "$output" in + *.lo) + if test -n "$objs"; then + echo "$progname: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`echo "$output" | sed 's/\.lo$/.o/'` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Create the old-style object. + reload_objs="$objs"`echo "$libobjs " | sed 's/[^ ]*\.a //g; s/\.lo /.o /g; s/ $//g'` + + output="$obj" + cmds=`eval echo \"$reload_cmds\"` + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + test -z "$libobj" && exit 0 + + if test "$build_libtool_libs" != yes; then + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs" + output="$libobj" + cmds=`eval echo \"$reload_cmds\"` + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + else + # Just create a symlink. + $show "$LN_S $obj $libobj" + $run $LN_S $obj $libobj || exit 1 + fi + + exit 0 + ;; + + *) + if test -n "$install_libdir"; then + echo "$progname: warning: \`-rpath' is ignored while linking programs" 1>&2 + fi + + if test -n "$vinfo"; then + echo "$progname: warning: \`-version-info' is ignored while linking programs" 1>&2 + fi + + if test -n "$libobjs"; then + # Transform all the library objects into standard objects. + compile_command=`echo "$compile_command " | sed 's/\.lo /.o /g; s/ $//'` + finalize_command=`echo "$finalize_command " | sed 's/\.lo /.o /g; s/ $//'` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`echo "$compile_command" | sed 's%@OUTPUT@%'"$output"'%g'` + finalize_command=`echo "$finalize_command" | sed 's%@OUTPUT@%'"$output"'%g'` + + # We have no uninstalled library dependencies, so finalize right now. + $show "$compile_command" + $run $compile_command + status=$? + + # If we failed to link statically, then try again. + if test $status -ne 0 && test -n "$link_static"; then + echo "$progname: cannot link \`$output' statically; retrying semi-dynamically" 1>&2 + compile_command=`echo "$compile_command " | sed "s% $link_static % %;s/ $//"` + $show "$finalize_command" + $run $finalize_command + status=$? + fi + exit $status + fi + + # Replace the output file specification. + compile_command=`echo "$compile_command" | sed 's%@OUTPUT@%'"$objdir/$output"'%g'` + finalize_command=`echo "$finalize_command" | sed 's%@OUTPUT@%'"$objdir/$output"'T%g'` + + # Create the binary in the object directory, then wrap it. + if test -d $objdir; then : + else + $show "$mkdir $objdir" + $run $mkdir $objdir || exit $? + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + /*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + # Delete the old output file. + $run $rm $output + + if test -n "$compile_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command" + finalize_command="$runpath_var=\"$rpath\$$runpath_var\" $finalize_command" + fi + + case "$hardcode_action" in + relink) + # AGH! Flame the AIX and HP-UX people for me, will ya? + echo "$progname: warning: using a buggy system linker" 1>&2 + echo "$progname: relinking will be required before \`$output' can be installed" 1>&2 + ;; + esac + + $show "$compile_command" + $run eval "$compile_command" || exit $? + + # Now create the wrapper script. + echo "creating $output" + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + cat > $output <> $output <> $output <&2 + echo "This script is just a wrapper for \$program." 1>&2 + echo "See the $PACKAGE documentation for more information." 1>&2 + exit 1 + fi +fi +EOF + chmod +x $output + fi + exit 0 + ;; + esac + + + # See if we need to build an old-fashioned archive. + if test "$build_old_libs" = "yes"; then + # Now set the variables for building old libraries. + oldlib="$objdir/$libname.a" + + # Transform .lo files to .o files. + oldobjs="$objs"`echo "$libobjs " | sed 's/[^ ]*\.a //g; s/\.lo /.o /g; s/ $//g'` + + if test -d "$objdir"; then + $show "$rm $oldlib" + $run $rm $oldlib + else + $show "$mkdir $objdir" + $run $mkdir $objdir + fi + + # Do each command in the archive commands. + cmds=`eval echo \"$old_archive_cmds\"` + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.a" + + echo "creating $output" + + # Only create the output if not a dry run. + if test -z "$run"; then + cat > $output <&2 + echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + echo "$progname: the \`$prev' option requires an argument" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + echo "$progname: no file or destination specified" 1>&2 + else + echo "$progname: you must specify a destination" 1>&2 + fi + echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`echo "$dest" | sed 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test -n "$isdir"; then + destdir="$dest" + destname= + else + destdir=`echo "$dest" | sed 's%/[^/]*$%%'` + test "$destdir" = "$dest" && destdir=. + destname=`echo "$dest" | sed 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + echo "$progname: \`$dest' is not a directory" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + /*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + echo "$progname: \`$destdir' must be an absolute directory name" 1>&2 + echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if egrep "^# Generated by $PROGRAM" $file >/dev/null 2>&1; then : + else + echo "$progname: \`$file' is not a valid libtool archive" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + # If there is no directory component, then add one. + case "$file" in + */*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "$destdir" = "$libdir"; then + case "$current_libdirs " in + "* $libdir *") ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + "* $libdir *") ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`echo "$file" | sed 's%/[^/]*$%%'`/" + test "$dir" = "$file/" && dir= + dir="$dir$objdir" + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$realname $destdir/$realname" + $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + test "X$dlname" = "X$realname" && dlname= + + # Support stripping libraries. + if test -n "$stripme"; then + if test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run $striplib $destdir/$realname || exit $? + else + echo "$progname: warning: no library stripping program" 1>&2 + fi + fi + + if test $# -gt 0; then + # Delete the old symlinks. + rmcmd="$rm" + for linkname + do + rmcmd="$rmcmd $destdir/$linkname" + done + $show "$rmcmd" + $run $rmcmd + + # ... and create new ones. + for linkname + do + test "X$dlname" = "X$linkname" && dlname= + $show "(cd $destdir && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $LN_S $realname $linkname)" + done + fi + + if test -n "$dlname"; then + # Install the dynamically-loadable library. + $show "$install_prog $dir/$dlname $destdir/$dlname" + $run eval "$install_prog $dir/$dlname $destdir/$dlname" || exit $? + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + cmds=`eval echo \"$postinstall_cmds\"` + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`echo "$file" | sed 's%^.*/%%'` + $show "$install_prog $file $destdir/$name" + $run $install_prog $file $destdir/$name || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`echo "$file" | sed 's%^.*/%%;'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`echo "$destfile" | sed 's/\.lo$/\.o/;'` + ;; + *.o) + staticdest="$destfile" + destfile= + ;; + *) + echo "$progname: cannot copy a libtool object to \`$destfile'" 1>&2 + echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run $install_prog $file $destfile || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`echo "$file" | sed 's/\.lo$/\.o/;'` + + $show "$install_prog $staticobj $staticdest" + $run $install_prog $staticobj $staticdest || exit $? + fi + exit 0 + ;; + + *) + # Do a test to see if this is really a libtool program. + if egrep "^# Generated by $PROGRAM" $file >/dev/null 2>&1; then + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + link_against_libtool_libs= + finalize_command= + + # If there is no directory component, then add one. + case "$file" in + */*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs" || test -z "$finalize_command"; then + echo "$progname: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`echo "$lib" | sed 's%^.*/%%g'`" + if test -z "$libdir"; then + echo "$progname: warning: \`$lib' contains no -rpath information" 1>&2 + elif test -f "$libfile"; then : + else + echo "$progname: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + if test "$hardcode_action" = relink; then + if test "$finalize" = yes; then + echo "$progname: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2 + $show "$finalize_command" + if $run $finalize_command; then : + else + echo "$progname: error: relink \`$file' with the above command before installing it" 1>&2 + continue + fi + file="$objdir/$file"T + else + echo "$progname: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 + fi + else + # Install the binary that we compiled earlier. + dir=`echo "$file" | sed 's%/[^/]*$%%'` + if test "$file" = "$dir"; then + file="$objdir/$file" + else + file="$dir/$objdir/`echo "$file" | sed 's%^.*/%%'`" + fi + fi + fi + + $show "$install_prog$stripme $file $dest" + $run $install_prog$stripme $file $dest || exit $? + ;; + esac + done + + for file in $staticlibs; do + name=`echo "$file" | sed 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run $install_prog $file $oldlib || exit $? + + # Support stripping libraries. + if test -n "$stripme"; then + if test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run $old_striplib $oldlib || exit $? + else + echo "$progname: warning: no static library stripping program" 1>&2 + fi + fi + + # Do each command in the postinstall commands. + cmds=`eval echo \"$old_postinstall_cmds\"` + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + echo "$progname: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool dlname mode + dlname) + progname="$progname: dlname" + ltlibs="$nonopt" + for lib + do + ltlibs="$ltlibs $lib" + done + + if test -z "$ltlibs"; then + echo "$progname: you must specify at least one LTLIBRARY" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + # Now check to make sure each one is a valid libtool library. + status=0 + for lib in $ltlibs; do + dlname= + libdir= + library_names= + + # Check to see that this really is a libtool archive. + if egrep "^# Generated by $PROGRAM" $arg >/dev/null 2>&1; then : + else + echo "$progname: \`$arg' is not a valid libtool archive" 1>&2 + status=1 + continue + fi + + # If there is no directory component, then add one. + case "$arg" in + */*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$libdir"; then + echo "$progname: \`$arg' contains no -rpath information" 1>&2 + status=1 + elif test -n "$dlname"; then + echo "$libdir/$dlname" + elif test -z "$library_names"; then + echo "$progname: \`$arg' is not a shared library" 1>&2 + status=1 + else + echo "$progname: \`$arg' was not linked with \`-export-dynamic'" 1>&2 + status=1 + fi + done + exit $status + ;; + + # libtool finish mode + finish) + progname="$progname: finish" + libdirs="$nonopt" + + if test -n "$finish_cmds" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + # Do each command in the postinstall commands. + cmds=`eval echo \"$finish_cmds\"` + IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + done + fi + + echo "To link against installed libraries in LIBDIR, users may have to:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to their \`$shlibpath_var' environment variable" + fi + echo " - use the \`-LLIBDIR' linker flag" + exit 0 + ;; + + # libtool uninstall mode + uninstall) + progname="$progname: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + echo "$progname: you must specify an RM program" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`echo "$file" | sed -e 's%/[^/]*$%%'` + test "$dir" = "$file" && dir=. + name=`echo "$file" | sed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if egrep "^# Generated by $PROGRAM" $file >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + test "X$n" = "X$dlname" && dlname= + done + test -n "$dlname" && rmfiles="$rmfiles $dir/$dlname" + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`echo "$name" | sed 's/\.lo$/\.o/'` + rmfiles="$rmfiles $dir/$oldobj" + fi + ;; + esac + + $show "$rm $rmfiles" + $run $rm $rmfiles + done + exit 0 + ;; + + NONE) + echo "$progname: you must specify a MODE" 1>&2 + echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + echo "$progname: invalid operation mode \`$mode'" 1>&2 + echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +NONE) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; +esac + +case "$mode" in +archive|compile) + echo + echo "Try \`$progname --help' for more information about other modes." + ;; +esac + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/missing b/missing new file mode 100755 index 000000000000..a6abd069801c --- /dev/null +++ b/missing @@ -0,0 +1,134 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Franc,ois Pinard , 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. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison touch file \`y.tab.c' + makeinfo touch the output file + yacc touch file \`y.tab.c'" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing - GNU libit 0.0" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`configure.in'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`configure.in'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`configure.in'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + touch config.h.in + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print \ + | sed 's/^\(.*\).am$/touch \1.in/' \ + | sh + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + touch y.tab.c + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 000000000000..cc8783edce30 --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,36 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Last modified: 1994-03-25 +# Public domain + +errstatus=0 + +for file in ${1+"$@"} ; do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d in ${1+"$@"} ; do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$? + fi + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/move-if-change b/move-if-change new file mode 100755 index 000000000000..565825f35bcd --- /dev/null +++ b/move-if-change @@ -0,0 +1,32 @@ +#!/bin/sh + +# Copyright (C) 1996 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 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +if +test -r $2 +then +if +cmp $1 $2 > /dev/null +then +echo $2 is unchanged +rm -f $1 +else +mv -f $1 $2 +fi +else +mv -f $1 $2 +fi diff --git a/mpw-README b/mpw-README new file mode 100644 index 000000000000..767140b5b263 --- /dev/null +++ b/mpw-README @@ -0,0 +1,376 @@ +This is basic information about the Macintosh(tm) MPW(tm) port of the +GNU tools. The information below applies to both native and cross +compilers. + +(Please note that there are two versions of this file; "mpw-README" +is the source form, and "Read Me for MPW" is the distribution form. +"Read Me for MPW" has 8-bit chars such as \Option-d embedded in it.) + +INSTALLING GNU TOOLS + +* System Requirements + +To use these tools, you will need a Mac with a 68020 or better or else +any PowerMac, System 7.1 or later, and MPW 3.3 or 3.4. You will *not* +need any other MPW compiler unless you want to rebuild from sources, +nor even any include files, unless you are building actual Mac +applications. For PowerMac native you will need PPCLink, however; +also the executables are PowerPC-only. + +* Automated Installation + +The simplest way to install GNU tools is to run the Install script. +The script will copy things to where you want to keep them, will build +a UserStartup file with settings corresponding to where things were +copied, and offer to put that UserStartup file in your MPW folder. + +The Install script does not alter anything in the System Folder, and +it does not take any action without confirmation. + +The Install script will be at the top level of the binary +distribution, or at the top level of the object directory if +rebuilding from source. (The sources include a file called +"mpw-install" at the top level, but it is the source to the Install +script and cannot be run directly.) + +* Manual Installation + +If you don't want to run the Install script, you can do installation +manually; this section describes the steps involved. + +The GNU tools can go in any directory that is in your {Commands} list. +We generally put all the tools somewhere like {Boot}Cygnus:latest:bin, +and then add to a UserStartup file: + + set Commands "{Boot}Cygnus:latest:bin:,{Commands}" + +However, the cpp and cc1 programs of GCC are not normally stored here. +Instead, they will be in a "lib" directory that is alongside "bin", +and organized by target and version underneath, with names like + + :lib:gcc-lib::cygnus-: + +If you build and install everything yourself according to the build +instructions below, then you will not have any problems. However, you +may discover that GCC seems unable to find the right cpp and cc1; +usually this will be because directory names have changed. (Even +renaming your hard disk will make this happen.) In such cases, you +have several choices. One is just to add this directory to +{Commands}, but then you will not be able to get any other cpp or cc1, +such as those used by a different target or version. Another way is +to rename your disk and directories to match the prefix used when the +tools were compiled. Finally, you can set the variable +GCC_EXEC_PREFIX to point to the library directory: + + set GCC_EXEC_PREFIX MyDisk:Stuff:lib:gcc-lib: + export GCC_EXEC_PREFIX + +You may also want to edit MPW's HEXA 128 resource. When GCC is built +using a native GCC, it is compiled to use a special stack allocator +function alloca(). While this is very efficient, it means that GCC +will need considerable stack space to run, especially when compiling +large programs with optimization turned on. You give MPW more stack +by editing the HEXA 128 resource of the MPW Shell. A value of "0008 +0000" gives 512K of stack size, which is usually sufficient. + +USING GNU TOOLS + +* Using Native PowerMac GCC + +Using a native PowerMac GCC to produce MPW tools or MacOS applications +is more complicated than just "gC foo.c", although no more complicated +than with other Mac compilers. + +To build a native PowerMac MPW tool, use this sequence, where hello.c +is the usual "hello world" program, and genericcfrg.r is the Rez file +with the code fragment resource: + +gC -I{CIncludes} -fno-builtin -Dpascal= -c -g hello.c +PPCLink hello.o -o hello \Option-d + "{PPCLibraries}"StdCRuntime.o \Option-d + "{SharedLibraries}"InterfaceLib \Option-d + "{SharedLibraries}"StdCLib \Option-d + "{PPCLibraries}"PPCToolLibs.o \Option-d + "{PPCLibraries}"PPCCRuntime.o \Option-d + "{GCCPPCLibraries}"libgcc.xcoff +rez -d APPNAME='"'hello'"' GenericCFRG.r -o hello +setfile -t 'MPST' -c 'MPS ' hello + +The same sequence works to build a MacOS application, but you set the file +type to 'APPL' and don't link in PPCToolLibs.o. For further details on +using MPW to build Mac applications, see the general MPW documentation. + +Recent versions of PPCLink have an option to generate the code +fragment resource and automatically set creator and file type; +here is what GenericCFRG.r should look like if you have an older +PPCLink or are using GNU ld: + +#include "CodeFragmentTypes.r" + +resource 'cfrg' (0) { + { + kPowerPC, + kFullLib, + kNoVersionNum,kNoVersionNum, + 0,0, + kIsApp,kOnDiskFlat,kZeroOffset,kWholeFork, + APPNAME // must be defined on Rez command line with -d option + } +}; + +In general this port of GCC supports the same option syntax and +behavior as its Unix counterpart. It also has similar compilation +rules, so it will run the assembler on .s files and so forth. + +The GCC manual includes full information on the available options. +One option that may be especially useful is "-v", which shows you what +tools and options are being used; unlike most Mac C compilers, GCC +directs assembly and linking in addition to compilation. + +MPW GCC does feature two extensions to the option syntax; '-d macro=name' +works just as '-Dmacro=name' does in Unix, and '-i directory' works the +same as '-Idirectory'. + +MPW GCC supports the usual Pascal-style strings and alignment pragmas. + +To find standard include files you can set the variable GCCIncludes: + + set GCCIncludes MyDisk:MyIncludes: + export GCCIncludes + +GCCIncludes is similar to MPW's CIncludes or CW's MWCIncludes. In +order to use MPW's usual include files, just say: + + set GCCIncludes "{CIncludes}" + export GCCIncludes + +* Using GCC as a Cross-Compiler + +If you have a cross-compiler, and you have all of the correct +target-side crt0 and libraries available, then to compile and link a +file "foo.c", you can say just + + gC foo.c + +The output file will be an MPW binary file named "a.out"; the format +of the contents will depend on which target is in use, so for instance +a MIPS-targeting GCC will produce ECOFF or ELF executables. + +Note that using MPW include files with a cross-compiler is somewhat +dangerous. + +* Using the Assembler and Friends + +The assembler ("as") and linker ("ld") are faithful ports of their +Unix counterparts. Similarly, the binutils "ar", "cplusfilt", "nm", +"objcopy", "objdump", "ranlib", "size", "strings", and "strip" are all +like they are under Unix. (Note that "cplusfilt" is usually called +"c++filt" under Unix.) + +* Using GDB + +There are two flavors of GDB. "gdb" is an MPW tool that works very +much like it does in Unix; put a command into the MPW worksheet and +type the key to send it to GDB. While "gdb" is running, you +cannot do anything else in MPW, although you can switch to other +Mac applications and use them. + +"SiowGDB" is also a Mac application, but it is GDB using the SIOW +package to provide console emulation. Commands are exactly as for the +MPW tool, but since this is its own application, you can switch +between it and MPW. + +BUILDING GNU TOOLS + +This port of the GNU tools uses a configure script similar to +that used for GNU tools under Unix, but rewritten for MPW. As with +Unix configuration, there is an "object" directory that may be +different from the "source" directory. In the example commands below, +we will assume that we are currently in the object directory, and that +the source directory is "{Boot}Cygnus:src:". + +* Requirements for Building + +In addition to the sources, you will need a set of tools that the +configure and build scripts assume to be available. These tools +(and their versions, if relevant) are as follows: + + byacc tool + flex (2.3.7) tool (and Flex.skel file) + forward-include script + MoveIfChange script + mpw-touch script + mpw-true script + NewFolderRecursive script + null-command script + open-brace script + sed (1.13) tool + tr-7to8 script + true script + +The scripts are in the sources, under utils:mpw:. You must arrange to +get the other tools yourself (they are readily available from the +"usual" net sites, and are also on many CDROMS). In addition, there +will usually be a set of these available at ftp.cygnus.com, in pub/mac. + +You may put the build tools in your usual Tools or Scripts +directories, or keep them in a separate directories. We prefer to +make a directory called "buildtools" and we put this in one of our +UserStartup files: + + set Commands "{Boot}Cygnus:buildtools:,{Commands}" + +Flex uses an environment variable FLEX_SKELETON to locate its skeleton +file, so you need to do something like this, preferably in a UserStartup: + + Set FLEX_SKELETON "{Boot}"Cygnus:buildtools:Flex.skel + Export FLEX_SKELETON + +* Configuring + +Before you can build anything, you must configure. You do this by +creating an directory where object files will be stored, setdirectory +to that directory and do a configure command: + + {Boot}Cygnus:src:mpw-configure --target --cc --srcdir {Boot}Cygnus:src: --prefix + +If the source directory is not in your {Commands} list, then you must +supply a full pathname to mpw-configure, since mpw-configure invokes +itself after switching into each subdirectory. Using a relative +pathname, even something like ':mpw-configure', will therefore not work. + + must be a known target. Valid ones include "m68k-apple-macos", +"powerpc-apple-macos", "i386-unknown-go32", "mips-idt-ecoff", and +"sh-hitachi-hms". Not all target types are accepted for all of the +tools yet. + + must be the name of the compiler to use. It defaults to "mpwc". + + (m68k) + mpwc MPW C + sc68k Symantec C + mwc68k Metrowerks C (Codewarrior) + gcc68k GCC + + (powerpc) + ppcc PPCC + mrc Macintosh on RisC (Mister C, aka(?) Frankenstein) + scppc Symantec C + mwcppc Metrowerks C (Codewarrior) + gccppc GCC + +Not all compilers will compile all tools equally well! For m68k Macs, +MPW C has the best record so far (it has problems, but they can be +worked around), while for PowerMacs, CodeWarrior is the only compiler +that has successfully compiled everything into running code. + + is the path that "gcc" will prepend when looking for tools +to execute. GCC_EXEC_PREFIX overrides this value, so you need not +include it if you plan to use GCC_EXEC_PREFIX. + +As an example, here is the configure line that you could use to build +native PowerMac GCC: + +"{Boot}"Cygnus:src:mpw-configure --cc mwcppc --target powerpc-apple-macos --srcdir "{Boot}"Cygnus:src: --prefix "{Boot}"GNUTools: + +* Building + +If you use CodeWarrior, you *must* first set MWCIncludes to +{CIncludes}. This is because you will be building MPW tools, and +their standard I/O works by making references to data that is part of +the MPW Shell, which means that the code must be compiled and linked +with macros that refer to that data, and those macros are in +{CIncludes}, not the default {MWCIncludes}. Without this change, you +will encounter problems compiling libiberty/mpw.c, but tweaking that +file only masks the real problem, and does not fix it. + +The command + + mpw-build + +will build everything. Building will take over an hour on a Quadra 800 +or PowerMac 8100/110, longer if the sources are on a shared volume. + +You may see some warnings; these are mostly likely benign, typically +disagreements about declarations of library and system functions. + +* Installing + +To install the just-built tools, use the command + + mpw-build install + +This part of the installation procedure just copies files to the +location specified at configure time by , and, in some cases, +renames them from temporary internal names to their usual names. This +install process is *not* the same as what the Install script does; +Install can copy tools from the installation location chosen at +configuration time to a user-chosen place, and sets up a UserStartup +file. Note that while the Install script is optional, the install +build action performs some tasks would be very hard to replicate +manually, so you should always do it before using the tools. + +* Known Problems With Using Various Compilers to Build + +Most versions of MPW C have problems with compiling GNU software. + +MPW C 3.2.x has preprocessing bugs that render it incapable of +compiling the BFD library, so it can't be used at all for building BFD. + +MPW C 3.3, 3.3.1, and 3.3.2 will spontaneously claim to have found +errors in the source code, but in fact the code is perfectly fine. If +this happens, just set the working directory back to the top-level +objdir (where the configure command above was performed), and type +"mpw-build all" again. If it goes on through the supposed error, then +you got one of the spurious errors. A full build may require a number +of these restarts. + +MPW C 3.3.3 seems to work OK, at least with the aid of a number of +workarounds that are in the sources (look for #ifdef MPW_C). + +Versions of MPW Make earlier than 4.0d2 have exhibited bizarre behavior, +failure to substitute variables and the like. + +Metrowerks CW6 PPC linker (MWLinkPPC) seems to do bad things with memory +if the "Modern Memory Manager" is turned on (in the Memory control panel), +but works OK if it is turned off. + +Metrowerks CW6 loses bigtime compiling opcodes:ppc-opc.c, which has +some deeply nested macros. (CW7 is OK.) There is a way to patch the +file, by substituting constant values. If you need to do this, +contact shebs@cygnus.com for details. + + is missing from {CIncludes} in the MPW version that comes +with CW7. You can just copy the one in CW7's {MWCIncludes}. + +CW8 and later have changes to headers and such that will require changes +to the source in order to be able to use them to rebuild. + +KNOWN BUGS + +The declarations for memcpy and memcmp in some versions of header files +may conflict with GCC's builtin definition. Either use -fno-builtin +or ignore the warnings. + +This is not a bug, but - watch out for cr/nl translation! For instance, +if config/mpw-mh-mpw is not properly translated because it has been +copied or updated separately, then everything will almost build, but +you will get puzzling error messages from make or the compiler. + +'/' or ' ' embedded in any device, directory, or file name may or may +not work. + +objcopy -O srec foo.o makes random output filenames. + +Mac-x-mips requires -mgas but Unix hosts don't. + +GDB will frequently require a '/' on the front of a device name in order +to recognize it as an absolute rather than a relative pathname. + +GDB doesn't seem to use the printer port correctly, although it tries. + +The cursor doesn't always spin as much as it should. To get elaborate +statistics and warnings about spin rates, add this to UserStartup: + + set MEASURE_SPIN all + export MEASURE_SPIN diff --git a/mpw-build.in b/mpw-build.in new file mode 100644 index 000000000000..86d9530fa3b5 --- /dev/null +++ b/mpw-build.in @@ -0,0 +1,204 @@ +# Top-level script fragment to build everything for MPW. + +Set savedir "`Directory`" + +#Set Echo 1 + +Set ThisScript "{0}" + +Set objdir ":" + +Set verify 0 + +Set BuildTarget "none" + +# Parse arguments. + +Loop + Break If {#} == 0 + If "{BuildTarget}" =~ /none/ + Set BuildTarget "{1}" + Else + Echo Only one build target allowed, ignoring "{1}" + End If + Shift 1 +End Loop + +If "{BuildTarget}" =~ /none/ + Set BuildTarget "all" +End If + +If {verify} == 1 + Echo "#" Doing "{ThisScript}" "{BuildTarget}" in "`Directory`" ... +End If + +Set ranmake 0 + +If "`Exists Makefile`" != "" + Echo "Set Echo 1" >{BuildTarget}.makeout + Make -f Makefile {BuildTarget} >>{BuildTarget}.makeout + {BuildTarget}.makeout + Delete {BuildTarget}.makeout + Set ranmake 1 +End If + +If "`Exists Makefile.PPC`" != "" + Echo "Set Echo 1" >{BuildTarget}.makeout.ppc + Make -f Makefile.PPC {BuildTarget} >>{BuildTarget}.makeout.ppc + {BuildTarget}.makeout.ppc + Delete {BuildTarget}.makeout.ppc + Set ranmake 1 +End If + +If {ranmake} == 1 + Exit +End If + +# Dispatch on various pseudo-targets. + +If "{BuildTarget}" =~ /all/ + Echo Started `Date` + "{ThisScript}" all-gcc + "{ThisScript}" all-gdb + Echo Finished `Date` +Else If "{BuildTarget}" =~ /all-libiberty/ + "{ThisScript}" do-libiberty +Else If "{BuildTarget}" =~ /all-bfd/ + "{ThisScript}" do-bfd +Else If "{BuildTarget}" =~ /all-opcodes/ + "{ThisScript}" do-opcodes +Else If "{BuildTarget}" =~ /all-byacc/ + "{ThisScript}" do-byacc +Else If "{BuildTarget}" =~ /all-flex/ + "{ThisScript}" all-libiberty + "{ThisScript}" do-flex +Else If "{BuildTarget}" =~ /all-binutils/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" all-opcodes + "{ThisScript}" do-binutils +Else If "{BuildTarget}" =~ /all-gas/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" all-opcodes + "{ThisScript}" do-gas +Else If "{BuildTarget}" =~ /all-gcc/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-gas + "{ThisScript}" all-binutils + "{ThisScript}" all-ld + "{ThisScript}" do-gcc +Else If "{BuildTarget}" =~ /all-gdb/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" all-opcodes + "{ThisScript}" do-gdb +Else If "{BuildTarget}" =~ /all-grez/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" do-grez +Else If "{BuildTarget}" =~ /all-ld/ + "{ThisScript}" all-libiberty + "{ThisScript}" all-bfd + "{ThisScript}" all-opcodes + "{ThisScript}" do-ld +Else If "{BuildTarget}" =~ /do-byacc/ + SetDirectory :byacc: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-flex/ + SetDirectory :flex: + ::mpw-build _bootstrap + ::mpw-build all +Else If "{BuildTarget}" =~ /do-bfd/ + SetDirectory :bfd: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-libiberty/ + SetDirectory :libiberty: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-opcodes/ + SetDirectory :opcodes: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-binutils/ + SetDirectory :binutils: + ::mpw-build stamps + ::mpw-build all +Else If "{BuildTarget}" =~ /do-gas/ + SetDirectory :gas: + ::mpw-build stamps + ::mpw-build all +Else If "{BuildTarget}" =~ /do-gcc/ + SetDirectory :gcc: + :mpw-build all +Else If "{BuildTarget}" =~ /do-gdb/ + SetDirectory :gdb: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-grez/ + SetDirectory :grez: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-ld/ + SetDirectory :ld: + ::mpw-build all +Else If "{BuildTarget}" =~ /do-newlib/ + SetDirectory :newlib: + ::mpw-build all +Else If "{BuildTarget}" =~ /install/ + "{ThisScript}" install-only-top + "{ThisScript}" install-binutils + "{ThisScript}" install-gas + "{ThisScript}" install-gcc + "{ThisScript}" install-ld + "{ThisScript}" install-gdb +Else If "{BuildTarget}" =~ /install-binutils/ + SetDirectory :binutils: + ::mpw-build install +Else If "{BuildTarget}" =~ /install-gas/ + SetDirectory :gas: + ::mpw-build install +Else If "{BuildTarget}" =~ /install-gcc/ + SetDirectory :gcc: + :mpw-build install +Else If "{BuildTarget}" =~ /install-gdb/ + SetDirectory :gdb: + ::mpw-build install +Else If "{BuildTarget}" =~ /install-grez/ + SetDirectory :grez: + ::mpw-build install +Else If "{BuildTarget}" =~ /install-ld/ + SetDirectory :ld: + ::mpw-build install +Else If "{BuildTarget}" =~ /install-only/ + "{ThisScript}" install-only-top + "{ThisScript}" install-only-binutils + "{ThisScript}" install-only-gas + "{ThisScript}" install-only-gcc + "{ThisScript}" install-only-gdb + "{ThisScript}" install-only-ld +Else If "{BuildTarget}" =~ /install-only-binutils/ + SetDirectory :binutils: + ::mpw-build install-only +Else If "{BuildTarget}" =~ /install-only-gas/ + SetDirectory :gas: + ::mpw-build install-only +Else If "{BuildTarget}" =~ /install-only-gcc/ + SetDirectory :gcc: + :mpw-build install-only +Else If "{BuildTarget}" =~ /install-only-gdb/ + SetDirectory :gdb: + ::mpw-build install-only +Else If "{BuildTarget}" =~ /install-only-grez/ + SetDirectory :grez: + ::mpw-build install-only +Else If "{BuildTarget}" =~ /install-only-ld/ + SetDirectory :ld: + ::mpw-build install-only +Else If "{BuildTarget}" =~ /install-only-top/ + NewFolderRecursive "{prefix}" + If "{prefix}" != "`Directory`" + Duplicate -y 'Read Me for MPW' "{prefix}"'Read Me for MPW' + Duplicate -y Install "{prefix}"Install + End If +Else + Echo {BuildTarget} not understood, ignoring +End If + +SetDirectory "{savedir}" diff --git a/mpw-config.in b/mpw-config.in new file mode 100644 index 000000000000..8028737a8b61 --- /dev/null +++ b/mpw-config.in @@ -0,0 +1,113 @@ +# Configuration fragment for Cygnus source tree. + +# Check that we can find all the special tools that we will need. +# The test for sed is semi-pointless, because it's already been invoked +# by the calculation of target_cpu in the main configure script, but +# the test will also show which one is being used. + +Set Exit 0 +Echo byacc is `Which byacc` +Echo flex is `Which flex` +Echo forward-include is `Which forward-include` +Echo MoveIfChange is `Which MoveIfChange` +Echo mpw-touch is `Which mpw-touch` +Echo mpw-true is `Which mpw-true` +Echo NewFolderRecursive is `Which NewFolderRecursive` +Echo null-command is `Which null-command` +Echo open-brace is `Which open-brace` +Echo sed is `Which sed` +Echo 'tr-7to8' is `Which tr-7to8` +Echo true is `Which true` +Set Exit 1 + +Set host_libs "mmalloc libiberty opcodes bfd readline gash tcl tk tclX" + +Set host_tools "texinfo byacc flex bison binutils ld gas gcc gdb make patch \Option-d + prms send-pr gprof gdbtest tgas etc expect dejagnu sim bash \Option-d + m4 autoconf ispell grep diff rcs cvs fileutils shellutils time \Option-d + textutils wdiff find emacs emacs19 uudecode hello tar gzip indent \Option-d + recode release sed utils guile perl apache inet gawk" + +Set target_libs "newlib" + +Set target_tools "examples" + +# Configure the resource compiler if targeting Macs. +If {target_os} =~ /macos/ || {target_os} =~ /mpw/ + Set host_tools "{host_tools} grez" +End If + +Set configdirs "{host_libs} {host_tools} {target_libs} {target_tools}" +Export configdirs + +# Make up a special include directory that tools will share. + +If "`Exists "{objdir}"extra-include`" == "" + NewFolder "{objdir}"extra-include +End If + +Set edir "{objdir}extra-include:" + +forward-include "{srcdir}"include:mpw:sys:file.h "{edir}"'sys/file.h' +forward-include "{srcdir}"include:mpw:sys:ioctl.h "{edir}"'sys/ioctl.h' +forward-include "{srcdir}"include:mpw:sys:param.h "{edir}"'sys/param.h' +forward-include "{srcdir}"include:mpw:sys:resource.h "{edir}"'sys/resource.h' +forward-include "{srcdir}"include:mpw:sys:stat.h "{edir}"'sys/stat.h' +forward-include "{srcdir}"include:mpw:sys:time.h "{edir}"'sys/time.h' +forward-include "{srcdir}"include:mpw:sys:types.h "{edir}"'sys/types.h' + +forward-include "{srcroot}"include:aout:aout64.h "{edir}"'aout/aout64.h' +forward-include "{srcroot}"include:aout:ar.h "{edir}"'aout/ar.h' +forward-include "{srcroot}"include:aout:ranlib.h "{edir}"'aout/ranlib.h' +forward-include "{srcroot}"include:aout:reloc.h "{edir}"'aout/reloc.h' +forward-include "{srcroot}"include:aout:stab.def "{edir}"'aout/stab.def' +forward-include "{srcroot}"include:aout:stab_gnu.h "{edir}"'aout/stab_gnu.h' + +If "`Exists "{srcroot}"include:aout:"{target_cpu}".h`" != "" + forward-include "{srcroot}"include:aout:"{target_cpu}".h "{edir}"'aout/'"{target_cpu}"'.h' +End If + +forward-include "{srcroot}"include:coff:ecoff.h "{edir}"'coff/ecoff.h' +forward-include "{srcroot}"include:coff:internal.h "{edir}"'coff/internal.h' +forward-include "{srcroot}"include:coff:sym.h "{edir}"'coff/sym.h' +forward-include "{srcroot}"include:coff:symconst.h "{edir}"'coff/symconst.h' + +If "`Exists "{srcroot}"include:coff:"{target_cpu}".h`" != "" + forward-include "{srcroot}"include:coff:"{target_cpu}".h "{edir}"'coff/'"{target_cpu}"'.h' +End If +If "{target_cpu}" =~ /powerpc/ + forward-include "{srcroot}"include:coff:rs6000.h "{edir}"'coff/rs6000.h' +End If + +forward-include "{srcroot}"include:elf:common.h "{edir}"'elf/common.h' +forward-include "{srcroot}"include:elf:dwarf.h "{edir}"'elf/dwarf.h' +forward-include "{srcroot}"include:elf:dwarf2.h "{edir}"'elf/dwarf2.h' +forward-include "{srcroot}"include:elf:external.h "{edir}"'elf/external.h' +forward-include "{srcroot}"include:elf:internal.h "{edir}"'elf/internal.h' + +# Believe it or not, GDB needs this for all targets. +forward-include "{srcroot}"include:elf:mips.h "{edir}"'elf/mips.h' + +If "`Exists "{srcroot}"include:elf:"{target_cpu}".h`" != "" + forward-include "{srcroot}"include:elf:"{target_cpu}".h "{edir}"'elf/'"{target_cpu}"'.h' +End If +If "{target_cpu}" =~ /powerpc/ + forward-include "{srcroot}"include:elf:ppc.h "{edir}"'elf/ppc.h' +End If + +If "`Exists "{srcroot}"include:opcode:"{target_cpu}".h`" != "" + forward-include "{srcroot}"include:opcode:"{target_cpu}".h "{edir}"'opcode/'"{target_cpu}"'.h' +End If +If "{target_cpu}" =~ /powerpc/ + forward-include "{srcroot}"include:opcode:ppc.h "{edir}"'opcode/ppc.h' +End If + +# Add some bfd includes that get mentioned outside the bfd dir. + +forward-include "{srcroot}"bfd:libcoff.h "{edir}"'bfd/libcoff.h' +forward-include "{srcroot}"bfd:libecoff.h "{edir}"'bfd/libecoff.h' + +# Translate random files into MPW-only character set. + +tr-7to8 "{srcdir}"mpw-README > "{objdir}Read Me for MPW" +tr-7to8 "{srcdir}"mpw-install > "{objdir}"Install diff --git a/mpw-configure b/mpw-configure new file mode 100644 index 000000000000..cf45148ec636 --- /dev/null +++ b/mpw-configure @@ -0,0 +1,448 @@ +# Configuration script +# Copyright (C) 1994, 1995, 1996 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 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. + +### WARNING +### This script must NOT use any 8-bit chars! +### WARNING + +# This is an MPW Shell script that sets everything up for compilation, +# mainly creating directories, and editing copies of files. + +Set savedir "`Directory`" + +#Set Echo 1 + +Set ThisScript "{0}" + +Set srcroot "--------" + +Set srcdir ":" + +Set objdir ":" + +Set prefix "{MPW}":GNUTools: + +Set exec_prefix "" + +Set bindir "" + +Set host_alias "m68k-apple-mpw" + +Set target_alias {host_alias} + +Set host_cc "mpwc" + +Set with_gnu_ld 0 + +Set helpoutput 0 + +Set recurse 1 + +Set verify 0 +Set verifystr "" + +Set enable_options "" +Set disable_options "" + +# Parse arguments. + +Loop + Break If {#} == 0 + If "{1}" =~ /--cc/ + Set host_cc "{2}" + Shift 1 + Else If "{1}" =~ /--bindir/ + Set bindir "{2}" + Shift 1 + Else If "{1}" =~ /--disable-?+/ + Set `Echo {1} | sed -e 's/--disable-/enable_/'` no + Set disable_options "{disable_options} '{1}'" + Else If "{1}" =~ /--enable-?+/ + Set `Echo {1} | sed -e 's/--enable-/enable_/'` yes + Set enable_options "{enable_options} '{1}'" + Else If "{1}" =~ /--exec-prefix/ + Set exec_prefix "{2}" + Shift 1 + Else If "{1}" =~ /--help/ + Set helpoutput 1 + Else If "{1}" =~ /--host/ + Set host_alias "{2}" + Shift 1 + Else If "{1}" =~ /--norecursion/ + Set recurse 0 + Else If "{1}" =~ /--prefix/ + Set prefix "{2}" + Shift 1 + Else If "{1}" =~ /--srcdir/ + Set srcdir "{2}" + Shift 1 + Else If "{1}" =~ /--srcroot/ + Set srcroot "{2}" + Shift 1 + Else If "{1}" =~ /--target/ + Set target_alias "{2}" + Shift 1 + Else If "{1}" =~ /-v/ + Set verify 1 + Set verifystr "-v" + Else If "{1}" =~ /--with-gnu-ld/ + Set with_gnu_ld 1 + Else + Echo -n 'mpw-configure: Unrecognized option: "' + Echo -n "{1}" + Echo '"; use --help for usage.' + Exit 1 + End If + Shift 1 +End Loop + +If {helpoutput} == 1 + Echo "Usage: mpw-configure [OPTIONS]" + Echo "" + Echo "Options: [defaults in brackets]" + Echo "--bindir DIR directory for binaries []" + Echo "--cc CC use C compiler CC [mpwc]" + Echo "--disable-FOO do not include feature FOO" + Echo "--enable-FOO include feature FOO" + Echo "--exec-prefix DIR install host-dependent files into DIR []" + Echo "--help print this message" + Echo "--host HOST configure for HOST [m68k-apple-mpw]" + Echo "--norecursion configure this directory only [recurse]" + Echo "--prefix DIR install into DIR [{MPW}:GNUTools:]" + Echo "--srcdir DIR find the sources in DIR [:]" + Echo "--srcroot DIR find the toplevel sources in DIR [:]" + Echo "--target TARGET configure for TARGET [TARGET=HOST]" + Echo "-v verbose" + Echo "--with-gnu-ld link using GNU ld [no]" + Exit 0 +End If + +Set Exit 0 + +# Default exec_prefix from prefix. + +If "{exec_prefix}" == "" + Set exec_prefix "{prefix}" +End If + +If "{bindir}" == "" + Set bindir "{prefix}"bin: +End If + +# Point to the correct set of tools to use with the chosen compiler. + +If "{host_cc}" =~ /mpwc/ + Set host_alias "m68k-apple-mpw" + Set cc_name '{CC_MPW_C}' + Set segment_flag '-s ' + Set ar_name '{AR_LIB}' + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_LINK}' + Set prog_ext_name '{PROG_EXT_68K}' + Set extralibs_name '{EXTRALIBS_C}' + Set makepef_name '{MAKEPEF_NULL}' + Set rez_name '{REZ_68K}' +Else If "{host_cc}" =~ /sc68k/ + Set host_alias "m68k-apple-mpw" + Set cc_name '{CC_SC}' + Set segment_flag '-s ' + Set ar_name '{AR_LIB}' + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_LINK}' + Set prog_ext_name '{PROG_EXT_68K}' + Set extralibs_name '{EXTRALIBS_C}' + Set makepef_name '{MAKEPEF_NULL}' + Set rez_name '{REZ_68K}' +Else If "{host_cc}" =~ /mwc68k/ + Set host_alias "m68k-apple-mpw" + Set cc_name '{CC_MWC68K}' + Set segment_flag '-s ' + Set ar_name '{AR_MWLINK68K}' + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_MWLINK68K}' + Set prog_ext_name '{PROG_EXT_68K}' + Set extralibs_name '{EXTRALIBS_MWC68K}' + Set makepef_name '{MAKEPEF_NULL}' + Set rez_name '{REZ_68K}' +Else If "{host_cc}" =~ /gcc68k/ + Set host_alias "m68k-apple-mpw" + Set cc_name '{CC_68K_GCC}' + Set segment_flag '-s ' + Set ar_name '{AR_68K_AR}' + Set ranlib_name '{RANLIB_RANLIB}' + Set cc_ld_name '{CC_68K_GCC}' + Set prog_ext_name '{PROG_EXT_68K}' + Set extralibs_name '{EXTRALIBS_C}' + Set makepef_name '{MAKEPEF_NULL}' + Set rez_name '{REZ_68K}' +Else If "{host_cc}" =~ /ppcc/ + Set host_alias "powerpc-apple-mpw" + Set cc_name '{CC_PPCC}' + Set segment_flag '-d ___s_e_g___=' + Set ar_name '{AR_PPCLINK}' + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_PPCLINK}' + Set prog_ext_name '{PROG_EXT_XCOFF}' + Set extralibs_name '{EXTRALIBS_PPC}' + Set makepef_name '{MAKEPEF_PPC}' + Set rez_name '{REZ_PPC}' +Else If "{host_cc}" =~ /mrc/ + Set host_alias "powerpc-apple-mpw" + Set cc_name '{CC_MRC}' + Set segment_flag '-d ___s_e_g___=' + Set ar_name '{AR_PPCLINK}' + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_PPCLINK}' + Set prog_ext_name '{PROG_EXT_XCOFF}' + Set extralibs_name '{EXTRALIBS_PPC}' + Set makepef_name '{MAKEPEF_PPC}' + Set rez_name '{REZ_PPC}' +Else If "{host_cc}" =~ /scppc/ + Set host_alias "powerpc-apple-mpw" + Set cc_name '{CC_SC}' + Set segment_flag '-d ___s_e_g___=' + Set ar_name '{AR_PPCLINK}' + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_PPCLINK}' + Set prog_ext_name '{PROG_EXT_XCOFF}' + Set extralibs_name '{EXTRALIBS_PPC}' + Set makepef_name '{MAKEPEF_PPC}' + Set rez_name '{REZ_PPC}' +Else If "{host_cc}" =~ /mwcppc/ + Set host_alias "powerpc-apple-mpw" + Set cc_name '{CC_MWCPPC}' + Set segment_flag '-d ___s_e_g___=' + Set ar_name '{AR_MWLINKPPC}' + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_MWLINKPPC}' + # Misleading, but we don't need a PEF step. + Set prog_ext_name '{PROG_EXT_68K}' + Set extralibs_name '{EXTRALIBS_MWCPPC}' + Set makepef_name '{MAKEPEF_NULL}' + Set rez_name '{REZ_PPC}' +Else If "{host_cc}" =~ /gccppc/ + Set host_alias "powerpc-apple-mpw" + Set cc_name '{CC_PPC_GCC}' + Set segment_flag '-d ___s_e_g___=' + Set ar_name '{AR_PPCLINK}' + If {with_gnu_ld} == 1 + Set ranlib_name '{RANLIB_RANLIB}' + Set cc_ld_name '{CC_LD_GLD}' + Else + Set ranlib_name '{RANLIB_NULL}' + Set cc_ld_name '{CC_LD_PPCLINK}' + End If + Set prog_ext_name '{PROG_EXT_XCOFF}' + Set extralibs_name '{EXTRALIBS_PPC}' + Set makepef_name '{MAKEPEF_PPC}' + Set rez_name '{REZ_PPC}' +Else + Echo "{host_cc}" is not a known MPW compiler type +End If + +Set dash_c_flag '' +If "{host_cc}" =~ /gcc68k/ + Set dash_c_flag '-c' +Else If "{host_cc}" =~ /gccppc/ + Set dash_c_flag '-c' +End If + +# (should interpret aliases if not in canonical form) + +Set host_canonical "{host_alias}" + +Set target_canonical "{target_alias}" + +Set configdirs "" + +If "{srcroot}" =~ /--------/ + Set srcroot "{srcdir}" +End If +If "`Exists "{srcdir}"`" == "" + Echo Source directory {srcdir} does not exist! + Exit 1 +End If +If "`Exists "{srcroot}"`" == "" + Echo Top-level source directory {srcroot} does not exist! + Exit 1 +End If + +Set target_cpu "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`" +Set target_vendor "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`" +Set target_os "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`" + +# Create a file that is guaranteed to be older than any other here. + +If "`Exists "{objdir}"_oldest`" == "" + mpw-touch _oldest +End If + +# Record this before creating any files, makefiles sometimes mention +# dependencies on config.status. + +Echo "# This directory was configured as follows:" >config.new +Echo "{ThisScript} --host {host_alias} --target {target_alias} --srcdir {srcdir} --srcroot {srcroot} --prefix {prefix} --cc {host_cc} {verifystr} {enable_options} {disable_options} --norecursion" >>config.new +MoveIfChange config.new config.status + +If "`Exists "{srcdir}"mpw-config.in`" != "" + tr-7to8 "{srcdir}"mpw-config.in >"{objdir}"mpw-config.in + Execute "{objdir}"mpw-config.in +End If + +# Start Makefile construction by defining all the variables chosen by +# configuration. + +Echo "# This Makefile produced by mpw-configure. Changes may get lost!" > "{objdir}"Makefile.tem +Echo "srcroot = " {srcroot} >> "{objdir}"Makefile.tem +Echo "topsrcdir = " {srcroot} >> "{objdir}"Makefile.tem +Echo "srcdir = " {srcdir} >> "{objdir}"Makefile.tem +Echo "mpw_prefix = " {prefix} >> "{objdir}"Makefile.tem +Echo "mpw_exec_prefix = " {exec_prefix} >> "{objdir}"Makefile.tem +Echo "mpw_bindir = " {bindir} >> "{objdir}"Makefile.tem +Echo "host_alias = " {host_alias} >> "{objdir}"Makefile.tem +Echo "target_alias = " {target_alias} >> "{objdir}"Makefile.tem +Echo "target_cpu = " {target_cpu} >> "{objdir}"Makefile.tem +Echo "target_vendor = " {target_vendor} >> "{objdir}"Makefile.tem +Echo "target_os = " {target_os} >> "{objdir}"Makefile.tem +Echo "target_canonical = " {target_canonical} >> "{objdir}"Makefile.tem +Echo "host_makefile_frag = " >> "{objdir}"Makefile.tem +Echo "target_makefile_frag = " >> "{objdir}"Makefile.tem +Echo "CC = " {cc_name} >> "{objdir}"Makefile.tem +Echo "AR = " {ar_name} >> "{objdir}"Makefile.tem +Echo "RANLIB = " {ranlib_name} >> "{objdir}"Makefile.tem +Echo "CC_LD = " {cc_ld_name} >> "{objdir}"Makefile.tem +Echo "PROG_EXT = " {prog_ext_name} >> "{objdir}"Makefile.tem +Echo "EXTRALIBS = " {extralibs_name} >> "{objdir}"Makefile.tem +Echo "MAKEPEF = " {makepef_name} >> "{objdir}"Makefile.tem +Echo "REZ = " {rez_name} >> "{objdir}"Makefile.tem + +If {host_cc} =~ /gccppc/ + Echo -n "dq =\Option-d\Option-d\Option-d" > "{objdir}"Makefile.tem0 + Echo '"' >> "{objdir}"Makefile.tem0 + tr-7to8 "{objdir}"Makefile.tem0 >>"{objdir}"Makefile.tem +Else + Echo -n "dq ='" >> "{objdir}"Makefile.tem + Echo -n '"' >> "{objdir}"Makefile.tem + Echo "'" >> "{objdir}"Makefile.tem +End If + +# Append the master set of definitions for the various compilers. + +If "`Exists "{srcdir}"config:mpw-mh-mpw`" != "" + tr-7to8 "{srcdir}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem +Else If "`Exists "{srcroot}"config:mpw-mh-mpw`" != "" + tr-7to8 "{srcroot}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem +Else + Echo "can't find a host config file!" + Exit 0 +End If + +# Append anything produced by the directory's mpw-config.in. + +If "`Exists "{objdir}"mk.tmp`" != "" + Catenate "{objdir}"mk.tmp >>"{objdir}"Makefile.tem + # An mpw-config.in might change so as not to create this + # anymore, so get rid of it now to be safe. + Delete -i -y "{objdir}"mk.tmp +End If + +# If there are sed scripts to edit the Unix Makefile.in, use them; otherwise +# use an mpw-make.in if present. + +If "`Exists "{srcdir}"mpw-make.sed`" != "" + If "`Exists "{objdir}"hacked_Makefile.in`" != "" + Set MakefileIn "{objdir}"hacked_Makefile.in + Else + Set MakefileIn "{srcdir}"Makefile.in + End If + # Find the generic makefile editing script. + If "`Exists "{srcroot}"config:mpw:g-mpw-make.sed`" != "" + sed -f "{srcroot}"config:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 + Else If "`Exists "{srcroot}"utils:mpw:g-mpw-make.sed`" != "" + sed -f "{srcroot}"utils:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 + Else If "`Exists "{srcdir}"g-mpw-make.sed`" != "" + sed -f "{srcdir}"g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 + Else + Echo Warning: g-mpw-make.sed not found, copying "{MakefileIn}" verbatim... + Catenate "{MakefileIn}" >"{objdir}"Makefile.tem1 + End If + sed -f "{srcdir}"mpw-make.sed "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 + sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' -e 's/^exec_prefix = .*$/exec_prefix = {mpw_exec_prefix}/g' -e 's/^bindir = @bindir@/bindir = {mpw_bindir}/g' "{objdir}"Makefile.tem2 >"{objdir}"Makefile.tem3 + sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}\1/" "{objdir}"Makefile.tem3 >"{objdir}"mpw-make.in + tr-7to8 "{objdir}"mpw-make.in >>"{objdir}"Makefile.tem + If "`Exists "{objdir}"mk.sed`" != "" + sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2 + Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem + End If + MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile + Delete -i -y "{objdir}"Makefile.tem[12] + If {verify} == 1 + Echo Created Makefile in "`Directory`" + End If +Else If "`Exists "{srcdir}"mpw-make.in`" != "" + sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' "{srcdir}"mpw-make.in >"{objdir}"Makefile.tem1 + sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}}\1/" "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 + tr-7to8 "{objdir}"Makefile.tem2 >>"{objdir}"Makefile.tem + If "`Exists "{objdir}"mk.sed`" != "" + sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2 + Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem + End If + MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile + Delete -i -y "{objdir}"Makefile.tem[12] + If {verify} == 1 + Echo Created Makefile in "`Directory`" + End If +End If + +# Produce a build script if the source is defined. + +If "`Exists "{srcdir}"mpw-build.in`" != "" + Echo "Set srcroot " {srcroot} > "{objdir}"mpw-build.tem + Echo "Set srcdir " {srcdir} >> "{objdir}"mpw-build.tem + Echo "Set target_canonical " {target_canonical} >> "{objdir}"mpw-build.tem + Echo "Set prefix " {prefix} >> "{objdir}"mpw-build.tem + tr-7to8 "{srcdir}"mpw-build.in >>"{objdir}"mpw-build.tem + MoveIfChange "{objdir}"mpw-build.tem "{objdir}"mpw-build + If {verify} == 1 + Echo Created mpw-build in "`Directory`" + End If +End If + +# Apply ourselves recursively to the list of subdirectories to configure. + +If {recurse} == 1 + For subdir In {configdirs} + Set savedir "`Directory`" + If "`Exists "{srcdir}{subdir}:"`" == "" + If {verify} == 1 + Echo No "{srcdir}{subdir}:" found, skipping + End If + Continue + End If + If {verify} == 1 + Echo Configuring {subdir}... + End If + If "`Exists "{objdir}{subdir}:"`" == "" + NewFolder "{objdir}{subdir}" + End If + SetDirectory "{objdir}{subdir}:" + "{ThisScript}" --target "{target_canonical}" --srcdir "{srcdir}{subdir}:" --srcroot "{srcroot}" --prefix "{prefix}" --cc "{host_cc}" {verifystr} {enable_options} {disable_options} + SetDirectory "{savedir}" + End For +End If + +SetDirectory "{savedir}" diff --git a/symlink-tree b/symlink-tree new file mode 100755 index 000000000000..096582db6eb6 --- /dev/null +++ b/symlink-tree @@ -0,0 +1,48 @@ +#!/bin/sh +# Create a symlink tree. +# +# Syntax: symlink-tree srcdir "ignore1 ignore2 ..." +# +# where srcdir is the directory to create a symlink tree to, +# and "ignoreN" is a list of files/directories to ignore. + +prog=$0 +srcdir=$1 +ignore="$2" + +ignore_additional=". .. CVS" + +# If we were invoked with a relative path name, adjust ${prog} to work +# in subdirs. +case ${prog} in +/*) ;; +*) prog=../${prog} ;; +esac + +# Set newsrcdir to something subdirectories can use. +case ${srcdir} in +/*) newsrcdir=${srcdir} ;; +*) newsrcdir=../${srcdir} ;; +esac + +for f in `ls -a ${srcdir}`; do + if [ -d ${srcdir}/$f ]; then + found= + for i in ${ignore} ${ignore_additional}; do + if [ "$f" = "$i" ]; then + found=yes + fi + done + if [ -z "${found}" ]; then + echo "$f ..working in" + if [ -d $f ]; then true; else mkdir $f; fi + (cd $f; ${prog} ${newsrcdir}/$f "${ignore}") + fi + else + echo "$f ..linked" + rm -f $f + ln -s ${srcdir}/$f . + fi +done + +exit 0 diff --git a/texinfo/COPYING b/texinfo/COPYING new file mode 100644 index 000000000000..916d1f0f2842 --- /dev/null +++ b/texinfo/COPYING @@ -0,0 +1,339 @@ + 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 + + Appendix: 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. + + + Copyright (C) 19yy + + 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) 19yy 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. + + , 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/texinfo/ChangeLog b/texinfo/ChangeLog new file mode 100644 index 000000000000..f4efc18de74c --- /dev/null +++ b/texinfo/ChangeLog @@ -0,0 +1,2389 @@ +Mon Jul 28 17:26:48 1997 Rob Savoye + + * aclocal.m4: Add CYGWIN and EXEEXT autoconf macros. + * configure.in: Use CYGWIN and EXEEXT autoconf macro to look for + win32 dependencies. + * configure: Regenerated with autoconf 2.12. + * Makefile.in: Add $(EXEEXT) to all executables. + * makeinfo/Makefile.in: Add $(EXEEXT) to all executables. + * util/Makefile.in: Add $(EXEEXT) to all executables. + +Mon May 26 12:44:43 1997 Ian Lance Taylor + + * texinfo.tex: Update to newest FSF version (2.201). + +Wed Feb 12 11:15:16 1997 Michael Meissner + + * util/texindex.c (main): Make main an int function, not void. + +Sat Jun 29 18:56:07 1996 Geoffrey Noer + + * configure.in: if ac_cv_c_cross is yes, don't run the + AC_FUNC_SETVBUF_REVERSED call since it tries to do a run + test. This allows texinfo to build for cygwin32 Canadian + crosses/natives + * configure: regenerate + +Wed Jun 26 12:48:10 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (bindir, libdir, mandir, infodir): Use autoconf-set + values. + * configure.in (AC_PREREQ): autoconf 2.5 or higher. + * configure: Rebuilt. + * emacs/Makefile.in (bindir, libdir, mandir, infodir): Use + autoconf-set values. + * info/Makefile.in (bindir, libdir, mandir, infodir): Use + autoconf-set values. + * libtxi/Makefile.in (bindir, libdir, mandir, infodir): Use + autoconf-set values. + * makeinfo/Makefile.in (bindir, libdir, mandir, infodir): + Use autoconf-set values. + * util/Makefile.in (bindir, libdir, mandir, infodir): Use + autoconf-set values. + +Fri Oct 4 07:49:49 1996 Karl Berry + + * Version 3.9. + + * Makefile.in (install): Say to install texinfo.tex manually. + + * util/texi2dvi, + * util/texindex.c, + * makeinfo/makeinfo.c, + * info/info.c: Include only the current year in the copyright message. + + * util/texi2dvi: Exit successfully. + From: Andreas Schwab . + +Thu Oct 3 12:58:32 1996 Karl Berry + + * Rename install.sh to the preferred install-sh. + + * Makefile.in (VERSION), + * util/texi2dvi, + * util/texindex.c, + * util/install-info.c, + * makeinfo/makeinfo.c (minor_version, print_version_info), + * info/info.c: Update version number. + + * util/texi2dvi: Only show diff if verbose. + + * util/install-info.c (main): Check for a missing dir file as well + as a missing info files. + (main): At start of a node, completely initialize the newly-malloced + node structure. + + * texinfo.texi: Fix incorrect uses of @key, + insert missing newline in Installing Dir Entries' @menu item, + document install-info invocation. + + * Makefile.in (DISTFILES): Do not put .gdbinit's in distribution. + (dist): Use || instead of && (and invert sense) so make doesn't think + the command failed. + (dist): Exclude more junk. + + * makeinfo/makeinfo.c (cm_xref): Back out patch from Tom T., since + we generate a good-enough error message that is suppressible + without it. + + * util/gen-dir-node: The recommended name for the top-level info + file is dir, not dir.info. + + * util/install-info.c (main): At `Mark the end of the Top node', + make sure the node name is non-NULL before comparing it. From + lvirden@cas.org. + + * configure.in (AC_REPLACE_FUNCS): Use this for memcpy, memmove, + and strdup. + (AC_CHECK_FUNCS): Instead of this. + Because both bcopy and memmove are missing on the 3b2, as reported by + Gaylen Miller , hence we must provide our own. + * libtxi/Makefile.in (LIBOBJS): New variable. + (OBJS): Include it. + * libtxi/memcpy.c, libtxi/memmove.c, libtxi/strdup.c: New files, + taken from fileutils 3.13. + * makeinfo/makeinfo.c, + * info/clib.c (strdup): Move to libtxi. + +Wed Oct 2 18:23:30 1996 Karl Berry + + * info/info-utils.h (memcpy) [!HAVE_MEMCPY], + * info/termdep.h (memcpy) [!HAVE_MEMCPY], + * makeinfo/makeinfo.c (memmove) [!HAVE_MEMMOVE]: Remove this + #ifdef, as we now include it in libtxi if missing. + +Tue Oct 1 17:41:52 1996 Karl Berry + + * makeinfo/Makefile.in (install), + * info/Makefile.in (install), + * Makefile.in (install): Use new option name --info-dir instead of + --infodir. + + * makeinfo/multi.c (out_char): New fn. Replace all calls to + putc/fprintf with calls to this. + + * util/install-info.c: Rename --infodir to info-dir. + +Mon Sep 30 10:07:21 1996 Karl Berry + + * Version 3.8. + + * texinfo.tex: Untabify. + + * texinfo.tex (\ptexl, \ptexL): Do not save, we have our own + commands now. + (\onepageout): Reformat for readability, and call \indexdummies + to avoid expansion of Texinfo commands (e.g., accents) in \write's. + (\,, \dotaccent, \ringaccent, \tieaccent, \ubaraccent, udotaccent, + \questiondown, \exclamdown, \dotless): New macros. + (\l): Let plain TeX definition remain, instead of switching + to ``lisp'' font. + (\multitable): Ensure space between the columns, + insert struts to make interline spacing constant, + use real strut instead of a box containing `Xy'. + (\indexdummies): Do not define \rm, \char, but + do define \@, \{, \}, \dotless, and \,. And \t should generate + \t, not \r. + (\indexnofonts): Define \, and \dotless as \indexdummyfont, + and let \@ be @. + (\doind): Reformat for readability, and use temp control sequence + names that actually make sense. + (\doublecolumnout, \pagesofar, \enddoublecolumns): Restore + Knuth's original code to avoid spurious overfull vbox messages. + (No boxes are actually overfull). + (\shortcontents): Do not allow hyphenations. + (\dochapentry, \tocentry): Make glue above and below flexible, to allow + better page breaks. + (\tex): Reset \, to its plain TeX meaning, + and do not reset \l. + + * COPYING: Update for new FSF address (from gcc dist). + + * libtxi/Makefile.in: Various simplifications. + +Sun Sep 29 12:58:44 1996 Karl Berry + + * util/texi2dvi: Use $progname instead of $0 for --version. + + * util/install-info.c (xmalloc, xrealloc): Declare malloc and + realloc as returning void *, + to avoid ptr/int problems on Digital Unix. + + * info/tilde.c (tilde_expand_word): Declare getenv as returning char *, + to avoid warning on Digital Unix. + + * makeinfo/multi.c (multitable_active): Declare extern here to + avoid ld warning on rs6000. + + * util/texindex.c (usage): Avoid ??' trigraph. + + * util/install-info.c: Include or , + according to HAVE_SYS_FCNTL_H, + and only include if HAVE_SYS_FILE_H. + (readlines): Oops, had NULL's and 0's reversed for ptr/int members. + + * info/terminal.c (terminal_goto_xy): Remove spurious extra ;. + + * util/install-info.c: Untabify. (input_sections): Initialize. + (find_lines): Initialize the terminating element of the array. + (print_help): Document --infodir. + (main): Compare the basename of infile sans .info to the dir entry, + not infile itself. + * util/Makefile.in (clean): Remove the install-info binary. + + * info/Makefile.in (distclean): Remove *.info* files. + + * Makefile.in (install), + * info/Makefile.in (install), + * makeinfo/Makefile.in (install): Use --infodir instead of --info-file. + + * info/info.c, + * makeinfo/makeinfo.c: Avoid newlines in string constants for the + sake of SunOS cc. + + * makeinfo/multi.c: Do not assume ANSI C. + + * info/info.texi: Oops, need @end vtable for a @vtable. + +Sat Sep 28 16:31:28 1996 Karl Berry + + * Makefile.in (texinfo): Do not depend on sub-all, as then + makeinfo is always run. Instead, depend on texinfo.texi. + + * makeinfo/Makefile.in (info, dvi): New targets. + makeinfo.info, makeinfo.dvi: Do not depend on macro.texi for now. + + * info/Makefile.in (install): Must call install-info twice. + + * info/info-stnd.texi, + * info/info.texi, + * makeinfo/makeinfo.texi: Include direntry. + + * emacs/Makefile.in: Use && after cd, etc. + + * texinfo.texi: Kludges so makeinfo -E will not create spurious + differences. Add new direntries. + + * util/install-info.c, + * util/texindex.c, + * makeinfo/makeinfo.c, + * info/info.c: Standardize --version output. + + * makeinfo/makeinfo.c (defun_internal): Don't insert index command + if expanding macros. + (cm_footnotestyle): Don't change the footnote style if it was set + on the command line. + + * util/texi2dvi: Recompute original index files each time through loop. + Make indentation uniform. + Use same basename for the temp input files. + Standardize --version output. + + * info/Makefile.in (install), + * makeinfo/Makefile.in (install): Insert $(POST_INSTALL). + +Fri Sep 27 13:27:30 1996 Karl Berry + + * texinfo.texi (Format with texi2dvi): Rewrite now that the script + runs in a loop. + + * info/Makefile.in (MAKEINFO): Simplify to ../makeinfo/makeinfo. + +Fri Sep 27 00:26:03 1996 Miles Bader + + * info/terminal.c [HAVE_TERMIOS_H] (terminal_prep_terminal, + terminal_unprep_terminal): Add code for termios. + [HAVE_TERMIOS_H] (original_termios, ttybuff): New variables. + * info/termdep.h: [HAVE_TERMIOS_H]: Add include of . + * configure.in: Add check for . + +Thu Sep 26 10:46:34 1996 Karl Berry + + * emacs/texnfo-upd.el, + * emacs/texinfo.el, + * emacs/texinfmt.el: Update from bob for new Texinfo commands, etc. + + * emacs/info.el, emacs/informat.el, emacs/makeinfo.el, + emacs/texnfo-tex.el: Update from Emacs 19.34 dist. + + * emacs/elisp-comp: Use TMPDIR if set. + + * util/Makefile.in (libdir): Remove. + + * makeinfo/Makefile.in (install), + * Makefile.in (install), + * info/Makefile.in (install): Run install-info. + (libdir): Remove. + + * texinfo.texi: Various fixes as I make this go through TeX. + + * util/install-info.c: Quote newlines in help message. + + * util/texi2dvi (texi2dvi): Run TeX until the aux/index files + stabilize, instead of just twice. From: David Shaw + . + +Tue Sep 24 14:43:03 1996 Karl Berry + + * dir: Blank dir file for installation on new systems. + +Mon Sep 23 12:18:43 1996 Karl Berry + + * makeinfo/makeinfo.c (args_from_string): Do not back up at a }; + that leads to an infinite loop. + +Sat Sep 21 17:48:04 1996 Karl Berry + + * makeinfo/makeinfo.c (cm_xref): Do not seg fault if outside of + any node. From: Tom Tromey . + (cm_ctrl): Make obsolete. + +Tue Sep 17 13:30:08 1996 Karl Berry + + * texinfo.tex (\inforef): Move to more appropriate place. + (\pounds): Remove spurious extra $. + (\email): Typeset argument in angle brackets. + (\macro): Use \doignore for robustness, instead of just letting TeX + parse the argument. + (\unmacro): Define. + +Sat Sep 14 16:17:35 1996 Karl Berry + + * texinfo.texi: Document multitables, new ISBN number. + +Wed Sep 11 18:01:24 1996 Karl Berry + + * makeinfo/multi.c (struct env): Remove unused output_position + field; this needs to be global. + (setup_multitable_parameters): Implement template-defined multitables. + (output_multitable_row): Remove trailing whitespace. + + * makeinfo/makeinfo.c (_READ_BUFFER_GROWTH, struct _defines): + Remove leading underscore for POSIX/ANSI pedants. + (init_conversion): Initialize output_position here. + (init_paragraph): Instead of here, where it loses with the + multitable calls, eventually resulting in negative counts to the + write call when the output file is split. + + * texinfo.texi: First cut at macro documentation. + Change accent doc to use tables. + Remove whitespace experiments, they are now the default. + +Mon Sep 9 14:16:24 1996 Karl Berry + + * makeinfo/makeinfo.c: Use putc instead of fprintf where possible. + (cm_accent): Put _ from @ubaraccent after argument. + + * util/texindex.c (strerror) [!strerror]: Conditionalize + declaration. + +Sat Sep 7 14:13:24 1996 Karl Berry + + * makeinfo/makeinfo.c (commandTable): Obsolete @setchapterstyle. + +Thu Sep 5 15:45:11 1996 Karl Berry + + * makeinfo/makeinfo.c (convert_from_loaded_file): Oops, fix + wording of initial output comment. + + * makeinfo/makeinfo.c (cm_angle_brackets): Rename from cm_key. + (commandTable): @email should produce angle brackets. + @key: Change name. + +Tue Sep 3 14:52:17 1996 Karl Berry + + * texinfo.tex (\hsize): Decrease. + (\hoffset): Increase. + (\setleading): Decrease dramatically. + This change affects 8.5x11 format only. + + * texinfo.texi: Document accent commands. + +Mon Sep 2 11:10:49 1996 Karl Berry + + * makeinfo/makeinfo.c (commandTable): Deprecate @ichapter and + @titlespec. + Move all the deprecated @i
commands to the end of the list. + + * texinfo.texi: Document @pounds{} and @centerchap{}. + + * texinfo.tex (\centerchfplain): Rewrite to use \chfplain, and to + actually center. + (\unnchfplain): Just call \chfplain. + (\chfplain): Rewrite to be generally callable. + (\centerparametersmaybe): Hook, a no-op except with @centerchap. + +Sun Sep 1 15:01:49 1996 Karl Berry + + * texinfo.texi: Document @, rearrange spacing section. + + * makeinfo.c (commandTable): Make @. @? @! insert themselves, + not be sentence-non-enders. They are sentence *enders*. Also, + make @\t and @\n insert a normal space character, not themselves. + Also, define @hyphenation. + (insert_space): New function. + (cm_ignore_sentence_ender): Remove this. + (flush_output): Check only for META-SPC, not META-. + +Fri Aug 30 18:55:30 1996 Karl Berry + + * texinfo.texi: Document @- and @hyphenation{}. + Miscellanous fixes. + + * makeinfo/makeinfo.c (commandTable): Define @- as cm_no_op, since + makeinfo doesn't do hyphenation. + +Thu Aug 29 13:05:38 1996 Karl Berry + + * texinfo.tex (\key): Do not uppercase the argument; key names + can be mixed case, e.g., `Control'. + + * makeinfo/makeinfo.c: @infotop, @infounnumbered, + @infounnumberedsec, @infounnumberedsubsec, + @infounnumberedsubsubsec, @infoappendix, @infoappendixsec, + @infoappendixsubsec, @infoappendixsubsubsec, @infochapter, + @infosection, @infosubsection, @infosubsubsection: + Remove these long-since obsolete commands. + @iappendix, @iappendixsection, @iappendixsec, @iappendixsubsec, + @iappendixsubsubsec, @ichapter, @isection, @isubsection, + @isubsubsection, @iunnumbered, @iunnumberedsec, @iunnumberedsubsec, + @iunnumberedsubsubsec: + Deprecate these. + @infoinclude: + Obsolete this. + @,: Have to take an argument, since have to do @,{c} not c@,; can't + feasibly implement the latter in TeX. + + * makeinfo/makeinfo.c: Rename @d to @udotaccent, since this is + relatively infrequently used. + +Tue Aug 27 14:58:56 1996 Karl Berry + + * info/info.c (print_short_help), + * util/install-info.c (print_help), + * util/texi2dvi, + * makeinfo/makeinfo.c (usage) Include bug reporting address. + +Mon Aug 26 15:27:17 1996 Karl Berry + + * makeinfo/makeinfo.c (commandTable): Remove @input, @medbreak, + @smallbreak, @overfullrule, @br. + +Sun Aug 25 17:25:48 1996 Karl Berry + + * makeinfo/makeinfo.c (commandTable): Unify commands that perform + the same operation, such as cm_file, cm_samp, cm_email, + etc., which all do cm_code. + + * texinfo.texi: Document @ifhtml ... @end ifhtml. Change + `PlainTeX' to `plain TeX'. + +Fri Aug 23 16:03:16 1996 Karl Berry + + * texinfo.tex (\pounds): New Texinfo command @pounds{}. + (\parskip): New smaller value. + (\chapheadingskip, \secheadingskip, \subsecheadingskip): New smaller + values, both for 8.5x11 and @smallbook formats. From Bob. + + * makeinfo/makeinfo.c (cm_special_char): @pounds{} prints a #. + (commandTable): Add new command @pounds. + +Tue Aug 20 13:47:20 1996 Karl Berry + + * makeinfo/makeinfo.c (CommandTable): Restore "!", accidentally + removed previously. + + * texinfo.tex (\key): Typeset a lozenge around the argument (from + gildea@intouchsys.com). + * makeinfo/makeinfo.c (cm_key): Surround arg with <...> to match + new lozenge style in TeX. + +Wed Aug 14 16:59:23 1996 Karl Berry + + * texinfo.texi: Propagate change from rms. + +Tue Aug 13 11:33:27 1996 Karl Berry + + * texinfo.texi: Propagate change from rms. + + * texinfo.texi: Document other @headings options. + +Sun Aug 11 13:19:42 1996 Karl Berry + + * makeinfo/makeinfo.c (cm_accent, cm_special_char, cm_dotless): + New functions. + (CommandTable): Add new commands for all of plain.tex's + accents and non-English characters. + +Fri Aug 9 14:12:07 1996 Karl Berry + + * makeinfo/makeinfo.c (convert_from_loaded_file): Say we're making + ``text'' file if no_headers. Also, use `input_filename' instead + of just `name' for clarity. + (suffixes): Check for no suffix last, i.e., prefer `foo.texi' as an + input file to `foo'. (The latter is probably a binary.) + +Mon Aug 5 13:52:39 1996 Karl Berry + + * texinfo.tex (\heading, \subheading, \subsubheading): Can no + longer call the nonexistent \*secheadingi series. Instead, call + \plain*secheading. + (\plainsubsecheading, \plainsubsubsecheading): New macros, by analogy + with \plainsecheading. + (\unnumberedsubseczzz, \unnumberedsubsubseczzz): Call them. + +Sun Aug 4 16:46:10 1996 Karl Berry + + * makeinfo/makeinfo.c (flush_output): Mask out eighth bit, that we + turned on in non-sentence enders. + +Sat Aug 3 14:03:10 1996 Karl Berry + + * texinfo.tex (\HEADINGSdouble, \HEADINGSsingle, + HEADINGSdoubleafter, \HEADINGSsingleafter, \CHAPPAGoff, + \CHAPPAGon, \CHAPPAGodd): Set \contentsalignmacro, analogous to + \pagealignmacro. + (\startcontents): Call \contentsalignmacro instead of \pagealignmacro. + +Mon Jul 29 14:44:33 1996 Karl Berry + + * texinfo.tex (\indexfonts): Make leading be 12pt. Otherwise, it's + too crammed. + (\smalllispx): Remove \setleading{10pt}. That was too small. + (\doprintindex): Do not call \tex ... \Etex. Index files are Texinfo + source, not TeX source, except for using \ instead of @ as the + escape character (for now). + +Sun Jul 28 13:37:05 1996 Karl Berry + + * texinfo.tex (paragraphindent): Move to more reasonable place in + the source file. + (chapfonts, secfonts, subsecfonts, indexfonts): Call \setleading. + (\chfplain, \secheading, \plainsecheading, \subsecheading, + \subsubheading): Rewrite to properly \hangindent the title. + (\sectionheading): New generic macro to print section titles. + + * texinfo.texi: Update the `Obtaining TeX' node. + +Fri Jul 26 14:11:48 1996 Karl Berry + + * util/texi2dvi: Do macro expansion with makeinfo before running TeX. + Various expansion safety measures added for test; avoid use of -o. + + * makeinfo/makeinfo.c (usage): More usage message tweaks. + +Fri Jul 26 11:55:37 1996 Karl Berry + + * util/texi2dvi: Format usage message to conform to the other *utils. + +Thu Jul 25 17:05:47 1996 Karl Berry + + * emacs/Makefile.in: Do not compile the Elisp by default. We + don't install it, so it confuses people to compile it. + +Sun Jul 21 07:20:09 1996 Karl Berry + + * util/Makefile.in (install-info): Dependency should be + install-info.o, not install-info. Also, update copyright years. + + * makeinfo/makeinfo.c (cm_printindex): Don't call execute_string + to print index entries, we've already done the expansion now. + + * makeinfo/makeinfo.h: Add copyright. Finish merge of rms changes. + * makeinfo/makeinfo.c: Finish merge, add my expansion changes again. + * makeinfo/multi.c: Add copyright message. + +Fri Jul 19 10:35:22 1996 Karl Berry + + * info/info.c: Update copyright date. + + * info/info.texi, + * util/install-info.c, + * emacs/Makefile.in, + * emacs/texnfo-tex.el, + * emacs/Makefile.in: Change FSF address. + + * Merged changes from bfox -- below, plus multitable changes, plus + lots more. + + Sun Apr 14 08:49:50 1996 Brian J. Fox + + * makeinfo/makeinfo.c (remember_node_reference): Numerous commands + call remember_node_reference. If a node has not yet been defined, + use the empty string as the current node for those cases. + + Mon Feb 12 17:35:38 1996 Brian J. Fox + + * makeinfo/makeinfo.c (push_node_filename): Clean up calls to + xmalloc and xrealloc. Only have to call xrealloc. + + Fri Jan 26 08:00:38 1996 Brian J. Fox + + * info/session.c (info_input_buffer_space_available): Fix typo + which forced the limitation of the sizeof (int) instead of sizeof + (buffer). + + * Makefile.in (PACKVER): now at 3.8. Add TERMIOS support to + Info. Minor bugs fixed in Makeinfo. + +Sat Jul 13 11:58:57 1996 Karl Berry + + * texinfo.texi (ftable vtable): Mention example. + +Sun Jun 30 14:59:51 1996 Karl Berry + + * makeinfo/makeinfo.c (cm_email): New function for new @email command. + * texinfo.texi (email): New node documenting it. + +Wed Apr 17 18:07:34 1996 Richard Stallman + + * makeinfo/makeinfo.c (cm_kbd): Do nothing if in @example or @code. + (struct brace_element): New field in_fixed_with_font. + (remember_brace_1): Save in_fixed_with_font. + (pop_and_call_brace): Restore in_fixed_with_font. + (cm_code): Don't decrement in_fixed_with_font at end of construct. + (struct istack_elt): New field in_fixed_with_font. + (push_insertion, pop_insertion): Save and restore in_fixed_with_font. + (end_insertion): Don't decrement in_fixed_with_font here. + (not_fixed_width): New function. + (cm_sc, cm_var, cm_italic, cm_roman, cm_titlefont): + Use not_fixed_width. + +Sat Apr 13 23:22:05 1996 Richard Stallman + + * util/install-info.c (main): Fatal error if no input file spec'd. + Look for START-INFO-DIR-ENTRY, not BEGIN-INFO-DIR-ENTRY. + +Thu Apr 11 18:21:50 1996 Richard Stallman + + * makeinfo/makeinfo.c (cm_enddots): New function. + (self_delimiting): Accept -, ^ and ". + (CommandTable): Add commands -, ^, ", enddots, centerchap. + +Sun Mar 24 12:18:32 1996 Richard Stallman + + * makeinfo/makeinfo.c (enum insertion_type): Add `direntry'. + (insertion_type_names): Add "direntry". + (cm_dircategory): New function. + (cm_direntry): New function. + (CommandTable): Add "dircategory" and "direntry". + (insert_string): New function. + (end_insertion): Handle direntry. + (begin_insertion): Handle direntry. + +Sun Mar 24 11:10:05 1996 Karl Berry + + * makeinfo/makeinfo.c (cm_url): New function for new @url command. + +Fri Feb 23 21:14:40 1996 Richard Stallman + + * info/Makefile.in (install, uninstall): Use manprefix. + +Fri Feb 23 19:50:18 1996 Richard Stallman + + * util/Makefile.in (install-info, install-info.o): New targets. + (all): Depend on install-info. + (install, uninstall): Operate on install-info. + + * install-info.c: New file. + +Wed Jan 3 10:01:45 1996 Brian J. Fox + + * makeinfo/makeinfo.c (make_index_entries_unique): Be a little bit + stricter about what makes two index entries identical. + +Fri Dec 29 13:00:24 1995 Brian J. Fox + + * makeinfo/makeinfo.c (Whole File): Add @detailmenu for allowing + detailed menu listings to appear while still defaulting nodes. + +Wed Dec 27 13:54:30 1995 Brian Fox + + * makeinfo/makeinfo.c (cm_code): Always notice that we are in + fixed_width_font, even if other formatting changes are not to take + place. + +Sat Dec 23 11:48:43 1995 Brian J. Fox + + * info/man.c: (clean_manpage) Remove ^L's from page. + + * makeinfo/makeinfo.c (get_brace_args): Change some memcpy's to + memmoves. + + * info/info.c (main): Prefer caseless matches over partial + matches. + + * Makefile.in (All Subdir Targets): Change suggested by Debian + people which allows errors in recursive makes to kill the + top-level make. + + * makeinfo/Makefile.in (makeinfo.dvi): New target. + + * info/info.c (main): Print version of containing texinfo package. + + * makeinfo/makeinfo.c (flush_output): Don't strip high-bit from + sentence_enders. + Print the version number of the containing texinfo package. + + * info/man.c (locate_manpage_xref): Count the 0th entry. + + * makeinfo/makeinfo.c (cm_menu): If a menu is seen before a node + has been defined, warn, and create the node `Top'. + +Wed Jun 21 03:19:39 1995 Brian Fox + + * makeinfo/makeinfo.c (cm_infoinclude): Clean up after printing + error if the file couldn't be included. + (discard_braces): Print errors only for those unmatched open + braces that belong to a texinfo command. + + * */Makefile.in: Use @CFLAGS@ and @LDFLAGS@. + + * makeinfo/makeinfo.c: End `node_search_string' and friends with a + terminating null character. + +Wed Jun 21 01:23:49 1995 Jim Meyering (meyering@comco.com) + + * makeinfo/makeinfo.c: Close comment after #endif. + +Tue Jun 20 04:58:26 1995 Brian Fox + + * emacs/Makefile.in (install): Fix typo: "fle" -> "file". + + * Makefile.in (VERSION): Bump to 3.6 + + * info/clib.c: Include general.h for `info_toupper' and friends. + + * info/clib.h: strncmp and strncascmp return an int. What kind of + drugs was I on? + +Mon Jun 19 23:34:47 1995 Brian Fox + + * makeinfo/makeinfo.c (make_index_entries_unique): Copy the last + index entry. + +Mon Jun 19 21:55:49 1995 Noah Friedman + + * util/texi2dvi (--version): New option. + Cosmetic changes. + +Mon Jun 19 16:06:40 1995 Brian Fox + + * makeinfo/makeinfo.c (cm_macro): Fix typo. `x != y' is not the + same as `x |= y'. + + * info/Makefile.in (exec_prefix): Use @exec_prefix@ not $(prefix). + * makeinfo/Makefile.in (exec_prefix): Use @exec_prefix@ not $(prefix). + * util/Makefile.in (exec_prefix): Use @exec_prefix@ not $(prefix). + * libtxi/Makefile.in (exec_prefix): Use @exec_prefix@ not $(prefix). + + * emacs/Makefile.in (uninstall): New target. + (install): Use the definition of $(lispdir), don't dynamically + find it. Use INSTALL_DATA not cp. + (exec_prefix): use @exec_prefix@ not $(prefix). + + * makeinfo/makeinfo.c (apply): If there isn't an actual argument + for a named argument, default it to "". + + * Makefile.in (VERSION): Now at 3.5. + (texinfo): Make ./makeinfo/makeinfo depend on sub-all for parallel + makes. + + * emacs/Makefile.in (ELISP_OBJS): Explictly declare .el and .elc + in the SUFFIXES list. + + * makeinfo/makeinfo.c (cm_today): Special case for losing alpha. + * (minor_version): Increase to 63. + + * info/info.c (version_string): Now at 2.14. + * info/tilde.c: Declare getenv to return (char *). + * info/window.c (build_message_buffer): Jump through hoops to keep + DEC Alpha's happy. + + * info/xmalloc.c: Declare malloc and realloc as (void *) returning + functions. + +Sun Jun 18 12:47:21 1995 Richard Stallman + + * emacs/detexinfo.el (detexinfo-line-cmds-without-arg): + Handle ifhtml. + +Fri Jun 16 13:48:14 1995 Brian Fox + + * util/texindex.c: Update TEXINDEX_VERSION_STRING for texinfo 3.4 + + * (All *.c *.h *.in): Change FSF old address to new. + * texinfo.texi (Obtaining TeX): Change FSF old address to new + address. Change Old phone numbers to new phone numbers. + + * Makefile.in (VERSION): Change to 3.4. + +Thu Jun 15 22:49:07 1995 Robert J. Chassell + + * texinfo.texi, emacs/=development/cover.texi: update + Texinfo distribution package version number + +Thu Jun 15 09:23:02 1995 Brian J. Fox + + * info/info.c: (minor_version): Set to 13. + + * info/clib.c,h: New files gather together replacement functions + for those POSIX-style C library functions that are not present on + the target system. + + * info/Makefile.in (SRCS): Add clib.c and clib.h. makedoc now + needs clib.o to build on systems missing various string.h stuff. + + * info/variables.c (whole file): Call strdup, not savestring. + * info/tilde.c (whole file): Call strdup, not savestring. + * info/search.c (whole file): Call strdup, not savestring. + * info/nodes.c (whole file): Call strdup, not savestring. + * info/nodemenu.c (whole file): Call strdup, not savestring. + * info/man.c (whole file): Call strdup, not savestring. + * info/makedoc.c (whole file): Call strdup, not savestring. + * info/m-x.c (whole file): Call strdup, not savestring. + * info/info.c (whole file): Call strdup, not savestring. + * info/indices.c (whole file): Call strdup, not savestring. + * info/echo_area.c (whole file): Call strdup, not savestring. + * info/session.c (whole file): Call strdup, not savestring. + * info/filesys.c (whole file): Call strdup, not savestring. + + * makeinfo/makeinfo.c (minor_version): Change to 1.62. + * makeinfo/makeinfo.c (get_execution_string): Initialize `i' to 0 + in case there are no execution_strings. + +Wed Jun 14 17:48:06 1995 Brian J. Fox + + * texinfo.texi: include "texinfo.tex", not "texinfo". + * info/session.c (forget_window_and_nodes): Place a sequence point + in between "info_windows[i] = info_windows[++i];" as per various + compiler experts. + + * makeinfo/makeinfo.c (strdup): Create this function if the system + doesn't have it. + (discard_insertions): Use the insertion's filename, not the + current input file. + (push_insertion): Remember the current input file with each + insertion. + (pop_insertion): Free storage used by remembered input file. + + * makeinfo/makeinfo.c (whole file): Use `strdup' instead of + `savestring'. + * configure.in: Check for `strdup'. + +Wed Jun 14 15:58:51 1995 Brian Fox + + * libtxi/Makefile.in (prefix): Use @prefix@, not /usr/local/ + +Wed Jun 14 10:50:57 1995 Brian J. Fox + + * Makefile.in (DISTFILES): Don't include *.elc files in the list + of files to distribute. + (installdirs): Include `emacs' in the list of sub-dirs with + Makefile.in's. + + * emacs/elisp-comp: Shell script which batch compiles the *.el files. + * emacs/Makefile.in: New file contains targets to build the elc files. + * configure.in: Add `emacs/Makefile' to the list of created makefiles. + * makeinfo/makeinfo.c (whole file): Give every function a return + type. All cm_xxx functions are now void. Add declarations for + functions to top of file. + +Mon Jun 12 12:00:57 1995 Brian J. Fox + + * info/man.c (reference_section_starters): Add versions of "SEE + ALSO" and "RELATED INFORMATION" with tabs instead of spaces as + well. + + * util/texindex.c: Back out changes for OFF_T. Explicity coerce + the result of lseek to a long, and use longs everywhere. + + * texinfo.texi: Change "@end shorttitlepage" to "@end titlepage". + * makeinfo/makeinfo.c: Make @shorttitlepage ignore the rest of the + line. + + * util/texindex.c (strrchr): Create if not present. + Test for HAVE_STRCHR and HAVE_STRING_H. + (main): Make PROGRAM_NAME be just the last path componenet of argv[0]. + (decode_command): Rewrite. + (usage): Rewrite. Now texindex handles --version. + + * makeinfo/makeinfo.c (make_index_entries_unique): Rewrite from + scratch. + + * Don't distribute created info files with texinfo. After all, + the user will have the tools necessary to create them, yes? + + * Makefile.in (distclean): Remove *.log + + * info/man.c (read_from_fd): Change timeout value for select to 15 + seconds. Some systems (e.g., albert.ai.mit.edu) actually need + more than 10 seconds to format a man page. + + * info/tilde.c: Fix typo in declaration for + `tilde_expansion_failure_hook'. + +Wed Jun 7 13:36:53 1995 Brian Fox + + * info/tilde.h: Change type of tilde_expansion_failure_hook to + a pointer to a function returning a (char *). + * info/tilde.c: Change type of tilde_expansion_failure_hook to a + pointer to function returning a (char *). + + * makeinfo/makeinfo.c (get_execution_string): Don't use `i' in the + latter assignment, use `execution_strings_index' instead. + + * info/man.c (read_from_fd): Change logic to avoid using FIONREAD. + + * info/xmalloc.c (xrealloc): Use (void *), not (caddr_t *). + * info/xmalloc.c (xmalloc): Use (void *), not (caddr_t *). + + * Makefile.in (DISTFILES): Don't find RCS no "=" directories. + + * util/Makefile.in (prefix): Use @prefix@ as the value. + * info/Makefile.in (prefix): Use @prefix@ as the value. + * makeinfo/Makefile.in (prefix): Use @prefix@ as the value. + +Wed Jun 7 12:29:28 1995 Robert J. Chassell + + * texinfo.texi: Correct minor typos. + + * emacs/texinfmt.el: Don't require @shorttitlepage to be inside + of @iftex ... @end iftex + +Mon May 8 18:33:52 1995 Brian J. Fox + + * info/nodes.c: #include "man.h" if HANDLE_MAN_PAGES. + (info_get_node_of_file_buffer): If the file buffer is one + associated with manpages, call the manpage node finding + function instead. + (info_find_file_internal): If the file buffer is one associated + with manpages, avoid doing any file I/O. + (info_reload_file_buffer_contents): Ditto. + (info_find_file_internal): Call create_manpage_file_buffer instead + of info_load_file_internal. + + * info/info.c: #include "man.h" if HANDLE_MAN_PAGES. + (main): If the initial node cannot be found, perhaps find it as a + manpage. + * info/info-utils.c: #include "man.h" if HANDLE_MAN_PAGES. + (info_xrefs_of_node): If handling man pages, and this is a manpage + node, use xrefs_of_manpage. + + * info/session.c (info_set_input_from_file): Only fclose (stream) + if it is non-null and not stdin. + #include "man.h" if HANDLE_MAN_PAGES. + (info_menu_or_ref_item): If handling man pages, and this is a + manpage node, get the xrefs from manpage_xrefs_in_binding. + (info_man): Compile in for M-x man if handling man pages. + (info_move_to_xref): If handling man pages, and the current node + is a manpage node, use locate_manpage_xref to get xrefs. + +Thu May 4 08:55:23 1995 Brian J. Fox + + * info/info.c (main): If the output device is not a terminal, and + no output filename has been specified, make user_output_filename + be "-", so that the info is written to stdout, and turn on the + dumping of subnodes. + +Thu Apr 13 18:05:06 1995 Daniel Hagerty + + * texinfo.texi: Fixed @end titlepage/@end shorttitlepage + +Sat Apr 8 12:51:49 1995 Roland McGrath + + * makeinfo/makeinfo.c [! HAVE_STRERROR] (strerror): New function, + snarfed from ../info/filesys.c. + (cm_infoinclude): Use strerror instead of sys_errlist. + +Tue Apr 4 18:44:00 1995 Brian J. Fox + + * util/texindex.c (sort_offline): Change TOTAL to be an off_t. + * util/texindex.c (sort_in_core): Change TOTAL to be an off_t. + * util/texindex.c (MAX_IN_CORE_SORT): Cast to off_t. + +Sun Apr 2 16:20:13 1995 Brian J. Fox + + * info/Makefile.in: Define DEFAULT_INFOPATH in case we are + compiling in the current directory. + * info/Makefile.in (info.o): Add filesys.h because of DEFAULT_INFOPATH. + * info/(search.c,h, nodes.c info-utils.c) Use strcasecmp and + strncasecmp instead of stricmp and strnicmp. Define strcasecmp + and strncasecmp in search.c if !HAVE_STRCASECMP. + * info/search.c: If HAVE_STRING_H include it. + * info/nodes.c: If HAVE_STRING_H include it. + * info/info-utils.c: If HAVE_STRING_H include it. + * info/info.h: If HAVE_STRING_H include it. + * configure.in (AC_HAVE_FUNCS): Check for strcasecmp. + * makeinfo/makeinfo.c (strcasecmp): Define if !HAVE_STRCASECMP. + * makeinfo/makeinfo.c (entire file): Use `strcasecmp' instead of + `stricmp'. + * makeinfo/makeinfo.c (cm_ifeq): New command takes three args. + Compares first two, executes remainder if the first two are + string-wise eq. + * makeinfo/makeinfo.c (ifhtml): Add to command list. Shouldn't be + used, but it is by people who don't want to hack macros. + +Sat Apr 1 09:20:14 1995 Brian J. Fox + + * makeinfo/makeinfo.c (begin_insertion): Fix reversed arguments to + line_error. + + * info/info-stnd.texi: Use "end" footnote style instead of "separate". + + * info/Makefile.in: Change "rm -f" to $(RM). + + * info/general.h: Define zero_mem in terms of memset if we have + it, else in terms of bzero if we have that, else as inline code. + + * info/NEWS: Updated to reflect changes in 2.11. + +Fri Mar 31 22:38:31 1995 Brian J. Fox + + * Makefile (DISTFILES): Don't include *.a, *orig, nor *.e + files. + (DISTFILES): + +Sat Mar 4 12:16:29 1995 Brian J. Fox + + * Makefile.in: Use @prefix@ instead of hardwired `/usr/local'. + Clean up makefile rules which make in subdirs. + (ALL_SUBDIRS): Add makeinfo/macros to list of subdirectories. + + * configure.in (AC_CHECK_FUNCS): Add `bcopy' to list of things to + check for. + +Fri Mar 3 13:54:10 1995 Robert J. Chassell + + * texinfo.texi: Minor changes for incremental new edition 2.20. + +Fri Mar 3 19:01:36 1995 Brian J. Fox + + * filesys.c (filesys_read_info_file): Local variable ST_SIZE is a + long which has the value of finfo->st_size casted to it. + * nodes.c (whole file): Similar changes. + + These changes and the following for makedoc.c were required for + proper operation on HPm68k NetBSD. + +Mon Feb 27 15:16:27 1995 Brian J. Fox + + * makedoc.c (process_one_file): Local variable FILE_SIZE is a long + which has the value of finfo.st_size casted to it. + + +Fri Mar 3 18:58:38 1995 Brian J. Fox + + * makeinfo.c (find_and_load): Cast fileinfo.st_size to a long for + internal use. This makes things work on NetBSD. + + +Fri Mar 3 13:54:10 1995 Robert J. Chassell + + * texinfo.texi: Minor changes for incremental new edition 2.20. + +Fri Mar 3 09:41:39 1995 Brian J. Fox + + * configure.in (TERMLIBS): Use AC_CHECK_LIB instead of + AC_HAVE_LIBRARY. + +Mon Jan 9 16:55:31 1995 Brian Fox + + * Makefile.in (DISTFILES): Add the directory EMACS-BACKUPS to the + list of things to avoid distributing. + +Tue Nov 29 17:48:37 1994 David J. MacKenzie + + * configure.in: Check for off_t. + * util/texindex.c (main): Use it. + +Fri Nov 11 14:46:28 1994 David J. MacKenzie + + * configure.in: Update for Autoconf v2. + +Thu Oct 13 02:17:38 1994 Richard Stallman + + * emacs/detexinfo.el (detexinfo): Handle @!, @?, @^, @". + +Mon Aug 1 03:26:13 1994 Richard Stallman + + * texindex.c: Move the memset define down past string.h include. + +Tue Jun 28 14:21:43 1994 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu) + + * makeinfo/makeinfo.c: Add --help option. + (usage): Take args for stream and error code. + Change callers. + (print_version_info): Write to stdout, not stderr. + +Wed May 18 18:55:24 1994 Brian J. Fox (bfox@ai.mit.edu) + + * info/session.c (forget_window_and_nodes): Negate test for + internal_info_node_p. We only want to free the text if it is + not an internal node. + +Thu Mar 10 03:07:18 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu) + + * texindex.c (memset): Fix invalid parm name (was 0). + +Thu Feb 10 12:56:52 1994 Noah Friedman (friedman@prep.ai.mit.edu) + + * makeinfo/makeinfo.c (current_item_function): Don't loop if elt + is NULL. + +Wed Feb 9 12:21:09 1994 Brian J. Fox (bfox@ai.mit.edu) + + * makeinfo/makeinfo.c (minor_version): Release now at 1.60. + + * makeinfo/makeinfo.c (expand_filename): Additional fixes. Now + when called with NULL filename, makes an output filename from the + input filename. + (convert_from_loaded_file): If REQUIRE_SETFILENAME is #defined (no + longer the default case) then error if no @setfilename was found + in the file. If REQUIRE_SETFILENAME is not #defined, the input + file starts either at the first line, or at the second line if the + first line contains the text "\input", and the output filename is + the input file name without directory and with ".info" replacing + any extension found. + (convert_from_loaded_file): Fixed bug in search for first + occurence of "@setfilename". + +Tue Feb 8 14:16:58 1994 Noah Friedman (friedman@prep.ai.mit.edu) + + * configure.in: Check for sys/file.h. + info/dir.c, info/filesys.c, info/makedoc.c, info/nodes.c, + info/session.c, info/termdep.h, makeinfo/makeinfo.c + [HAVE_SYS_FILE_H]: Include . + + * makeinfo/makeinfo.c (convert_from_loaded_file): Print + real_output_filename instead of output_filename, so user knows + exactly where output file is going. + + Fri Jun 11 14:34:30 1993 Ian Lance Taylor (ian@cygnus.com) + * configure.in: Check for sigprocmask and sigsetmask. + * info/signals.h (HAVE_SIGSETMASK): Don't define. + (HAVE_SIGPROCMASK): Use instead of _POSIX_VERSION. + (BLOCK_SIGNAL, UNBLOCK_SIGNAL): If neither HAVE_SIGPROCMASK nor + HAVE_SIGSETMASK is defined, define these to do nothing. + * info/signals.c (sigprocmask): Don't compile if HAVE_SIGSETMASK + is not defined. + + * info/terminal.c (terminal_prep_terminal): Don't clobber VINTR + and VQUIT in conditionals. + +Mon Feb 7 18:10:22 1994 Brian J. Fox (bfox@ai.mit.edu) + + * makeinfo/makeinfo.c (full_pathname): Correct to really return + the full pathname of the input argument. Now makeinfo + /foo/bar.texi, where /foo/bar.texi contains "@setfilename + bar.info", correctly leaves the output file in "./bar.info". + Note that "@setfilename ../bar.info" still works; this is already + an absolute pathname. + +Sat Feb 5 13:04:05 1994 Brian J. Fox (bfox@ai.mit.edu) + + * makeinfo/makeinfo.c: Version 1.59 released. + + * makeinfo/makeinfo.c (whole file): Large number of changes allow + the "-E filename" option to be used to write a macro expanded + output file. On a file which contains no @include's and no + @macro's, the output file is identical to the input file. + + * makeinfo/makeinfo.c (declarations): Remove cm_tex (). It is + never used since it is implemented with `command_name_condition'. + + * makeinfo/makeinfo.c (add_char): Shift braces following the + current break point if we have deleted any characters. + (adjust_braces_following): New function adjusts all of the markers + in the brace stack which follow HERE by AMOUNT. This fixes a bug + where (for example) @var{} immediately following a line break + which is the end of a sentence modified the output incorrectly. + +Wed Feb 2 14:14:03 1994 Brian J. Fox (bfox@ai.mit.edu) + + * makeinfo: Version 1.58. + + * makeinfo/makeinfo.c (cm_node): Add extra hair to allow + backtracking through execution strings. Add extra hair to allow + the first node seen after a @top node is seen to adjust the + sectioning level of the @top node and associated menus. + Fix a few typos. + Add facility for macros to invoke the original definition. This + works by not allowing a single macro to recurse. Mutual recursion + is also disallowed with this plan. + + * makeinfo/macros: New directory contains shippable macros. + * makeinfo/macros/simpledoc.texi: Macros which simplify the most + common uses of TeXinfo. See the example file. + Macros are now a reasonable way to get people started using + TeXinfo. + +Mon Jan 31 12:54:36 1994 Brian J. Fox (bfox@ai.mit.edu) + + * makeinfo/makeinfo.c (minor_version): Increase to 57. + + * makeinfo/makeinfo.c (cm_node): Call execute_string on the node, + next, prev, and up pointers. + (reader_loop): Change logic for `@bye'. No longer required at the + ends of executed strings. + (execute_string): Do not append `@bye' to the string to execute. + + * makeinfo/makeinfo.c (whole file): Use COMMAND_PREFIX instead of + hardcoding `@' character in strings and searches. + + * makeinfo/makeinfo.c (read_command): If HAVE_MACROS is defined, + then recognize and execute macros here. + (CommandTable): Add "macro" and "unmacro" to table if HAVE_MACROS + is defined. + + * makeinfo/makeinfo.c (cm_macro, cm_unmacro, execute_macro) + makeinfo/makeinfo.c (get_macro_args, find_macro, add_macro) + makeinfo/makeinfo.c (delete_macro, array_len, apply): + New functions implement macro facility if HAVE_MACROS is + defined. + + * makeinfo/macro.texi (new file): Examples of using the new macro + facility. + +Mon Jan 31 10:24:52 1994 Noah Friedman (friedman@prep.ai.mit.edu) + + * makeinfo/makeinfo.c (executing_string): Restore global + declaration. + +Mon Jan 24 23:48:26 1994 Noah Friedman (friedman@prep.ai.mit.edu) + + * texinfo.texi: Various typo fixes from Bob Chassell + . + +Thu Jan 6 13:34:21 1994 Noah Friedman (friedman@prep.ai.mit.edu) + + * texinfo.texi: Turned on smallbook format and @set smallbook. + +Wed Dec 15 20:08:43 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * info/filesys.h (DEFAULT_INFOPATH): Added /usr/local/info, + /opt/gnu/info, /usr/share/info, and /usr/local/share/info. + +Tue Dec 14 19:10:20 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * libtxi/Makefile.in (ALLOCA): Define from configure. + +Fri Dec 10 04:33:12 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/texi2dvi: Put under RCS control. + +Sun Dec 26 11:55:46 1993 Brian J. Fox (bfox@ai.mit.edu) + + * info/session.c (info_numeric_digit_arg_loop): Fix doc string. + + * info/infodoc.c (create_internal_info_help_node): Print out list + of functions which have to keystroke equivalent if we support + NAMED_FUNCTIONS. + + * info/filesys.c (compress_suffixes): Add ".gz" for "gunzip" to + alist. + + * info/footnotes.c (make_footnotes_node): If refs[i] doesn't have + a nodename, then it couldn't be a reference to a footnote. + + * info/nodemenu.c (get_visited_nodes): Handle the case where + filter_func has left no possible buffers to select. + +Sat Dec 25 10:35:56 1993 Brian J. Fox (bfox@ai.mit.edu) + + * info/infodoc.c (create_internal_info_help_node): Conditionalize + generation of the help node based on the #define + HELP_NODE_GETS_REGENERATED. When this is not set (the default) + the help node is generated exactly once, and is not gc'able. + Otherwise, a new node is always created for the help window, and + the old node gets garbage collected by the gc system. + (info_find_or_create_help_window): Conditionalize window node + selected based on the #define HELP_NODE_GETS_REGENERATED. + + * info/dir.c (add_menu_to_file_buffer): Place exactly one blank + line between directory entries. + + * info/info.c (version_string): Update minor version to "11". + + * info/info.h: Update comment to "2.11". + + * info/dir.c (maybe_build_dir_node): Only add the contents of a + new file if it is not identical to the file of the DIR buffer. + + * info/nodes.c (info_get_node): Call `maybe_build_dir_node' on + "dir" as well as "localdir" to mimic emacs-19.22 "dir" merging + behaviour. + +Fri Dec 3 13:41:44 1993 Brian J. Fox (bfox@ai.mit.edu) + + * info/info-utils.c (canonicalize_whitespace): Suppress whitespace + found at the start of STRING. + +Sat Nov 20 14:00:50 1993 Brian J. Fox (bfox@hippie) + + * info/indices.c (DECLARE_INFO_COMMAND): Fix typo in assignment to + `old_offset' (= instead of ==). + +Tue Nov 2 12:22:40 1993 Brian J. Fox (bfox@ai.mit.edu) + + * makeinfo/makeinfo.c (make_index_entries_unique): New function + makes a sorted array have all unique entries by appending numbers + to the ends of strings. + (sort_index): Call `make_index_entries_unique'. + +Mon Sep 20 12:04:05 1993 Brian J. Fox (bfox@ai.mit.edu) + + * makeinfo/makeinfo.c (get_execution_string): New Function returns + a pointer to an EXECUTION_STRING structure. + (execute_string): No longer uses a static string; call + `get_execution_string' instead in order to get a free buffer for + consing. + +Sun May 23 07:00:20 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * Texinfo 3.1 released. + +Sat May 22 18:21:27 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * info/info.c (info_patch_level): Increment constant to 1. + + * info/Makefile.in (DEFAULT_INFOPATH): Default definition deleted. + Makefile.in: Put it here instead. + * Makefile.in (MDEFINES): Add DEFAULT_INFOPATH. + + * configure.in: check for vfprintf and vsprintf. + + * makeinfo/makeinfo.c: Version 1.55. + + * makeinfo/makeinfo.c (add_word_args, execute_string) [HAVE_VARARGS_H]: + Don't use this definition unless HAVE_VSPRINTF is also defined. + (error, line_error, warning) [HAVE_VARARGS_H]: Don't use this + definition unless HAVE_VFPRINTF is also defined. + Remove indentation of all cpp directives, except for #pragma. + +Fri May 21 14:34:24 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * texinfo.texi: Rename to texi.texi. + Change @setfilenname and START-INFO-DIR-ENTRY to `texi.info'. + + * Makefile.in (MDEFINES): Pass LDFLAGS to sub-makes. + (realclean): Delete `configure'. + Changed all references to texinfo.info to texi.info + + * configure.in: Add AC_PROG_RANLIB, and AC_CONST. + Check for `rindex' function. + Check for varargs.h. + Clean up symbol names for header files so a single AC_HAVE_HEADERS + can be used. + (AC_INIT): Use texi.texi instead of makeinfo/makeinfo.c + + * info/info-utils.h: Copy definitions of bcopy, index, and rindex + (with appropriate #ifdef wrappers) from termdep.h. These are + included by a mutually exclusive set of files. + + * info/termdep.h [HAVE_SYS_PTEM]: Use HAVE_SYS_PTEM_H instead. + + * info/terminal.c, info/termdep.h [HAVE_TERMIO]: Use HAVE_TERMIO_H + instead. + + * info/makedoc.c, info/filesys.c [!O_RDONLY]: Include fcntl.h or + sys/fnctl.h, depending on whether HAVE_SYS_FCNTL_H is set. + + * info/termdep.h: Remove all indentation in #-exprs. + Remove old assumptions about bcopy, index, and rindex. + [HAVE_BCOPY]: Define bcopy. + [HAVE_RINDEX]: Define index and rindex. + + * info/nodes.c (info_get_node): Don't call stricmp if nodename is + NULL. Remove indentation in #-exprs. + + * info/echo_area.c (echo_area_stack_depth): Declare static. + + * info/Makefile.in (DEFAULT_INFOPATH): Make separate Makefile + variable so it can be overridden more easily by the user. Add `.' + to beginning of path. + (clean): Delete core.* (386bsd core files). + (MAKEDOC): Variable removed. Refer to `makedoc' explicitly. + (funs.h): Add `:' commands after if, to avoid spurious nonzero + exit statuses. + + * info/userdoc.texi: Improved comments explaining its purpose. + + * makeinfo/makeinfo.c [HAVE_VARARGS_H]: Include varargs.h. + (error, line_error, warning, add_word_args, + execute_string)[HAVE_VARARGS_H]: New versions that + use varargs. From bfox. + + * makeinfo/Makefile.in (clean): Delete core.* (386bsd core files). + + * util/Makefile.in (clean): Remove core.* (386bsd core files). + + * libtxi/Makefile.in: Remove all references to $(common). + (RANLIB): New variable, set from autoconf. + (libtxi.a): Use $(RANLIB) instead of `ranlib' in target rules. + (clean): Delete core.* (386bsd core files). + +Tue May 18 12:08:24 1993 Robert J. Chassell (bob at grackle.stockbridge.ma.us) + + * emacs/texinfmt.el (texinfo-format-refill): Do not fill a section + title line with the asterisks, hyphens, etc. that underline + it in any circumstance. + +Sun May 16 13:53:43 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/mkinstalldirs: handle relative pathnames. + +Fri May 14 20:18:49 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/mkinstalldirs: initialize IFS if unset. + +Tue May 11 06:33:14 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * makeinfo/makeinfo.c (cm_item): don't dereference item_func if NULL. + +Mon May 10 14:50:31 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * Texinfo 3.0 released. + + * Makefile.in (ALLOCA): Provide for substitution. + +Mon May 10 10:12:53 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * emacs/texinfmt.el (texinfmt-version): Updated year. + +Fri Apr 16 04:48:03 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * makeinfo/makeinfo.c: Version 1.54 from bfox. + + * util/fixfonts: Replace instances of `[..]' with `test'. + Use more portable `test' arguments: `z$foo = z' instead of `! $foo'. + Robustify quoting in eval assignments. + (textfmdir, texpkdir, texgfdir): Don't override definition from + environment, if any. + Trap EXIT, SIGHUP, SIGINT, SIGQUIT, SIGTERM to delete temp files + instead of trying to remove them explicitly before calling exit. + When changing cwd, do so in subshell, in case various tex*dir + variables are relative. + Don't use `head', `dirname', or `basename'. These don't behave + consistently and/or don't even exist on some systems. They can + all be emulated with `sed' anyway. + (tempfile2_line1): New variable. Use it instead of running + process to extract first line out of tempfile2 multiple times. + Eliminate some gratuitous uses of $tempfile2, such as in for loops. + +Fri Mar 26 23:25:13 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * texinfo.texi: @setfilename texinfo.info. + + * makeinfo/makeinfo.c (reader_loop, end_insertion): Fix typos in + comments. + (handle_variable_internal): Handle the case that there further + menu text after a false ifset/ifclear. + + * util/texi2dvi: Version 0.4 + Replace all instances of `[ ... ]' with `test'. + Updated bug-reporting address. + +Thu Mar 25 12:31:30 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * info/Makefile.in (install): Install info.1 man page. + (uninstall): Remove installed info.1 man page. + + * info/infoman.texi: Standalone manual renamed to info-stnd.texi. + Makefile.in: Targets updated appropriately. + + * info/Makefile.in (LDEFS): New variable. Use it for info-local + macros, since DEFS will be inherited from parent make and any + local definitions will get clobbered. + + * info/RELEASE: Renamed to info/NEWS. + + * README: New file. + + * Makefile.in (topclean): New target. + + * Getting-started: Renamed to INTRODUCTION. Former name is too + long (over 14 chars). + + * New-features: Renamed to NEWS. + + * Makefile.in (MDEFINES): Set it. + + * Makefile.in (dist): Use --gzip option to tar to make sure + resulting file is compressed with gzip. Change tar file + extension from `.Z' to `.z'. + + * Makefile.in (DISTFILES): Filter out any file or directory names + starting with `='. + + * fixfonts: Moved to util/fixfonts. + + * RELEASE: Deleted. + + * makeinfo/Makefile.in (VPATH): Use $(srcdir), not @srcdir@. + (common): Use ../libtxi, not ../common. + (makeinfo.in): Run makeinfo with --no-split. + + * makeinfo/makeinfo.texi: Changes from bob. + + * util/Makefile.in (VPATH): Use $(srcdir), not @srcdir@. + (common): Use ../libtxi, not ../common. + + * util/fixfonts: Moved from top-level directory. + +Wed Mar 24 10:21:31 1993 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-format-region): Do not require + `@setfilename' line; delete `\input texinfo' line if part of + region. + + * emacs/texinfmt.el (texinfo-raise-lower-sections): Raise or lower the + hierarchical level of chapters, sections, etc. according to + `@raisesections' and `@lowersections' commands. + +Thu Mar 18 16:02:27 1993 Robert J. Chassell (bob at grackle) + + * emacs/texinfo.el (texinfo-show-structure): Indent *Occur* buffer + according to the structure of the file. + +Sat Mar 6 05:16:44 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/texi2dvi: use ${1+"$@"}, not just "$@". + +Tue Feb 2 08:38:06 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * info/Makefile.in: Replace all "--nosplit" arguments to makeinfo + with "--no-split" + +Sun Jan 31 18:16:58 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/texi2dvi: Don't put .dvi and related auxillary files in same + directory as source files. Put them in current directory instead. + (TEXINPUTS_orig): New variable. + (file_texi): Variable removed. + (filename_texi): New variable. + (command_line_filename): Use this wherever references to file_texi + occured except in setting filename_noext. + (TEXINPUTS): Current directory and source directory where input + file resides prepended to standard path before invoking TeX. + +Wed Jan 27 16:24:37 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/Makefile.in: overhauled. + +Tue Jan 26 21:04:23 1993 Noah Friedman (friedman@prep.ai.mit.edu) + + * Makefile.in, info/Makefile.in, makeinfo/Makefile.in: Overhauled. + + * configure.in: Renamed from texinfo.in. + Incorporated makeinfo/makeinfo.in, info/info.in, and + util/util.in. Create all child Makefiles. + + * makeinfo/makeinfo.in, info/info.in: Deleted (incorporated into + top configure.in). + + * util/util.in: Deleted (incorporated into ../configure.in). + +Mon Jan 25 10:59:49 1993 Brian Fox (bfox@cubit) + + * info/info.c: New version 2.9; new variable INFO_PATCH_LEVEL + appears in the version string if it is non-zero. New function + version_string () produces the current version string, as in 2.8-p1. + + * info/dir.c: New file implements Gillespies `localdir' hacks. + + * info/nodes.c (info_get_node): Now calls maybe_build_dir_node () + if the file name to look for is "dir". + + * info/nodes.h: New flag N_CannotGC unconditionally prevents garbage + collection of a file buffer's contents. Used when "dir" is made + from at least one "localdir". + +Fri Jan 22 11:36:42 1993 Brian Fox (bfox@cubit) + + * info/footnotes.c: Do not declare auto_footnotes_p as "extern" in + this file. + +Thu Jan 21 08:57:08 1993 Brian Fox (bfox@cubit) + + * info/info.c: New version 2.8. + + * info/userdoc.texi, info/infoman.texi, info/info.texi: Fully + document Info; create both online and printed manual versions. + "userdoc.texi" contains exactly the documentation for GNU Info 2.x. + "infoman.texi" is a wrapper for that file; it is meant to produce + printed documentation. "info.texi" has the user documentation as a + complete chapter within itself, but continues to contain the Info + tutorial. + + * info/makedoc.c: Convert "ea_" into "echo_area_" when creating the + command name. + +Fri Jan 15 16:50:35 1993 Brian Fox (bfox@cubit) + + * info/search.c (skip_node_characters): New argument NEWLINES_OKAY if + non-zero says that newlines should be skipped over during parsing. + + * info/info-utils.c (info_parse_node): New argument NEWLINES_OKAY if + non-zero says that newlines should be skipped while parsing out + the nodename specification. + +Wed Jan 13 14:42:33 1993 Brian Fox (bfox@cubit) + + * info/makedoc.c: Remove "info_" from the front of the command name + before installing it. + + * info/session.c (info_menu_or_ref_item): A label of "Menu" is okay if + the builder is not info_menu_of_node (); + + * info/m-x.c: New function replace_in_documentation () replaces \\[foo] + with the keystrokes you type to get that command. Now used in + indices.c, info.c, infodoc.c. + +Mon Jan 11 10:27:41 1993 Brian Fox (bfox@cubit) + + * info/variables.c, h: New files contain describe-variable and stuff + moved out of m-x.c. + + * info/m-x.c: Move VARIABLE_ALIST and variable functions into + variables.c. Add documentation string to variable definition. + + * info/echo_area.c (push_echo_area): Zero the contents of + echo_area_completion_items after pushing the vars. + +Sat Jan 9 11:59:47 1993 Brian Fox (bfox@cubit) + + * info/Makefile.in: Add footnotes.c,h,o to the appropriate Makefile + variables. + + * info/window.c (window_tile_windows): New function divides the + available space among the visible windows. + + * info/session.c (info_tile_windows): New function calls + window_tile_windows. + + * info/footnotes.c, footnotes.h: New file implements functions for + aiding automatic footnote display when entering a node which has + footnotes. + + * info/m-x.c: New user-variable "automatic-footnotes". + + * info/window.c (window_physical_lines) New function counts the + carriage returns found in NODE. + +Wed Jan 6 11:24:19 1993 Brian Fox (bfox@cubit) + + * info/general.h: #include if we have it. + +Tue Jan 5 11:12:33 1993 Brian Fox (bfox@cubit) + + * info/info-utils.c (info_concatenate_references): If either arg is + NULL, return the other arg. + + * info/indices.c (info_indices_of_file_buffer): Simplified and + corrected loop through tags/nodes of file buffer looking for + indices. + + * info/search.c (skip_node_characters): Rewrite "if" statement for + clarification and conciseness. + +Fri Jan 1 03:18:26 1993 Brian Fox (bfox@cubit) + + * info/info.in: Check for setvbuf (), and check to see whether the args + are reversed. + + * info/dribble.c (open_dribble_file) Check HAVE_SETVBUF and + SETVBUF_REVERSED when setting the buffering on info_dribble_file. + +Thu Dec 31 20:14:13 1992 Brian Fox (bfox@cubit) + + * info/session.c (info_select_reference) If the node couldn't be found, + look for the label as a filename (i.e., "(LABEL)Top"). + +Wed Dec 30 01:57:50 1992 Brian Fox (bfox@cubit) + + * New Version 2.7 Beta. + + * info/echo_area.c: Numerous functions now do something with the + numeric argument. Kill ring implemented, as well as yank and + yank_pop. Also transpose-chars. + + * info/window.c (window_make_modeline): Check node->flags for + N_IsCompressed and display "zz" in the modeline if the node comes + from a file which is compressed on disk. + +Mon Dec 28 17:33:12 1992 Brian Fox (bfox@cubit) + + * info/filesys.c, info/nodes.c: New member of FILE_BUFFER "FILESIZE" + contains the size of file_buffer->contents. finfo.st_size is no + longer relied upon to read the contents of files, since the new + function (filesys_read_info_file) can read compressed files. + + * info/filesys.c (info_find_fullpath) If a file starts with a slash (or + tilde expansion causes it to start with a slash) still call + info_find_file_in_path () on it so that we can find files with + compression suffixes. + + * info/m-x.c: New variable "gc-compressed-files". + +Tue Dec 22 03:45:28 1992 Brian Fox (bfox@cubit) + + * info/info.c: Version 2.6 Beta. + + * info/indices.c (info_index_next): Improve the final search for the + matched index entry. + + * info/session.c (move_to_screen_line): New function implements `M-r'. + Given a numeric argument, move point to the start of that line in + the current window; without an arg, move to the center line. + * infomap.c: Put move_to_screen_line () on `M-r'. + + * info/nodes.c (adjust_nodestart): Don't set N_UpdateTags unless the + node came from a tags table. + + * info/nodes.c (info_find_file_internal): If the filename being looked + for doesn't start with a `/', then additionally compare the + filename against the fullpath of the file buffer sans the + directory name. This can happen when selecting nodemenu items. + +Mon Dec 21 10:07:18 1992 Brian Fox (bfox@cubit) + + * info/session.c, info/display.c: Remove all references to + active_window_ch, active_window_cv, cursor_h, and cursor_v. The + single function display_cursor_at_point () is used for all cursor + movement, and to place the terminal's cursor at the right location + on the screen. + +Sat Dec 19 12:01:33 1992 Brian Fox (bfox@cubit) + + * info/nodemenu.c: New file implements a few functions for manipulating + previously visited nodes. `list-visited-nodes' produces a menu of + the nodes that could be reached by info_history_node () in some + window. `select-visited-node' is similar to `list-visited-node' + followed by `info-menu-item', but doesn't display a window with + the visited nodes menu. + + * info/session.c (info_numeric_arg_digit_loop): If redisplay had been + interrupted, then redisplay all of the windows while waiting for + input. + + * info/display.c (display_was_interrupted_p): New variable keeps track + of interrupted display. Used in + info/session.c:info_numeric_arg_digit_loop (). + + * info/session.c (info_global_next, info_global_prev): Use the numeric + argument passed to determine how many nodes to move. + + * info/session.c (info_scroll_forward, info_scroll_backward): If the + invoking key is not SPC or DEL only do Page Only scrolling. + +Thu Dec 17 01:34:22 1992 Brian Fox (bfox@cubit) + + * info/display.c (display_update_one_window): Allow W_NoWrap to affect + window display. + + * info/window.c (calculate_line_starts): Now takes a WINDOW * as an + argument, and simply does the calculation, placing the results + into window->line_starts and window->line_count. It also handles + W_NoWrap in window->flags. + +Mon Dec 14 02:18:55 1992 Brian Fox (bfox@cubit) + + * info/session.c (info_backward_scroll): Don't try to get previous node + if the top of the node isn't currently being displayed. + + * info/window.c (window_adjust_pagetop) Use new variable + "window_scroll_step" to attempt to control the amount which the + window scrolls. + + * info/m-x.c (info_variables) Add "scroll-step" to the list. + +Thu Dec 10 08:52:10 1992 Brian Fox (bfox@cubit) + + * info/m-x.c: New variable entry show-index-matches. When set to + non-zero the matched portion of the search string is indicated + with ` and '. Perhaps I should use `|' inst|ea|d? + + * info/echo_area.c (ea_possible_completions): Always build completions + before checking to see how many there were. + + * info/info-utils.c: (info_concatenate_references): New utility + function concatenates references. + + * info/Makefile.in: Add indices.c and indices.h to SRCS and HDRS. + Add indices.c to CMDFILES. + + * info/indices.c, info/indices.h: New file implements `i' and `,' + commands of info, and provides index searching capabilities. + + * info/echo_area.c (info_read_completing_in_echo_area): Split off into + separate callable function info_read_completing_internal (). + + * info/echo_area.c (info_read_maybe_completing): New function calls + info_read_completing_internal () with non-forcing argument. + + * info/session.c: Rename down_next_upnext_or_error () and + prev_up_or_error () to forward_move_node_structure (), and + backward_move_node_structure (). Implement new commands + info_global_next () and info_global_prev (). + + * info/infomap.c (initialize_info_keymaps): Bind `[' and `]' to + backward_, forward_move_node_structure () respectively. + + * info/session.c (info_menu_digit): Called with "0" as arg, select the + last menu item. + + * info/infomap.c (initialize_info_keymaps): "0" calls + info_menu_digit (). + + * info/session.c (info_move_to_xref): Take dir into account when there + are xrefs and menu items in the node and we are wrapping + backwards. + +Tue Dec 8 09:57:58 1992 Brian Fox (bfox@cubit) + + * info/info.c: Version 2.5 Beta. + + * info/terminal.c (terminal_insert_lines, terminal_delete_lines) Do not + expect tgoto to return a new string; it returns the address of a + static buffer. + + * info/infodoc.c (info_find_or_create_help_window) Correct check for + prior existing help node. + + * info/m-x.c (set_variable): Allow variables to have a list of choices. + Add new variable scroll-behaviour. + + * info/session.c (down_next_upnext_or_error, prev_up_or_error) New + functions implement user-controlled behaviour when attempting to + scroll past the bottom or top of a node. New variable + info_scroll_behaviour is user visible as "scroll-behaviour". + + * info/session.c (info_scroll_forward, info_scroll_backward) Call new + functions for user-controlled scroll behaviour. + + * info/terminal.c (terminal_initialize_terminal) Set PC from BC not + from BUFFER. + +Mon Dec 7 11:26:12 1992 Brian Fox (bfox@cubit) + + * util/texindex.c: Change EXIT_SUCCESS and EXIT_FATAL to TI_NO_ERROR + and TI_FATAL_ERROR respectively. This avoids namespace conflicts + on NeXT 2.0. + +Sat Dec 5 00:07:59 1992 Brian Fox (bfox@cubit) + + * info/info.c: New option "--subnodes" says to recursively dump the + menus of the nodes that you wish to dump. Menu items which point + to external nodes are not dumped, and no node is dumped twice. + +Thu Dec 3 16:11:02 1992 Brian Fox (bfox@cubit) + + * info/session.c (info_error) Don't ring the bell if + info_error_rings_bell_p is zero. (info_abort_key) Ring the bell + if printing "Quit" in the echo area wouldn't do it. + + * info/m-x.c (set_variable) New functions allows setting of + variables in the echo area. Currently, only visilble-bell and + errors-ring-bell are implemented. + +Wed Dec 2 13:11:37 1992 Brian Fox (bfox@cubit) + + * info/nodes.c, info/makedoc.c: If O_RDONLY is not defined by + sys/file.h, include sys/fcntl.h. + + * info/filesys.c (info_file_in_path): Expand leading tildes found + within directory names. + + * info/terminal.c (terminal_initialize_terminal) Set ospeed to 13 if + not settable any other way. It is an index into an array of + output speeds. + + * info/display.c (free_display) Do not free a NULL display. + + * info/display.c (string_width): New functions returns the width of + STRING when printed at HPOS. + +Sun Nov 29 01:24:42 1992 Brian Fox (bfox@cubit) + + * info/info.c: New version 2.4 beta. + + * info/general.h: #define info_toupper and info_tolower which check + their arguments before performing any conversion. + + * info/search.c, info/echo_area.c: Use info_toupper. + +Sat Nov 28 14:23:24 1992 Brian Fox (bfox@cubit) + + * info/session.c (info_scroll_forward, info_scroll_backward) If at + last/first page of the node, and the last command was + forward/backward, do info_next/prev/_node. + + * info/session.c: New function info_select_reference_this_line gets + menu or cross reference immediately. + + * info/infomap.c (initialize_info_keymaps): Add info_keymap[LFD] to + invoke info_select_reference_this_line (). + + * info/session.c (info_last_reference) Rename to + info_history_reference. Wrote info_last_reference, and + info_first_reference which go to the last or first node of an info + file. + +Fri Nov 27 00:59:02 1992 Brian Fox (bfox@cubit) + + * info/info.c: New version 2.3. Completed implementing contents of + TODO file. + + * info/session.c (info_redraw_display): Fix C-l with numeric arg. + +Thu Nov 26 20:14:18 1992 Brian Fox (bfox@cubit) + + * info/m-x.c: New file implements reading named commands in the echo + area, along with a new function "info-set-screen-height". + Compilation of this file and some code in others controlled by the + Makefile variable NAMED_COMMANDS (set to -DNAMED_COMMANDS). + + * info/window.c (window_new_screen_size) Rewrite from scratch, allowing + clean growth and shrinkage of the screen. New variable + window_deletion_notifier is a pointer to a function to call when + the screen changes size, and some windows have to get deleted. + The function is called with the window to be deleted as an + argument, and it should clean up dangling references to that + window. + + * info/session.c (initialize_info_session): Set + window_deletion_function to forget_window_and_nodes. + + * info/display.c (display_update_one_window): If the first row of the + window to display wouldn't appear in the_screen, don't try to + display it. This happens when the screen has been made + unreasonably small, and we attempt to display the echo area. + +Tue Nov 24 00:47:20 1992 Brian Fox (bfox@cubit) + + * Release Info 2.2. + + * info/session.c: New functions implement reading typeahead and + implement C-g flushing typed ahead characters. + (info_search_internal): allows C-g to exit multi-file searches. + +Mon Nov 23 01:53:35 1992 Brian Fox (bfox@cubit) + + * info/nodes.c: Remove calls to sscanf (), replacing them with calls to + atol (), since that is much faster. + (get_nodes_of_tags_table) Only check for "(Indirect)" if we + haven't parsed any nodes out of the tags table. Increase the + amount that file_buffer->nodes grows to 100 from 50. These two + together sufficiently speed up the parsing process. + + * info/nodes.c: info_get_node_of_file_buffer_tags (), + info_get_node_of_file_buffer_nodes (): Search the appropriate list + and return a node. This was simply a cut and paste edit to + functionalize the code. + + * info/TODO: Remove suggestion for partial tag parsing, since tag + parsing is much faster now. + +Sat Nov 21 02:48:23 1992 Brian Fox (bfox@cubit) + + * info/makedoc.c: New File replaces makedoc.sh shell script. + + * info/infomap.c: Install info_isearch (on C-s) and + info_reverse_isearch (on C-r) for Info windows. + + * info/session.c (incremental_search, info_isearch, + info_reverse_isearch) New functions implement incremental + searching. + +Fri Nov 20 00:01:35 1992 Brian Fox (bfox@cubit) + + * info/terminal.c (terminal_initialize_terminal): Declare and set up + `ospeed'. Turn off C-s and C-q processing. + + * info/session.c (info_show_point) When this function is called, the + desired result is to show the point immediately. So now it calls + set_window_pagetop () if the new pagetop is not the same as the + old one. This means that info_prev_line (), info_next_line (), + info_forward_word (), and info_backward_word () can all scroll the + window if they have to. + +Thu Nov 19 12:27:07 1992 Brian Fox (bfox@cubit) + + * info/session.c (set_window_pagetop): Add scrolling to make this + faster. + + * info/echo_area.c (push/pop_echo_area): Remember the list of items to + complete over. + + * info/session.c (info_forward_char): Don't let point get equal to + nodelen, only to nodelen - 1. + + * info/display.c: New function display_scroll_display () scrolls the + rmembered display as well as the text on the actual display. + + * info/terminal.c: New functions terminal_scroll_terminal (), + terminal_scroll_down (), and terminal_scroll_up (). All + implemented using "al" and "dl" termcap capabilities. (i.e., + insert and delete line). + +Wed Nov 18 15:05:14 1992 Brian Fox (bfox@cubit) + + * info/termdep.h: Only define HAVE_FCNTL_H if !aix and !ultrix. + +Tue Nov 17 20:35:08 1992 Brian Fox (bfox@cubit) + + * First Beta Release of Info 2.0. + +Sun Nov 1 02:21:05 1992 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/texi2dvi (--force): Option removed. Always run tex at least + once, don't bother checking if .dvi file is newer than source. + +Fri Oct 30 02:16:28 1992 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/texi2dvi (-D): debugging option renamed from '-d'. + Made check to enable debugging more terse. + When checking if index files have changed, use + variable $this_file instead of $file in for loop. + (file_texi): wherever the variable $file was used to reference + the texinfo file, substituted $file_texi. + +Sat Oct 17 07:30:34 1992 Brian J. Fox (bfox@helios) + + * util/texindex.c: Remove references to USG replacing them with a + define declaring the actual feature required or missing. + +Thu Oct 15 16:17:47 1992 Robert J. Chassell (bob@nutrimat.gnu.ai.mit.edu) + + * emacs/texinfmt.el (texinfo-format-setfilename): Remove date from + Info file header so regression testing is easier. + +Tue Sep 15 16:28:35 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfmt-version): New variable. + (texinfo-format-setfilename): Include date and + version in Info file header. + Better documentation for @definfoenclose + Handle whitespace after @end iftex, etc. + +Thu Sep 3 09:25:37 1992 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el: Fix typo re `texinfo-sequential-node-update.' + +Tue Aug 18 08:56:24 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-value): Revise syntax. + + * emacs/texnfo-upd.el (texinfo-start-menu-description): + New function to insert title as description in a menu. + (texinfo-make-menu-list): Remove automatic title insertion. + + * emacs/texinfo.el (texinfo-mode-map): Add keybinding for + texinfo-start-menu-description. + +Wed Jul 29 11:58:53 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-set): Revise to set a string to the flag. + (texinfo-value): @value{flag}: New command which inserts the + string to which the flag is set. + +Tue Jul 7 15:10:52 1992 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el (texinfo-master-menu): Error message if file + contains too few nodes for a master menu. + (texinfo-insert-master-menu-list): Only attempt to insert detailed + master menu if there is one. + +Wed Jun 10 15:26:18 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-append-refill): Refill properly when lines + begin with within-paragraph @-commands. + +Tue Jun 9 12:28:11 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el: Add `texinfo-deffn-formatting-property' and + `texinfo-defun-indexing-property' to @deffn commands. + +Mon Jun 8 11:52:01 1992 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el: Replace `(mark-whole-buffer)' with + `(push-mark (point-max) t) (goto-char (point-min))' + to avoid `Mark set' messages. + +Fri Jun 5 15:15:16 1992 Robert J. Chassell (bob@kropotkin.gnu.ai.mit.edu) + + * emacs/texnfo-upd.el (texinfo-check-for-node-name): Offer section + title as prompt. + (texinfo-copy-next-section-title): Copy title correctly. + +Thu May 28 20:34:17 1992 Robert J. Chassell (bob@hill.gnu.ai.mit.edu) + + * emacs/texinfmt.el: @vtable defined, parallel to @ftable, for + variables. + (texinfo-append-refill): set case-fold-search nil so @TeX is not + confused with @tex. + +Thu Mar 26 21:36:41 1992 Robert J. Chassell (bob@kropotkin.gnu.ai.mit.edu) + + * emacs/makeinfo.el: Rename temp buffer from `*Makeinfo*' back to + `*compilation*' so `next-error' works; unfortunately, + `*compilation*' is written into the code as the name + `next-error' needs. + Rename `makeinfo-recenter-makeinfo-buffer' back to + `makeinfo-recenter-makeinfo-buffer' + +Thu May 14 21:14:25 1992 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/fixfonts: Enclosed most variable references with "" to prevent + potential globbing and other weirdness. Eliminated uses of + ${var-value}, which unfortunately isn't portable. + + * util/texi2dvi: rewritten from scratch. + +Sat Apr 18 23:46:25 1992 Charles Hannum (mycroft@hal.gnu.ai.mit.edu) + + * util/fixfonts: Re-evaluate prefix and libdir if inherited (to resolve + variable references from make). + (texlibdir): Don't add '/tex', since it's already there. + +Fri Apr 10 14:51:23 1992 Noah Friedman (friedman@prep.ai.mit.edu) + + * util/fixfonts: set prefix and libdir only if they are not already + defined (i.e. not inherited from the environment). + Changed default path for libdir to be consistent with Makefile. + +Tue Mar 3 13:17:42 1992 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el (texinfo-insert-master-menu-list): Insert a + master menu only after `Top' node and before next node. + (texinfo-copy-menu): Error message if menu empty. + +Mon Feb 24 15:47:49 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-format-region): Make sure region ends in a + newline. + (texinfo-itemize-item): Recognize all non-whitespace on same line + as @item command. + +Sat Feb 22 02:15:00 1992 Brian Fox (bfox at gnuwest.fsf.org) + + * util/texindex.c: New version 1.45 has cleanups, should compile under + VMS quietly. + +Wed Feb 12 10:50:51 1992 Robert J. Chassell (bob at grackle) + + * emacs/makeinfo.el: Rename temp buffer as *Makeinfo*. + Rename `makeinfo-recenter-compilation-buffer'. + (makeinfo-buffer): Offer to save buffer if it is modified. + (makeinfo-compile): Do not offer to save other buffers. + (makeinfo-compilation-sentinel): Switch to Info file. + +Tue Feb 4 13:07:39 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-print-index): Format so that node names in + the index are lined up. + +Mon Feb 3 09:08:14 1992 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-itemize-item): Format entry when text + is on the same line as @item command. Also, handle @-commands. + (texinfo-format-region, texinfo-format-buffer-1): Set fill column + to local value of Texinfo buffer. + + * emacs/texnfo-upd.el (texinfo-pointer-name): Find only those + section commands that are accompanied by `@node' lines. + +Tue Jan 14 16:10:16 1992 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el: Ensure that no commands depend on the value of + case-fold-search. + +Fri Jan 10 15:13:55 1992 Robert J. Chassell (bob at kropotkin) + + * emacs/texinfmt.el (texinfo-append-refill): Replace use of + unsupported function `looking-at-backward' with + `re-search-backward'. + +Mon Dec 23 23:46:42 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * util/texindex.c: Change POSIX ifdefs to HAVE_UNISTD_H and + _POSIX_VERSION. + +Mon Dec 16 15:01:36 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-append-refill): New function appends + @refill to all appropriate paragraphs so you no longer need to + append @refill command yourself. + (texinfo-format-region, texinfo-format-buffer-1, + texinfo-format-include): Call `texinfo-append-refill'. + +Fri Dec 6 01:25:09 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * util/texindex.c: Conditionalize on _AIX (which is predefined) instead + of AIX, just like makeinfo does. + +Tue Nov 26 10:21:04 1991 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el (texinfo-section-types-regexp): `@subtitle' no + longer treated as subsection. + +Sat Nov 16 08:27:42 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu) + + * util/fixfonts: New file, from Karl Berry. + +Tue Nov 12 16:13:24 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el: Create @end smalllisp. + +Mon Nov 11 16:50:13 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfo.el (texinfo-environment-regexp): Add all other block + enclosing Texinfo commands. + +Thu Nov 7 10:23:51 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfo.el (texinfo-insert-@end): Attempt to insert correct end + command statement, eg, @end table. Fails with nested lists. + (texinfo-insert-*): Accept prefix arg to surround following N + words with braces for command. + +Thu Oct 31 21:31:41 1991 Robert J. Chassell (bob at kropotki) + + * emacs/texinfmt.el (texinfo-clear): Clear flag even if flag not + previously set. + +Wed Oct 23 11:15:58 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfo.el (texinfo-mode): page-delimiter now finds top node as + well as chapters. + +Tue Oct 22 11:46:12 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-do-flushright): Test whether a line is too + long for the flush right command (line length must be less than + the value of fill column). + + * emacs/texnfo-tex.el (texinfo-tex-buffer): Prompt for original file + even if point moved to *texinfo-tex-shell*. + texinfo-tex-original-file: variable to hold file name. + +Wed Oct 16 08:32:05 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-format-center): Expand string before + centering so @-commands not included. + +Thu Oct 10 22:01:47 1991 Robert J. Chassell (bob at kropotki) + + * emacs/texnfo-tex.el (texinfo-show-tex-print-queue): Do not kill a + running process; do start a process none exists. + +Thu Sep 26 21:58:47 1991 Robert J. Chassell (bob at kropotki) + + * util/texi2dvi: Misc. bugs fixed. + + * emacs/texinfo.el: Remove extraneous references to TeX. + +Thu Sep 19 20:45:29 1991 Robert J. Chassell (bob at kropotki) + + * emacs/texinfmt.el: add @cartouche as a noop (makes box with rounded + corners in TeX) + +Tue Sep 10 20:44:57 1991 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el (texinfo-make-one-menu): Copy node-name correctly + for message. + +Thu Aug 29 17:54:07 1991 Robert J. Chassell (bob at kropotki) + + * emacs/texnfo-tex.el (texinfo-quit-tex-job): Do not set mark. + +Wed Aug 21 10:36:21 1991 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el: (texinfo-copy-menu-title): Copy title as it + should rather than node line. + +Mon Aug 5 15:27:12 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el (texinfo-format-convert): Changed regexp that + looks for three hyphens in a row to find those between word + constituent characters, as now, for Oxford Univ. style dashes and + also between spaces, for Cambridge Univ. Press style dashes. + + * emacs/texnfo-tex.el (texinfo-tex-start-shell): Runs "/bin/sh" so + `explicit-shell-file-name' is not set globally. + + * emacs/texnfo-upd.el: Rewrite messages. + (texinfo-find-higher-level-node): Stop search at limit. + (texinfo-copy-menu-title): Rewrite to handle outer include files. + (texinfo-multi-file-update): Update all nodes properly; + rewrite doc string and interactive. + +Sat Aug 3 10:46:13 1991 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-upd.el (texinfo-all-menus-update): Fixed typo that + caused the function to create a master menu when it shouldn't. + + * emacs/texinfo.el (texinfo-mode): Make `indent-tabs-mode' a local + variable and set to nil to prevent TABs troubles with TeX. + +Wed Jul 31 11:07:08 1991 Robert J. Chassell (bob at grackle) + + * emacs/texnfo-tex.el (texinfo-quit-tex-job): New function: quit + currently running TeX job, by sending an `x' to it. + (texinfo-tex-shell-sentinel): New function to + restart texinfo-tex-shell after it is killed. + (texinfo-kill-tex-job): Rewrite to use kill-process rather than + quit-process; uses `texinfo-tex-shell-sentinel' to restart + texinfo-tex-shell after it is killed. + (texinfo-tex-region, texinfo-tex-buffer): Replace + texinfo-kill-tex-job with quit-process. + + * emacs/texinfo.el (texinfo-define-common-keys): Add keybinding for + texinfo-quit-tex-job + +Wed Jul 10 15:15:03 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el: New commands @set, @clear, @ifset...@end + ifset, and @ifclear...@end ifclear. + Definition functions rewritten to make them easier to + maintain. + +Wed Jul 3 19:37:04 1991 Robert J. Chassell (bob at kropotki) + + * emacs/texinfmt.el (texinfo-format-deftypefn-index): Remove reference + to data-type to make consistent with texinfo.tex and makeinfo. + texinfo.el: Fix page-delimiter and texinfo-chapter-level-regexp + variables. + +Thu Jun 27 18:35:36 1991 Robert J. Chassell (bob at nutrimat) + + * emacs/texinfmt.el: Add @dmn as `texinfo-format-noop'. + texinfo2.texi: Document @dmn. + texinfmt.el (texinfo{,-end}-{eleterate,ecapitate} renamed + {alphaenumerate, capsenumerate}. + +Fri Jun 14 12:46:32 1991 Robert J. Chassell (bob at churchy.gnu.ai.mit.edu) + + * emacs/texinfmt.el (texinfo-format-defun-1): @defivar prints name + correctly. + +Thu Jun 6 21:38:33 1991 Robert J. Chassell (bob at churchy.gnu.ai.mit.edu) + + * emacs/texinfo.el (texinfo-mode): Set page delimiter to + 'texinfo-chapter-level-regexp' so that page commands work by + chapter or equivalent. + + * emacs/texinfmt.el (texinfo-format-defun-1): @defop prints name + correctly. + (batch-texinfo-format): replace unsupported + 'buffer-disable-undo' with 'buffer-flush-undo' + +Fri Apr 5 15:17:17 1991 Robert J. Chassell (bob at wookumz.gnu.ai.mit.edu) + + * emacs/makeinfo.el (makeinfo-compilation-sentinel): Check for + existance of makeinfo-temp-file to avoid harmless error message. + texinfo2.texi: Minor typos fixed. + +Thu Mar 28 19:13:24 1991 Robert J. Chassell (bob at pogo.gnu.ai.mit.edu) + + * util/texi2dvi: Revised. + +Mon Mar 11 12:35:51 1991 Robert J. Chassell (bob at grackle) + + * emacs/texinfmt.el: (@footnotestyle): New command to set + footnotestyle. + (@paragraphindent): New command to set indentation. + (texinfo-format-refill): Add indentation feature so as to + indent paragraph or leave indentation asis before refilling + according to value set by @paragraphindent command. + (texinfo-format-region): Insert header, if any, into Info buffer. + (texinfo-format-separate-node, texinfo-format-end-node): Run + texinfo-format-scan on footnote text only once. + (texinfo-format-scan): Shorten `---' to `--'. + + * emacs/texinfo.el: Define key for `texinfo-master-menu'; define + start and end of header expressions. + + * emacs/texnfo-upd.el (texinfo-all-menus-update): Update + pre-existing master menu, if there is one. + +Fri May 11 14:36:07 1990 Richard Stallman (rms at sugar-bombs.ai.mit.edu) + + * util/texindex.c: Rename `lines' to `nlines'. + (bzero): Pass arg to lib$movc5 through non-register var. + (perror_with_file, pfatal_with_file): Move extern decls and includes + to top of file. + [VMS]: If not using VMS C, define away `noshare' keyword. + Include perror.h. + +Mon Jul 11 18:02:29 1988 Chris Hanson (cph at kleph) + + * util/texindex.c (indexify): when comparing to initial strings to + decide whether to change the header, must use `strncmp' to avoid + comparing entire strings of which initials are a substring. + +Sun Jun 26 18:46:16 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu) + + * util/texindex.c (sort_in_core, sort_offline, parsefile): + Give up on input file if any line doesn't start with backslash. diff --git a/texinfo/INSTALL b/texinfo/INSTALL new file mode 100644 index 000000000000..a2c8722ccaff --- /dev/null +++ b/texinfo/INSTALL @@ -0,0 +1,181 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/texinfo/INTRODUCTION b/texinfo/INTRODUCTION new file mode 100644 index 000000000000..1d298ca36a7b --- /dev/null +++ b/texinfo/INTRODUCTION @@ -0,0 +1,119 @@ +Getting Started with Texinfo +============================ + +25 March 1993 + +Most of the installation instructions are described in the file `INSTALL'. +One additional note to make is that if your info files are in a nonstandard +place (i.e. not in the `info' directory immediately under $prefix) you may +wish to change the default info path as specified via DEFAULT_INFOPATH in +info/Makefile.in. + +"Texinfo" is a documentation system that uses a single source file to +produce both on-line information and printed output. Using Texinfo, +you can create a printed document with the normal features of a book, +including chapters, sections, cross references, and indices. From the +same Texinfo source file, you can create a menu-driven, on-line Info +file with nodes, menus, cross references, and indices. + +The name of the Texinfo source documentation file is `texinfo.texi'. +You can produce both on-line information and printed output from this +source file. The documentation describes Texinfo in detail, including +how to write Texinfo files, how to format them for both hard copy and +Info, and how to install Info files. + +To get started, you need to create either a printed manual or an +on-line Info file from the `texinfo.texi' file. You do not need to +create both, although you will probably want both eventually. + +To learn how to use Info, read the info documentation. You can do this in +one of two ways: using the standalone `info' program, or using Info mode in +GNU Emacs. + + * If you want to use the `info' program, type + + $ info -f info-stnd + + * If you want to use Emacs, start up emacs and type `C-h i' [M-x info]. + Follow the instructions to learn how to use Info. + +After learning how to use Info, you can read the Texinfo documentation. +Using the standalone `info', type the following at the shell prompt: + + $ info -f texinfo + +To use read this manual in Emacs, you first need to edit the Info-directory +menu (the file `dir' in the system info directory) to contain the +appropriate node. To learn how to do this, see node: Add in the Info +documentation. + +The Texinfo documentation describes Texinfo in detail; among other things, +it tells how to install Info files in the usual manner. (See node: Install +an Info File.) + +The `info-stnd.info' file describes the standalone Info reader in detail. To +read this file, type + + $ info -f info-stnd + +If you are using GNU Emacs, you may want to install the Emacs Lisp files +permanently. Move them them to a directory in the load-path for Emacs; +otherwise Emacs will not be able to load the autoloaded support files, such +as `texinfmt.el'. + +The `texinfo.el' file contains the autoload commands; it is the only +file that needs to be loaded initially. If your Emacs does not +automatically load `texinfo.el', you can tell it to do so by placing +the following in `default.el' or in your `.emacs' file: + + (load "texinfo") + + +To create a printed manual +========================== + +You need: + + * The `tex' program, which typesets the manual using TeX. + * The `texinfo.tex' definition file that tells TeX how to typeset + a Texinfo file. + * The `texindex' program, which sorts the unsorted index files + created by TeX. + * A printing program such as `lp' or `lpr', + * A printer. + +This Texinfo distribution package contains `texinfo.tex', the C source +for `texindex', and the handy shell script `texi2dvi'. The `tex' +program is not part of this distribution, but is available separately. +(See `How to Obtain TeX' in the Texinfo documentation.) + + * Install `tex'. (`texindex' is installed automagically by + `make install' in this distribution.) + + * Move the `texinfo.tex' file to an appropriate directory; the current + directory will do. (`/usr/local/lib/tex/inputs' might be a good place. + See ``Preparing to Use TeX'' in the Texinfo manual, for more + information.) + +After following those instructions, type the following to make the .dvi +files: + + $ make texinfo.dvi + $ (cd info; make info.dvi info-stnd.dvi) + $ (cd makeinfo; make makeinfo.dvi) + +You can then print the resulting .dvi files with the `lpr' command (on BSD +systems. On SysV systems the command is `lp'. Consult your man pages for +more information). + +For example, the command to print the texinfo.dvi file might be: + + $ lpr -d texinfo.dvi + +The name of the printing command depends on the system; `lpr -d' is +common, and is illustrated here. You may use a different name for the +printing command. + +Please report bugs to bug-texinfo@prep.ai.mit.edu. + +Happy formatting. diff --git a/texinfo/Makefile.in b/texinfo/Makefile.in new file mode 100644 index 000000000000..4a5083853ebd --- /dev/null +++ b/texinfo/Makefile.in @@ -0,0 +1,244 @@ +# Makefile for Texinfo distribution. +# $Id: Makefile.in,v 1.11 1996/10/04 18:40:33 karl Exp $ +# +# Copyright (C) 1993, 96 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. + +#### Start of system configuration section. #### + +srcdir = @srcdir@ +VPATH = $(srcdir):$(common) + +common = $(srcdir)/libtxi + +EXEEXT = @EXEEXT@ +CC = @CC@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +LN = ln +RM = rm -f +TAR = tar +MKDIR = mkdir + +DEFS = @DEFS@ +LIBS = @LIBS@ +LOADLIBES = $(LIBS) + +ALLOCA = @ALLOCA@ + +SHELL = /bin/sh + +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +# Prefix for each installed program, normally empty or `g'. +binprefix = +# Prefix for each installed man page, normally empty or `g'. +manprefix = +mandir = @mandir@/man$(manext) +manext = 1 +infodir = @infodir@ + +# For info program. +DEFAULT_INFOPATH = $(infodir):. + +#### End of system configuration section. #### + +VERSION = 3.9 +DISTNAME = texinfo-$(VERSION) + +# Subdirectories that have makefiles +SUBDIRS = libtxi makeinfo info util emacs + +# All subdirectories that go into a distribution +ALL_SUBDIRS = $(SUBDIRS) makeinfo/macros + +MDEFINES = bindir='$(bindir)' mandir='$(mandir)' manext='$(manext)' \ + prefix='$(prefix)' binprefix='$(binprefix)' \ + manprefix='$(manprefix)' infodir='$(infodir)' CFLAGS='$(CFLAGS)' \ + CC='$(CC)' ALLOCA='$(ALLOCA)' LDFLAGS='$(LDFLAGS)' \ + DEFAULT_INFOPATH='$(DEFAULT_INFOPATH)' \ + INSTALL='$(INSTALL)' INSTALL_DATA='$(INSTALL_DATA)' \ + INSTALL_PROGRAM='$(INSTALL_PROGRAM)' + +all: sub-all texinfo + +check: +installcheck: +dvi: texinfo.dvi license.dvi lgpl.dvi + @for dir in $(SUBDIRS); do cd $$dir; $(MAKE) $(FLAGS_TO_PASS) $@; cd ..; done + +install: all installdirs + test -f $(infodir)/dir || $(INSTALL_DATA) $(srcdir)/dir $(infodir) + for dir in $(SUBDIRS); do \ + echo making $@ in $$dir; \ + (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \ + done + d=$(srcdir); test -f ./texinfo && d=.; \ + (cd $$d && for f in texinfo* ; do \ + $(INSTALL_DATA) $$f $(infodir)/$$f; done) + $(POST_INSTALL) + ./util/install-info --info-dir=$(infodir) $(infodir)/texinfo + @echo Please install $(srcdir)/texinfo.tex manually. + +installdirs: + -$(SHELL) $(srcdir)/util/mkinstalldirs $(bindir) $(datadir) $(infodir) $(mandir) + +.PHONY: install-info +install-info: info + for dir in $(SUBDIRS); do \ + echo making $@ in $$dir; \ + (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \ + done + d=$(srcdir); test -f ./texinfo && d=.; \ + (cd $$d; \ + for f in texinfo* ; do \ + $(INSTALL_DATA) $$f $(infodir)/$$f; \ + done) + +uninstall: + for dir in $(SUBDIRS); do \ + echo making $@ in $$dir; \ + (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \ + done + $(RM) $(infodir)/texinfo $(infodir)/texinfo-* + +Makefile: Makefile.in config.status + $(SHELL) ./config.status + +config.status: configure + $(SHELL) ./config.status --recheck + +#configure: configure.in +# cd $(srcdir) && autoconf + +sub-all TAGS: + for dir in $(SUBDIRS); do \ + echo making $@ in $$dir; \ + (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \ + done +.PHONY: sub-all + +clean mostlyclean: + for dir in $(SUBDIRS); do \ + echo making $@ in $$dir; \ + (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \ + done + +distclean: clean texclean + for dir in $(SUBDIRS); do \ + echo making $@ in $$dir; \ + (cd $$dir && $(MAKE) $(MDEFINES) $@ || exit 1); \ + done + $(RM) Makefile *.status *.cache *.log texinfo texinfo-? texinfo-?? + +texclean: + $(RM) *.aux *.cp *.cps *.dvi *.fn *.fns *.ky *.kys *.pg *.pgs + $(RM) *.toc *.tp *.tps *.vr *.vrs + +realclean: distclean + +# Let's hope we weren't cross-compiling. +# If we depend on sub-all, this always gets remade. Annoying. +info texinfo: texinfo.texi + ./makeinfo/makeinfo$(EXEEXT) -I$(srcdir) texinfo.texi +.PHONY: info + +texinfo.dvi: + PATH="$(srcdir)/util:$${PATH}" TEXINPUTS="$(srcdir):$(common):$${TEXINPUTS}" texi2dvi $(srcdir)/texinfo.texi +.PHONY: dvi + +license.info: $(srcdir)/license.texi + $(MAKEINFO) -I$(srcdir) -o license.info $(srcdir)/license.texi + +license.dvi: $(srcdir)/license.texi + PATH="$(srcdir)/util:$${PATH}" TEXINPUTS="$(srcdir):$(common):$${TEXINPUTS}" texi2dvi $(srcdir)/license.texi + +lgpl.info: $(srcdir)/liblic.texi + $(MAKEINFO) -I$(srcdir) -o lgpl.info $(srcdir)/liblic.texi + +lgpl.dvi: $(srcdir)/liblic.texi + PATH="$(srcdir)/util:$${PATH}" TEXINPUTS="$(srcdir):$(common):$${TEXINPUTS}" texi2dvi $(srcdir)/liblic.texi + mv liblic.dvi lgpl.dvi + +dist: DISTFILES + $(RM) -r $(DISTNAME) + $(MKDIR) $(DISTNAME) + for d in `find . -type d ! -name RCS -print`; do \ + d=`echo $$d | grep -v '[@=]'`; \ + test -z "$$d" || test "$$d" = . || test "$$d" = "./$(DISTNAME)" \ + || mkdir $(DISTNAME)/$$d; done + for f in `cat DISTFILES`; do \ + $(LN) $(srcdir)/$$f $(DISTNAME)/$$f || \ + { echo copying $$f; cp -p $(srcdir)/$$f $(DISTNAME)/$$f ; } \ + done + (cd $(DISTNAME); $(MAKE) $(MFLAGS) distclean) + $(TAR) chvf - $(DISTNAME) | gzip >$(DISTNAME).tar.gz + $(RM) -r $(DISTNAME) + +# Gets rid of most of the unwanted files. Verify manually (if necessary) +# that this produces a list of all the files desired in the distribution. +DISTFILES: force + (cd $(srcdir); find . ! -type d -print) \ + | sed '/\/RCS\//d; \ + /\/EMACS-BACKUPS\//d; \ + /\.tar.*/d; \ + /~$$/d; /\.o$$/d; \ + /\.gdbinit$$/d; \ + /\.orig$$/d; \ + /\#$$/d; \ + /\/info\/info$$/d; \ + /\.info$$/d; \ + /\.elc/d; \ + /\/makeinfo\/makeinfo$$/d; \ + /\/$(DISTNAME)\/.*$$/d; \ + /\/util\/texindex$$/d; \ + /texinfo$$/d; \ + /texinfo-[0-9]+$$/d; \ + /\/.*\.BAK$$/d; \ + /\/.*\.a$$/d; \ + /\/core$$/d; \ + /\/*\.core$$/d; \ + /\/core\..*$$/d; \ + /\/a.out$$/d; \ + /\/[=@]/d; \ + /\/conftest\.c$$/d; \ + /\/DISTFILES$$/d; \ + /\/foo$$/d; \ + /\/bar$$/d; \ + /\.toc$$/d; \ + /\.bak$$/d; \ + /\.aux$$/d; /\.log$$/d; \ + /\.cps$$/d; /\.cp$$/d; \ + /\.fns$$/d; /\.fn$$/d; \ + /\.tps$$/d; /\.tp$$/d; \ + /\.vrs$$/d; /\.vr$$/d; \ + /\.pgs$$/d; /\.pg$$/d; \ + /\.kys$$/d; /\.ky$$/d; \ + /\.ops$$/d; /\.op$$/d; \ + s/^.\///; /^\.$$/d;' \ + | sort | uniq > DISTFILES + +force: + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: diff --git a/texinfo/NEWS b/texinfo/NEWS new file mode 100644 index 000000000000..ffc70933396d --- /dev/null +++ b/texinfo/NEWS @@ -0,0 +1,93 @@ +This file records noteworthy changes. + +3.9 (4 October 1996) +* makeinfo: + - Give a suppressible (with --no-validate) error for references + outside of any node. + - Keep track of multitable output correctly for split files; this + caused nodes after the first multitable to be ``undefined''. +* install-info: + - Rename --infodir option to --info-dir. + - More robust error checking to avoid various crashes. +* configure: Include replacements for memcpy and memmove functions in + the distribution, in case they are missing. + +3.8 (30 September 1996) +* Define and/or document new and/or previously existing commands: + Accents: @" @' @, @" @= @^ @` @~ @H @d @dotaccent @dotless @ringaccent + @tieaccent @u @ubaraccent @v + Special characters: @AA @AE @L @O @OE @aa @ae @exclamdown @l @o @oe + @pounds @questiondown @ss + Special punctuation: @! @? @enddots + dir file maintenance: @dircategory @direntry; also new program, install-info + HTML support: @email @url @ifhtml...@end ifhtml + Macros: @macro @unmacro + Tables: @multitable @tab + Hyphenation: @- @hyphenation + Spacing: @ @ @ + Sectioning: + @headings singleafter/doubleafter (change heading style after current page) + @centerchap + @setchapterstyle + Other: + @shorttitlepage (simple title pages) + @detailmenu...@end detailmenu (help makeinfo parse master menus) +* Makeinfo prefers an input file named `foo.texinfo' or `foo.texi' or + `foo.txinfo' to just `foo' (the latter most likely being an executable). +* Makeinfo implements @. @! @? correctly, as end-of-sentence punctuation. +* @key marks its argument with a lozenge in TeX and <...> in Info. +* TeX output has substantially decreased interline spacing and other + formatting changes. +* Remove these obsolete and never-documented commands: + @infotop + @infoappendix @infoappendixsec @infoappendixsubsec @infoappendixsubsubsec + @infochapter @infosection @infosubsection @infosubsubsection + @infounnumbered @infounnumberedsec @infounnumberedsubsec + @infounnumberedsubsubsec + @input + @smallbreak @medbreak + @overfullrule + @br +* Deprecate these obsolete commands, to be removed in the next release: + @ctrl + @infoinclude + @iappendix @iappendixsection @iappendixsec @iappendixsubsec + @iappendixsubsubsec + @ichapter @isection @isubsection @isubsubsection + @iunnumbered @iunnumberedsec @iunnumberedsubsec @iunnumberedsubsubsec + @setchapterstyle + @titlespec + +3.7 (24 December 1995) +* Have --version print texinfo release number as well as the individual + program version. +* Better man page cleaning. +* Update Elisp files from current Emacs release. + +3.6 (21 June 1995) +* Unmatched brace error reporting improved. +* Missing comment terminator prevented compilation. + +3.5 (20 June 1995) +* Autoconf update. +* Support for parallel makes. +* make install does not install Elisp files. + +3.4 (19 June 1995) +* Handle @ifhtml in Elisp. +* Update FSF address. + +3.3 (15 June 1995) +* Portability changes. +* Compile Elisp files. +* Don't distribute .info* files. + +3.2 (9 June 1995) +* Standalone Info can read Unix man pages. +* New commands: @! @? @^ @" @enddots. +* makeinfo -E does macro expansion (and nothing else). + +3.1 (23 May 1993) +Just bug fixes, see ChangeLog for full details. + +texinfo-3.0: first release of Texinfo version 2, with many new commands. diff --git a/texinfo/README b/texinfo/README new file mode 100644 index 000000000000..357a98fb5554 --- /dev/null +++ b/texinfo/README @@ -0,0 +1,163 @@ +Texinfo, Version 3 +================== + +This is the README file for version 3 of the Texinfo distribution. +Files within this distribution have their own version and edition +numbers. When you refer to a file, please mention its own number, as +well as the version number of the Texinfo distribution. + +PLEASE REPORT BUGS TO: bug-texinfo@prep.ai.mit.edu + +Texinfo is a documentation system that uses a single source file to +produce both on-line information and printed output. This means that +instead of writing two different documents, one for the on-line help +or other on-line information and the other for a typeset manual or +other printed work, you need write only one document. When the work +is revised, you need revise only one document. You can read the +on-line information, known as an "Info file", with an Info +documentation-reading program. By convention, Texinfo source file +names end with a `.texi' or `.texinfo' extension. Texinfo is +described in the Texinfo manual (the file ./texinfo.texi). + +You can write and format Texinfo files into Info files within GNU Emacs, +and read them using the Emacs Info reader. If you do not have Emacs, +you can format Texinfo files into Info files using `makeinfo' and read +them using `info'. Use TeX, which is not included in this package (see +`How to Obtain TeX' in the Texinfo manual for information), to typeset +Texinfo files for printing. + +For instructions on compiling and installing info, makeinfo, texi2dvi, +and texindex, please read the file `INSTALL'. The Emacs Lisp files are +not installed by default; to install them, use `make install' in the +`emacs' subdirectory. The Info tree uses a file `dir' as its root node; +a sample `dir' file is included in the distribution, but not installed +anywhere. Use it or not as you like. + +This distribution includes (but is not limited to) the following files: + + README This file. + + INTRODUCTION This file tells you how to create + readable files from the Texinfo source + files in this distribution. + +Texinfo source files: + + texinfo.texi This manual describes Texinfo. It + tells how to use Texinfo to write + documentation, how to use Texinfo mode + in GNU Emacs, how to use TeX, + makeinfo, and the Emacs Lisp Texinfo + formatting commands. + + info.texi This manual tells you how to use + Info. This document comes as part of + GNU Emacs. If you do not have Emacs, + you can format this Texinfo source + file with makeinfo or TeX and then + read the resulting Info file with the + standalone Info reader that is part of + this distribution. + + info-stnd.texi This manual tells you how to use + the standalone GNU Info reader that is + included in this distribution as a C + source file, `info.c'. + + makeinfo.texi This manual tells you how to use + makeinfo. The same information is + contained in a chapter of the Texinfo + manual; it has been extracted here for + your convenience. + + +Printing related files: + + texinfo.tex This TeX definitions file tells + the TeX program how to typeset a + Texinfo file into a DVI file ready for + printing. + + texindex.c This file contains the source for + the `texindex' program that generates + sorted indices used by TeX when + typesetting a file for printing. + + texi2dvi This is a shell script for + producing an indexed DVI file using + TeX and texindex. Must be used if the + source document uses Texinfo @macros. + + +GNU Emacs related files: + + texinfmt.el This Emacs Lisp file provides the + functions that GNU Emacs uses to + format a Texinfo file into an Info + file. + + texinfo.el This file provides Texinfo mode + for GNU Emacs. + + texnfo-upd.el These files provides commands to + texnfo-tex.el help you write Texinfo files + makeinfo.el using GNU Emacs Texinfo mode. + + detexinfo.el This extra utility file contains functions + to remove Texinfo commands from a + Texinfo source file. + + info.el These are the standard GNU Emacs + informat.el Info reading and support files, + included here for your convenience. + + +Source files for standalone C programs: + + makeinfo.c This file contains the source for + the `makeinfo' program that you can + use to create an Info file from a + Texinfo file. + + info.c This file contains the source for + the `info' program that you can use to + view Info files on an ASCII terminal. + + getopt.c Various support files + getopt1.c + getopt.h + + +C Installation files: + + configure This file creates creates a Makefile + which in turn creates an `info' or + `makeinfo' executable, or a C sources + distribution. + + configure.in This is a template for creating + `configure' using m4 macros. + + Makefile.in This is a template for `configure' + to use to make a Makefile. + + +Other files: + + NEWS This contains a summary of new + features since the first edition + of Texinfo. + + info.1 This is a `man' page that briefly + describes the standalone `info' + program. + + fixfonts This is a shell script to install the + `lcircle10' TeX fonts as an alias for + the `circle10' fonts. In some older + TeX distributions the names are + different. + + tex3patch This handles a bug for version + 3.0 of TeX that does not occur in + more recent versions. diff --git a/texinfo/TODO b/texinfo/TODO new file mode 100644 index 000000000000..de5b571722f5 --- /dev/null +++ b/texinfo/TODO @@ -0,0 +1,35 @@ +If you are interested in working on any of these, +email bug-texinfo@prep.ai.mit.edu. + +* Use Automake. + +* Use a config header file instead of @DEFS@. + +* A detexinfo program, like detex or delatex. This command would + strip all the texinfo commands out, and would be used as a filter on + the way to a speller. An option would be to NOT strip comments out. + makeinfo --no-headers come close. + +* Change bars. This is difficult or impossible in TeX, + unfortunately. To do it right requires device driver support. + +* The dark corner symbol for the gawk manual. + +* Better i18n support, including support for 8-bit input + characters. Requires fonts, and the DC fonts are not (as of this + writing) free. + +* @exercise/@answer command for, e.g., gawk. + +* @figure. + +* HTML output in makeinfo. + +* Include a complete functional summary, a la a reference card, in the manual. + +* Use @ as the escape character, and Texinfo syntax generally, in the + table of contents, aux, and index files. Eliminate all the crazy + redefinitions of every Texinfo command (which lists always seem to be + incomplete). + +* Improve the manuals for makeinfo, standalone info, etc. diff --git a/texinfo/aclocal.m4 b/texinfo/aclocal.m4 new file mode 100644 index 000000000000..556a341489c4 --- /dev/null +++ b/texinfo/aclocal.m4 @@ -0,0 +1,45 @@ +dnl aclocal.m4 generated automatically by aclocal 1.2 + +# Check to see if we're running under Cygwin32, without using +# AC_CANONICAL_*. If so, set output variable CYGWIN32 to "yes". +# Otherwise set it to "no". + +dnl AM_CYGWIN32() +AC_DEFUN(AM_CYGWIN32, +[AC_CACHE_CHECK(for Cygwin32 environment, am_cv_cygwin32, +[AC_TRY_COMPILE(,[int main () { return __CYGWIN32__; }], +am_cv_cygwin32=yes, am_cv_cygwin32=no) +rm -f conftest*]) +CYGWIN32= +test "$am_cv_cygwin32" = yes && CYGWIN32=yes]) + +# Check to see if we're running under Win32, without using +# AC_CANONICAL_*. If so, set output variable EXEEXT to ".exe". +# Otherwise set it to "". + +dnl AM_EXEEXT() +dnl This knows we add .exe if we're building in the Cygwin32 +dnl environment. But if we're not, then it compiles a test program +dnl to see if there is a suffix for executables. +AC_DEFUN(AM_EXEEXT, +dnl AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AM_CYGWIN32]) +AC_MSG_CHECKING([for executable suffix]) +[AC_CACHE_VAL(am_cv_exeext, +[if test "$CYGWIN32" = yes; then +am_cv_exeext=.exe +else +cat > am_c_test.c << 'EOF' +int main() { +/* Nothing needed here */ +} +EOF +${CC-cc} -o am_c_test $CFLAGS $CPPFLAGS $LDFLAGS am_c_test.c $LIBS 1>&5 +am_cv_exeext=`ls am_c_test.* | grep -v am_c_test.c | sed -e s/am_c_test//` +rm -f am_c_test*]) +test x"${am_cv_exeext}" = x && am_cv_exeext=no +fi +EXEEXT="" +test x"${am_cv_exeext}" != xno && EXEEXT=${am_cv_exeext} +AC_MSG_RESULT(${am_cv_exeext}) +AC_SUBST(EXEEXT)]) + diff --git a/texinfo/configure b/texinfo/configure new file mode 100755 index 000000000000..f6ecd8226671 --- /dev/null +++ b/texinfo/configure @@ -0,0 +1,2025 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.12 +# 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: + +# 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= +# 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.12" + 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=texinfo.texi + +# 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 $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +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 $srcdir $srcdir/.. $srcdir/../..; 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 $srcdir $srcdir/.. $srcdir/../.." 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. + +# 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 +# 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:553: 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="${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. + for ac_prog in ginstall installbsd 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. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + 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_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +# 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:605: 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="${IFS}:" + for ac_dir in $PATH; 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 + + +# 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:635: 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="${IFS}:" + for ac_dir in $PATH; 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:664: 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="${IFS}:" + ac_prog_rejected=no + for ac_dir in $PATH; 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 + + 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:712: 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 $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; 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* + +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:746: 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:751: 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 <&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 + 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:775: 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 + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + +echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 +echo "configure:803: 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 how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:824: 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 < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:845: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +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 < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:862: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +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* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 +echo "configure:886: checking for minix/config.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 +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:896: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +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 + MINIX=yes +else + echo "$ac_t""no" 1>&6 +MINIX= +fi + +if test "$MINIX" = yes; then + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX_1_SOURCE 2 +EOF + + cat >> confdefs.h <<\EOF +#define _MINIX 1 +EOF + +fi + + +echo $ac_n "checking for Cygwin32 environment""... $ac_c" 1>&6 +echo "configure:935: checking for Cygwin32 environment" >&5 +if eval "test \"`echo '$''{'am_cv_cygwin32'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + am_cv_cygwin32=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + am_cv_cygwin32=no +fi +rm -f conftest* +rm -f conftest* +fi + +echo "$ac_t""$am_cv_cygwin32" 1>&6 +CYGWIN32= +test "$am_cv_cygwin32" = yes && CYGWIN32=yes +echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 +echo "configure:964: checking for executable suffix" >&5 +if eval "test \"`echo '$''{'am_cv_exeext'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$CYGWIN32" = yes; then +am_cv_exeext=.exe +else +cat > am_c_test.c << 'EOF' +int main() { +/* Nothing needed here */ +} +EOF +${CC-cc} -o am_c_test $CFLAGS $CPPFLAGS $LDFLAGS am_c_test.c $LIBS 1>&5 +am_cv_exeext=`ls am_c_test.* | grep -v am_c_test.c | sed -e s/am_c_test//` +rm -f am_c_test* +fi + +test x"${am_cv_exeext}" = x && am_cv_exeext=no +fi +EXEEXT="" +test x"${am_cv_exeext}" != xno && EXEEXT=${am_cv_exeext} +echo "$ac_t""${am_cv_exeext}" 1>&6 + + +# Needed on sysV68 for sigblock, sigsetmask. +echo $ac_n "checking for sigblock in -lbsd""... $ac_c" 1>&6 +echo "configure:990: checking for sigblock in -lbsd" >&5 +ac_lib_var=`echo bsd'_'sigblock | 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="-lbsd $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; 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 bsd | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + + +TERMLIBS= +for termlib in curses ncurses termcap terminfo termlib ; do + echo $ac_n "checking for tputs in -l${termlib}""... $ac_c" 1>&6 +echo "configure:1040: checking for tputs in -l${termlib}" >&5 +ac_lib_var=`echo ${termlib}'_'tputs | 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="-l${termlib} $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; 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 + TERMLIBS="${TERMLIBS} -l${termlib}"; break +else + echo "$ac_t""no" 1>&6 +fi + +done + + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1083: 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 < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1096: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +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 +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 +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 < +#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:1163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./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 unistd.h termios.h termio.h strings.h string.h varargs.h \ + sys/time.h sys/fcntl.h sys/ttold.h sys/ptem.h sys/file.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1191: 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 +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1201: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +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 <&6 +fi +done + + +echo $ac_n "checking for off_t""... $ac_c" 1>&6 +echo "configure:1229: 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 < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "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 working const""... $ac_c" 1>&6 +echo "configure:1262: 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 <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1316: \"$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 whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 +echo "configure:1337: checking whether struct tm is in sys/time.h or time.h" >&5 +if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +int main() { +struct tm *tp; tp->tm_sec; +; return 0; } +EOF +if { (eval echo configure:1350: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_struct_tm=time.h +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_struct_tm=sys/time.h +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_struct_tm" 1>&6 +if test $ac_cv_struct_tm = sys/time.h; then + cat >> confdefs.h <<\EOF +#define TM_IN_SYS_TIME 1 +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:1374: 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 < +int main() { +char *p = alloca(2 * sizeof(int)); +; return 0; } +EOF +if { (eval echo configure:1386: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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:1407: 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 < +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +#endif + +int main() { +char *p = (char *) alloca(1); +; return 0; } +EOF +if { (eval echo configure:1435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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.o + cat >> confdefs.h <<\EOF +#define C_ALLOCA 1 +EOF + + +echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 +echo "configure:1467: 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 <&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:1497: 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 < +/* 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:1525: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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 <&6 +fi + +done +fi + +echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 +echo "configure:1552: 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 < addr) ? 1 : -1; +} +main () +{ + exit (find_stack_direction() < 0); +} +EOF +if { (eval echo configure:1579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./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 <&6 +echo "configure:1602: checking whether setvbuf arguments are reversed" >&5 +if eval "test \"`echo '$''{'ac_cv_func_setvbuf_reversed'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +/* If setvbuf has the reversed format, exit 0. */ +main () { + /* This call has the arguments reversed. + A reversed system may check and see that the address of main + is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ + if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0) + exit(1); + putc('\r', stdout); + exit(0); /* Non-reversed systems segv here. */ +} +EOF +if { (eval echo configure:1624: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_func_setvbuf_reversed=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_setvbuf_reversed=no +fi +rm -fr conftest* +fi + +rm -f core core.* *.core +fi + +echo "$ac_t""$ac_cv_func_setvbuf_reversed" 1>&6 +if test $ac_cv_func_setvbuf_reversed = yes; then + cat >> confdefs.h <<\EOF +#define SETVBUF_REVERSED 1 +EOF + +fi + +fi +for ac_func in setvbuf getcwd memset bzero strchr strcasecmp \ + vfprintf vsprintf strerror sigprocmask sigsetmask +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1652: 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 < +/* 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:1680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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 <&6 +fi +done + +for ac_func in memcpy memmove strdup +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1707: 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 < +/* 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:1735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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 <&6 +LIBOBJS="$LIBOBJS ${ac_func}.o" +fi +done + + + +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) 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 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# 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 </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.12" + 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 libtxi/Makefile makeinfo/Makefile info/Makefile util/Makefile emacs/Makefile " | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%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%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@RANLIB@%$RANLIB%g +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@EXEEXT@%$EXEEXT%g +s%@TERMLIBS@%$TERMLIBS%g +s%@ALLOCA@%$ALLOCA%g +s%@LIBOBJS@%$LIBOBJS%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 <> $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" ;; + ?:*) 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* + +EOF +cat >> $CONFIG_STATUS <> $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 + diff --git a/texinfo/configure.in b/texinfo/configure.in new file mode 100644 index 000000000000..321923d47531 --- /dev/null +++ b/texinfo/configure.in @@ -0,0 +1,48 @@ +dnl Process this file with autoconf to produce a configure script. +dnl $Id: configure.in,v 1.3 1996/10/03 18:33:52 karl Exp $ +AC_PREREQ(2.5) +AC_INIT(texinfo.texi) + +dnl Checks for programs. +dnl AC_PROG_GCC_TRADITIONAL +AC_PROG_INSTALL +AC_PROG_RANLIB + +AC_ISC_POSIX +AC_MINIX + +AM_CYGWIN32 +AM_EXEEXT + +dnl Checks for libraries. +# Needed on sysV68 for sigblock, sigsetmask. +AC_CHECK_LIB(bsd, sigblock) + +TERMLIBS= +for termlib in curses ncurses termcap terminfo termlib ; do + AC_CHECK_LIB(${termlib}, tputs, + [TERMLIBS="${TERMLIBS} -l${termlib}"; break]) +done +AC_SUBST(TERMLIBS) + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(unistd.h termios.h termio.h strings.h string.h varargs.h \ + sys/time.h sys/fcntl.h sys/ttold.h sys/ptem.h sys/file.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_TYPE_OFF_T +AC_C_CONST +AC_STRUCT_TM + +dnl Checks for library functions. +AC_FUNC_ALLOCA +if test "$ac_cv_c_cross" = no; then + AC_FUNC_SETVBUF_REVERSED +fi +AC_CHECK_FUNCS(setvbuf getcwd memset bzero strchr strcasecmp \ + vfprintf vsprintf strerror sigprocmask sigsetmask) +dnl strcasecmp, strerror, xmalloc, xrealloc, probably others should be added. +AC_REPLACE_FUNCS(memcpy memmove strdup) + +AC_OUTPUT(Makefile libtxi/Makefile makeinfo/Makefile info/Makefile util/Makefile emacs/Makefile diff --git a/texinfo/dir b/texinfo/dir new file mode 100644 index 000000000000..8f7e01d78670 --- /dev/null +++ b/texinfo/dir @@ -0,0 +1,16 @@ +$Id: dir,v 1.1 1997/08/21 22:57:52 jason Exp $ +This is the file .../info/dir, which contains the topmost node of the +Info hierarchy. The first time you invoke Info you start off +looking at that node, which is (dir)Top. + +File: dir Node: Top This is the top of the INFO tree + + This (the Directory node) gives a menu of major topics. + Typing "q" exits, "?" lists all Info commands, "d" returns here, + "h" gives a primer for first-timers, + "mEmacs" visits the Emacs topic, etc. + + In Emacs, you can click mouse button 2 on a menu item or cross reference + to select it. + +* Menu: diff --git a/texinfo/dir-example b/texinfo/dir-example new file mode 100644 index 000000000000..3b9bd72e3d7b --- /dev/null +++ b/texinfo/dir-example @@ -0,0 +1,309 @@ +This is the directory file `dir' a.k.a. `DIR', which contains the +topmost node of the Info hierarchy. This file is merely made available +for your hacking pleasure, not official or standard in any way. +If it doesn't make sense to you, or you don't like it, ignore it. + +$Id: dir-example,v 1.1 1997/08/21 22:57:52 jason Exp $ + +File: dir Node: Top This is the top of the INFO tree. + +This node gives a menu of the major topics accessible through Info. + + `q' quits; + `?' lists all Info commands; + `h' starts the Info tutorial; + `mTexinfo RET' visits the Texinfo manual, etc. + +* Menu: + +GNU packages +* Bash: (bash). Bourne again shell. +* Cpio: (cpio). Cpio archiver. +* DC: (dc). Postfix arbitrary expression calculator. +* Diff: (diff). Comparing and merging programs. +* Ed: (ed). Line editor. +* Emacs: (emacs). Extensible self-documenting text editor. +* File utilities: (fileutils). GNU file utilities. +* Finding files: (find). Operating on files matching certain criteria. +* Font utilities: (fontu). Programs for font manipulation. +* Gawk: (gawk). A text processing and scanning language. +* Gzip: (gzip). General (de)compression. +* Identifier DB: (id-utils). Identifier database utilities. +* Ispell: (ispell). Interactive spelling corrector. +* M4: (m4). Macro processor. +* Make: (make). Remake files automatically. +* Ptx: (ptx). Permuted index generator. +* Shar: (sharutils). Shell archiver, uudecode/uuencode. +* Shell utilities: (sh-utils). GNU shell utilities. +* Tar: (tar). ``Tape'' archiver. +* Text utilities: (textutils). GNU text utilities. +* Time: (time). Measuring program resource usage. +* UUCP: (uucp). Copying between machines, offline. +* Wdiff: (wdiff). Word-by-word comparison. + +GNU programming tools +* As: (as). Assembler. +* Binutils: (binutils). ar/copy/objdump/nm/size/strip/ranlib. +* Bison: (bison). LALR(1) parser generator. +* CPP: (cpp). C preprocessor. +* CVS: (cvs). Concurrent versions system for source control. +* DejaGnu: (dejagnu). Testing framework. +* Flex: (flex). A fast scanner generator. +* Gasp: (gasp). GNU Assembler preprocessor. +* Libtool: (libtool). Generic library support script. +* GCC: (gcc). C compiler. +* GDB: (gdb). Source-level debugger for C and C++. +* Gperf: (gperf). Perfect hash function generator. +* Gprof: (gprof). Profiler. +* Indent: (indent). Prettyprinter for programs. +* Ld: (ld). Linker. + +Texinfo documentation system +* Info: (info). Documentation browsing system. +* Texinfo: (texinfo). The GNU documentation format. +* install-info: (texinfo)Invoking install-info. Updating info/dir entries. +* texi2dvi: (texinfo)Format with texi2dvi. Printing Texinfo documentation. +* texindex: (texinfo)Format with tex/texindex. Sorting Texinfo index files. +* info program: (info-stnd). Standalone Info-reading program. +* makeinfo: (makeinfo). Convert Texinfo source to Info or plain ASCII. + +GNU Emacs Lisp +* Elisp: (elisp). GNU Emacs Lisp reference manual. +* Intro Elisp: (emacs-lisp-intro). Introduction to Elisp programming. + +* Calc: (calc). Calculator and more. +* CC-mode: (ccmode). Editing C, C++, and Objective C. +* Common Lisp: (cl). Partial Common Lisp support for Emacs Lisp. +* Dired-x: (dired-x). Extra directory editor features. +* Edebug: (edebug). Source-level debugger for Emacs Lisp. +* Ediff: (ediff). Comprehensive visual interface to diff & patch. +* EDB: (edb). Database for Emacs. +* Forms: (forms). Fill-in-the-form data entry. +* Gmhist: (gmhist). Generic minibuffer history. +* GNUS: (gnus). Netnews reading and posting. +* Mailcrypt: (mailcrypt). Use PGP in Emacs. +* MH-E: (mh-e). Emacs interface to the MH mail system. +* PCL-CVS: (pcl-cvs). Emacs front end to CVS. +* Supercite: (sc). Supercite for including other people's words. +* VIP: (vip). vi emulation. +* VIPER: (viper). The new VI-emulation mode in Emacs-19.29. +* VM: (vm). Mail reader. +* W3: (w3). WWW browser. + +GNU admin +* Autoconf: (autoconf). Automatic generation of package configuration. +* Automake: (automake). Making Makefile.in's. +* Configure: (configure). Cygnus configure. +* Gettext: (gettext). Internationalization. +* Gnats: (gnats). Cygnus bug tracking system. +* Maintaining: (maintain). Maintaining GNU software. +* Remsync: (remsync). Remote synchronization of directory trees. +* Send PR: (send-pr). Cygnus bug reporting for Gnats. +* Source config: (cfg-paper). Some theory on configuring source packages. +* Standards: (standards). GNU coding standards. + +GNU libraries +* Annotate: (annotate). High-level GDB to GUI's. +* BFD: (bfd). Binary file descriptors for object file IO. +* GDB library: (libgdb). Application programming interface to GDB. +* GDBM: (gdbm). Hashed databases. +* History: (history). Recall previous lines of input. +* Iostream: (iostream). C++ input/output. +* Libc: (libc). C library. +* Libg++: (libg++). C++ classes. +* Mmalloc: (mmalloc). Memory-mapped malloc. +* Readline: (readline). General command-line interface. +* Regex: (regex). Regular expressions. +* Termcap: (termcap). All about /etc/termcap. + +GNU programming documentation +* GDB internals: (gdbint). Debugger internals. +* Ld internals: (ldint). GNU linker internals. +* Stabs: (stabs). Symbol table debugging information format. + +DOS +* Demacs: (demacs). GNU Emacs for DOS. +* GNUish: (gnuish). GNU utilities for DOS. + +TeX things +* Afm2tfm: (dvips)Invoking afm2tfm. Making Type 1 fonts available to TeX. +* Dvips: (dvips). DVI-to-PostScript translator. +* Eplain: (eplain). Expanding on plain TeX. +* Kpathsearch: (kpathsea). File lookup along search paths. +* LaTeX: (latex). LaTeX. +* MakeIndex: (makeindex). Index creation for TeX. +* Naming fonts: (fontname). Filenames for TeX fonts. +* TeXDraw: (texdraw). Drawing PostScript diagrams within TeX. +* Web2c: (web2c). TeX, Metafont, and their companion programs. + +Other things +* Amd: (amdref). Filesystem automounter. +* CMUCL: (cmu-user). CMU Common Lisp. +* File headers: (filehdr). Bibliographic information for computer files. +* HTML: (snafu). Hypertext Markup Language 2.0 specification. +* Jargon: (jargon). The jargon file. +* Perl: (perl). Practical extraction and report language. +* PRCS: (prcs). Project revision control system. +* Screen: (screen). Virtual screen manager. +* UMB C.S. Dept.: (csinfo). UMass/Boston Computer Science Dept. info. + +Individual utilities +* aid: (id-utils)aid invocation. Matching strings. +* ar: (binutils)ar. Create/modify/extract archives. +* at-pr: (gnats)at-pr. Bug report timely reminders. +* autoreconf: (autoconf)Invoking autoreconf. Remake multiple configure's. +* autoscan: (autoconf)Invoking autoscan. Automate initial configure.in. +* awk: (Gawk)Invoking gawk. Text processing and scanning. +* basename: (sh-utils)basename invocation. Strip directory and suffix. +* bibtex: (web2c)BibTeX invocation. Maintaining bibliographies. +* c++filt: (binutils)c++filt. Demangle C++ symbols. +* cat: (textutils)cat invocation. Concatenate and write files. +* chgrp: (fileutils)chgrp invocation. Change file groups. +* chmod: (fileutils)chmod invocation. Change file permissions. +* chown: (fileutils)chown invocation. Change file owners/groups. +* chroot: (sh-utils)chroot invocation. Specify the root directory. +* cksum: (textutils)cksum invocation. Print POSIX CRC checksum. +* cmp: (diff)Invoking cmp. Character-by-character diff. +* comm: (textutils)comm invocation. Compare sorted files by line. +* cp: (fileutils)cp invocation. Copy files. +* csplit: (textutils)csplit invocation. Split by context. +* cut: (textutils)cut invocation. Print selected parts of lines. +* date: (sh-utils)date invocation. Print/set system date and time. +* dd: (fileutils)dd invocation. Copy and convert a file. +* df: (fileutils)df invocation. Report filesystems' disk usage. +* diff3: (diff)Invoking diff3. Three-way diff. +* dir: (fileutils)dir invocation. List directories briefly. +* dirname: (sh-utils)dirname invocation. Strip non-directory suffix. +* dmp: (web2c)Dmp invocation. Troff->MPX (MetaPost pictures). +* du: (fileutils)du invocation. Report on disk usage. +* dvicopy: (web2c)DVIcopy invocation. Virtual font expansion +* dvitomp: (web2c)DVItoMP invocation. DVI to MPX (MetaPost pictures). +* dvitype: (web2c)DVItype invocation. DVI to human-readable text. +* echo: (sh-utils)echo invocation. Print a line of text. +* edit-pr: (gnats)Invoking edit-pr. Changing bugs. +* eid: (id-utils)eid invocation. Invoking an editor on matches. +* emacsclient: (emacs)Emacs Server. Connecting to a running Emacs. +* emacsserver: (emacs)Emacs Server. Connecting to a running Emacs. +* env: (sh-utils)env invocation. Modify the environment. +* etags: (emacs)Create Tags Table. Creating a TAGS table. +* expand: (textutils)expand invocation. Convert tabs to spaces. +* expr: (sh-utils)expr invocation. Evaluate expressions. +* false: (sh-utils)false invocation. Do nothing, unsuccessfully. +* fid: (id-utils)fid invocation. Listing a file's identifiers. +* file-pr: (gnats)file-pr. Processing incoming traffic. +* find: (find)Invoking find. Finding and acting on files. +* fmt: (textutils)fmt invocation. Reformat paragraph text. +* fold: (textutils)fold invocation. Wrap long input lines. +* g++: (gcc)Invoking G++. The GNU C++ compiler. +* gftodvi: (web2c)GFtoDVI invocation. Generic font proofsheets. +* gftopk: (web2c)GFtoPK invocation. Generic to packed fonts. +* gftype: (web2c)GFtype invocation. GF to human-readable text. +* gid: (id-utils)gid invocation. Listing all matching lines. +* groups: (sh-utils)groups invocation. Print group names a user is in. +* gunzip: (gzip)Overview. Decompression. +* head: (textutils)head invocation. Output the first part of files. +* hostname: (sh-utils)hostname invocation. Print or set system name. +* id: (sh-utils)id invocation. Print real/effective uid/gid. +* idx: (id-utils)idx invocation. Testing mkid scanners. +* ifnames: (autoconf)Invoking ifnames. List conditionals in source. +* iid: (id-utils)iid invocation. Interactive complex queries. +* inimf: (web2c)inimf invocation. Initial Metafont. +* inimp: (web2c)inimp invocation. Initial MetaPost. +* initex: (web2c)initex invocation. Initial TeX. +* install: (fileutils)install invocation. Copy and change attributes. +* join: (textutils)join invocation. Join lines on a common field. +* kpsewhich: (kpathsea)Invoking kpsewhich. TeX file searching. +* lid: (id-utils)lid invocation. Matching identifier patterns. +* ln: (fileutils)ln invocation. Make links between files. +* locate: (find)Invoking locate. Finding files in a database. +* logname: (sh-utils)logname invocation. Print current login name. +* ls: (fileutils)ls invocation. List directory contents. +* makempx: (web2c)MakeMPX invocation. MetaPost label typesetting. +* maketexmf: (kpathsea)MakeTeX scripts. MF source generation. +* maketexpk: (kpathsea)MakeTeX scripts. PK bitmap generation. +* maketextex: (kpathsea)MakeTeX scripts. TeX source generation. +* maketextfm: (kpathsea)MakeTeX scripts. TeX font metric generation. +* mf: (web2c)mf invocation. Creating typeface families. +* mft: (web2c)MFT invocation. Prettyprinting Metafont source. +* mkdir: (fileutils)mkdir invocation. Create directories. +* mkfifo: (fileutils)mkfifo invocation. Create FIFOs: (named pipes). +* mkid: (id-utils)mkid invocation. Creating an ID database. +* mknod: (fileutils)mknod invocation. Create special files. +* mp: (web2c)mp invocation. Creating technical diagrams. +* mpto: (web2c)MPto invocation. MetaPost label extraction. +* mv: (fileutils)mv invocation. Rename files. +* newer: (web2c)Newer invocation. Compare modification times. +* nice: (sh-utils)nice invocation. Modify scheduling priority. +* nl: (textutils)nl invocation. Number lines and write files. +* nlmconv: (binutils)nlmconv. Convert object to NetWare LM. +* nm: (binutils)nm. List symbols in object files. +* nohup: (sh-utils)nohup invocation. Immunize to hangups. +* objcopy: (binutils)objcopy. Copy/translate object files. +* objdump: (binutils)objdump. Display info from object files. +* od: (textutils)od invocation. Dump files in octal, etc. +* paste: (textutils)paste invocation. Merge lines of files. +* patch: (diff)Invoking patch. Automatically applying diffs. +* patgen: (web2c)Patgen invocation. Creating hyphenation patterns. +* pathchk: (sh-utils)pathchk invocation. Check file name portability. +* pid: (id-utils)pid invocation. Looking up filenames. +* pktogf: (web2c)PKtoGF invocation. Packed to generic fonts. +* pktype: (web2c)PKtype invocation. PK to human-readable text. +* pltotf: (web2c)PLtoTF invocation. Property list to TFM. +* pooltype: (web2c)Pooltype invocation. Display WEB pool files. +* pr-addr: (gnats)pr-addr. Bug report address retrieval. +* pr-edit: (gnats)pr-edit. The edit-pr driver. +* pr: (textutils)pr invocation. Paginate or columnate files. +* printenv: (sh-utils)printenv invocation. Print environment variables. +* printf: (sh-utils)printf invocation. Format and print data. +* pwd: (sh-utils)pwd invocation. Print working directory. +* query-pr: (gnats)Invoking query-pr. Bug searching/reporting. +* queue-pr: (gnats)queue-pr. Handling incoming traffic. +* ranlib: (binutils)ranlib. Index archive file contents. +* rm: (fileutils)rm invocation. Remove files. +* rmdir: (fileutils)rmdir invocation. Remove empty directories. +* sdiff: (diff)Invoking sdiff. Interactively merge files. +* send-pr: (gnats)Invoking send-pr. Submitting bugs. +* shar: (sharutils)shar invocation. Create shell archive. +* size: (binutils)size. List object file section sizes. +* sleep: (sh-utils)sleep invocation. Delay for a specified time. +* sort: (textutils)sort invocation. Sort text files. +* split: (textutils)split invocation. Split into fixed-size pieces. +* strings: (binutils)strings. List printable strings. +* strip: (binutils)strip. Discard symbols. +* stty: (sh-utils)stty invocation. Print/change terminal settings. +* su: (sh-utils)su invocation. Modify user and group id. +* sum: (textutils)sum invocation. Print traditional checksum. +* sync: (fileutils)sync invocation. Synchronize memory and disk. +* tabs: (tput)Invoking tabs. Tab settings. +* tac: (textutils)tac invocation. Reverse files. +* tail: (textutils)tail invocation. Output the last part of files. +* tangle: (web2c)Tangle invocation. WEB to Pascal. +* tee: (sh-utils)tee invocation. Redirect to multiple files. +* test: (sh-utils)test invocation. File/string tests. +* tex: (web2c)tex invocation. Typesetting. +* tftopl: (web2c)TFtoPL invocation. TFM -> property list. +* touch: (fileutils)touch invocation. Change file timestamps. +* tput: (tput)Invoking tput. Termcap in shell scripts. +* tr: (textutils)tr invocation. Translate characters. +* true: (sh-utils)true invocation. Do nothing, successfully. +* tty: (sh-utils)tty invocation. Print terminal name. +* uname: (sh-utils)uname invocation. Print system information. +* unexpand: (textutils)unexpand invocation. Convert spaces to tabs. +* uniq: (textutils)uniq invocation. Uniqify files. +* unshar: (sharutils)unshar invocation. Extract from shell archive. +* updatedb: (find)Invoking updatedb. Building the locate database. +* users: (sh-utils)users invocation. Print current user names. +* vdir: (fileutils)vdir invocation. List directories verbosely. +* vftovp: (web2c)VFtoVP invocation. Virtual font -> virtual pl. +* view-pr: (gnats)Invoking view-pr. Showing bug reports. +* virmf: (web2c)virmf invocation. Virgin Metafont. +* virmp: (web2c)virmp invocation. Virgin MetaPost. +* virtex: (web2c)virtex invocation. Virgin TeX. +* vptovf: (web2c)VPtoVF invocation. Virtual pl -> virtual font. +* wc: (textutils)wc invocation. Byte, word, and line counts. +* weave: (web2c)Weave invocation. WEB to TeX. +* who: (sh-utils)who invocation. Print who is logged in. +* whoami: (sh-utils)whoami invocation. Print effective user id. +* xargs: (find)Invoking xargs. Operating on many files. +* yes: (sh-utils)yes invocation. Print a string indefinitely. +* zcat: (gzip)Overview. Decompression to stdout. diff --git a/texinfo/dir.info-template b/texinfo/dir.info-template new file mode 100644 index 000000000000..5f3df62a2c10 --- /dev/null +++ b/texinfo/dir.info-template @@ -0,0 +1,67 @@ +info +-- +intro +send-pr +README +COPYING +COPYING.LIB +-- +gcc +g++ +reno-1 +cpp +-- +gdb +gdbint +stabs +-- +binutils +ld +as +-- +dejagnu +-- +make +flex +bison +byacc +gperf +gprof +-- +libc +libg++ +iostream +libm +-- +bfd +readline +libiberty +regex +termcap +-- +emacs +elisp +ange-ftp +calc +calendar +cl +forms +gnus +vip +vm +-- +ispell +diff +patch +wdiff +m4 +-- +texinfo +makeinfo +-- +autoconf +configure +cfg-paper +-- +standards + diff --git a/texinfo/emacs/Makefile.in b/texinfo/emacs/Makefile.in new file mode 100644 index 000000000000..5f19d1abea99 --- /dev/null +++ b/texinfo/emacs/Makefile.in @@ -0,0 +1,91 @@ +# Makefile for Texinfo/emacs. +# Copyright (C) 1995, 96 Free Software Foundation, Inc. +# $Id: Makefile.in,v 1.1 1997/08/21 22:57:56 jason Exp $ + +# 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. +# +# Author: Brian J. Fox (bfox@ai.mit.edu) +# + +srcdir = @srcdir@ +VPATH = @srcdir@ +SHELL = /bin/sh +RM = rm -f + + +ELISP_SRCS = info.el makeinfo.el texinfo.el texnfo-upd.el \ + texnfo-tex.el texinfmt.el informat.el detexinfo.el +ELISP_OBJS = info.elc makeinfo.elc texinfo.elc texnfo-upd.elc \ + texnfo-tex.elc texinfmt.elc informat.elc detexinfo.elc + +.SUFFIXES: .el .elc + +.el.elc: + $(srcdir)/elisp-comp $< + +all: +sub-all: all + +dvi: +install-info: + +elisp: $(ELISP_OBJS) +.PHONY: elisp + +# Nobody likes any of these install targets. Fine. Install it +# manually, then. +install: + @echo Please install the Emacs Lisp files manually. + +uninstall: + @echo Please uninstall the Emacs Lisp files manually. + +# install: $(ELISP_OBJS) +# @(echo "(print (car load-path))" >/tmp/elc.$$$$; \ +# lispdir=`emacs -batch -q -l /tmp/elc.$$$$ -nw | grep site-lisp`; \ +# rm /tmp/elc.$$$$; \ +# if [ "$$lispdir" != "" ]; then \ +# lispdir=`echo $$lispdir | sed -e 's/"//g'`; \ +# echo "Installing .elc files in $$lispdir."; \ +# $(CP) $(ELISP_OBJS) $$lispdir; \ +# else \ +# echo "To install the elisp files, please copy *.elc to the"; \ +# echo "emacs site-lisp directory."; \ +# fi) +# +# install: $(ELISP_OBJS) +# for file in $(ELISP_OBJS); do \ +# $(INSTALL_DATA) $$file $(lispdir); \ +# done +# +# uninstall: $(ELISP_OBJS) +# cd $(lispdir) && rm -f $(ELISP_OBJS) +# +informat.elc: info.elc +makeinfo.elc: texinfo.elc +texinfmt.elc: texinfo.elc +texinfmt.elc: texnfo-upd.elc + +Makefile: $(srcdir)/Makefile.in ../config.status + cd .. && sh config.status + +realclean distclean: clean + $(RM) Makefile *.log + +clean: FORCE + $(RM) *.elc + +FORCE: + diff --git a/texinfo/emacs/detexinfo.el b/texinfo/emacs/detexinfo.el new file mode 100644 index 000000000000..fda99091c49a --- /dev/null +++ b/texinfo/emacs/detexinfo.el @@ -0,0 +1,250 @@ +;;; Here is a handy keybinding: + +(global-set-key "\C-x\\" 'detexinfo) + +;;;;;;;;;;;;;;;; detexinfo.el ;;;;;;;;;;;;;;;; +;;; +;;; Remove Texinfo commands from a Texinfo source file. +;;; +;;; Copyright (C) 1991, 1992 Free Software Foundation +;;; Robert J. Chassell +;;; bugs to bug-texinfo@prep.ai.mit.edu +;;; +;;; ==> test version <== +;;; Fails if Texinfo source file contains formatting errors. +;;; +;;; Version 0.05 - 3 Jun 1992 +;;; Add to list of removed commands. Improve messages. +;;; +;;; Version 0.04 - 27 Jan 1992 +;;; Rewrite to insert detexinfo'd text into a temporary buffer. +;;; +;;; Version 0.03 - 27 Dec 1991 +;;; Improved messages. +;;; +;;; Version 0.02 - 13 Nov 1991 +;;; detexinfo-remove-inline-cmd, detexinfo-syntax-table: Handle +;;; nested commands. +;;; detexinfo: Handle nested @'s, eg @samp{@}} and @samp{@@}; +;;; replace @TeX{} with TeX. +;;; +;;; Version 0.01 - 13 Nov 1991 +;;; +;;; Based on detex.el, by Bengt Martensson, 4 Oct 1987 +;;; +;;;;;;;;;;;;;;;; + +(defvar detexinfo-buffer-name "*detexinfo*" + "*Name of the temporary buffer used by \\[detexinfo].") + +(defvar detexinfo-syntax-table nil) + +(if detexinfo-syntax-table + nil + (setq detexinfo-syntax-table (make-syntax-table)) + (modify-syntax-entry ?\[ "." detexinfo-syntax-table) + (modify-syntax-entry ?\] "." detexinfo-syntax-table) + (modify-syntax-entry ?\" "." detexinfo-syntax-table) + (modify-syntax-entry ?\\ "." detexinfo-syntax-table) + (modify-syntax-entry ?\( "." detexinfo-syntax-table) + (modify-syntax-entry ?\) "." detexinfo-syntax-table) + (modify-syntax-entry ?{ "(}" detexinfo-syntax-table) + (modify-syntax-entry ?} "){" detexinfo-syntax-table)) + +(defun detexinfo () + "Remove Texinfo commands from current buffer, copying result to new buffer. +BUG: Fails if Texinfo source file contains formatting errors." + (interactive) + (let ((input-buffer (current-buffer))) + ;; Find a buffer to use. + (switch-to-buffer (get-buffer-create detexinfo-buffer-name)) + (setq major-mode 'detexinfo-mode) + (set-syntax-table detexinfo-syntax-table) + (erase-buffer) + (insert-buffer-substring input-buffer) + + ;; Replace @{ and @} with %#* and *#% temporarily, so @samp{@{} works. + ;; What is a better way of doing this?? + (goto-char (point-min)) + (while (search-forward "@{" nil t) ; e.g., @samp{@{} + (replace-match "%#*")) + (goto-char (point-min)) + (while (search-forward "@}" nil t) + (forward-char -3) ; e.g., @samp{@@} + (if (looking-at "@") ; Two @@ in a row + (progn + (delete-char 2) + (insert "%&%#")) + (forward-char 1) + (delete-char 2) + (insert "*#%"))) + + (goto-char (point-min)) + ;; Remove @refill, the only inline command without braces. + (while (search-forward "@refill" nil t) + (replace-match "")) + ;; Replace @TeX{} with TeX + (goto-char (point-min)) + (while (search-forward "@TeX{}" nil t) (replace-match "TeX" t t)) + + (detexinfo-remove-line-cmds-without-arg) + (detexinfo-remove-inline-cmds-without-arg) + (detexinfo-remove-inline-cmds-keep-arg) + (detexinfo-remove-line-cmds-deletable-arg) + (detexinfo-remove-line-cmds-maybe-delete-arg) + (detexinfo-remove-line-cmds-keep-arg) + + ;; Now replace %#*, *#%, and %&%# with {, }, and @@. + (goto-char (point-min)) + (while (search-forward "%#*" nil t) + (replace-match "{")) + (goto-char (point-min)) + (while (search-forward "*#%" nil t) + (replace-match "}")) + (goto-char (point-min)) + (while (search-forward "%&%#" nil t) + (replace-match "@@")) + + ;; Scan for remaining two character @-commands + (goto-char (point-min)) + (while (search-forward "@" nil t) + (cond ((looking-at "[*:]") + (delete-region (1- (point)) (1+ (point)))) + ((looking-at "[{}^@.'`]\"?!") + (delete-region (1- (point)) (point))))) + + (goto-char (point-min)) + (message "Done...removed Texinfo commands from buffer. You may save it."))) + +(defun detexinfo-remove-whole-line (cmd) + "Delete Texinfo line command CMD at beginning of line and rest of line." + (goto-char (point-min)) + (while + (re-search-forward + (concat "^@" cmd "[ \n]+") (point-max) t) + (goto-char (match-beginning 0)) + (delete-region + (point) (save-excursion (end-of-line) (1+ (point)))))) + +(defun detexinfo-remove-inline-cmd (cmd) + "Delete Texinfo inline command CMD, eg. @point, @code." + (goto-char (point-min)) + (while + (re-search-forward (concat "@" cmd "{") (point-max) t) + (save-excursion + (forward-char -1) + (forward-sexp 1) + (delete-char -1)) ; delete right brace + (delete-region (point) (match-beginning 0)))) + +;;;;;;;;;;;;;;;; + +;;; 1. @setfilename and other line commands with args to delete + +(defvar detexinfo-line-cmds-deletable-arg + '("enumerate" "ftable" "vtable" "itemize" "table" + "setfilename" "settitle" "setchapternewpage" + "footnotestyle" "paragraphindent" + "include" "need" "sp" + "clear" "ifclear" "ifset" "set" + "defcodeindex" "defindex" "syncodeindex" "synindex") + "List of Texinfo commands whose arguments should be deleted.") + +(defun detexinfo-remove-line-cmds-deletable-arg () + "Delete Texinfo line commands together with their args, eg @setfilename." + (message "Removing commands such as @enumerate...with their arguments...") + (mapcar 'detexinfo-remove-whole-line + detexinfo-line-cmds-deletable-arg)) + +;;; 2. @cindex and other cmds with args that may be deleted +;;; This list is here just to make it easier to revise the +;;; categories. In particular, you might want to keep the index entries. + +(defvar detexinfo-line-cmds-maybe-delete-arg + '("cindex" "findex" "kindex" "pindex" "tindex" "vindex" "node" + "c" "comment" "end" "headings" "printindex" "vskip" + "evenfooting" "evenheading" "everyfooting" "everyheading" + "oddfooting" "oddheading") + "List of Texinfo commands whose arguments may possibly be deleted.") + +(defun detexinfo-remove-line-cmds-maybe-delete-arg () + "Delete Texinfo line commands together with their arguments, eg, @cindex." + (message "Removing commands such as @cindex...with their arguments...") + (mapcar 'detexinfo-remove-whole-line + detexinfo-line-cmds-maybe-delete-arg)) + +;;; 3. @chapter and other line cmds with args to keep. + +(defvar detexinfo-line-cmds-keep-arg + '("top" "chapter" "section" "subsection" "subsubsection" + "unnumbered" "unnumberedsec" "unnumberedsubsec" "unnumberedsubsubsec" + "majorheading" "chapheading" "heading" "subheading" "subsubheading" + "appendix" "appendixsec" "appendixsubsec" "appendixsubsubsec" + "item" "itemx" + "title" "subtitle" "center" "author" "exdent" + "defcv" "deffn" "defivar" "defmac" "defmethod" "defop" "defopt" + "defspec" "deftp" "deftypefn" "deftypefun" "deftypvr" + "deftypevar" "defun" "defvar" "defvr") + "List of Texinfo line commands whose arguments should be kept.") + +(defun detexinfo-remove-line-cmds-keep-arg () + "Delete Texinfo line commands but keep their arguments, eg @chapter." + (message "Removing commands such as @chapter...but not their arguments...") + (mapcar 'detexinfo-remove-line-cmd-keep-arg + detexinfo-line-cmds-keep-arg)) + +(defun detexinfo-remove-line-cmd-keep-arg (cmd) + "Delete Texinfo line command CMD but keep its argument, eg @chapter." + (goto-char (point-min)) + (while + (re-search-forward + (concat "^@" cmd "[ \n]+") (point-max) t) + (delete-region (match-beginning 0) (match-end 0)))) + +;;; 4. @bye and other line commands without args. + +(defvar detexinfo-line-cmds-without-arg + '("bye" "contents" "display" "example" "finalout" + "flushleft" "flushright" "format" "group" "ifhtml" "ifinfo" "iftex" + "ignore" "lisp" "menu" "noindent" "page" "quotation" + "shortcontents" "smallbook" "smallexample" "smalllisp" + "summarycontents" "tex" "thischapter" "thischaptername" + "thisfile" "thispage" "thissection" "thistitle" "titlepage") + "List of Texinfo commands without arguments that should be deleted.") + +(defun detexinfo-remove-line-cmds-without-arg () + "Delete line Texinfo commands that lack args, eg. @example." + (message "Removing commands such as @example...that lack arguments...") + (mapcar 'detexinfo-remove-whole-line + detexinfo-line-cmds-without-arg)) + +;;; 5. @equiv and other inline cmds without args. + +(defvar detexinfo-inline-cmds-without-arg + '("equiv" "error" "expansion" "point" "print" "result" + "asis" "br" "bullet" "dots" "minus" "today") + "List of Texinfo inline commands without arguments that should be deleted.") + +(defun detexinfo-remove-inline-cmds-without-arg () + "Delete Texinfo inline commands in that lack arguments." + (message "Removing within line commands such as @result...") + (mapcar 'detexinfo-remove-inline-cmd + detexinfo-inline-cmds-without-arg)) + +;;; 6. @code and other inline cmds with args to keep + +(defvar detexinfo-inline-cmds-keep-arg + '("b" "cartouche" "cite" "code" "copyright" "ctrl" "dfn" "dmn" + "emph" "file" "footnote" "i" "inforef" + "kbd" "key" "pxref" "r" "ref" "samp" "sc" "titlefont" + "strong" "t" "var" "w" "xref") + "List of Texinfo inline commands with arguments that should be kept.") + +(defun detexinfo-remove-inline-cmds-keep-arg () + "Delete Texinfo inline commands but keep its arg, eg. @code." + (message + "Removing within line commands such as @code...but not their arguments...") + (mapcar 'detexinfo-remove-inline-cmd + detexinfo-inline-cmds-keep-arg)) + +;;;;;;;;;;;;;;;; end detexinfo.el ;;;;;;;;;;;;;;;; diff --git a/texinfo/emacs/elisp-comp b/texinfo/emacs/elisp-comp new file mode 100755 index 000000000000..72b204d68b52 --- /dev/null +++ b/texinfo/emacs/elisp-comp @@ -0,0 +1,7 @@ +#!/bin/sh +# $Id: elisp-comp,v 1.1 1997/08/21 22:57:57 jason Exp $ +# Trivial script to compile the Elisp files. +setpath=${TMPDIR-/tmp}/elc.$$ +echo "(setq load-path (cons nil load-path))" > $setpath +emacs -batch -l $setpath -f batch-byte-compile "$@" +rm -f $setpath diff --git a/texinfo/emacs/info.el b/texinfo/emacs/info.el new file mode 100644 index 000000000000..ead6ab92c987 --- /dev/null +++ b/texinfo/emacs/info.el @@ -0,0 +1,1846 @@ +;;; info.el --- info package for Emacs. + +;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc. + +;; Maintainer: FSF +;; Keywords: help + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Note that nowadays we expect info files to be made using makeinfo. + +;;; Code: + +(defvar Info-history nil + "List of info nodes user has visited. +Each element of list is a list (FILENAME NODENAME BUFFERPOS).") + +(defvar Info-enable-edit nil + "*Non-nil means the \\\\[Info-edit] command in Info can edit the current node. +This is convenient if you want to write info files by hand. +However, we recommend that you not do this. +It is better to write a Texinfo file and generate the Info file from that, +because that gives you a printed manual as well.") + +(defvar Info-enable-active-nodes nil + "Non-nil allows Info to execute Lisp code associated with nodes. +The Lisp code is executed when the node is selected.") +(put 'Info-enable-active-nodes 'risky-local-variable t) + +(defvar Info-fontify t + "*Non-nil enables highlighting and fonts in Info nodes.") + +(defvar Info-fontify-maximum-menu-size 30000 + "*Maximum size of menu to fontify if `Info-fontify' is non-nil.") + +(defvar Info-directory-list + (let ((path (getenv "INFOPATH")) + ;; This is for older Emacs versions + ;; which might get this info.el from the Texinfo distribution. + (path-separator (if (boundp 'path-separator) path-separator + (if (eq system-type 'ms-dos) ";" ":"))) + (source (expand-file-name "info/" source-directory)) + (sibling (if installation-directory + (expand-file-name "info/" installation-directory))) + alternative) + (if path + (let ((list nil) + idx) + (while (> (length path) 0) + (setq idx (or (string-match path-separator path) (length path)) + list (cons (substring path 0 idx) list) + path (substring path (min (1+ idx) + (length path))))) + (nreverse list)) + (if (and sibling (file-exists-p sibling)) + (setq alternative sibling) + (setq alternative source)) + (if (or (member alternative Info-default-directory-list) + (not (file-exists-p alternative)) + ;; On DOS/NT, we use movable executables always, + ;; and we must always find the Info dir at run time. + (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt)) + nil + ;; Use invocation-directory for Info only if we used it for + ;; exec-directory also. + (not (string= exec-directory + (expand-file-name "lib-src/" + installation-directory))))) + Info-default-directory-list + (reverse (cons alternative + (cdr (reverse Info-default-directory-list))))))) + "List of directories to search for Info documentation files. +nil means not yet initialized. In this case, Info uses the environment +variable INFOPATH to initialize it, or `Info-default-directory-list' +if there is no INFOPATH variable in the environment. +The last element of `Info-default-directory-list' is the directory +where Emacs installs the Info files that come with it. + +If you run the Emacs executable from the `src' directory in the Emacs +source tree, the `info' directory in the source tree is used as the last +element, in place of the installation Info directory. This is useful +when you run a version of Emacs without installing it.") + +(defvar Info-additional-directory-list nil + "List of additional directories to search for Info documentation files. +These directories are not searched for merging the `dir' file.") + +(defvar Info-current-file nil + "Info file that Info is now looking at, or nil. +This is the name that was specified in Info, not the actual file name. +It doesn't contain directory names or file name extensions added by Info.") + +(defvar Info-current-subfile nil + "Info subfile that is actually in the *info* buffer now, +or nil if current info file is not split into subfiles.") + +(defvar Info-current-node nil + "Name of node that Info is now looking at, or nil.") + +(defvar Info-tag-table-marker (make-marker) + "Marker pointing at beginning of current Info file's tag table. +Marker points nowhere if file has no tag table.") + +(defvar Info-current-file-completions nil + "Cached completion list for current Info file.") + +(defvar Info-index-alternatives nil + "List of possible matches for last Info-index command.") + +(defvar Info-standalone nil + "Non-nil if Emacs was started solely as an Info browser.") + +(defvar Info-suffix-list + (if (eq system-type 'ms-dos) + '( (".gz" . "gunzip") + (".z" . "gunzip") + (".inf" . nil) + ("" . nil)) + '( (".info.Z" . "uncompress") + (".info.Y" . "unyabba") + (".info.gz" . "gunzip") + (".info.z" . "gunzip") + (".info" . nil) + (".Z" . "uncompress") + (".Y" . "unyabba") + (".gz" . "gunzip") + (".z" . "gunzip") + ("" . nil))) + "List of file name suffixes and associated decoding commands. +Each entry should be (SUFFIX . STRING); the file is given to +the command as standard input. If STRING is nil, no decoding is done. +Because the SUFFIXes are tried in order, the empty string should +be last in the list.") + +;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot. +;; First, on ms-dos, delete some of the extension in FILENAME +;; to make room. +(defun info-insert-file-contents-1 (filename suffix) + (if (not (eq system-type 'ms-dos)) + (concat filename suffix) + (let* ((sans-exts (file-name-sans-extension filename)) + ;; How long is the extension in FILENAME (not counting the dot). + (ext-len (max 0 (- (length filename) (length sans-exts) 1))) + ext-left) + ;; SUFFIX starts with a dot. If FILENAME already has one, + ;; get rid of the one in SUFFIX (unless suffix is empty). + (or (and (<= ext-len 0) + (not (eq (aref filename (1- (length filename))) ?.))) + (= (length suffix) 0) + (setq suffix (substring suffix 1))) + ;; How many chars of that extension should we keep? + (setq ext-left (min ext-len (max 0 (- 3 (length suffix))))) + ;; Get rid of the rest of the extension, and add SUFFIX. + (concat (substring filename 0 (- (length filename) + (- ext-len ext-left))) + suffix)))) + +(defun info-insert-file-contents (filename &optional visit) + "Insert the contents of an info file in the current buffer. +Do the right thing if the file has been compressed or zipped." + (let ((tail Info-suffix-list) + fullname decoder) + (if (file-exists-p filename) + ;; FILENAME exists--see if that name contains a suffix. + ;; If so, set DECODE accordingly. + (progn + (while (and tail + (not (string-match + (concat (regexp-quote (car (car tail))) "$") + filename))) + (setq tail (cdr tail))) + (setq fullname filename + decoder (cdr (car tail)))) + ;; Try adding suffixes to FILENAME and see if we can find something. + (while (and tail + (not (file-exists-p (info-insert-file-contents-1 + filename (car (car tail)))))) + (setq tail (cdr tail))) + ;; If we found a file with a suffix, set DECODER according to the suffix + ;; and set FULLNAME to the file's actual name. + (setq fullname (info-insert-file-contents-1 filename (car (car tail))) + decoder (cdr (car tail))) + (or tail + (error "Can't find %s or any compressed version of it" filename))) + ;; check for conflict with jka-compr + (if (and (featurep 'jka-compr) + (jka-compr-installed-p) + (jka-compr-get-compression-info fullname)) + (setq decoder nil)) + (insert-file-contents fullname visit) + (if decoder + (let ((buffer-read-only nil) + (default-directory (or (file-name-directory fullname) + default-directory))) + (call-process-region (point-min) (point-max) decoder t t))))) + +;;;###autoload (add-hook 'same-window-buffer-names "*info*") + +;;;###autoload +(defun info (&optional file) + "Enter Info, the documentation browser. +Optional argument FILE specifies the file to examine; +the default is the top-level directory of Info. + +In interactive use, a prefix argument directs this command +to read a file name from the minibuffer. + +The search path for Info files is in the variable `Info-directory-list'. +The top-level Info directory is made by combining all the files named `dir' +in all the directories in that path." + (interactive (if current-prefix-arg + (list (read-file-name "Info file name: " nil nil t)))) + (if file + (Info-goto-node (concat "(" file ")")) + (if (get-buffer "*info*") + (pop-to-buffer "*info*") + (Info-directory)))) + +;;;###autoload +(defun info-standalone () + "Run Emacs as a standalone Info reader. +Usage: emacs -f info-standalone [filename] +In standalone mode, \\\\[Info-exit] exits Emacs itself." + (setq Info-standalone t) + (if (and command-line-args-left + (not (string-match "^-" (car command-line-args-left)))) + (condition-case err + (progn + (info (car command-line-args-left)) + (setq command-line-args-left (cdr command-line-args-left))) + (error (send-string-to-terminal + (format "%s\n" (if (eq (car-safe err) 'error) + (nth 1 err) err))) + (save-buffers-kill-emacs))) + (info))) + +;; Go to an info node specified as separate filename and nodename. +;; no-going-back is non-nil if recovering from an error in this function; +;; it says do not attempt further (recursive) error recovery. +(defun Info-find-node (filename nodename &optional no-going-back) + ;; Convert filename to lower case if not found as specified. + ;; Expand it. + (if filename + (let (temp temp-downcase found) + (setq filename (substitute-in-file-name filename)) + (if (string= (downcase filename) "dir") + (setq found t) + (let ((dirs (if (string-match "^\\./" filename) + ;; If specified name starts with `./' + ;; then just try current directory. + '("./") + (if (file-name-absolute-p filename) + ;; No point in searching for an + ;; absolute file name + '(nil) + (if Info-additional-directory-list + (append Info-directory-list + Info-additional-directory-list) + Info-directory-list))))) + ;; Search the directory list for file FILENAME. + (while (and dirs (not found)) + (setq temp (expand-file-name filename (car dirs))) + (setq temp-downcase + (expand-file-name (downcase filename) (car dirs))) + ;; Try several variants of specified name. + (let ((suffix-list Info-suffix-list)) + (while (and suffix-list (not found)) + (cond ((file-exists-p + (info-insert-file-contents-1 + temp (car (car suffix-list)))) + (setq found temp)) + ((file-exists-p + (info-insert-file-contents-1 + temp-downcase (car (car suffix-list)))) + (setq found temp-downcase))) + (setq suffix-list (cdr suffix-list)))) + (setq dirs (cdr dirs))))) + (if found + (setq filename found) + (error "Info file %s does not exist" filename)))) + ;; Record the node we are leaving. + (if (and Info-current-file (not no-going-back)) + (setq Info-history + (cons (list Info-current-file Info-current-node (point)) + Info-history))) + ;; Go into info buffer. + (switch-to-buffer "*info*") + (buffer-disable-undo (current-buffer)) + (or (eq major-mode 'Info-mode) + (Info-mode)) + (widen) + (setq Info-current-node nil) + (unwind-protect + (progn + ;; Switch files if necessary + (or (null filename) + (equal Info-current-file filename) + (let ((buffer-read-only nil)) + (setq Info-current-file nil + Info-current-subfile nil + Info-current-file-completions nil + Info-index-alternatives nil + buffer-file-name nil) + (erase-buffer) + (if (eq filename t) + (Info-insert-dir) + (info-insert-file-contents filename t) + (setq default-directory (file-name-directory filename))) + (set-buffer-modified-p nil) + ;; See whether file has a tag table. Record the location if yes. + (set-marker Info-tag-table-marker nil) + (goto-char (point-max)) + (forward-line -8) + ;; Use string-equal, not equal, to ignore text props. + (or (string-equal nodename "*") + (not (search-forward "\^_\nEnd tag table\n" nil t)) + (let (pos) + ;; We have a tag table. Find its beginning. + ;; Is this an indirect file? + (search-backward "\nTag table:\n") + (setq pos (point)) + (if (save-excursion + (forward-line 2) + (looking-at "(Indirect)\n")) + ;; It is indirect. Copy it to another buffer + ;; and record that the tag table is in that buffer. + (save-excursion + (let ((buf (current-buffer))) + (set-buffer (get-buffer-create " *info tag table*")) + (buffer-disable-undo (current-buffer)) + (setq case-fold-search t) + (erase-buffer) + (insert-buffer-substring buf) + (set-marker Info-tag-table-marker + (match-end 0)))) + (set-marker Info-tag-table-marker pos)))) + (setq Info-current-file + (if (eq filename t) "dir" filename)))) + ;; Use string-equal, not equal, to ignore text props. + (if (string-equal nodename "*") + (progn (setq Info-current-node nodename) + (Info-set-mode-line)) + ;; Search file for a suitable node. + (let ((guesspos (point-min)) + (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]"))) + ;; First get advice from tag table if file has one. + ;; Also, if this is an indirect info file, + ;; read the proper subfile into this buffer. + (if (marker-position Info-tag-table-marker) + (save-excursion + (set-buffer (marker-buffer Info-tag-table-marker)) + (goto-char Info-tag-table-marker) + (if (re-search-forward regexp nil t) + (progn + (setq guesspos (read (current-buffer))) + ;; If this is an indirect file, + ;; determine which file really holds this node + ;; and read it in. + (if (not (eq (current-buffer) (get-buffer "*info*"))) + (setq guesspos + (Info-read-subfile guesspos)))) + (error "No such node: %s" nodename)))) + (goto-char (max (point-min) (- guesspos 1000))) + ;; Now search from our advised position (or from beg of buffer) + ;; to find the actual node. + (catch 'foo + (while (search-forward "\n\^_" nil t) + (forward-line 1) + (let ((beg (point))) + (forward-line 1) + (if (re-search-backward regexp beg t) + (throw 'foo t)))) + (error "No such node: %s" nodename))) + (Info-select-node))) + ;; If we did not finish finding the specified node, + ;; go back to the previous one. + (or Info-current-node no-going-back (null Info-history) + (let ((hist (car Info-history))) + (setq Info-history (cdr Info-history)) + (Info-find-node (nth 0 hist) (nth 1 hist) t) + (goto-char (nth 2 hist))))) + (goto-char (point-min))) + +;; Cache the contents of the (virtual) dir file, once we have merged +;; it for the first time, so we can save time subsequently. +(defvar Info-dir-contents nil) + +;; Cache for the directory we decided to use for the default-directory +;; of the merged dir text. +(defvar Info-dir-contents-directory nil) + +;; Record the file attributes of all the files from which we +;; constructed Info-dir-contents. +(defvar Info-dir-file-attributes nil) + +;; Construct the Info directory node by merging the files named `dir' +;; from various directories. Set the *info* buffer's +;; default-directory to the first directory we actually get any text +;; from. +(defun Info-insert-dir () + (if (and Info-dir-contents Info-dir-file-attributes + ;; Verify that none of the files we used has changed + ;; since we used it. + (eval (cons 'and + (mapcar '(lambda (elt) + (let ((curr (file-attributes (car elt)))) + ;; Don't compare the access time. + (if curr (setcar (nthcdr 4 curr) 0)) + (setcar (nthcdr 4 (cdr elt)) 0) + (equal (cdr elt) curr))) + Info-dir-file-attributes)))) + (insert Info-dir-contents) + (let ((dirs Info-directory-list) + buffers buffer others nodes dirs-done) + + (setq Info-dir-file-attributes nil) + + ;; Search the directory list for the directory file. + (while dirs + (let ((truename (file-truename (expand-file-name (car dirs))))) + (or (member truename dirs-done) + (member (directory-file-name truename) dirs-done) + ;; Try several variants of specified name. + ;; Try upcasing, appending `.info', or both. + (let* (file + (attrs + (or + (progn (setq file (expand-file-name "dir" truename)) + (file-attributes file)) + (progn (setq file (expand-file-name "DIR" truename)) + (file-attributes file)) + (progn (setq file (expand-file-name "dir.info" truename)) + (file-attributes file)) + (progn (setq file (expand-file-name "DIR.INFO" truename)) + (file-attributes file))))) + (setq dirs-done + (cons truename + (cons (directory-file-name truename) + dirs-done))) + (if attrs + (save-excursion + (or buffers + (message "Composing main Info directory...")) + (set-buffer (generate-new-buffer "info dir")) + (insert-file-contents file) + (setq buffers (cons (current-buffer) buffers) + Info-dir-file-attributes + (cons (cons file attrs) + Info-dir-file-attributes)))))) + (or (cdr dirs) (setq Info-dir-contents-directory (car dirs))) + (setq dirs (cdr dirs)))) + + (or buffers + (error "Can't find the Info directory node")) + ;; Distinguish the dir file that comes with Emacs from all the + ;; others. Yes, that is really what this is supposed to do. + ;; If it doesn't work, fix it. + (setq buffer (car buffers) + others (cdr buffers)) + + ;; Insert the entire original dir file as a start; note that we've + ;; already saved its default directory to use as the default + ;; directory for the whole concatenation. + (insert-buffer buffer) + + ;; Look at each of the other buffers one by one. + (while others + (let ((other (car others))) + ;; In each, find all the menus. + (save-excursion + (set-buffer other) + (goto-char (point-min)) + ;; Find each menu, and add an elt to NODES for it. + (while (re-search-forward "^\\* Menu:" nil t) + (let (beg nodename end) + (forward-line 1) + (setq beg (point)) + (search-backward "\n\^_") + (search-forward "Node: ") + (setq nodename (Info-following-node-name)) + (search-forward "\n\^_" nil 'move) + (beginning-of-line) + (setq end (point)) + (setq nodes (cons (list nodename other beg end) nodes)))))) + (setq others (cdr others))) + ;; Add to the main menu a menu item for each other node. + (re-search-forward "^\\* Menu:") + (forward-line 1) + (let ((menu-items '("top")) + (nodes nodes) + (case-fold-search t) + (end (save-excursion (search-forward "\^_" nil t) (point)))) + (while nodes + (let ((nodename (car (car nodes)))) + (save-excursion + (or (member (downcase nodename) menu-items) + (re-search-forward (concat "^\\* " + (regexp-quote nodename) + "::") + end t) + (progn + (insert "* " nodename "::" "\n") + (setq menu-items (cons nodename menu-items)))))) + (setq nodes (cdr nodes)))) + ;; Now take each node of each of the other buffers + ;; and merge it into the main buffer. + (while nodes + (let ((nodename (car (car nodes)))) + (goto-char (point-min)) + ;; Find the like-named node in the main buffer. + (if (re-search-forward (concat "\n\^_.*\n.*Node: " + (regexp-quote nodename) + "[,\n\t]") + nil t) + (progn + (search-forward "\n\^_" nil 'move) + (beginning-of-line) + (insert "\n")) + ;; If none exists, add one. + (goto-char (point-max)) + (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n")) + ;; Merge the text from the other buffer's menu + ;; into the menu in the like-named node in the main buffer. + (apply 'insert-buffer-substring (cdr (car nodes)))) + (setq nodes (cdr nodes))) + ;; Kill all the buffers we just made. + (while buffers + (kill-buffer (car buffers)) + (setq buffers (cdr buffers))) + (message "Composing main Info directory...done")) + (setq Info-dir-contents (buffer-string))) + (setq default-directory Info-dir-contents-directory)) + +(defun Info-read-subfile (nodepos) + (set-buffer (marker-buffer Info-tag-table-marker)) + (goto-char (point-min)) + (search-forward "\n\^_") + (let (lastfilepos + lastfilename) + (forward-line 2) + (catch 'foo + (while (not (looking-at "\^_")) + (if (not (eolp)) + (let ((beg (point)) + thisfilepos thisfilename) + (search-forward ": ") + (setq thisfilename (buffer-substring beg (- (point) 2))) + (setq thisfilepos (read (current-buffer))) + ;; read in version 19 stops at the end of number. + ;; Advance to the next line. + (forward-line 1) + (if (> thisfilepos nodepos) + (throw 'foo t)) + (setq lastfilename thisfilename) + (setq lastfilepos thisfilepos)) + (forward-line 1)))) + (set-buffer (get-buffer "*info*")) + (or (equal Info-current-subfile lastfilename) + (let ((buffer-read-only nil)) + (setq buffer-file-name nil) + (widen) + (erase-buffer) + (info-insert-file-contents lastfilename) + (set-buffer-modified-p nil) + (setq Info-current-subfile lastfilename))) + (goto-char (point-min)) + (search-forward "\n\^_") + (+ (- nodepos lastfilepos) (point)))) + +;; Select the info node that point is in. +(defun Info-select-node () + (save-excursion + ;; Find beginning of node. + (search-backward "\n\^_") + (forward-line 2) + ;; Get nodename spelled as it is in the node. + (re-search-forward "Node:[ \t]*") + (setq Info-current-node + (buffer-substring-no-properties (point) + (progn + (skip-chars-forward "^,\t\n") + (point)))) + (Info-set-mode-line) + ;; Find the end of it, and narrow. + (beginning-of-line) + (let (active-expression) + (narrow-to-region (point) + (if (re-search-forward "\n[\^_\f]" nil t) + (prog1 + (1- (point)) + (if (looking-at "[\n\^_\f]*execute: ") + (progn + (goto-char (match-end 0)) + (setq active-expression + (read (current-buffer)))))) + (point-max))) + (if Info-enable-active-nodes (eval active-expression)) + (if Info-fontify (Info-fontify-node)) + (run-hooks 'Info-selection-hook)))) + +(defun Info-set-mode-line () + (setq mode-line-buffer-identification + (concat + "Info: (" + (if Info-current-file + (file-name-nondirectory Info-current-file) + "") + ")" + (or Info-current-node "")))) + +;; Go to an info node specified with a filename-and-nodename string +;; of the sort that is found in pointers in nodes. + +(defun Info-goto-node (nodename) + "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME." + (interactive (list (Info-read-node-name "Goto node: "))) + (let (filename) + (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" + nodename) + (setq filename (if (= (match-beginning 1) (match-end 1)) + "" + (substring nodename (match-beginning 2) (match-end 2))) + nodename (substring nodename (match-beginning 3) (match-end 3))) + (let ((trim (string-match "\\s *\\'" filename))) + (if trim (setq filename (substring filename 0 trim)))) + (let ((trim (string-match "\\s *\\'" nodename))) + (if trim (setq nodename (substring nodename 0 trim)))) + (if transient-mark-mode (deactivate-mark)) + (Info-find-node (if (equal filename "") nil filename) + (if (equal nodename "") "Top" nodename)))) + +;; This function is used as the "completion table" while reading a node name. +;; It does completion using the alist in completion-table +;; unless STRING starts with an open-paren. +(defun Info-read-node-name-1 (string predicate code) + (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\()))) + (cond ((eq code nil) + (if no-completion + string + (try-completion string completion-table predicate))) + ((eq code t) + (if no-completion + nil + (all-completions string completion-table predicate))) + ((eq code 'lambda) + (if no-completion + t + (assoc string completion-table)))))) + +(defun Info-read-node-name (prompt &optional default) + (let* ((completion-ignore-case t) + (completion-table (Info-build-node-completions)) + (nodename (completing-read prompt 'Info-read-node-name-1))) + (if (equal nodename "") + (or default + (Info-read-node-name prompt)) + nodename))) + +(defun Info-build-node-completions () + (or Info-current-file-completions + (let ((compl nil)) + (save-excursion + (save-restriction + (if (marker-buffer Info-tag-table-marker) + (progn + (set-buffer (marker-buffer Info-tag-table-marker)) + (widen) + (goto-char Info-tag-table-marker) + (while (re-search-forward "\nNode: \\(.*\\)\177" nil t) + (setq compl + (cons (list (buffer-substring (match-beginning 1) + (match-end 1))) + compl)))) + (widen) + (goto-char (point-min)) + (while (search-forward "\n\^_" nil t) + (forward-line 1) + (let ((beg (point))) + (forward-line 1) + (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]" + beg t) + (setq compl + (cons (list (buffer-substring (match-beginning 1) + (match-end 1))) + compl)))))))) + (setq Info-current-file-completions compl)))) + +(defun Info-restore-point (hl) + "If this node has been visited, restore the point value when we left." + (while hl + (if (and (equal (nth 0 (car hl)) Info-current-file) + ;; Use string-equal, not equal, to ignore text props. + (string-equal (nth 1 (car hl)) Info-current-node)) + (progn + (goto-char (nth 2 (car hl))) + (setq hl nil)) ;terminate the while at next iter + (setq hl (cdr hl))))) + +(defvar Info-last-search nil + "Default regexp for \\\\[Info-search] command to search for.") + +(defun Info-search (regexp) + "Search for REGEXP, starting from point, and select node it's found in." + (interactive "sSearch (regexp): ") + (if transient-mark-mode (deactivate-mark)) + (if (equal regexp "") + (setq regexp Info-last-search) + (setq Info-last-search regexp)) + (let ((found ()) current + (onode Info-current-node) + (ofile Info-current-file) + (opoint (point)) + (osubfile Info-current-subfile)) + (save-excursion + (save-restriction + (widen) + (if (null Info-current-subfile) + (progn (re-search-forward regexp) (setq found (point))) + (condition-case err + (progn (re-search-forward regexp) (setq found (point))) + (search-failed nil))))) + (if (not found) ;can only happen in subfile case -- else would have erred + (unwind-protect + (let ((list ())) + (set-buffer (marker-buffer Info-tag-table-marker)) + (goto-char (point-min)) + (search-forward "\n\^_\nIndirect:") + (save-restriction + (narrow-to-region (point) + (progn (search-forward "\n\^_") + (1- (point)))) + (goto-char (point-min)) + (search-forward (concat "\n" osubfile ": ")) + (beginning-of-line) + (while (not (eobp)) + (re-search-forward "\\(^.*\\): [0-9]+$") + (goto-char (+ (match-end 1) 2)) + (setq list (cons (cons (read (current-buffer)) + (buffer-substring (match-beginning 1) + (match-end 1))) + list)) + (goto-char (1+ (match-end 0)))) + (setq list (nreverse list) + current (car (car list)) + list (cdr list))) + (while list + (message "Searching subfile %s..." (cdr (car list))) + (Info-read-subfile (car (car list))) + (setq list (cdr list)) +;; (goto-char (point-min)) + (if (re-search-forward regexp nil t) + (setq found (point) list ()))) + (if found + (message "") + (signal 'search-failed (list regexp)))) + (if (not found) + (progn (Info-read-subfile opoint) + (goto-char opoint) + (Info-select-node))))) + (widen) + (goto-char found) + (Info-select-node) + ;; Use string-equal, not equal, to ignore text props. + (or (and (string-equal onode Info-current-node) + (equal ofile Info-current-file)) + (setq Info-history (cons (list ofile onode opoint) + Info-history))))) + +;; Extract the value of the node-pointer named NAME. +;; If there is none, use ERRORNAME in the error message; +;; if ERRORNAME is nil, just return nil. +(defun Info-extract-pointer (name &optional errorname) + (save-excursion + (goto-char (point-min)) + (forward-line 1) + (if (re-search-backward (concat name ":") nil t) + (progn + (goto-char (match-end 0)) + (Info-following-node-name)) + (if (eq errorname t) + nil + (error "Node has no %s" (capitalize (or errorname name))))))) + +;; Return the node name in the buffer following point. +;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp +;; saying which chas may appear in the node name. +(defun Info-following-node-name (&optional allowedchars) + (skip-chars-forward " \t") + (buffer-substring-no-properties + (point) + (progn + (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) + (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) + (if (looking-at "(") + (skip-chars-forward "^)"))) + (skip-chars-backward " ") + (point)))) + +(defun Info-next () + "Go to the next node of this node." + (interactive) + (Info-goto-node (Info-extract-pointer "next"))) + +(defun Info-prev () + "Go to the previous node of this node." + (interactive) + (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))) + +(defun Info-up () + "Go to the superior node of this node." + (interactive) + (Info-goto-node (Info-extract-pointer "up")) + (Info-restore-point Info-history)) + +(defun Info-last () + "Go back to the last node visited." + (interactive) + (or Info-history + (error "This is the first Info node you looked at")) + (let (filename nodename opoint) + (setq filename (car (car Info-history))) + (setq nodename (car (cdr (car Info-history)))) + (setq opoint (car (cdr (cdr (car Info-history))))) + (setq Info-history (cdr Info-history)) + (Info-find-node filename nodename) + (setq Info-history (cdr Info-history)) + (goto-char opoint))) + +(defun Info-directory () + "Go to the Info directory node." + (interactive) + (Info-find-node "dir" "top")) + +(defun Info-follow-reference (footnotename) + "Follow cross reference named NAME to the node it refers to. +NAME may be an abbreviation of the reference name." + (interactive + (let ((completion-ignore-case t) + completions default alt-default (start-point (point)) str i bol eol) + (save-excursion + ;; Store end and beginning of line. + (end-of-line) + (setq eol (point)) + (beginning-of-line) + (setq bol (point)) + + (goto-char (point-min)) + (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) + (setq str (buffer-substring + (match-beginning 1) + (1- (point)))) + ;; See if this one should be the default. + (and (null default) + (<= (match-beginning 0) start-point) + (<= start-point (point)) + (setq default t)) + ;; See if this one should be the alternate default. + (and (null alt-default) + (and (<= bol (match-beginning 0)) + (<= (point) eol)) + (setq alt-default t)) + (setq i 0) + (while (setq i (string-match "[ \n\t]+" str i)) + (setq str (concat (substring str 0 i) " " + (substring str (match-end 0)))) + (setq i (1+ i))) + ;; Record as a completion and perhaps as default. + (if (eq default t) (setq default str)) + (if (eq alt-default t) (setq alt-default str)) + (setq completions + (cons (cons str nil) + completions)))) + ;; If no good default was found, try an alternate. + (or default + (setq default alt-default)) + ;; If only one cross-reference found, then make it default. + (if (eq (length completions) 1) + (setq default (car (car completions)))) + (if completions + (let ((input (completing-read (if default + (concat "Follow reference named: (" + default ") ") + "Follow reference named: ") + completions nil t))) + (list (if (equal input "") + default input))) + (error "No cross-references in this node")))) + (let (target beg i (str (concat "\\*note " (regexp-quote footnotename)))) + (while (setq i (string-match " " str i)) + (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i)))) + (setq i (+ i 6))) + (save-excursion + (goto-char (point-min)) + (or (re-search-forward str nil t) + (error "No cross-reference named %s" footnotename)) + (goto-char (+ (match-beginning 0) 5)) + (setq target + (Info-extract-menu-node-name "Bad format cross reference" t))) + (while (setq i (string-match "[ \t\n]+" target i)) + (setq target (concat (substring target 0 i) " " + (substring target (match-end 0)))) + (setq i (+ i 1))) + (Info-goto-node target))) + +(defun Info-extract-menu-node-name (&optional errmessage multi-line) + (skip-chars-forward " \t\n") + (let ((beg (point)) + str i) + (skip-chars-forward "^:") + (forward-char 1) + (setq str + (if (looking-at ":") + (buffer-substring-no-properties beg (1- (point))) + (skip-chars-forward " \t\n") + (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n")))) + (while (setq i (string-match "\n" str i)) + (aset str i ?\ )) + ;; Collapse multiple spaces. + (while (string-match " +" str) + (setq str (replace-match " " t t str))) + str)) + +;; No one calls this. +;;(defun Info-menu-item-sequence (list) +;; (while list +;; (Info-menu (car list)) +;; (setq list (cdr list)))) + +(defun Info-complete-menu-item (string predicate action) + (let ((case-fold-search t)) + (cond ((eq action nil) + (let (completions + (pattern (concat "\n\\* \\(" + (regexp-quote string) + "[^:\t\n]*\\):"))) + (save-excursion + (set-buffer Info-complete-menu-buffer) + (goto-char (point-min)) + (search-forward "\n* Menu:") + (while (re-search-forward pattern nil t) + (setq completions (cons (cons (format "%s" + (buffer-substring + (match-beginning 1) + (match-end 1))) + (match-beginning 1)) + completions)))) + (try-completion string completions predicate))) + ((eq action t) + (let (completions + (pattern (concat "\n\\* \\(" + (regexp-quote string) + "[^:\t\n]*\\):"))) + (save-excursion + (set-buffer Info-complete-menu-buffer) + (goto-char (point-min)) + (search-forward "\n* Menu:") + (while (re-search-forward pattern nil t) + (setq completions (cons (cons (format "%s" + (buffer-substring + (match-beginning 1) + (match-end 1))) + (match-beginning 1)) + completions)))) + (all-completions string completions predicate))) + (t + (save-excursion + (set-buffer Info-complete-menu-buffer) + (goto-char (point-min)) + (search-forward "\n* Menu:") + (re-search-forward (concat "\n\\* " + (regexp-quote string) + ":") + nil t)))))) + + +(defun Info-menu (menu-item) + "Go to node for menu item named (or abbreviated) NAME. +Completion is allowed, and the menu item point is on is the default." + (interactive + (let ((completions '()) + ;; If point is within a menu item, use that item as the default + (default nil) + (p (point)) + beg + (last nil)) + (save-excursion + (goto-char (point-min)) + (if (not (search-forward "\n* menu:" nil t)) + (error "No menu in this node")) + (setq beg (point)) + (and (< (point) p) + (save-excursion + (goto-char p) + (end-of-line) + (re-search-backward "\n\\* \\([^:\t\n]*\\):" beg t) + (setq default (format "%s" (buffer-substring + (match-beginning 1) + (match-end 1))))))) + (let ((item nil)) + (while (null item) + (setq item (let ((completion-ignore-case t) + (Info-complete-menu-buffer (current-buffer))) + (completing-read (if default + (format "Menu item (default %s): " + default) + "Menu item: ") + 'Info-complete-menu-item nil t))) + ;; we rely on the fact that completing-read accepts an input + ;; of "" even when the require-match argument is true and "" + ;; is not a valid possibility + (if (string= item "") + (if default + (setq item default) + ;; ask again + (setq item nil)))) + (list item)))) + ;; there is a problem here in that if several menu items have the same + ;; name you can only go to the node of the first with this command. + (Info-goto-node (Info-extract-menu-item menu-item))) + +(defun Info-extract-menu-item (menu-item) + (setq menu-item (regexp-quote menu-item)) + (save-excursion + (goto-char (point-min)) + (or (search-forward "\n* menu:" nil t) + (error "No menu in this node")) + (or (re-search-forward (concat "\n\\* " menu-item ":") nil t) + (re-search-forward (concat "\n\\* " menu-item) nil t) + (error "No such item in menu")) + (beginning-of-line) + (forward-char 2) + (Info-extract-menu-node-name))) + +;; If COUNT is nil, use the last item in the menu. +(defun Info-extract-menu-counting (count) + (save-excursion + (goto-char (point-min)) + (or (search-forward "\n* menu:" nil t) + (error "No menu in this node")) + (if count + (or (search-forward "\n* " nil t count) + (error "Too few items in menu")) + (while (search-forward "\n* " nil t) + nil)) + (Info-extract-menu-node-name))) + +(defun Info-nth-menu-item () + "Go to the node of the Nth menu item. +N is the digit argument used to invoke this command." + (interactive) + (Info-goto-node + (Info-extract-menu-counting + (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0)))) + +(defun Info-top-node () + "Go to the Top node of this file." + (interactive) + (Info-goto-node "Top")) + +(defun Info-final-node () + "Go to the final node in this file." + (interactive) + (Info-goto-node "Top") + (let (Info-history) + ;; Go to the last node in the menu of Top. + (Info-goto-node (Info-extract-menu-counting nil)) + ;; If the last node in the menu is not last in pointer structure, + ;; move forward until we can't go any farther. + (while (Info-forward-node t t) nil) + ;; Then keep moving down to last subnode, unless we reach an index. + (while (and (not (string-match "\\" Info-current-node)) + (save-excursion (search-forward "\n* Menu:" nil t))) + (Info-goto-node (Info-extract-menu-counting nil))))) + +(defun Info-forward-node (&optional not-down no-error) + "Go forward one node, considering all nodes as forming one sequence." + (interactive) + (goto-char (point-min)) + (forward-line 1) + ;; three possibilities, in order of priority: + ;; 1. next node is in a menu in this node (but not in an index) + ;; 2. next node is next at same level + ;; 3. next node is up and next + (cond ((and (not not-down) + (save-excursion (search-forward "\n* menu:" nil t)) + (not (string-match "\\" Info-current-node))) + (Info-goto-node (Info-extract-menu-counting 1)) + t) + ((save-excursion (search-backward "next:" nil t)) + (Info-next) + t) + ((and (save-excursion (search-backward "up:" nil t)) + ;; Use string-equal, not equal, to ignore text props. + (not (string-equal (downcase (Info-extract-pointer "up")) + "top"))) + (let ((old-node Info-current-node)) + (Info-up) + (let (Info-history success) + (unwind-protect + (setq success (Info-forward-node t no-error)) + (or success (Info-goto-node old-node)))))) + (no-error nil) + (t (error "No pointer forward from this node")))) + +(defun Info-backward-node () + "Go backward one node, considering all nodes as forming one sequence." + (interactive) + (let ((prevnode (Info-extract-pointer "prev[ious]*" t)) + (upnode (Info-extract-pointer "up" t))) + (cond ((and upnode (string-match "(" upnode)) + (error "First node in file")) + ((and upnode (or (null prevnode) + ;; Use string-equal, not equal, + ;; to ignore text properties. + (string-equal (downcase prevnode) + (downcase upnode)))) + (Info-up)) + (prevnode + ;; If we move back at the same level, + ;; go down to find the last subnode*. + (Info-prev) + (let (Info-history) + (while (and (not (string-match "\\" Info-current-node)) + (save-excursion (search-forward "\n* Menu:" nil t))) + (Info-goto-node (Info-extract-menu-counting nil))))) + (t + (error "No pointer backward from this node"))))) + +(defun Info-exit () + "Exit Info by selecting some other buffer." + (interactive) + (if Info-standalone + (save-buffers-kill-emacs) + (switch-to-buffer (prog1 (other-buffer (current-buffer)) + (bury-buffer (current-buffer)))))) + +(defun Info-next-menu-item () + (interactive) + (save-excursion + (forward-line -1) + (search-forward "\n* menu:" nil t) + (or (search-forward "\n* " nil t) + (error "No more items in menu")) + (Info-goto-node (Info-extract-menu-node-name)))) + +(defun Info-last-menu-item () + (interactive) + (save-excursion + (forward-line 1) + (let ((beg (save-excursion + (and (search-backward "\n* menu:" nil t) + (point))))) + (or (and beg (search-backward "\n* " beg t)) + (error "No previous items in menu"))) + (Info-goto-node (save-excursion + (goto-char (match-end 0)) + (Info-extract-menu-node-name))))) + +(defmacro Info-no-error (&rest body) + (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil))) + +(defun Info-next-preorder () + "Go to the next subnode or the next node, or go up a level." + (interactive) + (cond ((Info-no-error (Info-next-menu-item))) + ((Info-no-error (Info-next))) + ((Info-no-error (Info-up)) + ;; Since we have already gone thru all the items in this menu, + ;; go up to the end of this node. + (goto-char (point-max)) + ;; Since logically we are done with the node with that menu, + ;; move on from it. + (Info-next-preorder)) + (t + (error "No more nodes")))) + +(defun Info-last-preorder () + "Go to the last node, popping up a level if there is none." + (interactive) + (cond ((Info-no-error + (Info-last-menu-item) + ;; If we go down a menu item, go to the end of the node + ;; so we can scroll back through it. + (goto-char (point-max))) + ;; Keep going down, as long as there are nested menu nodes. + (while (Info-no-error + (Info-last-menu-item) + ;; If we go down a menu item, go to the end of the node + ;; so we can scroll back through it. + (goto-char (point-max)))) + (recenter -1)) + ((Info-no-error (Info-prev)) + (goto-char (point-max)) + (while (Info-no-error + (Info-last-menu-item) + ;; If we go down a menu item, go to the end of the node + ;; so we can scroll back through it. + (goto-char (point-max)))) + (recenter -1)) + ((Info-no-error (Info-up)) + (goto-char (point-min)) + (or (search-forward "\n* Menu:" nil t) + (goto-char (point-max)))) + (t (error "No previous nodes")))) + +(defun Info-scroll-up () + "Scroll one screenful forward in Info, considering all nodes as one sequence. +Once you scroll far enough in a node that its menu appears on the screen, +the next scroll moves into its first subnode. When you scroll past +the end of a node, that goes to the next node or back up to the parent node." + (interactive) + (if (or (< (window-start) (point-min)) + (> (window-start) (point-max))) + (set-window-start (selected-window) (point))) + (let ((virtual-end (save-excursion + (goto-char (point-min)) + (if (search-forward "\n* Menu:" nil t) + (point) + (point-max))))) + (if (or (< virtual-end (window-start)) + (pos-visible-in-window-p virtual-end)) + (Info-next-preorder) + (scroll-up)))) + +(defun Info-scroll-down () + "Scroll one screenful back in Info, considering all nodes as one sequence. +Within the menu of a node, this goes to its last subnode. +When you scroll past the beginning of a node, that goes to the +previous node or back up to the parent node." + (interactive) + (if (or (< (window-start) (point-min)) + (> (window-start) (point-max))) + (set-window-start (selected-window) (point))) + (let* ((current-point (point)) + (virtual-end (save-excursion + (beginning-of-line) + (setq current-point (point)) + (goto-char (point-min)) + (search-forward "\n* Menu:" + current-point + t)))) + (if (or virtual-end (pos-visible-in-window-p (point-min))) + (Info-last-preorder) + (scroll-down)))) + +(defun Info-next-reference (&optional recur) + "Move cursor to the next cross-reference or menu item in the node." + (interactive) + (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:") + (old-pt (point))) + (or (eobp) (forward-char 1)) + (or (re-search-forward pat nil t) + (progn + (goto-char (point-min)) + (or (re-search-forward pat nil t) + (progn + (goto-char old-pt) + (error "No cross references in this node"))))) + (goto-char (match-beginning 0)) + (if (looking-at "\\* Menu:") + (if recur + (error "No cross references in this node") + (Info-next-reference t))))) + +(defun Info-prev-reference (&optional recur) + "Move cursor to the previous cross-reference or menu item in the node." + (interactive) + (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:") + (old-pt (point))) + (or (re-search-backward pat nil t) + (progn + (goto-char (point-max)) + (or (re-search-backward pat nil t) + (progn + (goto-char old-pt) + (error "No cross references in this node"))))) + (goto-char (match-beginning 0)) + (if (looking-at "\\* Menu:") + (if recur + (error "No cross references in this node") + (Info-prev-reference t))))) + +(defun Info-index (topic) + "Look up a string in the index for this file. +The index is defined as the first node in the top-level menu whose +name contains the word \"Index\", plus any immediately following +nodes whose names also contain the word \"Index\". +If there are no exact matches to the specified topic, this chooses +the first match which is a case-insensitive substring of a topic. +Use the `,' command to see the other matches. +Give a blank topic name to go to the Index node itself." + (interactive "sIndex topic: ") + (let ((orignode Info-current-node) + (rnode nil) + (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)" + (regexp-quote topic))) + node) + (Info-goto-node "Top") + (or (search-forward "\n* menu:" nil t) + (error "No index")) + (or (re-search-forward "\n\\* \\(.*\\\\)" nil t) + (error "No index")) + (goto-char (match-beginning 1)) + ;; Here, and subsequently in this function, + ;; we bind Info-history to nil for internal node-switches + ;; so that we don't put junk in the history. + ;; In the first Info-goto-node call, above, we do update the history + ;; because that is what the user's previous node choice into it. + (let ((Info-history nil)) + (Info-goto-node (Info-extract-menu-node-name))) + (or (equal topic "") + (let ((matches nil) + (exact nil) + (Info-history nil) + found) + (while + (progn + (goto-char (point-min)) + (while (re-search-forward pattern nil t) + (setq matches + (cons (list (buffer-substring (match-beginning 1) + (match-end 1)) + (buffer-substring (match-beginning 2) + (match-end 2)) + Info-current-node + (string-to-int (concat "0" + (buffer-substring + (match-beginning 3) + (match-end 3))))) + matches))) + (and (setq node (Info-extract-pointer "next" t)) + (string-match "\\" node))) + (Info-goto-node node)) + (or matches + (progn + (Info-goto-node orignode) + (error "No `%s' in index" topic))) + ;; Here it is a feature that assoc is case-sensitive. + (while (setq found (assoc topic matches)) + (setq exact (cons found exact) + matches (delq found matches))) + (setq Info-index-alternatives (nconc exact (nreverse matches))) + (Info-index-next 0))))) + +(defun Info-index-next (num) + "Go to the next matching index item from the last `i' command." + (interactive "p") + (or Info-index-alternatives + (error "No previous `i' command in this file")) + (while (< num 0) + (setq num (+ num (length Info-index-alternatives)))) + (while (> num 0) + (setq Info-index-alternatives + (nconc (cdr Info-index-alternatives) + (list (car Info-index-alternatives))) + num (1- num))) + (Info-goto-node (nth 1 (car Info-index-alternatives))) + (if (> (nth 3 (car Info-index-alternatives)) 0) + (forward-line (nth 3 (car Info-index-alternatives))) + (forward-line 3) ; don't search in headers + (let ((name (car (car Info-index-alternatives)))) + (Info-find-index-name name))) + (message "Found `%s' in %s. %s" + (car (car Info-index-alternatives)) + (nth 2 (car Info-index-alternatives)) + (if (cdr Info-index-alternatives) + "(Press `,' for more)" + "(Only match)"))) + +(defun Info-find-index-name (name) + "Move point to the place within the current node where NAME is defined." + (if (or (re-search-forward (format + "[a-zA-Z]+: %s\\( \\|$\\)" + (regexp-quote name)) nil t) + (search-forward (format "`%s'" name) nil t) + (and (string-match "\\`.*\\( (.*)\\)\\'" name) + (search-forward + (format "`%s'" (substring name 0 (match-beginning 1))) + nil t)) + (search-forward name nil t)) + (beginning-of-line) + (goto-char (point-min)))) + +(defun Info-undefined () + "Make command be undefined in Info." + (interactive) + (ding)) + +(defun Info-help () + "Enter the Info tutorial." + (interactive) + (delete-other-windows) + (Info-find-node "info" + (if (< (window-height) 23) + "Help-Small-Screen" + "Help"))) + +(defun Info-summary () + "Display a brief summary of all Info commands." + (interactive) + (save-window-excursion + (switch-to-buffer "*Help*") + (erase-buffer) + (insert (documentation 'Info-mode)) + (help-mode) + (goto-char (point-min)) + (let (ch flag) + (while (progn (setq flag (not (pos-visible-in-window-p (point-max)))) + (message (if flag "Type Space to see more" + "Type Space to return to Info")) + (if (not (eq ?\ (setq ch (read-event)))) + (progn (setq unread-command-events (list ch)) nil) + flag)) + (scroll-up))) + (bury-buffer "*Help*"))) + +(defun Info-get-token (pos start all &optional errorstring) + "Return the token around POS, +POS must be somewhere inside the token +START is a regular expression which will match the + beginning of the tokens delimited string +ALL is a regular expression with a single + parenthesized subpattern which is the token to be + returned. E.g. '{\(.*\)}' would return any string + enclosed in braces around POS. +SIG optional fourth argument, controls action on no match + nil: return nil + t: beep + a string: signal an error, using that string." + (save-excursion + (goto-char pos) + (re-search-backward start (max (point-min) (- pos 200)) 'yes) + (let (found) + (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes) + (not (setq found (and (<= (match-beginning 0) pos) + (> (match-end 0) pos)))))) + (if (and found (<= (match-beginning 0) pos) + (> (match-end 0) pos)) + (buffer-substring (match-beginning 1) (match-end 1)) + (cond ((null errorstring) + nil) + ((eq errorstring t) + (beep) + nil) + (t + (error "No %s around position %d" errorstring pos))))))) + +(defun Info-mouse-follow-nearest-node (click) + "\\Follow a node reference near point. +Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click. +At end of the node's text, moves to the next node, or up if none." + (interactive "e") + (let* ((start (event-start click)) + (window (car start)) + (pos (car (cdr start)))) + (select-window window) + (goto-char pos)) + (and (not (Info-try-follow-nearest-node)) + (save-excursion (forward-line 1) (eobp)) + (Info-next-preorder))) + +(defun Info-follow-nearest-node () + "\\Follow a node reference near point. +Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is. +If no reference to follow, moves to the next node, or up if none." + (interactive) + (or (Info-try-follow-nearest-node) + (Info-next-preorder))) + +;; Common subroutine. +(defun Info-try-follow-nearest-node () + "Follow a node reference near point. Return non-nil if successful." + (let (node) + (cond + ((setq node (Info-get-token (point) "\\*note[ \n]" + "\\*note[ \n]\\([^:]*\\):")) + (Info-follow-reference node)) + ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::")) + (Info-goto-node node)) + ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):")) + (Info-menu node)) + ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)")) + (Info-goto-node node)) + ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)")) + (Info-goto-node node)) + ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)")) + (Info-goto-node "Top")) + ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) + (Info-goto-node node))) + node)) + +(defvar Info-mode-map nil + "Keymap containing Info commands.") +(if Info-mode-map + nil + (setq Info-mode-map (make-keymap)) + (suppress-keymap Info-mode-map) + (define-key Info-mode-map "." 'beginning-of-buffer) + (define-key Info-mode-map " " 'Info-scroll-up) + (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node) + (define-key Info-mode-map "\t" 'Info-next-reference) + (define-key Info-mode-map "\e\t" 'Info-prev-reference) + (define-key Info-mode-map "1" 'Info-nth-menu-item) + (define-key Info-mode-map "2" 'Info-nth-menu-item) + (define-key Info-mode-map "3" 'Info-nth-menu-item) + (define-key Info-mode-map "4" 'Info-nth-menu-item) + (define-key Info-mode-map "5" 'Info-nth-menu-item) + (define-key Info-mode-map "6" 'Info-nth-menu-item) + (define-key Info-mode-map "7" 'Info-nth-menu-item) + (define-key Info-mode-map "8" 'Info-nth-menu-item) + (define-key Info-mode-map "9" 'Info-nth-menu-item) + (define-key Info-mode-map "0" 'undefined) + (define-key Info-mode-map "?" 'Info-summary) + (define-key Info-mode-map "]" 'Info-forward-node) + (define-key Info-mode-map "[" 'Info-backward-node) + (define-key Info-mode-map "<" 'Info-top-node) + (define-key Info-mode-map ">" 'Info-final-node) + (define-key Info-mode-map "b" 'beginning-of-buffer) + (define-key Info-mode-map "d" 'Info-directory) + (define-key Info-mode-map "e" 'Info-edit) + (define-key Info-mode-map "f" 'Info-follow-reference) + (define-key Info-mode-map "g" 'Info-goto-node) + (define-key Info-mode-map "h" 'Info-help) + (define-key Info-mode-map "i" 'Info-index) + (define-key Info-mode-map "l" 'Info-last) + (define-key Info-mode-map "m" 'Info-menu) + (define-key Info-mode-map "n" 'Info-next) + (define-key Info-mode-map "p" 'Info-prev) + (define-key Info-mode-map "q" 'Info-exit) + (define-key Info-mode-map "s" 'Info-search) + ;; For consistency with Rmail. + (define-key Info-mode-map "\M-s" 'Info-search) + (define-key Info-mode-map "t" 'Info-top-node) + (define-key Info-mode-map "u" 'Info-up) + (define-key Info-mode-map "," 'Info-index-next) + (define-key Info-mode-map "\177" 'Info-scroll-down) + (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node) + ) + +;; Info mode is suitable only for specially formatted data. +(put 'info-mode 'mode-class 'special) + +(defun Info-mode () + "\\ +Info mode provides commands for browsing through the Info documentation tree. +Documentation in Info is divided into \"nodes\", each of which discusses +one topic and contains references to other nodes which discuss related +topics. Info has commands to follow the references and show you other nodes. + +\\[Info-help] Invoke the Info tutorial. + +Selecting other nodes: +\\[Info-mouse-follow-nearest-node] + Follow a node reference you click on. + This works with menu items, cross references, and + the \"next\", \"previous\" and \"up\", depending on where you click. +\\[Info-next] Move to the \"next\" node of this node. +\\[Info-prev] Move to the \"previous\" node of this node. +\\[Info-up] Move \"up\" from this node. +\\[Info-menu] Pick menu item specified by name (or abbreviation). + Picking a menu item causes another node to be selected. +\\[Info-directory] Go to the Info directory node. +\\[Info-follow-reference] Follow a cross reference. Reads name of reference. +\\[Info-last] Move to the last node you were at. +\\[Info-index] Look up a topic in this file's Index and move to that node. +\\[Info-index-next] (comma) Move to the next match from a previous `i' command. + +Moving within a node: +\\[Info-scroll-up] Normally, scroll forward a full screen. If the end of the buffer is +already visible, try to go to the next menu entry, or up if there is none. +\\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is +already visible, try to go to the previous menu entry, or up if there is none. +\\[beginning-of-buffer] Go to beginning of node. + +Advanced commands: +\\[Info-exit] Quit Info: reselect previously selected buffer. +\\[Info-edit] Edit contents of selected node. +1 Pick first item in node's menu. +2, 3, 4, 5 Pick second ... fifth item in node's menu. +\\[Info-goto-node] Move to node specified by name. + You may include a filename as well, as (FILENAME)NODENAME. +\\[universal-argument] \\[info] Move to new Info file with completion. +\\[Info-search] Search through this Info file for specified regexp, + and select the node in which the next occurrence is found. +\\[Info-next-reference] Move cursor to next cross-reference or menu item. +\\[Info-prev-reference] Move cursor to previous cross-reference or menu item." + (kill-all-local-variables) + (setq major-mode 'Info-mode) + (setq mode-name "Info") + (use-local-map Info-mode-map) + (set-syntax-table text-mode-syntax-table) + (setq local-abbrev-table text-mode-abbrev-table) + (setq case-fold-search t) + (setq buffer-read-only t) + (make-local-variable 'Info-current-file) + (make-local-variable 'Info-current-subfile) + (make-local-variable 'Info-current-node) + (make-local-variable 'Info-tag-table-marker) + (make-local-variable 'Info-history) + (make-local-variable 'Info-index-alternatives) + (if (memq (framep (selected-frame)) '(x pc)) + (progn + (make-face 'info-node) + (make-face 'info-menu-5) + (make-face 'info-xref) + (or (face-differs-from-default-p 'info-node) + (if (face-differs-from-default-p 'bold-italic) + (copy-face 'bold-italic 'info-node) + (copy-face 'bold 'info-node))) + (or (face-differs-from-default-p 'info-menu-5) + (set-face-underline-p 'info-menu-5 t)) + (or (face-differs-from-default-p 'info-xref) + (copy-face 'bold 'info-xref))) + (setq Info-fontify nil)) + (Info-set-mode-line) + (run-hooks 'Info-mode-hook)) + +(defvar Info-edit-map nil + "Local keymap used within `e' command of Info.") +(if Info-edit-map + nil + (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map)) + (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit)) + +;; Info-edit mode is suitable only for specially formatted data. +(put 'info-edit-mode 'mode-class 'special) + +(defun Info-edit-mode () + "Major mode for editing the contents of an Info node. +Like text mode with the addition of `Info-cease-edit' +which returns to Info mode for browsing. +\\{Info-edit-map}" + (use-local-map Info-edit-map) + (setq major-mode 'Info-edit-mode) + (setq mode-name "Info Edit") + (kill-local-variable 'mode-line-buffer-identification) + (setq buffer-read-only nil) + (force-mode-line-update) + (buffer-enable-undo (current-buffer)) + (run-hooks 'Info-edit-mode-hook)) + +(defun Info-edit () + "Edit the contents of this Info node. +Allowed only if variable `Info-enable-edit' is non-nil." + (interactive) + (or Info-enable-edit + (error "Editing info nodes is not enabled")) + (Info-edit-mode) + (message "%s" (substitute-command-keys + "Editing: Type \\\\[Info-cease-edit] to return to info"))) + +(defun Info-cease-edit () + "Finish editing Info node; switch back to Info proper." + (interactive) + ;; Do this first, so nothing has changed if user C-g's at query. + (and (buffer-modified-p) + (y-or-n-p "Save the file? ") + (save-buffer)) + (use-local-map Info-mode-map) + (setq major-mode 'Info-mode) + (setq mode-name "Info") + (Info-set-mode-line) + (setq buffer-read-only t) + (force-mode-line-update) + (and (marker-position Info-tag-table-marker) + (buffer-modified-p) + (message "Tags may have changed. Use Info-tagify if necessary"))) + +(defvar Info-file-list-for-emacs + '("ediff" "forms" "gnus" "info" ("mh" . "mh-e") "sc") + "List of Info files that describe Emacs commands. +An element can be a file name, or a list of the form (PREFIX . FILE) +where PREFIX is a name prefix and FILE is the file to look in. +If the element is just a file name, the file name also serves as the prefix.") + +(defun Info-find-emacs-command-nodes (command) + "Return a list of locations documenting COMMAND. +The `info-file' property of COMMAND says which Info manual to search. +If COMMAND has no property, the variable `Info-file-list-for-emacs' +defines heuristics for which Info manual to try. +The locations are of the format used in Info-history, i.e. +\(FILENAME NODENAME BUFFERPOS\)." + (let ((where '()) + (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command)) + ":\\s *\\(.*\\)\\.$")) + (info-file "emacs")) ;default + ;; Determine which info file this command is documented in. + (if (get command 'info-file) + (setq info-file (get command 'info-file)) + ;; If it doesn't say explicitly, test its name against + ;; various prefixes that we know. + (let ((file-list Info-file-list-for-emacs)) + (while file-list + (let* ((elt (car file-list)) + (name (if (consp elt) + (car elt) + elt)) + (file (if (consp elt) (cdr elt) elt)) + (regexp (concat "\\`" (regexp-quote name) + "\\(\\'\\|-\\)"))) + (if (string-match regexp (symbol-name command)) + (setq info-file file file-list nil)) + (setq file-list (cdr file-list)))))) + (save-excursion + (condition-case nil + (Info-find-node info-file "Command Index") + ;; Some manuals may not have a separate Command Index node, + ;; so try just Index instead. + (error + (Info-find-node info-file "Index"))) + ;; Take the index node off the Info history. + (setq Info-history (cdr Info-history)) + (goto-char (point-max)) + (while (re-search-backward cmd-desc nil t) + (setq where (cons (list Info-current-file + (buffer-substring + (match-beginning 1) + (match-end 1)) + 0) + where))) + where))) + +;;;###autoload +(defun Info-goto-emacs-command-node (command) + "Go to the Info node in the Emacs manual for command COMMAND. +The command is found by looking up in Emacs manual's Command Index +or in another manual found via COMMAND's `info-file' property or +the variable `Info-file-list-for-emacs'." + (interactive "CFind documentation for command: ") + (or (commandp command) + (signal 'wrong-type-argument (list 'commandp command))) + (let ((where (Info-find-emacs-command-nodes command))) + (if where + (let ((num-matches (length where))) + ;; Get Info running, and pop to it in another window. + (save-window-excursion + (info)) + (pop-to-buffer "*info*") + (Info-find-node (car (car where)) + (car (cdr (car where)))) + (if (> num-matches 1) + (progn + ;; Info-find-node already pushed (car where) onto + ;; Info-history. Put the other nodes that were found on + ;; the history. + (setq Info-history (nconc (cdr where) Info-history)) + (message "Found %d other entr%s. Use %s to see %s." + (1- num-matches) + (if (> num-matches 2) "ies" "y") + (substitute-command-keys "\\[Info-last]") + (if (> num-matches 2) "them" "it"))))) + (error "Couldn't find documentation for %s" command)))) + +;;;###autoload +(defun Info-goto-emacs-key-command-node (key) + "Go to the Info node in the Emacs manual the command bound to KEY, a string. +Interactively, if the binding is execute-extended-command, a command is read. +The command is found by looking up in Emacs manual's Command Index +or in another manual found via COMMAND's `info-file' property or +the variable `Info-file-list-for-emacs'." + (interactive "kFind documentation for key:") + (let ((command (key-binding key))) + (cond ((null command) + (message "%s is undefined" (key-description key))) + ((and (interactive-p) + (eq command 'execute-extended-command)) + (Info-goto-emacs-command-node + (read-command "Find documentation for command: "))) + (t + (Info-goto-emacs-command-node command))))) + +(defvar Info-title-face-alist + '((?* bold underline) + (?= bold-italic underline) + (?- italic underline)) + "*Alist of face or list of faces to use for pseudo-underlined titles. +The alist key is the character the title is underlined with (?*, ?= or ?-).") + +(defun Info-fontify-node () + (save-excursion + (let ((buffer-read-only nil)) + (goto-char (point-min)) + (if (looking-at "^File: [^,: \t]+,?[ \t]+") + (progn + (goto-char (match-end 0)) + (while + (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?") + (goto-char (match-end 0)) + (put-text-property (match-beginning 1) (match-end 1) + 'face 'info-xref) + (put-text-property (match-beginning 1) (match-end 1) + 'mouse-face 'highlight)))) + (goto-char (point-min)) + (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$" + nil t) + (put-text-property (match-beginning 1) (match-end 1) + 'face + (cdr (assq (preceding-char) Info-title-face-alist))) + (put-text-property (match-end 1) (match-end 2) + 'invisible t)) + (goto-char (point-min)) + (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t) + (if (= (char-after (1- (match-beginning 0))) ?\") ; hack + nil + (put-text-property (match-beginning 1) (match-end 1) + 'face 'info-xref) + (put-text-property (match-beginning 1) (match-end 1) + 'mouse-face 'highlight))) + (goto-char (point-min)) + (if (and (search-forward "\n* Menu:" nil t) + (not (string-match "\\" Info-current-node)) + ;; Don't take time to annotate huge menus + (< (- (point-max) (point)) Info-fontify-maximum-menu-size)) + (let ((n 0)) + (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t) + (setq n (1+ n)) + (if (memq n '(5 9)) ; visual aids to help with 1-9 keys + (put-text-property (match-beginning 0) + (1+ (match-beginning 0)) + 'face 'info-menu-5)) + (put-text-property (match-beginning 1) (match-end 1) + 'face 'info-node) + (put-text-property (match-beginning 1) (match-end 1) + 'mouse-face 'highlight)))) + (set-buffer-modified-p nil)))) + +(provide 'info) + +;;; info.el ends here diff --git a/texinfo/emacs/informat.el b/texinfo/emacs/informat.el new file mode 100644 index 000000000000..0b195b9e620f --- /dev/null +++ b/texinfo/emacs/informat.el @@ -0,0 +1,429 @@ +;;; informat.el --- info support functions package for Emacs + +;; Copyright (C) 1986 Free Software Foundation, Inc. + +;; Maintainer: FSF +;; Keywords: help + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Code: + +(require 'info) + +;;;###autoload +(defun Info-tagify () + "Create or update Info-file tag table in current buffer." + (interactive) + ;; Save and restore point and restrictions. + ;; save-restrictions would not work + ;; because it records the old max relative to the end. + ;; We record it relative to the beginning. + (message "Tagifying %s ..." (file-name-nondirectory (buffer-file-name))) + (let ((omin (point-min)) + (omax (point-max)) + (nomax (= (point-max) (1+ (buffer-size)))) + (opoint (point))) + (unwind-protect + (progn + (widen) + (goto-char (point-min)) + (if (search-forward "\^_\nIndirect:\n" nil t) + (message "Cannot tagify split info file") + (let ((regexp "Node:[ \t]*\\([^,\n\t]*\\)[,\t\n]") + (case-fold-search t) + list) + (while (search-forward "\n\^_" nil t) + ;; We want the 0-origin character position of the ^_. + ;; That is the same as the Emacs (1-origin) position + ;; of the newline before it. + (let ((beg (match-beginning 0))) + (forward-line 2) + (if (re-search-backward regexp beg t) + (setq list + (cons (list (buffer-substring-no-properties + (match-beginning 1) + (match-end 1)) + beg) + list))))) + (goto-char (point-max)) + (forward-line -8) + (let ((buffer-read-only nil)) + (if (search-forward "\^_\nEnd tag table\n" nil t) + (let ((end (point))) + (search-backward "\nTag table:\n") + (beginning-of-line) + (delete-region (point) end))) + (goto-char (point-max)) + (insert "\^_\f\nTag table:\n") + (move-marker Info-tag-table-marker (point)) + (setq list (nreverse list)) + (while list + (insert "Node: " (car (car list)) ?\177) + (princ (car (cdr (car list))) (current-buffer)) + (insert ?\n) + (setq list (cdr list))) + (insert "\^_\nEnd tag table\n"))))) + (goto-char opoint) + (narrow-to-region omin (if nomax (1+ (buffer-size)) + (min omax (point-max)))))) + (message "Tagifying %s ... done" (file-name-nondirectory (buffer-file-name)))) + +;;;###autoload +(defun Info-split () + "Split an info file into an indirect file plus bounded-size subfiles. +Each subfile will be up to 50,000 characters plus one node. + +To use this command, first visit a large Info file that has a tag +table. The buffer is modified into a (small) indirect info file which +should be saved in place of the original visited file. + +The subfiles are written in the same directory the original file is +in, with names generated by appending `-' and a number to the original +file name. The indirect file still functions as an Info file, but it +contains just the tag table and a directory of subfiles." + + (interactive) + (if (< (buffer-size) 70000) + (error "This is too small to be worth splitting")) + (goto-char (point-min)) + (search-forward "\^_") + (forward-char -1) + (let ((start (point)) + (chars-deleted 0) + subfiles + (subfile-number 1) + (case-fold-search t) + (filename (file-name-sans-versions buffer-file-name))) + (goto-char (point-max)) + (forward-line -8) + (setq buffer-read-only nil) + (or (search-forward "\^_\nEnd tag table\n" nil t) + (error "Tag table required; use M-x Info-tagify")) + (search-backward "\nTag table:\n") + (if (looking-at "\nTag table:\n\^_") + (error "Tag table is just a skeleton; use M-x Info-tagify")) + (beginning-of-line) + (forward-char 1) + (save-restriction + (narrow-to-region (point-min) (point)) + (goto-char (point-min)) + (while (< (1+ (point)) (point-max)) + (goto-char (min (+ (point) 50000) (point-max))) + (search-forward "\^_" nil 'move) + (setq subfiles + (cons (list (+ start chars-deleted) + (concat (file-name-nondirectory filename) + (format "-%d" subfile-number))) + subfiles)) + ;; Put a newline at end of split file, to make Unix happier. + (insert "\n") + (write-region (point-min) (point) + (concat filename (format "-%d" subfile-number))) + (delete-region (1- (point)) (point)) + ;; Back up over the final ^_. + (forward-char -1) + (setq chars-deleted (+ chars-deleted (- (point) start))) + (delete-region start (point)) + (setq subfile-number (1+ subfile-number)))) + (while subfiles + (goto-char start) + (insert (nth 1 (car subfiles)) + (format ": %d" (1- (car (car subfiles)))) + "\n") + (setq subfiles (cdr subfiles))) + (goto-char start) + (insert "\^_\nIndirect:\n") + (search-forward "\nTag Table:\n") + (insert "(Indirect)\n"))) + +;;;###autoload +(defun Info-validate () + "Check current buffer for validity as an Info file. +Check that every node pointer points to an existing node." + (interactive) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (if (search-forward "\nTag table:\n(Indirect)\n" nil t) + (error "Don't yet know how to validate indirect info files: \"%s\"" + (buffer-name (current-buffer)))) + (goto-char (point-min)) + (let ((allnodes '(("*"))) + (regexp "Node:[ \t]*\\([^,\n\t]*\\)[,\t\n]") + (case-fold-search t) + (tags-losing nil) + (lossages ())) + (while (search-forward "\n\^_" nil t) + (forward-line 1) + (let ((beg (point))) + (forward-line 1) + (if (re-search-backward regexp beg t) + (let ((name (downcase + (buffer-substring-no-properties + (match-beginning 1) + (progn + (goto-char (match-end 1)) + (skip-chars-backward " \t") + (point)))))) + (if (assoc name allnodes) + (setq lossages + (cons (list name "Duplicate node-name" nil) + lossages)) + (setq allnodes + (cons (list name + (progn + (end-of-line) + (and (re-search-backward + "prev[ious]*:" beg t) + (progn + (goto-char (match-end 0)) + (downcase + (Info-following-node-name))))) + beg) + allnodes))))))) + (goto-char (point-min)) + (while (search-forward "\n\^_" nil t) + (forward-line 1) + (let ((beg (point)) + thisnode next) + (forward-line 1) + (if (re-search-backward regexp beg t) + (save-restriction + (search-forward "\n\^_" nil 'move) + (narrow-to-region beg (point)) + (setq thisnode (downcase + (buffer-substring-no-properties + (match-beginning 1) + (progn + (goto-char (match-end 1)) + (skip-chars-backward " \t") + (point))))) + (end-of-line) + (and (search-backward "next:" nil t) + (setq next (Info-validate-node-name "invalid Next")) + (assoc next allnodes) + (if (equal (car (cdr (assoc next allnodes))) + thisnode) + ;; allow multiple `next' pointers to one node + (let ((tem lossages)) + (while tem + (if (and (equal (car (cdr (car tem))) + "should have Previous") + (equal (car (car tem)) + next)) + (setq lossages (delq (car tem) lossages))) + (setq tem (cdr tem)))) + (setq lossages + (cons (list next + "should have Previous" + thisnode) + lossages)))) + (end-of-line) + (if (re-search-backward "prev[ious]*:" nil t) + (Info-validate-node-name "invalid Previous")) + (end-of-line) + (if (search-backward "up:" nil t) + (Info-validate-node-name "invalid Up")) + (if (re-search-forward "\n* Menu:" nil t) + (while (re-search-forward "\n\\* " nil t) + (Info-validate-node-name + (concat "invalid menu item " + (buffer-substring (point) + (save-excursion + (skip-chars-forward "^:") + (point)))) + (Info-extract-menu-node-name)))) + (goto-char (point-min)) + (while (re-search-forward "\\*note[ \n]*[^:\t]*:" nil t) + (goto-char (+ (match-beginning 0) 5)) + (skip-chars-forward " \n") + (Info-validate-node-name + (concat "invalid reference " + (buffer-substring (point) + (save-excursion + (skip-chars-forward "^:") + (point)))) + (Info-extract-menu-node-name "Bad format cross-reference"))))))) + (setq tags-losing (not (Info-validate-tags-table))) + (if (or lossages tags-losing) + (with-output-to-temp-buffer " *problems in info file*" + (while lossages + (princ "In node \"") + (princ (car (car lossages))) + (princ "\", ") + (let ((tem (nth 1 (car lossages)))) + (cond ((string-match "\n" tem) + (princ (substring tem 0 (match-beginning 0))) + (princ "...")) + (t + (princ tem)))) + (if (nth 2 (car lossages)) + (progn + (princ ": ") + (let ((tem (nth 2 (car lossages)))) + (cond ((string-match "\n" tem) + (princ (substring tem 0 (match-beginning 0))) + (princ "...")) + (t + (princ tem)))))) + (terpri) + (setq lossages (cdr lossages))) + (if tags-losing (princ "\nTags table must be recomputed\n"))) + ;; Here if info file is valid. + ;; If we already made a list of problems, clear it out. + (save-excursion + (if (get-buffer " *problems in info file*") + (progn + (set-buffer " *problems in info file*") + (kill-buffer (current-buffer))))) + (message "File appears valid")))))) + +(defun Info-validate-node-name (kind &optional name) + (if name + nil + (goto-char (match-end 0)) + (skip-chars-forward " \t") + (if (= (following-char) ?\() + nil + (setq name + (buffer-substring-no-properties + (point) + (progn + (skip-chars-forward "^,\t\n") + (skip-chars-backward " ") + (point)))))) + (if (null name) + nil + (setq name (downcase name)) + (or (and (> (length name) 0) (= (aref name 0) ?\()) + (assoc name allnodes) + (setq lossages + (cons (list thisnode kind name) lossages)))) + name) + +(defun Info-validate-tags-table () + (goto-char (point-min)) + (if (not (search-forward "\^_\nEnd tag table\n" nil t)) + t + (not (catch 'losing + (let* ((end (match-beginning 0)) + (start (progn (search-backward "\nTag table:\n") + (1- (match-end 0)))) + tem) + (setq tem allnodes) + (while tem + (goto-char start) + (or (equal (car (car tem)) "*") + (search-forward (concat "Node: " + (car (car tem)) + "\177") + end t) + (throw 'losing 'x)) + (setq tem (cdr tem))) + (goto-char (1+ start)) + (while (looking-at ".*Node: \\(.*\\)\177\\([0-9]+\\)$") + (setq tem (downcase (buffer-substring-no-properties + (match-beginning 1) + (match-end 1)))) + (setq tem (assoc tem allnodes)) + (if (or (not tem) + (< 1000 (progn + (goto-char (match-beginning 2)) + (setq tem (- (car (cdr (cdr tem))) + (read (current-buffer)))) + (if (> tem 0) tem (- tem))))) + (throw 'losing 'y)) + (forward-line 1))) + (if (looking-at "\^_\n") + (forward-line 1)) + (or (looking-at "End tag table\n") + (throw 'losing 'z)) + nil)))) + +;;;###autoload +(defun batch-info-validate () + "Runs `Info-validate' on the files remaining on the command line. +Must be used only with -batch, and kills Emacs on completion. +Each file will be processed even if an error occurred previously. +For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\"" + (if (not noninteractive) + (error "batch-info-validate may only be used -batch.")) + (let ((version-control t) + (auto-save-default nil) + (find-file-run-dired nil) + (kept-old-versions 259259) + (kept-new-versions 259259)) + (let ((error 0) + file + (files ())) + (while command-line-args-left + (setq file (expand-file-name (car command-line-args-left))) + (cond ((not (file-exists-p file)) + (message ">> %s does not exist!" file) + (setq error 1 + command-line-args-left (cdr command-line-args-left))) + ((file-directory-p file) + (setq command-line-args-left (nconc (directory-files file) + (cdr command-line-args-left)))) + (t + (setq files (cons file files) + command-line-args-left (cdr command-line-args-left))))) + (while files + (setq file (car files) + files (cdr files)) + (let ((lose nil)) + (condition-case err + (progn + (if buffer-file-name (kill-buffer (current-buffer))) + (find-file file) + (buffer-disable-undo (current-buffer)) + (set-buffer-modified-p nil) + (fundamental-mode) + (let ((case-fold-search nil)) + (goto-char (point-max)) + (cond ((search-backward "\n\^_\^L\nTag table:\n" nil t) + (message "%s already tagified" file)) + ((< (point-max) 30000) + (message "%s too small to bother tagifying" file)) + (t + (Info-tagify)))) + (let ((loss-name " *problems in info file*")) + (message "Checking validity of info file %s..." file) + (if (get-buffer loss-name) + (kill-buffer loss-name)) + (Info-validate) + (if (not (get-buffer loss-name)) + nil ;(message "Checking validity of info file %s... OK" file) + (message "----------------------------------------------------------------------") + (message ">> PROBLEMS IN INFO FILE %s" file) + (save-excursion + (set-buffer loss-name) + (princ (buffer-substring-no-properties + (point-min) (point-max)))) + (message "----------------------------------------------------------------------") + (setq error 1 lose t))) + (if (and (buffer-modified-p) + (not lose)) + (progn (message "Saving modified %s" file) + (save-buffer)))) + (error (message ">> Error: %s" (prin1-to-string err)))))) + (kill-emacs error)))) + +;;; informat.el ends here diff --git a/texinfo/emacs/makeinfo.el b/texinfo/emacs/makeinfo.el new file mode 100644 index 000000000000..a649d522156c --- /dev/null +++ b/texinfo/emacs/makeinfo.el @@ -0,0 +1,247 @@ +;;; makeinfo.el --- run makeinfo conveniently + +;; Copyright (C) 1991, 1993 Free Software Foundation, Inc. + +;; Author: Robert J. Chassell +;; Maintainer: FSF + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;;; The Texinfo mode `makeinfo' related commands are: + +;; makeinfo-region to run makeinfo on the current region. +;; makeinfo-buffer to run makeinfo on the current buffer, or +;; with optional prefix arg, on current region +;; kill-compilation to kill currently running makeinfo job +;; makeinfo-recenter-makeinfo-buffer to redisplay *compilation* buffer + +;;; Keybindings (defined in `texinfo.el') + +;; makeinfo bindings +; (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) +; (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) +; (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) +; (define-key texinfo-mode-map "\C-c\C-m\C-l" +; 'makeinfo-recenter-compilation-buffer) + +;;; Code: + +;;; Variables used by `makeinfo' + +(require 'compile) + +(defvar makeinfo-run-command "makeinfo" + "*Command used to run `makeinfo' subjob. +The name of the file is appended to this string, separated by a space.") + +(defvar makeinfo-options "--fill-column=70" + "*String containing options for running `makeinfo'. +Do not include `--footnote-style' or `--paragraph-indent'; +the proper way to specify those is with the Texinfo commands +`@footnotestyle` and `@paragraphindent'.") + +(require 'texinfo) + +(defvar makeinfo-compilation-process nil + "Process that runs `makeinfo'. Should start out nil.") + +(defvar makeinfo-temp-file nil + "Temporary file name used for text being sent as input to `makeinfo'.") + +(defvar makeinfo-output-file-name nil + "Info file name used for text output by `makeinfo'.") + + +;;; The `makeinfo' function definitions + +(defun makeinfo-region (region-beginning region-end) + "Make Info file from region of current Texinfo file, and switch to it. + +This command does not offer the `next-error' feature since it would +apply to a temporary file, not the original; use the `makeinfo-buffer' +command to gain use of `next-error'." + + (interactive "r") + (let (filename-or-header + filename-or-header-beginning + filename-or-header-end) + ;; Cannot use `let' for makeinfo-temp-file or + ;; makeinfo-output-file-name since `makeinfo-compilation-sentinel' + ;; needs them. + + (setq makeinfo-temp-file + (concat + (make-temp-name + (substring (buffer-file-name) + 0 + (or (string-match "\\.tex" (buffer-file-name)) + (length (buffer-file-name))))) + ".texinfo")) + + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (let ((search-end (save-excursion (forward-line 100) (point)))) + ;; Find and record the Info filename, + ;; or else explain that a filename is needed. + (if (re-search-forward + "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" + search-end t) + (setq makeinfo-output-file-name + (buffer-substring (match-beginning 1) (match-end 1))) + (error + "The texinfo file needs a line saying: @setfilename ")) + + ;; Find header and specify its beginning and end. + (goto-char (point-min)) + (if (and + (prog1 + (search-forward tex-start-of-header search-end t) + (beginning-of-line) + ;; Mark beginning of header. + (setq filename-or-header-beginning (point))) + (prog1 + (search-forward tex-end-of-header nil t) + (beginning-of-line) + ;; Mark end of header + (setq filename-or-header-end (point)))) + + ;; Insert the header into the temporary file. + (write-region + (min filename-or-header-beginning region-beginning) + filename-or-header-end + makeinfo-temp-file nil nil) + + ;; Else no header; insert @filename line into temporary file. + (goto-char (point-min)) + (search-forward "@setfilename" search-end t) + (beginning-of-line) + (setq filename-or-header-beginning (point)) + (forward-line 1) + (setq filename-or-header-end (point)) + (write-region + (min filename-or-header-beginning region-beginning) + filename-or-header-end + makeinfo-temp-file nil nil)) + + ;; Insert the region into the file. + (write-region + (max region-beginning filename-or-header-end) + region-end + makeinfo-temp-file t nil) + + ;; Run the `makeinfo-compile' command in the *compilation* buffer + (save-excursion + (makeinfo-compile + (concat makeinfo-run-command + " " + makeinfo-options + " " + makeinfo-temp-file) + "Use `makeinfo-buffer' to gain use of the `next-error' command" + nil))))))) + +;;; Actually run makeinfo. COMMAND is the command to run. +;;; ERROR-MESSAGE is what to say when next-error can't find another error. +;;; If PARSE-ERRORS is non-nil, do try to parse error messages. +(defun makeinfo-compile (command error-message parse-errors) + (let ((buffer + (compile-internal command error-message nil + (and (not parse-errors) + ;; If we do want to parse errors, pass nil. + ;; Otherwise, use this function, which won't + ;; ever find any errors. + '(lambda (&rest ignore) + (setq compilation-error-list nil)))))) + (set-process-sentinel (get-buffer-process buffer) + 'makeinfo-compilation-sentinel))) + +;; Delete makeinfo-temp-file after processing is finished, +;; and visit Info file. +;; This function is called when the compilation process changes state. +;; Based on `compilation-sentinel' in compile.el +(defun makeinfo-compilation-sentinel (proc msg) + (compilation-sentinel proc msg) + (if (and makeinfo-temp-file (file-exists-p makeinfo-temp-file)) + (delete-file makeinfo-temp-file)) + ;; Always use the version on disk. + (if (get-file-buffer makeinfo-output-file-name) + (progn (set-buffer makeinfo-output-file-name) + (revert-buffer t t)) + (find-file makeinfo-output-file-name)) + (goto-char (point-min))) + +(defun makeinfo-buffer () + "Make Info file from current buffer. + +Use the \\[next-error] command to move to the next error +\(if there are errors\)." + + (interactive) + (cond ((null buffer-file-name) + (error "Buffer not visiting any file")) + ((buffer-modified-p) + (if (y-or-n-p "Buffer modified; do you want to save it? ") + (save-buffer)))) + + ;; Find and record the Info filename, + ;; or else explain that a filename is needed. + (save-excursion + (goto-char (point-min)) + (let ((search-end (save-excursion (forward-line 100) (point)))) + (if (re-search-forward + "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" + search-end t) + (setq makeinfo-output-file-name + (buffer-substring (match-beginning 1) (match-end 1))) + (error + "The texinfo file needs a line saying: @setfilename ")))) + + (save-excursion + (makeinfo-compile + (concat makeinfo-run-command " " makeinfo-options + " " buffer-file-name) + "No more errors." + t))) + +(defun makeinfo-recenter-compilation-buffer (linenum) + "Redisplay `*compilation*' buffer so most recent output can be seen. +The last line of the buffer is displayed on +line LINE of the window, or centered if LINE is nil." + (interactive "P") + (let ((makeinfo-buffer (get-buffer "*compilation*")) + (old-buffer (current-buffer))) + (if (null makeinfo-buffer) + (message "No *compilation* buffer") + (pop-to-buffer makeinfo-buffer) + (bury-buffer makeinfo-buffer) + (goto-char (point-max)) + (recenter (if linenum + (prefix-numeric-value linenum) + (/ (window-height) 2))) + (pop-to-buffer old-buffer) + ))) + +;;; Place `provide' at end of file. +(provide 'makeinfo) + +;;; makeinfo.el ends here + diff --git a/texinfo/emacs/new-useful-setqs b/texinfo/emacs/new-useful-setqs new file mode 100644 index 000000000000..4241ae429efb --- /dev/null +++ b/texinfo/emacs/new-useful-setqs @@ -0,0 +1,180 @@ +;; -*- Mode: Emacs-Lisp -*- + +;; This is the `new-useful-setqs' file +;; This overrides old defvars since they were revised. + +(setq texinfmt-version "2.35 of 10 September 1996") + +(setq texinfo-master-menu-header + "\n@detailmenu\n --- The Detailed Node Listing ---\n") + +(setq texinfo-environment-regexp + (concat + "^@" + "\\(" + "cartouche\\|" + "display\\|" + "end\\|" + "enumerate\\|" + "example\\|" + "f?table\\|" + "flushleft\\|" + "flushright\\|" + "format\\|" + "group\\|" + "ifhtml\\|" + "ifinfo\\|" + "iftex\\|" + "ignore\\|" + "itemize\\|" + "lisp\\|" + "macro\\|" + "multitable\\|" + "quotation\\|" + "smallexample\\|" + "smalllisp\\|" + "tex" + "\\)") +) + +(setq texinfo-no-refill-regexp + (concat + "^@" + "\\(" + "example\\|" + "smallexample\\|" + "lisp\\|" + "smalllisp\\|" + "display\\|" + "format\\|" + "flushleft\\|" + "flushright\\|" + "menu\\|" + "multitable\\|" + "titlepage\\|" + "iftex\\|" + "ifhtml\\|" + "tex\\|" + "html" + "\\)")) + + +(setq texinfo-accent-commands + (concat + "@OE\\|" + "@oe\\|" + "@AA\\|" + "@aa\\|" + "@AE\\|" + "@ae\\|" + "@ss\\|" + "@^\\|" + "@`\\|" + "@'\\|" + "@\"\\|" + "@,\\|" + "@=\\|" + "@~\\|" + "@questiondown{\\|" + "@exclamdown{\\|" + "@L{\\|" + "@l{\\|" + "@O{\\|" + "@o{\\|" + "@dotaccent{\\|" + "@ubaraccent{\\|" + "@d{\\|" + "@H{\\|" + "@ringaccent{\\|" + "@tieaccent{\\|" + "@u{\\|" + "@v{\\|" + "@dotless{" + )) + +(setq texinfo-part-of-para-regexp + (concat + "^@" + "\\(" + "b{\\|" + "bullet{\\|" + "cite{\\|" + "code{\\|" + "emph{\\|" + "equiv{\\|" + "error{\\|" + "expansion{\\|" + "file{\\|" + "i{\\|" + "inforef{\\|" + "kbd{\\|" + "key{\\|" + "lisp{\\|" + "email{\\|" + "minus{\\|" + "point{\\|" + "print{\\|" + "pxref{\\|" + "r{\\|" + "ref{\\|" + "result{\\|" + "samp{\\|" + "sc{\\|" + "t{\\|" + "TeX{\\|" + "today{\\|" + "url{\\|" + "var{\\|" + "w{\\|" + "xref{\\|" + "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop). + texinfo-accent-commands + "\\)" + )) + +(setq texinfo-raisesections-alist + '((@chapter . @chapter) ; Cannot go higher + (@unnumbered . @unnumbered) + (@centerchap . @unnumbered) + + (@majorheading . @majorheading) + (@chapheading . @chapheading) + (@appendix . @appendix) + + (@section . @chapter) + (@unnumberedsec . @unnumbered) + (@heading . @chapheading) + (@appendixsec . @appendix) + + (@subsection . @section) + (@unnumberedsubsec . @unnumberedsec) + (@subheading . @heading) + (@appendixsubsec . @appendixsec) + + (@subsubsection . @subsection) + (@unnumberedsubsubsec . @unnumberedsubsec) + (@subsubheading . @subheading) + (@appendixsubsubsec . @appendixsubsec))) + +(setq texinfo-lowersections-alist + '((@chapter . @section) + (@unnumbered . @unnumberedsec) + (@centerchap . @unnumberedsec) + (@majorheading . @heading) + (@chapheading . @heading) + (@appendix . @appendixsec) + + (@section . @subsection) + (@unnumberedsec . @unnumberedsubsec) + (@heading . @subheading) + (@appendixsec . @appendixsubsec) + + (@subsection . @subsubsection) + (@unnumberedsubsec . @unnumberedsubsubsec) + (@subheading . @subsubheading) + (@appendixsubsec . @appendixsubsubsec) + + (@subsubsection . @subsubsection) ; Cannot go lower. + (@unnumberedsubsubsec . @unnumberedsubsubsec) + (@subsubheading . @subsubheading) + (@appendixsubsubsec . @appendixsubsubsec))) diff --git a/texinfo/emacs/texinfmt.el b/texinfo/emacs/texinfmt.el new file mode 100644 index 000000000000..c0d09635a8d4 --- /dev/null +++ b/texinfo/emacs/texinfmt.el @@ -0,0 +1,3979 @@ +;;; texinfmt.el --- format Texinfo files into Info files. + +;; Copyright (C) 1985, 1986, 1988, 1990, 1991, +;; 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + +;; Author: Robert J. Chassell +;; Date: 10 Sep 1996 +;; Maintainer: Robert J. Chassell +;; Keywords: maint, tex, docs + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Code: + +;;; Emacs lisp functions to convert Texinfo files to Info files. + +(defvar texinfmt-version "2.35 of 10 September 1996") + +(defun texinfmt-version (&optional here) + "Show the version of texinfmt.el in the minibuffer. +If optional argument HERE is non-nil, insert info at point." + (interactive "P") + (let ((version-string + (format "Version of \`texinfmt.el\': %s" texinfmt-version))) + (if here + (insert version-string) + (if (interactive-p) + (message "%s" version-string) + version-string)))) + + +;;; Variable definitions + +(require 'texinfo) ; So `texinfo-footnote-style' is defined. +(require 'texnfo-upd) ; So `texinfo-section-types-regexp' is defined. + +(defvar texinfo-format-syntax-table nil) + +(defvar texinfo-vindex) +(defvar texinfo-findex) +(defvar texinfo-cindex) +(defvar texinfo-pindex) +(defvar texinfo-tindex) +(defvar texinfo-kindex) +(defvar texinfo-last-node) +(defvar texinfo-node-names) +(defvar texinfo-enclosure-list) +(defvar texinfo-alias-list) + +(defvar texinfo-command-start) +(defvar texinfo-command-end) +(defvar texinfo-command-name) +(defvar texinfo-defun-type) +(defvar texinfo-last-node-pos) +(defvar texinfo-stack) +(defvar texinfo-short-index-cmds-alist) +(defvar texinfo-short-index-format-cmds-alist) +(defvar texinfo-format-filename) +(defvar texinfo-footnote-number) +(defvar texinfo-start-of-header) +(defvar texinfo-end-of-header) +(defvar texinfo-raisesections-alist) +(defvar texinfo-lowersections-alist) + +;;; Syntax table + +(if texinfo-format-syntax-table + nil + (setq texinfo-format-syntax-table (make-syntax-table)) + (modify-syntax-entry ?\" " " texinfo-format-syntax-table) + (modify-syntax-entry ?\\ " " texinfo-format-syntax-table) + (modify-syntax-entry ?@ "\\" texinfo-format-syntax-table) + (modify-syntax-entry ?\^q "\\" texinfo-format-syntax-table) + (modify-syntax-entry ?\[ "." texinfo-format-syntax-table) + (modify-syntax-entry ?\] "." texinfo-format-syntax-table) + (modify-syntax-entry ?\( "." texinfo-format-syntax-table) + (modify-syntax-entry ?\) "." texinfo-format-syntax-table) + (modify-syntax-entry ?{ "(}" texinfo-format-syntax-table) + (modify-syntax-entry ?} "){" texinfo-format-syntax-table) + (modify-syntax-entry ?\' "." texinfo-format-syntax-table)) + + +;;; Top level buffer and region formatting functions + +;;;###autoload +(defun texinfo-format-buffer (&optional notagify) + "Process the current buffer as texinfo code, into an Info file. +The Info file output is generated in a buffer visiting the Info file +names specified in the @setfilename command. + +Non-nil argument (prefix, if interactive) means don't make tag table +and don't split the file if large. You can use Info-tagify and +Info-split to do these manually." + (interactive "P") + (let ((lastmessage "Formatting Info file...")) + (message lastmessage) + (texinfo-format-buffer-1) + (if notagify + nil + (if (> (buffer-size) 30000) + (progn + (message (setq lastmessage "Making tags table for Info file...")) + (Info-tagify))) + (if (> (buffer-size) 100000) + (progn + (message (setq lastmessage "Splitting Info file...")) + (Info-split)))) + (message (concat lastmessage + (if (interactive-p) "done. Now save it." "done."))))) + +(defvar texinfo-region-buffer-name "*Info Region*" + "*Name of the temporary buffer used by \\[texinfo-format-region].") + +;;;###autoload +(defun texinfo-format-region (region-beginning region-end) + "Convert the current region of the Texinfo file to Info format. +This lets you see what that part of the file will look like in Info. +The command is bound to \\[texinfo-format-region]. The text that is +converted to Info is stored in a temporary buffer." + (interactive "r") + (message "Converting region to Info format...") + (let (texinfo-command-start + texinfo-command-end + texinfo-command-name + texinfo-vindex + texinfo-findex + texinfo-cindex + texinfo-pindex + texinfo-tindex + texinfo-kindex + texinfo-stack + (texinfo-format-filename "") + texinfo-example-start + texinfo-last-node-pos + texinfo-last-node + texinfo-node-names + (texinfo-footnote-number 0) + last-input-buffer + (fill-column-for-info fill-column) + (input-buffer (current-buffer)) + (input-directory default-directory) + (header-text "") + (header-beginning 1) + (header-end 1)) + +;;; Copy lines between beginning and end of header lines, +;;; if any, or else copy the `@setfilename' line, if any. + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (let ((search-end (save-excursion (forward-line 100) (point)))) + (if (or + ;; Either copy header text. + (and + (prog1 + (search-forward tex-start-of-header search-end t) + (forward-line 1) + ;; Mark beginning of header. + (setq header-beginning (point))) + (prog1 + (search-forward tex-end-of-header nil t) + (beginning-of-line) + ;; Mark end of header + (setq header-end (point)))) + ;; Or copy @filename line. + (prog2 + (goto-char (point-min)) + (search-forward "@setfilename" search-end t) + (beginning-of-line) + (setq header-beginning (point)) + (forward-line 1) + (setq header-end (point)))) + + ;; Copy header + (setq header-text + (buffer-substring + (min header-beginning region-beginning) + header-end)))))) + +;;; Find a buffer to use. + (switch-to-buffer (get-buffer-create texinfo-region-buffer-name)) + (erase-buffer) + ;; Insert the header into the buffer. + (insert header-text) + ;; Insert the region into the buffer. + (insert-buffer-substring + input-buffer + (max region-beginning header-end) + region-end) + ;; Make sure region ends in a newline. + (or (= (preceding-char) ?\n) + (insert "\n")) + + (goto-char (point-min)) + (texinfo-mode) + (message "Converting region to Info format...") + (setq fill-column fill-column-for-info) + ;; Install a syntax table useful for scanning command operands. + (set-syntax-table texinfo-format-syntax-table) + + ;; Insert @include files so `texinfo-raise-lower-sections' can + ;; work on them without losing track of multiple + ;; @raise/@lowersections commands. + (while (re-search-forward "^@include" nil t) + (setq texinfo-command-end (point)) + (let ((filename (concat input-directory + (texinfo-parse-line-arg)))) + (re-search-backward "^@include") + (delete-region (point) (save-excursion (forward-line 1) (point))) + (message "Reading included file: %s" filename) + (save-excursion + (save-restriction + (narrow-to-region + (point) + (+ (point) (car (cdr (insert-file-contents filename))))) + (goto-char (point-min)) + ;; Remove `@setfilename' line from included file, if any, + ;; so @setfilename command not duplicated. + (if (re-search-forward + "^@setfilename" (save-excursion (forward-line 100) (point)) t) + (progn + (beginning-of-line) + (delete-region + (point) (save-excursion (forward-line 1) (point))))))))) + + ;; Raise or lower level of each section, if necessary. + (goto-char (point-min)) + (texinfo-raise-lower-sections) + ;; Append @refill to appropriate paragraphs for filling. + (goto-char (point-min)) + (texinfo-append-refill) + ;; If the region includes the effective end of the data, + ;; discard everything after that. + (goto-char (point-max)) + (if (re-search-backward "^@bye" nil t) + (delete-region (point) (point-max))) + ;; Make sure buffer ends in a newline. + (or (= (preceding-char) ?\n) + (insert "\n")) + ;; Don't use a previous value of texinfo-enclosure-list. + (setq texinfo-enclosure-list nil) + (setq texinfo-alias-list nil) + + (goto-char (point-min)) + (if (looking-at "\\\\input[ \t]+texinfo") + (delete-region (point) (save-excursion (forward-line 1) (point)))) + + ;; Insert Info region title text. + (goto-char (point-min)) + (if (search-forward + "@setfilename" (save-excursion (forward-line 100) (point)) t) + (progn + (setq texinfo-command-end (point)) + (beginning-of-line) + (setq texinfo-command-start (point)) + (let ((arg (texinfo-parse-arg-discard))) + (insert " " + texinfo-region-buffer-name + " buffer for: `") + (insert (file-name-nondirectory (expand-file-name arg))) + (insert "', -*-Text-*-\n"))) + ;; Else no `@setfilename' line + (insert " " + texinfo-region-buffer-name + " buffer -*-Text-*-\n")) + (insert "produced by `texinfo-format-region'\n" + "from a region in: " + (if (buffer-file-name input-buffer) + (concat "`" + (file-name-sans-versions + (file-name-nondirectory + (buffer-file-name input-buffer))) + "'") + (concat "buffer `" (buffer-name input-buffer) "'")) + "\nusing `texinfmt.el' version " + texinfmt-version + ".\n\n") + + ;; Now convert for real. + (goto-char (point-min)) + (texinfo-format-scan) + (goto-char (point-min)) + + (message "Done."))) + + +;;; Primary internal formatting function for the whole buffer. + +(defun texinfo-format-buffer-1 () + (let (texinfo-format-filename + texinfo-example-start + texinfo-command-start + texinfo-command-end + texinfo-command-name + texinfo-last-node + texinfo-last-node-pos + texinfo-vindex + texinfo-findex + texinfo-cindex + texinfo-pindex + texinfo-tindex + texinfo-kindex + texinfo-stack + texinfo-node-names + (texinfo-footnote-number 0) + last-input-buffer + outfile + (fill-column-for-info fill-column) + (input-buffer (current-buffer)) + (input-directory default-directory)) + (setq texinfo-enclosure-list nil) + (setq texinfo-alias-list nil) + (save-excursion + (goto-char (point-min)) + (or (search-forward "@setfilename" nil t) + (error "Texinfo file needs an `@setfilename FILENAME' line.")) + (setq texinfo-command-end (point)) + (setq outfile (texinfo-parse-line-arg))) + (find-file outfile) + (texinfo-mode) + (setq fill-column fill-column-for-info) + (set-syntax-table texinfo-format-syntax-table) + (erase-buffer) + (insert-buffer-substring input-buffer) + (message "Converting %s to Info format..." (buffer-name input-buffer)) + + ;; Insert @include files so `texinfo-raise-lower-sections' can + ;; work on them without losing track of multiple + ;; @raise/@lowersections commands. + (goto-char (point-min)) + (while (re-search-forward "^@include" nil t) + (setq texinfo-command-end (point)) + (let ((filename (concat input-directory + (texinfo-parse-line-arg)))) + (re-search-backward "^@include") + (delete-region (point) (save-excursion (forward-line 1) (point))) + (message "Reading included file: %s" filename) + (save-excursion + (save-restriction + (narrow-to-region + (point) + (+ (point) (car (cdr (insert-file-contents filename))))) + (goto-char (point-min)) + ;; Remove `@setfilename' line from included file, if any, + ;; so @setfilename command not duplicated. + (if (re-search-forward + "^@setfilename" + (save-excursion (forward-line 100) (point)) t) + (progn + (beginning-of-line) + (delete-region + (point) (save-excursion (forward-line 1) (point))))))))) + ;; Raise or lower level of each section, if necessary. + (goto-char (point-min)) + (texinfo-raise-lower-sections) + ;; Append @refill to appropriate paragraphs + (goto-char (point-min)) + (texinfo-append-refill) + (goto-char (point-min)) + (search-forward "@setfilename") + (beginning-of-line) + (delete-region (point-min) (point)) + ;; Remove @bye at end of file, if it is there. + (goto-char (point-max)) + (if (search-backward "@bye" nil t) + (delete-region (point) (point-max))) + ;; Make sure buffer ends in a newline. + (or (= (preceding-char) ?\n) + (insert "\n")) + ;; Scan the whole buffer, converting to Info format. + (texinfo-format-scan) + ;; Return data for indices. + (goto-char (point-min)) + (list outfile + texinfo-vindex texinfo-findex texinfo-cindex + texinfo-pindex texinfo-tindex texinfo-kindex))) + + +;;; Perform non-@-command file conversions: quotes and hyphens + +(defun texinfo-format-convert (min max) + ;; Convert left and right quotes to typewriter font quotes. + (goto-char min) + (while (search-forward "``" max t) + (replace-match "\"")) + (goto-char min) + (while (search-forward "''" max t) + (replace-match "\"")) + ;; Convert three hyphens in a row to two. + (goto-char min) + (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t) + (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning + 2))))) + + +;;; Handle paragraph filling + +;; Keep as concatinated lists for ease of maintenance + +(defvar texinfo-no-refill-regexp + (concat + "^@" + "\\(" + "example\\|" + "smallexample\\|" + "lisp\\|" + "smalllisp\\|" + "display\\|" + "format\\|" + "flushleft\\|" + "flushright\\|" + "menu\\|" + "multitable\\|" + "titlepage\\|" + "iftex\\|" + "ifhtml\\|" + "tex\\|" + "html" + "\\)") + "Regexp specifying environments in which paragraphs are not filled.") + +(defvar texinfo-accent-commands + (concat + "@^\\|" + "@`\\|" + "@'\\|" + "@\"\\|" + "@,\\|" + "@=\\|" + "@~\\|" + "@OE{\\|" + "@oe{\\|" + "@AA{\\|" + "@aa{\\|" + "@AE{\\|" + "@ae{\\|" + "@ss{\\|" + "@questiondown{\\|" + "@exclamdown{\\|" + "@L{\\|" + "@l{\\|" + "@O{\\|" + "@o{\\|" + "@dotaccent{\\|" + "@ubaraccent{\\|" + "@d{\\|" + "@H{\\|" + "@ringaccent{\\|" + "@tieaccent{\\|" + "@u{\\|" + "@v{\\|" + "@dotless{" + )) + +(defvar texinfo-part-of-para-regexp + (concat + "^@" + "\\(" + "b{\\|" + "bullet{\\|" + "cite{\\|" + "code{\\|" + "emph{\\|" + "equiv{\\|" + "error{\\|" + "expansion{\\|" + "file{\\|" + "i{\\|" + "inforef{\\|" + "kbd{\\|" + "key{\\|" + "lisp{\\|" + "email{\\|" + "minus{\\|" + "point{\\|" + "print{\\|" + "pxref{\\|" + "r{\\|" + "ref{\\|" + "result{\\|" + "samp{\\|" + "sc{\\|" + "t{\\|" + "TeX{\\|" + "today{\\|" + "url{\\|" + "var{\\|" + "w{\\|" + "xref{\\|" + "@-\\|" ; @- is a descretionary hyphen (not an accent) (a noop). + texinfo-accent-commands + "\\)" + ) + "Regexp specifying @-commands found within paragraphs.") + +(defun texinfo-append-refill () + "Append @refill at end of each paragraph that should be filled. +Do not append @refill to paragraphs within @example and similar environments. +Do not append @refill to paragraphs containing @w{TEXT} or @*." + + ;; It is necessary to append @refill before other processing because + ;; the other processing removes information that tells Texinfo + ;; whether the text should or should not be filled. + + (while (< (point) (point-max)) + (let ((refill-blank-lines "^[ \t\n]*$") + (case-fold-search nil)) ; Don't confuse @TeX and @tex.... + (beginning-of-line) + ;; 1. Skip over blank lines; + ;; skip over lines beginning with @-commands, + ;; but do not skip over lines + ;; that are no-refill environments such as @example or + ;; that begin with within-paragraph @-commands such as @code. + (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines)) + (not (looking-at + (concat + "\\(" + texinfo-no-refill-regexp + "\\|" + texinfo-part-of-para-regexp + "\\)"))) + (< (point) (point-max))) + (forward-line 1)) + ;; 2. Skip over @example and similar no-refill environments. + (if (looking-at texinfo-no-refill-regexp) + (let ((environment + (buffer-substring (match-beginning 1) (match-end 1)))) + (progn (re-search-forward (concat "^@end " environment) nil t) + (forward-line 1))) + ;; Else + ;; 3. Do not refill a paragraph containing @w or @*, or ending + ;; with @ followed by a newline. + (if (or + (>= (point) (point-max)) + (re-search-forward + "@w{\\|@\\*\\|@\n\n" + (save-excursion + (forward-paragraph) + (forward-line 1) + (point)) t)) + ;; Go to end of paragraph and do nothing. + (forward-paragraph) + ;; 4. Else go to end of paragraph and insert @refill + (forward-paragraph) + (forward-line -1) + (end-of-line) + (delete-region + (point) + (save-excursion (skip-chars-backward " \t") (point))) + ;; `looking-at-backward' not available in v. 18.57 + ;; (if (not (looking-at-backward "@refill\\|@bye")) ;) + (if (not (re-search-backward + "@refill\\|@bye" + (save-excursion (beginning-of-line) (point)) + t)) + (insert "@refill")) + (forward-line 1)))))) + + +;;; Handle `@raisesections' and `@lowersections' commands + +;; These commands change the hierarchical level of chapter structuring +;; commands. +;; +;; @raisesections changes @subsection to @section, +;; @section to @chapter, +;; etc. +;; +;; @lowersections changes @chapter to @section +;; @subsection to @subsubsection, +;; etc. +;; +;; An @raisesections/@lowersections command changes only those +;; structuring commands that follow the @raisesections/@lowersections +;; command. +;; +;; Repeated @raisesections/@lowersections continue to raise or lower +;; the heading level. +;; +;; An @lowersections command cancels an @raisesections command, and +;; vice versa. +;; +;; You cannot raise or lower "beyond" chapters or subsubsections, but +;; trying to do so does not elicit an error---you just get more +;; headings that mean the same thing as you keep raising or lowering +;; (for example, after a single @raisesections, both @chapter and +;; @section produce chapter headings). + +(defun texinfo-raise-lower-sections () + "Raise or lower the hierarchical level of chapters, sections, etc. + +This function acts according to `@raisesections' and `@lowersections' +commands in the Texinfo file. + +For example, an `@lowersections' command is useful if you wish to +include what is written as an outer or standalone Texinfo file in +another Texinfo file as an inner, included file. The `@lowersections' +command changes chapters to sections, sections to subsections and so +on. + +@raisesections changes @subsection to @section, + @section to @chapter, + @heading to @chapheading, + etc. + +@lowersections changes @chapter to @section, + @subsection to @subsubsection, + @heading to @subheading, + etc. + +An `@raisesections' or `@lowersections' command changes only those +structuring commands that follow the `@raisesections' or +`@lowersections' command. + +An `@lowersections' command cancels an `@raisesections' command, and +vice versa. + +Repeated use of the commands continue to raise or lower the hierarchical +level a step at a time. + +An attempt to raise above `chapters' reproduces chapter commands; an +attempt to lower below subsubsections reproduces subsubsection +commands." + + ;; `texinfo-section-types-regexp' is defined in `texnfo-upd.el'; + ;; it is a regexp matching chapter, section, other headings + ;; (but not the top node). + + (let (type (level 0)) + (while + (re-search-forward + (concat + "\\(\\(^@\\(raise\\|lower\\)sections\\)\\|\\(" + texinfo-section-types-regexp + "\\)\\)") + nil t) + (beginning-of-line) + (save-excursion (setq type (read (current-buffer)))) + (cond + + ;; 1. Increment level + ((eq type '@raisesections) + (setq level (1+ level)) + (delete-region + (point) (save-excursion (forward-line 1) (point)))) + + ;; 2. Decrement level + ((eq type '@lowersections) + (setq level (1- level)) + (delete-region + (point) (save-excursion (forward-line 1) (point)))) + + ;; Now handle structuring commands + ((cond + + ;; 3. Raise level when positive + ((> level 0) + (let ((count level) + (new-level type)) + (while (> count 0) + (setq new-level + (cdr (assq new-level texinfo-raisesections-alist))) + (setq count (1- count))) + (kill-word 1) + (insert (symbol-name new-level)))) + + ;; 4. Do nothing except move point when level is zero + ((= level 0) (forward-line 1)) + + ;; 5. Lower level when positive + ((< level 0) + (let ((count level) + (new-level type)) + (while (< count 0) + (setq new-level + (cdr (assq new-level texinfo-lowersections-alist))) + (setq count (1+ count))) + (kill-word 1) + (insert (symbol-name new-level)))))))))) + +(defvar texinfo-raisesections-alist + '((@chapter . @chapter) ; Cannot go higher + (@unnumbered . @unnumbered) + (@centerchap . @unnumbered) + + (@majorheading . @majorheading) + (@chapheading . @chapheading) + (@appendix . @appendix) + + (@section . @chapter) + (@unnumberedsec . @unnumbered) + (@heading . @chapheading) + (@appendixsec . @appendix) + + (@subsection . @section) + (@unnumberedsubsec . @unnumberedsec) + (@subheading . @heading) + (@appendixsubsec . @appendixsec) + + (@subsubsection . @subsection) + (@unnumberedsubsubsec . @unnumberedsubsec) + (@subsubheading . @subheading) + (@appendixsubsubsec . @appendixsubsec)) + "*An alist of next higher levels for chapters, sections. etc. +For example, section to chapter, subsection to section. +Used by `texinfo-raise-lower-sections'. +The keys specify types of section; the values correspond to the next +higher types.") + +(defvar texinfo-lowersections-alist + '((@chapter . @section) + (@unnumbered . @unnumberedsec) + (@centerchap . @unnumberedsec) + (@majorheading . @heading) + (@chapheading . @heading) + (@appendix . @appendixsec) + + (@section . @subsection) + (@unnumberedsec . @unnumberedsubsec) + (@heading . @subheading) + (@appendixsec . @appendixsubsec) + + (@subsection . @subsubsection) + (@unnumberedsubsec . @unnumberedsubsubsec) + (@subheading . @subsubheading) + (@appendixsubsec . @appendixsubsubsec) + + (@subsubsection . @subsubsection) ; Cannot go lower. + (@unnumberedsubsubsec . @unnumberedsubsubsec) + (@subsubheading . @subsubheading) + (@appendixsubsubsec . @appendixsubsubsec)) + "*An alist of next lower levels for chapters, sections. etc. +For example, chapter to section, section to subsection. +Used by `texinfo-raise-lower-sections'. +The keys specify types of section; the values correspond to the next +lower types.") + + +;;; Perform those texinfo-to-info conversions that apply to the whole input +;;; uniformly. + +(defun texinfo-format-scan () + (texinfo-format-convert (point-min) (point-max)) + ;; Scan for @-commands. + (goto-char (point-min)) + (while (search-forward "@" nil t) + ;; + ;; These are the single-character accent commands: @^ @` @' @" @= @~ + ;; In Info, they are simply quoted and the @ deleted. + ;; Other single-character commands: + ;; @* forces a line break, + ;; @- is a discretionary hyphenation point; does nothing in Info. + ;; @, @, @ each produce a single space, + ;; unless followed by a newline. + ;; + ;; Old version 2.34 expression: (looking-at "[@{}^'` *\"?!]") + (if (looking-at "[@{}^'`\"=~ \t\n*?!-]") + ;; @*, causes a line break. + (cond + ;; @*, a line break + ((= (following-char) ?*) + ;; remove command + (delete-region (1- (point)) (1+ (point))) + ;; insert return if not at end of line; + ;; else line is already broken. + (if (not (= (following-char) ?\n)) + (insert ?\n))) + ;; @-, deleted + ((= (following-char) ?-) + (delete-region (1- (point)) (1+ (point)))) + ;; @, @, @: produce a single space, + ;; unless followed by a newline. + ((= (following-char) ? ) + (delete-region (1- (point)) (1+ (point))) + ;; insert single space if not at end of line; + ;; else line is already broken. + (if (not (= (following-char) ?\n)) + (insert ? ))) + ((= (following-char) ?\t) + (delete-region (1- (point)) (1+ (point))) + ;; insert single space if not at end of line; + ;; else line is already broken. + (if (not (= (following-char) ?\n)) + (insert ? ))) + ;; following char is a carriage return + ((= (following-char) ? +) + ;; remove command + (delete-region (1- (point)) (1+ (point))) + ;; insert single space if not at end of line; + ;; else line is already broken. + (if (not (= (following-char) ?\n)) + (insert ? ))) + ;; Otherwise: the other characters are simply quoted. Delete the @. + (t + (delete-char -1) + (forward-char 1))) + ;; @ is followed by a command-word; find the end of the word. + (setq texinfo-command-start (1- (point))) + (if (= (char-syntax (following-char)) ?w) + (forward-word 1) + (forward-char 1)) + (setq texinfo-command-end (point)) + ;; Handle let aliasing + (setq texinfo-command-name + (let (trial + (cmdname + (buffer-substring + (1+ texinfo-command-start) texinfo-command-end))) + (while (setq trial (assoc cmdname texinfo-alias-list)) + (setq cmdname (cdr trial))) + (intern cmdname))) + ;; Call the handler for this command. + (let ((enclosure-type + (assoc + (symbol-name texinfo-command-name) + texinfo-enclosure-list))) + (if enclosure-type + (progn + (insert + (car (car (cdr enclosure-type))) + (texinfo-parse-arg-discard) + (car (cdr (car (cdr enclosure-type))))) + (goto-char texinfo-command-start)) + (let ((cmd (get texinfo-command-name 'texinfo-format))) + (if cmd (funcall cmd) (texinfo-unsupported))))))) + + (cond (texinfo-stack + (goto-char (nth 2 (car texinfo-stack))) + (error "Unterminated @%s" (car (car texinfo-stack)))))) + +(put 'begin 'texinfo-format 'texinfo-format-begin) +(defun texinfo-format-begin () + (texinfo-format-begin-end 'texinfo-format)) + +(put 'end 'texinfo-format 'texinfo-format-end) +(defun texinfo-format-end () + (texinfo-format-begin-end 'texinfo-end)) + +(defun texinfo-format-begin-end (prop) + (setq texinfo-command-name (intern (texinfo-parse-line-arg))) + (let ((cmd (get texinfo-command-name prop))) + (if cmd (funcall cmd) + (texinfo-unsupported)))) + +;;; Parsing functions + +(defun texinfo-parse-line-arg () + "Return argument of @-command as string. +Argument is separated from command either by a space or by a brace. +If a space, return rest of line, with beginning and ending white +space removed. If a brace, return string between braces. +Leave point after argument." + (goto-char texinfo-command-end) + (let ((start (point))) + (cond ((looking-at " ") + (skip-chars-forward " ") + (setq start (point)) + (end-of-line) + (skip-chars-backward " ") + (delete-region (point) (progn (end-of-line) (point))) + (setq texinfo-command-end (1+ (point)))) + ((looking-at "{") + (setq start (1+ (point))) + (forward-list 1) + (setq texinfo-command-end (point)) + (forward-char -1)) + (t + (error "Invalid texinfo command arg format"))) + (prog1 (buffer-substring start (point)) + (if (eolp) (forward-char 1))))) + +(defun texinfo-parse-expanded-arg () + (goto-char texinfo-command-end) + (let ((start (point)) + marker) + (cond ((looking-at " ") + (skip-chars-forward " ") + (setq start (point)) + (end-of-line) + (setq texinfo-command-end (1+ (point)))) + ((looking-at "{") + (setq start (1+ (point))) + (forward-list 1) + (setq texinfo-command-end (point)) + (forward-char -1)) + (t + (error "Invalid texinfo command arg format"))) + (setq marker (move-marker (make-marker) texinfo-command-end)) + (texinfo-format-expand-region start (point)) + (setq texinfo-command-end (marker-position marker)) + (move-marker marker nil) + (prog1 (buffer-substring start (point)) + (if (eolp) (forward-char 1))))) + +(defun texinfo-format-expand-region (start end) + (save-restriction + (narrow-to-region start end) + (let (texinfo-command-start + texinfo-command-end + texinfo-command-name + texinfo-stack) + (texinfo-format-scan)) + (goto-char (point-max)))) + +(defun texinfo-parse-arg-discard () + "Delete command and argument; return argument of command." + (prog1 (texinfo-parse-line-arg) + (texinfo-discard-command))) + +(defun texinfo-discard-command () + (delete-region texinfo-command-start texinfo-command-end)) + +(defun texinfo-optional-braces-discard () + "Discard braces following command, if any." + (goto-char texinfo-command-end) + (let ((start (point))) + (cond ((looking-at "[ \t]*\n")) ; do nothing + ((looking-at "{") ; remove braces, if any + (forward-list 1) + (setq texinfo-command-end (point))) + (t + (error + "Invalid `texinfo-optional-braces-discard' format \(need braces?\)"))) + (delete-region texinfo-command-start texinfo-command-end))) + +(defun texinfo-format-parse-line-args () + (let ((start (1- (point))) + next beg end + args) + (skip-chars-forward " ") + (while (not (eolp)) + (setq beg (point)) + (re-search-forward "[\n,]") + (setq next (point)) + (if (bolp) (setq next (1- next))) + (forward-char -1) + (skip-chars-backward " ") + (setq end (point)) + (setq args (cons (if (> end beg) (buffer-substring beg end)) + args)) + (goto-char next) + (skip-chars-forward " ")) + (if (eolp) (forward-char 1)) + (setq texinfo-command-end (point)) + (nreverse args))) + +(defun texinfo-format-parse-args () + (let ((start (1- (point))) + next beg end + args) + (search-forward "{") + (save-excursion + (texinfo-format-expand-region + (point) + (save-excursion (up-list 1) (1- (point))))) + ;; The following does not handle cross references of the form: + ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the + ;; re-search-forward finds the first right brace after the second + ;; comma. + (while (/= (preceding-char) ?\}) + (skip-chars-forward " \t\n") + (setq beg (point)) + (re-search-forward "[},]") + (setq next (point)) + (forward-char -1) + (skip-chars-backward " \t\n") + (setq end (point)) + (cond ((< beg end) + (goto-char beg) + (while (search-forward "\n" end t) + (replace-match " ")))) + (setq args (cons (if (> end beg) (buffer-substring beg end)) + args)) + (goto-char next)) + (if (eolp) (forward-char 1)) + (setq texinfo-command-end (point)) + (nreverse args))) + +(defun texinfo-format-parse-defun-args () + (goto-char texinfo-command-end) + (let ((start (point))) + (end-of-line) + (setq texinfo-command-end (1+ (point))) + (let ((marker (move-marker (make-marker) texinfo-command-end))) + (texinfo-format-expand-region start (point)) + (setq texinfo-command-end (marker-position marker)) + (move-marker marker nil)) + (goto-char start) + (let ((args '()) + beg end) + (skip-chars-forward " ") + (while (not (eolp)) + (cond ((looking-at "{") + (setq beg (1+ (point))) + (forward-list 1) + (setq end (1- (point)))) + (t + (setq beg (point)) + (re-search-forward "[\n ]") + (forward-char -1) + (setq end (point)))) + (setq args (cons (buffer-substring beg end) args)) + (skip-chars-forward " ")) + (forward-char 1) + (nreverse args)))) + +(defun texinfo-discard-line () + (goto-char texinfo-command-end) + (skip-chars-forward " \t") + (or (eolp) + (error "Extraneous text at end of command line.")) + (goto-char texinfo-command-start) + (or (bolp) + (error "Extraneous text at beginning of command line.")) + (delete-region (point) (progn (forward-line 1) (point)))) + +(defun texinfo-discard-line-with-args () + (goto-char texinfo-command-start) + (delete-region (point) (progn (forward-line 1) (point)))) + + +;;; @setfilename + +;; Only `texinfo-format-buffer' handles @setfilename with this +;; definition; `texinfo-format-region' handles @setfilename, if any, +;; specially. +(put 'setfilename 'texinfo-format 'texinfo-format-setfilename) +(defun texinfo-format-setfilename () + (let ((arg (texinfo-parse-arg-discard))) + (message "Formatting Info file: %s" arg) + (setq texinfo-format-filename + (file-name-nondirectory (expand-file-name arg))) + (insert "Info file: " + texinfo-format-filename ", -*-Text-*-\n" + ;; Date string removed so that regression testing is easier. + ;; "produced on " + ;; (substring (current-time-string) 8 10) " " + ;; (substring (current-time-string) 4 7) " " + ;; (substring (current-time-string) -4) " " + "produced by `texinfo-format-buffer'\n" + "from file" + (if (buffer-file-name input-buffer) + (concat " `" + (file-name-sans-versions + (file-name-nondirectory + (buffer-file-name input-buffer))) + "'") + (concat "buffer `" (buffer-name input-buffer) "'")) + "\nusing `texinfmt.el' version " + texinfmt-version + ".\n\n"))) + +;;; @node, @menu, @detailmenu + +(put 'node 'texinfo-format 'texinfo-format-node) +(put 'nwnode 'texinfo-format 'texinfo-format-node) +(defun texinfo-format-node () + (let* ((args (texinfo-format-parse-line-args)) + (name (nth 0 args)) + (next (nth 1 args)) + (prev (nth 2 args)) + (up (nth 3 args))) + (texinfo-discard-command) + (setq texinfo-last-node name) + (let ((tem (downcase name))) + (if (assoc tem texinfo-node-names) + (error "Duplicate node name: %s" name) + (setq texinfo-node-names (cons (list tem) texinfo-node-names)))) + (setq texinfo-footnote-number 0) + ;; insert "\n\^_" unconditionally since this is what info is looking for + (insert "\n\^_\nFile: " texinfo-format-filename + ", Node: " name) + (if next + (insert ", Next: " next)) + (if prev + (insert ", Prev: " prev)) + (if up + (insert ", Up: " up)) + (insert ?\n) + (setq texinfo-last-node-pos (point)))) + +(put 'menu 'texinfo-format 'texinfo-format-menu) +(defun texinfo-format-menu () + (texinfo-discard-line) + (insert "* Menu:\n\n")) + +(put 'menu 'texinfo-end 'texinfo-discard-command) + +;; The @detailmenu should be removed eventually. + +;; According to Karl Berry, 31 August 1996: +;; +;; You don't like, I don't like it. I agree, it would be better just to +;; fix the bug [in `makeinfo']. .. At this point, since inserting those +;; two commands in the Elisp fn is trivial, I don't especially want to +;; expend more effort... +;; +;; I added a couple sentences of documentation to the manual (putting the +;; blame on makeinfo where it belongs :-(). + +(put 'detailmenu 'texinfo-format 'texinfo-discard-line) +(put 'detailmenu 'texinfo-end 'texinfo-discard-command) + +;; (Also see `texnfo-upd.el') + + +;;; Cross references + +;; @xref {NODE, FNAME, NAME, FILE, DOCUMENT} +;; -> *Note FNAME: (FILE)NODE +;; If FILE is missing, +;; *Note FNAME: NODE +;; If FNAME is empty and NAME is present +;; *Note NAME: Node +;; If both NAME and FNAME are missing +;; *Note NODE:: +;; texinfo ignores the DOCUMENT argument. +;; -> See section [NAME, else NODE], page +;; If FILE is specified, (FILE)NODE is used for xrefs. +;; If fifth argument DOCUMENT is specified, produces +;; See section [NAME, else NODE], page +;; of DOCUMENT + +;; @ref a reference that does not put `See' or `see' in +;; the hardcopy and is the same as @xref in Info +(put 'ref 'texinfo-format 'texinfo-format-xref) + +(put 'xref 'texinfo-format 'texinfo-format-xref) +(defun texinfo-format-xref () + (let ((args (texinfo-format-parse-args))) + (texinfo-discard-command) + (insert "*Note ") + (let ((fname (or (nth 1 args) (nth 2 args)))) + (if (null (or fname (nth 3 args))) + (insert (car args) "::") + (insert (or fname (car args)) ": ") + (if (nth 3 args) + (insert "(" (nth 3 args) ")")) + (insert (car args)))))) + +(put 'pxref 'texinfo-format 'texinfo-format-pxref) +(defun texinfo-format-pxref () + (texinfo-format-xref) + (or (save-excursion + (forward-char -2) + (looking-at "::")) + (insert "."))) + +;; @inforef{NODE, FNAME, FILE} +;; Like @xref{NODE, FNAME,,FILE} in texinfo. +;; In Tex, generates "See Info file FILE, node NODE" +(put 'inforef 'texinfo-format 'texinfo-format-inforef) +(defun texinfo-format-inforef () + (let ((args (texinfo-format-parse-args))) + (texinfo-discard-command) + (if (nth 1 args) + (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args)) + (insert "*Note " "(" (nth 2 args) ")" (car args) "::")))) + + +;;; Section headings + +(put 'majorheading 'texinfo-format 'texinfo-format-chapter) +(put 'chapheading 'texinfo-format 'texinfo-format-chapter) +(put 'ichapter 'texinfo-format 'texinfo-format-chapter) +(put 'chapter 'texinfo-format 'texinfo-format-chapter) +(put 'iappendix 'texinfo-format 'texinfo-format-chapter) +(put 'appendix 'texinfo-format 'texinfo-format-chapter) +(put 'iunnumbered 'texinfo-format 'texinfo-format-chapter) +(put 'top 'texinfo-format 'texinfo-format-chapter) +(put 'unnumbered 'texinfo-format 'texinfo-format-chapter) +(put 'centerchap 'texinfo-format 'texinfo-format-chapter) +(defun texinfo-format-chapter () + (texinfo-format-chapter-1 ?*)) + +(put 'heading 'texinfo-format 'texinfo-format-section) +(put 'isection 'texinfo-format 'texinfo-format-section) +(put 'section 'texinfo-format 'texinfo-format-section) +(put 'iappendixsection 'texinfo-format 'texinfo-format-section) +(put 'appendixsection 'texinfo-format 'texinfo-format-section) +(put 'iappendixsec 'texinfo-format 'texinfo-format-section) +(put 'appendixsec 'texinfo-format 'texinfo-format-section) +(put 'iunnumberedsec 'texinfo-format 'texinfo-format-section) +(put 'unnumberedsec 'texinfo-format 'texinfo-format-section) +(defun texinfo-format-section () + (texinfo-format-chapter-1 ?=)) + +(put 'subheading 'texinfo-format 'texinfo-format-subsection) +(put 'isubsection 'texinfo-format 'texinfo-format-subsection) +(put 'subsection 'texinfo-format 'texinfo-format-subsection) +(put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection) +(put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection) +(put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection) +(put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection) +(defun texinfo-format-subsection () + (texinfo-format-chapter-1 ?-)) + +(put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection) +(put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection) +(put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection) +(put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection) +(put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection) +(put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection) +(put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection) +(defun texinfo-format-subsubsection () + (texinfo-format-chapter-1 ?.)) + +(defun texinfo-format-chapter-1 (belowchar) + (let ((arg (texinfo-parse-arg-discard))) + (message "Formatting: %s ... " arg) ; So we can see where we are. + (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n) + (forward-line -2))) + +(put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad) +(defun texinfo-format-sectionpad () + (let ((str (texinfo-parse-arg-discard))) + (forward-char -1) + (let ((column (current-column))) + (forward-char 1) + (while (> column 0) + (insert str) + (setq column (1- column)))) + (insert ?\n))) + + +;;; Space controlling commands: @. and @:, and the soft hyphen. + +(put '\. 'texinfo-format 'texinfo-format-\.) +(defun texinfo-format-\. () + (texinfo-discard-command) + (insert ".")) + +(put '\: 'texinfo-format 'texinfo-format-\:) +(defun texinfo-format-\: () + (texinfo-discard-command)) + +(put '\- 'texinfo-format 'texinfo-format-soft-hyphen) +(defun texinfo-format-soft-hyphen () + (texinfo-discard-command)) + + +;;; @center, @sp, and @br + +(put 'center 'texinfo-format 'texinfo-format-center) +(defun texinfo-format-center () + (let ((arg (texinfo-parse-expanded-arg))) + (texinfo-discard-command) + (insert arg) + (insert ?\n) + (save-restriction + (goto-char (1- (point))) + (let ((indent-tabs-mode nil)) + (center-line))))) + +(put 'sp 'texinfo-format 'texinfo-format-sp) +(defun texinfo-format-sp () + (let* ((arg (texinfo-parse-arg-discard)) + (num (read arg))) + (insert-char ?\n num))) + +(put 'br 'texinfo-format 'texinfo-format-paragraph-break) +(defun texinfo-format-paragraph-break () + "Force a paragraph break. +If used within a line, follow `@br' with braces." + (texinfo-optional-braces-discard) + ;; insert one return if at end of line; + ;; else insert two returns, to generate a blank line. + (if (= (following-char) ?\n) + (insert ?\n) + (insert-char ?\n 2))) + + +;;; @footnote and @footnotestyle + +;; In Texinfo, footnotes are created with the `@footnote' command. +;; This command is followed immediately by a left brace, then by the text of +;; the footnote, and then by a terminating right brace. The +;; template for a footnote is: +;; +;; @footnote{TEXT} +;; +;; Info has two footnote styles: +;; +;; * In the End of node style, all the footnotes for a single node +;; are placed at the end of that node. The footnotes are +;; separated from the rest of the node by a line of dashes with +;; the word `Footnotes' within it. +;; +;; * In the Separate node style, all the footnotes for a single node +;; are placed in an automatically constructed node of their own. + +;; Footnote style is specified by the @footnotestyle command, either +;; @footnotestyle separate +;; or +;; @footnotestyle end +;; +;; The default is separate + +(defvar texinfo-footnote-style "separate" + "Footnote style, either separate or end.") + +(put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle) +(defun texinfo-footnotestyle () + "Specify whether footnotes are at end of node or in separate nodes. +Argument is either end or separate." + (setq texinfo-footnote-style (texinfo-parse-arg-discard))) + +(defvar texinfo-footnote-number) + +(put 'footnote 'texinfo-format 'texinfo-format-footnote) +(defun texinfo-format-footnote () + "Format a footnote in either end of node or separate node style. +The texinfo-footnote-style variable controls which style is used." + (setq texinfo-footnote-number (1+ texinfo-footnote-number)) + (cond ((string= texinfo-footnote-style "end") + (texinfo-format-end-node)) + ((string= texinfo-footnote-style "separate") + (texinfo-format-separate-node)))) + +(defun texinfo-format-separate-node () + "Format footnote in Separate node style, with notes in own node. +The node is constructed automatically." + (let* (start + (arg (texinfo-parse-line-arg)) + (node-name-beginning + (save-excursion + (re-search-backward + "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:") + (match-end 0))) + (node-name + (save-excursion + (buffer-substring + (progn (goto-char node-name-beginning) ; skip over node command + (skip-chars-forward " \t") ; and over spaces + (point)) + (if (search-forward + "," + (save-excursion (end-of-line) (point)) t) ; bound search + (1- (point)) + (end-of-line) (point)))))) + (texinfo-discard-command) ; remove or insert whitespace, as needed + (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) + (point)) + (insert (format " (%d) (*Note %s-Footnotes::)" + texinfo-footnote-number node-name)) + (fill-paragraph nil) + (save-excursion + (if (re-search-forward "^@node" nil 'move) + (forward-line -1)) + + ;; two cases: for the first footnote, we must insert a node header; + ;; for the second and subsequent footnotes, we need only insert + ;; the text of the footnote. + + (if (save-excursion + (re-search-backward + (concat node-name "-Footnotes, Up: ") + node-name-beginning + t)) + (progn ; already at least one footnote + (setq start (point)) + (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) + (fill-region start (point))) + ;; else not yet a footnote + (insert "\n\^_\nFile: " texinfo-format-filename + " Node: " node-name "-Footnotes, Up: " node-name "\n") + (setq start (point)) + (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) + (fill-region start (point)))))) + +(defun texinfo-format-end-node () + "Format footnote in the End of node style, with notes at end of node." + (let (start + (arg (texinfo-parse-line-arg))) + (texinfo-discard-command) ; remove or insert whitespace, as needed + (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) + (point)) + (insert (format " (%d) " texinfo-footnote-number)) + (fill-paragraph nil) + (save-excursion + (if (search-forward "\n--------- Footnotes ---------\n" nil t) + (progn ; already have footnote, put new one before end of node + (if (re-search-forward "^@node" nil 'move) + (forward-line -1)) + (setq start (point)) + (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) + (fill-region start (point))) + ;; else no prior footnote + (if (re-search-forward "^@node" nil 'move) + (forward-line -1)) + (insert "\n--------- Footnotes ---------\n") + (setq start (point)) + (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)))))) + + +;;; @itemize, @enumerate, and similar commands + +;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack. +;; @enumerate pushes (enumerate 0 STARTPOS). +;; @item dispatches to the texinfo-item prop of the first elt of the list. +;; For itemize, this puts in and rescans the COMMANDS. +;; For enumerate, this increments the number and puts it in. +;; In either case, it puts a Backspace at the front of the line +;; which marks it not to be indented later. +;; All other lines get indented by 5 when the @end is reached. + +(defvar texinfo-stack-depth 0 + "Count of number of unpopped texinfo-push-stack calls. +Used by @refill indenting command to avoid indenting within lists, etc.") + +(defun texinfo-push-stack (check arg) + (setq texinfo-stack-depth (1+ texinfo-stack-depth)) + (setq texinfo-stack + (cons (list check arg texinfo-command-start) + texinfo-stack))) + +(defun texinfo-pop-stack (check) + (setq texinfo-stack-depth (1- texinfo-stack-depth)) + (if (null texinfo-stack) + (error "Unmatched @end %s" check)) + (if (not (eq (car (car texinfo-stack)) check)) + (error "@end %s matches @%s" + check (car (car texinfo-stack)))) + (prog1 (cdr (car texinfo-stack)) + (setq texinfo-stack (cdr texinfo-stack)))) + +(put 'itemize 'texinfo-format 'texinfo-itemize) +(defun texinfo-itemize () + (texinfo-push-stack + 'itemize + (progn (skip-chars-forward " \t") + (if (eolp) + "@bullet" + (texinfo-parse-line-arg)))) + (texinfo-discard-line-with-args) + (setq fill-column (- fill-column 5))) + +(put 'itemize 'texinfo-end 'texinfo-end-itemize) +(defun texinfo-end-itemize () + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((stacktop + (texinfo-pop-stack 'itemize))) + (texinfo-do-itemize (nth 1 stacktop)))) + +(put 'enumerate 'texinfo-format 'texinfo-enumerate) +(defun texinfo-enumerate () + (texinfo-push-stack + 'enumerate + (progn (skip-chars-forward " \t") + (if (eolp) + 1 + (read (current-buffer))))) + (if (and (symbolp (car (cdr (car texinfo-stack)))) + (> 1 (length (symbol-name (car (cdr (car texinfo-stack))))))) + (error + "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." )) + (texinfo-discard-line-with-args) + (setq fill-column (- fill-column 5))) + +(put 'enumerate 'texinfo-end 'texinfo-end-enumerate) +(defun texinfo-end-enumerate () + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((stacktop + (texinfo-pop-stack 'enumerate))) + (texinfo-do-itemize (nth 1 stacktop)))) + +;; @alphaenumerate never became a standard part of Texinfo +(put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate) +(defun texinfo-alphaenumerate () + (texinfo-push-stack 'alphaenumerate (1- ?a)) + (setq fill-column (- fill-column 5)) + (texinfo-discard-line)) + +(put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate) +(defun texinfo-end-alphaenumerate () + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((stacktop + (texinfo-pop-stack 'alphaenumerate))) + (texinfo-do-itemize (nth 1 stacktop)))) + +;; @capsenumerate never became a standard part of Texinfo +(put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate) +(defun texinfo-capsenumerate () + (texinfo-push-stack 'capsenumerate (1- ?A)) + (setq fill-column (- fill-column 5)) + (texinfo-discard-line)) + +(put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate) +(defun texinfo-end-capsenumerate () + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((stacktop + (texinfo-pop-stack 'capsenumerate))) + (texinfo-do-itemize (nth 1 stacktop)))) + +;; At the @end, indent all the lines within the construct +;; except those marked with backspace. FROM says where +;; construct started. +(defun texinfo-do-itemize (from) + (save-excursion + (while (progn (forward-line -1) + (>= (point) from)) + (if (= (following-char) ?\b) + (save-excursion + (delete-char 1) + (end-of-line) + (delete-char 6)) + (if (not (looking-at "[ \t]*$")) + (save-excursion (insert " "))))))) + +(put 'item 'texinfo-format 'texinfo-item) +(put 'itemx 'texinfo-format 'texinfo-item) +(defun texinfo-item () + (funcall (get (car (car texinfo-stack)) 'texinfo-item))) + +(put 'itemize 'texinfo-item 'texinfo-itemize-item) +(defun texinfo-itemize-item () + ;; (texinfo-discard-line) ; Did not handle text on same line as @item. + (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point))) + (if (looking-at "[ \t]*[^ \t\n]+") + ;; Text on same line as @item command. + (insert "\b " (nth 1 (car texinfo-stack)) " \n") + ;; Else text on next line. + (insert "\b " (nth 1 (car texinfo-stack)) " ")) + (forward-line -1)) + +(put 'enumerate 'texinfo-item 'texinfo-enumerate-item) +(defun texinfo-enumerate-item () + (texinfo-discard-line) + (let (enumerating-symbol) + (cond ((integerp (car (cdr (car texinfo-stack)))) + (setq enumerating-symbol (car (cdr (car texinfo-stack)))) + (insert ?\b (format "%3d. " enumerating-symbol) ?\n) + (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol))) + ((symbolp (car (cdr (car texinfo-stack)))) + (setq enumerating-symbol + (symbol-name (car (cdr (car texinfo-stack))))) + (if (or (equal ?\[ (string-to-char enumerating-symbol)) + (equal ?\{ (string-to-char enumerating-symbol))) + (error + "Too many items in enumerated list; alphabet ends at Z.")) + (insert ?\b (format "%3s. " enumerating-symbol) ?\n) + (setcar (cdr (car texinfo-stack)) + (make-symbol + (char-to-string + (1+ + (string-to-char enumerating-symbol)))))) + (t + (error + "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." ))) + (forward-line -1))) + +(put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item) +(defun texinfo-alphaenumerate-item () + (texinfo-discard-line) + (let ((next (1+ (car (cdr (car texinfo-stack)))))) + (if (> next ?z) + (error "More than 26 items in @alphaenumerate; get a bigger alphabet.")) + (setcar (cdr (car texinfo-stack)) next) + (insert "\b " next ". \n")) + (forward-line -1)) + +(put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item) +(defun texinfo-capsenumerate-item () + (texinfo-discard-line) + (let ((next (1+ (car (cdr (car texinfo-stack)))))) + (if (> next ?Z) + (error "More than 26 items in @capsenumerate; get a bigger alphabet.")) + (setcar (cdr (car texinfo-stack)) next) + (insert "\b " next ". \n")) + (forward-line -1)) + + +;;; @table + +;; The `@table' command produces two-column tables. + +(put 'table 'texinfo-format 'texinfo-table) +(defun texinfo-table () + (texinfo-push-stack + 'table + (progn (skip-chars-forward " \t") + (if (eolp) + "@asis" + (texinfo-parse-line-arg)))) + (texinfo-discard-line-with-args) + (setq fill-column (- fill-column 5))) + +(put 'table 'texinfo-item 'texinfo-table-item) +(defun texinfo-table-item () + (let ((arg (texinfo-parse-arg-discard)) + (itemfont (car (cdr (car texinfo-stack))))) + (insert ?\b itemfont ?\{ arg "}\n \n")) + (forward-line -2)) + +(put 'table 'texinfo-end 'texinfo-end-table) +(defun texinfo-end-table () + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((stacktop + (texinfo-pop-stack 'table))) + (texinfo-do-itemize (nth 1 stacktop)))) + +;; @description appears to be an undocumented variant on @table that +;; does not require an arg. It fails in texinfo.tex 2.58 and is not +;; part of makeinfo.c The command appears to be a relic of the past. +(put 'description 'texinfo-end 'texinfo-end-table) +(put 'description 'texinfo-format 'texinfo-description) +(defun texinfo-description () + (texinfo-push-stack 'table "@asis") + (setq fill-column (- fill-column 5)) + (texinfo-discard-line)) + + +;;; @ftable, @vtable + +;; The `@ftable' and `@vtable' commands are like the `@table' command +;; but they also insert each entry in the first column of the table +;; into the function or variable index. + +;; Handle the @ftable and @vtable commands: + +(put 'ftable 'texinfo-format 'texinfo-ftable) +(put 'vtable 'texinfo-format 'texinfo-vtable) + +(defun texinfo-ftable () (texinfo-indextable 'ftable)) +(defun texinfo-vtable () (texinfo-indextable 'vtable)) + +(defun texinfo-indextable (table-type) + (texinfo-push-stack table-type (texinfo-parse-arg-discard)) + (setq fill-column (- fill-column 5))) + +;; Handle the @item commands within ftable and vtable: + +(put 'ftable 'texinfo-item 'texinfo-ftable-item) +(put 'vtable 'texinfo-item 'texinfo-vtable-item) + +(defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex)) +(defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex)) + +(defun texinfo-indextable-item (index-type) + (let ((item (texinfo-parse-arg-discard)) + (itemfont (car (cdr (car texinfo-stack)))) + (indexvar index-type)) + (insert ?\b itemfont ?\{ item "}\n \n") + (set indexvar + (cons + (list item texinfo-last-node) + (symbol-value indexvar))) + (forward-line -2))) + +;; Handle @end ftable, @end vtable + +(put 'ftable 'texinfo-end 'texinfo-end-ftable) +(put 'vtable 'texinfo-end 'texinfo-end-vtable) + +(defun texinfo-end-ftable () (texinfo-end-indextable 'ftable)) +(defun texinfo-end-vtable () (texinfo-end-indextable 'vtable)) + +(defun texinfo-end-indextable (table-type) + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((stacktop + (texinfo-pop-stack table-type))) + (texinfo-do-itemize (nth 1 stacktop)))) + + +;;; @multitable ... @end multitable + +;; Produce a multi-column table, with as many columns as desired. +;; +;; A multi-column table has this template: +;; +;; @multitable {A1} {A2} {A3} +;; @item A1 @tab A2 @tab A3 +;; @item B1 @tab B2 @tab B3 +;; @item C1 @tab C2 @tab C3 +;; @end multitable +;; +;; where the width of the text in brackets specifies the width of the +;; respective column. +;; +;; Or else: +;; +;; @multitable @columnfractions .25 .3 .45 +;; @item A1 @tab A2 @tab A3 +;; @item B1 @tab B2 @tab B3 +;; @end multitable +;; +;; where the fractions specify the width of each column as a percent +;; of the current width of the text (i.e., of the fill-column). +;; +;; Long lines of text are filled within columns. +;; +;; Using the Emacs Lisp formatter, texinfmt.el, +;; the whitespace between columns can be increased by setting +;; `extra-inter-column-width' to a value greater than 0. By default, +;; there is at least one blank space between columns. +;; +;; The Emacs Lisp formatter, texinfmt.el, ignores the following four +;; commands that are defined in texinfo.tex for printed output. +;; +;; @multitableparskip, +;; @multitableparindent, +;; @multitablecolmargin, +;; @multitablelinespace. + +;; How @multitable works. +;; ===================== +;; +;; `texinfo-multitable' reads the @multitable line and determines from it +;; how wide each column should be. +;; +;; Also, it pushes this information, along with an identifying symbol, +;; onto the `texinfo-stack'. At the @end multitable command, the stack +;; is checked for its matching @multitable command, and then popped, or +;; else an error is signaled. Also, this command pushes the location of +;; the start of the table onto the stack. +;; +;; `texinfo-end-multitable' checks the `texinfo-stack' that the @end +;; multitable truly is ending a corresponding beginning, and if it is, +;; pops the stack. +;; +;; `texinfo-multitable-widths' is called by `texinfo-multitable'. +;; The function returns a list of the widths of each column in a +;; multi-column table, based on the information supplied by the arguments +;; to the @multitable command (by arguments, I mean the text on the rest +;; of the @multitable line, not the remainder of the multi-column table +;; environment). +;; +;; `texinfo-multitable-item' formats a row within a multicolumn table. +;; This command is executed when texinfmt sees @item inside @multitable. +;; Cells in row are separated by `@tab's. Widths of cells are specified +;; by the arguments in the @multitable line. Cells are filled. All cells +;; are made to be the same height by padding their bottoms, as needed, +;; with blanks. +;; +;; `texinfo-multitable-extract-row' is called by `texinfo-multitable-item'. +;; This function returns the text in a multitable row, as a string. +;; The start of a row is marked by an @item and the end of row is the +;; beginning of next @item or beginning of the @end multitable line. +;; Cells within a row are separated by @tab. +;; +;; Note that @tab, the cell separators, are not treated as independent +;; Texinfo commands. + +(defvar extra-inter-column-width 0 +"*Insert NUMBER of additional columns of whitespace between entries of +a multi-column table.") + +(defvar multitable-temp-buffer-name "*multitable-temporary-buffer*") +(defvar multitable-temp-rectangle-name "texinfo-multitable-temp-") + +;; These commands are defined in texinfo.tex for printed output. +(put 'multitableparskip 'texinfo-format 'texinfo-discard-line-with-args) +(put 'multitableparindent 'texinfo-format 'texinfo-discard-line-with-args) +(put 'multitablecolmargin 'texinfo-format 'texinfo-discard-line-with-args) +(put 'multitablelinespace 'texinfo-format 'texinfo-discard-line-with-args) + +(put 'multitable 'texinfo-format 'texinfo-multitable) +(defun texinfo-multitable () + "Produce multi-column tables. + +A multi-column table has this template: + + @multitable {A1} {A2} {A3} + @item A1 @tab A2 @tab A3 + @item B1 @tab B2 @tab B3 + @item C1 @tab C2 @tab C3 + @end multitable + +where the width of the text in brackets specifies the width of the +respective column. + +Or else: + + @multitable @columnfractions .25 .3 .45 + @item A1 @tab A2 @tab A3 + @item B1 @tab B2 @tab B3 + @end multitable + +where the fractions specify the width of each column as a percent +of the current width of the text (i.e., of the fill-column). + +Long lines of text are filled within columns. + +Using the Emacs Lisp formatter, texinfmt.el, +the whitespace between columns can be increased by setting +`extra-inter-column-width' to a value greater than 0. By default, +there is at least one blank space between columns. + +The Emacs Lisp formatter, texinfmt.el, ignores the following four +commands that are defined in texinfo.tex for printed output. + + @multitableparskip, + @multitableparindent, + @multitablecolmargin, + @multitablelinespace." + +;; This function pushes information onto the `texinfo-stack'. +;; A stack element consists of: +;; - type-of-command, i.e., multitable +;; - the information about column widths, and +;; - the position of texinfo-command-start. +;; e.g., ('multitable (1 2 3 4) 123) +;; The command line is then deleted. + (texinfo-push-stack + 'multitable + ;; push width information on stack + (texinfo-multitable-widths)) + (texinfo-discard-line-with-args)) + +(put 'multitable 'texinfo-end 'texinfo-end-multitable) +(defun texinfo-end-multitable () + "Discard the @end multitable line and pop the stack of multitable." + (texinfo-discard-command) + (texinfo-pop-stack 'multitable)) + +(defun texinfo-multitable-widths () + "Return list of widths of each column in a multi-column table." + (let (texinfo-multitable-width-list) + ;; Fractions format: + ;; @multitable @columnfractions .25 .3 .45 + ;; + ;; Template format: + ;; @multitable {Column 1 template} {Column 2} {Column 3 example} + ;; Place point before first argument + (skip-chars-forward " \t") + (cond + ;; Check for common misspelling + ((looking-at "@columnfraction ") + (error "In @multitable, @columnfractions misspelled")) + ;; Case 1: @columnfractions .25 .3 .45 + ((looking-at "@columnfractions") + (forward-word 1) + (while (not (eolp)) + (setq texinfo-multitable-width-list + (cons + (truncate + (1- + (* fill-column (read (get-buffer (current-buffer)))))) + texinfo-multitable-width-list)))) + ;; + ;; Case 2: {Column 1 template} {Column 2} {Column 3 example} + ((looking-at "{") + (let ((start-of-templates (point))) + (while (not (eolp)) + (skip-chars-forward " \t") + (let* ((start-of-template (1+ (point))) + (end-of-template + ;; forward-sexp works with braces in Texinfo mode + (progn (forward-sexp 1) (1- (point))))) + (setq texinfo-multitable-width-list + (cons (- end-of-template start-of-template) + texinfo-multitable-width-list)) + ;; Remove carriage return from within a template, if any. + ;; This helps those those who want to use more than + ;; one line's worth of words in @multitable line. + (narrow-to-region start-of-template end-of-template) + (goto-char (point-min)) + (while (search-forward " +" nil t) + (delete-char -1)) + (goto-char (point-max)) + (widen) + (forward-char 1))))) + ;; + ;; Case 3: Trouble + (t + (error + "You probably need to specify column widths for @multitable correctly."))) + ;; Check whether columns fit on page. + (let ((desired-columns + (+ + ;; between column spaces + (length texinfo-multitable-width-list) + ;; additional between column spaces, if any + extra-inter-column-width + ;; sum of spaces for each entry + (apply '+ texinfo-multitable-width-list)))) + (if (> desired-columns fill-column) + (error + (format + "Multi-column table width, %d chars, is greater than page width, %d chars." + desired-columns fill-column)))) + texinfo-multitable-width-list)) + +;; @item A1 @tab A2 @tab A3 +(defun texinfo-multitable-extract-row () + "Return multitable row, as a string. +End of row is beginning of next @item or beginning of @end. +Cells within rows are separated by @tab." + (skip-chars-forward " \t") + (let* ((start (point)) + (end (progn + (re-search-forward "@item\\|@end") + (match-beginning 0))) + (row (progn (goto-char end) + (skip-chars-backward " ") + ;; remove whitespace at end of argument + (delete-region (point) end) + (buffer-substring start (point))))) + (delete-region texinfo-command-start end) + row)) + +(put 'multitable 'texinfo-item 'texinfo-multitable-item) +(defun texinfo-multitable-item () + "Format a row within a multicolumn table. +Cells in row are separated by @tab. +Widths of cells are specified by the arguments in the @multitable line. +All cells are made to be the same height. +This command is executed when texinfmt sees @item inside @multitable." + (let ((original-buffer (current-buffer)) + (table-widths (reverse (car (cdr (car texinfo-stack))))) + (existing-fill-column fill-column) + start + end + (table-column 0) + (table-entry-height 0) + ;; unformatted row looks like: A1 @tab A2 @tab A3 + ;; extract-row command deletes the source line in the table. + (unformated-row (texinfo-multitable-extract-row))) + ;; Use a temporary buffer + (set-buffer (get-buffer-create multitable-temp-buffer-name)) + (delete-region (point-min) (point-max)) + (insert unformated-row) + (goto-char (point-min)) +;; 1. Check for correct number of @tab in line. + (let ((tab-number 1)) ; one @tab between two columns + (while (search-forward "@tab" nil t) + (setq tab-number (1+ tab-number))) + (if (/= tab-number (length table-widths)) + (error "Wrong number of @tab's in a @multitable row."))) + (goto-char (point-min)) +;; 2. Format each cell, and copy to a rectangle + ;; buffer looks like this: A1 @tab A2 @tab A3 + ;; Cell #1: format up to @tab + ;; Cell #2: format up to @tab + ;; Cell #3: format up to eob + (while (not (eobp)) + (setq start (point)) + (setq end (save-excursion + (if (search-forward "@tab" nil 'move) + ;; Delete the @tab command, including the @-sign + (delete-region + (point) + (progn (forward-word -1) (1- (point))))) + (point))) + ;; Set fill-column *wider* than needed to produce inter-column space + (setq fill-column (+ 1 + extra-inter-column-width + (nth table-column table-widths))) + (narrow-to-region start end) + ;; Remove whitespace before and after entry. + (skip-chars-forward " ") + (delete-region (point) (save-excursion (beginning-of-line) (point))) + (goto-char (point-max)) + (skip-chars-backward " ") + (delete-region (point) (save-excursion (end-of-line) (point))) + ;; Temorarily set texinfo-stack to nil so texinfo-format-scan + ;; does not see an unterminated @multitable. + (let (texinfo-stack) ; nil + (texinfo-format-scan)) + (let (fill-prefix) ; no fill prefix + (fill-region (point-min) (point-max))) + (setq table-entry-height + (max table-entry-height (count-lines (point-min) (point-max)))) +;; 3. Move point to end of bottom line, and pad that line to fill column. + (goto-char (point-min)) + (forward-line (1- table-entry-height)) + (let* ((beg (point)) ; beginning of line + ;; add one more space for inter-column spacing + (needed-whitespace + (1+ + (- fill-column + (- + (progn (end-of-line) (point)) ; end of existing line + beg))))) + (insert (make-string + (if (> needed-whitespace 0) needed-whitespace 1) + ? ))) + ;; now, put formatted cell into a rectangle + (set (intern (concat multitable-temp-rectangle-name + (int-to-string table-column))) + (extract-rectangle (point-min) (point))) + (delete-region (point-min) (point)) + (goto-char (point-max)) + (setq table-column (1+ table-column)) + (widen)) +;; 4. Add extra lines to rectangles so all are of same height + (let ((total-number-of-columns table-column) + (column-number 0) + here) + (while (> table-column 0) + (let ((this-rectangle (int-to-string table-column))) + (while (< (length this-rectangle) table-entry-height) + (setq this-rectangle (append this-rectangle '(""))))) + (setq table-column (1- table-column))) +;; 5. Insert formatted rectangles in original buffer + (switch-to-buffer original-buffer) + (open-line table-entry-height) + (while (< column-number total-number-of-columns) + (setq here (point)) + (insert-rectangle + (eval (intern + (concat multitable-temp-rectangle-name + (int-to-string column-number))))) + (goto-char here) + (end-of-line) + (setq column-number (1+ column-number)))) + (kill-buffer multitable-temp-buffer-name) + (setq fill-column existing-fill-column))) + + +;;; @ifinfo, @iftex, @tex, @ifhtml, @html + +(put 'ifinfo 'texinfo-format 'texinfo-discard-line) +(put 'ifinfo 'texinfo-end 'texinfo-discard-command) + +(put 'iftex 'texinfo-format 'texinfo-format-iftex) +(defun texinfo-format-iftex () + (delete-region texinfo-command-start + (progn (re-search-forward "@end iftex[ \t]*\n") + (point)))) + +(put 'ifhtml 'texinfo-format 'texinfo-format-ifhtml) +(defun texinfo-format-ifhtml () + (delete-region texinfo-command-start + (progn (re-search-forward "@end ifhtml[ \t]*\n") + (point)))) + +(put 'tex 'texinfo-format 'texinfo-format-tex) +(defun texinfo-format-tex () + (delete-region texinfo-command-start + (progn (re-search-forward "@end tex[ \t]*\n") + (point)))) + +(put 'html 'texinfo-format 'texinfo-format-html) +(defun texinfo-format-html () + (delete-region texinfo-command-start + (progn (re-search-forward "@end html[ \t]*\n") + (point)))) + + +;;; @titlepage + +(put 'titlepage 'texinfo-format 'texinfo-format-titlepage) +(defun texinfo-format-titlepage () + (delete-region texinfo-command-start + (progn (re-search-forward "@end titlepage[ \t]*\n") + (point)))) + +(put 'endtitlepage 'texinfo-format 'texinfo-discard-line) + +;; @titlespec an alternative titling command; ignored by Info + +(put 'titlespec 'texinfo-format 'texinfo-format-titlespec) +(defun texinfo-format-titlespec () + (delete-region texinfo-command-start + (progn (re-search-forward "@end titlespec[ \t]*\n") + (point)))) + +(put 'endtitlespec 'texinfo-format 'texinfo-discard-line) + + +;;; @today + +(put 'today 'texinfo-format 'texinfo-format-today) + +;; Produces Day Month Year style of output. eg `1 Jan 1900' +;; The `@today{}' command requires a pair of braces, like `@dots{}'. +(defun texinfo-format-today () + (texinfo-parse-arg-discard) + (insert (format "%s %s %s" + (substring (current-time-string) 8 10) + (substring (current-time-string) 4 7) + (substring (current-time-string) -4)))) + + +;;; @ignore + +(put 'ignore 'texinfo-format 'texinfo-format-ignore) +(defun texinfo-format-ignore () + (delete-region texinfo-command-start + (progn (re-search-forward "@end ignore[ \t]*\n") + (point)))) + +(put 'endignore 'texinfo-format 'texinfo-discard-line) + + +;;; Define the Info enclosure command: @definfoenclose + +;; A `@definfoenclose' command may be used to define a highlighting +;; command for Info, but not for TeX. A command defined using +;; `@definfoenclose' marks text by enclosing it in strings that precede +;; and follow the text. +;; +;; Presumably, if you define a command with `@definfoenclose` for Info, +;; you will also define the same command in the TeX definitions file, +;; `texinfo.tex' in a manner appropriate for typesetting. +;; +;; Write a `@definfoenclose' command on a line and follow it with three +;; arguments separated by commas (commas are used as separators in an +;; `@node' line in the same way). The first argument to +;; `@definfoenclose' is the @-command name \(without the `@'\); the +;; second argument is the Info start delimiter string; and the third +;; argument is the Info end delimiter string. The latter two arguments +;; enclose the highlighted text in the Info file. A delimiter string +;; may contain spaces. Neither the start nor end delimiter is +;; required. However, if you do not provide a start delimiter, you +;; must follow the command name with two commas in a row; otherwise, +;; the Info formatting commands will misinterpret the end delimiter +;; string as a start delimiter string. +;; +;; If you do a @definfoenclose{} on the name of a pre-defined macro (such +;; as @emph{}, @strong{}, @tt{}, or @i{}) the enclosure definition will +;; override the built-in definition. +;; +;; An enclosure command defined this way takes one argument in braces. +;; +;; For example, you can write: +;; +;; @ifinfo +;; @definfoenclose phoo, //, \\ +;; @end ifinfo +;; +;; near the beginning of a Texinfo file at the beginning of the lines +;; to define `@phoo' as an Info formatting command that inserts `//' +;; before and `\\' after the argument to `@phoo'. You can then write +;; `@phoo{bar}' wherever you want `//bar\\' highlighted in Info. +;; +;; Also, for TeX formatting, you could write +;; +;; @iftex +;; @global@let@phoo=@i +;; @end iftex +;; +;; to define `@phoo' as a command that causes TeX to typeset +;; the argument to `@phoo' in italics. +;; +;; Note that each definition applies to its own formatter: one for TeX, +;; the other for texinfo-format-buffer or texinfo-format-region. +;; +;; Here is another example: write +;; +;; @definfoenclose headword, , : +;; +;; near the beginning of the file, to define `@headword' as an Info +;; formatting command that inserts nothing before and a colon after the +;; argument to `@headword'. + +(put 'definfoenclose 'texinfo-format 'texinfo-define-info-enclosure) +(defun texinfo-define-info-enclosure () + (let* ((args (texinfo-format-parse-line-args)) + (command-name (nth 0 args)) + (beginning-delimiter (or (nth 1 args) "")) + (end-delimiter (or (nth 2 args) ""))) + (texinfo-discard-command) + (setq texinfo-enclosure-list + (cons + (list command-name + (list + beginning-delimiter + end-delimiter)) + texinfo-enclosure-list)))) + + +;;; @var, @code and the like + +(put 'var 'texinfo-format 'texinfo-format-var) +;; @sc a small caps font for TeX; formatted as `var' in Info +(put 'sc 'texinfo-format 'texinfo-format-var) +(defun texinfo-format-var () + (insert (upcase (texinfo-parse-arg-discard))) + (goto-char texinfo-command-start)) + +(put 'url 'texinfo-format 'texinfo-format-code) +(put 'cite 'texinfo-format 'texinfo-format-code) +(put 'code 'texinfo-format 'texinfo-format-code) +(put 'file 'texinfo-format 'texinfo-format-code) +(put 'samp 'texinfo-format 'texinfo-format-code) +(defun texinfo-format-code () + (insert "`" (texinfo-parse-arg-discard) "'") + (goto-char texinfo-command-start)) + +(put 'emph 'texinfo-format 'texinfo-format-emph) +(put 'strong 'texinfo-format 'texinfo-format-emph) +(defun texinfo-format-emph () + (insert "*" (texinfo-parse-arg-discard) "*") + (goto-char texinfo-command-start)) + +(put 'dfn 'texinfo-format 'texinfo-format-defn) +(put 'defn 'texinfo-format 'texinfo-format-defn) +(defun texinfo-format-defn () + (insert "\"" (texinfo-parse-arg-discard) "\"") + (goto-char texinfo-command-start)) + +(put 'email 'texinfo-format 'texinfo-format-key) +(put 'key 'texinfo-format 'texinfo-format-key) +(defun texinfo-format-key () + (insert "<" (texinfo-parse-arg-discard) ">") + (goto-char texinfo-command-start)) + +(put 'bullet 'texinfo-format 'texinfo-format-bullet) +(defun texinfo-format-bullet () + "Insert an asterisk. +If used within a line, follow `@bullet' with braces." + (texinfo-optional-braces-discard) + (insert "*")) + + +;;; @kbd + +;; Inside of @example ... @end example and similar environments, +;; @kbd does nothing; but outside of such environments, it places +;; single quotation markes around its argument. + +(defvar texinfo-format-kbd-regexp + (concat + "^@" + "\\(" + "example\\|" + "smallexample\\|" + "lisp\\|" + "smalllisp" + "\\)") + "Regexp specifying environments in which @kbd does not put `...' + around argument.") + +(defvar texinfo-format-kbd-end-regexp + (concat + "^@end " + "\\(" + "example\\|" + "smallexample\\|" + "lisp\\|" + "smalllisp" + "\\)") + "Regexp specifying end of environments in which @kbd does not put `...' + around argument. (See `texinfo-format-kbd-regexp')") + +(put 'kbd 'texinfo-format 'texinfo-format-kbd) +(defun texinfo-format-kbd () + "Place single quote marks around arg, except in @example and similar." + ;; Search forward for @end example closer than an @example. + ;; Can stop search at nearest @node or texinfo-section-types-regexp + (let* ((stop + (save-excursion + (re-search-forward + (concat "^@node\\|\\(" texinfo-section-types-regexp "\\)") + nil + 'move-to-end) ; if necessary, return point at end of buffer + (point))) + (example-location + (save-excursion + (re-search-forward texinfo-format-kbd-regexp stop 'move-to-end) + (point))) + (end-example-location + (save-excursion + (re-search-forward texinfo-format-kbd-end-regexp stop 'move-to-end) + (point)))) + ;; If inside @example, @end example will be closer than @example + ;; or end of search i.e., end-example-location less than example-location + (if (>= end-example-location example-location) + ;; outside an @example or equivalent + (insert "`" (texinfo-parse-arg-discard) "'") + ;; else, in @example; do not surround with `...' + (insert (texinfo-parse-arg-discard))) + (goto-char texinfo-command-start))) + + +;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample + +(put 'display 'texinfo-format 'texinfo-format-example) +(put 'example 'texinfo-format 'texinfo-format-example) +(put 'lisp 'texinfo-format 'texinfo-format-example) +(put 'quotation 'texinfo-format 'texinfo-format-example) +(put 'smallexample 'texinfo-format 'texinfo-format-example) +(put 'smalllisp 'texinfo-format 'texinfo-format-example) +(defun texinfo-format-example () + (texinfo-push-stack 'example nil) + (setq fill-column (- fill-column 5)) + (texinfo-discard-line)) + +(put 'example 'texinfo-end 'texinfo-end-example) +(put 'display 'texinfo-end 'texinfo-end-example) +(put 'lisp 'texinfo-end 'texinfo-end-example) +(put 'quotation 'texinfo-end 'texinfo-end-example) +(put 'smallexample 'texinfo-end 'texinfo-end-example) +(put 'smalllisp 'texinfo-end 'texinfo-end-example) +(defun texinfo-end-example () + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((stacktop + (texinfo-pop-stack 'example))) + (texinfo-do-itemize (nth 1 stacktop)))) + +(put 'exdent 'texinfo-format 'texinfo-format-exdent) +(defun texinfo-format-exdent () + (texinfo-discard-command) + (delete-region (point) + (progn + (skip-chars-forward " ") + (point))) + (insert ?\b) + ;; Cancel out the deletion that texinfo-do-itemize + ;; is going to do at the end of this line. + (save-excursion + (end-of-line) + (insert "\n "))) + + +;;; @cartouche + +;; The @cartouche command is a noop in Info; in a printed manual, +;; it makes a box with rounded corners. + +(put 'cartouche 'texinfo-format 'texinfo-discard-line) +(put 'cartouche 'texinfo-end 'texinfo-discard-command) + + +;;; @flushleft and @format + +;; The @flushleft command left justifies every line but leaves the +;; right end ragged. As far as Info is concerned, @flushleft is a +;; `do-nothing' command + +;; The @format command is similar to @example except that it does not +;; indent; this means that in Info, @format is similar to @flushleft. + +(put 'format 'texinfo-format 'texinfo-format-flushleft) +(put 'flushleft 'texinfo-format 'texinfo-format-flushleft) +(defun texinfo-format-flushleft () + (texinfo-discard-line)) + +(put 'format 'texinfo-end 'texinfo-end-flushleft) +(put 'flushleft 'texinfo-end 'texinfo-end-flushleft) +(defun texinfo-end-flushleft () + (texinfo-discard-command)) + + +;;; @flushright + +;; The @flushright command right justifies every line but leaves the +;; left end ragged. Spaces and tabs at the right ends of lines are +;; removed so that visible text lines up on the right side. + +(put 'flushright 'texinfo-format 'texinfo-format-flushright) +(defun texinfo-format-flushright () + (texinfo-push-stack 'flushright nil) + (texinfo-discard-line)) + +(put 'flushright 'texinfo-end 'texinfo-end-flushright) +(defun texinfo-end-flushright () + (texinfo-discard-command) + + (let ((stacktop + (texinfo-pop-stack 'flushright))) + + (texinfo-do-flushright (nth 1 stacktop)))) + +(defun texinfo-do-flushright (from) + (save-excursion + (while (progn (forward-line -1) + (>= (point) from)) + + (beginning-of-line) + (insert + (make-string + (- fill-column + (save-excursion + (end-of-line) + (skip-chars-backward " \t") + (delete-region (point) (progn (end-of-line) (point))) + (current-column))) + ? ))))) + + +;;; @ctrl, @TeX, @copyright, @minus, @dots, @enddots, @pounds + +(put 'ctrl 'texinfo-format 'texinfo-format-ctrl) +(defun texinfo-format-ctrl () + (let ((str (texinfo-parse-arg-discard))) + (insert (logand 31 (aref str 0))))) + +(put 'TeX 'texinfo-format 'texinfo-format-TeX) +(defun texinfo-format-TeX () + (texinfo-parse-arg-discard) + (insert "TeX")) + +(put 'copyright 'texinfo-format 'texinfo-format-copyright) +(defun texinfo-format-copyright () + (texinfo-parse-arg-discard) + (insert "(C)")) + +(put 'minus 'texinfo-format 'texinfo-format-minus) +(defun texinfo-format-minus () + "Insert a minus sign. +If used within a line, follow `@minus' with braces." + (texinfo-optional-braces-discard) + (insert "-")) + +(put 'dots 'texinfo-format 'texinfo-format-dots) +(defun texinfo-format-dots () + (texinfo-parse-arg-discard) + (insert "...")) + +(put 'enddots 'texinfo-format 'texinfo-format-enddots) +(defun texinfo-format-enddots () + (texinfo-parse-arg-discard) + (insert "....")) + +(put 'pounds 'texinfo-format 'texinfo-format-pounds) +(defun texinfo-format-pounds () + (texinfo-parse-arg-discard) + (insert "#")) + + +;;; Refilling and indenting: @refill, @paragraphindent, @noindent + +;;; Indent only those paragraphs that are refilled as a result of an +;;; @refill command. + +;; * If the value is `asis', do not change the existing indentation at +;; the starts of paragraphs. + +;; * If the value zero, delete any existing indentation. + +;; * If the value is greater than zero, indent each paragraph by that +;; number of spaces. + +;;; But do not refill paragraphs with an @refill command that are +;;; preceded by @noindent or are part of a table, list, or deffn. + +(defvar texinfo-paragraph-indent "asis" + "Number of spaces for @refill to indent a paragraph; else to leave as is.") + +(put 'paragraphindent 'texinfo-format 'texinfo-paragraphindent) + +(defun texinfo-paragraphindent () + "Specify the number of spaces for @refill to indent a paragraph. +Default is to leave the number of spaces as is." + (let ((arg (texinfo-parse-arg-discard))) + (if (string= "asis" arg) + (setq texinfo-paragraph-indent "asis") + (setq texinfo-paragraph-indent (string-to-int arg))))) + +(put 'refill 'texinfo-format 'texinfo-format-refill) +(defun texinfo-format-refill () + "Refill paragraph. Also, indent first line as set by @paragraphindent. +Default is to leave paragraph indentation as is." + (texinfo-discard-command) + (forward-paragraph -1) + (if (looking-at "[ \t\n]*$") (forward-line 1)) + ;; Do not indent if an entry in a list, table, or deffn, + ;; or if paragraph is preceded by @noindent. + ;; Otherwise, indent + (cond + ;; delete a @noindent line and do not indent paragraph + ((save-excursion (forward-line -1) + (looking-at "^@noindent")) + (forward-line -1) + (delete-region (point) (progn (forward-line 1) (point)))) + ;; do nothing if "asis" + ((equal texinfo-paragraph-indent "asis")) + ;; do no indenting in list, etc. + ((> texinfo-stack-depth 0)) + ;; otherwise delete existing whitespace and indent + (t + (delete-region (point) (progn (skip-chars-forward " \t") (point))) + (insert (make-string texinfo-paragraph-indent ? )))) + (forward-paragraph 1) + (forward-line -1) + (end-of-line) + ;; Do not fill a section title line with asterisks, hyphens, etc. that + ;; are used to underline it. This could occur if the line following + ;; the underlining is not an index entry and has text within it. + (let* ((previous-paragraph-separate paragraph-separate) + (paragraph-separate + (concat paragraph-separate "\\|[-=.]+\\|\\*\\*+")) + (previous-paragraph-start paragraph-start) + (paragraph-start + (concat paragraph-start "\\|[-=.]+\\|\\*\\*+"))) + (unwind-protect + (fill-paragraph nil) + (setq paragraph-separate previous-paragraph-separate) + (setq paragraph-start previous-paragraph-start)))) + +(put 'noindent 'texinfo-format 'texinfo-noindent) +(defun texinfo-noindent () + (save-excursion + (forward-paragraph 1) + (if (search-backward "@refill" + (save-excursion (forward-line -1) (point)) t) + () ; leave @noindent command so @refill command knows not to indent + ;; else + (texinfo-discard-line)))) + + +;;; Index generation + +(put 'vindex 'texinfo-format 'texinfo-format-vindex) +(defun texinfo-format-vindex () + (texinfo-index 'texinfo-vindex)) + +(put 'cindex 'texinfo-format 'texinfo-format-cindex) +(defun texinfo-format-cindex () + (texinfo-index 'texinfo-cindex)) + +(put 'findex 'texinfo-format 'texinfo-format-findex) +(defun texinfo-format-findex () + (texinfo-index 'texinfo-findex)) + +(put 'pindex 'texinfo-format 'texinfo-format-pindex) +(defun texinfo-format-pindex () + (texinfo-index 'texinfo-pindex)) + +(put 'tindex 'texinfo-format 'texinfo-format-tindex) +(defun texinfo-format-tindex () + (texinfo-index 'texinfo-tindex)) + +(put 'kindex 'texinfo-format 'texinfo-format-kindex) +(defun texinfo-format-kindex () + (texinfo-index 'texinfo-kindex)) + +(defun texinfo-index (indexvar) + (let ((arg (texinfo-parse-expanded-arg))) + (texinfo-discard-command) + (set indexvar + (cons (list arg + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value indexvar))))) + +(defconst texinfo-indexvar-alist + '(("cp" . texinfo-cindex) + ("fn" . texinfo-findex) + ("vr" . texinfo-vindex) + ("tp" . texinfo-tindex) + ("pg" . texinfo-pindex) + ("ky" . texinfo-kindex))) + + +;;; @defindex @defcodeindex +(put 'defindex 'texinfo-format 'texinfo-format-defindex) +(put 'defcodeindex 'texinfo-format 'texinfo-format-defindex) + +(defun texinfo-format-defindex () + (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa' + (indexing-command (intern (concat index-name "index"))) + (index-formatting-command ; eg: `texinfo-format-aaindex' + (intern (concat "texinfo-format-" index-name "index"))) + (index-alist-name ; eg: `texinfo-aaindex' + (intern (concat "texinfo-" index-name "index")))) + + (set index-alist-name nil) + + (put indexing-command ; eg, aaindex + 'texinfo-format + index-formatting-command) ; eg, texinfo-format-aaindex + + ;; eg: "aa" . texinfo-aaindex + (or (assoc index-name texinfo-indexvar-alist) + (setq texinfo-indexvar-alist + (cons + (cons index-name + index-alist-name) + texinfo-indexvar-alist))) + + (fset index-formatting-command + (list 'lambda 'nil + (list 'texinfo-index + (list 'quote index-alist-name)))))) + + +;;; @synindex @syncodeindex + +(put 'synindex 'texinfo-format 'texinfo-format-synindex) +(put 'syncodeindex 'texinfo-format 'texinfo-format-synindex) + +(defun texinfo-format-synindex () + (let* ((args (texinfo-parse-arg-discard)) + (second (cdr (read-from-string args))) + (joiner (symbol-name (car (read-from-string args)))) + (joined (symbol-name (car (read-from-string args second))))) + + (if (assoc joiner texinfo-short-index-cmds-alist) + (put + (cdr (assoc joiner texinfo-short-index-cmds-alist)) + 'texinfo-format + (or (cdr (assoc joined texinfo-short-index-format-cmds-alist)) + (intern (concat "texinfo-format-" joined "index")))) + (put + (intern (concat joiner "index")) + 'texinfo-format + (or (cdr(assoc joined texinfo-short-index-format-cmds-alist)) + (intern (concat "texinfo-format-" joined "index"))))))) + +(defconst texinfo-short-index-cmds-alist + '(("cp" . cindex) + ("fn" . findex) + ("vr" . vindex) + ("tp" . tindex) + ("pg" . pindex) + ("ky" . kindex))) + +(defconst texinfo-short-index-format-cmds-alist + '(("cp" . texinfo-format-cindex) + ("fn" . texinfo-format-findex) + ("vr" . texinfo-format-vindex) + ("tp" . texinfo-format-tindex) + ("pg" . texinfo-format-pindex) + ("ky" . texinfo-format-kindex))) + + +;;; Sort and index (for VMS) + +;; Sort an index which is in the current buffer between START and END. +;; Used on VMS, where the `sort' utility is not available. +(defun texinfo-sort-region (start end) + (require 'sort) + (save-restriction + (narrow-to-region start end) + (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun))) + +;; Subroutine for sorting an index. +;; At start of a line, return a string to sort the line under. +(defun texinfo-sort-startkeyfun () + (let ((line + (buffer-substring (point) (save-excursion (end-of-line) (point))))) + ;; Canonicalize whitespace and eliminate funny chars. + (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line) + (setq line (concat (substring line 0 (match-beginning 0)) + " " + (substring line (match-end 0) (length line))))) + line)) + + +;;; @printindex + +(put 'printindex 'texinfo-format 'texinfo-format-printindex) + +(defun texinfo-format-printindex () + (let ((indexelts (symbol-value + (cdr (assoc (texinfo-parse-arg-discard) + texinfo-indexvar-alist)))) + opoint) + (insert "\n* Menu:\n\n") + (setq opoint (point)) + (texinfo-print-index nil indexelts) + + (if (memq system-type '(vax-vms windows-nt ms-dos)) + (texinfo-sort-region opoint (point)) + (shell-command-on-region opoint (point) "sort -fd" 1)))) + +(defun texinfo-print-index (file indexelts) + (while indexelts + (if (stringp (car (car indexelts))) + (progn + (insert "* " (car (car indexelts)) ": " ) + (indent-to 32) + (insert + (if file (concat "(" file ")") "") + (nth 1 (car indexelts)) ".") + (indent-to 54) + (insert + (if (nth 2 (car indexelts)) + (format " %d." (nth 2 (car indexelts))) + "") + "\n")) + ;; index entries from @include'd file + (texinfo-print-index (nth 1 (car indexelts)) + (nth 2 (car indexelts)))) + (setq indexelts (cdr indexelts)))) + + +;;; Glyphs: @equiv, @error, etc + +;; @equiv to show that two expressions are equivalent +;; @error to show an error message +;; @expansion to show what a macro expands to +;; @point to show the location of point in an example +;; @print to show what an evaluated expression prints +;; @result to indicate the value returned by an expression + +(put 'equiv 'texinfo-format 'texinfo-format-equiv) +(defun texinfo-format-equiv () + (texinfo-parse-arg-discard) + (insert "==")) + +(put 'error 'texinfo-format 'texinfo-format-error) +(defun texinfo-format-error () + (texinfo-parse-arg-discard) + (insert "error-->")) + +(put 'expansion 'texinfo-format 'texinfo-format-expansion) +(defun texinfo-format-expansion () + (texinfo-parse-arg-discard) + (insert "==>")) + +(put 'point 'texinfo-format 'texinfo-format-point) +(defun texinfo-format-point () + (texinfo-parse-arg-discard) + (insert "-!-")) + +(put 'print 'texinfo-format 'texinfo-format-print) +(defun texinfo-format-print () + (texinfo-parse-arg-discard) + (insert "-|")) + +(put 'result 'texinfo-format 'texinfo-format-result) +(defun texinfo-format-result () + (texinfo-parse-arg-discard) + (insert "=>")) + + +;;; Accent commands + +;; Info presumes a plain ASCII output, so the accented characters do +;; not look as they would if typeset, or output with a different +;; character set. + +;; See the `texinfo-accent-commands' variable +;; in the section for `texinfo-append-refill'. +;; Also, see the defun for `texinfo-format-scan' +;; for single-character accent commands. + +;; Command Info output Name + +;; These do not have braces: +;; @^ ==> ^ circumflex accent +;; @` ==> ` grave accent +;; @' ==> ' acute accent +;; @" ==> " umlaut accent +;; @= ==> = overbar accent +;; @~ ==> ~ tilde accent + +;; These have braces, but take no argument: +;; @OE{} ==> OE French-OE-ligature +;; @oe{} ==> oe +;; @AA{} ==> AA Scandinavian-A-with-circle +;; @aa{} ==> aa +;; @AE{} ==> AE Latin-Scandinavian-AE +;; @ae{} ==> ae +;; @ss{} ==> ss German-sharp-S + +;; @questiondown{} ==> ? upside-down-question-mark +;; @exclamdown{} ==> ! upside-down-exclamation-mark +;; @L{} ==> L/ Polish suppressed-L (Lslash) +;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case) +;; @O{} ==> O/ Scandinavian O-with-slash +;; @o{} ==> o/ Scandinavian O-with-slash (lower case) + +;; These have braces, and take an argument: +;; @,{c} ==> c, cedilla accent +;; @dotaccent{o} ==> .o overdot-accent +;; @ubaraccent{o} ==> _o underbar-accent +;; @udotaccent{o} ==> o-. underdot-accent +;; @H{o} ==> ""o long Hungarian umlaut +;; @ringaccent{o} ==> *o ring accent +;; @tieaccent{oo} ==> [oo tie after accent +;; @u{o} ==> (o breve accent +;; @v{o} ==> i dotless i and dotless j + +;; ========== + +;; Note: The defun texinfo-format-scan +;; looks at "[@{}^'`\",=~ *?!-]" +;; In the case of @*, a line break is inserted; +;; in the other cases, the characters are simply quoted and the @ is deleted. +;; Thus, `texinfo-format-scan' handles the following +;; single-character accent commands: @^ @` @' @" @, @- @= @~ + +;; @^ ==> ^ circumflex accent +;; (put '^ 'texinfo-format 'texinfo-format-circumflex-accent) +;; (defun texinfo-format-circumflex-accent () +;; (texinfo-discard-command) +;; (insert "^")) +;; +;; @` ==> ` grave accent +;; (put '\` 'texinfo-format 'texinfo-format-grave-accent) +;; (defun texinfo-format-grave-accent () +;; (texinfo-discard-command) +;; (insert "\`")) +;; +;; @' ==> ' acute accent +;; (put '\' 'texinfo-format 'texinfo-format-acute-accent) +;; (defun texinfo-format-acute-accent () +;; (texinfo-discard-command) +;; (insert "'")) +;; +;; @" ==> " umlaut accent +;; (put '\" 'texinfo-format 'texinfo-format-umlaut-accent) +;; (defun texinfo-format-umlaut-accent () +;; (texinfo-discard-command) +;; (insert "\"")) +;; +;; @= ==> = overbar accent +;; (put '= 'texinfo-format 'texinfo-format-overbar-accent) +;; (defun texinfo-format-overbar-accent () +;; (texinfo-discard-command) +;; (insert "=")) +;; +;; @~ ==> ~ tilde accent +;; (put '~ 'texinfo-format 'texinfo-format-tilde-accent) +;; (defun texinfo-format-tilde-accent () +;; (texinfo-discard-command) +;; (insert "~")) + +;; @OE{} ==> OE French-OE-ligature +(put 'OE 'texinfo-format 'texinfo-format-French-OE-ligature) +(defun texinfo-format-French-OE-ligature () + (insert "OE" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @oe{} ==> oe +(put 'oe 'texinfo-format 'texinfo-format-French-oe-ligature) +(defun texinfo-format-French-oe-ligature () ; lower case + (insert "oe" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @AA{} ==> AA Scandinavian-A-with-circle +(put 'AA 'texinfo-format 'texinfo-format-Scandinavian-A-with-circle) +(defun texinfo-format-Scandinavian-A-with-circle () + (insert "AA" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @aa{} ==> aa +(put 'aa 'texinfo-format 'texinfo-format-Scandinavian-a-with-circle) +(defun texinfo-format-Scandinavian-a-with-circle () ; lower case + (insert "aa" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @AE{} ==> AE Latin-Scandinavian-AE +(put 'AE 'texinfo-format 'texinfo-format-Latin-Scandinavian-AE) +(defun texinfo-format-Latin-Scandinavian-AE () + (insert "AE" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @ae{} ==> ae +(put 'ae 'texinfo-format 'texinfo-format-Latin-Scandinavian-ae) +(defun texinfo-format-Latin-Scandinavian-ae () ; lower case + (insert "ae" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @ss{} ==> ss German-sharp-S +(put 'ss 'texinfo-format 'texinfo-format-German-sharp-S) +(defun texinfo-format-German-sharp-S () + (insert "ss" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @questiondown{} ==> ? upside-down-question-mark +(put 'questiondown 'texinfo-format 'texinfo-format-upside-down-question-mark) +(defun texinfo-format-upside-down-question-mark () + (insert "?" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @exclamdown{} ==> ! upside-down-exclamation-mark +(put 'exclamdown 'texinfo-format 'texinfo-format-upside-down-exclamation-mark) +(defun texinfo-format-upside-down-exclamation-mark () + (insert "!" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @L{} ==> L/ Polish suppressed-L (Lslash) +(put 'L 'texinfo-format 'texinfo-format-Polish-suppressed-L) +(defun texinfo-format-Polish-suppressed-L () + (insert (texinfo-parse-arg-discard) "/L") + (goto-char texinfo-command-start)) + +;; @l{} ==> l/ Polish suppressed-L (Lslash) (lower case) +(put 'l 'texinfo-format 'texinfo-format-Polish-suppressed-l-lower-case) +(defun texinfo-format-Polish-suppressed-l-lower-case () + (insert (texinfo-parse-arg-discard) "/l") + (goto-char texinfo-command-start)) + + +;; @O{} ==> O/ Scandinavian O-with-slash +(put 'O 'texinfo-format 'texinfo-format-Scandinavian-O-with-slash) +(defun texinfo-format-Scandinavian-O-with-slash () + (insert (texinfo-parse-arg-discard) "O/") + (goto-char texinfo-command-start)) + +;; @o{} ==> o/ Scandinavian O-with-slash (lower case) +(put 'o 'texinfo-format 'texinfo-format-Scandinavian-o-with-slash-lower-case) +(defun texinfo-format-Scandinavian-o-with-slash-lower-case () + (insert (texinfo-parse-arg-discard) "o/") + (goto-char texinfo-command-start)) + +;; Take arguments + +;; @,{c} ==> c, cedilla accent +(put ', 'texinfo-format 'texinfo-format-cedilla-accent) +(defun texinfo-format-cedilla-accent () + (insert (texinfo-parse-arg-discard) ",") + (goto-char texinfo-command-start)) + + +;; @dotaccent{o} ==> .o overdot-accent +(put 'dotaccent 'texinfo-format 'texinfo-format-overdot-accent) +(defun texinfo-format-overdot-accent () + (insert "." (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @ubaraccent{o} ==> _o underbar-accent +(put 'ubaraccent 'texinfo-format 'texinfo-format-underbar-accent) +(defun texinfo-format-underbar-accent () + (insert "_" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @udotaccent{o} ==> o-. underdot-accent +(put 'udotaccent 'texinfo-format 'texinfo-format-underdot-accent) +(defun texinfo-format-underdot-accent () + (insert (texinfo-parse-arg-discard) "-.") + (goto-char texinfo-command-start)) + +;; @H{o} ==> ""o long Hungarian umlaut +(put 'H 'texinfo-format 'texinfo-format-long-Hungarian-umlaut) +(defun texinfo-format-long-Hungarian-umlaut () + (insert "\"\"" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @ringaccent{o} ==> *o ring accent +(put 'ringaccent 'texinfo-format 'texinfo-format-ring-accent) +(defun texinfo-format-ring-accent () + (insert "*" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @tieaccent{oo} ==> [oo tie after accent +(put 'tieaccent 'texinfo-format 'texinfo-format-tie-after-accent) +(defun texinfo-format-tie-after-accent () + (insert "[" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + + +;; @u{o} ==> (o breve accent +(put 'u 'texinfo-format 'texinfo-format-breve-accent) +(defun texinfo-format-breve-accent () + (insert "(" (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @v{o} ==> i dotless i and dotless j +(put 'dotless 'texinfo-format 'texinfo-format-dotless) +(defun texinfo-format-dotless () + (insert (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + + +;;; Definition formatting: @deffn, @defun, etc + +;; What definition formatting produces: +;; +;; @deffn category name args... +;; In Info, `Category: name ARGS' +;; In index: name: node. line#. +;; +;; @defvr category name +;; In Info, `Category: name' +;; In index: name: node. line#. +;; +;; @deftp category name attributes... +;; `category name attributes...' Note: @deftp args in lower case. +;; In index: name: node. line#. +;; +;; Specialized function-like or variable-like entity: +;; +;; @defun, @defmac, @defspec, @defvar, @defopt +;; +;; @defun name args In Info, `Function: name ARGS' +;; @defmac name args In Info, `Macro: name ARGS' +;; @defvar name In Info, `Variable: name' +;; etc. +;; In index: name: node. line#. +;; +;; Generalized typed-function-like or typed-variable-like entity: +;; @deftypefn category data-type name args... +;; In Info, `Category: data-type name args...' +;; @deftypevr category data-type name +;; In Info, `Category: data-type name' +;; In index: name: node. line#. +;; +;; Specialized typed-function-like or typed-variable-like entity: +;; @deftypefun data-type name args... +;; In Info, `Function: data-type name ARGS' +;; In index: name: node. line#. +;; +;; @deftypevar data-type name +;; In Info, `Variable: data-type name' +;; In index: name: node. line#. but include args after name!? +;; +;; Generalized object oriented entity: +;; @defop category class name args... +;; In Info, `Category on class: name ARG' +;; In index: name on class: node. line#. +;; +;; @defcv category class name +;; In Info, `Category of class: name' +;; In index: name of class: node. line#. +;; +;; Specialized object oriented entity: +;; @defmethod class name args... +;; In Info, `Method on class: name ARGS' +;; In index: name on class: node. line#. +;; +;; @defivar class name +;; In Info, `Instance variable of class: name' +;; In index: name of class: node. line#. + + +;;; The definition formatting functions + +(defun texinfo-format-defun () + (texinfo-push-stack 'defun nil) + (setq fill-column (- fill-column 5)) + (texinfo-format-defun-1 t)) + +(defun texinfo-end-defun () + (setq fill-column (+ fill-column 5)) + (texinfo-discard-command) + (let ((start (nth 1 (texinfo-pop-stack 'defun)))) + (texinfo-do-itemize start) + ;; Delete extra newline inserted after header. + (save-excursion + (goto-char start) + (delete-char -1)))) + +(defun texinfo-format-defunx () + (texinfo-format-defun-1 nil)) + +(defun texinfo-format-defun-1 (first-p) + (let ((parse-args (texinfo-format-parse-defun-args)) + (texinfo-defun-type (get texinfo-command-name 'texinfo-defun-type))) + (texinfo-discard-command) + ;; Delete extra newline inserted after previous header line. + (if (not first-p) + (delete-char -1)) + (funcall + (get texinfo-command-name 'texinfo-deffn-formatting-property) parse-args) + ;; Insert extra newline so that paragraph filling does not mess + ;; with header line. + (insert "\n\n") + (rplaca (cdr (cdr (car texinfo-stack))) (point)) + (funcall + (get texinfo-command-name 'texinfo-defun-indexing-property) parse-args))) + +;;; Formatting the first line of a definition + +;; @deffn, @defvr, @deftp +(put 'deffn 'texinfo-deffn-formatting-property 'texinfo-format-deffn) +(put 'deffnx 'texinfo-deffn-formatting-property 'texinfo-format-deffn) +(put 'defvr 'texinfo-deffn-formatting-property 'texinfo-format-deffn) +(put 'defvrx 'texinfo-deffn-formatting-property 'texinfo-format-deffn) +(put 'deftp 'texinfo-deffn-formatting-property 'texinfo-format-deffn) +(put 'deftpx 'texinfo-deffn-formatting-property 'texinfo-format-deffn) +(defun texinfo-format-deffn (parsed-args) + ;; Generalized function-like, variable-like, or generic data-type entity: + ;; @deffn category name args... + ;; In Info, `Category: name ARGS' + ;; @deftp category name attributes... + ;; `category name attributes...' Note: @deftp args in lower case. + (let ((category (car parsed-args)) + (name (car (cdr parsed-args))) + (args (cdr (cdr parsed-args)))) + (insert " -- " category ": " name) + (while args + (insert " " + (if (or (= ?& (aref (car args) 0)) + (eq (eval (car texinfo-defun-type)) 'deftp-type)) + (car args) + (upcase (car args)))) + (setq args (cdr args))))) + +;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple +(put 'defun 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defunx 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defmac 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defmacx 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defspec 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defspecx 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defvar 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defvarx 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defopt 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(put 'defoptx 'texinfo-deffn-formatting-property + 'texinfo-format-specialized-defun) +(defun texinfo-format-specialized-defun (parsed-args) + ;; Specialized function-like or variable-like entity: + ;; @defun name args In Info, `Function: Name ARGS' + ;; @defmac name args In Info, `Macro: Name ARGS' + ;; @defvar name In Info, `Variable: Name' + ;; Use cdr of texinfo-defun-type to determine category: + (let ((category (car (cdr texinfo-defun-type))) + (name (car parsed-args)) + (args (cdr parsed-args))) + (insert " -- " category ": " name) + (while args + (insert " " + (if (= ?& (aref (car args) 0)) + (car args) + (upcase (car args)))) + (setq args (cdr args))))) + +;; @deftypefn, @deftypevr: Generalized typed +(put 'deftypefn 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) +(put 'deftypefnx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) +(put 'deftypevr 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) +(put 'deftypevrx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) +(defun texinfo-format-deftypefn (parsed-args) + ;; Generalized typed-function-like or typed-variable-like entity: + ;; @deftypefn category data-type name args... + ;; In Info, `Category: data-type name args...' + ;; @deftypevr category data-type name + ;; In Info, `Category: data-type name' + ;; Note: args in lower case, unless modified in command line. + (let ((category (car parsed-args)) + (data-type (car (cdr parsed-args))) + (name (car (cdr (cdr parsed-args)))) + (args (cdr (cdr (cdr parsed-args))))) + (insert " -- " category ": " data-type " " name) + (while args + (insert " " (car args)) + (setq args (cdr args))))) + +;; @deftypefun, @deftypevar: Specialized typed +(put 'deftypefun 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun) +(put 'deftypefunx 'texinfo-deffn-formatting-property + 'texinfo-format-deftypefun) +(put 'deftypevar 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun) +(put 'deftypevarx 'texinfo-deffn-formatting-property + 'texinfo-format-deftypefun) +(defun texinfo-format-deftypefun (parsed-args) + ;; Specialized typed-function-like or typed-variable-like entity: + ;; @deftypefun data-type name args... + ;; In Info, `Function: data-type name ARGS' + ;; @deftypevar data-type name + ;; In Info, `Variable: data-type name' + ;; Note: args in lower case, unless modified in command line. + ;; Use cdr of texinfo-defun-type to determine category: + (let ((category (car (cdr texinfo-defun-type))) + (data-type (car parsed-args)) + (name (car (cdr parsed-args))) + (args (cdr (cdr parsed-args)))) + (insert " -- " category ": " data-type " " name) + (while args + (insert " " (car args)) + (setq args (cdr args))))) + +;; @defop: Generalized object-oriented +(put 'defop 'texinfo-deffn-formatting-property 'texinfo-format-defop) +(put 'defopx 'texinfo-deffn-formatting-property 'texinfo-format-defop) +(defun texinfo-format-defop (parsed-args) + ;; Generalized object oriented entity: + ;; @defop category class name args... + ;; In Info, `Category on class: name ARG' + ;; Note: args in upper case; use of `on' + (let ((category (car parsed-args)) + (class (car (cdr parsed-args))) + (name (car (cdr (cdr parsed-args)))) + (args (cdr (cdr (cdr parsed-args))))) + (insert " -- " category " on " class ": " name) + (while args + (insert " " (upcase (car args))) + (setq args (cdr args))))) + +;; @defcv: Generalized object-oriented +(put 'defcv 'texinfo-deffn-formatting-property 'texinfo-format-defcv) +(put 'defcvx 'texinfo-deffn-formatting-property 'texinfo-format-defcv) +(defun texinfo-format-defcv (parsed-args) + ;; Generalized object oriented entity: + ;; @defcv category class name + ;; In Info, `Category of class: name' + ;; Note: args in upper case; use of `of' + (let ((category (car parsed-args)) + (class (car (cdr parsed-args))) + (name (car (cdr (cdr parsed-args)))) + (args (cdr (cdr (cdr parsed-args))))) + (insert " -- " category " of " class ": " name) + (while args + (insert " " (upcase (car args))) + (setq args (cdr args))))) + +;; @defmethod: Specialized object-oriented +(put 'defmethod 'texinfo-deffn-formatting-property 'texinfo-format-defmethod) +(put 'defmethodx 'texinfo-deffn-formatting-property 'texinfo-format-defmethod) +(defun texinfo-format-defmethod (parsed-args) + ;; Specialized object oriented entity: + ;; @defmethod class name args... + ;; In Info, `Method on class: name ARGS' + ;; Note: args in upper case; use of `on' + ;; Use cdr of texinfo-defun-type to determine category: + (let ((category (car (cdr texinfo-defun-type))) + (class (car parsed-args)) + (name (car (cdr parsed-args))) + (args (cdr (cdr parsed-args)))) + (insert " -- " category " on " class ": " name) + (while args + (insert " " (upcase (car args))) + (setq args (cdr args))))) + +;; @defivar: Specialized object-oriented +(put 'defivar 'texinfo-deffn-formatting-property 'texinfo-format-defivar) +(put 'defivarx 'texinfo-deffn-formatting-property 'texinfo-format-defivar) +(defun texinfo-format-defivar (parsed-args) + ;; Specialized object oriented entity: + ;; @defivar class name + ;; In Info, `Instance variable of class: name' + ;; Note: args in upper case; use of `of' + ;; Use cdr of texinfo-defun-type to determine category: + (let ((category (car (cdr texinfo-defun-type))) + (class (car parsed-args)) + (name (car (cdr parsed-args))) + (args (cdr (cdr parsed-args)))) + (insert " -- " category " of " class ": " name) + (while args + (insert " " (upcase (car args))) + (setq args (cdr args))))) + + +;;; Indexing for definitions + +;; An index entry has three parts: the `entry proper', the node name, and the +;; line number. Depending on the which command is used, the entry is +;; formatted differently: +;; +;; @defun, +;; @defmac, +;; @defspec, +;; @defvar, +;; @defopt all use their 1st argument as the entry-proper +;; +;; @deffn, +;; @defvr, +;; @deftp +;; @deftypefun +;; @deftypevar all use their 2nd argument as the entry-proper +;; +;; @deftypefn, +;; @deftypevr both use their 3rd argument as the entry-proper +;; +;; @defmethod uses its 2nd and 1st arguments as an entry-proper +;; formatted: NAME on CLASS + +;; @defop uses its 3rd and 2nd arguments as an entry-proper +;; formatted: NAME on CLASS +;; +;; @defivar uses its 2nd and 1st arguments as an entry-proper +;; formatted: NAME of CLASS +;; +;; @defcv uses its 3rd and 2nd argument as an entry-proper +;; formatted: NAME of CLASS + +(put 'defun 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defunx 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defmac 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defmacx 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defspec 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defspecx 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defvar 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defvarx 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defopt 'texinfo-defun-indexing-property 'texinfo-index-defun) +(put 'defoptx 'texinfo-defun-indexing-property 'texinfo-index-defun) +(defun texinfo-index-defun (parsed-args) + ;; use 1st parsed-arg as entry-proper + ;; `index-list' will be texinfo-findex or the like + (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) + (set index-list + (cons + ;; Three elements: entry-proper, node-name, line-number + (list + (car parsed-args) + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value index-list))))) + +(put 'deffn 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'deffnx 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'defvr 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'defvrx 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'deftp 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'deftpx 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'deftypefun 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'deftypefunx 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'deftypevar 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(put 'deftypevarx 'texinfo-defun-indexing-property 'texinfo-index-deffn) +(defun texinfo-index-deffn (parsed-args) + ;; use 2nd parsed-arg as entry-proper + ;; `index-list' will be texinfo-findex or the like + (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) + (set index-list + (cons + ;; Three elements: entry-proper, node-name, line-number + (list + (car (cdr parsed-args)) + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value index-list))))) + +(put 'deftypefn 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) +(put 'deftypefnx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) +(put 'deftypevr 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) +(put 'deftypevrx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) +(defun texinfo-index-deftypefn (parsed-args) + ;; use 3rd parsed-arg as entry-proper + ;; `index-list' will be texinfo-findex or the like + (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) + (set index-list + (cons + ;; Three elements: entry-proper, node-name, line-number + (list + (car (cdr (cdr parsed-args))) + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value index-list))))) + +(put 'defmethod 'texinfo-defun-indexing-property 'texinfo-index-defmethod) +(put 'defmethodx 'texinfo-defun-indexing-property 'texinfo-index-defmethod) +(defun texinfo-index-defmethod (parsed-args) + ;; use 2nd on 1st parsed-arg as entry-proper + ;; `index-list' will be texinfo-findex or the like + (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) + (set index-list + (cons + ;; Three elements: entry-proper, node-name, line-number + (list + (format "%s on %s" + (car (cdr parsed-args)) + (car parsed-args)) + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value index-list))))) + +(put 'defop 'texinfo-defun-indexing-property 'texinfo-index-defop) +(put 'defopx 'texinfo-defun-indexing-property 'texinfo-index-defop) +(defun texinfo-index-defop (parsed-args) + ;; use 3rd on 2nd parsed-arg as entry-proper + ;; `index-list' will be texinfo-findex or the like + (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) + (set index-list + (cons + ;; Three elements: entry-proper, node-name, line-number + (list + (format "%s on %s" + (car (cdr (cdr parsed-args))) + (car (cdr parsed-args))) + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value index-list))))) + +(put 'defivar 'texinfo-defun-indexing-property 'texinfo-index-defivar) +(put 'defivarx 'texinfo-defun-indexing-property 'texinfo-index-defivar) +(defun texinfo-index-defivar (parsed-args) + ;; use 2nd of 1st parsed-arg as entry-proper + ;; `index-list' will be texinfo-findex or the like + (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) + (set index-list + (cons + ;; Three elements: entry-proper, node-name, line-number + (list + (format "%s of %s" + (car (cdr parsed-args)) + (car parsed-args)) + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value index-list))))) + +(put 'defcv 'texinfo-defun-indexing-property 'texinfo-index-defcv) +(put 'defcvx 'texinfo-defun-indexing-property 'texinfo-index-defcv) +(defun texinfo-index-defcv (parsed-args) + ;; use 3rd of 2nd parsed-arg as entry-proper + ;; `index-list' will be texinfo-findex or the like + (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) + (set index-list + (cons + ;; Three elements: entry-proper, node-name, line-number + (list + (format "%s of %s" + (car (cdr (cdr parsed-args))) + (car (cdr parsed-args))) + texinfo-last-node + ;; Region formatting may not provide last node position. + (if texinfo-last-node-pos + (1+ (count-lines texinfo-last-node-pos (point))) + 1)) + (symbol-value index-list))))) + + +;;; Properties for definitions + +;; Each definition command has six properties: +;; +;; 1. texinfo-deffn-formatting-property to format definition line +;; 2. texinfo-defun-indexing-property to create index entry +;; 3. texinfo-format formatting command +;; 4. texinfo-end end formatting command +;; 5. texinfo-defun-type type of deffn to format +;; 6. texinfo-defun-index type of index to use +;; +;; The `x' forms of each definition command are used for the second +;; and subsequent header lines. + +;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property +;; are listed just before the appropriate formatting and indexing commands. + +(put 'deffn 'texinfo-format 'texinfo-format-defun) +(put 'deffnx 'texinfo-format 'texinfo-format-defunx) +(put 'deffn 'texinfo-end 'texinfo-end-defun) +(put 'deffn 'texinfo-defun-type '('deffn-type nil)) +(put 'deffnx 'texinfo-defun-type '('deffn-type nil)) +(put 'deffn 'texinfo-defun-index 'texinfo-findex) +(put 'deffnx 'texinfo-defun-index 'texinfo-findex) + +(put 'defun 'texinfo-format 'texinfo-format-defun) +(put 'defunx 'texinfo-format 'texinfo-format-defunx) +(put 'defun 'texinfo-end 'texinfo-end-defun) +(put 'defun 'texinfo-defun-type '('defun-type "Function")) +(put 'defunx 'texinfo-defun-type '('defun-type "Function")) +(put 'defun 'texinfo-defun-index 'texinfo-findex) +(put 'defunx 'texinfo-defun-index 'texinfo-findex) + +(put 'defmac 'texinfo-format 'texinfo-format-defun) +(put 'defmacx 'texinfo-format 'texinfo-format-defunx) +(put 'defmac 'texinfo-end 'texinfo-end-defun) +(put 'defmac 'texinfo-defun-type '('defun-type "Macro")) +(put 'defmacx 'texinfo-defun-type '('defun-type "Macro")) +(put 'defmac 'texinfo-defun-index 'texinfo-findex) +(put 'defmacx 'texinfo-defun-index 'texinfo-findex) + +(put 'defspec 'texinfo-format 'texinfo-format-defun) +(put 'defspecx 'texinfo-format 'texinfo-format-defunx) +(put 'defspec 'texinfo-end 'texinfo-end-defun) +(put 'defspec 'texinfo-defun-type '('defun-type "Special form")) +(put 'defspecx 'texinfo-defun-type '('defun-type "Special form")) +(put 'defspec 'texinfo-defun-index 'texinfo-findex) +(put 'defspecx 'texinfo-defun-index 'texinfo-findex) + +(put 'defvr 'texinfo-format 'texinfo-format-defun) +(put 'defvrx 'texinfo-format 'texinfo-format-defunx) +(put 'defvr 'texinfo-end 'texinfo-end-defun) +(put 'defvr 'texinfo-defun-type '('deffn-type nil)) +(put 'defvrx 'texinfo-defun-type '('deffn-type nil)) +(put 'defvr 'texinfo-defun-index 'texinfo-vindex) +(put 'defvrx 'texinfo-defun-index 'texinfo-vindex) + +(put 'defvar 'texinfo-format 'texinfo-format-defun) +(put 'defvarx 'texinfo-format 'texinfo-format-defunx) +(put 'defvar 'texinfo-end 'texinfo-end-defun) +(put 'defvar 'texinfo-defun-type '('defun-type "Variable")) +(put 'defvarx 'texinfo-defun-type '('defun-type "Variable")) +(put 'defvar 'texinfo-defun-index 'texinfo-vindex) +(put 'defvarx 'texinfo-defun-index 'texinfo-vindex) + +(put 'defconst 'texinfo-format 'texinfo-format-defun) +(put 'defconstx 'texinfo-format 'texinfo-format-defunx) +(put 'defconst 'texinfo-end 'texinfo-end-defun) +(put 'defconst 'texinfo-defun-type '('defun-type "Constant")) +(put 'defconstx 'texinfo-defun-type '('defun-type "Constant")) +(put 'defconst 'texinfo-defun-index 'texinfo-vindex) +(put 'defconstx 'texinfo-defun-index 'texinfo-vindex) + +(put 'defcmd 'texinfo-format 'texinfo-format-defun) +(put 'defcmdx 'texinfo-format 'texinfo-format-defunx) +(put 'defcmd 'texinfo-end 'texinfo-end-defun) +(put 'defcmd 'texinfo-defun-type '('defun-type "Command")) +(put 'defcmdx 'texinfo-defun-type '('defun-type "Command")) +(put 'defcmd 'texinfo-defun-index 'texinfo-findex) +(put 'defcmdx 'texinfo-defun-index 'texinfo-findex) + +(put 'defopt 'texinfo-format 'texinfo-format-defun) +(put 'defoptx 'texinfo-format 'texinfo-format-defunx) +(put 'defopt 'texinfo-end 'texinfo-end-defun) +(put 'defopt 'texinfo-defun-type '('defun-type "User Option")) +(put 'defoptx 'texinfo-defun-type '('defun-type "User Option")) +(put 'defopt 'texinfo-defun-index 'texinfo-vindex) +(put 'defoptx 'texinfo-defun-index 'texinfo-vindex) + +(put 'deftp 'texinfo-format 'texinfo-format-defun) +(put 'deftpx 'texinfo-format 'texinfo-format-defunx) +(put 'deftp 'texinfo-end 'texinfo-end-defun) +(put 'deftp 'texinfo-defun-type '('deftp-type nil)) +(put 'deftpx 'texinfo-defun-type '('deftp-type nil)) +(put 'deftp 'texinfo-defun-index 'texinfo-tindex) +(put 'deftpx 'texinfo-defun-index 'texinfo-tindex) + +;;; Object-oriented stuff is a little hairier. + +(put 'defop 'texinfo-format 'texinfo-format-defun) +(put 'defopx 'texinfo-format 'texinfo-format-defunx) +(put 'defop 'texinfo-end 'texinfo-end-defun) +(put 'defop 'texinfo-defun-type '('defop-type nil)) +(put 'defopx 'texinfo-defun-type '('defop-type nil)) +(put 'defop 'texinfo-defun-index 'texinfo-findex) +(put 'defopx 'texinfo-defun-index 'texinfo-findex) + +(put 'defmethod 'texinfo-format 'texinfo-format-defun) +(put 'defmethodx 'texinfo-format 'texinfo-format-defunx) +(put 'defmethod 'texinfo-end 'texinfo-end-defun) +(put 'defmethod 'texinfo-defun-type '('defmethod-type "Method")) +(put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method")) +(put 'defmethod 'texinfo-defun-index 'texinfo-findex) +(put 'defmethodx 'texinfo-defun-index 'texinfo-findex) + +(put 'defcv 'texinfo-format 'texinfo-format-defun) +(put 'defcvx 'texinfo-format 'texinfo-format-defunx) +(put 'defcv 'texinfo-end 'texinfo-end-defun) +(put 'defcv 'texinfo-defun-type '('defop-type nil)) +(put 'defcvx 'texinfo-defun-type '('defop-type nil)) +(put 'defcv 'texinfo-defun-index 'texinfo-vindex) +(put 'defcvx 'texinfo-defun-index 'texinfo-vindex) + +(put 'defivar 'texinfo-format 'texinfo-format-defun) +(put 'defivarx 'texinfo-format 'texinfo-format-defunx) +(put 'defivar 'texinfo-end 'texinfo-end-defun) +(put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable")) +(put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable")) +(put 'defivar 'texinfo-defun-index 'texinfo-vindex) +(put 'defivarx 'texinfo-defun-index 'texinfo-vindex) + +;;; Typed functions and variables + +(put 'deftypefn 'texinfo-format 'texinfo-format-defun) +(put 'deftypefnx 'texinfo-format 'texinfo-format-defunx) +(put 'deftypefn 'texinfo-end 'texinfo-end-defun) +(put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil)) +(put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil)) +(put 'deftypefn 'texinfo-defun-index 'texinfo-findex) +(put 'deftypefnx 'texinfo-defun-index 'texinfo-findex) + +(put 'deftypefun 'texinfo-format 'texinfo-format-defun) +(put 'deftypefunx 'texinfo-format 'texinfo-format-defunx) +(put 'deftypefun 'texinfo-end 'texinfo-end-defun) +(put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function")) +(put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function")) +(put 'deftypefun 'texinfo-defun-index 'texinfo-findex) +(put 'deftypefunx 'texinfo-defun-index 'texinfo-findex) + +(put 'deftypevr 'texinfo-format 'texinfo-format-defun) +(put 'deftypevrx 'texinfo-format 'texinfo-format-defunx) +(put 'deftypevr 'texinfo-end 'texinfo-end-defun) +(put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil)) +(put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil)) +(put 'deftypevr 'texinfo-defun-index 'texinfo-vindex) +(put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex) + +(put 'deftypevar 'texinfo-format 'texinfo-format-defun) +(put 'deftypevarx 'texinfo-format 'texinfo-format-defunx) +(put 'deftypevar 'texinfo-end 'texinfo-end-defun) +(put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable")) +(put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable")) +(put 'deftypevar 'texinfo-defun-index 'texinfo-vindex) +(put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex) + + +;;; @set, @clear, @ifset, @ifclear + +;; If a flag is set with @set FLAG, then text between @ifset and @end +;; ifset is formatted normally, but if the flag is is cleared with +;; @clear FLAG, then the text is not formatted; it is ignored. + +;; If a flag is cleared with @clear FLAG, then text between @ifclear +;; and @end ifclear is formatted normally, but if the flag is is set with +;; @set FLAG, then the text is not formatted; it is ignored. @ifclear +;; is the opposite of @ifset. + +;; If a flag is set to a string with @set FLAG, +;; replace @value{FLAG} with the string. +;; If a flag with a value is cleared, +;; @value{FLAG} is invalid, +;; as if there had never been any @set FLAG previously. + +(put 'clear 'texinfo-format 'texinfo-clear) +(defun texinfo-clear () + "Clear the value of the flag." + (let* ((arg (texinfo-parse-arg-discard)) + (flag (car (read-from-string arg))) + (value (substring arg (cdr (read-from-string arg))))) + (put flag 'texinfo-whether-setp 'flag-cleared) + (put flag 'texinfo-set-value ""))) + +(put 'set 'texinfo-format 'texinfo-set) +(defun texinfo-set () + "Set the value of the flag, optionally to a string. +The command `@set foo This is a string.' +sets flag foo to the value: `This is a string.' +The command `@value{foo}' expands to the value." + (let* ((arg (texinfo-parse-arg-discard)) + (flag (car (read-from-string arg))) + (value (substring arg (cdr (read-from-string arg))))) + (put flag 'texinfo-whether-setp 'flag-set) + (put flag 'texinfo-set-value value))) + +(put 'value 'texinfo-format 'texinfo-value) +(defun texinfo-value () + "Insert the string to which the flag is set. +The command `@set foo This is a string.' +sets flag foo to the value: `This is a string.' +The command `@value{foo}' expands to the value." + (let ((arg (texinfo-parse-arg-discard))) + (cond ((and + (eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + 'flag-set) + (get (car (read-from-string arg)) 'texinfo-set-value)) + (insert (get (car (read-from-string arg)) 'texinfo-set-value))) + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + 'flag-cleared) + (insert (format "{No value for \"%s\"}" arg))) + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) nil) + (insert (format "{No value for \"%s\"}" arg)))))) + +(put 'ifset 'texinfo-end 'texinfo-discard-command) +(put 'ifset 'texinfo-format 'texinfo-if-set) +(defun texinfo-if-set () + "If set, continue formatting; else do not format region up to @end ifset" + (let ((arg (texinfo-parse-arg-discard))) + (cond + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + 'flag-set) + ;; Format the text (i.e., do not remove it); do nothing here. + ()) + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + 'flag-cleared) + ;; Clear region (i.e., cause the text to be ignored). + (delete-region texinfo-command-start + (progn (re-search-forward "@end ifset[ \t]*\n") + (point)))) + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + nil) + ;; In this case flag is neither set nor cleared. + ;; Act as if set, i.e. do nothing. + ())))) + +(put 'ifclear 'texinfo-end 'texinfo-discard-command) +(put 'ifclear 'texinfo-format 'texinfo-if-clear) +(defun texinfo-if-clear () + "If clear, continue formatting; if set, do not format up to @end ifset" + (let ((arg (texinfo-parse-arg-discard))) + (cond + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + 'flag-set) + ;; Clear region (i.e., cause the text to be ignored). + (delete-region texinfo-command-start + (progn (re-search-forward "@end ifclear[ \t]*\n") + (point)))) + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + 'flag-cleared) + ;; Format the text (i.e., do not remove it); do nothing here. + ()) + ((eq (get (car (read-from-string arg)) 'texinfo-whether-setp) + nil) + ;; In this case flag is neither set nor cleared. + ;; Act as if clear, i.e. do nothing. + ())))) + + +;;; @ifeq + +(put 'ifeq 'texinfo-format 'texinfo-format-ifeq) +(defun texinfo-format-ifeq () + "If ARG1 and ARG2 caselessly string compare to same string, performs COMMAND. +Otherwise produces no output. + +Thus: + @ifeq{ arg1 , arg1 , @code{foo}} bar + + ==> `foo' bar. +but + @ifeq{ arg1 , arg2 , @code{foo}} bar + + ==> bar + +Note that the Texinfo command and its arguments must be arguments to +the @ifeq command." + ;; compare-buffer-substrings does not exist in version 18; don't use + (goto-char texinfo-command-end) + (let* ((case-fold-search t) + (stop (save-excursion (forward-sexp 1) (point))) + start end + ;; @ifeq{arg1, arg2, @command{optional-args}} + (arg1 + (progn + (forward-char 1) + (skip-chars-forward " ") + (setq start (point)) + (search-forward "," stop t) + (skip-chars-backward ", ") + (buffer-substring start (point)))) + (arg2 + (progn + (search-forward "," stop t) + (skip-chars-forward " ") + (setq start (point)) + (search-forward "," stop t) + (skip-chars-backward ", ") + (buffer-substring start (point)))) + (texinfo-command + (progn + (search-forward "," stop t) + (skip-chars-forward " ") + (setq start (point)) + (goto-char (1- stop)) + (skip-chars-backward " ") + (buffer-substring start (point))))) + (delete-region texinfo-command-start stop) + (if (equal arg1 arg2) + (insert texinfo-command)) + (goto-char texinfo-command-start))) + + +;;; Process included files: `@include' command + +;; Updated 19 October 1990 +;; In the original version, include files were ignored by Info but +;; incorporated in to the printed manual. To make references to the +;; included file, the Texinfo source file has to refer to the included +;; files using the `(filename)nodename' format for referring to other +;; Info files. Also, the included files had to be formatted on their +;; own. It was just like they were another file. + +;; Currently, include files are inserted into the buffer that is +;; formatted for Info. If large, the resulting info file is split and +;; tagified. For current include files to work, the master menu must +;; refer to all the nodes, and the highest level nodes in the include +;; files must have the correct next, prev, and up pointers. + +;; The included file may have an @setfilename and even an @settitle, +;; but not an `\input texinfo' line. + +;; Updated 24 March 1993 +;; In order for @raisesections and @lowersections to work, included +;; files must be inserted into the buffer holding the outer file +;; before other Info formatting takes place. So @include is no longer +;; is treated like other @-commands. +(put 'include 'texinfo-format 'texinfo-format-noop) + +;; Original definition: +;; (defun texinfo-format-include () +;; (let ((filename (texinfo-parse-arg-discard)) +;; (default-directory input-directory) +;; subindex) +;; (setq subindex +;; (save-excursion +;; (progn (find-file +;; (cond ((file-readable-p (concat filename ".texinfo")) +;; (concat filename ".texinfo")) +;; ((file-readable-p (concat filename ".texi")) +;; (concat filename ".texi")) +;; ((file-readable-p (concat filename ".tex")) +;; (concat filename ".tex")) +;; ((file-readable-p filename) +;; filename) +;; (t (error "@include'd file %s not found" +;; filename)))) +;; (texinfo-format-buffer-1)))) +;; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex)) +;; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex)) +;; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex)) +;; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex)) +;; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex)) +;; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex)))) +;; +;;(defun texinfo-subindex (indexvar file content) +;; (set indexvar (cons (list 'recurse file content) +;; (symbol-value indexvar)))) + +;; Second definition: +;; (put 'include 'texinfo-format 'texinfo-format-include) +;; (defun texinfo-format-include () +;; (let ((filename (concat input-directory +;; (texinfo-parse-arg-discard))) +;; (default-directory input-directory)) +;; (message "Reading: %s" filename) +;; (save-excursion +;; (save-restriction +;; (narrow-to-region +;; (point) +;; (+ (point) (car (cdr (insert-file-contents filename))))) +;; (goto-char (point-min)) +;; (texinfo-append-refill) +;; (texinfo-format-convert (point-min) (point-max)))) +;; (setq last-input-buffer input-buffer) ; to bypass setfilename +;; )) + + +;;; Numerous commands do nothing in Info +;; These commands are defined in texinfo.tex for printed output. + + +;;; various noops, such as @b{foo}, that take arguments in braces + +(put 'b 'texinfo-format 'texinfo-format-noop) +(put 'i 'texinfo-format 'texinfo-format-noop) +(put 'r 'texinfo-format 'texinfo-format-noop) +(put 't 'texinfo-format 'texinfo-format-noop) +(put 'w 'texinfo-format 'texinfo-format-noop) +(put 'asis 'texinfo-format 'texinfo-format-noop) +(put 'dmn 'texinfo-format 'texinfo-format-noop) +(put 'math 'texinfo-format 'texinfo-format-noop) +(put 'titlefont 'texinfo-format 'texinfo-format-noop) +(defun texinfo-format-noop () + (insert (texinfo-parse-arg-discard)) + (goto-char texinfo-command-start)) + +;; @hyphenation command discards an argument within braces +(put 'hyphenation 'texinfo-format 'texinfo-discard-command-and-arg) +(defun texinfo-discard-command-and-arg () + "Discard both @-command and its argument in braces." + (goto-char texinfo-command-end) + (forward-list 1) + (setq texinfo-command-end (point)) + (delete-region texinfo-command-start texinfo-command-end)) + + +;;; Do nothing commands, such as @smallbook, that have no args and no braces +;; These must appear on a line of their own + +(put 'bye 'texinfo-format 'texinfo-discard-line) +(put 'smallbook 'texinfo-format 'texinfo-discard-line) +(put 'finalout 'texinfo-format 'texinfo-discard-line) +(put 'overfullrule 'texinfo-format 'texinfo-discard-line) +(put 'smallbreak 'texinfo-format 'texinfo-discard-line) +(put 'medbreak 'texinfo-format 'texinfo-discard-line) +(put 'bigbreak 'texinfo-format 'texinfo-discard-line) + + +;;; These noop commands discard the rest of the line. + +(put 'c 'texinfo-format 'texinfo-discard-line-with-args) +(put 'comment 'texinfo-format 'texinfo-discard-line-with-args) +(put 'contents 'texinfo-format 'texinfo-discard-line-with-args) +(put 'group 'texinfo-end 'texinfo-discard-line-with-args) +(put 'group 'texinfo-format 'texinfo-discard-line-with-args) +(put 'headings 'texinfo-format 'texinfo-discard-line-with-args) +(put 'setchapterstyle 'texinfo-format 'texinfo-discard-line-with-args) +(put 'hsize 'texinfo-format 'texinfo-discard-line-with-args) +(put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args) +(put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args) +(put 'need 'texinfo-format 'texinfo-discard-line-with-args) +(put 'nopara 'texinfo-format 'texinfo-discard-line-with-args) +(put 'page 'texinfo-format 'texinfo-discard-line-with-args) +(put 'parindent 'texinfo-format 'texinfo-discard-line-with-args) +(put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args) +(put 'setq 'texinfo-format 'texinfo-discard-line-with-args) +(put 'settitle 'texinfo-format 'texinfo-discard-line-with-args) +(put 'setx 'texinfo-format 'texinfo-discard-line-with-args) +(put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args) +(put 'shorttitlepage 'texinfo-format 'texinfo-discard-line-with-args) +(put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args) +(put 'input 'texinfo-format 'texinfo-discard-line-with-args) +(put 'dircategory 'texinfo-format 'texinfo-discard-line-with-args) + + +;;; Some commands cannot be handled + +(defun texinfo-unsupported () + (error "%s is not handled by texinfo" + (buffer-substring texinfo-command-start texinfo-command-end))) + +;;; Batch formatting + +(defun batch-texinfo-format () + "Runs texinfo-format-buffer on the files remaining on the command line. +Must be used only with -batch, and kills emacs on completion. +Each file will be processed even if an error occurred previously. +For example, invoke + \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"." + (if (not noninteractive) + (error "batch-texinfo-format may only be used -batch.")) + (let ((version-control t) + (auto-save-default nil) + (find-file-run-dired nil) + (kept-old-versions 259259) + (kept-new-versions 259259)) + (let ((error 0) + file + (files ())) + (while command-line-args-left + (setq file (expand-file-name (car command-line-args-left))) + (cond ((not (file-exists-p file)) + (message ">> %s does not exist!" file) + (setq error 1 + command-line-args-left (cdr command-line-args-left))) + ((file-directory-p file) + (setq command-line-args-left + (nconc (directory-files file) + (cdr command-line-args-left)))) + (t + (setq files (cons file files) + command-line-args-left (cdr command-line-args-left))))) + (while files + (setq file (car files) + files (cdr files)) + (condition-case err + (progn + (if buffer-file-name (kill-buffer (current-buffer))) + (find-file file) + (buffer-disable-undo (current-buffer)) + (set-buffer-modified-p nil) + (texinfo-mode) + (message "texinfo formatting %s..." file) + (texinfo-format-buffer nil) + (if (buffer-modified-p) + (progn (message "Saving modified %s" (buffer-file-name)) + (save-buffer)))) + (error + (message ">> Error: %s" (prin1-to-string err)) + (message ">> point at") + (let ((s (buffer-substring (point) + (min (+ (point) 100) + (point-max)))) + (tem 0)) + (while (setq tem (string-match "\n+" s tem)) + (setq s (concat (substring s 0 (match-beginning 0)) + "\n>> " + (substring s (match-end 0))) + tem (1+ tem))) + (message ">> %s" s)) + (setq error 1)))) + (kill-emacs error)))) + + +;;; Place `provide' at end of file. +(provide 'texinfmt) + +;;; texinfmt.el ends here. diff --git a/texinfo/emacs/texinfo.el b/texinfo/emacs/texinfo.el new file mode 100644 index 000000000000..0a1ab13401ea --- /dev/null +++ b/texinfo/emacs/texinfo.el @@ -0,0 +1,932 @@ +;;; texinfo.el--major mode for editing Texinfo files. + +;; Copyright (C) 1985, '88, '89, '90, '91, +;; '92, '93, '96 Free Software Foundation, Inc. + +;; Author: Robert J. Chassell +;; Date: 6 Sep 1996 +;; Maintainer: bug-texinfo@prep.ai.mit.edu +;; Keywords: maint, tex, docs + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Autoloads: + +(autoload 'makeinfo-region + "makeinfo" + "Make Info file from region of current Texinfo file, and switch to it. + +This command does not offer the `next-error' feature since it would +apply to a temporary file, not the original; use the `makeinfo-buffer' +command to gain use of `next-error'." + t nil) + +(autoload 'makeinfo-buffer + "makeinfo" + "Make Info file from current buffer. + +Use the \\[next-error] command to move to the next error +\(if there are errors\)." + t nil) + +(autoload 'kill-compilation + "compile" + "Kill the process made by the \\[compile] command." + t nil) + +(autoload 'makeinfo-recenter-compilation-buffer + "makeinfo" + "Redisplay `*compilation*' buffer so most recent output can be seen. +The last line of the buffer is displayed on +line LINE of the window, or centered if LINE is nil." + t nil) + +(autoload 'texinfo-update-node + "texnfo-upd" + "Without any prefix argument, update the node in which point is located. +Non-nil argument (prefix, if interactive) means update the nodes in the +marked region. + +The functions for creating or updating nodes and menus, and their +keybindings, are: + + texinfo-update-node (&optional region-p) \\[texinfo-update-node] + texinfo-every-node-update () \\[texinfo-every-node-update] + texinfo-sequential-node-update (&optional region-p) + + texinfo-make-menu (&optional region-p) \\[texinfo-make-menu] + texinfo-all-menus-update () \\[texinfo-all-menus-update] + texinfo-master-menu () + + texinfo-indent-menu-description (column &optional region-p) + +The `texinfo-column-for-description' variable specifies the column to +which menu descriptions are indented. Its default value is 32." + t nil) + +(autoload 'texinfo-every-node-update + "texnfo-upd" + "Update every node in a Texinfo file." + t nil) + +(autoload 'texinfo-sequential-node-update + "texnfo-upd" + "Update one node (or many) in a Texinfo file with sequential pointers. + +This function causes the `Next' or `Previous' pointer to point to the +immediately preceding or following node, even if it is at a higher or +lower hierarchical level in the document. Continually pressing `n' or +`p' takes you straight through the file. + +Without any prefix argument, update the node in which point is located. +Non-nil argument (prefix, if interactive) means update the nodes in the +marked region. + +This command makes it awkward to navigate among sections and +subsections; it should be used only for those documents that are meant +to be read like a novel rather than a reference, and for which the +Info `g*' command is inadequate." + t nil) + +(autoload 'texinfo-make-menu + "texnfo-upd" + "Without any prefix argument, make or update a menu. +Make the menu for the section enclosing the node found following point. + +Non-nil argument (prefix, if interactive) means make or update menus +for nodes within or part of the marked region. + +Whenever a menu exists, and is being updated, the descriptions that +are associated with node names in the pre-existing menu are +incorporated into the new menu. Otherwise, the nodes' section titles +are inserted as descriptions." + t nil) + +(autoload 'texinfo-all-menus-update + "texnfo-upd" + "Update every regular menu in a Texinfo file. +Remove pre-existing master menu, if there is one. + +If called with a non-nil argument, this function first updates all the +nodes in the buffer before updating the menus." + t nil) + +(autoload 'texinfo-master-menu + "texnfo-upd" + "Make a master menu for a whole Texinfo file. +Non-nil argument (prefix, if interactive) means first update all +existing nodes and menus. Remove pre-existing master menu, if there is one. + +This function creates a master menu that follows the top node. The +master menu includes every entry from all the other menus. It +replaces any existing ordinary menu that follows the top node. + +If called with a non-nil argument, this function first updates all the +menus in the buffer (incorporating descriptions from pre-existing +menus) before it constructs the master menu. + +The function removes the detailed part of an already existing master +menu. This action depends on the pre-existing master menu using the +standard `texinfo-master-menu-header'. + +The master menu has the following format, which is adapted from the +recommendation in the Texinfo Manual: + + * The first part contains the major nodes in the Texinfo file: the + nodes for the chapters, chapter-like sections, and the major + appendices. This includes the indices, so long as they are in + chapter-like sections, such as unnumbered sections. + + * The second and subsequent parts contain a listing of the other, + lower level menus, in order. This way, an inquirer can go + directly to a particular node if he or she is searching for + specific information. + +Each of the menus in the detailed node listing is introduced by the +title of the section containing the menu." + t nil) + +(autoload 'texinfo-indent-menu-description + "texnfo-upd" + "Indent every description in menu following point to COLUMN. +Non-nil argument (prefix, if interactive) means indent every +description in every menu in the region. Does not indent second and +subsequent lines of a multi-line description." + t nil) + +(autoload 'texinfo-insert-node-lines + "texnfo-upd" + "Insert missing `@node' lines in region of Texinfo file. +Non-nil argument (prefix, if interactive) means also to insert the +section titles as node names; and also to insert the section titles as +node names in pre-existing @node lines that lack names." + t nil) + +(autoload 'texinfo-start-menu-description + "texnfo-upd" + "In this menu entry, insert the node's section title as a description. +Position point at beginning of description ready for editing. +Do not insert a title if the line contains an existing description. + +You will need to edit the inserted text since a useful description +complements the node name rather than repeats it as a title does." + t nil) + +(autoload 'texinfo-multiple-files-update + "texnfo-upd" + "Update first node pointers in each file included in OUTER-FILE; +create or update main menu in the outer file that refers to such nodes. +This does not create or update menus or pointers within the included files. + +With optional MAKE-MASTER-MENU argument (prefix arg, if interactive), +insert a master menu in OUTER-FILE. This does not create or update +menus or pointers within the included files. + +With optional UPDATE-EVERYTHING argument (numeric prefix arg, if +interactive), update all the menus and all the `Next', `Previous', and +`Up' pointers of all the files included in OUTER-FILE before inserting +a master menu in OUTER-FILE. + +The command also updates the `Top' level node pointers of OUTER-FILE. + +Notes: + + * this command does NOT save any files--you must save the + outer file and any modified, included files. + + * except for the `Top' node, this command does NOT handle any + pre-existing nodes in the outer file; hence, indices must be + enclosed in an included file. + +Requirements: + + * each of the included files must contain exactly one highest + hierarchical level node, + * this highest node must be the first node in the included file, + * each highest hierarchical level node must be of the same type. + +Thus, normally, each included file contains one, and only one, +chapter." + t nil) + + +;;; Code: + +;;; Don't you dare insert any `require' calls at top level in this file--rms. + +;;; Syntax table + +(defvar texinfo-mode-syntax-table nil) + +(if texinfo-mode-syntax-table + nil + (setq texinfo-mode-syntax-table (make-syntax-table)) + (modify-syntax-entry ?\" " " texinfo-mode-syntax-table) + (modify-syntax-entry ?\\ " " texinfo-mode-syntax-table) + (modify-syntax-entry ?@ "\\" texinfo-mode-syntax-table) + (modify-syntax-entry ?\^q "\\" texinfo-mode-syntax-table) + (modify-syntax-entry ?\[ "(]" texinfo-mode-syntax-table) + (modify-syntax-entry ?\] ")[" texinfo-mode-syntax-table) + (modify-syntax-entry ?{ "(}" texinfo-mode-syntax-table) + (modify-syntax-entry ?} "){" texinfo-mode-syntax-table) + (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table)) + +;; Written by Wolfgang Bangerth +;; To override this example, set either `imenu-generic-expression' +;; or `imenu-create-index-function'. +(defvar texinfo-imenu-generic-expression + '((nil "^@node[ \t]+\\([^,\n]*\\)" 1) + ("Chapters" "^@chapter[ \t]+\\(.*\\)$" 1)) + + "Imenu generic expression for TexInfo mode. See `imenu-generic-expression'.") + +(defvar texinfo-font-lock-keywords + '(;; All but the first 2 had an OVERRIDE of t. + ;; It didn't seem to be any better, and it's slower--simon. + ("^\\(@c\\|@comment\\)\\>.*" . font-lock-comment-face) ;comments + ;; Robert J. Chassell says remove this line. + ;("\\$\\([^$]*\\)\\$" 1 font-lock-string-face t) + ("@\\([a-zA-Z]+\\|[^ \t\n]\\)" 1 font-lock-keyword-face) ;commands + ("^\\*\\(.*\\)[\t ]*$" 1 font-lock-function-name-face t) ;menu items + ("@\\(emph\\|strong\\|b\\|i\\){\\([^}]+\\)" 2 font-lock-comment-face) + ("@\\(file\\|kbd\\|key\\){\\([^}]+\\)" 2 font-lock-string-face) + ("@\\(samp\\|code\\|var\\|math\\){\\([^}]+\\)" + 2 font-lock-variable-name-face) + ("@\\(cite\\|xref\\|pxref\\){\\([^}]+\\)" 2 font-lock-reference-face) + ("@\\(end\\|itemx?\\) +\\(.+\\)" 2 font-lock-function-name-face keep) + ) + "Additional expressions to highlight in TeXinfo mode.") + +(defvar texinfo-section-list + '(("top" 1) + ("majorheading" 1) + ("chapter" 2) + ("unnumbered" 2) + ("appendix" 2) + ("chapheading" 2) + ("section" 3) + ("unnumberedsec" 3) + ("appendixsec" 3) + ("heading" 3) + ("subsection" 4) + ("unnumberedsubsec" 4) + ("appendixsubsec" 4) + ("subheading" 4) + ("subsubsection" 5) + ("unnumberedsubsubsec" 5) + ("appendixsubsubsec" 5) + ("subsubheading" 5)) + "Alist of sectioning commands and their relative level.") + +(defun texinfo-outline-level () + ;; Calculate level of current texinfo outline heading. + (save-excursion + (if (bobp) + 0 + (forward-char 1) + (let* ((word (buffer-substring-no-properties + (point) (progn (forward-word 1) (point)))) + (entry (assoc word texinfo-section-list))) + (if entry + (nth 1 entry) + 5))))) + + +;;; Keybindings +(defvar texinfo-mode-map nil) + +;;; Keys common both to Texinfo mode and to TeX shell. + +(defun texinfo-define-common-keys (keymap) + "Define the keys both in Texinfo mode and in the texinfo-tex-shell." + (define-key keymap "\C-c\C-t\C-k" 'tex-kill-job) + (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-job) + (define-key keymap "\C-c\C-t\C-l" 'tex-recenter-output-buffer) + (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-print-queue) + (define-key keymap "\C-c\C-t\C-q" 'tex-show-print-queue) + (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print) + (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex) + + (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region) + (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer)) + +;; Mode documentation displays commands in reverse order +;; from how they are listed in the texinfo-mode-map. + +(if texinfo-mode-map + nil + (setq texinfo-mode-map (make-sparse-keymap)) + + ;; bindings for `texnfo-tex.el' + (texinfo-define-common-keys texinfo-mode-map) + + ;; bindings for `makeinfo.el' + (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) + (define-key texinfo-mode-map "\C-c\C-m\C-l" + 'makeinfo-recenter-compilation-buffer) + (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) + (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) + + ;; bindings for `texinfmt.el' + (define-key texinfo-mode-map "\C-c\C-e\C-r" 'texinfo-format-region) + (define-key texinfo-mode-map "\C-c\C-e\C-b" 'texinfo-format-buffer) + + ;; bindings for updating nodes and menus + + (define-key texinfo-mode-map "\C-c\C-um" 'texinfo-master-menu) + + (define-key texinfo-mode-map "\C-c\C-u\C-m" 'texinfo-make-menu) + (define-key texinfo-mode-map "\C-c\C-u\C-n" 'texinfo-update-node) + (define-key texinfo-mode-map "\C-c\C-u\C-e" 'texinfo-every-node-update) + (define-key texinfo-mode-map "\C-c\C-u\C-a" 'texinfo-all-menus-update) + + (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure) + + (define-key texinfo-mode-map "\C-c}" 'up-list) + (define-key texinfo-mode-map "\C-c]" 'up-list) + (define-key texinfo-mode-map "\C-c{" 'texinfo-insert-braces) + + ;; bindings for inserting strings + + (define-key texinfo-mode-map "\C-c\C-c\C-d" 'texinfo-start-menu-description) + + (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var) + (define-key texinfo-mode-map "\C-c\C-ct" 'texinfo-insert-@table) + (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp) + (define-key texinfo-mode-map "\C-c\C-co" 'texinfo-insert-@noindent) + (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node) + (define-key texinfo-mode-map "\C-c\C-ck" 'texinfo-insert-@kbd) + (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item) + (define-key texinfo-mode-map "\C-c\C-cf" 'texinfo-insert-@file) + (define-key texinfo-mode-map "\C-c\C-cx" 'texinfo-insert-@example) + (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end) + (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn) + (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code)) + + +;;; Texinfo mode + +(defvar texinfo-chapter-level-regexp + "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" + "Regular expression matching Texinfo chapter-level headings. +This does not match `@node' and does not match the `@top' command.") + +;;;###autoload +(defun texinfo-mode () + "Major mode for editing Texinfo files. + + It has these extra commands: +\\{texinfo-mode-map} + + These are files that are used as input for TeX to make printed manuals +and also to be turned into Info files with \\[makeinfo-buffer] or +the `makeinfo' program. These files must be written in a very restricted and +modified version of TeX input format. + + Editing commands are like text-mode except that the syntax table is +set up so expression commands skip Texinfo bracket groups. To see +what the Info version of a region of the Texinfo file will look like, +use \\[makeinfo-region], which runs `makeinfo' on the current region. + + You can show the structure of a Texinfo file with \\[texinfo-show-structure]. +This command shows the structure of a Texinfo file by listing the +lines with the @-sign commands for @chapter, @section, and the like. +These lines are displayed in another window called the *Occur* window. +In that window, you can position the cursor over one of the lines and +use \\[occur-mode-goto-occurrence], to jump to the corresponding spot +in the Texinfo file. + + In addition, Texinfo mode provides commands that insert various +frequently used @-sign commands into the buffer. You can use these +commands to save keystrokes. And you can insert balanced braces with +\\[texinfo-insert-braces] and later use the command \\[up-list] to +move forward past the closing brace. + +Also, Texinfo mode provides functions for automatically creating or +updating menus and node pointers. These functions + + * insert the `Next', `Previous' and `Up' pointers of a node, + * insert or update the menu for a section, and + * create a master menu for a Texinfo source file. + +Here are the functions: + + texinfo-update-node \\[texinfo-update-node] + texinfo-every-node-update \\[texinfo-every-node-update] + texinfo-sequential-node-update + + texinfo-make-menu \\[texinfo-make-menu] + texinfo-all-menus-update \\[texinfo-all-menus-update] + texinfo-master-menu + + texinfo-indent-menu-description (column &optional region-p) + +The `texinfo-column-for-description' variable specifies the column to +which menu descriptions are indented. + +Passed an argument (a prefix argument, if interactive), the +`texinfo-update-node' and `texinfo-make-menu' functions do their jobs +in the region. + +To use the updating commands, you must structure your Texinfo file +hierarchically, such that each `@node' line, with the exception of the +Top node, is accompanied by some kind of section line, such as an +`@chapter' or `@section' line. + +If the file has a `top' node, it must be called `top' or `Top' and +be the first node in the file. + +Entering Texinfo mode calls the value of text-mode-hook, and then the +value of texinfo-mode-hook." + (interactive) + (text-mode) + (setq mode-name "Texinfo") + (setq major-mode 'texinfo-mode) + (use-local-map texinfo-mode-map) + (set-syntax-table texinfo-mode-syntax-table) + (make-local-variable 'page-delimiter) + (setq page-delimiter + (concat + "^@node [ \t]*[Tt]op\\|^@\\(" + texinfo-chapter-level-regexp + "\\)")) + (make-local-variable 'require-final-newline) + (setq require-final-newline t) + (make-local-variable 'indent-tabs-mode) + (setq indent-tabs-mode nil) + (make-local-variable 'paragraph-separate) + (setq paragraph-separate (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate)) + (make-local-variable 'paragraph-start) + (setq paragraph-start (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-start)) + (make-local-variable 'fill-column) + (setq fill-column 72) + (make-local-variable 'comment-start) + (setq comment-start "@c ") + (make-local-variable 'comment-start-skip) + (setq comment-start-skip "@c +") + (make-local-variable 'words-include-escapes) + (setq words-include-escapes t) + (make-local-variable 'imenu-generic-expression) + (setq imenu-generic-expression texinfo-imenu-generic-expression) + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults '(texinfo-font-lock-keywords t)) + (make-local-variable 'outline-regexp) + (setq outline-regexp + (concat "@\\(" + (mapconcat 'car texinfo-section-list "\\>\\|") + "\\>\\)")) + (make-local-variable 'outline-level) + (setq outline-level 'texinfo-outline-level) + (make-local-variable 'tex-start-of-header) + (setq tex-start-of-header "%**start") + (make-local-variable 'tex-end-of-header) + (setq tex-end-of-header "%**end") + (run-hooks 'text-mode-hook 'texinfo-mode-hook)) + + +;;; Insert string commands + +;; Keep as concatinated lists for ease of maintenance +(defconst texinfo-environment-regexp + (concat + "^@" + "\\(" + "cartouche\\|" + "display\\|" + "end\\|" + "enumerate\\|" + "example\\|" + "f?table\\|" + "flushleft\\|" + "flushright\\|" + "format\\|" + "group\\|" + "ifhtml\\|" + "ifinfo\\|" + "iftex\\|" + "ignore\\|" + "itemize\\|" + "lisp\\|" + "macro\\|" + "multitable\\|" + "quotation\\|" + "smallexample\\|" + "smalllisp\\|" + "tex" + "\\)") + "Regexp for environment-like TexInfo list commands. + Subexpression 1 is what goes into the corresponding `@end' statement.") + +;; The following texinfo-insert-@end command not only inserts a SPC +;; after the @end, but tries to find out what belongs there. It is +;; not very smart: it does not understand nested lists. + +(defun texinfo-insert-@end () + "Insert the matching `@end' for the last Texinfo command that needs one." + (interactive) + (let ((depth 1) string) + (save-excursion + (while (and (> depth 0) + (re-search-backward texinfo-environment-regexp nil t) + (if (looking-at "@end") + (setq depth (1+ depth)) + (setq depth (1- depth))))) + (looking-at texinfo-environment-regexp) + (if (zerop depth) + (setq string + (buffer-substring (match-beginning 1) + (match-end 1))))) + (insert "@end ") + (if string (insert string "\n")))) + +;; The following insert commands accept a prefix arg N, which is the +;; number of words (actually s-exprs) that should be surrounded by +;; braces. Thus you can first paste a variable name into a .texinfo +;; buffer, then say C-u 1 C-c C-c v at the beginning of the just +;; pasted variable name to put @var{...} *around* the variable name. +;; Operate on previous word or words with negative arg. + +;; These commands use texinfo-insert-@-with-arg +(defun texinfo-insert-@-with-arg (string &optional arg) + (if arg + (progn + (setq arg (prefix-numeric-value arg)) + (if (< arg 0) + (progn + (skip-chars-backward " \t\n\r\f") + (save-excursion + (forward-sexp arg) + (insert "@" string "{")) + (insert "}")) + (skip-chars-forward " \t\n\r\f") + (insert "@" string "{") + (forward-sexp arg) + (insert "}"))) + (insert "@" string "{}") + (backward-char))) + +(defun texinfo-insert-braces () + "Make a pair of braces and be poised to type inside of them. +Use \\[up-list] to move forward out of the braces." + (interactive) + (insert "{}") + (backward-char)) + +(defun texinfo-insert-@code (&optional arg) + "Insert a `@code{...}' command in a Texinfo buffer. +A numeric argument says how many words the braces should surround. +The default is not to surround any existing words with the braces." + (interactive "P") + (texinfo-insert-@-with-arg "code" arg)) + +(defun texinfo-insert-@dfn (&optional arg) + "Insert a `@dfn{...}' command in a Texinfo buffer. +A numeric argument says how many words the braces should surround. +The default is not to surround any existing words with the braces." + (interactive "P") + (texinfo-insert-@-with-arg "dfn" arg)) + +(defun texinfo-insert-@example () + "Insert the string `@example' in a Texinfo buffer." + (interactive) + (insert "@example\n")) + +(defun texinfo-insert-@file (&optional arg) + "Insert a `@file{...}' command in a Texinfo buffer. +A numeric argument says how many words the braces should surround. +The default is not to surround any existing words with the braces." + (interactive "P") + (texinfo-insert-@-with-arg "file" arg)) + +(defun texinfo-insert-@item () + "Insert the string `@item' in a Texinfo buffer." + (interactive) + (insert "@item") + (newline)) + +(defun texinfo-insert-@kbd (&optional arg) + "Insert a `@kbd{...}' command in a Texinfo buffer. +A numeric argument says how many words the braces should surround. +The default is not to surround any existing words with the braces." + (interactive "P") + (texinfo-insert-@-with-arg "kbd" arg)) + +(defun texinfo-insert-@node () + "Insert the string `@node' in a Texinfo buffer. +This also inserts on the following line a comment indicating +the order of arguments to @node." + (interactive) + (insert "@node \n@comment node-name, next, previous, up") + (forward-line -1) + (forward-char 6)) + +(defun texinfo-insert-@noindent () + "Insert the string `@noindent' in a Texinfo buffer." + (interactive) + (insert "@noindent\n")) + +(defun texinfo-insert-@samp (&optional arg) + "Insert a `@samp{...}' command in a Texinfo buffer. +A numeric argument says how many words the braces should surround. +The default is not to surround any existing words with the braces." + (interactive "P") + (texinfo-insert-@-with-arg "samp" arg)) + +(defun texinfo-insert-@table (&optional arg) + "Insert the string `@table' in a Texinfo buffer." + (interactive "P") + (insert "@table ")) + +(defun texinfo-insert-@var (&optional arg) + "Insert a `@var{}' command in a Texinfo buffer. +A numeric argument says how many words the braces should surround. +The default is not to surround any existing words with the braces." + (interactive "P") + (texinfo-insert-@-with-arg "var" arg)) + +;;; Texinfo file structure + +;; These are defined in texnfo-upd.el. +;; texinfo-section-types-regexp +;; texinfo-section-level-regexp +;; texinfo-subsection-level-regexp +;; texinfo-subsubsection-level-regexp + +;; `texinfo-show-structure' requires texnfo-upd.el +(defun texinfo-show-structure (&optional nodes-too) + "Show the structure of a Texinfo file. +List the lines in the file that begin with the @-sign commands for +@chapter, @section, and the like. + +With optional argument (prefix if interactive), list both the lines +with @-sign commands for @chapter, @section, and the like, and list +@node lines. + +Lines with structuring commands beginning in them are displayed in +another buffer named `*Occur*'. In that buffer, you can move point to +one of those lines and then use \\\\[occur-mode-goto-occurrence], +to jump to the corresponding spot in the Texinfo source file." + + (interactive "P") + (require 'texnfo-upd) + (save-excursion + (goto-char (point-min)) + (if nodes-too + (occur (concat "\\(^@node\\)\\|" texinfo-section-types-regexp)) + (occur texinfo-section-types-regexp))) + (pop-to-buffer "*Occur*") + (goto-char (point-min)) + (flush-lines "-----") + ;; Now format the "*Occur*" buffer to show the structure. + ;; Thanks to ceder@signum.se (Per Cederqvist) + (goto-char (point-max)) + (let ((margin 5)) + (while (re-search-backward "^ *[0-9]*:" nil 0) + (re-search-forward ":") + (setq margin + (cond + ((looking-at + (concat "@\\(" texinfo-chapter-level-regexp "\\)")) 5) + ;; ((looking-at "@chapter ") 5) + ;; ((looking-at "@unnumbered ") 5) + ;; ((looking-at "@appendix ") 5) + ;; ((looking-at "@majorheading ") 5) + ;; ((looking-at "@chapheading ") 5) + + ((looking-at + (concat "@\\(" texinfo-section-level-regexp "\\)")) 9) + ;; ((looking-at "@section ") 9) + ;; ((looking-at "@unnumberedsec ") 9) + ;; ((looking-at "@appendixsec ") 9) + ;; ((looking-at "@heading ") 9) + + ((looking-at + (concat "@\\(" texinfo-subsection-level-regexp "\\)")) 13) + ;; ((looking-at "@subsection ") 13) + ;; ((looking-at "@unnumberedsubsec ") 13) + ;; ((looking-at "@appendixsubsec ") 13) + ;; ((looking-at "@subheading ") 13) + + ((looking-at + (concat "@\\(" texinfo-subsubsection-level-regexp "\\)")) 17) + ;; ((looking-at "@subsubsection ") 17) + ;; ((looking-at "@unnumberedsubsubsec ") 17) + ;; ((looking-at "@appendixsubsubsec ") 17) + ;; ((looking-at "@subsubheading ") 17) + (t margin))) + (indent-to-column margin) + (beginning-of-line)))) + +;;; The tex and print function definitions: + +(defvar texinfo-texi2dvi-command "texi2dvi" + "*Command used by `texinfo-tex-buffer' to run TeX and texindex on a buffer.") + +(defvar texinfo-tex-command "tex" + "*Command used by `texinfo-tex-region' to run TeX on a region.") + +(defvar texinfo-texindex-command "texindex" + "*Command used by `texinfo-texindex' to sort unsorted index files.") + +(defvar texinfo-delete-from-print-queue-command "lprm" + "*Command string used to delete a job from the line printer queue. +Command is used by \\[texinfo-delete-from-print-queue] based on +number provided by a previous \\[tex-show-print-queue] +command.") + +(defvar texinfo-tex-trailer "@bye" + "String appended after a region sent to TeX by `texinfo-tex-region'.") + +(defun texinfo-tex-region (beg end) + "Run TeX on the current region. +This works by writing a temporary file (`tex-zap-file') in the directory +that is the value of `tex-directory', then running TeX on that file. + +The first line of the buffer is copied to the +temporary file; and if the buffer has a header, it is written to the +temporary file before the region itself. The buffer's header is all lines +between the strings defined by `tex-start-of-header' and `tex-end-of-header' +inclusive. The header must start in the first 100 lines. + +The value of `texinfo-tex-trailer' is appended to the temporary file after the region." + (interactive "r") + (require 'tex-mode) + (if (get-buffer "*tex-shell*") + (tex-kill-job) + (tex-start-shell)) + (or tex-zap-file (setq tex-zap-file (make-temp-name "#tz"))) + (let ((tex-out-file (concat tex-zap-file ".tex")) + (temp-buffer (get-buffer-create " tex-Output-Buffer")) + (zap-directory + (file-name-as-directory (expand-file-name tex-directory)))) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line 100) + (let ((search-end (point)) + (hbeg (point-min)) (hend (point-min)) + (default-directory zap-directory)) + (goto-char (point-min)) + + ;; Copy first line, the `\input texinfo' line, to temp file + (write-region (point) + (save-excursion (end-of-line) (point)) + tex-out-file nil nil) + + ;; Don't copy first line twice if region includes it. + (forward-line 1) + (if (< beg (point)) (setq beg (point))) + + ;; Initialize the temp file with either the header or nothing + (if (search-forward tex-start-of-header search-end t) + (progn + (beginning-of-line) + (setq hbeg (point)) ; Mark beginning of header. + (if (search-forward tex-end-of-header nil t) + (progn (beginning-of-line) + (setq hend (point))) ; Mark end of header. + (setq hbeg (point-min))))) ; Else no header. + + ;; Copy header to temp file. + (write-region (min hbeg beg) hend tex-out-file t nil) + + ;; Copy region to temp file. + (write-region (max beg hend) end tex-out-file t nil)) + + ;; This is a kludge to insert the tex-trailer into the tex-out-file. + ;; We have to create a special buffer in which to insert + ;; the tex-trailer first because there is no function with + ;; which to append a literal string directly to a file. + (let ((local-tex-trailer texinfo-tex-trailer)) + (set-buffer temp-buffer) + (erase-buffer) + ;; make sure trailer isn't hidden by a comment + (insert-string "\n") + (if local-tex-trailer (insert-string local-tex-trailer)) + (tex-set-buffer-directory temp-buffer zap-directory) + (write-region (point-min) (point-max) tex-out-file t nil)) + +;;; The following is sufficient in Emacs 19. +;;; (write-region (concat "\n" texinfo-tex-trailer) nil +;;; tex-out-file t nil) + )) + + (tex-set-buffer-directory "*tex-shell*" zap-directory) + (tex-send-command tex-shell-cd-command zap-directory) + (tex-send-command texinfo-tex-command tex-out-file) + ;; alternatively: + ;; (send-string "tex-shell" (concat tex-shell-cd-command " " + ;; zap-directory "\n")) + ;; (send-string "tex-shell" (concat texinfo-tex-command " " + ;; tex-out-file "\n")) + (tex-recenter-output-buffer 0))) + +(defun texinfo-tex-buffer () + "Run TeX on visited file, once or twice, to make a correct `.dvi' file." + (interactive) + + ;; Make sure TeX shell is running. + (require 'tex-mode) + (if (get-buffer "*tex-shell*") + (quit-process (get-process "tex-shell") t) + (tex-start-shell)) + + (cond ((null buffer-file-name) + (error "Buffer not visiting any file!")) + ((buffer-modified-p) + (error "Buffer has been modified since last saved!"))) + + (setq tex-zap-file buffer-file-name) + + (tex-send-command tex-shell-cd-command (file-name-directory tex-zap-file)) + + (tex-send-command texinfo-texi2dvi-command tex-zap-file) + + ;; alternatively: + ;; (send-string "tex-shell" + ;; (concat tex-shell-cd-command + ;; " " (file-name-directory tex-zap-file) "\n")) + ;; ) + ;; + ;; (send-string "tex-shell" + ;; (concat texinfo-texi2dvi-command " " tex-zap-file "\n")) + + + (tex-recenter-output-buffer 0)) + +(defun texinfo-texindex () + "Run `texindex' on unsorted index files. +The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. +This runs the shell command defined by `texinfo-texindex-command'." + (interactive) + (require 'tex-mode) + (tex-send-command texinfo-texindex-command (concat tex-zap-file ".??")) + ;; alternatively + ;; (send-string "tex-shell" + ;; (concat texinfo-texindex-command + ;; " " tex-zap-file ".??" "\n")) + (tex-recenter-output-buffer nil)) + +(defun texinfo-tex-print () + "Print `.dvi' file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. +This runs the shell command defined by `tex-dvi-print-command'." + (interactive) + (require 'tex-mode) + (tex-send-command tex-dvi-print-command (concat tex-zap-file ".dvi")) + ;; alternatively: + ;; (send-string "tex-shell" + ;; (concat tex-dvi-print-command + ;; " " tex-zap-file ".dvi" "\n")) + (tex-recenter-output-buffer nil)) + +(defun texinfo-quit-job () + "Quit currently running TeX job, by sending an `x' to it." + (interactive) + (if (not (get-process "tex-shell")) + (error "No TeX shell running")) + (tex-send-command "x")) +;; alternatively: +;; save-excursion +;; (set-buffer (get-buffer "*tex-shell*")) +;; (goto-char (point-max)) +;; (insert "x") +;; (comint-send-input) + +(defun texinfo-delete-from-print-queue (job-number) + "Delete job from the line printer spooling queue. +You are prompted for the job number (use a number shown by a previous +\\[tex-show-print-queue] command)." + (interactive "nPrinter job number for deletion: ") + (require 'tex-mode) + (if (tex-shell-running) + (tex-kill-job) + (tex-start-shell)) + (tex-send-command texinfo-delete-from-print-queue-command job-number) + ;; alternatively + ;; (send-string "tex-shell" + ;; (concat + ;; texinfo-delete-from-print-queue-command + ;; " " + ;; job-number"\n")) + (tex-recenter-output-buffer nil)) + +(provide 'texinfo) + +;;; texinfo.el ends here diff --git a/texinfo/emacs/texnfo-tex.el b/texinfo/emacs/texnfo-tex.el new file mode 100644 index 000000000000..225ea685c042 --- /dev/null +++ b/texinfo/emacs/texnfo-tex.el @@ -0,0 +1,346 @@ +;;;; texnfo-tex.el + +;;; Texinfo mode TeX and hardcopy printing commands. + +;; These commands are for running TeX on a region of a Texinfo file in +;; GNU Emacs, or on the whole buffer, and for printing the resulting +;; DVI file. + +;;; Version 2.07 22 October 1991 +;;; Robert J. Chassell +;;; Please send bug reports to: bug-texinfo@prep.ai.mit.edu + +;;; Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. + + +;;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 Emacs; see the file COPYING. If not, write to +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, + + +;;; The Texinfo mode TeX related commands are: + +; texinfo-tex-region to run tex on the current region. +; texinfo-tex-buffer to run tex on the current buffer. +; texinfo-texindex to sort unsorted index files. +; texinfo-tex-print to print the .dvi file made by tex. +; texinfo-kill-tex-job to kill the currently running tex job. +; texinfo-recenter-tex-output-buffer to redisplay tex output buffer. +; texinfo-show-tex-print-queue to show the print queue. + + +;;; Keys common both to Texinfo mode and to TeX shell. + +;; Defined in `texinfo.el' +; (defun texinfo-define-common-keys (keymap) +; "Define the keys both in Texinfo mode and in the texinfo-tex-shell." +; (define-key keymap "\C-c\C-t\C-k" 'texinfo-kill-tex-job) +; (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-tex-job) +; (define-key keymap "\C-c\C-t\C-l" 'texinfo-recenter-tex-output-buffer) +; (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-tex-print-queue) +; (define-key keymap "\C-c\C-t\C-q" 'texinfo-show-tex-print-queue) +; (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print) +; (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex) +; (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region) +; (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer)) + +;; See also texinfo-tex-start-shell. +;; The following is executed in the `texinfo.el' file +;(texinfo-define-common-keys texinfo-mode-map) + + +;;; Variable definitions: + +(require 'shell) + +(defvar texinfo-tex-shell-cd-command "cd" + "Command to give to shell running TeX to change directory.") + +(defvar texinfo-tex-command "tex" + "*Command used by texinfo-tex-region to run tex on a region.") + +(defvar texinfo-texindex-command "texindex" + "*Command used by texinfo-texindex to sort unsorted index files.") + +(defvar texinfo-tex-dvi-print-command "lpr -d" + "*Command string used by \\[tex-print] to print a .dvi file.") + +(defvar texinfo-show-tex-queue-command "lpq" + "*Command string used to show the Texinfo TeX print queue. +Command is used by \\[texinfo-show-tex-print-queue] and it +should show the queue that \\[texinfo-tex-print] puts jobs on.") + +(defvar texinfo-delete-from-print-queue-command "lprm" + "*Command string used to delete a job from the line printer queue. +Command is used by \\[texinfo-delete-from-tex-print-queue] based on +number provided by a previous \\[texinfo-show-tex-print-queue] +command.") + +(defvar texinfo-tex-trailer "@bye" + "String appended after a region sent to TeX by texinfo-tex-region.") + +(defvar texinfo-tex-original-file "" + "Original name of file on which to run TeX.") + +(defvar texinfo-tex-temp-file nil + "Temporary file name used for text being sent as input to TeX.") + +(defvar texinfo-tex-root-temp-file nil + "Temporary file name used for text being sent as input to TeX.") + + +;;; Texinfo TeX main functions + +(defun texinfo-tex-region (beginning end) + "Run tex on the current region. + +A temporary file is written in the default directory, and tex is run +in that directory. The first line of the file is copied to the +temporary file; and if the buffer has a header, it is written to the +temporary file before the region itself. The buffer's header is all +lines between the strings defined by texinfo-start-of-header and +texinfo-end-of-header inclusive. The header must start in the first 100 +lines. The value of texinfo-tex-trailer is appended to the temporary file +after the region." + + (interactive "r") + (if (get-buffer "*texinfo-tex-shell*") + (quit-process (get-process "texinfo-tex-shell") t) + (texinfo-tex-start-shell)) + + (setq texinfo-tex-root-temp-file + (expand-file-name + (make-temp-name + (prin1-to-string (read (buffer-name)))))) + + (let ((texinfo-tex-temp-file (concat texinfo-tex-root-temp-file ".tex"))) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line 100) + (let ((search-end (point)) + (header-beginning (point-min)) (header-end (point-min))) + (goto-char (point-min)) + ;; Copy first line, the `\input texinfo' line, to temp file + (write-region (point) + (save-excursion (forward-line 1) (point)) + texinfo-tex-temp-file nil nil) + ;; Don't copy first line twice if region includes it. + (forward-line 1) + (if (< beginning (point)) (setq beginning (point))) + ;; Initialize the temp file with either the header or nothing + (if (search-forward texinfo-start-of-header search-end t) + (progn + (beginning-of-line) + (setq header-beginning (point)) ; Mark beginning of header. + (if (search-forward texinfo-end-of-header nil t) + (progn (beginning-of-line) + (setq header-end (point))) ; Mark end of header. + (setq header-beginning (point-min))))) ; Else no header. + ;; Copy header to temp file. + (write-region + (min header-beginning beginning ) + header-end + texinfo-tex-temp-file t nil) + ;; Copy region to temp file. + (write-region + (max beginning header-end) + end + texinfo-tex-temp-file t nil) + ;; This is a kludge to insert the texinfo-tex-trailer into the + ;; texinfo-tex-temp-file. We have to create a special buffer + ;; in which to insert the texinfo-tex-trailer first because there is + ;; no function with which to append a literal string directly + ;; to a file. + (let ((local-tex-trailer texinfo-tex-trailer) + (temp-buffer (get-buffer-create " texinfo-trailer-buffer"))) + (set-buffer temp-buffer) + (erase-buffer) + ;; make sure trailer isn't hidden by a comment + (insert-string "\n") + (if local-tex-trailer (insert local-tex-trailer)) + (write-region (point-min) (point-max) + texinfo-tex-temp-file t nil))) + (set-process-sentinel (get-process "texinfo-tex-shell") + 'texinfo-tex-shell-sentinel) + (send-string "texinfo-tex-shell" + (concat texinfo-tex-shell-cd-command " " + default-directory "\n")) + (send-string "texinfo-tex-shell" + (concat texinfo-tex-command " " + texinfo-tex-temp-file "\n ")) + (texinfo-recenter-tex-output-buffer 0))))) + +(defun texinfo-tex-buffer (buffer) + "Run TeX on current buffer. +After running TeX the first time, you may have to run \\[texinfo-texindex] +and then \\[texinfo-tex-buffer] again." + (interactive + (list + ;; Sometimes you put point into *texinfo-tex-shell*; this prompts + ;; you for the correct file regardless. + (if (and + (string= (buffer-name (current-buffer)) "*texinfo-tex-shell*") + texinfo-tex-root-temp-file) + (read-string (format "Run TeX on: ") + texinfo-tex-original-file) + (read-string (format "Run TeX on: ") (buffer-name (current-buffer)))))) + + ;; Set to original buffer if in *texinfo-tex-shell*; otherwise, + ;; record name of current buffer. + (if (string= (buffer-name (current-buffer)) "*texinfo-tex-shell*") + (set-buffer buffer) + (setq texinfo-tex-original-file + (buffer-name (current-buffer)))) + + (if (get-buffer "*texinfo-tex-shell*") + (quit-process (get-process "texinfo-tex-shell") t) + (texinfo-tex-start-shell)) + (cond ((null buffer-file-name) + (error "Buffer not visiting any file!")) + ((buffer-modified-p) + (error "Buffer has been modified since last saved!")) + (t (set-process-sentinel (get-process "texinfo-tex-shell") + 'texinfo-tex-shell-sentinel) + (send-string "texinfo-tex-shell" + (concat texinfo-tex-shell-cd-command + " " + (file-name-directory + (buffer-file-name + (get-buffer buffer))) + "\n")) + (send-string "texinfo-tex-shell" + (concat texinfo-tex-command " " buffer "\n ")) + + ;; so the texinfo-tex-print command works + (setq texinfo-tex-root-temp-file + (substring buffer 0 + (or (string-match "\\.tex" buffer) + (length buffer)))) + + (texinfo-recenter-tex-output-buffer 0)))) + +(defun texinfo-texindex () + "Run texindex on unsorted index files. +The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. +Runs the shell command defined by texinfo-texindex-command." + (interactive) + (send-string "texinfo-tex-shell" + (concat texinfo-texindex-command + " " texinfo-tex-root-temp-file ".??" "\n")) + (texinfo-recenter-tex-output-buffer nil)) + +(defun texinfo-tex-print () + "Print .dvi file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. +Runs the shell command defined by texinfo-tex-dvi-print-command." + (interactive) + (send-string "texinfo-tex-shell" + (concat texinfo-tex-dvi-print-command + " " texinfo-tex-root-temp-file ".dvi" "\n")) + (texinfo-recenter-tex-output-buffer nil)) + + +;;; Texinfo TeX utility functions + +(defun texinfo-tex-start-shell () + (save-excursion + (require 'texinfo) + (set-buffer (make-shell "texinfo-tex-shell" "/bin/sh" nil "-v")) + (setq texinfo-tex-shell-map (copy-keymap shell-mode-map)) + (texinfo-define-common-keys texinfo-tex-shell-map) + (use-local-map texinfo-tex-shell-map) + (run-hooks 'texinfo-tex-shell-hook) + (if (zerop (buffer-size)) + (sleep-for 1)))) + +(defun texinfo-quit-tex-job () + "Quit currently running TeX job, by sending an `x' to it." + (interactive) + (if (not (get-process "texinfo-tex-shell")) + (error "No TeX shell running.")) + (save-excursion + (set-buffer (get-buffer "*texinfo-tex-shell*")) + (goto-char (point-max)) + (insert "x") + (shell-send-input))) + +(defun texinfo-kill-tex-job () + "Kill the currently running TeX job." + (interactive) + (if (get-process "texinfo-tex-shell") + ;; Use `texinfo-tex-shell-sentinel' to restart + ;; texinfo-tex-shell after it is killed. + (kill-process (get-process "texinfo-tex-shell")))) + +(defun texinfo-tex-shell-sentinel (process event) + "Restart texinfo-tex-shell after it is killed." + (if (equal event "killed\n") + (save-excursion + (set-buffer "*texinfo-tex-shell*") + (insert "\n") + (texinfo-tex-start-shell)))) + +(defun texinfo-recenter-tex-output-buffer (linenum) + "Redisplay buffer of TeX job output so that most recent output can be seen. +The last line of the buffer is displayed on +line LINE of the window, or centered if LINE is nil." + (interactive "P") + (let ((texinfo-tex-shell (get-buffer "*texinfo-tex-shell*")) + (old-buffer (current-buffer))) + (if (null texinfo-tex-shell) + (message "No TeX output buffer") + (pop-to-buffer texinfo-tex-shell) + (bury-buffer texinfo-tex-shell) + (goto-char (point-max)) + (recenter (if linenum + (prefix-numeric-value linenum) + (/ (window-height) 2))) + (pop-to-buffer old-buffer) + ))) + +(defun texinfo-show-tex-print-queue () + "Show the print queue that \\[texinfo-tex-print] put your job on. +Runs the shell command defined by texinfo-show-tex-queue-command." + (interactive) + (if (not (texinfo-tex-shell-running-p)) + (texinfo-tex-start-shell)) + (send-string "texinfo-tex-shell" + (concat texinfo-show-tex-queue-command "\n")) + (texinfo-recenter-tex-output-buffer nil)) + +(defun texinfo-delete-from-tex-print-queue (job-number) + "Delete job from the line printer spooling queue. +You are prompted for the job number (shown by a previous +\\[texinfo-show-tex-print-queue] command." + (interactive "nPrinter job number for deletion: ") + (if (texinfo-tex-shell-running-p) + (texinfo-kill-tex-job) + (texinfo-tex-start-shell)) + (send-string "texinfo-tex-shell" + (concat + texinfo-delete-from-print-queue-command + " " + job-number"\n")) + (texinfo-recenter-tex-output-buffer nil)) + +(defun texinfo-tex-shell-running-p () + (and (get-process "texinfo-tex-shell") + (eq (process-status (get-process "texinfo-tex-shell")) 'run))) + + +;;; Place `provide' at end of file. +(provide 'texnfo-tex) +;;;;;;;;;;;;;;;; end texnfo-tex.el ;;;;;;;;;;;;;;;; diff --git a/texinfo/emacs/texnfo-upd.el b/texinfo/emacs/texnfo-upd.el new file mode 100644 index 000000000000..4827fe5f8190 --- /dev/null +++ b/texinfo/emacs/texnfo-upd.el @@ -0,0 +1,2058 @@ +;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files + +;; Copyright 1989, 1990, 1991, 1992, 1996 Free Software Foundation, Inc. + +;; Author: Robert J. Chassell +;; Date: 12 Sep 1996 +;; Maintainer: Robert J. Chassell +;; Keywords: maint, tex, docs + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Known bug: update commands fail to ignore @ignore. + +;; Summary: how to use the updating commands + +;; The node and menu updating functions automatically + +;; * insert missing `@node' lines, +;; * insert the `Next', `Previous' and `Up' pointers of a node, +;; * insert or update the menu for a section, +;; * create a master menu for a Texinfo source file. +;; +;; Passed an argument, the `texinfo-update-node' and +;; `texinfo-make-menu' functions do their jobs in the region. +;; +;; In brief, the functions for creating or updating nodes and menus, are: +;; +;; texinfo-update-node (&optional region-p) +;; texinfo-every-node-update () +;; texinfo-sequential-node-update (&optional region-p) +;; +;; texinfo-make-menu (&optional region-p) +;; texinfo-all-menus-update () +;; texinfo-master-menu () +;; +;; texinfo-insert-node-lines (&optional title-p) +;; +;; texinfo-indent-menu-description (column &optional region-p) + +;; The `texinfo-column-for-description' variable specifies the column to +;; which menu descriptions are indented. + +;; Texinfo file structure +;; ---------------------- + +;; To use the updating commands, you must structure your Texinfo file +;; hierarchically. Each `@node' line, with the exception of the top +;; node, must be accompanied by some kind of section line, such as an +;; `@chapter' or `@section' line. Each node-line/section-line +;; combination must look like this: + +;; @node Lists and Tables, Cross References, Structuring, Top +;; @comment node-name, next, previous, up +;; @chapter Making Lists and Tables + +;; or like this (without the `@comment' line): + +;; @node Lists and Tables, Cross References, Structuring, Top +;; @chapter Making Lists and Tables + +;; If the file has a `top' node, it must be called `top' or `Top' and +;; be the first node in the file. + + +;;; The update node functions described in detail + +;; The `texinfo-update-node' function without an argument inserts +;; the correct next, previous and up pointers for the node in which +;; point is located (i.e., for the node preceding point). + +;; With an argument, the `texinfo-update-node' function inserts the +;; correct next, previous and up pointers for the nodes inside the +;; region. + +;; It does not matter whether the `@node' line has pre-existing +;; `Next', `Previous', or `Up' pointers in it. They are removed. + +;; The `texinfo-every-node-update' function runs `texinfo-update-node' +;; on the whole buffer. + +;; The `texinfo-sequential-node-update' function inserts the +;; immediately following and preceding node into the `Next' or +;; `Previous' pointers regardless of their hierarchical level. This is +;; only useful for certain kinds of text, like a novel, which you go +;; through sequentially. + + +;;; The menu making functions described in detail + +;; The `texinfo-make-menu' function without an argument creates or +;; updates a menu for the section encompassing the node that follows +;; point. With an argument, it makes or updates menus for the nodes +;; within or part of the marked region. + +;; Whenever an existing menu is updated, the descriptions from +;; that menu are incorporated into the new menu. This is done by copying +;; descriptions from the existing menu to the entries in the new menu +;; that have the same node names. If the node names are different, the +;; descriptions are not copied to the new menu. + +;; Menu entries that refer to other Info files are removed since they +;; are not a node within current buffer. This is a deficiency. + +;; The `texinfo-all-menus-update' function runs `texinfo-make-menu' +;; on the whole buffer. + +;; The `texinfo-master-menu' function creates an extended menu located +;; after the top node. (The file must have a top node.) The function +;; first updates all the regular menus in the buffer (incorporating the +;; descriptions from pre-existing menus), and then constructs a master +;; menu that includes every entry from every other menu. (However, the +;; function cannot update an already existing master menu; if one +;; exists, it must be removed before calling the function.) + +;; The `texinfo-indent-menu-description' function indents every +;; description in the menu following point, to the specified column. +;; Non-nil argument (prefix, if interactive) means indent every +;; description in every menu in the region. This function does not +;; indent second and subsequent lines of a multi-line description. + +;; The `texinfo-insert-node-lines' function inserts `@node' before the +;; `@chapter', `@section', and such like lines of a region in a Texinfo +;; file where the `@node' lines are missing. +;; +;; With a non-nil argument (prefix, if interactive), the function not +;; only inserts `@node' lines but also inserts the chapter or section +;; titles as the names of the corresponding nodes; and inserts titles +;; as node names in pre-existing `@node' lines that lack names. +;; +;; Since node names should be more concise than section or chapter +;; titles, node names so inserted will need to be edited manually. + + +;;; Code: + +;;; The menu making functions + +(defun texinfo-make-menu (&optional region-p) + "Without any prefix argument, make or update a menu. +Make the menu for the section enclosing the node found following point. + +Non-nil argument (prefix, if interactive) means make or update menus +for nodes within or part of the marked region. + +Whenever a menu exists, and is being updated, the descriptions that +are associated with node names in the pre-existing menu are +incorporated into the new menu. Otherwise, the nodes' section titles +are inserted as descriptions." + + (interactive "P") + (if (not region-p) + (let ((level (texinfo-hierarchic-level))) + (texinfo-make-one-menu level) + (message "Done...updated the menu. You may save the buffer.")) + ;; else + (message "Making or updating menus in %s... " (buffer-name)) + (let ((beginning (region-beginning)) + (region-end (region-end)) + (level (progn ; find section type following point + (goto-char (region-beginning)) + (texinfo-hierarchic-level)))) + (if (= region-end beginning) + (error "Please mark a region!")) + (save-excursion + (save-restriction + (widen) + + (while (texinfo-find-lower-level-node level region-end) + (setq level (texinfo-hierarchic-level)) ; new, lower level + (texinfo-make-one-menu level)) + + (while (and (< (point) region-end) + (texinfo-find-higher-level-node level region-end)) + (setq level (texinfo-hierarchic-level)) + (while (texinfo-find-lower-level-node level region-end) + (setq level (texinfo-hierarchic-level)) ; new, lower level + (texinfo-make-one-menu level)))))) + (message "Done...updated menus. You may save the buffer."))) + +(defun texinfo-make-one-menu (level) + "Make a menu of all the appropriate nodes in this section. +`Appropriate nodes' are those associated with sections that are +at the level specified by LEVEL. Point is left at the end of menu." + (let* + ((case-fold-search t) + (beginning + (save-excursion + (goto-char (texinfo-update-menu-region-beginning level)) + (end-of-line) + (point))) + (end (texinfo-update-menu-region-end level)) + (first (texinfo-menu-first-node beginning end)) + (node-name (progn + (goto-char beginning) + (beginning-of-line) + (texinfo-copy-node-name))) + (new-menu-list (texinfo-make-menu-list beginning end level))) + (if (texinfo-old-menu-p beginning first) + (progn + (texinfo-incorporate-descriptions new-menu-list) + (texinfo-incorporate-menu-entry-names new-menu-list) + (texinfo-delete-old-menu beginning first))) + (texinfo-insert-menu new-menu-list node-name))) + +(defun texinfo-all-menus-update (&optional update-all-nodes-p) + "Update every regular menu in a Texinfo file. +Update pre-existing master menu, if there is one. + +If called with a non-nil argument, this function first updates all the +nodes in the buffer before updating the menus." + (interactive "P") + (let ((case-fold-search t) + master-menu-p) + (save-excursion + (push-mark (point-max) t) + (goto-char (point-min)) + (message "Checking for a master menu in %s ... "(buffer-name)) + (save-excursion + (if (re-search-forward texinfo-master-menu-header nil t) + ;; Remove detailed master menu listing + (progn + (setq master-menu-p t) + (goto-char (match-beginning 0)) + (let ((end-of-detailed-menu-descriptions + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) (forward-char -1) + (point)))) + (delete-region (point) end-of-detailed-menu-descriptions))))) + + (if update-all-nodes-p + (progn + (message "Updating all nodes in %s ... " (buffer-name)) + (sleep-for 2) + (push-mark (point-max) t) + (goto-char (point-min)) + ;; Using the mark to pass bounds this way + ;; is kludgy, but it's not worth fixing. -- rms. + (let ((mark-active t)) + (texinfo-update-node t)))) + + (message "Updating all menus in %s ... " (buffer-name)) + (sleep-for 2) + (push-mark (point-max) t) + (goto-char (point-min)) + ;; Using the mark to pass bounds this way + ;; is kludgy, but it's not worth fixing. -- rms. + (let ((mark-active t)) + (texinfo-make-menu t)) + + (if master-menu-p + (progn + (message "Updating the master menu in %s... " (buffer-name)) + (sleep-for 2) + (texinfo-master-menu nil)))) + + (message "Done...updated all the menus. You may save the buffer."))) + +(defun texinfo-find-lower-level-node (level region-end) + "Search forward from point for node at any level lower than LEVEL. +Search is limited to the end of the marked region, REGION-END, +and to the end of the menu region for the level. + +Return t if the node is found, else nil. Leave point at the beginning +of the node if one is found; else do not move point." + (let ((case-fold-search t)) + (if (and (< (point) region-end) + (re-search-forward + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval (cdr (assoc level texinfo-update-menu-lower-regexps)))) + ;; the next higher level node marks the end of this + ;; section, and no lower level node will be found beyond + ;; this position even if region-end is farther off + (texinfo-update-menu-region-end level) + t)) + (goto-char (match-beginning 1))))) + +(defun texinfo-find-higher-level-node (level region-end) + "Search forward from point for node at any higher level than argument LEVEL. +Search is limited to the end of the marked region, REGION-END. + +Return t if the node is found, else nil. Leave point at the beginning +of the node if one is found; else do not move point." + (let ((case-fold-search t)) + (cond + ((or (string-equal "top" level) (string-equal "chapter" level)) + (if (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" region-end t) + (progn (beginning-of-line) t))) + (t + (if (re-search-forward + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) + region-end t) + (progn (beginning-of-line) t)))))) + + +;;; Making the list of new menu entries + +(defun texinfo-make-menu-list (beginning end level) + "Make a list of node names and their descriptions. +Point is left at the end of the menu region, but the menu is not inserted. + +First argument is position from which to start making menu list; +second argument is end of region in which to try to locate entries; +third argument is the level of the nodes that are the entries. + +Node names and descriptions are dotted pairs of strings. Each pair is +an element of the list. If the description does not exist, the +element consists only of the node name." + (goto-char beginning) + (let (new-menu-list) + (while (texinfo-menu-locate-entry-p level end) + (setq new-menu-list + (cons (cons + (texinfo-copy-node-name) + (prog1 "" (forward-line 1))) + ;; Use following to insert section titles automatically. + ;; (texinfo-copy-section-title)) + new-menu-list))) + (reverse new-menu-list))) + +(defun texinfo-menu-locate-entry-p (level search-end) + "Find a node that will be part of menu for this section. +First argument is a string such as \"section\" specifying the general +hierarchical level of the menu; second argument is a position +specifying the end of the search. + +The function returns t if the node is found, else nil. It searches +forward from point, and leaves point at the beginning of the node. + +The function finds entries of the same type. Thus `subsections' and +`unnumberedsubsecs' will appear in the same menu." + (let ((case-fold-search t)) + (if (re-search-forward + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval + (cdr (assoc level texinfo-update-menu-same-level-regexps)))) + search-end + t) + (goto-char (match-beginning 1))))) + +(defun texinfo-copy-node-name () + "Return the node name as a string. + +Start with point at the beginning of the node line; copy the text +after the node command up to the first comma on the line, if any, and +return the text as a string. Leaves point at the beginning of the +line. If there is no node name, returns an empty string." + + (save-excursion + (buffer-substring + (progn (forward-word 1) ; skip over node command + (skip-chars-forward " \t") ; and over spaces + (point)) + (if (search-forward + "," + (save-excursion (end-of-line) (point)) t) ; bound search + (1- (point)) + (end-of-line) (point))))) + +(defun texinfo-copy-section-title () + "Return the title of the section as a string. +The title is used as a description line in the menu when one does not +already exist. + +Move point to the beginning of the appropriate section line by going +to the start of the text matched by last regexp searched for, which +must have been done by `texinfo-menu-locate-entry-p'." + + ;; could use the same re-search as in `texinfo-menu-locate-entry-p' + ;; instead of using `match-beginning'; such a variation would be + ;; more general, but would waste information already collected + + (goto-char (match-beginning 7)) ; match section name + + (buffer-substring + (progn (forward-word 1) ; skip over section type + (skip-chars-forward " \t") ; and over spaces + (point)) + (progn (end-of-line) (point)))) + + +;;; Handling the old menu + +(defun texinfo-old-menu-p (beginning first) + "Move point to the beginning of the menu for this section, if any. +Otherwise move point to the end of the first node of this section. +Return t if a menu is found, nil otherwise. + +First argument is the position of the beginning of the section in which +the menu will be located; second argument is the position of the first +node within the section. + +If no menu is found, the function inserts two newlines just before the +end of the section, and leaves point there where a menu ought to be." + (goto-char beginning) + (if (not (re-search-forward "^@menu" first 'goto-end)) + (progn (insert "\n\n") (forward-line -2) nil) + t)) + +(defun texinfo-incorporate-descriptions (new-menu-list) + "Copy the old menu line descriptions that exist to the new menu. + +Point must be at beginning of old menu. + +If the node-name of the new menu is found in the old menu, insert the +old description into the new entry. + +For this function, the new menu is a list made up of lists of dotted +pairs in which the first element of the pair is the node name and the +second element the description. The new menu is changed destructively. +The old menu is the menu as it appears in the texinfo file." + + (let ((new-menu-list-pointer new-menu-list) + (end-of-menu (texinfo-menu-end))) + (while new-menu-list + (save-excursion ; keep point at beginning of menu + (if (re-search-forward + ;; Existing nodes can have the form + ;; * NODE NAME:: DESCRIPTION + ;; or + ;; * MENU ITEM: NODE NAME. DESCRIPTION. + ;; + ;; Recognize both when looking for the description. + (concat "\\* \\(" ; so only menu entries are found + (car (car new-menu-list)) "::" + "\\|" + ".*: " (car (car new-menu-list)) "[.,\t\n]" + "\\)" + ) ; so only complete entries are found + end-of-menu + t) + (setcdr (car new-menu-list) + (texinfo-menu-copy-old-description end-of-menu)))) + (setq new-menu-list (cdr new-menu-list))) + (setq new-menu-list new-menu-list-pointer))) + +(defun texinfo-incorporate-menu-entry-names (new-menu-list) + "Copy any old menu entry names to the new menu. + +Point must be at beginning of old menu. + +If the node-name of the new menu entry cannot be found in the old +menu, do nothing. + +For this function, the new menu is a list made up of lists of dotted +pairs in which the first element of the pair is the node name and the +second element is the description (or nil). + +If we find an existing menu entry name, we change the first element of +the pair to be another dotted pair in which the car is the menu entry +name and the cdr is the node name. + +NEW-MENU-LIST is changed destructively. The old menu is the menu as it +appears in the texinfo file." + + (let ((new-menu-list-pointer new-menu-list) + (end-of-menu (texinfo-menu-end))) + (while new-menu-list + (save-excursion ; keep point at beginning of menu + (if (re-search-forward + ;; Existing nodes can have the form + ;; * NODE NAME:: DESCRIPTION + ;; or + ;; * MENU ITEM: NODE NAME. DESCRIPTION. + ;; + ;; We're interested in the second case. + (concat "\\* " ; so only menu entries are found + "\\(.*\\): " (car (car new-menu-list)) "[.,\t\n]") + end-of-menu + t) + (setcar + (car new-menu-list) ; replace the node name + (cons (buffer-substring (match-beginning 1) (match-end 1)) + (car (car new-menu-list))))) + (setq new-menu-list (cdr new-menu-list)))) + (setq new-menu-list new-menu-list-pointer))) + +(defun texinfo-menu-copy-old-description (end-of-menu) + "Return description field of old menu line as string. +Point must be located just after the node name. Point left before description. +Single argument, END-OF-MENU, is position limiting search." + (skip-chars-forward "[:.,\t\n ]+") + ;; don't copy a carriage return at line beginning with asterisk! + ;; do copy a description that begins with an `@'! + ;; !! Known bug: does not copy descriptions starting with ^|\{?* etc. + (if (and (looking-at "\\(\\w+\\|@\\)") + (not (looking-at "\\(^\\* \\|^@end menu\\)"))) + (buffer-substring + (point) + (save-excursion + (re-search-forward "\\(^\\* \\|^@end menu\\)" end-of-menu t) + (forward-line -1) + (end-of-line) ; go to end of last description line + (point))) + "")) + +(defun texinfo-menu-end () + "Return position of end of menu. Does not change location of point. +Signal an error if not end of menu." + (save-excursion + (if (re-search-forward "^@end menu" nil t) + (point) + (error "Menu does not have an end.")))) + +(defun texinfo-delete-old-menu (beginning first) + "Delete the old menu. Point must be in or after menu. +First argument is position of the beginning of the section in which +the menu will be located; second argument is the position of the first +node within the section." + ;; No third arg to search, so error if search fails. + (re-search-backward "^@menu" beginning) + (delete-region (point) + (save-excursion + (re-search-forward "^@end menu" first) + (point)))) + + +;;; Inserting new menu + +;; try 32, but perhaps 24 is better +(defvar texinfo-column-for-description 32 + "*Column at which descriptions start in a Texinfo menu.") + +(defun texinfo-insert-menu (menu-list node-name) + "Insert formatted menu at point. +Indents the first line of the description, if any, to the value of +texinfo-column-for-description. + +MENU-LIST has form: + + \(\(\"node-name1\" . \"description\"\) + \(\"node-name2\" . \"description\"\) ... \) + +However, the description field might be nil. + +Also, the node-name field might itself be a dotted pair (call it P) of +strings instead of just a string. In that case, the car of P +is the menu entry name, and the cdr of P is the node name." + + (insert "@menu\n") + (while menu-list + ;; Every menu entry starts with a star and a space. + (insert "* ") + + ;; Insert the node name (and menu entry name, if present). + (let ((node-part (car (car menu-list)))) + (if (stringp node-part) + ;; "Double colon" entry line; menu entry and node name are the same, + (insert (format "%s::" node-part)) + ;; "Single colon" entry line; menu entry and node name are different. + (insert (format "%s: %s." (car node-part) (cdr node-part))))) + + ;; Insert the description, if present. + (if (cdr (car menu-list)) + (progn + ;; Move to right place. + (indent-to texinfo-column-for-description 2) + ;; Insert description. + (insert (format "%s" (cdr (car menu-list)))))) + + (insert "\n") ; end this menu entry + (setq menu-list (cdr menu-list))) + (insert "@end menu") + (message + "Updated \"%s\" level menu following node: %s ... " level node-name)) + + +;;; Starting menu descriptions by inserting titles + +(defun texinfo-start-menu-description () + "In this menu entry, insert the node's section title as a description. +Position point at beginning of description ready for editing. +Do not insert a title if the line contains an existing description. + +You will need to edit the inserted text since a useful description +complements the node name rather than repeats it as a title does." + + (interactive) + (let (beginning end node-name title) + (save-excursion + (beginning-of-line) + (if (search-forward "* " (save-excursion (end-of-line) (point)) t) + (progn (skip-chars-forward " \t") + (setq beginning (point))) + (error "This is not a line in a menu!")) + + (cond + ;; "Double colon" entry line; menu entry and node name are the same, + ((search-forward "::" (save-excursion (end-of-line) (point)) t) + (if (looking-at "[ \t]*[^ \t\n]+") + (error "Descriptive text already exists.")) + (skip-chars-backward ": \t") + (setq node-name (buffer-substring beginning (point)))) + + ;; "Single colon" entry line; menu entry and node name are different. + ((search-forward ":" (save-excursion (end-of-line) (point)) t) + (skip-chars-forward " \t") + (setq beginning (point)) + ;; Menu entry line ends in a period, comma, or tab. + (if (re-search-forward "[.,\t]" + (save-excursion (forward-line 1) (point)) t) + (progn + (if (looking-at "[ \t]*[^ \t\n]+") + (error "Descriptive text already exists.")) + (skip-chars-backward "., \t") + (setq node-name (buffer-substring beginning (point)))) + ;; Menu entry line ends in a return. + (re-search-forward ".*\n" + (save-excursion (forward-line 1) (point)) t) + (skip-chars-backward " \t\n") + (setq node-name (buffer-substring beginning (point))) + (if (= 0 (length node-name)) + (error "No node name on this line.") + (insert ".")))) + (t (error "No node name on this line."))) + ;; Search for node that matches node name, and copy the section title. + (if (re-search-forward + (concat + "^@node[ \t]+" + node-name + ".*\n" ; match node line + "\\(" + "\\(\\(^@c \\|^@comment\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)" ; ifinfo line, if any + "\\)?") + nil t) + (progn + (setq title + (buffer-substring + ;; skip over section type + (progn (forward-word 1) + ;; and over spaces + (skip-chars-forward " \t") + (point)) + (progn (end-of-line) + (skip-chars-backward " \t") + (point))))) + (error "Cannot find node to match node name in menu entry."))) + ;; Return point to the menu and insert the title. + (end-of-line) + (delete-region + (point) + (save-excursion (skip-chars-backward " \t") (point))) + (indent-to texinfo-column-for-description 2) + (save-excursion (insert title)))) + + +;;; Handling description indentation + +;; Since the make-menu functions indent descriptions, these functions +;; are useful primarily for indenting a single menu specially. + +(defun texinfo-indent-menu-description (column &optional region-p) + "Indent every description in menu following point to COLUMN. +Non-nil argument (prefix, if interactive) means indent every +description in every menu in the region. Does not indent second and +subsequent lines of a multi-line description." + + (interactive + "nIndent menu descriptions to (column number): \nP") + (save-excursion + (save-restriction + (widen) + (if (not region-p) + (progn + (re-search-forward "^@menu") + (texinfo-menu-indent-description column) + (message + "Indented descriptions in menu. You may save the buffer.")) + ;;else + (message "Indenting every menu description in region... ") + (goto-char (region-beginning)) + (while (and (< (point) (region-end)) + (texinfo-locate-menu-p)) + (forward-line 1) + (texinfo-menu-indent-description column)) + (message "Indenting done. You may save the buffer."))))) + +(defun texinfo-menu-indent-description (to-column-number) + "Indent the Texinfo file menu description to TO-COLUMN-NUMBER. +Start with point just after the word `menu' in the `@menu' line and +leave point on the line before the `@end menu' line. Does not indent +second and subsequent lines of a multi-line description." + (let* ((beginning-of-next-line (point))) + (while (< beginning-of-next-line + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) + (point))) + + (if (re-search-forward "\\* \\(.*::\\|.*: [^.,\t\n]+[.,\t]\\)" + (texinfo-menu-end) + t) + (progn + (let ((beginning-white-space (point))) + (skip-chars-forward " \t") ; skip over spaces + (if (looking-at "\\(@\\|\\w\\)+") ; if there is text + (progn + ;; remove pre-existing indentation + (delete-region beginning-white-space (point)) + (indent-to-column to-column-number)))))) + ;; position point at beginning of next line + (forward-line 1) + (setq beginning-of-next-line (point))))) + + +;;; Making the master menu + +(defun texinfo-master-menu (update-all-nodes-menus-p) + "Make a master menu for a whole Texinfo file. +Non-nil argument (prefix, if interactive) means first update all +existing nodes and menus. Remove pre-existing master menu, if there is one. + +This function creates a master menu that follows the top node. The +master menu includes every entry from all the other menus. It +replaces any existing ordinary menu that follows the top node. + +If called with a non-nil argument, this function first updates all the +menus in the buffer (incorporating descriptions from pre-existing +menus) before it constructs the master menu. + +The function removes the detailed part of an already existing master +menu. This action depends on the pre-existing master menu using the +standard `texinfo-master-menu-header'. + +The master menu has the following format, which is adapted from the +recommendation in the Texinfo Manual: + + * The first part contains the major nodes in the Texinfo file: the + nodes for the chapters, chapter-like sections, and the major + appendices. This includes the indices, so long as they are in + chapter-like sections, such as unnumbered sections. + + * The second and subsequent parts contain a listing of the other, + lower level menus, in order. This way, an inquirer can go + directly to a particular node if he or she is searching for + specific information. + +Each of the menus in the detailed node listing is introduced by the +title of the section containing the menu." + + (interactive "P") + (let ((case-fold-search t)) + (widen) + (goto-char (point-min)) + + ;; Move point to location after `top'. + (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) + (error "This buffer needs a Top node!")) + + (let ((first-chapter + (save-excursion + (or (re-search-forward "^@node" nil t) + (error "Too few nodes for a master menu!")) + (point)))) + (if (re-search-forward texinfo-master-menu-header first-chapter t) + ;; Remove detailed master menu listing + (progn + (goto-char (match-beginning 0)) + (let ((end-of-detailed-menu-descriptions + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) (forward-char -1) + (point)))) + (delete-region (point) end-of-detailed-menu-descriptions))))) + + (if update-all-nodes-menus-p + (progn + (message "Making a master menu in %s ...first updating all nodes... " + (buffer-name)) + (sleep-for 2) + (push-mark (point-max) t) + (goto-char (point-min)) + (texinfo-update-node t) + + (message "Updating all menus in %s ... " (buffer-name)) + (sleep-for 2) + (push-mark (point-max) t) + (goto-char (point-min)) + (texinfo-make-menu t))) + + (message "Now making the master menu in %s... " (buffer-name)) + (sleep-for 2) + (goto-char (point-min)) + (texinfo-insert-master-menu-list + (texinfo-master-menu-list)) + + ;; Remove extra newlines that texinfo-insert-master-menu-list + ;; may have inserted. + + (save-excursion + (goto-char (point-min)) + + (if (re-search-forward texinfo-master-menu-header nil t) + (progn + (goto-char (match-beginning 0)) + (insert "\n") + (delete-blank-lines) + (goto-char (point-min)))) + + (re-search-forward "^@menu") + (forward-line -1) + (delete-blank-lines) + + (re-search-forward "^@end menu") + (forward-line 1) + (delete-blank-lines)) + + (message + "Done...completed making master menu. You may save the buffer."))) + +(defun texinfo-master-menu-list () + "Return a list of menu entries and header lines for the master menu. + +Start with the menu for chapters and indices and then find each +following menu and the title of the node preceding that menu. + +The master menu list has this form: + + \(\(\(... \"entry-1-2\" \"entry-1\"\) \"title-1\"\) + \(\(... \"entry-2-2\" \"entry-2-1\"\) \"title-2\"\) + ...\) + +However, there does not need to be a title field." + + (let (master-menu-list) + (while (texinfo-locate-menu-p) + (setq master-menu-list + (cons (list + (texinfo-copy-menu) + (texinfo-copy-menu-title)) + master-menu-list))) + (reverse master-menu-list))) + +(defun texinfo-insert-master-menu-list (master-menu-list) + "Format and insert the master menu in the current buffer." + (goto-char (point-min)) + ;; Insert a master menu only after `Top' node and before next node + ;; \(or include file if there is no next node\). + (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) + (error "This buffer needs a Top node!")) + (let ((first-chapter + (save-excursion (re-search-forward "^@node\\|^@include") (point)))) + (if (not (re-search-forward "^@menu" first-chapter t)) + (error + "Buffer lacks ordinary `Top' menu in which to insert master."))) + (beginning-of-line) + (delete-region ; buffer must have ordinary top menu + (point) + (save-excursion (re-search-forward "^@end menu") (point))) + + (save-excursion ; leave point at beginning of menu + ;; Handle top of menu + (insert "\n@menu\n") + ;; Insert chapter menu entries + (setq this-very-menu-list (reverse (car (car master-menu-list)))) + ;; Tell user what is going on. + (message "Inserting chapter menu entry: %s ... " this-very-menu-list) + (while this-very-menu-list + (insert "* " (car this-very-menu-list) "\n") + (setq this-very-menu-list (cdr this-very-menu-list))) + + (setq master-menu-list (cdr master-menu-list)) + + ;; Only insert detailed master menu if there is one.... + (if (car (car master-menu-list)) +;; @detailmenu added 5 Sept 1996 at Karl Berry's request to avert a +;; bug in `makeinfo'; all agree this is a bad kluge and should +;; eventually be removed. @detailmenu ... @end detailmenu is a noop +;; in `texinfmt.el' See @end detailmenu below +;; also see `texinfo-all-menus-update' above, `texinfo-master-menu', +;; `texinfo-multiple-files-update' + (insert texinfo-master-menu-header)) + + ;; Now, insert all the other menus + + ;; The menu master-menu-list has a form like this: + ;; ((("beta" "alpha") "title-A") + ;; (("delta" "gamma") "title-B")) + + (while master-menu-list + + (message + "Inserting menu for %s .... " (car (cdr (car master-menu-list)))) + ;; insert title of menu section + (insert "\n" (car (cdr (car master-menu-list))) "\n\n") + + ;; insert each menu entry + (setq this-very-menu-list (reverse (car (car master-menu-list)))) + (while this-very-menu-list + (insert "* " (car this-very-menu-list) "\n") + (setq this-very-menu-list (cdr this-very-menu-list))) + + (setq master-menu-list (cdr master-menu-list))) + + ;; Finish menu +;; @detailmenu (see note above) + (insert "\n@end detailmenu") + (insert "\n@end menu\n\n"))) + +(defvar texinfo-master-menu-header + "\n@detailmenu\n --- The Detailed Node Listing ---\n" + "String inserted before lower level entries in Texinfo master menu. +It comes after the chapter-level menu entries.") + +(defun texinfo-locate-menu-p () + "Find the next menu in the texinfo file. +If found, leave point after word `menu' on the `@menu' line, and return t. +If a menu is not found, do not move point and return nil." + (re-search-forward "\\(^@menu\\)" nil t)) + +(defun texinfo-copy-menu-title () + "Return the title of the section preceding the menu as a string. +If such a title cannot be found, return an empty string. Do not move +point." + (let ((case-fold-search t)) + (save-excursion + (if (re-search-backward + (concat + "\\(^@top" + "\\|" ; or + texinfo-section-types-regexp ; all other section types + "\\)") + nil + t) + (progn + (beginning-of-line) + (forward-word 1) ; skip over section type + (skip-chars-forward " \t") ; and over spaces + (buffer-substring + (point) + (progn (end-of-line) (point)))) + "")))) + +(defun texinfo-copy-menu () + "Return the entries of an existing menu as a list. +Start with point just after the word `menu' in the `@menu' line +and leave point on the line before the `@end menu' line." + (let* (this-menu-list + (end-of-menu (texinfo-menu-end)) ; position of end of `@end menu' + (last-entry (save-excursion ; position of beginning of + ; last `* ' entry + (goto-char end-of-menu) + ;; handle multi-line description + (if (not (re-search-backward "^\\* " nil t)) + (error "No entries in menu.")) + (point)))) + (while (< (point) last-entry) + (if (re-search-forward "^\\* " end-of-menu t) + (progn + (setq this-menu-list + (cons + (buffer-substring + (point) + ;; copy multi-line descriptions + (save-excursion + (re-search-forward "\\(^\\* \\|^@e\\)" nil t) + (- (point) 3))) + this-menu-list))))) + this-menu-list)) + + +;;; Determining the hierarchical level in the texinfo file + +(defun texinfo-specific-section-type () + "Return the specific type of next section, as a string. +For example, \"unnumberedsubsec\". Return \"top\" for top node. + +Searches forward for a section. Hence, point must be before the +section whose type will be found. Does not move point. Signal an +error if the node is not the top node and a section is not found." + (let ((case-fold-search t)) + (save-excursion + (cond + ((re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" +;;; Following search limit by cph but causes a bug +;;; (save-excursion +;;; (end-of-line) +;;; (point)) + nil + t) + "top") + ((re-search-forward texinfo-section-types-regexp nil t) + (buffer-substring-no-properties + (progn (beginning-of-line) ; copy its name + (1+ (point))) + (progn (forward-word 1) + (point)))) + (t + (error + "texinfo-specific-section-type: Chapter or section not found.")))))) + +(defun texinfo-hierarchic-level () + "Return the general hierarchal level of the next node in a texinfo file. +Thus, a subheading or appendixsubsec is of type subsection." + (let ((case-fold-search t)) + (cdr (assoc + (texinfo-specific-section-type) + texinfo-section-to-generic-alist)))) + + +;;; Locating the major positions + +(defun texinfo-update-menu-region-beginning (level) + "Locate beginning of higher level section this section is within. +Return position of the beginning of the node line; do not move point. +Thus, if this level is subsection, searches backwards for section node. +Only argument is a string of the general type of section." + (let ((case-fold-search t)) + ;; !! Known bug: if section immediately follows top node, this + ;; returns the beginning of the buffer as the beginning of the + ;; higher level section. + (cond + ((or (string-equal "top" level) + (string-equal "chapter" level)) + (save-excursion + (goto-char (point-min)) + (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) + (beginning-of-line) + (point))) + (t + (save-excursion + (re-search-backward + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval + (cdr (assoc level texinfo-update-menu-higher-regexps)))) + nil + 'goto-beginning) + (point)))))) + +(defun texinfo-update-menu-region-end (level) + "Locate end of higher level section this section is within. +Return position; do not move point. Thus, if this level is a +subsection, find the node for the section this subsection is within. +If level is top or chapter, returns end of file. Only argument is a +string of the general type of section." + (let ((case-fold-search t)) + (save-excursion + (if (re-search-forward + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval + ;; Never finds end of level above chapter so goes to end. + (cdr (assoc level texinfo-update-menu-higher-regexps)))) + nil + 'goto-end) + (match-beginning 1) + (point-max))))) + +(defun texinfo-menu-first-node (beginning end) + "Locate first node of the section the menu will be placed in. +Return position; do not move point. +The menu will be located just before this position. + +First argument is the position of the beginning of the section in +which the menu will be located; second argument is the position of the +end of that region; it limits the search." + + (save-excursion + (goto-char beginning) + (forward-line 1) + (re-search-forward "^@node" end t) + (beginning-of-line) + (point))) + + +;;; Alists and regular expressions for defining hierarchical levels + +(defvar texinfo-section-to-generic-alist + '(("top" . "top") + + ("chapter" . "chapter") + ("unnumbered" . "chapter") + ("majorheading" . "chapter") + ("chapheading" . "chapter") + ("appendix" . "chapter") + + ("section" . "section") + ("unnumberedsec" . "section") + ("heading" . "section") + ("appendixsec" . "section") + + ("subsection" . "subsection") + ("unnumberedsubsec" . "subsection") + ("subheading" . "subsection") + ("appendixsubsec" . "subsection") + + ("subsubsection" . "subsubsection") + ("unnumberedsubsubsec" . "subsubsection") + ("subsubheading" . "subsubsection") + ("appendixsubsubsec" . "subsubsection")) + "*An alist of specific and corresponding generic Texinfo section types. +The keys are strings specifying specific types of section; the values +are strings of their corresponding general types.") + +;; We used to look for just sub, but that found @subtitle. +(defvar texinfo-section-types-regexp + "^@\\(chapter \\|sect\\|subs\\|subh\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" + "Regexp matching chapter, section, other headings (but not the top node).") + +(defvar texinfo-chapter-level-regexp + "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" + "Regular expression matching just the Texinfo chapter level headings.") + +(defvar texinfo-section-level-regexp + "section\\|unnumberedsec\\|heading \\|appendixsec" + "Regular expression matching just the Texinfo section level headings.") + +(defvar texinfo-subsection-level-regexp + "subsection\\|unnumberedsubsec\\|subheading\\|appendixsubsec" + "Regular expression matching just the Texinfo subsection level headings.") + +(defvar texinfo-subsubsection-level-regexp + "subsubsection\\|unnumberedsubsubsec\\|subsubheading\\|appendixsubsubsec" + "Regular expression matching just the Texinfo subsubsection level headings.") + +(defvar texinfo-update-menu-same-level-regexps + '(("top" . "top[ \t]+") + ("chapter" . + (concat "\\(^@\\)\\(" texinfo-chapter-level-regexp "\\)[ \t]*")) + ("section" . + (concat "\\(^@\\)\\(" texinfo-section-level-regexp "\\)[ \t]*")) + ("subsection" . + (concat "\\(^@\\)\\(" texinfo-subsection-level-regexp "\\)[ \t]+")) + ("subsubsection" . + (concat "\\(^@\\)\\(" texinfo-subsubsection-level-regexp "\\)[ \t]+"))) + "*Regexps for searching for same level sections in a Texinfo file. +The keys are strings specifying the general hierarchical level in the +document; the values are regular expressions.") + +(defvar texinfo-update-menu-higher-regexps + '(("top" . "^@node [ \t]*DIR") + ("chapter" . "^@node [ \t]*top[ \t]*\\(,\\|$\\)") + ("section" . + (concat + "\\(^@\\(" + texinfo-chapter-level-regexp + "\\)[ \t]*\\)")) + ("subsection" . + (concat + "\\(^@\\(" + texinfo-section-level-regexp + "\\|" + texinfo-chapter-level-regexp + "\\)[ \t]*\\)")) + ("subsubsection" . + (concat + "\\(^@\\(" + texinfo-subsection-level-regexp + "\\|" + texinfo-section-level-regexp + "\\|" + texinfo-chapter-level-regexp + "\\)[ \t]*\\)"))) + "*Regexps for searching for higher level sections in a Texinfo file. +The keys are strings specifying the general hierarchical level in the +document; the values are regular expressions.") + +(defvar texinfo-update-menu-lower-regexps + '(("top" . + (concat + "\\(^@\\(" + texinfo-chapter-level-regexp + "\\|" + texinfo-section-level-regexp + "\\|" + texinfo-subsection-level-regexp + "\\|" + texinfo-subsubsection-level-regexp + "\\)[ \t]*\\)")) + ("chapter" . + (concat + "\\(^@\\(" + texinfo-section-level-regexp + "\\|" + texinfo-subsection-level-regexp + "\\|" + texinfo-subsubsection-level-regexp + "\\)[ \t]*\\)")) + ("section" . + (concat + "\\(^@\\(" + texinfo-subsection-level-regexp + "\\|" + texinfo-subsubsection-level-regexp + "\\)[ \t]+\\)")) + ("subsection" . + (concat + "\\(^@\\(" + texinfo-subsubsection-level-regexp + "\\)[ \t]+\\)")) + ("subsubsection" . "nothing lower")) + "*Regexps for searching for lower level sections in a Texinfo file. +The keys are strings specifying the general hierarchical level in the +document; the values are regular expressions.") + + +;;; Updating a node + +;;;###autoload +(defun texinfo-update-node (&optional region-p) + "Without any prefix argument, update the node in which point is located. +Non-nil argument (prefix, if interactive) means update the nodes in the +marked region. + +The functions for creating or updating nodes and menus, and their +keybindings, are: + + texinfo-update-node (&optional region-p) \\[texinfo-update-node] + texinfo-every-node-update () \\[texinfo-every-node-update] + texinfo-sequential-node-update (&optional region-p) + + texinfo-make-menu (&optional region-p) \\[texinfo-make-menu] + texinfo-all-menus-update () \\[texinfo-all-menus-update] + texinfo-master-menu () + + texinfo-indent-menu-description (column &optional region-p) + +The `texinfo-column-for-description' variable specifies the column to +which menu descriptions are indented. Its default value is 32." + + (interactive "P") + (if (not region-p) + ;; update a single node + (let ((auto-fill-function nil) (auto-fill-hook nil)) + (if (not (re-search-backward "^@node" (point-min) t)) + (error "Node line not found before this position.")) + (texinfo-update-the-node) + (message "Done...updated the node. You may save the buffer.")) + ;; else + (let ((auto-fill-function nil) + (auto-fill-hook nil) + (beginning (region-beginning)) + (end (region-end))) + (if (= end beginning) + (error "Please mark a region!")) + (save-restriction + (narrow-to-region beginning end) + (goto-char beginning) + (push-mark (point) t) + (while (re-search-forward "^@node" (point-max) t) + (beginning-of-line) + (texinfo-update-the-node)) + (message "Done...updated nodes in region. You may save the buffer."))))) + +;;;###autoload +(defun texinfo-every-node-update () + "Update every node in a Texinfo file." + (interactive) + (save-excursion + (push-mark (point-max) t) + (goto-char (point-min)) + ;; Using the mark to pass bounds this way + ;; is kludgy, but it's not worth fixing. -- rms. + (let ((mark-active t)) + (texinfo-update-node t)) + (message "Done...updated every node. You may save the buffer."))) + +(defun texinfo-update-the-node () + "Update one node. Point must be at the beginning of node line. +Leave point at the end of the node line." + (texinfo-check-for-node-name) + (texinfo-delete-existing-pointers) + (message "Updating node: %s ... " (texinfo-copy-node-name)) + (save-restriction + (widen) + (let* + ((case-fold-search t) + (level (texinfo-hierarchic-level)) + (beginning (texinfo-update-menu-region-beginning level)) + (end (texinfo-update-menu-region-end level))) + (if (string-equal level "top") + (texinfo-top-pointer-case) + ;; else + (texinfo-insert-pointer beginning end level 'next) + (texinfo-insert-pointer beginning end level 'previous) + (texinfo-insert-pointer beginning end level 'up) + (texinfo-clean-up-node-line))))) + +(defun texinfo-top-pointer-case () + "Insert pointers in the Top node. This is a special case. + +The `Next' pointer is a pointer to a chapter or section at a lower +hierarchical level in the file. The `Previous' and `Up' pointers are +to `(dir)'. Point must be at the beginning of the node line, and is +left at the end of the node line." + + (texinfo-clean-up-node-line) + (insert ", " + (save-excursion + ;; There may be an @chapter or other such command between + ;; the top node line and the next node line, as a title + ;; for an `ifinfo' section. This @chapter command must + ;; must be skipped. So the procedure is to search for + ;; the next `@node' line, and then copy its name. + (if (re-search-forward "^@node" nil t) + (progn + (beginning-of-line) + (texinfo-copy-node-name)) + " ")) + ", (dir), (dir)")) + +(defun texinfo-check-for-node-name () + "Determine whether the node has a node name. Prompt for one if not. +Point must be at beginning of node line. Does not move point." + (save-excursion + (let ((initial (texinfo-copy-next-section-title))) + ;; This is not clean. Use `interactive' to read the arg. + (forward-word 1) ; skip over node command + (skip-chars-forward " \t") ; and over spaces + (if (not (looking-at "[^,\t\n ]+")) ; regexp based on what Info looks for + ; alternatively, use "[a-zA-Z]+" + (let ((node-name + (read-from-minibuffer + "Node name (use no @, commas, colons, or apostrophes): " + initial))) + (insert " " node-name)))))) + +(defun texinfo-delete-existing-pointers () + "Delete `Next', `Previous', and `Up' pointers. +Starts from the current position of the cursor, and searches forward +on the line for a comma and if one is found, deletes the rest of the +line, including the comma. Leaves point at beginning of line." + (let ((eol-point (save-excursion (end-of-line) (point)))) + (if (search-forward "," eol-point t) + (delete-region (1- (point)) eol-point))) + (beginning-of-line)) + +(defun texinfo-find-pointer (beginning end level direction) + "Move point to section associated with next, previous, or up pointer. +Return type of pointer (either 'normal or 'no-pointer). + +The first and second arguments bound the search for a pointer to the +beginning and end, respectively, of the enclosing higher level +section. The third argument is a string specifying the general kind +of section such as \"chapter\" or \"section\". When looking for the +`Next' pointer, the section found will be at the same hierarchical +level in the Texinfo file; when looking for the `Previous' pointer, +the section found will be at the same or higher hierarchical level in +the Texinfo file; when looking for the `Up' pointer, the section found +will be at some level higher in the Texinfo file. The fourth argument +\(one of 'next, 'previous, or 'up\) specifies whether to find the +`Next', `Previous', or `Up' pointer." + (let ((case-fold-search t)) + (cond ((eq direction 'next) + (forward-line 3) ; skip over current node + ;; Search for section commands accompanied by node lines; + ;; ignore section commands in the middle of nodes. + (if (re-search-forward + ;; A `Top' node is never a next pointer, so won't find it. + (concat + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval + (cdr (assoc level texinfo-update-menu-same-level-regexps)))) + end + t) + 'normal + 'no-pointer)) + ((eq direction 'previous) + (if (re-search-backward + (concat + "\\(" + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval + (cdr (assoc level texinfo-update-menu-same-level-regexps))) + "\\|" + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval + (cdr (assoc level texinfo-update-menu-higher-regexps))) + "\\|" + ;; Handle `Top' node specially. + "^@node [ \t]*top[ \t]*\\(,\\|$\\)" + "\\)") + beginning + t) + 'normal + 'no-pointer)) + ((eq direction 'up) + (if (re-search-backward + (concat + "\\(" + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) + "\\|" + ;; Handle `Top' node specially. + "^@node [ \t]*top[ \t]*\\(,\\|$\\)" + "\\)") + (save-excursion + (goto-char beginning) + (beginning-of-line) + (point)) + t) + 'normal + 'no-pointer)) + (t + (error "texinfo-find-pointer: lack proper arguments"))))) + +(defun texinfo-pointer-name (kind) + "Return the node name preceding the section command. +The argument is the kind of section, either normal or no-pointer." + (let (name) + (cond ((eq kind 'normal) + (end-of-line) ; this handles prev node top case + (re-search-backward ; when point is already + "^@node" ; at the beginning of @node line + (save-excursion (forward-line -3)) + t) + (setq name (texinfo-copy-node-name))) + ((eq kind 'no-pointer) + (setq name " "))) ; put a blank in the pointer slot + name)) + +(defun texinfo-insert-pointer (beginning end level direction) + "Insert the `Next', `Previous' or `Up' node name at point. +Move point forward. + +The first and second arguments bound the search for a pointer to the +beginning and end, respectively, of the enclosing higher level +section. The third argument is the hierarchical level of the Texinfo +file, a string such as \"section\". The fourth argument is direction +towards which the pointer is directed, one of `next, `previous, or +'up." + + (end-of-line) + (insert + ", " + (save-excursion + (texinfo-pointer-name + (texinfo-find-pointer beginning end level direction))))) + +(defun texinfo-clean-up-node-line () + "Remove extra commas, if any, at end of node line." + (end-of-line) + (skip-chars-backward ", ") + (delete-region (point) (save-excursion (end-of-line) (point)))) + + +;;; Updating nodes sequentially +;; These sequential update functions insert `Next' or `Previous' +;; pointers that point to the following or preceding nodes even if they +;; are at higher or lower hierarchical levels. This means that if a +;; section contains one or more subsections, the section's `Next' +;; pointer will point to the subsection and not the following section. +;; (The subsection to which `Next' points will most likely be the first +;; item on the section's menu.) + +;;;###autoload +(defun texinfo-sequential-node-update (&optional region-p) + "Update one node (or many) in a Texinfo file with sequential pointers. + +This function causes the `Next' or `Previous' pointer to point to the +immediately preceding or following node, even if it is at a higher or +lower hierarchical level in the document. Continually pressing `n' or +`p' takes you straight through the file. + +Without any prefix argument, update the node in which point is located. +Non-nil argument (prefix, if interactive) means update the nodes in the +marked region. + +This command makes it awkward to navigate among sections and +subsections; it should be used only for those documents that are meant +to be read like a novel rather than a reference, and for which the +Info `g*' command is inadequate." + + (interactive "P") + (if (not region-p) + ;; update a single node + (let ((auto-fill-function nil) (auto-fill-hook nil)) + (if (not (re-search-backward "^@node" (point-min) t)) + (error "Node line not found before this position.")) + (texinfo-sequentially-update-the-node) + (message + "Done...sequentially updated the node . You may save the buffer.")) + ;; else + (let ((auto-fill-function nil) + (auto-fill-hook nil) + (beginning (region-beginning)) + (end (region-end))) + (if (= end beginning) + (error "Please mark a region!")) + (save-restriction + (narrow-to-region beginning end) + (goto-char beginning) + (push-mark (point) t) + (while (re-search-forward "^@node" (point-max) t) + (beginning-of-line) + (texinfo-sequentially-update-the-node)) + (message + "Done...updated the nodes in sequence. You may save the buffer."))))) + +(defun texinfo-sequentially-update-the-node () + "Update one node such that the pointers are sequential. +A `Next' or `Previous' pointer points to any preceding or following node, +regardless of its hierarchical level." + + (texinfo-check-for-node-name) + (texinfo-delete-existing-pointers) + (message + "Sequentially updating node: %s ... " (texinfo-copy-node-name)) + (save-restriction + (widen) + (let* + ((case-fold-search t) + (level (texinfo-hierarchic-level))) + (if (string-equal level "top") + (texinfo-top-pointer-case) + ;; else + (texinfo-sequentially-insert-pointer level 'next) + (texinfo-sequentially-insert-pointer level 'previous) + (texinfo-sequentially-insert-pointer level 'up) + (texinfo-clean-up-node-line))))) + +(defun texinfo-sequentially-find-pointer (level direction) + "Find next or previous pointer sequentially in Texinfo file, or up pointer. +Move point to section associated with the pointer. Find point even if +it is in a different section. + +Return type of pointer (either 'normal or 'no-pointer). + +The first argument is a string specifying the general kind of section +such as \"chapter\" or \"section\". The section found will be at the +same hierarchical level in the Texinfo file, or, in the case of the up +pointer, some level higher. The second argument (one of 'next, +'previous, or 'up) specifies whether to find the `Next', `Previous', +or `Up' pointer." + (let ((case-fold-search t)) + (cond ((eq direction 'next) + (forward-line 3) ; skip over current node + (if (re-search-forward + texinfo-section-types-regexp + (point-max) + t) + 'normal + 'no-pointer)) + ((eq direction 'previous) + (if (re-search-backward + texinfo-section-types-regexp + (point-min) + t) + 'normal + 'no-pointer)) + ((eq direction 'up) + (if (re-search-backward + (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) + beginning + t) + 'normal + 'no-pointer)) + (t + (error "texinfo-sequential-find-pointer: lack proper arguments"))))) + +(defun texinfo-sequentially-insert-pointer (level direction) + "Insert the `Next', `Previous' or `Up' node name at point. +Move point forward. + +The first argument is the hierarchical level of the Texinfo file, a +string such as \"section\". The second argument is direction, one of +`next, `previous, or 'up." + + (end-of-line) + (insert + ", " + (save-excursion + (texinfo-pointer-name + (texinfo-sequentially-find-pointer level direction))))) + + +;;; Inserting `@node' lines +;; The `texinfo-insert-node-lines' function inserts `@node' lines as needed +;; before the `@chapter', `@section', and such like lines of a region +;; in a Texinfo file. + +(defun texinfo-insert-node-lines (beginning end &optional title-p) + "Insert missing `@node' lines in region of Texinfo file. +Non-nil argument (prefix, if interactive) means also to insert the +section titles as node names; and also to insert the section titles as +node names in pre-existing @node lines that lack names." + (interactive "r\nP") + + ;; Use marker; after inserting node lines, leave point at end of + ;; region and mark at beginning. + + (let (beginning-marker end-marker title last-section-position) + + ;; Save current position on mark ring and set mark to end. + (push-mark end t) + (setq end-marker (mark-marker)) + + (goto-char beginning) + (while (re-search-forward + texinfo-section-types-regexp + end-marker + 'end) + ;; Copy title if desired. + (if title-p + (progn + (beginning-of-line) + (forward-word 1) + (skip-chars-forward " \t") + (setq title (buffer-substring + (point) + (save-excursion (end-of-line) (point)))))) + ;; Insert node line if necessary. + (if (re-search-backward + "^@node" + ;; Avoid finding previous node line if node lines are close. + (or last-section-position + (save-excursion (forward-line -2) (point))) t) + ;; @node is present, and point at beginning of that line + (forward-word 1) ; Leave point just after @node. + ;; Else @node missing; insert one. + (beginning-of-line) ; Beginning of `@section' line. + (insert "@node\n") + (backward-char 1)) ; Leave point just after `@node'. + ;; Insert title if desired. + (if title-p + (progn + (skip-chars-forward " \t") + ;; Use regexp based on what info looks for + ;; (alternatively, use "[a-zA-Z]+"); + ;; this means we only insert a title if none exists. + (if (not (looking-at "[^,\t\n ]+")) + (progn + (beginning-of-line) + (forward-word 1) + (insert " " title) + (message "Inserted title %s ... " title))))) + ;; Go forward beyond current section title. + (re-search-forward texinfo-section-types-regexp + (save-excursion (forward-line 3) (point)) t) + (setq last-section-position (point)) + (forward-line 1)) + + ;; Leave point at end of region, mark at beginning. + (set-mark beginning) + + (if title-p + (message + "Done inserting node lines and titles. You may save the buffer.") + (message "Done inserting node lines. You may save the buffer.")))) + + +;;; Update and create menus for multi-file Texinfo sources + +;; 1. M-x texinfo-multiple-files-update +;; +;; Read the include file list of an outer Texinfo file and +;; update all highest level nodes in the files listed and insert a +;; main menu in the outer file after its top node. + +;; 2. C-u M-x texinfo-multiple-files-update +;; +;; Same as 1, but insert a master menu. (Saves reupdating lower +;; level menus and nodes.) This command simply reads every menu, +;; so if the menus are wrong, the master menu will be wrong. +;; Similarly, if the lower level node pointers are wrong, they +;; will stay wrong. + +;; 3. C-u 2 M-x texinfo-multiple-files-update +;; +;; Read the include file list of an outer Texinfo file and +;; update all nodes and menus in the files listed and insert a +;; master menu in the outer file after its top node. + +;;; Note: these functions: +;;; +;;; * Do not save or delete any buffers. You may fill up your memory. +;;; * Do not handle any pre-existing nodes in outer file. +;;; Hence, you may need a file for indices. + + +;;; Auxiliary functions for multiple file updating + +(defun texinfo-multi-file-included-list (outer-file) + "Return a list of the included files in OUTER-FILE." + (let ((included-file-list (list outer-file)) + start) + (save-excursion + (switch-to-buffer (find-file-noselect outer-file)) + (widen) + (goto-char (point-min)) + (while (re-search-forward "^@include" nil t) + (skip-chars-forward " \t") + (setq start (point)) + (end-of-line) + (skip-chars-backward " \t") + (setq included-file-list + (cons (buffer-substring start (point)) + included-file-list))) + (nreverse included-file-list)))) + +(defun texinfo-copy-next-section-title () + "Return the name of the immediately following section as a string. + +Start with point at the beginning of the node line. Leave point at the +same place. If there is no title, returns an empty string." + + (save-excursion + (end-of-line) + (let ((node-end (or + (save-excursion + (if (re-search-forward "\\(^@node\\)" nil t) + (match-beginning 0))) + (point-max)))) + (if (re-search-forward texinfo-section-types-regexp node-end t) + (progn + (beginning-of-line) + ;; copy title + (let ((title + (buffer-substring + (progn (forward-word 1) ; skip over section type + (skip-chars-forward " \t") ; and over spaces + (point)) + (progn (end-of-line) (point))))) + title)) + "")))) + +(defun texinfo-multi-file-update (files &optional update-everything) + "Update first node pointers in each file in FILES. +Return a list of the node names. + +The first file in the list is an outer file; the remaining are +files included in the outer file with `@include' commands. + +If optional arg UPDATE-EVERYTHING non-nil, update every menu and +pointer in each of the included files. + +Also update the `Top' level node pointers of the outer file. + +Requirements: + + * the first file in the FILES list must be the outer file, + * each of the included files must contain exactly one highest + hierarchical level node, + * this node must be the first node in the included file, + * each highest hierarchical level node must be of the same type. + +Thus, normally, each included file contains one, and only one, +chapter." + +;; The menu-list has the form: +;; +;; \(\(\"node-name1\" . \"title1\"\) +;; \(\"node-name2\" . \"title2\"\) ... \) +;; +;; However, there does not need to be a title field and this function +;; does not fill it; however a comment tells you how to do so. +;; You would use the title field if you wanted to insert titles in the +;; description slot of a menu as a description. + + (let ((case-fold-search t) + menu-list) + + ;; Find the name of the first node of the first included file. + (switch-to-buffer (find-file-noselect (car (cdr files)))) + (widen) + (goto-char (point-min)) + (if (not (re-search-forward "^@node" nil t)) + (error "No `@node' line found in %s !" (buffer-name))) + (beginning-of-line) + (texinfo-check-for-node-name) + (setq next-node-name (texinfo-copy-node-name)) + + (setq menu-list + (cons (cons + next-node-name + (prog1 "" (forward-line 1))) + ;; Use following to insert section titles automatically. + ;; (texinfo-copy-next-section-title) + menu-list)) + + ;; Go to outer file + (switch-to-buffer (find-file-noselect (car files))) + (goto-char (point-min)) + (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) + (error "This buffer needs a Top node!")) + (beginning-of-line) + (texinfo-delete-existing-pointers) + (end-of-line) + (insert ", " next-node-name ", (dir), (dir)") + (beginning-of-line) + (setq previous-node-name "Top") + (setq files (cdr files)) + + (while files + + (if (not (cdr files)) + ;; No next file + (setq next-node-name "") + ;; Else, + ;; find the name of the first node in the next file. + (switch-to-buffer (find-file-noselect (car (cdr files)))) + (widen) + (goto-char (point-min)) + (if (not (re-search-forward "^@node" nil t)) + (error "No `@node' line found in %s !" (buffer-name))) + (beginning-of-line) + (texinfo-check-for-node-name) + (setq next-node-name (texinfo-copy-node-name)) + (setq menu-list + (cons (cons + next-node-name + (prog1 "" (forward-line 1))) + ;; Use following to insert section titles automatically. + ;; (texinfo-copy-next-section-title) + menu-list))) + + ;; Go to node to be updated. + (switch-to-buffer (find-file-noselect (car files))) + (goto-char (point-min)) + (if (not (re-search-forward "^@node" nil t)) + (error "No `@node' line found in %s !" (buffer-name))) + (beginning-of-line) + + ;; Update other menus and nodes if requested. + (if update-everything (texinfo-all-menus-update t)) + + (beginning-of-line) + (texinfo-delete-existing-pointers) + (end-of-line) + (insert ", " next-node-name ", " previous-node-name ", " up-node-name) + + (beginning-of-line) + (setq previous-node-name (texinfo-copy-node-name)) + + (setq files (cdr files))) + (nreverse menu-list))) + +(defun texinfo-multi-files-insert-main-menu (menu-list) + "Insert formatted main menu at point. +Indents the first line of the description, if any, to the value of +texinfo-column-for-description." + + (insert "@menu\n") + (while menu-list + ;; Every menu entry starts with a star and a space. + (insert "* ") + + ;; Insert the node name (and menu entry name, if present). + (let ((node-part (car (car menu-list)))) + (if (stringp node-part) + ;; "Double colon" entry line; menu entry and node name are the same, + (insert (format "%s::" node-part)) + ;; "Single colon" entry line; menu entry and node name are different. + (insert (format "%s: %s." (car node-part) (cdr node-part))))) + + ;; Insert the description, if present. + (if (cdr (car menu-list)) + (progn + ;; Move to right place. + (indent-to texinfo-column-for-description 2) + ;; Insert description. + (insert (format "%s" (cdr (car menu-list)))))) + + (insert "\n") ; end this menu entry + (setq menu-list (cdr menu-list))) + (insert "@end menu")) + +(defun texinfo-multi-file-master-menu-list (files-list) + "Return master menu list from files in FILES-LIST. +Menu entries in each file collected using `texinfo-master-menu-list'. + +The first file in FILES-LIST must be the outer file; the others must +be the files included within it. A main menu must already exist." + (save-excursion + (let (master-menu-list) + (while files-list + (switch-to-buffer (find-file-noselect (car files-list))) + (message "Working on: %s " (current-buffer)) + (goto-char (point-min)) + (setq master-menu-list + (append master-menu-list (texinfo-master-menu-list))) + (setq files-list (cdr files-list))) + master-menu-list))) + + +;;; The multiple-file update function + +(defun texinfo-multiple-files-update + (outer-file &optional update-everything make-master-menu) + "Update first node pointers in each file included in OUTER-FILE; +create or update the `Top' level node pointers and the main menu in +the outer file that refers to such nodes. This does not create or +update menus or pointers within the included files. + +With optional MAKE-MASTER-MENU argument (prefix arg, if interactive), +insert a master menu in OUTER-FILE in addition to creating or updating +pointers in the first @node line in each included file and creating or +updating the `Top' level node pointers of the outer file. This does +not create or update other menus and pointers within the included +files. + +With optional UPDATE-EVERYTHING argument (numeric prefix arg, if +interactive), update all the menus and all the `Next', `Previous', and +`Up' pointers of all the files included in OUTER-FILE before inserting +a master menu in OUTER-FILE. Also, update the `Top' level node +pointers of OUTER-FILE. + +Notes: + + * this command does NOT save any files--you must save the + outer file and any modified, included files. + + * except for the `Top' node, this command does NOT handle any + pre-existing nodes in the outer file; hence, indices must be + enclosed in an included file. + +Requirements: + + * each of the included files must contain exactly one highest + hierarchical level node, + * this highest node must be the first node in the included file, + * each highest hierarchical level node must be of the same type. + +Thus, normally, each included file contains one, and only one, +chapter." + + (interactive (cons + (read-string + "Name of outer `include' file: " + (buffer-file-name)) + (cond ((not current-prefix-arg) + '(nil nil)) + ((listp current-prefix-arg) + '(t nil)) ; make-master-menu + ((numberp current-prefix-arg) + '(t t)) ; update-everything + ))) + + (let* ((included-file-list (texinfo-multi-file-included-list outer-file)) + (files included-file-list) + main-menu-list + next-node-name + previous-node-name + (up-node-name "Top")) + +;;; Update the pointers +;;; and collect the names of the nodes and titles + (setq main-menu-list (texinfo-multi-file-update files update-everything)) + +;;; Insert main menu + + ;; Go to outer file + (switch-to-buffer (find-file-noselect (car included-file-list))) + (if (texinfo-old-menu-p + (point-min) + (save-excursion + (re-search-forward "^@include") + (beginning-of-line) + (point))) + + ;; If found, leave point after word `menu' on the `@menu' line. + (progn + (texinfo-incorporate-descriptions main-menu-list) + ;; Delete existing menu. + (beginning-of-line) + (delete-region + (point) + (save-excursion (re-search-forward "^@end menu") (point))) + ;; Insert main menu + (texinfo-multi-files-insert-main-menu main-menu-list)) + + ;; Else no current menu; insert it before `@include' + (texinfo-multi-files-insert-main-menu main-menu-list)) + +;;; Insert master menu + + (if make-master-menu + (progn + ;; First, removing detailed part of any pre-existing master menu + (goto-char (point-min)) + (if (re-search-forward texinfo-master-menu-header nil t) + ;; Remove detailed master menu listing + (progn + (goto-char (match-beginning 0)) + (let ((end-of-detailed-menu-descriptions + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) (forward-char -1) + (point)))) + (delete-region (point) end-of-detailed-menu-descriptions)))) + + ;; Create a master menu and insert it + (texinfo-insert-master-menu-list + (texinfo-multi-file-master-menu-list + included-file-list))))) + + ;; Remove unwanted extra lines. + (save-excursion + (goto-char (point-min)) + + (re-search-forward "^@menu") + (forward-line -1) + (insert "\n") ; Ensure at least one blank line. + (delete-blank-lines) + + (re-search-forward "^@end menu") + (forward-line 1) + (insert "\n") ; Ensure at least one blank line. + (delete-blank-lines)) + + (message "Multiple files updated.")) + + +;;; Place `provide' at end of file. +(provide 'texnfo-upd) + +;;; texnfo-upd.el ends here diff --git a/texinfo/gen-info-dir b/texinfo/gen-info-dir new file mode 100755 index 000000000000..ede0daa7e7b9 --- /dev/null +++ b/texinfo/gen-info-dir @@ -0,0 +1,101 @@ +#!/bin/sh +# +# generate an Info directory, given a directory of Info files and a +# list of entries. The output will be suitable for a dir.info file, +# in the order given in the skeleton file + +INFODIR=$1 +if [ $# = 2 ] ; then + SKELETON=$2 +else + SKELETON=/dev/null +fi + +skip= + +if [ $# -gt 2 ] ; then + echo usage: $0 info-directory [ skeleton-file ] 1>&2 + exit 1 +else + true +fi + +if [ ! -d ${INFODIR} ] ; then + echo "$0: first argument must specify a directory" + exit 1 +fi + +infofiles=`(cd ${INFODIR}; ls *.info | sort | sed "s/dir\.info//")` +template=`cat ${SKELETON}` + +### output the dir.info header +echo "-*- Text -*-" +echo "This file was generated automatically by the gen-info-dir script." +echo "This version was generated on `date`" +echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`" + +cat << moobler + +This is the file .../info/dir, which contains the topmost node of the +Info hierarchy. The first time you invoke Info you start off +looking at that node, which is (dir)Top. + +File: dir Node: Top This is the top of the INFO tree + This (the Directory node) gives a menu of major topics. + Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" + gives a primer for first-timers, "mTexinfo" visits Texinfo topic, + etc. + --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) --- + +* Menu: The list of major topics begins on the next line. + +moobler + + +### go through the list of files in the template. If an info file +### exists, grab the ENTRY information from it. If there is no entry +### info, then create a minimal dir entry, otherwise use the given info. +### +### Then remove that file from the list of existing files. If any +### additional files remain (ones that don't have a template entry), +### then generate entries for those in the same way, putting the info for +### those at the very end.... + +for file in ${template} ; do + if [ "${file}" = "--" ] ; then + skip=1 + else + if [ -f ${INFODIR}/${file}.info ] ; then + entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}.info` + if [ ! -z "${skip}" ] ; then + echo + skip= + fi + + if [ ! -z "${entry}" ] ; then + echo "${entry}" + else + echo "* ${file}: (${file})." + fi + + infofiles=`echo ${infofiles} | sed -e "s/${file}\.info//"` + fi + fi +done + +if [ -z "${infofiles}" ] ; then + exit 0 +else + echo +fi + +for file in ${infofiles}; do + entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}` + + if [ ! -z "${entry}" ] ; then + echo "${entry}" + else + echo "* ${file}: (${file})." + fi +done + diff --git a/texinfo/gpl.texinfo b/texinfo/gpl.texinfo new file mode 100644 index 000000000000..ce7d62ec8f8c --- /dev/null +++ b/texinfo/gpl.texinfo @@ -0,0 +1,398 @@ +@c This GPL is meant to be included from other files. +@c To format a standalone GPL, use license.texi. + +@center Version 2, June 1991 + +@display +Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. 675 +Mass Ave, Boston, MA 02111-1307, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@unnumberedsec 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. + +@iftex +@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end iftex +@ifinfo +@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end ifinfo + +@enumerate 0 +@item +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. + +@item +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. + +@item +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: + +@enumerate a +@item +You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + +@item +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. + +@item +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.) +@end enumerate + +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. + +@item +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: + +@enumerate a +@item +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, + +@item +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, + +@item +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.) +@end enumerate + +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. + +@item +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. + +@item +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. + +@item +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. + +@item +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. + +@item +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. + +@item +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. + +@item +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. + +@iftex +@vskip -@baselineskip +@vskip -@baselineskip +@heading NO WARRANTY +@end iftex +@ifinfo +@center NO WARRANTY +@end ifinfo + +@item +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. + +@item +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 enumerate + +@iftex +@heading END OF TERMS AND CONDITIONS +@end iftex +@ifinfo +@center END OF TERMS AND CONDITIONS +@end ifinfo + +@page +@unnumberedsec 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. + +@smallexample +@var{one line to give the program's name and an idea of what it does.} +Copyright (C) 19@var{yy} @var{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. +@end smallexample + +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: + +@smallexample +Gnomovision version 69, Copyright (C) 19@var{yy} @var{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. +@end smallexample + +The hypothetical commands @samp{show w} and @samp{show c} should show +the appropriate parts of the General Public License. Of course, the +commands you use may be called something other than @samp{show w} and +@samp{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: + +@example +@group +Yoyodyne, Inc., hereby disclaims all copyright +interest in the program `Gnomovision' +(which makes passes at compilers) written +by James Hacker. + +@var{signature of Ty Coon}, 1 April 1989 +Ty Coon, President of Vice +@end group +@end example + +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/texinfo/info/Makefile.in b/texinfo/info/Makefile.in new file mode 100644 index 000000000000..776872ef68ef --- /dev/null +++ b/texinfo/info/Makefile.in @@ -0,0 +1,232 @@ +# Makefile for texinfo/info. -*- Indented-Text -*- +# $Id: Makefile.in,v 1.1 1997/08/21 22:57:59 jason Exp $ +# +# Copyright (C) 1993,96 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. + +#### Start of system configuration section. #### + +srcdir = @srcdir@ +VPATH = $(srcdir):$(common) + +common = $(srcdir)/../libtxi +util = $(srcdir)/../util + +EXEEXT = @EXEEXT@ +CC = @CC@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +LN = ln +RM = rm -f +MKDIR = mkdir +MAKEINFO= ../makeinfo/makeinfo$(EXEEXT) + +DEFS = @DEFS@ + +LDEFS = -DHANDLE_MAN_PAGES -DNAMED_FUNCTIONS=1 -DDEFAULT_INFOPATH='"$(DEFAULT_INFOPATH)"' + +TERMLIBS = @TERMLIBS@ +LIBS = $(TERMLIBS) -L../libtxi -ltxi @LIBS@ +LOADLIBES = $(LIBS) + +SHELL = /bin/sh + +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +# Prefix for each installed program, normally empty or `g'. +binprefix = +# Prefix for each installed man page, normally empty or `g'. +manprefix = +mandir = @mandir@/man1 +manext = 1 +infodir = @infodir@ +DEFAULT_INFOPATH= $(infodir):. + +#### End of system configuration section. #### + +SRCS = dir.c display.c echo_area.c filesys.c \ + info-utils.c info.c infodoc.c infomap.c \ + m-x.c nodes.c search.c session.c \ + signals.c terminal.c tilde.c window.c \ + xmalloc.c indices.c makedoc.c nodemenu.c \ + footnotes.c dribble.c variables.c gc.c man.c \ + clib.c + +HDRS = display.h doc.h echo_area.h filesys.h \ + general.h getopt.h info-utils.h info.h \ + infomap.h nodes.h search.h session.h \ + signals.h termdep.h terminal.h tilde.h \ + indices.h window.h footnotes.h dribble.h \ + variables.h gc.h clib.h + +OBJS = dir.o display.o doc.o echo_area.o filesys.o info-utils.o info.o \ + infodoc.o infomap.o m-x.o nodes.o search.o session.o signals.o \ + terminal.o tilde.o window.o indices.o xmalloc.o nodemenu.o \ + footnotes.o dribble.o variables.o gc.o man.o clib.o + +# The names of files which declare info commands. +CMDFILES = $(srcdir)/session.c $(srcdir)/echo_area.c $(srcdir)/infodoc.c \ + $(srcdir)/m-x.c $(srcdir)/indices.c $(srcdir)/nodemenu.c \ + $(srcdir)/footnotes.c $(srcdir)/variables.c + +# The name of the program which builds documentation structure from CMDFILES. +MAKEDOC_OBJECTS = makedoc.o clib.o xmalloc.o +MAKEDOC_SOURCE = makedoc.c clib.c xmalloc.c + +infofiles = info.info info-stnd.info + +.c.o: + $(CC) -c $(CPPFLAGS) $(LDEFS) $(DEFS) -I. -I$(srcdir) -I$(common) $(CFLAGS) $< + +all: info$(EXEEXT) $(infofiles) +sub-all: all + +dvi: all-dvi + +install: all + $(INSTALL_PROGRAM) info$(EXEEXT) $(bindir)/$(binprefix)info$(EXEEXT) + -$(INSTALL_DATA) $(srcdir)/info.1 $(mandir)/$(manprefix)info.$(manext) + $(POST_INSTALL) + +install-info: + -d=$(srcdir); test -f ./info.info && d=.; $(INSTALL_DATA) $$d/info.info $(infodir)/info.info + -d=$(srcdir); test -f ./info-stnd.info && d=.; $(INSTALL_DATA) $$d/info-stnd.info $(infodir)/info-stnd.info + ../util/install-info --info-dir=$(infodir) $(infodir)/info.info + ../util/install-info --info-dir=$(infodir) $(infodir)/info-stnd.info + +uninstall: + $(RM) $(bindir)/info$(EXEEXT) + $(RM) $(infodir)/info.info + $(RM) $(infodir)/info-stnd.info + $(RM) $(mandir)/$(manprefix)info.$(manext) + +info$(EXEEXT): $(OBJS) ../libtxi/libtxi.a + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LOADLIBES) + +all-info: info.info info-stnd.info + +info.info: info.texi + $(MAKEINFO) --no-split -I$(srcdir) info.texi + +info-stnd.info: info-stnd.texi + $(MAKEINFO) --no-split -I$(srcdir) info-stnd.texi + +dvi all-dvi: info.dvi info-stnd.dvi +info.dvi: info.texi + PATH="$(util):$${PATH}" TEXINPUTS="$(srcdir):$(common):$${TEXINPUTS}" texi2dvi $(srcdir)/info.texi + +info-stnd.dvi: info-stnd.texi + PATH="$(util):$${PATH}" TEXINPUTS="$(srcdir):$(common):$${TEXINPUTS}" texi2dvi $(srcdir)/info-stnd.texi + +makedoc$(EXEEXT): $(MAKEDOC_OBJECTS) ../libtxi/libtxi.a + $(CC) $(LDFLAGS) -o $@ $(MAKEDOC_OBJECTS) $(LOADLIBES) + +Makefile: $(srcdir)/Makefile.in ../config.status + cd ..; $(SHELL) config.status + +clean: + $(RM) info$(EXEEXT) funs.h doc.c makedoc$(EXEEXT) $(OBJS) $(MAKEDOC_OBJECTS) + +distclean: clean texclean + $(RM) Makefile config.status config.cache *~ core core.* *.core + $(RM) *.BAK makedoc-TAGS TAGS \#* *.info* + +mostlyclean: clean + +realclean: distclean + $(RM) info.info info-stnd.info + +TAGS: $(SRCS) makedoc-TAGS + etags $(SRCS) + cat makedoc-TAGS >>TAGS && $(RM) makedoc-TAGS + +makedoc-TAGS: $(CMDFILES) + ./makedoc -tags $(CMDFILES) >makedoc-TAGS + +texclean: + $(RM) *.toc *.aux *.log *.cp *.fn *.tp *.vr *.pg *.ky *.cps + $(RM) *.tps *.fns *.kys *.pgs *.vrs + +check: info + +# The files `doc.c' and `funs.h' are created by ./makedoc run over the source +# files which contain DECLARE_INFO_COMMAND. `funs.h' is a header file +# listing the functions found. `doc.c' is a structure containing pointers +# to those functions along with completable names and documentation strings. +funs.h: makedoc$(EXEEXT) $(CMDFILES) + -@if test -f funs.h; then mv -f funs.h old-funs.h; fi; : + -@if test -f doc.c; then mv -f doc.c old-doc.c; fi; : + ./makedoc$(EXEEXT) $(CMDFILES) + -@if cmp -s old-funs.h funs.h; then mv old-funs.h funs.h; \ + else $(RM) old-funs.h; fi; : + -@if cmp -s old-doc.c doc.c; then mv old-doc.c doc.c; \ + else $(RM) old-doc.c; fi; : + +doc.c: funs.h +dribble.o: dribble.c dribble.h +display.o: display.c +echo_area.o: echo_area.c +filesys.o: filesys.c +info-utils.o: info-utils.c +info.o: info.c filesys.h +infodoc.o: infodoc.c +infomap.o: infomap.c +m-x.o: m-x.c +nodes.o: nodes.c +search.o: search.c +session.o: session.c +signals.o: signals.c +terminal.o: terminal.c +tilde.o: tilde.c +window.o: window.c +xmalloc.o: xmalloc.c +indices.o: indices.c +makedoc.o: makedoc.c + +dir.o: dir.c +display.o: nodes.h info-utils.h search.h +display.o: terminal.h window.h display.h +echo_area.o: info.h +filesys.o: general.h tilde.h filesys.h +footnotes.o: footnotes.h +info-utils.o: info-utils.h nodes.h search.h +info.o: info.h $(common)/getopt.h +infodoc.o: info.h doc.h +infomap.o: infomap.h funs.h +gc.o: info.h +m-x.o: info.h +nodes.o: search.h filesys.h +nodes.o: nodes.h info-utils.h +search.o: general.h search.h nodes.h +session.o: info.h +signals.o: info.h signals.h +terminal.o: terminal.h termdep.h +tilde.o: tilde.h +variables.c: variables.h +window.o: nodes.h window.h display.h +window.o: info-utils.h search.h infomap.h + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: + +# eof diff --git a/texinfo/info/NEWS b/texinfo/info/NEWS new file mode 100644 index 000000000000..b13fb1531b50 --- /dev/null +++ b/texinfo/info/NEWS @@ -0,0 +1,200 @@ +This release of Info is version 2.11. Please read the file README. + +Version 2.11, Sat Apr 1 09:15:21 1995 + +Changes since 2.7 beta: + +Although the basic code remains the same, there are numerous nits +fixed, including some display bugs, and a memory leak. Some changes +that have taken place with larger impact include the way in which the +(dir) node is built; I have added in support for "localdir" +directories among other things. Info files may be stored in +compressed formats, and in their own subdirectories; menu items which +do not explicitly name the node to which they are attached have the +menu item name looked up as an Info file if it is not found within the +current document. This means that the menu item: + +* Info:: The Info documentation reader. + +in (dir) refers to the info node "(info)Top". + +Please see the ChangeLog and documentation for details on other +changes. + +Version 2.7 beta, Wed Dec 30 02:02:38 1992 +Version 2.6 beta, Tue Dec 22 03:58:07 1992 +Version 2.5 beta, Tue Dec 8 14:50:35 1992 +Version 2.4 beta, Sat Nov 28 14:34:02 1992 +Version 2.3 beta, Fri Nov 27 01:04:13 1992 +Version 2.2 beta, Tue Nov 24 09:36:08 1992 +Version 2.1 beta, Tue Nov 17 23:29:36 1992 + +Changes since 2.5 beta: + +Note that versions 2.6 and 2.7 Beta were only released to a select group. + +* "info-" removed from the front of M-x commands. + +* Automatic footnote display. When you enter a node which contains + footnotes, and the variable "automatic-footnotes" is "On", Info pops + up a window containing the footnotes. Likewise, when you leave that + node, the window containing the footnotes goes away. + +* Cleaner built in documentation, and documentation functions. + + Use: + o `M-x describe-variable' to read a variable's documenation + o `M-x describe-key' to find out what a particular keystroke does. + o `M-x describe-function' to read a function's documentation. + o `M-x where-is' to find out what keys invoke a particular function. + +* Info can "tile" the displayed windows (via "M-x tile-windows"). If + the variable "automatic-tiling" is "On", then splitting a window or + deleting a window causes the remaining windows to be retiled. + +* You can save every keystroke you type in a "dribble file" by using the + `--dribble FILENAME' option. You can initially read keystrokes from an + alternate input stream with `--restore FILENAME', or by redirecting + input on the command line `info < old-dribble'. + +* New behaviour of menu items. If the label is the same as the + target node name, and the node couldn't be found in the current file, + treat the label as a file name. For example, a menu entry in "DIR" + might contain: + + * Emacs:: Cool text-editor. + + Info would not find the node "(dir)Emacs", so just plain "(emacs)" + would be tried. + +* New variable "ISO-Latin" allows you to use European machines with + 8-bit character sets. + +* Cleanups in echo area reading, and redisplay. Cleanups in handling the + window which shows possible completions. + +* Info can now read files that have been compressed. An array in filesys.c + maps extensions to programs that can decompress stdin, and write the results + to stdout. Currently, ".Z"/uncompress, ".z"/gunzip, and ".Y"/unyabba are + supported. The modeline for a compressed file shows "zz" in it. + +* There is a new variable "gc-compressed-files" which, if non-zero, says + it is okay to reclaim the file buffer space allocated to a file which + was compressed, if, and only if, that file's contents do not appear in + any history node. + +* New file `nodemenu.c' implements a few functions for manipulating + previously visited nodes. `C-x C-b' (list-visited-nodes) produces a + menu of the nodes that could be reached by info-history-node in some + window. `C-x b' (select-visited-node) is similar, but reads one of + the node names with completion. + +* Keystroke `M-r' (move_to_screen_line) allows the user to place the cursor at + the start of a specific screen line. Without a numeric argument, place the + cursor on the center line; with an arg, place the cursor on that line. + +* Interruptible display implemented. Basic display speedups and hacks. +* The message "*** Tags Out of Date ***" now means what it says. +* Index searching with `,' (info-index-next) has been improved. +* When scrolling with C-v, C-M-v, or M-v, only "Page Only" scrolling + will happen. + +* Continous scrolling (along with `]' (info-global-next) and `[' + (info-global-prev) works better. `]' and `[' accept numeric + arguments, moving that many nodes in that case. + +* `C-x w' (info-toggle-wrap) controls how lines wider than the width + of the screen are displayed. If a line is too long, a `$' is + displayed in the rightmost column of the window. + +* There are some new variables for controlling the behaviour of Info + interactively. The current list of variables is as follows: + + Variable Name Default Value Description + ------------- ------------- ----------- + `automatic-footnotes' On When "On", footnotes appear and + disappear automatically. + + `automatic-tiling' Off When "On", creating of deleting a + window resizes other windows. + + `visible-bell' Off If non-zero, try to use a visible bell. + + `errors-ring-bell' On If non-zero, errors cause a ring. + + `show-index-match' On If non-zero, the portion of the string + matched is highlighted by changing its + case. + + `scroll-behaviour' Continuous One of "Continuous", "Next Only", or + "Page Only". "Page Only" prevents you from + scrolling past the bottom or top of a node. + "Next Only" causes the Next or Prev node to + be selected when you scroll past the bottom + or top of a node. "Continous" moves + linearly through the files hierchichal + structure. + + `scroll-step' 0 Controls how scrolling is done for you when + the cursor moves out of the current window. + Non-zero means it is the number of lines + you would like the screen to shift. A + value of 0 means to center the line + containing the cursor in the window. + + `gc-compressed-files' Off If non-zero means it is okay to reclaim the + file buffer space allocated to a file which + was compressed, if, and only if, that + file's contents do not appear in the node + list of any window. + + `ISO-Latin' Off Non-zero means that you are using an ISO + Latin character set. By default, standard + ASCII characters are assumed. +________________________________________ +This release of Info is version 2.5 beta. + +Changes since 2.4 beta: + +* Index (i) and (,) commands fully implemented. +* "configure" script now shipped with Info. +* New function "set-variable" allows users to set various variables. +* User-settable behaviour on end or beginning of node scrolling. This + supercedes the SPC and DEL changes in 2.3 beta. + +________________________________________ +This release of Info is version 2.4 beta. + +Changes since 2.3 beta: + +* info-last-node now means move to the last node of this info file. +* info-history-node means move backwards through this window's node history. +* info-first-node moves to the first node in the Info file. This node is + not necessarily "Top"! +* SPC and DEL can select the Next or Prev node after printing an informative + message when pressed at the end/beg of a node. + +---------------------------------------- +This release of Info is version 2.3 beta. + +Changes since 2.2 beta: + +* M-x command lines if NAMED_COMMANDS is #defined. Variable in Makefile. +* Screen height changes made quite robust. +* Interactive function "set-screen-height" implements user height changes. +* Scrolling on some terminals is faster now. +* C-l with numeric arguement is fixed. + +---------------------------------------- +This release of Info is version 2.2 beta. + +Changes since 2.0: + +* C-g can now interrupt multi-file searches. +* Incremental search is fully implemented. +* Loading large tag tables is much faster now. +* makedoc.c replaces shell script, speeding incremental builds. +* Scrolling in redisplay is implemented. +* Recursive uses of the echo area made more robust. +* Garbage collection of unreferenced nodes. + diff --git a/texinfo/info/README b/texinfo/info/README new file mode 100644 index 000000000000..d8f1ab624d84 --- /dev/null +++ b/texinfo/info/README @@ -0,0 +1,37 @@ +The file NEWS contains information about what has changed since the last +release. + +The file ../INSTALL contains instructions on how to install Info. + + +Info 2.0 is a complete rewrite of the original standalone Info I wrote in +1987, the first program I wrote for rms. That program was something like +my second Unix program ever, and my die-hard machine language coding habits +tended to show through. I found the original Info hard to read and +maintain, and thus decided to write this one. + +The rewrite consists of about 12,000 lines of code written in about 12 +days. I believe this version of Info to be in much better shape than the +original Info, and the only reason it is in Beta test is because of its +short life span. + +Info 2.0 is substantially different from its original standalone +predecessor. It appears almost identical to the GNU Emacs version, but has +the advantages of smaller size, ease of portability, and a built in library +which can be used in other programs (to get or display documentation from +Info files, for example). + +I eagerly await responses to this newer version of Info; comments on its +portability, ease of use and user interface, code quality, and general +usefulness are all of interest to me, and I will appreciate any comments +that you would care to make. + +A full listing of the commands available in Info can be gotten by typing +`?' while within an Info window. This produces a node in a window which +can be viewed just like any Info node. + +Please send your comments, bug reports, and suggestions to + + bug-texinfo@prep.ai.mit.edu + +--Brian Fox diff --git a/texinfo/info/clib.c b/texinfo/info/clib.c new file mode 100644 index 000000000000..0f913370bf30 --- /dev/null +++ b/texinfo/info/clib.c @@ -0,0 +1,112 @@ +/* clib.c: Functions which we normally expect to find in the C library. + $Id: clib.c,v 1.1 1997/08/21 22:57:59 jason Exp $ + + This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1995 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include + +#if defined (HAVE_UNISTD_H) +#include +#endif + +#if defined (HAVE_STDLIB_H) +#include +#endif + +#if defined (HAVE_STRING_H) +#include +#endif + +#include + +extern void *xmalloc (), *xrealloc (); +#include "general.h" + +#if !defined (errno) +extern int errno; +#endif + +#if !defined (HAVE_STRERROR) +extern char *sys_errlist[]; +extern int sys_nerr; + +char * +strerror (num) + int num; +{ + if (num >= sys_nerr) + return (""); + else + return (sys_errlist[num]); +} +#endif /* !HAVE_STRERROR */ + +#if !defined (HAVE_STRCASECMP) +/* This Unix doesn't have the strcasecmp () function. */ +int +strcasecmp (string1, string2) + char *string1, *string2; +{ + char ch1, ch2; + + for (;;) + { + ch1 = *string1++; + ch2 = *string2++; + + if (!(ch1 | ch2)) + return (0); + + ch1 = info_toupper (ch1); + ch2 = info_toupper (ch2); + + if (ch1 != ch2) + return (ch1 - ch2); + } +} + +/* Compare at most COUNT characters from string1 to string2. Case + doesn't matter. */ +int +strncasecmp (string1, string2, count) + char *string1, *string2; + int count; +{ + register char ch1, ch2; + + while (count) + { + ch1 = *string1++; + ch2 = *string2++; + + ch1 = info_toupper (ch1); + ch2 = info_toupper (ch2); + + if (ch1 == ch2) + count--; + else + break; + } + return (count); +} +#endif /* !STRCASECMP */ + diff --git a/texinfo/info/clib.h b/texinfo/info/clib.h new file mode 100644 index 000000000000..c559fe51b607 --- /dev/null +++ b/texinfo/info/clib.h @@ -0,0 +1,42 @@ +/* clib.h: Declarations of functions which appear in clib.c (or libc.a). */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1995 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_CLIB_H_) +#define _CLIB_H_ + +#if !defined (HAVE_STRDUP) +extern char *strdup (); +#endif + +#if !defined (HAVE_STRERROR) +extern char *strerror (); +#endif + +#if !defined (HAVE_STRCASECMP) +extern int strcasecmp (); +extern int strncasecmp (); +#endif + +#endif /* !_CLIB_H_ */ + + diff --git a/texinfo/info/dir.c b/texinfo/info/dir.c new file mode 100644 index 000000000000..4ccf85613101 --- /dev/null +++ b/texinfo/info/dir.c @@ -0,0 +1,273 @@ +/* dir.c -- How to build a special "dir" node from "localdir" files. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include +#include +#if defined (HAVE_SYS_FILE_H) +#include +#endif /* HAVE_SYS_FILE_H */ +#include +#include "info-utils.h" +#include "filesys.h" +#include "tilde.h" + +/* The "dir" node can be built from the contents of a file called "dir", + with the addition of the menus of every file named in the array + dirs_to_add which are found in INFOPATH. */ + +static void add_menu_to_file_buffer (), insert_text_into_fb_at_binding (); +static void build_dir_node_internal (); + +static char *dirs_to_add[] = { + "dir", "localdir", (char *)NULL +}; + +void +maybe_build_dir_node (dirname) + char *dirname; +{ + FILE_BUFFER *dir_buffer; + int path_index, update_tags; + char *this_dir; + + /* Check to see if the file has already been built. If so, then + do not build it again. */ + dir_buffer = info_find_file (dirname); + + /* If there is no "dir" in the current info path, we cannot build one + from nothing. */ + if (!dir_buffer) + return; + + /* If this directory has already been built, return now. */ + if (dir_buffer->flags & N_CannotGC) + return; + + path_index = update_tags = 0; + + /* Using each element of the path, check for one of the files in + DIRS_TO_ADD. Do not check for "localdir.info.Z" or anything else. + Only files explictly named are eligible. This is a design decision. + There can be an info file name "localdir.info" which contains + information on the setting up of "localdir" files. */ + while (this_dir = extract_colon_unit (infopath, &path_index)) + { + register int da_index; + char *from_file; + + /* Expand a leading tilde if one is present. */ + if (*this_dir == '~') + { + char *tilde_expanded_dirname; + + tilde_expanded_dirname = tilde_expand_word (this_dir); + if (tilde_expanded_dirname != this_dir) + { + free (this_dir); + this_dir = tilde_expanded_dirname; + } + } + + /* For every file named in DIRS_TO_ADD found in the search path, + add the contents of that file's menu to our "dir" node. */ + for (da_index = 0; from_file = dirs_to_add[da_index]; da_index++) + { + struct stat finfo; + char *fullpath; + int namelen, statable; + + namelen = strlen (from_file); + + fullpath = (char *)xmalloc (3 + strlen (this_dir) + namelen); + strcpy (fullpath, this_dir); + if (fullpath[strlen (fullpath) - 1] != '/') + strcat (fullpath, "/"); + strcat (fullpath, from_file); + + statable = (stat (fullpath, &finfo) == 0); + + /* Only add the contents of this file if it is not identical to the + file of the DIR buffer. */ + if ((statable && S_ISREG (finfo.st_mode)) && + (strcmp (dir_buffer->fullpath, fullpath) != 0)) + { + long filesize; + char *contents; + + contents = filesys_read_info_file (fullpath, &filesize, &finfo); + + if (contents) + { + update_tags++; + add_menu_to_file_buffer (contents, filesize, dir_buffer); + free (contents); + } + } + + free (fullpath); + } + free (this_dir); + } + + if (update_tags) + build_tags_and_nodes (dir_buffer); + + /* Flag that the dir buffer has been built. */ + dir_buffer->flags |= N_CannotGC; +} + +/* Given CONTENTS and FB (a file buffer), add the menu found in CONTENTS + to the menu found in FB->contents. Second argument SIZE is the total + size of CONTENTS. */ +static void +add_menu_to_file_buffer (contents, size, fb) + char *contents; + long size; + FILE_BUFFER *fb; +{ + SEARCH_BINDING contents_binding, fb_binding; + long contents_offset, fb_offset; + + contents_binding.buffer = contents; + contents_binding.start = 0; + contents_binding.end = size; + contents_binding.flags = S_FoldCase | S_SkipDest; + + fb_binding.buffer = fb->contents; + fb_binding.start = 0; + fb_binding.end = fb->filesize; + fb_binding.flags = S_FoldCase | S_SkipDest; + + /* Move to the start of the menus in CONTENTS and FB. */ + contents_offset = search_forward (INFO_MENU_LABEL, &contents_binding); + fb_offset = search_forward (INFO_MENU_LABEL, &fb_binding); + + /* If there is no menu in CONTENTS, quit now. */ + if (contents_offset == -1) + return; + + /* There is a menu in CONTENTS, and contents_offset points to the first + character following the menu starter string. Skip all whitespace + and newline characters. */ + contents_offset += skip_whitespace_and_newlines (contents + contents_offset); + + /* If there is no menu in FB, make one. */ + if (fb_offset == -1) + { + /* Find the start of the second node in this file buffer. If there + is only one node, we will be adding the contents to the end of + this node. */ + fb_offset = find_node_separator (&fb_binding); + + /* If not even a single node separator, give up. */ + if (fb_offset == -1) + return; + + fb_binding.start = fb_offset; + fb_binding.start += + skip_node_separator (fb_binding.buffer + fb_binding.start); + + /* Try to find the next node separator. */ + fb_offset = find_node_separator (&fb_binding); + + /* If found one, consider that the start of the menu. Otherwise, the + start of this menu is the end of the file buffer (i.e., fb->size). */ + if (fb_offset != -1) + fb_binding.start = fb_offset; + else + fb_binding.start = fb_binding.end; + + insert_text_into_fb_at_binding + (fb, &fb_binding, INFO_MENU_LABEL, strlen (INFO_MENU_LABEL)); + + fb_binding.buffer = fb->contents; + fb_binding.start = 0; + fb_binding.end = fb->filesize; + fb_offset = search_forward (INFO_MENU_LABEL, &fb_binding); + if (fb_offset == -1) + abort (); + } + + /* CONTENTS_OFFSET and FB_OFFSET point to the starts of the menus that + appear in their respective buffers. Add the remainder of CONTENTS + to the end of FB's menu. */ + fb_binding.start = fb_offset; + fb_offset = find_node_separator (&fb_binding); + if (fb_offset != -1) + fb_binding.start = fb_offset; + else + fb_binding.start = fb_binding.end; + + /* Leave exactly one blank line between directory entries. */ + { + int num_found = 0; + + while ((fb_binding.start > 0) && + (whitespace_or_newline (fb_binding.buffer[fb_binding.start - 1]))) + { + num_found++; + fb_binding.start--; + } + + /* Optimize if possible. */ + if (num_found >= 2) + { + fb_binding.buffer[fb_binding.start++] = '\n'; + fb_binding.buffer[fb_binding.start++] = '\n'; + } + else + { + /* Do it the hard way. */ + insert_text_into_fb_at_binding (fb, &fb_binding, "\n\n", 2); + fb_binding.start += 2; + } + } + + /* Insert the new menu. */ + insert_text_into_fb_at_binding + (fb, &fb_binding, contents + contents_offset, size - contents_offset); +} + +static void +insert_text_into_fb_at_binding (fb, binding, text, textlen) + FILE_BUFFER *fb; + SEARCH_BINDING *binding; + char *text; + int textlen; +{ + char *contents; + long start, end; + + start = binding->start; + end = fb->filesize; + + contents = (char *)xmalloc (fb->filesize + textlen + 1); + memcpy (contents, fb->contents, start); + memcpy (contents + start, text, textlen); + memcpy (contents + start + textlen, fb->contents + start, end - start); + free (fb->contents); + fb->contents = contents; + fb->filesize += textlen; + fb->finfo.st_size = fb->filesize; +} diff --git a/texinfo/info/display.c b/texinfo/info/display.c new file mode 100644 index 000000000000..0194afafa200 --- /dev/null +++ b/texinfo/info/display.c @@ -0,0 +1,561 @@ +/* display.c -- How to display Info windows. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include +#include +#include +#include "display.h" + +extern int info_any_buffered_input_p (); /* Found in session.c. */ + +static void free_display (); +static DISPLAY_LINE **make_display (); + +/* An array of display lines which tell us what is currently visible on + the display. */ +DISPLAY_LINE **the_display = (DISPLAY_LINE **)NULL; + +/* Non-zero means do no output. */ +int display_inhibited = 0; + +/* Initialize THE_DISPLAY to WIDTH and HEIGHT, with nothing in it. */ +void +display_initialize_display (width, height) + int width, height; +{ + free_display (the_display); + the_display = make_display (width, height); + display_clear_display (the_display); +} + +/* Clear all of the lines in DISPLAY making the screen blank. */ +void +display_clear_display (display) + DISPLAY_LINE **display; +{ + register int i; + register DISPLAY_LINE *display_line; + + for (i = 0; display_line = display[i]; i++) + { + display[i]->text[0] = '\0'; + display[i]->textlen = 0; + display[i]->inverse = 0; + } +} + +/* Non-zero if we didn't completely redisplay a window. */ +int display_was_interrupted_p = 0; + +/* Update the windows pointed to by WINDOW in the_display. This actually + writes the text on the screen. */ +void +display_update_display (window) + WINDOW *window; +{ + register WINDOW *win; + + display_was_interrupted_p = 0; + + /* For every window in the list, check contents against the display. */ + for (win = window; win; win = win->next) + { + /* Only re-display visible windows which need updating. */ + if (((win->flags & W_WindowVisible) == 0) || + ((win->flags & W_UpdateWindow) == 0) || + (win->height == 0)) + continue; + + display_update_one_window (win); + if (display_was_interrupted_p) + break; + } + + /* Always update the echo area. */ + display_update_one_window (the_echo_area); +} + +/* Display WIN on the_display. Unlike display_update_display (), this + function only does one window. */ +void +display_update_one_window (win) + WINDOW *win; +{ + register char *nodetext; /* Current character to display. */ + register char *last_node_char; /* Position of the last character in node. */ + register int i; /* General use index. */ + char *printed_line; /* Buffer for a printed line. */ + int pl_index = 0; /* Index into PRINTED_LINE. */ + int line_index = 0; /* Number of lines done so far. */ + DISPLAY_LINE **display = the_display; + + /* If display is inhibited, that counts as an interrupted display. */ + if (display_inhibited) + display_was_interrupted_p = 1; + + /* If the window has no height, or display is inhibited, quit now. */ + if (!win->height || display_inhibited) + return; + + /* If the window's first row doesn't appear in the_screen, then it + cannot be displayed. This can happen when the_echo_area is the + window to be displayed, and the screen has shrunk to less than one + line. */ + if ((win->first_row < 0) || (win->first_row > the_screen->height)) + return; + + /* Print each line in the window into our local buffer, and then + check the contents of that buffer against the display. If they + differ, update the display. */ + printed_line = (char *)xmalloc (1 + win->width); + + if (!win->node || !win->line_starts) + goto done_with_node_display; + + nodetext = win->line_starts[win->pagetop]; + last_node_char = win->node->contents + win->node->nodelen; + + for (; nodetext < last_node_char; nodetext++) + { + char *rep, *rep_carried_over, rep_temp[2]; + int replen; + + if (isprint (*nodetext)) + { + rep_temp[0] = *nodetext; + replen = 1; + rep_temp[1] = '\0'; + rep = rep_temp; + } + else + { + if (*nodetext == '\r' || *nodetext == '\n') + { + replen = win->width - pl_index; + } + else + { + rep = printed_representation (*nodetext, pl_index); + replen = strlen (rep); + } + } + + /* If this character can be printed without passing the width of + the line, then stuff it into the line. */ + if (replen + pl_index < win->width) + { + /* Optimize if possible. */ + if (replen == 1) + { + printed_line[pl_index++] = *rep; + } + else + { + for (i = 0; i < replen; i++) + printed_line[pl_index++] = rep[i]; + } + } + else + { + DISPLAY_LINE *entry; + + /* If this character cannot be printed in this line, we have + found the end of this line as it would appear on the screen. + Carefully print the end of the line, and then compare. */ + if (*nodetext == '\n' || *nodetext == '\r' || *nodetext == '\t') + { + printed_line[pl_index] = '\0'; + rep_carried_over = (char *)NULL; + } + else + { + /* The printed representation of this character extends into + the next line. Remember the offset of the last character + printed out of REP so that we can carry the character over + to the next line. */ + for (i = 0; pl_index < (win->width - 1);) + printed_line[pl_index++] = rep[i++]; + + rep_carried_over = rep + i; + + /* If printing the last character in this window couldn't + possibly cause the screen to scroll, place a backslash + in the rightmost column. */ + if (1 + line_index + win->first_row < the_screen->height) + { + if (win->flags & W_NoWrap) + printed_line[pl_index++] = '$'; + else + printed_line[pl_index++] = '\\'; + } + printed_line[pl_index] = '\0'; + } + + /* We have the exact line as it should appear on the screen. + Check to see if this line matches the one already appearing + on the screen. */ + entry = display[line_index + win->first_row]; + + /* If the screen line is inversed, then we have to clear + the line from the screen first. Why, I don't know. */ + if (entry->inverse) + { + terminal_goto_xy (0, line_index + win->first_row); + terminal_clear_to_eol (); + entry->inverse = 0; + entry->text[0] = '\0'; + entry->textlen = 0; + } + + /* Find the offset where these lines differ. */ + for (i = 0; i < pl_index; i++) + if (printed_line[i] != entry->text[i]) + break; + + /* If the lines are not the same length, or if they differed + at all, we must do some redrawing. */ + if ((i != pl_index) || (pl_index != entry->textlen)) + { + /* Move to the proper point on the terminal. */ + terminal_goto_xy (i, line_index + win->first_row); + + /* If there is any text to print, print it. */ + if (i != pl_index) + terminal_put_text (printed_line + i); + + /* If the printed text didn't extend all the way to the edge + of the window, and text was appearing between here and the + edge of the window, clear from here to the end of the line. */ + if ((pl_index < win->width && pl_index < entry->textlen) || + (entry->inverse)) + terminal_clear_to_eol (); + + fflush (stdout); + + /* Update the display text buffer. */ + strcpy (entry->text + i, printed_line + i); + entry->textlen = pl_index; + + /* Lines showing node text are not in inverse. Only modelines + have that distinction. */ + entry->inverse = 0; + } + + /* We have done at least one line. Increment our screen line + index, and check against the bottom of the window. */ + if (++line_index == win->height) + break; + + /* A line has been displayed, and the screen reflects that state. + If there is typeahead pending, then let that typeahead be read + now, instead of continuing with the display. */ + if (info_any_buffered_input_p ()) + { + free (printed_line); + display_was_interrupted_p = 1; + return; + } + + /* Reset PL_INDEX to the start of the line. */ + pl_index = 0; + + /* If there are characters from REP left to print, stuff them + into the buffer now. */ + if (rep_carried_over) + for (; rep[pl_index]; pl_index++) + printed_line[pl_index] = rep[pl_index]; + + /* If this window has chosen not to wrap lines, skip to the end + of the physical line in the buffer, and start a new line here. */ + if (pl_index && (win->flags & W_NoWrap)) + { + char *begin; + + pl_index = 0; + printed_line[0] = '\0'; + + begin = nodetext; + + while ((nodetext < last_node_char) && (*nodetext != '\n')) + nodetext++; + } + } + } + + done_with_node_display: + /* We have reached the end of the node or the end of the window. If it + is the end of the node, then clear the lines of the window from here + to the end of the window. */ + for (; line_index < win->height; line_index++) + { + DISPLAY_LINE *entry = display[line_index + win->first_row]; + + /* If this line has text on it then make it go away. */ + if (entry && entry->textlen) + { + entry->textlen = 0; + entry->text[0] = '\0'; + + terminal_goto_xy (0, line_index + win->first_row); + terminal_clear_to_eol (); + } + } + + /* Finally, if this window has a modeline it might need to be redisplayed. + Check the window's modeline against the one in the display, and update + if necessary. */ + if ((win->flags & W_InhibitMode) == 0) + { + window_make_modeline (win); + line_index = win->first_row + win->height; + + /* This display line must both be in inverse, and have the same + contents. */ + if ((!display[line_index]->inverse) || + (strcmp (display[line_index]->text, win->modeline) != 0)) + { + terminal_goto_xy (0, line_index); + terminal_begin_inverse (); + terminal_put_text (win->modeline); + terminal_end_inverse (); + strcpy (display[line_index]->text, win->modeline); + display[line_index]->inverse = 1; + display[line_index]->textlen = strlen (win->modeline); + fflush (stdout); + } + } + + /* Okay, this window doesn't need updating anymore. */ + win->flags &= ~W_UpdateWindow; + free (printed_line); + fflush (stdout); +} + +/* Scroll the region of the_display starting at START, ending at END, and + moving the lines AMOUNT lines. If AMOUNT is less than zero, the lines + are moved up in the screen, otherwise down. Actually, it is possible + for no scrolling to take place in the case that the terminal doesn't + support it. This doesn't matter to us. */ +void +display_scroll_display (start, end, amount) + int start, end, amount; +{ + register int i, last; + DISPLAY_LINE *temp; + + /* If this terminal cannot do scrolling, give up now. */ + if (!terminal_can_scroll) + return; + + /* If there isn't anything displayed on the screen because it is too + small, quit now. */ + if (!the_display[0]) + return; + + /* If there is typeahead pending, then don't actually do any scrolling. */ + if (info_any_buffered_input_p ()) + return; + + /* Do it on the screen. */ + terminal_scroll_terminal (start, end, amount); + + /* Now do it in the display buffer so our contents match the screen. */ + if (amount > 0) + { + last = end + amount; + + /* Shift the lines to scroll right into place. */ + for (i = 0; i < (end - start); i++) + { + temp = the_display[last - i]; + the_display[last - i] = the_display[end - i]; + the_display[end - i] = temp; + } + + /* The lines have been shifted down in the buffer. Clear all of the + lines that were vacated. */ + for (i = start; i != (start + amount); i++) + { + the_display[i]->text[0] = '\0'; + the_display[i]->textlen = 0; + the_display[i]->inverse = 0; + } + } + + if (amount < 0) + { + last = start + amount; + for (i = 0; i < (end - start); i++) + { + temp = the_display[last + i]; + the_display[last + i] = the_display[start + i]; + the_display[start + i] = temp; + } + + /* The lines have been shifted up in the buffer. Clear all of the + lines that are left over. */ + for (i = end + amount; i != end; i++) + { + the_display[i]->text[0] = '\0'; + the_display[i]->textlen = 0; + the_display[i]->inverse = 0; + } + } +} + +/* Try to scroll lines in WINDOW. OLD_PAGETOP is the pagetop of WINDOW before + having had its line starts recalculated. OLD_STARTS is the list of line + starts that used to appear in this window. OLD_COUNT is the number of lines + that appear in the OLD_STARTS array. */ +void +display_scroll_line_starts (window, old_pagetop, old_starts, old_count) + WINDOW *window; + int old_pagetop, old_count; + char **old_starts; +{ + register int i, old, new; /* Indices into the line starts arrays. */ + int last_new, last_old; /* Index of the last visible line. */ + int old_first, new_first; /* Index of the first changed line. */ + int unchanged_at_top = 0; + int already_scrolled = 0; + + /* Locate the first line which was displayed on the old window. */ + old_first = old_pagetop; + new_first = window->pagetop; + + /* Find the last line currently visible in this window. */ + last_new = window->pagetop + (window->height - 1); + if (last_new > window->line_count) + last_new = window->line_count - 1; + + /* Find the last line which used to be currently visible in this window. */ + last_old = old_pagetop + (window->height - 1); + if (last_old > old_count) + last_old = old_count - 1; + + for (old = old_first, new = new_first; + old < last_old && new < last_new; + old++, new++) + if (old_starts[old] != window->line_starts[new]) + break; + else + unchanged_at_top++; + + /* Loop through the old lines looking for a match in the new lines. */ + for (old = old_first + unchanged_at_top; old < last_old; old++) + { + for (new = new_first; new < last_new; new++) + if (old_starts[old] == window->line_starts[new]) + { + /* Find the extent of the matching lines. */ + for (i = 0; (old + i) < last_old; i++) + if (old_starts[old + i] != window->line_starts[new + i]) + break; + + /* Scroll these lines if there are enough of them. */ + { + int start, end, amount; + + start = (window->first_row + + ((old + already_scrolled) - old_pagetop)); + amount = new - (old + already_scrolled); + end = window->first_row + window->height; + + /* If we are shifting the block of lines down, then the last + AMOUNT lines will become invisible. Thus, don't bother + scrolling them. */ + if (amount > 0) + end -= amount; + + if ((end - start) > 0) + { + display_scroll_display (start, end, amount); + + /* Some lines have been scrolled. Simulate the scrolling + by offsetting the value of the old index. */ + old += i; + already_scrolled += amount; + } + } + } + } +} + +/* Move the screen cursor to directly over the current character in WINDOW. */ +void +display_cursor_at_point (window) + WINDOW *window; +{ + int vpos, hpos; + + vpos = window_line_of_point (window) - window->pagetop + window->first_row; + hpos = window_get_cursor_column (window); + terminal_goto_xy (hpos, vpos); +} + +/* **************************************************************** */ +/* */ +/* Functions Static to this File */ +/* */ +/* **************************************************************** */ + +/* Make a DISPLAY_LINE ** with width and height. */ +static DISPLAY_LINE ** +make_display (width, height) + int width, height; +{ + register int i; + DISPLAY_LINE **display; + + display = (DISPLAY_LINE **)xmalloc ((1 + height) * sizeof (DISPLAY_LINE *)); + + for (i = 0; i < height; i++) + { + display[i] = (DISPLAY_LINE *)xmalloc (sizeof (DISPLAY_LINE)); + display[i]->text = (char *)xmalloc (1 + width); + display[i]->textlen = 0; + display[i]->inverse = 0; + } + display[i] = (DISPLAY_LINE *)NULL; + return (display); +} + +/* Free the storage allocated to DISPLAY. */ +static void +free_display (display) + DISPLAY_LINE **display; +{ + register int i; + register DISPLAY_LINE *display_line; + + if (!display) + return; + + for (i = 0; display_line = display[i]; i++) + { + free (display_line->text); + free (display_line); + } + free (display); +} diff --git a/texinfo/info/display.h b/texinfo/info/display.h new file mode 100644 index 000000000000..d8bd5a166fe5 --- /dev/null +++ b/texinfo/info/display.h @@ -0,0 +1,76 @@ +/* display.h -- How the display in Info is done. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_DISPLAY_H_) +#define _DISPLAY_H_ + +#include "info-utils.h" +#include "terminal.h" + +typedef struct { + char *text; /* Text of the line as it appears. */ + int textlen; /* Printable Length of TEXT. */ + int inverse; /* Non-zero means this line is inverse. */ +} DISPLAY_LINE; + +/* An array of display lines which tell us what is currently visible on + the display. */ +extern DISPLAY_LINE **the_display; + +/* Non-zero means do no output. */ +extern int display_inhibited; + +/* Non-zero if we didn't completely redisplay a window. */ +extern int display_was_interrupted_p; + +/* Initialize THE_DISPLAY to WIDTH and HEIGHT, with nothing in it. */ +extern void display_initialize_display (); + +/* Clear all of the lines in DISPLAY making the screen blank. */ +extern void display_clear_display (); + +/* Update the windows pointed to by WINDOWS in THE_DISPLAY. This actually + writes the text on the screen. */ +extern void display_update_display (); + +/* Display WIN on THE_DISPLAY. Unlike display_update_display (), this + function only does one window. */ +extern void display_update_one_window (); + +/* Move the screen cursor to directly over the current character in WINDOW. */ +extern void display_cursor_at_point (); + +/* Scroll the region of the_display starting at START, ending at END, and + moving the lines AMOUNT lines. If AMOUNT is less than zero, the lines + are moved up in the screen, otherwise down. Actually, it is possible + for no scrolling to take place in the case that the terminal doesn't + support it. This doesn't matter to us. */ +extern void display_scroll_display (); + +/* Try to scroll lines in WINDOW. OLD_PAGETOP is the pagetop of WINDOW before + having had its line starts recalculated. OLD_STARTS is the list of line + starts that used to appear in this window. OLD_COUNT is the number of lines + that appear in the OLD_STARTS array. */ +extern void display_scroll_line_starts (); + +#endif /* !_DISPLAY_H_ */ diff --git a/texinfo/info/doc.h b/texinfo/info/doc.h new file mode 100644 index 000000000000..8afc28f74464 --- /dev/null +++ b/texinfo/info/doc.h @@ -0,0 +1,58 @@ +/* doc.h -- Structure associating function pointers with documentation. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_DOC_H_) +#define _DOC_H_ + +#if !defined (NULL) +# define NULL 0x0 +#endif /* !NULL */ + +#if !defined (__FUNCTION_DEF) +# define __FUNCTION_DEF +typedef int Function (); +typedef void VFunction (); +#endif /* _FUNCTION_DEF */ + +typedef struct { + VFunction *func; +#if defined (NAMED_FUNCTIONS) + char *func_name; +#endif /* NAMED_FUNCTIONS */ + char *doc; +} FUNCTION_DOC; + +extern FUNCTION_DOC function_doc_array[]; + +extern char *function_documentation (); +extern char *key_documentation (); +extern char *pretty_keyname (); +extern char *replace_in_documentation (); +extern void info_document_key (); +extern void dump_map_to_message_buffer (); + +#if defined (NAMED_FUNCTIONS) +extern char *function_name (); +extern VFunction *named_function (); +#endif /* NAMED_FUNCTIONS */ +#endif /* !_DOC_H_ */ diff --git a/texinfo/info/dribble.c b/texinfo/info/dribble.c new file mode 100644 index 000000000000..8e16cea4e45f --- /dev/null +++ b/texinfo/info/dribble.c @@ -0,0 +1,71 @@ +/* dribble.c -- Dribble files for Info. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include "dribble.h" + +/* When non-zero, it is a stream to write all input characters to for the + duration of this info session. */ +FILE *info_dribble_file = (FILE *)NULL; + +/* Open a dribble file named NAME, perhaps closing an already open one. + This sets the global variable INFO_DRIBBLE_FILE to the open stream. */ +void +open_dribble_file (name) + char *name; +{ + /* Perhaps close existing dribble file. */ + close_dribble_file (); + + info_dribble_file = fopen (name, "w"); + +#if defined (HAVE_SETVBUF) + if (info_dribble_file) +# if defined (SETVBUF_REVERSED) + setvbuf (info_dribble_file, _IONBF, (char *)NULL, 1); +# else + setvbuf (info_dribble_file, (char *)NULL, _IONBF, 1); +# endif /* !SETVBUF_REVERSED */ +#endif /* HAVE_SETVBUF */ +} + +/* If there is a dribble file already open, close it. */ +void +close_dribble_file () +{ + if (info_dribble_file) + { + fflush (info_dribble_file); + fclose (info_dribble_file); + info_dribble_file = (FILE *)NULL; + } +} + +/* Write some output to our existing dribble file. */ +void +dribble (byte) + unsigned char byte; +{ + if (info_dribble_file) + fwrite (&byte, sizeof (unsigned char), 1, info_dribble_file); +} diff --git a/texinfo/info/dribble.h b/texinfo/info/dribble.h new file mode 100644 index 000000000000..5647b40529e4 --- /dev/null +++ b/texinfo/info/dribble.h @@ -0,0 +1,41 @@ +/* dribble.h -- Functions and vars declared in dribble.c. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_DRIBBLE_H_) +#define _DRIBBLE_H_ + +/* When non-zero, it is a stream to write all input characters to for the + duration of this info session. */ +extern FILE *info_dribble_file; + +/* Open a dribble file named NAME, perhaps closing an already open one. + This sets the global variable INFO_DRIBBLE_FILE to the open stream. */ +extern void open_dribble_file (); + +/* If there is a dribble file already open, close it. */ +extern void close_dribble_file (); + +/* Write some output to our existing dribble file. */ +extern void dribble (); + +#endif /* !_DRIBBLE_H_ */ diff --git a/texinfo/info/echo_area.c b/texinfo/info/echo_area.c new file mode 100644 index 000000000000..265e98804259 --- /dev/null +++ b/texinfo/info/echo_area.c @@ -0,0 +1,1508 @@ +/* echo_area.c -- How to read a line in the echo area. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" + +#if defined (FD_SET) +# if defined (hpux) +# define fd_set_cast(x) (int *)(x) +# else +# define fd_set_cast(x) (fd_set *)(x) +# endif /* !hpux */ +#endif /* FD_SET */ + +/* Non-zero means that C-g was used to quit reading input. */ +int info_aborted_echo_area = 0; + +/* Non-zero means that the echo area is being used to read input. */ +int echo_area_is_active = 0; + +/* The address of the last command executed in the echo area. */ +VFunction *ea_last_executed_command = (VFunction *)NULL; + +/* Non-zero means that the last command executed while reading input + killed some text. */ +int echo_area_last_command_was_kill = 0; + +/* Variables which hold on to the current state of the input line. */ +static char input_line[1 + EA_MAX_INPUT]; +static char *input_line_prompt; +static int input_line_point; +static int input_line_beg; +static int input_line_end; +static NODE input_line_node = { + (char *)NULL, (char *)NULL, (char *)NULL, input_line, EA_MAX_INPUT, 0 +}; + +static void echo_area_initialize_node (); +static void push_echo_area (), pop_echo_area (); +static int echo_area_stack_depth (), echo_area_stack_contains_completions_p (); + +static void ea_kill_text (); + +/* Non-zero means we force the user to complete. */ +static int echo_area_must_complete_p = 0; +static int completions_window_p (); + +/* If non-null, this is a window which was specifically created to display + possible completions output. We remember it so we can delete it when + appropriate. */ +static WINDOW *echo_area_completions_window = (WINDOW *)NULL; + +/* Variables which keep track of the window which was active prior to + entering the echo area. */ +static WINDOW *calling_window = (WINDOW *)NULL; +static NODE *calling_window_node = (NODE *)NULL; +static long calling_window_point = 0; +static long calling_window_pagetop = 0; + +/* Remember the node and pertinent variables of the calling window. */ +static void +remember_calling_window (window) + WINDOW *window; +{ + /* Only do this if the calling window is not the completions window, or, + if it is the completions window and there is no other window. */ + if (!completions_window_p (window) || + ((window == windows) && !(window->next))) + { + calling_window = window; + calling_window_node = window->node; + calling_window_point = window->point; + calling_window_pagetop = window->pagetop; + } +} + +/* Restore the caller's window so that it shows the node that it was showing + on entry to info_read_xxx_echo_area (). */ +static void +restore_calling_window () +{ + register WINDOW *win, *compwin = (WINDOW *)NULL; + + /* If the calling window is still visible, and it is the window that + we used for completions output, then restore the calling window. */ + for (win = windows; win; win = win->next) + { + if (completions_window_p (win)) + compwin = win; + + if (win == calling_window && win == compwin) + { + window_set_node_of_window (calling_window, calling_window_node); + calling_window->point = calling_window_point; + calling_window->pagetop = calling_window_pagetop; + compwin = (WINDOW *)NULL; + break; + } + } + + /* Delete the completions window if it is still present, it isn't the + last window on the screen, and there aren't any prior echo area reads + pending which created a completions window. */ + if (compwin) + { + if ((compwin != windows || windows->next) && + !echo_area_stack_contains_completions_p ()) + { + WINDOW *next; + int pagetop, start, end, amount; + + next = compwin->next; + if (next) + { + start = next->first_row; + end = start + next->height; + amount = - (compwin->height + 1); + pagetop = next->pagetop; + } + + info_delete_window_internal (compwin); + + /* This is not necessary because info_delete_window_internal () + calls echo_area_inform_of_deleted_window (), which does the + right thing. */ +#if defined (UNNECESSARY) + echo_area_completions_window = (WINDOW *)NULL; +#endif /* UNNECESSARY */ + + if (next) + { + display_scroll_display (start, end, amount); + next->pagetop = pagetop; + display_update_display (windows); + } + } + } +} + +/* Set up a new input line with PROMPT. */ +static void +initialize_input_line (prompt) + char *prompt; +{ + input_line_prompt = prompt; + if (prompt) + strcpy (input_line, prompt); + else + input_line[0] = '\0'; + + input_line_beg = input_line_end = input_line_point = strlen (prompt); +} + +static char * +echo_area_after_read () +{ + char *return_value; + + if (info_aborted_echo_area) + { + info_aborted_echo_area = 0; + return_value = (char *)NULL; + } + else + { + if (input_line_beg == input_line_end) + return_value = strdup (""); + else + { + int line_len = input_line_end - input_line_beg; + return_value = (char *) xmalloc (1 + line_len); + strncpy (return_value, &input_line[input_line_beg], line_len); + return_value[line_len] = '\0'; + } + } + return (return_value); +} + +/* Read a line of text in the echo area. Return a malloc ()'ed string, + or NULL if the user aborted out of this read. WINDOW is the currently + active window, so that we can restore it when we need to. PROMPT, if + non-null, is a prompt to print before reading the line. */ +char * +info_read_in_echo_area (window, prompt) + WINDOW *window; + char *prompt; +{ + char *line; + + /* If the echo area is already active, remember the current state. */ + if (echo_area_is_active) + push_echo_area (); + + /* Initialize our local variables. */ + initialize_input_line (prompt); + + /* Initialize the echo area for the first (but maybe not the last) time. */ + echo_area_initialize_node (); + + /* Save away the original node of this window, and the window itself, + so echo area commands can temporarily use this window. */ + remember_calling_window (window); + + /* Let the rest of Info know that the echo area is active. */ + echo_area_is_active++; + active_window = the_echo_area; + + /* Read characters in the echo area. */ + info_read_and_dispatch (); + + echo_area_is_active--; + + /* Restore the original active window and show point in it. */ + active_window = calling_window; + restore_calling_window (); + display_cursor_at_point (active_window); + fflush (stdout); + + /* Get the value of the line. */ + line = echo_area_after_read (); + + /* If there is a previous loop waiting for us, restore it now. */ + if (echo_area_is_active) + pop_echo_area (); + + /* Return the results to the caller. */ + return (line); +} + +/* (re) Initialize the echo area node. */ +static void +echo_area_initialize_node () +{ + register int i; + + for (i = input_line_end; i < sizeof (input_line); i++) + input_line[i] = ' '; + + input_line[i - 1] = '\n'; + window_set_node_of_window (the_echo_area, &input_line_node); + input_line[input_line_end] = '\n'; +} + +/* Prepare to read characters in the echo area. This can initialize the + echo area node, but its primary purpose is to side effect the input + line buffer contents. */ +void +echo_area_prep_read () +{ + if (the_echo_area->node != &input_line_node) + echo_area_initialize_node (); + + the_echo_area->point = input_line_point; + input_line[input_line_end] = '\n'; + display_update_one_window (the_echo_area); + display_cursor_at_point (active_window); +} + + +/* **************************************************************** */ +/* */ +/* Echo Area Movement Commands */ +/* */ +/* **************************************************************** */ + +DECLARE_INFO_COMMAND (ea_forward, "Move forward a character") +{ + if (count < 0) + ea_backward (window, -count, key); + else + { + input_line_point += count; + if (input_line_point > input_line_end) + input_line_point = input_line_end; + } +} + +DECLARE_INFO_COMMAND (ea_backward, "Move backward a character") +{ + if (count < 0) + ea_forward (window, -count, key); + else + { + input_line_point -= count; + if (input_line_point < input_line_beg) + input_line_point = input_line_beg; + } +} + +DECLARE_INFO_COMMAND (ea_beg_of_line, "Move to the start of this line") +{ + input_line_point = input_line_beg; +} + +DECLARE_INFO_COMMAND (ea_end_of_line, "Move to the end of this line") +{ + input_line_point = input_line_end; +} + +#define alphabetic(c) (islower (c) || isupper (c) || isdigit (c)) + +/* Move forward a word in the input line. */ +DECLARE_INFO_COMMAND (ea_forward_word, "Move forward a word") +{ + int c; + + if (count < 0) + ea_backward_word (window, -count, key); + else + { + while (count--) + { + if (input_line_point == input_line_end) + return; + + /* If we are not in a word, move forward until we are in one. + Then, move forward until we hit a non-alphabetic character. */ + c = input_line[input_line_point]; + + if (!alphabetic (c)) + { + while (++input_line_point < input_line_end) + { + c = input_line[input_line_point]; + if (alphabetic (c)) + break; + } + } + + if (input_line_point == input_line_end) + return; + + while (++input_line_point < input_line_end) + { + c = input_line[input_line_point]; + if (!alphabetic (c)) + break; + } + } + } +} + +DECLARE_INFO_COMMAND (ea_backward_word, "Move backward a word") +{ + int c; + + if (count < 0) + ea_forward_word (window, -count, key); + else + { + while (count--) + { + if (input_line_point == input_line_beg) + return; + + /* Like ea_forward_word (), except that we look at the + characters just before point. */ + + c = input_line[input_line_point - 1]; + + if (!alphabetic (c)) + { + while ((--input_line_point) != input_line_beg) + { + c = input_line[input_line_point - 1]; + if (alphabetic (c)) + break; + } + } + + while (input_line_point != input_line_beg) + { + c = input_line[input_line_point - 1]; + if (!alphabetic (c)) + break; + else + --input_line_point; + } + } + } +} + +DECLARE_INFO_COMMAND (ea_delete, "Delete the character under the cursor") +{ + register int i; + + if (count < 0) + ea_rubout (window, -count, key); + else + { + if (input_line_point == input_line_end) + return; + + if (info_explicit_arg || count > 1) + { + int orig_point; + + orig_point = input_line_point; + ea_forward (window, count, key); + ea_kill_text (orig_point, input_line_point); + input_line_point = orig_point; + } + else + { + for (i = input_line_point; i < input_line_end; i++) + input_line[i] = input_line[i + 1]; + + input_line_end--; + } + } +} + +DECLARE_INFO_COMMAND (ea_rubout, "Delete the character behind the cursor") +{ + if (count < 0) + ea_delete (window, -count, key); + else + { + int start; + + if (input_line_point == input_line_beg) + return; + + start = input_line_point; + ea_backward (window, count, key); + + if (info_explicit_arg || count > 1) + ea_kill_text (start, input_line_point); + else + ea_delete (window, count, key); + } +} + +DECLARE_INFO_COMMAND (ea_abort, "Cancel or quit operation") +{ + /* If any text, just discard it, and restore the calling window's node. + If no text, quit. */ + if (input_line_end != input_line_beg) + { + terminal_ring_bell (); + input_line_end = input_line_point = input_line_beg; + if (calling_window->node != calling_window_node) + restore_calling_window (); + } + else + info_aborted_echo_area = 1; +} + +DECLARE_INFO_COMMAND (ea_newline, "Accept (or force completion of) this line") +{ + /* Stub does nothing. Simply here to see if it has been executed. */ +} + +DECLARE_INFO_COMMAND (ea_quoted_insert, "Insert next character verbatim") +{ + unsigned char character; + + character = info_get_another_input_char (); + ea_insert (window, count, character); +} + +DECLARE_INFO_COMMAND (ea_insert, "Insert this character") +{ + register int i; + + if ((input_line_end + 1) == EA_MAX_INPUT) + { + terminal_ring_bell (); + return; + } + + for (i = input_line_end + 1; i != input_line_point; i--) + input_line[i] = input_line[i - 1]; + + input_line[input_line_point] = key; + input_line_point++; + input_line_end++; +} + +DECLARE_INFO_COMMAND (ea_tab_insert, "Insert a TAB character") +{ + ea_insert (window, count, '\t'); +} + +/* Transpose the characters at point. If point is at the end of the line, + then transpose the characters before point. */ +DECLARE_INFO_COMMAND (ea_transpose_chars, "Transpose characters at point") +{ + /* Handle conditions that would make it impossible to transpose + characters. */ + if (!count || !input_line_point || (input_line_end - input_line_beg) < 2) + return; + + while (count) + { + int t; + if (input_line_point == input_line_end) + { + t = input_line[input_line_point - 1]; + + input_line[input_line_point - 1] = input_line[input_line_point - 2]; + input_line[input_line_point - 2] = t; + } + else + { + t = input_line[input_line_point]; + + input_line[input_line_point] = input_line[input_line_point - 1]; + input_line[input_line_point - 1] = t; + + if (count < 0 && input_line_point != input_line_beg) + input_line_point--; + else + input_line_point++; + } + + if (count < 0) + count++; + else + count--; + } +} + +/* **************************************************************** */ +/* */ +/* Echo Area Killing and Yanking */ +/* */ +/* **************************************************************** */ + +static char **kill_ring = (char **)NULL; +static int kill_ring_index = 0; /* Number of kills appearing in KILL_RING. */ +static int kill_ring_slots = 0; /* Number of slots allocated to KILL_RING. */ +static int kill_ring_loc = 0; /* Location of current yank pointer. */ + +/* The largest number of kills that we remember at one time. */ +static int max_retained_kills = 15; + +DECLARE_INFO_COMMAND (ea_yank, "Yank back the contents of the last kill") +{ + register int i; + register char *text; + + if (!kill_ring_index) + { + inform_in_echo_area ("Kill ring is empty"); + return; + } + + text = kill_ring[kill_ring_loc]; + + for (i = 0; text[i]; i++) + ea_insert (window, 1, text[i]); +} + +/* If the last command was yank, or yank_pop, and the text just before + point is identical to the current kill item, then delete that text + from the line, rotate the index down, and yank back some other text. */ +DECLARE_INFO_COMMAND (ea_yank_pop, "Yank back a previous kill") +{ + register int len; + + if (((ea_last_executed_command != ea_yank) && + (ea_last_executed_command != ea_yank_pop)) || + (kill_ring_index == 0)) + return; + + len = strlen (kill_ring[kill_ring_loc]); + + /* Delete the last yanked item from the line. */ + { + register int i, counter; + + counter = input_line_end - input_line_point; + + for (i = input_line_point - len; counter; i++, counter--) + input_line[i] = input_line[i + len]; + + input_line_end -= len; + input_line_point -= len; + } + + /* Get a previous kill, and yank that. */ + kill_ring_loc--; + if (kill_ring_loc < 0) + kill_ring_loc = kill_ring_index - 1; + + ea_yank (window, count, key); +} + +/* Delete the text from point to end of line. */ +DECLARE_INFO_COMMAND (ea_kill_line, "Kill to the end of the line") +{ + if (count < 0) + { + ea_kill_text (input_line_point, input_line_beg); + input_line_point = input_line_beg; + } + else + ea_kill_text (input_line_point, input_line_end); +} + +/* Delete the text from point to beg of line. */ +DECLARE_INFO_COMMAND (ea_backward_kill_line, + "Kill to the beginning of the line") +{ + if (count < 0) + ea_kill_text (input_line_point, input_line_end); + else + { + ea_kill_text (input_line_point, input_line_beg); + input_line_point = input_line_beg; + } +} + +/* Delete from point to the end of the current word. */ +DECLARE_INFO_COMMAND (ea_kill_word, "Kill the word following the cursor") +{ + int orig_point = input_line_point; + + if (count < 0) + ea_backward_kill_word (window, -count, key); + else + { + ea_forward_word (window, count, key); + + if (input_line_point != orig_point) + ea_kill_text (orig_point, input_line_point); + + input_line_point = orig_point; + } +} + +/* Delete from point to the start of the current word. */ +DECLARE_INFO_COMMAND (ea_backward_kill_word, + "Kill the word preceding the cursor") +{ + int orig_point = input_line_point; + + if (count < 0) + ea_kill_word (window, -count, key); + else + { + ea_backward_word (window, count, key); + + if (input_line_point != orig_point) + ea_kill_text (orig_point, input_line_point); + } +} + +/* The way to kill something. This appends or prepends to the last + kill, if the last command was a kill command. If FROM is less + than TO, then the killed text is appended to the most recent kill, + otherwise it is prepended. If the last command was not a kill command, + then a new slot is made for this kill. */ +static void +ea_kill_text (from, to) + int from, to; +{ + register int i, counter, distance; + int killing_backwards, slot; + char *killed_text; + + killing_backwards = (from > to); + + /* If killing backwards, reverse the values of FROM and TO. */ + if (killing_backwards) + { + int temp = from; + from = to; + to = temp; + } + + /* Remember the text that we are about to delete. */ + distance = to - from; + killed_text = (char *)xmalloc (1 + distance); + strncpy (killed_text, &input_line[from], distance); + killed_text[distance] = '\0'; + + /* Actually delete the text from the line. */ + counter = input_line_end - to; + + for (i = from; counter; i++, counter--) + input_line[i] = input_line[i + distance]; + + input_line_end -= distance; + + /* If the last command was a kill, append or prepend the killed text to + the last command's killed text. */ + if (echo_area_last_command_was_kill) + { + char *old, *new; + + slot = kill_ring_loc; + old = kill_ring[slot]; + new = (char *)xmalloc (1 + strlen (old) + strlen (killed_text)); + + if (killing_backwards) + { + /* Prepend TEXT to current kill. */ + strcpy (new, killed_text); + strcat (new, old); + } + else + { + /* Append TEXT to current kill. */ + strcpy (new, old); + strcat (new, killed_text); + } + + free (old); + free (killed_text); + kill_ring[slot] = new; + } + else + { + /* Try to store the kill in a new slot, unless that would cause there + to be too many remembered kills. */ + slot = kill_ring_index; + + if (slot == max_retained_kills) + slot = 0; + + if (slot + 1 > kill_ring_slots) + kill_ring = (char **) xrealloc + (kill_ring, + (kill_ring_slots += max_retained_kills) * sizeof (char *)); + + if (slot != kill_ring_index) + free (kill_ring[slot]); + else + kill_ring_index++; + + kill_ring[slot] = killed_text; + + kill_ring_loc = slot; + } + + /* Notice that the last command was a kill. */ + echo_area_last_command_was_kill++; +} + +/* **************************************************************** */ +/* */ +/* Echo Area Completion */ +/* */ +/* **************************************************************** */ + +/* Pointer to an array of REFERENCE to complete over. */ +static REFERENCE **echo_area_completion_items = (REFERENCE **)NULL; + +/* Sorted array of REFERENCE * which is the possible completions found in + the variable echo_area_completion_items. If there is only one element, + it is the only possible completion. */ +static REFERENCE **completions_found = (REFERENCE **)NULL; +static int completions_found_index = 0; +static int completions_found_slots = 0; + +/* The lowest common denominator found while completing. */ +static REFERENCE *LCD_completion; + +/* Internal functions used by the user calls. */ +static void build_completions (), completions_must_be_rebuilt (); + +/* Variable which holds the output of completions. */ +static NODE *possible_completions_output_node = (NODE *)NULL; + +static char *compwin_name = "*Completions*"; + +/* Return non-zero if WINDOW is a window used for completions output. */ +static int +completions_window_p (window) + WINDOW *window; +{ + int result = 0; + + if (internal_info_node_p (window->node) && + (strcmp (window->node->nodename, compwin_name) == 0)) + result = 1; + + return (result); +} + +/* Workhorse for completion readers. If FORCE is non-zero, the user cannot + exit unless the line read completes, or is empty. */ +char * +info_read_completing_internal (window, prompt, completions, force) + WINDOW *window; + char *prompt; + REFERENCE **completions; + int force; +{ + char *line; + + /* If the echo area is already active, remember the current state. */ + if (echo_area_is_active) + push_echo_area (); + + echo_area_must_complete_p = force; + + /* Initialize our local variables. */ + initialize_input_line (prompt); + + /* Initialize the echo area for the first (but maybe not the last) time. */ + echo_area_initialize_node (); + + /* Save away the original node of this window, and the window itself, + so echo area commands can temporarily use this window. */ + remember_calling_window (window); + + /* Save away the list of items to complete over. */ + echo_area_completion_items = completions; + completions_must_be_rebuilt (); + + active_window = the_echo_area; + echo_area_is_active++; + + /* Read characters in the echo area. */ + while (1) + { + info_read_and_dispatch (); + + line = echo_area_after_read (); + + /* Force the completion to take place if the user hasn't accepted + a default or aborted, and if FORCE is active. */ + if (force && line && *line && completions) + { + register int i; + + build_completions (); + + /* If there is only one completion, then make the line be that + completion. */ + if (completions_found_index == 1) + { + free (line); + line = strdup (completions_found[0]->label); + break; + } + + /* If one of the completions matches exactly, then that is okay, so + return the current line. */ + for (i = 0; i < completions_found_index; i++) + if (strcasecmp (completions_found[i]->label, line) == 0) + { + free (line); + line = strdup (completions_found[i]->label); + break; + } + + /* If no match, go back and try again. */ + if (i == completions_found_index) + { + inform_in_echo_area ("Not complete"); + continue; + } + } + break; + } + echo_area_is_active--; + + /* Restore the original active window and show point in it. */ + active_window = calling_window; + restore_calling_window (); + display_cursor_at_point (active_window); + fflush (stdout); + + echo_area_completion_items = (REFERENCE **)NULL; + completions_must_be_rebuilt (); + + /* If there is a previous loop waiting for us, restore it now. */ + if (echo_area_is_active) + pop_echo_area (); + + return (line); +} + +/* Read a line in the echo area with completion over COMPLETIONS. */ +char * +info_read_completing_in_echo_area (window, prompt, completions) + WINDOW *window; + char *prompt; + REFERENCE **completions; +{ + return (info_read_completing_internal (window, prompt, completions, 1)); +} + +/* Read a line in the echo area allowing completion over COMPLETIONS, but + not requiring it. */ +char * +info_read_maybe_completing (window, prompt, completions) + WINDOW *window; + char *prompt; + REFERENCE **completions; +{ + return (info_read_completing_internal (window, prompt, completions, 0)); +} + +DECLARE_INFO_COMMAND (ea_possible_completions, "List possible completions") +{ + if (!echo_area_completion_items) + { + ea_insert (window, count, key); + return; + } + + build_completions (); + + if (!completions_found_index) + { + terminal_ring_bell (); + inform_in_echo_area ("No completions"); + } + else if ((completions_found_index == 1) && (key != '?')) + { + inform_in_echo_area ("Sole completion"); + } + else + { + register int i, l; + int limit, count, max_label = 0; + + initialize_message_buffer (); + printf_to_message_buffer + ("There %s %d ", completions_found_index == 1 ? "is" : "are", + completions_found_index); + printf_to_message_buffer + ("completion%s:\n", completions_found_index == 1 ? "" : "s"); + + /* Find the maximum length of a label. */ + for (i = 0; i < completions_found_index; i++) + { + int len = strlen (completions_found[i]->label); + if (len > max_label) + max_label = len; + } + + max_label += 4; + + /* Find out how many columns we should print in. */ + limit = calling_window->width / max_label; + if (limit != 1 && (limit * max_label == calling_window->width)) + limit--; + + /* Avoid a possible floating exception. If max_label > width then + the limit will be 0 and a divide-by-zero fault will result. */ + if (limit == 0) + limit = 1; + + /* How many iterations of the printing loop? */ + count = (completions_found_index + (limit - 1)) / limit; + + /* Watch out for special case. If the number of completions is less + than LIMIT, then just do the inner printing loop. */ + if (completions_found_index < limit) + count = 1; + + /* Print the sorted items, up-and-down alphabetically. */ + for (i = 0; i < count; i++) + { + register int j; + + for (j = 0, l = i; j < limit; j++) + { + if (l >= completions_found_index) + break; + else + { + char *label; + int printed_length, k; + + label = completions_found[l]->label; + printed_length = strlen (label); + printf_to_message_buffer ("%s", label); + + if (j + 1 < limit) + { + for (k = 0; k < max_label - printed_length; k++) + printf_to_message_buffer (" "); + } + } + l += count; + } + printf_to_message_buffer ("\n"); + } + + /* Make a new node to hold onto possible completions. Don't destroy + dangling pointers. */ + { + NODE *temp; + + temp = message_buffer_to_node (); + add_gcable_pointer (temp->contents); + name_internal_node (temp, compwin_name); + possible_completions_output_node = temp; + } + + /* Find a suitable window for displaying the completions output. + First choice is an existing window showing completions output. + If there is only one window, and it is large, make another + (smaller) window, and use that one. Otherwise, use the caller's + window. */ + { + WINDOW *compwin; + + compwin = get_internal_info_window (compwin_name); + + if (!compwin) + { + /* If we can split the window to display most of the completion + items, then do so. */ + if (calling_window->height > (count * 2)) + { + int start, end, pagetop; + + active_window = calling_window; + + /* Perhaps we can scroll this window on redisplay. */ + start = calling_window->first_row; + pagetop = calling_window->pagetop; + + compwin = + window_make_window (possible_completions_output_node); + active_window = the_echo_area; + window_change_window_height + (compwin, -(compwin->height - (count + 2))); + + window_adjust_pagetop (calling_window); + remember_calling_window (calling_window); + +#if defined (SPLIT_BEFORE_ACTIVE) + /* If the pagetop hasn't changed, scrolling the calling + window is a reasonable thing to do. */ + if (pagetop == calling_window->pagetop) + { + end = start + calling_window->height; + display_scroll_display + (start, end, calling_window->prev->height + 1); + } +#else /* !SPLIT_BEFORE_ACTIVE */ + /* If the pagetop has changed, set the new pagetop here. */ + if (pagetop != calling_window->pagetop) + { + int newtop = calling_window->pagetop; + calling_window->pagetop = pagetop; + set_window_pagetop (calling_window, newtop); + } +#endif /* !SPLIT_BEFORE_ACTIVE */ + + echo_area_completions_window = compwin; + remember_window_and_node (compwin, compwin->node); + } + else + compwin = calling_window; + } + + if (compwin->node != possible_completions_output_node) + { + window_set_node_of_window + (compwin, possible_completions_output_node); + remember_window_and_node (compwin, compwin->node); + } + + display_update_display (windows); + } + } +} + +DECLARE_INFO_COMMAND (ea_complete, "Insert completion") +{ + if (!echo_area_completion_items) + { + ea_insert (window, count, key); + return; + } + + /* If KEY is SPC, and we are not forcing completion to take place, simply + insert the key. */ + if (!echo_area_must_complete_p && key == SPC) + { + ea_insert (window, count, key); + return; + } + + if (ea_last_executed_command == ea_complete) + { + /* If the keypress is a SPC character, and we have already tried + completing once, and there are several completions, then check + the batch of completions to see if any continue with a space. + If there are some, insert the space character and continue. */ + if (key == SPC && completions_found_index > 1) + { + register int i, offset; + + offset = input_line_end - input_line_beg; + + for (i = 0; i < completions_found_index; i++) + if (completions_found[i]->label[offset] == ' ') + break; + + if (completions_found[i]) + ea_insert (window, 1, ' '); + else + { + ea_possible_completions (window, count, key); + return; + } + } + else + { + ea_possible_completions (window, count, key); + return; + } + } + + input_line_point = input_line_end; + build_completions (); + + if (!completions_found_index) + terminal_ring_bell (); + else if (LCD_completion->label[0] == '\0') + ea_possible_completions (window, count, key); + else + { + register int i; + input_line_point = input_line_end = input_line_beg; + for (i = 0; LCD_completion->label[i]; i++) + ea_insert (window, 1, LCD_completion->label[i]); + } +} + +/* Utility REFERENCE used to store possible LCD. */ +static REFERENCE LCD_reference = { (char *)NULL, (char *)NULL, (char *)NULL }; + +static void remove_completion_duplicates (); + +/* Variables which remember the state of the most recent call + to build_completions (). */ +static char *last_completion_request = (char *)NULL; +static REFERENCE **last_completion_items = (REFERENCE **)NULL; + +/* How to tell the completion builder to reset internal state. */ +static void +completions_must_be_rebuilt () +{ + maybe_free (last_completion_request); + last_completion_request = (char *)NULL; + last_completion_items = (REFERENCE **)NULL; +} + +/* Build a list of possible completions from echo_area_completion_items, + and the contents of input_line. */ +static void +build_completions () +{ + register int i, len; + register REFERENCE *entry; + char *request; + int informed_of_lengthy_job = 0; + + /* If there are no items to complete over, exit immediately. */ + if (!echo_area_completion_items) + { + completions_found_index = 0; + LCD_completion = (REFERENCE *)NULL; + return; + } + + /* Check to see if this call to build completions is the same as the last + call to build completions. */ + len = input_line_end - input_line_beg; + request = (char *)xmalloc (1 + len); + strncpy (request, &input_line[input_line_beg], len); + request[len] = '\0'; + + if (last_completion_request && last_completion_items && + last_completion_items == echo_area_completion_items && + (strcmp (last_completion_request, request) == 0)) + { + free (request); + return; + } + + maybe_free (last_completion_request); + last_completion_request = request; + last_completion_items = echo_area_completion_items; + + /* Always start at the beginning of the list. */ + completions_found_index = 0; + LCD_completion = (REFERENCE *)NULL; + + for (i = 0; entry = echo_area_completion_items[i]; i++) + { + if (strncasecmp (request, entry->label, len) == 0) + add_pointer_to_array (entry, completions_found_index, + completions_found, completions_found_slots, + 20, REFERENCE *); + + if (!informed_of_lengthy_job && completions_found_index > 100) + { + informed_of_lengthy_job = 1; + window_message_in_echo_area ("Building completions..."); + } + } + + if (!completions_found_index) + return; + + /* Sort and prune duplicate entries from the completions array. */ + remove_completion_duplicates (); + + /* If there is only one completion, just return that. */ + if (completions_found_index == 1) + { + LCD_completion = completions_found[0]; + return; + } + + /* Find the least common denominator. */ + { + long shortest = 100000; + + for (i = 1; i < completions_found_index; i++) + { + register int j; + int c1, c2; + + for (j = 0; + (c1 = info_tolower (completions_found[i - 1]->label[j])) && + (c2 = info_tolower (completions_found[i]->label[j])); + j++) + if (c1 != c2) + break; + + if (shortest > j) + shortest = j; + } + + maybe_free (LCD_reference.label); + LCD_reference.label = (char *)xmalloc (1 + shortest); + strncpy (LCD_reference.label, completions_found[0]->label, shortest); + LCD_reference.label[shortest] = '\0'; + LCD_completion = &LCD_reference; + } + + if (informed_of_lengthy_job) + echo_area_initialize_node (); +} + +/* Function called by qsort. */ +static int +compare_references (entry1, entry2) + REFERENCE **entry1, **entry2; +{ + return (strcasecmp ((*entry1)->label, (*entry2)->label)); +} + +/* Prune duplicate entries from COMPLETIONS_FOUND. */ +static void +remove_completion_duplicates () +{ + register int i, j; + REFERENCE **temp; + int newlen; + + if (!completions_found_index) + return; + + /* Sort the items. */ + qsort (completions_found, completions_found_index, sizeof (REFERENCE *), + compare_references); + + for (i = 0, newlen = 1; i < completions_found_index - 1; i++) + { + if (strcmp (completions_found[i]->label, + completions_found[i + 1]->label) == 0) + completions_found[i] = (REFERENCE *)NULL; + else + newlen++; + } + + /* We have marked all the dead slots. It is faster to copy the live slots + twice than to prune the dead slots one by one. */ + temp = (REFERENCE **)xmalloc ((1 + newlen) * sizeof (REFERENCE *)); + for (i = 0, j = 0; i < completions_found_index; i++) + if (completions_found[i]) + temp[j++] = completions_found[i]; + + for (i = 0; i < newlen; i++) + completions_found[i] = temp[i]; + + completions_found[i] = (REFERENCE *)NULL; + completions_found_index = newlen; + free (temp); +} + +/* Scroll the "other" window. If there is a window showing completions, scroll + that one, otherwise scroll the window which was active on entering the read + function. */ +DECLARE_INFO_COMMAND (ea_scroll_completions_window, "Scroll the completions window") +{ + WINDOW *compwin; + int old_pagetop; + + compwin = get_internal_info_window (compwin_name); + + if (!compwin) + compwin = calling_window; + + old_pagetop = compwin->pagetop; + + /* Let info_scroll_forward () do the work, and print any messages that + need to be displayed. */ + info_scroll_forward (compwin, count, key); +} + +/* Function which gets called when an Info window is deleted while the + echo area is active. WINDOW is the window which has just been deleted. */ +void +echo_area_inform_of_deleted_window (window) + WINDOW *window; +{ + /* If this is the calling_window, forget what we remembered about it. */ + if (window == calling_window) + { + if (active_window != the_echo_area) + remember_calling_window (active_window); + else + remember_calling_window (windows); + } + + /* If this window was the echo_area_completions_window, then notice that + the window has been deleted. */ + if (window == echo_area_completions_window) + echo_area_completions_window = (WINDOW *)NULL; +} + +/* **************************************************************** */ +/* */ +/* Pushing and Popping the Echo Area */ +/* */ +/* **************************************************************** */ + +/* Push and Pop the echo area. */ +typedef struct { + char *line; + char *prompt; + REFERENCE **comp_items; + int point, beg, end; + int must_complete; + NODE node; + WINDOW *compwin; +} PUSHED_EA; + +static PUSHED_EA **pushed_echo_areas = (PUSHED_EA **)NULL; +static int pushed_echo_areas_index = 0; +static int pushed_echo_areas_slots = 0; + +/* Pushing the echo_area has a side effect of zeroing the completion_items. */ +static void +push_echo_area () +{ + PUSHED_EA *pushed; + + pushed = (PUSHED_EA *)xmalloc (sizeof (PUSHED_EA)); + pushed->line = strdup (input_line); + pushed->prompt = input_line_prompt; + pushed->point = input_line_point; + pushed->beg = input_line_beg; + pushed->end = input_line_end; + pushed->node = input_line_node; + pushed->comp_items = echo_area_completion_items; + pushed->must_complete = echo_area_must_complete_p; + pushed->compwin = echo_area_completions_window; + + add_pointer_to_array (pushed, pushed_echo_areas_index, pushed_echo_areas, + pushed_echo_areas_slots, 4, PUSHED_EA *); + + echo_area_completion_items = (REFERENCE **)NULL; +} + +static void +pop_echo_area () +{ + PUSHED_EA *popped; + + popped = pushed_echo_areas[--pushed_echo_areas_index]; + + strcpy (input_line, popped->line); + free (popped->line); + input_line_prompt = popped->prompt; + input_line_point = popped->point; + input_line_beg = popped->beg; + input_line_end = popped->end; + input_line_node = popped->node; + echo_area_completion_items = popped->comp_items; + echo_area_must_complete_p = popped->must_complete; + echo_area_completions_window = popped->compwin; + completions_must_be_rebuilt (); + + /* If the completion window no longer exists, forget about it. */ + if (echo_area_completions_window) + { + register WINDOW *win; + + for (win = windows; win; win = win->next) + if (echo_area_completions_window == win) + break; + + /* If the window wasn't found, then it has already been deleted. */ + if (!win) + echo_area_completions_window = (WINDOW *)NULL; + } + + free (popped); +} + +static int +echo_area_stack_depth () +{ + return (pushed_echo_areas_index); +} + +/* Returns non-zero if any of the prior stacked calls to read in the echo + area produced a completions window. */ +static int +echo_area_stack_contains_completions_p () +{ + register int i; + + for (i = 0; i < pushed_echo_areas_index; i++) + if (pushed_echo_areas[i]->compwin) + return (1); + + return (0); +} + +/* **************************************************************** */ +/* */ +/* Error Messages While Reading in Echo Area */ +/* */ +/* **************************************************************** */ + +#if defined (HAVE_SYS_TIME_H) +# include +# define HAVE_STRUCT_TIMEVAL +#endif /* HAVE_SYS_TIME_H */ + +static void +pause_or_input () +{ +#if defined (FD_SET) + struct timeval timer; + fd_set readfds; + int ready; + + FD_ZERO (&readfds); + FD_SET (fileno (stdin), &readfds); + timer.tv_sec = 2; + timer.tv_usec = 750; + ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer); +#endif /* FD_SET */ +} + +/* Print MESSAGE right after the end of the current line, and wait + for input or 2.75 seconds, whichever comes first. Then flush the + informational message that was printed. */ +void +inform_in_echo_area (message) + char *message; +{ + register int i; + char *text; + + text = strdup (message); + for (i = 0; text[i] && text[i] != '\n'; i++); + text[i] = '\0'; + + echo_area_initialize_node (); + sprintf (&input_line[input_line_end], "%s[%s]\n", + echo_area_is_active ? " ": "", text); + free (text); + the_echo_area->point = input_line_point; + display_update_one_window (the_echo_area); + display_cursor_at_point (active_window); + fflush (stdout); + pause_or_input (); + echo_area_initialize_node (); +} diff --git a/texinfo/info/echo_area.h b/texinfo/info/echo_area.h new file mode 100644 index 000000000000..09c2bc7e22eb --- /dev/null +++ b/texinfo/info/echo_area.h @@ -0,0 +1,63 @@ +/* echo_area.h -- Functions used in reading information from the echo area. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_ECHO_AREA_H_) +#define _ECHO_AREA_H_ + +#define EA_MAX_INPUT 256 + +extern int echo_area_is_active, info_aborted_echo_area; + +/* Non-zero means that the last command executed while reading input + killed some text. */ +extern int echo_area_last_command_was_kill; + +extern void inform_in_echo_area (), echo_area_inform_of_deleted_window (); +extern void echo_area_prep_read (); +extern VFunction *ea_last_executed_command; + +/* Read a line of text in the echo area. Return a malloc ()'ed string, + or NULL if the user aborted out of this read. WINDOW is the currently + active window, so that we can restore it when we need to. PROMPT, if + non-null, is a prompt to print before reading the line. */ +extern char *info_read_in_echo_area (); + +/* Read a line in the echo area with completion over COMPLETIONS. + Takes arguments of WINDOW, PROMPT, and COMPLETIONS, a REFERENCE **. */ +char *info_read_completing_in_echo_area (); + +/* Read a line in the echo area allowing completion over COMPLETIONS, but + not requiring it. Takes arguments of WINDOW, PROMPT, and COMPLETIONS, + a REFERENCE **. */ +extern char *info_read_maybe_completing (); + +extern void ea_insert (), ea_quoted_insert (); +extern void ea_beg_of_line (), ea_backward (), ea_delete (), ea_end_of_line (); +extern void ea_forward (), ea_abort (), ea_rubout (), ea_complete (); +extern void ea_newline (), ea_kill_line (), ea_transpose_chars (); +extern void ea_yank (), ea_tab_insert (), ea_possible_completions (); +extern void ea_backward_word (), ea_kill_word (), ea_forward_word (); +extern void ea_yank_pop (), ea_backward_kill_word (); +extern void ea_scroll_completions_window (); + +#endif /* _ECHO_AREA_H_ */ diff --git a/texinfo/info/filesys.c b/texinfo/info/filesys.c new file mode 100644 index 000000000000..e684bf81f7b1 --- /dev/null +++ b/texinfo/info/filesys.c @@ -0,0 +1,617 @@ +/* filesys.c -- File system specific functions for hacking this system. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include +#include +#if defined (HAVE_SYS_FILE_H) +#include +#endif /* HAVE_SYS_FILE_H */ +#include +#include "general.h" +#include "tilde.h" +#include "filesys.h" + +#if !defined (O_RDONLY) +#if defined (HAVE_SYS_FCNTL_H) +#include +#else /* !HAVE_SYS_FCNTL_H */ +#include +#endif /* !HAVE_SYS_FCNTL_H */ +#endif /* !O_RDONLY */ + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +/* Found in info-utils.c. */ +extern char *filename_non_directory (); + +#if !defined (BUILDING_LIBRARY) +/* Found in session.c */ +extern int info_windows_initialized_p; + +/* Found in window.c. */ +extern void message_in_echo_area (), unmessage_in_echo_area (); +#endif /* !BUILDING_LIBRARY */ + +/* Local to this file. */ +static char *info_file_in_path (), *lookup_info_filename (); +static void remember_info_filename (), maybe_initialize_infopath (); + +#if !defined (NULL) +# define NULL 0x0 +#endif /* !NULL */ + +typedef struct { + char *suffix; + char *decompressor; +} COMPRESSION_ALIST; + +static char *info_suffixes[] = { + "", + ".info", + "-info", + (char *)NULL +}; + +static COMPRESSION_ALIST compress_suffixes[] = { + { ".Z", "uncompress" }, + { ".Y", "unyabba" }, + { ".z", "gunzip" }, + { ".gz", "gunzip" }, + { (char *)NULL, (char *)NULL } +}; + +/* The path on which we look for info files. You can initialize this + from the environment variable INFOPATH if there is one, or you can + call info_add_path () to add paths to the beginning or end of it. + You can call zap_infopath () to make the path go away. */ +char *infopath = (char *)NULL; +static int infopath_size = 0; + +/* Expand the filename in PARTIAL to make a real name for this operating + system. This looks in INFO_PATHS in order to find the correct file. + If it can't find the file, it returns NULL. */ +static char *local_temp_filename = (char *)NULL; +static int local_temp_filename_size = 0; + +char * +info_find_fullpath (partial) + char *partial; +{ + int initial_character; + char *temp; + + filesys_error_number = 0; + + maybe_initialize_infopath (); + + if (partial && (initial_character = *partial)) + { + char *expansion; + + expansion = lookup_info_filename (partial); + + if (expansion) + return (expansion); + + /* If we have the full path to this file, we still may have to add + various extensions to it. I guess we have to stat this file + after all. */ + if (initial_character == '/') + temp = info_file_in_path (partial + 1, "/"); + else if (initial_character == '~') + { + expansion = tilde_expand_word (partial); + if (*expansion == '/') + { + temp = info_file_in_path (expansion + 1, "/"); + free (expansion); + } + else + temp = expansion; + } + else if (initial_character == '.' && + (partial[1] == '/' || (partial[1] == '.' && partial[2] == '/'))) + { + if (local_temp_filename_size < 1024) + local_temp_filename = (char *)xrealloc + (local_temp_filename, (local_temp_filename_size = 1024)); +#if defined (HAVE_GETCWD) + if (!getcwd (local_temp_filename, local_temp_filename_size)) +#else /* !HAVE_GETCWD */ + if (!getwd (local_temp_filename)) +#endif /* !HAVE_GETCWD */ + { + filesys_error_number = errno; + return (partial); + } + + strcat (local_temp_filename, "/"); + strcat (local_temp_filename, partial); + return (local_temp_filename); + } + else + temp = info_file_in_path (partial, infopath); + + if (temp) + { + remember_info_filename (partial, temp); + if (strlen (temp) > local_temp_filename_size) + local_temp_filename = (char *) xrealloc + (local_temp_filename, + (local_temp_filename_size = (50 + strlen (temp)))); + strcpy (local_temp_filename, temp); + free (temp); + return (local_temp_filename); + } + } + return (partial); +} + +/* Scan the list of directories in PATH looking for FILENAME. If we find + one that is a regular file, return it as a new string. Otherwise, return + a NULL pointer. */ +static char * +info_file_in_path (filename, path) + char *filename, *path; +{ + struct stat finfo; + char *temp_dirname; + int statable, dirname_index; + + dirname_index = 0; + + while (temp_dirname = extract_colon_unit (path, &dirname_index)) + { + register int i, pre_suffix_length; + char *temp; + + /* Expand a leading tilde if one is present. */ + if (*temp_dirname == '~') + { + char *expanded_dirname; + + expanded_dirname = tilde_expand_word (temp_dirname); + free (temp_dirname); + temp_dirname = expanded_dirname; + } + + temp = (char *)xmalloc (30 + strlen (temp_dirname) + strlen (filename)); + strcpy (temp, temp_dirname); + if (temp[(strlen (temp)) - 1] != '/') + strcat (temp, "/"); + strcat (temp, filename); + + pre_suffix_length = strlen (temp); + + free (temp_dirname); + + for (i = 0; info_suffixes[i]; i++) + { + strcpy (temp + pre_suffix_length, info_suffixes[i]); + + statable = (stat (temp, &finfo) == 0); + + /* If we have found a regular file, then use that. Else, if we + have found a directory, look in that directory for this file. */ + if (statable) + { + if (S_ISREG (finfo.st_mode)) + { + return (temp); + } + else if (S_ISDIR (finfo.st_mode)) + { + char *newpath, *filename_only, *newtemp; + + newpath = strdup (temp); + filename_only = filename_non_directory (filename); + newtemp = info_file_in_path (filename_only, newpath); + + free (newpath); + if (newtemp) + { + free (temp); + return (newtemp); + } + } + } + else + { + /* Add various compression suffixes to the name to see if + the file is present in compressed format. */ + register int j, pre_compress_suffix_length; + + pre_compress_suffix_length = strlen (temp); + + for (j = 0; compress_suffixes[j].suffix; j++) + { + strcpy (temp + pre_compress_suffix_length, + compress_suffixes[j].suffix); + + statable = (stat (temp, &finfo) == 0); + if (statable && (S_ISREG (finfo.st_mode))) + return (temp); + } + } + } + free (temp); + } + return ((char *)NULL); +} + +/* Given a string containing units of information separated by colons, + return the next one pointed to by IDX, or NULL if there are no more. + Advance IDX to the character after the colon. */ +char * +extract_colon_unit (string, idx) + char *string; + int *idx; +{ + register int i, start; + + i = start = *idx; + if ((i >= strlen (string)) || !string) + return ((char *) NULL); + + while (string[i] && string[i] != ':') + i++; + if (i == start) + { + return ((char *) NULL); + } + else + { + char *value; + + value = (char *) xmalloc (1 + (i - start)); + strncpy (value, &string[start], (i - start)); + value[i - start] = '\0'; + if (string[i]) + ++i; + *idx = i; + return (value); + } +} + +/* A structure which associates a filename with its expansion. */ +typedef struct { + char *filename; + char *expansion; +} FILENAME_LIST; + +/* An array of remembered arguments and results. */ +static FILENAME_LIST **names_and_files = (FILENAME_LIST **)NULL; +static int names_and_files_index = 0; +static int names_and_files_slots = 0; + +/* Find the result for having already called info_find_fullpath () with + FILENAME. */ +static char * +lookup_info_filename (filename) + char *filename; +{ + if (filename && names_and_files) + { + register int i; + for (i = 0; names_and_files[i]; i++) + { + if (strcmp (names_and_files[i]->filename, filename) == 0) + return (names_and_files[i]->expansion); + } + } + return (char *)NULL;; +} + +/* Add a filename and its expansion to our list. */ +static void +remember_info_filename (filename, expansion) + char *filename, *expansion; +{ + FILENAME_LIST *new; + + if (names_and_files_index + 2 > names_and_files_slots) + { + int alloc_size; + names_and_files_slots += 10; + + alloc_size = names_and_files_slots * sizeof (FILENAME_LIST *); + + names_and_files = + (FILENAME_LIST **) xrealloc (names_and_files, alloc_size); + } + + new = (FILENAME_LIST *)xmalloc (sizeof (FILENAME_LIST)); + new->filename = strdup (filename); + new->expansion = expansion ? strdup (expansion) : (char *)NULL; + + names_and_files[names_and_files_index++] = new; + names_and_files[names_and_files_index] = (FILENAME_LIST *)NULL; +} + +static void +maybe_initialize_infopath () +{ + if (!infopath_size) + { + infopath = (char *) + xmalloc (infopath_size = (1 + strlen (DEFAULT_INFOPATH))); + + strcpy (infopath, DEFAULT_INFOPATH); + } +} + +/* Add PATH to the list of paths found in INFOPATH. 2nd argument says + whether to put PATH at the front or end of INFOPATH. */ +void +info_add_path (path, where) + char *path; + int where; +{ + int len; + + if (!infopath) + { + infopath = (char *)xmalloc (infopath_size = 200 + strlen (path)); + infopath[0] = '\0'; + } + + len = strlen (path) + strlen (infopath); + + if (len + 2 >= infopath_size) + infopath = (char *)xrealloc (infopath, (infopath_size += (2 * len) + 2)); + + if (!*infopath) + strcpy (infopath, path); + else if (where == INFOPATH_APPEND) + { + strcat (infopath, ":"); + strcat (infopath, path); + } + else if (where == INFOPATH_PREPEND) + { + char *temp = strdup (infopath); + strcpy (infopath, path); + strcat (infopath, ":"); + strcat (infopath, temp); + free (temp); + } +} + +/* Make INFOPATH have absolutely nothing in it. */ +void +zap_infopath () +{ + if (infopath) + free (infopath); + + infopath = (char *)NULL; + infopath_size = 0; +} + +/* Read the contents of PATHNAME, returning a buffer with the contents of + that file in it, and returning the size of that buffer in FILESIZE. + FINFO is a stat struct which has already been filled in by the caller. + If the file cannot be read, return a NULL pointer. */ +char * +filesys_read_info_file (pathname, filesize, finfo) + char *pathname; + long *filesize; + struct stat *finfo; +{ + long st_size; + + *filesize = filesys_error_number = 0; + + if (compressed_filename_p (pathname)) + return (filesys_read_compressed (pathname, filesize, finfo)); + else + { + int descriptor; + char *contents; + + descriptor = open (pathname, O_RDONLY, 0666); + + /* If the file couldn't be opened, give up. */ + if (descriptor < 0) + { + filesys_error_number = errno; + return ((char *)NULL); + } + + /* Try to read the contents of this file. */ + st_size = (long) finfo->st_size; + contents = (char *)xmalloc (1 + st_size); + if ((read (descriptor, contents, st_size)) != st_size) + { + filesys_error_number = errno; + close (descriptor); + free (contents); + return ((char *)NULL); + } + + close (descriptor); + + *filesize = st_size; + return (contents); + } +} + +/* Typically, pipe buffers are 4k. */ +#define BASIC_PIPE_BUFFER (4 * 1024) + +/* We use some large multiple of that. */ +#define FILESYS_PIPE_BUFFER_SIZE (16 * BASIC_PIPE_BUFFER) + +char * +filesys_read_compressed (pathname, filesize, finfo) + char *pathname; + long *filesize; + struct stat *finfo; +{ + FILE *stream; + char *command, *decompressor; + char *contents = (char *)NULL; + + *filesize = filesys_error_number = 0; + + decompressor = filesys_decompressor_for_file (pathname); + + if (!decompressor) + return ((char *)NULL); + + command = (char *)xmalloc (10 + strlen (pathname) + strlen (decompressor)); + sprintf (command, "%s < %s", decompressor, pathname); + +#if !defined (BUILDING_LIBRARY) + if (info_windows_initialized_p) + { + char *temp; + + temp = (char *)xmalloc (5 + strlen (command)); + sprintf (temp, "%s...", command); + message_in_echo_area ("%s", temp); + free (temp); + } +#endif /* !BUILDING_LIBRARY */ + + stream = popen (command, "r"); + free (command); + + /* Read chunks from this file until there are none left to read. */ + if (stream) + { + int offset, size; + char *chunk; + + offset = size = 0; + chunk = (char *)xmalloc (FILESYS_PIPE_BUFFER_SIZE); + + while (1) + { + int bytes_read; + + bytes_read = fread (chunk, 1, FILESYS_PIPE_BUFFER_SIZE, stream); + + if (bytes_read + offset >= size) + contents = (char *)xrealloc + (contents, size += (2 * FILESYS_PIPE_BUFFER_SIZE)); + + memcpy (contents + offset, chunk, bytes_read); + offset += bytes_read; + if (bytes_read != FILESYS_PIPE_BUFFER_SIZE) + break; + } + + free (chunk); + pclose (stream); + contents = (char *)xrealloc (contents, offset + 1); + *filesize = offset; + } + else + { + filesys_error_number = errno; + } + +#if !defined (BUILDING_LIBARARY) + if (info_windows_initialized_p) + unmessage_in_echo_area (); +#endif /* !BUILDING_LIBRARY */ + return (contents); +} + +/* Return non-zero if FILENAME belongs to a compressed file. */ +int +compressed_filename_p (filename) + char *filename; +{ + char *decompressor; + + /* Find the final extension of this filename, and see if it matches one + of our known ones. */ + decompressor = filesys_decompressor_for_file (filename); + + if (decompressor) + return (1); + else + return (0); +} + +/* Return the command string that would be used to decompress FILENAME. */ +char * +filesys_decompressor_for_file (filename) + char *filename; +{ + register int i; + char *extension = (char *)NULL; + + /* Find the final extension of FILENAME, and see if it appears in our + list of known compression extensions. */ + for (i = strlen (filename) - 1; i > 0; i--) + if (filename[i] == '.') + { + extension = filename + i; + break; + } + + if (!extension) + return ((char *)NULL); + + for (i = 0; compress_suffixes[i].suffix; i++) + if (strcmp (extension, compress_suffixes[i].suffix) == 0) + return (compress_suffixes[i].decompressor); + + return ((char *)NULL); +} + +/* The number of the most recent file system error. */ +int filesys_error_number = 0; + +/* A function which returns a pointer to a static buffer containing + an error message for FILENAME and ERROR_NUM. */ +static char *errmsg_buf = (char *)NULL; +static int errmsg_buf_size = 0; + +char * +filesys_error_string (filename, error_num) + char *filename; + int error_num; +{ + int len; + char *result; + + if (error_num == 0) + return ((char *)NULL); + + result = strerror (error_num); + + len = 4 + strlen (filename) + strlen (result); + if (len >= errmsg_buf_size) + errmsg_buf = (char *)xrealloc (errmsg_buf, (errmsg_buf_size = 2 + len)); + + sprintf (errmsg_buf, "%s: %s", filename, result); + return (errmsg_buf); +} + diff --git a/texinfo/info/filesys.h b/texinfo/info/filesys.h new file mode 100644 index 000000000000..130a52a6357b --- /dev/null +++ b/texinfo/info/filesys.h @@ -0,0 +1,84 @@ +/* filesys.h -- External declarations of functions and vars in filesys.c. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_FILESYS_H_) +#define _FILESYS_H_ + +/* The path on which we look for info files. You can initialize this + from the environment variable INFOPATH if there is one, or you can + call info_add_path () to add paths to the beginning or end of it. */ +extern char *infopath; + +/* Make INFOPATH have absolutely nothing in it. */ +extern void zap_infopath (); + +/* Add PATH to the list of paths found in INFOPATH. 2nd argument says + whether to put PATH at the front or end of INFOPATH. */ +extern void info_add_path (); + +/* Defines that are passed along with the pathname to info_add_path (). */ +#define INFOPATH_PREPEND 0 +#define INFOPATH_APPEND 1 + +/* Expand the filename in PARTIAL to make a real name for this operating + system. This looks in INFO_PATHS in order to find the correct file. + If it can't find the file, it returns NULL. */ +extern char *info_find_fullpath (); + +/* Read the contents of PATHNAME, returning a buffer with the contents of + that file in it, and returning the size of that buffer in FILESIZE. + FINFO is a stat struct which has already been filled in by the caller. + If the file cannot be read, return a NULL pointer. */ +extern char *filesys_read_info_file (); +extern char *filesys_read_compressed (); + +/* Return the command string that would be used to decompress FILENAME. */ +extern char *filesys_decompressor_for_file (); +extern int compressed_filename_p (); + +/* A function which returns a pointer to a static buffer containing + an error message for FILENAME and ERROR_NUM. */ +extern char *filesys_error_string (); + +/* The number of the most recent file system error. */ +extern int filesys_error_number; + +/* Given a string containing units of information separated by colons, + return the next one pointed to by IDX, or NULL if there are no more. + Advance IDX to the character after the colon. */ +extern char *extract_colon_unit (); + +/* The default value of INFOPATH. */ +#if !defined (DEFAULT_INFOPATH) +! # define DEFAULT_INFOPATH "/usr/local/info:/usr/info:/usr/local/lib/info:/usr/lib/info:/usr/local/gnu/info:/usr/local/gnu/lib/info:/usr/gnu/info:/usr/gnu/lib/info:/opt/gnu/info:/usr/share/info:/usr/share/lib/info:/usr/local/share/info:/usr/local/share/lib/info:/usr/gnu/lib/emacs/info:/usr/local/gnu/lib/emacs/info:/usr/local/lib/emacs/info:/usr/local/emacs/info:." +#endif /* !DEFAULT_INFOPATH */ + +#if !defined (S_ISREG) && defined (S_IFREG) +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif /* !S_ISREG && S_IFREG */ + +#if !defined (S_ISDIR) && defined (S_IFDIR) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif /* !S_ISDIR && S_IFDIR */ + +#endif /* !_FILESYS_H_ */ diff --git a/texinfo/info/footnotes.c b/texinfo/info/footnotes.c new file mode 100644 index 000000000000..35a0f352de88 --- /dev/null +++ b/texinfo/info/footnotes.c @@ -0,0 +1,265 @@ +/* footnotes.c -- Some functions for manipulating footnotes. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" + +/* Non-zero means attempt to show footnotes when displaying a new window. */ +int auto_footnotes_p = 1; + +static char *footnote_nodename = "*Footnotes*"; + +#define FOOTNOTE_HEADER_FORMAT \ + "*** Footnotes appearing in the node \"%s\" ***\n" + +/* Find the window currently showing footnotes. */ +static WINDOW * +find_footnotes_window () +{ + WINDOW *win; + + /* Try to find an existing window first. */ + for (win = windows; win; win = win->next) + if (internal_info_node_p (win->node) && + (strcmp (win->node->nodename, footnote_nodename) == 0)) + break; + + return (win); +} + +/* Manufacture a node containing the footnotes of this node, and + return the manufactured node. If NODE has no footnotes, return a + NULL pointer. */ +NODE * +make_footnotes_node (node) + NODE *node; +{ + NODE *fn_node, *result = (NODE *)NULL; + long fn_start; + + /* Make the initial assumption that the footnotes appear as simple + text within this windows node. */ + fn_node = node; + + /* See if this node contains the magic footnote label. */ + fn_start = + info_search_in_node (FOOTNOTE_LABEL, node, 0, (WINDOW *)NULL, 1); + + /* If it doesn't, check to see if it has an associated footnotes node. */ + if (fn_start == -1) + { + REFERENCE **refs; + + refs = info_xrefs_of_node (node); + + if (refs) + { + register int i; + char *refname; + + refname = (char *)xmalloc + (1 + strlen ("-Footnotes") + strlen (node->nodename)); + + strcpy (refname, node->nodename); + strcat (refname, "-Footnotes"); + + for (i = 0; refs[i]; i++) + if ((refs[i]->nodename != (char *)NULL) && + (strcmp (refs[i]->nodename, refname) == 0)) + { + char *filename; + + filename = node->parent; + if (!filename) + filename = node->filename; + + fn_node = info_get_node (filename, refname); + + if (fn_node) + fn_start = 0; + + break; + } + + free (refname); + info_free_references (refs); + } + } + + /* If we never found the start of a footnotes area, quit now. */ + if (fn_start == -1) + return ((NODE *)NULL); + + /* Make the new node. */ + result = (NODE *)xmalloc (sizeof (NODE)); + result->flags = 0; + + /* Get the size of the footnotes appearing within this node. */ + { + char *header; + long text_start = fn_start; + + header = (char *)xmalloc + (1 + strlen (node->nodename) + strlen (FOOTNOTE_HEADER_FORMAT)); + sprintf (header, FOOTNOTE_HEADER_FORMAT, node->nodename); + + /* Move the start of the displayed text to right after the first line. + This effectively skips either "---- footno...", or "File: foo...". */ + while (text_start < fn_node->nodelen) + if (fn_node->contents[text_start++] == '\n') + break; + + result->nodelen = strlen (header) + fn_node->nodelen - text_start; + + /* Set the contents of this node. */ + result->contents = (char *)xmalloc (1 + result->nodelen); + sprintf (result->contents, "%s", header); + memcpy (result->contents + strlen (header), + fn_node->contents + text_start, fn_node->nodelen - text_start); + + name_internal_node (result, footnote_nodename); + free (header); + } + +#if defined (NOTDEF) + /* If the footnotes were gleaned from the node that we were called with, + shorten the calling node's display length. */ + if (fn_node == node) + narrow_node (node, 0, fn_start); +#endif /* NOTDEF */ + + return (result); +} + +/* Create or delete the footnotes window depending on whether footnotes + exist in WINDOW's node or not. Returns FN_FOUND if footnotes were found + and displayed. Returns FN_UNFOUND if there were no footnotes found + in WINDOW's node. Returns FN_UNABLE if there were footnotes, but the + window to show them couldn't be made. */ +int +info_get_or_remove_footnotes (window) + WINDOW *window; +{ + WINDOW *fn_win; + NODE *new_footnotes; + + fn_win = find_footnotes_window (); + + /* If we are in the footnotes window, change nothing. */ + if (fn_win == window) + return (FN_FOUND); + + /* Try to find footnotes for this window's node. */ + new_footnotes = make_footnotes_node (window->node); + + /* If there was a window showing footnotes, and there are no footnotes + for the current window, delete the old footnote window. */ + if (fn_win && !new_footnotes) + { + if (windows->next) + info_delete_window_internal (fn_win); + } + + /* If there are footnotes for this window's node, but no window around + showing footnotes, try to make a new window. */ + if (new_footnotes && !fn_win) + { + WINDOW *old_active; + WINDOW *last, *win; + + /* Always make this window be the last one appearing in the list. Find + the last window in the chain. */ + for (win = windows, last = windows; win; last = win, win = win->next); + + /* Try to split this window, and make the split window the one to + contain the footnotes. */ + old_active = active_window; + active_window = last; + fn_win = window_make_window (new_footnotes); + active_window = old_active; + + if (!fn_win) + { + free (new_footnotes->contents); + free (new_footnotes); + + /* If we are hacking automatic footnotes, and there are footnotes + but we couldn't display them, print a message to that effect. */ + if (auto_footnotes_p) + inform_in_echo_area ("Footnotes could not be displayed"); + return (FN_UNABLE); + } + } + + /* If there are footnotes, and there is a window to display them, + make that window be the number of lines appearing in the footnotes. */ + if (new_footnotes && fn_win) + { + window_set_node_of_window (fn_win, new_footnotes); + + window_change_window_height + (fn_win, fn_win->line_count - fn_win->height); + + remember_window_and_node (fn_win, new_footnotes); + add_gcable_pointer (new_footnotes->contents); + } + + if (!new_footnotes) + return (FN_UNFOUND); + else + return (FN_FOUND); +} + +/* Show the footnotes associated with this node in another window. */ +DECLARE_INFO_COMMAND (info_show_footnotes, + "Show the footnotes associated with this node in another window") +{ + int result; + + /* A negative argument means just make the window go away. */ + if (count < 0) + { + WINDOW *fn_win = find_footnotes_window (); + + /* If there is an old footnotes window, and it isn't the only window + on the screen, delete it. */ + if (fn_win && windows->next) + info_delete_window_internal (fn_win); + } + else + { + int result; + + result = info_get_or_remove_footnotes (window); + + switch (result) + { + case FN_UNFOUND: + info_error (NO_FOOT_NODE); + break; + + case FN_UNABLE: + info_error (WIN_TOO_SMALL); + break; + } + } +} diff --git a/texinfo/info/footnotes.h b/texinfo/info/footnotes.h new file mode 100644 index 000000000000..89b1b3578e6d --- /dev/null +++ b/texinfo/info/footnotes.h @@ -0,0 +1,46 @@ +/* footnotes.h -- Some functions for manipulating footnotes. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_FOOTNOTES_H_) +#define _FOOTNOTES_H_ + +/* Magic string which indicates following text is footnotes. */ +#define FOOTNOTE_LABEL "---------- Footnotes ----------" + +#define FN_FOUND 0 +#define FN_UNFOUND 1 +#define FN_UNABLE 2 + + +/* Create or delete the footnotes window depending on whether footnotes + exist in WINDOW's node or not. Returns FN_FOUND if footnotes were found + and displayed. Returns FN_UNFOUND if there were no footnotes found + in WINDOW's node. Returns FN_UNABLE if there were footnotes, but the + window to show them couldn't be made. */ +extern int info_get_or_remove_footnotes (); + +/* Non-zero means attempt to show footnotes when displaying a new window. */ +extern int auto_footnotes_p; + +#endif /* !_FOOTNOTES_H_ */ + diff --git a/texinfo/info/gc.c b/texinfo/info/gc.c new file mode 100644 index 000000000000..3b9b0907f511 --- /dev/null +++ b/texinfo/info/gc.c @@ -0,0 +1,95 @@ +/* gc.c -- Functions to remember and garbage collect unused node contents. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" + +/* Array of pointers to the contents of gc-able nodes. A pointer on this + list can be garbage collected when no info window contains a node whose + contents member match the pointer. */ +static char **gcable_pointers = (char **)NULL; +static int gcable_pointers_index = 0; +static int gcable_pointers_slots = 0; + +/* Add POINTER to the list of garbage collectible pointers. A pointer + is not actually garbage collected until no info window contains a node + whose contents member is equal to the pointer. */ +void +add_gcable_pointer (pointer) + char *pointer; +{ + gc_pointers (); + add_pointer_to_array (pointer, gcable_pointers_index, gcable_pointers, + gcable_pointers_slots, 10, char *); +} + +/* Grovel the list of info windows and gc-able pointers finding those + node->contents which are collectible, and free them. */ +void +gc_pointers () +{ + register int i, j, k; + INFO_WINDOW *iw; + char **new = (char **)NULL; + int new_index = 0; + int new_slots = 0; + + if (!info_windows || !gcable_pointers_index) + return; + + for (i = 0; iw = info_windows[i]; i++) + { + for (j = 0; j < iw->nodes_index; j++) + { + NODE *node = iw->nodes[j]; + + /* If this node->contents appears in our list of gcable_pointers, + it is not gc-able, so save it. */ + for (k = 0; k < gcable_pointers_index; k++) + if (gcable_pointers[k] == node->contents) + { + add_pointer_to_array + (node->contents, new_index, new, new_slots, 10, char *); + break; + } + } + } + + /* We have gathered all of the pointers which need to be saved. Free any + of the original pointers which do not appear in the new list. */ + for (i = 0; i < gcable_pointers_index; i++) + { + for (j = 0; j < new_index; j++) + if (gcable_pointers[i] == new[j]) + break; + + /* If we got all the way through the new list, then the old pointer + can be garbage collected. */ + if (new && !new[j]) + free (gcable_pointers[i]); + } + + free (gcable_pointers); + gcable_pointers = new; + gcable_pointers_slots = new_slots; + gcable_pointers_index = new_index; +} diff --git a/texinfo/info/gc.h b/texinfo/info/gc.h new file mode 100644 index 000000000000..876062ad2496 --- /dev/null +++ b/texinfo/info/gc.h @@ -0,0 +1,36 @@ +/* gc.h -- Functions for garbage collecting unused node contents. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_GC_H_) +#define _GC_H_ + +/* Add POINTER to the list of garbage collectible pointers. A pointer + is not actually garbage collected until no info window contains a node + whose contents member is equal to the pointer. */ +extern void add_gcable_pointer (); + +/* Grovel the list of info windows and gc-able pointers finding those + node->contents which are collectible, and free them. */ +extern void gc_pointers (); + +#endif /* !_GC_H_ */ diff --git a/texinfo/info/general.h b/texinfo/info/general.h new file mode 100644 index 000000000000..4b97dc8d8daa --- /dev/null +++ b/texinfo/info/general.h @@ -0,0 +1,94 @@ +/* general.h -- Some generally useful defines. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_GENERAL_H_) +#define _GENERAL_H_ + +extern void *xmalloc (), *xrealloc (); + +#if defined (HAVE_UNISTD_H) +# include +#endif /* HAVE_UNISTD_H */ + +#if defined (HAVE_STRING_H) +# include +#else +# include +#endif /* !HAVE_STRING_H */ + +#include "clib.h" + +#define info_toupper(x) (islower (x) ? toupper (x) : x) +#define info_tolower(x) (isupper (x) ? tolower (x) : x) + +#if !defined (whitespace) +# define whitespace(c) ((c == ' ') || (c == '\t')) +#endif /* !whitespace */ + +#if !defined (whitespace_or_newline) +# define whitespace_or_newline(c) (whitespace (c) || (c == '\n')) +#endif /* !whitespace_or_newline */ + +#if !defined (__FUNCTION_DEF) +# define __FUNCTION_DEF +typedef int Function (); +typedef void VFunction (); +typedef char *CFunction (); +#endif /* _FUNCTION_DEF */ + +/* Add POINTER to the list of pointers found in ARRAY. SLOTS is the number + of slots that have already been allocated. INDEX is the index into the + array where POINTER should be added. GROW is the number of slots to grow + ARRAY by, in the case that it needs growing. TYPE is a cast of the type + of object stored in ARRAY (e.g., NODE_ENTRY *. */ +#define add_pointer_to_array(pointer, idx, array, slots, grow, type) \ + do { \ + if (idx + 2 >= slots) \ + array = (type *)(xrealloc (array, (slots += grow) * sizeof (type))); \ + array[idx++] = (type)pointer; \ + array[idx] = (type)NULL; \ + } while (0) + +#define maybe_free(x) do { if (x) free (x); } while (0) + +#if !defined (zero_mem) && defined (HAVE_MEMSET) +# define zero_mem(mem, length) memset (mem, 0, length) +#endif /* !zero_mem && HAVE_MEMSET */ + +#if !defined (zero_mem) && defined (HAVE_BZERO) +# define zero_mem(mem, length) bzero (mem, length) +#endif /* !zero_mem && HAVE_BZERO */ + +#if !defined (zero_mem) +# define zero_mem(mem, length) \ + do { \ + register int zi; \ + register unsigned char *place; \ + \ + place = (unsigned char *)mem; \ + for (zi = 0; zi < length; zi++) \ + place[zi] = 0; \ + } while (0) +#endif /* !zero_mem */ + +#endif /* !_GENERAL_H_ */ diff --git a/texinfo/info/indices.c b/texinfo/info/indices.c new file mode 100644 index 000000000000..6848884288ba --- /dev/null +++ b/texinfo/info/indices.c @@ -0,0 +1,667 @@ +/* indices.c -- Commands for dealing with an Info file Index. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" +#include "indices.h" + +/* User-visible variable controls the output of info-index-next. */ +int show_index_match = 1; + +/* In the Info sense, an index is a menu. This variable holds the last + parsed index. */ +static REFERENCE **index_index = (REFERENCE **)NULL; + +/* The offset of the most recently selected index element. */ +static int index_offset = 0; + +/* Variable which holds the last string searched for. */ +static char *index_search = (char *)NULL; + +/* A couple of "globals" describing where the initial index was found. */ +static char *initial_index_filename = (char *)NULL; +static char *initial_index_nodename = (char *)NULL; + +/* A structure associating index names with index offset ranges. */ +typedef struct { + char *name; /* The nodename of this index. */ + int first; /* The index in our list of the first entry. */ + int last; /* The index in our list of the last entry. */ +} INDEX_NAME_ASSOC; + +/* An array associating index nodenames with index offset ranges. */ +static INDEX_NAME_ASSOC **index_nodenames = (INDEX_NAME_ASSOC **)NULL; +static int index_nodenames_index = 0; +static int index_nodenames_slots = 0; + +/* Add the name of NODE, and the range of the associated index elements + (passed in ARRAY) to index_nodenames. */ +static void +add_index_to_index_nodenames (array, node) + REFERENCE **array; + NODE *node; +{ + register int i, last; + INDEX_NAME_ASSOC *assoc; + + for (last = 0; array[last]; last++); + assoc = (INDEX_NAME_ASSOC *)xmalloc (sizeof (INDEX_NAME_ASSOC)); + assoc->name = strdup (node->nodename); + + if (!index_nodenames_index) + { + assoc->first = 0; + assoc->last = last; + } + else + { + for (i = 0; index_nodenames[i + 1]; i++); + assoc->first = 1 + index_nodenames[i]->last; + assoc->last = assoc->first + last; + } + add_pointer_to_array + (assoc, index_nodenames_index, index_nodenames, index_nodenames_slots, + 10, INDEX_NAME_ASSOC *); +} + +/* Find and return the indices of WINDOW's file. The indices are defined + as the first node in the file containing the word "Index" and any + immediately following nodes whose names also contain "Index". All such + indices are concatenated and the result returned. If WINDOW's info file + doesn't have any indices, a NULL pointer is returned. */ +REFERENCE ** +info_indices_of_window (window) + WINDOW *window; +{ + FILE_BUFFER *fb; + + fb = file_buffer_of_window (window); + + return (info_indices_of_file_buffer (fb)); +} + +REFERENCE ** +info_indices_of_file_buffer (file_buffer) + FILE_BUFFER *file_buffer; +{ + register int i; + REFERENCE **result = (REFERENCE **)NULL; + + /* No file buffer, no indices. */ + if (!file_buffer) + return ((REFERENCE **)NULL); + + /* Reset globals describing where the index was found. */ + maybe_free (initial_index_filename); + maybe_free (initial_index_nodename); + initial_index_filename = (char *)NULL; + initial_index_nodename = (char *)NULL; + + if (index_nodenames) + { + for (i = 0; index_nodenames[i]; i++) + { + free (index_nodenames[i]->name); + free (index_nodenames[i]); + } + + index_nodenames_index = 0; + index_nodenames[0] = (INDEX_NAME_ASSOC *)NULL; + } + + /* Grovel the names of the nodes found in this file. */ + if (file_buffer->tags) + { + TAG *tag; + + for (i = 0; tag = file_buffer->tags[i]; i++) + { + if (string_in_line ("Index", tag->nodename) != -1) + { + NODE *node; + REFERENCE **menu; + + /* Found one. Get its menu. */ + node = info_get_node (tag->filename, tag->nodename); + if (!node) + continue; + + /* Remember the filename and nodename of this index. */ + initial_index_filename = strdup (file_buffer->filename); + initial_index_nodename = strdup (tag->nodename); + + menu = info_menu_of_node (node); + + /* If we have a menu, add this index's nodename and range + to our list of index_nodenames. */ + if (menu) + { + add_index_to_index_nodenames (menu, node); + + /* Concatenate the references found so far. */ + result = info_concatenate_references (result, menu); + } + free (node); + } + } + } + + /* If there is a result, clean it up so that every entry has a filename. */ + for (i = 0; result && result[i]; i++) + if (!result[i]->filename) + result[i]->filename = strdup (file_buffer->filename); + + return (result); +} + +DECLARE_INFO_COMMAND (info_index_search, + "Look up a string in the index for this file") +{ + FILE_BUFFER *fb; + char *line; + + /* Reset the index offset, since this is not the info-index-next command. */ + index_offset = 0; + + /* The user is selecting a new search string, so flush the old one. */ + maybe_free (index_search); + index_search = (char *)NULL; + + /* If this window's file is not the same as the one that we last built an + index for, build and remember an index now. */ + fb = file_buffer_of_window (window); + if (!initial_index_filename || + (strcmp (initial_index_filename, fb->filename) != 0)) + { + info_free_references (index_index); + window_message_in_echo_area ("Finding index entries..."); + index_index = info_indices_of_file_buffer (fb); + } + + /* If there is no index, quit now. */ + if (!index_index) + { + info_error ("No indices found."); + return; + } + + /* Okay, there is an index. Let the user select one of the members of it. */ + line = + info_read_maybe_completing (window, "Index entry: ", index_index); + + window = active_window; + + /* User aborted? */ + if (!line) + { + info_abort_key (active_window, 1, 0); + return; + } + + /* Empty line means move to the Index node. */ + if (!*line) + { + free (line); + + if (initial_index_filename && initial_index_nodename) + { + NODE *node; + + node = + info_get_node (initial_index_filename, initial_index_nodename); + set_remembered_pagetop_and_point (window); + window_set_node_of_window (window, node); + remember_window_and_node (window, node); + window_clear_echo_area (); + return; + } + } + + /* The user typed either a completed index label, or a partial string. + Find an exact match, or, failing that, the first index entry containing + the partial string. So, we just call info_next_index_match () with minor + manipulation of INDEX_OFFSET. */ + { + int old_offset; + + /* Start the search right after/before this index. */ + if (count < 0) + { + register int i; + for (i = 0; index_index[i]; i++); + index_offset = i; + } + else + index_offset = -1; + + old_offset = index_offset; + + /* The "last" string searched for is this one. */ + index_search = line; + + /* Find it, or error. */ + info_next_index_match (window, count, 0); + + /* If the search failed, return the index offset to where it belongs. */ + if (index_offset == old_offset) + index_offset = 0; + } +} + +DECLARE_INFO_COMMAND (info_next_index_match, + "Go to the next matching index item from the last `\\[index-search]' command") +{ + register int i; + int partial, dir; + NODE *node; + + /* If there is no previous search string, the user hasn't built an index + yet. */ + if (!index_search) + { + info_error ("No previous index search string."); + return; + } + + /* If there is no index, that is an error. */ + if (!index_index) + { + info_error ("No index entries."); + return; + } + + /* The direction of this search is controlled by the value of the + numeric argument. */ + if (count < 0) + dir = -1; + else + dir = 1; + + /* Search for the next occurence of index_search. First try to find + an exact match. */ + partial = 0; + + for (i = index_offset + dir; (i > -1) && (index_index[i]); i += dir) + if (strcmp (index_search, index_index[i]->label) == 0) + break; + + /* If that failed, look for the next substring match. */ + if ((i < 0) || (!index_index[i])) + { + for (i = index_offset + dir; (i > -1) && (index_index[i]); i += dir) + if (string_in_line (index_search, index_index[i]->label) != -1) + break; + + if ((i > -1) && (index_index[i])) + partial = string_in_line (index_search, index_index[i]->label); + } + + /* If that failed, print an error. */ + if ((i < 0) || (!index_index[i])) + { + info_error ("No %sindex entries containing \"%s\".", + index_offset > 0 ? "more " : "", index_search); + return; + } + + /* Okay, we found the next one. Move the offset to the current entry. */ + index_offset = i; + + /* Report to the user on what we have found. */ + { + register int j; + char *name = "CAN'T SEE THIS"; + char *match; + + for (j = 0; index_nodenames[j]; j++) + { + if ((i >= index_nodenames[j]->first) && + (i <= index_nodenames[j]->last)) + { + name = index_nodenames[j]->name; + break; + } + } + + /* If we had a partial match, indicate to the user which part of the + string matched. */ + match = strdup (index_index[i]->label); + + if (partial && show_index_match) + { + int j, ls, start, upper; + + ls = strlen (index_search); + start = partial - ls; + upper = isupper (match[start]) ? 1 : 0; + + for (j = 0; j < ls; j++) + if (upper) + match[j + start] = info_tolower (match[j + start]); + else + match[j + start] = info_toupper (match[j + start]); + } + + { + char *format; + + format = replace_in_documentation + ("Found \"%s\" in %s. (`\\[next-index-match]' tries to find next.)"); + + window_message_in_echo_area (format, match, name); + } + + free (match); + } + + /* Select the node corresponding to this index entry. */ + node = info_get_node (index_index[i]->filename, index_index[i]->nodename); + + if (!node) + { + info_error (CANT_FILE_NODE, + index_index[i]->filename, index_index[i]->nodename); + return; + } + + set_remembered_pagetop_and_point (window); + window_set_node_of_window (window, node); + remember_window_and_node (window, node); + + + /* Try to find an occurence of LABEL in this node. */ + { + long start, loc; + + start = window->line_starts[1] - window->node->contents; + loc = info_target_search_node (node, index_index[i]->label, start); + + if (loc != -1) + { + window->point = loc; + window_adjust_pagetop (window); + } + } +} + +/* **************************************************************** */ +/* */ +/* Info APROPOS: Search every known index. */ +/* */ +/* **************************************************************** */ + +/* For every menu item in DIR, search the indices of that file for + SEARCH_STRING. */ +REFERENCE ** +apropos_in_all_indices (search_string, inform) + char *search_string; + int inform; +{ + register int i, dir_index; + REFERENCE **all_indices = (REFERENCE **)NULL; + REFERENCE **dir_menu = (REFERENCE **)NULL; + NODE *dir_node; + int printed = 0; + + dir_node = info_get_node ("dir", "Top"); + if (dir_node) + dir_menu = info_menu_of_node (dir_node); + + if (!dir_menu) + return; + + /* For every menu item in DIR, get the associated node's file buffer and + read the indices of that file buffer. Gather all of the indices into + one large one. */ + for (dir_index = 0; dir_menu[dir_index]; dir_index++) + { + REFERENCE **this_index, *this_item; + NODE *this_node; + FILE_BUFFER *this_fb; + + this_item = dir_menu[dir_index]; + + if (!this_item->filename) + { + if (dir_node->parent) + this_item->filename = strdup (dir_node->parent); + else + this_item->filename = strdup (dir_node->filename); + } + + /* Find this node. If we cannot find it, try using the label of the + entry as a file (i.e., "(LABEL)Top"). */ + this_node = info_get_node (this_item->filename, this_item->nodename); + + if (!this_node && this_item->nodename && + (strcmp (this_item->label, this_item->nodename) == 0)) + this_node = info_get_node (this_item->label, "Top"); + + if (!this_node) + continue; + + /* Get the file buffer associated with this node. */ + { + char *files_name; + + files_name = this_node->parent; + if (!files_name) + files_name = this_node->filename; + + this_fb = info_find_file (files_name); + + if (this_fb && inform) + message_in_echo_area ("Scanning indices of \"%s\"...", files_name); + + this_index = info_indices_of_file_buffer (this_fb); + free (this_node); + + if (this_fb && inform) + unmessage_in_echo_area (); + } + + if (this_index) + { + /* Remember the filename which contains this set of references. */ + for (i = 0; this_index && this_index[i]; i++) + if (!this_index[i]->filename) + this_index[i]->filename = strdup (this_fb->filename); + + /* Concatenate with the other indices. */ + all_indices = info_concatenate_references (all_indices, this_index); + } + } + + info_free_references (dir_menu); + + /* Build a list of the references which contain SEARCH_STRING. */ + if (all_indices) + { + REFERENCE *entry, **apropos_list = (REFERENCE **)NULL; + int apropos_list_index = 0; + int apropos_list_slots = 0; + + for (i = 0; (entry = all_indices[i]); i++) + { + if (string_in_line (search_string, entry->label) != -1) + { + add_pointer_to_array + (entry, apropos_list_index, apropos_list, apropos_list_slots, + 100, REFERENCE *); + } + else + { + maybe_free (entry->label); + maybe_free (entry->filename); + maybe_free (entry->nodename); + free (entry); + } + } + + free (all_indices); + all_indices = apropos_list; + } + return (all_indices); +} + +#define APROPOS_NONE \ + "No available info files reference \"%s\" in their indices." + +void +info_apropos (string) + char *string; +{ + REFERENCE **apropos_list; + + apropos_list = apropos_in_all_indices (string, 0); + + if (!apropos_list) + { + info_error (APROPOS_NONE, string); + } + else + { + register int i; + REFERENCE *entry; + + for (i = 0; (entry = apropos_list[i]); i++) + fprintf (stderr, "\"(%s)%s\" -- %s\n", + entry->filename, entry->nodename, entry->label); + } + info_free_references (apropos_list); +} + +static char *apropos_list_nodename = "*Apropos*"; + +DECLARE_INFO_COMMAND (info_index_apropos, + "Grovel all known info file's indices for a string and build a menu") +{ + char *line; + + line = info_read_in_echo_area (window, "Index apropos: "); + + window = active_window; + + /* User aborted? */ + if (!line) + { + info_abort_key (window, 1, 1); + return; + } + + /* User typed something? */ + if (*line) + { + REFERENCE **apropos_list; + NODE *apropos_node; + + apropos_list = apropos_in_all_indices (line, 1); + + if (!apropos_list) + { + info_error (APROPOS_NONE, line); + } + else + { + register int i; + char *line_buffer; + + initialize_message_buffer (); + printf_to_message_buffer + ("\n* Menu: Nodes whoses indices contain \"%s\":\n", line); + line_buffer = (char *)xmalloc (500); + + for (i = 0; apropos_list[i]; i++) + { + int len; + sprintf (line_buffer, "* (%s)%s::", + apropos_list[i]->filename, apropos_list[i]->nodename); + len = pad_to (36, line_buffer); + sprintf (line_buffer + len, "%s", apropos_list[i]->label); + printf_to_message_buffer ("%s\n", line_buffer); + } + free (line_buffer); + } + + apropos_node = message_buffer_to_node (); + add_gcable_pointer (apropos_node->contents); + name_internal_node (apropos_node, apropos_list_nodename); + + /* Even though this is an internal node, we don't want the window + system to treat it specially. So we turn off the internalness + of it here. */ + apropos_node->flags &= ~N_IsInternal; + + /* Find/Create a window to contain this node. */ + { + WINDOW *new; + NODE *node; + + set_remembered_pagetop_and_point (window); + + /* If a window is visible and showing an apropos list already, + re-use it. */ + for (new = windows; new; new = new->next) + { + node = new->node; + + if (internal_info_node_p (node) && + (strcmp (node->nodename, apropos_list_nodename) == 0)) + break; + } + + /* If we couldn't find an existing window, try to use the next window + in the chain. */ + if (!new && window->next) + new = window->next; + + /* If we still don't have a window, make a new one to contain + the list. */ + if (!new) + { + WINDOW *old_active; + + old_active = active_window; + active_window = window; + new = window_make_window ((NODE *)NULL); + active_window = old_active; + } + + /* If we couldn't make a new window, use this one. */ + if (!new) + new = window; + + /* Lines do not wrap in this window. */ + new->flags |= W_NoWrap; + + window_set_node_of_window (new, apropos_node); + remember_window_and_node (new, apropos_node); + active_window = new; + } + info_free_references (apropos_list); + } + free (line); + + if (!info_error_was_printed) + window_clear_echo_area (); +} + diff --git a/texinfo/info/indices.h b/texinfo/info/indices.h new file mode 100644 index 000000000000..265b1472ba89 --- /dev/null +++ b/texinfo/info/indices.h @@ -0,0 +1,39 @@ +/* indices.h -- Functions defined in indices.c. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_INDICES_H_) +#define _INDICES_H_ + +/* User-visible variable controls the output of info-index-next. */ +extern int show_index_match; + +extern REFERENCE **info_indices_of_window (), **info_indices_of_file_buffer (); +extern void info_apropos (); + +/* For every menu item in DIR, search the indices of that file for STRING. */ +REFERENCE **apropos_in_all_indices (); + +/* User visible functions declared in indices.c. */ +extern void info_index_search (), info_next_index_match (); + +#endif /* !_INDICES_H_ */ diff --git a/texinfo/info/info-stnd.texi b/texinfo/info/info-stnd.texi new file mode 100644 index 000000000000..1e2fccb1d8e2 --- /dev/null +++ b/texinfo/info/info-stnd.texi @@ -0,0 +1,1365 @@ +\input texinfo @c -*-texinfo-*- +@comment %**start of header +@setfilename info-stnd.info +@settitle GNU Info +@set InfoProgVer 2.11 +@paragraphindent none +@footnotestyle end +@synindex vr cp +@synindex fn cp +@synindex ky cp +@comment %**end of header +@comment $Id: info-stnd.texi,v 1.1 1997/08/21 22:58:01 jason Exp $ + +@dircategory Texinfo documentation system +@direntry +* info program: (info-stnd). Standalone Info-reading program. +@end direntry + +@ifinfo +This file documents GNU Info, a program for viewing the on-line formatted +versions of Texinfo files. This documentation is different from the +documentation for the Info reader that is part of GNU Emacs. If you do +not know how to use Info, but have a working Info reader, you should +read that documentation first. + +Copyright @copyright{} 1992, 93, 96 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries a copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). +@end ignore + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that the +sections entitled ``Copying'' and ``GNU General Public License'' are +included exactly as in the original, and provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation +approved by the Free Software Foundation. +@end ifinfo + +@titlepage +@title GNU Info User's Guide +@subtitle For GNU Info version @value{InfoProgVer} +@author Brian J. Fox (bfox@@ai.mit.edu) +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1992, 1993 Free Software Foundation + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that the +sections entitled ``Copying'' and ``GNU General Public License'' are +included exactly as in the original, and provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation +approved by the Free Software Foundation. +@end titlepage + +@ifinfo +@node Top, What is Info, (dir), (dir) +@top The GNU Info Program + +This file documents GNU Info, a program for viewing the on-line +formatted versions of Texinfo files, version @value{InfoProgVer}. This +documentation is different from the documentation for the Info reader +that is part of GNU Emacs. +@end ifinfo + +@menu +* What is Info:: +* Options:: Options you can pass on the command line. +* Cursor Commands:: Commands which move the cursor within a node. +* Scrolling Commands:: Commands for moving the node around + in a window. +* Node Commands:: Commands for selecting a new node. +* Searching Commands:: Commands for searching an Info file. +* Xref Commands:: Commands for selecting cross references. +* Window Commands:: Commands which manipulate multiple windows. +* Printing Nodes:: How to print out the contents of a node. +* Miscellaneous Commands:: A few commands that defy categories. +* Variables:: How to change the default behavior of Info. +* GNU Info Global Index:: Global index containing keystrokes, + command names, variable names, + and general concepts. +@end menu + +@node What is Info, Options, Top, Top +@chapter What is Info? + +@iftex +This file documents GNU Info, a program for viewing the on-line formatted +versions of Texinfo files, version @value{InfoProgVer}. +@end iftex + +@dfn{Info} is a program which is used to view Info files on an ASCII +terminal. @dfn{Info files} are the result of processing Texinfo files +with the program @code{makeinfo} or with one of the Emacs commands, such +as @code{M-x texinfo-format-buffer}. Texinfo itself is a documentation +system that uses a single source file to produce both on-line +information and printed output. You can typeset and print the +files that you read in Info.@refill + +@node Options, Cursor Commands, What is Info, Top +@chapter Command Line Options +@cindex command line options +@cindex arguments, command line + +GNU Info accepts several options to control the initial node being +viewed, and to specify which directories to search for Info files. Here +is a template showing an invocation of GNU Info from the shell: + +@example +info [--@var{option-name} @var{option-value}] @var{menu-item}@dots{} +@end example + +The following @var{option-names} are available when invoking Info from +the shell: + +@table @code +@cindex directory path +@item --directory @var{directory-path} +@itemx -d @var{directory-path} +Add @var{directory-path} to the list of directory paths searched when +Info needs to find a file. You may issue @code{--directory} multiple +times; once for each directory which contains Info files. +Alternatively, you may specify a value for the environment variable +@code{INFOPATH}; if @code{--directory} is not given, the value of +@code{INFOPATH} is used. The value of @code{INFOPATH} is a colon +separated list of directory names. If you do not supply @code{INFOPATH} +or @code{--directory-path}, Info uses a default path. + +@item --file @var{filename} +@itemx -f @var{filename} +@cindex Info file, selecting +Specify a particular Info file to visit. By default, Info visits +the file @code{dir}; if you use this option, Info will start with +@code{(@var{filename})Top} as the first file and node. + +@item --node @var{nodename} +@itemx -n @var{nodename} +@cindex node, selecting +Specify a particular node to visit in the initial file that Info +loads. This is especially useful in conjunction with +@code{--file}@footnote{Of course, you can specify both the file and node +in a @code{--node} command; but don't forget to escape the open and +close parentheses from the shell as in: @code{info --node +"(emacs)Buffers"}}. You may specify @code{--node} multiple times; for +an interactive Info, each @var{nodename} is visited in its own window, +for a non-interactive Info (such as when @code{--output} is given) each +@var{nodename} is processed sequentially. + +@item --output @var{filename} +@itemx -o @var{filename} +@cindex file, outputting to +@cindex outputting to a file +Specify @var{filename} as the name of a file to which to direct output. +Each node that Info visits will be output to @var{filename} instead of +interactively viewed. A value of @code{-} for @var{filename} specifies +the standard output. + +@item --subnodes +@cindex @code{--subnodes}, command line option +This option only has meaning when given in conjunction with +@code{--output}. It means to recursively output the nodes appearing in +the menus of each node being output. Menu items which resolve to +external Info files are not output, and neither are menu items which are +members of an index. Each node is only output once. + +@item --help +@itemx -h +Produces a relatively brief description of the available Info options. + +@item --version +@cindex version information +Prints the version information of Info and exits. + +@item @var{menu-item} +@cindex menu, following +Info treats its remaining arguments as the names of menu items. The +first argument is a menu item in the initial node visited, while +the second argument is a menu item in the first argument's node. +You can easily move to the node of your choice by specifying the menu +names which describe the path to that node. For example, + +@example +info emacs buffers +@end example + +@noindent +first selects the menu item @samp{Emacs} in the node @samp{(dir)Top}, +and then selects the menu item @samp{Buffers} in the node +@samp{(emacs)Top}. +@end table + +@node Cursor Commands, Scrolling Commands, Options, Top +@chapter Moving the Cursor +@cindex cursor, moving + +Many people find that reading screens of text page by page is made +easier when one is able to indicate particular pieces of text with some +kind of pointing device. Since this is the case, GNU Info (both the +Emacs and standalone versions) have several commands which allow you to +move the cursor about the screen. The notation used in this manual to +describe keystrokes is identical to the notation used within the Emacs +manual, and the GNU Readline manual. @xref{Characters, , Character +Conventions, emacs, the GNU Emacs Manual}, if you are unfamiliar with the +notation. + +The following table lists the basic cursor movement commands in Info. +Each entry consists of the key sequence you should type to execute the +cursor movement, the @code{M-x}@footnote{@code{M-x} is also a command; it +invokes @code{execute-extended-command}. @xref{M-x, , Executing an +extended command, emacs, the GNU Emacs Manual}, for more detailed +information.} command name (displayed in parentheses), and a short +description of what the command does. All of the cursor motion commands +can take an @dfn{numeric} argument (@pxref{Miscellaneous Commands, +@code{universal-argument}}), to find out how to supply them. With a +numeric argument, the motion commands are simply executed that +many times; for example, a numeric argument of 4 given to +@code{next-line} causes the cursor to move down 4 lines. With a +negative numeric argument, the motion is reversed; an argument of -4 +given to the @code{next-line} command would cause the cursor to move +@emph{up} 4 lines. + +@table @asis +@item @code{C-n} (@code{next-line}) +@kindex C-n +@findex next-line +Move the cursor down to the next line. + +@item @code{C-p} (@code{prev-line}) +@kindex C-p +@findex prev-line +Move the cursor up to the previous line. + +@item @code{C-a} (@code{beginning-of-line}) +@kindex C-a, in Info windows +@findex beginning-of-line +Move the cursor to the start of the current line. + +@item @code{C-e} (@code{end-of-line}) +@kindex C-e, in Info windows +@findex end-of-line +Move the cursor to the end of the current line. + +@item @code{C-f} (@code{forward-char}) +@kindex C-f, in Info windows +@findex forward-char +Move the cursor forward a character. + +@item @code{C-b} (@code{backward-char}) +@kindex C-b, in Info windows +@findex backward-char +Move the cursor backward a character. + +@item @code{M-f} (@code{forward-word}) +@kindex M-f, in Info windows +@findex forward-word +Move the cursor forward a word. + +@item @code{M-b} (@code{backward-word}) +@kindex M-b, in Info windows +@findex backward-word +Move the cursor backward a word. + +@item @code{M-<} (@code{beginning-of-node}) +@itemx @code{b} +@kindex b, in Info windows +@kindex M-< +@findex beginning-of-node +Move the cursor to the start of the current node. + +@item @code{M->} (@code{end-of-node}) +@kindex M-> +@findex end-of-node +Move the cursor to the end of the current node. + +@item @code{M-r} (@code{move-to-window-line}) +@kindex M-r +@findex move-to-window-line +Move the cursor to a specific line of the window. Without a numeric +argument, @code{M-r} moves the cursor to the start of the line in the +center of the window. With a numeric argument of @var{n}, @code{M-r} +moves the cursor to the start of the @var{n}th line in the window. +@end table + +@node Scrolling Commands, Node Commands, Cursor Commands, Top +@chapter Moving Text Within a Window +@cindex scrolling + +Sometimes you are looking at a screenful of text, and only part of the +current paragraph you are reading is visible on the screen. The +commands detailed in this section are used to shift which part of the +current node is visible on the screen. + +@table @asis +@item @code{SPC} (@code{scroll-forward}) +@itemx @code{C-v} +@kindex SPC, in Info windows +@kindex C-v +@findex scroll-forward +Shift the text in this window up. That is, show more of the node which +is currently below the bottom of the window. With a numeric argument, +show that many more lines at the bottom of the window; a numeric +argument of 4 would shift all of the text in the window up 4 lines +(discarding the top 4 lines), and show you four new lines at the bottom +of the window. Without a numeric argument, @key{SPC} takes the bottom +two lines of the window and places them at the top of the window, +redisplaying almost a completely new screenful of lines. + +@item @code{DEL} (@code{scroll-backward}) +@itemx @code{M-v} +@kindex DEL, in Info windows +@kindex M-v +@findex scroll-backward +Shift the text in this window down. The inverse of +@code{scroll-forward}. +@end table + +@cindex scrolling through node structure +The @code{scroll-forward} and @code{scroll-backward} commands can also +move forward and backward through the node structure of the file. If +you press @key{SPC} while viewing the end of a node, or @key{DEL} while +viewing the beginning of a node, what happens is controlled by the +variable @code{scroll-behavior}. @xref{Variables, +@code{scroll-behavior}}, for more information. + +@table @asis +@item @code{C-l} (@code{redraw-display}) +@kindex C-l +@findex redraw-display +Redraw the display from scratch, or shift the line containing the cursor +to a specified location. With no numeric argument, @samp{C-l} clears +the screen, and then redraws its entire contents. Given a numeric +argument of @var{n}, the line containing the cursor is shifted so that +it is on the @var{n}th line of the window. + +@item @code{C-x w} (@code{toggle-wrap}) +@kindex C-w +@findex toggle-wrap +Toggles the state of line wrapping in the current window. Normally, +lines which are longer than the screen width @dfn{wrap}, i.e., they are +continued on the next line. Lines which wrap have a @samp{\} appearing +in the rightmost column of the screen. You can cause such lines to be +terminated at the rightmost column by changing the state of line +wrapping in the window with @code{C-x w}. When a line which needs more +space than one screen width to display is displayed, a @samp{$} appears +in the rightmost column of the screen, and the remainder of the line is +invisible. +@end table + +@node Node Commands, Searching Commands, Scrolling Commands, Top +@chapter Selecting a New Node +@cindex nodes, selection of + +This section details the numerous Info commands which select a new node +to view in the current window. + +The most basic node commands are @samp{n}, @samp{p}, @samp{u}, and +@samp{l}. + +When you are viewing a node, the top line of the node contains some Info +@dfn{pointers} which describe where the next, previous, and up nodes +are. Info uses this line to move about the node structure of the file +when you use the following commands: + +@table @asis +@item @code{n} (@code{next-node}) +@kindex n +@findex next-node +Select the `Next' node. + +@item @code{p} (@code{prev-node}) +@kindex p +@findex prev-node +Select the `Prev' node. + +@item @code{u} (@code{up-node}) +@kindex u +@findex up-node +Select the `Up' node. +@end table + +You can easily select a node that you have already viewed in this window +by using the @samp{l} command -- this name stands for "last", and +actually moves through the list of already visited nodes for this +window. @samp{l} with a negative numeric argument moves forward through +the history of nodes for this window, so you can quickly step between +two adjacent (in viewing history) nodes. + +@table @asis +@item @code{l} (@code{history-node}) +@kindex l +@findex history-node +Select the most recently selected node in this window. +@end table + +Two additional commands make it easy to select the most commonly +selected nodes; they are @samp{t} and @samp{d}. + +@table @asis +@item @code{t} (@code{top-node}) +@kindex t +@findex top-node +Select the node @samp{Top} in the current Info file. + +@item @code{d} (@code{dir-node}) +@kindex d +@findex dir-node +Select the directory node (i.e., the node @samp{(dir)}). +@end table + +Here are some other commands which immediately result in the selection +of a different node in the current window: + +@table @asis +@item @code{<} (@code{first-node}) +@kindex < +@findex first-node +Selects the first node which appears in this file. This node is most +often @samp{Top}, but it does not have to be. + +@item @code{>} (@code{last-node}) +@kindex > +@findex last-node +Select the last node which appears in this file. + +@item @code{]} (@code{global-next-node}) +@kindex ] +@findex global-next-node +Move forward or down through node structure. If the node that you are +currently viewing has a @samp{Next} pointer, that node is selected. +Otherwise, if this node has a menu, the first menu item is selected. If +there is no @samp{Next} and no menu, the same process is tried with the +@samp{Up} node of this node. + +@item @code{[} (@code{global-prev-node}) +@kindex [ +@findex global-prev-node +Move backward or up through node structure. If the node that you are +currently viewing has a @samp{Prev} pointer, that node is selected. +Otherwise, if the node has an @samp{Up} pointer, that node is selected, +and if it has a menu, the last item in the menu is selected. +@end table + +You can get the same behavior as @code{global-next-node} and +@code{global-prev-node} while simply scrolling through the file with +@key{SPC} and @key{DEL}; @xref{Variables, @code{scroll-behavior}}, for +more information. + +@table @asis +@item @code{g} (@code{goto-node}) +@kindex g +@findex goto-node +Read the name of a node and select it. No completion is done while +reading the node name, since the desired node may reside in a separate +file. The node must be typed exactly as it appears in the Info file. A +file name may be included as with any node specification, for example + +@example +@code{g(emacs)Buffers} +@end example + +finds the node @samp{Buffers} in the Info file @file{emacs}. + +@item @code{C-x k} (@code{kill-node}) +@kindex C-x k +@findex kill-node +Kill a node. The node name is prompted for in the echo area, with a +default of the current node. @dfn{Killing} a node means that Info tries +hard to forget about it, removing it from the list of history nodes kept +for the window where that node is found. Another node is selected in +the window which contained the killed node. + +@item @code{C-x C-f} (@code{view-file}) +@kindex C-x C-f +@findex view-file +Read the name of a file and selects the entire file. The command +@example +@code{C-x C-f @var{filename}} +@end example +is equivalent to typing +@example +@code{g(@var{filename})*} +@end example + +@item @code{C-x C-b} (@code{list-visited-nodes}) +@kindex C-x C-b +@findex list-visited-nodes +Make a window containing a menu of all of the currently visited nodes. +This window becomes the selected window, and you may use the standard +Info commands within it. + +@item @code{C-x b} (@code{select-visited-node}) +@kindex C-x b +@findex select-visited-node +Select a node which has been previously visited in a visible window. +This is similar to @samp{C-x C-b} followed by @samp{m}, but no window is +created. +@end table + +@node Searching Commands, Xref Commands, Node Commands, Top +@chapter Searching an Info File +@cindex searching + +GNU Info allows you to search for a sequence of characters throughout an +entire Info file, search through the indices of an Info file, or find +areas within an Info file which discuss a particular topic. + +@table @asis +@item @code{s} (@code{search}) +@kindex s +@findex search +Read a string in the echo area and search for it. + +@item @code{C-s} (@code{isearch-forward}) +@kindex C-s +@findex isearch-forward +Interactively search forward through the Info file for a string as you +type it. + +@item @code{C-r} (@code{isearch-backward}) +@kindex C-r +@findex isearch-backward +Interactively search backward through the Info file for a string as +you type it. + +@item @code{i} (@code{index-search}) +@kindex i +@findex index-search +Look up a string in the indices for this Info file, and select a node +where the found index entry points to. + +@item @code{,} (@code{next-index-match}) +@kindex , +@findex next-index-match +Move to the node containing the next matching index item from the last +@samp{i} command. +@end table + +The most basic searching command is @samp{s} (@code{search}). The +@samp{s} command prompts you for a string in the echo area, and then +searches the remainder of the Info file for an occurrence of that string. +If the string is found, the node containing it is selected, and the +cursor is left positioned at the start of the found string. Subsequent +@samp{s} commands show you the default search string within @samp{[} and +@samp{]}; pressing @key{RET} instead of typing a new string will use the +default search string. + +@dfn{Incremental searching} is similar to basic searching, but the +string is looked up while you are typing it, instead of waiting until +the entire search string has been specified. + +@node Xref Commands, Window Commands, Searching Commands, Top +@chapter Selecting Cross References + +We have already discussed the @samp{Next}, @samp{Prev}, and @samp{Up} +pointers which appear at the top of a node. In addition to these +pointers, a node may contain other pointers which refer you to a +different node, perhaps in another Info file. Such pointers are called +@dfn{cross references}, or @dfn{xrefs} for short. + +@menu +* Parts of an Xref:: What a cross reference is made of. +* Selecting Xrefs:: Commands for selecting menu or note items. +@end menu + +@node Parts of an Xref, Selecting Xrefs, , Xref Commands +@section Parts of an Xref + +Cross references have two major parts: the first part is called the +@dfn{label}; it is the name that you can use to refer to the cross +reference, and the second is the @dfn{target}; it is the full name of +the node that the cross reference points to. + +The target is separated from the label by a colon @samp{:}; first the +label appears, and then the target. For example, in the sample menu +cross reference below, the single colon separates the label from the +target. + +@example +* Foo Label: Foo Target. More information about Foo. +@end example + +Note the @samp{.} which ends the name of the target. The @samp{.} is +not part of the target; it serves only to let Info know where the target +name ends. + +A shorthand way of specifying references allows two adjacent colons to +stand for a target name which is the same as the label name: + +@example +* Foo Commands:: Commands pertaining to Foo. +@end example + +In the above example, the name of the target is the same as the name of +the label, in this case @code{Foo Commands}. + +You will normally see two types of cross reference while viewing nodes: +@dfn{menu} references, and @dfn{note} references. Menu references +appear within a node's menu; they begin with a @samp{*} at the beginning +of a line, and continue with a label, a target, and a comment which +describes what the contents of the node pointed to contains. + +Note references appear within the body of the node text; they begin with +@code{*Note}, and continue with a label and a target. + +Like @samp{Next}, @samp{Prev}, and @samp{Up} pointers, cross references +can point to any valid node. They are used to refer you to a place +where more detailed information can be found on a particular subject. +Here is a cross reference which points to a node within the Texinfo +documentation: @xref{xref, , Writing an Xref, texinfo, the Texinfo +Manual}, for more information on creating your own texinfo cross +references. + +@node Selecting Xrefs, , Parts of an Xref, Xref Commands +@section Selecting Xrefs + +The following table lists the Info commands which operate on menu items. + +@table @asis +@item @code{1} (@code{menu-digit}) +@itemx @code{2} @dots{} @code{9} +@cindex 1 @dots{} 9, in Info windows +@kindex 1 @dots{} 9, in Info windows +@findex menu-digit +Within an Info window, pressing a single digit, (such as @samp{1}), +selects that menu item, and places its node in the current window. +For convenience, there is one exception; pressing @samp{0} selects the +@emph{last} item in the node's menu. + +@item @code{0} (@code{last-menu-item}) +@kindex 0, in Info windows +@findex last-menu-item +Select the last item in the current node's menu. + +@item @code{m} (@code{menu-item}) +@kindex m +@findex menu-item +Reads the name of a menu item in the echo area and selects its node. +Completion is available while reading the menu label. + +@item @code{M-x find-menu} +@findex find-menu +Move the cursor to the start of this node's menu. +@end table + +This table lists the Info commands which operate on note cross references. + +@table @asis +@item @code{f} (@code{xref-item}) +@itemx @code{r} +@kindex f +@kindex r +@findex xref-item +Reads the name of a note cross reference in the echo area and selects +its node. Completion is available while reading the cross reference +label. +@end table + +Finally, the next few commands operate on menu or note references alike: + +@table @asis +@item @code{TAB} (@code{move-to-next-xref}) +@kindex TAB, in Info windows +@findex move-to-next-xref +Move the cursor to the start of the next nearest menu item or note +reference in this node. You can then use @key{RET} +(@code{select-reference-this-line}) to select the menu or note reference. + +@item @code{M-TAB} (@code{move-to-prev-xref}) +@kindex M-TAB, in Info windows +@findex move-to-prev-xref +Move the cursor the start of the nearest previous menu item or note +reference in this node. + +@item @code{RET} (@code{select-reference-this-line}) +@kindex RET, in Info windows +@findex select-reference-this-line +Select the menu item or note reference appearing on this line. +@end table + +@node Window Commands, Printing Nodes, Xref Commands, Top +@chapter Manipulating Multiple Windows +@cindex windows, manipulating + +A @dfn{window} is a place to show the text of a node. Windows have a +view area where the text of the node is displayed, and an associated +@dfn{mode line}, which briefly describes the node being viewed. + +GNU Info supports multiple windows appearing in a single screen; each +window is separated from the next by its modeline. At any time, there +is only one @dfn{active} window, that is, the window in which the cursor +appears. There are commands available for creating windows, changing +the size of windows, selecting which window is active, and for deleting +windows. + +@menu +* The Mode Line:: What appears in the mode line? +* Basic Windows:: Manipulating windows in Info. +* The Echo Area:: Used for displaying errors and reading input. +@end menu + +@node The Mode Line, Basic Windows, , Window Commands +@section The Mode Line + +A @dfn{mode line} is a line of inverse video which appears at the bottom +of an Info window. It describes the contents of the window just above +it; this information includes the name of the file and node appearing in +that window, the number of screen lines it takes to display the node, +and the percentage of text that is above the top of the window. It can +also tell you if the indirect tags table for this Info file needs to be +updated, and whether or not the Info file was compressed when stored on +disk. + +Here is a sample mode line for a window containing an uncompressed file +named @file{dir}, showing the node @samp{Top}. + +@example +@group +-----Info: (dir)Top, 40 lines --Top--------------------------------------- + ^^ ^ ^^^ ^^ + (file)Node #lines where +@end group +@end example + +When a node comes from a file which is compressed on disk, this is +indicated in the mode line with two small @samp{z}'s. In addition, if +the Info file containing the node has been split into subfiles, the name +of the subfile containing the node appears in the modeline as well: + +@example +--zz-Info: (emacs)Top, 291 lines --Top-- Subfile: emacs-1.Z--------------- +@end example + +When Info makes a node internally, such that there is no corresponding +info file on disk, the name of the node is surrounded by asterisks +(@samp{*}). The name itself tells you what the contents of the window +are; the sample mode line below shows an internally constructed node +showing possible completions: + +@example +-----Info: *Completions*, 7 lines --All----------------------------------- +@end example + +@node Basic Windows, The Echo Area, The Mode Line, Window Commands +@section Window Commands + +It can be convenient to view more than one node at a time. To allow +this, Info can display more than one @dfn{window}. Each window has its +own mode line (@pxref{The Mode Line}) and history of nodes viewed in that +window (@pxref{Node Commands, , @code{history-node}}). + +@table @asis +@item @code{C-x o} (@code{next-window}) +@cindex windows, selecting +@kindex C-x o +@findex next-window +Select the next window on the screen. Note that the echo area can only be +selected if it is already in use, and you have left it temporarily. +Normally, @samp{C-x o} simply moves the cursor into the next window on +the screen, or if you are already within the last window, into the first +window on the screen. Given a numeric argument, @samp{C-x o} moves over +that many windows. A negative argument causes @samp{C-x o} to select +the previous window on the screen. + +@item @code{M-x prev-window} +@findex prev-window +Select the previous window on the screen. This is identical to +@samp{C-x o} with a negative argument. + +@item @code{C-x 2} (@code{split-window}) +@cindex windows, creating +@kindex C-x 2 +@findex split-window +Split the current window into two windows, both showing the same node. +Each window is one half the size of the original window, and the cursor +remains in the original window. The variable @code{automatic-tiling} +can cause all of the windows on the screen to be resized for you +automatically, please @pxref{Variables, , automatic-tiling} for more +information. + +@item @code{C-x 0} (@code{delete-window}) +@cindex windows, deleting +@kindex C-x 0 +@findex delete-window +Delete the current window from the screen. If you have made too many +windows and your screen appears cluttered, this is the way to get rid of +some of them. + +@item @code{C-x 1} (@code{keep-one-window}) +@kindex C-x 1 +@findex keep-one-window +Delete all of the windows excepting the current one. + +@item @code{ESC C-v} (@code{scroll-other-window}) +@kindex ESC C-v, in Info windows +@findex scroll-other-window +Scroll the other window, in the same fashion that @samp{C-v} might +scroll the current window. Given a negative argument, scroll the +"other" window backward. + +@item @code{C-x ^} (@code{grow-window}) +@kindex C-x ^ +@findex grow-window +Grow (or shrink) the current window. Given a numeric argument, grow +the current window that many lines; with a negative numeric argument, +shrink the window instead. + +@item @code{C-x t} (@code{tile-windows}) +@cindex tiling +@kindex C-x t +@findex tile-windows +Divide the available screen space among all of the visible windows. +Each window is given an equal portion of the screen in which to display +its contents. The variable @code{automatic-tiling} can cause +@code{tile-windows} to be called when a window is created or deleted. +@xref{Variables, , @code{automatic-tiling}}. +@end table + +@node The Echo Area, , Basic Windows, Window Commands +@section The Echo Area +@cindex echo area + +The @dfn{echo area} is a one line window which appears at the bottom of +the screen. It is used to display informative or error messages, and to +read lines of input from you when that is necessary. Almost all of the +commands available in the echo area are identical to their Emacs +counterparts, so please refer to that documentation for greater depth of +discussion on the concepts of editing a line of text. The following +table briefly lists the commands that are available while input is being +read in the echo area: + +@table @asis +@item @code{C-f} (@code{echo-area-forward}) +@kindex C-f, in the echo area +@findex echo-area-forward +Move forward a character. + +@item @code{C-b} (@code{echo-area-backward}) +@kindex C-b, in the echo area +@findex echo-area-backward +Move backward a character. + +@item @code{C-a} (@code{echo-area-beg-of-line}) +@kindex C-a, in the echo area +@findex echo-area-beg-of-line +Move to the start of the input line. + +@item @code{C-e} (@code{echo-area-end-of-line}) +@kindex C-e, in the echo area +@findex echo-area-end-of-line +Move to the end of the input line. + +@item @code{M-f} (@code{echo-area-forward-word}) +@kindex M-f, in the echo area +@findex echo-area-forward-word +Move forward a word. + +@item @code{M-b} (@code{echo-area-backward-word}) +@kindex M-b, in the echo area +@findex echo-area-backward-word +Move backward a word. + +@item @code{C-d} (@code{echo-area-delete}) +@kindex C-d, in the echo area +@findex echo-area-delete +Delete the character under the cursor. + +@item @code{DEL} (@code{echo-area-rubout}) +@kindex DEL, in the echo area +@findex echo-area-rubout +Delete the character behind the cursor. + +@item @code{C-g} (@code{echo-area-abort}) +@kindex C-g, in the echo area +@findex echo-area-abort +Cancel or quit the current operation. If completion is being read, +@samp{C-g} discards the text of the input line which does not match any +completion. If the input line is empty, @samp{C-g} aborts the calling +function. + +@item @code{RET} (@code{echo-area-newline}) +@kindex RET, in the echo area +@findex echo-area-newline +Accept (or forces completion of) the current input line. + +@item @code{C-q} (@code{echo-area-quoted-insert}) +@kindex C-q, in the echo area +@findex echo-area-quoted-insert +Insert the next character verbatim. This is how you can insert control +characters into a search string, for example. + +@item @var{printing character} (@code{echo-area-insert}) +@kindex printing characters, in the echo area +@findex echo-area-insert +Insert the character. + +@item @code{M-TAB} (@code{echo-area-tab-insert}) +@kindex M-TAB, in the echo area +@findex echo-area-tab-insert +Insert a TAB character. + +@item @code{C-t} (@code{echo-area-transpose-chars}) +@kindex C-t, in the echo area +@findex echo-area-transpose-chars +Transpose the characters at the cursor. +@end table + +The next group of commands deal with @dfn{killing}, and @dfn{yanking} +text. For an in depth discussion of killing and yanking, +@pxref{Killing, , Killing and Deleting, emacs, the GNU Emacs Manual} + +@table @asis +@item @code{M-d} (@code{echo-area-kill-word}) +@kindex M-d, in the echo area +@findex echo-area-kill-word +Kill the word following the cursor. + +@item @code{M-DEL} (@code{echo-area-backward-kill-word}) +@kindex M-DEL, in the echo area +@findex echo-area-backward-kill-word +Kill the word preceding the cursor. + +@item @code{C-k} (@code{echo-area-kill-line}) +@kindex C-k, in the echo area +@findex echo-area-kill-line +Kill the text from the cursor to the end of the line. + +@item @code{C-x DEL} (@code{echo-area-backward-kill-line}) +@kindex C-x DEL, in the echo area +@findex echo-area-backward-kill-line +Kill the text from the cursor to the beginning of the line. + +@item @code{C-y} (@code{echo-area-yank}) +@kindex C-y, in the echo area +@findex echo-area-yank +Yank back the contents of the last kill. + +@item @code{M-y} (@code{echo-area-yank-pop}) +@kindex M-y, in the echo area +@findex echo-area-yank-pop +Yank back a previous kill, removing the last yanked text first. +@end table + +Sometimes when reading input in the echo area, the command that needed +input will only accept one of a list of several choices. The choices +represent the @dfn{possible completions}, and you must respond with one +of them. Since there are a limited number of responses you can make, +Info allows you to abbreviate what you type, only typing as much of the +response as is necessary to uniquely identify it. In addition, you can +request Info to fill in as much of the response as is possible; this +is called @dfn{completion}. + +The following commands are available when completing in the echo area: + +@table @asis +@item @code{TAB} (@code{echo-area-complete}) +@itemx @code{SPC} +@kindex TAB, in the echo area +@kindex SPC, in the echo area +@findex echo-area-complete +Insert as much of a completion as is possible. + +@item @code{?} (@code{echo-area-possible-completions}) +@kindex ?, in the echo area +@findex echo-area-possible-completions +Display a window containing a list of the possible completions of what +you have typed so far. For example, if the available choices are: + +@example +@group +bar +foliate +food +forget +@end group +@end example + +@noindent +and you have typed an @samp{f}, followed by @samp{?}, the possible +completions would contain: + +@example +@group +foliate +food +forget +@end group +@end example + +@noindent +i.e., all of the choices which begin with @samp{f}. Pressing @key{SPC} +or @key{TAB} would result in @samp{fo} appearing in the echo area, since +all of the choices which begin with @samp{f} continue with @samp{o}. +Now, typing @samp{l} followed by @samp{TAB} results in @samp{foliate} +appearing in the echo area, since that is the only choice which begins +with @samp{fol}. + +@item @code{ESC C-v} (@code{echo-area-scroll-completions-window}) +@kindex ESC C-v, in the echo area +@findex echo-area-scroll-completions-window +Scroll the completions window, if that is visible, or the "other" +window if not. +@end table + +@node Printing Nodes, Miscellaneous Commands, Window Commands, Top +@chapter Printing Out Nodes +@cindex printing + +You may wish to print out the contents of a node as a quick reference +document for later use. Info provides you with a command for doing +this. In general, we recommend that you use @TeX{} to format the +document and print sections of it, by running @code{tex} on the Texinfo +source file. + +@table @asis +@item @code{M-x print-node} +@findex print-node +@cindex INFO_PRINT_COMMAND, environment variable +Pipe the contents of the current node through the command in the +environment variable @code{INFO_PRINT_COMMAND}. If the variable does not +exist, the node is simply piped to @code{lpr}. +@end table + +@node Miscellaneous Commands, Variables, Printing Nodes, Top +@chapter Miscellaneous Commands + +GNU Info contains several commands which self-document GNU Info: + +@table @asis +@item @code{M-x describe-command} +@cindex functions, describing +@cindex commands, describing +@findex describe-command +Read the name of an Info command in the echo area and then display a +brief description of what that command does. + +@item @code{M-x describe-key} +@cindex keys, describing +@findex describe-key +Read a key sequence in the echo area, and then display the name and +documentation of the Info command that the key sequence invokes. + +@item @code{M-x describe-variable} +Read the name of a variable in the echo area and then display a brief +description of what the variable affects. + +@item @code{M-x where-is} +@findex where-is +Read the name of an Info command in the echo area, and then display +a key sequence which can be typed in order to invoke that command. + +@item @code{C-h} (@code{get-help-window}) +@itemx @code{?} +@kindex C-h +@kindex ?, in Info windows +@findex get-help-window +Create (or Move into) the window displaying @code{*Help*}, and place +a node containing a quick reference card into it. This window displays +the most concise information about GNU Info available. + +@item @code{h} (@code{get-info-help-node}) +@kindex h +@findex get-info-help-node +Try hard to visit the node @code{(info)Help}. The Info file +@file{info.texi} distributed with GNU Info contains this node. Of +course, the file must first be processed with @code{makeinfo}, and then +placed into the location of your Info directory. +@end table + +Here are the commands for creating a numeric argument: + +@table @asis +@item @code{C-u} (@code{universal-argument}) +@cindex numeric arguments +@kindex C-u +@findex universal-argument +Start (or multiply by 4) the current numeric argument. @samp{C-u} is +a good way to give a small numeric argument to cursor movement or +scrolling commands; @samp{C-u C-v} scrolls the screen 4 lines, while +@samp{C-u C-u C-n} moves the cursor down 16 lines. + +@item @code{M-1} (@code{add-digit-to-numeric-arg}) +@itemx @code{M-2} @dots{} @code{M-9} +@kindex M-1 @dots{} M-9 +@findex add-digit-to-numeric-arg +Add the digit value of the invoking key to the current numeric +argument. Once Info is reading a numeric argument, you may just type +the digits of the argument, without the Meta prefix. For example, you +might give @samp{C-l} a numeric argument of 32 by typing: + +@example +@kbd{C-u 3 2 C-l} +@end example + +@noindent +or + +@example +@kbd{M-3 2 C-l} +@end example +@end table + +@samp{C-g} is used to abort the reading of a multi-character key +sequence, to cancel lengthy operations (such as multi-file searches) and +to cancel reading input in the echo area. + +@table @asis +@item @code{C-g} (@code{abort-key}) +@cindex cancelling typeahead +@cindex cancelling the current operation +@kindex C-g, in Info windows +@findex abort-key +Cancel current operation. +@end table + +The @samp{q} command of Info simply quits running Info. + +@table @asis +@item @code{q} (@code{quit}) +@cindex quitting +@kindex q +@findex quit +Exit GNU Info. +@end table + +If the operating system tells GNU Info that the screen is 60 lines tall, +and it is actually only 40 lines tall, here is a way to tell Info that +the operating system is correct. + +@table @asis +@item @code{M-x set-screen-height} +@findex set-screen-height +@cindex screen, changing the height of +Read a height value in the echo area and set the height of the +displayed screen to that value. +@end table + +Finally, Info provides a convenient way to display footnotes which might +be associated with the current node that you are viewing: + +@table @asis +@item @code{ESC C-f} (@code{show-footnotes}) +@kindex ESC C-f +@findex show-footnotes +@cindex footnotes, displaying +Show the footnotes (if any) associated with the current node in another +window. You can have Info automatically display the footnotes +associated with a node when the node is selected by setting the variable +@code{automatic-footnotes}. @xref{Variables, , @code{automatic-footnotes}}. +@end table + +@node Variables, GNU Info Global Index, Miscellaneous Commands, Top +@chapter Manipulating Variables + +GNU Info contains several @dfn{variables} whose values are looked at by +various Info commands. You can change the values of these variables, +and thus change the behavior of Info to more closely match your +environment and Info file reading manner. + +@table @asis +@item @code{M-x set-variable} +@cindex variables, setting +@findex set-variable +Read the name of a variable, and the value for it, in the echo area and +then set the variable to that value. Completion is available when +reading the variable name; often, completion is available when reading +the value to give to the variable, but that depends on the variable +itself. If a variable does @emph{not} supply multiple choices to +complete over, it expects a numeric value. + +@item @code{M-x describe-variable} +@cindex variables, describing +@findex describe-variable +Read the name of a variable in the echo area and then display a brief +description of what the variable affects. +@end table + +Here is a list of the variables that you can set in Info. + +@table @code +@item automatic-footnotes +@vindex automatic-footnotes +When set to @code{On}, footnotes appear and disappear automatically. +This variable is @code{On} by default. When a node is selected, a +window containing the footnotes which appear in that node is created, +and the footnotes are displayed within the new window. The window that +Info creates to contain the footnotes is called @samp{*Footnotes*}. If +a node is selected which contains no footnotes, and a @samp{*Footnotes*} +window is on the screen, the @samp{*Footnotes*} window is deleted. +Footnote windows created in this fashion are not automatically tiled so +that they can use as little of the display as is possible. + +@item automatic-tiling +@vindex automatic-tiling +When set to @code{On}, creating or deleting a window resizes other +windows. This variable is @code{Off} by default. Normally, typing +@samp{C-x 2} divides the current window into two equal parts. When +@code{automatic-tiling} is set to @code{On}, all of the windows are +resized automatically, keeping an equal number of lines visible in each +window. There are exceptions to the automatic tiling; specifically, the +windows @samp{*Completions*} and @samp{*Footnotes*} are @emph{not} +resized through automatic tiling; they remain their original size. + +@item visible-bell +@vindex visible-bell +When set to @code{On}, GNU Info attempts to flash the screen instead of +ringing the bell. This variable is @code{Off} by default. Of course, +Info can only flash the screen if the terminal allows it; in the case +that the terminal does not allow it, the setting of this variable has no +effect. However, you can make Info perform quietly by setting the +@code{errors-ring-bell} variable to @code{Off}. + +@item errors-ring-bell +@vindex errors-ring-bell +When set to @code{On}, errors cause the bell to ring. The default +setting of this variable is @code{On}. + +@item gc-compressed-files +@vindex gc-compressed-files +When set to @code{On}, Info garbage collects files which had to be +uncompressed. The default value of this variable is @code{Off}. +Whenever a node is visited in Info, the Info file containing that node +is read into core, and Info reads information about the tags and nodes +contained in that file. Once the tags information is read by Info, it +is never forgotten. However, the actual text of the nodes does not need +to remain in core unless a particular Info window needs it. For +non-compressed files, the text of the nodes does not remain in core when +it is no longer in use. But de-compressing a file can be a time +consuming operation, and so Info tries hard not to do it twice. +@code{gc-compressed-files} tells Info it is okay to garbage collect the +text of the nodes of a file which was compressed on disk. + +@item show-index-match +@vindex show-index-match +When set to @code{On}, the portion of the matched search string is +highlighted in the message which explains where the matched search +string was found. The default value of this variable is @code{On}. +When Info displays the location where an index match was found, +(@pxref{Searching Commands, , @code{next-index-match}}), the portion of the +string that you had typed is highlighted by displaying it in the inverse +case from its surrounding characters. + +@item scroll-behavior +@vindex scroll-behavior +Control what happens when forward scrolling is requested at the end of +a node, or when backward scrolling is requested at the beginning of a +node. The default value for this variable is @code{Continuous}. There +are three possible values for this variable: + +@table @code +@item Continuous +Try to get the first item in this node's menu, or failing that, the +@samp{Next} node, or failing that, the @samp{Next} of the @samp{Up}. +This behavior is identical to using the @samp{]} +(@code{global-next-node}) and @samp{[} (@code{global-prev-node}) +commands. + +@item Next Only +Only try to get the @samp{Next} node. + +@item Page Only +Simply give up, changing nothing. If @code{scroll-behavior} is +@code{Page Only}, no scrolling command can change the node that is being +viewed. +@end table + +@item scroll-step +@vindex scroll-step +The number of lines to scroll when the cursor moves out of the window. +Scrolling happens automatically if the cursor has moved out of the +visible portion of the node text when it is time to display. Usually +the scrolling is done so as to put the cursor on the center line of the +current window. However, if the variable @code{scroll-step} has a +nonzero value, Info attempts to scroll the node text by that many lines; +if that is enough to bring the cursor back into the window, that is what +is done. The default value of this variable is 0, thus placing the +cursor (and the text it is attached to) in the center of the window. +Setting this variable to 1 causes a kind of "smooth scrolling" which +some people prefer. + +@item ISO-Latin +@cindex ISO Latin characters +@vindex ISO-Latin +When set to @code{On}, Info accepts and displays ISO Latin characters. +By default, Info assumes an ASCII character set. @code{ISO-Latin} tells +Info that it is running in an environment where the European standard +character set is in use, and allows you to input such characters to +Info, as well as display them. +@end table + + + +@c the following is incomplete +@ignore +@c node Info for Sys Admins +@c chapter Info for System Administrators + +This text describes some common ways of setting up an Info hierarchy +from scratch, and details the various options that are available when +installing Info. This text is designed for the person who is installing +GNU Info on the system; although users may find the information present +in this section interesting, none of it is vital to understanding how to +use GNU Info. + +@menu +* Setting the INFOPATH:: Where are my Info files kept? +* Editing the DIR node:: What goes in `DIR', and why? +* Storing Info files:: Alternate formats allow flexibility in setups. +* Using `localdir':: Building DIR on the fly. +* Example setups:: Some common ways to organize Info files. +@end menu + +@c node Setting the INFOPATH +@c section Setting the INFOPATH + +Where are my Info files kept? + +@c node Editing the DIR node +@c section Editing the DIR node + +What goes in `DIR', and why? + +@c node Storing Info files +@c section Storing Info files + +Alternate formats allow flexibility in setups. + +@c node Using `localdir' +@c section Using `localdir' + +Building DIR on the fly. + +@c node Example setups +@c section Example setups + +Some common ways to organize Info files. +@end ignore + +@node GNU Info Global Index, , Variables, Top +@appendix Global Index + +@printindex cp + +@contents +@bye diff --git a/texinfo/info/info-utils.c b/texinfo/info/info-utils.c new file mode 100644 index 000000000000..6af3dd0e2cab --- /dev/null +++ b/texinfo/info/info-utils.c @@ -0,0 +1,672 @@ +/* info-utils.c -- Useful functions for manipulating Info file quirks. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include /* For "NULL". Yechhh! */ +#include +#include +#include +#if defined (HAVE_STRING_H) +# include +#endif /* HAVE_STRING_H */ +#include "info-utils.h" + +#if defined (HANDLE_MAN_PAGES) +# include "man.h" +#endif /* HANDLE_MAN_PAGES */ + +/* When non-zero, various display and input functions handle ISO Latin + character sets correctly. */ +int ISO_Latin_p = 0; + +/* Variable which holds the most recent filename parsed as a result of + calling info_parse_xxx (). */ +char *info_parsed_filename = (char *)NULL; + +/* Variable which holds the most recent nodename parsed as a result of + calling info_parse_xxx (). */ +char *info_parsed_nodename = (char *)NULL; + +/* Functions to remember a filename or nodename for later return. */ +static void save_filename (), saven_filename (); +static void save_nodename (), saven_nodename (); + +/* How to get a reference (either menu or cross). */ +static REFERENCE **info_references_internal (); + +/* Parse the filename and nodename out of STRING. If STRING doesn't + contain a filename (i.e., it is NOT (FILENAME)NODENAME) then set + INFO_PARSED_FILENAME to NULL. If second argument NEWLINES_OKAY is + non-zero, it says to allow the nodename specification to cross a + newline boundary (i.e., only `,', `.', or `TAB' can end the spec). */ +void +info_parse_node (string, newlines_okay) + char *string; + int newlines_okay; +{ + register int i = 0; + + /* Default the answer. */ + save_filename ((char *)NULL); + save_nodename ((char *)NULL); + + /* Special case of nothing passed. Return nothing. */ + if (!string || !*string) + return; + + string += skip_whitespace (string); + + /* Check for (FILENAME)NODENAME. */ + if (*string == '(') + { + i = 0; + /* Advance past the opening paren. */ + string++; + + /* Find the closing paren. */ + while (string[i] && string[i] != ')') + i++; + + /* Remember parsed filename. */ + saven_filename (string, i); + + /* Point directly at the nodename. */ + string += i; + + if (*string) + string++; + } + + /* Parse out nodename. */ + i = skip_node_characters (string, newlines_okay); + saven_nodename (string, i); + canonicalize_whitespace (info_parsed_nodename); + if (info_parsed_nodename && !*info_parsed_nodename) + { + free (info_parsed_nodename); + info_parsed_nodename = (char *)NULL; + } +} + +/* Return the node addressed by LABEL in NODE (usually one of "Prev:", + "Next:", "Up:", "File:", or "Node:". After a call to this function, + the global INFO_PARSED_NODENAME and INFO_PARSED_FILENAME contain + the information. */ +void +info_parse_label (label, node) + char *label; + NODE *node; +{ + register int i; + char *nodeline; + + /* Default answer to failure. */ + save_nodename ((char *)NULL); + save_filename ((char *)NULL); + + /* Find the label in the first line of this node. */ + nodeline = node->contents; + i = string_in_line (label, nodeline); + + if (i == -1) + return; + + nodeline += i; + nodeline += skip_whitespace (nodeline); + info_parse_node (nodeline, DONT_SKIP_NEWLINES); +} + +/* **************************************************************** */ +/* */ +/* Finding and Building Menus */ +/* */ +/* **************************************************************** */ + +/* Return a NULL terminated array of REFERENCE * which represents the menu + found in NODE. If there is no menu in NODE, just return a NULL pointer. */ +REFERENCE ** +info_menu_of_node (node) + NODE *node; +{ + long position; + SEARCH_BINDING search; + REFERENCE **menu = (REFERENCE **)NULL; + + search.buffer = node->contents; + search.start = 0; + search.end = node->nodelen; + search.flags = S_FoldCase; + + /* Find the start of the menu. */ + position = search_forward (INFO_MENU_LABEL, &search); + + if (position == -1) + return ((REFERENCE **) NULL); + + /* We have the start of the menu now. Glean menu items from the rest + of the node. */ + search.start = position + strlen (INFO_MENU_LABEL); + search.start += skip_line (search.buffer + search.start); + search.start--; + menu = info_menu_items (&search); + return (menu); +} + +/* Return a NULL terminated array of REFERENCE * which represents the cross + refrences found in NODE. If there are no cross references in NODE, just + return a NULL pointer. */ +REFERENCE ** +info_xrefs_of_node (node) + NODE *node; +{ + SEARCH_BINDING search; + +#if defined (HANDLE_MAN_PAGES) + if (node->flags & N_IsManPage) + return (xrefs_of_manpage (node)); +#endif + + search.buffer = node->contents; + search.start = 0; + search.end = node->nodelen; + search.flags = S_FoldCase; + + return (info_xrefs (&search)); +} + +/* Glean menu entries from BINDING->buffer + BINDING->start until we + have looked at the entire contents of BINDING. Return an array + of REFERENCE * that represents each menu item in this range. */ +REFERENCE ** +info_menu_items (binding) + SEARCH_BINDING *binding; +{ + return (info_references_internal (INFO_MENU_ENTRY_LABEL, binding)); +} + +/* Glean cross references from BINDING->buffer + BINDING->start until + BINDING->end. Return an array of REFERENCE * that represents each + cross reference in this range. */ +REFERENCE ** +info_xrefs (binding) + SEARCH_BINDING *binding; +{ + return (info_references_internal (INFO_XREF_LABEL, binding)); +} + +/* Glean cross references or menu items from BINDING. Return an array + of REFERENCE * that represents the items found. */ +static REFERENCE ** +info_references_internal (label, binding) + char *label; + SEARCH_BINDING *binding; +{ + SEARCH_BINDING search; + REFERENCE **refs = (REFERENCE **)NULL; + int refs_index = 0, refs_slots = 0; + int searching_for_menu_items = 0; + long position; + + search.buffer = binding->buffer; + search.start = binding->start; + search.end = binding->end; + search.flags = S_FoldCase | S_SkipDest; + + searching_for_menu_items = (strcasecmp (label, INFO_MENU_ENTRY_LABEL) == 0); + + while ((position = search_forward (label, &search)) != -1) + { + int offset, start; + char *refdef; + REFERENCE *entry; + + search.start = position; + search.start += skip_whitespace (search.buffer + search.start); + start = search.start - binding->start; + refdef = search.buffer + search.start; + offset = string_in_line (":", refdef); + + /* When searching for menu items, if no colon, there is no + menu item on this line. */ + if (offset == -1) + { + if (searching_for_menu_items) + continue; + else + { + int temp; + + temp = skip_line (refdef); + offset = string_in_line (":", refdef + temp); + if (offset == -1) + continue; /* Give up? */ + else + offset += temp; + } + } + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->filename = (char *)NULL; + entry->nodename = (char *)NULL; + entry->label = (char *)xmalloc (offset); + strncpy (entry->label, refdef, offset - 1); + entry->label[offset - 1] = '\0'; + canonicalize_whitespace (entry->label); + + refdef += offset; + entry->start = start; + entry->end = refdef - binding->buffer; + + /* If this reference entry continues with another ':' then the + nodename is the same as the label. */ + if (*refdef == ':') + { + entry->nodename = strdup (entry->label); + } + else + { + /* This entry continues with a specific nodename. Parse the + nodename from the specification. */ + + refdef += skip_whitespace_and_newlines (refdef); + + if (searching_for_menu_items) + info_parse_node (refdef, DONT_SKIP_NEWLINES); + else + info_parse_node (refdef, SKIP_NEWLINES); + + if (info_parsed_filename) + entry->filename = strdup (info_parsed_filename); + + if (info_parsed_nodename) + entry->nodename = strdup (info_parsed_nodename); + } + + add_pointer_to_array + (entry, refs_index, refs, refs_slots, 50, REFERENCE *); + } + return (refs); +} + +/* Get the entry associated with LABEL in MENU. Return a pointer to the + REFERENCE if found, or NULL. */ +REFERENCE * +info_get_labeled_reference (label, references) + char *label; + REFERENCE **references; +{ + register int i; + REFERENCE *entry; + + for (i = 0; references && (entry = references[i]); i++) + { + if (strcmp (label, entry->label) == 0) + return (entry); + } + return ((REFERENCE *)NULL); +} + +/* A utility function for concatenating REFERENCE **. Returns a new + REFERENCE ** which is the concatenation of REF1 and REF2. The REF1 + and REF2 arrays are freed, but their contents are not. */ +REFERENCE ** +info_concatenate_references (ref1, ref2) + REFERENCE **ref1, **ref2; +{ + register int i, j; + REFERENCE **result; + int size; + + /* With one argument passed as NULL, simply return the other arg. */ + if (!ref1) + return (ref2); + else if (!ref2) + return (ref1); + + /* Get the total size of the slots that we will need. */ + for (i = 0; ref1[i]; i++); + size = i; + for (i = 0; ref2[i]; i++); + size += i; + + result = (REFERENCE **)xmalloc ((1 + size) * sizeof (REFERENCE *)); + + /* Copy the contents over. */ + for (i = 0; ref1[i]; i++) + result[i] = ref1[i]; + + j = i; + for (i = 0; ref2[i]; i++) + result[j++] = ref2[i]; + + result[j] = (REFERENCE *)NULL; + free (ref1); + free (ref2); + return (result); +} + +/* Free the data associated with REFERENCES. */ +void +info_free_references (references) + REFERENCE **references; +{ + register int i; + REFERENCE *entry; + + if (references) + { + for (i = 0; references && (entry = references[i]); i++) + { + maybe_free (entry->label); + maybe_free (entry->filename); + maybe_free (entry->nodename); + + free (entry); + } + + free (references); + } +} + +/* Search for sequences of whitespace or newlines in STRING, replacing + all such sequences with just a single space. Remove whitespace from + start and end of string. */ +void +canonicalize_whitespace (string) + char *string; +{ + register int i, j; + int len, whitespace_found, whitespace_loc; + char *temp; + + if (!string) + return; + + len = strlen (string); + temp = (char *)xmalloc (1 + len); + + /* Search for sequences of whitespace or newlines. Replace all such + sequences in the string with just a single space. */ + + whitespace_found = 0; + for (i = 0, j = 0; string[i]; i++) + { + if (whitespace_or_newline (string[i])) + { + whitespace_found++; + whitespace_loc = i; + continue; + } + else + { + if (whitespace_found && whitespace_loc) + { + whitespace_found = 0; + + /* Suppress whitespace at start of string. */ + if (j) + temp[j++] = ' '; + } + + temp[j++] = string[i]; + } + } + + /* Kill trailing whitespace. */ + if (j && whitespace (temp[j - 1])) + j--; + + temp[j] = '\0'; + strcpy (string, temp); + free (temp); +} + +/* String representation of a char returned by printed_representation (). */ +static char the_rep[10]; + +/* Return a pointer to a string which is the printed representation + of CHARACTER if it were printed at HPOS. */ +char * +printed_representation (character, hpos) + unsigned char character; + int hpos; +{ + register int i = 0; + int printable_limit; + + if (ISO_Latin_p) + printable_limit = 160; + else + printable_limit = 127; + + if (character == '\177') + { + the_rep[i++] = '^'; + the_rep[i++] = '?'; + } + else if (iscntrl (character)) + { + switch (character) + { + case '\r': + case '\n': + the_rep[i++] = character; + break; + + case '\t': + { + int tw; + + tw = ((hpos + 8) & 0xf8) - hpos; + while (i < tw) + the_rep[i++] = ' '; + } + break; + + default: + the_rep[i++] = '^'; + the_rep[i++] = (character | 0x40); + } + } + else if (character > printable_limit) + { + sprintf (the_rep + i, "\\%0o", character); + i = strlen (the_rep); + } + else + the_rep[i++] = character; + + the_rep[i] = '\0'; + + return (the_rep); +} + + +/* **************************************************************** */ +/* */ +/* Functions Static To This File */ +/* */ +/* **************************************************************** */ + +/* Amount of space allocated to INFO_PARSED_FILENAME via xmalloc (). */ +static int parsed_filename_size = 0; + +/* Amount of space allocated to INFO_PARSED_NODENAME via xmalloc (). */ +static int parsed_nodename_size = 0; + +static void save_string (), saven_string (); + +/* Remember FILENAME in PARSED_FILENAME. An empty FILENAME is translated + to a NULL pointer in PARSED_FILENAME. */ +static void +save_filename (filename) + char *filename; +{ + save_string (filename, &info_parsed_filename, &parsed_filename_size); +} + +/* Just like save_filename (), but you pass the length of the string. */ +static void +saven_filename (filename, len) + char *filename; + int len; +{ + saven_string (filename, len, + &info_parsed_filename, &parsed_filename_size); +} + +/* Remember NODENAME in PARSED_NODENAME. An empty NODENAME is translated + to a NULL pointer in PARSED_NODENAME. */ +static void +save_nodename (nodename) + char *nodename; +{ + save_string (nodename, &info_parsed_nodename, &parsed_nodename_size); +} + +/* Just like save_nodename (), but you pass the length of the string. */ +static void +saven_nodename (nodename, len) + char *nodename; + int len; +{ + saven_string (nodename, len, + &info_parsed_nodename, &parsed_nodename_size); +} + +/* Remember STRING in STRING_P. STRING_P should currently have STRING_SIZE_P + bytes allocated to it. An empty STRING is translated to a NULL pointer + in STRING_P. */ +static void +save_string (string, string_p, string_size_p) + char *string; + char **string_p; + int *string_size_p; +{ + if (!string || !*string) + { + if (*string_p) + free (*string_p); + + *string_p = (char *)NULL; + *string_size_p = 0; + } + else + { + if (strlen (string) >= *string_size_p) + *string_p = (char *)xrealloc + (*string_p, (*string_size_p = 1 + strlen (string))); + + strcpy (*string_p, string); + } +} + +/* Just like save_string (), but you also pass the length of STRING. */ +static void +saven_string (string, len, string_p, string_size_p) + char *string; + int len; + char **string_p; + int *string_size_p; +{ + if (!string) + { + if (*string_p) + free (*string_p); + + *string_p = (char *)NULL; + *string_size_p = 0; + } + else + { + if (len >= *string_size_p) + *string_p = (char *)xrealloc (*string_p, (*string_size_p = 1 + len)); + + strncpy (*string_p, string, len); + (*string_p)[len] = '\0'; + } +} + +/* Return a pointer to the part of PATHNAME that simply defines the file. */ +char * +filename_non_directory (pathname) + char *pathname; +{ + char *filename; + + filename = (char *) strrchr (pathname, '/'); + + if (filename) + filename++; + else + filename = pathname; + + return (filename); +} + +/* Return non-zero if NODE is one especially created by Info. */ +int +internal_info_node_p (node) + NODE *node; +{ +#if defined (NEVER) + if (node && + (node->filename && !*node->filename) && + !node->parent && node->nodename) + return (1); + else + return (0); +#else + return ((node != (NODE *)NULL) && ((node->flags & N_IsInternal) != 0)); +#endif /* !NEVER */ +} + +/* Make NODE appear to be one especially created by Info. */ +void +name_internal_node (node, name) + NODE *node; + char *name; +{ + if (!node) + return; + + node->filename = ""; + node->parent = (char *)NULL; + node->nodename = name; + node->flags |= N_IsInternal; +} + +/* Return the window displaying NAME, the name of an internally created + Info window. */ +WINDOW * +get_internal_info_window (name) + char *name; +{ + WINDOW *win; + + for (win = windows; win; win = win->next) + if (internal_info_node_p (win->node) && + (strcmp (win->node->nodename, name) == 0)) + break; + + return (win); +} diff --git a/texinfo/info/info-utils.h b/texinfo/info/info-utils.h new file mode 100644 index 000000000000..9f17a39f88b7 --- /dev/null +++ b/texinfo/info/info-utils.h @@ -0,0 +1,140 @@ +/* info-utils.h -- Exported functions and variables from info-util.c. + $Id: info-utils.h,v 1.1 1997/08/21 22:58:02 jason Exp $ + + This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993, 96 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_INFO_UTILS_H_) +#define _INFO_UTILS_H_ + +#if !defined (HAVE_STRCHR) +# undef strchr +# undef strrchr +# define strchr index +# define strrchr rindex +#endif /* !HAVE_STRCHR */ + +#include "nodes.h" +#include "window.h" +#include "search.h" + +/* Structure which describes a node reference, such as a menu entry or + cross reference. Arrays of such references can be built by calling + info_menus_of_node () or info_xrefs_of_node (). */ +typedef struct { + char *label; /* User Label. */ + char *filename; /* File where this node can be found. */ + char *nodename; /* Name of the node. */ + int start, end; /* Offsets within the containing node of LABEL. */ +} REFERENCE; + +/* When non-zero, various display and input functions handle ISO Latin + character sets correctly. */ +extern int ISO_Latin_p; + +/* Variable which holds the most recent filename parsed as a result of + calling info_parse_xxx (). */ +extern char *info_parsed_filename; + +/* Variable which holds the most recent nodename parsed as a result of + calling info_parse_xxx (). */ +extern char *info_parsed_nodename; + +/* Parse the filename and nodename out of STRING. If STRING doesn't + contain a filename (i.e., it is NOT (FILENAME)NODENAME) then set + INFO_PARSED_FILENAME to NULL. If second argument NEWLINES_OKAY is + non-zero, it says to allow the nodename specification to cross a + newline boundary (i.e., only `,', `.', or `TAB' can end the spec). */ +void info_parse_node (); + +/* Return a NULL terminated array of REFERENCE * which represents the menu + found in NODE. If there is no menu in NODE, just return a NULL pointer. */ +extern REFERENCE **info_menu_of_node (); + +/* Return a NULL terminated array of REFERENCE * which represents the cross + refrences found in NODE. If there are no cross references in NODE, just + return a NULL pointer. */ +extern REFERENCE **info_xrefs_of_node (); + +/* Glean cross references from BINDING->buffer + BINDING->start until + BINDING->end. Return an array of REFERENCE * that represents each + cross reference in this range. */ +extern REFERENCE **info_xrefs (); + +/* Get the entry associated with LABEL in REFERENCES. Return a pointer to + the reference if found, or NULL. */ +extern REFERENCE *info_get_labeled_reference (); + +/* Glean menu entries from BINDING->buffer + BINDING->start until we + have looked at the entire contents of BINDING. Return an array + of REFERENCE * that represents each menu item in this range. */ +extern REFERENCE **info_menu_items (); + +/* A utility function for concatenating REFERENCE **. Returns a new + REFERENCE ** which is the concatenation of REF1 and REF2. The REF1 + and REF2 arrays are freed, but their contents are not. */ +REFERENCE **info_concatenate_references (); + +/* Free the data associated with REFERENCES. */ +extern void info_free_references (); + +/* Search for sequences of whitespace or newlines in STRING, replacing + all such sequences with just a single space. Remove whitespace from + start and end of string. */ +void canonicalize_whitespace (); + +/* Return a pointer to a string which is the printed representation + of CHARACTER if it were printed at HPOS. */ +extern char *printed_representation (); + +/* Return a pointer to the part of PATHNAME that simply defines the file. */ +extern char *filename_non_directory (); + +/* Return non-zero if NODE is one especially created by Info. */ +extern int internal_info_node_p (); + +/* Make NODE appear to be one especially created by Info, and give it NAME. */ +extern void name_internal_node (); + +/* Return the window displaying NAME, the name of an internally created + Info window. */ +extern WINDOW *get_internal_info_window (); + +/* Return the node addressed by LABEL in NODE (usually one of "Prev:", + "Next:", "Up:", "File:", or "Node:". After a call to this function, + the global INFO_PARSED_NODENAME and INFO_PARSED_FILENAME contain + the information. */ +extern void info_parse_label (/* label, node */); + +#define info_label_was_found \ + (info_parsed_nodename != NULL || info_parsed_filename != NULL) + +#define info_file_label_of_node(n) info_parse_label (INFO_FILE_LABEL, n) +#define info_next_label_of_node(n) info_parse_label (INFO_NEXT_LABEL, n) +#define info_up_label_of_node(n) info_parse_label (INFO_UP_LABEL, n) +#define info_prev_label_of_node(n) \ + do { \ + info_parse_label (INFO_PREV_LABEL, n); \ + if (!info_label_was_found) \ + info_parse_label (INFO_ALTPREV_LABEL, n); \ + } while (0) + +#endif /* !_INFO_UTILS_H_ */ diff --git a/texinfo/info/info.1 b/texinfo/info/info.1 new file mode 100644 index 000000000000..f95687303d22 --- /dev/null +++ b/texinfo/info/info.1 @@ -0,0 +1,229 @@ +.TH info 1 "7th December 1990" +.SH NAME +info \- GNU's hypertext system +.SH SYNOPSIS +.B info +[ +.B \-\-option-name option-value +] +.B \menu-item... +.SH COPYRIGHT +.if n Copyright (C) 1989, 1993 Free Software Foundation, Inc. +.if t Copyright \(co 1989, 1993 Free Software Foundation, Inc. +.SH DESCRIPTION +.LP +The GNU project has a hypertext system called +.I Info +which allows the same source file to be either printed as a +paper manual, or viewed using +.B info. +It is possible to use the +.B info +program from inside Emacs, or to use the stand-alone version described here. +This manual page gives a brief summary of its capabilities. + +.SH OPTIONS +.TP +.B \-\-directory directory-path +Add +.B directory-path +to the list of directory paths searched when +.B info +needs to find a file. You may issue +.B \-\-directory +multiple times. +Alternatively, you may specify a value for the environment variable +.B INFOPATH; +if +.B \-\-directory +is not given, the value of +.B INFOPATH +is used. The value of +.B INFOPATH +is a colon separated list of directory names. If you do not supply either +.B INFOPATH +or +.B \-\-directory-path, +.B info +uses a default path. +.TP +.B \-f filename +Specify a particular +.B info +file to visit. By default, +.B info +visits +the file +.B dir; +if you use this option, +.B info +will start with +.B (FILENAME)Top +as the first file and node. +.TP +.B \-n nodename +Specify a particular node to visit in the initial file that +.B info +loads. This is especially useful in conjunction with +.B \-\-file. +You may specify +.B \-\-node +multiple times. +.TP +.B -o file +Direct output to +.B file +instead of starting an interactive +.B info +session. +.TP +.B \-h +Produce a relatively brief description of the available +.B info +options. +.TP +.B \-\-version +Print the version information of +.B info +and exit. +.TP +.B menu-item +.B info +treats its remaining arguments as the names of menu items. +The first argument is a menu item in the initial node visited, +while the second argument is a menu item in the first argument's +node. You can easily move to the node of your choice by +specifying the menu names which describe the path to that node. +For example, + +.B info emacs buffers + +first selects the menu item +.B emacs +in the node +.B (dir)Top, +and then selects the menu item +.B buffers +in the node +.B (emacs)Top. +.SH COMMANDS +When in +.B info +the following commands are available: +.TP +.B h +Invoke the Info tutorial. +.TP +.B ? +Get a short summary of +.B info +commands. +.TP +.B h +Select the +.B info +node from the main directory; this is much more complete than just +using +.B ?. +.TP +.B Ctrl-g +Abort whatever you are doing. +.TP +.B Ctrl-l +Redraw the screen. +.PP +Selecting other nodes: +.TP +.B n +Move to the "next" node of this node. +.TP +.B p +Move to the "previous" node of this node. +.TP +.B u +Move to this node's "up" node. +.TP +.B m +Pick a menu item specified by name. Picking a menu item causes another +node to be selected. You do not need to type a complete nodename; if +you type a few letters and then a space or tab +.B info +will will try to fill in the rest of the nodename. If you ask for further +completion without typing any more characters you'll be given a list +of possibilities; you can also get the list with +.B ?. +If you type a few characters and then hit return +.B info +will try to do a completion, and if it is ambigous use the first possibility. +.TP +.B f +Follow a cross reference. You are asked for the name of the reference, +using command completion as for +.B m. +.TP +.B l +Move to the last node you were at. +.PP +Moving within a node: +.TP +.B Space +Scroll forward a page. +.TP +.B DEL +Scroll backward a page. +.TP +.B b +Go to the beginning of this node. +.PP +Advanced commands: +.TP +.B q +Quit +.B info. +.TP +.B 1 +Pick first item in node's menu. +.TP +.B 2 \-\- 5 +Pick second ... fifth item in node's menu. +.TP +.B g +Move to node specified by name. You may include a filename as well, +as +.B (FILENAME)NODENAME. +.TP +.B s +Search through this +.B info +file for a specified string, and select the node in which +the next occurrence is found. +.TP +.B M-x print-node +Pipe the contents of the current node through the command in the +environment variable +.B INFO_PRINT_COMMAND. +If the variable does not exist, the node is simply piped to +.B lpr. +.SH ENVIRONMENT +.TP +.B INFOPATH +A colon-separated list of directories to search for +.B info +files. Used if +.B \-\-directory +is not given. +.TP +.B INFO_PRINT_COMMAND +The command used for printing. +.SH SEE ALSO +.BR emacs (1) +.SH AUTHOR +.RS +Brian Fox, Free Software Foundation +.br +bfox@ai.mit.edu +.SH MANUAL AUTHOR +.RS +Robert Lupton; updated by Robert J. Chassell. +.br +rhl@astro.princeton.edu; bob@gnu.ai.mit.edu diff --git a/texinfo/info/info.c b/texinfo/info/info.c new file mode 100644 index 000000000000..223df55acb28 --- /dev/null +++ b/texinfo/info/info.c @@ -0,0 +1,565 @@ +/* info.c -- Display nodes of Info files in multiple windows. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993, 96 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" +#include "dribble.h" +#include "getopt.h" +#if defined (HANDLE_MAN_PAGES) +# include "man.h" +#endif /* HANDLE_MAN_PAGES */ + +/* The version numbers of this version of Info. */ +int info_major_version = 2; +int info_minor_version = 16; +int info_patch_level = 0; + +/* Non-zero means search all indices for APROPOS_SEARCH_STRING. */ +static int apropos_p = 0; + +/* Variable containing the string to search for when apropos_p is non-zero. */ +static char *apropos_search_string = (char *)NULL; + +/* Non-zero means print version info only. */ +static int print_version_p = 0; + +/* Non-zero means print a short description of the options. */ +static int print_help_p = 0; + +/* Array of the names of nodes that the user specified with "--node" on the + command line. */ +static char **user_nodenames = (char **)NULL; +static int user_nodenames_index = 0; +static int user_nodenames_slots = 0; + +/* String specifying the first file to load. This string can only be set + by the user specifying "--file" on the command line. */ +static char *user_filename = (char *)NULL; + +/* String specifying the name of the file to dump nodes to. This value is + filled if the user speficies "--output" on the command line. */ +static char *user_output_filename = (char *)NULL; + +/* Non-zero indicates that when "--output" is specified, all of the menu + items of the specified nodes (and their subnodes as well) should be + dumped in the order encountered. This basically can print a book. */ +int dump_subnodes = 0; + +/* Structure describing the options that Info accepts. We pass this structure + to getopt_long (). If you add or otherwise change this structure, you must + also change the string which follows it. */ +#define APROPOS_OPTION 1 +#define DRIBBLE_OPTION 2 +#define RESTORE_OPTION 3 +static struct option long_options[] = { + { "apropos", 1, 0, APROPOS_OPTION }, + { "directory", 1, 0, 'd' }, + { "node", 1, 0, 'n' }, + { "file", 1, 0, 'f' }, + { "subnodes", 0, &dump_subnodes, 1 }, + { "output", 1, 0, 'o' }, + { "help", 0, &print_help_p, 1 }, + { "version", 0, &print_version_p, 1 }, + { "dribble", 1, 0, DRIBBLE_OPTION }, + { "restore", 1, 0, RESTORE_OPTION }, + {NULL, 0, NULL, 0} +}; + +/* String describing the shorthand versions of the long options found above. */ +static char *short_options = "d:n:f:o:s"; + +/* When non-zero, the Info window system has been initialized. */ +int info_windows_initialized_p = 0; + +/* Some "forward" declarations. */ +static void usage (), info_short_help (), remember_info_program_name (); + + +/* **************************************************************** */ +/* */ +/* Main Entry Point to the Info Program */ +/* */ +/* **************************************************************** */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int getopt_long_index; /* Index returned by getopt_long (). */ + NODE *initial_node; /* First node loaded by Info. */ + + remember_info_program_name (argv[0]); + + while (1) + { + int option_character; + + option_character = getopt_long + (argc, argv, short_options, long_options, &getopt_long_index); + + /* getopt_long () returns EOF when there are no more long options. */ + if (option_character == EOF) + break; + + /* If this is a long option, then get the short version of it. */ + if (option_character == 0 && long_options[getopt_long_index].flag == 0) + option_character = long_options[getopt_long_index].val; + + /* Case on the option that we have received. */ + switch (option_character) + { + case 0: + break; + + /* User wants to add a directory. */ + case 'd': + info_add_path (optarg, INFOPATH_PREPEND); + break; + + /* User is specifying a particular node. */ + case 'n': + add_pointer_to_array (optarg, user_nodenames_index, user_nodenames, + user_nodenames_slots, 10, char *); + break; + + /* User is specifying a particular Info file. */ + case 'f': + if (user_filename) + free (user_filename); + + user_filename = strdup (optarg); + break; + + /* User is specifying the name of a file to output to. */ + case 'o': + if (user_output_filename) + free (user_output_filename); + user_output_filename = strdup (optarg); + break; + + /* User is specifying that she wishes to dump the subnodes of + the node that she is dumping. */ + case 's': + dump_subnodes = 1; + break; + + /* User has specified a string to search all indices for. */ + case APROPOS_OPTION: + apropos_p = 1; + maybe_free (apropos_search_string); + apropos_search_string = strdup (optarg); + break; + + /* User has specified a dribble file to receive keystrokes. */ + case DRIBBLE_OPTION: + close_dribble_file (); + open_dribble_file (optarg); + break; + + /* User has specified an alternate input stream. */ + case RESTORE_OPTION: + info_set_input_from_file (optarg); + break; + + default: + usage (); + } + } + + /* If the output device is not a terminal, and no output filename has been + specified, make user_output_filename be "-", so that the info is written + to stdout, and turn on the dumping of subnodes. */ + if ((!isatty (fileno (stdout))) && (user_output_filename == (char *)NULL)) + { + user_output_filename = strdup ("-"); + dump_subnodes = 1; + } + + /* If the user specified --version, then show the version and exit. */ + if (print_version_p) + { + printf ("GNU Info (Texinfo 3.9) %s\n", version_string ()); + puts ("Copyright (C) 1996 Free Software Foundation, Inc.\n\ +There is NO warranty. You may redistribute this software\n\ +under the terms of the GNU General Public License.\n\ +For more information about these matters, see the files named COPYING."); + exit (0); + } + + /* If the `--help' option was present, show the help and exit. */ + if (print_help_p) + { + info_short_help (); + exit (0); + } + + /* If the user hasn't specified a path for Info files, default that path + now. */ + if (!infopath) + { + char *path_from_env, *getenv (); + + path_from_env = getenv ("INFOPATH"); + + if (path_from_env) + info_add_path (path_from_env, INFOPATH_PREPEND); + else + info_add_path (DEFAULT_INFOPATH, INFOPATH_PREPEND); + } + + /* If the user specified a particular filename, add the path of that + file to the contents of INFOPATH. */ + if (user_filename) + { + char *directory_name, *temp; + + directory_name = strdup (user_filename); + temp = filename_non_directory (directory_name); + + if (temp != directory_name) + { + *temp = 0; + info_add_path (directory_name, INFOPATH_PREPEND); + } + + free (directory_name); + } + + /* If the user wants to search every known index for a given string, + do that now, and report the results. */ + if (apropos_p) + { + info_apropos (apropos_search_string); + exit (0); + } + + /* Get the initial Info node. It is either "(dir)Top", or what the user + specifed with values in user_filename and user_nodenames. */ + if (user_nodenames) + initial_node = info_get_node (user_filename, user_nodenames[0]); + else + initial_node = info_get_node (user_filename, (char *)NULL); + + /* If we couldn't get the initial node, this user is in trouble. */ + if (!initial_node) + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error + (CANT_FIND_NODE, user_nodenames ? user_nodenames[0] : "Top"); + exit (1); + } + + /* Special cases for when the user specifies multiple nodes. If we are + dumping to an output file, dump all of the nodes specified. Otherwise, + attempt to create enough windows to handle the nodes that this user wants + displayed. */ + if (user_nodenames_index > 1) + { + free (initial_node); + + if (user_output_filename) + dump_nodes_to_file + (user_filename, user_nodenames, user_output_filename, dump_subnodes); + else + begin_multiple_window_info_session (user_filename, user_nodenames); + + exit (0); + } + + /* If there are arguments remaining, they are the names of menu items + in sequential info files starting from the first one loaded. That + file name is either "dir", or the contents of user_filename if one + was specified. */ + while (optind != argc) + { + REFERENCE **menu; + REFERENCE *entry; + NODE *node; + char *arg; + static char *first_arg = (char *)NULL; + + /* Remember the name of the menu entry we want. */ + arg = argv[optind++]; + + if (first_arg == (char *)NULL) + first_arg = arg; + + /* Build and return a list of the menu items in this node. */ + menu = info_menu_of_node (initial_node); + + /* If there wasn't a menu item in this node, stop here, but let + the user continue to use Info. Perhaps they wanted this node + and didn't realize it. */ + if (!menu) + { +#if defined (HANDLE_MAN_PAGES) + if (first_arg == arg) + { + node = make_manpage_node (first_arg); + if (node) + goto maybe_got_node; + } +#endif /* HANDLE_MAN_PAGES */ + begin_info_session_with_error + (initial_node, "There is no menu in this node."); + exit (0); + } + + /* Find the specified menu item. */ + entry = info_get_labeled_reference (arg, menu); + + /* If the item wasn't found, search the list sloppily. Perhaps this + user typed "buffer" when they really meant "Buffers". */ + if (!entry) + { + register int i; + int best_guess = -1; + + for (i = 0; entry = menu[i]; i++) + { + if (strcasecmp (entry->label, arg) == 0) + break; + else + if (strncasecmp (entry->label, arg, strlen (arg)) == 0) + best_guess = i; + } + + if (!entry && best_guess != -1) + entry = menu[best_guess]; + } + + /* If we failed to find the reference, start Info with the current + node anyway. It is probably a misspelling. */ + if (!entry) + { + char *error_message = "There is no menu item \"%s\" in this node."; + +#if defined (HANDLE_MAN_PAGES) + if (first_arg == arg) + { + node = make_manpage_node (first_arg); + if (node) + goto maybe_got_node; + } +#endif /* HANDLE_MAN_PAGES */ + + info_free_references (menu); + + /* If we were supposed to dump this node, complain. */ + if (user_output_filename) + info_error (error_message, arg); + else + begin_info_session_with_error (initial_node, error_message, arg); + + exit (0); + } + + /* We have found the reference that the user specified. Clean it + up a little bit. */ + if (!entry->filename) + { + if (initial_node->parent) + entry->filename = strdup (initial_node->parent); + else + entry->filename = strdup (initial_node->filename); + } + + /* Find this node. If we can find it, then turn the initial_node + into this one. If we cannot find it, try using the label of the + entry as a file (i.e., "(LABEL)Top"). Otherwise the Info file is + malformed in some way, and we will just use the current value of + initial node. */ + node = info_get_node (entry->filename, entry->nodename); + +#if defined (HANDLE_MAN_PAGES) + if ((first_arg == arg) && !node) + { + node = make_manpage_node (first_arg); + if (node) + goto maybe_got_node; + } +#endif /* HANDLE_MAN_PAGES */ + + if (!node && entry->nodename && + (strcmp (entry->label, entry->nodename) == 0)) + node = info_get_node (entry->label, "Top"); + + maybe_got_node: + if (node) + { + free (initial_node); + initial_node = node; + info_free_references (menu); + } + else + { + char *temp = strdup (entry->label); + char *error_message; + + error_message = "Unable to find the node referenced by \"%s\"."; + + info_free_references (menu); + + /* If we were trying to dump the node, then give up. Otherwise, + start the session with an error message. */ + if (user_output_filename) + info_error (error_message, temp); + else + begin_info_session_with_error (initial_node, error_message, temp); + + exit (0); + } + } + + /* If the user specified that this node should be output, then do that + now. Otherwise, start the Info session with this node. */ + if (user_output_filename) + dump_node_to_file (initial_node, user_output_filename, dump_subnodes); + else + begin_info_session (initial_node); + + exit (0); +} + +/* Return a string describing the current version of Info. */ +char * +version_string () +{ + static char *vstring = (char *)NULL; + + if (!vstring) + { + vstring = (char *)xmalloc (50); + sprintf (vstring, "%d.%d", info_major_version, info_minor_version); + if (info_patch_level) + sprintf (vstring + strlen (vstring), "-p%d", info_patch_level); + } + return (vstring); +} + +/* **************************************************************** */ +/* */ +/* Error Handling for Info */ +/* */ +/* **************************************************************** */ + +static char *program_name = (char *)NULL; + +static void +remember_info_program_name (fullpath) + char *fullpath; +{ + char *filename; + + filename = filename_non_directory (fullpath); + program_name = strdup (filename); +} + +/* Non-zero if an error has been signalled. */ +int info_error_was_printed = 0; + +/* Non-zero means ring terminal bell on errors. */ +int info_error_rings_bell_p = 1; + +/* Print FORMAT with ARG1 and ARG2. If the window system was initialized, + then the message is printed in the echo area. Otherwise, a message is + output to stderr. */ +void +info_error (format, arg1, arg2) + char *format; + void *arg1, *arg2; +{ + info_error_was_printed = 1; + + if (!info_windows_initialized_p || display_inhibited) + { + fprintf (stderr, "%s: ", program_name); + fprintf (stderr, format, arg1, arg2); + fprintf (stderr, "\n"); + fflush (stderr); + } + else + { + if (!echo_area_is_active) + { + if (info_error_rings_bell_p) + terminal_ring_bell (); + window_message_in_echo_area (format, arg1, arg2); + } + else + { + NODE *temp; + + temp = build_message_node (format, arg1, arg2); + if (info_error_rings_bell_p) + terminal_ring_bell (); + inform_in_echo_area (temp->contents); + free (temp->contents); + free (temp); + } + } +} + +/* Produce a very brief descripton of the available options and exit with + an error. */ +static void +usage () +{ + fprintf (stderr,"%s\n%s\n%s\n%s\n%s\n", +"Usage: info [-d dir-path] [-f info-file] [-o output-file] [-n node-name]...", +" [--directory dir-path] [--file info-file] [--node node-name]...", +" [--help] [--output output-file] [--subnodes] [--version]", +" [--dribble dribble-file] [--restore from-file]", +" [menu-selection ...]"); + exit (1); +} + +/* Produce a scaled down description of the available options to Info. */ +static void +info_short_help () +{ + puts ("\ +Here is a quick description of Info's options. For a more complete\n\ +description of how to use Info, type `info info options'.\n\ +\n\ + --directory DIR Add DIR to INFOPATH.\n\ + --dribble FILENAME Remember user keystrokes in FILENAME.\n\ + --file FILENAME Specify Info file to visit.\n\ + --node NODENAME Specify nodes in first visited Info file.\n\ + --output FILENAME Output selected nodes to FILENAME.\n\ + --restore FILENAME Read initial keystrokes from FILENAME.\n\ + --subnodes Recursively output menu items.\n\ + --help Get this help message.\n\ + --version Display Info's version information.\n\ +\n\ +Remaining arguments to Info are treated as the names of menu\n\ +items in the initial node visited. You can easily move to the\n\ +node of your choice by specifying the menu names which describe\n\ +the path to that node. For example, `info emacs buffers'.\n\ +\n\ +Email bug reports to bug-texinfo@prep.ai.mit.edu."); + + exit (0); +} diff --git a/texinfo/info/info.h b/texinfo/info/info.h new file mode 100644 index 000000000000..a8759227758a --- /dev/null +++ b/texinfo/info/info.h @@ -0,0 +1,100 @@ +/* info.h -- Header file which includes all of the other headers. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_INFO_H_) +#define _INFO_H_ + +#include +#include +#include +#include +#if defined (HAVE_STRING_H) +#include +#endif /* HAVE_STRING_H */ +#include "filesys.h" +#include "display.h" +#include "session.h" +#include "echo_area.h" +#include "doc.h" +#include "footnotes.h" +#include "gc.h" + +/* A structure associating the nodes visited in a particular window. */ +typedef struct { + WINDOW *window; /* The window that this list is attached to. */ + NODE **nodes; /* Array of nodes visited in this window. */ + int *pagetops; /* For each node in NODES, the pagetop. */ + long *points; /* For each node in NODES, the point. */ + int current; /* Index in NODES of the current node. */ + int nodes_index; /* Index where to add the next node. */ + int nodes_slots; /* Number of slots allocated to NODES. */ +} INFO_WINDOW; + +/* Array of structures describing for each window which nodes have been + visited in that window. */ +extern INFO_WINDOW **info_windows; + +/* For handling errors. If you initialize the window system, you should + also set info_windows_initialized_p to non-zero. It is used by the + info_error () function to determine how to format and output errors. */ +extern int info_windows_initialized_p; + +/* Non-zero if an error message has been printed. */ +extern int info_error_was_printed; + +/* Non-zero means ring terminal bell on errors. */ +extern int info_error_rings_bell_p; + +/* Print FORMAT with ARG1 and ARG2. If the window system was initialized, + then the message is printed in the echo area. Otherwise, a message is + output to stderr. */ +extern void info_error (); + +/* The version numbers of Info. */ +extern int info_major_version, info_minor_version, info_patch_level; + +/* How to get the version string for this version of Info. Returns + something similar to "2.11". */ +extern char *version_string (); + +/* Error message defines. */ +#define CANT_FIND_NODE "Cannot find the node \"%s\"." +#define CANT_FILE_NODE "Cannot find the node \"(%s)%s\"." +#define CANT_FIND_WIND "Cannot find a window!" +#define CANT_FIND_POINT "Point doesn't appear within this window's node!" +#define CANT_KILL_LAST "Cannot delete the last window." +#define NO_MENU_NODE "No menu in this node." +#define NO_FOOT_NODE "No footnotes in this node." +#define NO_XREF_NODE "No cross references in this node." +#define NO_POINTER "No \"%s\" pointer for this node." +#define UNKNOWN_COMMAND "Unknown Info command `%c'. `?' for help." +#define TERM_TOO_DUMB "Terminal type \"%s\" is not smart enough to run Info." +#define AT_NODE_BOTTOM "You are already at the last page of this node." +#define AT_NODE_TOP "You are already at the first page of this node." +#define ONE_WINDOW "Only one window." +#define WIN_TOO_SMALL "Resulting window would be too small." +#define CANT_MAKE_HELP \ +"There isn't enough room to make a help window. Please delete a window." + +#endif /* !_INFO_H_ */ + diff --git a/texinfo/info/info.texi b/texinfo/info/info.texi new file mode 100644 index 000000000000..efc3077e339c --- /dev/null +++ b/texinfo/info/info.texi @@ -0,0 +1,929 @@ +\input texinfo @c -*-texinfo-*- +@comment %**start of header +@setfilename info.info +@settitle Info 1.0 +@comment %**end of header +@comment $Id: info.texi,v 1.1 1997/08/21 22:58:02 jason Exp $ + +@ifinfo +@c This is a dir.info fragment to support semi-automated addition of +@c manuals to an info tree. +@format +START-INFO-DIR-ENTRY +* info: (info). Reading GNU online documentation. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@iftex +@finalout +@end iftex +@dircategory Texinfo documentation system +@direntry +* Info: (info). Documentation browsing system. +@end direntry + +@ifinfo +This file describes how to use Info, +the on-line, menu-driven GNU documentation system. + +Copyright (C) 1989, 92, 96 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end ifinfo + +@titlepage +@sp 11 +@center @titlefont{Info} +@sp 2 +@center The +@sp 2 +@center On-line, Menu-driven +@sp 2 +@center GNU Documentation System + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1989, 1992, 1993 Free Software Foundation, Inc. +@sp 2 + +Published by the Free Software Foundation @* +59 Temple Place - Suite 330 @* +Boston, MA 02111-1307, USA. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end titlepage + +@ifinfo +@node Top, Getting Started, (dir), (dir) +@top Info: An Introduction + +Info is a program for reading documentation, which you are using now. + +To learn how to use Info, type the command @kbd{h}. It brings you +to a programmed instruction sequence. + +@c Need to make sure that `Info-help' goes to the right node, +@c which is the first node of the first chapter. (It should.) +@c (Info-find-node "info" +@c (if (< (window-height) 23) +@c "Help-Small-Screen" +@c "Help"))) + +To learn advanced Info commands, type @kbd{n} twice. This brings you to +@cite{Info for Experts}, skipping over the `Getting Started' chapter. +@end ifinfo + +@menu +* Getting Started:: Getting started using an Info reader. +* Advanced Info:: Advanced commands within Info. +* Create an Info File:: How to make your own Info file. +* The Standalone Info Program: (info-stnd.info). +@end menu + +@node Getting Started, Advanced Info, Top, Top +@comment node-name, next, previous, up +@chapter Getting Started + +This first part of the Info manual describes how to get around inside +of Info. The second part of the manual describes various advanced +Info commands, and how to write an Info as distinct from a Texinfo +file. The third part is about how to generate Info files from +Texinfo files. + +@iftex +This manual is primarily designed for use on a computer, so that you can +try Info commands while reading about them. Reading it on paper is less +effective, since you must take it on faith that the commands described +really do what the manual says. By all means go through this manual now +that you have it; but please try going through the on-line version as +well. + +There are two ways of looking at the online version of this manual: + +@enumerate +@item +Type @code{info} at your shell's command line. This approach uses a +small stand-alone program designed just to read Info files. + +@item +Type @code{emacs} at the command line; then type @kbd{C-h i} (Control +@kbd{h}, followed by @kbd{i}). This approach uses the Info mode of the +Emacs program, an editor with many other capabilities. +@end enumerate + +In either case, then type @kbd{mInfo} (just the letters), followed by +@key{RET}---the ``Return'' or ``Enter'' key. At this point, you should +be ready to follow the instructions in this manual as you read them on +the screen. +@c FIXME! (pesch@cygnus.com, 14 dec 1992) +@c Is it worth worrying about what-if the beginner goes to somebody +@c else's Emacs session, which already has an Info running in the middle +@c of something---in which case these simple instructions won't work? +@end iftex + +@menu +* Help-Small-Screen:: Starting Info on a Small Screen +* Help:: How to use Info +* Help-P:: Returning to the Previous node +* Help-^L:: The Space, Rubout, B and ^L commands. +* Help-M:: Menus +* Help-Adv:: Some advanced Info commands +* Help-Q:: Quitting Info +@end menu + +@node Help-Small-Screen, Help, , Getting Started +@comment node-name, next, previous, up +@section Starting Info on a Small Screen + +@iftex +(In Info, you only see this section if your terminal has a small +number of lines; most readers pass by it without seeing it.) +@end iftex + +Since your terminal has an unusually small number of lines on its +screen, it is necessary to give you special advice at the beginning. + +If you see the text @samp{--All----} at near the bottom right corner +of the screen, it means the entire text you are looking at fits on the +screen. If you see @samp{--Top----} instead, it means that there is +more text below that does not fit. To move forward through the text +and see another screen full, press the Space bar, @key{SPC}. To move +back up, press the key labeled @samp{Backspace} or @key{Delete}. + +@ifinfo +Here are 40 lines of junk, so you can try Spaces and Deletes and +see what they do. At the end are instructions of what you should do +next. + +This is line 17 @* +This is line 18 @* +This is line 19 @* +This is line 20 @* +This is line 21 @* +This is line 22 @* +This is line 23 @* +This is line 24 @* +This is line 25 @* +This is line 26 @* +This is line 27 @* +This is line 28 @* +This is line 29 @* +This is line 30 @* +This is line 31 @* +This is line 32 @* +This is line 33 @* +This is line 34 @* +This is line 35 @* +This is line 36 @* +This is line 37 @* +This is line 38 @* +This is line 39 @* +This is line 40 @* +This is line 41 @* +This is line 42 @* +This is line 43 @* +This is line 44 @* +This is line 45 @* +This is line 46 @* +This is line 47 @* +This is line 48 @* +This is line 49 @* +This is line 50 @* +This is line 51 @* +This is line 52 @* +This is line 53 @* +This is line 54 @* +This is line 55 @* +This is line 56 @* + +If you have managed to get here, go back to the beginning with +Delete, and come back here again, then you understand Space and +Delete. So now type an @kbd{n} ---just one character; don't type +the quotes and don't type the Return key afterward--- to +get to the normal start of the course. +@end ifinfo + +@node Help, Help-P, Help-Small-Screen, Getting Started +@comment node-name, next, previous, up +@section How to use Info + +You are talking to the program Info, for reading documentation. + + Right now you are looking at one @dfn{Node} of Information. +A node contains text describing a specific topic at a specific +level of detail. This node's topic is ``how to use Info''. + + The top line of a node is its @dfn{header}. This node's header (look at +it now) says that it is the node named @samp{Help} in the file +@file{info}. It says that the @samp{Next} node after this one is the node +called @samp{Help-P}. An advanced Info command lets you go to any node +whose name you know. + + Besides a @samp{Next}, a node can have a @samp{Previous} or an @samp{Up}. +This node has a @samp{Previous} but no @samp{Up}, as you can see. + + Now it is time to move on to the @samp{Next} node, named @samp{Help-P}. + +>> Type @samp{n} to move there. Type just one character; + do not type the quotes and do not type a @key{RET} afterward. + +@samp{>>} in the margin means it is really time to try a command. + +@node Help-P, Help-^L, Help, Getting Started +@comment node-name, next, previous, up +@section Returning to the Previous node + +This node is called @samp{Help-P}. The @samp{Previous} node, as you see, +is @samp{Help}, which is the one you just came from using the @kbd{n} +command. Another @kbd{n} command now would take you to the next +node, @samp{Help-^L}. + +>> But do not do that yet. First, try the @kbd{p} command, which takes + you to the @samp{Previous} node. When you get there, you can do an + @kbd{n} again to return here. + + This all probably seems insultingly simple so far, but @emph{do not} be +led into skimming. Things will get more complicated soon. Also, +do not try a new command until you are told it is time to. Otherwise, +you may make Info skip past an important warning that was coming up. + +>> Now do an @kbd{n} to get to the node @samp{Help-^L} and learn more. + +@node Help-^L, Help-M, Help-P, Getting Started +@comment node-name, next, previous, up +@section The Space, Delete, B and ^L commands. + + This node's header tells you that you are now at node @samp{Help-^L}, and +that @kbd{p} would get you back to @samp{Help-P}. The node's title is +underlined; it says what the node is about (most nodes have titles). + + This is a big node and it does not all fit on your display screen. +You can tell that there is more that is not visible because you +can see the string @samp{--Top-----} rather than @samp{--All----} near +the bottom right corner of the screen. + + The Space, Delete and @kbd{B} commands exist to allow you to ``move +around'' in a node that does not all fit on the screen at once. +Space moves forward, to show what was below the bottom of the screen. +Delete moves backward, to show what was above the top of the screen +(there is not anything above the top until you have typed some spaces). + +>> Now try typing a Space (afterward, type a Delete to return here). + + When you type the space, the two lines that were at the bottom of +the screen appear at the top, followed by more lines. Delete takes +the two lines from the top and moves them to the bottom, +@emph{usually}, but if there are not a full screen's worth of lines +above them they may not make it all the way to the bottom. + + If you type Space when there is no more to see, it rings the +bell and otherwise does nothing. The same goes for Delete when +the header of the node is visible. + + If your screen is ever garbaged, you can tell Info to print it out +again by typing @kbd{C-l} (@kbd{Control-L}, that is---hold down ``Control'' and +type an @key{L} or @kbd{l}). + +>> Type @kbd{C-l} now. + + To move back to the beginning of the node you are on, you can type +a lot of Deletes. You can also type simply @kbd{b} for beginning. +>> Try that now. (We have put in enough verbiage to push this past +the first screenful, but screens are so big nowadays that perhaps it +isn't enough. You may need to shrink your Emacs or Info window.) +Then come back, with Spaces. + + If your screen is very tall, all of this node might fit at once. +In that case, "b" won't do anything. Sorry; what can we do? + + You have just learned a considerable number of commands. If you +want to use one but have trouble remembering which, you should type +a @key{?} which prints out a brief list of commands. When you are +finished looking at the list, make it go away by typing a @key{SPC}. + +>> Type a @key{?} now. After it finishes, type a @key{SPC}. + + (If you are using the standalone Info reader, type `l' to return here.) + + From now on, you will encounter large nodes without warning, and +will be expected to know how to use Space and Delete to move +around in them without being told. Since not all terminals have +the same size screen, it would be impossible to warn you anyway. + +>> Now type @kbd{n} to see the description of the @kbd{m} command. + +@node Help-M, Help-Adv, Help-^L, Getting Started +@comment node-name, next, previous, up +@section Menus + +Menus and the @kbd{m} command + + With only the @kbd{n} and @kbd{p} commands for moving between nodes, nodes +are restricted to a linear sequence. Menus allow a branching +structure. A menu is a list of other nodes you can move to. It is +actually just part of the text of the node formatted specially so that +Info can interpret it. The beginning of a menu is always identified +by a line which starts with @samp{* Menu:}. A node contains a menu if and +only if it has a line in it which starts that way. The only menu you +can use at any moment is the one in the node you are in. To use a +menu in any other node, you must move to that node first. + + After the start of the menu, each line that starts with a @samp{*} +identifies one subtopic. The line usually contains a brief name +for the subtopic (followed by a @samp{:}), the name of the node that talks +about that subtopic, and optionally some further description of the +subtopic. Lines in the menu that do not start with a @samp{*} have no +special meaning---they are only for the human reader's benefit and do +not define additional subtopics. Here is an example: + +@example +* Foo: FOO's Node This tells about FOO +@end example + +The subtopic name is Foo, and the node describing it is @samp{FOO's Node}. +The rest of the line is just for the reader's Information. +[[ But this line is not a real menu item, simply because there is +no line above it which starts with @samp{* Menu:}.]] + + When you use a menu to go to another node (in a way that will be +described soon), what you specify is the subtopic name, the first +thing in the menu line. Info uses it to find the menu line, extracts +the node name from it, and goes to that node. The reason that there +is both a subtopic name and a node name is that the node name must be +meaningful to the computer and may therefore have to be ugly looking. +The subtopic name can be chosen just to be convenient for the user to +specify. Often the node name is convenient for the user to specify +and so both it and the subtopic name are the same. There is an +abbreviation for this: + +@example +* Foo:: This tells about FOO +@end example + +@noindent +This means that the subtopic name and node name are the same; they are +both @samp{Foo}. + +>> Now use Spaces to find the menu in this node, then come back to + the front with a @kbd{b} and some Spaces. As you see, a menu is + actually visible in its node. If you cannot find a menu in a node + by looking at it, then the node does not have a menu and the + @kbd{m} command is not available. + + The command to go to one of the subnodes is @kbd{m}---but @emph{do +not do it yet!} Before you use @kbd{m}, you must understand the +difference between commands and arguments. So far, you have learned +several commands that do not need arguments. When you type one, Info +processes it and is instantly ready for another command. The @kbd{m} +command is different: it is incomplete without the @dfn{name of the +subtopic}. Once you have typed @kbd{m}, Info tries to read the +subtopic name. + + Now look for the line containing many dashes near the bottom of the +screen. There is one more line beneath that one, but usually it is +blank. If it is empty, Info is ready for a command, such as @kbd{n} +or @kbd{b} or Space or @kbd{m}. If that line contains text ending +in a colon, it mean Info is trying to read the @dfn{argument} to a +command. At such times, commands do not work, because Info tries to +use them as the argument. You must either type the argument and +finish the command you started, or type @kbd{Control-g} to cancel the +command. When you have done one of those things, the line becomes +blank again. + + The command to go to a subnode via a menu is @kbd{m}. After you type +the @kbd{m}, the line at the bottom of the screen says @samp{Menu item: }. +You must then type the name of the subtopic you want, and end it with +a @key{RET}. + + You can abbreviate the subtopic name. If the abbreviation is not +unique, the first matching subtopic is chosen. Some menus put +the shortest possible abbreviation for each subtopic name in capital +letters, so you can see how much you need to type. It does not +matter whether you use upper case or lower case when you type the +subtopic. You should not put any spaces at the end, or inside of the +item name, except for one space where a space appears in the item in +the menu. + + You can also use the @dfn{completion} feature to help enter the subtopic +name. If you type the Tab key after entering part of a name, it will +magically fill in more of the name---as much as follows uniquely from +what you have entered. + + If you move the cursor to one of the menu subtopic lines, then you do +not need to type the argument: you just type a Return, and it stands for +the subtopic of the line you are on. + +Here is a menu to give you a chance to practice. + +* Menu: The menu starts here. + +This menu gives you three ways of going to one place, Help-FOO. + +* Foo: Help-FOO. A node you can visit for fun.@* +* Bar: Help-FOO. Strange! two ways to get to the same place.@* +* Help-FOO:: And yet another!@* + + +>> Now type just an @kbd{m} and see what happens: + + Now you are ``inside'' an @kbd{m} command. Commands cannot be used +now; the next thing you will type must be the name of a subtopic. + + You can change your mind about doing the @kbd{m} by typing Control-g. + +>> Try that now; notice the bottom line clear. + +>> Then type another @kbd{m}. + +>> Now type @samp{BAR} item name. Do not type Return yet. + + While you are typing the item name, you can use the Delete key to +cancel one character at a time if you make a mistake. + +>> Type one to cancel the @samp{R}. You could type another @samp{R} to + replace it. You do not have to, since @samp{BA} is a valid abbreviation. + +>> Now you are ready to go. Type a @key{RET}. + + After visiting Help-FOO, you should return here. + +>> Type @kbd{n} to see more commands. + +@c If a menu appears at the end of this node, remove it. +@c It is an accident of the menu updating command. + +Here is another way to get to Help-FOO, a menu. You can ignore this +if you want, or else try it (but then please come back to here). + +@menu +* Help-FOO:: +@end menu + +@node Help-FOO, , , Help-M +@comment node-name, next, previous, up +@subsection The @kbd{u} command + + Congratulations! This is the node @samp{Help-FOO}. Unlike the other +nodes you have seen, this one has an @samp{Up}: @samp{Help-M}, the node you +just came from via the @kbd{m} command. This is the usual +convention---the nodes you reach from a menu have @samp{Up} nodes that lead +back to the menu. Menus move Down in the tree, and @samp{Up} moves Up. +@samp{Previous}, on the other hand, is usually used to ``stay on the same +level but go backwards'' + + You can go back to the node @samp{Help-M} by typing the command +@kbd{u} for ``Up''. That puts you at the @emph{front} of the +node---to get back to where you were reading you have to type +some @key{SPC}s. + +>> Now type @kbd{u} to move back up to @samp{Help-M}. + +@node Help-Adv, Help-Q, Help-M, Getting Started +@comment node-name, next, previous, up +@section Some advanced Info commands + + The course is almost over, so please stick with it to the end. + + If you have been moving around to different nodes and wish to +retrace your steps, the @kbd{l} command (@kbd{l} for @dfn{last}) will +do that, one node-step at a time. As you move from node to node, Info +records the nodes where you have been in a special history list. The +@kbd{l} command revisits nodes in the history list; each successive +@kbd{l} command moves one step back through the history. + + If you have been following directions, ad @kbd{l} command now will get +you back to @samp{Help-M}. Another @kbd{l} command would undo the +@kbd{u} and get you back to @samp{Help-FOO}. Another @kbd{l} would undo +the @kbd{m} and get you back to @samp{Help-M}. + +>> Try typing three @kbd{l}'s, pausing in between to see what each + @kbd{l} does. + +Then follow directions again and you will end up back here. + + Note the difference between @kbd{l} and @kbd{p}: @kbd{l} moves to +where @emph{you} last were, whereas @kbd{p} always moves to the node +which the header says is the @samp{Previous} node (from this node, to +@samp{Help-M}). + + The @samp{d} command gets you instantly to the Directory node. +This node, which is the first one you saw when you entered Info, +has a menu which leads (directly, or indirectly through other menus), +to all the nodes that exist. + +>> Try doing a @samp{d}, then do an @kbd{l} to return here (yes, + @emph{do} return). + + Sometimes, in Info documentation, you will see a cross reference. +Cross references look like this: @xref{Help-Cross, Cross}. That is a +real, live cross reference which is named @samp{Cross} and points at +the node named @samp{Help-Cross}. + + If you wish to follow a cross reference, you must use the @samp{f} +command. The @samp{f} must be followed by the cross reference name +(in this case, @samp{Cross}). While you enter the name, you can use the +Delete key to edit your input. If you change your mind about following +any reference, you can use @kbd{Control-g} to cancel the command. + + Completion is available in the @samp{f} command; you can complete among +all the cross reference names in the current node by typing a Tab. + +>> Type @samp{f}, followed by @samp{Cross}, and a @key{RET}. + + To get a list of all the cross references in the current node, you can +type @kbd{?} after an @samp{f}. The @samp{f} continues to await a +cross reference name even after printing the list, so if you don't +actually want to follow a reference, you should type a @kbd{Control-g} +to cancel the @samp{f}. + +>> Type "f?" to get a list of the cross references in this node. Then + type a @kbd{Control-g} and see how the @samp{f} gives up. + +>> Now type @kbd{n} to see the last node of the course. + +@c If a menu appears at the end of this node, remove it. +@c It is an accident of the menu updating command. + +@node Help-Cross, , , Help-Adv +@comment node-name, next, previous, up +@unnumberedsubsec The node reached by the cross reference in Info + + This is the node reached by the cross reference named @samp{Cross}. + + While this node is specifically intended to be reached by a cross +reference, most cross references lead to nodes that ``belong'' +someplace else far away in the structure of Info. So you cannot expect +the footnote to have a @samp{Next}, @samp{Previous} or @samp{Up} pointing back to +where you came from. In general, the @kbd{l} (el) command is the only +way to get back there. + +>> Type @kbd{l} to return to the node where the cross reference was. + +@node Help-Q, , Help-Adv, Getting Started +@comment node-name, next, previous, up +@section Quitting Info + + To get out of Info, back to what you were doing before, type @kbd{q} +for @dfn{Quit}. + + This is the end of the course on using Info. There are some other +commands that are meant for experienced users; they are useful, and you +can find them by looking in the directory node for documentation on +Info. Finding them will be a good exercise in using Info in the usual +manner. + +>> Type @samp{d} to go to the Info directory node; then type + @samp{mInfo} and Return, to get to the node about Info and + see what other help is available. + +@node Advanced Info, Create an Info File, Getting Started, Top +@comment node-name, next, previous, up +@chapter Info for Experts + +This chapter describes various advanced Info commands, and how to write +an Info as distinct from a Texinfo file. (However, in most cases, writing a +Texinfo file is better, since you can use it @emph{both} to generate an +Info file and to make a printed manual. @xref{Top,, Overview of +Texinfo, texinfo, Texinfo: The GNU Documentation Format}.) + +@menu +* Expert:: Advanced Info commands: g, s, e, and 1 - 5. +* Add:: Describes how to add new nodes to the hierarchy. + Also tells what nodes look like. +* Menus:: How to add to or create menus in Info nodes. +* Cross-refs:: How to add cross-references to Info nodes. +* Tags:: How to make tag tables for Info files. +* Checking:: Checking an Info File +* Emacs Info Variables:: Variables modifying the behavior of Emacs Info. +@end menu + +@node Expert, Add, , Advanced Info +@comment node-name, next, previous, up +@section Advanced Info Commands + +@kbd{g}, @kbd{s}, @kbd{1}, -- @kbd{9}, and @kbd{e} + +If you know a node's name, you can go there by typing @kbd{g}, the +name, and @key{RET}. Thus, @kbd{gTop@key{RET}} would go to the node +called @samp{Top} in this file (its directory node). +@kbd{gExpert@key{RET}} would come back here. + +Unlike @kbd{m}, @kbd{g} does not allow the use of abbreviations. + +To go to a node in another file, you can include the filename in the +node name by putting it at the front, in parentheses. Thus, +@kbd{g(dir)Top@key{RET}} would go to the Info Directory node, which is +node @samp{Top} in the file @file{dir}. + +The node name @samp{*} specifies the whole file. So you can look at +all of the current file by typing @kbd{g*@key{RET}} or all of any +other file with @kbd{g(FILENAME)@key{RET}}. + +The @kbd{s} command allows you to search a whole file for a string. +It switches to the next node if and when that is necessary. You +type @kbd{s} followed by the string to search for, terminated by +@key{RET}. To search for the same string again, just @kbd{s} followed +by @key{RET} will do. The file's nodes are scanned in the order +they are in in the file, which has no necessary relationship to the +order that they may be in in the tree structure of menus and @samp{next} pointers. +But normally the two orders are not very different. In any case, +you can always do a @kbd{b} to find out what node you have reached, if +the header is not visible (this can happen, because @kbd{s} puts your +cursor at the occurrence of the string, not at the beginning of the +node). + +If you grudge the system each character of type-in it requires, you +might like to use the commands @kbd{1}, @kbd{2}, @kbd{3}, @kbd{4}, ... +@kbd{9}. They are short for the @kbd{m} command together with an +argument. @kbd{1} goes through the first item in the current node's +menu; @kbd{2} goes through the second item, etc. + +If you display supports multiple fonts, and you are using Emacs' Info +mode to read Info files, the @samp{*} for the fifth menu item is +underlines, and so is the @samp{*} for the ninth item; these underlines +make it easy to see at a glance which number to use for an item. + +On ordinary terminals, you won't have underlining. If you need to +actually count items, it is better to use @kbd{m} instead, and specify +the name. + +The Info command @kbd{e} changes from Info mode to an ordinary +Emacs editing mode, so that you can edit the text of the current node. +Type @kbd{C-c C-c} to switch back to Info. The @kbd{e} command is allowed +only if the variable @code{Info-enable-edit} is non-@code{nil}. + +@node Add, Menus, Expert, Advanced Info +@comment node-name, next, previous, up +@section Adding a new node to Info + +To add a new topic to the list in the Info directory, you must: +@enumerate +@item +Create some nodes, in some file, to document that topic. +@item +Put that topic in the menu in the directory. @xref{Menus, Menu}. +@end enumerate + +Usually, the way to create the nodes is with Texinfo @pxref{Top,, Overview of +Texinfo, texinfo, Texinfo: The GNU Documentation Format}); this has the +advantage that you can also make a printed manual from them. However, +if hyou want to edit an Info file, here is how. + + The new node can live in an existing documentation file, or in a new +one. It must have a @key{^_} character before it (invisible to the +user; this node has one but you cannot see it), and it ends with either +a @key{^_}, a @key{^L}, or the end of file. Note: If you put in a +@key{^L} to end a new node, be sure that there is a @key{^_} after it +to start the next one, since @key{^L} cannot @emph{start} a node. +Also, a nicer way to make a node boundary be a page boundary as well +is to put a @key{^L} @emph{right after} the @key{^_}. + + The @key{^_} starting a node must be followed by a newline or a +@key{^L} newline, after which comes the node's header line. The +header line must give the node's name (by which Info finds it), +and state the names of the @samp{Next}, @samp{Previous}, and @samp{Up} nodes (if +there are any). As you can see, this node's @samp{Up} node is the node +@samp{Top}, which points at all the documentation for Info. The @samp{Next} +node is @samp{Menus}. + + The keywords @dfn{Node}, @dfn{Previous}, @dfn{Up}, and @dfn{Next}, +may appear in any order, anywhere in the header line, but the +recommended order is the one in this sentence. Each keyword must be +followed by a colon, spaces and tabs, and then the appropriate name. +The name may be terminated with a tab, a comma, or a newline. A space +does not end it; node names may contain spaces. The case of letters +in the names is insignificant. + + A node name has two forms. A node in the current file is named by +what appears after the @samp{Node: } in that node's first line. For +example, this node's name is @samp{Add}. A node in another file is +named by @samp{(@var{filename})@var{node-within-file}}, as in +@samp{(info)Add} for this node. If the file name starts with ``./'', +then it is relative to the current directory; otherwise, it is relative +starting from the standard Info file directory of your site. +The name @samp{(@var{filename})Top} can be abbreviated to just +@samp{(@var{filename})}. By convention, the name @samp{Top} is used for +the ``highest'' node in any single file---the node whose @samp{Up} points +out of the file. The Directory node is @file{(dir)}. The @samp{Top} node +of a document file listed in the Directory should have an @samp{Up: +(dir)} in it. + + The node name @kbd{*} is special: it refers to the entire file. +Thus, @kbd{g*} shows you the whole current file. The use of the +node @kbd{*} is to make it possible to make old-fashioned, +unstructured files into nodes of the tree. + + The @samp{Node:} name, in which a node states its own name, must not +contain a filename, since Info when searching for a node does not +expect one to be there. The @samp{Next}, @samp{Previous} and @samp{Up} names may +contain them. In this node, since the @samp{Up} node is in the same file, +it was not necessary to use one. + + Note that the nodes in this file have a file name in the header +line. The file names are ignored by Info, but they serve as comments +to help identify the node for the user. + +@node Menus, Cross-refs, Add, Advanced Info +@comment node-name, next, previous, up +@section How to Create Menus + + Any node in the Info hierarchy may have a @dfn{menu}---a list of subnodes. +The @kbd{m} command searches the current node's menu for the topic which it +reads from the terminal. + + A menu begins with a line starting with @samp{* Menu:}. The rest of the +line is a comment. After the starting line, every line that begins +with a @samp{* } lists a single topic. The name of the topic--the +argument that the user must give to the @kbd{m} command to select this +topic---comes right after the star and space, and is followed by a +colon, spaces and tabs, and the name of the node which discusses that +topic. The node name, like node names following @samp{Next}, @samp{Previous} +and @samp{Up}, may be terminated with a tab, comma, or newline; it may also +be terminated with a period. + + If the node name and topic name are the same, then rather than +giving the name twice, the abbreviation @samp{* NAME::} may be used +(and should be used, whenever possible, as it reduces the visual +clutter in the menu). + + It is considerate to choose the topic names so that they differ +from each other very near the beginning---this allows the user to type +short abbreviations. In a long menu, it is a good idea to capitalize +the beginning of each item name which is the minimum acceptable +abbreviation for it (a long menu is more than 5 or so entries). + + The nodes listed in a node's menu are called its ``subnodes'', and +it is their ``superior''. They should each have an @samp{Up:} pointing at +the superior. It is often useful to arrange all or most of the +subnodes in a sequence of @samp{Next} and @samp{Previous} pointers so that someone who +wants to see them all need not keep revisiting the Menu. + + The Info Directory is simply the menu of the node @samp{(dir)Top}---that +is, node @samp{Top} in file @file{.../info/dir}. You can put new entries +in that menu just like any other menu. The Info Directory is @emph{not} the +same as the file directory called @file{info}. It happens that many of +Info's files live on that file directory, but they do not have to; and +files on that directory are not automatically listed in the Info +Directory node. + + Also, although the Info node graph is claimed to be a ``hierarchy'', +in fact it can be @emph{any} directed graph. Shared structures and +pointer cycles are perfectly possible, and can be used if they are +appropriate to the meaning to be expressed. There is no need for all +the nodes in a file to form a connected structure. In fact, this file +has two connected components. You are in one of them, which is under +the node @samp{Top}; the other contains the node @samp{Help} which the +@kbd{h} command goes to. In fact, since there is no garbage +collector, nothing terrible happens if a substructure is not pointed +to, but such a substructure is rather useless since nobody can +ever find out that it exists. + +@node Cross-refs, Tags, Menus, Advanced Info +@comment node-name, next, previous, up +@section Creating Cross References + + A cross reference can be placed anywhere in the text, unlike a menu +item which must go at the front of a line. A cross reference looks +like a menu item except that it has @samp{*note} instead of @kbd{*}. +It @emph{cannot} be terminated by a @samp{)}, because @samp{)}'s are +so often part of node names. If you wish to enclose a cross reference +in parentheses, terminate it with a period first. Here are two +examples of cross references pointers: + +@example +*Note details: commands. (See *note 3: Full Proof.) +@end example + +They are just examples. The places they ``lead to'' do not really exist! + +@node Tags, Checking, Cross-refs, Advanced Info +@comment node-name, next, previous, up +@section Tag Tables for Info Files + + You can speed up the access to nodes of a large Info file by giving +it a tag table. Unlike the tag table for a program, the tag table for +an Info file lives inside the file itself and is used +automatically whenever Info reads in the file. + + To make a tag table, go to a node in the file using Emacs Info mode and type +@kbd{M-x Info-tagify}. Then you must use @kbd{C-x C-s} to save the +file. + + Once the Info file has a tag table, you must make certain it is up +to date. If, as a result of deletion of text, any node moves back +more than a thousand characters in the file from the position +recorded in the tag table, Info will no longer be able to find that +node. To update the tag table, use the @code{Info-tagify} command again. + + An Info file tag table appears at the end of the file and looks like +this: + +@example +^_ +Tag Table: +File: info, Node: Cross-refs^?21419 +File: info, Node: Tags^?22145 +^_ +End Tag Table +@end example + +@noindent +Note that it contains one line per node, and this line contains +the beginning of the node's header (ending just after the node name), +a Delete character, and the character position in the file of the +beginning of the node. + +@node Checking, Emacs Info Variables, Tags, Advanced Info +@comment node-name, next, previous, up +@section Checking an Info File + + When creating an Info file, it is easy to forget the name of a node +when you are making a pointer to it from another node. If you put in +the wrong name for a node, this is not detected until someone +tries to go through the pointer using Info. Verification of the Info +file is an automatic process which checks all pointers to nodes and +reports any pointers which are invalid. Every @samp{Next}, @samp{Previous}, and +@samp{Up} is checked, as is every menu item and every cross reference. In +addition, any @samp{Next} which does not have a @samp{Previous} pointing back is +reported. Only pointers within the file are checked, because checking +pointers to other files would be terribly slow. But those are usually +few. + + To check an Info file, do @kbd{M-x Info-validate} while looking at +any node of the file with Emacs Info mode. + +@node Emacs Info Variables, , Checking, Advanced Info +@section Emacs Info-mode Variables + +The following variables may modify the behaviour of Info-mode in Emacs; +you may wish to set one or several of these variables interactively, or +in your @file{~/.emacs} init file. @xref{Examining, Examining and Setting +Variables, Examining and Setting Variables, emacs, The GNU Emacs +Manual}. + +@vtable @code +@item Info-enable-edit +Set to @code{nil}, disables the @samp{e} (@code{Info-edit}) command. A +non-@code{nil} value enables it. @xref{Add, Edit}. + +@item Info-enable-active-nodes +When set to a non-@code{nil} value, allows Info to execute Lisp code +associated with nodes. The Lisp code is executed when the node is +selected. + +@item Info-directory-list +The list of directories to search for Info files. Each element is a +string (directory name) or @code{nil} (try default directory). + +@item Info-directory +The standard directory for Info documentation files. Only used when the +function @code{Info-directory} is called. +@end vtable + +@node Create an Info File, , Advanced Info, Top +@comment node-name, next, previous, up +@chapter Creating an Info File from a Makeinfo file + +@code{makeinfo} is a utility that converts a Texinfo file into an Info +file; @code{texinfo-format-region} and @code{texinfo-format-buffer} are +GNU Emacs functions that do the same. + +@xref{Create an Info File, , Creating an Info File, texinfo, the Texinfo +Manual}, to learn how to create an Info file from a Texinfo file. + +@xref{Top,, Overview of Texinfo, texinfo, Texinfo: The GNU Documentation +Format}, to learn how to write a Texinfo file. + +@bye diff --git a/texinfo/info/infodoc.c b/texinfo/info/infodoc.c new file mode 100644 index 000000000000..35675095e70c --- /dev/null +++ b/texinfo/info/infodoc.c @@ -0,0 +1,771 @@ +/* infodoc.c -- Functions which build documentation nodes. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" + +/* Normally we do not define HELP_NODE_GETS_REGENERATED because the + contents of the help node currently can never change once an info + session has been started. You should consider defining this in + the case that you place information about dynamic variables in the + help text. When that happens, the contents of the help node will + change dependent on the value of those variables, and the user will + expect to see those changes. */ +/* #define HELP_NODE_GETS_REGENERATED 1 */ + +/* **************************************************************** */ +/* */ +/* Info Help Windows */ +/* */ +/* **************************************************************** */ + +/* The name of the node used in the help window. */ +static char *info_help_nodename = "*Info Help*"; + +/* A node containing printed key bindings and their documentation. */ +static NODE *internal_info_help_node = (NODE *)NULL; + +/* A pointer to the contents of the help node. */ +static char *internal_info_help_node_contents = (char *)NULL; + +/* The static text which appears in the internal info help node. */ +static char *info_internal_help_text[] = { + "Basic Commands in Info Windows", + "******************************", + "", + " h Invoke the Info tutorial.", + "", + "Selecting other nodes:", + "----------------------", + " n Move to the \"next\" node of this node.", + " p Move to the \"previous\" node of this node.", + " u Move \"up\" from this node.", + " m Pick menu item specified by name.", + " Picking a menu item causes another node to be selected.", + " f Follow a cross reference. Reads name of reference.", + " l Move to the last node seen in this window.", + " d Move to the `directory' node. Equivalent to `g(DIR)'.", + "", + "Moving within a node:", + "---------------------", + " SPC Scroll forward a page.", + " DEL Scroll backward a page.", + " b Go to the beginning of this node.", + " e Go to the end of this node.", + "", + "\"Advanced\" commands:", + "--------------------", + " q Quit Info.", + " 1 Pick first item in node's menu.", + " 2-9 Pick second ... ninth item in node's menu.", + " 0 Pick last item in node's menu.", + " g Move to node specified by name.", + " You may include a filename as well, as in (FILENAME)NODENAME.", + " s Search through this Info file for a specified string,", + " and select the node in which the next occurrence is found.", + (char *)NULL +}; + +static char *where_is (), *where_is_internal (); + +void +dump_map_to_message_buffer (prefix, map) + char *prefix; + Keymap map; +{ + register int i; + + for (i = 0; i < 256; i++) + { + if (map[i].type == ISKMAP) + { + char *new_prefix, *keyname; + + keyname = pretty_keyname (i); + new_prefix = (char *) + xmalloc (3 + strlen (prefix) + strlen (keyname)); + sprintf (new_prefix, "%s%s%s ", prefix, *prefix ? " " : "", keyname); + + dump_map_to_message_buffer (new_prefix, (Keymap)map[i].function); + free (new_prefix); + } + else if (map[i].function) + { + register int last; + char *doc, *name; + + doc = function_documentation (map[i].function); + name = function_name (map[i].function); + + if (!*doc) + continue; + + /* Find out if there is a series of identical functions, as in + ea_insert (). */ + for (last = i + 1; last < 256; last++) + if ((map[last].type != ISFUNC) || + (map[last].function != map[i].function)) + break; + + if (last - 1 != i) + { + printf_to_message_buffer + ("%s%s .. ", prefix, pretty_keyname (i)); + printf_to_message_buffer + ("%s%s\t", prefix, pretty_keyname (last - 1)); + i = last - 1; + } + else + printf_to_message_buffer ("%s%s\t", prefix, pretty_keyname (i)); + +#if defined (NAMED_FUNCTIONS) + /* Print the name of the function, and some padding before the + documentation string is printed. */ + { + int length_so_far; + int desired_doc_start = 40; /* Must be multiple of 8. */ + + printf_to_message_buffer ("(%s)", name); + length_so_far = message_buffer_length_this_line (); + + if ((desired_doc_start + strlen (doc)) >= the_screen->width) + printf_to_message_buffer ("\n "); + else + { + while (length_so_far < desired_doc_start) + { + printf_to_message_buffer ("\t"); + length_so_far += character_width ('\t', length_so_far); + } + } + } +#endif /* NAMED_FUNCTIONS */ + printf_to_message_buffer ("%s\n", doc); + } + } +} + +/* How to create internal_info_help_node. */ +static void +create_internal_info_help_node () +{ + register int i; + char *contents = (char *)NULL; + NODE *node; + +#if !defined (HELP_NODE_GETS_REGENERATED) + if (internal_info_help_node_contents) + contents = internal_info_help_node_contents; +#endif /* !HELP_NODE_GETS_REGENERATED */ + + if (!contents) + { + int printed_one_mx = 0; + + initialize_message_buffer (); + + for (i = 0; info_internal_help_text[i]; i++) + printf_to_message_buffer ("%s\n", info_internal_help_text[i]); + + printf_to_message_buffer ("---------------------\n\n"); + printf_to_message_buffer ("The current search path is:\n"); + printf_to_message_buffer (" \"%s\"\n", infopath); + printf_to_message_buffer ("---------------------\n\n"); + printf_to_message_buffer ("Commands available in Info windows:\n\n"); + dump_map_to_message_buffer ("", info_keymap); + printf_to_message_buffer ("---------------------\n\n"); + printf_to_message_buffer ("Commands available in the echo area:\n\n"); + dump_map_to_message_buffer ("", echo_area_keymap); + +#if defined (NAMED_FUNCTIONS) + /* Get a list of the M-x commands which have no keystroke equivs. */ + for (i = 0; function_doc_array[i].func; i++) + { + VFunction *func = function_doc_array[i].func; + + if ((!where_is_internal (info_keymap, func)) && + (!where_is_internal (echo_area_keymap, func))) + { + if (!printed_one_mx) + { + printf_to_message_buffer ("---------------------\n\n"); + printf_to_message_buffer + ("The following commands can only be invoked via M-x:\n\n"); + printed_one_mx = 1; + } + + printf_to_message_buffer + ("M-x %s\n %s\n", + function_doc_array[i].func_name, + replace_in_documentation (function_doc_array[i].doc)); + } + } + + if (printed_one_mx) + printf_to_message_buffer ("\n"); +#endif /* NAMED_FUNCTIONS */ + + printf_to_message_buffer + ("%s", replace_in_documentation + ("--- Use `\\[history-node]' or `\\[kill-node]' to exit ---\n")); + node = message_buffer_to_node (); + internal_info_help_node_contents = node->contents; + } + else + { + /* We already had the right contents, so simply use them. */ + node = build_message_node ("", 0, 0); + free (node->contents); + node->contents = contents; + node->nodelen = 1 + strlen (contents); + } + + internal_info_help_node = node; + + /* Do not GC this node's contents. It never changes, and we never need + to delete it once it is made. If you change some things (such as + placing information about dynamic variables in the help text) then + you will need to allow the contents to be gc'd, and you will have to + arrange to always regenerate the help node. */ +#if defined (HELP_NODE_GETS_REGENERATED) + add_gcable_pointer (internal_info_help_node->contents); +#endif + + name_internal_node (internal_info_help_node, info_help_nodename); + + /* Even though this is an internal node, we don't want the window + system to treat it specially. So we turn off the internalness + of it here. */ + internal_info_help_node->flags &= ~N_IsInternal; +} + +/* Return a window which is the window showing help in this Info. */ +static WINDOW * +info_find_or_create_help_window () +{ + WINDOW *help_window, *eligible, *window; + + eligible = (WINDOW *)NULL; + help_window = get_internal_info_window (info_help_nodename); + + /* If we couldn't find the help window, then make it. */ + if (!help_window) + { + int max = 0; + + for (window = windows; window; window = window->next) + { + if (window->height > max) + { + max = window->height; + eligible = window; + } + } + + if (!eligible) + return ((WINDOW *)NULL); + } +#if !defined (HELP_NODE_GETS_REGENERATED) + else + return (help_window); +#endif /* !HELP_NODE_GETS_REGENERATED */ + + /* Make sure that we have a node containing the help text. */ + create_internal_info_help_node (); + + /* Either use the existing window to display the help node, or create + a new window if there was no existing help window. */ + if (!help_window) + { + /* Split the largest window into 2 windows, and show the help text + in that window. */ + if (eligible->height > 30) + { + active_window = eligible; + help_window = window_make_window (internal_info_help_node); + } + else + { + set_remembered_pagetop_and_point (active_window); + window_set_node_of_window (active_window, internal_info_help_node); + help_window = active_window; + } + } + else + { + /* Case where help node always gets regenerated, and we have an + existing window in which to place the node. */ + if (active_window != help_window) + { + set_remembered_pagetop_and_point (active_window); + active_window = help_window; + } + window_set_node_of_window (active_window, internal_info_help_node); + } + remember_window_and_node (help_window, help_window->node); + return (help_window); +} + +/* Create or move to the help window. */ +DECLARE_INFO_COMMAND (info_get_help_window, "Display help message") +{ + WINDOW *help_window; + + help_window = info_find_or_create_help_window (); + if (help_window) + { + active_window = help_window; + active_window->flags |= W_UpdateWindow; + } + else + { + info_error (CANT_MAKE_HELP); + } +} + +/* Show the Info help node. This means that the "info" file is installed + where it can easily be found on your system. */ +DECLARE_INFO_COMMAND (info_get_info_help_node, "Visit Info node `(info)Help'") +{ + NODE *node; + char *nodename; + + /* If there is a window on the screen showing the node "(info)Help" or + the node "(info)Help-Small-Screen", simply select that window. */ + { + WINDOW *win; + + for (win = windows; win; win = win->next) + { + if (win->node && win->node->filename && + (strcasecmp + (filename_non_directory (win->node->filename), "info") == 0) && + ((strcmp (win->node->nodename, "Help") == 0) || + (strcmp (win->node->nodename, "Help-Small-Screen") == 0))) + { + active_window = win; + return; + } + } + } + + /* If the current window is small, show the small screen help. */ + if (active_window->height < 24) + nodename = "Help-Small-Screen"; + else + nodename = "Help"; + + /* Try to get the info file for Info. */ + node = info_get_node ("Info", nodename); + + if (!node) + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error (CANT_FILE_NODE, "Info", nodename); + } + else + { + /* If the current window is very large (greater than 45 lines), + then split it and show the help node in another window. + Otherwise, use the current window. */ + + if (active_window->height > 45) + active_window = window_make_window (node); + else + { + set_remembered_pagetop_and_point (active_window); + window_set_node_of_window (active_window, node); + } + + remember_window_and_node (active_window, node); + } +} + +/* **************************************************************** */ +/* */ +/* Groveling Info Keymaps and Docs */ +/* */ +/* **************************************************************** */ + +/* Return the documentation associated with the Info command FUNCTION. */ +char * +function_documentation (function) + VFunction *function; +{ + register int i; + + for (i = 0; function_doc_array[i].func; i++) + if (function == function_doc_array[i].func) + break; + + return (replace_in_documentation (function_doc_array[i].doc)); +} + +#if defined (NAMED_FUNCTIONS) +/* Return the user-visible name of the function associated with the + Info command FUNCTION. */ +char * +function_name (function) + + VFunction *function; +{ + register int i; + + for (i = 0; function_doc_array[i].func; i++) + if (function == function_doc_array[i].func) + break; + + return (function_doc_array[i].func_name); +} + +/* Return a pointer to the function named NAME. */ +VFunction * +named_function (name) + char *name; +{ + register int i; + + for (i = 0; function_doc_array[i].func; i++) + if (strcmp (function_doc_array[i].func_name, name) == 0) + break; + + return (function_doc_array[i].func); +} +#endif /* NAMED_FUNCTIONS */ + +/* Return the documentation associated with KEY in MAP. */ +char * +key_documentation (key, map) + char key; + Keymap map; +{ + VFunction *function = map[key].function; + + if (function) + return (function_documentation (function)); + else + return ((char *)NULL); +} + +DECLARE_INFO_COMMAND (describe_key, "Print documentation for KEY") +{ + char keyname[50]; + int keyname_index = 0; + unsigned char keystroke; + char *rep; + Keymap map; + + keyname[0] = '\0'; + map = window->keymap; + + while (1) + { + message_in_echo_area ("Describe key: %s", keyname); + keystroke = info_get_input_char (); + unmessage_in_echo_area (); + + if (Meta_p (keystroke) && (!ISO_Latin_p || key < 160)) + { + if (map[ESC].type != ISKMAP) + { + window_message_in_echo_area + ("ESC %s is undefined.", pretty_keyname (UnMeta (keystroke))); + return; + } + + strcpy (keyname + keyname_index, "ESC "); + keyname_index = strlen (keyname); + keystroke = UnMeta (keystroke); + map = (Keymap)map[ESC].function; + } + + /* Add the printed representation of KEYSTROKE to our keyname. */ + rep = pretty_keyname (keystroke); + strcpy (keyname + keyname_index, rep); + keyname_index = strlen (keyname); + + if (map[keystroke].function == (VFunction *)NULL) + { + message_in_echo_area ("%s is undefined.", keyname); + return; + } + else if (map[keystroke].type == ISKMAP) + { + map = (Keymap)map[keystroke].function; + strcat (keyname, " "); + keyname_index = strlen (keyname); + continue; + } + else + { + char *message, *fundoc, *funname = ""; + +#if defined (NAMED_FUNCTIONS) + funname = function_name (map[keystroke].function); +#endif /* NAMED_FUNCTIONS */ + + fundoc = function_documentation (map[keystroke].function); + + message = (char *)xmalloc + (10 + strlen (keyname) + strlen (fundoc) + strlen (funname)); + +#if defined (NAMED_FUNCTIONS) + sprintf (message, "%s (%s): %s.", keyname, funname, fundoc); +#else + sprintf (message, "%s is defined to %s.", keyname, fundoc); +#endif /* !NAMED_FUNCTIONS */ + + window_message_in_echo_area ("%s", message); + free (message); + break; + } + } +} + +/* How to get the pretty printable name of a character. */ +static char rep_buffer[30]; + +char * +pretty_keyname (key) + unsigned char key; +{ + char *rep; + + if (Meta_p (key)) + { + char temp[20]; + + rep = pretty_keyname (UnMeta (key)); + + sprintf (temp, "ESC %s", rep); + strcpy (rep_buffer, temp); + rep = rep_buffer; + } + else if (Control_p (key)) + { + switch (key) + { + case '\n': rep = "LFD"; break; + case '\t': rep = "TAB"; break; + case '\r': rep = "RET"; break; + case ESC: rep = "ESC"; break; + + default: + sprintf (rep_buffer, "C-%c", UnControl (key)); + rep = rep_buffer; + } + } + else + { + switch (key) + { + case ' ': rep = "SPC"; break; + case DEL: rep = "DEL"; break; + default: + rep_buffer[0] = key; + rep_buffer[1] = '\0'; + rep = rep_buffer; + } + } + return (rep); +} + +/* Replace the names of functions with the key that invokes them. */ +char * +replace_in_documentation (string) + char *string; +{ + register int i, start, next; + static char *result = (char *)NULL; + + maybe_free (result); + result = (char *)xmalloc (1 + strlen (string)); + + i = next = start = 0; + + /* Skip to the beginning of a replaceable function. */ + for (i = start; string[i]; i++) + { + /* Is this the start of a replaceable function name? */ + if (string[i] == '\\' && string[i + 1] == '[') + { + char *fun_name, *rep; + VFunction *function; + + /* Copy in the old text. */ + strncpy (result + next, string + start, i - start); + next += (i - start); + start = i + 2; + + /* Move to the end of the function name. */ + for (i = start; string[i] && (string[i] != ']'); i++); + + fun_name = (char *)xmalloc (1 + i - start); + strncpy (fun_name, string + start, i - start); + fun_name[i - start] = '\0'; + + /* Find a key which invokes this function in the info_keymap. */ + function = named_function (fun_name); + + /* If the internal documentation string fails, there is a + serious problem with the associated command's documentation. + We croak so that it can be fixed immediately. */ + if (!function) + abort (); + + rep = where_is (info_keymap, function); + strcpy (result + next, rep); + next = strlen (result); + + start = i; + if (string[i]) + start++; + } + } + strcpy (result + next, string + start); + return (result); +} + +/* Return a string of characters which could be typed from the keymap + MAP to invoke FUNCTION. */ +static char *where_is_rep = (char *)NULL; +static int where_is_rep_index = 0; +static int where_is_rep_size = 0; + +static char * +where_is (map, function) + Keymap map; + VFunction *function; +{ + char *rep; + + if (!where_is_rep_size) + where_is_rep = (char *)xmalloc (where_is_rep_size = 100); + where_is_rep_index = 0; + + rep = where_is_internal (map, function); + + /* If it couldn't be found, return "M-x Foo". */ + if (!rep) + { + char *name; + + name = function_name (function); + + if (name) + sprintf (where_is_rep, "M-x %s", name); + + rep = where_is_rep; + } + return (rep); +} + +/* Return the printed rep of FUNCTION as found in MAP, or NULL. */ +static char * +where_is_internal (map, function) + Keymap map; + VFunction *function; +{ + register int i; + + /* If the function is directly invokable in MAP, return the representation + of that keystroke. */ + for (i = 0; i < 256; i++) + if ((map[i].type == ISFUNC) && map[i].function == function) + { + sprintf (where_is_rep + where_is_rep_index, "%s", pretty_keyname (i)); + return (where_is_rep); + } + + /* Okay, search subsequent maps for this function. */ + for (i = 0; i < 256; i++) + { + if (map[i].type == ISKMAP) + { + int saved_index = where_is_rep_index; + char *rep; + + sprintf (where_is_rep + where_is_rep_index, "%s ", + pretty_keyname (i)); + + where_is_rep_index = strlen (where_is_rep); + rep = where_is_internal ((Keymap)map[i].function, function); + + if (rep) + return (where_is_rep); + + where_is_rep_index = saved_index; + } + } + + return ((char *)NULL); +} + +extern char *read_function_name (); + +DECLARE_INFO_COMMAND (info_where_is, + "Show what to type to execute a given command") +{ + char *command_name; + + command_name = read_function_name ("Where is command: ", window); + + if (!command_name) + { + info_abort_key (active_window, count, key); + return; + } + + if (*command_name) + { + VFunction *function; + + function = named_function (command_name); + + if (function) + { + char *location; + + location = where_is (active_window->keymap, function); + + if (!location) + { + info_error ("`%s' is not on any keys", command_name); + } + else + { + if (strncmp (location, "M-x ", 4) == 0) + window_message_in_echo_area + ("%s can only be invoked via %s.", command_name, location); + else + window_message_in_echo_area + ("%s can be invoked via %s.", command_name, location); + } + } + else + info_error ("There is no function named `%s'", command_name); + } + + free (command_name); +} diff --git a/texinfo/info/infomap.c b/texinfo/info/infomap.c new file mode 100644 index 000000000000..3f24f1f55d56 --- /dev/null +++ b/texinfo/info/infomap.c @@ -0,0 +1,274 @@ +/* infomap.c -- Keymaps for Info. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "stdio.h" +#include "ctype.h" +#include "infomap.h" +#include "funs.h" + +/* Return a new keymap which has all the uppercase letters mapped to run + the function info_do_lowercase_version (). */ +Keymap +keymap_make_keymap () +{ + register int i; + Keymap keymap; + + keymap = (Keymap)xmalloc (256 * sizeof (KEYMAP_ENTRY)); + + for (i = 0; i < 256; i++) + { + keymap[i].type = ISFUNC; + keymap[i].function = (VFunction *)NULL; + } + + for (i = 'A'; i < ('Z' + 1); i++) + { + keymap[i].type = ISFUNC; + keymap[i].function = info_do_lowercase_version; + } + + return (keymap); +} + +/* Return a new keymap which is a copy of MAP. */ +Keymap +keymap_copy_keymap (map) + Keymap map; +{ + register int i; + Keymap keymap; + + keymap = keymap_make_keymap (); + + for (i = 0; i < 256; i++) + { + keymap[i].type = map[i].type; + keymap[i].function = map[i].function; + } + return (keymap); +} + +/* Free the keymap and it's descendents. */ +void +keymap_discard_keymap (map) + Keymap (map); +{ + register int i; + + if (!map) + return; + + for (i = 0; i < 256; i++) + { + switch (map[i].type) + { + case ISFUNC: + break; + + case ISKMAP: + keymap_discard_keymap ((Keymap)map[i].function); + break; + + } + } +} + +/* Initialize the standard info keymaps. */ + +Keymap info_keymap = (Keymap)NULL; +Keymap echo_area_keymap = (Keymap)NULL; + +void +initialize_info_keymaps () +{ + register int i; + Keymap map; + + if (!info_keymap) + { + info_keymap = keymap_make_keymap (); + info_keymap[ESC].type = ISKMAP; + info_keymap[ESC].function = (VFunction *)keymap_make_keymap (); + info_keymap[Control ('x')].type = ISKMAP; + info_keymap[Control ('x')].function = (VFunction *)keymap_make_keymap (); + echo_area_keymap = keymap_make_keymap (); + echo_area_keymap[ESC].type = ISKMAP; + echo_area_keymap[ESC].function = (VFunction *)keymap_make_keymap (); + echo_area_keymap[Control ('x')].type = ISKMAP; + echo_area_keymap[Control ('x')].function = + (VFunction *)keymap_make_keymap (); + } + + /* Bind numeric arg functions for both echo area and info window maps. */ + for (i = '0'; i < '9' + 1; i++) + { + ((Keymap) info_keymap[ESC].function)[i].function = + ((Keymap) echo_area_keymap[ESC].function)[i].function = + info_add_digit_to_numeric_arg; + } + ((Keymap) info_keymap[ESC].function)['-'].function = + ((Keymap) echo_area_keymap[ESC].function)['-'].function = + info_add_digit_to_numeric_arg; + + /* Bind the echo area routines. */ + map = echo_area_keymap; + + /* Bind the echo area insert routines. */ + for (i = 0; i < 160; i++) + if (isprint (i)) + map[i].function = ea_insert; + + map[Control ('a')].function = ea_beg_of_line; + map[Control ('b')].function = ea_backward; + map[Control ('d')].function = ea_delete; + map[Control ('e')].function = ea_end_of_line; + map[Control ('f')].function = ea_forward; + map[Control ('g')].function = ea_abort; + map[Control ('h')].function = ea_rubout; + map[Control ('k')].function = ea_kill_line; + map[Control ('l')].function = info_redraw_display; + map[Control ('q')].function = ea_quoted_insert; + map[Control ('t')].function = ea_transpose_chars; + map[Control ('u')].function = info_universal_argument; + map[Control ('y')].function = ea_yank; + + map[LFD].function = ea_newline; + map[RET].function = ea_newline; + map[SPC].function = ea_complete; + map[TAB].function = ea_complete; + map['?'].function = ea_possible_completions; + map[DEL].function = ea_rubout; + + /* Bind the echo area ESC keymap. */ + map = (Keymap)echo_area_keymap[ESC].function; + + map[Control ('g')].function = ea_abort; + map[Control ('v')].function = ea_scroll_completions_window; + map['b'].function = ea_backward_word; + map['d'].function = ea_kill_word; + map['f'].function = ea_forward_word; +#if defined (NAMED_FUNCTIONS) + /* map['x'].function = info_execute_command; */ +#endif /* NAMED_FUNCTIONS */ + map['y'].function = ea_yank_pop; + map['?'].function = ea_possible_completions; + map[TAB].function = ea_tab_insert; + map[DEL].function = ea_backward_kill_word; + + /* Bind the echo area Control-x keymap. */ + map = (Keymap)echo_area_keymap[Control ('x')].function; + + map['o'].function = info_next_window; + map[DEL].function = ea_backward_kill_line; + + /* Bind commands for Info window keymaps. */ + map = info_keymap; + map[TAB].function = info_move_to_next_xref; + map[LFD].function = info_select_reference_this_line; + map[RET].function = info_select_reference_this_line; + map[SPC].function = info_scroll_forward; + map[Control ('a')].function = info_beginning_of_line; + map[Control ('b')].function = info_backward_char; + map[Control ('e')].function = info_end_of_line; + map[Control ('f')].function = info_forward_char; + map[Control ('g')].function = info_abort_key; + map[Control ('h')].function = info_get_help_window; + map[Control ('l')].function = info_redraw_display; + map[Control ('n')].function = info_next_line; + map[Control ('p')].function = info_prev_line; + map[Control ('r')].function = isearch_backward; + map[Control ('s')].function = isearch_forward; + map[Control ('u')].function = info_universal_argument; + map[Control ('v')].function = info_scroll_forward; + map[','].function = info_next_index_match; + + for (i = '1'; i < '9' + 1; i++) + map[i].function = info_menu_digit; + map['0'].function = info_last_menu_item; + + map['<'].function = info_first_node; + map['>'].function = info_last_node; + map['?'].function = info_get_help_window; + map['['].function = info_global_prev_node; + map[']'].function = info_global_next_node; + + map['b'].function = info_beginning_of_node; + map['d'].function = info_dir_node; + map['e'].function = info_end_of_node; + map['f'].function = info_xref_item; + map['g'].function = info_goto_node; + map['h'].function = info_get_info_help_node; + map['i'].function = info_index_search; + map['l'].function = info_history_node; + map['m'].function = info_menu_item; + map['n'].function = info_next_node; + map['p'].function = info_prev_node; + map['q'].function = info_quit; + map['r'].function = info_xref_item; + map['s'].function = info_search; + map['t'].function = info_top_node; + map['u'].function = info_up_node; + map[DEL].function = info_scroll_backward; + + /* Bind members in the ESC map for Info windows. */ + map = (Keymap)info_keymap[ESC].function; + map[Control ('f')].function = info_show_footnotes; + map[Control ('g')].function = info_abort_key; + map[TAB].function = info_move_to_prev_xref; + map[Control ('v')].function = info_scroll_other_window; + map['<'].function = info_beginning_of_node; + map['>'].function = info_end_of_node; + map['b'].function = info_backward_word; + map['f'].function = info_forward_word; + map['r'].function = info_move_to_window_line; + map['v'].function = info_scroll_backward; +#if defined (NAMED_FUNCTIONS) + map['x'].function = info_execute_command; +#endif /* NAMED_FUNCTIONS */ + + /* Bind members in the Control-X map for Info windows. */ + map = (Keymap)info_keymap[Control ('x')].function; + + map[Control ('b')].function = list_visited_nodes; + map[Control ('c')].function = info_quit; + map[Control ('f')].function = info_view_file; + map[Control ('g')].function = info_abort_key; + map[Control ('v')].function = info_view_file; + map['0'].function = info_delete_window; + map['1'].function = info_keep_one_window; + map['2'].function = info_split_window; + map['^'].function = info_grow_window; + map['b'].function = select_visited_node; + map['k'].function = info_kill_node; + map['o'].function = info_next_window; + map['t'].function = info_tile_windows; + map['w'].function = info_toggle_wrap; +} + +/* Strings which represent the sequence of characters that the arrow keys + produce. If these keys begin with ESC, and the second character of the + sequence does not conflict with an existing binding in the Meta keymap, + then bind the keys to do what C-p, C-n, C-f, and C-b do. */ +extern char *term_ku, *term_kd, *term_kr, *term_kl; + diff --git a/texinfo/info/infomap.h b/texinfo/info/infomap.h new file mode 100644 index 000000000000..faf93884fd58 --- /dev/null +++ b/texinfo/info/infomap.h @@ -0,0 +1,82 @@ +/* infomap.h -- Description of a keymap in Info and related functions. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_INFOMAP_H_) +#define _INFOMAP_H_ + +#include "general.h" + +#define ESC '\033' +#define DEL '\177' +#define TAB '\011' +#define RET '\r' +#define LFD '\n' +#define SPC ' ' + +#define meta_character_threshold (DEL + 1) +#define control_character_threshold (SPC) + +#define meta_character_bit 0x80 +#define control_character_bit 0x40 + +#define Meta_p(c) (((c) > meta_character_threshold)) +#define Control_p(c) ((c) < control_character_threshold) + +#define Meta(c) ((c) | (meta_character_bit)) +#define UnMeta(c) ((c) & (~meta_character_bit)) +#define Control(c) ((toupper (c)) & (~control_character_bit)) +#define UnControl(c) (tolower ((c) | control_character_bit)) + +/* A keymap contains one entry for each key in the ASCII set. + Each entry consists of a type and a pointer. + FUNCTION is the address of a function to run, or the + address of a keymap to indirect through. + TYPE says which kind of thing FUNCTION is. */ +typedef struct { + char type; + VFunction *function; +} KEYMAP_ENTRY; + +typedef KEYMAP_ENTRY *Keymap; + +/* The values that TYPE can have in a keymap entry. */ +#define ISFUNC 0 +#define ISKMAP 1 + +extern Keymap info_keymap; +extern Keymap echo_area_keymap; + +/* Return a new keymap which has all the uppercase letters mapped to run + the function info_do_lowercase_version (). */ +extern Keymap keymap_make_keymap (); + +/* Return a new keymap which is a copy of MAP. */ +extern Keymap keymap_copy_keymap (); + +/* Free MAP and it's descendents. */ +extern void keymap_discard_keymap (); + +/* Initialize the info keymaps. */ +extern void initialize_info_keymaps (); + +#endif /* !_INFOMAP_H_ */ diff --git a/texinfo/info/m-x.c b/texinfo/info/m-x.c new file mode 100644 index 000000000000..03ac1a522326 --- /dev/null +++ b/texinfo/info/m-x.c @@ -0,0 +1,195 @@ +/* m-x.c -- Meta-X minibuffer reader. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" + +/* **************************************************************** */ +/* */ +/* Reading Named Commands */ +/* */ +/* **************************************************************** */ + +/* Read the name of an Info function in the echo area and return the + name. A return value of NULL indicates that no function name could + be read. */ +char * +read_function_name (prompt, window) + char *prompt; + WINDOW *window; +{ + register int i; + char *line; + REFERENCE **array = (REFERENCE **)NULL; + int array_index = 0, array_slots = 0; + + /* Make an array of REFERENCE which actually contains the names of + the functions available in Info. */ + for (i = 0; function_doc_array[i].func; i++) + { + REFERENCE *entry; + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->label = strdup (function_doc_array[i].func_name); + entry->nodename = (char *)NULL; + entry->filename = (char *)NULL; + + add_pointer_to_array + (entry, array_index, array, array_slots, 200, REFERENCE *); + } + + line = info_read_completing_in_echo_area (window, prompt, array); + + info_free_references (array); + + if (!echo_area_is_active) + window_clear_echo_area (); + + return (line); +} + +DECLARE_INFO_COMMAND (describe_command, + "Read the name of an Info command and describe it") +{ + char *line; + + line = read_function_name ("Describe command: ", window); + + if (!line) + { + info_abort_key (active_window, count, key); + return; + } + + /* Describe the function named in "LINE". */ + if (*line) + { + char *fundoc; + VFunction *fun; + + fun = named_function (line); + + if (!fun) + return; + + window_message_in_echo_area ("%s: %s.", + line, function_documentation (fun)); + } + free (line); +} + +DECLARE_INFO_COMMAND (info_execute_command, + "Read a command name in the echo area and execute it") +{ + char *line; + + /* Ask the completer to read a reference for us. */ + if (info_explicit_arg || count != 1) + { + char *prompt; + + prompt = (char *)xmalloc (20); + sprintf (prompt, "%d M-x ", count); + line = read_function_name (prompt, window); + } + else + line = read_function_name ("M-x ", window); + + /* User aborted? */ + if (!line) + { + info_abort_key (active_window, count, key); + return; + } + + /* User accepted "default"? (There is none.) */ + if (!*line) + { + free (line); + return; + } + + /* User wants to execute a named command. Do it. */ + { + VFunction *function; + + if ((active_window != the_echo_area) && + (strncmp (line, "echo-area-", 10) == 0)) + { + free (line); + info_error ("Cannot execute an `echo-area' command here."); + return; + } + + function = named_function (line); + free (line); + + if (!function) + return; + + (*function) (active_window, count, 0); + } +} + +/* Okay, now that we have M-x, let the user set the screen height. */ +DECLARE_INFO_COMMAND (set_screen_height, + "Set the height of the displayed window") +{ + int new_height; + + if (info_explicit_arg || count != 1) + new_height = count; + else + { + char prompt[80]; + char *line; + + new_height = screenheight; + + sprintf (prompt, "Set screen height to (%d): ", new_height); + + line = info_read_in_echo_area (window, prompt); + + /* If the user aborted, do that now. */ + if (!line) + { + info_abort_key (active_window, count, 0); + return; + } + + /* Find out what the new height is supposed to be. */ + if (*line) + new_height = atoi (line); + + /* Clear the echo area if it isn't active. */ + if (!echo_area_is_active) + window_clear_echo_area (); + + free (line); + } + + terminal_clear_screen (); + display_clear_display (the_display); + screenheight = new_height; + display_initialize_display (screenwidth, screenheight); + window_new_screen_size (screenwidth, screenheight); +} diff --git a/texinfo/info/makedoc.c b/texinfo/info/makedoc.c new file mode 100644 index 000000000000..c0c4587ff181 --- /dev/null +++ b/texinfo/info/makedoc.c @@ -0,0 +1,481 @@ +/* makedoc.c -- Make DOC.C and FUNS.H from input files. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +/* This program grovels the contents of the source files passed as arguments + and writes out a file of function pointers and documentation strings, and + a header file which describes the contents. This only does the functions + declared with DECLARE_INFO_COMMAND. */ + +#include +#include +#include +#if defined (HAVE_SYS_FILE_H) +#include +#endif /* HAVE_SYS_FILE_H */ +#include +#include "general.h" + +#if !defined (O_RDONLY) +#if defined (HAVE_SYS_FCNTL_H) +#include +#else /* !HAVE_SYS_FCNTL_H */ +#include +#endif /* !HAVE_SYS_FCNTL_H */ +#endif /* !O_RDONLY */ + +extern void *xmalloc (), *xrealloc (); +static void fatal_file_error (); + +/* Name of the header file which receives the declarations of functions. */ +static char *funs_filename = "funs.h"; + +/* Name of the documentation to function pointer file. */ +static char *doc_filename = "doc.c"; + +static char *doc_header[] = { + "/* doc.c -- Generated structure containing function names and doc strings.", + "", + " This file was automatically made from various source files with the", + " command \"%s\". DO NOT EDIT THIS FILE, only \"%s.c\".", + (char *)NULL +}; + +static char *doc_header_1[] = { + " An entry in the array FUNCTION_DOC_ARRAY is made for each command", + " found in the above files; each entry consists of a function pointer,", +#if defined (NAMED_FUNCTIONS) + " a string which is the user-visible name of the function,", +#endif /* NAMED_FUNCTIONS */ + " and a string which documents its purpose. */", + "", + "#include \"doc.h\"", + "#include \"funs.h\"", + "", + "FUNCTION_DOC function_doc_array[] = {", + "", + (char *)NULL +}; + +/* How to remember the locations of the functions found so that Emacs + can use the information in a tag table. */ +typedef struct { + char *name; /* Name of the tag. */ + int line; /* Line number at which it appears. */ + long char_offset; /* Character offset at which it appears. */ +} EMACS_TAG; + +typedef struct { + char *filename; /* Name of the file containing entries. */ + long entrylen; /* Total number of characters in tag block. */ + EMACS_TAG **entries; /* Entries found in FILENAME. */ + int entries_index; + int entries_slots; +} EMACS_TAG_BLOCK; + +EMACS_TAG_BLOCK **emacs_tags = (EMACS_TAG_BLOCK **)NULL; +int emacs_tags_index = 0; +int emacs_tags_slots = 0; + +#define DECLARATION_STRING "\nDECLARE_INFO_COMMAND" + +static void process_one_file (); +static void maybe_dump_tags (); +static FILE *must_fopen (); + +int +main (argc, argv) + int argc; + char **argv; +{ + register int i; + int tags_only = 0; + FILE *funs_stream, *doc_stream; + + for (i = 1; i < argc; i++) + if (strcmp (argv[i], "-tags") == 0) + { + tags_only++; + break; + } + + if (tags_only) + { + funs_filename = "/dev/null"; + doc_filename = "/dev/null"; + } + + funs_stream = must_fopen (funs_filename, "w"); + doc_stream = must_fopen (doc_filename, "w"); + + fprintf (funs_stream, + "/* %s -- Generated declarations for Info commands. */\n", + funs_filename); + + for (i = 0; doc_header[i]; i++) + { + fprintf (doc_stream, doc_header[i], argv[0], argv[0]); + fprintf (doc_stream, "\n"); + } + + fprintf (doc_stream, + " Source files groveled to make this file include:\n\n"); + + for (i = 1; i < argc; i++) + fprintf (doc_stream, "\t%s\n", argv[i]); + + fprintf (doc_stream, "\n"); + + for (i = 0; doc_header_1[i]; i++) + fprintf (doc_stream, "%s\n", doc_header_1[i]); + + + for (i = 1; i < argc; i++) + { + char *curfile; + curfile = argv[i]; + + if (*curfile == '-') + continue; + + fprintf (doc_stream, "/* Commands found in \"%s\". */\n", curfile); + fprintf (funs_stream, "\n/* Functions declared in \"%s\". */\n", + curfile); + + process_one_file (curfile, doc_stream, funs_stream); + } + + fprintf (doc_stream, + " { (VFunction *)NULL, (char *)NULL, (char *)NULL }\n};\n"); + + fclose (funs_stream); + fclose (doc_stream); + + if (tags_only) + maybe_dump_tags (stdout); + exit (0); +} + +/* Dumping out the contents of an Emacs tags table. */ +static void +maybe_dump_tags (stream) + FILE *stream; +{ + register int i; + + /* Print out the information for each block. */ + for (i = 0; i < emacs_tags_index; i++) + { + register int j; + register EMACS_TAG_BLOCK *block; + register EMACS_TAG *etag; + long block_len; + + block_len = 0; + block = emacs_tags[i]; + + /* Calculate the length of the dumped block first. */ + for (j = 0; j < block->entries_index; j++) + { + char digits[30]; + etag = block->entries[j]; + block_len += 3 + strlen (etag->name); + sprintf (digits, "%d,%d", etag->line, etag->char_offset); + block_len += strlen (digits); + } + + /* Print out the defining line. */ + fprintf (stream, "\f\n%s,%d\n", block->filename, block_len); + + /* Print out the individual tags. */ + for (j = 0; j < block->entries_index; j++) + { + etag = block->entries[j]; + + fprintf (stream, "%s,\177%d,%d\n", + etag->name, etag->line, etag->char_offset); + } + } +} + +/* Keeping track of names, line numbers and character offsets of functions + found in source files. */ +static EMACS_TAG_BLOCK * +make_emacs_tag_block (filename) + char *filename; +{ + EMACS_TAG_BLOCK *block; + + block = (EMACS_TAG_BLOCK *)xmalloc (sizeof (EMACS_TAG_BLOCK)); + block->filename = strdup (filename); + block->entrylen = 0; + block->entries = (EMACS_TAG **)NULL; + block->entries_index = 0; + block->entries_slots = 0; + return (block); +} + +static void +add_tag_to_block (block, name, line, char_offset) + EMACS_TAG_BLOCK *block; + char *name; + int line; + long char_offset; +{ + EMACS_TAG *tag; + + tag = (EMACS_TAG *)xmalloc (sizeof (EMACS_TAG)); + tag->name = name; + tag->line = line; + tag->char_offset = char_offset; + add_pointer_to_array (tag, block->entries_index, block->entries, + block->entries_slots, 50, EMACS_TAG *); +} + +/* Read the file represented by FILENAME into core, and search it for Info + function declarations. Output the declarations in various forms to the + DOC_STREAM and FUNS_STREAM. */ +static void +process_one_file (filename, doc_stream, funs_stream) + char *filename; + FILE *doc_stream, *funs_stream; +{ + int descriptor, decl_len; + char *buffer, *decl_str; + struct stat finfo; + long offset; + long file_size; + EMACS_TAG_BLOCK *block; + + if (stat (filename, &finfo) == -1) + fatal_file_error (filename); + + descriptor = open (filename, O_RDONLY, 0666); + + if (descriptor == -1) + fatal_file_error (filename); + + file_size = (long) finfo.st_size; + buffer = (char *)xmalloc (1 + file_size); + read (descriptor, buffer, file_size); + close (descriptor); + + offset = 0; + decl_str = DECLARATION_STRING; + decl_len = strlen (decl_str); + + block = make_emacs_tag_block (filename); + + while (1) + { + long point = 0; + long line_start = 0; + int line_number = 0; + + char *func, *doc; +#if defined (NAMED_FUNCTIONS) + char *func_name; +#endif /* NAMED_FUNCTIONS */ + + for (; offset < (file_size - decl_len); offset++) + { + if (buffer[offset] == '\n') + { + line_number++; + line_start = offset + 1; + } + + if (strncmp (buffer + offset, decl_str, decl_len) == 0) + { + offset += decl_len; + point = offset; + break; + } + } + + if (!point) + break; + + /* Skip forward until we find the open paren. */ + while (point < file_size) + { + if (buffer[point] == '\n') + { + line_number++; + line_start = point + 1; + } + else if (buffer[point] == '(') + break; + + point++; + } + + while (point++ < file_size) + { + if (!whitespace_or_newline (buffer[point])) + break; + else if (buffer[point] == '\n') + { + line_number++; + line_start = point + 1; + } + } + + if (point >= file_size) + break; + + /* Now looking at name of function. Get it. */ + for (offset = point; buffer[offset] != ','; offset++); + func = (char *)xmalloc (1 + (offset - point)); + strncpy (func, buffer + point, offset - point); + func[offset - point] = '\0'; + + /* Remember this tag in the current block. */ + { + char *tag_name; + + tag_name = (char *)xmalloc (1 + (offset - line_start)); + strncpy (tag_name, buffer + line_start, offset - line_start); + tag_name[offset - line_start] = '\0'; + add_tag_to_block (block, tag_name, line_number, point); + } + +#if defined (NAMED_FUNCTIONS) + /* Generate the user-visible function name from the function's name. */ + { + register int i; + char *name_start; + + name_start = func; + + if (strncmp (name_start, "info_", 5) == 0) + name_start += 5; + + func_name = strdup (name_start); + + /* Fix up "ea" commands. */ + if (strncmp (func_name, "ea_", 3) == 0) + { + char *temp_func_name; + + temp_func_name = (char *)xmalloc (10 + strlen (func_name)); + strcpy (temp_func_name, "echo_area_"); + strcat (temp_func_name, func_name + 3); + free (func_name); + func_name = temp_func_name; + } + + for (i = 0; func_name[i]; i++) + if (func_name[i] == '_') + func_name[i] = '-'; + } +#endif /* NAMED_FUNCTIONS */ + + /* Find doc string. */ + point = offset + 1; + + while (point < file_size) + { + if (buffer[point] == '\n') + { + line_number++; + line_start = point + 1; + } + + if (buffer[point] == '"') + break; + else + point++; + } + + offset = point + 1; + + while (offset < file_size) + { + if (buffer[offset] == '\n') + { + line_number++; + line_start = offset + 1; + } + + if (buffer[offset] == '\\') + offset += 2; + else if (buffer[offset] == '"') + break; + else + offset++; + } + + offset++; + if (offset >= file_size) + break; + + doc = (char *)xmalloc (1 + (offset - point)); + strncpy (doc, buffer + point, offset - point); + doc[offset - point] = '\0'; + +#if defined (NAMED_FUNCTIONS) + fprintf (doc_stream, " { %s, \"%s\", %s },\n", func, func_name, doc); + free (func_name); +#else /* !NAMED_FUNCTIONS */ + fprintf (doc_stream, " { %s, %s },\n", func, doc); +#endif /* !NAMED_FUNCTIONS */ + + fprintf (funs_stream, "extern void %s ();\n", func); + free (func); + free (doc); + } + free (buffer); + + /* If we created any tags, remember this file on our global list. Otherwise, + free the memory already allocated to it. */ + if (block->entries) + add_pointer_to_array (block, emacs_tags_index, emacs_tags, + emacs_tags_slots, 10, EMACS_TAG_BLOCK *); + else + { + free (block->filename); + free (block); + } +} + +static void +fatal_file_error (filename) + char *filename; +{ + fprintf (stderr, "Couldn't manipulate the file %s.\n", filename); + exit (2); +} + +static FILE * +must_fopen (filename, mode) + char *filename, *mode; +{ + FILE *stream; + + stream = fopen (filename, mode); + if (!stream) + fatal_file_error (filename); + + return (stream); +} + diff --git a/texinfo/info/man.c b/texinfo/info/man.c new file mode 100644 index 000000000000..b899ec1d273f --- /dev/null +++ b/texinfo/info/man.c @@ -0,0 +1,643 @@ +/* man.c: How to read and format man files. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1995 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. + + Written by Brian Fox Thu May 4 09:17:52 1995 (bfox@ai.mit.edu). */ + +#include "info.h" +#include +#include +#include "signals.h" +#if defined (HAVE_SYS_TIME_H) +#include +#endif +#if defined (HAVE_SYS_WAIT_H) +#include +#endif +#include "tilde.h" + +#include "man.h" + +#if !defined (_POSIX_VERSION) +#define pid_t int +#endif + +#if defined (FD_SET) +# if defined (hpux) +# define fd_set_cast(x) (int *)(x) +# else +# define fd_set_cast(x) (fd_set *)(x) +# endif /* !hpux */ +#endif /* FD_SET */ + +static char *read_from_fd (); +static void clean_manpage (); +static NODE *manpage_node_of_file_buffer (); +static char *get_manpage_contents (); + +NODE * +make_manpage_node (pagename) + char *pagename; +{ + return (info_get_node (MANPAGE_FILE_BUFFER_NAME, pagename)); +} + +NODE * +get_manpage_node (file_buffer, pagename) + FILE_BUFFER *file_buffer; + char *pagename; +{ + NODE *node; + + node = manpage_node_of_file_buffer (file_buffer, pagename); + + if (!node) + { + char *page; + + page = get_manpage_contents (pagename); + + if (page) + { + char header[1024]; + long oldsize, newsize; + int hlen, plen; + + sprintf (header, "\n\n%c\n%s %s, %s %s, %s (dir)\n\n", + INFO_COOKIE, + INFO_FILE_LABEL, file_buffer->filename, + INFO_NODE_LABEL, pagename, + INFO_UP_LABEL); + oldsize = file_buffer->filesize; + hlen = strlen (header); + plen = strlen (page); + newsize = (oldsize + hlen + plen); + file_buffer->contents = + (char *)xrealloc (file_buffer->contents, 1 + newsize); + memcpy (file_buffer->contents + oldsize, header, hlen); + oldsize += hlen; + memcpy (file_buffer->contents + oldsize, page, plen); + file_buffer->contents[newsize] = '\0'; + file_buffer->filesize = newsize; + file_buffer->finfo.st_size = newsize; + build_tags_and_nodes (file_buffer); + free (page); + } + + node = manpage_node_of_file_buffer (file_buffer, pagename); + } + + return (node); +} + +FILE_BUFFER * +create_manpage_file_buffer () +{ + FILE_BUFFER *file_buffer; + struct stat *finfo; + + file_buffer = make_file_buffer (); + file_buffer->filename = strdup (MANPAGE_FILE_BUFFER_NAME); + file_buffer->fullpath = strdup (MANPAGE_FILE_BUFFER_NAME); + file_buffer->finfo.st_size = 0; + file_buffer->filesize = 0; + file_buffer->contents = (char *)NULL; + file_buffer->flags = (N_IsInternal | N_CannotGC | N_IsManPage); + + return (file_buffer); +} + +/* Scan the list of directories in PATH looking for FILENAME. If we find + one that is an executable file, return it as a new string. Otherwise, + return a NULL pointer. */ +static char * +executable_file_in_path (filename, path) + char *filename, *path; +{ + struct stat finfo; + char *temp_dirname; + int statable, dirname_index; + + dirname_index = 0; + + while (temp_dirname = extract_colon_unit (path, &dirname_index)) + { + register int i; + char *temp; + + /* Expand a leading tilde if one is present. */ + if (*temp_dirname == '~') + { + char *expanded_dirname; + + expanded_dirname = tilde_expand_word (temp_dirname); + free (temp_dirname); + temp_dirname = expanded_dirname; + } + + temp = (char *)xmalloc (30 + strlen (temp_dirname) + strlen (filename)); + strcpy (temp, temp_dirname); + if (temp[(strlen (temp)) - 1] != '/') + strcat (temp, "/"); + strcat (temp, filename); + + free (temp_dirname); + + statable = (stat (temp, &finfo) == 0); + + /* If we have found a regular executable file, then use it. */ + if ((statable) && (S_ISREG (finfo.st_mode)) && + (access (temp, X_OK) == 0)) + return (temp); + else + free (temp); + } + return ((char *)NULL); +} + +/* Return the full pathname of the system man page formatter. */ +static char * +find_man_formatter () +{ + return (executable_file_in_path ("man", (char *)getenv ("PATH"))); +} + +static char *manpage_pagename = (char *)NULL; +static char *manpage_section = (char *)NULL; + +static void +get_page_and_section (pagename) + char *pagename; +{ + register int i; + + if (manpage_pagename) + free (manpage_pagename); + + if (manpage_section) + free (manpage_section); + + manpage_pagename = (char *)NULL; + manpage_section = (char *)NULL; + + for (i = 0; pagename[i] != '\0' && pagename[i] != '('; i++); + + manpage_pagename = (char *)xmalloc (1 + i); + strncpy (manpage_pagename, pagename, i); + manpage_pagename[i] = '\0'; + + if (pagename[i] == '(') + { + int start; + + start = i + 1; + + for (i = start; pagename[i] != '\0' && pagename[i] != ')'; i++); + + manpage_section = (char *)xmalloc (1 + (i - start)); + strncpy (manpage_section, pagename + start, (i - start)); + manpage_section[i - start] = '\0'; + } +} + +static void +reap_children (sig) + int sig; +{ + unsigned int status; + wait (&status); +} + +static char * +get_manpage_contents (pagename) + char *pagename; +{ + static char *formatter_args[4] = { (char *)NULL }; + int pipes[2]; + pid_t child; + char *formatted_page = (char *)NULL; + char *section = (char *)NULL; + int arg_index = 1; + + if (formatter_args[0] == (char *)NULL) + formatter_args[0] = find_man_formatter (); + + if (formatter_args[0] == (char *)NULL) + return ((char *)NULL); + + get_page_and_section (pagename); + + if (manpage_section != (char *)NULL) + formatter_args[arg_index++] = manpage_section; + + formatter_args[arg_index++] = manpage_pagename; + formatter_args[arg_index] = (char *)NULL; + + /* Open a pipe to this program, read the output, and save it away + in FORMATTED_PAGE. The reader end of the pipe is pipes[0]; the + writer end is pipes[1]. */ + pipe (pipes); + + signal (SIGCHLD, reap_children); + + child = fork (); + + if (child == -1) + return ((char *)NULL); + + if (child != 0) + { + /* In the parent, close the writing end of the pipe, and read from + the exec'd child. */ + close (pipes[1]); + formatted_page = read_from_fd (pipes[0]); + close (pipes[0]); + } + else + { + /* In the child, close the read end of the pipe, make the write end + of the pipe be stdout, and execute the man page formatter. */ + close (pipes[0]); + close (fileno (stderr)); + close (fileno (stdin)); /* Don't print errors. */ + dup2 (pipes[1], fileno (stdout)); + + execv (formatter_args[0], formatter_args); + + /* If we get here, we couldn't exec, so close out the pipe and + exit. */ + close (pipes[1]); + exit (0); + } + + /* If we have the page, then clean it up. */ + if (formatted_page) + clean_manpage (formatted_page); + + return (formatted_page); +} + +static void +clean_manpage (manpage) + char *manpage; +{ + register int i, j; + int newline_count = 0; + char *newpage; + + newpage = (char *)xmalloc (1 + strlen (manpage)); + + for (i = 0, j = 0; newpage[j] = manpage[i]; i++, j++) + { + if (manpage[i] == '\n') + newline_count++; + else + newline_count = 0; + + if (newline_count == 3) + { + j--; + newline_count--; + } + + if (manpage[i] == '\b' || manpage[i] == '\f') + j -= 2; + } + + newpage[j++] = '\0'; + + strcpy (manpage, newpage); + free (newpage); +} + +static NODE * +manpage_node_of_file_buffer (file_buffer, pagename) + FILE_BUFFER *file_buffer; + char *pagename; +{ + NODE *node = (NODE *)NULL; + TAG *tag = (TAG *)NULL; + + if (file_buffer->contents) + { + register int i; + + for (i = 0; tag = file_buffer->tags[i]; i++) + { + if (strcasecmp (pagename, tag->nodename) == 0) + break; + } + } + + if (tag) + { + node = (NODE *)xmalloc (sizeof (NODE)); + node->filename = file_buffer->filename; + node->nodename = tag->nodename; + node->contents = file_buffer->contents + tag->nodestart; + node->nodelen = tag->nodelen; + node->flags = 0; + node->parent = (char *)NULL; + node->flags = (N_HasTagsTable | N_IsManPage); + node->contents += skip_node_separator (node->contents); + } + + return (node); +} + +static char * +read_from_fd (fd) + int fd; +{ + struct timeval timeout; + char *buffer = (char *)NULL; + int bsize = 0; + int bindex = 0; + int select_result; +#if defined (FD_SET) + fd_set read_fds; + + timeout.tv_sec = 15; + timeout.tv_usec = 0; + + FD_ZERO (&read_fds); + FD_SET (fd, &read_fds); + + select_result = select (fd + 1, fd_set_cast (&read_fds), 0, 0, &timeout); +#else /* !FD_SET */ + select_result = 1; +#endif /* !FD_SET */ + + switch (select_result) + { + case 0: + case -1: + break; + + default: + { + int amount_read; + int done = 0; + + while (!done) + { + while ((bindex + 1024) > (bsize)) + buffer = (char *)xrealloc (buffer, (bsize += 1024)); + buffer[bindex] = '\0'; + + amount_read = read (fd, buffer + bindex, 1023); + + if (amount_read < 0) + { + done = 1; + } + else + { + bindex += amount_read; + buffer[bindex] = '\0'; + if (amount_read == 0) + done = 1; + } + } + } + } + + if ((buffer != (char *)NULL) && (*buffer == '\0')) + { + free (buffer); + buffer = (char *)NULL; + } + + return (buffer); +} + +static char *reference_section_starters[] = +{ + "\nRELATED INFORMATION", + "\nRELATED\tINFORMATION", + "RELATED INFORMATION\n", + "RELATED\tINFORMATION\n", + "\nSEE ALSO", + "\nSEE\tALSO", + "SEE ALSO\n", + "SEE\tALSO\n", + (char *)NULL +}; + +static SEARCH_BINDING frs_binding; + +static SEARCH_BINDING * +find_reference_section (node) + NODE *node; +{ + register int i; + long position = -1; + + frs_binding.buffer = node->contents; + frs_binding.start = 0; + frs_binding.end = node->nodelen; + frs_binding.flags = S_SkipDest; + + for (i = 0; reference_section_starters[i] != (char *)NULL; i++) + { + position = search_forward (reference_section_starters[i], &frs_binding); + if (position != -1) + break; + } + + if (position == -1) + return ((SEARCH_BINDING *)NULL); + + /* We found the start of the reference section, and point is right after + the string which starts it. The text from here to the next header + (or end of buffer) contains the only references in this manpage. */ + frs_binding.start = position; + + for (i = frs_binding.start; i < frs_binding.end - 2; i++) + { + if ((frs_binding.buffer[i] == '\n') && + (!whitespace (frs_binding.buffer[i + 1]))) + { + frs_binding.end = i; + break; + } + } + + return (&frs_binding); +} + +REFERENCE ** +xrefs_of_manpage (node) + NODE *node; +{ + SEARCH_BINDING *reference_section; + REFERENCE **refs = (REFERENCE **)NULL; + int refs_index = 0; + int refs_slots = 0; + long position; + + reference_section = find_reference_section (node); + + if (reference_section == (SEARCH_BINDING *)NULL) + return ((REFERENCE **)NULL); + + /* Grovel the reference section building a list of references found there. + A reference is alphabetic characters followed by non-whitespace text + within parenthesis. */ + reference_section->flags = 0; + + while ((position = search_forward ("(", reference_section)) != -1) + { + register int start, end; + + for (start = position; start > reference_section->start; start--) + if (whitespace (reference_section->buffer[start])) + break; + + start++; + + for (end = position; end < reference_section->end; end++) + { + if (whitespace (reference_section->buffer[end])) + { + end = start; + break; + } + + if (reference_section->buffer[end] == ')') + { + end++; + break; + } + } + + if (end != start) + { + REFERENCE *entry; + int len = end - start; + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->label = (char *)xmalloc (1 + len); + strncpy (entry->label, (reference_section->buffer) + start, len); + entry->label[len] = '\0'; + entry->filename = strdup (node->filename); + entry->nodename = strdup (entry->label); + entry->start = start; + entry->end = end; + + add_pointer_to_array + (entry, refs_index, refs, refs_slots, 10, REFERENCE *); + } + + reference_section->start = position + 1; + } + + return (refs); +} + +long +locate_manpage_xref (node, start, dir) + NODE *node; + long start; + int dir; +{ + register int i, count; + REFERENCE **refs; + long position = -1; + + refs = xrefs_of_manpage (node); + + if (refs) + { + register int i, count; + REFERENCE *entry; + + for (i = 0; refs[i]; i++); + count = i; + + if (dir > 0) + { + for (i = 0; entry = refs[i]; i++) + if (entry->start > start) + { + position = entry->start; + break; + } + } + else + { + for (i = count - 1; i > -1; i--) + { + entry = refs[i]; + + if (entry->start < start) + { + position = entry->start; + break; + } + } + } + + info_free_references (refs); + } + return (position); +} + +/* This one was a little tricky. The binding buffer that is passed in has + a START and END value of 0 -- strlen (window-line-containing-point). + The BUFFER is a pointer to the start of that line. */ +REFERENCE ** +manpage_xrefs_in_binding (node, binding) + NODE *node; + SEARCH_BINDING *binding; +{ + register int i; + REFERENCE **all_refs = xrefs_of_manpage (node); + REFERENCE **brefs = (REFERENCE **)NULL; + REFERENCE *entry; + int brefs_index = 0; + int brefs_slots = 0; + int start, end; + + if (!all_refs) + return ((REFERENCE **)NULL); + + start = binding->start + (binding->buffer - node->contents); + end = binding->end + (binding->buffer - node->contents); + + for (i = 0; entry = all_refs[i]; i++) + { + if ((entry->start > start) && (entry->end < end)) + { + add_pointer_to_array + (entry, brefs_index, brefs, brefs_slots, 10, REFERENCE *); + } + else + { + maybe_free (entry->label); + maybe_free (entry->filename); + maybe_free (entry->nodename); + free (entry); + } + } + + free (all_refs); + return (brefs); +} diff --git a/texinfo/info/man.h b/texinfo/info/man.h new file mode 100644 index 000000000000..1584e260687e --- /dev/null +++ b/texinfo/info/man.h @@ -0,0 +1,36 @@ +/* man.h: Defines and external function declarations for man.c */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Author: Brian J. Fox (bfox@ai.mit.edu) Sat May 6 16:19:13 1995. */ + +#if !defined (_MAN_H_) +#define _MAN_H_ + +#define MANPAGE_FILE_BUFFER_NAME "*manpages*" + +extern NODE *make_manpage_node (/* char *pagename */); +extern NODE *get_manpage_node (/* FILE_BUFFER *file_buffer, char *pagename */); +extern FILE_BUFFER *create_manpage_file_buffer (/* void */); +extern long locate_manpage_xref (/* NODE *node, long start, int dir */); +extern REFERENCE **xrefs_of_manpage (/* NODE *node */); +extern REFERENCE **manpage_xrefs_in_binding (/* NODE *node, SEARCH_BINDING *binding */); + +#endif /* !_MAN_H_ */ diff --git a/texinfo/info/nodemenu.c b/texinfo/info/nodemenu.c new file mode 100644 index 000000000000..33044157bd27 --- /dev/null +++ b/texinfo/info/nodemenu.c @@ -0,0 +1,329 @@ +/* nodemenu.c -- Produce a menu of all visited nodes. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" + +/* Return a line describing the format of a node information line. */ +static char * +nodemenu_format_info () +{ + return ("\n\ +* Menu:\n\ + (File)Node Lines Size Containing File\n\ + ---------- ----- ---- ---------------"); +} + +/* Produce a formatted line of information about NODE. Here is what we want + the output listing to look like: + +* Menu: + (File)Node Lines Size Containing File + ---------- ----- ---- --------------- +* (emacs)Buffers:: 48 2230 /usr/gnu/info/emacs/emacs-1 +* (autoconf)Writing configure.in:: 123 58789 /usr/gnu/info/autoconf/autoconf-1 +* (dir)Top:: 40 589 /usr/gnu/info/dir +*/ +static char * +format_node_info (node) + NODE *node; +{ + register int i, len; + char *parent, *containing_file; + static char *line_buffer = (char *)NULL; + + if (!line_buffer) + line_buffer = (char *)xmalloc (1000); + + if (node->parent) + { + parent = filename_non_directory (node->parent); + if (!parent) + parent = node->parent; + } + else + parent = (char *)NULL; + + containing_file = node->filename; + + if (!parent && !*containing_file) + sprintf (line_buffer, "* %s::", node->nodename); + else + { + char *file = (char *)NULL; + + if (parent) + file = parent; + else + file = filename_non_directory (containing_file); + + if (!file) + file = containing_file; + + if (!*file) + file = "dir"; + + sprintf (line_buffer, "* (%s)%s::", file, node->nodename); + } + + len = pad_to (36, line_buffer); + + { + int lines = 1; + + for (i = 0; i < node->nodelen; i++) + if (node->contents[i] == '\n') + lines++; + + sprintf (line_buffer + len, "%d", lines); + } + + len = pad_to (44, line_buffer); + sprintf (line_buffer + len, "%d", node->nodelen); + + if (node->filename && *(node->filename)) + { + len = pad_to (51, line_buffer); + sprintf (line_buffer + len, node->filename); + } + + return (strdup (line_buffer)); +} + +/* Little string comparison routine for qsort (). */ +static int +compare_strings (string1, string2) + char **string1, **string2; +{ + return (strcasecmp (*string1, *string2)); +} + +/* The name of the nodemenu node. */ +static char *nodemenu_nodename = "*Node Menu*"; + +/* Produce an informative listing of all the visited nodes, and return it + in a node. If FILTER_FUNC is non-null, it is a function which filters + which nodes will appear in the listing. FILTER_FUNC takes an argument + of NODE, and returns non-zero if the node should appear in the listing. */ +NODE * +get_visited_nodes (filter_func) + Function *filter_func; +{ + register int i, iw_index; + INFO_WINDOW *info_win; + NODE *node; + char **lines = (char **)NULL; + int lines_index = 0, lines_slots = 0; + + if (!info_windows) + return ((NODE *)NULL); + + for (iw_index = 0; info_win = info_windows[iw_index]; iw_index++) + { + for (i = 0; i < info_win->nodes_index; i++) + { + node = info_win->nodes[i]; + + /* We skip mentioning "*Node Menu*" nodes. */ + if (internal_info_node_p (node) && + (strcmp (node->nodename, nodemenu_nodename) == 0)) + continue; + + if (node && (!filter_func || (*filter_func) (node))) + { + char *line; + + line = format_node_info (node); + add_pointer_to_array + (line, lines_index, lines, lines_slots, 20, char *); + } + } + } + + /* Sort the array of information lines, if there are any. */ + if (lines) + { + register int j, newlen; + char **temp; + + qsort (lines, lines_index, sizeof (char *), compare_strings); + + /* Delete duplicates. */ + for (i = 0, newlen = 1; i < lines_index - 1; i++) + { + if (strcmp (lines[i], lines[i + 1]) == 0) + { + free (lines[i]); + lines[i] = (char *)NULL; + } + else + newlen++; + } + + /* We have free ()'d and marked all of the duplicate slots. + Copy the live slots rather than pruning the dead slots. */ + temp = (char **)xmalloc ((1 + newlen) * sizeof (char *)); + for (i = 0, j = 0; i < lines_index; i++) + if (lines[i]) + temp[j++] = lines[i]; + + temp[j] = (char *)NULL; + free (lines); + lines = temp; + lines_index = newlen; + } + + initialize_message_buffer (); + + printf_to_message_buffer + ("%s", replace_in_documentation + ("Here is the menu of nodes you have recently visited.\n\ +Select one from this menu, or use `\\[history-node]' in another window.\n")); + + printf_to_message_buffer ("%s\n", nodemenu_format_info ()); + + for (i = 0; (lines != (char **)NULL) && (i < lines_index); i++) + { + printf_to_message_buffer ("%s\n", lines[i]); + free (lines[i]); + } + + if (lines) + free (lines); + + node = message_buffer_to_node (); + add_gcable_pointer (node->contents); + return (node); +} + +DECLARE_INFO_COMMAND (list_visited_nodes, + "Make a window containing a menu of all of the currently visited nodes") +{ + WINDOW *new; + NODE *node; + + set_remembered_pagetop_and_point (window); + + /* If a window is visible and showing the buffer list already, re-use it. */ + for (new = windows; new; new = new->next) + { + node = new->node; + + if (internal_info_node_p (node) && + (strcmp (node->nodename, nodemenu_nodename) == 0)) + break; + } + + /* If we couldn't find an existing window, try to use the next window + in the chain. */ + if (!new && window->next) + new = window->next; + + /* If we still don't have a window, make a new one to contain the list. */ + if (!new) + { + WINDOW *old_active; + + old_active = active_window; + active_window = window; + new = window_make_window ((NODE *)NULL); + active_window = old_active; + } + + /* If we couldn't make a new window, use this one. */ + if (!new) + new = window; + + /* Lines do not wrap in this window. */ + new->flags |= W_NoWrap; + node = get_visited_nodes ((Function *)NULL); + name_internal_node (node, nodemenu_nodename); + + /* Even if this is an internal node, we don't want the window + system to treat it specially. So we turn off the internalness + of it here. */ + node->flags &= ~N_IsInternal; + + /* If this window is already showing a node menu, reuse the existing node + slot. */ + { + int remember_me = 1; + +#if defined (NOTDEF) + if (internal_info_node_p (new->node) && + (strcmp (new->node->nodename, nodemenu_nodename) == 0)) + remember_me = 0; +#endif /* NOTDEF */ + + window_set_node_of_window (new, node); + + if (remember_me) + remember_window_and_node (new, node); + } + + active_window = new; +} + +DECLARE_INFO_COMMAND (select_visited_node, + "Select a node which has been previously visited in a visible window") +{ + char *line; + NODE *node; + REFERENCE **menu; + + node = get_visited_nodes ((Function *)NULL); + + menu = info_menu_of_node (node); + free (node); + + line = + info_read_completing_in_echo_area (window, "Select visited node: ", menu); + + window = active_window; + + /* User aborts, just quit. */ + if (!line) + { + info_abort_key (window, 0, 0); + info_free_references (menu); + return; + } + + if (*line) + { + REFERENCE *entry; + + /* Find the selected label in the references. */ + entry = info_get_labeled_reference (line, menu); + + if (!entry) + info_error ("The reference disappeared! (%s).", line); + else + info_select_reference (window, entry); + } + + free (line); + info_free_references (menu); + + if (!info_error_was_printed) + window_clear_echo_area (); +} diff --git a/texinfo/info/nodes.c b/texinfo/info/nodes.c new file mode 100644 index 000000000000..8995c78195f6 --- /dev/null +++ b/texinfo/info/nodes.c @@ -0,0 +1,1207 @@ +/* nodes.c -- How to get an Info file and node. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include +#include +#if defined (HAVE_SYS_FILE_H) +#include +#endif /* HAVE_SYS_FILE_H */ +#include +#include +#if defined (HAVE_STRING_H) +#include +#endif /* HAVE_STRING_H */ +#include "nodes.h" +#include "search.h" +#include "filesys.h" +#include "info-utils.h" + +#if defined (HANDLE_MAN_PAGES) +# include "man.h" +#endif /* HANDLE_MAN_PAGES */ + +#if !defined (O_RDONLY) +#if defined (HAVE_SYS_FCNTL_H) +#include +#else /* !HAVE_SYS_FCNTL_H */ +#include +#endif /* !HAVE_SYS_FCNTL_H */ +#endif /* !O_RDONLY */ + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +/* **************************************************************** */ +/* */ +/* Functions Static to this File */ +/* */ +/* **************************************************************** */ + +static void forget_info_file (), remember_info_file (); +static void free_file_buffer_tags (), free_info_tag (); +static void get_nodes_of_tags_table (), get_nodes_of_info_file (); +static void get_tags_of_indirect_tags_table (); +static void info_reload_file_buffer_contents (); +static char *adjust_nodestart (); +static FILE_BUFFER *info_load_file_internal (), *info_find_file_internal (); +static NODE *info_node_of_file_buffer_tags (); + +static long get_node_length (); + +/* Magic number that RMS used to decide how much a tags table pointer could + be off by. I feel that it should be much smaller, like on the order of + 4. */ +#define DEFAULT_INFO_FUDGE 1000 + +/* Passed to *_internal functions. INFO_GET_TAGS says to do what is + neccessary to fill in the nodes or tags arrays in FILE_BUFFER. */ +#define INFO_NO_TAGS 0 +#define INFO_GET_TAGS 1 + +/* **************************************************************** */ +/* */ +/* Global Variables */ +/* */ +/* **************************************************************** */ + +/* When non-zero, this is a string describing the recent file error. */ +char *info_recent_file_error = (char *)NULL; + +/* The list of already loaded nodes. */ +FILE_BUFFER **info_loaded_files = (FILE_BUFFER **)NULL; + +/* The number of slots currently allocated to LOADED_FILES. */ +int info_loaded_files_slots = 0; + +/* **************************************************************** */ +/* */ +/* Public Functions for Node Manipulation */ +/* */ +/* **************************************************************** */ + +/* Used to build "dir" menu from "localdir" files found in INFOPATH. */ +extern void maybe_build_dir_node (); + +/* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME. + FILENAME can be passed as NULL, in which case the filename of "dir" is used. + NODENAME can be passed as NULL, in which case the nodename of "Top" is used. + If the node cannot be found, return a NULL pointer. */ +NODE * +info_get_node (filename, nodename) + char *filename, *nodename; +{ + FILE_BUFFER *file_buffer; + NODE *node; + + file_buffer = (FILE_BUFFER *)NULL; + info_recent_file_error = (char *)NULL; + + info_parse_node (nodename, DONT_SKIP_NEWLINES); + nodename = (char *)NULL; + + if (info_parsed_filename) + filename = info_parsed_filename; + + if (info_parsed_nodename) + nodename = info_parsed_nodename; + + /* If FILENAME is not specified, it defaults to "dir". */ + if (!filename) + filename = "dir"; + + /* If the file to be looked up is "dir", build the contents from all of + the "dir"s and "localdir"s found in INFOPATH. */ + if (strcasecmp (filename, "dir") == 0) + maybe_build_dir_node (filename); + + /* Find the correct info file. */ + file_buffer = info_find_file (filename); + + if (!file_buffer) + { + if (filesys_error_number) + info_recent_file_error = + filesys_error_string (filename, filesys_error_number); + return ((NODE *)NULL); + } + + node = info_get_node_of_file_buffer (nodename, file_buffer); + /* If the node looked for was "Top", try again looking for the node under + a slightly different name. */ + if (!node && (nodename == NULL || strcasecmp (nodename, "Top") == 0)) + { + node = info_get_node_of_file_buffer ("Top", file_buffer); + if (!node) + node = info_get_node_of_file_buffer ("top", file_buffer); + if (!node) + node = info_get_node_of_file_buffer ("TOP", file_buffer); + } + return (node); +} + +/* Return a pointer to a NODE structure for the Info node NODENAME in + FILE_BUFFER. NODENAME can be passed as NULL, in which case the + nodename of "Top" is used. If the node cannot be found, return a + NULL pointer. */ +NODE * +info_get_node_of_file_buffer (nodename, file_buffer) + char *nodename; + FILE_BUFFER *file_buffer; +{ + NODE *node = (NODE *)NULL; + + /* If we are unable to find the file, we have to give up. There isn't + anything else we can do. */ + if (!file_buffer) + return ((NODE *)NULL); + + /* If the file buffer was gc'ed, reload the contents now. */ + if (!file_buffer->contents) + info_reload_file_buffer_contents (file_buffer); + + /* If NODENAME is not specified, it defaults to "Top". */ + if (!nodename) + nodename = "Top"; + + /* If the name of the node that we wish to find is exactly "*", then the + node body is the contents of the entire file. Create and return such + a node. */ + if (strcmp (nodename, "*") == 0) + { + node = (NODE *)xmalloc (sizeof (NODE)); + node->filename = file_buffer->fullpath; + node->parent = (char *)NULL; + node->nodename = strdup ("*"); + node->contents = file_buffer->contents; + node->nodelen = file_buffer->filesize; + node->flags = 0; + } +#if defined (HANDLE_MAN_PAGES) + /* If the file buffer is the magic one associated with manpages, call + the manpage node finding function instead. */ + else if (file_buffer->flags & N_IsManPage) + { + node = get_manpage_node (file_buffer, nodename); + } +#endif /* HANDLE_MAN_PAGES */ + /* If this is the "main" info file, it might contain a tags table. Search + the tags table for an entry which matches the node that we want. If + there is a tags table, get the file which contains this node, but don't + bother building a node list for it. */ + else if (file_buffer->tags) + { + node = info_node_of_file_buffer_tags (file_buffer, nodename); + } + + /* Return the results of our node search. */ + return (node); +} + +/* Locate the file named by FILENAME, and return the information structure + describing this file. The file may appear in our list of loaded files + already, or it may not. If it does not already appear, find the file, + and add it to the list of loaded files. If the file cannot be found, + return a NULL FILE_BUFFER *. */ +FILE_BUFFER * +info_find_file (filename) + char *filename; +{ + return (info_find_file_internal (filename, INFO_GET_TAGS)); +} + +/* Load the info file FILENAME, remembering information about it in a + file buffer. */ +FILE_BUFFER * +info_load_file (filename) + char *filename; +{ + return (info_load_file_internal (filename, INFO_GET_TAGS)); +} + + +/* **************************************************************** */ +/* */ +/* Private Functions Implementation */ +/* */ +/* **************************************************************** */ + +/* The workhorse for info_find_file (). Non-zero 2nd argument says to + try to build a tags table (or otherwise glean the nodes) for this + file once found. By default, we build the tags table, but when this + function is called by info_get_node () when we already have a valid + tags table describing the nodes, it is unnecessary. */ +static FILE_BUFFER * +info_find_file_internal (filename, get_tags) + char *filename; + int get_tags; +{ + register int i; + register FILE_BUFFER *file_buffer; + + /* First try to find the file in our list of already loaded files. */ + if (info_loaded_files) + { + for (i = 0; file_buffer = info_loaded_files[i]; i++) + if ((strcmp (filename, file_buffer->filename) == 0) || + (strcmp (filename, file_buffer->fullpath) == 0) || + ((*filename != '/') && + strcmp (filename, + filename_non_directory (file_buffer->fullpath)) == 0)) + { + struct stat new_info, *old_info; + + /* This file is loaded. If the filename that we want is + specifically "dir", then simply return the file buffer. */ + if (strcasecmp (filename_non_directory (filename), "dir") == 0) + return (file_buffer); + +#if defined (HANDLE_MAN_PAGES) + /* Do the same for the magic MANPAGE file. */ + if (file_buffer->flags & N_IsManPage) + return (file_buffer); +#endif /* HANDLE_MAN_PAGES */ + + /* The file appears to be already loaded, and it is not "dir". + Check to see if it has changed since the last time it was + loaded. */ + if (stat (file_buffer->fullpath, &new_info) == -1) + { + filesys_error_number = errno; + return ((FILE_BUFFER *)NULL); + } + + old_info = &file_buffer->finfo; + + if ((new_info.st_size != old_info->st_size) || + (new_info.st_mtime != old_info->st_mtime)) + { + /* The file has changed. Forget that we ever had loaded it + in the first place. */ + forget_info_file (filename); + break; + } + else + { + /* The info file exists, and has not changed since the last + time it was loaded. If the caller requested a nodes list + for this file, and there isn't one here, build the nodes + for this file_buffer. In any case, return the file_buffer + object. */ + if (get_tags && !file_buffer->tags) + build_tags_and_nodes (file_buffer); + + return (file_buffer); + } + } + } + + /* The file wasn't loaded. Try to load it now. */ +#if defined (HANDLE_MAN_PAGES) + /* If the name of the file that we want is our special file buffer for + Unix manual pages, then create the file buffer, and return it now. */ + if (strcasecmp (filename, MANPAGE_FILE_BUFFER_NAME) == 0) + file_buffer = create_manpage_file_buffer (); + else +#endif /* HANDLE_MAN_PAGES */ + file_buffer = info_load_file_internal (filename, get_tags); + + /* If the file was loaded, remember the name under which it was found. */ + if (file_buffer) + remember_info_file (file_buffer); + + return (file_buffer); +} + +/* The workhorse function for info_load_file (). Non-zero second argument + says to build a list of tags (or nodes) for this file. This is the + default behaviour when info_load_file () is called, but it is not + necessary when loading a subfile for which we already have tags. */ +static FILE_BUFFER * +info_load_file_internal (filename, get_tags) + char *filename; + int get_tags; +{ + char *fullpath, *contents; + long filesize; + struct stat finfo; + int retcode; + FILE_BUFFER *file_buffer = (FILE_BUFFER *)NULL; + + /* Get the full pathname of this file, as known by the info system. + That is to say, search along INFOPATH and expand tildes, etc. */ + fullpath = info_find_fullpath (filename); + + /* Did we actually find the file? */ + retcode = stat (fullpath, &finfo); + + /* If the file referenced by the name returned from info_find_fullpath () + doesn't exist, then try again with the last part of the filename + appearing in lowercase. */ + if (retcode < 0) + { + char *lowered_name; + char *basename; + + lowered_name = strdup (filename); + basename = (char *) strrchr (lowered_name, '/'); + + if (basename) + basename++; + else + basename = lowered_name; + + while (*basename) + { + if (isupper (*basename)) + *basename = tolower (*basename); + + basename++; + } + + fullpath = info_find_fullpath (lowered_name); + free (lowered_name); + + retcode = stat (fullpath, &finfo); + } + + /* If the file wasn't found, give up, returning a NULL pointer. */ + if (retcode < 0) + { + filesys_error_number = errno; + return ((FILE_BUFFER *)NULL); + } + + /* Otherwise, try to load the file. */ + contents = filesys_read_info_file (fullpath, &filesize, &finfo); + + if (!contents) + return ((FILE_BUFFER *)NULL); + + /* The file was found, and can be read. Allocate FILE_BUFFER and fill + in the various members. */ + file_buffer = make_file_buffer (); + file_buffer->filename = strdup (filename); + file_buffer->fullpath = strdup (fullpath); + file_buffer->finfo = finfo; + file_buffer->filesize = filesize; + file_buffer->contents = contents; + if (file_buffer->filesize != file_buffer->finfo.st_size) + file_buffer->flags |= N_IsCompressed; + + /* If requested, build the tags and nodes for this file buffer. */ + if (get_tags) + build_tags_and_nodes (file_buffer); + + return (file_buffer); +} + +/* Grovel FILE_BUFFER->contents finding tags and nodes, and filling in the + various slots. This can also be used to rebuild a tag or node table. */ +void +build_tags_and_nodes (file_buffer) + FILE_BUFFER *file_buffer; +{ + SEARCH_BINDING binding; + long position; + + free_file_buffer_tags (file_buffer); + file_buffer->flags &= ~N_HasTagsTable; + + /* See if there is a tags table in this info file. */ + binding.buffer = file_buffer->contents; + binding.start = file_buffer->filesize; + binding.end = binding.start - 1000; + if (binding.end < 0) + binding.end = 0; + binding.flags = S_FoldCase; + + position = search_backward (TAGS_TABLE_END_LABEL, &binding); + + /* If there is a tag table, find the start of it, and grovel over it + extracting tag information. */ + if (position != -1) + while (1) + { + long tags_table_begin, tags_table_end; + + binding.end = position; + binding.start = binding.end - 5 - strlen (TAGS_TABLE_END_LABEL); + if (binding.start < 0) + binding.start = 0; + + position = find_node_separator (&binding); + + /* For this test, (and all others here) failure indicates a bogus + tags table. Grovel the file. */ + if (position == -1) + break; + + /* Remember the end of the tags table. */ + binding.start = position; + tags_table_end = binding.start; + binding.end = 0; + + /* Locate the start of the tags table. */ + position = search_backward (TAGS_TABLE_BEG_LABEL, &binding); + + if (position == -1) + break; + + binding.end = position; + binding.start = binding.end - 5 - strlen (TAGS_TABLE_BEG_LABEL); + position = find_node_separator (&binding); + + if (position == -1) + break; + + /* The file contains a valid tags table. Fill the FILE_BUFFER's + tags member. */ + file_buffer->flags |= N_HasTagsTable; + tags_table_begin = position; + + /* If this isn't an indirect tags table, just remember the nodes + described locally in this tags table. Note that binding.end + is pointing to just after the beginning label. */ + binding.start = binding.end; + binding.end = file_buffer->filesize; + + if (!looking_at (TAGS_TABLE_IS_INDIRECT_LABEL, &binding)) + { + binding.start = tags_table_begin; + binding.end = tags_table_end; + get_nodes_of_tags_table (file_buffer, &binding); + return; + } + else + { + /* This is an indirect tags table. Build TAGS member. */ + SEARCH_BINDING indirect; + + indirect.start = tags_table_begin; + indirect.end = 0; + indirect.buffer = binding.buffer; + indirect.flags = S_FoldCase; + + position = search_backward (INDIRECT_TAGS_TABLE_LABEL, &indirect); + + if (position == -1) + { + /* This file is malformed. Give up. */ + return; + } + + indirect.start = position; + indirect.end = tags_table_begin; + binding.start = tags_table_begin; + binding.end = tags_table_end; + get_tags_of_indirect_tags_table (file_buffer, &indirect, &binding); + return; + } + } + + /* This file doesn't contain any kind of tags table. Grovel the + file and build node entries for it. */ + get_nodes_of_info_file (file_buffer); +} + +/* Search through FILE_BUFFER->contents building an array of TAG *, + one entry per each node present in the file. Store the tags in + FILE_BUFFER->tags, and the number of allocated slots in + FILE_BUFFER->tags_slots. */ +static void +get_nodes_of_info_file (file_buffer) + FILE_BUFFER *file_buffer; +{ + long nodestart; + int tags_index = 0; + SEARCH_BINDING binding; + + binding.buffer = file_buffer->contents; + binding.start = 0; + binding.end = file_buffer->filesize; + binding.flags = S_FoldCase; + + while ((nodestart = find_node_separator (&binding)) != -1) + { + int start, end; + char *nodeline; + TAG *entry; + + /* Skip past the characters just found. */ + binding.start = nodestart; + binding.start += skip_node_separator (binding.buffer + binding.start); + + /* Move to the start of the line defining the node. */ + nodeline = binding.buffer + binding.start; + + /* Find "Node:" */ + start = string_in_line (INFO_NODE_LABEL, nodeline); + + /* If not there, this is not the start of a node. */ + if (start == -1) + continue; + + /* Find the start of the nodename. */ + start += skip_whitespace (nodeline + start); + + /* Find the end of the nodename. */ + end = start + + skip_node_characters (nodeline + start, DONT_SKIP_NEWLINES); + + /* Okay, we have isolated the node name, and we know where the + node starts. Remember this information in a NODE structure. */ + entry = (TAG *)xmalloc (sizeof (TAG)); + entry->nodename = (char *)xmalloc (1 + (end - start)); + strncpy (entry->nodename, nodeline + start, end - start); + entry->nodename[end - start] = '\0'; + entry->nodestart = nodestart; + { + SEARCH_BINDING node_body; + + node_body.buffer = binding.buffer + binding.start; + node_body.start = 0; + node_body.end = binding.end - binding.start; + node_body.flags = S_FoldCase; + entry->nodelen = get_node_length (&node_body); + } + + entry->filename = file_buffer->fullpath; + + /* Add this tag to the array of tag structures in this FILE_BUFFER. */ + add_pointer_to_array (entry, tags_index, file_buffer->tags, + file_buffer->tags_slots, 100, TAG *); + } +} + +/* Return the length of the node which starts at BINDING. */ +static long +get_node_length (binding) + SEARCH_BINDING *binding; +{ + register int i; + char *body; + + /* From the Info-RFC file: + [A node] ends with either a ^_, a ^L, or the end of file. */ + for (i = binding->start, body = binding->buffer; i < binding->end; i++) + { + if (body[i] == INFO_FF || body[i] == INFO_COOKIE) + break; + } + return ((long) i - binding->start); +} + +/* Build and save the array of nodes in FILE_BUFFER by searching through the + contents of BUFFER_BINDING for a tags table, and groveling the contents. */ +static void +get_nodes_of_tags_table (file_buffer, buffer_binding) + FILE_BUFFER *file_buffer; + SEARCH_BINDING *buffer_binding; +{ + int offset, tags_index = 0; + SEARCH_BINDING *search; + long position; + + search = copy_binding (buffer_binding); + + /* Find the start of the tags table. */ + position = find_tags_table (search); + + /* If none, we're all done. */ + if (position == -1) + return; + + /* Move to one character before the start of the actual table. */ + search->start = position; + search->start += skip_node_separator (search->buffer + search->start); + search->start += strlen (TAGS_TABLE_BEG_LABEL); + search->start--; + + /* The tag table consists of lines containing node names and positions. + Do each line until we find one that doesn't contain a node name. */ + while ((position = search_forward ("\n", search)) != -1) + { + TAG *entry; + char *nodedef; + + /* Prepare to skip this line. */ + search->start = position; + search->start++; + + /* Skip past informative "(Indirect)" tags table line. */ + if (!tags_index && looking_at (TAGS_TABLE_IS_INDIRECT_LABEL, search)) + continue; + + /* Find the label preceding the node name. */ + offset = + string_in_line (INFO_NODE_LABEL, search->buffer + search->start); + + /* If not there, not a defining line, so we must be out of the + tags table. */ + if (offset == -1) + break; + + /* Point to the beginning of the node definition. */ + search->start += offset; + nodedef = search->buffer + search->start; + nodedef += skip_whitespace (nodedef); + + /* Move past the node's name. */ + for (offset = 0; + (nodedef[offset]) && (nodedef[offset] != INFO_TAGSEP); + offset++); + + if (nodedef[offset] != INFO_TAGSEP) + continue; + + entry = (TAG *)xmalloc (sizeof (TAG)); + entry->nodename = (char *)xmalloc (1 + offset); + strncpy (entry->nodename, nodedef, offset); + entry->nodename[offset] = '\0'; + offset++; + entry->nodestart = (long) atol (nodedef + offset); + + /* We don't know the length of this node yet. */ + entry->nodelen = -1; + + /* The filename of this node is currently known as the same as the + name of this file. */ + entry->filename = file_buffer->fullpath; + + /* Add this node structure to the array of node structures in this + FILE_BUFFER. */ + add_pointer_to_array (entry, tags_index, file_buffer->tags, + file_buffer->tags_slots, 100, TAG *); + } + free (search); +} + +/* A structure used only in get_tags_of_indirect_tags_table () to hold onto + an intermediate value. */ +typedef struct { + char *filename; + long first_byte; +} SUBFILE; + +/* Remember in FILE_BUFFER the nodenames, subfilenames, and offsets within the + subfiles of every node which appears in TAGS_BINDING. The 2nd argument is + a binding surrounding the indirect files list. */ +static void +get_tags_of_indirect_tags_table (file_buffer, indirect_binding, tags_binding) + FILE_BUFFER *file_buffer; + SEARCH_BINDING *indirect_binding, *tags_binding; +{ + register int i; + SUBFILE **subfiles = (SUBFILE **)NULL; + int subfiles_index = 0, subfiles_slots = 0; + TAG *entry; + + /* First get the list of tags from the tags table. Then lookup the + associated file in the indirect list for each tag, and update it. */ + get_nodes_of_tags_table (file_buffer, tags_binding); + + /* We have the list of tags in file_buffer->tags. Get the list of + subfiles from the indirect table. */ + { + char *start, *end, *line; + SUBFILE *subfile; + + start = indirect_binding->buffer + indirect_binding->start; + end = indirect_binding->buffer + indirect_binding->end; + line = start; + + while (line < end) + { + int colon; + + colon = string_in_line (":", line); + + if (colon == -1) + break; + + subfile = (SUBFILE *)xmalloc (sizeof (SUBFILE)); + subfile->filename = (char *)xmalloc (colon); + strncpy (subfile->filename, line, colon - 1); + subfile->filename[colon - 1] = '\0'; + subfile->first_byte = (long) atol (line + colon); + + add_pointer_to_array + (subfile, subfiles_index, subfiles, subfiles_slots, 10, SUBFILE *); + + while (*line++ != '\n'); + } + } + + /* If we have successfully built the indirect files table, then + merge the information in the two tables. */ + if (!subfiles) + { + free_file_buffer_tags (file_buffer); + return; + } + else + { + register int tags_index; + long header_length; + SEARCH_BINDING binding; + + /* Find the length of the header of the file containing the indirect + tags table. This header appears at the start of every file. We + want the absolute position of each node within each subfile, so + we subtract the start of the containing subfile from the logical + position of the node, and then add the length of the header in. */ + binding.buffer = file_buffer->contents; + binding.start = 0; + binding.end = file_buffer->filesize; + binding.flags = S_FoldCase; + + header_length = find_node_separator (&binding); + if (header_length == -1) + header_length = 0; + + /* Build the file buffer's list of subfiles. */ + { + char *containing_dir, *temp; + int len_containing_dir; + + containing_dir = strdup (file_buffer->fullpath); + temp = (char *) strrchr (containing_dir, '/'); + + if (temp) + *temp = '\0'; + + len_containing_dir = strlen (containing_dir); + + for (i = 0; subfiles[i]; i++); + + file_buffer->subfiles = (char **) xmalloc ((1 + i) * sizeof (char *)); + + for (i = 0; subfiles[i]; i++) + { + char *fullpath; + + fullpath = (char *) xmalloc + (2 + strlen (subfiles[i]->filename) + len_containing_dir); + + sprintf (fullpath, "%s/%s", + containing_dir, subfiles[i]->filename); + + file_buffer->subfiles[i] = fullpath; + } + file_buffer->subfiles[i] = (char *)NULL; + free (containing_dir); + } + + /* For each node in the file's tags table, remember the starting + position. */ + for (tags_index = 0; + entry = file_buffer->tags[tags_index]; + tags_index++) + { + for (i = 0; + subfiles[i] && entry->nodestart >= subfiles[i]->first_byte; + i++); + + /* If the Info file containing the indirect tags table is + malformed, then give up. */ + if (!i) + { + /* The Info file containing the indirect tags table is + malformed. Give up. */ + for (i = 0; subfiles[i]; i++) + { + free (subfiles[i]->filename); + free (subfiles[i]); + free (file_buffer->subfiles[i]); + } + file_buffer->subfiles = (char **)NULL; + free_file_buffer_tags (file_buffer); + return; + } + + /* SUBFILES[i] is the index of the first subfile whose logical + first byte is greater than the logical offset of this node's + starting position. This means that the subfile directly + preceding this one is the one containing the node. */ + + entry->filename = file_buffer->subfiles[i - 1]; + entry->nodestart -= subfiles[i -1]->first_byte; + entry->nodestart += header_length; + entry->nodelen = -1; + } + + /* We have successfully built the tags table. Remember that it + was indirect. */ + file_buffer->flags |= N_TagsIndirect; + } + + /* Free the structures assigned to SUBFILES. Free the names as well + as the structures themselves, then finally, the array. */ + for (i = 0; subfiles[i]; i++) + { + free (subfiles[i]->filename); + free (subfiles[i]); + } + free (subfiles); +} + +/* Return the node from FILE_BUFFER which matches NODENAME by searching + the tags table in FILE_BUFFER. If the node could not be found, return + a NULL pointer. */ +static NODE * +info_node_of_file_buffer_tags (file_buffer, nodename) + FILE_BUFFER *file_buffer; + char *nodename; +{ + register int i; + TAG *tag; + + for (i = 0; tag = file_buffer->tags[i]; i++) + if (strcmp (nodename, tag->nodename) == 0) + { + FILE_BUFFER *subfile; + + subfile = info_find_file_internal (tag->filename, INFO_NO_TAGS); + + if (!subfile) + return ((NODE *)NULL); + + if (!subfile->contents) + { + info_reload_file_buffer_contents (subfile); + + if (!subfile->contents) + return ((NODE *)NULL); + } + + /* If we were able to find this file and load it, then return + the node within it. */ + { + NODE *node; + + node = (NODE *)xmalloc (sizeof (NODE)); + node->filename = (subfile->fullpath); + node->nodename = tag->nodename; + node->contents = subfile->contents + tag->nodestart; + node->flags = 0; + node->parent = (char *)NULL; + + if (file_buffer->flags & N_HasTagsTable) + { + node->flags |= N_HasTagsTable; + + if (file_buffer->flags & N_TagsIndirect) + { + node->flags |= N_TagsIndirect; + node->parent = file_buffer->fullpath; + } + } + + if (subfile->flags & N_IsCompressed) + node->flags |= N_IsCompressed; + + /* If TAG->nodelen hasn't been calculated yet, then we aren't + in a position to trust the entry pointer. Adjust things so + that ENTRY->nodestart gets the exact address of the start of + the node separator which starts this node, and NODE->contents + gets the address of the line defining this node. If we cannot + do that, the node isn't really here. */ + if (tag->nodelen == -1) + { + int min, max; + char *node_sep; + SEARCH_BINDING node_body; + char *buff_end; + + min = max = DEFAULT_INFO_FUDGE; + + if (tag->nodestart < DEFAULT_INFO_FUDGE) + min = tag->nodestart; + + if (DEFAULT_INFO_FUDGE > + (subfile->filesize - tag->nodestart)) + max = subfile->filesize - tag->nodestart; + + /* NODE_SEP gets the address of the separator which defines + this node, or (char *)NULL if the node wasn't found. + NODE->contents is side-effected to point to right after + the separator. */ + node_sep = adjust_nodestart (node, min, max); + if (node_sep == (char *)NULL) + { + free (node); + return ((NODE *)NULL); + } + /* Readjust tag->nodestart. */ + tag->nodestart = node_sep - subfile->contents; + + /* Calculate the length of the current node. */ + buff_end = subfile->contents + subfile->filesize; + + node_body.buffer = node->contents; + node_body.start = 0; + node_body.end = buff_end - node_body.buffer; + node_body.flags = 0; + tag->nodelen = get_node_length (&node_body); + } + else + { + /* Since we know the length of this node, we have already + adjusted tag->nodestart to point to the exact start of + it. Simply skip the node separator. */ + node->contents += skip_node_separator (node->contents); + } + + node->nodelen = tag->nodelen; + return (node); + } + } + + /* There was a tag table for this file, and the node wasn't found. + Return NULL, since this file doesn't contain the desired node. */ + return ((NODE *)NULL); +} + +/* **************************************************************** */ +/* */ +/* Managing file_buffers, nodes, and tags. */ +/* */ +/* **************************************************************** */ + +/* Create a new, empty file buffer. */ +FILE_BUFFER * +make_file_buffer () +{ + FILE_BUFFER *file_buffer; + + file_buffer = (FILE_BUFFER *)xmalloc (sizeof (FILE_BUFFER)); + file_buffer->filename = file_buffer->fullpath = (char *)NULL; + file_buffer->contents = (char *)NULL; + file_buffer->tags = (TAG **)NULL; + file_buffer->subfiles = (char **)NULL; + file_buffer->tags_slots = 0; + file_buffer->flags = 0; + + return (file_buffer); +} + +/* Add FILE_BUFFER to our list of already loaded info files. */ +static void +remember_info_file (file_buffer) + FILE_BUFFER *file_buffer; +{ + int i; + + for (i = 0; info_loaded_files && info_loaded_files[i]; i++) + ; + + add_pointer_to_array (file_buffer, i, info_loaded_files, + info_loaded_files_slots, 10, FILE_BUFFER *); +} + +/* Forget the contents, tags table, nodes list, and names of FILENAME. */ +static void +forget_info_file (filename) + char *filename; +{ + register int i; + FILE_BUFFER *file_buffer; + + if (!info_loaded_files) + return; + + for (i = 0; file_buffer = info_loaded_files[i]; i++) + if ((strcmp (filename, file_buffer->filename) == 0) || + (strcmp (filename, file_buffer->fullpath) == 0)) + { + free (file_buffer->filename); + free (file_buffer->fullpath); + + if (file_buffer->contents) + free (file_buffer->contents); + + /* Note that free_file_buffer_tags () also kills the subfiles + list, since the subfiles list is only of use in conjunction + with tags. */ + free_file_buffer_tags (file_buffer); + + while (info_loaded_files[i] = info_loaded_files[++i]) + ; + + break; + } +} + +/* Free the tags (if any) associated with FILE_BUFFER. */ +static void +free_file_buffer_tags (file_buffer) + FILE_BUFFER *file_buffer; +{ + register int i; + + if (file_buffer->tags) + { + register TAG *tag; + + for (i = 0; tag = file_buffer->tags[i]; i++) + free_info_tag (tag); + + free (file_buffer->tags); + file_buffer->tags = (TAG **)NULL; + file_buffer->tags_slots = 0; + } + + if (file_buffer->subfiles) + { + for (i = 0; file_buffer->subfiles[i]; i++) + free (file_buffer->subfiles[i]); + + free (file_buffer->subfiles); + file_buffer->subfiles = (char **)NULL; + } +} + +/* Free the data associated with TAG, as well as TAG itself. */ +static void +free_info_tag (tag) + TAG *tag; +{ + free (tag->nodename); + + /* We don't free tag->filename, because that filename is part of the + subfiles list for the containing FILE_BUFFER. free_info_tags () + will free the subfiles when it is appropriate. */ + + free (tag); +} + +/* Load the contents of FILE_BUFFER->contents. This function is called + when a file buffer was loaded, and then in order to conserve memory, the + file buffer's contents were freed and the pointer was zero'ed. Note that + the file was already loaded at least once successfully, so the tags and/or + nodes members are still correctly filled. */ +static void +info_reload_file_buffer_contents (fb) + FILE_BUFFER *fb; +{ + +#if defined (HANDLE_MAN_PAGES) + /* If this is the magic manpage node, don't try to reload, just give up. */ + if (fb->flags & N_IsManPage) + return; +#endif + + fb->flags &= ~N_IsCompressed; + + /* Let the filesystem do all the work for us. */ + fb->contents = + filesys_read_info_file (fb->fullpath, &(fb->filesize), &(fb->finfo)); + if (fb->filesize != (long) (fb->finfo.st_size)) + fb->flags |= N_IsCompressed; +} + +/* Return the actual starting memory location of NODE, side-effecting + NODE->contents. MIN and MAX are bounds for a search if one is necessary. + Because of the way that tags are implemented, the physical nodestart may + not actually be where the tag says it is. If that is the case, but the + node was found anyway, set N_UpdateTags in NODE->flags. If the node is + found, return non-zero. NODE->contents is returned positioned right after + the node separator that precedes this node, while the return value is + position directly on the separator that precedes this node. If the node + could not be found, return a NULL pointer. */ +static char * +adjust_nodestart (node, min, max) + NODE *node; + int min, max; +{ + long position; + SEARCH_BINDING node_body; + + /* Define the node body. */ + node_body.buffer = node->contents; + node_body.start = 0; + node_body.end = max; + node_body.flags = 0; + + /* Try the optimal case first. Who knows? This file may actually be + formatted (mostly) correctly. */ + if (node_body.buffer[0] != INFO_COOKIE && min > 2) + node_body.buffer -= 3; + + position = find_node_separator (&node_body); + + /* If we found a node start, then check it out. */ + if (position != -1) + { + int sep_len; + + sep_len = skip_node_separator (node->contents); + + /* If we managed to skip a node separator, then check for this node + being the right one. */ + if (sep_len != 0) + { + char *nodedef, *nodestart; + int offset; + + nodestart = node_body.buffer + position + sep_len; + nodedef = nodestart; + offset = string_in_line (INFO_NODE_LABEL, nodedef); + + if (offset != -1) + { + nodedef += offset; + nodedef += skip_whitespace (nodedef); + offset = skip_node_characters (nodedef, DONT_SKIP_NEWLINES); + if ((offset == strlen (node->nodename)) && + (strncmp (node->nodename, nodedef, offset) == 0)) + { + node->contents = nodestart; + return (node_body.buffer + position); + } + } + } + } + + /* Oh well, I guess we have to try to find it in a larger area. */ + node_body.buffer = node->contents - min; + node_body.start = 0; + node_body.end = min + max; + node_body.flags = 0; + + position = find_node_in_binding (node->nodename, &node_body); + + /* If the node couldn't be found, we lose big. */ + if (position == -1) + return ((char *)NULL); + + /* Otherwise, the node was found, but the tags table could need updating + (if we used a tag to get here, that is). Set the flag in NODE->flags. */ + node->contents = node_body.buffer + position; + node->contents += skip_node_separator (node->contents); + if (node->flags & N_HasTagsTable) + node->flags |= N_UpdateTags; + return (node_body.buffer + position); +} diff --git a/texinfo/info/nodes.h b/texinfo/info/nodes.h new file mode 100644 index 000000000000..7ddea17ddda9 --- /dev/null +++ b/texinfo/info/nodes.h @@ -0,0 +1,168 @@ +/* nodes.h -- How we represent nodes internally. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_NODES_H_) +#define _NODES_H_ + +#include "general.h" + +/* **************************************************************** */ +/* */ +/* User Code Interface */ +/* */ +/* **************************************************************** */ + +/* Callers generally only want the node itself. This structure is used + to pass node information around. None of the information in this + structure should ever be directly freed. The structure itself can + be passed to free (). Note that NODE->parent is non-null if this + node's file is a subfile. In that case, NODE->parent is the logical + name of the file containing this node. Both names are given as full + paths, so you might have: node->filename = "/usr/gnu/info/emacs-1", + with node->parent = "/usr/gnu/info/emacs". */ +typedef struct { + char *filename; /* The physical file containing this node. */ + char *parent; /* Non-null is the logical file name. */ + char *nodename; /* The name of this node. */ + char *contents; /* Characters appearing in this node. */ + long nodelen; /* The length of the CONTENTS member. */ + int flags; /* See immediately below. */ +} NODE; + +/* Defines that can appear in NODE->flags. All informative. */ +#define N_HasTagsTable 0x01 /* This node was found through a tags table. */ +#define N_TagsIndirect 0x02 /* The tags table was an indirect one. */ +#define N_UpdateTags 0x04 /* The tags table is out of date. */ +#define N_IsCompressed 0x08 /* The file is compressed on disk. */ +#define N_IsInternal 0x10 /* This node was made by Info. */ +#define N_CannotGC 0x20 /* File buffer cannot be gc'ed. */ +#define N_IsManPage 0x40 /* This node is a Un*x manpage. */ + +/* **************************************************************** */ +/* */ +/* Internal Data Structures */ +/* */ +/* **************************************************************** */ + +/* Some defines describing details about Info file contents. */ + +/* String Constants. */ +#define INFO_FILE_LABEL "File:" +#define INFO_NODE_LABEL "Node:" +#define INFO_PREV_LABEL "Prev:" +#define INFO_ALTPREV_LABEL "Previous:" +#define INFO_NEXT_LABEL "Next:" +#define INFO_UP_LABEL "Up:" +#define INFO_MENU_LABEL "\n* Menu:" +#define INFO_MENU_ENTRY_LABEL "\n* " +#define INFO_XREF_LABEL "*Note" +#define TAGS_TABLE_END_LABEL "\nEnd Tag Table" +#define TAGS_TABLE_BEG_LABEL "Tag Table:\n" +#define INDIRECT_TAGS_TABLE_LABEL "Indirect:\n" +#define TAGS_TABLE_IS_INDIRECT_LABEL "(Indirect)" + +/* Character Constants. */ +#define INFO_COOKIE '\037' +#define INFO_FF '\014' +#define INFO_TAGSEP '\177' + +/* For each logical file that we have loaded, we keep a list of the names + of the nodes that are found in that file. A pointer to a node in an + info file is called a "tag". For split files, the tag pointer is + "indirect"; that is, the pointer also contains the name of the split + file where the node can be found. For non-split files, the filename + member in the structure below simply contains the name of the current + file. The following structure describes a single node within a file. */ +typedef struct { + char *filename; /* The file where this node can be found. */ + char *nodename; /* The node pointed to by this tag. */ + long nodestart; /* The offset of the start of this node. */ + long nodelen; /* The length of this node. */ +} TAG; + +/* The following structure is used to remember information about the contents + of Info files that we have loaded at least once before. The FINFO member + is present so that we can reload the file if it has been modified since + last being loaded. All of the arrays appearing within this structure + are NULL terminated, and each array which can change size has a + corresponding SLOTS member which says how many slots have been allocated + (with malloc ()) for this array. */ +typedef struct { + char *filename; /* The filename used to find this file. */ + char *fullpath; /* The full pathname of this info file. */ + struct stat finfo; /* Information about this file. */ + char *contents; /* The contents of this particular file. */ + long filesize; /* The number of bytes this file expands to. */ + char **subfiles; /* If non-null, the list of subfiles. */ + TAG **tags; /* If non-null, the indirect tags table. */ + int tags_slots; /* Number of slots allocated for TAGS. */ + int flags; /* Various flags. Mimics of N_* flags. */ +} FILE_BUFFER; + +/* **************************************************************** */ +/* */ +/* Externally Visible Functions */ +/* */ +/* **************************************************************** */ + +/* Array of FILE_BUFFER * which represents the currently loaded info files. */ +extern FILE_BUFFER **info_loaded_files; + +/* The number of slots currently allocated to INFO_LOADED_FILES. */ +extern int info_loaded_files_slots; + +/* Locate the file named by FILENAME, and return the information structure + describing this file. The file may appear in our list of loaded files + already, or it may not. If it does not already appear, find the file, + and add it to the list of loaded files. If the file cannot be found, + return a NULL FILE_BUFFER *. */ +extern FILE_BUFFER *info_find_file (); + +/* Force load the file named FILENAME, and return the information structure + describing this file. Even if the file was already loaded, this loads + a new buffer, rebuilds tags and nodes, and returns a new FILE_BUFFER *. */ +extern FILE_BUFFER *info_load_file (); + +/* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME. + FILENAME can be passed as NULL, in which case the filename of "dir" is used. + NODENAME can be passed as NULL, in which case the nodename of "Top" is used. + If the node cannot be found, return a NULL pointer. */ +extern NODE *info_get_node (); + +/* Return a pointer to a NODE structure for the Info node NODENAME in + FILE_BUFFER. NODENAME can be passed as NULL, in which case the + nodename of "Top" is used. If the node cannot be found, return a + NULL pointer. */ +extern NODE *info_get_node_of_file_buffer (); + +/* Grovel FILE_BUFFER->contents finding tags and nodes, and filling in the + various slots. This can also be used to rebuild a tag or node table. */ +extern void build_tags_and_nodes (); + +/* When non-zero, this is a string describing the most recent file error. */ +extern char *info_recent_file_error; + +/* Create a new, empty file buffer. */ +extern FILE_BUFFER *make_file_buffer (); + +#endif /* !_NODES_H_ */ diff --git a/texinfo/info/search.c b/texinfo/info/search.c new file mode 100644 index 000000000000..c5fd47794b08 --- /dev/null +++ b/texinfo/info/search.c @@ -0,0 +1,519 @@ +/* search.c -- How to search large bodies of text. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include +#include +#include "general.h" +#include "search.h" +#include "nodes.h" + +#if !defined (NULL) +# define NULL 0x0 +#endif /* !NULL */ + +/* The search functions take two arguments: + + 1) a string to search for, and + + 2) a pointer to a SEARCH_BINDING which contains the buffer, start, + and end of the search. + + They return a long, which is the offset from the start of the buffer + at which the match was found. An offset of -1 indicates failure. */ + +/* A function which makes a binding with buffer and bounds. */ +SEARCH_BINDING * +make_binding (buffer, start, end) + char *buffer; + long start, end; +{ + SEARCH_BINDING *binding; + + binding = (SEARCH_BINDING *)xmalloc (sizeof (SEARCH_BINDING)); + binding->buffer = buffer; + binding->start = start; + binding->end = end; + binding->flags = 0; + + return (binding); +} + +/* Make a copy of BINDING without duplicating the data. */ +SEARCH_BINDING * +copy_binding (binding) + SEARCH_BINDING *binding; +{ + SEARCH_BINDING *copy; + + copy = make_binding (binding->buffer, binding->start, binding->end); + copy->flags = binding->flags; + return (copy); +} + + +/* **************************************************************** */ +/* */ +/* The Actual Searching Functions */ +/* */ +/* **************************************************************** */ + +/* Search forwards or backwards for the text delimited by BINDING. + The search is forwards if BINDING->start is greater than BINDING->end. */ +long +search (string, binding) + char *string; + SEARCH_BINDING *binding; +{ + long result; + + /* If the search is backwards, then search backwards, otherwise forwards. */ + if (binding->start > binding->end) + result = search_backward (string, binding); + else + result = search_forward (string, binding); + + return (result); +} + +/* Search forwards for STRING through the text delimited in BINDING. */ +long +search_forward (string, binding) + char *string; + SEARCH_BINDING *binding; +{ + register int c, i, len; + register char *buff, *end; + char *alternate = (char *)NULL; + + len = strlen (string); + + /* We match characters in the search buffer against STRING and ALTERNATE. + ALTERNATE is a case reversed version of STRING; this is cheaper than + case folding each character before comparison. Alternate is only + used if the case folding bit is turned on in the passed BINDING. */ + + if (binding->flags & S_FoldCase) + { + alternate = strdup (string); + + for (i = 0; i < len; i++) + { + if (islower (alternate[i])) + alternate[i] = toupper (alternate[i]); + else if (isupper (alternate[i])) + alternate[i] = tolower (alternate[i]); + } + } + + buff = binding->buffer + binding->start; + end = binding->buffer + binding->end + 1; + + while (buff < (end - len)) + { + for (i = 0; i < len; i++) + { + c = buff[i]; + + if ((c != string[i]) && (!alternate || c != alternate[i])) + break; + } + + if (!string[i]) + { + if (alternate) + free (alternate); + if (binding->flags & S_SkipDest) + buff += len; + return ((long) (buff - binding->buffer)); + } + + buff++; + } + + if (alternate) + free (alternate); + + return ((long) -1); +} + +/* Search for STRING backwards through the text delimited in BINDING. */ +long +search_backward (input_string, binding) + char *input_string; + SEARCH_BINDING *binding; +{ + register int c, i, len; + register char *buff, *end; + char *string; + char *alternate = (char *)NULL; + + len = strlen (input_string); + + /* Reverse the characters in the search string. */ + string = (char *)xmalloc (1 + len); + for (c = 0, i = len - 1; input_string[c]; c++, i--) + string[i] = input_string[c]; + + string[c] = '\0'; + + /* We match characters in the search buffer against STRING and ALTERNATE. + ALTERNATE is a case reversed version of STRING; this is cheaper than + case folding each character before comparison. ALTERNATE is only + used if the case folding bit is turned on in the passed BINDING. */ + + if (binding->flags & S_FoldCase) + { + alternate = strdup (string); + + for (i = 0; i < len; i++) + { + if (islower (alternate[i])) + alternate[i] = toupper (alternate[i]); + else if (isupper (alternate[i])) + alternate[i] = tolower (alternate[i]); + } + } + + buff = binding->buffer + binding->start - 1; + end = binding->buffer + binding->end; + + while (buff > (end + len)) + { + for (i = 0; i < len; i++) + { + c = *(buff - i); + + if (c != string[i] && (alternate && c != alternate[i])) + break; + } + + if (!string[i]) + { + free (string); + if (alternate) + free (alternate); + + if (binding->flags & S_SkipDest) + buff -= len; + return ((long) (1 + (buff - binding->buffer))); + } + + buff--; + } + + free (string); + if (alternate) + free (alternate); + + return ((long) -1); +} + +/* Find STRING in LINE, returning the offset of the end of the string. + Return an offset of -1 if STRING does not appear in LINE. The search + is bound by the end of the line (i.e., either NEWLINE or 0). */ +int +string_in_line (string, line) + char *string, *line; +{ + register int end; + SEARCH_BINDING binding; + + /* Find the end of the line. */ + for (end = 0; line[end] && line[end] != '\n'; end++); + + /* Search for STRING within these confines. */ + binding.buffer = line; + binding.start = 0; + binding.end = end; + binding.flags = S_FoldCase | S_SkipDest; + + return (search_forward (string, &binding)); +} + +/* Return non-zero if STRING is the first text to appear at BINDING. */ +int +looking_at (string, binding) + char *string; + SEARCH_BINDING *binding; +{ + long search_end; + + search_end = search (string, binding); + + /* If the string was not found, SEARCH_END is -1. If the string was found, + but not right away, SEARCH_END is != binding->start. Otherwise, the + string was found at binding->start. */ + return (search_end == binding->start); +} + +/* **************************************************************** */ +/* */ +/* Small String Searches */ +/* */ +/* **************************************************************** */ + +/* Function names that start with "skip" are passed a string, and return + an offset from the start of that string. Function names that start + with "find" are passed a SEARCH_BINDING, and return an absolute position + marker of the item being searched for. "Find" functions return a value + of -1 if the item being looked for couldn't be found. */ + +/* Return the index of the first non-whitespace character in STRING. */ +int +skip_whitespace (string) + char *string; +{ + register int i; + + for (i = 0; string && whitespace (string[i]); i++); + return (i); +} + +/* Return the index of the first non-whitespace or newline character in + STRING. */ +int +skip_whitespace_and_newlines (string) + char *string; +{ + register int i; + + for (i = 0; string && (whitespace (string[i]) || string[i] == '\n'); i++); + return (i); +} + +/* Return the index of the first whitespace character in STRING. */ +int +skip_non_whitespace (string) + char *string; +{ + register int i; + + for (i = 0; string && !whitespace (string[i]); i++); + return (i); +} + +/* Return the index of the first non-node character in STRING. Note that + this function contains quite a bit of hair to ignore periods in some + special cases. This is because we here at GNU ship some info files which + contain nodenames that contain periods. No such nodename can start with + a period, or continue with whitespace, newline, or ')' immediately following + the period. If second argument NEWLINES_OKAY is non-zero, newlines should + be skipped while parsing out the nodename specification. */ +int +skip_node_characters (string, newlines_okay) + char *string; + int newlines_okay; +{ + register int c, i = 0; + int paren_seen = 0; + int paren = 0; + + /* Handle special case. This is when another function has parsed out the + filename component of the node name, and we just want to parse out the + nodename proper. In that case, a period at the start of the nodename + indicates an empty nodename. */ + if (string && *string == '.') + return (0); + + if (string && *string == '(') + { + paren++; + paren_seen++; + i++; + } + + for (; string && (c = string[i]); i++) + { + if (paren) + { + if (c == '(') + paren++; + else if (c == ')') + paren--; + + continue; + } + + /* If the character following the close paren is a space or period, + then this node name has no more characters associated with it. */ + if (c == '\t' || + c == ',' || + c == INFO_TAGSEP || + ((!newlines_okay) && (c == '\n')) || + ((paren_seen && string[i - 1] == ')') && + (c == ' ' || c == '.')) || + (c == '.' && + ((!string[i + 1]) || + (whitespace_or_newline (string[i + 1])) || + (string[i + 1] == ')')))) + break; + } + return (i); +} + + +/* **************************************************************** */ +/* */ +/* Searching FILE_BUFFER's */ +/* */ +/* **************************************************************** */ + +/* Return the absolute position of the first occurence of a node separator in + BINDING-buffer. The search starts at BINDING->start. Return -1 if no node + separator was found. */ +long +find_node_separator (binding) + SEARCH_BINDING *binding; +{ + register long i; + char *body; + + body = binding->buffer; + + /* A node is started by [^L]^_[^L]\n. That is to say, the C-l's are + optional, but the DELETE and NEWLINE are not. This separator holds + true for all separated elements in an Info file, including the tags + table (if present) and the indirect tags table (if present). */ + for (i = binding->start; i < binding->end - 1; i++) + if (((body[i] == INFO_FF && body[i + 1] == INFO_COOKIE) && + (body[i + 2] == '\n' || + (body[i + 2] == INFO_FF && body[i + 3] == '\n'))) || + ((body[i] == INFO_COOKIE) && + (body[i + 1] == '\n' || + (body[i + 1] == INFO_FF && body[i + 2] == '\n')))) + return (i); + return (-1); +} + +/* Return the length of the node separator characters that BODY is + currently pointing at. */ +int +skip_node_separator (body) + char *body; +{ + register int i; + + i = 0; + + if (body[i] == INFO_FF) + i++; + + if (body[i++] != INFO_COOKIE) + return (0); + + if (body[i] == INFO_FF) + i++; + + if (body[i++] != '\n') + return (0); + + return (i); +} + +/* Return the number of characters from STRING to the start of + the next line. */ +int +skip_line (string) + char *string; +{ + register int i; + + for (i = 0; string && string[i] && string[i] != '\n'; i++); + + if (string[i] == '\n') + i++; + + return (i); +} + +/* Return the absolute position of the beginning of a tags table in this + binding starting the search at binding->start. */ +long +find_tags_table (binding) + SEARCH_BINDING *binding; +{ + SEARCH_BINDING search; + long position; + + search.buffer = binding->buffer; + search.start = binding->start; + search.end = binding->end; + search.flags = S_FoldCase; + + while ((position = find_node_separator (&search)) != -1 ) + { + search.start = position; + search.start += skip_node_separator (search.buffer + search.start); + + if (looking_at (TAGS_TABLE_BEG_LABEL, &search)) + return (position); + } + return (-1); +} + +/* Return the absolute position of the node named NODENAME in BINDING. + This is a brute force search, and we wish to avoid it when possible. + This function is called when a tag (indirect or otherwise) doesn't + really point to the right node. It returns the absolute position of + the separator preceding the node. */ +long +find_node_in_binding (nodename, binding) + char *nodename; + SEARCH_BINDING *binding; +{ + register long position; + register int offset, namelen; + SEARCH_BINDING search; + + namelen = strlen (nodename); + + search.buffer = binding->buffer; + search.start = binding->start; + search.end = binding->end; + search.flags = 0; + + while ((position = find_node_separator (&search)) != -1) + { + search.start = position; + search.start += skip_node_separator (search.buffer + search.start); + + offset = string_in_line (INFO_NODE_LABEL, search.buffer + search.start); + + if (offset == -1) + continue; + + search.start += offset; + search.start += skip_whitespace (search.buffer + search.start); + offset = skip_node_characters + (search.buffer + search.start, DONT_SKIP_NEWLINES); + + /* Notice that this is an exact match. You cannot grovel through + the buffer with this function looking for random nodes. */ + if ((offset == namelen) && + (search.buffer[search.start] == nodename[0]) && + (strncmp (search.buffer + search.start, nodename, offset) == 0)) + return (position); + } + return (-1); +} diff --git a/texinfo/info/search.h b/texinfo/info/search.h new file mode 100644 index 000000000000..72695c3f0b63 --- /dev/null +++ b/texinfo/info/search.h @@ -0,0 +1,75 @@ +/* search.h -- Structure used to search large bodies of text, with bounds. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +/* The search functions take two arguments: + + 1) a string to search for, and + + 2) a pointer to a SEARCH_BINDING which contains the buffer, start, + and end of the search. + + They return a long, which is the offset from the start of the buffer + at which the match was found. An offset of -1 indicates failure. */ + +#if !defined (_SEARCH_H_) +#define _SEARCH_H_ + +typedef struct { + char *buffer; /* The buffer of text to search. */ + long start; /* Offset of the start of the search. */ + long end; /* Offset of the end of the searh. */ + int flags; /* Flags controlling the type of search. */ +} SEARCH_BINDING; + +#define S_FoldCase 0x01 /* Set means fold case in searches. */ +#define S_SkipDest 0x02 /* Set means return pointing after the dest. */ + +SEARCH_BINDING *make_binding (), *copy_binding (); +extern long search_forward (), search_backward (), search (); +extern int looking_at (); + +/* Note that STRING_IN_LINE () always returns the offset of the 1st character + after the string. */ +extern int string_in_line (); + +/* Some unixes don't have strcasecmp or strncasecmp. */ +#if !defined (HAVE_STRCASECMP) +extern int strcasecmp (), strncasecmp (); +#endif /* !HAVE_STRCASECMP */ + +/* Function names that start with "skip" are passed a string, and return + an offset from the start of that string. Function names that start + with "find" are passed a SEARCH_BINDING, and return an absolute position + marker of the item being searched for. "Find" functions return a value + of -1 if the item being looked for couldn't be found. */ +extern int skip_whitespace (), skip_non_whitespace (); +extern int skip_whitespace_and_newlines (), skip_line (); +extern int skip_node_characters (), skip_node_separator (); +#define DONT_SKIP_NEWLINES 0 +#define SKIP_NEWLINES 1 + +extern long find_node_separator (), find_tags_table (); +extern long find_node_in_binding (); + +#endif /* !_SEARCH_H_ */ + diff --git a/texinfo/info/session.c b/texinfo/info/session.c new file mode 100644 index 000000000000..be3076c9ac1b --- /dev/null +++ b/texinfo/info/session.c @@ -0,0 +1,4263 @@ +/* session.c -- The user windowing interface to Info. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993, 96 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" +#if defined (HAVE_SYS_FILE_H) +#include +#endif /* HAVE_SYS_FILE_H */ +#include +#include + +#if defined (HAVE_SYS_TIME_H) +# include +# define HAVE_STRUCT_TIMEVAL +#endif /* HAVE_SYS_TIME_H */ + +#if defined (HANDLE_MAN_PAGES) +# include "man.h" +#endif + +static void info_clear_pending_input (), info_set_pending_input (); +static void info_handle_pointer (); + +/* **************************************************************** */ +/* */ +/* Running an Info Session */ +/* */ +/* **************************************************************** */ + +/* The place that we are reading input from. */ +static FILE *info_input_stream = (FILE *)NULL; + +/* The last executed command. */ +VFunction *info_last_executed_command = (VFunction *)NULL; + +/* Becomes non-zero when 'q' is typed to an Info window. */ +int quit_info_immediately = 0; + +/* Array of structures describing for each window which nodes have been + visited in that window. */ +INFO_WINDOW **info_windows = (INFO_WINDOW **)NULL; + +/* Where to add the next window, if we need to add one. */ +static int info_windows_index = 0; + +/* Number of slots allocated to INFO_WINDOWS. */ +static int info_windows_slots = 0; + +void remember_window_and_node (), forget_window_and_nodes (); +void initialize_info_session (), info_session (); +void display_startup_message_and_start (); + +/* Begin an info session finding the nodes specified by FILENAME and NODENAMES. + For each loaded node, create a new window. Always split the largest of the + available windows. */ +void +begin_multiple_window_info_session (filename, nodenames) + char *filename; + char **nodenames; +{ + register int i; + WINDOW *window = (WINDOW *)NULL; + + for (i = 0; nodenames[i]; i++) + { + NODE *node; + + node = info_get_node (filename, nodenames[i]); + + if (!node) + break; + + /* If this is the first node, initialize the info session. */ + if (!window) + { + initialize_info_session (node); + window = active_window; + } + else + { + /* Find the largest window in WINDOWS, and make that be the active + one. Then split it and add our window and node to the list + of remembered windows and nodes. Then tile the windows. */ + register WINDOW *win, *largest = (WINDOW *)NULL; + int max_height = 0; + + for (win = windows; win; win = win->next) + if (win->height > max_height) + { + max_height = win->height; + largest = win; + } + + if (!largest) + { + display_update_display (windows); + info_error (CANT_FIND_WIND); + info_session (); + exit (0); + } + + active_window = largest; + window = window_make_window (node); + if (window) + { + window_tile_windows (TILE_INTERNALS); + remember_window_and_node (window, node); + } + else + { + display_update_display (windows); + info_error (WIN_TOO_SMALL); + info_session (); + exit (0); + } + } + } + display_startup_message_and_start (); +} + +/* Start an info session with INITIAL_NODE, and an error message in the echo + area made from FORMAT and ARG. */ +void +begin_info_session_with_error (initial_node, format, arg) + NODE *initial_node; + char *format; + void *arg; +{ + initialize_info_session (initial_node); + info_error (format, arg, (void *)NULL); + info_session (); +} + +/* Start an info session with INITIAL_NODE. */ +void +begin_info_session (initial_node) + NODE *initial_node; +{ + initialize_info_session (initial_node); + display_startup_message_and_start (); +} + +void +display_startup_message_and_start () +{ + char *format; + + format = replace_in_documentation + ("Welcome to Info version %s. \"\\[get-help-window]\" for help, \"\\[menu-item]\" for menu item."); + + window_message_in_echo_area (format, version_string ()); + info_session (); +} + +/* Run an info session with an already initialized window and node. */ +void +info_session () +{ + terminal_prep_terminal (); + display_update_display (windows); + info_last_executed_command = (VFunction *)NULL; + info_read_and_dispatch (); + /* On program exit, leave the cursor at the bottom of the window, and + restore the terminal I/O. */ + terminal_goto_xy (0, screenheight - 1); + terminal_clear_to_eol (); + fflush (stdout); + terminal_unprep_terminal (); + close_dribble_file (); +} + +/* Here is a window-location dependent event loop. Called from the + functions info_session (), and from read_xxx_in_echo_area (). */ +void +info_read_and_dispatch () +{ + unsigned char key; + int done; + done = 0; + + while (!done && !quit_info_immediately) + { + int lk; + + /* If we haven't just gone up or down a line, there is no + goal column for this window. */ + if ((info_last_executed_command != info_next_line) && + (info_last_executed_command != info_prev_line)) + active_window->goal_column = -1; + + if (echo_area_is_active) + { + lk = echo_area_last_command_was_kill; + echo_area_prep_read (); + } + + if (!info_any_buffered_input_p ()) + display_update_display (windows); + + display_cursor_at_point (active_window); + info_initialize_numeric_arg (); + + initialize_keyseq (); + key = info_get_input_char (); + + /* No errors yet. We just read a character, that's all. Only clear + the echo_area if it is not currently active. */ + if (!echo_area_is_active) + window_clear_echo_area (); + + info_error_was_printed = 0; + + /* Do the selected command. */ + info_dispatch_on_key (key, active_window->keymap); + + if (echo_area_is_active) + { + /* Echo area commands that do killing increment the value of + ECHO_AREA_LAST_COMMAND_WAS_KILL. Thus, if there is no + change in the value of this variable, the last command + executed was not a kill command. */ + if (lk == echo_area_last_command_was_kill) + echo_area_last_command_was_kill = 0; + + if (ea_last_executed_command == ea_newline || + info_aborted_echo_area) + { + ea_last_executed_command = (VFunction *)NULL; + done = 1; + } + + if (info_last_executed_command == info_quit) + quit_info_immediately = 1; + } + else if (info_last_executed_command == info_quit) + done = 1; + } +} + +/* Found in signals.c */ +extern void initialize_info_signal_handler (); + +/* Initialize the first info session by starting the terminal, window, + and display systems. */ +void +initialize_info_session (node) + NODE *node; +{ + char *getenv (), *term_name; + + term_name = getenv ("TERM"); + terminal_initialize_terminal (term_name); + + if (terminal_is_dumb_p) + { + if (!term_name) + term_name = "dumb"; + + info_error (TERM_TOO_DUMB, term_name); + exit (1); + } + + terminal_clear_screen (); + initialize_info_keymaps (); + window_initialize_windows (screenwidth, screenheight); + initialize_info_signal_handler (); + display_initialize_display (screenwidth, screenheight); + info_set_node_of_window (active_window, node); + + /* Tell the window system how to notify us when a window needs to be + asynchronously deleted (e.g., user resizes window very small). */ + window_deletion_notifier = forget_window_and_nodes; + + /* If input has not been redirected yet, make it come from STDIN. */ + if (!info_input_stream) + info_input_stream = stdin; + + info_windows_initialized_p = 1; +} + +/* Tell Info that input is coming from the file FILENAME. */ +void +info_set_input_from_file (filename) + char *filename; +{ + FILE *stream; + + stream = fopen (filename, "r"); + + if (!stream) + return; + + if ((info_input_stream != (FILE *)NULL) && + (info_input_stream != stdin)) + fclose (info_input_stream); + + info_input_stream = stream; + + if (stream != stdin) + display_inhibited = 1; +} + +/* Return the INFO_WINDOW containing WINDOW, or NULL if there isn't one. */ +static INFO_WINDOW * +get_info_window_of_window (window) + WINDOW *window; +{ + register int i; + INFO_WINDOW *info_win = (INFO_WINDOW *)NULL; + + for (i = 0; info_windows && (info_win = info_windows[i]); i++) + if (info_win->window == window) + break; + + return (info_win); +} + +/* Reset the remembered pagetop and point of WINDOW to WINDOW's current + values if the window and node are the same as the current one being + displayed. */ +void +set_remembered_pagetop_and_point (window) + WINDOW *window; +{ + INFO_WINDOW *info_win; + + info_win = get_info_window_of_window (window); + + if (!info_win) + return; + + if (info_win->nodes_index && + (info_win->nodes[info_win->current] == window->node)) + { + info_win->pagetops[info_win->current] = window->pagetop; + info_win->points[info_win->current] = window->point; + } +} + +void +remember_window_and_node (window, node) + WINDOW *window; + NODE *node; +{ + INFO_WINDOW *info_win; + + /* See if we already have this window in our list. */ + info_win = get_info_window_of_window (window); + + /* If the window wasn't already on our list, then make a new entry. */ + if (!info_win) + { + info_win = (INFO_WINDOW *)xmalloc (sizeof (INFO_WINDOW)); + info_win->window = window; + info_win->nodes = (NODE **)NULL; + info_win->pagetops = (int *)NULL; + info_win->points = (long *)NULL; + info_win->current = 0; + info_win->nodes_index = 0; + info_win->nodes_slots = 0; + + add_pointer_to_array (info_win, info_windows_index, info_windows, + info_windows_slots, 10, INFO_WINDOW *); + } + + /* If this node, the current pagetop, and the current point are the + same as the last saved node and pagetop, don't really add this to + the list of history nodes. */ + { + int ni = info_win->nodes_index - 1; + + if ((ni != -1) && + (info_win->nodes[ni]->contents == node->contents) && + (info_win->pagetops[ni] == window->pagetop) && + (info_win->points[ni] == window->point)) + return; + } + + /* Remember this node, the currently displayed pagetop, and the current + location of point in this window. Because we are updating pagetops + and points as well as nodes, it is more efficient to avoid the + add_pointer_to_array macro here. */ + if (info_win->nodes_index + 2 >= info_win->nodes_slots) + { + info_win->nodes = (NODE **) + xrealloc (info_win->nodes, + (info_win->nodes_slots += 20) * sizeof (NODE *)); + + info_win->pagetops = (int *) + xrealloc (info_win->pagetops, info_win->nodes_slots * sizeof (int)); + + info_win->points = (long *) + xrealloc (info_win->points, info_win->nodes_slots * sizeof (long)); + } + + info_win->nodes[info_win->nodes_index] = node; + info_win->pagetops[info_win->nodes_index] = window->pagetop; + info_win->points[info_win->nodes_index] = window->point; + info_win->current = info_win->nodes_index++; + info_win->nodes[info_win->nodes_index] = (NODE *)NULL; + info_win->pagetops[info_win->nodes_index] = 0; + info_win->points[info_win->nodes_index] = 0; +} + +#define DEBUG_FORGET_WINDOW_AND_NODES +#if defined (DEBUG_FORGET_WINDOW_AND_NODES) +static void +consistency_check_info_windows () +{ + register int i; + INFO_WINDOW *info_win; + + for (i = 0; i < info_windows_index; i++) + { + WINDOW *win; + + for (win = windows; win; win = win->next) + if (win == info_windows[i]->window) + break; + + if (!win) + abort (); + } +} +#endif /* DEBUG_FORGET_WINDOW_AND_NODES */ + +/* Remove WINDOW and its associated list of nodes from INFO_WINDOWS. */ +void +forget_window_and_nodes (window) + WINDOW *window; +{ + register int i; + INFO_WINDOW *info_win = (INFO_WINDOW *)NULL; + + for (i = 0; info_windows && (info_win = info_windows[i]); i++) + if (info_win->window == window) + break; + + /* If we found the window to forget, then do so. */ + if (info_win) + { + while (i < info_windows_index) + { + info_windows[i] = info_windows[i + 1]; + i++; + } + + info_windows_index--; + info_windows[info_windows_index] = (INFO_WINDOW *)NULL; + + if (info_win->nodes) + { + /* Free the node structures which held onto internal node contents + here. This doesn't free the contents; we have a garbage collector + which does that. */ + for (i = 0; info_win->nodes[i]; i++) + if (internal_info_node_p (info_win->nodes[i])) + free (info_win->nodes[i]); + free (info_win->nodes); + + maybe_free (info_win->pagetops); + maybe_free (info_win->points); + } + + free (info_win); + } +#if defined (DEBUG_FORGET_WINDOW_AND_NODES) + consistency_check_info_windows (); +#endif /* DEBUG_FORGET_WINDOW_AND_NODES */ +} + +/* Set WINDOW to show NODE. Remember the new window in our list of Info + windows. If we are doing automatic footnote display, also try to display + the footnotes for this window. */ +void +info_set_node_of_window (window, node) + WINDOW *window; + NODE *node; +{ + /* Put this node into the window. */ + window_set_node_of_window (window, node); + + /* Remember this node and window in our list of info windows. */ + remember_window_and_node (window, node); + + /* If doing auto-footnote display/undisplay, show the footnotes belonging + to this window's node. */ + if (auto_footnotes_p) + info_get_or_remove_footnotes (window); +} + + +/* **************************************************************** */ +/* */ +/* Info Movement Commands */ +/* */ +/* **************************************************************** */ + +/* Change the pagetop of WINDOW to DESIRED_TOP, perhaps scrolling the screen + to do so. */ +void +set_window_pagetop (window, desired_top) + WINDOW *window; + int desired_top; +{ + int point_line, old_pagetop; + + if (desired_top < 0) + desired_top = 0; + else if (desired_top > window->line_count) + desired_top = window->line_count - 1; + + if (window->pagetop == desired_top) + return; + + old_pagetop = window->pagetop; + window->pagetop = desired_top; + + /* Make sure that point appears in this window. */ + point_line = window_line_of_point (window); + if ((point_line < window->pagetop) || + ((point_line - window->pagetop) > window->height - 1)) + window->point = + window->line_starts[window->pagetop] - window->node->contents; + + window->flags |= W_UpdateWindow; + + /* Find out which direction to scroll, and scroll the window in that + direction. Do this only if there would be a savings in redisplay + time. This is true if the amount to scroll is less than the height + of the window, and if the number of lines scrolled would be greater + than 10 % of the window's height. */ + if (old_pagetop < desired_top) + { + int start, end, amount; + + amount = desired_top - old_pagetop; + + if ((amount >= window->height) || + (((window->height - amount) * 10) < window->height)) + return; + + start = amount + window->first_row; + end = window->height + window->first_row; + + display_scroll_display (start, end, -amount); + } + else + { + int start, end, amount; + + amount = old_pagetop - desired_top; + + if ((amount >= window->height) || + (((window->height - amount) * 10) < window->height)) + return; + + start = window->first_row; + end = (window->first_row + window->height) - amount; + display_scroll_display (start, end, amount); + } +} + +/* Immediately make WINDOW->point visible on the screen, and move the + terminal cursor there. */ +static void +info_show_point (window) + WINDOW *window; +{ + int old_pagetop; + + old_pagetop = window->pagetop; + window_adjust_pagetop (window); + if (old_pagetop != window->pagetop) + { + int new_pagetop; + + new_pagetop = window->pagetop; + window->pagetop = old_pagetop; + set_window_pagetop (window, new_pagetop); + } + + if (window->flags & W_UpdateWindow) + display_update_one_window (window); + + display_cursor_at_point (window); +} + +/* Move WINDOW->point from OLD line index to NEW line index. */ +static void +move_to_new_line (old, new, window) + int old, new; + WINDOW *window; +{ + if (old == -1) + { + info_error (CANT_FIND_POINT); + } + else + { + int goal; + + if (new >= window->line_count || new < 0) + return; + + goal = window_get_goal_column (window); + window->goal_column = goal; + + window->point = window->line_starts[new] - window->node->contents; + window->point += window_chars_to_goal (window->line_starts[new], goal); + info_show_point (window); + } +} + +/* Move WINDOW's point down to the next line if possible. */ +DECLARE_INFO_COMMAND (info_next_line, "Move down to the next line") +{ + int old_line, new_line; + + if (count < 0) + info_prev_line (window, -count, key); + else + { + old_line = window_line_of_point (window); + new_line = old_line + count; + move_to_new_line (old_line, new_line, window); + } +} + +/* Move WINDOW's point up to the previous line if possible. */ +DECLARE_INFO_COMMAND (info_prev_line, "Move up to the previous line") +{ + int old_line, new_line; + + if (count < 0) + info_next_line (window, -count, key); + else + { + old_line = window_line_of_point (window); + new_line = old_line - count; + move_to_new_line (old_line, new_line, window); + } +} + +/* Move WINDOW's point to the end of the true line. */ +DECLARE_INFO_COMMAND (info_end_of_line, "Move to the end of the line") +{ + register int point, len; + register char *buffer; + + buffer = window->node->contents; + len = window->node->nodelen; + + for (point = window->point; + (point < len) && (buffer[point] != '\n'); + point++); + + if (point != window->point) + { + window->point = point; + info_show_point (window); + } +} + +/* Move WINDOW's point to the beginning of the true line. */ +DECLARE_INFO_COMMAND (info_beginning_of_line, "Move to the start of the line") +{ + register int point; + register char *buffer; + + buffer = window->node->contents; + point = window->point; + + for (; (point) && (buffer[point - 1] != '\n'); point--); + + /* If at a line start alreay, do nothing. */ + if (point != window->point) + { + window->point = point; + info_show_point (window); + } +} + +/* Move point forward in the node. */ +DECLARE_INFO_COMMAND (info_forward_char, "Move forward a character") +{ + if (count < 0) + info_backward_char (window, -count, key); + else + { + window->point += count; + + if (window->point >= window->node->nodelen) + window->point = window->node->nodelen - 1; + + info_show_point (window); + } +} + +/* Move point backward in the node. */ +DECLARE_INFO_COMMAND (info_backward_char, "Move backward a character") +{ + if (count < 0) + info_forward_char (window, -count, key); + else + { + window->point -= count; + + if (window->point < 0) + window->point = 0; + + info_show_point (window); + } +} + +#define alphabetic(c) (islower (c) || isupper (c) || isdigit (c)) + +/* Move forward a word in this node. */ +DECLARE_INFO_COMMAND (info_forward_word, "Move forward a word") +{ + long point; + char *buffer; + int end, c; + + if (count < 0) + { + info_backward_word (window, -count, key); + return; + } + + point = window->point; + buffer = window->node->contents; + end = window->node->nodelen; + + while (count) + { + if (point + 1 >= end) + return; + + /* If we are not in a word, move forward until we are in one. + Then, move forward until we hit a non-alphabetic character. */ + c = buffer[point]; + + if (!alphabetic (c)) + { + while (++point < end) + { + c = buffer[point]; + if (alphabetic (c)) + break; + } + } + + if (point >= end) return; + + while (++point < end) + { + c = buffer[point]; + if (!alphabetic (c)) + break; + } + --count; + } + window->point = point; + info_show_point (window); +} + +DECLARE_INFO_COMMAND (info_backward_word, "Move backward a word") +{ + long point; + char *buffer; + int c; + + if (count < 0) + { + info_forward_word (window, -count, key); + return; + } + + buffer = window->node->contents; + point = window->point; + + while (count) + { + if (point == 0) + break; + + /* Like info_forward_word (), except that we look at the + characters just before point. */ + + c = buffer[point - 1]; + + if (!alphabetic (c)) + { + while (--point) + { + c = buffer[point - 1]; + if (alphabetic (c)) + break; + } + } + + while (point) + { + c = buffer[point - 1]; + if (!alphabetic (c)) + break; + else + --point; + } + --count; + } + window->point = point; + info_show_point (window); +} + +/* Here is a list of time counter names which correspond to ordinal numbers. + It is used to print "once" instead of "1". */ +static char *counter_names[] = { + "not at all", "once", "twice", "three", "four", "five", "six", + (char *)NULL +}; + +/* Buffer used to return values from times_description (). */ +static char td_buffer[50]; + +/* Function returns a static string fully describing the number of times + present in COUNT. */ +static char * +times_description (count) + int count; +{ + register int i; + + td_buffer[0] = '\0'; + + for (i = 0; counter_names[i]; i++) + if (count == i) + break; + + if (counter_names[i]) + sprintf (td_buffer, "%s%s", counter_names[i], count > 2 ? " times" : ""); + else + sprintf (td_buffer, "%d times", count); + + return (td_buffer); +} + +/* Variable controlling the behaviour of default scrolling when you are + already at the bottom of a node. Possible values are defined in session.h. + The meanings are: + + IS_Continuous Try to get first menu item, or failing that, the + "Next:" pointer, or failing that, the "Up:" and + "Next:" of the up. + IS_NextOnly Try to get "Next:" menu item. + IS_PageOnly Simply give up at the bottom of a node. */ + +int info_scroll_behaviour = IS_Continuous; + +/* Choices used by the completer when reading a value for the user-visible + variable "scroll-behaviour". */ +char *info_scroll_choices[] = { + "Continuous", "Next Only", "Page Only", (char *)NULL +}; + +/* Move to 1st menu item, Next, Up/Next, or error in this window. */ +static void +forward_move_node_structure (window, behaviour) + WINDOW *window; + int behaviour; +{ + switch (behaviour) + { + case IS_PageOnly: + info_error (AT_NODE_BOTTOM); + break; + + case IS_NextOnly: + info_next_label_of_node (window->node); + if (!info_parsed_nodename && !info_parsed_filename) + info_error ("No \"Next\" pointer for this node."); + else + { + window_message_in_echo_area ("Following \"Next\" node..."); + info_handle_pointer ("Next", window); + } + break; + + case IS_Continuous: + { + /* First things first. If this node contains a menu, move down + into the menu. */ + { + REFERENCE **menu; + + menu = info_menu_of_node (window->node); + + if (menu) + { + info_free_references (menu); + window_message_in_echo_area ("Selecting first menu item..."); + info_menu_digit (window, 1, '1'); + return; + } + } + + /* Okay, this node does not contain a menu. If it contains a + "Next:" pointer, use that. */ + info_next_label_of_node (window->node); + if (info_label_was_found) + { + window_message_in_echo_area ("Selecting \"Next\" node..."); + info_handle_pointer ("Next", window); + return; + } + + /* Okay, there wasn't a "Next:" for this node. Move "Up:" until we + can move "Next:". If that isn't possible, complain that there + are no more nodes. */ + { + int up_counter, old_current; + INFO_WINDOW *info_win; + + /* Remember the current node and location. */ + info_win = get_info_window_of_window (window); + old_current = info_win->current; + + /* Back up through the "Up:" pointers until we have found a "Next:" + that isn't the same as the first menu item found in that node. */ + up_counter = 0; + while (!info_error_was_printed) + { + info_up_label_of_node (window->node); + if (info_label_was_found) + { + info_handle_pointer ("Up", window); + if (info_error_was_printed) + continue; + + up_counter++; + + info_next_label_of_node (window->node); + + /* If no "Next" pointer, keep backing up. */ + if (!info_label_was_found) + continue; + + /* If this node's first menu item is the same as this node's + Next pointer, keep backing up. */ + if (!info_parsed_filename) + { + REFERENCE **menu; + char *next_nodename; + + /* Remember the name of the Next node, since reading + the menu can overwrite the contents of the + info_parsed_xxx strings. */ + next_nodename = strdup (info_parsed_nodename); + + menu = info_menu_of_node (window->node); + if (menu && + (strcmp + (menu[0]->nodename, next_nodename) == 0)) + { + info_free_references (menu); + free (next_nodename); + continue; + } + else + { + /* Restore the world to where it was before + reading the menu contents. */ + info_free_references (menu); + free (next_nodename); + info_next_label_of_node (window->node); + } + } + + /* This node has a "Next" pointer, and it is not the + same as the first menu item found in this node. */ + window_message_in_echo_area + ("Moving \"Up\" %s, then \"Next\".", + times_description (up_counter)); + + info_handle_pointer ("Next", window); + return; + } + else + { + /* No more "Up" pointers. Print an error, and call it + quits. */ + register int i; + + for (i = 0; i < up_counter; i++) + { + info_win->nodes_index--; + free (info_win->nodes[info_win->nodes_index]); + info_win->nodes[info_win->nodes_index] = (NODE *)NULL; + } + info_win->current = old_current; + window->node = info_win->nodes[old_current]; + window->pagetop = info_win->pagetops[old_current]; + window->point = info_win->points[old_current]; + recalculate_line_starts (window); + window->flags |= W_UpdateWindow; + info_error ("No more nodes."); + } + } + } + break; + } + } +} + +/* Move Prev, Up or error in WINDOW depending on BEHAVIOUR. */ +static void +backward_move_node_structure (window, behaviour) + WINDOW *window; + int behaviour; +{ + switch (behaviour) + { + case IS_PageOnly: + info_error (AT_NODE_TOP); + break; + + case IS_NextOnly: + info_prev_label_of_node (window->node); + if (!info_parsed_nodename && !info_parsed_filename) + info_error ("No \"Prev\" for this node."); + else + { + window_message_in_echo_area ("Moving \"Prev\" in this window."); + info_handle_pointer ("Prev", window); + } + break; + + case IS_Continuous: + info_prev_label_of_node (window->node); + + if (!info_parsed_nodename && !info_parsed_filename) + { + info_up_label_of_node (window->node); + if (!info_parsed_nodename && !info_parsed_filename) + info_error ("No \"Prev\" or \"Up\" for this node."); + else + { + window_message_in_echo_area ("Moving \"Up\" in this window."); + info_handle_pointer ("Up", window); + } + } + else + { + REFERENCE **menu; + int inhibit_menu_traversing = 0; + + /* Watch out! If this node's Prev is the same as the Up, then + move Up. Otherwise, we could move Prev, and then to the last + menu item in the Prev. This would cause the user to loop + through a subsection of the info file. */ + if (!info_parsed_filename && info_parsed_nodename) + { + char *pnode; + + pnode = strdup (info_parsed_nodename); + info_up_label_of_node (window->node); + + if (!info_parsed_filename && info_parsed_nodename && + strcmp (info_parsed_nodename, pnode) == 0) + { + /* The nodes are the same. Inhibit moving to the last + menu item. */ + free (pnode); + inhibit_menu_traversing = 1; + } + else + { + free (pnode); + info_prev_label_of_node (window->node); + } + } + + /* Move to the previous node. If this node now contains a menu, + and we have not inhibited movement to it, move to the node + corresponding to the last menu item. */ + window_message_in_echo_area ("Moving \"Prev\" in this window."); + info_handle_pointer ("Prev", window); + + if (!inhibit_menu_traversing) + { + while (!info_error_was_printed && + (menu = info_menu_of_node (window->node))) + { + info_free_references (menu); + window_message_in_echo_area + ("Moving to \"Prev\"'s last menu item."); + info_menu_digit (window, 1, '0'); + } + } + } + break; + } +} + +/* Move continuously forward through the node structure of this info file. */ +DECLARE_INFO_COMMAND (info_global_next_node, + "Move forwards or down through node structure") +{ + if (count < 0) + info_global_prev_node (window, -count, key); + else + { + while (count && !info_error_was_printed) + { + forward_move_node_structure (window, IS_Continuous); + count--; + } + } +} + +/* Move continuously backward through the node structure of this info file. */ +DECLARE_INFO_COMMAND (info_global_prev_node, + "Move backwards or up through node structure") +{ + if (count < 0) + info_global_next_node (window, -count, key); + else + { + while (count && !info_error_was_printed) + { + backward_move_node_structure (window, IS_Continuous); + count--; + } + } +} + +/* Show the next screen of WINDOW's node. */ +DECLARE_INFO_COMMAND (info_scroll_forward, "Scroll forward in this window") +{ + if (count < 0) + info_scroll_backward (window, -count, key); + else + { + int desired_top; + + /* Without an explicit numeric argument, scroll the bottom two + lines to the top of this window, Or, if at bottom of window, + and the user wishes to scroll through nodes get the "Next" node + for this window. */ + if (!info_explicit_arg && count == 1) + { + desired_top = window->pagetop + (window->height - 2); + + /* If there are no more lines to scroll here, error, or get + another node, depending on INFO_SCROLL_BEHAVIOUR. */ + if (desired_top > window->line_count) + { + int behaviour = info_scroll_behaviour; + + /* Here is a hack. If the key being used is not SPC, do the + PageOnly behaviour. */ + if (key != SPC && key != DEL) + behaviour = IS_PageOnly; + + forward_move_node_structure (window, behaviour); + return; + } + } + else + desired_top = window->pagetop + count; + + if (desired_top >= window->line_count) + desired_top = window->line_count - 2; + + if (window->pagetop > desired_top) + return; + else + set_window_pagetop (window, desired_top); + } +} + +/* Show the previous screen of WINDOW's node. */ +DECLARE_INFO_COMMAND (info_scroll_backward, "Scroll backward in this window") +{ + if (count < 0) + info_scroll_forward (window, -count, key); + else + { + int desired_top; + + /* Without an explicit numeric argument, scroll the top two lines + to the bottom of this window, or move to the previous, or Up'th + node. */ + if (!info_explicit_arg && count == 1) + { + desired_top = window->pagetop - (window->height - 2); + + if ((desired_top < 0) && (window->pagetop == 0)) + { + int behaviour = info_scroll_behaviour; + + /* Same kind of hack as in info_scroll_forward. If the key + used to invoke this command is not DEL, do only the PageOnly + behaviour. */ + if (key != DEL && key != SPC) + behaviour = IS_PageOnly; + + backward_move_node_structure (window, behaviour); + return; + } + } + else + desired_top = window->pagetop - count; + + if (desired_top < 0) + desired_top = 0; + + set_window_pagetop (window, desired_top); + } +} + +/* Move to the beginning of the node. */ +DECLARE_INFO_COMMAND (info_beginning_of_node, "Move to the start of this node") +{ + window->pagetop = window->point = 0; + window->flags |= W_UpdateWindow; +} + +/* Move to the end of the node. */ +DECLARE_INFO_COMMAND (info_end_of_node, "Move to the end of this node") +{ + window->point = window->node->nodelen - 1; + info_show_point (window); +} + +/* **************************************************************** */ +/* */ +/* Commands for Manipulating Windows */ +/* */ +/* **************************************************************** */ + +/* Make the next window in the chain be the active window. */ +DECLARE_INFO_COMMAND (info_next_window, "Select the next window") +{ + if (count < 0) + { + info_prev_window (window, -count, key); + return; + } + + /* If no other window, error now. */ + if (!windows->next && !echo_area_is_active) + { + info_error (ONE_WINDOW); + return; + } + + while (count--) + { + if (window->next) + window = window->next; + else + { + if (window == the_echo_area || !echo_area_is_active) + window = windows; + else + window = the_echo_area; + } + } + + if (active_window != window) + { + if (auto_footnotes_p) + info_get_or_remove_footnotes (window); + + window->flags |= W_UpdateWindow; + active_window = window; + } +} + +/* Make the previous window in the chain be the active window. */ +DECLARE_INFO_COMMAND (info_prev_window, "Select the previous window") +{ + if (count < 0) + { + info_next_window (window, -count, key); + return; + } + + /* Only one window? */ + + if (!windows->next && !echo_area_is_active) + { + info_error (ONE_WINDOW); + return; + } + + while (count--) + { + /* If we are in the echo area, or if the echo area isn't active and we + are in the first window, find the last window in the chain. */ + if (window == the_echo_area || + (window == windows && !echo_area_is_active)) + { + register WINDOW *win, *last; + + for (win = windows; win; win = win->next) + last = win; + + window = last; + } + else + { + if (window == windows) + window = the_echo_area; + else + window = window->prev; + } + } + + if (active_window != window) + { + if (auto_footnotes_p) + info_get_or_remove_footnotes (window); + + window->flags |= W_UpdateWindow; + active_window = window; + } +} + +/* Split WINDOW into two windows, both showing the same node. If we + are automatically tiling windows, re-tile after the split. */ +DECLARE_INFO_COMMAND (info_split_window, "Split the current window") +{ + WINDOW *split, *old_active; + int pagetop; + + /* Remember the current pagetop of the window being split. If it doesn't + change, we can scroll its contents around after the split. */ + pagetop = window->pagetop; + + /* Make the new window. */ + old_active = active_window; + active_window = window; + split = window_make_window (window->node); + active_window = old_active; + + if (!split) + { + info_error (WIN_TOO_SMALL); + } + else + { +#if defined (SPLIT_BEFORE_ACTIVE) + /* Try to scroll the old window into its new postion. */ + if (pagetop == window->pagetop) + { + int start, end, amount; + + start = split->first_row; + end = start + window->height; + amount = split->height + 1; + display_scroll_display (start, end, amount); + } +#else /* !SPLIT_BEFORE_ACTIVE */ + /* Make sure point still appears in the active window. */ + info_show_point (window); +#endif /* !SPLIT_BEFORE_ACTIVE */ + + /* If the window just split was one internal to Info, try to display + something else in it. */ + if (internal_info_node_p (split->node)) + { + register int i, j; + INFO_WINDOW *iw; + NODE *node = (NODE *)NULL; + char *filename; + + for (i = 0; iw = info_windows[i]; i++) + { + for (j = 0; j < iw->nodes_index; j++) + if (!internal_info_node_p (iw->nodes[j])) + { + if (iw->nodes[j]->parent) + filename = iw->nodes[j]->parent; + else + filename = iw->nodes[j]->filename; + + node = info_get_node (filename, iw->nodes[j]->nodename); + if (node) + { + window_set_node_of_window (split, node); + i = info_windows_index - 1; + break; + } + } + } + } + split->pagetop = window->pagetop; + + if (auto_tiling_p) + window_tile_windows (DONT_TILE_INTERNALS); + else + window_adjust_pagetop (split); + + remember_window_and_node (split, split->node); + } +} + +/* Delete WINDOW, forgetting the list of last visited nodes. If we are + automatically displaying footnotes, show or remove the footnotes + window. If we are automatically tiling windows, re-tile after the + deletion. */ +DECLARE_INFO_COMMAND (info_delete_window, "Delete the current window") +{ + if (!windows->next) + { + info_error (CANT_KILL_LAST); + } + else if (window->flags & W_WindowIsPerm) + { + info_error ("Cannot delete a permanent window"); + } + else + { + info_delete_window_internal (window); + + if (auto_footnotes_p) + info_get_or_remove_footnotes (active_window); + + if (auto_tiling_p) + window_tile_windows (DONT_TILE_INTERNALS); + } +} + +/* Do the physical deletion of WINDOW, and forget this window and + associated nodes. */ +void +info_delete_window_internal (window) + WINDOW *window; +{ + if (windows->next && ((window->flags & W_WindowIsPerm) == 0)) + { + /* We not only delete the window from the display, we forget it from + our list of remembered windows. */ + forget_window_and_nodes (window); + window_delete_window (window); + + if (echo_area_is_active) + echo_area_inform_of_deleted_window (window); + } +} + +/* Just keep WINDOW, deleting all others. */ +DECLARE_INFO_COMMAND (info_keep_one_window, "Delete all other windows") +{ + int num_deleted; /* The number of windows we deleted. */ + int pagetop, start, end; + + /* Remember a few things about this window. We may be able to speed up + redisplay later by scrolling its contents. */ + pagetop = window->pagetop; + start = window->first_row; + end = start + window->height; + + num_deleted = 0; + + while (1) + { + WINDOW *win; + + /* Find an eligible window and delete it. If no eligible windows + are found, we are done. A window is eligible for deletion if + is it not permanent, and it is not WINDOW. */ + for (win = windows; win; win = win->next) + if (win != window && ((win->flags & W_WindowIsPerm) == 0)) + break; + + if (!win) + break; + + info_delete_window_internal (win); + num_deleted++; + } + + /* Scroll the contents of this window into the right place so that the + user doesn't have to wait any longer than necessary for redisplay. */ + if (num_deleted) + { + int amount; + + amount = (window->first_row - start); + amount -= (window->pagetop - pagetop); + display_scroll_display (start, end, amount); + } + + window->flags |= W_UpdateWindow; +} + +/* Scroll the "other" window of WINDOW. */ +DECLARE_INFO_COMMAND (info_scroll_other_window, "Scroll the other window") +{ + WINDOW *other; + + /* If only one window, give up. */ + if (!windows->next) + { + info_error (ONE_WINDOW); + return; + } + + other = window->next; + + if (!other) + other = window->prev; + + info_scroll_forward (other, count, key); +} + +/* Change the size of WINDOW by AMOUNT. */ +DECLARE_INFO_COMMAND (info_grow_window, "Grow (or shrink) this window") +{ + window_change_window_height (window, count); +} + +/* When non-zero, tiling takes place automatically when info_split_window + is called. */ +int auto_tiling_p = 0; + +/* Tile all of the visible windows. */ +DECLARE_INFO_COMMAND (info_tile_windows, + "Divide the available screen space among the visible windows") +{ + window_tile_windows (TILE_INTERNALS); +} + +/* Toggle the state of this window's wrapping of lines. */ +DECLARE_INFO_COMMAND (info_toggle_wrap, + "Toggle the state of line wrapping in the current window") +{ + window_toggle_wrap (window); +} + +/* **************************************************************** */ +/* */ +/* Info Node Commands */ +/* */ +/* **************************************************************** */ + +/* Using WINDOW for various defaults, select the node referenced by ENTRY + in it. If the node is selected, the window and node are remembered. */ +void +info_select_reference (window, entry) + WINDOW *window; + REFERENCE *entry; +{ + NODE *node; + char *filename, *nodename, *file_system_error; + + file_system_error = (char *)NULL; + + filename = entry->filename; + if (!filename) + filename = window->node->parent; + if (!filename) + filename = window->node->filename; + + if (filename) + filename = strdup (filename); + + if (entry->nodename) + nodename = strdup (entry->nodename); + else + nodename = strdup ("Top"); + + node = info_get_node (filename, nodename); + + /* Try something a little weird. If the node couldn't be found, and the + reference was of the form "foo::", see if the entry->label can be found + as a file, with a node of "Top". */ + if (!node) + { + if (info_recent_file_error) + file_system_error = strdup (info_recent_file_error); + + if (entry->nodename && (strcmp (entry->nodename, entry->label) == 0)) + { + node = info_get_node (entry->label, "Top"); + if (!node && info_recent_file_error) + { + maybe_free (file_system_error); + file_system_error = strdup (info_recent_file_error); + } + } + } + + if (!node) + { + if (file_system_error) + info_error (file_system_error); + else + info_error (CANT_FIND_NODE, nodename); + } + + maybe_free (file_system_error); + maybe_free (filename); + maybe_free (nodename); + + if (node) + { + set_remembered_pagetop_and_point (window); + info_set_node_of_window (window, node); + } +} + +/* Parse the node specification in LINE using WINDOW to default the filename. + Select the parsed node in WINDOW and remember it, or error if the node + couldn't be found. */ +static void +info_parse_and_select (line, window) + char *line; + WINDOW *window; +{ + REFERENCE entry; + + info_parse_node (line, DONT_SKIP_NEWLINES); + + entry.nodename = info_parsed_nodename; + entry.filename = info_parsed_filename; + entry.label = "*info-parse-and-select*"; + + info_select_reference (window, &entry); +} + +/* Given that the values of INFO_PARSED_FILENAME and INFO_PARSED_NODENAME + are previously filled, try to get the node represented by them into + WINDOW. The node should have been pointed to by the LABEL pointer of + WINDOW->node. */ +static void +info_handle_pointer (label, window) + char *label; + WINDOW *window; +{ + if (info_parsed_filename || info_parsed_nodename) + { + char *filename, *nodename; + NODE *node; + + filename = nodename = (char *)NULL; + + if (info_parsed_filename) + filename = strdup (info_parsed_filename); + else + { + if (window->node->parent) + filename = strdup (window->node->parent); + else if (window->node->filename) + filename = strdup (window->node->filename); + } + + if (info_parsed_nodename) + nodename = strdup (info_parsed_nodename); + else + nodename = strdup ("Top"); + + node = info_get_node (filename, nodename); + + if (node) + { + INFO_WINDOW *info_win; + + info_win = get_info_window_of_window (window); + if (info_win) + { + info_win->pagetops[info_win->current] = window->pagetop; + info_win->points[info_win->current] = window->point; + } + set_remembered_pagetop_and_point (window); + info_set_node_of_window (window, node); + } + else + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error (CANT_FILE_NODE, filename, nodename); + } + + free (filename); + free (nodename); + } + else + { + info_error (NO_POINTER, label); + } +} + +/* Make WINDOW display the "Next:" node of the node currently being + displayed. */ +DECLARE_INFO_COMMAND (info_next_node, "Select the `Next' node") +{ + info_next_label_of_node (window->node); + info_handle_pointer ("Next", window); +} + +/* Make WINDOW display the "Prev:" node of the node currently being + displayed. */ +DECLARE_INFO_COMMAND (info_prev_node, "Select the `Prev' node") +{ + info_prev_label_of_node (window->node); + info_handle_pointer ("Prev", window); +} + +/* Make WINDOW display the "Up:" node of the node currently being + displayed. */ +DECLARE_INFO_COMMAND (info_up_node, "Select the `Up' node") +{ + info_up_label_of_node (window->node); + info_handle_pointer ("Up", window); +} + +/* Make WINDOW display the last node of this info file. */ +DECLARE_INFO_COMMAND (info_last_node, "Select the last node in this file") +{ + register int i; + FILE_BUFFER *fb = file_buffer_of_window (window); + NODE *node = (NODE *)NULL; + + if (fb && fb->tags) + { + for (i = 0; fb->tags[i]; i++); + node = info_get_node (fb->filename, fb->tags[i - 1]->nodename); + } + + if (!node) + info_error ("This window has no additional nodes"); + else + { + set_remembered_pagetop_and_point (window); + info_set_node_of_window (window, node); + } +} + +/* Make WINDOW display the first node of this info file. */ +DECLARE_INFO_COMMAND (info_first_node, "Select the first node in this file") +{ + FILE_BUFFER *fb = file_buffer_of_window (window); + NODE *node = (NODE *)NULL; + + if (fb && fb->tags) + node = info_get_node (fb->filename, fb->tags[0]->nodename); + + if (!node) + info_error ("This window has no additional nodes"); + else + { + set_remembered_pagetop_and_point (window); + info_set_node_of_window (window, node); + } +} + +/* Make WINDOW display the previous node displayed in this window. */ +DECLARE_INFO_COMMAND (info_history_node, + "Select the most recently selected node") +{ + INFO_WINDOW *info_win; + + /* Find the INFO_WINDOW which contains WINDOW. */ + info_win = get_info_window_of_window (window); + + if (!info_win) + { + info_error ("Requested window is not present!"); + return; + } + + set_remembered_pagetop_and_point (window); + if (!info_win->current) + { + if (info_win->nodes_index > 1) + { + window_message_in_echo_area + ("Now wrapped around to beginning of history."); + info_win->current = info_win->nodes_index; + } + else + { + info_error ("No earlier nodes in this window."); + return; + } + } + + info_win->current--; + window_set_node_of_window (window, info_win->nodes[info_win->current]); + window->pagetop = info_win->pagetops[info_win->current]; + window->point = info_win->points[info_win->current]; + window->flags |= W_UpdateWindow; + if (auto_footnotes_p) + info_get_or_remove_footnotes (window); +} + +/* Select the last menu item in WINDOW->node. */ +DECLARE_INFO_COMMAND (info_last_menu_item, + "Select the last item in this node's menu") +{ + info_menu_digit (window, 1, '0'); +} + +/* Use KEY (a digit) to select the Nth menu item in WINDOW->node. */ +DECLARE_INFO_COMMAND (info_menu_digit, "Select this menu item") +{ + register int i, item; + register REFERENCE *entry, **menu; + + menu = info_menu_of_node (window->node); + + if (!menu) + { + info_error (NO_MENU_NODE); + return; + } + + /* We have the menu. See if there are this many items in it. */ + item = key - '0'; + + /* Special case. Item "0" is the last item in this menu. */ + if (item == 0) + for (i = 0; menu[i + 1]; i++); + else + { + for (i = 0; entry = menu[i]; i++) + if (i == item - 1) + break; + } + + if (menu[i]) + info_select_reference (window, menu[i]); + else + info_error ("There aren't %d items in this menu.", item); + + info_free_references (menu); + return; +} + +/* Read a menu or followed reference from the user defaulting to the + reference found on the current line, and select that node. The + reading is done with completion. BUILDER is the function used + to build the list of references. ASK_P is non-zero if the user + should be prompted, or zero to select the default item. */ +static void +info_menu_or_ref_item (window, count, key, builder, ask_p) + WINDOW *window; + int count; + unsigned char key; + REFERENCE **(*builder) (); + int ask_p; +{ + REFERENCE **menu, *entry, *defentry = (REFERENCE *)NULL; + char *line; + + menu = (*builder) (window->node); + + if (!menu) + { + if (builder == info_menu_of_node) + info_error (NO_MENU_NODE); + else + info_error (NO_XREF_NODE); + return; + } + + /* Default the selected reference to the one which is on the line that + point is in. */ + { + REFERENCE **refs = (REFERENCE **)NULL; + int point_line; + + point_line = window_line_of_point (window); + + if (point_line != -1) + { + SEARCH_BINDING binding; + + binding.buffer = window->node->contents; + binding.start = window->line_starts[point_line] - binding.buffer; + if (window->line_starts[point_line + 1]) + binding.end = window->line_starts[point_line + 1] - binding.buffer; + else + binding.end = window->node->nodelen; + binding.flags = 0; + + if (builder == info_menu_of_node) + { + if (point_line) + { + binding.start--; + refs = info_menu_items (&binding); + } + } + else + { +#if defined (HANDLE_MAN_PAGES) + if (window->node->flags & N_IsManPage) + refs = manpage_xrefs_in_binding (window->node, &binding); + else +#endif /* HANDLE_MAN_PAGES */ + refs = info_xrefs (&binding); + } + + if (refs) + { + if ((strcmp (refs[0]->label, "Menu") != 0) || + (builder == info_xrefs_of_node)) + { + int which = 0; + + /* Find the closest reference to point. */ + if (builder == info_xrefs_of_node) + { + int closest = -1; + + for (; refs[which]; which++) + { + if ((window->point >= refs[which]->start) && + (window->point <= refs[which]->end)) + { + closest = which; + break; + } + else if (window->point < refs[which]->start) + { + break; + } + } + if (closest == -1) + which--; + else + which = closest; + } + + defentry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + defentry->label = strdup (refs[which]->label); + defentry->filename = refs[which]->filename; + defentry->nodename = refs[which]->nodename; + + if (defentry->filename) + defentry->filename = strdup (defentry->filename); + if (defentry->nodename) + defentry->nodename = strdup (defentry->nodename); + } + info_free_references (refs); + } + } + } + + /* If we are going to ask the user a question, do it now. */ + if (ask_p) + { + char *prompt; + + /* Build the prompt string. */ + if (defentry) + prompt = (char *)xmalloc (20 + strlen (defentry->label)); + else + prompt = (char *)xmalloc (20); + + if (builder == info_menu_of_node) + { + if (defentry) + sprintf (prompt, "Menu item (%s): ", defentry->label); + else + sprintf (prompt, "Menu item: "); + } + else + { + if (defentry) + sprintf (prompt, "Follow xref (%s): ", defentry->label); + else + sprintf (prompt, "Follow xref: "); + } + + line = info_read_completing_in_echo_area (window, prompt, menu); + free (prompt); + + window = active_window; + + /* User aborts, just quit. */ + if (!line) + { + maybe_free (defentry); + info_free_references (menu); + info_abort_key (window, 0, 0); + return; + } + + /* If we had a default and the user accepted it, use that. */ + if (!*line) + { + free (line); + if (defentry) + line = strdup (defentry->label); + else + line = (char *)NULL; + } + } + else + { + /* Not going to ask any questions. If we have a default entry, use + that, otherwise return. */ + if (!defentry) + return; + else + line = strdup (defentry->label); + } + + if (line) + { + /* Find the selected label in the references. */ + entry = info_get_labeled_reference (line, menu); + + if (!entry && defentry) + info_error ("The reference disappeared! (%s).", line); + else + { + NODE *orig; + + orig = window->node; + info_select_reference (window, entry); + if ((builder == info_xrefs_of_node) && (window->node != orig)) + { + long offset; + long start; + + if (window->line_count > 0) + start = window->line_starts[1] - window->node->contents; + else + start = 0; + + offset = + info_target_search_node (window->node, entry->label, start); + + if (offset != -1) + { + window->point = offset; + window_adjust_pagetop (window); + } + } + } + + free (line); + if (defentry) + { + free (defentry->label); + maybe_free (defentry->filename); + maybe_free (defentry->nodename); + free (defentry); + } + } + + info_free_references (menu); + + if (!info_error_was_printed) + window_clear_echo_area (); +} + +/* Read a line (with completion) which is the name of a menu item, + and select that item. */ +DECLARE_INFO_COMMAND (info_menu_item, "Read a menu item and select its node") +{ + info_menu_or_ref_item (window, count, key, info_menu_of_node, 1); +} + +/* Read a line (with completion) which is the name of a reference to + follow, and select the node. */ +DECLARE_INFO_COMMAND + (info_xref_item, "Read a footnote or cross reference and select its node") +{ + info_menu_or_ref_item (window, count, key, info_xrefs_of_node, 1); +} + +/* Position the cursor at the start of this node's menu. */ +DECLARE_INFO_COMMAND (info_find_menu, "Move to the start of this node's menu") +{ + SEARCH_BINDING binding; + long position; + + binding.buffer = window->node->contents; + binding.start = 0; + binding.end = window->node->nodelen; + binding.flags = S_FoldCase | S_SkipDest; + + position = search (INFO_MENU_LABEL, &binding); + + if (position == -1) + info_error (NO_MENU_NODE); + else + { + window->point = position; + window_adjust_pagetop (window); + window->flags |= W_UpdateWindow; + } +} + +/* Visit as many menu items as is possible, each in a separate window. */ +DECLARE_INFO_COMMAND (info_visit_menu, + "Visit as many menu items at once as possible") +{ + register int i; + REFERENCE *entry, **menu; + + menu = info_menu_of_node (window->node); + + if (!menu) + info_error (NO_MENU_NODE); + + for (i = 0; (!info_error_was_printed) && (entry = menu[i]); i++) + { + WINDOW *new; + + new = window_make_window (window->node); + window_tile_windows (TILE_INTERNALS); + + if (!new) + info_error (WIN_TOO_SMALL); + else + { + active_window = new; + info_select_reference (new, entry); + } + } +} + +/* Read a line of input which is a node name, and go to that node. */ +DECLARE_INFO_COMMAND (info_goto_node, "Read a node name and select it") +{ + char *line; + NODE *node; + +#define GOTO_COMPLETES +#if defined (GOTO_COMPLETES) + /* Build a completion list of all of the known nodes. */ + { + register int fbi, i; + FILE_BUFFER *current; + REFERENCE **items = (REFERENCE **)NULL; + int items_index = 0; + int items_slots = 0; + + current = file_buffer_of_window (window); + + for (fbi = 0; info_loaded_files && info_loaded_files[fbi]; fbi++) + { + FILE_BUFFER *fb; + REFERENCE *entry; + int this_is_the_current_fb; + + fb = info_loaded_files[fbi]; + this_is_the_current_fb = (current == fb); + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->filename = entry->nodename = (char *)NULL; + entry->label = (char *)xmalloc (4 + strlen (fb->filename)); + sprintf (entry->label, "(%s)*", fb->filename); + + add_pointer_to_array + (entry, items_index, items, items_slots, 10, REFERENCE *); + + if (fb->tags) + { + for (i = 0; fb->tags[i]; i++) + { + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->filename = entry->nodename = (char *)NULL; + entry->label = (char *) xmalloc + (4 + strlen (fb->filename) + strlen (fb->tags[i]->nodename)); + sprintf (entry->label, "(%s)%s", + fb->filename, fb->tags[i]->nodename); + + add_pointer_to_array + (entry, items_index, items, items_slots, 100, REFERENCE *); + } + + if (this_is_the_current_fb) + { + for (i = 0; fb->tags[i]; i++) + { + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->filename = entry->nodename = (char *)NULL; + entry->label = strdup (fb->tags[i]->nodename); + add_pointer_to_array (entry, items_index, items, + items_slots, 100, REFERENCE *); + } + } + } + } + line = info_read_maybe_completing (window, "Goto Node: ", items); + info_free_references (items); + } +#else /* !GOTO_COMPLETES */ + line = info_read_in_echo_area (window, "Goto Node: "); +#endif /* !GOTO_COMPLETES */ + + /* If the user aborted, quit now. */ + if (!line) + { + info_abort_key (window, 0, 0); + return; + } + + canonicalize_whitespace (line); + + if (*line) + info_parse_and_select (line, window); + + free (line); + if (!info_error_was_printed) + window_clear_echo_area (); +} + +#if defined (HANDLE_MAN_PAGES) +DECLARE_INFO_COMMAND (info_man, "Read a manpage reference and select it") +{ + char *line; + NODE *node; + + line = info_read_in_echo_area (window, "Get Manpage: "); + + if (!line) + { + info_abort_key (window, 0, 0); + return; + } + + canonicalize_whitespace (line); + + if (*line) + { + char *goto_command; + + goto_command = (char *)xmalloc + (4 + strlen (MANPAGE_FILE_BUFFER_NAME) + strlen (line)); + + sprintf (goto_command, "(%s)%s", MANPAGE_FILE_BUFFER_NAME, line); + + info_parse_and_select (goto_command, window); + free (goto_command); + } + + free (line); + if (!info_error_was_printed) + window_clear_echo_area (); +} +#endif /* HANDLE_MAN_PAGES */ + +/* Move to the "Top" node in this file. */ +DECLARE_INFO_COMMAND (info_top_node, "Select the node `Top' in this file") +{ + info_parse_and_select ("Top", window); +} + +/* Move to the node "(dir)Top". */ +DECLARE_INFO_COMMAND (info_dir_node, "Select the node `(dir)'") +{ + info_parse_and_select ("(dir)Top", window); +} + +/* Try to delete the current node appearing in this window, showing the most + recently selected node in this window. */ +DECLARE_INFO_COMMAND (info_kill_node, "Kill this node") +{ + register int iw, i; + register INFO_WINDOW *info_win; + char *nodename = (char *)NULL; + NODE *temp = (NODE *)NULL; + + /* Read the name of a node to kill. The list of available nodes comes + from the nodes appearing in the current window configuration. */ + { + REFERENCE **menu = (REFERENCE **)NULL; + int menu_index = 0, menu_slots = 0; + char *default_nodename, *prompt; + + for (iw = 0; info_win = info_windows[iw]; iw++) + { + REFERENCE *entry; + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->label = strdup (info_win->window->node->nodename); + entry->filename = entry->nodename = (char *)NULL; + + add_pointer_to_array + (entry, menu_index, menu, menu_slots, 10, REFERENCE *); + } + + default_nodename = strdup (active_window->node->nodename); + prompt = (char *)xmalloc (40 + strlen (default_nodename)); + sprintf (prompt, "Kill node (%s): ", default_nodename); + + nodename = info_read_completing_in_echo_area (window, prompt, menu); + free (prompt); + info_free_references (menu); + if (nodename && !*nodename) + { + free (nodename); + nodename = default_nodename; + } + else + free (default_nodename); + } + + /* If there is no nodename to kill, quit now. */ + if (!nodename) + { + info_abort_key (window, 0, 0); + return; + } + + /* If there is a nodename, find it in our window list. */ + for (iw = 0; info_win = info_windows[iw]; iw++) + if (strcmp (nodename, info_win->nodes[info_win->current]->nodename) == 0) + break; + + if (!info_win) + { + if (*nodename) + info_error ("Cannot kill the node `%s'", nodename); + else + window_clear_echo_area (); + + return; + } + + /* If there are no more nodes left anywhere to view, complain and exit. */ + if (info_windows_index == 1 && info_windows[0]->nodes_index == 1) + { + info_error ("Cannot kill the last node"); + return; + } + + /* INFO_WIN contains the node that the user wants to stop viewing. + Delete this node from the list of nodes previously shown in this + window. */ + for (i = info_win->current; i < info_win->nodes_index; i++) + info_win->nodes[i] = info_win->nodes[i++]; + + /* There is one less node in this window's history list. */ + info_win->nodes_index--; + + /* Make this window show the most recent history node. */ + info_win->current = info_win->nodes_index - 1; + + /* If there aren't any nodes left in this window, steal one from the + next window. */ + if (info_win->current < 0) + { + INFO_WINDOW *stealer; + int which, pagetop; + long point; + + if (info_windows[iw + 1]) + stealer = info_windows[iw + 1]; + else + stealer = info_windows[0]; + + /* If the node being displayed in the next window is not the most + recently loaded one, get the most recently loaded one. */ + if ((stealer->nodes_index - 1) != stealer->current) + which = stealer->nodes_index - 1; + + /* Else, if there is another node behind the stealers current node, + use that one. */ + else if (stealer->current > 0) + which = stealer->current - 1; + + /* Else, just use the node appearing in STEALER's window. */ + else + which = stealer->current; + + /* Copy this node. */ + { + NODE *copy; + + temp = stealer->nodes[which]; + point = stealer->points[which]; + pagetop = stealer->pagetops[which]; + + copy = (NODE *)xmalloc (sizeof (NODE)); + copy->filename = temp->filename; + copy->parent = temp->parent; + copy->nodename = temp->nodename; + copy->contents = temp->contents; + copy->nodelen = temp->nodelen; + copy->flags = temp->flags; + + temp = copy; + } + + window_set_node_of_window (info_win->window, temp); + window->point = point; + window->pagetop = pagetop; + remember_window_and_node (info_win->window, temp); + } + else + { + temp = info_win->nodes[info_win->current]; + window_set_node_of_window (info_win->window, temp); + } + if (!info_error_was_printed) + window_clear_echo_area (); +} + +/* Read the name of a file and select the entire file. */ +DECLARE_INFO_COMMAND (info_view_file, "Read the name of a file and select it") +{ + char *line; + + line = info_read_in_echo_area (window, "Find file: "); + if (!line) + { + info_abort_key (active_window, 1, 0); + return; + } + + if (*line) + { + NODE *node; + + node = info_get_node (line, "*"); + if (!node) + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error ("Cannot find \"%s\".", line); + } + else + { + set_remembered_pagetop_and_point (active_window); + info_set_node_of_window (window, node); + } + free (line); + } + + if (!info_error_was_printed) + window_clear_echo_area (); +} + +/* **************************************************************** */ +/* */ +/* Dumping and Printing Nodes */ +/* */ +/* **************************************************************** */ + +#define VERBOSE_NODE_DUMPING +static void write_node_to_stream (); +static void dump_node_to_stream (); +static void initialize_dumping (); + +/* Dump the nodes specified by FILENAME and NODENAMES to the file named + in OUTPUT_FILENAME. If DUMP_SUBNODES is non-zero, recursively dump + the nodes which appear in the menu of each node dumped. */ +void +dump_nodes_to_file (filename, nodenames, output_filename, dump_subnodes) + char *filename; + char **nodenames; + char *output_filename; + int dump_subnodes; +{ + register int i; + FILE *output_stream; + + /* Get the stream to print the nodes to. Special case of an output + filename of "-" means to dump the nodes to stdout. */ + if (strcmp (output_filename, "-") == 0) + output_stream = stdout; + else + output_stream = fopen (output_filename, "w"); + + if (!output_stream) + { + info_error ("Could not create output file \"%s\".", output_filename); + return; + } + + /* Print each node to stream. */ + initialize_dumping (); + for (i = 0; nodenames[i]; i++) + dump_node_to_stream (filename, nodenames[i], output_stream, dump_subnodes); + + if (output_stream != stdout) + fclose (output_stream); + +#if defined (VERBOSE_NODE_DUMPING) + info_error ("Done."); +#endif /* VERBOSE_NODE_DUMPING */ +} + +/* A place to remember already dumped nodes. */ +static char **dumped_already = (char **)NULL; +static int dumped_already_index = 0; +static int dumped_already_slots = 0; + +static void +initialize_dumping () +{ + dumped_already_index = 0; +} + +/* Get and print the node specified by FILENAME and NODENAME to STREAM. + If DUMP_SUBNODES is non-zero, recursively dump the nodes which appear + in the menu of each node dumped. */ +static void +dump_node_to_stream (filename, nodename, stream, dump_subnodes) + char *filename, *nodename; + FILE *stream; + int dump_subnodes; +{ + register int i; + NODE *node; + + node = info_get_node (filename, nodename); + + if (!node) + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + { + if (filename && *nodename != '(') + info_error + (CANT_FILE_NODE, filename_non_directory (filename), nodename); + else + info_error (CANT_FIND_NODE, nodename); + } + return; + } + + /* If we have already dumped this node, don't dump it again. */ + for (i = 0; i < dumped_already_index; i++) + if (strcmp (node->nodename, dumped_already[i]) == 0) + { + free (node); + return; + } + add_pointer_to_array (node->nodename, dumped_already_index, dumped_already, + dumped_already_slots, 50, char *); + +#if defined (VERBOSE_NODE_DUMPING) + /* Maybe we should print some information about the node being output. */ + if (node->filename) + info_error ("Writing node \"(%s)%s\"...", + filename_non_directory (node->filename), node->nodename); + else + info_error ("Writing node \"%s\"...", node->nodename); +#endif /* VERBOSE_NODE_DUMPING */ + + write_node_to_stream (node, stream); + + /* If we are dumping subnodes, get the list of menu items in this node, + and dump each one recursively. */ + if (dump_subnodes) + { + REFERENCE **menu = (REFERENCE **)NULL; + + /* If this node is an Index, do not dump the menu references. */ + if (string_in_line ("Index", node->nodename) == -1) + menu = info_menu_of_node (node); + + if (menu) + { + for (i = 0; menu[i]; i++) + { + /* We don't dump Info files which are different than the + current one. */ + if (!menu[i]->filename) + dump_node_to_stream + (filename, menu[i]->nodename, stream, dump_subnodes); + } + info_free_references (menu); + } + } + + free (node); +} + +/* Dump NODE to FILENAME. If DUMP_SUBNODES is non-zero, recursively dump + the nodes which appear in the menu of each node dumped. */ +void +dump_node_to_file (node, filename, dump_subnodes) + NODE *node; + char *filename; + int dump_subnodes; +{ + FILE *output_stream; + char *nodes_filename; + + /* Get the stream to print this node to. Special case of an output + filename of "-" means to dump the nodes to stdout. */ + if (strcmp (filename, "-") == 0) + output_stream = stdout; + else + output_stream = fopen (filename, "w"); + + if (!output_stream) + { + info_error ("Could not create output file \"%s\".", filename); + return; + } + + if (node->parent) + nodes_filename = node->parent; + else + nodes_filename = node->filename; + + initialize_dumping (); + dump_node_to_stream + (nodes_filename, node->nodename, output_stream, dump_subnodes); + + if (output_stream != stdout) + fclose (output_stream); + +#if defined (VERBOSE_NODE_DUMPING) + info_error ("Done."); +#endif /* VERBOSE_NODE_DUMPING */ +} + +#if !defined (DEFAULT_INFO_PRINT_COMMAND) +# define DEFAULT_INFO_PRINT_COMMAND "lpr" +#endif /* !DEFAULT_INFO_PRINT_COMMAND */ + +DECLARE_INFO_COMMAND (info_print_node, + "Pipe the contents of this node through INFO_PRINT_COMMAND") +{ + print_node (window->node); +} + +/* Print NODE on a printer piping it into INFO_PRINT_COMMAND. */ +void +print_node (node) + NODE *node; +{ + char *print_command, *getenv (); + FILE *printer_pipe; + + print_command = getenv ("INFO_PRINT_COMMAND"); + + if (!print_command || !*print_command) + print_command = DEFAULT_INFO_PRINT_COMMAND; + + printer_pipe = popen (print_command, "w"); + + if (!printer_pipe) + { + info_error ("Cannot open pipe to \"%s\".", print_command); + return; + } + +#if defined (VERBOSE_NODE_DUMPING) + /* Maybe we should print some information about the node being output. */ + if (node->filename) + info_error ("Printing node \"(%s)%s\"...", + filename_non_directory (node->filename), node->nodename); + else + info_error ("Printing node \"%s\"...", node->nodename); +#endif /* VERBOSE_NODE_DUMPING */ + + write_node_to_stream (node, printer_pipe); + pclose (printer_pipe); + +#if defined (VERBOSE_NODE_DUMPING) + info_error ("Done."); +#endif /* VERBOSE_NODE_DUMPING */ +} + +static void +write_node_to_stream (node, stream) + NODE *node; + FILE *stream; +{ + fwrite (node->contents, 1, node->nodelen, stream); +} + +/* **************************************************************** */ +/* */ +/* Info Searching Commands */ +/* */ +/* **************************************************************** */ + +/* Variable controlling the garbage collection of files briefly visited + during searches. Such files are normally gc'ed, unless they were + compressed to begin with. If this variable is non-zero, it says + to gc even those file buffer contents which had to be uncompressed. */ +int gc_compressed_files = 0; + +static void info_gc_file_buffers (); + +static char *search_string = (char *)NULL; +static int search_string_index = 0; +static int search_string_size = 0; +static int isearch_is_active = 0; + +/* Return the file buffer which belongs to WINDOW's node. */ +FILE_BUFFER * +file_buffer_of_window (window) + WINDOW *window; +{ + /* If this window has no node, then it has no file buffer. */ + if (!window->node) + return ((FILE_BUFFER *)NULL); + + if (window->node->parent) + return (info_find_file (window->node->parent)); + + if (window->node->filename) + return (info_find_file (window->node->filename)); + + return ((FILE_BUFFER *)NULL); +} + +/* Search for STRING in NODE starting at START. Return -1 if the string + was not found, or the location of the string if it was. If WINDOW is + passed as non-null, set the window's node to be NODE, its point to be + the found string, and readjust the window's pagetop. Final argument + DIR says which direction to search in. If it is positive, search + forward, else backwards. */ +long +info_search_in_node (string, node, start, window, dir) + char *string; + NODE *node; + long start; + WINDOW *window; + int dir; +{ + SEARCH_BINDING binding; + long offset; + + binding.buffer = node->contents; + binding.start = start; + binding.end = node->nodelen; + binding.flags = S_FoldCase; + + if (dir < 0) + { + binding.end = 0; + binding.flags |= S_SkipDest; + } + + if (binding.start < 0) + return (-1); + + /* For incremental searches, we always wish to skip past the string. */ + if (isearch_is_active) + binding.flags |= S_SkipDest; + + offset = search (string, &binding); + + if (offset != -1 && window) + { + set_remembered_pagetop_and_point (window); + if (window->node != node) + window_set_node_of_window (window, node); + window->point = offset; + window_adjust_pagetop (window); + } + return (offset); +} + +/* Search NODE, looking for the largest possible match of STRING. Start the + search at START. Return the absolute position of the match, or -1, if + no part of the string could be found. */ +long +info_target_search_node (node, string, start) + NODE *node; + char *string; + long start; +{ + register int i; + long offset; + char *target; + + target = strdup (string); + i = strlen (target); + + /* Try repeatedly searching for this string while removing words from + the end of it. */ + while (i) + { + target[i] = '\0'; + offset = info_search_in_node (target, node, start, (WINDOW *)NULL, 1); + + if (offset != -1) + break; + + /* Delete the last word from TARGET. */ + for (; i && (!whitespace (target[i]) && (target[i] != ',')); i--); + } + free (target); + return (offset); +} + +/* Search for STRING starting in WINDOW at point. If the string is found + in this node, set point to that position. Otherwise, get the file buffer + associated with WINDOW's node, and search through each node in that file. + If the search fails, return non-zero, else zero. Side-effect window + leaving the node and point where the string was found current. */ +static char *last_searched_for_string = (char *)NULL; +static int +info_search_internal (string, window, dir) + char *string; + WINDOW *window; + int dir; +{ + register int i; + FILE_BUFFER *file_buffer; + char *initial_nodename; + long ret, start = 0; + + file_buffer = file_buffer_of_window (window); + initial_nodename = window->node->nodename; + + if ((info_last_executed_command == info_search) && + (last_searched_for_string) && + (strcmp (last_searched_for_string, string) == 0)) + { + ret = info_search_in_node + (string, window->node, window->point + dir, window, dir); + } + else + { + ret = info_search_in_node + (string, window->node, window->point, window, dir); + } + + maybe_free (last_searched_for_string); + last_searched_for_string = strdup (string); + + if (ret != -1) + { + /* We won! */ + if (!echo_area_is_active && !isearch_is_active) + window_clear_echo_area (); + return (0); + } + + /* The string wasn't found in the current node. Search through the + window's file buffer, iff the current node is not "*". */ + if (!file_buffer || (strcmp (initial_nodename, "*") == 0)) + return (-1); + + /* If this file has tags, search through every subfile, starting at + this node's subfile and node. Otherwise, search through the + file's node list. */ + if (file_buffer->tags) + { + register int current_tag, number_of_tags; + char *last_subfile; + TAG *tag; + + /* Find number of tags and current tag. */ + last_subfile = (char *)NULL; + for (i = 0; file_buffer->tags[i]; i++) + if (strcmp (initial_nodename, file_buffer->tags[i]->nodename) == 0) + { + current_tag = i; + last_subfile = file_buffer->tags[i]->filename; + } + + number_of_tags = i; + + /* If there is no last_subfile, our tag wasn't found. */ + if (!last_subfile) + return (-1); + + /* Search through subsequent nodes, wrapping around to the top + of the info file until we find the string or return to this + window's node and point. */ + while (1) + { + NODE *node; + + /* Allow C-g to quit the search, failing it if pressed. */ + return_if_control_g (-1); + + current_tag += dir; + + if (current_tag < 0) + current_tag = number_of_tags - 1; + else if (current_tag == number_of_tags) + current_tag = 0; + + tag = file_buffer->tags[current_tag]; + + if (!echo_area_is_active && (last_subfile != tag->filename)) + { + window_message_in_echo_area + ("Searching subfile \"%s\"...", + filename_non_directory (tag->filename)); + + last_subfile = tag->filename; + } + + node = info_get_node (file_buffer->filename, tag->nodename); + + if (!node) + { + /* If not doing i-search... */ + if (!echo_area_is_active) + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error (CANT_FILE_NODE, + filename_non_directory (file_buffer->filename), + tag->nodename); + } + return (-1); + } + + if (dir < 0) + start = tag->nodelen; + + ret = + info_search_in_node (string, node, start, window, dir); + + /* Did we find the string in this node? */ + if (ret != -1) + { + /* Yes! We win. */ + remember_window_and_node (window, node); + if (!echo_area_is_active) + window_clear_echo_area (); + return (0); + } + + /* No. Free this node, and make sure that we haven't passed + our starting point. */ + free (node); + + if (strcmp (initial_nodename, tag->nodename) == 0) + return (-1); + } + } + return (-1); +} + +DECLARE_INFO_COMMAND (info_search, "Read a string and search for it") +{ + char *line, *prompt; + int result, old_pagetop; + int direction; + + if (count < 0) + direction = -1; + else + direction = 1; + + /* Read a string from the user, defaulting the search to SEARCH_STRING. */ + if (!search_string) + { + search_string = (char *)xmalloc (search_string_size = 100); + search_string[0] = '\0'; + } + + prompt = (char *)xmalloc (50 + strlen (search_string)); + + sprintf (prompt, "%s for string [%s]: ", + direction < 0 ? "Search backward" : "Search", + search_string); + + line = info_read_in_echo_area (window, prompt); + free (prompt); + + if (!line) + { + info_abort_key (); + return; + } + + if (*line) + { + if (strlen (line) + 1 > search_string_size) + search_string = (char *) + xrealloc (search_string, (search_string_size += 50 + strlen (line))); + + strcpy (search_string, line); + search_string_index = strlen (line); + free (line); + } + + old_pagetop = active_window->pagetop; + result = info_search_internal (search_string, active_window, direction); + + if (result != 0 && !info_error_was_printed) + info_error ("Search failed."); + else if (old_pagetop != active_window->pagetop) + { + int new_pagetop; + + new_pagetop = active_window->pagetop; + active_window->pagetop = old_pagetop; + set_window_pagetop (active_window, new_pagetop); + if (auto_footnotes_p) + info_get_or_remove_footnotes (active_window); + } + + /* Perhaps free the unreferenced file buffers that were searched, but + not retained. */ + info_gc_file_buffers (); +} + +/* **************************************************************** */ +/* */ +/* Incremental Searching */ +/* */ +/* **************************************************************** */ + +static void incremental_search (); + +DECLARE_INFO_COMMAND (isearch_forward, + "Search interactively for a string as you type it") +{ + incremental_search (window, count, key); +} + +DECLARE_INFO_COMMAND (isearch_backward, + "Search interactively for a string as you type it") +{ + incremental_search (window, -count, key); +} + +/* Incrementally search for a string as it is typed. */ +/* The last accepted incremental search string. */ +static char *last_isearch_accepted = (char *)NULL; + +/* The current incremental search string. */ +static char *isearch_string = (char *)NULL; +static int isearch_string_index = 0; +static int isearch_string_size = 0; +static unsigned char isearch_terminate_search_key = ESC; + +/* Structure defining the current state of an incremental search. */ +typedef struct { + WINDOW_STATE_DECL; /* The node, pagetop and point. */ + int search_index; /* Offset of the last char in the search string. */ + int direction; /* The direction that this search is heading in. */ + int failing; /* Whether or not this search failed. */ +} SEARCH_STATE; + +/* Array of search states. */ +static SEARCH_STATE **isearch_states = (SEARCH_STATE **)NULL; +static int isearch_states_index = 0; +static int isearch_states_slots = 0; + +/* Push the state of this search. */ +static void +push_isearch (window, search_index, direction, failing) + WINDOW *window; + int search_index, direction, failing; +{ + SEARCH_STATE *state; + + state = (SEARCH_STATE *)xmalloc (sizeof (SEARCH_STATE)); + window_get_state (window, state); + state->search_index = search_index; + state->direction = direction; + state->failing = failing; + + add_pointer_to_array (state, isearch_states_index, isearch_states, + isearch_states_slots, 20, SEARCH_STATE *); +} + +/* Pop the state of this search to WINDOW, SEARCH_INDEX, and DIRECTION. */ +static void +pop_isearch (window, search_index, direction, failing) + WINDOW *window; + int *search_index, *direction, *failing; +{ + SEARCH_STATE *state; + + if (isearch_states_index) + { + isearch_states_index--; + state = isearch_states[isearch_states_index]; + window_set_state (window, state); + *search_index = state->search_index; + *direction = state->direction; + *failing = state->failing; + + free (state); + isearch_states[isearch_states_index] = (SEARCH_STATE *)NULL; + } +} + +/* Free the memory used by isearch_states. */ +static void +free_isearch_states () +{ + register int i; + + for (i = 0; i < isearch_states_index; i++) + { + free (isearch_states[i]); + isearch_states[i] = (SEARCH_STATE *)NULL; + } + isearch_states_index = 0; +} + +/* Display the current search in the echo area. */ +static void +show_isearch_prompt (dir, string, failing_p) + int dir; + unsigned char *string; + int failing_p; +{ + register int i; + char *prefix, *prompt, *p_rep; + int prompt_len, p_rep_index, p_rep_size; + + if (dir < 0) + prefix = "I-search backward: "; + else + prefix = "I-search: "; + + p_rep_index = p_rep_size = 0; + p_rep = (char *)NULL; + for (i = 0; string[i]; i++) + { + char *rep; + + switch (string[i]) + { + case ' ': rep = " "; break; + case LFD: rep = "\\n"; break; + case TAB: rep = "\\t"; break; + default: + rep = pretty_keyname (string[i]); + } + if ((p_rep_index + strlen (rep) + 1) >= p_rep_size) + p_rep = (char *)xrealloc (p_rep, p_rep_size += 100); + + strcpy (p_rep + p_rep_index, rep); + p_rep_index += strlen (rep); + } + + prompt_len = strlen (prefix) + p_rep_index + 20; + prompt = (char *)xmalloc (prompt_len); + sprintf (prompt, "%s%s%s", failing_p ? "Failing " : "", prefix, + p_rep ? p_rep : ""); + + window_message_in_echo_area ("%s", prompt); + maybe_free (p_rep); + free (prompt); + display_cursor_at_point (active_window); +} + +static void +incremental_search (window, count, ignore) + WINDOW *window; + int count; + unsigned char ignore; +{ + unsigned char key; + int last_search_result, search_result, dir; + SEARCH_STATE mystate, orig_state; + + if (count < 0) + dir = -1; + else + dir = 1; + + last_search_result = search_result = 0; + + window_get_state (window, &orig_state); + + isearch_string_index = 0; + if (!isearch_string_size) + isearch_string = (char *)xmalloc (isearch_string_size = 50); + + /* Show the search string in the echo area. */ + isearch_string[isearch_string_index] = '\0'; + show_isearch_prompt (dir, isearch_string, search_result); + + isearch_is_active = 1; + + while (isearch_is_active) + { + VFunction *func = (VFunction *)NULL; + int quoted = 0; + + /* If a recent display was interrupted, then do the redisplay now if + it is convenient. */ + if (!info_any_buffered_input_p () && display_was_interrupted_p) + { + display_update_one_window (window); + display_cursor_at_point (active_window); + } + + /* Read a character and dispatch on it. */ + key = info_get_input_char (); + window_get_state (window, &mystate); + + if (key == DEL) + { + /* User wants to delete one level of search? */ + if (!isearch_states_index) + { + terminal_ring_bell (); + continue; + } + else + { + pop_isearch + (window, &isearch_string_index, &dir, &search_result); + isearch_string[isearch_string_index] = '\0'; + show_isearch_prompt (dir, isearch_string, search_result); + goto after_search; + } + } + else if (key == Control ('q')) + { + key = info_get_input_char (); + quoted = 1; + } + + /* We are about to search again, or quit. Save the current search. */ + push_isearch (window, isearch_string_index, dir, search_result); + + if (quoted) + goto insert_and_search; + + if (!Meta_p (key) || (ISO_Latin_p && key < 160)) + { + func = window->keymap[key].function; + + /* If this key invokes an incremental search, then this means that + we will either search again in the same direction, search + again in the reverse direction, or insert the last search + string that was accepted through incremental searching. */ + if (func == isearch_forward || func == isearch_backward) + { + if ((func == isearch_forward && dir > 0) || + (func == isearch_backward && dir < 0)) + { + /* If the user has typed no characters, then insert the + last successful search into the current search string. */ + if (isearch_string_index == 0) + { + /* Of course, there must be something to insert. */ + if (last_isearch_accepted) + { + if (strlen (last_isearch_accepted) + 1 >= + isearch_string_size) + isearch_string = (char *) + xrealloc (isearch_string, + isearch_string_size += 10 + + strlen (last_isearch_accepted)); + strcpy (isearch_string, last_isearch_accepted); + isearch_string_index = strlen (isearch_string); + goto search_now; + } + else + continue; + } + else + { + /* Search again in the same direction. This means start + from a new place if the last search was successful. */ + if (search_result == 0) + window->point += dir; + } + } + else + { + /* Reverse the direction of the search. */ + dir = -dir; + } + } + else if (isprint (key) || func == (VFunction *)NULL) + { + insert_and_search: + + if (isearch_string_index + 2 >= isearch_string_size) + isearch_string = (char *)xrealloc + (isearch_string, isearch_string_size += 100); + + isearch_string[isearch_string_index++] = key; + isearch_string[isearch_string_index] = '\0'; + goto search_now; + } + else if (func == info_abort_key) + { + /* If C-g pressed, and the search is failing, pop the search + stack back to the last unfailed search. */ + if (isearch_states_index && (search_result != 0)) + { + terminal_ring_bell (); + while (isearch_states_index && (search_result != 0)) + pop_isearch + (window, &isearch_string_index, &dir, &search_result); + isearch_string[isearch_string_index] = '\0'; + show_isearch_prompt (dir, isearch_string, search_result); + continue; + } + else + goto exit_search; + } + else + goto exit_search; + } + else + { + exit_search: + /* The character is not printable, or it has a function which is + non-null. Exit the search, remembering the search string. If + the key is not the same as the isearch_terminate_search_key, + then push it into pending input. */ + if (isearch_string_index && func != info_abort_key) + { + maybe_free (last_isearch_accepted); + last_isearch_accepted = strdup (isearch_string); + } + + if (key != isearch_terminate_search_key) + info_set_pending_input (key); + + if (func == info_abort_key) + { + if (isearch_states_index) + window_set_state (window, &orig_state); + } + + if (!echo_area_is_active) + window_clear_echo_area (); + + if (auto_footnotes_p) + info_get_or_remove_footnotes (active_window); + + isearch_is_active = 0; + continue; + } + + /* Search for the contents of isearch_string. */ + search_now: + show_isearch_prompt (dir, isearch_string, search_result); + + if (search_result == 0) + { + /* Check to see if the current search string is right here. If + we are looking at it, then don't bother calling the search + function. */ + if (((dir < 0) && + (strncasecmp (window->node->contents + window->point, + isearch_string, isearch_string_index) == 0)) || + ((dir > 0) && + ((window->point - isearch_string_index) >= 0) && + (strncasecmp (window->node->contents + + (window->point - (isearch_string_index - 1)), + isearch_string, isearch_string_index) == 0))) + { + if (dir > 0) + window->point++; + } + else + search_result = info_search_internal (isearch_string, window, dir); + } + + /* If this search failed, and we didn't already have a failed search, + then ring the terminal bell. */ + if (search_result != 0 && last_search_result == 0) + terminal_ring_bell (); + + after_search: + show_isearch_prompt (dir, isearch_string, search_result); + + if (search_result == 0) + { + if ((mystate.node == window->node) && + (mystate.pagetop != window->pagetop)) + { + int newtop = window->pagetop; + window->pagetop = mystate.pagetop; + set_window_pagetop (window, newtop); + } + display_update_one_window (window); + display_cursor_at_point (window); + } + + last_search_result = search_result; + } + + /* Free the memory used to remember each search state. */ + free_isearch_states (); + + /* Perhaps GC some file buffers. */ + info_gc_file_buffers (); + + /* After searching, leave the window in the correct state. */ + if (!echo_area_is_active) + window_clear_echo_area (); +} + +/* GC some file buffers. A file buffer can be gc-ed if there we have + no nodes in INFO_WINDOWS that reference this file buffer's contents. + Garbage collecting a file buffer means to free the file buffers + contents. */ +static void +info_gc_file_buffers () +{ + register int fb_index, iw_index, i; + register FILE_BUFFER *fb; + register INFO_WINDOW *iw; + + if (!info_loaded_files) + return; + + for (fb_index = 0; fb = info_loaded_files[fb_index]; fb_index++) + { + int fb_referenced_p = 0; + + /* If already gc-ed, do nothing. */ + if (!fb->contents) + continue; + + /* If this file had to be uncompressed, check to see if we should + gc it. This means that the user-variable "gc-compressed-files" + is non-zero. */ + if ((fb->flags & N_IsCompressed) && !gc_compressed_files) + continue; + + /* If this file's contents are not gc-able, move on. */ + if (fb->flags & N_CannotGC) + continue; + + /* Check each INFO_WINDOW to see if it has any nodes which reference + this file. */ + for (iw_index = 0; iw = info_windows[iw_index]; iw_index++) + { + for (i = 0; iw->nodes && iw->nodes[i]; i++) + { + if ((strcmp (fb->fullpath, iw->nodes[i]->filename) == 0) || + (strcmp (fb->filename, iw->nodes[i]->filename) == 0)) + { + fb_referenced_p = 1; + break; + } + } + } + + /* If this file buffer wasn't referenced, free its contents. */ + if (!fb_referenced_p) + { + free (fb->contents); + fb->contents = (char *)NULL; + } + } +} + +/* **************************************************************** */ +/* */ +/* Traversing and Selecting References */ +/* */ +/* **************************************************************** */ + +/* Move to the next or previous cross reference in this node. */ +static void +info_move_to_xref (window, count, key, dir) + WINDOW *window; + int count; + unsigned char key; + int dir; +{ + long firstmenu, firstxref; + long nextmenu, nextxref; + long placement = -1; + long start = 0; + NODE *node = window->node; + + if (dir < 0) + start = node->nodelen; + + /* This search is only allowed to fail if there is no menu or cross + reference in the current node. Otherwise, the first menu or xref + found is moved to. */ + + firstmenu = info_search_in_node + (INFO_MENU_ENTRY_LABEL, node, start, (WINDOW *)NULL, dir); + + /* FIRSTMENU may point directly to the line defining the menu. Skip that + and go directly to the first item. */ + + if (firstmenu != -1) + { + char *text = node->contents + firstmenu; + + if (strncmp (text, INFO_MENU_LABEL, strlen (INFO_MENU_LABEL)) == 0) + firstmenu = info_search_in_node + (INFO_MENU_ENTRY_LABEL, node, firstmenu + dir, (WINDOW *)NULL, dir); + } + + firstxref = + info_search_in_node (INFO_XREF_LABEL, node, start, (WINDOW *)NULL, dir); + +#if defined (HANDLE_MAN_PAGES) + if ((firstxref == -1) && (node->flags & N_IsManPage)) + { + firstxref = locate_manpage_xref (node, start, dir); + } +#endif /* HANDLE_MAN_PAGES */ + + if (firstmenu == -1 && firstxref == -1) + { + info_error ("No cross references in this node."); + return; + } + + /* There is at least one cross reference or menu entry in this node. + Try hard to find the next available one. */ + + nextmenu = info_search_in_node + (INFO_MENU_ENTRY_LABEL, node, window->point + dir, (WINDOW *)NULL, dir); + + nextxref = info_search_in_node + (INFO_XREF_LABEL, node, window->point + dir, (WINDOW *)NULL, dir); + +#if defined (HANDLE_MAN_PAGES) + if ((nextxref == -1) && (node->flags & N_IsManPage) && (firstxref != -1)) + nextxref = locate_manpage_xref (node, window->point + dir, dir); +#endif /* HANDLE_MAN_PAGES */ + + /* Ignore "Menu:" as a menu item. */ + if (nextmenu != -1) + { + char *text = node->contents + nextmenu; + + if (strncmp (text, INFO_MENU_LABEL, strlen (INFO_MENU_LABEL)) == 0) + nextmenu = info_search_in_node + (INFO_MENU_ENTRY_LABEL, node, nextmenu + dir, (WINDOW *)NULL, dir); + } + + /* If there is both a next menu entry, and a next xref entry, choose the + one which occurs first. Otherwise, select the one which actually + appears in this node following point. */ + if (nextmenu != -1 && nextxref != -1) + { + if (((dir == 1) && (nextmenu < nextxref)) || + ((dir == -1) && (nextmenu > nextxref))) + placement = nextmenu + 1; + else + placement = nextxref; + } + else if (nextmenu != -1) + placement = nextmenu + 1; + else if (nextxref != -1) + placement = nextxref; + + /* If there was neither a menu or xref entry appearing in this node after + point, choose the first menu or xref entry appearing in this node. */ + if (placement == -1) + { + if (firstmenu != -1 && firstxref != -1) + { + if (((dir == 1) && (firstmenu < firstxref)) || + ((dir == -1) && (firstmenu > firstxref))) + placement = firstmenu + 1; + else + placement = firstxref; + } + else if (firstmenu != -1) + placement = firstmenu + 1; + else + placement = firstxref; + } + window->point = placement; + window_adjust_pagetop (window); + window->flags |= W_UpdateWindow; +} + +DECLARE_INFO_COMMAND (info_move_to_prev_xref, + "Move to the previous cross reference") +{ + if (count < 0) + info_move_to_prev_xref (window, -count, key); + else + info_move_to_xref (window, count, key, -1); +} + +DECLARE_INFO_COMMAND (info_move_to_next_xref, + "Move to the next cross reference") +{ + if (count < 0) + info_move_to_next_xref (window, -count, key); + else + info_move_to_xref (window, count, key, 1); +} + +/* Select the menu item or reference that appears on this line. */ +DECLARE_INFO_COMMAND (info_select_reference_this_line, + "Select reference or menu item appearing on this line") +{ + char *line; + NODE *orig; + + line = window->line_starts[window_line_of_point (window)]; + orig = window->node; + + /* If this line contains a menu item, select that one. */ + if (strncmp ("* ", line, 2) == 0) + info_menu_or_ref_item (window, count, key, info_menu_of_node, 0); + else + info_menu_or_ref_item (window, count, key, info_xrefs_of_node, 0); +} + +/* **************************************************************** */ +/* */ +/* Miscellaneous Info Commands */ +/* */ +/* **************************************************************** */ + +/* What to do when C-g is pressed in a window. */ +DECLARE_INFO_COMMAND (info_abort_key, "Cancel current operation") +{ + /* If error printing doesn't oridinarily ring the bell, do it now, + since C-g always rings the bell. Otherwise, let the error printer + do it. */ + if (!info_error_rings_bell_p) + terminal_ring_bell (); + info_error ("Quit"); + + info_initialize_numeric_arg (); + info_clear_pending_input (); + info_last_executed_command = (VFunction *)NULL; +} + +/* Move the cursor to the desired line of the window. */ +DECLARE_INFO_COMMAND (info_move_to_window_line, + "Move to the cursor to a specific line of the window") +{ + int line; + + /* With no numeric argument of any kind, default to the center line. */ + if (!info_explicit_arg && count == 1) + line = (window->height / 2) + window->pagetop; + else + { + if (count < 0) + line = (window->height + count) + window->pagetop; + else + line = window->pagetop + count; + } + + /* If the line doesn't appear in this window, make it do so. */ + if ((line - window->pagetop) >= window->height) + line = window->pagetop + (window->height - 1); + + /* If the line is too small, make it fit. */ + if (line < window->pagetop) + line = window->pagetop; + + /* If the selected line is past the bottom of the node, force it back. */ + if (line >= window->line_count) + line = window->line_count - 1; + + window->point = (window->line_starts[line] - window->node->contents); +} + +/* Clear the screen and redraw its contents. Given a numeric argument, + move the line the cursor is on to the COUNT'th line of the window. */ +DECLARE_INFO_COMMAND (info_redraw_display, "Redraw the display") +{ + if ((!info_explicit_arg && count == 1) || echo_area_is_active) + { + terminal_clear_screen (); + display_clear_display (the_display); + window_mark_chain (windows, W_UpdateWindow); + display_update_display (windows); + } + else + { + int desired_line, point_line; + int new_pagetop; + + point_line = window_line_of_point (window) - window->pagetop; + + if (count < 0) + desired_line = window->height + count; + else + desired_line = count; + + if (desired_line < 0) + desired_line = 0; + + if (desired_line >= window->height) + desired_line = window->height - 1; + + if (desired_line == point_line) + return; + + new_pagetop = window->pagetop + (point_line - desired_line); + + set_window_pagetop (window, new_pagetop); + } +} +/* This command does nothing. It is the fact that a key is bound to it + that has meaning. See the code at the top of info_session (). */ +DECLARE_INFO_COMMAND (info_quit, "Quit using Info") +{} + + +/* **************************************************************** */ +/* */ +/* Reading Keys and Dispatching on Them */ +/* */ +/* **************************************************************** */ + +/* Declaration only. Special cased in info_dispatch_on_key (). */ +DECLARE_INFO_COMMAND (info_do_lowercase_version, "") +{} + +static void +dispatch_error (keyseq) + char *keyseq; +{ + char *rep; + + rep = pretty_keyseq (keyseq); + + if (!echo_area_is_active) + info_error ("Unknown command (%s).", rep); + else + { + char *temp; + + temp = (char *)xmalloc (1 + strlen (rep) + strlen ("\"\" is invalid")); + + sprintf (temp, "\"%s\" is invalid", rep); + terminal_ring_bell (); + inform_in_echo_area (temp); + free (temp); + } +} + +/* Keeping track of key sequences. */ +static char *info_keyseq = (char *)NULL; +static char keyseq_rep[100]; +static int info_keyseq_index = 0; +static int info_keyseq_size = 0; +static int info_keyseq_displayed_p = 0; + +/* Initialize the length of the current key sequence. */ +void +initialize_keyseq () +{ + info_keyseq_index = 0; + info_keyseq_displayed_p = 0; +} + +/* Add CHARACTER to the current key sequence. */ +void +add_char_to_keyseq (character) + char character; +{ + if (info_keyseq_index + 2 >= info_keyseq_size) + info_keyseq = (char *)xrealloc (info_keyseq, info_keyseq_size += 10); + + info_keyseq[info_keyseq_index++] = character; + info_keyseq[info_keyseq_index] = '\0'; +} + +/* Return the pretty printable string which represents KEYSEQ. */ +char * +pretty_keyseq (keyseq) + char *keyseq; +{ + register int i; + + keyseq_rep[0] = '\0'; + + for (i = 0; keyseq[i]; i++) + { + sprintf (keyseq_rep + strlen (keyseq_rep), "%s%s", + strlen (keyseq_rep) ? " " : "", + pretty_keyname (keyseq[i])); + } + + return (keyseq_rep); +} + +/* Display the current value of info_keyseq. If argument EXPECTING is + non-zero, input is expected to be read after the key sequence is + displayed, so add an additional prompting character to the sequence. */ +void +display_info_keyseq (expecting_future_input) + int expecting_future_input; +{ + char *rep; + + rep = pretty_keyseq (info_keyseq); + if (expecting_future_input) + strcat (rep, "-"); + + if (echo_area_is_active) + inform_in_echo_area (rep); + else + { + window_message_in_echo_area (rep); + display_cursor_at_point (active_window); + } + info_keyseq_displayed_p = 1; +} + +/* Called by interactive commands to read a keystroke. */ +unsigned char +info_get_another_input_char () +{ + int ready = 0; + + /* If there isn't any input currently available, then wait a + moment looking for input. If we don't get it fast enough, + prompt a little bit with the current key sequence. */ + if (!info_keyseq_displayed_p && + !info_any_buffered_input_p () && + !info_input_pending_p ()) + { +#if defined (FD_SET) + struct timeval timer; + fd_set readfds; + + FD_ZERO (&readfds); + FD_SET (fileno (info_input_stream), &readfds); + timer.tv_sec = 1; + timer.tv_usec = 750; + ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer); +#endif /* FD_SET */ + } + + if (!ready) + display_info_keyseq (1); + + return (info_get_input_char ()); +} + +/* Do the command associated with KEY in MAP. If the associated command is + really a keymap, then read another key, and dispatch into that map. */ +void +info_dispatch_on_key (key, map) + unsigned char key; + Keymap map; +{ + if (Meta_p (key) && (!ISO_Latin_p || map[key].function != ea_insert)) + { + if (map[ESC].type == ISKMAP) + { + map = (Keymap)map[ESC].function; + add_char_to_keyseq (ESC); + key = UnMeta (key); + info_dispatch_on_key (key, map); + } + else + { + dispatch_error (info_keyseq); + } + return; + } + + switch (map[key].type) + { + case ISFUNC: + { + VFunction *func; + + func = map[key].function; + if (func != (VFunction *)NULL) + { + /* Special case info_do_lowercase_version (). */ + if (func == info_do_lowercase_version) + { + info_dispatch_on_key (tolower (key), map); + return; + } + + add_char_to_keyseq (key); + + if (info_keyseq_displayed_p) + display_info_keyseq (0); + + { + WINDOW *where; + + where = active_window; + (*map[key].function) + (active_window, info_numeric_arg * info_numeric_arg_sign, key); + + /* If we have input pending, then the last command was a prefix + command. Don't change the value of the last function vars. + Otherwise, remember the last command executed in the var + appropriate to the window in which it was executed. */ + if (!info_input_pending_p ()) + { + if (where == the_echo_area) + ea_last_executed_command = map[key].function; + else + info_last_executed_command = map[key].function; + } + } + } + else + { + add_char_to_keyseq (key); + dispatch_error (info_keyseq); + return; + } + } + break; + + case ISKMAP: + add_char_to_keyseq (key); + if (map[key].function != (VFunction *)NULL) + { + unsigned char newkey; + + newkey = info_get_another_input_char (); + info_dispatch_on_key (newkey, (Keymap)map[key].function); + } + else + { + dispatch_error (info_keyseq); + return; + } + break; + } +} + +/* **************************************************************** */ +/* */ +/* Numeric Arguments */ +/* */ +/* **************************************************************** */ + +/* Handle C-u style numeric args, as well as M--, and M-digits. */ + +/* Non-zero means that an explicit argument has been passed to this + command, as in C-u C-v. */ +int info_explicit_arg = 0; + +/* The sign of the numeric argument. */ +int info_numeric_arg_sign = 1; + +/* The value of the argument itself. */ +int info_numeric_arg = 1; + +/* Add the current digit to the argument in progress. */ +DECLARE_INFO_COMMAND (info_add_digit_to_numeric_arg, + "Add this digit to the current numeric argument") +{ + info_numeric_arg_digit_loop (window, 0, key); +} + +/* C-u, universal argument. Multiply the current argument by 4. + Read a key. If the key has nothing to do with arguments, then + dispatch on it. If the key is the abort character then abort. */ +DECLARE_INFO_COMMAND (info_universal_argument, + "Start (or multiply by 4) the current numeric argument") +{ + info_numeric_arg *= 4; + info_numeric_arg_digit_loop (window, 0, 0); +} + +/* Create a default argument. */ +void +info_initialize_numeric_arg () +{ + info_numeric_arg = info_numeric_arg_sign = 1; + info_explicit_arg = 0; +} + +DECLARE_INFO_COMMAND (info_numeric_arg_digit_loop, + "Internally used by \\[universal-argument]") +{ + unsigned char pure_key; + Keymap keymap = window->keymap; + + while (1) + { + if (key) + pure_key = key; + else + { + if (display_was_interrupted_p && !info_any_buffered_input_p ()) + display_update_display (windows); + + if (active_window != the_echo_area) + display_cursor_at_point (active_window); + + pure_key = key = info_get_another_input_char (); + + if (Meta_p (key)) + add_char_to_keyseq (ESC); + + add_char_to_keyseq (UnMeta (key)); + } + + if (Meta_p (key)) + key = UnMeta (key); + + if (keymap[key].type == ISFUNC && + keymap[key].function == info_universal_argument) + { + info_numeric_arg *= 4; + key = 0; + continue; + } + + if (isdigit (key)) + { + if (info_explicit_arg) + info_numeric_arg = (info_numeric_arg * 10) + (key - '0'); + else + info_numeric_arg = (key - '0'); + info_explicit_arg = 1; + } + else + { + if (key == '-' && !info_explicit_arg) + { + info_numeric_arg_sign = -1; + info_numeric_arg = 1; + } + else + { + info_keyseq_index--; + info_dispatch_on_key (pure_key, keymap); + return; + } + } + key = 0; + } +} + +/* **************************************************************** */ +/* */ +/* Input Character Buffering */ +/* */ +/* **************************************************************** */ + +/* Character waiting to be read next. */ +static int pending_input_character = 0; + +/* How to make there be no pending input. */ +static void +info_clear_pending_input () +{ + pending_input_character = 0; +} + +/* How to set the pending input character. */ +static void +info_set_pending_input (key) + unsigned char key; +{ + pending_input_character = key; +} + +/* How to see if there is any pending input. */ +unsigned char +info_input_pending_p () +{ + return (pending_input_character); +} + +/* Largest number of characters that we can read in advance. */ +#define MAX_INFO_INPUT_BUFFERING 512 + +static int pop_index = 0, push_index = 0; +static unsigned char info_input_buffer[MAX_INFO_INPUT_BUFFERING]; + +/* Add KEY to the buffer of characters to be read. */ +static void +info_push_typeahead (key) + unsigned char key; +{ + /* Flush all pending input in the case of C-g pressed. */ + if (key == Control ('g')) + { + push_index = pop_index; + info_set_pending_input (Control ('g')); + } + else + { + info_input_buffer[push_index++] = key; + if (push_index >= sizeof (info_input_buffer)) + push_index = 0; + } +} + +/* Return the amount of space available in INFO_INPUT_BUFFER for new chars. */ +static int +info_input_buffer_space_available () +{ + if (pop_index > push_index) + return (pop_index - push_index); + else + return (sizeof (info_input_buffer) - (push_index - pop_index)); +} + +/* Get a key from the buffer of characters to be read. + Return the key in KEY. + Result is non-zero if there was a key, or 0 if there wasn't. */ +static int +info_get_key_from_typeahead (key) + unsigned char *key; +{ + if (push_index == pop_index) + return (0); + + *key = info_input_buffer[pop_index++]; + + if (pop_index >= sizeof (info_input_buffer)) + pop_index = 0; + + return (1); +} + +int +info_any_buffered_input_p () +{ + info_gather_typeahead (); + return (push_index != pop_index); +} + +/* Push KEY into the *front* of the input buffer. Returns non-zero if + successful, zero if there is no space left in the buffer. */ +static int +info_replace_key_to_typeahead (key) + unsigned char key; +{ + if (info_input_buffer_space_available ()) + { + pop_index--; + if (pop_index < 0) + pop_index = sizeof (info_input_buffer) - 1; + info_input_buffer[pop_index] = key; + return (1); + } + return (0); +} + +/* If characters are available to be read, then read them and stuff them into + info_input_buffer. Otherwise, do nothing. */ +void +info_gather_typeahead () +{ + register int i = 0; + int tty, space_avail; + long chars_avail; + unsigned char input[MAX_INFO_INPUT_BUFFERING]; + + tty = fileno (info_input_stream); + chars_avail = 0; + + space_avail = info_input_buffer_space_available (); + + /* If we can just find out how many characters there are to read, do so. */ +#if defined (FIONREAD) + { + ioctl (tty, FIONREAD, &chars_avail); + + if (chars_avail > space_avail) + chars_avail = space_avail; + + if (chars_avail) + read (tty, &input[0], chars_avail); + } +#else /* !FIONREAD */ +# if defined (O_NDELAY) + { + int flags; + + flags = fcntl (tty, F_GETFL, 0); + + fcntl (tty, F_SETFL, (flags | O_NDELAY)); + chars_avail = read (tty, &input[0], space_avail); + fcntl (tty, F_SETFL, flags); + + if (chars_avail == -1) + chars_avail = 0; + } +# endif /* O_NDELAY */ +#endif /* !FIONREAD */ + + while (i < chars_avail) + { + info_push_typeahead (input[i]); + i++; + } +} + +/* How to read a single character. */ +unsigned char +info_get_input_char () +{ + unsigned char keystroke; + + info_gather_typeahead (); + + if (pending_input_character) + { + keystroke = pending_input_character; + pending_input_character = 0; + } + else if (info_get_key_from_typeahead (&keystroke) == 0) + { + int rawkey; + + rawkey = getc (info_input_stream); + keystroke = rawkey; + + if (rawkey == EOF) + { + if (info_input_stream != stdin) + { + fclose (info_input_stream); + info_input_stream = stdin; + display_inhibited = 0; + display_update_display (windows); + display_cursor_at_point (active_window); + rawkey = getc (info_input_stream); + keystroke = rawkey; + } + + if (rawkey == EOF) + { + terminal_unprep_terminal (); + close_dribble_file (); + exit (0); + } + } + } + + if (info_dribble_file) + dribble (keystroke); + + return (keystroke); +} diff --git a/texinfo/info/session.h b/texinfo/info/session.h new file mode 100644 index 000000000000..98b8ccf695fd --- /dev/null +++ b/texinfo/info/session.h @@ -0,0 +1,146 @@ +/* session.h -- Functions found in session.c. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_SESSION_H_) +#define _SESSION_H_ + +#include "general.h" +#include "dribble.h" + +/* All commands that can be invoked from within info_session () receive + arguments in the same way. This simple define declares the header + of a function named NAME, with associated documentation DOC. The + documentation string is groveled out of the source files by the + utility program `makedoc', which is also responsible for making + the documentation/function-pointer maps. */ +#define DECLARE_INFO_COMMAND(name, doc) \ +void name (window, count, key) WINDOW *window; int count; unsigned char key; + +/* Variables found in session.h. */ +extern VFunction *info_last_executed_command; + +/* Variable controlling the garbage collection of files briefly visited + during searches. Such files are normally gc'ed, unless they were + compressed to begin with. If this variable is non-zero, it says + to gc even those file buffer contents which had to be uncompressed. */ +extern int gc_compressed_files; + +/* When non-zero, tiling takes place automatically when info_split_window + is called. */ +extern int auto_tiling_p; + +/* Variable controlling the behaviour of default scrolling when you are + already at the bottom of a node. */ +extern int info_scroll_behaviour; +extern char *info_scroll_choices[]; + +/* Values for info_scroll_behaviour. */ +#define IS_Continuous 0 /* Try to get first menu item, or failing that, the + "Next:" pointer, or failing that, the "Up:" and + "Next:" of the up. */ +#define IS_NextOnly 1 /* Try to get "Next:" menu item. */ +#define IS_PageOnly 2 /* Simply give up at the bottom of a node. */ + +/* Utility functions found in session.c */ +extern void info_dispatch_on_key (); +extern unsigned char info_get_input_char (), info_get_another_input_char (); +extern unsigned char info_input_pending_p (); +extern void remember_window_and_node (), set_remembered_pagetop_and_point (); +extern void set_window_pagetop (), info_set_node_of_window (); +extern char *pretty_keyseq (); +extern void initialize_keyseq (), add_char_to_keyseq (); +extern void info_gather_typeahead (); +extern FILE_BUFFER *file_buffer_of_window (); +extern long info_search_in_node (), info_target_search_node (); +extern void info_select_reference (); +extern int info_any_buffered_input_p (); +extern void print_node (); +extern void dump_node_to_file (), dump_nodes_to_file (); + +/* Do the physical deletion of WINDOW, and forget this window and + associated nodes. */ +extern void info_delete_window_internal (); + +/* Tell Info that input is coming from the file FILENAME. */ +extern void info_set_input_from_file (); + +#define return_if_control_g(val) \ + do { \ + info_gather_typeahead (); \ + if (info_input_pending_p () == Control ('g')) \ + return (val); \ + } while (0) + +/* The names of the functions that run an info session. */ + +/* Starting an info session. */ +extern void begin_multiple_window_info_session (), begin_info_session (); +extern void begin_info_session_with_error (), info_session (); +extern void info_read_and_dispatch (); + +/* Moving the point within a node. */ +extern void info_next_line (), info_prev_line (); +extern void info_end_of_line (), info_beginning_of_line (); +extern void info_forward_char (), info_backward_char (); +extern void info_forward_word (), info_backward_word (); +extern void info_beginning_of_node (), info_end_of_node (); +extern void info_move_to_prev_xref (), info_move_to_next_xref (); + +/* Scrolling text within a window. */ +extern void info_scroll_forward (), info_scroll_backward (); +extern void info_redraw_display (), info_toggle_wrap (); +extern void info_move_to_window_line (); + +/* Manipulating multiple windows. */ +extern void info_split_window (), info_delete_window (); +extern void info_keep_one_window (), info_grow_window (); +extern void info_scroll_other_window (), info_tile_windows (); +extern void info_next_window (), info_prev_window (); + +/* Selecting nodes. */ +extern void info_next_node (), info_prev_node (), info_up_node (); +extern void info_last_node (), info_first_node (), info_history_node (); +extern void info_goto_node (), info_top_node (), info_dir_node (); +extern void info_global_next_node (), info_global_prev_node (); +extern void info_kill_node (), info_view_file (); + +/* Selecting cross references. */ +extern void info_menu_digit (), info_menu_item (), info_xref_item (); +extern void info_find_menu (), info_select_reference_this_line (); + +/* Hacking numeric arguments. */ +extern int info_explicit_arg, info_numeric_arg, info_numeric_arg_sign; + +extern void info_add_digit_to_numeric_arg (), info_universal_argument (); +extern void info_initialize_numeric_arg (), info_numeric_arg_digit_loop (); + +/* Searching commands. */ +extern void info_search (), isearch_forward (), isearch_backward (); + +/* Dumping and printing nodes. */ +extern void info_print_node (); + +/* Miscellaneous commands. */ +extern void info_abort_key (), info_quit (), info_do_lowercase_version (); + +#endif /* _SESSION_H_ */ diff --git a/texinfo/info/signals.c b/texinfo/info/signals.c new file mode 100644 index 000000000000..a60777fe597a --- /dev/null +++ b/texinfo/info/signals.c @@ -0,0 +1,173 @@ +/* signals.c -- Install and maintain Info signal handlers. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993, 1994, 1995 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" +#include "signals.h" + +/* **************************************************************** */ +/* */ +/* Pretending That We Have POSIX Signals */ +/* */ +/* **************************************************************** */ + +#if !defined (HAVE_SIGPROCMASK) && defined (HAVE_SIGSETMASK) +/* Perform OPERATION on NEWSET, perhaps leaving information in OLDSET. */ +static void +sigprocmask (operation, newset, oldset) + int operation, *newset, *oldset; +{ + switch (operation) + { + case SIG_UNBLOCK: + sigsetmask (sigblock (0) & ~(*newset)); + break; + + case SIG_BLOCK: + *oldset = sigblock (*newset); + break; + + case SIG_SETMASK: + sigsetmask (*newset); + break; + + default: + abort (); + } +} +#endif /* !HAVE_SIGPROCMASK && HAVE_SIGSETMASK */ + +/* **************************************************************** */ +/* */ +/* Signal Handling for Info */ +/* */ +/* **************************************************************** */ + +typedef void SigHandlerType; +typedef SigHandlerType SigHandler (); + +static SigHandlerType info_signal_handler (); +static SigHandler *old_TSTP, *old_TTOU, *old_TTIN; +static SigHandler *old_WINCH, *old_INT; + +void +initialize_info_signal_handler () +{ +#if defined (SIGTSTP) + old_TSTP = (SigHandler *) signal (SIGTSTP, info_signal_handler); + old_TTOU = (SigHandler *) signal (SIGTTOU, info_signal_handler); + old_TTIN = (SigHandler *) signal (SIGTTIN, info_signal_handler); +#endif /* SIGTSTP */ + +#if defined (SIGWINCH) + old_WINCH = (SigHandler *) signal (SIGWINCH, info_signal_handler); +#endif + +#if defined (SIGINT) + old_INT = (SigHandler *) signal (SIGINT, info_signal_handler); +#endif +} + +static void +redisplay_after_signal () +{ + terminal_clear_screen (); + display_clear_display (the_display); + window_mark_chain (windows, W_UpdateWindow); + display_update_display (windows); + display_cursor_at_point (active_window); + fflush (stdout); +} + +static SigHandlerType +info_signal_handler (sig) + int sig; +{ + SigHandler **old_signal_handler; + + switch (sig) + { +#if defined (SIGTSTP) + case SIGTSTP: + case SIGTTOU: + case SIGTTIN: +#endif +#if defined (SIGINT) + case SIGINT: +#endif + { +#if defined (SIGTSTP) + if (sig == SIGTSTP) + old_signal_handler = &old_TSTP; + if (sig == SIGTTOU) + old_signal_handler = &old_TTOU; + if (sig == SIGTTIN) + old_signal_handler = &old_TTIN; +#endif /* SIGTSTP */ + if (sig == SIGINT) + old_signal_handler = &old_INT; + + /* For stop signals, restore the terminal IO, leave the cursor + at the bottom of the window, and stop us. */ + terminal_goto_xy (0, screenheight - 1); + terminal_clear_to_eol (); + fflush (stdout); + terminal_unprep_terminal (); + signal (sig, *old_signal_handler); + UNBLOCK_SIGNAL (sig); + kill (getpid (), sig); + + /* The program is returning now. Restore our signal handler, + turn on terminal handling, redraw the screen, and place the + cursor where it belongs. */ + terminal_prep_terminal (); + *old_signal_handler = (SigHandler *) signal (sig, info_signal_handler); + redisplay_after_signal (); + fflush (stdout); + } + break; + +#if defined (SIGWINCH) + case SIGWINCH: + { + /* Turn off terminal IO, tell our parent that the window has changed, + then reinitialize the terminal and rebuild our windows. */ + old_signal_handler = &old_WINCH; + terminal_goto_xy (0, 0); + fflush (stdout); + terminal_unprep_terminal (); + signal (sig, *old_signal_handler); + UNBLOCK_SIGNAL (sig); + kill (getpid (), sig); + + /* After our old signal handler returns... */ + terminal_get_screen_size (); + terminal_prep_terminal (); + display_initialize_display (screenwidth, screenheight); + window_new_screen_size (screenwidth, screenheight, (VFunction *)NULL); + *old_signal_handler = (SigHandler *) signal (sig, info_signal_handler); + redisplay_after_signal (); + } + break; +#endif /* SIGWINCH */ + } +} diff --git a/texinfo/info/signals.h b/texinfo/info/signals.h new file mode 100644 index 000000000000..ab87a3b54958 --- /dev/null +++ b/texinfo/info/signals.h @@ -0,0 +1,89 @@ +/* signals.h -- Header to include system dependent signal definitions. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993, 1994, 1995 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_SIGNALS_H_) +#define _SIGNALS_H_ + +#include + +#if !defined (HAVE_SIGPROCMASK) && !defined (sigmask) +# define sigmask(x) (1 << ((x)-1)) +#endif /* !HAVE_SIGPROCMASK && !sigmask */ + +#if !defined (HAVE_SIGPROCMASK) +# if !defined (SIG_BLOCK) +# define SIG_UNBLOCK 1 +# define SIG_BLOCK 2 +# define SIG_SETMASK 3 +# endif /* SIG_BLOCK */ + +/* Type of a signal set. */ +# define sigset_t int + +/* Make SET have no signals in it. */ +# define sigemptyset(set) (*(set) = (sigset_t)0x0) + +/* Make SET have the full range of signal specifications possible. */ +# define sigfillset(set) (*(set) = (sigset_t)0xffffffffff) + +/* Add SIG to the contents of SET. */ +# define sigaddset(set, sig) *(set) |= sigmask (sig) + +/* Delete SIG from the contents of SET. */ +# define sigdelset(set, sig) *(set) &= ~(sigmask (sig)) + +/* Tell if SET contains SIG. */ +# define sigismember(set, sig) (*(set) & (sigmask (sig))) + +/* Suspend the process until the reception of one of the signals + not present in SET. */ +# define sigsuspend(set) sigpause (*(set)) +#endif /* !HAVE_SIGPROCMASK */ + +#if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK) +/* These definitions are used both in POSIX and non-POSIX implementations. */ + +#define BLOCK_SIGNAL(sig) \ + do { \ + sigset_t nvar, ovar; \ + sigemptyset (&nvar); \ + sigemptyset (&ovar); \ + sigaddset (&nvar, sig); \ + sigprocmask (SIG_BLOCK, &nvar, &ovar); \ + } while (0) + +#define UNBLOCK_SIGNAL(sig) \ + do { \ + sigset_t nvar, ovar; \ + sigemptyset (&ovar); \ + sigemptyset (&nvar); \ + sigaddset (&nvar, sig); \ + sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \ + } while (0) + +#else /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */ +# define BLOCK_SIGNAL(sig) +# define UNBLOCK_SIGNAL(sig) +#endif /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */ + +#endif /* !_SIGNALS_H_ */ diff --git a/texinfo/info/termdep.h b/texinfo/info/termdep.h new file mode 100644 index 000000000000..4f8ce9057ccb --- /dev/null +++ b/texinfo/info/termdep.h @@ -0,0 +1,76 @@ +/* termdep.h -- System things that terminal.c depends on. + $Id: termdep.h,v 1.3 1996/10/02 22:23:52 karl Exp $ + + This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993, 96 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_TERMDEP_H_) +# define _TERMDEP_H_ + +#if defined (HAVE_SYS_FCNTL_H) +# include +#else +# include +#endif /* !HAVE_SYS_FCNTL_H */ + +#if defined (HAVE_SYS_FILE_H) +# include +#endif /* HAVE_SYS_FILE_H */ + +#if defined (HAVE_STRINGS_H) +# include +#else +# if defined (HAVE_STRING_H) +# include +# endif +#endif + +#if defined (HAVE_TERMIOS_H) +# include +#else +# if defined (HAVE_TERMIO_H) +# include +# if defined (HAVE_SYS_PTEM_H) +# if defined (M_UNIX) || !defined (M_XENIX) +# include +# include +# undef TIOCGETC +# else /* M_XENIX */ +# define tchars tc +# endif /* M_XENIX */ +# endif /* HAVE_SYS_PTEM_H */ +# else /* !HAVE_TERMIO_H */ +# include +# endif /* !HAVE_TERMIO_H */ +#endif /* !HAVE_TERMIOS_H */ + +#if defined (HAVE_SYS_TTOLD_H) +# include +#endif /* HAVE_SYS_TTOLD_H */ + +#if !defined (HAVE_STRCHR) +# undef strchr +# undef strrchr +# define strchr index +# define strrchr rindex +#endif /* !HAVE_STRCHR */ + +#endif /* _TERMDEP_H_ */ diff --git a/texinfo/info/terminal.c b/texinfo/info/terminal.c new file mode 100644 index 000000000000..9c1017696c63 --- /dev/null +++ b/texinfo/info/terminal.c @@ -0,0 +1,769 @@ +/* terminal.c -- How to handle the physical terminal for Info. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + This file has appeared in prior works by the Free Software Foundation; + thus it carries copyright dates from 1988 through 1993. + + Copyright (C) 1988, 89, 90, 91, 92, 93, 96 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include +#include "terminal.h" +#include "termdep.h" + +extern void *xmalloc (), *xrealloc (); + +/* The Unix termcap interface code. */ + +extern int tgetnum (), tgetflag (), tgetent (); +extern char *tgetstr (), *tgoto (); +extern char *getenv (); +extern void tputs (); + +/* Function "hooks". If you make one of these point to a function, that + function is called when appropriate instead of its namesake. Your + function is called with exactly the same arguments that were passed + to the namesake function. */ +VFunction *terminal_begin_inverse_hook = (VFunction *)NULL; +VFunction *terminal_end_inverse_hook = (VFunction *)NULL; +VFunction *terminal_prep_terminal_hook = (VFunction *)NULL; +VFunction *terminal_unprep_terminal_hook = (VFunction *)NULL; +VFunction *terminal_up_line_hook = (VFunction *)NULL; +VFunction *terminal_down_line_hook = (VFunction *)NULL; +VFunction *terminal_clear_screen_hook = (VFunction *)NULL; +VFunction *terminal_clear_to_eol_hook = (VFunction *)NULL; +VFunction *terminal_get_screen_size_hook = (VFunction *)NULL; +VFunction *terminal_goto_xy_hook = (VFunction *)NULL; +VFunction *terminal_initialize_terminal_hook = (VFunction *)NULL; +VFunction *terminal_new_terminal_hook = (VFunction *)NULL; +VFunction *terminal_put_text_hook = (VFunction *)NULL; +VFunction *terminal_ring_bell_hook = (VFunction *)NULL; +VFunction *terminal_write_chars_hook = (VFunction *)NULL; +VFunction *terminal_scroll_terminal_hook = (VFunction *)NULL; + +/* **************************************************************** */ +/* */ +/* Terminal and Termcap */ +/* */ +/* **************************************************************** */ + +/* On Solaris2, sys/types.h #includes sys/reg.h, which #defines PC. + Unfortunately, PC is a global variable used by the termcap library. */ +#undef PC + +/* TERMCAP requires these variables, whether we access them or not. */ +char PC; +char *BC, *UP; +short ospeed; + +/* A buffer which holds onto the current terminal description, and a pointer + used to float within it. */ +static char *term_buffer = (char *)NULL; +static char *term_string_buffer = (char *)NULL; + +/* Some strings to control terminal actions. These are output by tputs (). */ +static char *term_goto, *term_clreol, *term_cr, *term_clrpag; +static char *term_begin_use, *term_end_use; +static char *term_AL, *term_DL, *term_al, *term_dl; + +/* How to go up a line. */ +static char *term_up; + +/* How to go down a line. */ +static char *term_dn; + +/* An audible bell, if the terminal can be made to make noise. */ +static char *audible_bell; + +/* A visible bell, if the terminal can be made to flash the screen. */ +static char *visible_bell; + +/* The string to write to turn on the meta key, if this term has one. */ +static char *term_mm; + +/* The string to write to turn off the meta key, if this term has one. */ +static char *term_mo; + +/* The string to turn on inverse mode, if this term has one. */ +static char *term_invbeg; + +/* The string to turn off inverse mode, if this term has one. */ +static char *term_invend; + +static void +output_character_function (c) + int c; +{ + putc (c, stdout); +} + +/* Macro to send STRING to the terminal. */ +#define send_to_terminal(string) \ + do { \ + if (string) \ + tputs (string, 1, output_character_function); \ + } while (0) + +/* Tell the terminal that we will be doing cursor addressable motion. */ +static void +terminal_begin_using_terminal () +{ + send_to_terminal (term_begin_use); +} + +/* Tell the terminal that we will not be doing any more cursor addressable + motion. */ +static void +terminal_end_using_terminal () +{ + send_to_terminal (term_end_use); +} + +/* **************************************************************** */ +/* */ +/* Necessary Terminal Functions */ +/* */ +/* **************************************************************** */ + +/* The functions and variables on this page implement the user visible + portion of the terminal interface. */ + +/* The width and height of the terminal. */ +int screenwidth, screenheight; + +/* Non-zero means this terminal can't really do anything. */ +int terminal_is_dumb_p = 0; + +/* Non-zero means that this terminal has a meta key. */ +int terminal_has_meta_p = 0; + +/* Non-zero means that this terminal can produce a visible bell. */ +int terminal_has_visible_bell_p = 0; + +/* Non-zero means to use that visible bell if at all possible. */ +int terminal_use_visible_bell_p = 0; + +/* Non-zero means that the terminal can do scrolling. */ +int terminal_can_scroll = 0; + +/* The key sequences output by the arrow keys, if this terminal has any. */ +char *term_ku = (char *)NULL; +char *term_kd = (char *)NULL; +char *term_kr = (char *)NULL; +char *term_kl = (char *)NULL; + +/* Move the cursor to the terminal location of X and Y. */ +void +terminal_goto_xy (x, y) + int x, y; +{ + if (terminal_goto_xy_hook) + (*terminal_goto_xy_hook) (x, y); + else + { + if (term_goto) + tputs (tgoto (term_goto, x, y), 1, output_character_function); + } +} + +/* Print STRING to the terminal at the current position. */ +void +terminal_put_text (string) + char *string; +{ + if (terminal_put_text_hook) + (*terminal_put_text_hook) (string); + else + { + printf ("%s", string); + } +} + +/* Print NCHARS from STRING to the terminal at the current position. */ +void +terminal_write_chars (string, nchars) + char *string; + int nchars; +{ + if (terminal_write_chars_hook) + (*terminal_write_chars_hook) (string, nchars); + else + { + if (nchars) + fwrite (string, 1, nchars, stdout); + } +} + +/* Clear from the current position of the cursor to the end of the line. */ +void +terminal_clear_to_eol () +{ + if (terminal_clear_to_eol_hook) + (*terminal_clear_to_eol_hook) (); + else + { + send_to_terminal (term_clreol); + } +} + +/* Clear the entire terminal screen. */ +void +terminal_clear_screen () +{ + if (terminal_clear_screen_hook) + (*terminal_clear_screen_hook) (); + else + { + send_to_terminal (term_clrpag); + } +} + +/* Move the cursor up one line. */ +void +terminal_up_line () +{ + if (terminal_up_line_hook) + (*terminal_up_line_hook) (); + else + { + send_to_terminal (term_up); + } +} + +/* Move the cursor down one line. */ +void +terminal_down_line () +{ + if (terminal_down_line_hook) + (*terminal_down_line_hook) (); + else + { + send_to_terminal (term_dn); + } +} + +/* Turn on reverse video if possible. */ +void +terminal_begin_inverse () +{ + if (terminal_begin_inverse_hook) + (*terminal_begin_inverse_hook) (); + else + { + send_to_terminal (term_invbeg); + } +} + +/* Turn off reverse video if possible. */ +void +terminal_end_inverse () +{ + if (terminal_end_inverse_hook) + (*terminal_end_inverse_hook) (); + else + { + send_to_terminal (term_invend); + } +} + +/* Ring the terminal bell. The bell is run visibly if it both has one and + terminal_use_visible_bell_p is non-zero. */ +void +terminal_ring_bell () +{ + if (terminal_ring_bell_hook) + (*terminal_ring_bell_hook) (); + else + { + if (terminal_has_visible_bell_p && terminal_use_visible_bell_p) + send_to_terminal (visible_bell); + else + send_to_terminal (audible_bell); + } +} + +/* At the line START, delete COUNT lines from the terminal display. */ +static void +terminal_delete_lines (start, count) + int start, count; +{ + int lines; + + /* Normalize arguments. */ + if (start < 0) + start = 0; + + lines = screenheight - start; + terminal_goto_xy (0, start); + if (term_DL) + tputs (tgoto (term_DL, 0, count), lines, output_character_function); + else + { + while (count--) + tputs (term_dl, lines, output_character_function); + } + + fflush (stdout); +} + +/* At the line START, insert COUNT lines in the terminal display. */ +static void +terminal_insert_lines (start, count) + int start, count; +{ + int lines; + + /* Normalize arguments. */ + if (start < 0) + start = 0; + + lines = screenheight - start; + terminal_goto_xy (0, start); + + if (term_AL) + tputs (tgoto (term_AL, 0, count), lines, output_character_function); + else + { + while (count--) + tputs (term_al, lines, output_character_function); + } + + fflush (stdout); +} + +/* Scroll an area of the terminal, starting with the region from START + to END, AMOUNT lines. If AMOUNT is negative, the lines are scrolled + towards the top of the screen, else they are scrolled towards the + bottom of the screen. */ +void +terminal_scroll_terminal (start, end, amount) + int start, end, amount; +{ + if (!terminal_can_scroll) + return; + + /* Any scrolling at all? */ + if (amount == 0) + return; + + if (terminal_scroll_terminal_hook) + (*terminal_scroll_terminal_hook) (start, end, amount); + else + { + /* If we are scrolling down, delete AMOUNT lines at END. Then insert + AMOUNT lines at START. */ + if (amount > 0) + { + terminal_delete_lines (end, amount); + terminal_insert_lines (start, amount); + } + + /* If we are scrolling up, delete AMOUNT lines before START. This + actually does the upwards scroll. Then, insert AMOUNT lines + after the already scrolled region (i.e., END - AMOUNT). */ + if (amount < 0) + { + int abs_amount = -amount; + terminal_delete_lines (start - abs_amount, abs_amount); + terminal_insert_lines (end - abs_amount, abs_amount); + } + } +} + +/* Re-initialize the terminal considering that the TERM/TERMCAP variable + has changed. */ +void +terminal_new_terminal (terminal_name) + char *terminal_name; +{ + if (terminal_new_terminal_hook) + (*terminal_new_terminal_hook) (terminal_name); + else + { + terminal_initialize_terminal (terminal_name); + } +} + +/* Set the global variables SCREENWIDTH and SCREENHEIGHT. */ +void +terminal_get_screen_size () +{ + if (terminal_get_screen_size_hook) + (*terminal_get_screen_size_hook) (); + else + { + screenwidth = screenheight = 0; + +#if defined (TIOCGWINSZ) + { + struct winsize window_size; + + if (ioctl (fileno (stdout), TIOCGWINSZ, &window_size) == 0) + { + screenwidth = (int) window_size.ws_col; + screenheight = (int) window_size.ws_row; + } + } +#endif /* TIOCGWINSZ */ + + /* Environment variable COLUMNS overrides setting of "co". */ + if (screenwidth <= 0) + { + char *sw = getenv ("COLUMNS"); + + if (sw) + screenwidth = atoi (sw); + + if (screenwidth <= 0) + screenwidth = tgetnum ("co"); + } + + /* Environment variable LINES overrides setting of "li". */ + if (screenheight <= 0) + { + char *sh = getenv ("LINES"); + + if (sh) + screenheight = atoi (sh); + + if (screenheight <= 0) + screenheight = tgetnum ("li"); + } + + /* If all else fails, default to 80x24 terminal. */ + if (screenwidth <= 0) + screenwidth = 80; + + if (screenheight <= 0) + screenheight = 24; + } +} + +/* Initialize the terminal which is known as TERMINAL_NAME. If this terminal + doesn't have cursor addressability, TERMINAL_IS_DUMB_P becomes non-zero. + The variables SCREENHEIGHT and SCREENWIDTH are set to the dimensions that + this terminal actually has. The variable TERMINAL_HAS_META_P becomes non- + zero if this terminal supports a Meta key. Finally, the terminal screen is + cleared. */ +void +terminal_initialize_terminal (terminal_name) + char *terminal_name; +{ + char *term, *buffer; + + terminal_is_dumb_p = 0; + + if (terminal_initialize_terminal_hook) + { + (*terminal_initialize_terminal_hook) (terminal_name); + return; + } + + term = terminal_name ? terminal_name : getenv ("TERM"); + + if (!term_string_buffer) + term_string_buffer = (char *)xmalloc (2048); + + if (!term_buffer) + term_buffer = (char *)xmalloc (2048); + + buffer = term_string_buffer; + + term_clrpag = term_cr = term_clreol = (char *)NULL; + + if (!term) + term = "dumb"; + + if (tgetent (term_buffer, term) <= 0) + { + terminal_is_dumb_p = 1; + screenwidth = 80; + screenheight = 24; + term_cr = "\r"; + term_up = term_dn = audible_bell = visible_bell = (char *)NULL; + term_ku = term_kd = term_kl = term_kr = (char *)NULL; + return; + } + + BC = tgetstr ("pc", &buffer); + PC = BC ? *BC : 0; + +#if defined (TIOCGETP) + { + struct sgttyb sg; + + if (ioctl (fileno (stdout), TIOCGETP, &sg) != -1) + ospeed = sg.sg_ospeed; + else + ospeed = B9600; + } +#else + ospeed = B9600; +#endif /* !TIOCGETP */ + + term_cr = tgetstr ("cr", &buffer); + term_clreol = tgetstr ("ce", &buffer); + term_clrpag = tgetstr ("cl", &buffer); + term_goto = tgetstr ("cm", &buffer); + + /* Find out about this terminals scrolling capability. */ + term_AL = tgetstr ("AL", &buffer); + term_DL = tgetstr ("DL", &buffer); + term_al = tgetstr ("al", &buffer); + term_dl = tgetstr ("dl", &buffer); + + terminal_can_scroll = ((term_AL || term_al) && (term_DL || term_dl)); + + term_invbeg = tgetstr ("mr", &buffer); + if (term_invbeg) + term_invend = tgetstr ("me", &buffer); + else + term_invend = (char *)NULL; + + if (!term_cr) + term_cr = "\r"; + + terminal_get_screen_size (); + + term_up = tgetstr ("up", &buffer); + term_dn = tgetstr ("dn", &buffer); + visible_bell = tgetstr ("vb", &buffer); + terminal_has_visible_bell_p = (visible_bell != (char *)NULL); + audible_bell = tgetstr ("bl", &buffer); + if (!audible_bell) + audible_bell = "\007"; + term_begin_use = tgetstr ("ti", &buffer); + term_end_use = tgetstr ("te", &buffer); + + /* Check to see if this terminal has a meta key. */ + terminal_has_meta_p = (tgetflag ("km") || tgetflag ("MT")); + if (terminal_has_meta_p) + { + term_mm = tgetstr ("mm", &buffer); + term_mo = tgetstr ("mo", &buffer); + } + else + { + term_mm = (char *)NULL; + term_mo = (char *)NULL; + } + + /* Attempt to find the arrow keys. */ + term_ku = tgetstr ("ku", &buffer); + term_kd = tgetstr ("kd", &buffer); + term_kr = tgetstr ("kr", &buffer); + term_kl = tgetstr ("kl", &buffer); + + /* If this terminal is not cursor addressable, then it is really dumb. */ + if (!term_goto) + terminal_is_dumb_p = 1; + + terminal_begin_using_terminal (); +} + +/* **************************************************************** */ +/* */ +/* How to Read Characters From the Terminal */ +/* */ +/* **************************************************************** */ + +#if defined (TIOCGETC) +/* A buffer containing the terminal interrupt characters upon entry + to Info. */ +struct tchars original_tchars; +#endif + +#if defined (TIOCGLTC) +/* A buffer containing the local terminal mode characters upon entry + to Info. */ +struct ltchars original_ltchars; +#endif + +#if defined (HAVE_TERMIOS_H) +struct termios original_termios, ttybuff; +#else +# if defined (HAVE_TERMIO_H) +/* A buffer containing the terminal mode flags upon entry to info. */ +struct termio original_termio, ttybuff; +# else /* !HAVE_TERMIO_H */ +/* Buffers containing the terminal mode flags upon entry to info. */ +int original_tty_flags = 0; +int original_lmode; +struct sgttyb ttybuff; +# endif /* !HAVE_TERMIO_H */ +#endif /* !HAVE_TERMIOS_H */ + +/* Prepare to start using the terminal to read characters singly. */ +void +terminal_prep_terminal () +{ + int tty; + + if (terminal_prep_terminal_hook) + { + (*terminal_prep_terminal_hook) (); + return; + } + + tty = fileno (stdin); + +#if defined (HAVE_TERMIOS_H) + tcgetattr (tty, &original_termios); + tcgetattr (tty, &ttybuff); +#else +# if defined (HAVE_TERMIO_H) + ioctl (tty, TCGETA, &original_termio); + ioctl (tty, TCGETA, &ttybuff); +# endif +#endif + +#if defined (HAVE_TERMIOS_H) || defined (HAVE_TERMIO_H) + ttybuff.c_iflag &= (~ISTRIP & ~INLCR & ~IGNCR & ~ICRNL & ~IXON); + ttybuff.c_oflag &= (~ONLCR & ~OCRNL); + ttybuff.c_lflag &= (~ICANON & ~ECHO); + + ttybuff.c_cc[VMIN] = 1; + ttybuff.c_cc[VTIME] = 0; + + if (ttybuff.c_cc[VINTR] == '\177') + ttybuff.c_cc[VINTR] = -1; + + if (ttybuff.c_cc[VQUIT] == '\177') + ttybuff.c_cc[VQUIT] = -1; +#endif + +#if defined (HAVE_TERMIOS_H) + tcsetattr (tty, TCSANOW, &ttybuff); +#else +# if defined (HAVE_TERMIO_H) + ioctl (tty, TCSETA, &ttybuff); +# endif +#endif + +#if !defined (HAVE_TERMIOS_H) && !defined (HAVE_TERMIO_H) + ioctl (tty, TIOCGETP, &ttybuff); + + if (!original_tty_flags) + original_tty_flags = ttybuff.sg_flags; + + /* Make this terminal pass 8 bits around while we are using it. */ +# if defined (PASS8) + ttybuff.sg_flags |= PASS8; +# endif /* PASS8 */ + +# if defined (TIOCLGET) && defined (LPASS8) + { + int flags; + ioctl (tty, TIOCLGET, &flags); + original_lmode = flags; + flags |= LPASS8; + ioctl (tty, TIOCLSET, &flags); + } +# endif /* TIOCLGET && LPASS8 */ + +# if defined (TIOCGETC) + { + struct tchars temp; + + ioctl (tty, TIOCGETC, &original_tchars); + temp = original_tchars; + + /* C-s and C-q. */ + temp.t_startc = temp.t_stopc = -1; + + /* Often set to C-d. */ + temp.t_eofc = -1; + + /* If the a quit or interrupt character conflicts with one of our + commands, then make it go away. */ + if (temp.t_intrc == '\177') + temp.t_intrc = -1; + + if (temp.t_quitc == '\177') + temp.t_quitc = -1; + + ioctl (tty, TIOCSETC, &temp); + } +# endif /* TIOCGETC */ + +# if defined (TIOCGLTC) + { + struct ltchars temp; + + ioctl (tty, TIOCGLTC, &original_ltchars); + temp = original_ltchars; + + /* Make the interrupt keys go away. Just enough to make people happy. */ + temp.t_lnextc = -1; /* C-v. */ + temp.t_dsuspc = -1; /* C-y. */ + temp.t_flushc = -1; /* C-o. */ + ioctl (tty, TIOCSLTC, &temp); + } +# endif /* TIOCGLTC */ + + ttybuff.sg_flags &= ~ECHO; + ttybuff.sg_flags |= CBREAK; + ioctl (tty, TIOCSETN, &ttybuff); +#endif /* !HAVE_TERMIOS_H && !HAVE_TERMIO_H */ +} + +/* Restore the tty settings back to what they were before we started using + this terminal. */ +void +terminal_unprep_terminal () +{ + int tty; + + if (terminal_unprep_terminal_hook) + { + (*terminal_unprep_terminal_hook) (); + return; + } + + tty = fileno (stdin); + +#if defined (HAVE_TERMIOS_H) + tcsetattr (tty, TCSANOW, &original_termios); +#else +# if defined (HAVE_TERMIO_H) + ioctl (tty, TCSETA, &original_termio); +# else /* !HAVE_TERMIO_H */ + ioctl (tty, TIOCGETP, &ttybuff); + ttybuff.sg_flags = original_tty_flags; + ioctl (tty, TIOCSETN, &ttybuff); + +# if defined (TIOCGETC) + ioctl (tty, TIOCSETC, &original_tchars); +# endif /* TIOCGETC */ + +# if defined (TIOCGLTC) + ioctl (tty, TIOCSLTC, &original_ltchars); +# endif /* TIOCGLTC */ + +# if defined (TIOCLGET) && defined (LPASS8) + ioctl (tty, TIOCLSET, &original_lmode); +# endif /* TIOCLGET && LPASS8 */ + +# endif /* !HAVE_TERMIO_H */ +#endif /* !HAVE_TERMIOS_H */ + terminal_end_using_terminal (); +} + diff --git a/texinfo/info/terminal.h b/texinfo/info/terminal.h new file mode 100644 index 000000000000..7cb115835c68 --- /dev/null +++ b/texinfo/info/terminal.h @@ -0,0 +1,129 @@ +/* terminal.h -- The external interface to terminal I/O. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993, 96 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_TERMINAL_H_) +#define _TERMINAL_H_ + +/* We use the following data type to talk about pointers to functions. */ +#if !defined (__FUNCTION_DEF) +# define __FUNCTION_DEF +typedef int Function (); +typedef void VFunction (); +#endif /* _FUNCTION_DEF */ + +/* For almost every function externally visible from terminal.c, there is + a corresponding "hook" function which can be bound in order to replace + the functionality of the one found in terminal.c. This is how we go + about implemented X window display. */ + +/* The width and height of the terminal. */ +extern int screenwidth, screenheight; + +/* Non-zero means this terminal can't really do anything. */ +extern int terminal_is_dumb_p; + +/* Non-zero means that this terminal has a meta key. */ +extern int terminal_has_meta_p; + +/* Non-zero means that this terminal can produce a visible bell. */ +extern int terminal_has_visible_bell_p; + +/* Non-zero means to use that visible bell if at all possible. */ +extern int terminal_use_visible_bell_p; + +/* Non-zero means that this terminal can scroll lines up and down. */ +extern int terminal_can_scroll; + +/* Initialize the terminal which is known as TERMINAL_NAME. If this terminal + doesn't have cursor addressability, TERMINAL_IS_DUMB_P becomes non-zero. + The variables SCREENHEIGHT and SCREENWIDTH are set to the dimensions that + this terminal actually has. The variable TERMINAL_HAS_META_P becomes non- + zero if this terminal supports a Meta key. */ +extern void terminal_initialize_terminal (); +extern VFunction *terminal_initialize_terminal_hook; + +/* Return the current screen width and height in the variables + SCREENWIDTH and SCREENHEIGHT. */ +extern void terminal_get_screen_size (); +extern VFunction *terminal_get_screen_size_hook; + +/* Save and restore tty settings. */ +extern void terminal_prep_terminal (), terminal_unprep_terminal (); +extern VFunction *terminal_prep_terminal_hook, *terminal_unprep_terminal_hook; + +/* Re-initialize the terminal to TERMINAL_NAME. */ +extern void terminal_new_terminal (); +extern VFunction *terminal_new_terminal_hook; + +/* Move the cursor to the terminal location of X and Y. */ +extern void terminal_goto_xy (); +extern VFunction *terminal_goto_xy_hook; + +/* Print STRING to the terminal at the current position. */ +extern void terminal_put_text (); +extern VFunction *terminal_put_text_hook; + +/* Print NCHARS from STRING to the terminal at the current position. */ +extern void terminal_write_chars (); +extern VFunction *terminal_write_chars_hook; + +/* Clear from the current position of the cursor to the end of the line. */ +extern void terminal_clear_to_eol (); +extern VFunction *terminal_clear_to_eol_hook; + +/* Clear the entire terminal screen. */ +extern void terminal_clear_screen (); +extern VFunction *terminal_clear_screen_hook; + +/* Move the cursor up one line. */ +extern void terminal_up_line (); +extern VFunction *terminal_up_line_hook; + +/* Move the cursor down one line. */ +extern void terminal_down_line (); +extern VFunction *terminal_down_line_hook; + +/* Turn on reverse video if possible. */ +extern void terminal_begin_inverse (); +extern VFunction *terminal_begin_inverse_hook; + +/* Turn off reverse video if possible. */ +extern void terminal_end_inverse (); +extern VFunction *terminal_end_inverse_hook; + +/* Scroll an area of the terminal, starting with the region from START + to END, AMOUNT lines. If AMOUNT is negative, the lines are scrolled + towards the top of the screen, else they are scrolled towards the + bottom of the screen. */ +extern void terminal_scroll_terminal (); +extern VFunction *terminal_scroll_terminal_hook; + +/* Ring the terminal bell. The bell is run visibly if it both has one and + terminal_use_visible_bell_p is non-zero. */ +extern void terminal_ring_bell (); +extern VFunction *terminal_ring_bell_hook; + +/* The key sequences output by the arrow keys, if this terminal has any. */ +extern char *term_ku, *term_kd, *term_kr, *term_kl; + +#endif /* !_TERMINAL_H_ */ diff --git a/texinfo/info/tilde.c b/texinfo/info/tilde.c new file mode 100644 index 000000000000..817f9092c307 --- /dev/null +++ b/texinfo/info/tilde.c @@ -0,0 +1,376 @@ +/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). + $Id: tilde.c,v 1.1 1997/08/21 22:58:05 jason Exp $ + + This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1988, 89, 90, 91, 92, 93, 96 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if defined (__GNUC__) +# define alloca __builtin_alloca +#else /* !__GNUC__ */ +# if defined (_AIX) + #pragma alloca +# else /* !_AIX */ +# if defined (HAVE_ALLOCA_H) +# include +# endif /* HAVE_ALLOCA_H */ +# endif /* !AIX */ +#endif /* !__GNUC__ */ + +#if defined (HAVE_STDLIB_H) +#include +#endif + +#include "tilde.h" +#include + +#if defined (HAVE_STRING_H) +#include +#endif + +#include "clib.h" + +#if !defined (NULL) +# define NULL 0x0 +#endif + +#if defined (TEST) || defined (STATIC_MALLOC) +static void *xmalloc (), *xrealloc (); +#else +extern void *xmalloc (), *xrealloc (); +#endif /* TEST || STATIC_MALLOC */ + +/* The default value of tilde_additional_prefixes. This is set to + whitespace preceding a tilde so that simple programs which do not + perform any word separation get desired behaviour. */ +static char *default_prefixes[] = + { " ~", "\t~", (char *)NULL }; + +/* The default value of tilde_additional_suffixes. This is set to + whitespace or newline so that simple programs which do not + perform any word separation get desired behaviour. */ +static char *default_suffixes[] = + { " ", "\n", (char *)NULL }; + +/* If non-null, this contains the address of a function to call if the + standard meaning for expanding a tilde fails. The function is called + with the text (sans tilde, as in "foo"), and returns a malloc()'ed string + which is the expansion, or a NULL pointer if there is no expansion. */ +CFunction *tilde_expansion_failure_hook = (CFunction *)NULL; + +/* When non-null, this is a NULL terminated array of strings which + are duplicates for a tilde prefix. Bash uses this to expand + `=~' and `:~'. */ +char **tilde_additional_prefixes = default_prefixes; + +/* When non-null, this is a NULL terminated array of strings which match + the end of a username, instead of just "/". Bash sets this to + `:' and `=~'. */ +char **tilde_additional_suffixes = default_suffixes; + +/* Find the start of a tilde expansion in STRING, and return the index of + the tilde which starts the expansion. Place the length of the text + which identified this tilde starter in LEN, excluding the tilde itself. */ +static int +tilde_find_prefix (string, len) + char *string; + int *len; +{ + register int i, j, string_len; + register char **prefixes = tilde_additional_prefixes; + + string_len = strlen (string); + *len = 0; + + if (!*string || *string == '~') + return (0); + + if (prefixes) + { + for (i = 0; i < string_len; i++) + { + for (j = 0; prefixes[j]; j++) + { + if (strncmp (string + i, prefixes[j], strlen (prefixes[j])) == 0) + { + *len = strlen (prefixes[j]) - 1; + return (i + *len); + } + } + } + } + return (string_len); +} + +/* Find the end of a tilde expansion in STRING, and return the index of + the character which ends the tilde definition. */ +static int +tilde_find_suffix (string) + char *string; +{ + register int i, j, string_len; + register char **suffixes = tilde_additional_suffixes; + + string_len = strlen (string); + + for (i = 0; i < string_len; i++) + { + if (string[i] == '/' || !string[i]) + break; + + for (j = 0; suffixes && suffixes[j]; j++) + { + if (strncmp (string + i, suffixes[j], strlen (suffixes[j])) == 0) + return (i); + } + } + return (i); +} + +/* Return a new string which is the result of tilde expanding STRING. */ +char * +tilde_expand (string) + char *string; +{ + char *result, *tilde_expand_word (); + int result_size, result_index; + + result_size = result_index = 0; + result = (char *)NULL; + + /* Scan through STRING expanding tildes as we come to them. */ + while (1) + { + register int start, end; + char *tilde_word, *expansion; + int len; + + /* Make START point to the tilde which starts the expansion. */ + start = tilde_find_prefix (string, &len); + + /* Copy the skipped text into the result. */ + if ((result_index + start + 1) > result_size) + result = (char *)xrealloc (result, 1 + (result_size += (start + 20))); + + strncpy (result + result_index, string, start); + result_index += start; + + /* Advance STRING to the starting tilde. */ + string += start; + + /* Make END be the index of one after the last character of the + username. */ + end = tilde_find_suffix (string); + + /* If both START and END are zero, we are all done. */ + if (!start && !end) + break; + + /* Expand the entire tilde word, and copy it into RESULT. */ + tilde_word = (char *)xmalloc (1 + end); + strncpy (tilde_word, string, end); + tilde_word[end] = '\0'; + string += end; + + expansion = tilde_expand_word (tilde_word); + free (tilde_word); + + len = strlen (expansion); + if ((result_index + len + 1) > result_size) + result = (char *)xrealloc (result, 1 + (result_size += (len + 20))); + + strcpy (result + result_index, expansion); + result_index += len; + free (expansion); + } + + result[result_index] = '\0'; + + return (result); +} + +/* Do the work of tilde expansion on FILENAME. FILENAME starts with a + tilde. If there is no expansion, call tilde_expansion_failure_hook. */ +char * +tilde_expand_word (filename) + char *filename; +{ + char *dirname; + + dirname = filename ? strdup (filename) : (char *)NULL; + + if (dirname && *dirname == '~') + { + char *temp_name; + if (!dirname[1] || dirname[1] == '/') + { + /* Prepend $HOME to the rest of the string. */ + extern char *getenv (); + char *temp_home = getenv ("HOME"); + + /* If there is no HOME variable, look up the directory in + the password database. */ + if (!temp_home) + { + struct passwd *entry; + + entry = (struct passwd *) getpwuid (getuid ()); + if (entry) + temp_home = entry->pw_dir; + } + + temp_name = (char *) + alloca (1 + strlen (&dirname[1]) + + (temp_home ? strlen (temp_home) : 0)); + temp_name[0] = '\0'; + if (temp_home) + strcpy (temp_name, temp_home); + strcat (temp_name, &dirname[1]); + free (dirname); + dirname = strdup (temp_name); + } + else + { + struct passwd *user_entry; + char *username = (char *)alloca (257); + int i, c; + + for (i = 1; c = dirname[i]; i++) + { + if (c == '/') + break; + else + username[i - 1] = c; + } + username[i - 1] = '\0'; + + if (!(user_entry = (struct passwd *) getpwnam (username))) + { + /* If the calling program has a special syntax for + expanding tildes, and we couldn't find a standard + expansion, then let them try. */ + if (tilde_expansion_failure_hook) + { + char *expansion; + + expansion = (*tilde_expansion_failure_hook) (username); + + if (expansion) + { + temp_name = (char *)alloca + (1 + strlen (expansion) + strlen (&dirname[i])); + strcpy (temp_name, expansion); + strcat (temp_name, &dirname[i]); + free (expansion); + goto return_name; + } + } + /* We shouldn't report errors. */ + } + else + { + temp_name = (char *)alloca + (1 + strlen (user_entry->pw_dir) + strlen (&dirname[i])); + strcpy (temp_name, user_entry->pw_dir); + strcat (temp_name, &dirname[i]); + return_name: + free (dirname); + dirname = strdup (temp_name); + } + endpwent (); + } + } + return (dirname); +} + + +#if defined (TEST) +#undef NULL +#include + +main (argc, argv) + int argc; + char **argv; +{ + char *result, line[512]; + int done = 0; + + while (!done) + { + printf ("~expand: "); + fflush (stdout); + + if (!gets (line)) + strcpy (line, "done"); + + if ((strcmp (line, "done") == 0) || + (strcmp (line, "quit") == 0) || + (strcmp (line, "exit") == 0)) + { + done = 1; + break; + } + + result = tilde_expand (line); + printf (" --> %s\n", result); + free (result); + } + exit (0); +} + +static void memory_error_and_abort (); + +static void * +xmalloc (bytes) + int bytes; +{ + void *temp = (void *)malloc (bytes); + + if (!temp) + memory_error_and_abort (); + return (temp); +} + +static void * +xrealloc (pointer, bytes) + void *pointer; + int bytes; +{ + void *temp; + + if (!pointer) + temp = (char *)malloc (bytes); + else + temp = (char *)realloc (pointer, bytes); + + if (!temp) + memory_error_and_abort (); + + return (temp); +} + +static void +memory_error_and_abort () +{ + fprintf (stderr, "readline: Out of virtual memory!\n"); + abort (); +} +#endif /* TEST */ + diff --git a/texinfo/info/tilde.h b/texinfo/info/tilde.h new file mode 100644 index 000000000000..d66aee95015e --- /dev/null +++ b/texinfo/info/tilde.h @@ -0,0 +1,58 @@ +/* tilde.h: Externally available variables and function in libtilde.a. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + This file has appeared in prior works by the Free Software Foundation; + thus it carries copyright dates from 1988 through 1993. + + Copyright (C) 1988, 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 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +/* Function pointers can be declared as (Function *)foo. */ +#if !defined (__FUNCTION_DEF) +# define __FUNCTION_DEF +typedef int Function (); +typedef void VFunction (); +typedef char *CFunction (); +#endif /* _FUNCTION_DEF */ + +/* If non-null, this contains the address of a function to call if the + standard meaning for expanding a tilde fails. The function is called + with the text (sans tilde, as in "foo"), and returns a malloc()'ed string + which is the expansion, or a NULL pointer if there is no expansion. */ +extern CFunction *tilde_expansion_failure_hook; + +/* When non-null, this is a NULL terminated array of strings which + are duplicates for a tilde prefix. Bash uses this to expand + `=~' and `:~'. */ +extern char **tilde_additional_prefixes; + +/* When non-null, this is a NULL terminated array of strings which match + the end of a username, instead of just "/". Bash sets this to + `:' and `=~'. */ +extern char **tilde_additional_suffixes; + +/* Return a new string which is the result of tilde expanding STRING. */ +extern char *tilde_expand (); + +/* Do the work of tilde expansion on FILENAME. FILENAME starts with a + tilde. If there is no expansion, call tilde_expansion_failure_hook. */ +extern char *tilde_expand_word (); + diff --git a/texinfo/info/userdoc.texi b/texinfo/info/userdoc.texi new file mode 100644 index 000000000000..f9349c65c508 --- /dev/null +++ b/texinfo/info/userdoc.texi @@ -0,0 +1,1270 @@ +@c This file is meant to be included in any arbitrary piece of +@c documentation that wishes to describe the info program. Some day +@c info-stnd.texi should probably use this file instead of duplicating +@c its contents. +@c +@c This file documents the use of the standalone GNU Info program, +@c versions 2.7 and later. + +@ifclear InfoProgVer +@set InfoProgVer 2.11 +@end ifclear +@synindex vr cp +@synindex fn cp +@synindex ky cp + +@heading What is Info? + +This text documents the use of the GNU Info program, version +@value{InfoProgVer}. + +@dfn{Info} is a program which is used to view info files on an ASCII +terminal. @dfn{info files} are the result of processing texinfo files +with the program @code{makeinfo} or with the Emacs command @code{M-x +texinfo-format-buffer}. Finally, @dfn{texinfo} is a documentation +language which allows a printed manual and online documentation (an info +file) to be produced from a single source file. + +@menu +* Options:: Options you can pass on the command line. +* Cursor Commands:: Commands which move the cursor within a node. +* Scrolling Commands:: Commands for moving the node around in a window. +* Node Commands:: Commands for selecting a new node. +* Searching Commands:: Commands for searching an info file. +* Xref Commands:: Commands for selecting cross references. +* Window Commands:: Commands which manipulate multiple windows. +* Printing Nodes:: How to print out the contents of a node. +* Miscellaneous Commands:: A few commands that defy categories. +* Variables:: How to change the default behaviour of Info. +@ifset NOTSET +* Info for Sys Admins:: How to setup Info. Using special options. +@end ifset +@ifset STANDALONE +* GNU Info Global Index:: Global index containing keystrokes, command names, + variable names, and general concepts. +@end ifset +@end menu + +@node Options +@chapter Command Line Options +@cindex command line options +@cindex arguments, command line + +GNU Info accepts several options to control the initial node being +viewed, and to specify which directories to search for info files. Here +is a template showing an invocation of GNU Info from the shell: + +@example +info [--@var{option-name} @var{option-value}] @var{menu-item}@dots{} +@end example + +The following @var{option-names} are available when invoking Info from +the shell: + +@table @code +@cindex directory path +@item --directory @var{directory-path} +@itemx -d @var{directory-path} +Adds @var{directory-path} to the list of directory paths searched when +Info needs to find a file. You may issue @code{--directory} multiple +times; once for each directory which contains info files. +Alternatively, you may specify a value for the environment variable +@code{INFOPATH}; if @code{--directory} is not given, the value of +@code{INFOPATH} is used. The value of @code{INFOPATH} is a colon +separated list of directory names. If you do not supply +@code{INFOPATH} or @code{--directory-path} a default path is used. + +@item --file @var{filename} +@itemx -f @var{filename} +@cindex info file, selecting +Specifies a particular info file to visit. Instead of visiting the file +@code{dir}, Info will start with @code{(@var{filename})Top} as the first +file and node. + +@item --node @var{nodename} +@itemx -n @var{nodename} +@cindex node, selecting +Specifies a particular node to visit in the initial file loaded. This +is especially useful in conjunction with @code{--file}@footnote{Of +course, you can specify both the file and node in a @code{--node} +command; but don't forget to escape the open and close parentheses from +the shell as in: @code{info --node '(emacs)Buffers'}}. You may specify +@code{--node} multiple times; for an interactive Info, each +@var{nodename} is visited in its own window, for a non-interactive Info +(such as when @code{--output} is given) each @var{nodename} is processed +sequentially. + +@item --output @var{filename} +@itemx -o @var{filename} +@cindex file, outputting to +@cindex outputting to a file +Specify @var{filename} as the name of a file to output to. Each node +that Info visits will be output to @var{filename} instead of +interactively viewed. A value of @code{-} for @var{filename} specifies +the standard output. + +@item --subnodes +@cindex @code{--subnodes}, command line option +This option only has meaning when given in conjunction with +@code{--output}. It means to recursively output the nodes appearing in +the menus of each node being output. Menu items which resolve to +external info files are not output, and neither are menu items which are +members of an index. Each node is only output once. + +@item --help +@itemx -h +Produces a relatively brief description of the available Info options. + +@item --version +@cindex version information +Prints the version information of Info and exits. + +@item @var{menu-item} +@cindex menu, following +Remaining arguments to Info are treated as the names of menu items. The +first argument would be a menu item in the initial node visited, while +the second argument would be a menu item in the first argument's node. +You can easily move to the node of your choice by specifying the menu +names which describe the path to that node. For example, + +@example +info emacs buffers +@end example + +first selects the menu item @samp{Emacs} in the node @samp{(dir)Top}, +and then selects the menu item @samp{Buffers} in the node +@samp{(emacs)Top}. + +@end table + +@node Cursor Commands +@chapter Moving the Cursor +@cindex cursor, moving +Many people find that reading screens of text page by page is made +easier when one is able to indicate particular pieces of text with some +kind of pointing device. Since this is the case, GNU Info (both the +Emacs and standalone versions) have several commands which allow you to +move the cursor about the screen. The notation used in this manual to +describe keystrokes is identical to the notation used within the Emacs +manual, and the GNU Readline manual. @xref{Characters, , Character +Conventions, emacs, the GNU Emacs Manual}, if you are unfamilar with the +notation. + +The following table lists the basic cursor movement commands in Info. +Each entry consists of the key sequence you should type to execute the +cursor movement, the @code{M-x}@footnote{@code{M-x} is also a command; it +invokes @code{execute-extended-command}. @xref{M-x, , Executing an +extended command, emacs, the GNU Emacs Manual}, for more detailed +information.} command name (displayed in parentheses), and a short +description of what the command does. All of the cursor motion commands +can take an @dfn{numeric} argument (@pxref{Miscellaneous Commands, +@code{universal-argument}}), to find out how to supply them. With a +numeric argument, the motion commands are simply executed that +many times; for example, a numeric argument of 4 given to +@code{next-line} causes the cursor to move down 4 lines. With a +negative numeric argument, the motion is reversed; an argument of -4 +given to the @code{next-line} command would cause the cursor to move +@emph{up} 4 lines. + +@table @asis +@item @code{C-n} (@code{next-line}) +@kindex C-n +@findex next-line +Moves the cursor down to the next line. + +@item @code{C-p} (@code{prev-line}) +@kindex C-p +@findex prev-line +Move the cursor up to the previous line. + +@item @code{C-a} (@code{beginning-of-line}) +@kindex C-a, in Info windows +@findex beginning-of-line +Move the cursor to the start of the current line. + +@item @code{C-e} (@code{end-of-line}) +@kindex C-e, in Info windows +@findex end-of-line +Moves the cursor to the end of the current line. + +@item @code{C-f} (@code{forward-char}) +@kindex C-f, in Info windows +@findex forward-char +Move the cursor forward a character. + +@item @code{C-b} (@code{backward-char}) +@kindex C-b, in Info windows +@findex backward-char +Move the cursor backward a character. + +@item @code{M-f} (@code{forward-word}) +@kindex M-f, in Info windows +@findex forward-word +Moves the cursor forward a word. + +@item @code{M-b} (@code{backward-word}) +@kindex M-b, in Info winows +@findex backward-word +Moves the cursor backward a word. + +@item @code{M-<} (@code{beginning-of-node}) +@itemx @code{b} +@kindex b, in Info winows +@kindex M-< +@findex beginning-of-node +Moves the cursor to the start of the current node. + +@item @code{M->} (@code{end-of-node}) +@kindex M-> +@findex end-of-node +Moves the cursor to the end of the current node. + +@item @code{M-r} (@code{move-to-window-line}) +@kindex M-r +@findex move-to-window-line +Moves the cursor to a specific line of the window. Without a numeric +argument, @code{M-r} moves the cursor to the start of the line in the +center of the window. With a numeric argument of @var{n}, @code{M-r} +moves the cursor to the start of the @var{n}th line in the window. +@end table + +@node Scrolling Commands +@chapter Moving Text Within a Window +@cindex scrolling + +Sometimes you are looking at a screenful of text, and only part of the +current paragraph you are reading is visible on the screen. The +commands detailed in this section are used to shift which part of the +current node is visible on the screen. + +@table @asis +@item @code{SPC} (@code{scroll-forward}) +@itemx @code{C-v} +@kindex SPC, in Info windows +@kindex C-v +@findex scroll-forward +Shift the text in this window up. That is, show more of the node which +is currently below the bottom of the window. With a numeric argument, +show that many more lines at the bottom of the window; a numeric +argument of 4 would shift all of the text in the window up 4 lines +(discarding the top 4 lines), and show you four new lines at the bottom +of the window. Without a numeric argument, @key{SPC} takes the bottom +two lines of the window and places them at the top of the window, +redisplaying almost a completely new screenful of lines. + +@item @code{DEL} (@code{scroll-backward}) +@itemx @code{M-v} +@kindex DEL, in Info windows +@kindex M-v +@findex scroll-backward +Shift the text in this window down. The inverse of +@code{scroll-forward}. + +@end table + +@cindex scrolling through node structure +The @code{scroll-forward} and @code{scroll-backward} commands can also +move forward and backward through the node structure of the file. If +you press @key{SPC} while viewing the end of a node, or @key{DEL} while +viewing the beginning of a node, what happens is controlled by the +variable @code{scroll-behaviour}. @xref{Variables, +@code{scroll-behaviour}}, for more information. + +@table @asis +@item @code{C-l} (@code{redraw-display}) +@kindex C-l +@findex redraw-display +Redraw the display from scratch, or shift the line containing the cursor +to a specified location. With no numeric argument, @samp{C-l} clears +the screen, and then redraws its entire contents. Given a numeric +argument of @var{n}, the line containing the cursor is shifted so that +it is on the @var{n}th line of the window. + +@item @code{C-x w} (@code{toggle-wrap}) +@kindex C-w +@findex toggle-wrap +Toggles the state of line wrapping in the current window. Normally, +lines which are longer than the screen width @dfn{wrap}, i.e., they are +continued on the next line. Lines which wrap have a @samp{\} appearing +in the rightmost column of the screen. You can cause such lines to be +terminated at the rightmost column by changing the state of line +wrapping in the window with @code{C-x w}. When a line which needs more +space than one screen width to display is displayed, a @samp{$} appears +in the rightmost column of the screen, and the remainder of the line is +invisible. +@end table + +@node Node Commands +@chapter Selecting a New Node +@cindex nodes, selection of + +This section details the numerous Info commands which select a new node +to view in the current window. + +The most basic node commands are @samp{n}, @samp{p}, @samp{u}, and +@samp{l}. + +When you are viewing a node, the top line of the node contains some Info +@dfn{pointers} which describe where the next, previous, and up nodes +are. Info uses this line to move about the node structure of the file +when you use the following commands: + +@table @asis +@item @code{n} (@code{next-node}) +@kindex n +@findex next-node +Selects the `Next' node. + +@item @code{p} (@code{prev-node}) +@kindex p +@findex prev-node +Selects the `Prev' node. + +@item @code{u} (@code{up-node}) +@kindex u +@findex up-node +Selects the `Up' node. +@end table + +You can easily select a node that you have already viewed in this window +by using the @samp{l} command -- this name stands for "last", and +actually moves through the list of already visited nodes for this +window. @samp{l} with a negative numeric argument moves forward through +the history of nodes for this window, so you can quickly step between +two adjacent (in viewing history) nodes. + +@table @asis +@item @code{l} (@code{history-node}) +@kindex l +@findex history-node +Selects the most recently selected node in this window. +@end table + +Two additional commands make it easy to select the most commonly +selected nodes; they are @samp{t} and @samp{d}. + +@table @asis +@item @code{t} (@code{top-node}) +@kindex t +@findex top-node +Selects the node @samp{Top} in the current info file. + +@item @code{d} (@code{dir-node}) +@kindex d +@findex dir-node +Selects the directory node (i.e., the node @samp{(dir)}). +@end table + +Here are some other commands which immediately result in the selection +of a different node in the current window: + +@table @asis +@item @code{<} (@code{first-node}) +@kindex < +@findex first-node +Selects the first node which appears in this file. This node is most +often @samp{Top}, but it doesn't have to be. + +@item @code{>} (@code{last-node}) +@kindex > +@findex last-node +Selects the last node which appears in this file. + +@item @code{]} (@code{global-next-node}) +@kindex ] +@findex global-next-node +Moves forward or down through node structure. If the node that you are +currently viewing has a @samp{Next} pointer, that node is selected. +Otherwise, if this node has a menu, the first menu item is selected. If +there is no @samp{Next} and no menu, the same process is tried with the +@samp{Up} node of this node. + +@item @code{[} (@code{global-prev-node}) +@kindex [ +@findex global-prev-node +Moves backward or up through node structure. If the node that you are +currently viewing has a @samp{Prev} pointer, that node is selected. +Otherwise, if the node has an @samp{Up} pointer, that node is selected, +and if it has a menu, the last item in the menu is selected. +@end table + +You can get the same behaviour as @code{global-next-node} and +@code{global-prev-node} while simply scrolling through the file with +@key{SPC} and @key{DEL}; @xref{Variables, @code{scroll-behaviour}}, for +more information. + +@table @asis +@item @code{g} (@code{goto-node}) +@kindex g +@findex goto-node +Reads the name of a node and selects it. No completion is done while +reading the node name, since the desired node may reside in a separate +file. The node must be typed exactly as it appears in the info file. A +file name may be included as with any node specification, for example + +@example +@code{g(emacs)Buffers} +@end example + +finds the node @samp{Buffers} in the info file @file{emacs}. + +@item @code{C-x k} (@code{kill-node}) +@kindex C-x k +@findex kill-node +Kills a node. The node name is prompted for in the echo area, with a +default of the current node. @dfn{Killing} a node means that Info tries +hard to forget about it, removing it from the list of history nodes kept +for the window where that node is found. Another node is selected in +the window which contained the killed node. + +@item @code{C-x C-f} (@code{view-file}) +@kindex C-x C-f +@findex view-file +Reads the name of a file and selects the entire file. The command +@example +@code{C-x C-f @var{filename}} +@end example +is equivalent to typing +@example +@code{g(@var{filename})*} +@end example + +@item @code{C-x C-b} (@code{list-visited-nodes}) +@kindex C-x C-b +@findex list-visited-nodes +Makes a window containing a menu of all of the currently visited nodes. +This window becomes the selected window, and you may use the standard +Info commands within it. + +@item @code{C-x b} (@code{select-visited-node}) +@kindex C-x b +@findex select-visited-node +Selects a node which has been previously visited in a visible window. +This is similar to @samp{C-x C-b} followed by @samp{m}, but no window is +created. +@end table + +@node Searching Commands +@chapter Searching an Info File +@cindex searching + +GNU Info allows you to search for a sequence of characters throughout an +entire info file, search through the indices of an info file, or find +areas within an info file which discuss a particular topic. + +@table @asis +@item @code{s} (@code{search}) +@kindex s +@findex search +Reads a string in the echo area and searches for it. + +@item @code{C-s} (@code{isearch-forward}) +@kindex C-s +@findex isearch-forward +Interactively searches forward through the info file for a string as you +type it. + +@item @code{C-r} (@code{isearch-backward}) +@kindex C-r +@findex isearch-backward +Interactively searches backward through the info file for a string as +you type it. + +@item @code{i} (@code{index-search}) +@kindex i +@findex index-search +Looks up a string in the indices for this info file, and selects a node +where the found index entry points to. + +@item @code{,} (@code{next-index-match}) +@kindex , +@findex next-index-match +Moves to the node containing the next matching index item from the last +@samp{i} command. +@end table + +The most basic searching command is @samp{s} (@code{search}). The +@samp{s} command prompts you for a string in the echo area, and then +searches the remainder of the info file for an ocurrence of that string. +If the string is found, the node containing it is selected, and the +cursor is left positioned at the start of the found string. Subsequent +@samp{s} commands show you the default search string within @samp{[} and +@samp{]}; pressing @key{RET} instead of typing a new string will use the +default search string. + +@dfn{Incremental searching} is similar to basic searching, but the +string is looked up while you are typing it, instead of waiting until +the entire search string has been specified. + +@node Xref Commands +@chapter Selecting Cross References + +We have already discussed the @samp{Next}, @samp{Prev}, and @samp{Up} +pointers which appear at the top of a node. In addition to these +pointers, a node may contain other pointers which refer you to a +different node, perhaps in another info file. Such pointers are called +@dfn{cross references}, or @dfn{xrefs} for short. + +@menu +* Parts of an Xref:: What a cross reference is made of. +* Selecting Xrefs:: Commands for selecting menu or note items. +@end menu + +@node Parts of an Xref +@section Parts of an Xref + +Cross references have two major parts: the first part is called the +@dfn{label}; it is the name that you can use to refer to the cross +reference, and the second is the @dfn{target}; it is the full name of +the node that the cross reference points to. + +The target is separated from the label by a colon @samp{:}; first the +label appears, and then the target. For example, in the sample menu +cross reference below, the single colon separates the label from the +target. + +@example +* Foo Label: Foo Target. More information about Foo. +@end example + +Note the @samp{.} which ends the name of the target. The @samp{.} is +not part of the target; it serves only to let Info know where the target +name ends. + +A shorthand way of specifying references allows two adjacent colons to +stand for a target name which is the same as the label name: + +@example +* Foo Commands:: Commands pertaining to Foo. +@end example + +In the above example, the name of the target is the same as the name of +the label, in this case @code{Foo Commands}. + +You will normally see two types of cross references while viewing nodes: +@dfn{menu} references, and @dfn{note} references. Menu references +appear within a node's menu; they begin with a @samp{*} at the beginning +of a line, and continue with a label, a target, and a comment which +describes what the contents of the node pointed to contains. + +Note references appear within the body of the node text; they begin with +@code{*Note}, and continue with a label and a target. + +Like @samp{Next}, @samp{Prev} and @samp{Up} pointers, cross references +can point to any valid node. They are used to refer you to a place +where more detailed information can be found on a particular subject. +Here is a cross reference which points to a node within the Texinfo +documentation: @xref{xref, , Writing an Xref, texinfo, the Texinfo +Manual}, for more information on creating your own texinfo cross +references. + +@node Selecting Xrefs +@section Selecting Xrefs + +The following table lists the Info commands which operate on menu items. + +@table @asis +@item @code{1} (@code{menu-digit}) +@itemx @code{2} @dots{} @code{9} +@cindex 1 @dots{} 9, in Info windows +@kindex 1 @dots{} 9, in Info windows +@findex menu-digit +Within an Info window, pressing a single digit, (such as @samp{1}), +selects that menu item, and places its node in the current window. +For convenience, there is one exception; pressing @samp{0} selects the +@emph{last} item in the node's menu. + +@item @code{0} (@code{last-menu-item}) +@kindex 0, in Info windows +@findex last-menu-item +Select the last item in the current node's menu. + +@item @code{m} (@code{menu-item}) +@kindex m +@findex menu-item +Reads the name of a menu item in the echo area and selects its node. +Completion is available while reading the menu label. + +@item @code{M-x find-menu} +@findex find-menu +Moves the cursor to the start of this node's menu. +@end table + +This table lists the Info commands which operate on note cross references. + +@table @asis +@item @code{f} (@code{xref-item}) +@itemx @code{r} +@kindex f +@kindex r +@findex xref-item +Reads the name of a note cross reference in the echo area and selects +its node. Completion is available while reading the cross reference +label. +@end table + +Finally, the next few commands operate on menu or note references alike: + +@table @asis +@item @code{TAB} (@code{move-to-next-xref}) +@kindex TAB, in Info windows +@findex move-to-next-xref +Moves the cursor to the start of the next nearest menu item or note +reference in this node. You can then use @key{RET} +(@code{select-reference-this-line} to select the menu or note reference. + +@item @code{M-TAB} (@code{move-to-prev-xref}) +@kindex M-TAB, in Info windows +@findex move-to-prev-xref +Moves the cursor the start of the nearest previous menu item or note +reference in this node. + +@item @code{RET} (@code{select-reference-this-line}) +@kindex RET, in Info windows +@findex select-reference-this-line +Selects the menu item or note reference appearing on this line. +@end table + +@node Window Commands +@chapter Manipulating Multiple Windows +@cindex windows, manipulating + +A @dfn{window} is a place to show the text of a node. Windows have a +view area where the text of the node is displayed, and an associated +@dfn{mode line}, which briefly describes the node being viewed. + +GNU Info supports multiple windows appearing in a single screen; each +window is separated from the next by its modeline. At any time, there +is only one @dfn{active} window, that is, the window in which the cursor +appears. There are commands available for creating windows, changing +the size of windows, selecting which window is active, and for deleting +windows. + +@menu +* The Mode Line:: What appears in the mode line? +* Basic Windows:: Manipulating windows in Info. +* The Echo Area:: Used for displaying errors and reading input. +@end menu + +@node The Mode Line +@section The Mode Line + +A @dfn{mode line} is a line of inverse video which appears at the bottom +of an info window. It describes the contents of the window just above +it; this information includes the name of the file and node appearing in +that window, the number of screen lines it takes to display the node, +and the percentage of text that is above the top of the window. It can +also tell you if the indirect tags table for this info file needs to be +updated, and whether or not the info file was compressed when stored on +disk. + +Here is a sample mode line for a window containing an uncompressed file +named @file{dir}, showing the node @samp{Top}. + +@example +-----Info: (dir)Top, 40 lines --Top--------------------------------------- + ^^ ^ ^^^ ^^ + (file)Node #lines where +@end example + +When a node comes from a file which is compressed on disk, this is +indicated in the mode line with two small @samp{z}'s. In addition, if +the info file containing the node has been split into subfiles, the name +of the subfile containing the node appears in the modeline as well: + +@example +--zz-Info: (emacs)Top, 291 lines --Top-- Subfile: emacs-1.Z--------------- +@end example + +When Info makes a node internally, such that there is no corresponding +info file on disk, the name of the node is surrounded by asterisks +(@samp{*}). The name itself tells you what the contents of the window +are; the sample mode line below shows an internally constructed node +showing possible completions: + +@example +-----Info: *Completions*, 7 lines --All----------------------------------- +@end example + +@node Basic Windows +@section Window Commands + +It can be convenient to view more than one node at a time. To allow +this, Info can display more than one @dfn{window}. Each window has its +own mode line (@pxref{The Mode Line}) and history of nodes viewed in that +window (@pxref{Node Commands, , @code{history-node}}). + +@table @asis +@item @code{C-x o} (@code{next-window}) +@cindex windows, selecting +@kindex C-x o +@findex next-window +Selects the next window on the screen. Note that the echo area can only be +selected if it is already in use, and you have left it temporarily. +Normally, @samp{C-x o} simply moves the cursor into the next window on +the screen, or if you are already within the last window, into the first +window on the screen. Given a numeric argument, @samp{C-x o} moves over +that many windows. A negative argument causes @samp{C-x o} to select +the previous window on the screen. + +@item @code{M-x prev-window} +@findex prev-window +Selects the previous window on the screen. This is identical to +@samp{C-x o} with a negative argument. + +@item @code{C-x 2} (@code{split-window}) +@cindex windows, creating +@kindex C-x 2 +@findex split-window +Splits the current window into two windows, both showing the same node. +Each window is one half the size of the original window, and the cursor +remains in the original window. The variable @code{automatic-tiling} +can cause all of the windows on the screen to be resized for you +automatically, please @pxref{Variables, , automatic-tiling} for more +information. + +@item @code{C-x 0} (@code{delete-window}) +@cindex windows, deleting +@kindex C-x 0 +@findex delete-window +Deletes the current window from the screen. If you have made too many +windows and your screen appears cluttered, this is the way to get rid of +some of them. + +@item @code{C-x 1} (@code{keep-one-window}) +@kindex C-x 1 +@findex keep-one-window +Deletes all of the windows excepting the current one. + +@item @code{ESC C-v} (@code{scroll-other-window}) +@kindex ESC C-v, in Info windows +@findex scroll-other-window +Scrolls the other window, in the same fashion that @samp{C-v} might +scroll the current window. Given a negative argument, the "other" +window is scrolled backward. + +@item @code{C-x ^} (@code{grow-window}) +@kindex C-x ^ +@findex grow-window +Grows (or shrinks) the current window. Given a numeric argument, grows +the current window that many lines; with a negative numeric argument, +the window is shrunk instead. + +@item @code{C-x t} (@code{tile-windows}) +@cindex tiling +@kindex C-x t +@findex tile-windows +Divides the available screen space among all of the visible windows. +Each window is given an equal portion of the screen in which to display +its contents. The variable @code{automatic-tiling} can cause +@code{tile-windows} to be called when a window is created or deleted. +@xref{Variables, , @code{automatic-tiling}}. +@end table + +@node The Echo Area +@section The Echo Area +@cindex echo area + +The @dfn{echo area} is a one line window which appears at the bottom of +the screen. It is used to display informative or error messages, and to +read lines of input from you when that is necessary. Almost all of the +commands available in the echo area are identical to their Emacs +counterparts, so please refer to that documentation for greater depth of +discussion on the concepts of editing a line of text. The following +table briefly lists the commands that are available while input is being +read in the echo area: + +@table @asis +@item @code{C-f} (@code{echo-area-forward}) +@kindex C-f, in the echo area +@findex echo-area-forward +Moves forward a character. + +@item @code{C-b} (@code{echo-area-backward}) +@kindex C-b, in the echo area +@findex echo-area-backward +Moves backward a character. + +@item @code{C-a} (@code{echo-area-beg-of-line}) +@kindex C-a, in the echo area +@findex echo-area-beg-of-line +Moves to the start of the input line. + +@item @code{C-e} (@code{echo-area-end-of-line}) +@kindex C-e, in the echo area +@findex echo-area-end-of-line +Moves to the end of the input line. + +@item @code{M-f} (@code{echo-area-forward-word}) +@kindex M-f, in the echo area +@findex echo-area-forward-word +Moves forward a word. + +@item @code{M-b} (@code{echo-area-backward-word}) +@kindex M-b, in the echo area +@findex echo-area-backward-word +Moves backward a word. + +@item @code{C-d} (@code{echo-area-delete}) +@kindex C-d, in the echo area +@findex echo-area-delete +Deletes the character under the cursor. + +@item @code{DEL} (@code{echo-area-rubout}) +@kindex DEL, in the echo area +@findex echo-area-rubout +Deletes the character behind the cursor. + +@item @code{C-g} (@code{echo-area-abort}) +@kindex C-g, in the echo area +@findex echo-area-abort +Cancels or quits the current operation. If completion is being read, +@samp{C-g} discards the text of the input line which does not match any +completion. If the input line is empty, @samp{C-g} aborts the calling +function. + +@item @code{RET} (@code{echo-area-newline}) +@kindex RET, in the echo area +@findex echo-area-newline +Accepts (or forces completion of) the current input line. + +@item @code{C-q} (@code{echo-area-quoted-insert}) +@kindex C-q, in the echo area +@findex echo-area-quoted-insert +Inserts the next character verbatim. This is how you can insert control +characters into a search string, for example. + +@item @var{printing character} (@code{echo-area-insert}) +@kindex printing characters, in the echo area +@findex echo-area-insert +Inserts the character. + +@item @code{M-TAB} (@code{echo-area-tab-insert}) +@kindex M-TAB, in the echo area +@findex echo-area-tab-insert +Inserts a TAB character. + +@item @code{C-t} (@code{echo-area-transpose-chars}) +@kindex C-t, in the echo area +@findex echo-area-transpose-chars +Transposes the characters at the cursor. +@end table + +The next group of commands deal with @dfn{killing}, and @dfn{yanking} +text. For an in depth discussion of killing and yanking, +@pxref{Killing, , Killing and Deleting, emacs, the GNU Emacs Manual} + +@table @asis +@item @code{M-d} (@code{echo-area-kill-word}) +@kindex M-d, in the echo area +@findex echo-area-kill-word +Kills the word following the cursor. + +@item @code{M-DEL} (@code{echo-area-backward-kill-word}) +@kindex M-DEL, in the echo area +@findex echo-area-backward-kill-word +Kills the word preceding the cursor. + +@item @code{C-k} (@code{echo-area-kill-line}) +@kindex C-k, in the echo area +@findex echo-area-kill-line +Kills the text from the cursor to the end of the line. + +@item @code{C-x DEL} (@code{echo-area-backward-kill-line}) +@kindex C-x DEL, in the echo area +@findex echo-area-backward-kill-line +Kills the text from the cursor to the beginning of the line. + +@item @code{C-y} (@code{echo-area-yank}) +@kindex C-y, in the echo area +@findex echo-area-yank +Yanks back the contents of the last kill. + +@item @code{M-y} (@code{echo-area-yank-pop}) +@kindex M-y, in the echo area +@findex echo-area-yank-pop +Yanks back a previous kill, removing the last yanked text first. +@end table + +Sometimes when reading input in the echo area, the command that needed +input will only accept one of a list of several choices. The choices +represent the @dfn{possible completions}, and you must respond with one +of them. Since there are a limited number of responses you can make, +Info allows you to abbreviate what you type, only typing as much of the +response as is necessary to uniquely identify it. In addition, you can +request Info to fill in as much of the response as is possible; this +is called @dfn{completion}. + +The following commands are available when completing in the echo area: + +@table @asis +@item @code{TAB} (@code{echo-area-complete}) +@itemx @code{SPC} +@kindex TAB, in the echo area +@kindex SPC, in the echo area +@findex echo-area-complete +Inserts as much of a completion as is possible. + +@item @code{?} (@code{echo-area-possible-completions}) +@kindex ?, in the echo area +@findex echo-area-possible-completions +Displays a window containing a list of the possible completions of what +you have typed so far. For example, if the available choices are: +@example +bar +foliate +food +forget +@end example +and you have typed an @samp{f}, followed by @samp{?}, the possible +completions would contain: +@example +foliate +food +forget +@end example +i.e., all of the choices which begin with @samp{f}. Pressing @key{SPC} +or @key{TAB} would result in @samp{fo} appearing in the echo area, since +all of the choices which begin with @samp{f} continue with @samp{o}. +Now, typing @samp{l} followed by @samp{TAB} results in @samp{foliate} +appearing in the echo area, since that is the only choice which begins +with @samp{fol}. + +@item @code{ESC C-v} (@code{echo-area-scroll-completions-window}) +@kindex ESC C-v, in the echo area +@findex echo-area-scroll-completions-window +Scrolls the completions window, if that is visible, or the "other" +window if not. +@end table + +@node Printing Nodes +@chapter Printing Out Nodes +@cindex printing + +You may wish to print out the contents of a node as a quick reference +document for later use. Info provides you with a command for doing +this. In general, we recommend that you use @TeX{} to format the +document and print sections of it, by running @code{tex} on the texinfo +source file. + +@table @asis +@item @code{M-x print-node} +@findex print-node +@cindex INFO_PRINT_COMMAND, environment variable +Pipes the contents of the current node through the command in the +environment variable @code{INFO_PRINT_COMMAND}. If the variable doesn't +exist, the node is simply piped to @code{lpr}. +@end table + +@node Miscellaneous Commands +@chapter Miscellaneous Commands + +GNU Info contains several commands which self-document GNU Info: + +@table @asis +@item @code{M-x describe-command} +@cindex functions, describing +@cindex commands, describing +@findex describe-command +Reads the name of an Info command in the echo area and then displays a +brief description of what that command does. + +@item @code{M-x describe-key} +@cindex keys, describing +@findex describe-key +Reads a key sequence in the echo area, and then displays the name and +documentation of the Info command that the key sequence invokes. + +@item @code{M-x describe-variable} +Reads the name of a variable in the echo area and then displays a brief +description of what the variable affects. + +@item @code{M-x where-is} +@findex where-is +Reads the name of an Info command in the echo area, and then displays +a key sequence which can be typed in order to invoke that command. + +@item @code{C-h} (@code{get-help-window}) +@itemx @code{?} +@kindex C-h +@kindex ?, in Info windows +@findex get-help-window +Creates (or moves into) the window displaying @code{*Help*}, and places +a node containing a quick reference card into it. This window displays +the most concise information about GNU Info available. + +@item @code{h} (@code{get-info-help-node}) +@kindex h +@findex get-info-help-node +Tries hard to visit the node @code{(info)Help}. The info file +@file{info.texi} distributed with GNU Info contains this node. Of +course, the file must first be processed with @code{makeinfo}, and then +placed into the location of your info directory. +@end table + +Here are the commands for creating a numeric argument: + +@table @asis +@item @code{C-u} (@code{universal-argument}) +@cindex numeric arguments +@kindex C-u +@findex universal-argument +Starts (or multiplies by 4) the current numeric argument. @samp{C-u} is +a good way to give a small numeric argument to cursor movement or +scrolling commands; @samp{C-u C-v} scrolls the screen 4 lines, while +@samp{C-u C-u C-n} moves the cursor down 16 lines. + +@item @code{M-1} (@code{add-digit-to-numeric-arg}) +@itemx @code{M-2} @dots{} @code{M-9} +@kindex M-1 @dots{} M-9 +@findex add-digit-to-numeric-arg +Adds the digit value of the invoking key to the current numeric +argument. Once Info is reading a numeric argument, you may just type +the digits of the argument, without the Meta prefix. For example, you +might give @samp{C-l} a numeric argument of 32 by typing: + +@example +@kbd{C-u 3 2 C-l} +@end example +or +@example +@kbd{M-3 2 C-l} +@end example +@end table + +@samp{C-g} is used to abort the reading of a multi-character key +sequence, to cancel lengthy operations (such as multi-file searches) and +to cancel reading input in the echo area. + +@table @asis +@item @code{C-g} (@code{abort-key}) +@cindex cancelling typeahead +@cindex cancelling the current operation +@kindex C-g, in Info windows +@findex abort-key +Cancels current operation. +@end table + +The @samp{q} command of Info simply quits running Info. + +@table @asis +@item @code{q} (@code{quit}) +@cindex quitting +@kindex q +@findex quit +Exits GNU Info. +@end table + +If the operating system tells GNU Info that the screen is 60 lines tall, +and it is actually only 40 lines tall, here is a way to tell Info that +the operating system is correct. + +@table @asis +@item @code{M-x set-screen-height} +@findex set-screen-height +@cindex screen, changing the height of +Reads a height value in the echo area and sets the height of the +displayed screen to that value. +@end table + +Finally, Info provides a convenient way to display footnotes which might +be associated with the current node that you are viewing: + +@table @asis +@item @code{ESC C-f} (@code{show-footnotes}) +@kindex ESC C-f +@findex show-footnotes +@cindex footnotes, displaying +Shows the footnotes (if any) associated with the current node in another +window. You can have Info automatically display the footnotes +associated with a node when the node is selected by setting the variable +@code{automatic-footnotes}. @xref{Variables, , @code{automatic-footnotes}}. +@end table + +@node Variables +@chapter Manipulating Variables + +GNU Info contains several @dfn{variables} whose values are looked at by various +Info commands. You can change the values of these variables, and thus +change the behaviour of Info to more closely match your environment and +info file reading manner. + +@table @asis +@item @code{M-x set-variable} +@cindex variables, setting +@findex set-variable +Reads the name of a variable, and the value for it, in the echo area and +then sets the variable to that value. Completion is available when +reading the variable name; often, completion is available when reading +the value to give to the variable, but that depends on the variable +itself. If a variable does @emph{not} supply multiple choices to +complete over, it expects a numeric value. + +@item @code{M-x describe-variable} +@cindex variables, describing +@findex describe-variable +Reads the name of a variable in the echo area and then displays a brief +description of what the variable affects. +@end table + +Here is a list of the variables that you can set in Info. + +@table @code +@item automatic-footnotes +@vindex automatic-footnotes +When set to @code{On}, footnotes appear and disappear automatically. +This variable is @code{On} by default. When a node is selected, a +window containing the footnotes which appear in that node is created, +and the footnotes are displayed within the new window. The window that +Info creates to contain the footnotes is called @samp{*Footnotes*}. If +a node is selected which contains no footnotes, and a @samp{*Footnotes*} +window is on the screen, the @samp{*Footnotes*} window is deleted. +Footnote windows created in this fashion are not automatically tiled so +that they can use as little of the display as is possible. + +@item automatic-tiling +@vindex automatic-tiling +When set to @code{On}, creating or deleting a window resizes other +windows. This variable is @code{Off} by default. Normally, typing +@samp{C-x 2} divides the current window into two equal parts. When +@code{automatic-tiling} is set to @code{On}, all of the windows are +resized automatically, keeping an equal number of lines visible in each +window. There are exceptions to the automatic tiling; specifically, the +windows @samp{*Completions*} and @samp{*Footnotes*} are @emph{not} +resized through automatic tiling; they remain their original size. + +@item visible-bell +@vindex visible-bell +When set to @code{On}, GNU Info attempts to flash the screen instead of +ringing the bell. This variable is @code{Off} by default. Of course, +Info can only flash the screen if the terminal allows it; in the case +that the terminal does not allow it, the setting of this variable has no +effect. However, you can make Info perform quietly by setting the +@code{errors-ring-bell} variable to @code{Off}. + +@item errors-ring-bell +@vindex errors-ring-bell +When set to @code{On}, errors cause the bell to ring. The default +setting of this variable is @code{On}. + +@item gc-compressed-files +@vindex gc-compressed-files +When set to @code{On}, Info garbage collects files which had to be +uncompressed. The default value of this variable is @code{Off}. +Whenever a node is visited in Info, the info file containing that node +is read into core, and Info reads information about the tags and nodes +contained in that file. Once the tags information is read by Info, it +is never forgotten. However, the actual text of the nodes does not need +to remain in core unless a particular info window needs it. For +non-compressed files, the text of the nodes does not remain in core when +it is no longer in use. But de-compressing a file can be a time +consuming operation, and so Info tries hard not to do it twice. +@code{gc-compressed-files} tells Info it is okay to garbage collect the +text of the nodes of a file which was compressed on disk. + +@item show-index-match +@vindex show-index-match +When set to @code{On}, the portion of the matched search string is +highlighted in the message which explains where the matched search +string was found. The default value of this variable is @code{On}. +When Info displays the location where an index match was found, +(@pxref{Searching Commands, , @code{next-index-match}}), the portion of the +string that you had typed is highlighted by displaying it in the inverse +case from its surrounding characters. + +@item scroll-behaviour +@vindex scroll-behaviour +Controls what happens when forward scrolling is requested at the end of +a node, or when backward scrolling is requested at the beginning of a +node. The default value for this variable is @code{Continuous}. There +are three possible values for this variable: + +@table @code +@item Continuous +Tries to get the first item in this node's menu, or failing that, the +@samp{Next} node, or failing that, the @samp{Next} of the @samp{Up}. +This behaviour is identical to using the @samp{]} +(@code{global-next-node}) and @samp{[} (@code{global-prev-node}) +commands. + +@item Next Only +Only tries to get the @samp{Next} node. + +@item Page Only +Simply gives up, changing nothing. If @code{scroll-behaviour} is +@code{Page Only}, no scrolling command can change the node that is being +viewed. +@end table + +@item scroll-step +@vindex scroll-step +The number of lines to scroll when the cursor moves out of the window. +Scrolling happens automatically if the cursor has moved out of the +visible portion of the node text when it is time to display. Usually +the scrolling is done so as to put the cursor on the center line of the +current window. However, if the variable @code{scroll-step} has a +nonzero value, Info attempts to scroll the node text by that many lines; +if that is enough to bring the cursor back into the window, that is what +is done. The default value of this variable is 0, thus placing the +cursor (and the text it is attached to) in the center of the window. +Setting this variable to 1 causes a kind of "smooth scrolling" which +some people prefer. + +@item ISO-Latin +@cindex ISO Latin characters +@vindex ISO-Latin +When set to @code{On}, Info accepts and displays ISO Latin characters. +By default, Info assumes an ASCII character set. @code{ISO-Latin} tells +Info that it is running in an environment where the European standard +character set is in use, and allows you to input such characters to +Info, as well as display them. +@end table + +@c The following node and its children are currently unfinished. Please feel +@c free to finish it! + +@ifset NOTSET +@node Info for Sys Admins +@chapter Info for System Administrators + +This text describes some common ways of setting up an Info heierarchy +from scratch, and details the various options that are available when +installing Info. This text is designed for the person who is installing +GNU Info on the system; although users may find the information present +in this section interesting, none of it is vital to understanding how to +use GNU Info. + +@menu +* Setting the INFOPATH:: Where are my Info files kept? +* Editing the DIR node:: What goes in `DIR', and why? +* Storing Info files:: Alternate formats allow flexibilty in setups. +* Using `localdir':: Building DIR on the fly. +* Example setups:: Some common ways to origanize Info files. +@end menu + +@node Setting the INFOPATH +@section Setting the INFOPATH +Where are my Info files kept? + +@node Editing the DIR node +@section Editing the DIR node +What goes in `DIR', and why? + +@node Storing Info files +@section Storing Info files +Alternate formats allow flexibilty in setups. + +@node Using `localdir' +@section Using `localdir' +Building DIR on the fly. + +@node Example setups +@section Example setups +Some common ways to origanize Info files. +@end ifset + +@ifset STANDALONE +@node GNU Info Global Index +@appendix Global Index +@printindex cp +@end ifset diff --git a/texinfo/info/variables.c b/texinfo/info/variables.c new file mode 100644 index 000000000000..7798701c124e --- /dev/null +++ b/texinfo/info/variables.c @@ -0,0 +1,272 @@ +/* variables.c -- How to manipulate user visible variables in Info. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include "info.h" +#include "variables.h" + +/* **************************************************************** */ +/* */ +/* User Visible Variables in Info */ +/* */ +/* **************************************************************** */ + +/* Choices used by the completer when reading a zero/non-zero value for + a variable. */ +static char *on_off_choices[] = { "Off", "On", (char *)NULL }; + +VARIABLE_ALIST info_variables[] = { + { "automatic-footnotes", + "When \"On\", footnotes appear and disappear automatically", + &auto_footnotes_p, (char **)on_off_choices }, + + { "automatic-tiling", + "When \"On\", creating or deleting a window resizes other windows", + &auto_tiling_p, (char **)on_off_choices }, + + { "visible-bell", + "When \"On\", flash the screen instead of ringing the bell", + &terminal_use_visible_bell_p, (char **)on_off_choices }, + + { "errors-ring-bell", + "When \"On\", errors cause the bell to ring", + &info_error_rings_bell_p, (char **)on_off_choices }, + + { "gc-compressed-files", + "When \"On\", Info garbage collects files which had to be uncompressed", + &gc_compressed_files, (char **)on_off_choices }, + { "show-index-match", + "When \"On\", the portion of the matched search string is highlighted", + &show_index_match, (char **)on_off_choices }, + + { "scroll-behaviour", + "Controls what happens when scrolling is requested at the end of a node", + &info_scroll_behaviour, (char **)info_scroll_choices }, + + { "scroll-step", + "The number lines to scroll when the cursor moves out of the window", + &window_scroll_step, (char **)NULL }, + + { "ISO-Latin", + "When \"On\", Info accepts and displays ISO Latin characters", + &ISO_Latin_p, (char **)on_off_choices }, + + { (char *)NULL, (char *)NULL, (int *)NULL, (char **)NULL } +}; + +DECLARE_INFO_COMMAND (describe_variable, "Explain the use of a variable") +{ + VARIABLE_ALIST *var; + char *description; + + /* Get the variable's name. */ + var = read_variable_name ("Describe variable: ", window); + + if (!var) + return; + + description = (char *)xmalloc (20 + strlen (var->name) + strlen (var->doc)); + + if (var->choices) + sprintf (description, "%s (%s): %s.", + var->name, var->choices[*(var->value)], var->doc); + else + sprintf (description, "%s (%d): %s.", var->name, *(var->value), var->doc); + + window_message_in_echo_area ("%s", description); + free (description); +} + +DECLARE_INFO_COMMAND (set_variable, "Set the value of an Info variable") +{ + VARIABLE_ALIST *var; + char *line; + + /* Get the variable's name and value. */ + var = read_variable_name ("Set variable: ", window); + + if (!var) + return; + + /* Read a new value for this variable. */ + { + char prompt[100]; + + if (!var->choices) + { + int potential_value; + + if (info_explicit_arg || count != 1) + potential_value = count; + else + potential_value = *(var->value); + + sprintf (prompt, "Set %s to value (%d): ", + var->name, potential_value); + line = info_read_in_echo_area (active_window, prompt); + + /* If no error was printed, clear the echo area. */ + if (!info_error_was_printed) + window_clear_echo_area (); + + /* User aborted? */ + if (!line) + return; + + /* If the user specified a value, get that, otherwise, we are done. */ + canonicalize_whitespace (line); + if (*line) + *(var->value) = atoi (line); + else + *(var->value) = potential_value; + + free (line); + } + else + { + register int i; + REFERENCE **array = (REFERENCE **)NULL; + int array_index = 0; + int array_slots = 0; + + for (i = 0; var->choices[i]; i++) + { + REFERENCE *entry; + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->label = strdup (var->choices[i]); + entry->nodename = (char *)NULL; + entry->filename = (char *)NULL; + + add_pointer_to_array + (entry, array_index, array, array_slots, 10, REFERENCE *); + } + + sprintf (prompt, "Set %s to value (%s): ", + var->name, var->choices[*(var->value)]); + + /* Ask the completer to read a variable value for us. */ + line = info_read_completing_in_echo_area (window, prompt, array); + + info_free_references (array); + + if (!echo_area_is_active) + window_clear_echo_area (); + + /* User aborted? */ + if (!line) + { + info_abort_key (active_window, 0, 0); + return; + } + + /* User accepted default choice? If so, no change. */ + if (!*line) + { + free (line); + return; + } + + /* Find the choice in our list of choices. */ + for (i = 0; var->choices[i]; i++) + if (strcmp (var->choices[i], line) == 0) + break; + + if (var->choices[i]) + *(var->value) = i; + } + } +} + +/* Read the name of an Info variable in the echo area and return the + address of a VARIABLE_ALIST member. A return value of NULL indicates + that no variable could be read. */ +VARIABLE_ALIST * +read_variable_name (prompt, window) + char *prompt; + WINDOW *window; +{ + register int i; + char *line; + REFERENCE **variables; + + /* Get the completion array of variable names. */ + variables = make_variable_completions_array (); + + /* Ask the completer to read a variable for us. */ + line = + info_read_completing_in_echo_area (window, prompt, variables); + + info_free_references (variables); + + if (!echo_area_is_active) + window_clear_echo_area (); + + /* User aborted? */ + if (!line) + { + info_abort_key (active_window, 0, 0); + return ((VARIABLE_ALIST *)NULL); + } + + /* User accepted "default"? (There is none.) */ + if (!*line) + { + free (line); + return ((VARIABLE_ALIST *)NULL); + } + + /* Find the variable in our list of variables. */ + for (i = 0; info_variables[i].name; i++) + if (strcmp (info_variables[i].name, line) == 0) + break; + + if (!info_variables[i].name) + return ((VARIABLE_ALIST *)NULL); + else + return (&(info_variables[i])); +} + +/* Make an array of REFERENCE which actually contains the names of the + variables available in Info. */ +REFERENCE ** +make_variable_completions_array () +{ + register int i; + REFERENCE **array = (REFERENCE **)NULL; + int array_index = 0, array_slots = 0; + + for (i = 0; info_variables[i].name; i++) + { + REFERENCE *entry; + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->label = strdup (info_variables[i].name); + entry->nodename = (char *)NULL; + entry->filename = (char *)NULL; + + add_pointer_to_array + (entry, array_index, array, array_slots, 200, REFERENCE *); + } + + return (array); +} diff --git a/texinfo/info/variables.h b/texinfo/info/variables.h new file mode 100644 index 000000000000..85bde27737b9 --- /dev/null +++ b/texinfo/info/variables.h @@ -0,0 +1,64 @@ +/* variables.h -- Description of user visible variables in Info. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_VARIABLES_H_) +#define _VARIABLES_H_ + +/* A variable (in the Info sense) is an integer value with a user-visible + name. You may supply an array of strings to complete over when the + variable is set; in that case, the variable is set to the index of the + string that the user chose. If you supply a null list, the user can + set the variable to a numeric value. */ + +/* Structure describing a user visible variable. */ +typedef struct { + char *name; /* Polite name. */ + char *doc; /* Documentation string. */ + int *value; /* Address of value. */ + char **choices; /* Array of strings or NULL if numeric only. */ +} VARIABLE_ALIST; + +/* Read the name of an Info variable in the echo area and return the + address of a VARIABLE_ALIST member. A return value of NULL indicates + that no variable could be read. */ +extern VARIABLE_ALIST *read_variable_name (); + +/* Make an array of REFERENCE which actually contains the names of the + variables available in Info. */ +extern REFERENCE **make_variable_completions_array (); + +/* Set the value of an info variable. */ +extern void set_variable (); + +/* The list of user-visible variables. */ +extern int auto_footnotes_p; +extern int auto_tiling_p; +extern int terminal_use_visible_bell_p; +extern int info_error_rings_bell_p; +extern int gc_compressed_files; +extern int show_index_match; +extern int info_scroll_behaviour; +extern int window_scroll_step; +extern int ISO_Latin_p; + +#endif /* _VARIABLES_H_ */ diff --git a/texinfo/info/window.c b/texinfo/info/window.c new file mode 100644 index 000000000000..304e89c0c75a --- /dev/null +++ b/texinfo/info/window.c @@ -0,0 +1,1482 @@ +/* window.c -- Windows in Info. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#include +#include +#include +#include +#include "nodes.h" +#include "window.h" +#include "display.h" +#include "info-utils.h" +#include "infomap.h" + +/* The window which describes the screen. */ +WINDOW *the_screen = (WINDOW *)NULL; + +/* The window which describes the echo area. */ +WINDOW *the_echo_area = (WINDOW *)NULL; + +/* The list of windows in Info. */ +WINDOW *windows = (WINDOW *)NULL; + +/* Pointer to the active window in WINDOW_LIST. */ +WINDOW *active_window = (WINDOW *)NULL; + +/* The size of the echo area in Info. It never changes, irregardless of the + size of the screen. */ +#define ECHO_AREA_HEIGHT 1 + +/* Macro returns the amount of space that the echo area truly requires relative + to the entire screen. */ +#define echo_area_required (1 + the_echo_area->height) + +/* Initalize the window system by creating THE_SCREEN and THE_ECHO_AREA. + Create the first window ever. + You pass the dimensions of the total screen size. */ +void +window_initialize_windows (width, height) + int width, height; +{ + the_screen = (WINDOW *)xmalloc (sizeof (WINDOW)); + the_echo_area = (WINDOW *)xmalloc (sizeof (WINDOW)); + windows = (WINDOW *)xmalloc (sizeof (WINDOW)); + active_window = windows; + + zero_mem (the_screen, sizeof (WINDOW)); + zero_mem (the_echo_area, sizeof (WINDOW)); + zero_mem (active_window, sizeof (WINDOW)); + + /* None of these windows has a goal column yet. */ + the_echo_area->goal_column = -1; + active_window->goal_column = -1; + the_screen->goal_column = -1; + + /* The active and echo_area windows are visible. + The echo_area is permanent. + The screen is permanent. */ + active_window->flags = W_WindowVisible; + the_echo_area->flags = W_WindowIsPerm | W_InhibitMode | W_WindowVisible; + the_screen->flags = W_WindowIsPerm; + + /* The height of the echo area never changes. It is statically set right + here, and it must be at least 1 line for display. The size of the + initial window cannot be the same size as the screen, since the screen + includes the echo area. So, we make the height of the initial window + equal to the screen's displayable region minus the height of the echo + area. */ + the_echo_area->height = ECHO_AREA_HEIGHT; + active_window->height = the_screen->height - 1 - the_echo_area->height; + window_new_screen_size (width, height, (VFunction *)NULL); + + /* The echo area uses a different keymap than normal info windows. */ + the_echo_area->keymap = echo_area_keymap; + active_window->keymap = info_keymap; +} + +/* Given that the size of the screen has changed to WIDTH and HEIGHT + from whatever it was before (found in the_screen->height, ->width), + change the size (and possibly location) of each window in the screen. + If a window would become too small, call the function DELETER on it, + after deleting the window from our chain of windows. If DELETER is NULL, + nothing extra is done. The last window can never be deleted, but it can + become invisible. */ + +/* If non-null, a function to call with WINDOW as argument when the function + window_new_screen_size () has deleted WINDOW. */ +VFunction *window_deletion_notifier = (VFunction *)NULL; + +void +window_new_screen_size (width, height) + int width, height; +{ + register WINDOW *win; + int delta_height, delta_each, delta_leftover; + int numwins; + + /* If no change, do nothing. */ + if (width == the_screen->width && height == the_screen->height) + return; + + /* If the new window height is too small, make it be zero. */ + if (height < (WINDOW_MIN_SIZE + the_echo_area->height)) + height = 0; + if (width < 0) + width = 0; + + /* Find out how many windows will change. */ + for (numwins = 0, win = windows; win; win = win->next, numwins++); + + /* See if some windows will need to be deleted. This is the case if + the screen is getting smaller, and the available space divided by + the number of windows is less than WINDOW_MIN_SIZE. In that case, + delete some windows and try again until there is either enough + space to divy up among the windows, or until there is only one + window left. */ + while ((height - echo_area_required) / numwins <= WINDOW_MIN_SIZE) + { + /* If only one window, make the size of it be zero, and return + immediately. */ + if (!windows->next) + { + windows->height = 0; + maybe_free (windows->line_starts); + windows->line_starts = (char **)NULL; + windows->line_count = 0; + break; + } + + /* If we have some temporary windows, delete one of them. */ + for (win = windows; win; win = win->next) + if (win->flags & W_TempWindow) + break; + + /* Otherwise, delete the first window, and try again. */ + if (!win) + win = windows; + + if (window_deletion_notifier) + (*window_deletion_notifier) (win); + + window_delete_window (win); + numwins--; + } + + /* The screen has changed height and width. */ + delta_height = height - the_screen->height; /* This is how much. */ + the_screen->height = height; /* This is the new height. */ + the_screen->width = width; /* This is the new width. */ + + /* Set the start of the echo area. */ + the_echo_area->first_row = height - the_echo_area->height; + the_echo_area->width = width; + + /* Check to see if the screen can really be changed this way. */ + if ((!windows->next) && ((windows->height == 0) && (delta_height < 0))) + return; + + /* Divide the change in height among the available windows. */ + delta_each = delta_height / numwins; + delta_leftover = delta_height - (delta_each * numwins); + + /* Change the height of each window in the chain by delta_each. Change + the height of the last window in the chain by delta_each and by the + leftover amount of change. Change the width of each window to be + WIDTH. */ + for (win = windows; win; win = win->next) + { + if ((win->width != width) && ((win->flags & W_InhibitMode) == 0)) + { + win->width = width; + maybe_free (win->modeline); + win->modeline = (char *)xmalloc (1 + width); + } + + win->height += delta_each; + + /* If the previous height of this window was zero, it was the only + window, and it was not visible. Thus we need to compensate for + the echo_area. */ + if (win->height == delta_each) + win->height -= (1 + the_echo_area->height); + + /* If this is not the first window in the chain, then change the + first row of it. We cannot just add delta_each to the first row, + since this window's first row is the sum of the collective increases + that have gone before it. So we just add one to the location of the + previous window's modeline. */ + if (win->prev) + win->first_row = (win->prev->first_row + win->prev->height) + 1; + + /* The last window in the chain gets the extra space (or shrinkage). */ + if (!win->next) + win->height += delta_leftover; + + if (win->node) + recalculate_line_starts (win); + + win->flags |= W_UpdateWindow; + } + + /* If the screen got smaller, check over the windows just shrunk to + keep them within bounds. Some of the windows may have gotten smaller + than WINDOW_MIN_HEIGHT in which case some of the other windows are + larger than the available display space in the screen. Because of our + intial test above, we know that there is enough space for all of the + windows. */ + if ((delta_each < 0) && ((windows->height != 0) && windows->next)) + { + int avail; + + avail = the_screen->height - (numwins + the_echo_area->height); + win = windows; + + while (win) + { + if ((win->height < WINDOW_MIN_HEIGHT) || + (win->height > avail)) + { + WINDOW *lastwin; + + /* Split the space among the available windows. */ + delta_each = avail / numwins; + delta_leftover = avail - (delta_each * numwins); + + for (win = windows; win; win = win->next) + { + lastwin = win; + if (win->prev) + win->first_row = + (win->prev->first_row + win->prev->height) + 1; + win->height = delta_each; + } + + /* Give the leftover space (if any) to the last window. */ + lastwin->height += delta_leftover; + break; + } + else + win= win->next; + } + } +} + +/* Make a new window showing NODE, and return that window structure. + If NODE is passed as NULL, then show the node showing in the active + window. If the window could not be made return a NULL pointer. The + active window is not changed.*/ +WINDOW * +window_make_window (node) + NODE *node; +{ + WINDOW *window; + + if (!node) + node = active_window->node; + + /* If there isn't enough room to make another window, return now. */ + if ((active_window->height / 2) < WINDOW_MIN_SIZE) + return ((WINDOW *)NULL); + + /* Make and initialize the new window. + The fudging about with -1 and +1 is because the following window in the + chain cannot start at window->height, since that is where the modeline + for the previous window is displayed. The inverse adjustment is made + in window_delete_window (). */ + window = (WINDOW *)xmalloc (sizeof (WINDOW)); + window->width = the_screen->width; + window->height = (active_window->height / 2) - 1; +#if defined (SPLIT_BEFORE_ACTIVE) + window->first_row = active_window->first_row; +#else + window->first_row = active_window->first_row + + (active_window->height - window->height); +#endif + window->keymap = info_keymap; + window->goal_column = -1; + window->modeline = (char *)xmalloc (1 + window->width); + window->line_starts = (char **)NULL; + window->flags = W_UpdateWindow | W_WindowVisible; + window_set_node_of_window (window, node); + + /* Adjust the height of the old active window. */ + active_window->height -= (window->height + 1); +#if defined (SPLIT_BEFORE_ACTIVE) + active_window->first_row += (window->height + 1); +#endif + active_window->flags |= W_UpdateWindow; + + /* Readjust the new and old windows so that their modelines and contents + will be displayed correctly. */ +#if defined (NOTDEF) + /* We don't have to do this for WINDOW since window_set_node_of_window () + already did. */ + window_adjust_pagetop (window); + window_make_modeline (window); +#endif /* NOTDEF */ + + /* We do have to readjust the existing active window. */ + window_adjust_pagetop (active_window); + window_make_modeline (active_window); + +#if defined (SPLIT_BEFORE_ACTIVE) + /* This window is just before the active one. The active window gets + bumped down one. The active window is not changed. */ + window->next = active_window; + + window->prev = active_window->prev; + active_window->prev = window; + + if (window->prev) + window->prev->next = window; + else + windows = window; +#else + /* This window is just after the active one. Which window is active is + not changed. */ + window->prev = active_window; + window->next = active_window->next; + active_window->next = window; + if (window->next) + window->next->prev = window; +#endif /* !SPLIT_BEFORE_ACTIVE */ + return (window); +} + +/* These useful macros make it possible to read the code in + window_change_window_height (). */ +#define grow_me_shrinking_next(me, next, diff) \ + do { \ + me->height += diff; \ + next->height -= diff; \ + next->first_row += diff; \ + window_adjust_pagetop (next); \ + } while (0) + +#define grow_me_shrinking_prev(me, prev, diff) \ + do { \ + me->height += diff; \ + prev->height -= diff; \ + me->first_row -=diff; \ + window_adjust_pagetop (prev); \ + } while (0) + +#define shrink_me_growing_next(me, next, diff) \ + do { \ + me->height -= diff; \ + next->height += diff; \ + next->first_row -= diff; \ + window_adjust_pagetop (next); \ + } while (0) + +#define shrink_me_growing_prev(me, prev, diff) \ + do { \ + me->height -= diff; \ + prev->height += diff; \ + me->first_row += diff; \ + window_adjust_pagetop (prev); \ + } while (0) + +/* Change the height of WINDOW by AMOUNT. This also automagically adjusts + the previous and next windows in the chain. If there is only one user + window, then no change takes place. */ +void +window_change_window_height (window, amount) + WINDOW *window; + int amount; +{ + register WINDOW *win, *prev, *next; + + /* If there is only one window, or if the amount of change is zero, + return immediately. */ + if (!windows->next || amount == 0) + return; + + /* Find this window in our chain. */ + for (win = windows; win; win = win->next) + if (win == window) + break; + + /* If the window is isolated (i.e., doesn't appear in our window list, + then quit now. */ + if (!win) + return; + + /* Change the height of this window by AMOUNT, if that is possible. + It can be impossible if there isn't enough available room on the + screen, or if the resultant window would be too small. */ + + prev = window->prev; + next = window->next; + + /* WINDOW decreasing in size? */ + if (amount < 0) + { + int abs_amount = -amount; /* It is easier to deal with this way. */ + + /* If the resultant window would be too small, stop here. */ + if ((window->height - abs_amount) < WINDOW_MIN_HEIGHT) + return; + + /* If we have two neighboring windows, choose the smaller one to get + larger. */ + if (next && prev) + { + if (prev->height < next->height) + shrink_me_growing_prev (window, prev, abs_amount); + else + shrink_me_growing_next (window, next, abs_amount); + } + else if (next) + shrink_me_growing_next (window, next, abs_amount); + else + shrink_me_growing_prev (window, prev, abs_amount); + } + + /* WINDOW increasing in size? */ + if (amount > 0) + { + int total_avail, next_avail = 0, prev_avail = 0; + + if (next) + next_avail = next->height - WINDOW_MIN_SIZE; + + if (prev) + prev_avail = prev->height - WINDOW_MIN_SIZE; + + total_avail = next_avail + prev_avail; + + /* If there isn't enough space available to grow this window, give up. */ + if (amount > total_avail) + return; + + /* If there aren't two neighboring windows, or if one of the neighbors + is larger than the other one by at least AMOUNT, grow that one. */ + if ((next && !prev) || ((next_avail - amount) >= prev_avail)) + grow_me_shrinking_next (window, next, amount); + else if ((prev && !next) || ((prev_avail - amount) >= next_avail)) + grow_me_shrinking_prev (window, prev, amount); + else + { + int change; + + /* This window has two neighbors. They both must be shrunk in to + make enough space for WINDOW to grow. Make them both the same + size. */ + if (prev_avail > next_avail) + { + change = prev_avail - next_avail; + grow_me_shrinking_prev (window, prev, change); + amount -= change; + } + else + { + change = next_avail - prev_avail; + grow_me_shrinking_next (window, next, change); + amount -= change; + } + + /* Both neighbors are the same size. Split the difference in + AMOUNT between them. */ + while (amount) + { + window->height++; + amount--; + + /* Odd numbers grow next, even grow prev. */ + if (amount & 1) + { + prev->height--; + window->first_row--; + } + else + { + next->height--; + next->first_row++; + } + } + window_adjust_pagetop (prev); + window_adjust_pagetop (next); + } + } + if (prev) + prev->flags |= W_UpdateWindow; + + if (next) + next->flags |= W_UpdateWindow; + + window->flags |= W_UpdateWindow; + window_adjust_pagetop (window); +} + +/* Tile all of the windows currently displayed in the global variable + WINDOWS. If argument STYLE is TILE_INTERNALS, tile windows displaying + internal nodes as well, otherwise do not change the height of such + windows. */ +void +window_tile_windows (style) + int style; +{ + WINDOW *win, *last_adjusted; + int numwins, avail, per_win_height, leftover; + int do_internals; + + numwins = avail = 0; + do_internals = (style == TILE_INTERNALS); + + for (win = windows; win; win = win->next) + if (do_internals || !win->node || + (win->node->flags & N_IsInternal) == 0) + { + avail += win->height; + numwins++; + } + + if (numwins <= 1 || !the_screen->height) + return; + + /* Find the size for each window. Divide the size of the usable portion + of the screen by the number of windows. */ + per_win_height = avail / numwins; + leftover = avail - (per_win_height * numwins); + + last_adjusted = (WINDOW *)NULL; + for (win = windows; win; win = win->next) + { + if (do_internals || !win->node || + (win->node->flags & N_IsInternal) == 0) + { + last_adjusted = win; + win->height = per_win_height; + } + } + + if (last_adjusted) + last_adjusted->height += leftover; + + /* Readjust the first_row of every window in the chain. */ + for (win = windows; win; win = win->next) + { + if (win->prev) + win->first_row = win->prev->first_row + win->prev->height + 1; + + window_adjust_pagetop (win); + win->flags |= W_UpdateWindow; + } +} + +/* Toggle the state of line wrapping in WINDOW. This can do a bit of fancy + redisplay. */ +void +window_toggle_wrap (window) + WINDOW *window; +{ + if (window->flags & W_NoWrap) + window->flags &= ~W_NoWrap; + else + window->flags |= W_NoWrap; + + if (window != the_echo_area) + { + char **old_starts; + int old_lines, old_pagetop; + + old_starts = window->line_starts; + old_lines = window->line_count; + old_pagetop = window->pagetop; + + calculate_line_starts (window); + + /* Make sure that point appears within this window. */ + window_adjust_pagetop (window); + + /* If the pagetop hasn't changed maybe we can do some scrolling now + to speed up the display. Many of the line starts will be the same, + so scrolling here is a very good optimization.*/ + if (old_pagetop == window->pagetop) + display_scroll_line_starts + (window, old_pagetop, old_starts, old_lines); + maybe_free (old_starts); + } + window->flags |= W_UpdateWindow; +} + +/* Set WINDOW to display NODE. */ +void +window_set_node_of_window (window, node) + WINDOW *window; + NODE *node; +{ + window->node = node; + window->pagetop = 0; + window->point = 0; + recalculate_line_starts (window); + window->flags |= W_UpdateWindow; + window_adjust_pagetop (window); + window_make_modeline (window); +} + +/* Delete WINDOW from the list of known windows. If this window was the + active window, make the next window in the chain be the active window. + If the active window is the next or previous window, choose that window + as the recipient of the extra space. Otherwise, prefer the next window. */ +void +window_delete_window (window) + WINDOW *window; +{ + WINDOW *next, *prev, *window_to_fix; + + next = window->next; + prev = window->prev; + + /* You cannot delete the only window or a permanent window. */ + if ((!next && !prev) || (window->flags & W_WindowIsPerm)) + return; + + if (next) + next->prev = prev; + + if (!prev) + windows = next; + else + prev->next = next; + + if (window->line_starts) + free (window->line_starts); + + if (window->modeline) + free (window->modeline); + + if (window == active_window) + { + /* If there isn't a next window, then there must be a previous one, + since we cannot delete the last window. If there is a next window, + prefer to use that as the active window. */ + if (next) + active_window = next; + else + active_window = prev; + } + + if (next && active_window == next) + window_to_fix = next; + else if (prev && active_window == prev) + window_to_fix = prev; + else if (next) + window_to_fix = next; + else if (prev) + window_to_fix = prev; + else + window_to_fix = windows; + + if (window_to_fix->first_row > window->first_row) + { + int diff; + + /* Try to adjust the visible part of the node so that as little + text as possible has to move. */ + diff = window_to_fix->first_row - window->first_row; + window_to_fix->first_row = window->first_row; + + window_to_fix->pagetop -= diff; + if (window_to_fix->pagetop < 0) + window_to_fix->pagetop = 0; + } + + /* The `+ 1' is to offset the difference between the first_row locations. + See the code in window_make_window (). */ + window_to_fix->height += window->height + 1; + window_to_fix->flags |= W_UpdateWindow; + + free (window); +} + +/* For every window in CHAIN, set the flags member to have FLAG set. */ +void +window_mark_chain (chain, flag) + WINDOW *chain; + int flag; +{ + register WINDOW *win; + + for (win = chain; win; win = win->next) + win->flags |= flag; +} + +/* For every window in CHAIN, clear the flags member of FLAG. */ +void +window_unmark_chain (chain, flag) + WINDOW *chain; + int flag; +{ + register WINDOW *win; + + for (win = chain; win; win = win->next) + win->flags &= ~flag; +} + +/* Return the number of characters it takes to display CHARACTER on the + screen at HPOS. */ +int +character_width (character, hpos) + int character, hpos; +{ + int printable_limit = 127; + int width = 1; + + if (ISO_Latin_p) + printable_limit = 160; + + if (character > printable_limit) + width = 3; + else if (iscntrl (character)) + { + switch (character) + { + case '\r': + case '\n': + width = the_screen->width - hpos; + break; + case '\t': + width = ((hpos + 8) & 0xf8) - hpos; + break; + default: + width = 2; + } + } + else if (character == DEL) + width = 2; + + return (width); +} + +/* Return the number of characters it takes to display STRING on the screen + at HPOS. */ +int +string_width (string, hpos) + char *string; + int hpos; +{ + register int i, width, this_char_width; + + for (width = 0, i = 0; string[i]; i++) + { + this_char_width = character_width (string[i], hpos); + width += this_char_width; + hpos += this_char_width; + } + return (width); +} + +/* Quickly guess the approximate number of lines to that NODE would + take to display. This really only counts carriage returns. */ +int +window_physical_lines (node) + NODE *node; +{ + register int i, lines; + char *contents; + + if (!node) + return (0); + + contents = node->contents; + for (i = 0, lines = 1; i < node->nodelen; i++) + if (contents[i] == '\n') + lines++; + + return (lines); +} + +/* Calculate a list of line starts for the node belonging to WINDOW. The line + starts are pointers to the actual text within WINDOW->NODE. */ +void +calculate_line_starts (window) + WINDOW *window; +{ + register int i, hpos; + char **line_starts = (char **)NULL; + int line_starts_index = 0, line_starts_slots = 0; + int bump_index; + NODE *node; + + window->line_starts = (char **)NULL; + window->line_count = 0; + node = window->node; + + if (!node) + return; + + /* Grovel the node starting at the top, and for each line calculate the + width of the characters appearing in that line. Add each line start + to our array. */ + i = 0; + hpos = 0; + bump_index = 0; + + while (i < node->nodelen) + { + char *line = node->contents + i; + unsigned int cwidth, c; + + add_pointer_to_array (line, line_starts_index, line_starts, + line_starts_slots, 100, char *); + if (bump_index) + { + i++; + bump_index = 0; + } + + while (1) + { + c = node->contents[i]; + cwidth = character_width (c, hpos); + + /* If this character fits within this line, just do the next one. */ + if ((hpos + cwidth) < window->width) + { + i++; + hpos += cwidth; + continue; + } + else + { + /* If this character would position the cursor at the start of + the next printed screen line, then do the next line. */ + if (c == '\n' || c == '\r' || c == '\t') + { + i++; + hpos = 0; + break; + } + else + { + /* This character passes the window width border. Postion + the cursor after the printed character, but remember this + line start as where this character is. A bit tricky. */ + + /* If this window doesn't wrap lines, proceed to the next + physical line here. */ + if (window->flags & W_NoWrap) + { + hpos = 0; + while (i < node->nodelen && node->contents[i] != '\n') + i++; + + if (node->contents[i] == '\n') + i++; + } + else + { + hpos = the_screen->width - hpos; + bump_index++; + } + break; + } + } + } + } + window->line_starts = line_starts; + window->line_count = line_starts_index; +} + +/* Given WINDOW, recalculate the line starts for the node it displays. */ +void +recalculate_line_starts (window) + WINDOW *window; +{ + maybe_free (window->line_starts); + calculate_line_starts (window); +} + +/* Global variable control redisplay of scrolled windows. If non-zero, it + is the desired number of lines to scroll the window in order to make + point visible. A user might set this to 1 for smooth scrolling. If + set to zero, the line containing point is centered within the window. */ +int window_scroll_step = 0; + +/* Adjust the pagetop of WINDOW such that the cursor point will be visible. */ +void +window_adjust_pagetop (window) + WINDOW *window; +{ + register int line = 0; + char *contents; + + if (!window->node) + return; + + contents = window->node->contents; + + /* Find the first printed line start which is after WINDOW->point. */ + for (line = 0; line < window->line_count; line++) + { + char *line_start; + + line_start = window->line_starts[line]; + + if ((line_start - contents) > window->point) + break; + } + + /* The line index preceding the line start which is past point is the + one containing point. */ + line--; + + /* If this line appears in the current displayable page, do nothing. + Otherwise, adjust the top of the page to make this line visible. */ + if ((line < window->pagetop) || + (line - window->pagetop > (window->height - 1))) + { + /* The user-settable variable "scroll-step" is used to attempt + to make point visible, iff it is non-zero. If that variable + is zero, then the line containing point is centered within + the window. */ + if (window_scroll_step < window->height) + { + if ((line < window->pagetop) && + ((window->pagetop - window_scroll_step) <= line)) + window->pagetop -= window_scroll_step; + else if ((line - window->pagetop > (window->height - 1)) && + ((line - (window->pagetop + window_scroll_step) + < window->height))) + window->pagetop += window_scroll_step; + else + window->pagetop = line - ((window->height - 1) / 2); + } + else + window->pagetop = line - ((window->height - 1) / 2); + + if (window->pagetop < 0) + window->pagetop = 0; + window->flags |= W_UpdateWindow; + } +} + +/* Return the index of the line containing point. */ +int +window_line_of_point (window) + WINDOW *window; +{ + register int i, start = 0; + + /* Try to optimize. Check to see if point is past the pagetop for + this window, and if so, start searching forward from there. */ + if ((window->pagetop > -1 && window->pagetop < window->line_count) && + (window->line_starts[window->pagetop] - window->node->contents) + <= window->point) + start = window->pagetop; + + for (i = start; i < window->line_count; i++) + { + if ((window->line_starts[i] - window->node->contents) > window->point) + break; + } + + return (i - 1); +} + +/* Get and return the goal column for this window. */ +int +window_get_goal_column (window) + WINDOW *window; +{ + if (!window->node) + return (-1); + + if (window->goal_column != -1) + return (window->goal_column); + + /* Okay, do the work. Find the printed offset of the cursor + in this window. */ + return (window_get_cursor_column (window)); +} + +/* Get and return the printed column offset of the cursor in this window. */ +int +window_get_cursor_column (window) + WINDOW *window; +{ + int i, hpos, end; + char *line; + + i = window_line_of_point (window); + + if (i < 0) + return (-1); + + line = window->line_starts[i]; + end = window->point - (line - window->node->contents); + + for (hpos = 0, i = 0; i < end; i++) + hpos += character_width (line[i], hpos); + + return (hpos); +} + +/* Count the number of characters in LINE that precede the printed column + offset of GOAL. */ +int +window_chars_to_goal (line, goal) + char *line; + int goal; +{ + register int i, check, hpos; + + for (hpos = 0, i = 0; line[i] != '\n'; i++) + { + + check = hpos + character_width (line[i], hpos); + + if (check > goal) + break; + + hpos = check; + } + return (i); +} + +/* Create a modeline for WINDOW, and store it in window->modeline. */ +void +window_make_modeline (window) + WINDOW *window; +{ + register int i; + char *modeline; + char location_indicator[4]; + int lines_remaining; + + /* Only make modelines for those windows which have one. */ + if (window->flags & W_InhibitMode) + return; + + /* Find the number of lines actually displayed in this window. */ + lines_remaining = window->line_count - window->pagetop; + + if (window->pagetop == 0) + { + if (lines_remaining <= window->height) + strcpy (location_indicator, "All"); + else + strcpy (location_indicator, "Top"); + } + else + { + if (lines_remaining <= window->height) + strcpy (location_indicator, "Bot"); + else + { + float pt, lc; + int percentage; + + pt = (float)window->pagetop; + lc = (float)window->line_count; + + percentage = 100 * (pt / lc); + + sprintf (location_indicator, "%2d%%", percentage); + } + } + + /* Calculate the maximum size of the information to stick in MODELINE. */ + { + int modeline_len = 0; + char *parent = (char *)NULL, *filename = "*no file*"; + char *nodename = "*no node*"; + char *update_message = (char *)NULL; + NODE *node = window->node; + + if (node) + { + if (node->nodename) + nodename = node->nodename; + + if (node->parent) + { + parent = filename_non_directory (node->parent); + modeline_len += strlen ("Subfile: ") + strlen (node->filename); + } + + if (node->filename) + filename = filename_non_directory (node->filename); + + if (node->flags & N_UpdateTags) + update_message = "--*** Tags out of Date ***"; + } + + if (update_message) + modeline_len += strlen (update_message); + modeline_len += strlen (filename); + modeline_len += strlen (nodename); + modeline_len += 4; /* strlen (location_indicator). */ + + /* 10 for the decimal representation of the number of lines in this + node, and the remainder of the text that can appear in the line. */ + modeline_len += 10 + strlen ("-----Info: (), lines ----, "); + modeline_len += window->width; + + modeline = (char *)xmalloc (1 + modeline_len); + + /* Special internal windows have no filename. */ + if (!parent && !*filename) + sprintf (modeline, "-%s---Info: %s, %d lines --%s--", + (window->flags & W_NoWrap) ? "$" : "-", + nodename, window->line_count, location_indicator); + else + sprintf (modeline, "-%s%s-Info: (%s)%s, %d lines --%s--", + (window->flags & W_NoWrap) ? "$" : "-", + (node && (node->flags & N_IsCompressed)) ? "zz" : "--", + parent ? parent : filename, + nodename, window->line_count, location_indicator); + + if (parent) + sprintf (modeline + strlen (modeline), " Subfile: %s", filename); + + if (update_message) + sprintf (modeline + strlen (modeline), "%s", update_message); + + i = strlen (modeline); + + if (i >= window->width) + modeline[window->width] = '\0'; + else + { + while (i < window->width) + modeline[i++] = '-'; + modeline[i] = '\0'; + } + + strcpy (window->modeline, modeline); + free (modeline); + } +} + +/* Make WINDOW start displaying at PERCENT percentage of its node. */ +void +window_goto_percentage (window, percent) + WINDOW *window; + int percent; +{ + int desired_line; + + if (!percent) + desired_line = 0; + else + desired_line = + (int) ((float)window->line_count * ((float)percent / 100.0)); + + window->pagetop = desired_line; + window->point = + window->line_starts[window->pagetop] - window->node->contents; + window->flags |= W_UpdateWindow; + window_make_modeline (window); +} + +/* Get the state of WINDOW, and save it in STATE. */ +void +window_get_state (window, state) + WINDOW *window; + WINDOW_STATE *state; +{ + state->node = window->node; + state->pagetop = window->pagetop; + state->point = window->point; +} + +/* Set the node, pagetop, and point of WINDOW. */ +void +window_set_state (window, state) + WINDOW *window; + WINDOW_STATE *state; +{ + if (window->node != state->node) + window_set_node_of_window (window, state->node); + window->pagetop = state->pagetop; + window->point = state->point; +} + + +/* **************************************************************** */ +/* */ +/* Manipulating Home-Made Nodes */ +/* */ +/* **************************************************************** */ + +/* A place to buffer echo area messages. */ +static NODE *echo_area_node = (NODE *)NULL; + +/* Make the node of the_echo_area be an empty one. */ +static void +free_echo_area () +{ + if (echo_area_node) + { + maybe_free (echo_area_node->contents); + free (echo_area_node); + } + + echo_area_node = (NODE *)NULL; + window_set_node_of_window (the_echo_area, echo_area_node); +} + +/* Clear the echo area, removing any message that is already present. + The echo area is cleared immediately. */ +void +window_clear_echo_area () +{ + free_echo_area (); + display_update_one_window (the_echo_area); +} + +/* Make a message appear in the echo area, built from FORMAT, ARG1 and ARG2. + The arguments are treated similar to printf () arguments, but not all of + printf () hair is present. The message appears immediately. If there was + already a message appearing in the echo area, it is removed. */ +void +window_message_in_echo_area (format, arg1, arg2) + char *format; + void *arg1, *arg2; +{ + free_echo_area (); + echo_area_node = build_message_node (format, arg1, arg2); + window_set_node_of_window (the_echo_area, echo_area_node); + display_update_one_window (the_echo_area); +} + +/* Place a temporary message in the echo area built from FORMAT, ARG1 + and ARG2. The message appears immediately, but does not destroy + any existing message. A future call to unmessage_in_echo_area () + restores the old contents. */ +static NODE **old_echo_area_nodes = (NODE **)NULL; +static int old_echo_area_nodes_index = 0; +static int old_echo_area_nodes_slots = 0; + +void +message_in_echo_area (format, arg1, arg2) + char *format; + void *arg1, *arg2; +{ + if (echo_area_node) + { + add_pointer_to_array (echo_area_node, old_echo_area_nodes_index, + old_echo_area_nodes, old_echo_area_nodes_slots, + 4, NODE *); + } + echo_area_node = (NODE *)NULL; + window_message_in_echo_area (format, arg1, arg2); +} + +void +unmessage_in_echo_area () +{ + free_echo_area (); + + if (old_echo_area_nodes_index) + echo_area_node = old_echo_area_nodes[--old_echo_area_nodes_index]; + + window_set_node_of_window (the_echo_area, echo_area_node); + display_update_one_window (the_echo_area); +} + +/* A place to build a message. */ +static char *message_buffer = (char *)NULL; +static int message_buffer_index = 0; +static int message_buffer_size = 0; + +/* Ensure that there is enough space to stuff LENGTH characters into + MESSAGE_BUFFER. */ +static void +message_buffer_resize (length) + int length; +{ + if (!message_buffer) + { + message_buffer_size = length + 1; + message_buffer = (char *)xmalloc (message_buffer_size); + message_buffer_index = 0; + } + + while (message_buffer_size <= message_buffer_index + length) + message_buffer = (char *) + xrealloc (message_buffer, + message_buffer_size += 100 + (2 * length)); +} + +/* Format MESSAGE_BUFFER with the results of printing FORMAT with ARG1 and + ARG2. */ +static void +build_message_buffer (format, arg1, arg2) + char *format; + void *arg1, *arg2; +{ + register int i, len; + void *args[2]; + int arg_index = 0; + + args[0] = arg1; + args[1] = arg2; + + len = strlen (format); + + message_buffer_resize (len); + + for (i = 0; format[i]; i++) + { + if (format[i] != '%') + { + message_buffer[message_buffer_index++] = format[i]; + len--; + } + else + { + char c; + + c = format[++i]; + + switch (c) + { + case '%': /* Insert a percent sign. */ + message_buffer_resize (len + 1); + message_buffer[message_buffer_index++] = '%'; + break; + + case 's': /* Insert the current arg as a string. */ + { + char *string; + int string_len; + + string = (char *)args[arg_index++]; + string_len = strlen (string); + + message_buffer_resize (len + string_len); + sprintf + (message_buffer + message_buffer_index, "%s", string); + message_buffer_index += string_len; + } + break; + + case 'd': /* Insert the current arg as an integer. */ + { + long long_val; + int integer; + + long_val = (long)args[arg_index++]; + integer = (int)long_val; + + message_buffer_resize (len + 32); + sprintf + (message_buffer + message_buffer_index, "%d", integer); + message_buffer_index = strlen (message_buffer); + } + break; + + case 'c': /* Insert the current arg as a character. */ + { + long long_val; + int character; + + long_val = (long)args[arg_index++]; + character = (int)long_val; + + message_buffer_resize (len + 1); + message_buffer[message_buffer_index++] = character; + } + break; + + default: + abort (); + } + } + } + message_buffer[message_buffer_index] = '\0'; +} + +/* Build a new node which has FORMAT printed with ARG1 and ARG2 as the + contents. */ +NODE * +build_message_node (format, arg1, arg2) + char *format; + void *arg1, *arg2; +{ + NODE *node; + + message_buffer_index = 0; + build_message_buffer (format, arg1, arg2); + + node = message_buffer_to_node (); + return (node); +} + +/* Convert the contents of the message buffer to a node. */ +NODE * +message_buffer_to_node () +{ + NODE *node; + + node = (NODE *)xmalloc (sizeof (NODE)); + node->filename = (char *)NULL; + node->parent = (char *)NULL; + node->nodename = (char *)NULL; + node->flags = 0; + + /* Make sure that this buffer ends with a newline. */ + node->nodelen = 1 + strlen (message_buffer); + node->contents = (char *)xmalloc (1 + node->nodelen); + strcpy (node->contents, message_buffer); + node->contents[node->nodelen - 1] = '\n'; + node->contents[node->nodelen] = '\0'; + return (node); +} + +/* Useful functions can be called from outside of window.c. */ +void +initialize_message_buffer () +{ + message_buffer_index = 0; +} + +/* Print FORMAT with ARG1,2 to the end of the current message buffer. */ +void +printf_to_message_buffer (format, arg1, arg2) + char *format; + void *arg1, *arg2; +{ + build_message_buffer (format, arg1, arg2); +} + +/* Return the current horizontal position of the "cursor" on the most + recently output message buffer line. */ +int +message_buffer_length_this_line () +{ + register int i; + + if (!message_buffer_index) + return (0); + + for (i = message_buffer_index; i && message_buffer[i - 1] != '\n'; i--); + + return (string_width (message_buffer + i, 0)); +} + +/* Pad STRING to COUNT characters by inserting blanks. */ +int +pad_to (count, string) + int count; + char *string; +{ + register int i; + + i = strlen (string); + + if (i >= count) + string[i++] = ' '; + else + { + while (i < count) + string[i++] = ' '; + } + string[i] = '\0'; + + return (i); +} diff --git a/texinfo/info/window.h b/texinfo/info/window.h new file mode 100644 index 000000000000..5bde64a10acc --- /dev/null +++ b/texinfo/info/window.h @@ -0,0 +1,229 @@ +/* window.h -- Structure and flags used in manipulating Info windows. */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + Copyright (C) 1993 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (_WINDOW_H_) +#define _WINDOW_H_ + +#include "nodes.h" +#include "infomap.h" + +/* Smallest number of visible lines in a window. The actual height is + always one more than this number because each window has a modeline. */ +#define WINDOW_MIN_HEIGHT 2 + +/* Smallest number of screen lines that can be used to fully present a + window. This number includes the modeline of the window. */ +#define WINDOW_MIN_SIZE (WINDOW_MIN_HEIGHT + 1) + +/* The exact same elements are used within the WINDOW_STATE structure and a + subsection of the WINDOW structure. We could define a structure which + contains this elements, and include that structure in each of WINDOW_STATE + and WINDOW. But that would lead references in the code such as + window->state->node which we would like to avoid. Instead, we #define the + elements here, and simply include the define in both data structures. Thus, + if you need to change window state information, here is where you would + do it. NB> The last element does NOT end with a semi-colon. */ +#define WINDOW_STATE_DECL \ + NODE *node; /* The node displayed in this window. */ \ + int pagetop; /* LINE_STARTS[PAGETOP] is first line in WINDOW. */ \ + long point /* Offset within NODE of the cursor position. */ + +/* Structure which defines a window. Windows are doubly linked, next + and prev. The list of windows is kept on WINDOWS. The structure member + window->height is the total height of the window. The position location + (0, window->height + window->first_row) is the first character of this + windows modeline. The number of lines that can be displayed in a window + is equal to window->height - 1. */ +typedef struct __window__ { + struct __window__ *next; /* Next window in this chain. */ + struct __window__ *prev; /* Previous window in this chain. */ + int width; /* Width of this window. */ + int height; /* Height of this window. */ + int first_row; /* Offset of the first line in the_screen. */ + int goal_column; /* The column we would like the cursor to appear in. */ + Keymap keymap; /* Keymap used to read commands in this window. */ + WINDOW_STATE_DECL; /* Node, pagetop and point. */ + char *modeline; /* Calculated text of the modeline for this window. */ + char **line_starts; /* Array of printed line starts for this node. */ + int line_count; /* Number of lines appearing in LINE_STARTS. */ + int flags; /* See below for details. */ +} WINDOW; + +typedef struct { + WINDOW_STATE_DECL; /* What gets saved. */ +} WINDOW_STATE; + +#define W_UpdateWindow 0x01 /* WINDOW needs updating. */ +#define W_WindowIsPerm 0x02 /* This WINDOW is a permanent object. */ +#define W_WindowVisible 0x04 /* This WINDOW is currently visible. */ +#define W_InhibitMode 0x08 /* This WINDOW has no modeline. */ +#define W_NoWrap 0x10 /* Lines do not wrap in this window. */ +#define W_InputWindow 0x20 /* Window accepts input. */ +#define W_TempWindow 0x40 /* Window is less important. */ + +extern WINDOW *windows; /* List of visible Info windows. */ +extern WINDOW *active_window; /* The currently active window. */ +extern WINDOW *the_screen; /* The Info screen is just another window. */ +extern WINDOW *the_echo_area; /* THE_ECHO_AREA is a window in THE_SCREEN. */ + +/* Global variable control redisplay of scrolled windows. If non-zero, it + is the desired number of lines to scroll the window in order to make + point visible. A user might set this to 1 for smooth scrolling. If + set to zero, the line containing point is centered within the window. */ +extern int window_scroll_step; + + /* Make the modeline member for WINDOW. */ +extern void window_make_modeline (); + +/* Initalize the window system by creating THE_SCREEN and THE_ECHO_AREA. + Create the first window ever, and make it permanent. + You pass WIDTH and HEIGHT; the dimensions of the total screen size. */ +extern void window_initialize_windows (); + +/* Make a new window showing NODE, and return that window structure. + The new window is made to be the active window. If NODE is passed + as NULL, then show the node showing in the active window. If the + window could not be made return a NULL pointer. The active window + is not changed.*/ +extern WINDOW *window_make_window (); + +/* Delete WINDOW from the list of known windows. If this window was the + active window, make the next window in the chain be the active window, + or the previous window in the chain if there is no next window. */ +extern void window_delete_window (); + +/* A function to call when the screen changes size, and some windows have + to get deleted. The function is called with the window to be deleted + as an argument, and it can't do anything about the window getting deleted; + it can only clean up dangling references to that window. */ +extern VFunction *window_deletion_notifier; + +/* Set WINDOW to display NODE. */ +extern void window_set_node_of_window (); + +/* Tell the window system that the size of the screen has changed. This + causes lots of interesting things to happen. The permanent windows + are resized, as well as every visible window. You pass WIDTH and HEIGHT; + the dimensions of the total screen size. */ +extern void window_new_screen_size (); + +/* Change the height of WINDOW by AMOUNT. This also automagically adjusts + the previous and next windows in the chain. If there is only one user + window, then no change takes place. */ +extern void window_change_window_height (); + +/* Adjust the pagetop of WINDOW such that the cursor point will be visible. */ +extern void window_adjust_pagetop (); + +/* Tile all of the windows currently displayed in the global variable + WINDOWS. If argument DO_INTERNALS is non-zero, tile windows displaying + internal nodes as well. */ +#define DONT_TILE_INTERNALS 0 +#define TILE_INTERNALS 1 +extern void window_tile_windows (); + +/* Toggle the state of line wrapping in WINDOW. This can do a bit of fancy + redisplay. */ +extern void window_toggle_wrap (); + +/* For every window in CHAIN, set the flags member to have FLAG set. */ +extern void window_mark_chain (); + +/* For every window in CHAIN, clear the flags member of FLAG. */ +extern void window_unmark_chain (); + +/* Make WINDOW start displaying at PERCENT percentage of its node. */ +extern void window_goto_percentage (); + +/* Build a new node which has FORMAT printed with ARG1 and ARG2 as the + contents. */ +extern NODE *build_message_node (); + +/* Useful functions can be called from outside of window.c. */ +extern void initialize_message_buffer (); + +/* Print FORMAT with ARG1,2 to the end of the current message buffer. */ +extern void printf_to_message_buffer (); + +/* Convert the contents of the message buffer to a node. */ +extern NODE *message_buffer_to_node (); + +/* Return the length of the most recently printed line in message buffer. */ +extern int message_buffer_length_this_line (); + +/* Pad STRING to COUNT characters by inserting blanks. */ +extern int pad_to (); + +/* Make a message appear in the echo area, built from FORMAT, ARG1 and ARG2. + The arguments are treated similar to printf () arguments, but not all of + printf () hair is present. The message appears immediately. If there was + already a message appearing in the echo area, it is removed. */ +extern void window_message_in_echo_area (); + +/* Place a temporary message in the echo area built from FORMAT, ARG1 + and ARG2. The message appears immediately, but does not destroy + any existing message. A future call to unmessage_in_echo_area () + restores the old contents. */ +extern void message_in_echo_area (); +extern void unmessage_in_echo_area (); + +/* Clear the echo area, removing any message that is already present. + The echo area is cleared immediately. */ +extern void window_clear_echo_area (); + +/* Quickly guess the approximate number of lines to that NODE would + take to display. This really only counts carriage returns. */ +extern int window_physical_lines (); + +/* Calculate a list of line starts for the node belonging to WINDOW. The line + starts are pointers to the actual text within WINDOW->NODE. */ +extern void calculate_line_starts (); + +/* Given WINDOW, recalculate the line starts for the node it displays. */ +extern void recalculate_line_starts (); + +/* Return the number of characters it takes to display CHARACTER on the + screen at HPOS. */ +extern int character_width (); + +/* Return the number of characters it takes to display STRING on the + screen at HPOS. */ +extern int string_width (); + +/* Return the index of the line containing point. */ +extern int window_line_of_point (); + +/* Get and return the goal column for this window. */ +extern int window_get_goal_column (); + +/* Get and return the printed column offset of the cursor in this window. */ +extern int window_get_cursor_column (); + +/* Get and Set the node, pagetop, and point of WINDOW. */ +extern void window_get_state (), window_set_state (); + +/* Count the number of characters in LINE that precede the printed column + offset of GOAL. */ +extern int window_chars_to_goal (); + +#endif /* !_WINDOW_H_ */ diff --git a/texinfo/info/xmalloc.c b/texinfo/info/xmalloc.c new file mode 100644 index 000000000000..156989ed7118 --- /dev/null +++ b/texinfo/info/xmalloc.c @@ -0,0 +1,80 @@ +/* xmalloc.c -- safe versions of malloc and realloc */ + +/* This file is part of GNU Info, a program for reading online documentation + stored in Info format. + + This file has appeared in prior works by the Free Software Foundation; + thus it carries copyright dates from 1988 through 1993. + + Copyright (C) 1988, 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 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +#if !defined (ALREADY_HAVE_XMALLOC) +#include +#include + +extern void *malloc (), *realloc (); +static void memory_error_and_abort (); + +/* **************************************************************** */ +/* */ +/* Memory Allocation and Deallocation. */ +/* */ +/* **************************************************************** */ + +/* Return a pointer to free()able block of memory large enough + to hold BYTES number of bytes. If the memory cannot be allocated, + print an error message and abort. */ +void * +xmalloc (bytes) + int bytes; +{ + void *temp = malloc (bytes); + + if (!temp) + memory_error_and_abort ("xmalloc"); + return (temp); +} + +void * +xrealloc (pointer, bytes) + void *pointer; + int bytes; +{ + void *temp; + + if (!pointer) + temp = malloc (bytes); + else + temp = realloc (pointer, bytes); + + if (!temp) + memory_error_and_abort ("xrealloc"); + + return (temp); +} + +static void +memory_error_and_abort (fname) + char *fname; +{ + fprintf (stderr, "%s: Out of virtual memory!\n", fname); + abort (); +} +#endif /* !ALREADY_HAVE_XMALLOC */ diff --git a/texinfo/install-sh b/texinfo/install-sh new file mode 100755 index 000000000000..2c212ccf4ae8 --- /dev/null +++ b/texinfo/install-sh @@ -0,0 +1,250 @@ +#! /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. +# + + +# 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=: + 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/texinfo/lgpl.texinfo b/texinfo/lgpl.texinfo new file mode 100644 index 000000000000..5a57ff9620af --- /dev/null +++ b/texinfo/lgpl.texinfo @@ -0,0 +1,548 @@ +@c This LGPL is meant to be included from other files. +@c To format a standalone LGPL, use liblic.texi. + +@ifset lgpl-appendix +@appendix GNU LIBRARY GENERAL PUBLIC LICENSE +@end ifset + +@ifclear lgpl-appendix +@unnumbered GNU LIBRARY GENERAL PUBLIC LICENSE +@end ifclear +@center Version 2, June 1991 + +@display +Copyright @copyright{} 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. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] +@end display + +@unnumberedsec Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software---to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, 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 library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, 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 companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +``work based on the library'' and a ``work that uses the library''. The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + +@iftex +@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end iftex +@ifinfo +@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end ifinfo + +@enumerate 0 +@item +This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called ``this License''). Each licensee is +addressed as ``you''. + + A ``library'' means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The ``Library'', below, refers to any such software library or work +which has been distributed under these terms. A ``work based on the +Library'' means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term ``modification''.) + + ``Source code'' for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + +@item +You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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. + +@item +You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + +@enumerate a +@item +The modified work must itself be a software library. + +@item +You must cause the files modified to carry prominent notices +stating that you changed the files and the date of any change. + +@item +You must cause the whole of the work to be licensed at no +charge to all third parties under the terms of this License. + +@item +If a facility in the modified Library refers to a function or a +table of data to be supplied by an application program that uses +the facility, other than as an argument passed when the facility +is invoked, then you must make a good faith effort to ensure that, +in the event an application does not supply such function or +table, the facility still operates, and performs whatever part of +its purpose remains meaningful. + +(For example, a function in a library to compute square roots has +a purpose that is entirely well-defined independent of the +application. Therefore, Subsection 2d requires that any +application-supplied function or table used by this function must +be optional: if the application does not supply it, the square +root function must still compute square roots.) +@end enumerate + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +@item +You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + +@item +You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + +@item +A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a ``work that uses the Library''. Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a ``work that uses the Library'' with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a ``work that uses the +library''. The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a ``work that uses the Library'' uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + +@item +As an exception to the Sections above, you may also compile or +link a ``work that uses the Library'' with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + +@enumerate a +@item +Accompany the work with the complete corresponding +machine-readable source code for the Library including whatever +changes were used in the work (which must be distributed under +Sections 1 and 2 above); and, if the work is an executable linked +with the Library, with the complete machine-readable ``work that +uses the Library'', as object code and/or source code, so that the +user can modify the Library and then relink to produce a modified +executable containing the modified Library. (It is understood +that the user who changes the contents of definitions files in the +Library will not necessarily be able to recompile the application +to use the modified definitions.) + +@item +Accompany the work with a written offer, valid for at +least three years, to give the same user the materials +specified in Subsection 6a, above, for a charge no more +than the cost of performing this distribution. + +@item +If distribution of the work is made by offering access to copy +from a designated place, offer equivalent access to copy the above +specified materials from the same place. + +@item +Verify that the user has already received a copy of these +materials or that you have already sent this user a copy. +@end enumerate + + For an executable, the required form of the ``work that uses the +Library'' must include any data and utility programs needed for +reproducing the executable from it. 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + +@item +You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + +@enumerate a +@item +Accompany the combined library with a copy of the same work +based on the Library, uncombined with any other library +facilities. This must be distributed under the terms of the +Sections above. + +@item +Give prominent notice with the combined library of the fact +that part of it is a work based on the Library, and explaining +where to find the accompanying uncombined form of the same work. +@end enumerate + +@item +You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + +@item +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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + +@item +Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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. + +@item +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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + +@item +If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + +@item +The Free Software Foundation may publish revised and/or new +versions of the Library 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + +@item +If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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. + +@iftex +@heading NO WARRANTY +@end iftex +@ifinfo +@center NO WARRANTY +@end ifinfo + +@item +BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY ``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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +@item +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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. +@end enumerate + +@iftex +@heading END OF TERMS AND CONDITIONS +@end iftex +@ifinfo +@center END OF TERMS AND CONDITIONS +@end ifinfo + +@page +@unnumberedsec How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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. + +@smallexample +@var{one line to give the library's name and an idea of what it does.} +Copyright (C) @var{year} @var{name of author} + +This library 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 of the License, 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, +MA 02139, USA. +@end smallexample + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a ``copyright disclaimer'' for the library, if +necessary. Here is a sample; alter the names: + +@example +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +@var{signature of Ty Coon}, 1 April 1990 +Ty Coon, President of Vice +@end example + +That's all there is to it! diff --git a/texinfo/liblic.texi b/texinfo/liblic.texi new file mode 100644 index 000000000000..b7ede0e35e57 --- /dev/null +++ b/texinfo/liblic.texi @@ -0,0 +1,23 @@ +\input texinfo +@setfilename lgpl.info + +@ifinfo +@format +START-INFO-DIR-ENTRY +* COPYING LIBS: (lgpl). The GNU Library General Public License +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@settitle LGPL +@iftex +@headings doubleafter +@setchapternewpage off +@end iftex +@finalout + +@clear lgpl-appendix +@node Top, , (dir), (dir) +@include lgpl.texinfo + +@bye diff --git a/texinfo/libtxi/Makefile.in b/texinfo/libtxi/Makefile.in new file mode 100644 index 000000000000..a067cb9be5e3 --- /dev/null +++ b/texinfo/libtxi/Makefile.in @@ -0,0 +1,84 @@ +# Makefile for GNU texinfo/libtxi. -*- Indented-Text -*- +# $Id: Makefile.in,v 1.3 1996/10/03 18:32:28 karl Exp $ + +# Copyright (C) 1993, 96 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. + +SHELL = /bin/sh +srcdir = @srcdir@ +VPATH = @srcdir@ + +CC = @CC@ +AR = ar +RANLIB = @RANLIB@ + +DEFS = @DEFS@ +LIBS = @LIBS@ +LOADLIBES = $(LIBS) + +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +# This is normally inherited from parent make, but if someone wants to +# build libtxi.a alone, this variable will still be properly defined. +ALLOCA = @ALLOCA@ + +# Standard functions that may be missing. +LIBOBJS = @LIBOBJS@ + +SRCS = getopt.c getopt1.c bzero.c getopt.h +OBJS = getopt.o getopt1.o bzero.o $(ALLOCA) $(LIBOBJS) + +PROGS = libtxi.a + +all: $(PROGS) +sub-all: all + +.c.o: + $(CC) -c $(CPPFLAGS) -I. -I$(srcdir) $(DEFS) $(CFLAGS) $< + +libtxi.a: $(OBJS) + rm -f $@ + $(AR) cq $@ $(OBJS) + $(RANLIB) $@ + +getopt.o: getopt.c getopt.h +getopt1.o: getopt1.c getopt.h +alloca.o: alloca.c + +install: +uninstall: +dvi: +install-info: + +TAGS: $(SRCS) + etags $(SRCS) + +clean: + rm -f *.o a.out core core.* $(PROGS) + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status TAGS ID + +realclean: distclean + +Makefile: Makefile.in ../config.status + cd .. && sh config.status + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: diff --git a/texinfo/libtxi/alloca.c b/texinfo/libtxi/alloca.c new file mode 100644 index 000000000000..8f98b73dbb90 --- /dev/null +++ b/texinfo/libtxi/alloca.c @@ -0,0 +1,504 @@ +/* alloca.c -- allocate automatically reclaimed memory + (Mostly) portable public-domain implementation -- D A Gwyn + + This implementation of the PWB library alloca function, + which is used to allocate space off the run-time stack so + that it is automatically reclaimed upon procedure exit, + was inspired by discussions with J. Q. Johnson of Cornell. + J.Otto Tennant contributed the Cray support. + + There are some preprocessor constants that can + be defined when compiling for your specific system, for + improved efficiency; however, the defaults should be okay. + + The general concept of this implementation is to keep + track of all alloca-allocated blocks, and reclaim any + that are found to be deeper in the stack than the current + invocation. This heuristic does not reclaim storage as + soon as it becomes invalid, but it will do so eventually. + + As a special case, alloca(0) reclaims storage without + allocating any. It is a good idea to use alloca(0) in + your main control loop, etc. to force garbage collection. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef emacs +#include "blockinput.h" +#endif + +/* If compiling with GCC 2, this file's not needed. */ +#if !defined (__GNUC__) || __GNUC__ < 2 + +/* If someone has defined alloca as a macro, + there must be some other way alloca is supposed to work. */ +#ifndef alloca + +#ifdef emacs +#ifdef static +/* actually, only want this if static is defined as "" + -- this is for usg, in which emacs must undefine static + in order to make unexec workable + */ +#ifndef STACK_DIRECTION +you +lose +-- must know STACK_DIRECTION at compile-time +#endif /* STACK_DIRECTION undefined */ +#endif /* static */ +#endif /* emacs */ + +/* If your stack is a linked list of frames, you have to + provide an "address metric" ADDRESS_FUNCTION macro. */ + +#if defined (CRAY) && defined (CRAY_STACKSEG_END) +long i00afunc (); +#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) +#else +#define ADDRESS_FUNCTION(arg) &(arg) +#endif + +#if __STDC__ +typedef void *pointer; +#else +typedef char *pointer; +#endif + +#ifndef NULL +#define NULL 0 +#endif + +/* Different portions of Emacs need to call different versions of + malloc. The Emacs executable needs alloca to call xmalloc, because + ordinary malloc isn't protected from input signals. On the other + hand, the utilities in lib-src need alloca to call malloc; some of + them are very simple, and don't have an xmalloc routine. + + Non-Emacs programs expect this to call use xmalloc. + + Callers below should use malloc. */ + +#ifndef emacs +#define malloc xmalloc +#endif +extern pointer malloc (); + +/* Define STACK_DIRECTION 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 */ + +#ifndef STACK_DIRECTION +#define STACK_DIRECTION 0 /* Direction unknown. */ +#endif + +#if STACK_DIRECTION != 0 + +#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ + +#else /* STACK_DIRECTION == 0; need run-time code. */ + +static int stack_dir; /* 1 or -1 once known. */ +#define STACK_DIR stack_dir + +static void +find_stack_direction () +{ + static char *addr = NULL; /* Address of first `dummy', once known. */ + auto char dummy; /* To get stack address. */ + + if (addr == NULL) + { /* Initial entry. */ + addr = ADDRESS_FUNCTION (dummy); + + find_stack_direction (); /* Recurse once. */ + } + else + { + /* Second entry. */ + if (ADDRESS_FUNCTION (dummy) > addr) + stack_dir = 1; /* Stack grew upward. */ + else + stack_dir = -1; /* Stack grew downward. */ + } +} + +#endif /* STACK_DIRECTION == 0 */ + +/* An "alloca header" is used to: + (a) chain together all alloca'ed blocks; + (b) keep track of stack depth. + + It is very important that sizeof(header) agree with malloc + alignment chunk size. The following default should work okay. */ + +#ifndef ALIGN_SIZE +#define ALIGN_SIZE sizeof(double) +#endif + +typedef union hdr +{ + char align[ALIGN_SIZE]; /* To force sizeof(header). */ + struct + { + union hdr *next; /* For chaining headers. */ + char *deep; /* For stack depth measure. */ + } h; +} header; + +static header *last_alloca_header = NULL; /* -> last alloca header. */ + +/* Return a pointer to at least SIZE bytes of storage, + which will be automatically reclaimed upon exit from + the procedure that called alloca. Originally, this space + was supposed to be taken from the current stack frame of the + caller, but that method cannot be made to work for some + implementations of C, for example under Gould's UTX/32. */ + +pointer +alloca (size) + unsigned size; +{ + auto char probe; /* Probes stack depth: */ + register char *depth = ADDRESS_FUNCTION (probe); + +#if STACK_DIRECTION == 0 + if (STACK_DIR == 0) /* Unknown growth direction. */ + find_stack_direction (); +#endif + + /* Reclaim garbage, defined as all alloca'd storage that + was allocated from deeper in the stack than currently. */ + + { + register header *hp; /* Traverses linked list. */ + +#ifdef emacs + BLOCK_INPUT; +#endif + + for (hp = last_alloca_header; hp != NULL;) + if ((STACK_DIR > 0 && hp->h.deep > depth) + || (STACK_DIR < 0 && hp->h.deep < depth)) + { + register header *np = hp->h.next; + + free ((pointer) hp); /* Collect garbage. */ + + hp = np; /* -> next header. */ + } + else + break; /* Rest are not deeper. */ + + last_alloca_header = hp; /* -> last valid storage. */ + +#ifdef emacs + UNBLOCK_INPUT; +#endif + } + + if (size == 0) + return NULL; /* No allocation required. */ + + /* Allocate combined header + user data storage. */ + + { + register pointer new = malloc (sizeof (header) + size); + /* Address of header. */ + + if (new == 0) + abort(); + + ((header *) new)->h.next = last_alloca_header; + ((header *) new)->h.deep = depth; + + last_alloca_header = (header *) new; + + /* User storage begins just after header. */ + + return (pointer) ((char *) new + sizeof (header)); + } +} + +#if defined (CRAY) && defined (CRAY_STACKSEG_END) + +#ifdef DEBUG_I00AFUNC +#include +#endif + +#ifndef CRAY_STACK +#define CRAY_STACK +#ifndef CRAY2 +/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ +struct stack_control_header + { + long shgrow:32; /* Number of times stack has grown. */ + long shaseg:32; /* Size of increments to stack. */ + long shhwm:32; /* High water mark of stack. */ + long shsize:32; /* Current size of stack (all segments). */ + }; + +/* The stack segment linkage control information occurs at + the high-address end of a stack segment. (The stack + grows from low addresses to high addresses.) The initial + part of the stack segment linkage control information is + 0200 (octal) words. This provides for register storage + for the routine which overflows the stack. */ + +struct stack_segment_linkage + { + long ss[0200]; /* 0200 overflow words. */ + long sssize:32; /* Number of words in this segment. */ + long ssbase:32; /* Offset to stack base. */ + long:32; + long sspseg:32; /* Offset to linkage control of previous + segment of stack. */ + long:32; + long sstcpt:32; /* Pointer to task common address block. */ + long sscsnm; /* Private control structure number for + microtasking. */ + long ssusr1; /* Reserved for user. */ + long ssusr2; /* Reserved for user. */ + long sstpid; /* Process ID for pid based multi-tasking. */ + long ssgvup; /* Pointer to multitasking thread giveup. */ + long sscray[7]; /* Reserved for Cray Research. */ + long ssa0; + long ssa1; + long ssa2; + long ssa3; + long ssa4; + long ssa5; + long ssa6; + long ssa7; + long sss0; + long sss1; + long sss2; + long sss3; + long sss4; + long sss5; + long sss6; + long sss7; + }; + +#else /* CRAY2 */ +/* The following structure defines the vector of words + returned by the STKSTAT library routine. */ +struct stk_stat + { + long now; /* Current total stack size. */ + long maxc; /* Amount of contiguous space which would + be required to satisfy the maximum + stack demand to date. */ + long high_water; /* Stack high-water mark. */ + long overflows; /* Number of stack overflow ($STKOFEN) calls. */ + long hits; /* Number of internal buffer hits. */ + long extends; /* Number of block extensions. */ + long stko_mallocs; /* Block allocations by $STKOFEN. */ + long underflows; /* Number of stack underflow calls ($STKRETN). */ + long stko_free; /* Number of deallocations by $STKRETN. */ + long stkm_free; /* Number of deallocations by $STKMRET. */ + long segments; /* Current number of stack segments. */ + long maxs; /* Maximum number of stack segments so far. */ + long pad_size; /* Stack pad size. */ + long current_address; /* Current stack segment address. */ + long current_size; /* Current stack segment size. This + number is actually corrupted by STKSTAT to + include the fifteen word trailer area. */ + long initial_address; /* Address of initial segment. */ + long initial_size; /* Size of initial segment. */ + }; + +/* The following structure describes the data structure which trails + any stack segment. I think that the description in 'asdef' is + out of date. I only describe the parts that I am sure about. */ + +struct stk_trailer + { + long this_address; /* Address of this block. */ + long this_size; /* Size of this block (does not include + this trailer). */ + long unknown2; + long unknown3; + long link; /* Address of trailer block of previous + segment. */ + long unknown5; + long unknown6; + long unknown7; + long unknown8; + long unknown9; + long unknown10; + long unknown11; + long unknown12; + long unknown13; + long unknown14; + }; + +#endif /* CRAY2 */ +#endif /* not CRAY_STACK */ + +#ifdef CRAY2 +/* Determine a "stack measure" for an arbitrary ADDRESS. + I doubt that "lint" will like this much. */ + +static long +i00afunc (long *address) +{ + struct stk_stat status; + struct stk_trailer *trailer; + long *block, size; + long result = 0; + + /* We want to iterate through all of the segments. The first + step is to get the stack status structure. We could do this + more quickly and more directly, perhaps, by referencing the + $LM00 common block, but I know that this works. */ + + STKSTAT (&status); + + /* Set up the iteration. */ + + trailer = (struct stk_trailer *) (status.current_address + + status.current_size + - 15); + + /* There must be at least one stack segment. Therefore it is + a fatal error if "trailer" is null. */ + + if (trailer == 0) + abort (); + + /* Discard segments that do not contain our argument address. */ + + while (trailer != 0) + { + block = (long *) trailer->this_address; + size = trailer->this_size; + if (block == 0 || size == 0) + abort (); + trailer = (struct stk_trailer *) trailer->link; + if ((block <= address) && (address < (block + size))) + break; + } + + /* Set the result to the offset in this segment and add the sizes + of all predecessor segments. */ + + result = address - block; + + if (trailer == 0) + { + return result; + } + + do + { + if (trailer->this_size <= 0) + abort (); + result += trailer->this_size; + trailer = (struct stk_trailer *) trailer->link; + } + while (trailer != 0); + + /* We are done. Note that if you present a bogus address (one + not in any segment), you will get a different number back, formed + from subtracting the address of the first block. This is probably + not what you want. */ + + return (result); +} + +#else /* not CRAY2 */ +/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. + Determine the number of the cell within the stack, + given the address of the cell. The purpose of this + routine is to linearize, in some sense, stack addresses + for alloca. */ + +static long +i00afunc (long address) +{ + long stkl = 0; + + long size, pseg, this_segment, stack; + long result = 0; + + struct stack_segment_linkage *ssptr; + + /* Register B67 contains the address of the end of the + current stack segment. If you (as a subprogram) store + your registers on the stack and find that you are past + the contents of B67, you have overflowed the segment. + + B67 also points to the stack segment linkage control + area, which is what we are really interested in. */ + + stkl = CRAY_STACKSEG_END (); + ssptr = (struct stack_segment_linkage *) stkl; + + /* If one subtracts 'size' from the end of the segment, + one has the address of the first word of the segment. + + If this is not the first segment, 'pseg' will be + nonzero. */ + + pseg = ssptr->sspseg; + size = ssptr->sssize; + + this_segment = stkl - size; + + /* It is possible that calling this routine itself caused + a stack overflow. Discard stack segments which do not + contain the target address. */ + + while (!(this_segment <= address && address <= stkl)) + { +#ifdef DEBUG_I00AFUNC + fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); +#endif + if (pseg == 0) + break; + stkl = stkl - pseg; + ssptr = (struct stack_segment_linkage *) stkl; + size = ssptr->sssize; + pseg = ssptr->sspseg; + this_segment = stkl - size; + } + + result = address - this_segment; + + /* If you subtract pseg from the current end of the stack, + you get the address of the previous stack segment's end. + This seems a little convoluted to me, but I'll bet you save + a cycle somewhere. */ + + while (pseg != 0) + { +#ifdef DEBUG_I00AFUNC + fprintf (stderr, "%011o %011o\n", pseg, size); +#endif + stkl = stkl - pseg; + ssptr = (struct stack_segment_linkage *) stkl; + size = ssptr->sssize; + pseg = ssptr->sspseg; + result += size; + } + return (result); +} + +#endif /* not CRAY2 */ +#endif /* CRAY */ + +#endif /* no alloca */ +#endif /* not GCC version 2 */ diff --git a/texinfo/libtxi/bzero.c b/texinfo/libtxi/bzero.c new file mode 100644 index 000000000000..e73738234fd1 --- /dev/null +++ b/texinfo/libtxi/bzero.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 1993 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, you can either send email to this + * program's author (see below) or write to: The Free Software Foundation, + * Inc.; 59 Temple Place - Suite 330. Boston, MA 02111-1307, USA. + */ + +#if !defined (HAVE_MEMSET) && !defined (HAVE_BZERO) + +void +bzero (b, length) + register char *b; + register int length; +{ +#ifdef VMS /* but this is definitely VMS-specific */ + short zero = 0; + long max_str = 65535; + + while (length > max_str) + { + (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); + length -= max_str; + b += max_str; + } + (void) LIB$MOVC5 (&zero, &zero, &zero, &length, b); +#else + while (length-- > 0) + *b++ = 0; +#endif /* not VMS */ +} + +#endif /* not HAVE_MEMSET && not HAVE_BZERO */ diff --git a/texinfo/libtxi/getopt.c b/texinfo/libtxi/getopt.c new file mode 100644 index 000000000000..36ebf5c5b030 --- /dev/null +++ b/texinfo/libtxi/getopt.c @@ -0,0 +1,762 @@ +/* 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +#define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +#include +#endif + +#if !defined (__STDC__) || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* 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. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +#include +#endif /* GNU C library. */ + +/* This is for other GNU distributions with internationalized messages. + The GNU C Library itself does not yet support such messages. */ +#if HAVE_LIBINTL_H +# include +#else +# define gettext(msgid) (msgid) +#endif + +/* 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; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#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 +#define my_index strchr +#else + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +char *getenv (); + +static char * +my_index (str, chr) + 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. */ +#if !defined (__STDC__) || !__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 (argv) + 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 (optstring) + 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; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* 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 (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 (argc, argv, optstring, longopts, longind, long_only) + 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); + optind = 1; /* Don't scan ARGV[0], the program name. */ + } + + 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; + 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 (nameend - nextchar == 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, gettext ("%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, + gettext ("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + gettext ("%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, + gettext ("%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, gettext ("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, gettext ("%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) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, gettext ("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, gettext ("%s: invalid 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, + gettext ("%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 (argc, argv, optstring) + 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/texinfo/libtxi/getopt.h b/texinfo/libtxi/getopt.h new file mode 100644 index 000000000000..952f4830d3dc --- /dev/null +++ b/texinfo/libtxi/getopt.h @@ -0,0 +1,129 @@ +/* Declarations for getopt. + Copyright (C) 1989, 90, 91, 92, 93, 94 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, 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 defined (__STDC__) && __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 defined (__STDC__) && __STDC__ +#ifdef __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 /* __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 /* __STDC__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* _GETOPT_H */ diff --git a/texinfo/libtxi/getopt1.c b/texinfo/libtxi/getopt1.c new file mode 100644 index 000000000000..7cf0bfb01383 --- /dev/null +++ b/texinfo/libtxi/getopt1.c @@ -0,0 +1,180 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987, 88, 89, 90, 91, 92, 1993, 1994 + 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "getopt.h" + +#if !defined (__STDC__) || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include + +/* 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. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#else +char *getenv (); +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + 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 (argc, argv, options, long_options, opt_index) + 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 + +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/texinfo/libtxi/memcpy.c b/texinfo/libtxi/memcpy.c new file mode 100644 index 000000000000..521625464cdd --- /dev/null +++ b/texinfo/libtxi/memcpy.c @@ -0,0 +1,20 @@ +/* Copy LEN bytes starting at SRCADDR to DESTADDR. Result undefined + if the source overlaps with the destination. + Return DESTADDR. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +char * +memcpy (destaddr, srcaddr, len) + char *destaddr; + const char *srcaddr; + int len; +{ + char *dest = destaddr; + + while (len-- > 0) + *destaddr++ = *srcaddr++; + return dest; +} diff --git a/texinfo/libtxi/memmove.c b/texinfo/libtxi/memmove.c new file mode 100644 index 000000000000..d7bdd7cd9950 --- /dev/null +++ b/texinfo/libtxi/memmove.c @@ -0,0 +1,24 @@ +/* memmove.c -- copy memory. + Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate. + In the public domain. + By David MacKenzie . */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +void +memmove (dest, source, length) + char *dest; + const char *source; + unsigned length; +{ + if (source < dest) + /* Moving from low mem to hi mem; start at end. */ + for (source += length, dest += length; length; --length) + *--dest = *--source; + else if (source != dest) + /* Moving from hi mem to low mem; start at beginning. */ + for (; length; --length) + *dest++ = *source++; +} diff --git a/texinfo/libtxi/strdup.c b/texinfo/libtxi/strdup.c new file mode 100644 index 000000000000..1d60f13948a6 --- /dev/null +++ b/texinfo/libtxi/strdup.c @@ -0,0 +1,43 @@ +/* strdup.c -- return a newly allocated copy of a string + Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef STDC_HEADERS +#include +#include +#else +char *malloc (); +char *strcpy (); +#endif + +/* Return a newly allocated copy of STR, + or 0 if out of memory. */ + +char * +strdup (str) + const char *str; +{ + char *newstr; + + newstr = (char *) malloc (strlen (str) + 1); + if (newstr) + strcpy (newstr, str); + return newstr; +} diff --git a/texinfo/license.texi b/texinfo/license.texi new file mode 100644 index 000000000000..c23a4dc8095d --- /dev/null +++ b/texinfo/license.texi @@ -0,0 +1,24 @@ +\input texinfo +@setfilename license.info + +@ifinfo +@format +START-INFO-DIR-ENTRY +* COPYING: (license). The GNU General Public License +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@settitle GPL +@iftex +@headings doubleafter +@setchapternewpage off +@end iftex +@finalout + +@node Top, , (dir), (dir) +@unnumbered GNU GENERAL PUBLIC LICENSE + +@include gpl.texinfo + +@bye diff --git a/texinfo/makeinfo/Makefile.in b/texinfo/makeinfo/Makefile.in new file mode 100644 index 000000000000..fe81fcdff5ee --- /dev/null +++ b/texinfo/makeinfo/Makefile.in @@ -0,0 +1,116 @@ +# Makefile for GNU makeinfo. +# $Id: Makefile.in,v 1.1 1997/08/21 22:58:07 jason Exp $ +# +# Copyright (C) 1993, 96 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. + +#### Start of system configuration section. #### + +srcdir = @srcdir@ +VPATH = $(srcdir):$(common) + +common = $(srcdir)/../libtxi + +EXEEXT = @EXEEXT@ +CC = @CC@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +LN = ln +RM = rm -f +MKDIR = mkdir + +DEFS = @DEFS@ +LIBS = -L../libtxi -ltxi @LIBS@ +LOADLIBES = $(LIBS) + +SHELL = /bin/sh + +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +# Prefix for each installed program, normally empty or `g'. +binprefix = +infodir = @infodir@ + +#### End of system configuration section. #### + +SRCS = makeinfo.c multi.c +OBJS = makeinfo.o multi.o + +PROGS = makeinfo$(EXEEXT) + +all: $(PROGS) makeinfo.info +sub-all: all + +.c.o: + $(CC) -c $(CPPFLAGS) -I. -I$(srcdir) -I$(common) $(DEFS) $(CFLAGS) $< + +makeinfo$(EXEEXT): $(OBJS) ../libtxi/libtxi.a + $(CC) $(LDFLAGS) -o makeinfo $(OBJS) $(LOADLIBES) + +../libtxi/libtxi.a: + (cd ../libtxi && $(MAKE) $(MFLAGS) libtxi.a) + +makeinfo.o: makeinfo.c $(common)/getopt.h + +$(OBJS): makeinfo.h + +info makeinfo.info: ./makeinfo makeinfo.texi #macro.texi + ./makeinfo --no-split -I$(srcdir) makeinfo.texi + +# makeinfo.texi: ./makeinfo makeinfo.mki +# ./makeinfo -E makeinfo.texi -I$(srcdir) makeinfo.mki + +dvi makeinfo.dvi: ./makeinfo makeinfo.texi #macro.texi + $(srcdir)/../util/texi2dvi makeinfo.txi + +install: all + $(INSTALL_PROGRAM) makeinfo$(EXEEXT) $(bindir)/$(binprefix)makeinfo$(EXEEXT) + -d=$(srcdir); test -f ./makeinfo.info && d=.; $(INSTALL_DATA) $$d/makeinfo.info $(infodir)/makeinfo.info + $(POST_INSTALL) + +install-info: + -d=$(srcdir); test -f ./makeinfo.info && d=.; $(INSTALL_DATA) $$d/makeinfo.info $(infodir)/makeinfo.info + ../util/install-info --info-dir=$(infodir) $(infodir)/makeinfo.info + +uninstall: + for f in $(PROGS); do rm -f $(bindir)/$(binprefix)$$f; done + rm -f $(infodir)/makeinfo.info + +TAGS: $(SRCS) + etags $(SRCS) + +clean: + rm -f *.o a.out core core.* $(PROGS) + +mostlyclean: clean + +distclean: clean + rm -f TAGS Makefile config.status *.info */*.info + +realclean: distclean +maintainer-clean: distclean + +Makefile: Makefile.in ../config.status + cd .. && sh config.status + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: diff --git a/texinfo/makeinfo/macro.texi b/texinfo/makeinfo/macro.texi new file mode 100644 index 000000000000..8a3fe802392e --- /dev/null +++ b/texinfo/makeinfo/macro.texi @@ -0,0 +1,177 @@ +@c This file is included in makeinfo.texi. +@c +@ifinfo +@comment Here are some useful examples of the macro facility. + +@c Simply insert the right version of the texinfo name. +@macro texinfo{} +TeXinfo +@end macro + +@macro dfn{text} +@dfn{\text\} +@cpindex \text\ +@end macro + +@c Define a macro which expands to a pretty version of the name of the +@c Makeinfo program. +@macro makeinfo{} +@code{Makeinfo} +@end macro + +@c Define a macro which is used to define other macros. This one makes +@c a macro which creates a node and gives it a sectioning command. Note +@c that the created macro uses the original definition within the +@c expansion text. This takes advantage of the non-recursion feature of +@c macro execution. +@macro node_define{orig-name} +@macro \orig-name\{title} +@node \title\ +@\orig-name\ \title\ +@end macro +@end macro + +@c Now actually define a new set of sectioning commands. +@node_define {chapter} +@node_define {section} +@node_define {subsection} +@end ifinfo + +@chapter The Macro Facility + +This chapter describes the new macro facility. + +A @dfn{macro} is a command that you define in terms of other commands. +It doesn't exist as a @texinfo{} command until you define it as part of +the input file to @makeinfo{}. Once the command exists, it behaves much +as any other @texinfo{} command. Macros are a useful way to ease the +details and tedium of writing a `correct' info file. The following +sections explain how to write and invoke macros. + +@menu +* How to Use Macros in @texinfo{}:: + How to use the macro facility. + +* Using Macros Recursively:: + How to write a macro which does (or doesn't) recurse. + +* Using @texinfo{} Macros As Arguments:: + Passing a macro as an argument. +@end menu + +@section How to Use Macros in @texinfo{} + +Using macros in @texinfo{} is easy. First you define the macro. After +that, the macro command is available as a normal @texinfo{} command. +Here is what a definition looks like: + +@example +@@macro @var{name}@{@var{arg1}, @var{@dots{}} @var{argn}@} +@var{@texinfo{} commands@dots{}} +@@end macro +@end example + +The arguments that you specify that the macro takes are expanded with +the actual parameters used when calling the macro if they are seen +surrounded by backslashes. For example, here is a definition of +@code{@@codeitem}, a macro which can be used wherever @code{@@item} can +be used, but which surrounds its argument with @code{@@code@{@dots{}@}}. + +@example +@@macro codeitem@{item@} +@@item @@code@{\item\@} +@@end macro +@end example + +When the macro is expanded, all of the text between the @code{@@macro} +and @code{@@end macro} is inserted into the document at the expansion +point, with the actual parameters substituted for the named parameters. +So, a call to the above macro might look like: + +@example +@@codeitem@{Foo@} +@end example + +and @makeinfo{} would execute the following code: + +@example +@@item @@code@{Foo@} +@end example + +A special case is made for macros which only take a single argument, and +which are invoked without any brace characters (i.e., +@samp{@{}@dots{}@samp{@}}) surrounding an argument; the rest of the line +is supplied as is as the sole argument to the macro. This special case +allows one to redefine some standard @texinfo{} commands without +modifying the input file. Along with the non-recursive action of macro +invocation, one can easily redefine the sectioning commands to also +provide index entries: + +@example +@@macro chapter@{name@} +@@chapter \name\ +@@findex \name\ +@@end macro +@end example + +Thus, the text: + +@example +@@chapter strlen +@end example + +will expand to: + +@example +@@chapter strlen +@@findex strlen +@end example + +@section Using Macros Recursively + +Normally, while a particular macro is executing, any call to that macro +will be seen as a call to a builtin @texinfo{} command. This allows one +to redefine a builtin @texinfo{} command as a macro, and then use that +command within the definition of the macro itself. For example, one +might wish to make sure that whereever a term was defined with +@code{@@dfn@{@dots{}@}}, the location of the definition would appear +in the concept index for the manual. Here is a macro which redefines +@code{@@dfn} to do just that: + +@example +@@macro dfn@{text@} +@@dfn@{\text\@} +@@cpindex \text\ +@@end macro +@end example + +Note that we used the builtin @texinfo{} command @code{@@dfn} within our +overriding macro definition. + +This behaviour itself can be overridden for macro execution by writing a +special @dfn{macro control command} in the definition of the macro. The +command is considered special because it doesn't affect the output text +directly, rather, it affects the way in which the macro is defined. One +such special command is @code{@@allow-recursion}. + +@example +@@macro silly@{arg@} +@@allow-recursion +\arg\ +@@end macro +@end example + +Now @code{@@silly} is a macro that can be used within a call to itself: + +@example +This text @@silly@{@@silly@{some text@}@} is ``some text''. +@end example + +@section Using @texinfo{} Macros As Arguments + +@printindex cp +How to use @texinfo{} macros as arguments to other @texinfo{} macros. + +@bye + + diff --git a/texinfo/makeinfo/macros/example.texi b/texinfo/makeinfo/macros/example.texi new file mode 100644 index 000000000000..d3554ff3ddcd --- /dev/null +++ b/texinfo/makeinfo/macros/example.texi @@ -0,0 +1,224 @@ +\input texinfo @c -*-texinfo-*- +@comment %**start of header +@setfilename example.info +@set VERSION 1.58 +@paragraphindent none +@comment %**end of header + +@include simpledoc.texi + +@document {@makeinfo{}, Brian J. Fox, +This file is an extract from the @cite{@texinfo{}} manual.@* +It documents @makeinfo{}\, a program that converts @texinfo{} files into +Info files. +} + +@menu +* What is @makeinfo{}?:: +* Controlling Paragraph Formats:: +* Command Line Options:: +* Pointer Validation:: +@end menu + +@section What is @makeinfo{}? + +@iftex +This file documents the use of the @code{makeinfo} program, versions +@value{VERSION} and later. It is an extract from the @cite{TeXinfo} manual. +@end iftex + +@makeinfo{} is a program for converting @dfn{@texinfo{}} files into +@dfn{@Info{}} files. @texinfo{} is a documentation system that uses a +single source file to produce both on-line information and printed output. + +You can read the on-line information using @Info{}; type @code{info} to +learn about @Info{}. +@ifinfo +@xref{Top, Texinfo, Overview of Texinfo, texinfo, Texinfo}, +@end ifinfo +@iftex +See the @cite{TeXinfo} manual, +@end iftex +to learn about the TeXinfo documentation system. + +@section Controlling Paragraph Formats + +In general, @makeinfo{} @dfn{fills} the paragraphs that it outputs +to an @Info{} file. Filling is the process of breaking and connecting +lines so that lines are the same length as or shorter than the number +specified as the fill column. Lines are broken between words. With +@makeinfo{}, you can control: + +@itemize @bullet +@item +The width of each paragraph (the @dfn{fill-column}). +@item +The amount of indentation that the first line of +each paragraph receives (the @dfn{paragraph-indentation}). +@end itemize + +@section Command Line Options + +The following command line options are available for @makeinfo{}. + +@need 100 +@table @code +@item -D @var{var} +Cause @var{var} to be defined. This is equivalent to +@code{@@set @var{var}} in the Texinfo file. + +@need 150 +@item --error-limit @var{limit} +Set the maximum number of errors that @makeinfo{} will report +before exiting (on the assumption that continuing would be useless). +The default number of errors that can be reported before +@makeinfo{} gives up is 100.@refill + +@need 150 +@item --fill-column @var{width} +Specify the maximum number of columns in a line; this is the right-hand +edge of a line. Paragraphs that are filled will be filled to this +width. The default value for @code{fill-column} is 72. + +@item --footnote-style @var{style} +Set the footnote style to @var{style}, either @samp{end} for the end +node style or @samp{separate} for the separate node style. The value +set by this option overrides the value set in a Texinfo file by an +@code{@@footnotestyle} command. When the footnote style is +@samp{separate}, @makeinfo{} makes a new node containing the +footnotes found in the current node. When the footnote style is +@samp{end}, @makeinfo{} places the footnote references at the end +of the current node. + +@need 150 +@item -I @var{dir} +Add @code{dir} to the directory search list for finding files that are +included using the @code{@@include} command. By default, +@makeinfo{} searches only the current directory. + +@need 150 +@item --no-headers +Do not include menus or node lines in the output. This results in an +@sc{ascii} file that you cannot read in Info since it does not contain +the requisite nodes or menus; but you can print such a file in a +single, typewriter-like font and produce acceptable output. + +@need 150 +@item --no-split +Suppress the splitting stage of @makeinfo{}. Normally, large +output files (where the size is greater than 70k bytes) are split into +smaller subfiles, each one approximately 50k bytes. If you specify +@samp{--no-split}, @makeinfo{} will not split up the output +file. + +@need 100 +@item --no-pointer-validate +@item --no-validate +Suppress the pointer-validation phase of @makeinfo{}. Normally, +after a Texinfo file is processed, some consistency checks are made to +ensure that cross references can be resolved, etc. +@xref{Pointer Validation}. + +@need 150 +@item --no-warn +Suppress the output of warning messages. This does @emph{not} +suppress the output of error messages, only warnings. You might +want this if the file you are creating has examples of Texinfo cross +references within it, and the nodes that are referenced do not actually +exist. + +@item --no-number-footnotes +Supress automatic footnote numbering. By default, @makeinfo{} +numbers each footnote sequentially in a single node, resetting the +current footnote number to 1 at the start of each node. + +@need 150 +@item --output @var{file} +@itemx -o @var{file} +Specify that the output should be directed to @var{file} and not to the +file name specified in the @code{@@setfilename} command found in the Texinfo +source. @var{file} can be the special token @samp{-}, which specifies +standard output. + +@need 150 +@item --paragraph-indent @var{indent} +Set the paragraph indentation style to @var{indent}. The value set by +this option overrides the value set in a Texinfo file by an +@code{@@paragraphindent} command. The value of @var{indent} is +interpreted as follows: + +@itemize @bullet +@item +If the value of @var{indent} is @samp{asis}, do not change the +existing indentation at the starts of paragraphs. + +@item +If the value of @var{indent} is zero, delete any existing +indentation. + +@item +If the value of @var{indent} is greater than zero, indent each +paragraph by that number of spaces. +@end itemize + +@need 100 +@item --reference-limit @var{limit} +Set the value of the number of references to a node that +@makeinfo{} will make without reporting a warning. If a node has more +than this number of references in it, @makeinfo{} will make the +references but also report a warning. + +@need 150 +@item -U @var{var} +Cause @var{var} to be undefined. This is equivalent to +@code{@@clear @var{var}} in the Texinfo file. + +@need 100 +@item --verbose +Cause @makeinfo{} to display messages saying what it is doing. +Normally, @makeinfo{} only outputs messages if there are errors or +warnings. + +@need 100 +@item --version +Report the version number of this copy of @makeinfo{}. +@end table + +@section Pointer Validation +@cindex Pointer validation with @makeinfo{} +@cindex Validation of pointers + +If you do not suppress pointer-validation (by using the +@samp{--no-pointer-validation} option), @makeinfo{} +will check the validity of the final Info file. Mostly, +this means ensuring that nodes you have referenced +really exist. Here is a complete list of what is +checked: + +@enumerate +@item +If a `Next', `Previous', or `Up' node reference is a reference to a +node in the current file and is not an external reference such as to +@file{(dir)}, then the referenced node must exist. + +@item +In every node, if the `Previous' node is different from the `Up' node, +then the `Previous' node must also be pointed to by a `Next' node. + +@item +Every node except the `Top' node must have an `Up' pointer. + +@item +The node referenced by an `Up' pointer must contain a reference to the +current node in some manner other than through a `Next' reference. +This includes menu entries and cross references. + +@item +If the `Next' reference of a node is not the same as the `Next' reference +of the `Up' reference, then the node referenced by the `Next' pointer +must have a `Previous' pointer that points back to the current node. +This rule allows the last node in a section to point to the first node +of the next chapter. +@end enumerate + +@bye diff --git a/texinfo/makeinfo/macros/html.texi b/texinfo/makeinfo/macros/html.texi new file mode 100644 index 000000000000..60760825c685 --- /dev/null +++ b/texinfo/makeinfo/macros/html.texi @@ -0,0 +1,269 @@ +@c html.texi: -*- Texinfo -*- Macros which support HTML output. + +@c Copyright (c) 1995 Brian Fox (bfox@ai.mit.edu) +@c Author: Brian J. Fox (bfox@ai.mit.edu) Sat Apr 1 20:30:54 1995. +@c +@c I didn't want to write this myself, because I wanted some HTML wizard +@c to get everything exactly right. However, rms continues to believe +@c that the macro system is not a good idea. I couldn't disagree more, +@c so I am writing this as an example of how useful such macros can be. + +@macro html +@set html + +@end macro + +@c +@c The first step is to define the macros which really only have meaning +@c when producing output for HTML. + +@c +@c @anchor{Brian Fox, http://www.ua.com/users/bfox/} +@c +@macro anchor{text, link} +@ifset html +\text\ +@end ifset +@ifclear html +\text\ +@end ifclear +@end macro + +@macro pre{} +@ifset html +
+@end ifset
+@end macro
+
+@macro endpre{}
+@ifset html
+
+@end ifset +@end macro + +@macro TeX +@ifset html +TeX +@end ifset +@ifclear html +@TeX{} +@end ifclear +@end macro + +@macro paragraph{} +@ifset html +

+@end ifset +@end macro + +@c +@c @email{bfox@@ai.mit.edu} +@c +@macro email{address} +@anchor{mailto:\address\, \address\} +@end macro + +@c +@c Redefine the TeXinfo commands which have direct HTML counterparts. +@c + +@macro html-define-0arg{command, html-insertion} +@macro \command\ +@ifset html +\html-insertion\ +@end ifset +@ifclear html +@\command\ +@end ifclear +@end macro +@end macro + +@macro html-define-1arg{command, html-insertion} +@macro \command\{arg} +@ifset html +\html-insertion\ +@end ifset +@ifclear html +@\command\{\arg\} +@end ifclear +@end macro +@end macro + +@macro html-define-line{command, html-insertion} +@macro \command\{line} +@ifset html +\html-insertion\ +@end ifset +@ifclear html +@\command\ \line\ +@end ifclear +@end macro +@end macro + +@html-define-0arg{*,
} +@html-define-1arg{b, \\arg\\} +@html-define-1arg{code, \\arg\\} +@html-define-line{itemize,

    } +@html-define-line{item,

  • } +@html-define-line{heading,

    \\line\\

    } +@html-define-0arg{bye, } + +@c +@c Define into nothing the macros which do nothing in html. +@c +@html-define-line{group,} + +@c +@c Define a macro which is used to define other macros. This one makes +@c a macro which creates an HTML header line. No sectioning commands +@c are used. This takes advantage of the non-recursion feature of +@c macro execution. +@macro node_define{orig-name, header-style} +@macro \orig-name\{title} +@ifset html +@node \title\ +<\header-style\>\title\ +@end ifset +@ifclear html +@\orig-name\ \title\ +@end ifclear +@end macro +@end macro + +@c +@c The same as NODE_DEFINE, but italicized. +@macro inode_define{orig-name, header-style} +@macro \orig-name\{title} +@ifset html +@node \title\ +<\header-style\>\title\ +@end ifset +@ifclear html +@\orig-name\ \title\ +@end ifclear +@end macro +@end macro + +@c Ignore @node commands. +@html-define-line{node,} + +@c Here is a special one for "@top". +@macro top{title} +@end macro + +@c Now actually define a new set of sectioning commands. +@node_define {appendix, h1} +@node_define {appendixsec, h2} +@node_define {appendixsubsec, h3} +@node_define {appendixsubsubsec, h4} +@node_define {chapter, h1} +@node_define {section, h2} +@node_define {subsection, h3} +@node_define {subsubsec, h4} +@node_define {unnumbered, h1} +@node_define {unnumberedsec, h2} +@node_define {unnumberedsubsec, h3} +@node_define {unnumberedsubsubsec, h4} + +@c The italicized analogues. +@inode_define {iappendix, h1} +@inode_define {iappendixsec, h2} +@inode_define {iappendixsubsec, h3} +@inode_define {iappendixsubsubsec, h4} +@inode_define {ichapter, h1} +@inode_define {isection, h2} +@inode_define {isubsection, h3} +@inode_define {isubsubsec, h4} +@inode_define {iunnumbered, h1} +@inode_define {iunnumberedsec, h2} +@inode_define {iunnumberedsubsec, h3} +@inode_define {iunnumberedsubsubsec, h4} + +@c Manual starter: +@c +@c Pass arguments of TITLE, AUTHOR, and a short DESCRIPTION. +@c Immediately following, insert the Top node's menu. +@c +@c Typical usage: +@c +@c @document{Makeinfo, Brian J. Fox, This file documents the use of the +@c @code{makeinfo} program\, versions 1.61 and later.} +@c +@c @menu +@c * What is @makeinfo{}?:: +@c @end menu +@macro document{title, author, description} +@ifinfo +\description\ + +Copyright @copyright{} 1995 \author\ +Copyright @copyright{} 1995 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the copyright holders. +@end ifinfo + +@titlepage +@title \title\ +@author \author\ + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1995 \author\ +Copyright @copyright{} 1995 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the copyright holders. +@end titlepage + +@top{\title\} + +\description\ +@end macro + +@html-define-line{end, +@ifeq{"\\line\\"\, "ifinfo"\, @end ifinfo} +@ifeq{"\\line\\"\, "ifset"\, @end ifset} +@ifeq{"\\line\\"\, "ifclear"\, @end ifclear} +@ifeq{"\\line\\"\, "cartouche"\, @end cartouche} +@ifeq{"\\line\\"\, "menu"\, @end menu} +@ifeq{"\\line\\"\, "itemize"\,
} +@ifeq{"\\line\\"\, "enumerate"\, } +@ifeq{"\\line\\"\, "table"\, } +@ifeq{"\\line\\"\, "ftable"\, } +@ifeq{"\\line\\"\, "vtable"\, } +@ifeq{"\\line\\"\, "menu"\, xxx} +@ifeq{"\\line\\"\, "quotation"\, } +@ifeq{"\\line\\"\, "example"\, } +@ifeq{"\\line\\"\, "smallexample"\, } +@ifeq{"\\line\\"\, "lisp"\, } +@ifeq{"\\line\\"\, "format"\, } +@ifeq{"\\line\\"\, "display"\, } +@ifeq{"\\line\\"\, "group"}} diff --git a/texinfo/makeinfo/macros/multifmt.texi b/texinfo/makeinfo/macros/multifmt.texi new file mode 100644 index 000000000000..0f2eb32a5852 --- /dev/null +++ b/texinfo/makeinfo/macros/multifmt.texi @@ -0,0 +1,41 @@ +@c multiformat.texi: -*- Texinfo -*- \input texinfo.tex + +@c Copyright (c) 1995 Universal Access, Inc +@c Author: Brian J. Fox (bfox@ua.com) Sun Apr 2 07:56:23 1995. +@setfilename multiformat.info + +@include html.texi + +@ifset html +@html +@end ifset + +@node First Node, First Section, (dir), (dir) +@chapter First Chapter +Here is some text that belongs in the first chapter. Nothing very +exciting happens here, but this is enough text to span a couple of +lines, and we feel that is important. +@paragraph + +This is the second paragraph of the first chapter. Note that the +formatting commands in @code{HTML} seem to do the right thing, as do the +commands when invoked in @code{Texinfo} mode and in @TeX{}. + +@node First Section, , First Node, First Node +@isection First Section + +Here is some text in the first section of the first chapter. We are +trying very hard to examine the output here to see exactly how proper it +is. If I wasn't so tired, we could probably see it already. +@paragraph + +Here is a list of items: +@paragraph + +@itemize @bullet +@item Here is the first item. +@item Here is the second item. +@end itemize + +@bye + diff --git a/texinfo/makeinfo/macros/res-samp.texi b/texinfo/makeinfo/macros/res-samp.texi new file mode 100644 index 000000000000..5b4e869e0c3d --- /dev/null +++ b/texinfo/makeinfo/macros/res-samp.texi @@ -0,0 +1,32 @@ +\input texinfo.tex +@setfilename resume-example.info + +@include resume.texi + +@name Brian J. Fox +@email bfox@@ai.mit.edu +@street 116 Barranca Ave, Ste. B +@city Santa Barbara +@state CA +@zip 93109 +@phone (805) 564-2192 + +@resume + +@block{EDUCATION} +@entry{ +12/11/59, +12/11/63, +My Mom's House, +Learning at home with my mother., +This was the most learning I ever did.} + +@entry{12/11/63, 12/11/77, Brookline\, MA, Learning in the public school system.} +@entry{12/11/78, 12/11/81, Santa Barbara\, CA, Learning in life +experience\, and three months at Santa Barbara City College.} + +@block{WORK EXPERIENCE} +@entry{12/11/59, 12/11/75, Mom's house, Various and sundry tasks\, +including washing dishes and clothes\, and toilet training.} +@entry{3 months ago, present, Terrapin\, Inc., hacking up Unix systems\, breaking @code{LOGO} worlds\, terrorizing surrounding neighborhood.} +@bye diff --git a/texinfo/makeinfo/macros/resume.texi b/texinfo/makeinfo/macros/resume.texi new file mode 100644 index 000000000000..a4dc5d04be93 --- /dev/null +++ b/texinfo/makeinfo/macros/resume.texi @@ -0,0 +1,64 @@ +@c +@c Reusme writing macros. Produce a very specific format. +@c + +@c A macro which creates a macro. The resultant macro can be called to +@c set a variable which has the same name as the macro. Use +@c @value{name} to get the value set in @name{}. +@macro make-var-macro{macro-name} +@macro \macro-name\{value} +@quote-arg +@set \macro-name\ \value\ +@end macro +@end macro + +@make-var-macro{name} +@make-var-macro{street} +@make-var-macro{city} +@make-var-macro{state} +@make-var-macro{zip} +@make-var-macro{phone} +@make-var-macro{email} + +@c Give all of the above variable/macros a null value to start. +@name +@street +@city +@state +@zip +@phone +@email + +@c A typical heading for a resume block is a non-indented line. +@macro block{title} +@paragraphindent none +@comment @noindent +@heading \title\ +@end macro + +@c A typical entry in a resume has a from-date, a to-date, a location, +@c a job title, and a longer descrition body. + +@macro entry{from-date, to-date, where, what, body} +@paragraphindent 8 +@b{\where\: \what\ (\from-date\ --- \to-date\)} +@paragraphindent 3 + +\body\ +@paragraphindent none +@end macro + +@macro address{} +@value{name}@* +@value{street}@* +@value{city}, @value{state}@* +@value{zip}@* +@value{phone} +@end macro + +@macro resume{} +@center @value{name}@* +@center @value{street}@* +@center @value{city}, @value{state} @value{zip}@* +@center @value{email} +@end macro diff --git a/texinfo/makeinfo/macros/simpledoc.texi b/texinfo/makeinfo/macros/simpledoc.texi new file mode 100644 index 000000000000..576cb9b8e414 --- /dev/null +++ b/texinfo/makeinfo/macros/simpledoc.texi @@ -0,0 +1,135 @@ + +@comment Here are some useful examples of the macro facility. + +@c Simply insert the right version of the texinfo name. +@macro texinfo{} +TeXinfo +@end macro + +@c Define a macro which expands to a pretty version of the name of the +@c Makeinfo program. +@macro makeinfo{} +@code{Makeinfo} +@end macro + +@c Simple insert the right version of the Info name. +@macro Info{} +@code{Info} +@end macro + +@c Define a macro which is used to define other macros. This one makes +@c a macro which creates a node and gives it a sectioning command. Note +@c that the created macro uses the original definition within the +@c expansion text. This takes advantage of the non-recursion feature of +@c macro execution. +@macro node_define{orig-name} +@macro \orig-name\{title} +@node \title\ +@\orig-name\ \title\ +@end macro +@end macro + +@c Here is a special one for "@top", causing the node name to be "Top", +@c but leaving the section name as the specified title. +@macro top{title} +@node Top +@top \title\ +@end macro + +@c Now actually define a new set of sectioning commands. +@node_define {appendix} +@node_define {appendixsec} +@node_define {appendixsubsec} +@node_define {appendixsubsubsec} +@node_define {chapter} +@node_define {section} +@node_define {subsection} +@node_define {subsubsec} +@node_define {unnumbered} +@node_define {unnumberedsec} +@node_define {unnumberedsubsec} +@node_define {unnumberedsubsubsec} + +@c The italicized analogues. +@node_define {iappendix} +@node_define {iappendixsec} +@node_define {iappendixsubsec} +@node_define {iappendixsubsubsec} +@node_define {ichapter} +@node_define {isection} +@node_define {isubsection} +@node_define {isubsubsec} +@node_define {iunnumbered} +@node_define {iunnumberedsec} +@node_define {iunnumberedsubsec} +@node_define {iunnumberedsubsubsec} + +@c Manual starter: +@c +@c Pass arguments of TITLE, AUTHOR, and a short DESCRIPTION. +@c Immediately following, insert the Top node's menu. +@c +@c Typical usage: +@c +@c @document{Makeinfo, Brian J. Fox, This file documents the use of the +@c @code{makeinfo} program\, versions 1.58 and later.} +@c +@c @menu +@c * What is @makeinfo{}?:: +@c @end menu + +@macro document{title, author, description} +@ifinfo +\description\ + +Copyright @copyright{} 1994 \author\ +Copyright @copyright{} 1994 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the copyright holders. +@end ifinfo + +@titlepage +@title \title\ +@author \author\ + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1994 \author\ +Copyright @copyright{} 1994 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the copyright holders. +@end titlepage + +@top{\title\} + +\description\ +@end macro diff --git a/texinfo/makeinfo/makeinfo.c b/texinfo/makeinfo/makeinfo.c new file mode 100644 index 000000000000..ee12ef27e71f --- /dev/null +++ b/texinfo/makeinfo/makeinfo.c @@ -0,0 +1,9349 @@ +/* Makeinfo -- convert texinfo format files into info files. + $Id: makeinfo.c,v 1.37 1996/10/04 18:20:52 karl Exp $ + + Copyright (C) 1987, 92, 93, 94, 95, 96 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. + + Makeinfo is authored by Brian Fox (bfox@ai.mit.edu). */ + +int major_version = 1; +int minor_version = 67; + +/* You can change some of the behaviour of Makeinfo by changing the + following defines: */ + +/* Define INDENT_PARAGRAPHS_IN_TABLE if you want the paragraphs which + appear within an @table, @ftable, or @itemize environment to have + standard paragraph indentation. Without this, such paragraphs have + no starting indentation. */ +/* #define INDENT_PARAGRAPHS_IN_TABLE */ + +/* Define DEFAULT_INDENTATION_INCREMENT as an integer which is the amount + that @example should increase indentation by. This incremement is used + for all insertions which indent the enclosed text. */ +#define DEFAULT_INDENTATION_INCREMENT 5 + +/* Define PARAGRAPH_START_INDENT to be the amount of indentation that + the first lines of paragraphs receive by default, where no other + value has been specified. Users can change this value on the command + line, with the --paragraph-indent option, or within the texinfo file, + with the @paragraphindent command. */ +#define PARAGRAPH_START_INDENT 3 + +/* Define DEFAULT_PARAGRAPH_SPACING as the number of blank lines that you + wish to appear between paragraphs. A value of 1 creates a single blank + line between paragraphs. Paragraphs are defined by 2 or more consecutive + newlines in the input file (i.e., one or more blank lines). */ +#define DEFAULT_PARAGRAPH_SPACING 1 + +/* Define HAVE_MACROS to enable the macro facility of Texinfo. Using this + facility, users can create their own command procedures with arguments. */ +#define HAVE_MACROS + + +/* Indent #pragma so that older Cpp's don't try to parse it. */ +#if defined (_AIX) + # pragma alloca +#endif /* _AIX */ + +#include +#include +#include +#include +#include +#include + +#if defined (HAVE_VARARGS_H) +#include +#endif /* HAVE_VARARGS_H */ +#include "getopt.h" + +#if defined (HAVE_UNISTD_H) +#include +#endif /* HAVE_UNISTD_H */ + +#if defined (VMS) +#include +#endif + +#if defined (HAVE_STRING_H) +#include +#else +#include +#endif /* !HAVE_STRING_H */ + +#if defined (TM_IN_SYS_TIME) +#include +#else +#include +#endif /* !TM_IN_SYS_TIME */ + +#if defined (HAVE_SYS_FCNTL_H) +#include +#else +#include +#endif /* !HAVE_SYS_FCNTL_H */ + +#if defined (HAVE_SYS_FILE_H) +#include +#endif /* HAVE_SYS_FILE_H */ + +#if defined (__GNUC__) +#define alloca __builtin_alloca +#else +#if defined(HAVE_ALLOCA_H) +#include +#else /* !HAVE_ALLOCA_H */ +#if !defined (_AIX) +extern char *alloca (); +#endif /* !_AIX */ +#endif /* !HAVE_ALLOCA_H */ +#endif /* !__GNUC__ */ + +void *xmalloc (), *xrealloc (); +#if defined (__osf__) +extern void *malloc (), *realloc (); +#endif /* __osf__ */ + +char **get_brace_args (); +int array_len (); +void free_array (); +static void isolate_nodename (); + +#define COMPILING_MAKEINFO +#include "makeinfo.h" + +/* Non-zero means that we are currently hacking the insides of an + insertion which would use a fixed width font. */ +static int in_fixed_width_font = 0; + +/* Non-zero means that start_paragraph () MUST be called before we pay + any attention to close_paragraph () calls. */ +int must_start_paragraph = 0; + +/* Non-zero means a string is in execution, as opposed to a file. */ +static int executing_string = 0; + +#if defined (HAVE_MACROS) +/* If non-NULL, this is an output stream to write the full macro expansion + of the input text to. The resultant file is another texinfo file, but + missing @include, @infoinclude, @macro, and macro invocations. Instead, + all of the text is placed within the file. */ +FILE *macro_expansion_output_stream = (FILE *)NULL; + +/* Here is a structure used to remember input text strings and offsets + within them. */ +typedef struct { + char *pointer; /* Pointer to the input text. */ + int offset; /* Offset of the last character output. */ +} ITEXT; + +static ITEXT **itext_info = (ITEXT **)NULL; +static int itext_size = 0; + +/* Non-zero means to inhibit the writing of macro expansions to the output + stream. This is used in special cases where the output has already been + written. */ +int me_inhibit_expansion = 0; + +ITEXT *remember_itext (); +void forget_itext (), me_append_before_this_command (); +void append_to_expansion_output (), write_region_to_macro_output (); +void maybe_write_itext (), me_execute_string (); +#endif /* HAVE_MACROS */ + +/* Some systems don't declare this function in pwd.h. */ +struct passwd *getpwnam (); + +/* **************************************************************** */ +/* */ +/* Global Variables */ +/* */ +/* **************************************************************** */ + +/* Global pointer to argv[0]. */ +char *progname; + +/* Return non-zero if STRING is the text at input_text + input_text_offset, + else zero. */ +#define looking_at(string) \ + (strncmp (input_text + input_text_offset, string, strlen (string)) == 0) + +/* And writing to the output. */ + +/* The output file name. */ +char *output_filename = (char *)NULL; +char *pretty_output_filename; + +/* Name of the output file that the user elected to pass on the command line. + Such a name overrides any name found with the @setfilename command. */ +char *command_output_filename = (char *)NULL; + +/* A colon separated list of directories to search for files included + with @include. This can be controlled with the `-I' option to makeinfo. */ +char *include_files_path = (char *)NULL; + +/* Current output stream. */ +FILE *output_stream; + +/* Position in the output file. */ +int output_position; + +#define INITIAL_PARAGRAPH_SPACE 5000 +int paragraph_buffer_len = INITIAL_PARAGRAPH_SPACE; + +/* Filling.. */ +/* Non-zero indicates that filling will take place on long lines. */ +int filling_enabled = 1; + +/* Non-zero means that words are not to be split, even in long lines. This + gets changed for cm_w (). */ +int non_splitting_words = 0; + +/* Non-zero indicates that filling a line also indents the new line. */ +int indented_fill = 0; + +/* The amount of indentation to add at the starts of paragraphs. + 0 means don't change existing indentation at paragraph starts. + > 0 is amount to indent new paragraphs by. + < 0 means indent to column zero by removing indentation if necessary. + + This is normally zero, but some people prefer paragraph starts to be + somewhat more indented than paragraph bodies. A pretty value for + this is 3. */ +int paragraph_start_indent = PARAGRAPH_START_INDENT; + +/* Non-zero means that the use of paragraph_start_indent is inhibited. + @example uses this to line up the left columns of the example text. + A negative value for this variable is incremented each time it is used. + @noindent uses this to inhibit indentation for a single paragraph. */ +int inhibit_paragraph_indentation = 0; + +/* Indentation that is pending insertion. We have this for hacking lines + which look blank, but contain whitespace. We want to treat those as + blank lines. */ +int pending_indent = 0; + +/* The amount that indentation increases/decreases by. */ +int default_indentation_increment = DEFAULT_INDENTATION_INCREMENT; + +/* Non-zero indicates that indentation is temporarily turned off. */ +int no_indent = 1; + +/* Non-zero means forcing output text to be flushright. */ +int force_flush_right = 0; + +/* Non-zero means that the footnote style for this document was set on + the command line, which overrides any other settings. */ +int footnote_style_preset = 0; + +/* Non-zero means that we automatically number footnotes that have no + specified marker. */ +int number_footnotes = 1; + +/* The current footnote number in this node. Each time a new node is + started this is reset to 1. */ +int current_footnote_number = 1; + +/* Command name in the process of being hacked. */ +char *command; + +/* The index in our internal command table of the currently + executing command. */ +int command_index; + +/* A search string which is used to find a line defining a node. */ +char node_search_string[] = + { '\n', COMMAND_PREFIX, 'n', 'o', 'd', 'e', ' ', '\0' }; + +/* A search string which is used to find a line defining a menu. */ +char menu_search_string[] = + { '\n', COMMAND_PREFIX, 'm', 'e', 'n', 'u', '\0' }; + +/* A search string which is used to find the first @setfilename. */ +char setfilename_search[] = + { COMMAND_PREFIX, + 's', 'e', 't', 'f', 'i', 'l', 'e', 'n', 'a', 'm', 'e', '\0' }; + +/* A stack of file information records. If a new file is read in with + "@input", we remember the old input file state on this stack. */ +typedef struct fstack +{ + struct fstack *next; + char *filename; + char *text; + int size; + int offset; + int line_number; +} FSTACK; + +FSTACK *filestack = (FSTACK *) NULL; + +/* Stuff for nodes. */ +/* The current nodes node name. */ +char *current_node = (char *)NULL; + +/* The current nodes section level. */ +int current_section = 0; + +/* The filename of the current input file. This is never freed. */ +char *node_filename = (char *)NULL; + +/* What we remember for each node. */ +typedef struct tentry +{ + struct tentry *next_ent; + char *node; /* name of this node. */ + char *prev; /* name of "Prev:" for this node. */ + char *next; /* name of "Next:" for this node. */ + char *up; /* name of "Up:" for this node. */ + int position; /* output file position of this node. */ + int line_no; /* defining line in source file. */ + char *filename; /* The file that this node was found in. */ + int touched; /* non-zero means this node has been referenced. */ + int flags; /* Room for growth. Right now, contains 1 bit. */ +} TAG_ENTRY; + +/* If node-a has a "Next" for node-b, but node-b has no "Prev" for node-a, + we turn on this flag bit in node-b's tag entry. This means that when + it is time to validate node-b, we don't report an additional error + if there was no "Prev" field. */ +#define PREV_ERROR 0x1 +#define NEXT_ERROR 0x2 +#define UP_ERROR 0x4 +#define NO_WARN 0x8 +#define IS_TOP 0x10 + +TAG_ENTRY *tag_table = (TAG_ENTRY *) NULL; + +#if defined (HAVE_MACROS) +#define ME_RECURSE 0x01 +#define ME_QUOTE_ARG 0x02 + +/* Macro definitions for user-defined commands. */ +typedef struct { + char *name; /* Name of the macro. */ + char **arglist; /* Args to replace when executing. */ + char *body; /* Macro body. */ + char *source_file; /* File where this macro is defined. */ + int source_lineno; /* Line number within FILENAME. */ + int inhibited; /* Non-zero means make find_macro () fail. */ + int flags; /* ME_RECURSE, ME_QUOTE_ARG, etc. */ +} MACRO_DEF; + +void add_macro (), execute_macro (); +MACRO_DEF *find_macro (), *delete_macro (); +#endif /* HAVE_MACROS */ + +/* Menu reference, *note reference, and validation hacking. */ + +/* The various references that we know about. */ +enum reftype +{ + menu_reference, followed_reference +}; + +/* A structure to remember references with. A reference to a node is + either an entry in a menu, or a cross-reference made with [px]ref. */ +typedef struct node_ref +{ + struct node_ref *next; + char *node; /* Name of node referred to. */ + char *containing_node; /* Name of node containing this reference. */ + int line_no; /* Line number where the reference occurs. */ + int section; /* Section level where the reference occurs. */ + char *filename; /* Name of file where the reference occurs. */ + enum reftype type; /* Type of reference, either menu or note. */ +} NODE_REF; + +/* The linked list of such structures. */ +NODE_REF *node_references = (NODE_REF *) NULL; + +/* Flag which tells us whether to examine menu lines or not. */ +int in_menu = 0; + +/* Flag which tells us how to examine menu lines. */ +int in_detailmenu = 0; + +/* Non-zero means that we have seen "@top" once already. */ +int top_node_seen = 0; + +/* Non-zero means that we have seen a non-"@top" node already. */ +int non_top_node_seen = 0; + +/* Flags controlling the operation of the program. */ + +/* Default is to notify users of bad choices. */ +int print_warnings = 1; + +/* Default is to check node references. */ +int validating = 1; + +/* Non-zero means do not output "Node: Foo" for node separations. */ +int no_headers = 0; + +/* Number of errors that we tolerate on a given fileset. */ +int max_error_level = 100; + +/* Maximum number of references to a single node before complaining. */ +int reference_warning_limit = 1000; + +/* Non-zero means print out information about what is going on when it + is going on. */ +int verbose_mode = 0; + +/* Non-zero means to be relaxed about the input file. This is useful when + we can successfully format the input, but it doesn't strictly match our + somewhat pedantic ideas of correctness. Right now, it affects what + @table and @itemize do without arguments. */ +int allow_lax_format = 0; + +/* The list of commands that we hack in texinfo. Each one + has an associated function. When the command is encountered in the + text, the associated function is called with START as the argument. + If the function expects arguments in braces, it remembers itself on + the stack. When the corresponding close brace is encountered, the + function is called with END as the argument. */ + +#define START 0 +#define END 1 + +typedef struct brace_element +{ + struct brace_element *next; + COMMAND_FUNCTION *proc; + int pos, line; + int in_fixed_width_font; +} BRACE_ELEMENT; + +BRACE_ELEMENT *brace_stack = (BRACE_ELEMENT *) NULL; + +/* Forward declarations. */ +#if !defined (HAVE_STRDUP) +extern char *strdup (); +#endif /* HAVE_STRDUP */ + +extern void do_multitable (); + +void print_version_info (); +void usage (); +void push_node_filename (), pop_node_filename (); +void remember_error (); +void convert_from_stream (), convert_from_file (), convert_from_loaded_file (); +void init_internals (), init_paragraph (), init_brace_stack (); +void init_insertion_stack (), init_indices (); +void init_tag_table (), write_tag_table (), write_tag_table_internal (); +void validate_file (), validate_other_references (), split_file (); +void free_node_references (), do_enumeration (), handle_variable (); +void handle_variable_internal (); +void execute_string (); +void normalize_node_name (); +void undefindex (), top_defindex (), gen_defindex (); +void define_user_command (); +void free_pending_notes (), output_pending_notes (); + +void reader_loop (), read_command (); +void remember_brace (), remember_brace_1 (); +void pop_and_call_brace (), discard_braces (); +void add_word_args (), add_word (), add_char (), insert (), flush_output (); +void insert_string (); +void close_paragraph_with_lines (), close_paragraph (); +void ignore_blank_line (); +void do_flush_right_indentation (); +void start_paragraph (), indent (); + +void insert_self (), insert_space (), cm_ignore_line (); + +void + cm_TeX (), cm_asterisk (), cm_bullet (), cm_cite (), + cm_code (), cm_copyright (), cm_ctrl (), cm_dfn (), cm_dircategory (), + cm_direntry (), cm_dots (), cm_emph (), cm_enddots (), + cm_kbd (), cm_angle_brackets (), cm_no_op (), cm_not_fixed_width (), + cm_strong (), cm_var (), cm_w (); + +/* Sectioning. */ +void + cm_chapter (), cm_unnumbered (), cm_appendix (), cm_top (), + cm_section (), cm_unnumberedsec (), cm_appendixsec (), + cm_subsection (), cm_unnumberedsubsec (), cm_appendixsubsec (), + cm_subsubsection (), cm_unnumberedsubsubsec (), cm_appendixsubsubsec (), + cm_heading (), cm_chapheading (), cm_subheading (), cm_subsubheading (), + cm_majorheading (), cm_raisesections (), cm_lowersections (); + +/* All @defxxx commands map to cm_defun, most accent commands map to + cm_accent, most non-English letters map to cm_special_char. */ +void cm_defun (), cm_accent (), cm_special_char (), cm_dotless (); + +void + cm_node (), cm_menu (), cm_xref (), cm_ftable (), cm_vtable (), cm_pxref (), + cm_inforef (), cm_quotation (), cm_display (), cm_itemize (), + cm_enumerate (), cm_tab (), cm_table (), cm_itemx (), cm_noindent (), + cm_setfilename (), cm_br (), cm_sp (), cm_page (), cm_group (), + cm_center (), cm_include (), cm_bye (), cm_item (), cm_end (), + cm_ifinfo (), cm_kindex (), cm_cindex (), + cm_findex (), cm_pindex (), cm_vindex (), cm_tindex (), + cm_synindex (), cm_printindex (), cm_minus (), cm_footnote (), + cm_example (), cm_smallexample (), cm_lisp (), cm_format (), cm_exdent (), + cm_defindex (), cm_defcodeindex (), cm_sc (), cm_result (), cm_expansion (), + cm_equiv (), cm_print (), cm_error (), cm_point (), cm_today (), + cm_flushleft (), cm_flushright (), cm_smalllisp (), cm_finalout (), + cm_cartouche (), cm_detailmenu (), cm_multitable (); + +/* Conditionals. */ +void cm_set (), cm_clear (), cm_ifset (), cm_ifclear (); +void cm_value (), cm_ifeq (); + +#if defined (HAVE_MACROS) +/* Define a user-defined command which is simple substitution. */ +void cm_macro (), cm_unmacro (); +#endif /* HAVE_MACROS */ + +/* Options. */ +void cm_paragraphindent (), cm_footnotestyle (); + +/* Internals. */ +void command_name_condition (), misplaced_brace (), cm_obsolete (), + cm_ideprecated (); + +typedef struct +{ + char *name; + COMMAND_FUNCTION *proc; + int argument_in_braces; +} COMMAND; + +/* Stuff for defining commands on the fly. */ +COMMAND **user_command_array = (COMMAND **) NULL; +int user_command_array_len = 0; + +#define NO_BRACE_ARGS 0 +#define BRACE_ARGS 1 + +static COMMAND CommandTable[] = { + { "\t", insert_space, NO_BRACE_ARGS }, + { "\n", insert_space, NO_BRACE_ARGS }, + { " ", insert_self, NO_BRACE_ARGS }, + { "!", insert_self, NO_BRACE_ARGS }, + { "\"", insert_self, NO_BRACE_ARGS }, + { "'", insert_self, NO_BRACE_ARGS }, + { "*", cm_asterisk, NO_BRACE_ARGS }, + { ",", cm_accent, BRACE_ARGS }, + { "-", cm_no_op, NO_BRACE_ARGS }, + { ".", insert_self, NO_BRACE_ARGS }, + { ":", cm_no_op, NO_BRACE_ARGS }, + { "=", insert_self, NO_BRACE_ARGS }, + { "?", insert_self, NO_BRACE_ARGS }, + { "@", insert_self, NO_BRACE_ARGS }, + { "^", insert_self, NO_BRACE_ARGS }, + { "`", insert_self, NO_BRACE_ARGS }, + { "{", insert_self, NO_BRACE_ARGS }, + { "|", cm_no_op, NO_BRACE_ARGS }, + { "}", insert_self, NO_BRACE_ARGS }, + { "~", insert_self, NO_BRACE_ARGS }, + { "AA", insert_self, BRACE_ARGS }, + { "AE", insert_self, BRACE_ARGS }, + { "H", cm_accent, BRACE_ARGS }, + { "L", cm_special_char, BRACE_ARGS }, + { "O", cm_special_char, BRACE_ARGS }, + { "OE", insert_self, BRACE_ARGS }, + { "TeX", cm_TeX, BRACE_ARGS }, + { "aa", insert_self, BRACE_ARGS }, + { "ae", insert_self, BRACE_ARGS }, + { "appendix", cm_appendix, NO_BRACE_ARGS }, + { "appendixsection", cm_appendixsec, NO_BRACE_ARGS }, + { "appendixsec", cm_appendixsec, NO_BRACE_ARGS }, + { "appendixsubsec", cm_appendixsubsec, NO_BRACE_ARGS }, + { "appendixsubsubsec", cm_appendixsubsubsec, NO_BRACE_ARGS }, + { "asis", cm_no_op, BRACE_ARGS }, + { "b", cm_not_fixed_width, BRACE_ARGS }, + { "bullet", cm_bullet, BRACE_ARGS }, + { "bye", cm_bye, NO_BRACE_ARGS }, + { "c", cm_ignore_line, NO_BRACE_ARGS }, + { "cartouche", cm_cartouche, NO_BRACE_ARGS }, + { "center", cm_center, NO_BRACE_ARGS }, + { "centerchap", cm_unnumbered, NO_BRACE_ARGS }, + { "chapheading", cm_chapheading, NO_BRACE_ARGS }, + { "chapter", cm_chapter, NO_BRACE_ARGS }, + { "cindex", cm_cindex, NO_BRACE_ARGS }, + { "cite", cm_cite, BRACE_ARGS }, + { "clear", cm_clear, NO_BRACE_ARGS }, + { "code", cm_code, BRACE_ARGS }, + { "comment", cm_ignore_line, NO_BRACE_ARGS }, + { "contents", cm_no_op, NO_BRACE_ARGS }, + { "copyright", cm_copyright, BRACE_ARGS }, + { "ctrl", cm_obsolete, BRACE_ARGS }, + { "defcodeindex", cm_defcodeindex, NO_BRACE_ARGS }, + { "defindex", cm_defindex, NO_BRACE_ARGS }, +/* The `def' commands. */ + { "defcv", cm_defun, NO_BRACE_ARGS }, + { "defcvx", cm_defun, NO_BRACE_ARGS }, + { "deffn", cm_defun, NO_BRACE_ARGS }, + { "deffnx", cm_defun, NO_BRACE_ARGS }, + { "defivar", cm_defun, NO_BRACE_ARGS }, + { "defivarx", cm_defun, NO_BRACE_ARGS }, + { "defmac", cm_defun, NO_BRACE_ARGS }, + { "defmacx", cm_defun, NO_BRACE_ARGS }, + { "defmethod", cm_defun, NO_BRACE_ARGS }, + { "defmethodx", cm_defun, NO_BRACE_ARGS }, + { "defop", cm_defun, NO_BRACE_ARGS }, + { "defopt", cm_defun, NO_BRACE_ARGS }, + { "defoptx", cm_defun, NO_BRACE_ARGS }, + { "defopx", cm_defun, NO_BRACE_ARGS }, + { "defspec", cm_defun, NO_BRACE_ARGS }, + { "defspecx", cm_defun, NO_BRACE_ARGS }, + { "deftp", cm_defun, NO_BRACE_ARGS }, + { "deftpx", cm_defun, NO_BRACE_ARGS }, + { "deftypefn", cm_defun, NO_BRACE_ARGS }, + { "deftypefnx", cm_defun, NO_BRACE_ARGS }, + { "deftypefun", cm_defun, NO_BRACE_ARGS }, + { "deftypefunx", cm_defun, NO_BRACE_ARGS }, + { "deftypemethod", cm_defun, NO_BRACE_ARGS }, + { "deftypemethodx", cm_defun, NO_BRACE_ARGS }, + { "deftypevar", cm_defun, NO_BRACE_ARGS }, + { "deftypevarx", cm_defun, NO_BRACE_ARGS }, + { "deftypevr", cm_defun, NO_BRACE_ARGS }, + { "deftypevrx", cm_defun, NO_BRACE_ARGS }, + { "defun", cm_defun, NO_BRACE_ARGS }, + { "defunx", cm_defun, NO_BRACE_ARGS }, + { "defvar", cm_defun, NO_BRACE_ARGS }, + { "defvarx", cm_defun, NO_BRACE_ARGS }, + { "defvr", cm_defun, NO_BRACE_ARGS }, + { "defvrx", cm_defun, NO_BRACE_ARGS }, +/* The end of the `def' commands. */ + { "detailmenu", cm_detailmenu, NO_BRACE_ARGS }, + { "dfn", cm_dfn, BRACE_ARGS }, + { "dircategory", cm_dircategory, NO_BRACE_ARGS }, + { "direntry", cm_direntry, NO_BRACE_ARGS }, + { "display", cm_display, NO_BRACE_ARGS }, + { "dmn", cm_no_op, BRACE_ARGS }, + { "dotaccent", cm_accent, BRACE_ARGS }, + { "dotless", cm_dotless, BRACE_ARGS }, + { "dots", cm_dots, BRACE_ARGS }, + { "email", cm_angle_brackets, BRACE_ARGS }, + { "emph", cm_emph, BRACE_ARGS }, + { "end", cm_end, NO_BRACE_ARGS }, + { "enddots", cm_enddots, BRACE_ARGS }, + { "enumerate", cm_enumerate, NO_BRACE_ARGS }, + { "equiv", cm_equiv, BRACE_ARGS }, + { "error", cm_error, BRACE_ARGS }, + { "example", cm_example, NO_BRACE_ARGS }, + { "exclamdown", cm_special_char, BRACE_ARGS }, + { "exdent", cm_exdent, NO_BRACE_ARGS }, + { "expansion", cm_expansion, BRACE_ARGS }, + { "file", cm_code, BRACE_ARGS }, + { "finalout", cm_no_op, NO_BRACE_ARGS }, + { "findex", cm_findex, NO_BRACE_ARGS }, + { "flushleft", cm_flushleft, NO_BRACE_ARGS }, + { "flushright", cm_flushright, NO_BRACE_ARGS }, + { "footnote", cm_footnote, NO_BRACE_ARGS}, /* self-arg eater */ + { "footnotestyle", cm_footnotestyle, NO_BRACE_ARGS }, + { "format", cm_format, NO_BRACE_ARGS }, + { "ftable", cm_ftable, NO_BRACE_ARGS }, + { "group", cm_group, NO_BRACE_ARGS }, + { "heading", cm_heading, NO_BRACE_ARGS }, + { "headings", cm_ignore_line, NO_BRACE_ARGS }, + { "hyphenation", cm_no_op, BRACE_ARGS }, + { "i", cm_not_fixed_width, BRACE_ARGS }, + { "ifclear", cm_ifclear, NO_BRACE_ARGS }, + { "ifeq", cm_ifeq, NO_BRACE_ARGS }, + { "ifhtml", command_name_condition, NO_BRACE_ARGS }, + { "ifinfo", cm_ifinfo, NO_BRACE_ARGS }, + { "ifset", cm_ifset, NO_BRACE_ARGS }, + { "iftex", command_name_condition, NO_BRACE_ARGS }, + { "ignore", command_name_condition, NO_BRACE_ARGS }, + { "include", cm_include, NO_BRACE_ARGS }, + { "inforef", cm_inforef, BRACE_ARGS }, + { "item", cm_item, NO_BRACE_ARGS }, + { "itemize", cm_itemize, NO_BRACE_ARGS }, + { "itemx", cm_itemx, NO_BRACE_ARGS }, + { "kbd", cm_kbd, BRACE_ARGS }, + { "key", cm_angle_brackets, BRACE_ARGS }, + { "kindex", cm_kindex, NO_BRACE_ARGS }, + { "l", cm_special_char, BRACE_ARGS }, + { "lisp", cm_lisp, NO_BRACE_ARGS }, + { "lowersections", cm_lowersections, NO_BRACE_ARGS }, +#if defined (HAVE_MACROS) + { "macro", cm_macro, NO_BRACE_ARGS }, +#endif + { "majorheading", cm_majorheading, NO_BRACE_ARGS }, + { "math", cm_no_op, BRACE_ARGS }, + { "menu", cm_menu, NO_BRACE_ARGS }, + { "minus", cm_minus, BRACE_ARGS }, + { "multitable", cm_multitable, NO_BRACE_ARGS }, + { "need", cm_ignore_line, NO_BRACE_ARGS }, + { "node", cm_node, NO_BRACE_ARGS }, + { "noindent", cm_noindent, NO_BRACE_ARGS }, + { "nwnode", cm_node, NO_BRACE_ARGS }, + { "o", cm_special_char, BRACE_ARGS }, + { "oe", insert_self, BRACE_ARGS }, + { "page", cm_no_op, NO_BRACE_ARGS }, + { "paragraphindent", cm_paragraphindent, NO_BRACE_ARGS }, + { "pindex", cm_pindex, NO_BRACE_ARGS }, + { "point", cm_point, BRACE_ARGS }, + { "pounds", cm_special_char, BRACE_ARGS }, + { "print", cm_print, BRACE_ARGS }, + { "printindex", cm_printindex, NO_BRACE_ARGS }, + { "pxref", cm_pxref, BRACE_ARGS }, + { "questiondown", cm_special_char, BRACE_ARGS }, + { "quotation", cm_quotation, NO_BRACE_ARGS }, + { "r", cm_not_fixed_width, BRACE_ARGS }, + { "raisesections", cm_raisesections, NO_BRACE_ARGS }, + { "ref", cm_xref, BRACE_ARGS }, + { "refill", cm_no_op, NO_BRACE_ARGS }, + { "result", cm_result, BRACE_ARGS }, + { "ringaccent", cm_accent, BRACE_ARGS }, + { "samp", cm_code, BRACE_ARGS }, + { "sc", cm_sc, BRACE_ARGS }, + { "section", cm_section, NO_BRACE_ARGS }, + { "set", cm_set, NO_BRACE_ARGS }, + { "setchapternewpage", cm_ignore_line, NO_BRACE_ARGS }, + { "setchapterstyle", cm_obsolete, NO_BRACE_ARGS }, + { "setfilename", cm_setfilename, NO_BRACE_ARGS }, + { "settitle", cm_ignore_line, NO_BRACE_ARGS }, + { "shortcontents", cm_no_op, NO_BRACE_ARGS }, + { "shorttitlepage", cm_ignore_line, NO_BRACE_ARGS }, + { "smallbook", cm_ignore_line, NO_BRACE_ARGS }, + { "smallexample", cm_smallexample, NO_BRACE_ARGS }, + { "smalllisp", cm_smalllisp, NO_BRACE_ARGS }, + { "sp", cm_sp, NO_BRACE_ARGS }, + { "ss", insert_self, BRACE_ARGS }, + { "strong", cm_strong, BRACE_ARGS }, + { "subheading", cm_subheading, NO_BRACE_ARGS }, + { "subsection", cm_subsection, NO_BRACE_ARGS }, + { "subsubheading", cm_subsubheading, NO_BRACE_ARGS }, + { "subsubsection", cm_subsubsection, NO_BRACE_ARGS }, + { "summarycontents", cm_no_op, NO_BRACE_ARGS }, + { "syncodeindex", cm_synindex, NO_BRACE_ARGS }, + { "synindex", cm_synindex, NO_BRACE_ARGS }, + { "t", cm_no_op, BRACE_ARGS }, + { "tab", cm_tab, NO_BRACE_ARGS }, + { "table", cm_table, NO_BRACE_ARGS }, + { "tex", command_name_condition, NO_BRACE_ARGS }, + { "tieaccent", cm_accent, BRACE_ARGS }, + { "tindex", cm_tindex, NO_BRACE_ARGS }, + { "titlefont", cm_not_fixed_width, BRACE_ARGS }, + { "titlepage", command_name_condition, NO_BRACE_ARGS }, + { "today", cm_today, BRACE_ARGS }, + { "top", cm_top, NO_BRACE_ARGS }, + { "u", cm_accent, BRACE_ARGS }, + { "ubaraccent", cm_accent, BRACE_ARGS }, + { "udotaccent", cm_accent, BRACE_ARGS }, +#if defined (HAVE_MACROS) + { "unmacro", cm_unmacro, NO_BRACE_ARGS }, +#endif + { "unnumbered", cm_unnumbered, NO_BRACE_ARGS }, + { "unnumberedsec", cm_unnumberedsec, NO_BRACE_ARGS }, + { "unnumberedsubsec", cm_unnumberedsubsec, NO_BRACE_ARGS }, + { "unnumberedsubsubsec", cm_unnumberedsubsubsec, NO_BRACE_ARGS }, + { "url", cm_code, BRACE_ARGS }, + { "v", cm_accent, BRACE_ARGS }, + { "value", cm_value, BRACE_ARGS }, + { "var", cm_var, BRACE_ARGS }, + { "vindex", cm_vindex, NO_BRACE_ARGS }, + { "vtable", cm_vtable, NO_BRACE_ARGS }, + { "w", cm_w, BRACE_ARGS }, + { "xref", cm_xref, BRACE_ARGS }, + + /* Deprecated commands. These used to be for italics. */ + { "iappendix", cm_ideprecated, NO_BRACE_ARGS }, + { "iappendixsec", cm_ideprecated, NO_BRACE_ARGS }, + { "iappendixsection", cm_ideprecated, NO_BRACE_ARGS }, + { "iappendixsubsec", cm_ideprecated, NO_BRACE_ARGS }, + { "iappendixsubsubsec", cm_ideprecated, NO_BRACE_ARGS }, + { "ichapter", cm_ideprecated, NO_BRACE_ARGS }, + { "isection", cm_ideprecated, NO_BRACE_ARGS }, + { "isubsection", cm_ideprecated, NO_BRACE_ARGS }, + { "isubsubsection", cm_ideprecated, NO_BRACE_ARGS }, + { "iunnumbered", cm_ideprecated, NO_BRACE_ARGS }, + { "iunnumberedsec", cm_ideprecated, NO_BRACE_ARGS }, + { "iunnumberedsubsec", cm_ideprecated, NO_BRACE_ARGS }, + { "iunnumberedsubsubsec", cm_ideprecated, NO_BRACE_ARGS }, + + /* Now @include does what this was supposed to. */ + { "infoinclude", cm_obsolete, NO_BRACE_ARGS }, + { "titlespec", cm_obsolete, NO_BRACE_ARGS }, + + {(char *) NULL, (COMMAND_FUNCTION *) NULL}, NO_BRACE_ARGS}; + +struct option long_options[] = +{ + { "error-limit", 1, 0, 'e' }, /* formerly -el */ + { "fill-column", 1, 0, 'f' }, /* formerly -fc */ + { "footnote-style", 1, 0, 's' }, /* formerly -ft */ + { "no-headers", 0, &no_headers, 1 }, /* Do not output Node: foo */ + { "no-pointer-validate", 0, &validating, 0 }, /* formerly -nv */ + { "no-validate", 0, &validating, 0 }, /* formerly -nv */ + { "no-split", 0, &splitting, 0 }, /* formerly -ns */ + { "no-warn", 0, &print_warnings, 0 }, /* formerly -nw */ +#if defined (HAVE_MACROS) + { "macro-expand", 1, 0, 'E' }, +#endif /* HAVE_MACROS */ + { "number-footnotes", 0, &number_footnotes, 1 }, + { "no-number-footnotes", 0, &number_footnotes, 0 }, + { "output", 1, 0, 'o' }, + { "paragraph-indent", 1, 0, 'p' }, /* formerly -pi */ + { "reference-limit", 1, 0, 'r' }, /* formerly -rl */ + { "verbose", 0, &verbose_mode, 1 }, /* formerly -verbose */ + { "help", 0, 0, 'h' }, + { "version", 0, 0, 'V' }, + {NULL, 0, NULL, 0} +}; + +/* Values for calling handle_variable_internal (). */ +#define SET 1 +#define CLEAR 2 +#define IFSET 3 +#define IFCLEAR 4 + +/* **************************************************************** */ +/* */ +/* Main () Start of code */ +/* */ +/* **************************************************************** */ + +/* For each file mentioned in the command line, process it, turning + Texinfo commands into wonderfully formatted output text. */ +int +main (argc, argv) + int argc; + char **argv; +{ + extern int errors_printed; + char *filename_part (); + int c, ind; + int reading_from_stdin = 0; + + /* The name of this program is the last filename in argv[0]. */ + progname = filename_part (argv[0]); + + /* Parse argument flags from the input line. */ + while ((c = getopt_long + (argc, argv, +#if defined (HAVE_MACROS) + "D:E:U:I:f:o:p:e:r:s:V", +#else + "D:U:I:f:o:p:e:r:s:V", +#endif /* !HAVE_MACROS */ + long_options, &ind)) + != EOF) + { + if (c == 0 && long_options[ind].flag == 0) + c = long_options[ind].val; + + switch (c) + { + /* User specified variable to set or clear? */ + case 'D': + case 'U': + handle_variable_internal ((c == 'D') ? SET : CLEAR, optarg); + break; + +#if defined (HAVE_MACROS) + /* Use specified a macro expansion output file? */ + case 'E': + if (!macro_expansion_output_stream) + { + macro_expansion_output_stream = fopen (optarg, "w"); + if (!macro_expansion_output_stream) + error ("Couldn't open macro expansion output \"%s\"", optarg); + } + else + error ("Cannot specify more than one macro expansion output"); + break; +#endif /* HAVE_MACROS */ + + /* User specified include file path? */ + case 'I': + if (!include_files_path) + include_files_path = strdup ("."); + + include_files_path = (char *) + xrealloc (include_files_path, + 2 + strlen (include_files_path) + strlen (optarg)); + strcat (include_files_path, ":"); + strcat (include_files_path, optarg); + break; + + /* User specified fill_column? */ + case 'f': + if (sscanf (optarg, "%d", &fill_column) != 1) + { + fprintf (stderr, + "%s: --fill-column arg must be numeric, not `%s'.\n", + progname, optarg); + usage (FATAL); + } + break; + + /* User specified output file? */ + case 'o': + command_output_filename = strdup (optarg); + break; + + /* User specified paragraph indent (paragraph_start_index)? */ + case 'p': + if (set_paragraph_indent (optarg) < 0) + { + fprintf (stderr, + "%s: --paragraph-indent arg must be numeric/none/asis, not `%s'.\n", + progname, optarg); + usage (FATAL); + } + break; + + /* User specified error level? */ + case 'e': + if (sscanf (optarg, "%d", &max_error_level) != 1) + { + fprintf (stderr, + "%s: --error-limit arg must be numeric, not `%s'.\n", + progname, optarg); + } + usage (stderr, FATAL); + break; + + /* User specified reference warning limit? */ + case 'r': + if (sscanf (optarg, "%d", &reference_warning_limit) != 1) + { + fprintf (stderr, + "%s: --reference-limit arg must be numeric, not `%s'.\n", + progname, optarg); + usage (FATAL); + } + break; + + /* User specified footnote style? */ + case 's': + if (set_footnote_style (optarg) < 0) + { + fprintf (stderr, + "%s: --footnote-style arg must be `separate' or `end', not `%s'.\n", + progname, optarg); + usage (FATAL); + } + footnote_style_preset = 1; + break; + + case 'h': + usage (NO_ERROR); + break; + + /* User requested version info? */ + case 'V': + print_version_info (); + puts ("Copyright (C) 1996 Free Software Foundation, Inc.\n\ +There is NO warranty. You may redistribute this software\n\ +under the terms of the GNU General Public License.\n\ +For more information about these matters, see the files named COPYING."); + exit (NO_ERROR); + break; + + case '?': + usage (FATAL); + break; + } + } + + if (optind == argc) + { + /* Check to see if input is a file. If so, process that. */ + if (!isatty (fileno (stdin))) + reading_from_stdin = 1; + else + { + fprintf (stderr, "%s: missing file argument.\n", progname); + usage (FATAL); + } + } + + /* If the user has specified --no-headers, this should imply --no-split. + Do that here. I think it might also imply that we should ignore the + setfilename at the top of the file, but this might break some FSF things, + so I will hold off on that. */ + if (no_headers) + { + splitting = 0; + + /* If the user has not specified an output file, then use stdout by + default. */ + if (!command_output_filename) + command_output_filename = strdup ("-"); + } + + if (verbose_mode) + print_version_info (); + + /* Remaining arguments are file names of texinfo files. + Convert them, one by one. */ + if (!reading_from_stdin) + { + while (optind != argc) + convert_from_file (argv[optind++]); + } + else + convert_from_stream (stdin, "stdin"); + + if (errors_printed) + return (SYNTAX); + else + return (NO_ERROR); +} + +/* Display the version info of this invocation of Makeinfo. */ +void +print_version_info () +{ + printf ("GNU Makeinfo (Texinfo 3.9) %d.%d\n", major_version, minor_version); +} + +/* **************************************************************** */ +/* */ +/* Generic Utilities */ +/* */ +/* **************************************************************** */ + +static void +memory_error (callers_name, bytes_wanted) + char *callers_name; + int bytes_wanted; +{ + char printable_string[80]; + + sprintf (printable_string, + "Virtual memory exhausted in %s ()! Needed %d bytes.", + callers_name, bytes_wanted); + + error (printable_string); + abort (); +} + +/* Just like malloc, but kills the program in case of fatal error. */ +void * +xmalloc (nbytes) + unsigned int nbytes; +{ + void *temp = (void *) malloc (nbytes); + + if (nbytes && temp == (void *)NULL) + memory_error ("xmalloc", nbytes); + + return (temp); +} + +/* Like realloc (), but barfs if there isn't enough memory. */ +void * +xrealloc (pointer, nbytes) + void *pointer; + unsigned int nbytes; +{ + void *temp; + + if (!pointer) + temp = (void *)xmalloc (nbytes); + else + temp = (void *)realloc (pointer, nbytes); + + if (nbytes && !temp) + memory_error ("xrealloc", nbytes); + + return (temp); +} + +/* If EXIT_VALUE is zero, print the full usage message to stdout. + Otherwise, just say to use --help for more info. + Then exit with EXIT_VALUE. */ +void +usage (exit_value) + int exit_value; +{ + if (exit_value != 0) + fprintf (stderr, "Try `%s --help' for more information.\n", progname); + else + printf ("Usage: %s [OPTION]... TEXINFO-FILE...\n\ +\n\ +Translate Texinfo source documentation to a format suitable for reading\n\ +with GNU Info.\n\ +\n\ +Options:\n\ +-D VAR define a variable, as with @set.\n\ +-E MACRO-OFILE process macros only, output texinfo source.\n\ +-I DIR add DIR to the directory search list for @include.\n\ +-U VAR undefine a variable, as with @clear.\n\ +--error-limit NUM quit after NUM errors (default %d).\n\ +--fill-column NUM break lines at NUM characters (default %d).\n\ +--footnote-style STYLE output footnotes according to STYLE:\n\ + `separate' to place footnotes in their own node,\n\ + `end' to place the footnotes at the end of\n\ + the node in which they are defined (the default).\n\ +--help display this help and exit.\n\ +--no-validate suppress node cross-reference validation.\n\ +--no-warn suppress warnings (but not errors).\n\ +--no-split suppress splitting of large files.\n\ +--no-headers suppress node separators and Node: Foo headers.\n\ +--output FILE, -o FILE output to FILE, and ignore any @setfilename.\n\ +--paragraph-indent NUM indent paragraphs with NUM spaces (default %d).\n\ +--reference-limit NUM complain about at most NUM references (default %d).\n\ +--verbose report about what is being done.\n\ +--version display version information and exit.\n\ +\n\ +Email bug reports to bug-texinfo@prep.ai.mit.edu.\n\ +", + progname, paragraph_start_indent, + fill_column, max_error_level, reference_warning_limit); + exit (exit_value); +} + +/* Manipulating Lists */ + +typedef struct generic_list { + struct generic_list *next; +} GENERIC_LIST; + +/* Reverse the chain of structures in LIST. Output the new head + of the chain. You should always assign the output value of this + function to something, or you will lose the chain. */ +GENERIC_LIST * +reverse_list (list) + register GENERIC_LIST *list; +{ + register GENERIC_LIST *next; + register GENERIC_LIST *prev = (GENERIC_LIST *) NULL; + + while (list) + { + next = list->next; + list->next = prev; + prev = list; + list = next; + } + return (prev); +} + +/* Pushing and Popping Files */ + +/* Find and load the file named FILENAME. Return a pointer to + the loaded file, or NULL if it can't be loaded. */ +char * +find_and_load (filename) + char *filename; +{ + struct stat fileinfo; + long file_size; + int file = -1, n, i, count = 0; + char *fullpath, *result, *get_file_info_in_path (); + + result = fullpath = (char *)NULL; + + fullpath = get_file_info_in_path (filename, include_files_path, &fileinfo); + + if (!fullpath) + goto error_exit; + + filename = fullpath; + file_size = (long) fileinfo.st_size; + + file = open (filename, O_RDONLY); + if (file < 0) + goto error_exit; + + /* Load the file. */ + result = (char *)xmalloc (1 + file_size); + + /* VMS stat lies about the st_size value. The actual number of + readable bytes is always less than this value. The arcane + mysteries of VMS/RMS are too much to probe, so this hack + suffices to make things work. */ +#if defined (VMS) + while ((n = read (file, result + count, file_size)) > 0) + count += n; + if (n == -1) +#else /* !VMS */ + count = file_size; + if (read (file, result, file_size) != file_size) +#endif /* !VMS */ + error_exit: + { + if (result) + free (result); + + if (fullpath) + free (fullpath); + + if (file != -1) + close (file); + + return ((char *) NULL); + } + close (file); + + /* Set the globals to the new file. */ + input_text = result; + size_of_input_text = count; + input_filename = fullpath; + node_filename = strdup (fullpath); + input_text_offset = 0; + line_number = 1; + /* Not strictly necessary. This magic prevents read_token () from doing + extra unnecessary work each time it is called (that is a lot of times). + The SIZE_OF_INPUT_TEXT is one past the actual end of the text. */ + input_text[size_of_input_text] = '\n'; + return (result); +} + +/* Save the state of the current input file. */ +void +pushfile () +{ + FSTACK *newstack = (FSTACK *) xmalloc (sizeof (FSTACK)); + newstack->filename = input_filename; + newstack->text = input_text; + newstack->size = size_of_input_text; + newstack->offset = input_text_offset; + newstack->line_number = line_number; + newstack->next = filestack; + + filestack = newstack; + push_node_filename (); +} + +/* Make the current file globals be what is on top of the file stack. */ +void +popfile () +{ + FSTACK *tos = filestack; + + if (!tos) + abort (); /* My fault. I wonder what I did? */ + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + { + maybe_write_itext (input_text, input_text_offset); + forget_itext (input_text); + } +#endif /* HAVE_MACROS */ + + /* Pop the stack. */ + filestack = filestack->next; + + /* Make sure that commands with braces have been satisfied. */ + if (!executing_string) + discard_braces (); + + /* Get the top of the stack into the globals. */ + input_filename = tos->filename; + input_text = tos->text; + size_of_input_text = tos->size; + input_text_offset = tos->offset; + line_number = tos->line_number; + free (tos); + + /* Go back to the (now) current node. */ + pop_node_filename (); +} + +/* Flush all open files on the file stack. */ +void +flush_file_stack () +{ + while (filestack) + { + char *fname = input_filename; + char *text = input_text; + popfile (); + free (fname); + free (text); + } +} + +int node_filename_stack_index = 0; +int node_filename_stack_size = 0; +char **node_filename_stack = (char **)NULL; + +void +push_node_filename () +{ + if (node_filename_stack_index + 1 > node_filename_stack_size) + node_filename_stack = (char **)xrealloc + (node_filename_stack, (node_filename_stack_size += 10) * sizeof (char *)); + + node_filename_stack[node_filename_stack_index] = node_filename; + node_filename_stack_index++; +} + +void +pop_node_filename () +{ + node_filename = node_filename_stack[--node_filename_stack_index]; +} + +/* Return just the simple part of the filename; i.e. the + filename without the path information, or extensions. + This conses up a new string. */ +char * +filename_part (filename) + char *filename; +{ + char *basename; + + basename = strrchr (filename, '/'); + if (!basename) + basename = filename; + else + basename++; + + basename = strdup (basename); +#if defined (REMOVE_OUTPUT_EXTENSIONS) + + /* See if there is an extension to remove. If so, remove it. */ + { + char *temp; + + temp = strrchr (basename, '.'); + if (temp) + *temp = '\0'; + } +#endif /* REMOVE_OUTPUT_EXTENSIONS */ + return (basename); +} + +/* Return the pathname part of filename. This can be NULL. */ +char * +pathname_part (filename) + char *filename; +{ + char *expand_filename (); + char *result = (char *) NULL; + register int i; + + filename = expand_filename (filename, ""); + + i = strlen (filename) - 1; + + while (i && filename[i] != '/') + i--; + if (filename[i] == '/') + i++; + + if (i) + { + result = (char *)xmalloc (1 + i); + strncpy (result, filename, i); + result[i] = '\0'; + } + free (filename); + return (result); +} + +char * +filename_non_directory (name) + char *name; +{ + register int i; + + for (i = strlen (name) - 1; i; i--) + if (name[i] == '/') + return (strdup (name + i + 1)); + + return (strdup (name)); +} + +/* Return the expansion of FILENAME. */ +char * +expand_filename (filename, input_name) + char *filename, *input_name; +{ + register int i; + char *full_pathname (); + + if (filename) + filename = full_pathname (filename); + else + { + filename = filename_non_directory (input_name); + + if (!*filename) + { + free (filename); + filename = strdup ("noname.texi"); + } + + for (i = strlen (filename) - 1; i; i--) + if (filename[i] == '.') + break; + + if (!i) + i = strlen (filename); + + if (i + 6 > (strlen (filename))) + filename = (char *)xrealloc (filename, i + 6); + strcpy (filename + i, ".info"); + return (filename); + } + + if (filename[0] == '.' || filename[0] == '/') + return (filename); + + if (filename[0] != '/' && input_name[0] == '/') + { + /* Make it so that relative names work. */ + char *result; + + i = strlen (input_name) - 1; + + result = (char *)xmalloc (1 + strlen (input_name) + strlen (filename)); + strcpy (result, input_name); + + while (result[i] != '/' && i) + i--; + + if (result[i] == '/') + i++; + + strcpy (&result[i], filename); + free (filename); + return (result); + } + return (filename); +} + +/* Return the full path to FILENAME. */ +char * +full_pathname (filename) + char *filename; +{ + int initial_character; + char *result; + + /* No filename given? */ + if (!filename || !(initial_character = *filename)) + return (strdup ("")); + + /* Already absolute? */ + if ((initial_character == '/') || + ((strncmp (filename, "./", 2) == 0) || + (strncmp (filename, "../", 3) == 0))) + return (strdup (filename)); + + if (initial_character != '~') + { + char *localdir; + + localdir = (char *)xmalloc (1025); +#if defined (HAVE_GETCWD) + if (!getcwd (localdir, 1024)) +#else /* !HAVE_GETCWD */ + if (!getwd (localdir)) +#endif /* !HAVE_GETCWD */ + { + fprintf (stderr, "%s: getwd: %s, %s\n", + progname, filename, localdir); + exit (1); + } + + strcat (localdir, "/"); + strcat (localdir, filename); + result = strdup (localdir); + free (localdir); + } + else + { + if (filename[1] == '/') + { + /* Return the concatenation of the environment variable HOME + and the rest of the string. */ + char *temp_home; + + temp_home = (char *) getenv ("HOME"); + result = (char *)xmalloc (strlen (&filename[1]) + + 1 + + temp_home ? strlen (temp_home) + : 0); + *result = '\0'; + + if (temp_home) + strcpy (result, temp_home); + + strcat (result, &filename[1]); + } + else + { + struct passwd *user_entry; + int i, c; + char *username = (char *)xmalloc (257); + + for (i = 1; c = filename[i]; i++) + { + if (c == '/') + break; + else + username[i - 1] = c; + } + if (c) + username[i - 1] = '\0'; + + user_entry = getpwnam (username); + + if (!user_entry) + return (strdup (filename)); + + result = (char *)xmalloc (1 + strlen (user_entry->pw_dir) + + strlen (&filename[i])); + strcpy (result, user_entry->pw_dir); + strcat (result, &filename[i]); + } + } + return (result); +} + +char * +output_name_from_input_name (name) + char *name; +{ + return (expand_filename ((char *)NULL, name)); +} + +/* **************************************************************** */ +/* */ +/* Error Handling */ +/* */ +/* **************************************************************** */ + +/* Number of errors encountered. */ +int errors_printed = 0; + +/* Print the last error gotten from the file system. */ +int +fs_error (filename) + char *filename; +{ + remember_error (); + perror (filename); + return (0); +} + +/* Print an error message, and return false. */ +#if defined (HAVE_VARARGS_H) && defined (HAVE_VFPRINTF) + +int +error (va_alist) + va_dcl +{ + char *format; + va_list args; + + remember_error (); + va_start (args); + format = va_arg (args, char *); + vfprintf (stderr, format, args); + va_end (args); + putc ('\n', stderr); +} + +/* Just like error (), but print the line number as well. */ +int +line_error (va_alist) + va_dcl +{ + char *format; + va_list args; + + remember_error (); + va_start (args); + format = va_arg (args, char *); + fprintf (stderr, "%s:%d: ", input_filename, line_number); + vfprintf (stderr, format, args); + fprintf (stderr, ".\n"); + va_end (args); + return ((int) 0); +} + +int +warning (va_alist) + va_dcl +{ + char *format; + va_list args; + + va_start (args); + format = va_arg (args, char *); + if (print_warnings) + { + fprintf (stderr, "%s:%d: Warning: ", input_filename, line_number); + vfprintf (stderr, format, args); + fprintf (stderr, ".\n"); + } + va_end (args); + return ((int) 0); +} + +#else /* !(HAVE_VARARGS_H && HAVE_VFPRINTF) */ + +int +error (format, arg1, arg2, arg3, arg4, arg5) + char *format; +{ + remember_error (); + fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5); + putc ('\n', stderr); + return ((int) 0); +} + +/* Just like error (), but print the line number as well. */ +int +line_error (format, arg1, arg2, arg3, arg4, arg5) + char *format; +{ + remember_error (); + fprintf (stderr, "%s:%d: ", input_filename, line_number); + fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5); + fprintf (stderr, ".\n"); + return ((int) 0); +} + +int +warning (format, arg1, arg2, arg3, arg4, arg5) + char *format; +{ + if (print_warnings) + { + fprintf (stderr, "%s:%d: Warning: ", input_filename, line_number); + fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5); + fprintf (stderr, ".\n"); + } + return ((int) 0); +} + +#endif /* !(HAVE_VARARGS_H && HAVE_VFPRINTF) */ + +/* Remember that an error has been printed. If this is the first + error printed, then tell them which program is printing them. + If more than max_error_level have been printed, then exit the + program. */ +void +remember_error () +{ + errors_printed++; + if (max_error_level && (errors_printed > max_error_level)) + { + fprintf (stderr, "Too many errors! Gave up.\n"); + flush_file_stack (); + cm_bye (); + exit (1); + } +} + +/* **************************************************************** */ +/* */ +/* Hacking Tokens and Strings */ +/* */ +/* **************************************************************** */ + +/* Return the next token as a string pointer. We cons the string. */ +char * +read_token () +{ + int i, character; + char *result; + + /* If the first character to be read is self-delimiting, then that + is the command itself. */ + character = curchar (); + if (self_delimiting (character)) + { + input_text_offset++; + + if (character == '\n') + line_number++; + + result = strdup (" "); + *result = character; + return (result); + } + + for (i = 0; ((input_text_offset != size_of_input_text) + && (character = curchar ()) + && command_char (character)); + i++, input_text_offset++); + result = (char *)xmalloc (i + 1); + memcpy (result, &input_text[input_text_offset - i], i); + result[i] = '\0'; + return (result); +} + +/* Return non-zero if CHARACTER is self-delimiting. */ +int +self_delimiting (character) + int character; +{ + /* @; and @\ are not Texinfo commands, but they are listed here + anyway. I don't know why. --karl, 10aug96. */ + return member (character, "~{|}`^\\@?=;:.-,*\'\" !\n\t"); +} + +/* Clear whitespace from the front and end of string. */ +void +canon_white (string) + char *string; +{ + int len = strlen (string); + int x; + + if (!len) + return; + + for (x = 0; x < len; x++) + { + if (!cr_or_whitespace (string[x])) + { + strcpy (string, string + x); + break; + } + } + len = strlen (string); + if (len) + len--; + while (len > -1 && cr_or_whitespace (string[len])) + len--; + string[len + 1] = '\0'; +} + +/* Bash STRING, replacing all whitespace with just one space. */ +void +fix_whitespace (string) + char *string; +{ + char *temp = (char *)xmalloc (strlen (string) + 1); + int string_index = 0; + int temp_index = 0; + int c; + + canon_white (string); + + while (string[string_index]) + { + c = temp[temp_index++] = string[string_index++]; + + if (c == ' ' || c == '\n' || c == '\t') + { + temp[temp_index - 1] = ' '; + while ((c = string[string_index]) && (c == ' ' || + c == '\t' || + c == '\n')) + string_index++; + } + } + temp[temp_index] = '\0'; + strcpy (string, temp); + free (temp); +} + +/* Discard text until the desired string is found. The string is + included in the discarded text. */ +void +discard_until (string) + char *string; +{ + int temp = search_forward (string, input_text_offset); + + int tt = (temp < 0) ? size_of_input_text : temp + strlen (string); + int from = input_text_offset; + + /* Find out what line we are on. */ + while (from != tt) + if (input_text[from++] == '\n') + line_number++; + + if (temp < 0) + { + input_text_offset = size_of_input_text - strlen (string); + + if (strcmp (string, "\n") != 0) + { + line_error ("Expected `%s'", string); + return; + } + } + else + input_text_offset = temp; + + input_text_offset += strlen (string); +} + +/* Read characters from the file until we are at MATCH. + Place the characters read into STRING. + On exit input_text_offset is after the match string. + Return the offset where the string starts. */ +int +get_until (match, string) + char *match, **string; +{ + int len, current_point, x, new_point, tem; + + current_point = x = input_text_offset; + new_point = search_forward (match, input_text_offset); + + if (new_point < 0) + new_point = size_of_input_text; + len = new_point - current_point; + + /* Keep track of which line number we are at. */ + tem = new_point + (strlen (match) - 1); + while (x != tem) + if (input_text[x++] == '\n') + line_number++; + + *string = (char *)xmalloc (len + 1); + + memcpy (*string, &input_text[current_point], len); + (*string)[len] = '\0'; + + /* Now leave input_text_offset in a consistent state. */ + input_text_offset = tem; + + if (input_text_offset > size_of_input_text) + input_text_offset = size_of_input_text; + + return (new_point); +} + +/* Read characters from the file until we are at MATCH or end of line. + Place the characters read into STRING. */ +void +get_until_in_line (match, string) + char *match, **string; +{ + int real_bottom, temp; + + real_bottom = size_of_input_text; + temp = search_forward ("\n", input_text_offset); + + if (temp < 0) + temp = size_of_input_text; + + size_of_input_text = temp; + get_until (match, string); + size_of_input_text = real_bottom; +} + +void +get_rest_of_line (string) + char **string; +{ + get_until ("\n", string); + canon_white (*string); + + if (curchar () == '\n') /* as opposed to the end of the file... */ + { + line_number++; + input_text_offset++; + } +} + +/* Backup the input pointer to the previous character, keeping track + of the current line number. */ +void +backup_input_pointer () +{ + if (input_text_offset) + { + input_text_offset--; + if (curchar () == '\n') + line_number--; + } +} + +/* Read characters from the file until we are at MATCH or closing brace. + Place the characters read into STRING. */ +void +get_until_in_braces (match, string) + char *match, **string; +{ + int i, brace = 0; + int match_len = strlen (match); + char *temp; + + for (i = input_text_offset; i < size_of_input_text; i++) + { + if (input_text[i] == '{') + brace++; + else if (input_text[i] == '}') + brace--; + else if (input_text[i] == '\n') + line_number++; + + if (brace < 0 || + (brace == 0 && strncmp (input_text + i, match, match_len) == 0)) + break; + } + + match_len = i - input_text_offset; + temp = (char *)xmalloc (2 + match_len); + strncpy (temp, input_text + input_text_offset, match_len); + temp[match_len] = '\0'; + input_text_offset = i; + *string = temp; +} + +/* **************************************************************** */ +/* */ +/* Converting the File */ +/* */ +/* **************************************************************** */ + +/* Convert the file named by NAME. The output is saved on the file + named as the argument to the @setfilename command. */ +static char *suffixes[] = { + ".texinfo", + ".texi", + ".txinfo", + "", + (char *)NULL +}; + +void +initialize_conversion () +{ + init_tag_table (); + init_indices (); + init_internals (); + init_paragraph (); + + /* This is used for splitting the output file and for doing section + headings. It was previously initialized in `init_paragraph', but its + use there loses with the `init_paragraph' calls done by the + multitable code; the tag indices get reset to zero. */ + output_position = 0; +} + +/* We read in multiples of 4k, simply because it is a typical pipe size + on unix systems. */ +#define READ_BUFFER_GROWTH (4 * 4096) + +/* Convert the texinfo file coming from the open stream STREAM. Assume the + source of the stream is named NAME. */ +void +convert_from_stream (stream, name) + FILE *stream; + char *name; +{ + char *buffer = (char *)NULL; + int buffer_offset = 0, buffer_size = 0; + + initialize_conversion (); + + /* Read until the end of the stream. This isn't strictly correct, since + the texinfo input may end before the stream ends, but it is a quick + working hueristic. */ + while (!feof (stream)) + { + int count; + + if (buffer_offset + (READ_BUFFER_GROWTH + 1) >= buffer_size) + buffer = (char *) + xrealloc (buffer, (buffer_size += READ_BUFFER_GROWTH)); + + count = fread (buffer + buffer_offset, 1, READ_BUFFER_GROWTH, stream); + + if (count < 0) + { + perror (name); + exit (FATAL); + } + + buffer_offset += count; + if (count == 0) + break; + } + + /* Set the globals to the new file. */ + input_text = buffer; + size_of_input_text = buffer_offset; + input_filename = strdup (name); + node_filename = strdup (name); + input_text_offset = 0; + line_number = 1; + + /* Not strictly necessary. This magic prevents read_token () from doing + extra unnecessary work each time it is called (that is a lot of times). + The SIZE_OF_INPUT_TEXT is one past the actual end of the text. */ + input_text[size_of_input_text] = '\n'; + + convert_from_loaded_file (name); +} + +void +convert_from_file (name) + char *name; +{ + register int i; + char *filename = (char *)xmalloc (strlen (name) + 50); + + initialize_conversion (); + + /* Try to load the file specified by NAME, concatenated with our + various suffixes. Prefer files like `makeinfo.texi' to + `makeinfo'. */ + for (i = 0; suffixes[i]; i++) + { + strcpy (filename, name); + strcat (filename, suffixes[i]); + + if (find_and_load (filename)) + break; + + if (!suffixes[i][0] && strrchr (filename, '.')) + { + fs_error (filename); + free (filename); + return; + } + } + + if (!suffixes[i]) + { + fs_error (name); + free (filename); + return; + } + + input_filename = filename; + + convert_from_loaded_file (name); +} + +void +convert_from_loaded_file (name) + char *name; +{ + char *expand_filename (), *filename_part (); + char *real_output_filename = (char *)NULL; + +#if defined (HAVE_MACROS) + remember_itext (input_text, 0); +#endif /* HAVE_MACROS */ + + /* Search this file looking for the special string which starts conversion. + Once found, we may truly begin. */ + input_text_offset = 0; + while (input_text_offset >= 0) + { + input_text_offset = + search_forward (setfilename_search, input_text_offset); + + if ((input_text_offset == 0) || + ((input_text_offset > 0) && + (input_text[input_text_offset -1] == '\n'))) + break; + else if (input_text_offset > 0) + input_text_offset++; + } + + if (input_text_offset < 0) + { + if (!command_output_filename) + { +#if defined (REQUIRE_SETFILENAME) + error ("No `%s' found in `%s'", setfilename_search, name); + goto finished; +#else + register int i, end_of_first_line; + + /* Find the end of the first line in the file. */ + for (i = 0; i < size_of_input_text - 1; i++) + if (input_text[i] == '\n') + break; + + end_of_first_line = i + 1; + + input_text_offset = 0; + + for (i = 0; i < end_of_first_line; i++) + { + if ((input_text[i] == '\\') && + (strncmp (input_text + i + 1, "include", 7) == 0)) + { + input_text_offset = end_of_first_line; + break; + } + } + command_output_filename = output_name_from_input_name (name); +#endif /* !REQUIRE_SETFILENAME */ + } + } + else + input_text_offset += strlen (setfilename_search); + + if (!command_output_filename) + get_until ("\n", &output_filename); + else + { + if (input_text_offset != -1) + discard_until ("\n"); + else + input_text_offset = 0; + + real_output_filename = output_filename = command_output_filename; + command_output_filename = (char *)NULL; + } + + canon_white (output_filename); + + if (real_output_filename && + strcmp (real_output_filename, "-") == 0) + { + real_output_filename = strdup (real_output_filename); + output_stream = stdout; + splitting = 0; /* Cannot split when writing to stdout. */ + } + else + { + if (!real_output_filename) + real_output_filename = expand_filename (output_filename, name); + else + real_output_filename = strdup (real_output_filename); + + output_stream = fopen (real_output_filename, "w"); + } + + if (output_stream != stdout) + printf ("Making %s file `%s' from `%s'.\n", + no_headers ? "text" : "info", output_filename, input_filename); + + if (output_stream == NULL) + { + fs_error (real_output_filename); + goto finished; + } + + /* Make the displayable filename from output_filename. Only the base + portion of the filename need be displayed. */ + if (output_stream != stdout) + pretty_output_filename = filename_part (output_filename); + else + pretty_output_filename = strdup ("stdout"); + + /* For this file only, count the number of newlines from the top of + the file to here. This way, we keep track of line numbers for + error reporting. Line_number starts at 1, since the user isn't + zero-based. */ + { + int temp = 0; + line_number = 1; + while (temp != input_text_offset) + if (input_text[temp++] == '\n') + line_number++; + } + + if (!no_headers) + { + add_word_args ("This is Info file %s, produced by Makeinfo version %d.%d", + output_filename, major_version, minor_version); + add_word_args (" from the input file %s.\n", input_filename); + } + + close_paragraph (); + reader_loop (); + +finished: + close_paragraph (); + flush_file_stack (); + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + fclose (macro_expansion_output_stream); +#endif /* HAVE_MACROS */ + + if (output_stream != NULL) + { + output_pending_notes (); + free_pending_notes (); + if (tag_table != NULL) + { + tag_table = (TAG_ENTRY *) reverse_list (tag_table); + if (!no_headers) + write_tag_table (); + } + + if (output_stream != stdout) + fclose (output_stream); + + /* If validating, then validate the entire file right now. */ + if (validating) + validate_file (tag_table); + + /* This used to test && !errors_printed. + But some files might have legit warnings. So split anyway. */ + if (splitting) + split_file (real_output_filename, 0); + } + free (real_output_filename); +} + +void +free_and_clear (pointer) + char **pointer; +{ + if ((*pointer) != (char *) NULL) + { + free (*pointer); + *pointer = (char *) NULL; + } +} + + /* Initialize some state. */ +void +init_internals () +{ + free_and_clear (¤t_node); + free_and_clear (&output_filename); + free_and_clear (&command); + free_and_clear (&input_filename); + free_node_references (); + init_insertion_stack (); + init_brace_stack (); + command_index = 0; + in_menu = 0; + in_detailmenu = 0; + top_node_seen = 0; + non_top_node_seen = 0; +} + +void +init_paragraph () +{ + free_and_clear (&output_paragraph); + output_paragraph = (unsigned char *)xmalloc (paragraph_buffer_len); + output_paragraph[0] = '\0'; + output_paragraph_offset = 0; + output_column = 0; + paragraph_is_open = 0; + current_indent = 0; +} + +/* Okay, we are ready to start the conversion. Call the reader on + some text, and fill the text as it is output. Handle commands by + remembering things like open braces and the current file position on a + stack, and when the corresponding close brace is found, you can call + the function with the proper arguments. */ +void +reader_loop () +{ + int character; + int done = 0; + int dash_count = 0; + + while (!done) + { + if (input_text_offset >= size_of_input_text) + break; + + character = curchar (); + + if (!in_fixed_width_font && + (character == '\'' || character == '`') && + input_text[input_text_offset + 1] == character) + { + input_text_offset++; + character = '"'; + } + + if (character == '-') + { + dash_count++; + if (dash_count == 2 && !in_fixed_width_font) + { + input_text_offset++; + continue; + } + } + else + { + dash_count = 0; + } + + /* If this is a whitespace character, then check to see if the line + is blank. If so, advance to the carriage return. */ + if (whitespace (character)) + { + register int i = input_text_offset + 1; + + while (i < size_of_input_text && whitespace (input_text[i])) + i++; + + if (i == size_of_input_text || input_text[i] == '\n') + { + if (i == size_of_input_text) + i--; + + input_text_offset = i; + character = curchar (); + } + } + + if (character == '\n') + { + line_number++; + + /* Check for a menu entry here, since the "escape sequence" + that begins menu entries is "\n* ". */ + if (in_menu && input_text_offset + 1 < size_of_input_text) + { + char *glean_node_from_menu (), *tem; + + /* Note that the value of TEM is discarded, since it is + gauranteed to be NULL when glean_node_from_menu () is + called with a non-zero argument. */ + if (!in_detailmenu) + tem = glean_node_from_menu (1); + } + } + + switch (character) + { + case COMMAND_PREFIX: + read_command (); + break; + + case '{': + + /* Special case. I'm not supposed to see this character by itself. + If I do, it means there is a syntax error in the input text. + Report the error here, but remember this brace on the stack so + you can ignore its partner. */ + + line_error ("Misplaced `{'"); + remember_brace (misplaced_brace); + + /* Don't advance input_text_offset since this happens in + remember_brace (). + input_text_offset++; + */ + break; + + case '}': + pop_and_call_brace (); + input_text_offset++; + break; + + default: + add_char (character); + input_text_offset++; + } + } +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + maybe_write_itext (input_text, input_text_offset); +#endif /* HAVE_MACROS */ +} + +/* Find the command corresponding to STRING. If the command + is found, return a pointer to the data structure. Otherwise + return (-1). */ +COMMAND * +get_command_entry (string) + char *string; +{ + register int i; + + for (i = 0; CommandTable[i].name; i++) + if (strcmp (CommandTable[i].name, string) == 0) + return (&CommandTable[i]); + + /* This command is not in our predefined command table. Perhaps + it is a user defined command. */ + for (i = 0; i < user_command_array_len; i++) + if (user_command_array[i] && + (strcmp (user_command_array[i]->name, string) == 0)) + return (user_command_array[i]); + + /* Nope, we never heard of this command. */ + return ((COMMAND *) -1); +} + +/* input_text_offset is right at the command prefix character. + Read the next token to determine what to do. */ +void +read_command () +{ + COMMAND *entry; + + input_text_offset++; + free_and_clear (&command); + command = read_token (); + +#if defined (HAVE_MACROS) + /* Check to see if this command is a macro. If so, execute it here. */ + { + MACRO_DEF *def; + + def = find_macro (command); + + if (def) + { + /* We disallow recursive use of a macro call. Inhibit the expansion + of this macro during the life of its execution. */ + if (!(def->flags & ME_RECURSE)) + def->inhibited = 1; + + execute_macro (def); + + if (!(def->flags & ME_RECURSE)) + def->inhibited = 0; + + return; + } + } +#endif /* HAVE_MACROS */ + + entry = get_command_entry (command); + + if (entry == (COMMAND *)-1) + { + line_error ("Unknown command `%s'", command); + return; + } + + if (entry->argument_in_braces) + remember_brace (entry->proc); + + (*(entry->proc)) (START, output_paragraph_offset, 0); +} + +/* Return the string which invokes PROC; a pointer to a function. */ +char * +find_proc_name (proc) + COMMAND_FUNCTION *proc; +{ + register int i; + + for (i = 0; CommandTable[i].name; i++) + if (proc == CommandTable[i].proc) + return (CommandTable[i].name); + return ("NO_NAME!"); +} + +void +init_brace_stack () +{ + brace_stack = (BRACE_ELEMENT *) NULL; +} + +void +remember_brace (proc) + COMMAND_FUNCTION *proc; +{ + if (curchar () != '{') + line_error ("%c%s expected `{..}'", COMMAND_PREFIX, command); + else + input_text_offset++; + remember_brace_1 (proc, output_paragraph_offset); +} + +/* Remember the current output position here. Save PROC + along with it so you can call it later. */ +void +remember_brace_1 (proc, position) + COMMAND_FUNCTION *proc; + int position; +{ + BRACE_ELEMENT *new = (BRACE_ELEMENT *) xmalloc (sizeof (BRACE_ELEMENT)); + new->next = brace_stack; + new->proc = proc; + new->pos = position; + new->line = line_number; + new->in_fixed_width_font = in_fixed_width_font; + brace_stack = new; +} + +/* Pop the top of the brace stack, and call the associated function + with the args END and POS. */ +void +pop_and_call_brace () +{ + BRACE_ELEMENT *temp; + COMMAND_FUNCTION *proc; + int pos; + + if (brace_stack == (BRACE_ELEMENT *) NULL) + { + line_error ("Unmatched }"); + return; + } + + pos = brace_stack->pos; + proc = brace_stack->proc; + in_fixed_width_font = brace_stack->in_fixed_width_font; + temp = brace_stack->next; + free (brace_stack); + brace_stack = temp; + + (*proc) (END, pos, output_paragraph_offset); +} + +/* Shift all of the markers in `brace_stack' by AMOUNT. */ +void +adjust_braces_following (here, amount) + int here, amount; +{ + register BRACE_ELEMENT *stack = brace_stack; + + while (stack) + { + if (stack->pos >= here) + stack->pos += amount; + stack = stack->next; + } +} + +/* You call discard_braces () when you shouldn't have any braces on the stack. + I used to think that this happens for commands that don't take arguments + in braces, but that was wrong because of things like @code{foo @@}. So now + I only detect it at the beginning of nodes. */ +void +discard_braces () +{ + if (!brace_stack) + return; + + while (brace_stack) + { + if (brace_stack->proc != misplaced_brace) + { + char *proc_name; + int temp_line_number = line_number; + + line_number = brace_stack->line; + proc_name = find_proc_name (brace_stack->proc); + line_error ("%c%s missing close brace", COMMAND_PREFIX, proc_name); + line_number = temp_line_number; + pop_and_call_brace (); + } + else + { + BRACE_ELEMENT *temp; + temp = brace_stack->next; + free (brace_stack); + brace_stack = temp; + } + } +} + +int +get_char_len (character) + int character; +{ + /* Return the printed length of the character. */ + int len; + + switch (character) + { + case '\t': + len = (output_column + 8) & 0xf7; + if (len > fill_column) + len = fill_column - output_column; + else + len = len - output_column; + break; + + case '\n': + len = fill_column - output_column; + break; + + default: + if (character < ' ') + len = 2; + else + len = 1; + } + return (len); +} + +#if defined (HAVE_VARARGS_H) && defined (HAVE_VSPRINTF) + +void +add_word_args (va_alist) + va_dcl +{ + char buffer[1000]; + char *format; + va_list args; + + va_start (args); + format = va_arg (args, char *); + vsprintf (buffer, format, args); + va_end (args); + add_word (buffer); +} + +#else /* !(HAVE_VARARGS_H && HAVE_VSPRINTF) */ + +void +add_word_args (format, arg1, arg2, arg3, arg4, arg5) + char *format; +{ + char buffer[1000]; + sprintf (buffer, format, arg1, arg2, arg3, arg4, arg5); + add_word (buffer); +} + +#endif /* !(HAVE_VARARGS_H && HAVE_VSPRINTF) */ + +/* Add STRING to output_paragraph. */ +void +add_word (string) + char *string; +{ + while (*string) + add_char (*string++); +} + +/* Non-zero if the last character inserted has the syntax class of NEWLINE. */ +int last_char_was_newline = 1; + +/* The actual last inserted character. Note that this may be something + other than NEWLINE even if last_char_was_newline is 1. */ +int last_inserted_character = 0; + +/* Non-zero means that a newline character has already been + inserted, so close_paragraph () should insert one less. */ +int line_already_broken = 0; + +/* When non-zero we have finished an insertion (see end_insertion ()) and we + want to ignore false continued paragraph closings. */ +int insertion_paragraph_closed = 0; + +/* Non-zero means attempt to make all of the lines have fill_column width. */ +int do_justification = 0; + +/* Add the character to the current paragraph. If filling_enabled is + non-zero, then do filling as well. */ +void +add_char (character) + int character; +{ + /* If we are avoiding outputting headers, and we are currently + in a menu, then simply return. */ + if (no_headers && (in_menu || in_detailmenu)) + return; + + /* If we are adding a character now, then we don't have to + ignore close_paragraph () calls any more. */ + if (must_start_paragraph && character != '\n') + { + must_start_paragraph = 0; + line_already_broken = 0; /* The line is no longer broken. */ + if (current_indent > output_column) + { + indent (current_indent - output_column); + output_column = current_indent; + } + } + + if (non_splitting_words && member (character, " \t\n")) + character = ' ' | 0x80; + + insertion_paragraph_closed = 0; + + switch (character) + { + case '\n': + if (!filling_enabled) + { + insert ('\n'); + + if (force_flush_right) + { + close_paragraph (); + /* Hack to force single blank lines out in this mode. */ + flush_output (); + } + + output_column = 0; + + if (!no_indent && paragraph_is_open) + indent (output_column = current_indent); + break; + } + else /* CHARACTER is newline, and filling is enabled. */ + { + if (sentence_ender (last_inserted_character)) + { + insert (' '); + output_column++; + last_inserted_character = character; + } + } + + if (last_char_was_newline) + { + close_paragraph (); + pending_indent = 0; + } + else + { + last_char_was_newline = 1; + insert (' '); + output_column++; + } + break; + + default: + { + int len = get_char_len (character); + int suppress_insert = 0; + + if ((character == ' ') && (last_char_was_newline)) + { + if (!paragraph_is_open) + { + pending_indent++; + return; + } + } + + if (!paragraph_is_open) + { + start_paragraph (); + + /* If the paragraph is supposed to be indented a certain way, + then discard all of the pending whitespace. Otherwise, we + let the whitespace stay. */ + if (!paragraph_start_indent) + indent (pending_indent); + pending_indent = 0; + } + + if ((output_column += len) > fill_column) + { + if (filling_enabled) + { + int temp = output_paragraph_offset; + while (--temp > 0 && output_paragraph[temp] != '\n') + { + /* If we have found a space, we have the place to break + the line. */ + if (output_paragraph[temp] == ' ') + { + /* Remove trailing whitespace from output. */ + while (temp && whitespace (output_paragraph[temp - 1])) + temp--; + + output_paragraph[temp++] = '\n'; + + /* We have correctly broken the line where we want + to. What we don't want is spaces following where + we have decided to break the line. We get rid of + them. */ + { + int t1 = temp; + + for (;; t1++) + { + if (t1 == output_paragraph_offset) + { + if (whitespace (character)) + suppress_insert = 1; + break; + } + if (!whitespace (output_paragraph[t1])) + break; + } + + if (t1 != temp) + { + adjust_braces_following (temp, (- (t1 - temp))); + strncpy ((char *) &output_paragraph[temp], + (char *) &output_paragraph[t1], + (output_paragraph_offset - t1)); + output_paragraph_offset -= (t1 - temp); + } + } + + /* Filled, but now indent if that is right. */ + if (indented_fill && current_indent) + { + int buffer_len = ((output_paragraph_offset - temp) + + current_indent); + char *temp_buffer = (char *)xmalloc (buffer_len); + int indentation = 0; + + /* We have to shift any markers that are in + front of the wrap point. */ + adjust_braces_following (temp, current_indent); + + while (current_indent > 0 && + indentation != current_indent) + temp_buffer[indentation++] = ' '; + + strncpy ((char *) &temp_buffer[current_indent], + (char *) &output_paragraph[temp], + buffer_len - current_indent); + + if (output_paragraph_offset + buffer_len + >= paragraph_buffer_len) + { + unsigned char *tt = xrealloc + (output_paragraph, + (paragraph_buffer_len += buffer_len)); + output_paragraph = tt; + } + strncpy ((char *) &output_paragraph[temp], + temp_buffer, buffer_len); + output_paragraph_offset += current_indent; + free (temp_buffer); + } + output_column = 0; + while (temp < output_paragraph_offset) + output_column += + get_char_len (output_paragraph[temp++]); + output_column += len; + break; + } + } + } + } + + if (!suppress_insert) + { + insert (character); + last_inserted_character = character; + } + last_char_was_newline = 0; + line_already_broken = 0; + } + } +} + +/* Insert CHARACTER into `output_paragraph'. */ +void +insert (character) + int character; +{ + output_paragraph[output_paragraph_offset++] = character; + if (output_paragraph_offset == paragraph_buffer_len) + { + output_paragraph = + xrealloc (output_paragraph, (paragraph_buffer_len += 100)); + } +} + +/* Insert the null-terminated string STRING into `output_paragraph'. */ +void +insert_string (string) + char *string; +{ + while (*string) + insert (*string++); +} + +/* Remove upto COUNT characters of whitespace from the + the current output line. If COUNT is less than zero, + then remove until none left. */ +void +kill_self_indent (count) + int count; +{ + /* Handle infinite case first. */ + if (count < 0) + { + output_column = 0; + while (output_paragraph_offset) + { + if (whitespace (output_paragraph[output_paragraph_offset - 1])) + output_paragraph_offset--; + else + break; + } + } + else + { + while (output_paragraph_offset && count--) + if (whitespace (output_paragraph[output_paragraph_offset - 1])) + output_paragraph_offset--; + else + break; + } +} + +/* Non-zero means do not honor calls to flush_output (). */ +static int flushing_ignored = 0; + +/* Prevent calls to flush_output () from having any effect. */ +void +inhibit_output_flushing () +{ + flushing_ignored++; +} + +/* Allow calls to flush_output () to write the paragraph data. */ +void +uninhibit_output_flushing () +{ + flushing_ignored--; +} + +void +flush_output () +{ + register int i; + + if (!output_paragraph_offset || flushing_ignored) + return; + + for (i = 0; i < output_paragraph_offset; i++) + { + /* If we turned on the 8th bit for a space + inside @w, turn it back off for output. */ + if (output_paragraph[i] & meta_character_bit) + { + int temp = UNMETA (output_paragraph[i]); + if (temp == ' ') + output_paragraph[i] &= 0x7f; + } + } + + fwrite (output_paragraph, 1, output_paragraph_offset, output_stream); + + output_position += output_paragraph_offset; + output_paragraph_offset = 0; +} + +/* How to close a paragraph controlling the number of lines between + this one and the last one. */ + +/* Paragraph spacing is controlled by this variable. It is the number of + blank lines that you wish to appear between paragraphs. A value of + 1 creates a single blank line between paragraphs. */ +int paragraph_spacing = DEFAULT_PARAGRAPH_SPACING; + +/* Close the current paragraph, leaving no blank lines between them. */ +void +close_single_paragraph () +{ + close_paragraph_with_lines (0); +} + +/* Close a paragraph after an insertion has ended. */ +void +close_insertion_paragraph () +{ + if (!insertion_paragraph_closed) + { + /* Close the current paragraph, breaking the line. */ + close_single_paragraph (); + + /* Start a new paragraph here, inserting whatever indention is correct + for the now current insertion level (one above the one that we are + ending). */ + start_paragraph (); + + /* Tell close_paragraph () that the previous line has already been + broken, so it should insert one less newline. */ + line_already_broken = 1; + + /* Let functions such as add_char () know that we have already found a + newline. */ + ignore_blank_line (); + } + else + { + /* If the insertion paragraph is closed already, then we are seeing + two `@end' commands in a row. Note that the first one we saw was + handled in the first part of this if-then-else clause, and at that + time start_paragraph () was called, partially to handle the proper + indentation of the current line. However, the indentation level + may have just changed again, so we may have to outdent the current + line to the new indentation level. */ + if (current_indent < output_column) + kill_self_indent (output_column - current_indent); + } + + insertion_paragraph_closed = 1; +} + +void +close_paragraph_with_lines (lines) + int lines; +{ + int old_spacing = paragraph_spacing; + paragraph_spacing = lines; + close_paragraph (); + paragraph_spacing = old_spacing; +} + +/* Close the currently open paragraph. */ +void +close_paragraph () +{ + register int i; + + /* The insertion paragraph is no longer closed. */ + insertion_paragraph_closed = 0; + + if (paragraph_is_open && !must_start_paragraph) + { + register int tindex, c; + + tindex = output_paragraph_offset; + + /* Back up to last non-newline/space character, forcing all such + subsequent characters to be newlines. This isn't strictly + necessary, but a couple of functions use the presence of a newline + to make decisions. */ + for (tindex = output_paragraph_offset - 1; tindex >= 0; --tindex) + { + c = output_paragraph[tindex]; + + if (c == ' '|| c == '\n') + output_paragraph[tindex] = '\n'; + else + break; + } + + /* All trailing whitespace is ignored. */ + output_paragraph_offset = ++tindex; + + /* Break the line if that is appropriate. */ + if (paragraph_spacing >= 0) + insert ('\n'); + + /* Add as many blank lines as is specified in PARAGRAPH_SPACING. */ + if (!force_flush_right) + { + for (i = 0; i < (paragraph_spacing - line_already_broken); i++) + insert ('\n'); + } + + /* If we are doing flush right indentation, then do it now + on the paragraph (really a single line). */ + if (force_flush_right) + do_flush_right_indentation (); + + flush_output (); + paragraph_is_open = 0; + no_indent = 0; + output_column = 0; + } + ignore_blank_line (); +} + +/* Make the last line just read look as if it were only a newline. */ +void +ignore_blank_line () +{ + last_inserted_character = '\n'; + last_char_was_newline = 1; +} + +/* Align the end of the text in output_paragraph with fill_column. */ +void +do_flush_right_indentation () +{ + char *temp; + int temp_len; + + kill_self_indent (-1); + + if (output_paragraph[0] != '\n') + { + output_paragraph[output_paragraph_offset] = '\0'; + + if (output_paragraph_offset < fill_column) + { + register int i; + + if (fill_column >= paragraph_buffer_len) + output_paragraph = + xrealloc (output_paragraph, + (paragraph_buffer_len += fill_column)); + + temp_len = strlen ((char *)output_paragraph); + temp = (char *)xmalloc (temp_len + 1); + memcpy (temp, (char *)output_paragraph, temp_len); + + for (i = 0; i < fill_column - output_paragraph_offset; i++) + output_paragraph[i] = ' '; + + memcpy ((char *)output_paragraph + i, temp, temp_len); + free (temp); + output_paragraph_offset = fill_column; + } + } +} + +/* Begin a new paragraph. */ +void +start_paragraph () +{ + /* First close existing one. */ + if (paragraph_is_open) + close_paragraph (); + + /* In either case, the insertion paragraph is no longer closed. */ + insertion_paragraph_closed = 0; + + /* However, the paragraph is open! */ + paragraph_is_open = 1; + + /* If we MUST_START_PARAGRAPH, that simply means that start_paragraph () + had to be called before we would allow any other paragraph operations + to have an effect. */ + if (!must_start_paragraph) + { + int amount_to_indent = 0; + + /* If doing indentation, then insert the appropriate amount. */ + if (!no_indent) + { + if (inhibit_paragraph_indentation) + { + amount_to_indent = current_indent; + if (inhibit_paragraph_indentation < 0) + inhibit_paragraph_indentation++; + } + else if (paragraph_start_indent < 0) + amount_to_indent = current_indent; + else + amount_to_indent = current_indent + paragraph_start_indent; + + if (amount_to_indent >= output_column) + { + amount_to_indent -= output_column; + indent (amount_to_indent); + output_column += amount_to_indent; + } + } + } + else + must_start_paragraph = 0; +} + +/* Insert the indentation specified by AMOUNT. */ +void +indent (amount) + int amount; +{ + register BRACE_ELEMENT *elt = brace_stack; + + /* For every START_POS saved within the brace stack which will be affected + by this indentation, bump that start pos forward. */ + while (elt) + { + if (elt->pos >= output_paragraph_offset) + elt->pos += amount; + elt = elt->next; + } + + while (--amount >= 0) + insert (' '); +} + +/* Search forward for STRING in input_text. + FROM says where where to start. */ +int +search_forward (string, from) + char *string; + int from; +{ + int len = strlen (string); + + while (from < size_of_input_text) + { + if (strncmp (input_text + from, string, len) == 0) + return (from); + from++; + } + return (-1); +} + +/* Whoops, Unix doesn't have strcasecmp. */ + +/* Case independent string compare. */ +#if !defined (HAVE_STRCASECMP) +int +strcasecmp (string1, string2) + char *string1, *string2; +{ + char ch1, ch2; + + for (;;) + { + ch1 = *string1++; + ch2 = *string2++; + + if (!(ch1 | ch2)) + return (0); + + ch1 = coerce_to_upper (ch1); + ch2 = coerce_to_upper (ch2); + + if (ch1 != ch2) + return (ch1 - ch2); + } +} +#endif /* !HAVE_STRCASECMP */ + +void +init_insertion_stack () +{ + insertion_stack = (INSERTION_ELT *) NULL; +} + +/* Return the type of the current insertion. */ +enum insertion_type +current_insertion_type () +{ + if (!insertion_level) + return (bad_type); + else + return (insertion_stack->insertion); +} + +/* Return a pointer to the string which is the function to wrap around + items. */ +char * +current_item_function () +{ + register int level, done; + register INSERTION_ELT *elt; + + level = insertion_level; + elt = insertion_stack; + done = 0; + + /* Skip down through the stack until we find a non-conditional insertion. */ + while (!done && (elt != NULL)) + { + switch (elt->insertion) + { + case ifinfo: + case ifset: + case ifclear: + case cartouche: + elt = elt->next; + level--; + break; + + default: + done = 1; + } + } + + if (!level) + return ((char *) NULL); + else + return (elt->item_function); +} + +char * +get_item_function () +{ + char *item_function; + get_rest_of_line (&item_function); + backup_input_pointer (); + canon_white (item_function); + return (item_function); +} + + /* Push the state of the current insertion on the stack. */ +void +push_insertion (type, item_function) + enum insertion_type type; + char *item_function; +{ + INSERTION_ELT *new = (INSERTION_ELT *) xmalloc (sizeof (INSERTION_ELT)); + + new->item_function = item_function; + new->filling_enabled = filling_enabled; + new->indented_fill = indented_fill; + new->insertion = type; + new->line_number = line_number; + new->filename = strdup (input_filename); + new->inhibited = inhibit_paragraph_indentation; + new->in_fixed_width_font = in_fixed_width_font; + new->next = insertion_stack; + insertion_stack = new; + insertion_level++; +} + + /* Pop the value on top of the insertion stack into the + global variables. */ +void +pop_insertion () +{ + INSERTION_ELT *temp = insertion_stack; + + if (temp == (INSERTION_ELT *) NULL) + return; + + in_fixed_width_font = temp->in_fixed_width_font; + inhibit_paragraph_indentation = temp->inhibited; + filling_enabled = temp->filling_enabled; + indented_fill = temp->indented_fill; + free_and_clear (&(temp->item_function)); + free_and_clear (&(temp->filename)); + insertion_stack = insertion_stack->next; + free (temp); + insertion_level--; +} + + /* Return a pointer to the print name of this + enumerated type. */ +char * +insertion_type_pname (type) + enum insertion_type type; +{ + if ((int) type < (int) bad_type) + return (insertion_type_names[(int) type]); + else + return ("Broken-Type in insertion_type_pname"); +} + +/* Return the insertion_type associated with NAME. + If the type is not one of the known ones, return BAD_TYPE. */ +enum insertion_type +find_type_from_name (name) + char *name; +{ + int index = 0; + while (index < (int) bad_type) + { + if (strcmp (name, insertion_type_names[index]) == 0) + return (enum insertion_type) index; + index++; + } + return (bad_type); +} + +int +defun_insertion (type) + enum insertion_type type; +{ + return + ((type == deffn) + || (type == defun) + || (type == defmac) + || (type == defspec) + || (type == defvr) + || (type == defvar) + || (type == defopt) + || (type == deftypefn) + || (type == deftypefun) + || (type == deftypevr) + || (type == deftypevar) + || (type == defcv) + || (type == defivar) + || (type == defop) + || (type == defmethod) + || (type == deftypemethod) + || (type == deftp)); +} + +/* MAX_NS is the maximum nesting level for enumerations. I picked 100 + which seemed reasonable. This doesn't control the number of items, + just the number of nested lists. */ +#define max_stack_depth 100 +#define ENUM_DIGITS 1 +#define ENUM_ALPHA 2 +typedef struct { + int enumtype; + int enumval; +} DIGIT_ALPHA; + +DIGIT_ALPHA enumstack[max_stack_depth]; +int enumstack_offset = 0; +int current_enumval = 1; +int current_enumtype = ENUM_DIGITS; +char *enumeration_arg = (char *)NULL; + +void +start_enumerating (at, type) + int at, type; +{ + if ((enumstack_offset + 1) == max_stack_depth) + { + line_error ("Enumeration stack overflow"); + return; + } + enumstack[enumstack_offset].enumtype = current_enumtype; + enumstack[enumstack_offset].enumval = current_enumval; + enumstack_offset++; + current_enumval = at; + current_enumtype = type; +} + +void +stop_enumerating () +{ + --enumstack_offset; + if (enumstack_offset < 0) + enumstack_offset = 0; + + current_enumval = enumstack[enumstack_offset].enumval; + current_enumtype = enumstack[enumstack_offset].enumtype; +} + +/* Place a letter or digits into the output stream. */ +void +enumerate_item () +{ + char temp[10]; + + if (current_enumtype == ENUM_ALPHA) + { + if (current_enumval == ('z' + 1) || current_enumval == ('Z' + 1)) + { + current_enumval = ((current_enumval - 1) == 'z' ? 'a' : 'A'); + warning ("Lettering overflow, restarting at %c", current_enumval); + } + sprintf (temp, "%c. ", current_enumval); + } + else + sprintf (temp, "%d. ", current_enumval); + + indent (output_column += (current_indent - strlen (temp))); + add_word (temp); + current_enumval++; +} + +/* This is where the work for all the "insertion" style + commands is done. A huge switch statement handles the + various setups, and generic code is on both sides. */ +void +begin_insertion (type) + enum insertion_type type; +{ + int no_discard = 0; + + if (defun_insertion (type)) + { + push_insertion (type, strdup ("")); + no_discard++; + } + else + push_insertion (type, get_item_function ()); + + switch (type) + { + case menu: + if (!no_headers) + close_paragraph (); + + filling_enabled = no_indent = 0; + inhibit_paragraph_indentation = 1; + + if (!no_headers) + add_word ("* Menu:\n"); + + in_menu++; + no_discard++; + break; + + case detailmenu: + + if (!in_menu) + { + if (!no_headers) + close_paragraph (); + + filling_enabled = no_indent = 0; + inhibit_paragraph_indentation = 1; + + no_discard++; + } + + in_detailmenu++; + break; + + case direntry: + close_single_paragraph (); + filling_enabled = no_indent = 0; + inhibit_paragraph_indentation = 1; + insert_string ("START-INFO-DIR-ENTRY\n"); + break; + + /* I think @quotation is meant to do filling. + If you don't want filling, then use @display. */ + case quotation: + close_single_paragraph (); + last_char_was_newline = no_indent = 0; + indented_fill = filling_enabled = 1; + inhibit_paragraph_indentation = 1; + current_indent += default_indentation_increment; + break; + + case display: + case example: + case smallexample: + case lisp: + case smalllisp: + /* Just like @example, but no indentation. */ + case format: + + close_single_paragraph (); + inhibit_paragraph_indentation = 1; + in_fixed_width_font++; + filling_enabled = 0; + last_char_was_newline = 0; + + if (type != format) + current_indent += default_indentation_increment; + + break; + + case multitable: + do_multitable (); + break; + + case table: + case ftable: + case vtable: + case itemize: + close_single_paragraph (); + current_indent += default_indentation_increment; + filling_enabled = indented_fill = 1; +#if defined (INDENT_PARAGRAPHS_IN_TABLE) + inhibit_paragraph_indentation = 0; +#else + inhibit_paragraph_indentation = 1; +#endif /* !INDENT_PARAGRAPHS_IN_TABLE */ + + /* Make things work for losers who forget the itemize syntax. */ + if (allow_lax_format && (type == itemize)) + { + if (!(*insertion_stack->item_function)) + { + free (insertion_stack->item_function); + insertion_stack->item_function = strdup ("@bullet"); + insertion_stack->item_function[0] = COMMAND_PREFIX; + } + } + + if (!*insertion_stack->item_function) + { + line_error ("%s requires an argument: the formatter for %citem", + insertion_type_pname (type), COMMAND_PREFIX); + } + break; + + case enumerate: + close_single_paragraph (); + no_indent = 0; +#if defined (INDENT_PARAGRAPHS_IN_TABLE) + inhibit_paragraph_indentation = 0; +#else + inhibit_paragraph_indentation = 1; +#endif /* !INDENT_PARAGRAPHS_IN_TABLE */ + + current_indent += default_indentation_increment; + filling_enabled = indented_fill = 1; + + if (isdigit (*enumeration_arg)) + start_enumerating (atoi (enumeration_arg), ENUM_DIGITS); + else + start_enumerating (*enumeration_arg, ENUM_ALPHA); + break; + + /* Does nothing special in makeinfo. */ + case group: + /* Only close the paragraph if we are not inside of an @example. */ + if (!insertion_stack->next || + insertion_stack->next->insertion != example) + close_single_paragraph (); + break; + + /* Insertions that are no-ops in info, but do something in TeX. */ + case ifinfo: + case ifset: + case ifclear: + case cartouche: + if (in_menu) + no_discard++; + break; + + case deffn: + case defun: + case defmac: + case defspec: + case defvr: + case defvar: + case defopt: + case deftypefn: + case deftypefun: + case deftypevr: + case deftypevar: + case defcv: + case defivar: + case defop: + case defmethod: + case deftypemethod: + case deftp: + inhibit_paragraph_indentation = 1; + filling_enabled = indented_fill = 1; + current_indent += default_indentation_increment; + no_indent = 0; + break; + + case flushleft: + close_single_paragraph (); + inhibit_paragraph_indentation = 1; + filling_enabled = indented_fill = no_indent = 0; + break; + + case flushright: + close_single_paragraph (); + filling_enabled = indented_fill = no_indent = 0; + inhibit_paragraph_indentation = 1; + force_flush_right++; + break; + } + + if (!no_discard) + discard_until ("\n"); +} + +/* Try to end the insertion with the specified TYPE. + TYPE, with a value of bad_type, gets translated to match + the value currently on top of the stack. + Otherwise, if TYPE doesn't match the top of the insertion stack, + give error. */ +void +end_insertion (type) + enum insertion_type type; +{ + enum insertion_type temp_type; + + if (!insertion_level) + return; + + temp_type = current_insertion_type (); + + if (type == bad_type) + type = temp_type; + + if (type != temp_type) + { + line_error + ("`%cend' expected `%s', but saw `%s'", COMMAND_PREFIX, + insertion_type_pname (temp_type), insertion_type_pname (type)); + return; + } + + pop_insertion (); + + switch (type) + { + /* Insertions which have no effect on paragraph formatting. */ + case ifinfo: + case ifset: + case ifclear: + break; + + case direntry: + insert_string ("END-INFO-DIR-ENTRY\n\n"); + close_insertion_paragraph (); + break; + + case detailmenu: + in_detailmenu--; /* No longer hacking menus. */ + if (!in_menu) + { + if (!no_headers) + close_insertion_paragraph (); + } + break; + + case menu: + in_menu--; /* No longer hacking menus. */ + if (!no_headers) + close_insertion_paragraph (); + break; + + case multitable: + end_multitable (); + break; + + case enumerate: + stop_enumerating (); + close_insertion_paragraph (); + current_indent -= default_indentation_increment; + break; + + case flushleft: + case group: + case cartouche: + close_insertion_paragraph (); + break; + + case format: + case display: + case example: + case smallexample: + case lisp: + case smalllisp: + case quotation: + + /* @format is the only fixed_width insertion without a change + in indentation. */ + if (type != format) + current_indent -= default_indentation_increment; + + /* The ending of one of these insertions always marks the + start of a new paragraph. */ + close_insertion_paragraph (); + break; + + case table: + case ftable: + case vtable: + case itemize: + current_indent -= default_indentation_increment; + break; + + case flushright: + force_flush_right--; + close_insertion_paragraph (); + break; + + /* Handle the @defun style insertions with a default clause. */ + default: + current_indent -= default_indentation_increment; + close_insertion_paragraph (); + break; + } +} + +/* Insertions cannot cross certain boundaries, such as node beginnings. In + code that creates such boundaries, you should call discard_insertions () + before doing anything else. It prints the errors for you, and cleans up + the insertion stack. */ +void +discard_insertions () +{ + int real_line_number = line_number; + while (insertion_stack) + { + if (insertion_stack->insertion == ifinfo || + insertion_stack->insertion == ifset || + insertion_stack->insertion == ifclear) + break; + else + { + char *offender; + char *current_filename; + + current_filename = input_filename; + offender = (char *)insertion_type_pname (insertion_stack->insertion); + input_filename = insertion_stack->filename; + line_number = insertion_stack->line_number; + line_error ("This `%s' doesn't have a matching `%cend %s'", offender, + COMMAND_PREFIX, offender); + input_filename = current_filename; + pop_insertion (); + } + } + line_number = real_line_number; +} + +/* The Texinfo commands. */ + +/* Commands which insert their own names. */ +void +insert_self (arg) + int arg; +{ + if (arg == START) + add_word (command); +} + +void +insert_space (arg) + int arg; +{ + if (arg == START) + add_char (' '); +} + +/* Force a line break in the output. */ +void +cm_asterisk () +{ + close_single_paragraph (); +#if !defined (ASTERISK_NEW_PARAGRAPH) + cm_noindent (); +#endif /* ASTERISK_NEW_PARAGRAPH */ +} + +/* Insert ellipsis. */ +void +cm_dots (arg) + int arg; +{ + if (arg == START) + add_word ("..."); +} + +/* Insert ellipsis for sentence end. */ +void +cm_enddots (arg) + int arg; +{ + if (arg == START) + add_word ("...."); +} + +void +cm_bullet (arg) + int arg; +{ + if (arg == START) + add_char ('*'); +} + +void +cm_minus (arg) + int arg; +{ + if (arg == START) + add_char ('-'); +} + +/* Insert "TeX". */ +void +cm_TeX (arg) + int arg; +{ + if (arg == START) + add_word ("TeX"); +} + +/* Copyright symbol. */ +void +cm_copyright (arg) + int arg; +{ + if (arg == START) + add_word ("(C)"); +} + +/* Accent commands that take explicit arguments. */ +void +cm_accent (arg) + int arg; +{ + if (arg == START) + { + if (strcmp (command, "dotaccent") == 0) /* overdot */ + add_char ('.'); + else if (strcmp (command, "H") == 0) /* Hungarian umlaut */ + add_word ("''"); + else if (strcmp (command, "ringaccent") == 0) + add_char ('*'); + else if (strcmp (command, "tieaccent") == 0) + add_char ('['); + else if (strcmp (command, "u") == 0) /* breve */ + add_char ('('); + else if (strcmp (command, "v") == 0) /* hacek/check */ + add_char ('<'); + } + else if (arg == END) + { + if (strcmp (command, "ubaraccent") == 0) /* underbar */ + add_char ('_'); + else if (strcmp (command, "udotaccent") == 0) /* underdot */ + add_word ("-."); + else if (strcmp (command, ",") == 0) /* cedilla */ + add_word (","); + } +} + +/* Non-English letters/characters that don't insert themselves. */ +void +cm_special_char (arg) +{ + if (arg == START) + { + if ((*command == 'L' || *command == 'l' + || *command == 'O' || *command == 'o') + && command[1] == 0) + { + /* Lslash lslash Oslash oslash */ + add_char (*command); + add_char ('/'); + } + else if (strcmp (command, "exclamdown") == 0) + add_char ('!'); + else if (strcmp (command, "pounds") == 0) + add_char ('#'); + else if (strcmp (command, "questiondown") == 0) + add_char ('?'); + else + fprintf (stderr, "How did @%s end up in cm_special_char?\n", command); + } +} + +/* Dotless i or j. */ +void +cm_dotless (arg, start, end) + int arg, start, end; +{ + if (arg == END) + { + if (output_paragraph[start] != 'i' && output_paragraph[start] != 'j') + /* This error message isn't perfect if the argument is multiple + characters, but it doesn't seem worth getting right. */ + line_error ("%c%s expects `i' or `j' as argument, not `%c'", + COMMAND_PREFIX, command, output_paragraph[start]); + + else if (end - start != 1) + line_error ("%c%s expects a single character `i' or `j' as argument", + COMMAND_PREFIX, command); + + /* We've already inserted the `i' or `j', so nothing to do. */ + } +} + +#if defined (__osf__) +#define LOCALTIME_CAST(x) (time_t *)(x) +#else +#define LOCALTIME_CAST(x) (x) +#endif + +void +cm_today (arg) + int arg; +{ + static char * months [12] = + { "January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December" }; + if (arg == START) + { + long timer = time (0); + struct tm *ts = localtime (LOCALTIME_CAST (&timer)); + add_word_args + ("%d %s %d", + (ts -> tm_mday), + (months [ts -> tm_mon]), + ((ts -> tm_year) + 1900)); + } +} + +void +cm_code (arg) + int arg; +{ + extern int printing_index; + + if (arg == START) + { + in_fixed_width_font++; + + if (!printing_index) + add_char ('`'); + } + else + { + if (!printing_index) + add_char ('\''); + } +} + +void +cm_kbd (arg) + int arg; +{ + /* People use @kbd in an example to get the "user input" font. + We don't want quotes in that case. */ + if (!in_fixed_width_font) + cm_code (arg); +} + +void +cm_angle_brackets (arg) + int arg; +{ + add_char (arg == START ? '<' : '>'); +} + +/* Convert the character at position into a true control character. */ +void +cm_ctrl (arg, start, end) + int arg, start, end; +{ + /* Should we allow multiple character arguments? I think yes. */ + if (arg == END) + { + register int i, character; +#if defined (NO_MULTIPLE_CTRL) + if ((end - start) != 1) + line_error ("%c%s expects a single character as an argument", + COMMAND_PREFIX, command); + else +#endif + for (i = start; i < end; i++) + { + character = output_paragraph[i]; + + if (isletter (character)) + output_paragraph[i] = CTL (coerce_to_upper (character)); + } + } +} + +/* Handle a command that switches to a non-fixed-width font. */ +void +not_fixed_width (arg) + int arg; +{ + if (arg == START) + in_fixed_width_font = 0; +} + +/* Small caps in makeinfo has to do just all caps. */ +void +cm_sc (arg, start_pos, end_pos) + int arg, start_pos, end_pos; +{ + not_fixed_width (arg); + + if (arg == END) + { + while (start_pos < end_pos) + { + output_paragraph[start_pos] = + coerce_to_upper (output_paragraph[start_pos]); + start_pos++; + } + } +} + +/* @var in makeinfo just uppercases the text. */ +void +cm_var (arg, start_pos, end_pos) + int arg, start_pos, end_pos; +{ + not_fixed_width (arg); + + if (arg == END) + { + while (start_pos < end_pos) + { + output_paragraph[start_pos] = + coerce_to_upper (output_paragraph[start_pos]); + start_pos++; + } + } +} + +void +cm_dfn (arg, position) + int arg, position; +{ + add_char ('"'); +} + +void +cm_emph (arg) + int arg; +{ + add_char ('*'); +} + +void +cm_strong (arg, position) + int arg, position; +{ + cm_emph (arg); +} + +void +cm_cite (arg, position) + int arg, position; +{ + if (arg == START) + add_word ("`"); + else + add_word ("'"); +} + +/* No highlighting, but argument switches fonts. */ +void +cm_not_fixed_width (arg, start, end) + int arg, start, end; +{ + not_fixed_width (arg); +} + +/* Various commands are NOP's. */ +void +cm_no_op () +{ +} + +/* Prevent the argument from being split across two lines. */ +void +cm_w (arg, start, end) + int arg, start, end; +{ + if (arg == START) + non_splitting_words++; + else + non_splitting_words--; +} + + +/* Explain that this command is obsolete, thus the user shouldn't + do anything with it. */ +void +cm_obsolete (arg, start, end) + int arg, start, end; +{ + if (arg == START) + warning ("The command `%c%s' is obsolete", COMMAND_PREFIX, command); +} + +/* Insert the text following input_text_offset up to the end of the line + in a new, separate paragraph. Directly underneath it, insert a + line of WITH_CHAR, the same length of the inserted text. */ +void +insert_and_underscore (with_char) + int with_char; +{ + register int i, len; + int old_no_indent, starting_pos, ending_pos; + char *temp; + + close_paragraph (); + filling_enabled = indented_fill = 0; + old_no_indent = no_indent; + no_indent = 1; + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + append_to_expansion_output (input_text_offset + 1); +#endif /* HAVE_MACROS */ + + get_rest_of_line (&temp); + + starting_pos = output_position + output_paragraph_offset; +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + { + char *temp1; + + temp1 = (char *)xmalloc (2 + strlen (temp)); + sprintf (temp1, "%s\n", temp); + remember_itext (input_text, input_text_offset); + me_execute_string (temp1); + free (temp1); + } + else +#endif /* HAVE_MACROS */ + execute_string ("%s\n", temp); + + ending_pos = output_position + output_paragraph_offset; + free (temp); + + len = (ending_pos - starting_pos) - 1; + for (i = 0; i < len; i++) + add_char (with_char); + insert ('\n'); + close_paragraph (); + filling_enabled = 1; + no_indent = old_no_indent; +} + +/* Here is a structure which associates sectioning commands with + an integer, hopefully to reflect the `depth' of the current + section. */ +struct { + char *name; + int level; +} section_alist[] = { + { "unnumberedsubsubsec", 5 }, + { "unnumberedsubsec", 4 }, + { "unnumberedsec", 3 }, + { "unnumbered", 2 }, + { "appendixsubsubsec", 5 }, + { "appendixsubsec", 4 }, + { "appendixsec", 3 }, + { "appendixsection", 3 }, + { "appendix", 2 }, + { "subsubsec", 5 }, + { "subsubsection", 5 }, + { "subsection", 4 }, + { "section", 3 }, + { "chapter", 2 }, + { "top", 1 }, + + { (char *)NULL, 0 } +}; + +/* Amount to offset the name of sectioning commands to levels by. */ +int section_alist_offset = 0; + +/* Shift the meaning of @section to @chapter. */ +void +cm_raisesections () +{ + discard_until ("\n"); + section_alist_offset--; +} + +/* Shift the meaning of @chapter to @section. */ +void +cm_lowersections () +{ + discard_until ("\n"); + section_alist_offset++; +} + +/* Return an integer which identifies the type section present in TEXT. */ +int +what_section (text) + char *text; +{ + register int i, j; + char *t; + + find_section_command: + for (j = 0; text[j] && cr_or_whitespace (text[j]); j++); + if (text[j] != COMMAND_PREFIX) + return (-1); + + text = text + j + 1; + + /* We skip @c, @comment, and @?index commands. */ + if ((strncmp (text, "comment", strlen ("comment")) == 0) || + (text[0] == 'c' && cr_or_whitespace (text[1])) || + (strcmp (text + 1, "index") == 0)) + { + while (*text++ != '\n'); + goto find_section_command; + } + + /* Handle italicized sectioning commands. */ + if (*text == 'i') + text++; + + for (j = 0; text[j] && !cr_or_whitespace (text[j]); j++); + + for (i = 0; t = section_alist[i].name; i++) + { + if (j == strlen (t) && strncmp (t, text, j) == 0) + { + int return_val; + + return_val = (section_alist[i].level + section_alist_offset); + + if (return_val < 0) + return_val = 0; + else if (return_val > 5) + return_val = 5; + return (return_val); + } + } + return (-1); +} + +/* Set the level of @top to LEVEL. Return the old level of @top. */ +int +set_top_section_level (level) + int level; +{ + register int i, result = -1; + + for (i = 0; section_alist[i].name; i++) + if (strcmp (section_alist[i].name, "top") == 0) + { + result = section_alist[i].level; + section_alist[i].level = level; + break; + } + return (result); +} + +/* Treat this just like @unnumbered. The only difference is + in node defaulting. */ +void +cm_top () +{ + /* It is an error to have more than one @top. */ + if (top_node_seen) + { + TAG_ENTRY *tag = tag_table; + + line_error ("There already is a node having %ctop as a section", + COMMAND_PREFIX); + + while (tag != (TAG_ENTRY *)NULL) + { + if ((tag->flags & IS_TOP)) + { + int old_line_number = line_number; + char *old_input_filename = input_filename; + + line_number = tag->line_no; + input_filename = tag->filename; + line_error ("Here is the %ctop node", COMMAND_PREFIX); + input_filename = old_input_filename; + line_number = old_line_number; + return; + } + tag = tag->next_ent; + } + } + else + { + top_node_seen = 1; + + /* It is an error to use @top before you have used @node. */ + if (!tag_table) + { + char *top_name; + + get_rest_of_line (&top_name); + free (top_name); + line_error ("%ctop used before %cnode, defaulting to %s", + COMMAND_PREFIX, COMMAND_PREFIX, top_name); + execute_string ("@node Top, , (dir), (dir)\n@top %s\n", top_name); + return; + } + + cm_unnumbered (); + + /* The most recently defined node is the top node. */ + tag_table->flags |= IS_TOP; + + /* Now set the logical hierarchical level of the Top node. */ + { + int orig_offset = input_text_offset; + + input_text_offset = search_forward (node_search_string, orig_offset); + + if (input_text_offset > 0) + { + int this_section; + + /* We have encountered a non-top node, so mark that one exists. */ + non_top_node_seen = 1; + + /* Move to the end of this line, and find out what the + sectioning command is here. */ + while (input_text[input_text_offset] != '\n') + input_text_offset++; + + if (input_text_offset < size_of_input_text) + input_text_offset++; + + this_section = what_section (input_text + input_text_offset); + + /* If we found a sectioning command, then give the top section + a level of this section - 1. */ + if (this_section != -1) + set_top_section_level (this_section - 1); + } + input_text_offset = orig_offset; + } + } +} + +/* Organized by level commands. That is, "*" == chapter, "=" == section. */ +char *scoring_characters = "*=-."; + +void +sectioning_underscore (command) + char *command; +{ + char character; + char *temp; + int level; + + temp = (char *)xmalloc (2 + strlen (command)); + temp[0] = COMMAND_PREFIX; + strcpy (&temp[1], command); + level = what_section (temp); + free (temp); + level -= 2; + + if (level < 0) + level = 0; + + character = scoring_characters[level]; + + insert_and_underscore (character); +} + +/* The command still works, but prints a warning message in addition. */ +void +cm_ideprecated (arg, start, end) + int arg, start, end; +{ + warning ("The command `%c%s' is obsolete; use `%c%s' instead", + COMMAND_PREFIX, command, COMMAND_PREFIX, command + 1); + sectioning_underscore (command + 1); +} + +/* The remainder of the text on this line is a chapter heading. */ +void +cm_chapter () +{ + sectioning_underscore ("chapter"); +} + +/* The remainder of the text on this line is a section heading. */ +void +cm_section () +{ + sectioning_underscore ("section"); +} + +/* The remainder of the text on this line is a subsection heading. */ +void +cm_subsection () +{ + sectioning_underscore ("subsection"); +} + +/* The remainder of the text on this line is a subsubsection heading. */ +void +cm_subsubsection () +{ + sectioning_underscore ("subsubsection"); +} + +/* The remainder of the text on this line is an unnumbered heading. */ +void +cm_unnumbered () +{ + cm_chapter (); +} + +/* The remainder of the text on this line is an unnumbered section heading. */ +void +cm_unnumberedsec () +{ + cm_section (); +} + +/* The remainder of the text on this line is an unnumbered + subsection heading. */ +void +cm_unnumberedsubsec () +{ + cm_subsection (); +} + +/* The remainder of the text on this line is an unnumbered + subsubsection heading. */ +void +cm_unnumberedsubsubsec () +{ + cm_subsubsection (); +} + +/* The remainder of the text on this line is an appendix heading. */ +void +cm_appendix () +{ + cm_chapter (); +} + +/* The remainder of the text on this line is an appendix section heading. */ +void +cm_appendixsec () +{ + cm_section (); +} + +/* The remainder of the text on this line is an appendix subsection heading. */ +void +cm_appendixsubsec () +{ + cm_subsection (); +} + +/* The remainder of the text on this line is an appendix + subsubsection heading. */ +void +cm_appendixsubsubsec () +{ + cm_subsubsection (); +} + +/* Compatibility functions substitute for chapter, section, etc. */ +void +cm_majorheading () +{ + cm_chapheading (); +} + +void +cm_chapheading () +{ + cm_chapter (); +} + +void +cm_heading () +{ + cm_section (); +} + +void +cm_subheading () +{ + cm_subsection (); +} + +void +cm_subsubheading () +{ + cm_subsubsection (); +} + +/* **************************************************************** */ +/* */ +/* Adding nodes, and making tags */ +/* */ +/* **************************************************************** */ + +/* Start a new tag table. */ +void +init_tag_table () +{ + while (tag_table != (TAG_ENTRY *) NULL) + { + TAG_ENTRY *temp = tag_table; + free (temp->node); + free (temp->prev); + free (temp->next); + free (temp->up); + tag_table = tag_table->next_ent; + free (temp); + } +} + +void +write_tag_table () +{ + write_tag_table_internal (0); /* Not indirect. */ +} + +void +write_tag_table_indirect () +{ + write_tag_table_internal (1); +} + +/* Write out the contents of the existing tag table. + INDIRECT_P says how to format the output. */ +void +write_tag_table_internal (indirect_p) + int indirect_p; +{ + TAG_ENTRY *node = tag_table; + int old_indent = no_indent; + + no_indent = 1; + filling_enabled = 0; + must_start_paragraph = 0; + close_paragraph (); + + if (!indirect_p) + { + no_indent = 1; + insert ('\n'); + } + + add_word_args ("\037\nTag Table:\n%s", indirect_p ? "(Indirect)\n" : ""); + + while (node != (TAG_ENTRY *) NULL) + { + execute_string ("Node: %s", node->node); + add_word_args ("\177%d\n", node->position); + node = node->next_ent; + } + + add_word ("\037\nEnd Tag Table\n"); + flush_output (); + no_indent = old_indent; +} + +char * +get_node_token () +{ + char *string; + + get_until_in_line (",", &string); + + if (curchar () == ',') + input_text_offset++; + + canon_white (string); + + /* Force all versions of "top" to be "Top". */ + normalize_node_name (string); + + return (string); +} + +/* Convert "top" and friends into "Top". */ +void +normalize_node_name (string) + char *string; +{ + if (strcasecmp (string, "Top") == 0) + strcpy (string, "Top"); +} + +/* Look up NAME in the tag table, and return the associated + tag_entry. If the node is not in the table return NULL. */ +TAG_ENTRY * +find_node (name) + char *name; +{ + TAG_ENTRY *tag = tag_table; + + while (tag != (TAG_ENTRY *) NULL) + { + if (strcmp (tag->node, name) == 0) + return (tag); + tag = tag->next_ent; + } + return ((TAG_ENTRY *) NULL); +} + +/* Remember NODE and associates. */ +void +remember_node (node, prev, next, up, position, line_no, no_warn) + char *node, *prev, *next, *up; + int position, line_no, no_warn; +{ + /* Check for existence of this tag already. */ + if (validating) + { + register TAG_ENTRY *tag = find_node (node); + if (tag) + { + line_error ("Node `%s' multiply defined (%d is first definition)", + node, tag->line_no); + return; + } + } + + /* First, make this the current node. */ + current_node = node; + + /* Now add it to the list. */ + { + TAG_ENTRY *new = (TAG_ENTRY *) xmalloc (sizeof (TAG_ENTRY)); + new->node = node; + new->prev = prev; + new->next = next; + new->up = up; + new->position = position; + new->line_no = line_no; + new->filename = node_filename; + new->touched = 0; /* not yet referenced. */ + new->flags = 0; + if (no_warn) + new->flags |= NO_WARN; + new->next_ent = tag_table; + tag_table = new; + } +} + +/* The order is: nodename, nextnode, prevnode, upnode. + If all of the NEXT, PREV, and UP fields are empty, they are defaulted. + You must follow a node command which has those fields defaulted + with a sectioning command (e.g. @chapter) giving the "level" of that node. + It is an error not to do so. + The defaults come from the menu in this node's parent. */ +void +cm_node () +{ + char *node, *prev, *next, *up; + int new_node_pos, defaulting, this_section, no_warn = 0; + extern int already_outputting_pending_notes; + + if (strcmp (command, "nwnode") == 0) + no_warn = 1; + + /* Get rid of unmatched brace arguments from previous commands. */ + discard_braces (); + + /* There also might be insertions left lying around that haven't been + ended yet. Do that also. */ + discard_insertions (); + + if (!already_outputting_pending_notes) + { + close_paragraph (); + output_pending_notes (); + free_pending_notes (); + } + + filling_enabled = indented_fill = 0; + new_node_pos = output_position; + current_footnote_number = 1; + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + append_to_expansion_output (input_text_offset + 1); +#endif /* HAVE_MACROS */ + + node = get_node_token (); + next = get_node_token (); + prev = get_node_token (); + up = get_node_token (); + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + remember_itext (input_text, input_text_offset); +#endif /* HAVE_MACROS */ + + no_indent = 1; + if (!no_headers) + { + add_word_args ("\037\nFile: %s, Node: ", pretty_output_filename); + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + me_execute_string (node); + else +#endif /* HAVE_MACROS */ + execute_string ("%s", node); + filling_enabled = indented_fill = 0; + } + + /* Check for defaulting of this node's next, prev, and up fields. */ + defaulting = ((strlen (next) == 0) && + (strlen (prev) == 0) && + (strlen (up) == 0)); + + this_section = what_section (input_text + input_text_offset); + + /* If we are defaulting, then look at the immediately following + sectioning command (error if none) to determine the node's + level. Find the node that contains the menu mentioning this node + that is one level up (error if not found). That node is the "Up" + of this node. Default the "Next" and "Prev" from the menu. */ + if (defaulting) + { + NODE_REF *last_ref = (NODE_REF *)NULL; + NODE_REF *ref = node_references; + + if ((this_section < 0) && (strcmp (node, "Top") != 0)) + { + char *polite_section_name = "top"; + int i; + + for (i = 0; section_alist[i].name; i++) + if (section_alist[i].level == current_section + 1) + { + polite_section_name = section_alist[i].name; + break; + } + + line_error + ("Node `%s' requires a sectioning command (e.g. %c%s)", + node, COMMAND_PREFIX, polite_section_name); + } + else + { + if (strcmp (node, "Top") == 0) + { + /* Default the NEXT pointer to be the first menu item in + this node, if there is a menu in this node. We have to + try very hard to find the menu, as it may be obscured + by execution_strings which are on the filestack. For + every member of the filestack which has a FILENAME + member which is identical to the current INPUT_FILENAME, + search forward from that offset. */ + int saved_input_text_offset = input_text_offset; + int saved_size_of_input_text = size_of_input_text; + char *saved_input_text = input_text; + FSTACK *next_file = filestack; + + int orig_offset, orig_size; + char *glean_node_from_menu (); + + /* No matter what, make this file point back at `(dir)'. */ + free (up); up = strdup ("(dir)"); + + while (1) + { + orig_offset = input_text_offset; + orig_size = + search_forward (node_search_string, orig_offset); + + if (orig_size < 0) + orig_size = size_of_input_text; + + input_text_offset = + search_forward (menu_search_string, orig_offset); + + if (input_text_offset > -1) + { + char *nodename_from_menu = (char *)NULL; + + input_text_offset = + search_forward ("\n* ", input_text_offset); + + if (input_text_offset != -1) + nodename_from_menu = glean_node_from_menu (0); + + if (nodename_from_menu) + { + free (next); next = nodename_from_menu; + break; + } + } + + /* We got here, so it hasn't been found yet. Try + the next file on the filestack if there is one. */ + if (next_file && + (strcmp (next_file->filename, input_filename) == 0)) + { + input_text = next_file->text; + input_text_offset = next_file->offset; + size_of_input_text = next_file->size; + next_file = next_file->next; + } + else + { + /* No more input files to check. */ + break; + } + } + + input_text = saved_input_text; + input_text_offset = saved_input_text_offset; + size_of_input_text = saved_size_of_input_text; + } + } + + /* Fix the level of the menu references in the Top node, iff it + was declared with @top, and no subsequent reference was found. */ + if (top_node_seen && !non_top_node_seen) + { + /* Then this is the first non-@top node seen. */ + int level; + + level = set_top_section_level (this_section - 1); + non_top_node_seen = 1; + + while (ref) + { + if (ref->section == level) + ref->section = this_section - 1; + ref = ref->next; + } + + ref = node_references; + } + + while (ref) + { + if (ref->section == (this_section - 1) && + ref->type == menu_reference && + strcmp (ref->node, node) == 0) + { + char *containing_node = ref->containing_node; + + free (up); + up = strdup (containing_node); + + if (last_ref && + last_ref->type == menu_reference && + (strcmp (last_ref->containing_node, + containing_node) == 0)) + { + free (next); + next = strdup (last_ref->node); + } + + while ((ref->section == this_section - 1) && + (ref->next) && + (ref->next->type != menu_reference)) + ref = ref->next; + + if (ref->next && ref->type == menu_reference && + (strcmp (ref->next->containing_node, + containing_node) == 0)) + { + free (prev); + prev = strdup (ref->next->node); + } + else if (!ref->next && + strcasecmp (ref->containing_node, "Top") == 0) + { + free (prev); + prev = strdup (ref->containing_node); + } + break; + } + last_ref = ref; + ref = ref->next; + } + } + +#if defined (HAVE_MACROS) + /* Insert the correct args if we are expanding macros, and the node's + pointers weren't defaulted. */ + if (macro_expansion_output_stream && !defaulting) + { + char *temp; + int op_orig = output_paragraph_offset; + + temp = (char *)xmalloc (3 + strlen (next)); + sprintf (temp, ", %s", next); + me_execute_string (temp); + free (temp); + + temp = (char *)xmalloc (3 + strlen (prev)); + sprintf (temp, ", %s", prev); + me_execute_string (temp); + free (temp); + + temp = (char *)xmalloc (4 + strlen (up)); + sprintf (temp, ", %s", up); + me_execute_string (temp); + free (temp); + + output_paragraph_offset = op_orig; + } +#endif /* HAVE_MACROS */ + + if (!no_headers) + { +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + me_inhibit_expansion++; +#endif /* HAVE_MACROS */ + + if (*next) + { + execute_string (", Next: %s", next); + filling_enabled = indented_fill = 0; + } + + if (*prev) + { + execute_string (", Prev: %s", prev); + filling_enabled = indented_fill = 0; + } + + if (*up) + { + execute_string (", Up: %s", up); + filling_enabled = indented_fill = 0; + } +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + me_inhibit_expansion--; +#endif /* HAVE_MACROS */ + } + + close_paragraph (); + no_indent = 0; + + if (!*node) + { + line_error ("No node name specified for `%c%s' command", + COMMAND_PREFIX, command); + free (node); + free (next); + free (prev); + free (up); + } + else + { + if (!*next) { free (next); next = (char *)NULL; } + if (!*prev) { free (prev); prev = (char *)NULL; } + if (!*up) { free (up); up = (char *)NULL; } + remember_node (node, prev, next, up, new_node_pos, line_number, no_warn); + } + + /* Change the section only if there was a sectioning command. */ + if (this_section >= 0) + current_section = this_section; + + filling_enabled = 1; +} + +/* Validation of an info file. + Scan through the list of tag entries touching the Prev, Next, and Up + elements of each. It is an error not to be able to touch one of them, + except in the case of external node references, such as "(DIR)". + + If the Prev is different from the Up, + then the Prev node must have a Next pointing at this node. + + Every node except Top must have an Up. + The Up node must contain some sort of reference, other than a Next, + to this node. + + If the Next is different from the Next of the Up, + then the Next node must have a Prev pointing at this node. */ +void +validate_file (tag_table) + TAG_ENTRY *tag_table; +{ + char *old_input_filename = input_filename; + TAG_ENTRY *tags = tag_table; + + while (tags != (TAG_ENTRY *) NULL) + { + register TAG_ENTRY *temp_tag; + + input_filename = tags->filename; + line_number = tags->line_no; + + /* If this is a "no warn" node, don't validate it in any way. */ + if (tags->flags & NO_WARN) + { + tags = tags->next_ent; + continue; + } + + /* If this node has a Next, then make sure that the Next exists. */ + if (tags->next) + { + validate (tags->next, tags->line_no, "Next"); + + /* If the Next node exists, and there is no Up, then make + sure that the Prev of the Next points back. */ + if (temp_tag = find_node (tags->next)) + { + char *prev; + + if (temp_tag->flags & NO_WARN) + { + /* Do nothing if we aren't supposed to issue warnings + about this node. */ + } + else + { + prev = temp_tag->prev; + if (!prev || (strcmp (prev, tags->node) != 0)) + { + line_error ("Node `%s''s Next field not pointed back to", + tags->node); + line_number = temp_tag->line_no; + input_filename = temp_tag->filename; + line_error + ("This node (`%s') is the one with the bad `Prev'", + temp_tag->node); + input_filename = tags->filename; + line_number = tags->line_no; + temp_tag->flags |= PREV_ERROR; + } + } + } + } + + /* Validate the Prev field if there is one, and we haven't already + complained about it in some way. You don't have to have a Prev + field at this stage. */ + if (!(tags->flags & PREV_ERROR) && tags->prev) + { + int valid = validate (tags->prev, tags->line_no, "Prev"); + + if (!valid) + tags->flags |= PREV_ERROR; + else + { + /* If the Prev field is not the same as the Up field, + then the node pointed to by the Prev field must have + a Next field which points to this node. */ + if (tags->up && (strcmp (tags->prev, tags->up) != 0)) + { + temp_tag = find_node (tags->prev); + + /* If we aren't supposed to issue warnings about the + target node, do nothing. */ + if (!temp_tag || (temp_tag->flags & NO_WARN)) + { + /* Do nothing. */ + } + else + { + if (!temp_tag->next || + (strcmp (temp_tag->next, tags->node) != 0)) + { + line_error + ("Node `%s''s Prev field not pointed back to", + tags->node); + line_number = temp_tag->line_no; + input_filename = temp_tag->filename; + line_error + ("This node (`%s') is the one with the bad `Next'", + temp_tag->node); + input_filename = tags->filename; + line_number = tags->line_no; + temp_tag->flags |= NEXT_ERROR; + } + } + } + } + } + + if (!tags->up && (strcasecmp (tags->node, "Top") != 0)) + line_error ("Node `%s' is missing an \"Up\" field", tags->node); + else if (tags->up) + { + int valid = validate (tags->up, tags->line_no, "Up"); + + /* If node X has Up: Y, then warn if Y fails to have a menu item + or note pointing at X, if Y isn't of the form "(Y)". */ + if (valid && *tags->up != '(') + { + NODE_REF *nref, *tref, *list; + NODE_REF *find_node_reference (); + + tref = (NODE_REF *) NULL; + list = node_references; + + for (;;) + { + if (!(nref = find_node_reference (tags->node, list))) + break; + + if (strcmp (nref->containing_node, tags->up) == 0) + { + if (nref->type != menu_reference) + { + tref = nref; + list = nref->next; + } + else + break; + } + list = nref->next; + } + + if (!nref) + { + temp_tag = find_node (tags->up); + line_number = temp_tag->line_no; + input_filename = temp_tag->filename; + if (!tref) + line_error ( +"`%s' has an Up field of `%s', but `%s' has no menu item for `%s'", + tags->node, tags->up, tags->up, tags->node); + line_number = tags->line_no; + input_filename = tags->filename; + } + } + } + tags = tags->next_ent; + } + + validate_other_references (node_references); + /* We have told the user about the references which didn't exist. + Now tell him about the nodes which aren't referenced. */ + + tags = tag_table; + while (tags != (TAG_ENTRY *) NULL) + { + /* If this node is a "no warn" node, do nothing. */ + if (tags->flags & NO_WARN) + { + tags = tags->next_ent; + continue; + } + + /* Special hack. If the node in question appears to have + been referenced more than REFERENCE_WARNING_LIMIT times, + give a warning. */ + if (tags->touched > reference_warning_limit) + { + input_filename = tags->filename; + line_number = tags->line_no; + warning ("Node `%s' has been referenced %d times", + tags->node, tags->touched); + } + + if (tags->touched == 0) + { + input_filename = tags->filename; + line_number = tags->line_no; + + /* Notice that the node "Top" is special, and doesn't have to + be referenced. */ + if (strcasecmp (tags->node, "Top") != 0) + warning ("Unreferenced node `%s'", tags->node); + } + tags = tags->next_ent; + } + input_filename = old_input_filename; +} + +/* Return 1 if tag correctly validated, or 0 if not. */ +int +validate (tag, line, label) + char *tag; + int line; + char *label; +{ + TAG_ENTRY *result; + + /* If there isn't a tag to verify, or if the tag is in another file, + then it must be okay. */ + if (!tag || !*tag || *tag == '(') + return (1); + + /* Otherwise, the tag must exist. */ + result = find_node (tag); + + if (!result) + { + line_number = line; + line_error ( +"Validation error. `%s' field points to node `%s', which doesn't exist", + label, tag); + return (0); + } + result->touched++; + return (1); +} + +/* Split large output files into a series of smaller files. Each file + is pointed to in the tag table, which then gets written out as the + original file. The new files have the same name as the original file + with a "-num" attached. SIZE is the largest number of bytes to allow + in any single split file. */ +void +split_file (filename, size) + char *filename; + int size; +{ + char *root_filename, *root_pathname; + char *the_file, *filename_part (); + struct stat fileinfo; + long file_size; + char *the_header; + int header_size; + + /* Can only do this to files with tag tables. */ + if (!tag_table) + return; + + if (size == 0) + size = DEFAULT_SPLIT_SIZE; + + if ((stat (filename, &fileinfo) != 0) || + (((long) fileinfo.st_size) < SPLIT_SIZE_THRESHOLD)) + return; + file_size = (long) fileinfo.st_size; + + the_file = find_and_load (filename); + if (!the_file) + return; + + root_filename = filename_part (filename); + root_pathname = pathname_part (filename); + + if (!root_pathname) + root_pathname = strdup (""); + + /* Start splitting the file. Walk along the tag table + outputting sections of the file. When we have written + all of the nodes in the tag table, make the top-level + pointer file, which contains indirect pointers and + tags for the nodes. */ + { + int which_file = 1; + TAG_ENTRY *tags = tag_table; + char *indirect_info = (char *)NULL; + + /* Remember the `header' of this file. The first tag in the file is + the bottom of the header; the top of the file is the start. */ + the_header = (char *)xmalloc (1 + (header_size = tags->position)); + memcpy (the_header, the_file, header_size); + + while (tags) + { + int file_top, file_bot, limit; + + /* Have to include the Control-_. */ + file_top = file_bot = tags->position; + limit = file_top + size; + + /* If the rest of this file is only one node, then + that is the entire subfile. */ + if (!tags->next_ent) + { + int i = tags->position + 1; + char last_char = the_file[i]; + + while (i < file_size) + { + if ((the_file[i] == '\037') && + ((last_char == '\n') || + (last_char == '\014'))) + break; + else + last_char = the_file[i]; + i++; + } + file_bot = i; + tags = tags->next_ent; + goto write_region; + } + + /* Otherwise, find the largest number of nodes that can fit in + this subfile. */ + for (; tags; tags = tags->next_ent) + { + if (!tags->next_ent) + { + /* This entry is the last node. Search forward for the end + of this node, and that is the end of this file. */ + int i = tags->position + 1; + char last_char = the_file[i]; + + while (i < file_size) + { + if ((the_file[i] == '\037') && + ((last_char == '\n') || + (last_char == '\014'))) + break; + else + last_char = the_file[i]; + i++; + } + file_bot = i; + + if (file_bot < limit) + { + tags = tags->next_ent; + goto write_region; + } + else + { + /* Here we want to write out everything before the last + node, and then write the last node out in a file + by itself. */ + file_bot = tags->position; + goto write_region; + } + } + + if (tags->next_ent->position > limit) + { + if (tags->position == file_top) + tags = tags->next_ent; + + file_bot = tags->position; + + write_region: + { + int fd; + char *split_filename; + + split_filename = (char *) xmalloc + (10 + strlen (root_pathname) + strlen (root_filename)); + sprintf + (split_filename, + "%s%s-%d", root_pathname, root_filename, which_file); + + fd = open + (split_filename, O_WRONLY | O_TRUNC | O_CREAT, 0666); + + if ((fd < 0) || + (write (fd, the_header, header_size) != header_size) || + (write (fd, the_file + file_top, file_bot - file_top) + != (file_bot - file_top)) || + ((close (fd)) < 0)) + { + perror (split_filename); + if (fd != -1) + close (fd); + exit (FATAL); + } + + if (!indirect_info) + { + indirect_info = the_file + file_top; + sprintf (indirect_info, "\037\nIndirect:\n"); + indirect_info += strlen (indirect_info); + } + + sprintf (indirect_info, "%s-%d: %d\n", + root_filename, which_file, file_top); + + free (split_filename); + indirect_info += strlen (indirect_info); + which_file++; + break; + } + } + } + } + + /* We have sucessfully created the subfiles. Now write out the + original again. We must use `output_stream', or + write_tag_table_indirect () won't know where to place the output. */ + output_stream = fopen (filename, "w"); + if (!output_stream) + { + perror (filename); + exit (FATAL); + } + + { + int distance = indirect_info - the_file; + fwrite (the_file, 1, distance, output_stream); + + /* Inhibit newlines. */ + paragraph_is_open = 0; + + write_tag_table_indirect (); + fclose (output_stream); + free (the_header); + free (the_file); + return; + } + } +} + +/* Some menu hacking. This is used to remember menu references while + reading the input file. After the output file has been written, if + validation is on, then we use the contents of NODE_REFERENCES as a + list of nodes to validate. */ +char * +reftype_type_string (type) + enum reftype type; +{ + switch (type) + { + case menu_reference: + return ("Menu"); + case followed_reference: + return ("Followed-Reference"); + default: + return ("Internal-bad-reference-type"); + } +} + +/* Remember this node name for later validation use. */ +void +remember_node_reference (node, line, type) + char *node; + int line; + enum reftype type; +{ + NODE_REF *temp = (NODE_REF *) xmalloc (sizeof (NODE_REF)); + + temp->next = node_references; + temp->node = strdup (node); + temp->line_no = line; + temp->section = current_section; + temp->type = type; + temp->containing_node = strdup (current_node ? current_node : ""); + temp->filename = node_filename; + + node_references = temp; +} + +void +validate_other_references (ref_list) + register NODE_REF *ref_list; +{ + char *old_input_filename = input_filename; + + while (ref_list != (NODE_REF *) NULL) + { + input_filename = ref_list->filename; + validate (ref_list->node, ref_list->line_no, + reftype_type_string (ref_list->type)); + ref_list = ref_list->next; + } + input_filename = old_input_filename; +} + +/* Find NODE in REF_LIST. */ +NODE_REF * +find_node_reference (node, ref_list) + char *node; + register NODE_REF *ref_list; +{ + while (ref_list) + { + if (strcmp (node, ref_list->node) == 0) + break; + ref_list = ref_list->next; + } + return (ref_list); +} + +void +free_node_references () +{ + register NODE_REF *list, *temp; + + list = node_references; + + while (list) + { + temp = list; + free (list->node); + free (list->containing_node); + list = list->next; + free (temp); + } + node_references = (NODE_REF *) NULL; +} + + /* This function gets called at the start of every line while inside of + a menu. It checks to see if the line starts with "* ", and if so, + remembers the node reference that this menu refers to. + input_text_offset is at the \n just before the line start. */ +#define menu_starter "* " +char * +glean_node_from_menu (remember_reference) + int remember_reference; +{ + int i, orig_offset = input_text_offset; + char *nodename; + + if (strncmp (&input_text[input_text_offset + 1], + menu_starter, + strlen (menu_starter)) != 0) + return ((char *)NULL); + else + input_text_offset += strlen (menu_starter) + 1; + + get_until_in_line (":", &nodename); + if (curchar () == ':') + input_text_offset++; + canon_white (nodename); + + if (curchar () == ':') + goto save_node; + + free (nodename); + get_rest_of_line (&nodename); + + /* Special hack: If the nodename follows the menu item name, + then we have to read the rest of the line in order to find + out what the nodename is. But we still have to read the + line later, in order to process any formatting commands that + might be present. So un-count the carriage return that has just + been counted. */ + line_number--; + + isolate_nodename (nodename); + +save_node: + input_text_offset = orig_offset; + normalize_node_name (nodename); + i = strlen (nodename); + if (i && nodename[i - 1] == ':') + nodename[i - 1] = '\0'; + + if (remember_reference) + { + remember_node_reference (nodename, line_number, menu_reference); + free (nodename); + return ((char *)NULL); + } + else + return (nodename); +} + +static void +isolate_nodename (nodename) + char *nodename; +{ + register int i, c; + int paren_seen, paren; + + if (!nodename) + return; + + canon_white (nodename); + paren_seen = paren = i = 0; + + if (*nodename == '.' || !*nodename) + { + *nodename = '\0'; + return; + } + + if (*nodename == '(') + { + paren++; + paren_seen++; + i++; + } + + for (; c = nodename[i]; i++) + { + if (paren) + { + if (c == '(') + paren++; + else if (c == ')') + paren--; + + continue; + } + + /* If the character following the close paren is a space, then this + node has no more characters associated with it. */ + if (c == '\t' || + c == '\n' || + c == ',' || + ((paren_seen && nodename[i - 1] == ')') && + (c == ' ' || c == '.')) || + (c == '.' && + ((!nodename[i + 1] || + (cr_or_whitespace (nodename[i + 1])) || + (nodename[i + 1] == ')'))))) + break; + } + nodename[i] = '\0'; +} + +void +cm_menu () +{ + if (current_node == (char *)NULL) + { + warning ("%cmenu seen before a node has been defined", COMMAND_PREFIX); + warning ("Creating `TOP' node."); + execute_string ("@node Top"); + } + begin_insertion (menu); +} + +void +cm_detailmenu () +{ + if (current_node == (char *)NULL) + { + warning ("%cmenu seen before a node has been defined", COMMAND_PREFIX); + warning ("Creating `TOP' node."); + execute_string ("@node Top"); + } + begin_insertion (detailmenu); +} + +/* **************************************************************** */ +/* */ +/* Cross Reference Hacking */ +/* */ +/* **************************************************************** */ + +char * +get_xref_token () +{ + char *string; + + get_until_in_braces (",", &string); + if (curchar () == ',') + input_text_offset++; + fix_whitespace (string); + return (string); +} + +int px_ref_flag = 0; /* Controls initial output string. */ + +/* Make a cross reference. */ +void +cm_xref (arg) +{ + if (arg == START) + { + char *arg1, *arg2, *arg3, *arg4, *arg5; + + arg1 = get_xref_token (); + arg2 = get_xref_token (); + arg3 = get_xref_token (); + arg4 = get_xref_token (); + arg5 = get_xref_token (); + + add_word_args ("%s", px_ref_flag ? "*note " : "*Note "); + + if (*arg5 || *arg4) + { + char *node_name; + + if (!*arg2) + { + if (*arg3) + node_name = arg3; + else + node_name = arg1; + } + else + node_name = arg2; + + execute_string ("%s: (%s)%s", node_name, arg4, arg1); + /* Free all of the arguments found. */ + if (arg1) free (arg1); + if (arg2) free (arg2); + if (arg3) free (arg3); + if (arg4) free (arg4); + if (arg5) free (arg5); + return; + } + else + remember_node_reference (arg1, line_number, followed_reference); + + if (*arg3) + { + if (!*arg2) + execute_string ("%s: %s", arg3, arg1); + else + execute_string ("%s: %s", arg2, arg1); + } + else + { + if (*arg2) + execute_string ("%s: %s", arg2, arg1); + else + execute_string ("%s::", arg1); + } + + /* Free all of the arguments found. */ + if (arg1) free (arg1); + if (arg2) free (arg2); + if (arg3) free (arg3); + if (arg4) free (arg4); + if (arg5) free (arg5); + } + else + { + /* Check to make sure that the next non-whitespace character is either + a period or a comma. input_text_offset is pointing at the "}" which + ended the xref or pxref command. */ + int temp = input_text_offset + 1; + + if (output_paragraph[output_paragraph_offset - 2] == ':' && + output_paragraph[output_paragraph_offset - 1] == ':') + return; + while (temp < size_of_input_text) + { + if (cr_or_whitespace (input_text[temp])) + temp++; + else + { + if (input_text[temp] == '.' || + input_text[temp] == ',' || + input_text[temp] == '\t') + return; + else + { + line_error ( + "Cross-reference must be terminated with a period or a comma"); + return; + } + } + } + } +} + +void +cm_pxref (arg) + int arg; +{ + if (arg == START) + { + px_ref_flag++; + cm_xref (arg); + px_ref_flag--; + } + else + add_char ('.'); +} + +void +cm_inforef (arg) + int arg; +{ + if (arg == START) + { + char *node, *pname, *file; + + node = get_xref_token (); + pname = get_xref_token (); + file = get_xref_token (); + + execute_string ("*note %s: (%s)%s", pname, file, node); + } +} + +/* **************************************************************** */ +/* */ +/* Insertion Command Stubs */ +/* */ +/* **************************************************************** */ + +void +cm_quotation () +{ + begin_insertion (quotation); +} + +void +cm_example () +{ + begin_insertion (example); +} + +void +cm_smallexample () +{ + begin_insertion (smallexample); +} + +void +cm_lisp () +{ + begin_insertion (lisp); +} + +void +cm_smalllisp () +{ + begin_insertion (smalllisp); +} + +/* @cartouche/@end cartouche draws box with rounded corners in + TeX output. Right now, just a NOP insertion. */ +void +cm_cartouche () +{ + begin_insertion (cartouche); +} + +void +cm_format () +{ + begin_insertion (format); +} + +void +cm_display () +{ + begin_insertion (display); +} + +void +cm_direntry () +{ + if (no_headers) + command_name_condition (); + else + begin_insertion (direntry); +} + +void +cm_itemize () +{ + begin_insertion (itemize); +} + +void +cm_enumerate () +{ + do_enumeration (enumerate, "1"); +} + +/* Start an enumeration insertion of type TYPE. If the user supplied + no argument on the line, then use DEFAULT_STRING as the initial string. */ +void +do_enumeration (type, default_string) + int type; + char *default_string; +{ + get_until_in_line (".", &enumeration_arg); + canon_white (enumeration_arg); + + if (!*enumeration_arg) + { + free (enumeration_arg); + enumeration_arg = strdup (default_string); + } + + if (!isdigit (*enumeration_arg) && !isletter (*enumeration_arg)) + { + warning ("%s requires a letter or a digit", insertion_type_pname (type)); + + switch (type) + { + case enumerate: + default_string = "1"; + break; + } + enumeration_arg = strdup (default_string); + } + begin_insertion (type); +} + +void +cm_table () +{ + begin_insertion (table); +} + +void +cm_multitable () +{ + begin_insertion (multitable); /* @@ */ +} + +void +cm_ftable () +{ + begin_insertion (ftable); +} + +void +cm_vtable () +{ + begin_insertion (vtable); +} + +void +cm_group () +{ + begin_insertion (group); +} + +void +cm_ifinfo () +{ + begin_insertion (ifinfo); +} + +/* Begin an insertion where the lines are not filled or indented. */ +void +cm_flushleft () +{ + begin_insertion (flushleft); +} + +/* Begin an insertion where the lines are not filled, and each line is + forced to the right-hand side of the page. */ +void +cm_flushright () +{ + begin_insertion (flushright); +} + +/* **************************************************************** */ +/* */ +/* Conditional Handling */ +/* */ +/* **************************************************************** */ + +/* A structure which contains `defined' variables. */ +typedef struct defines { + struct defines *next; + char *name; + char *value; +} DEFINE; + +/* The linked list of `set' defines. */ +DEFINE *defines = (DEFINE *)NULL; + +/* Add NAME to the list of `set' defines. */ +void +set (name, value) + char *name; + char *value; +{ + DEFINE *temp; + + for (temp = defines; temp; temp = temp->next) + if (strcmp (name, temp->name) == 0) + { + free (temp->value); + temp->value = strdup (value); + return; + } + + temp = (DEFINE *)xmalloc (sizeof (DEFINE)); + temp->next = defines; + temp->name = strdup (name); + temp->value = strdup (value); + defines = temp; +} + +/* Remove NAME from the list of `set' defines. */ +void +clear (name) + char *name; +{ + register DEFINE *temp, *last; + + last = (DEFINE *)NULL; + temp = defines; + + while (temp) + { + if (strcmp (temp->name, name) == 0) + { + if (last) + last->next = temp->next; + else + defines = temp->next; + + free (temp->name); + free (temp->value); + free (temp); + break; + } + last = temp; + temp = temp->next; + } +} + +/* Return the value of NAME. The return value is NULL if NAME is unset. */ +char * +set_p (name) + char *name; +{ + register DEFINE *temp; + + for (temp = defines; temp; temp = temp->next) + if (strcmp (temp->name, name) == 0) + return (temp->value); + + return ((char *)NULL); +} + +/* Conditionally parse based on the current command name. */ +void +command_name_condition () +{ + char *discarder; + + discarder = (char *)xmalloc (8 + strlen (command)); + + sprintf (discarder, "\n%cend %s", COMMAND_PREFIX, command); + discard_until (discarder); + discard_until ("\n"); + + free (discarder); +} + +/* Create a variable whose name appears as the first word on this line. */ +void +cm_set () +{ + handle_variable (SET); +} + +/* Remove a variable whose name appears as the first word on this line. */ +void +cm_clear () +{ + handle_variable (CLEAR); +} + +void +cm_ifset () +{ + handle_variable (IFSET); +} + +void +cm_ifclear () +{ + handle_variable (IFCLEAR); +} + +/* This command takes braces, but we parse the contents specially, so we + don't use the standard brace popping code. + + The syntax @ifeq{arg1, arg2, texinfo-commands} performs texinfo-commands + if ARG1 and ARG2 caselessly string compare to the same string, otherwise, + it produces no output. */ +void +cm_ifeq () +{ + register int i; + char **arglist; + + arglist = get_brace_args (0); + + if (arglist) + { + if (array_len (arglist) > 1) + { + if ((strcasecmp (arglist[0], arglist[1]) == 0) && + (arglist[2] != (char *)NULL)) + execute_string ("%s\n", arglist[2]); + } + + free_array (arglist); + } +} + +void +cm_value (arg, start_pos, end_pos) + int arg, start_pos, end_pos; +{ + if (arg == END) + { + char *name, *value; + name = (char *)&output_paragraph[start_pos]; + output_paragraph[end_pos] = '\0'; + name = strdup (name); + value = set_p (name); + output_column -= end_pos - start_pos; + output_paragraph_offset = start_pos; + + if (value) + execute_string ("%s", value); + else + add_word_args ("{No Value For \"%s\"}", name); + + free (name); + } +} + +/* Set, clear, or conditionalize based on ACTION. */ +void +handle_variable (action) + int action; +{ + char *name; + + get_rest_of_line (&name); + backup_input_pointer (); + canon_white (name); + handle_variable_internal (action, name); + free (name); +} + +void +handle_variable_internal (action, name) + int action; + char *name; +{ + char *temp; + int delimiter, additional_text_present = 0; + + /* Only the first word of NAME is a valid tag. */ + temp = name; + delimiter = 0; + while (*temp && (delimiter || !whitespace (*temp))) + { +/* #if defined (SET_WITH_EQUAL) */ + if (*temp == '"' || *temp == '\'') + { + if (*temp == delimiter) + delimiter = 0; + else + delimiter = *temp; + } +/* #endif SET_WITH_EQUAL */ + temp++; + } + + if (*temp) + additional_text_present++; + + *temp = '\0'; + + if (!*name) + line_error ("%c%s requires a name", COMMAND_PREFIX, command); + else + { + switch (action) + { + case SET: + { + char *value; + +#if defined (SET_WITH_EQUAL) + /* Allow a value to be saved along with a variable. The value is + the text following an `=' sign in NAME, if any is present. */ + + for (value = name; *value && *value != '='; value++); + + if (*value) + *value++ = '\0'; + + if (*value == '"' || *value == '\'') + { + value++; + value[strlen (value) - 1] = '\0'; + } + +#else /* !SET_WITH_EQUAL */ + /* The VALUE of NAME is the remainder of the line sans + whitespace. */ + if (additional_text_present) + { + value = temp + 1; + canon_white (value); + } + else + value = ""; +#endif /* !SET_WITH_VALUE */ + + set (name, value); + } + break; + + case CLEAR: + clear (name); + break; + + case IFSET: + case IFCLEAR: + /* If IFSET and NAME is not set, or if IFCLEAR and NAME is set, + read lines from the the file until we reach a matching + "@end CONDITION". This means that we only take note of + "@ifset/clear" and "@end" commands. */ + { + char condition[8]; + int condition_len; + + if (action == IFSET) + strcpy (condition, "ifset"); + else + strcpy (condition, "ifclear"); + + condition_len = strlen (condition); + + if ((action == IFSET && !set_p (name)) || + (action == IFCLEAR && set_p (name))) + { + int level = 0, done = 0; + + while (!done) + { + char *freeable_line, *line; + + get_rest_of_line (&freeable_line); + + for (line = freeable_line; whitespace (*line); line++); + + if (*line == COMMAND_PREFIX && + (strncmp (line + 1, condition, condition_len) == 0)) + level++; + else if (strncmp (line, "@end", 4) == 0) + { + char *cname = line + 4; + char *temp; + + while (*cname && whitespace (*cname)) + cname++; + temp = cname; + + while (*temp && !whitespace (*temp)) + temp++; + *temp = '\0'; + + if (strcmp (cname, condition) == 0) + { + if (!level) + { + done = 1; + } + else + level--; + } + } + free (freeable_line); + } + /* We found the end of a false @ifset/ifclear. If we are + in a menu, back up over the newline that ends the ifset, + since that newline may also begin the next menu entry. */ + break; + } + else + { + if (action == IFSET) + begin_insertion (ifset); + else + begin_insertion (ifclear); + } + } + break; + } + } +} + +/* Execution of random text not in file. */ + +typedef struct { + char *string; /* The string buffer. */ + int size; /* The size of the buffer. */ + int in_use; /* Non-zero means string currently in use. */ +} EXECUTION_STRING; + +static EXECUTION_STRING **execution_strings = (EXECUTION_STRING **)NULL; +static int execution_strings_index = 0; +static int execution_strings_slots = 0; + +EXECUTION_STRING * +get_execution_string (initial_size) + int initial_size; +{ + register int i = 0; + EXECUTION_STRING *es = (EXECUTION_STRING *)NULL; + + if (execution_strings) + { + for (i = 0; i < execution_strings_index; i++) + if (execution_strings[i] && (execution_strings[i]->in_use == 0)) + { + es = execution_strings[i]; + break; + } + } + + if (!es) + { + if (execution_strings_index + 1 >= execution_strings_slots) + { + execution_strings = (EXECUTION_STRING **)xrealloc + (execution_strings, + (execution_strings_slots += 3) * sizeof (EXECUTION_STRING *)); + for (; i < execution_strings_slots; i++) + execution_strings[i] = (EXECUTION_STRING *)NULL; + } + + execution_strings[execution_strings_index] = + (EXECUTION_STRING *)xmalloc (sizeof (EXECUTION_STRING)); + es = execution_strings[execution_strings_index]; + execution_strings_index++; + + es->size = 0; + es->string = (char *)NULL; + es->in_use = 0; + } + + if (initial_size > es->size) + { + es->string = (char *) xrealloc (es->string, initial_size); + es->size = initial_size; + } + return (es); +} + +/* Execute the string produced by formatting the ARGs with FORMAT. This + is like submitting a new file with @include. */ +#if defined (HAVE_VARARGS_H) && defined (HAVE_VSPRINTF) +void +execute_string (va_alist) + va_dcl +{ + EXECUTION_STRING *es; + char *temp_string; + char *format; + va_list args; + + es = get_execution_string (4000); + temp_string = es->string; + es->in_use = 1; + + va_start (args); + format = va_arg (args, char *); + vsprintf (temp_string, format, args); + va_end (args); + +#else /* !(HAVE_VARARGS_H && HAVE_VSPRINTF) */ + +void +execute_string (format, arg1, arg2, arg3, arg4, arg5) + char *format; +{ + EXECUTION_STRING *es; + char *temp_string; + + es = get_execution_string (4000); + temp_string = es->string; + es->in_use = 1; + + sprintf (temp_string, format, arg1, arg2, arg3, arg4, arg5); + +#endif /* !(HAVE_VARARGS_H && HAVE_VSPRINTF) */ + + pushfile (); + input_text_offset = 0; + input_text = temp_string; + input_filename = strdup (input_filename); + size_of_input_text = strlen (temp_string); + + executing_string++; + reader_loop (); + free (input_filename); + + popfile (); + executing_string--; + es->in_use = 0; +} + + +/* Return what would be output for STR, i.e., expand Texinfo commands. + If IMPLICIT_CODE is set, expand @code{STR}. */ + +char * +expansion (str, implicit_code) + char *str; + int implicit_code; +{ + int length; + char *result; + + /* Inhibit any real output. */ + int start = output_paragraph_offset; + int saved_paragraph_is_open = paragraph_is_open; + + inhibit_output_flushing (); + execute_string (implicit_code ? "@code{%s}" : "%s", str); + uninhibit_output_flushing (); + + /* Copy the expansion from the buffer. */ + length = output_paragraph_offset - start; + result = xmalloc (1 + length); + memcpy (result, (char *) (output_paragraph + start), length); + result[length] = 0; + + /* Pretend it never happened. */ + output_paragraph_offset = start; + paragraph_is_open = saved_paragraph_is_open; + + return result; +} + +/* @itemx, @item. */ + +static int itemx_flag = 0; + +void +cm_itemx () +{ + itemx_flag++; + cm_item (); + itemx_flag--; +} + +void +cm_item () +{ + char *rest_of_line, *item_func; + + /* Can only hack "@item" while inside of an insertion. */ + if (insertion_level) + { + INSERTION_ELT *stack = insertion_stack; + int original_input_text_offset; + + skip_whitespace (); + original_input_text_offset = input_text_offset; + + get_rest_of_line (&rest_of_line); + canon_white (rest_of_line); + item_func = current_item_function (); + + /* Okay, do the right thing depending on which insertion function + is active. */ + + switch_top: + switch (stack->insertion) + { + case multitable: + multitable_item (); + /* Ultra special hack. It appears that some people incorrectly + place text directly after the @item, instead of on a new line + by itself. This happens to work in TeX, so I make it work + here. */ + if (*rest_of_line) + { + line_number--; + input_text_offset = original_input_text_offset; + } + break; + + case ifinfo: + case ifset: + case ifclear: + case cartouche: + stack = stack->next; + if (!stack) + goto no_insertion; + else + goto switch_top; + break; + + case menu: + case quotation: + case example: + case smallexample: + case lisp: + case format: + case display: + case group: + line_error ("The `%c%s' command is meaningless within a `@%s' block", + COMMAND_PREFIX, command, + insertion_type_pname (current_insertion_type ())); + break; + + case itemize: + case enumerate: + if (itemx_flag) + { + line_error ("%citemx is not meaningful inside of a `%s' block", + COMMAND_PREFIX, + insertion_type_pname (current_insertion_type ())); + } + else + { + start_paragraph (); + kill_self_indent (-1); + filling_enabled = indented_fill = 1; + + if (current_insertion_type () == itemize) + { + indent (output_column = current_indent - 2); + + /* I need some way to determine whether this command + takes braces or not. I believe the user can type + either "@bullet" or "@bullet{}". Of course, they + can also type "o" or "#" or whatever else they want. */ + if (item_func && *item_func) + { + if (*item_func == COMMAND_PREFIX) + if (item_func[strlen (item_func) - 1] != '}') + execute_string ("%s{}", item_func); + else + execute_string ("%s", item_func); + else + execute_string ("%s", item_func); + } + insert (' '); + output_column++; + } + else + enumerate_item (); + + /* Special hack. This makes close paragraph ignore you until + the start_paragraph () function has been called. */ + must_start_paragraph = 1; + + /* Ultra special hack. It appears that some people incorrectly + place text directly after the @item, instead of on a new line + by itself. This happens to work in TeX, so I make it work + here. */ + if (*rest_of_line) + { + line_number--; + input_text_offset = original_input_text_offset; + } + } + break; + + case table: + case ftable: + case vtable: + { + /* Get rid of extra characters. */ + kill_self_indent (-1); + + /* close_paragraph () almost does what we want. The problem + is when paragraph_is_open, and last_char_was_newline, and + the last newline has been turned into a space, because + filling_enabled. I handle it here. */ + if (last_char_was_newline && filling_enabled && paragraph_is_open) + insert ('\n'); + close_paragraph (); + +#if defined (INDENT_PARAGRAPHS_IN_TABLE) + /* Indent on a new line, but back up one indentation level. */ + { + int t; + + t = inhibit_paragraph_indentation; + inhibit_paragraph_indentation = 1; + /* At this point, inserting any non-whitespace character will + force the existing indentation to be output. */ + add_char ('i'); + inhibit_paragraph_indentation = t; + } +#else /* !INDENT_PARAGRAPHS_IN_TABLE */ + add_char ('i'); +#endif /* !INDENT_PARAGRAPHS_IN_TABLE */ + + output_paragraph_offset--; + kill_self_indent (default_indentation_increment + 1); + + /* Add item's argument to the line. */ + filling_enabled = 0; + if (item_func && *item_func) + execute_string ("%s{%s}", item_func, rest_of_line); + else + execute_string ("%s", rest_of_line); + + if (current_insertion_type () == ftable) + execute_string ("%cfindex %s\n", COMMAND_PREFIX, rest_of_line); + + if (current_insertion_type () == vtable) + execute_string ("%cvindex %s\n", COMMAND_PREFIX, rest_of_line); + + /* Start a new line, and let start_paragraph () + do the indenting of it for you. */ + close_single_paragraph (); + indented_fill = filling_enabled = 1; + } + } + free (rest_of_line); + } + else + { + no_insertion: + line_error ("%c%s found outside of an insertion block", + COMMAND_PREFIX, command); + } +} + +/* **************************************************************** */ +/* */ +/* Defun and Friends */ +/* */ +/* **************************************************************** */ + +#define DEFUN_SELF_DELIMITING(c) \ + (((c) == '(') \ + || ((c) == ')') \ + || ((c) == '[') \ + || ((c) == ']')) + +struct token_accumulator +{ + unsigned int length; + unsigned int index; + char **tokens; +}; + +void +initialize_token_accumulator (accumulator) + struct token_accumulator *accumulator; +{ + (accumulator->length) = 0; + (accumulator->index) = 0; + (accumulator->tokens) = NULL; +} + +void +accumulate_token (accumulator, token) + struct token_accumulator *accumulator; + char *token; +{ + if ((accumulator->index) >= (accumulator->length)) + { + (accumulator->length) += 10; + (accumulator->tokens) = (char **) xrealloc + (accumulator->tokens, (accumulator->length * sizeof (char *))); + } + accumulator->tokens[accumulator->index] = token; + accumulator->index += 1; +} + +char * +copy_substring (start, end) + char *start; + char *end; +{ + char *result, *scan, *scan_result; + + result = (char *) xmalloc ((end - start) + 1); + scan_result = result; + scan = start; + + while (scan < end) + *scan_result++ = *scan++; + + *scan_result = '\0'; + return (result); +} + +/* Given `string' pointing at an open brace, skip forward and return a + pointer to just past the matching close brace. */ +int +scan_group_in_string (string_pointer) + char **string_pointer; +{ + register int c; + register char *scan_string; + register unsigned int level = 1; + + scan_string = (*string_pointer) + 1; + + while (1) + { + if (level == 0) + { + (*string_pointer) = scan_string; + return (1); + } + c = (*scan_string++); + if (c == '\0') + { + /* Tweak line_number to compensate for fact that + we gobbled the whole line before coming here. */ + line_number -= 1; + line_error ("Missing `}' in %cdef arg", COMMAND_PREFIX); + line_number += 1; + (*string_pointer) = (scan_string - 1); + return (0); + } + if (c == '{') + level += 1; + if (c == '}') + level -= 1; + } +} + +/* Return a list of tokens from the contents of `string'. + Commands and brace-delimited groups count as single tokens. + Contiguous whitespace characters are converted to a token + consisting of a single space. */ +char ** +args_from_string (string) + char *string; +{ + struct token_accumulator accumulator; + register char *scan_string = string; + char *token_start, *token_end; + + initialize_token_accumulator (&accumulator); + + while ((*scan_string) != '\0') + { + /* Replace arbitrary whitespace by a single space. */ + if (whitespace (*scan_string)) + { + scan_string += 1; + while (whitespace (*scan_string)) + scan_string += 1; + accumulate_token ((&accumulator), (strdup (" "))); + continue; + } + + /* Commands count as single tokens. */ + if ((*scan_string) == COMMAND_PREFIX) + { + token_start = scan_string; + scan_string += 1; + if (self_delimiting (*scan_string)) + scan_string += 1; + else + { + register int c; + while (1) + { + c = *scan_string++; + + if ((c == '\0') || (c == '{') || (whitespace (c))) + { + scan_string -= 1; + break; + } + } + + if (*scan_string == '{') + { + char *s = scan_string; + (void) scan_group_in_string (&s); + scan_string = s; + } + } + token_end = scan_string; + } + + /* Parentheses and brackets are self-delimiting. */ + else if (DEFUN_SELF_DELIMITING (*scan_string)) + { + token_start = scan_string; + scan_string += 1; + token_end = scan_string; + } + + /* Open brace introduces a group that is a single token. */ + else if (*scan_string == '{') + { + char *s = scan_string; + int balanced = scan_group_in_string (&s); + + token_start = scan_string + 1; + scan_string = s; + token_end = balanced ? (scan_string - 1) : scan_string; + } + + /* Otherwise a token is delimited by whitespace, parentheses, + brackets, or braces. A token is also ended by a command. */ + else + { + token_start = scan_string; + + while (1) + { + register int c; + + c = *scan_string++; + + /* Do not back up if we're looking at a }; since the only + valid }'s are those matched with {'s, we want to give + an error. If we back up, we go into an infinite loop. */ + if (!c || whitespace (c) || DEFUN_SELF_DELIMITING (c) + || c == '{') + { + scan_string--; + break; + } + + /* If we encounter a command embedded within a token, + then end the token. */ + if (c == COMMAND_PREFIX) + { + scan_string--; + break; + } + } + token_end = scan_string; + } + + accumulate_token + (&accumulator, copy_substring (token_start, token_end)); + } + accumulate_token (&accumulator, NULL); + return (accumulator.tokens); +} + +void +process_defun_args (defun_args, auto_var_p) + char **defun_args; + int auto_var_p; +{ + int pending_space = 0; + + while (1) + { + char *defun_arg = *defun_args++; + + if (defun_arg == NULL) + break; + + if (defun_arg[0] == ' ') + { + pending_space = 1; + continue; + } + + if (pending_space) + { + add_char (' '); + pending_space = 0; + } + + if (DEFUN_SELF_DELIMITING (defun_arg[0])) + add_char (defun_arg[0]); + else if (defun_arg[0] == '&') + add_word (defun_arg); + else if (defun_arg[0] == COMMAND_PREFIX) + execute_string ("%s", defun_arg); + else if (auto_var_p) + execute_string ("%cvar{%s}", COMMAND_PREFIX, defun_arg); + else + add_word (defun_arg); + } +} + +char * +next_nonwhite_defun_arg (arg_pointer) + char ***arg_pointer; +{ + char **scan = (*arg_pointer); + char *arg = (*scan++); + + if ((arg != 0) && (*arg == ' ')) + arg = *scan++; + + if (arg == 0) + scan -= 1; + + *arg_pointer = scan; + + return ((arg == 0) ? "" : arg); +} + +/* Make the defun type insertion. + TYPE says which insertion this is. + X_P says not to start a new insertion if non-zero. */ +void +defun_internal (type, x_p) + enum insertion_type type; + int x_p; +{ + enum insertion_type base_type; + char **defun_args, **scan_args; + char *category, *defined_name, *type_name, *type_name2; + + { + char *line; + get_rest_of_line (&line); + defun_args = (args_from_string (line)); + free (line); + } + + scan_args = defun_args; + + switch (type) + { + case defun: + category = "Function"; + base_type = deffn; + break; + case defmac: + category = "Macro"; + base_type = deffn; + break; + case defspec: + category = "Special Form"; + base_type = deffn; + break; + case defvar: + category = "Variable"; + base_type = defvr; + break; + case defopt: + category = "User Option"; + base_type = defvr; + break; + case deftypefun: + category = "Function"; + base_type = deftypefn; + break; + case deftypevar: + category = "Variable"; + base_type = deftypevr; + break; + case defivar: + category = "Instance Variable"; + base_type = defcv; + break; + case defmethod: + category = "Method"; + base_type = defop; + break; + case deftypemethod: + category = "Method"; + base_type = deftypemethod; + break; + default: + category = next_nonwhite_defun_arg (&scan_args); + base_type = type; + break; + } + + if ((base_type == deftypefn) + || (base_type == deftypevr) + || (base_type == defcv) + || (base_type == defop) + || (base_type == deftypemethod)) + type_name = next_nonwhite_defun_arg (&scan_args); + + if (base_type == deftypemethod) + type_name2 = next_nonwhite_defun_arg (&scan_args); + + defined_name = next_nonwhite_defun_arg (&scan_args); + + /* This hack exists solely for the purposes of formatting the texinfo + manual. I couldn't think of a better way. The token might be + a simple @@ followed immediately by more text. If this is the case, + then the next defun arg is part of this one, and we should concatenate + them. */ + if (*scan_args && **scan_args && !whitespace (**scan_args) && + (strcmp (defined_name, "@@") == 0)) + { + char *tem = (char *)xmalloc (3 + strlen (scan_args[0])); + + sprintf (tem, "@@%s", scan_args[0]); + + free (scan_args[0]); + scan_args[0] = tem; + scan_args++; + defined_name = tem; + } + + if (!x_p) + begin_insertion (type); + + /* Write the definition header line. + This should start at the normal indentation. */ + current_indent -= default_indentation_increment; + start_paragraph (); + + switch (base_type) + { + case deffn: + case defvr: + case deftp: + execute_string (" -- %s: %s", category, defined_name); + break; + case deftypefn: + case deftypevr: + execute_string (" -- %s: %s %s", category, type_name, defined_name); + break; + case defcv: + execute_string (" -- %s of %s: %s", category, type_name, defined_name); + break; + case defop: + execute_string (" -- %s on %s: %s", category, type_name, defined_name); + break; + case deftypemethod: + execute_string (" -- %s on %s: %s %s", category, type_name, type_name2, + defined_name); + break; + } + current_indent += default_indentation_increment; + + /* Now process the function arguments, if any. + If these carry onto the next line, they should be indented by two + increments to distinguish them from the body of the definition, + which is indented by one increment. */ + current_indent += default_indentation_increment; + + switch (base_type) + { + case deffn: + case defop: + process_defun_args (scan_args, 1); + break; + case deftp: + case deftypefn: + case deftypemethod: + process_defun_args (scan_args, 0); + break; + } + current_indent -= default_indentation_increment; + close_single_paragraph (); + + if (!macro_expansion_output_stream) + /* Make an entry in the appropriate index unless we are just + expanding macros. */ + switch (base_type) + { + case deffn: + case deftypefn: + execute_string ("%cfindex %s\n", COMMAND_PREFIX, defined_name); + break; + case defvr: + case deftypevr: + case defcv: + execute_string ("%cvindex %s\n", COMMAND_PREFIX, defined_name); + break; + case defop: + case deftypemethod: + execute_string ("%cfindex %s on %s\n", + COMMAND_PREFIX, defined_name, type_name); + break; + case deftp: + execute_string ("%ctindex %s\n", COMMAND_PREFIX, defined_name); + break; + } + + /* Deallocate the token list. */ + scan_args = defun_args; + while (1) + { + char * arg = (*scan_args++); + if (arg == NULL) + break; + free (arg); + } + free (defun_args); +} + +/* Add an entry for a function, macro, special form, variable, or option. + If the name of the calling command ends in `x', then this is an extra + entry included in the body of an insertion of the same type. */ +void +cm_defun () +{ + int x_p; + enum insertion_type type; + char *temp = strdup (command); + + x_p = (command[strlen (command) - 1] == 'x'); + + if (x_p) + temp[strlen (temp) - 1] = '\0'; + + type = find_type_from_name (temp); + free (temp); + + /* If we are adding to an already existing insertion, then make sure + that we are already in an insertion of type TYPE. */ + if (x_p && + (!insertion_level || insertion_stack->insertion != type)) + { + line_error ("Must be in a `%s' insertion in order to use `%s'x", + command, command); + discard_until ("\n"); + return; + } + + defun_internal (type, x_p); +} + +/* End existing insertion block. */ +void +cm_end () +{ + char *temp; + enum insertion_type type; + + if (!insertion_level) + { + line_error ("Unmatched `%c%s'", COMMAND_PREFIX, command); + return; + } + + get_rest_of_line (&temp); + canon_white (temp); + + if (strlen (temp) == 0) + line_error ("`%c%s' needs something after it", COMMAND_PREFIX, command); + + type = find_type_from_name (temp); + + if (type == bad_type) + { + line_error ("Bad argument to `%s', `%s', using `%s'", + command, temp, insertion_type_pname (current_insertion_type ())); + } + end_insertion (type); + free (temp); +} + +/* **************************************************************** */ +/* */ +/* Other Random Commands */ +/* */ +/* **************************************************************** */ + +/* This says to inhibit the indentation of the next paragraph, but + not of following paragraphs. */ +void +cm_noindent () +{ + if (!inhibit_paragraph_indentation) + inhibit_paragraph_indentation = -1; +} + +/* I don't know exactly what to do with this. Should I allow + someone to switch filenames in the middle of output? Since the + file could be partially written, this doesn't seem to make sense. + Another option: ignore it, since they don't *really* want to + switch files. Finally, complain, or at least warn. */ +void +cm_setfilename () +{ + char *filename; + get_rest_of_line (&filename); + /* warning ("`@%s %s' encountered and ignored", command, filename); */ + free (filename); +} + +void +cm_ignore_line () +{ + discard_until ("\n"); +} + +/* @br can be immediately followed by `{}', so we have to read those here. + It should simply close the paragraph. */ +void +cm_br () +{ + if (looking_at ("{}")) + input_text_offset += 2; + + if (curchar () == '\n') + { + input_text_offset++; + line_number++; + } + + close_paragraph (); +} + + /* Insert the number of blank lines passed as argument. */ +void +cm_sp () +{ + int lines; + char *line; + + get_rest_of_line (&line); + + if (sscanf (line, "%d", &lines) != 1) + { + line_error ("%csp requires a positive numeric argument", COMMAND_PREFIX); + } + else + { + if (lines < 0) + lines = 0; + + while (lines--) + add_char ('\n'); + } + free (line); +} + +/* @dircategory LINE outputs INFO-DIR-SECTION LINE, + but not if --no-headers. */ + +void +cm_dircategory () +{ + char *line, *p; + + get_rest_of_line (&line);; + + if (! no_headers) + { + insert_string ("INFO-DIR-SECTION "); + insert_string (line); + insert ('\n'); + } + + free (line); +} + +/* Start a new line with just this text on it. + Then center the line of text. + This always ends the current paragraph. */ +void +cm_center () +{ + register int i, start, length; + int fudge_factor = 1; + unsigned char *line; + + close_paragraph (); + filling_enabled = indented_fill = 0; + cm_noindent (); + start = output_paragraph_offset; + inhibit_output_flushing (); + get_rest_of_line ((char **)&line); + execute_string ("%s", (char *)line); + free (line); + uninhibit_output_flushing (); + + i = output_paragraph_offset - 1; + while (i > (start - 1) && output_paragraph[i] == '\n') + i--; + + output_paragraph_offset = ++i; + length = output_paragraph_offset - start; + + if (length < (fill_column - fudge_factor)) + { + line = (unsigned char *)xmalloc (1 + length); + memcpy (line, (char *)(output_paragraph + start), length); + + i = (fill_column - fudge_factor - length) / 2; + output_paragraph_offset = start; + + while (i--) + insert (' '); + + for (i = 0; i < length; i++) + insert (line[i]); + + free (line); + } + + insert ('\n'); + close_paragraph (); + filling_enabled = 1; +} + +/* Show what an expression returns. */ +void +cm_result (arg) + int arg; +{ + if (arg == END) + add_word ("=>"); +} + +/* What an expression expands to. */ +void +cm_expansion (arg) + int arg; +{ + if (arg == END) + add_word ("==>"); +} + +/* Indicates two expressions are equivalent. */ +void +cm_equiv (arg) + int arg; +{ + if (arg == END) + add_word ("=="); +} + +/* What an expression may print. */ +void +cm_print (arg) + int arg; +{ + if (arg == END) + add_word ("-|"); +} + +/* An error signaled. */ +void +cm_error (arg) + int arg; +{ + if (arg == END) + add_word ("error-->"); +} + +/* The location of point in an example of a buffer. */ +void +cm_point (arg) + int arg; +{ + if (arg == END) + add_word ("-!-"); +} + +/* Start a new line with just this text on it. + The text is outdented one level if possible. */ +void +cm_exdent () +{ + char *line; + int i = current_indent; + + if (current_indent) + current_indent -= default_indentation_increment; + + get_rest_of_line (&line); + close_single_paragraph (); + execute_string ("%s", line); + current_indent = i; + free (line); + close_single_paragraph (); +} + +#if !defined (HAVE_STRERROR) +extern char *sys_errlist[]; +extern int sys_nerr; + +char * +strerror (num) + int num; +{ + if (num >= sys_nerr) + return ("Unknown file system error"); + else + return (sys_errlist[num]); +} +#endif /* !HAVE_STRERROR */ + +/* Remember this file, and move onto the next. */ +void +cm_include () +{ + char *filename; + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + me_append_before_this_command (); +#endif /* HAVE_MACROS */ + + close_paragraph (); + get_rest_of_line (&filename); + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + remember_itext (input_text, input_text_offset); +#endif /* HAVE_MACROS */ + + pushfile (); + + /* In verbose mode we print info about including another file. */ + if (verbose_mode) + { + register int i = 0; + register FSTACK *stack = filestack; + + for (i = 0, stack = filestack; stack; stack = stack->next, i++); + + i *= 2; + + printf ("%*s", i, ""); + printf ("%c%s %s\n", COMMAND_PREFIX, command, filename); + fflush (stdout); + } + + if (!find_and_load (filename)) + { + extern int errno; + + popfile (); + line_number--; + + /* Cannot "@include foo", in line 5 of "/wh/bar". */ + line_error ("`%c%s %s': %s", COMMAND_PREFIX, command, filename, + strerror (errno)); + + free (filename); + return; + } + else + { +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + remember_itext (input_text, input_text_offset); +#endif /* HAVE_MACROS */ + reader_loop (); + } + free (filename); + popfile (); +} + +/* The other side of a malformed expression. */ +void +misplaced_brace () +{ + line_error ("Misplaced `}'"); +} + +/* Signals end of processing. Easy to make this happen. */ +void +cm_bye () +{ + input_text_offset = size_of_input_text; +} + +/* **************************************************************** */ +/* */ +/* Indexing Stuff */ +/* */ +/* **************************************************************** */ + + +/* An index element... */ +typedef struct index_elt +{ + struct index_elt *next; + char *entry; /* The index entry itself. */ + char *node; /* The node from whence it came. */ + int code; /* Non-zero means add `@code{...}' when + printing this element. */ + int defining_line; /* Line number where this entry was written. */ +} INDEX_ELT; + +/* A list of short-names for each index, and the index to that index in our + index array, the_indices. In addition, for each index, it is remembered + whether that index is a code index or not. Code indices have @code{} + inserted around the first word when they are printed with printindex. */ +typedef struct +{ + char *name; + int index; + int code; +} INDEX_ALIST; + +INDEX_ALIST **name_index_alist = (INDEX_ALIST **) NULL; + +/* An array of pointers. Each one is for a different index. The + "synindex" command changes which array slot is pointed to by a + given "index". */ +INDEX_ELT **the_indices = (INDEX_ELT **) NULL; + +/* The number of defined indices. */ +int defined_indices = 0; + +/* We predefine these. */ +#define program_index 0 +#define function_index 1 +#define concept_index 2 +#define variable_index 3 +#define datatype_index 4 +#define key_index 5 + +void +init_indices () +{ + int i; + + /* Create the default data structures. */ + + /* Initialize data space. */ + if (!the_indices) + { + the_indices = (INDEX_ELT **) xmalloc ((1 + defined_indices) * + sizeof (INDEX_ELT *)); + the_indices[defined_indices] = (INDEX_ELT *) NULL; + + name_index_alist = (INDEX_ALIST **) xmalloc ((1 + defined_indices) * + sizeof (INDEX_ALIST *)); + name_index_alist[defined_indices] = (INDEX_ALIST *) NULL; + } + + /* If there were existing indices, get rid of them now. */ + for (i = 0; i < defined_indices; i++) + undefindex (name_index_alist[i]->name); + + /* Add the default indices. */ + top_defindex ("pg", 0); + top_defindex ("fn", 1); /* "fn" is a code index. */ + top_defindex ("cp", 0); + top_defindex ("vr", 0); + top_defindex ("tp", 0); + top_defindex ("ky", 0); + +} + +/* Find which element in the known list of indices has this name. + Returns -1 if NAME isn't found. */ +int +find_index_offset (name) + char *name; +{ + register int i; + for (i = 0; i < defined_indices; i++) + if (name_index_alist[i] && + strcmp (name, name_index_alist[i]->name) == 0) + return (name_index_alist[i]->index); + return (-1); +} + +/* Return a pointer to the entry of (name . index) for this name. + Return NULL if the index doesn't exist. */ +INDEX_ALIST * +find_index (name) + char *name; +{ + int offset = find_index_offset (name); + if (offset > -1) + return (name_index_alist[offset]); + else + return ((INDEX_ALIST *) NULL); +} + +/* Given an index name, return the offset in the_indices of this index, + or -1 if there is no such index. */ +int +translate_index (name) + char *name; +{ + INDEX_ALIST *which = find_index (name); + + if (which) + return (which->index); + else + return (-1); +} + +/* Return the index list which belongs to NAME. */ +INDEX_ELT * +index_list (name) + char *name; +{ + int which = translate_index (name); + if (which < 0) + return ((INDEX_ELT *) -1); + else + return (the_indices[which]); +} + +/* Please release me, let me go... */ +void +free_index (index) + INDEX_ELT *index; +{ + INDEX_ELT *temp; + + while ((temp = index) != (INDEX_ELT *) NULL) + { + free (temp->entry); + free (temp->node); + index = index->next; + free (temp); + } +} + +/* Flush an index by name. */ +void +undefindex (name) + char *name; +{ + int i; + int which = find_index_offset (name); + + if (which < 0) + return; + + i = name_index_alist[which]->index; + + free_index (the_indices[i]); + the_indices[i] = (INDEX_ELT *) NULL; + + free (name_index_alist[which]->name); + free (name_index_alist[which]); + name_index_alist[which] = (INDEX_ALIST *) NULL; +} + +/* Define an index known as NAME. We assign the slot number. + CODE if non-zero says to make this a code index. */ +void +defindex (name, code) + char *name; + int code; +{ + register int i, slot; + + /* If it already exists, flush it. */ + undefindex (name); + + /* Try to find an empty slot. */ + slot = -1; + for (i = 0; i < defined_indices; i++) + if (!name_index_alist[i]) + { + slot = i; + break; + } + + if (slot < 0) + { + /* No such luck. Make space for another index. */ + slot = defined_indices; + defined_indices++; + + name_index_alist = (INDEX_ALIST **) + xrealloc ((char *)name_index_alist, + (1 + defined_indices) * sizeof (INDEX_ALIST *)); + the_indices = (INDEX_ELT **) + xrealloc ((char *)the_indices, + (1 + defined_indices) * sizeof (INDEX_ELT *)); + } + + /* We have a slot. Start assigning. */ + name_index_alist[slot] = (INDEX_ALIST *) xmalloc (sizeof (INDEX_ALIST)); + name_index_alist[slot]->name = strdup (name); + name_index_alist[slot]->index = slot; + name_index_alist[slot]->code = code; + + the_indices[slot] = (INDEX_ELT *) NULL; +} + +/* Add the arguments to the current index command to the index NAME. */ +void +index_add_arg (name) + char *name; +{ + int which; + char *index_entry; + INDEX_ALIST *tem; + + tem = find_index (name); + + which = tem ? tem->index : -1; + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + append_to_expansion_output (input_text_offset + 1); +#endif /* HAVE_MACROS */ + + get_rest_of_line (&index_entry); + ignore_blank_line (); + +#if defined (HAVE_MACROS) + if (macro_expansion_output_stream) + { + int op_orig; + + remember_itext (input_text, input_text_offset); + op_orig = output_paragraph_offset; + me_execute_string (index_entry); + me_execute_string ("\n"); + output_paragraph_offset = op_orig; + } +#endif /* HAVE_MACROS */ + + if (which < 0) + { + line_error ("Unknown index reference `%s'", name); + free (index_entry); + } + else + { + INDEX_ELT *new = (INDEX_ELT *) xmalloc (sizeof (INDEX_ELT)); + new->next = the_indices[which]; + new->entry = index_entry; + new->node = current_node; + new->code = tem->code; + new->defining_line = line_number - 1; + the_indices[which] = new; + } +} + +#define INDEX_COMMAND_SUFFIX "index" + +/* The function which user defined index commands call. */ +void +gen_index () +{ + char *name = strdup (command); + if (strlen (name) >= strlen ("index")) + name[strlen (name) - strlen ("index")] = '\0'; + index_add_arg (name); + free (name); +} + +void +top_defindex (name, code) + char *name; + int code; +{ + char *temp; + + temp = (char *) xmalloc (1 + strlen (name) + strlen ("index")); + sprintf (temp, "%sindex", name); + define_user_command (temp, gen_index, 0); + defindex (name, code); + free (temp); +} + +/* Define a new index command. Arg is name of index. */ +void +cm_defindex () +{ + gen_defindex (0); +} + +void +cm_defcodeindex () +{ + gen_defindex (1); +} + +void +gen_defindex (code) + int code; +{ + char *name; + get_rest_of_line (&name); + + if (find_index (name)) + { + line_error ("Index `%s' already exists", name); + free (name); + return; + } + else + { + char *temp = (char *) alloca (1 + strlen (name) + strlen ("index")); + sprintf (temp, "%sindex", name); + define_user_command (temp, gen_index, 0); + defindex (name, code); + free (name); + } +} + +/* Append LIST2 to LIST1. Return the head of the list. */ +INDEX_ELT * +index_append (head, tail) + INDEX_ELT *head, *tail; +{ + register INDEX_ELT *t_head = head; + + if (!t_head) + return (tail); + + while (t_head->next) + t_head = t_head->next; + t_head->next = tail; + return (head); +} + +/* Expects 2 args, on the same line. Both are index abbreviations. + Make the first one be a synonym for the second one, i.e. make the + first one have the same index as the second one. */ +void +cm_synindex () +{ + int redirector, redirectee; + char *temp; + + skip_whitespace (); + get_until_in_line (" ", &temp); + redirectee = find_index_offset (temp); + skip_whitespace (); + free_and_clear (&temp); + get_until_in_line (" ", &temp); + redirector = find_index_offset (temp); + free (temp); + if (redirector < 0 || redirectee < 0) + { + line_error ("Unknown index reference"); + } + else + { + /* I think that we should let the user make indices synonymous to + each other without any lossage of info. This means that one can + say @synindex cp dt anywhere in the file, and things that used to + be in cp will go into dt. */ + INDEX_ELT *i1 = the_indices[redirectee], *i2 = the_indices[redirector]; + + if (i1 || i2) + { + if (i1) + the_indices[redirectee] = index_append (i1, i2); + else + the_indices[redirectee] = index_append (i2, i1); + } + + name_index_alist[redirectee]->index = + name_index_alist[redirector]->index; + } +} + +void +cm_pindex () /* Pinhead index. */ +{ + index_add_arg ("pg"); +} + +void +cm_vindex () /* Variable index. */ +{ + index_add_arg ("vr"); +} + +void +cm_kindex () /* Key index. */ +{ + index_add_arg ("ky"); +} + +void +cm_cindex () /* Concept index. */ +{ + index_add_arg ("cp"); +} + +void +cm_findex () /* Function index. */ +{ + index_add_arg ("fn"); +} + +void +cm_tindex () /* Data Type index. */ +{ + index_add_arg ("tp"); +} + +/* Sorting the index. */ +int +index_element_compare (element1, element2) + INDEX_ELT **element1, **element2; +{ + return (strcasecmp ((*element1)->entry, (*element2)->entry)); +} + +/* Force all index entries to be unique. */ +void +make_index_entries_unique (array, count) + INDEX_ELT **array; + int count; +{ + register int i, j; + INDEX_ELT **copy; + int counter = 1; + + copy = (INDEX_ELT **)xmalloc ((1 + count) * sizeof (INDEX_ELT *)); + + for (i = 0, j = 0; i < count; i++) + { + if ((i == (count - 1)) || + (array[i]->node != array[i + 1]->node) || + (strcmp (array[i]->entry, array[i + 1]->entry) != 0)) + copy[j++] = array[i]; + else + { + free (array[i]->entry); + free (array[i]); + } + } + copy[j] = (INDEX_ELT *)NULL; + + /* Now COPY contains only unique entries. Duplicated entries in the + original array have been freed. Replace the current array with + the copy, fixing the NEXT pointers. */ + for (i = 0; copy[i] != (INDEX_ELT *)NULL; i++) + { + + copy[i]->next = copy[i + 1]; + + /* Fix entry names which are the same. They point to different nodes, + so we make the entry name unique. */ + if ((copy[i + 1] != (INDEX_ELT *)NULL) && + (strcmp (copy[i]->entry, copy[i + 1]->entry) == 0)) + { + char *new_entry_name; + + new_entry_name = (char *)xmalloc (10 + strlen (copy[i]->entry)); + sprintf (new_entry_name, "%s <%d>", copy[i]->entry, counter); + free (copy[i]->entry); + copy[i]->entry = new_entry_name; + counter++; + } + else + counter = 1; + + array[i] = copy[i]; + } + array[i] = (INDEX_ELT *)NULL; + + /* Free the storage used only by COPY. */ + free (copy); +} + +/* Sort the index passed in INDEX, returning an array of + pointers to elements. The array is terminated with a NULL + pointer. We call qsort because it's supposed to be fast. + I think this looks bad. */ +INDEX_ELT ** +sort_index (index) + INDEX_ELT *index; +{ + INDEX_ELT *temp = index; + INDEX_ELT **array; + int count = 0; + + while (temp != (INDEX_ELT *) NULL) + { + count++; + temp = temp->next; + } + + /* We have the length. Make an array. */ + + array = (INDEX_ELT **) xmalloc ((count + 1) * sizeof (INDEX_ELT *)); + count = 0; + temp = index; + + while (temp != (INDEX_ELT *) NULL) + { + array[count++] = temp; + + /* Maybe should set line number to the defining_line? Any errors + have already been given, though, I think. */ + + /* If this particular entry should be printed as a "code" index, + then wrap the entry with "@code{...}". */ + array[count - 1]->entry = expansion (temp->entry, index->code); + + temp = temp->next; + } + array[count] = (INDEX_ELT *) NULL; /* terminate the array. */ + + /* Sort the array. */ + qsort (array, count, sizeof (INDEX_ELT *), index_element_compare); + make_index_entries_unique (array, count); + return (array); +} + +/* Non-zero means that we are in the middle of printing an index. */ +int printing_index = 0; + +/* Takes one arg, a short name of an index to print. + Outputs a menu of the sorted elements of the index. */ +void +cm_printindex () +{ + int item; + INDEX_ELT *index; + INDEX_ELT **array; + char *index_name; + unsigned line_length; + char *line; + int saved_inhibit_paragraph_indentation = inhibit_paragraph_indentation; + int saved_filling_enabled = filling_enabled; + + close_paragraph (); + get_rest_of_line (&index_name); + + index = index_list (index_name); + if (index == (INDEX_ELT *)-1) + { + line_error ("Unknown index name `%s'", index_name); + free (index_name); + return; + } + else + free (index_name); + + /* Do this before sorting, so execute_string in index_element_compare + will give the same results as when we actually print. */ + printing_index = 1; + filling_enabled = 0; + inhibit_paragraph_indentation = 1; + array = sort_index (index); + + close_paragraph (); + add_word ("* Menu:\n\n"); + +#if defined (HAVE_MACROS) + me_inhibit_expansion++; +#endif /* HAVE_MACROS */ + + /* This will probably be enough. */ + line_length = 100; + line = xmalloc (line_length); + + for (item = 0; (index = array[item]); item++) + { + /* A pathological document might have an index entry outside of any + node. Don't crash. Perhaps should warn. */ + char *index_node = index->node ? index->node : "(none)"; + unsigned new_length = strlen (index->entry) + strlen (index_node); + + if (new_length > line_length) + { + line_length = new_length + 6; /* * : .\0 */ + line = xrealloc (line, line_length); + } + + /* Print the entry, nicely formatted. We've already expanded any + commands, including any implicit @code. Thus, can't call + execute_string, since @@ has turned into @. */ + sprintf (line, "* %-37s %s.\n", index->entry, index_node); + line[2 + strlen (index->entry)] = ':'; + insert_string (line); + + /* Previous `output_paragraph' from growing to the size of the + whole index. */ + flush_output (); + } + + free (line); + +#if defined (HAVE_MACROS) + me_inhibit_expansion--; +#endif /* HAVE_MACROS */ + + printing_index = 0; + free (array); + close_single_paragraph (); + filling_enabled = saved_filling_enabled; + inhibit_paragraph_indentation = saved_inhibit_paragraph_indentation; +} + +/* User-defined commands. */ + +void +define_user_command (name, proc, needs_braces_p) + char *name; + COMMAND_FUNCTION *proc; + int needs_braces_p; +{ + int slot = user_command_array_len; + user_command_array_len++; + + if (!user_command_array) + user_command_array = (COMMAND **) xmalloc (1 * sizeof (COMMAND *)); + + user_command_array = (COMMAND **) xrealloc (user_command_array, + (1 + user_command_array_len) * + sizeof (COMMAND *)); + + user_command_array[slot] = (COMMAND *) xmalloc (sizeof (COMMAND)); + user_command_array[slot]->name = strdup (name); + user_command_array[slot]->proc = proc; + user_command_array[slot]->argument_in_braces = needs_braces_p; +} + +/* Set the paragraph indentation variable to the value specified in STRING. + Values can be: + `asis': Don't change existing indentation. + `none': Remove existing indentation. + NUM: Indent NUM spaces at the starts of paragraphs. + Note that if NUM is zero, we assume `none'. + + Returns 0 if successful, or non-zero if STRING isn't one of the above. */ +int +set_paragraph_indent (string) + char *string; +{ + if (strcmp (string, "asis") == 0) + paragraph_start_indent = 0; + else if (strcmp (string, "none") == 0) + paragraph_start_indent = -1; + else + { + if (sscanf (string, "%d", ¶graph_start_indent) != 1) + return (-1); + else + { + if (paragraph_start_indent == 0) + paragraph_start_indent = -1; + } + } + return (0); +} + +void +cm_paragraphindent () +{ + char *arg; + + get_rest_of_line (&arg); + if (set_paragraph_indent (arg) != 0) + line_error ("Bad argument to %c%s", COMMAND_PREFIX, command); + + free (arg); +} + +/* Some support for footnotes. */ + +/* Footnotes are a new construct in Info. We don't know the best method + of implementing them for sure, so we present two possiblities. + + SeparateNode: + Make them look like followed references, with the reference + destinations in a makeinfo manufactured node or, + + EndNode: + Make them appear at the bottom of the node that they originally + appeared in. */ +#define SeparateNode 0 +#define EndNode 1 + +int footnote_style = EndNode; +int first_footnote_this_node = 1; +int footnote_count = 0; + +/* Set the footnote style based on he style identifier in STRING. */ +int +set_footnote_style (string) + char *string; +{ + if ((strcasecmp (string, "separate") == 0) || + (strcasecmp (string, "MN") == 0)) + footnote_style = SeparateNode; + else if ((strcasecmp (string, "end") == 0) || + (strcasecmp (string, "EN") == 0)) + footnote_style = EndNode; + else + return (-1); + + return (0); +} + +void +cm_footnotestyle () +{ + char *arg; + + get_rest_of_line (&arg); + + /* If set on command line, do not change the footnote style. */ + if (!footnote_style_preset && set_footnote_style (arg) != 0) + line_error ("Bad argument to %c%s", COMMAND_PREFIX, command); + + free (arg); +} + +typedef struct fn +{ + struct fn *next; + char *marker; + char *note; +} FN; + +FN *pending_notes = (FN *) NULL; + +/* A method for remembering footnotes. Note that this list gets output + at the end of the current node. */ +void +remember_note (marker, note) + char *marker, *note; +{ + FN *temp = (FN *) xmalloc (sizeof (FN)); + + temp->marker = strdup (marker); + temp->note = strdup (note); + temp->next = pending_notes; + pending_notes = temp; + footnote_count++; +} + +/* How to get rid of existing footnotes. */ +void +free_pending_notes () +{ + FN *temp; + + while ((temp = pending_notes) != (FN *) NULL) + { + free (temp->marker); + free (temp->note); + pending_notes = pending_notes->next; + free (temp); + } + first_footnote_this_node = 1; + footnote_count = 0; +} + +/* What to do when you see a @footnote construct. */ + + /* Handle a "footnote". + footnote *{this is a footnote} + where "*" is the marker character for this note. */ +void +cm_footnote () +{ + char *marker; + char *note; + + get_until ("{", &marker); + canon_white (marker); + + /* Read the argument in braces. */ + if (curchar () != '{') + { + line_error ("`%c%s' expected more than just `%s'. It needs something in `{...}'", + COMMAND_PREFIX, command, marker); + free (marker); + return; + } + else + { + int braces = 1; + int temp = ++input_text_offset; + int len; + + while (braces) + { + if (temp == size_of_input_text) + { + line_error ("No closing brace for footnote `%s'", marker); + return; + } + + if (input_text[temp] == '{') + braces++; + else if (input_text[temp] == '}') + braces--; + else if (input_text[temp] == '\n') + line_number ++; + + temp++; + } + + len = (temp - input_text_offset) - 1; + note = (char *)xmalloc (len + 1); + strncpy (note, &input_text[input_text_offset], len); + note[len] = '\0'; + input_text_offset = temp; + } + + if (!current_node || !*current_node) + { + line_error ("Footnote defined without parent node"); + free (marker); + free (note); + return; + } + + if (!*marker) + { + free (marker); + + if (number_footnotes) + { + marker = (char *)xmalloc (10); + sprintf (marker, "%d", current_footnote_number); + current_footnote_number++; + } + else + marker = strdup ("*"); + } + + remember_note (marker, note); + + /* Your method should at least insert MARKER. */ + switch (footnote_style) + { + case SeparateNode: + add_word_args ("(%s)", marker); + if (first_footnote_this_node) + { + char *temp_string; + + temp_string = (char *) + xmalloc ((strlen (current_node)) + (strlen ("-Footnotes")) + 1); + + add_word_args (" (*note %s-Footnotes::)", current_node); + strcpy (temp_string, current_node); + strcat (temp_string, "-Footnotes"); + remember_node_reference (temp_string, line_number, followed_reference); + free (temp_string); + first_footnote_this_node = 0; + } + break; + + case EndNode: + add_word_args ("(%s)", marker); + break; + + default: + break; + } + free (marker); + free (note); +} + +/* Non-zero means that we are currently in the process of outputting + footnotes. */ +int already_outputting_pending_notes = 0; + +/* Output the footnotes. We are at the end of the current node. */ +void +output_pending_notes () +{ + FN *footnote = pending_notes; + + if (!pending_notes) + return; + + switch (footnote_style) + { + case SeparateNode: + { + char *old_current_node = current_node; + char *old_command = strdup (command); + + already_outputting_pending_notes++; + execute_string ("%cnode %s-Footnotes,,,%s\n", + COMMAND_PREFIX, current_node, current_node); + already_outputting_pending_notes--; + current_node = old_current_node; + free (command); + command = old_command; + } + break; + + case EndNode: + close_paragraph (); + in_fixed_width_font++; + execute_string ("---------- Footnotes ----------\n\n"); + in_fixed_width_font--; + break; + } + + /* Handle the footnotes in reverse order. */ + { + FN **array = (FN **) xmalloc ((footnote_count + 1) * sizeof (FN *)); + + array[footnote_count] = (FN *) NULL; + + while (--footnote_count > -1) + { + array[footnote_count] = footnote; + footnote = footnote->next; + } + + filling_enabled = 1; + indented_fill = 1; + + while (footnote = array[++footnote_count]) + { + + switch (footnote_style) + { + case SeparateNode: + case EndNode: + execute_string ("(%s) %s", footnote->marker, footnote->note); + close_paragraph (); + break; + } + } + close_paragraph (); + free (array); + } +} + +/* **************************************************************** */ +/* */ +/* User definable Macros (text substitution) */ +/* */ +/* **************************************************************** */ + +#if defined (HAVE_MACROS) + +/* Array of macros and definitions. */ +MACRO_DEF **macro_list = (MACRO_DEF **)NULL; + +int macro_list_len = 0; /* Number of elements. */ +int macro_list_size = 0; /* Number of slots in total. */ + +/* Return the macro definition of NAME or NULL if NAME is not defined. */ +MACRO_DEF * +find_macro (name) + char *name; +{ + register int i; + register MACRO_DEF *def; + + def = (MACRO_DEF *)NULL; + for (i = 0; macro_list && (def = macro_list[i]); i++) + { + if ((!def->inhibited) && (strcmp (def->name, name) == 0)) + break; + } + return (def); +} + +/* Add the macro NAME with ARGLIST and BODY to the list of defined macros. + SOURCE_FILE is the name of the file where this definition can be found, + and SOURCE_LINENO is the line number within that file. If a macro already + exists with NAME, then a warning is produced, and that previous + definition is overwritten. */ +void +add_macro (name, arglist, body, source_file, source_lineno, flags) + char *name; + char **arglist; + char *body; + char *source_file; + int source_lineno, flags; +{ + register MACRO_DEF *def; + + def = find_macro (name); + + if (!def) + { + if (macro_list_len + 2 >= macro_list_size) + macro_list = (MACRO_DEF **)xrealloc + (macro_list, ((macro_list_size += 10) * sizeof (MACRO_DEF *))); + + macro_list[macro_list_len] = (MACRO_DEF *)xmalloc (sizeof (MACRO_DEF)); + macro_list[macro_list_len + 1] = (MACRO_DEF *)NULL; + + def = macro_list[macro_list_len]; + macro_list_len += 1; + def->name = name; + } + else + { + char *temp_filename = input_filename; + int temp_line = line_number; + + warning ("The macro `%s' is previously defined", name); + + input_filename = def->source_file; + line_number = def->source_lineno; + + warning ("Here is the previous definition of `%s'", name); + + input_filename = temp_filename; + line_number = temp_line; + + if (def->arglist) + { + register int i; + + for (i = 0; def->arglist[i]; i++) + free (def->arglist[i]); + + free (def->arglist); + } + free (def->source_file); + free (def->body); + } + + def->source_file = strdup (source_file); + def->source_lineno = source_lineno; + def->body = body; + def->arglist = arglist; + def->inhibited = 0; + def->flags = flags; +} + +/* Delete the macro with name NAME. The macro is deleted from the list, + but it is also returned. If there was no macro defined, NULL is + returned. */ +MACRO_DEF * +delete_macro (name) + char *name; +{ + register int i; + register MACRO_DEF *def; + + def = (MACRO_DEF *)NULL; + + for (i = 0; macro_list && (def = macro_list[i]); i++) + if (strcmp (def->name, name) == 0) + { + memmove (macro_list + i, macro_list + i + 1, + ((macro_list_len + 1) - i) * sizeof (MACRO_DEF *)); + break; + } + return (def); +} + +/* Return the arglist on the current line. This can behave in two different + ways, depending on the variable BRACES_REQUIRED_FOR_MACRO_ARGS. */ +int braces_required_for_macro_args = 0; + +char ** +get_macro_args (def) + MACRO_DEF *def; +{ + register int i; + char *word; + + /* Quickly check to see if this macro has been invoked with any arguments. + If not, then don't skip any of the following whitespace. */ + for (i = input_text_offset; i < size_of_input_text; i++) + if (!cr_or_whitespace (input_text[i])) + break; + + if (input_text[i] != '{') + { + if (braces_required_for_macro_args) + { + return ((char **)NULL); + } + else + { + /* Braces are not required to fill out the macro arguments. If + this macro takes one argument, it is considered to be the + remainder of the line, sans whitespace. */ + if (def->arglist && def->arglist[0] && !def->arglist[1]) + { + char **arglist; + + get_rest_of_line (&word); + if (input_text[input_text_offset - 1] == '\n') + input_text_offset--; + /* canon_white (word); */ + arglist = (char **)xmalloc (2 * sizeof (char *)); + arglist[0] = word; + arglist[1] = (char *)NULL; + return (arglist); + } + else + { + /* The macro either took no arguments, or took more than + one argument. In that case, it must be invoked with + arguments surrounded by braces. */ + return ((char **)NULL); + } + } + } + return (get_brace_args (def->flags & ME_QUOTE_ARG)); +} + +/* Substitute actual parameters for named parameters in body. + The named parameters which appear in BODY must by surrounded + reverse slashes, as in \foo\. */ +char * +apply (named, actuals, body) + char **named, **actuals, *body; +{ + register int i; + int new_body_index, new_body_size; + char *new_body, *text; + int length_of_actuals; + + length_of_actuals = array_len (actuals); + new_body_size = strlen (body); + new_body = (char *)xmalloc (1 + new_body_size); + + /* Copy chars from BODY into NEW_BODY. */ + i = 0; new_body_index = 0; + + while (1) + { + if (!body[i]) + break; + + if (body[i] != '\\') + new_body[new_body_index++] = body[i++]; + else + { + /* Snarf parameter name, check against named parameters. */ + char *param; + int param_start, which, len; + + param_start = ++i; + while ((body[i]) && (body[i] != '\\')) + i++; + + len = i - param_start; + param = (char *)xmalloc (1 + len); + memcpy (param, body + param_start, len); + param[len] = '\0'; + + if (body[i]) + i++; + + /* Now check against named parameters. */ + for (which = 0; named && named[which]; which++) + if (strcmp (named[which], param) == 0) + break; + + if (named[which]) + { + if (which < length_of_actuals) + text = actuals[which]; + else + text = (char *)NULL; + + if (!text) + text = ""; + + len = strlen (text); + } + else + { + len += 2; + text = (char *)xmalloc (1 + len); + sprintf (text, "\\%s\\", param); + } + + if ((2 + strlen (param)) < len) + new_body = (char *)xrealloc + (new_body, new_body_size += (1 + len)); + + free (param); + + strcpy (new_body + new_body_index, text); + new_body_index += len; + + if (!named[which]) + free (text); + } + } + new_body[new_body_index] = '\0'; + return (new_body); +} + +/* Execute the macro passed in DEF, a pointer to a MACRO_DEF. */ +void +execute_macro (def) + MACRO_DEF *def; +{ + register int i; + char **arglist; + int num_args; + char *execution_string = (char *)NULL; + + if (macro_expansion_output_stream && !me_inhibit_expansion) + me_append_before_this_command (); + + /* Find out how many arguments this macro definition takes. */ + num_args = array_len (def->arglist); + + /* Gather the arguments present on the line if there are any. */ + arglist = get_macro_args (def); + + if (num_args < array_len (arglist)) + { + free_array (arglist); + line_error ("Macro `%s' called with too many args", def->name); + return; + } + + if (def->body) + execution_string = apply (def->arglist, arglist, def->body); + + free_array (arglist); + + if (def->body) + { + if (macro_expansion_output_stream && !me_inhibit_expansion) + { + remember_itext (input_text, input_text_offset); + me_execute_string (execution_string); + } + else + execute_string ("%s", execution_string); + + free (execution_string); + } +} + +/* Read and remember the definition of a macro. */ +void +cm_macro () +{ + register int i; + char *name, **arglist, *body, *line; + int body_size, body_index; + int depth = 1; + int defining_line = line_number; + int flags = 0; + + arglist = (char **)NULL; + body = (char *)NULL; + body_size = 0; + body_index = 0; + + if (macro_expansion_output_stream) + me_append_before_this_command (); + + skip_whitespace (); + + /* Get the name of the macro. This is the set of characters which are + not whitespace and are not `{' immediately following the @macro. */ + { + int start = input_text_offset; + int len; + + for (i = start; + (i < size_of_input_text) && + (input_text[i] != '{') && + (!cr_or_whitespace (input_text[i])); + i++); + + len = i - start; + name = (char *)xmalloc (1 + len); + strncpy (name, input_text + start, len); + name[len] = '\0'; + input_text_offset = i; + } + + skip_whitespace (); + + /* It is not required that the definition of a macro includes an arglist. + If not, don't try to get the named parameters, just use a null list. */ + if (curchar () == '{') + { + int arglist_index = 0, arglist_size = 0; + int gathering_words = 1; + char *word = (char *)NULL; + int character; + + /* Read the words inside of the braces which determine the arglist. + These words will be replaced within the body of the macro at + execution time. */ + + input_text_offset++; + skip_whitespace_and_newlines (); + + while (gathering_words) + { + int len; + + for (i = input_text_offset; + character = input_text[i]; + i++) + { + switch (character) + { + case '\n': + line_number++; + case ' ': + case '\t': + case ',': + case '}': + /* Found the end of the current arglist word. Save it. */ + len = i - input_text_offset; + word = (char *)xmalloc (1 + len); + strncpy (word, input_text + input_text_offset, len); + word[len] = '\0'; + input_text_offset = i; + + /* Advance to the comma or close-brace that signified + the end of the argument. */ + while ((character = curchar ()) + && character != ',' + && character != '}') + { + input_text_offset++; + if (character == '\n') + line_number++; + } + + /* Add the word to our list of words. */ + if ((arglist_index + 2) >= arglist_size) + arglist = (char **)xrealloc + (arglist, (arglist_size += 10) * sizeof (char *)); + + arglist[arglist_index++] = word; + arglist[arglist_index] = (char *)NULL; + break; + } + + if (character == '}') + { + input_text_offset++; + gathering_words = 0; + break; + } + + if (character == ',') + { + input_text_offset++; + skip_whitespace_and_newlines (); + i = input_text_offset - 1; + } + } + } + } + + /* Read the text carefully until we find an "@end macro" which + matches this one. The text in between is the body of the macro. */ + skip_whitespace_and_newlines (); + + while (depth) + { + if ((input_text_offset + 9) > size_of_input_text) + { + int temp_line = line_number; + line_number = defining_line; + line_error ("%cend macro not found", COMMAND_PREFIX); + line_number = temp_line; + return; + } + + get_rest_of_line (&line); + + /* Handle commands only meaningful within a macro. */ + if ((*line == COMMAND_PREFIX) && (depth == 1) && + (strncmp (line + 1, "allow-recursion", 15) == 0) && + (line[16] == '\0' || whitespace (line[16]))) + { + for (i = 16; whitespace (line[i]); i++); + strcpy (line, line + i); + flags |= ME_RECURSE; + if (!*line) + { + free (line); + continue; + } + } + + if ((*line == COMMAND_PREFIX) && (depth == 1) && + (strncmp (line + 1, "quote-arg", 9) == 0) && + (line[10] == '\0' || whitespace (line[10]))) + { + for (i = 10; whitespace (line[i]); i++); + strcpy (line, line + i); + + if (arglist && arglist[0] && !arglist[1]) + { + flags |= ME_QUOTE_ARG; + if (!*line) + { + free (line); + continue; + } + } + else + { + line_error ("%cquote-arg only useful when the macro takes a single argument", + COMMAND_PREFIX); + } + } + + if ((*line == COMMAND_PREFIX) && + (strncmp (line + 1, "macro ", 6) == 0)) + depth++; + + if ((*line == COMMAND_PREFIX) && + (strncmp (line + 1, "end macro", 9) == 0)) + depth--; + + if (depth) + { + if ((body_index + strlen (line) + 3) >= body_size) + body = (char *)xrealloc + (body, body_size += 3 + strlen (line)); + strcpy (body + body_index, line); + body_index += strlen (line); + body[body_index++] = '\n'; + body[body_index] = '\0'; + } + free (line); + } + + /* We now have the name, the arglist, and the body. However, BODY + includes the final newline which preceded the `@end macro' text. + Delete it. */ + if (body && strlen (body)) + body[strlen (body) - 1] = '\0'; + + add_macro (name, arglist, body, input_filename, defining_line, flags); + + if (macro_expansion_output_stream) + remember_itext (input_text, input_text_offset); +} + +void +cm_unmacro () +{ + register int i; + char *line, *name; + MACRO_DEF *def; + + if (macro_expansion_output_stream) + me_append_before_this_command (); + + get_rest_of_line (&line); + canon_white (line); + + for (i = 0; line[i] && !whitespace (line[i]); i++); + name = (char *)xmalloc (i); + strncpy (name, line, i); + name[i] = '\0'; + + def = delete_macro (name); + + if (def) + { + free (def->source_file); + free (def->name); + free (def->body); + + if (def->arglist) + { + register int i; + + for (i = 0; def->arglist[i]; i++) + free (def->arglist[i]); + + free (def->arglist); + } + + free (def); + } + + free (line); + free (name); + + if (macro_expansion_output_stream) + remember_itext (input_text, input_text_offset); +} + +/* How to output sections of the input file verbatim. */ + +/* Set the value of POINTER's offset to OFFSET. */ +ITEXT * +remember_itext (pointer, offset) + char *pointer; + int offset; +{ + register int i; + ITEXT *itext = (ITEXT *)NULL; + + /* If we have no info, initialize a blank list. */ + if (!itext_info) + { + itext_info = (ITEXT **)xmalloc ((itext_size = 10) * sizeof (ITEXT *)); + for (i = 0; i < itext_size; i++) + itext_info[i] = (ITEXT *)NULL; + } + + /* If the pointer is already present in the list, then set the offset. */ + for (i = 0; i < itext_size; i++) + if ((itext_info[i] != (ITEXT *)NULL) && + (itext_info[i]->pointer == pointer)) + { + itext = itext_info[i]; + itext_info[i]->offset = offset; + break; + } + + if (i == itext_size) + { + /* Find a blank slot, (or create a new one), and remember the + pointer and offset. */ + for (i = 0; i < itext_size; i++) + if (itext_info[i] == (ITEXT *)NULL) + break; + + /* If not found, then add some slots. */ + if (i == itext_size) + { + register int j; + + itext_info = (ITEXT **)xrealloc + (itext_info, (itext_size += 10) * sizeof (ITEXT *)); + + for (j = i; j < itext_size; j++) + itext_info[j] = (ITEXT *)NULL; + } + + /* Now add the pointer and the offset. */ + itext_info[i] = (ITEXT *)xmalloc (sizeof (ITEXT)); + itext_info[i]->pointer = pointer; + itext_info[i]->offset = offset; + itext = itext_info[i]; + } + return (itext); +} + +/* Forget the input text associated with POINTER. */ +void +forget_itext (pointer) + char *pointer; +{ + register int i; + + for (i = 0; i < itext_size; i++) + if (itext_info[i] && (itext_info[i]->pointer == pointer)) + { + free (itext_info[i]); + itext_info[i] = (ITEXT *)NULL; + break; + } +} + +/* Append the text which appeared in input_text from the last offset to + the character just before the command that we are currently executing. */ +void +me_append_before_this_command () +{ + register int i; + + for (i = input_text_offset; i && (input_text[i] != COMMAND_PREFIX); i--); + maybe_write_itext (input_text, i); +} + +/* Similar to execute_string (), but only takes a single string argument, + and remembers the input text location, etc. */ +void +me_execute_string (execution_string) + char *execution_string; +{ + pushfile (); + input_text_offset = 0; + input_text = execution_string; + input_filename = strdup (input_filename); + size_of_input_text = strlen (execution_string); + + remember_itext (execution_string, 0); + + executing_string++; + reader_loop (); + popfile (); + executing_string--; +} + +/* Append the text which appears in input_text from the last offset to + the current OFFSET. */ +void +append_to_expansion_output (offset) + int offset; +{ + register int i; + ITEXT *itext = (ITEXT *)NULL; + + for (i = 0; i < itext_size; i++) + if (itext_info[i] && itext_info[i]->pointer == input_text) + { + itext = itext_info[i]; + break; + } + + if (!itext) + itext = remember_itext (input_text, 0); + + if (offset > itext->offset) + { + write_region_to_macro_output + (input_text, itext->offset, offset); + remember_itext (input_text, offset); + } +} + +/* Only write this input text iff it appears in our itext list. */ +void +maybe_write_itext (pointer, offset) + char *pointer; + int offset; +{ + register int i; + ITEXT *itext = (ITEXT *)NULL; + + for (i = 0; i < itext_size; i++) + if (itext_info[i] && (itext_info[i]->pointer == pointer)) + { + itext = itext_info[i]; + break; + } + + if (itext && (itext->offset < offset)) + { + write_region_to_macro_output (itext->pointer, itext->offset, offset); + remember_itext (pointer, offset); + } +} + +void +write_region_to_macro_output (string, start, end) + char *string; + int start, end; +{ + if (macro_expansion_output_stream) + fwrite (string + start, 1, end - start, macro_expansion_output_stream); +} + +#endif /* HAVE_MACROS */ + +/* Return the length of the array in ARRAY. */ +int +array_len (array) + char **array; +{ + register int i = 0; + + if (array) + for (i = 0; array[i] != (char *)NULL; i++); + + return (i); +} + +void +free_array (array) + char **array; +{ + if (array) + { + register int i; + + for (i = 0; array[i] != (char *)NULL; i++) + free (array[i]); + + free (array); + } +} + +/* Function is used even when we don't have macros. Although, I have + to admit, it is unlikely that you would have a use for it if you + aren't using macros. */ +char ** +get_brace_args (quote_single) + int quote_single; +{ + char **arglist, *word; + int arglist_index, arglist_size; + int character, escape_seen, start; + int depth = 1; + + /* There is an arglist in braces here, so gather the args inside of it. */ + skip_whitespace_and_newlines (); + input_text_offset++; + arglist = (char **)NULL; + arglist_index = arglist_size = 0; + + get_arg: + skip_whitespace_and_newlines (); + start = input_text_offset; + escape_seen = 0; + + while (character = curchar ()) + { + if (character == '\\') + { + input_text_offset += 2; + escape_seen = 1; + } + else if (character == '{') + { + depth++; + input_text_offset++; + } + else if ((character == ',' && !quote_single) || + ((character == '}') && depth == 1)) + { + int len = input_text_offset - start; + + if (len || (character != '}')) + { + word = (char *)xmalloc (1 + len); + strncpy (word, input_text + start, len); + word[len] = '\0'; + + /* Clean up escaped characters. */ + if (escape_seen) + { + register int i; + + for (i = 0; word[i]; i++) + if (word[i] == '\\') + memmove (word + i, word + i + 1, + 1 + strlen (word + i + 1)); + } + + if (arglist_index + 2 >= arglist_size) + arglist = (char **)xrealloc + (arglist, (arglist_size += 10) * sizeof (char *)); + + arglist[arglist_index++] = word; + arglist[arglist_index] = (char *)NULL; + } + + input_text_offset++; + if (character == '}') + break; + else + goto get_arg; + } + else if (character == '}') + { + depth--; + input_text_offset++; + } + else + { + input_text_offset++; + if (character == '\n') line_number++; + } + } + return (arglist); +} + +/* **************************************************************** */ +/* */ +/* Looking For Include Files */ +/* */ +/* **************************************************************** */ + +/* Given a string containing units of information separated by colons, + return the next one pointed to by INDEX, or NULL if there are no more. + Advance INDEX to the character after the colon. */ +char * +extract_colon_unit (string, index) + char *string; + int *index; +{ + int i, start; + + i = *index; + + if (!string || (i >= strlen (string))) + return ((char *)NULL); + + /* Each call to this routine leaves the index pointing at a colon if + there is more to the path. If I is > 0, then increment past the + `:'. If I is 0, then the path has a leading colon. Trailing colons + are handled OK by the `else' part of the if statement; an empty + string is returned in that case. */ + if (i && string[i] == ':') + i++; + + start = i; + + while (string[i] && string[i] != ':') i++; + + *index = i; + + if (i == start) + { + if (string[i]) + (*index)++; + + /* Return "" in the case of a trailing `:'. */ + return (strdup ("")); + } + else + { + char *value; + + value = (char *)xmalloc (1 + (i - start)); + strncpy (value, &string[start], (i - start)); + value [i - start] = '\0'; + + return (value); + } +} + +/* Return the full pathname for FILENAME by searching along PATH. + When found, return the stat () info for FILENAME in FINFO. + If PATH is NULL, only the current directory is searched. + If the file could not be found, return a NULL pointer. */ +char * +get_file_info_in_path (filename, path, finfo) + char *filename, *path; + struct stat *finfo; +{ + char *dir; + int result, index = 0; + + if (path == (char *)NULL) + path = "."; + + /* Handle absolute pathnames. "./foo", "/foo", "../foo". */ + if (*filename == '/' || + (*filename == '.' && + (filename[1] == '/' || + (filename[1] == '.' && filename[2] == '/')))) + { + if (stat (filename, finfo) == 0) + return (strdup (filename)); + else + return ((char *)NULL); + } + + while (dir = extract_colon_unit (path, &index)) + { + char *fullpath; + + if (!*dir) + { + free (dir); + dir = strdup ("."); + } + + fullpath = (char *)xmalloc (2 + strlen (dir) + strlen (filename)); + sprintf (fullpath, "%s/%s", dir, filename); + free (dir); + + result = stat (fullpath, finfo); + + if (result == 0) + return (fullpath); + else + free (fullpath); + } + return ((char *)NULL); +} diff --git a/texinfo/makeinfo/makeinfo.h b/texinfo/makeinfo/makeinfo.h new file mode 100644 index 000000000000..399764eb88b5 --- /dev/null +++ b/texinfo/makeinfo/makeinfo.h @@ -0,0 +1,193 @@ +/* makeinfo.h -- Declarations for Makeinfo. + $Id: makeinfo.h,v 1.1 1997/08/21 22:58:08 jason Exp $ + + Copyright (C) 1996 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. + + Written by Brian Fox (bfox@ai.mit.edu). */ + +/* Why, oh why, did I ever listen to rms when he said: + "Don't make lots of small files, just make one big one!" I've + regretted it ever since with this program, and with readline. + bfox@ai.mit.edu Thu Jul 11 07:54:32 1996 */ + +#if !defined (MAKEINFO_H) +#define MAKEINFO_H + +#if defined (COMPILING_MAKEINFO) +# define DECLARE(type, var, init) type var = init +#else +# define DECLARE(type, var, init) extern type var +#endif + +enum insertion_type +{ + menu, detailmenu, quotation, lisp, smalllisp, example, smallexample, + display, itemize, format, enumerate, cartouche, multitable, table, + ftable, vtable, group, ifinfo, flushleft, flushright, ifset, + ifclear, deffn, defun, defmac, defspec, defvr, defvar, defopt, + deftypefn, deftypefun, deftypevr, deftypevar, defcv, defivar, defop, + defmethod, deftypemethod, deftp, direntry, bad_type +}; + +DECLARE (int, insertion_level, 0); + +#if defined (COMPILING_MAKEINFO) +char *insertion_type_names[] = +{ + "menu", "detailmenu", "quotation", "lisp", "smalllisp", "example", + "smallexample", "display", "itemize", "format", "enumerate", + "cartouche", "multitable", "table", "ftable", "vtable", "group", + "ifinfo", "flushleft", "flushright", "ifset", "ifclear", "deffn", + "defun", "defmac", "defspec", "defvr", "defvar", "defopt", + "deftypefn", "deftypefun", "deftypevr", "deftypevar", "defcv", + "defivar", "defop", "defmethod", "deftypemethod", "deftp", "direntry", + "bad_type" +}; +#endif + +typedef struct istack_elt +{ + struct istack_elt *next; + char *item_function; + char *filename; + int line_number; + int filling_enabled; + int indented_fill; + enum insertion_type insertion; + int inhibited; + int in_fixed_width_font; +} INSERTION_ELT; + +DECLARE (INSERTION_ELT *, insertion_stack, (INSERTION_ELT *)NULL); + +/* Current output stream. */ +DECLARE (FILE *, output_stream, (FILE *)NULL); + +/* Output paragraph buffer. */ +DECLARE (unsigned char *, output_paragraph, (unsigned char *)NULL); + +/* Offset into OUTPUT_PARAGRAPH. */ +DECLARE (int, output_paragraph_offset, 0); + +/* The output paragraph "cursor" horizontal position. */ +DECLARE (int, output_column, 0); + +/* Non-zero means output_paragraph contains text. */ +DECLARE (int, paragraph_is_open, 0); + +/* The amount of indentation to apply at the start of each line. */ +DECLARE (int, current_indent, 0); + +/* nonzero if we are currently processing a multitable command */ +DECLARE (int, multitable_active, 0); + +/* The column at which long lines are broken. */ +DECLARE (int, fill_column, 72); + +/* The current input file state. */ +DECLARE (char *, input_filename, (char *)NULL); +DECLARE (char *, input_text, (char *)NULL); +DECLARE (int, size_of_input_text, 0); +DECLARE (int, input_text_offset, 0); +DECLARE (int, line_number, 0); + +#define curchar() input_text[input_text_offset] +/* **************************************************************** */ +/* */ +/* Global Defines */ +/* */ +/* **************************************************************** */ + +/* Error levels */ +#define NO_ERROR 0 +#define SYNTAX 2 +#define FATAL 4 + +/* C's standard macros don't check to make sure that the characters being + changed are within range. So I have to check explicitly. */ + +/* GNU Library doesn't have toupper(). Until GNU gets this fixed, I will + have to do it. */ +#ifndef toupper +#define toupper(c) ((c) - 32) +#endif + +#define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c))) +#define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c))) + +#define control_character_bit 0x40 /* %01000000, must be off. */ +#define meta_character_bit 0x080/* %10000000, must be on. */ +#define CTL(c) ((c) & (~control_character_bit)) +#define UNCTL(c) coerce_to_upper(((c)|control_character_bit)) +#define META(c) ((c) | (meta_character_bit)) +#define UNMETA(c) ((c) & (~meta_character_bit)) + +#define whitespace(c) (((c) == '\t') || ((c) == ' ')) +#define sentence_ender(c) ((c) == '.' || (c) == '?' || (c) == '!') +#define cr_or_whitespace(c) (((c) == '\t') || ((c) == ' ') || ((c) == '\n')) + +#ifndef isletter +#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z')) +#endif + +#ifndef isupper +#define isupper(c) ((c) >= 'A' && (c) <= 'Z') +#endif + +#ifndef isdigit +#define isdigit(c) ((c) >= '0' && (c) <= '9') +#endif + +#ifndef digit_value +#define digit_value(c) ((c) - '0') +#endif + +#define member(c, s) (strchr (s, c) != NULL) + +#define COMMAND_PREFIX '@' + +/* Stuff for splitting large files. */ +#define SPLIT_SIZE_THRESHOLD 70000 /* What's good enough for Stallman... */ +#define DEFAULT_SPLIT_SIZE 50000 /* Is probably good enough for me. */ + +DECLARE (int, splitting, 1); /* Defaults to true for now. */ + +typedef void COMMAND_FUNCTION (); /* So I can say COMMAND_FUNCTION *foo; */ + +#define command_char(c) ((!whitespace(c)) && \ + ((c) != '\n') && \ + ((c) != '{') && \ + ((c) != '}') && \ + ((c) != '=')) + +#define skip_whitespace() \ + while ((input_text_offset != size_of_input_text) && \ + whitespace (curchar())) \ + input_text_offset++ + +#define skip_whitespace_and_newlines() \ + do { \ + while ((input_text_offset != size_of_input_text) && \ + (whitespace (curchar ()) || (curchar () == '\n'))) \ + { \ + if (curchar () == '\n') \ + line_number++; \ + input_text_offset++; \ + } \ + } while (0) + +#endif /* !MAKEINFO_H */ diff --git a/texinfo/makeinfo/makeinfo.texi b/texinfo/makeinfo/makeinfo.texi new file mode 100644 index 000000000000..04c136875ab8 --- /dev/null +++ b/texinfo/makeinfo/makeinfo.texi @@ -0,0 +1,311 @@ +\input texinfo @c -*-texinfo-*- +@comment %**start of header +@setfilename makeinfo.info +@set VERSION 1.61 +@paragraphindent none +@comment %**start of header +@comment $Id: makeinfo.texi,v 1.1 1997/08/21 22:58:08 jason Exp $ + +@ifinfo +@format +START-INFO-DIR-ENTRY +* makeinfo: (makeinfo). Making info files from texinfo files. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@dircategory Texinfo documentation system +@direntry +* makeinfo: (makeinfo). Convert Texinfo source to Info or plain ASCII. +@end direntry + +@ifinfo +This file is an extract from the @cite{Texinfo} manual.@* +It documents Makeinfo, a program that converts Texinfo +files into Info files. + +Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end ifinfo + +@titlepage +@title GNU Makeinfo +@author Brian J. Fox and Robert J. Chassell + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end titlepage + +@node Top +@chapter What is @code{makeinfo}? + +@iftex +This file documents the use of the @code{makeinfo} program, versions +@value{VERSION} and later. It is an extract from the @cite{Texinfo} manual. +@end iftex + +@code{makeinfo} is a program for converting @dfn{Texinfo} files into @dfn{Info} +files. Texinfo is a documentation system that uses a single source file to +produce both on-line information and printed output. + +You can read the on-line information using Info; type @code{info} to +learn about Info. +@ifinfo +@xref{Top, Texinfo, Overview of Texinfo, Texinfo, Texinfo}, +@end ifinfo +@iftex +See the @cite{Texinfo} manual, +@end iftex +to learn about the Texinfo documentation system. + +@menu +* Formatting Control:: Controlling the width of lines, paragraph + indentation, and other similar formatting. + +* Options:: Command line options which control the + behaviour of Makeinfo. + +* Pointer Validation:: How Makeinfo can help you to track node + references through complex Texinfo files. + +* Index:: Index of Concepts. +@end menu + +@c Removed this for 3.8 until it's time to rewrite it. +@c * The Macro Facility:: Makeinfo allows the use of @dfn{macros}. + +@node Formatting Control +@section Controlling Paragraph Formats + +Without any special options, @code{makeinfo} @dfn{fills} the paragraphs that +it outputs to an Info file. Filling is the process of breaking and connecting +lines so that lines are the same length as or shorter than the number +specified as the fill column. Lines are broken between words. With +@code{makeinfo}, you can control: + +@itemize @bullet +@item +The width of each paragraph (the @dfn{fill-column}). +@item +The amount of indentation that the first line of +each paragraph receives (the @dfn{paragraph-indentation}). +@end itemize + +@node Options +@section Command Line Options + +The following command line options are available for @code{makeinfo}. + +@need 100 +@table @code +@item -D @var{var} +Cause @var{var} to be defined. This is equivalent to +@code{@@set @var{var}} in the Texinfo file. + +@need 150 +@item --error-limit @var{limit} +Set the maximum number of errors that @code{makeinfo} will report +before exiting (on the assumption that continuing would be useless). +The default number of errors that can be reported before +@code{makeinfo} gives up is 100.@refill + +@need 150 +@item --fill-column @var{width} +Specify the maximum number of columns in a line; this is the right-hand +edge of a line. Paragraphs that are filled will be filled to this +width. The default value for @code{fill-column} is 72. +@refill + +@item --footnote-style @var{style} +Set the footnote style to @var{style}, either @samp{end} for the end +node style or @samp{separate} for the separate node style. The value +set by this option overrides the value set in a Texinfo file by an +@code{@@footnotestyle} command. When the footnote style is +@samp{separate}, @code{makeinfo} makes a new node containing the +footnotes found in the current node. When the footnote style is +@samp{end}, @code{makeinfo} places the footnote references at the end +of the current node.@refill + +@need 150 +@item -I @var{dir} +Add @code{dir} to the directory search list for finding files that are +included using the @code{@@include} command. By default, +@code{makeinfo} searches only the current directory. + +@need 150 +@item --no-headers +Do not include menus or node lines in the output. This results in an +@sc{ascii} file that you cannot read in Info since it does not contain +the requisite nodes or menus; but you can print such a file in a +single, typewriter-like font and produce acceptable output. + +@need 150 +@item --no-split +Suppress the splitting stage of @code{makeinfo}. Normally, large +output files (where the size is greater than 70k bytes) are split into +smaller subfiles, each one approximately 50k bytes. If you specify +@samp{--no-split}, @code{makeinfo} will not split up the output +file.@refill + +@need 100 +@item --no-pointer-validate +@item --no-validate +Suppress the pointer-validation phase of @code{makeinfo}. Normally, +after a Texinfo file is processed, some consistency checks are made to +ensure that cross references can be resolved, etc. +@xref{Pointer Validation}.@refill + +@need 150 +@item --no-warn +Suppress the output of warning messages. This does @emph{not} +suppress the output of error messages, only warnings. You might +want this if the file you are creating has examples of Texinfo cross +references within it, and the nodes that are referenced do not actually +exist.@refill + +@item --no-number-footnotes +Supress automatic footnote numbering. By default, @code{makeinfo} +numbers each footnote sequentially in a single node, resetting the +current footnote number to 1 at the start of each node. + +@need 150 +@item --output @var{file} +@itemx -o @var{file} +Specify that the output should be directed to @var{file} and not to the +file name specified in the @code{@@setfilename} command found in the Texinfo +source. @var{file} can be the special token @samp{-}, which specifies +standard output. + +@need 150 +@item --paragraph-indent @var{indent} +Set the paragraph indentation style to @var{indent}. The value set by +this option overrides the value set in a Texinfo file by an +@code{@@paragraphindent} command. The value of @var{indent} is +interpreted as follows:@refill + +@itemize @bullet +@item +If the value of @var{indent} is @samp{asis}, do not change the +existing indentation at the starts of paragraphs.@refill + +@item +If the value of @var{indent} is zero, delete any existing +indentation.@refill + +@item +If the value of @var{indent} is greater than zero, indent each +paragraph by that number of spaces.@refill +@end itemize + +@need 100 +@item --reference-limit @var{limit} +Set the value of the number of references to a node that +@code{makeinfo} will make without reporting a warning. If a node has more +than this number of references in it, @code{makeinfo} will make the +references but also report a warning.@refill + +@need 150 +@item -U @var{var} +Cause @var{var} to be undefined. This is equivalent to +@code{@@clear @var{var}} in the Texinfo file. + +@need 100 +@item --verbose +Cause @code{makeinfo} to display messages saying what it is doing. +Normally, @code{makeinfo} only outputs messages if there are errors or +warnings.@refill + +@need 100 +@item --version +Report the version number of this copy of @code{makeinfo}.@refill + +@item --help +Show a summary of the commend line arguments to @code{makeinfo}. +@end table + +@node Pointer Validation +@section Pointer Validation +@cindex Pointer validation with @code{makeinfo} +@cindex Validation of pointers + +If you do not suppress pointer-validation (by using the +@samp{--no-pointer-validation} option), @code{makeinfo} +will check the validity of the final Info file. Mostly, +this means ensuring that nodes you have referenced +really exist. Here is a complete list of what is +checked:@refill + +@enumerate +@item +If a `Next', `Previous', or `Up' node reference is a reference to a +node in the current file and is not an external reference such as to +@file{(dir)}, then the referenced node must exist.@refill + +@item +In every node, if the `Previous' node is different from the `Up' node, +then the `Previous' node must also be pointed to by a `Next' node.@refill + +@item +Every node except the `Top' node must have an `Up' pointer.@refill + +@item +The node referenced by an `Up' pointer must contain a reference to the +current node in some manner other than through a `Next' reference. +This includes menu entries and cross references.@refill + +@item +If the `Next' reference of a node is not the same as the `Next' reference +of the `Up' reference, then the node referenced by the `Next' pointer +must have a `Previous' pointer that points back to the current node. +This rule allows the last node in a section to point to the first node +of the next chapter.@refill +@end enumerate + +@c We don't want to advertise redefining commands. +@c lowersections +@c include macro.texi +@c raisesections + +@lowersections +@node Index +@appendix Index +@printindex cp +@raisesections + +@contents +@bye diff --git a/texinfo/makeinfo/multi.c b/texinfo/makeinfo/multi.c new file mode 100644 index 000000000000..5d4bb70b28e7 --- /dev/null +++ b/texinfo/makeinfo/multi.c @@ -0,0 +1,418 @@ +/* multi.c -- Multitable stuff for makeinfo. + $Id: multi.c,v 1.1 1997/08/21 22:58:08 jason Exp $ + + Copyright (C) 1996 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 +#include "makeinfo.h" + +#define MAXCOLS 100 /* remove this limit later @@ */ + + +/* + * Output environments. This is a hack grafted onto existing + * structure. The "output environment" used to consist of the + * global variables `output_paragraph', `fill_column', etc. + * Routines like add_char would manipulate these variables. + * + * Now, when formatting a multitable, we maintain separate environments + * for each column. That way we can build up the columns separately + * and write them all out at once. The "current" output environment" + * is still kept in those global variables, so that the old output + * routines don't have to change. But we provide routines to save + * and restore these variables in an "environment table". The + * `select_output_environment' function switches from one output + * environment to another. + * + * Environment #0 (i.e. element #0 of the table) is the regular + * environment that is used when we're not formatting a multitable. + * + * Environment #N (where N = 1,2,3,...) is the env. for column #N of + * the table, when a multitable is active. + */ + +/* contents of an output environment */ +/* some more vars may end up being needed here later @@ */ +struct env +{ + unsigned char *output_paragraph; + int output_paragraph_offset; + int output_column; + int paragraph_is_open; + int current_indent; + int fill_column; +} envs[MAXCOLS]; /* the environment table */ + +/* index in environment table of currently selected environment */ +static int current_env_no; + +/* column number of last column in current multitable */ +static int last_column; + +/* flags indicating whether horizontal and vertical separators need + to be drawn, separating rows and columns in the current multitable. */ +static int hsep, vsep; + +void +do_multitable () +{ + int ncolumns; + + /* + * multitable strategy: + * for each item { + * for each column in an item { + * initialize a new paragraph + * do ordinary formatting into the new paragraph + * save the paragraph away + * repeat if there are more paragraphs in the column + * } + * dump out the saved paragraphs and free the storage + * } + */ + + if (multitable_active) + { + line_error ("Multitables cannot be nested"); + return; + } + + /* scan the current item function to get the field widths + and number of columns, and set up the output environment list + accordingly. */ + ncolumns = setup_multitable_parameters (); + if (hsep) + draw_horizontal_separator (); + + /* The next @item command will direct stdout into the first column + and start processing. @tab will then switch to the next column, + and @item will flush out the saved output and return to the first + column. Environment #1 is the first column. (Environment #0 is + the normal output) */ + + ++multitable_active; +} + +/* Read the parameters for a multitable from the current command + line, save the parameters away, and return the + number of columns. */ +int +setup_multitable_parameters () +{ + char *params = insertion_stack->item_function; + int nchars; + float columnfrac; + char command[200]; + int i = 1; + + /* We implement @hsep and @vsep even though TeX doesn't. + We don't get mixing of @columnfractions and templates right, + but TeX doesn't either. */ + hsep = vsep = 0; + + while (*params) { + while (whitespace (*params)) + params++; + + if (*params == '@') { + sscanf (params, "%s%n", command, &nchars); + params += nchars; + if (strcmp (command, "@hsep") == 0) + hsep++; + else if (strcmp (command, "@vsep") == 0) + vsep++; + else if (strcmp (command, "@columnfractions") == 0) { + /* Clobber old environments and create new ones, + starting at #1. Environment #0 is the normal standard output, + so we don't mess with it. */ + for ( ; i <= MAXCOLS; i++) { + if (sscanf (params, "%f%n", &columnfrac, &nchars) < 1) + goto done; + params += nchars; + setup_output_environment (i, (int) (columnfrac * fill_column + .5)); + } + } + + } else if (*params == '{') { + char *start = params; + while ((*params != '}' || params[-1] == '@') && *params) { + params++; + } + /* This gives us two spaces between columns. Seems reasonable. + Really should expand the text, though, so a template of + `@code{foo}' has a width of three, not ten. Also have to match + braces, then. */ + setup_output_environment (i++, params++ - start); + + } else { + warning ("ignoring stray text `%s' after @multitable", params); + break; + } + } + +done: + + flush_output (); + inhibit_output_flushing (); + + last_column = i - 1; + return last_column; +} + +/* Initialize environment number ENV_NO, of width WIDTH. + The idea is that we're going to use one environment for each column of + a multitable, so we can build them up separately and print them + all out at the end. */ +int +setup_output_environment (env_no, width) + int env_no; + int width; +{ + int old_env = select_output_environment (env_no); + + /* clobber old environment and set width of new one */ + init_paragraph (); + + /* make our change */ + fill_column = width; + + /* Save new environment and restore previous one. */ + select_output_environment (old_env); + + return env_no; +} + +/* Direct current output to environment number N. Used when + switching work from one column of a multitable to the next. + Returns previous environment number. */ +int +select_output_environment (n) + int n; +{ + struct env *e = &envs[current_env_no]; + int old_env_no = current_env_no; + + /* stash current env info from global vars into the old environment */ + e->output_paragraph = output_paragraph; + e->output_paragraph_offset = output_paragraph_offset; + e->output_column = output_column; + e->paragraph_is_open = paragraph_is_open; + e->current_indent = current_indent; + e->fill_column = fill_column; + + /* now copy new environment into global vars */ + current_env_no = n; + e = &envs[current_env_no]; + output_paragraph = e->output_paragraph; + output_paragraph_offset = e->output_paragraph_offset; + output_column = e->output_column; + paragraph_is_open = e->paragraph_is_open; + current_indent = e->current_indent; + fill_column = e->fill_column; + return old_env_no; +} + +/* advance to the next environment number */ +int +nselect_next_environment () +{ + if (current_env_no >= last_column) { + line_error ("Too many columns in multitable item (max %d)", last_column); + return 1; + } + select_output_environment (current_env_no + 1); +} + + +static void output_multitable_row (); + +/* start a new item (row) of a multitable */ +multitable_item () +{ + if (!multitable_active) { + /* impossible, I think. */ + error ("multitable item not in active multitable"); + exit (1); + } + if (current_env_no > 0) { + output_multitable_row (); + } + /* start at column 1 */ + select_output_environment (1); + if (!output_paragraph) { + line_error ("Cannot select column #%d in multitable", current_env_no); + exit (FATAL); + } + + init_column (); + + return 0; +} + +/* do anything needed at the beginning of processing a + multitable column. */ +init_column () +{ + /* don't indent 1st paragraph in the item */ + cm_noindent (); + + /* throw away possible whitespace after @item or @tab command */ + skip_whitespace (); +} + +/* Output a row. Have to keep `output_position' up-to-date for each + character we output, or the tags table will be off, leading to + chopped-off output files and undefined nodes (because they're in the + wrong file, etc.). Perhaps it would be better to accumulate this + value somewhere and add it once at the end of the table, or return it + as the value, but this seems simplest. */ + +static void +out_char (ch) + int ch; +{ + extern int output_position; + putc (ch, output_stream); + output_position++; +} + + +static void +output_multitable_row () +{ + int i, j, remaining; + + /* offset in the output paragraph of the next char needing + to be output for that column. */ + int offset[MAXCOLS]; + + for (i = 0; i <= last_column; i++) + offset[i] = 0; + + /* select the current environment, to make sure the env variables + get updated */ + select_output_environment (current_env_no); + +#define CHAR_ADDR(n) (offset[i] + (n)) +#define CHAR_AT(n) (envs[i].output_paragraph[CHAR_ADDR(n)]) + + /* remove trailing whitespace from each column */ + for (i = 1; i <= last_column; i++) { + while (cr_or_whitespace (CHAR_AT (envs[i].output_paragraph_offset - 1))) { + envs[i].output_paragraph_offset--; + } + } + + /* read the current line from each column, outputting them all + pasted together. Do this til all lines are output from all + columns. */ + for (;;) { + remaining = 0; + /* first, see if there is any work to do */ + for (i = 1; i <= last_column; i++) { + if (CHAR_ADDR (0) < envs[i].output_paragraph_offset) { + remaining = 1; + break; + } + } + if (!remaining) + break; + + if (vsep) + out_char ('|'); + + for (i = 1; i <= last_column; i++) { + for (j = 0; CHAR_ADDR (j) < envs[i].output_paragraph_offset; j++) { + if (CHAR_AT (j) == '\n') + break; + out_char (CHAR_AT (j)); + } + offset[i] += j + 1; /* skip last text plus skip the newline */ + for (; j <= envs[i].fill_column; j++) + out_char (' '); + if (vsep) + out_char ('|'); /* draw column separator */ + } + out_char ('\n'); /* end of line */ + } + + if (hsep) + draw_horizontal_separator (); + + /* Now dispose of the buffered output. */ + for (i = 1; i <= last_column; i++) { + select_output_environment (i); + init_paragraph (); + } +} + +#undef CHAR_AT +#undef CHAR_ADDR + +int +draw_horizontal_separator () +{ + int i, j; + if (vsep) + out_char ('+'); + for (i = 1; i <= last_column; i++) { + for (j = 0; j <= envs[i].fill_column; j++) + out_char ('-'); + if (vsep) + out_char ('+'); + } + out_char ('\n'); +} + +/* select a new column in current row of multitable */ +void +cm_tab () +{ + if (!multitable_active) + error ("ignoring @tab outside of multitable"); + + nselect_next_environment (); + init_column (); +} + +/* close a multitable, flushing its output and resetting + whatever needs resetting */ +void +end_multitable () +{ + int i; + + output_multitable_row (); + + /* Multitables cannot be nested. Otherwise, we'd have to save the + previous output environment number on a stack somewhere, and then + restore to that environment. */ + select_output_environment (0); + close_paragraph (); + insert ('\n'); /* we swallow newlines, so insert one of our own */ + + multitable_active = 0; + uninhibit_output_flushing (); + +#if 0 + printf ("** Multicolumn output from last row:\n"); + for (i = 1; i <= last_column; i++) { + select_output_environment (i); + printf ("* column #%d: output = %s\n", i, output_paragraph); + } +#endif +} diff --git a/texinfo/makeinfo/multiformat.texi b/texinfo/makeinfo/multiformat.texi new file mode 100644 index 000000000000..0c6c467dc0d2 --- /dev/null +++ b/texinfo/makeinfo/multiformat.texi @@ -0,0 +1,40 @@ +@c multiformat.texi: -*- Texinfo -*- \input texinfo.tex + +@c Copyright (c) 1995 Universal Access, Inc +@c Author: Brian J. Fox (bfox@ua.com) Sun Apr 2 07:56:23 1995. +@setfilename multiformat.info + +@include html.texi + +@ifset html +@html +@end ifset + +@node First Node, First Section, (dir), (dir) +@chapter First Chapter +Here is some text that belongs in the first chapter. Nothing very +exciting happens here, but this is enough text to span a couple of +lines, and we feel that is important. +@paragraph + +This is the second paragraph of the first chapter. Note that the +formatting commands in @code{HTML} seem to do the right thing, as do the +commands when invoked in @code{Texinfo} mode and in @TeX{}. + +@node First Section, , First Node, First Node +@isection First Section + +Here is some text in the first section of the first chapter. We are +trying very hard to examine the output here to see exactly how proper it +is. If I wasn't so tired, we could probably see it already. +@paragraph + +Here is a list of items: +@paragraph + +@itemize @bullet +@item Here is the first item. +@item Here is the second item. +@end itemize + +@bye diff --git a/texinfo/testsuite/ChangeLog b/texinfo/testsuite/ChangeLog new file mode 100644 index 000000000000..72366e2db687 --- /dev/null +++ b/texinfo/testsuite/ChangeLog @@ -0,0 +1,37 @@ +Thu Oct 3 15:31:09 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (clean): Move config.log to distclean. + +Wed Oct 2 16:01:58 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * configure.in: Switch to autoconf configure.in + * configure: New. + * Makefile.in: Use autoconf-substituted values. + (clean): Remove config.log. + (distclean): Remove config.cache. + +Tue May 17 15:49:09 1994 Bill Cox (bill@rtl.cygnus.com) + + * config/unix.exp: Replace error proc calls with perror calls. + +Mon Apr 11 17:37:09 1994 Bill Cox (bill@rtl.cygnus.com) + + * Makefile.in (EXPECT, RUNTEST): Set these for the check goal. + +Mon Apr 11 10:31:00 1994 Bill Cox (bill@rtl.cygnus.com) + + * Makefile.in (check): Set TCL_LIBRARY for runtest. + +Fri Jun 18 23:16:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com) + + * makeinfo.0/atnode.exp, text/atnode.texi: Add test for at sign + in node name. + +Wed May 19 13:02:59 1993 Jim Kingdon (kingdon@cygnus.com) + + * makeinfo.0/conditions.exp, text/conditions.texi: Add test for bug + currently being worked around in GDB manual. + +May 1993 Roland Pesch (pesch@cygnus.com) + + * New directory. diff --git a/texinfo/testsuite/Makefile.in b/texinfo/testsuite/Makefile.in new file mode 100644 index 000000000000..4920a6290c0b --- /dev/null +++ b/texinfo/testsuite/Makefile.in @@ -0,0 +1,100 @@ +# Makefile for regression testing GNU texinfo. +# Copyright (C) 1987, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc. + +#This file is part of GNU texinfo. + +#texinfo 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. + +#texinfo 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. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ + +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +tooldir = $(libdir)/$(target_alias) + +datadir = @datadir@/deja-gnu + +EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; \ + then echo $${rootme}/../../expect/expect ; \ + else echo expect; fi` + +RUNTEST = `if [ -f ${srcdir}/../../dejagnu/runtest ] ; \ + then echo ${srcdir}/../../dejagnu/runtest ; \ + else echo runtest ; fi` +RUNTESTFLAGS = +FLAGS_TO_PASS = + +#### host, target, and site specific Makefile frags come in here. + +all: + +info: + +install-info: + +check: site.exp all + rootme=`pwd`; export rootme; \ + srcdir=${srcdir} ; export srcdir ; \ + EXPECT=${EXPECT} ; export EXPECT ; \ + if [ -f $${rootme}/../../expect/expect ] ; then \ + TCL_LIBRARY=$${srcdir}/../../tcl/library ; \ + export TCL_LIBRARY ; fi ; \ + $(RUNTEST) $(RUNTESTFLAGS) $(FLAGS_TO_PASS) --tool makeinfo \ + --srcdir $(srcdir) --target $(target_canonical) + +site.exp: ./config.status Makefile + @echo "Making a new config file..." + -@rm -f ./tmp? + @touch site.exp + + -@mv site.exp site.bak + @echo "## these variables are automatically generated by make ##" > ./tmp0 + @echo "# Do not edit here. If you wish to override these values" >> ./tmp0 + @echo "# add them to the last section" >> ./tmp0 + @echo "set host_os ${host_os}" >> ./tmp0 + @echo "set host_alias ${host_alias}" >> ./tmp0 + @echo "set host_cpu ${host_cpu}" >> ./tmp0 + @echo "set host_vendor ${host_vendor}" >> ./tmp0 + @echo "set target_os ${target_os}" >> ./tmp0 + @echo "set target_alias ${target_alias}" >> ./tmp0 + @echo "set target_cpu ${target_cpu}" >> ./tmp0 + @echo "set target_vendor ${target_vendor}" >> ./tmp0 + @echo "set host_triplet ${host_canonical}" >> ./tmp0 + @echo "set target_triplet ${target_canonical}" >> ./tmp0 + @echo "set tool binutils" >> ./tmp0 + @echo "set srcdir ${srcdir}" >> ./tmp0 + @echo "set objdir `pwd`" >> ./tmp0 + @echo "set MAKEINFO makeinfo" >> ./tmp0 + @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0 + @cat ./tmp0 > site.exp + @cat site.bak | sed \ + -e '1,/^## All variables above are.*##/ d' >> site.exp + -@rm -f ./tmp? + +install: +uninstall: + +clean: + -rm -f *~ */*~ core *.info* *.log *.sum *.plog *.psum + +distclean: clean + -rm -f Makefile config.status site.exp config.cache config.log + +Makefile : $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) + $(SHELL) ./config.status + diff --git a/texinfo/testsuite/config/unix.exp b/texinfo/testsuite/config/unix.exp new file mode 100644 index 000000000000..12b38ba0ec6d --- /dev/null +++ b/texinfo/testsuite/config/unix.exp @@ -0,0 +1,29 @@ +load_lib utils.exp ;# Get the file of utilities for Texinfo tests + +default MAKEINFO makeinfo ;# ensure Tcl var MAKEINFO has value + +# Ensure we can execute this tool +if [is_executable $MAKEINFO] then { + verbose "$MAKEINFO is executable\n" 1 +} else { + perror "$MAKEINFO: cannot execute\n" + exit 1 ;# no point in running any makeinfo tests +} + +# makeinfo_start undefined by choice; +# 1) it makes it clearer where the output is to start +# $MAKEINFO directly with `catch' from each test case, +# and +# 2) this takes no more lines than it would to call makeinfo_start + +proc makeinfo_exit {} {} + +proc makeinfo_version {} { + global MAKEINFO + set tmp [ exec $MAKEINFO --version ] + regexp "version.*$" $tmp vn ;# "vn" undef if pattern not found + if [info exists vn] then { + clone_output "[which $MAKEINFO] $vn\n" + } +} + diff --git a/texinfo/testsuite/configure b/texinfo/testsuite/configure new file mode 100755 index 000000000000..5337df459f36 --- /dev/null +++ b/texinfo/testsuite/configure @@ -0,0 +1,707 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.10 +# 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: + +# 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= + +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.10" + 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 LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LANG+set}" = set; then LANG=C; export LANG; 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=makeinfo.0/atnode.exp + +# 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 $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' + +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 + + + +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 +# 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 | + sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \ + >> 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 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# 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 </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.10" + 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 + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%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 + +CEOF +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[: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 relative srcdir, etc. 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 + + 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 + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +" -f conftest.subs $ac_given_srcdir/$ac_file_in > $ac_file +fi; done +rm -f conftest.subs + + + +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 + diff --git a/texinfo/testsuite/configure.in b/texinfo/testsuite/configure.in new file mode 100644 index 000000000000..8cf18763df0e --- /dev/null +++ b/texinfo/testsuite/configure.in @@ -0,0 +1,5 @@ +dnl Process this file with autoconf to produce a configure script. +AC_PREREQ(2.5) +AC_INIT(makeinfo.0/atnode.exp) + +AC_OUTPUT(Makefile) diff --git a/texinfo/testsuite/lib/utils.exp b/texinfo/testsuite/lib/utils.exp new file mode 100644 index 000000000000..713e9f2332a0 --- /dev/null +++ b/texinfo/testsuite/lib/utils.exp @@ -0,0 +1,31 @@ +# utils.exp, a collection of Tcl/Expect utilities for texinfo tests. + +# ----------default-------------------------------------------- +# default VAR VALUE +# Check whether VAR exists and has a nonempty value; +# if not, use VALUE as the default +# ------------------------------------------------------------- +proc default {varname varval} { + upvar $varname outervar + if { ![info exists outervar] || [string match {} $outervar] } then { + verbose "Defaulting $varname to $varval\n" 1 + set outervar $varval + } else { + verbose "$varname retains existing value $outervar\n" 1 + } + return +} + + +# ----------is_executable-------------------------------------- +# is_executable NAME +# Boolean predicate: is NAME an executable file +# somewhere on our PATH? +# ------------------------------------------------------------- +proc is_executable {name} { + if [ file executable [which $name] ] then { + return 1 + } else { + return 0 + } +} diff --git a/texinfo/testsuite/makeinfo.0/atnode.exp b/texinfo/testsuite/makeinfo.0/atnode.exp new file mode 100644 index 000000000000..19724347cbbb --- /dev/null +++ b/texinfo/testsuite/makeinfo.0/atnode.exp @@ -0,0 +1,19 @@ +# Lessons: +# 1) may use \ to continue long lines +# 2) Careful in specifying string end on string match, to be sure +# to exclude errors! (cf output from nonsense.exp) + +catch "exec $MAKEINFO -o ./atnode.info $srcdir/text/atnode.texi" maki_out + +verbose "Makeinfo output: $maki_out" 1 + +setup_xfail "*-*-*" +if [string match \ + "Making*file*atnode*from*atnode.texi'." \ + "$maki_out" \ + ] then { + pass "at sign in node name" +} else { + fail "at sign in node name" +} +clear_xfail "*-*-*" diff --git a/texinfo/testsuite/makeinfo.0/conditions.exp b/texinfo/testsuite/makeinfo.0/conditions.exp new file mode 100644 index 000000000000..c62c66a2a047 --- /dev/null +++ b/texinfo/testsuite/makeinfo.0/conditions.exp @@ -0,0 +1,21 @@ +# Lessons: +# 1) may use \ to continue long lines +# 2) Careful in specifying string end on string match, to be sure +# to exclude errors! (cf output from nonsense.exp) + +catch "exec $MAKEINFO -o ./conditions.info $srcdir/text/conditions.texi" maki_out + +verbose "Makeinfo output: $maki_out" 1 + +# The gdb manual works around this by putting a blank line after the pair of +# @end if* commands. +setup_xfail "*-*-*" +if [string match \ + "Making*file*conditions*from*conditions.texi'." \ + "$maki_out" \ + ] then { + pass "texinfo conditions" +} else { + fail "texinfo conditions" +} +clear_xfail "*-*-*" diff --git a/texinfo/testsuite/makeinfo.0/mini.exp b/texinfo/testsuite/makeinfo.0/mini.exp new file mode 100644 index 000000000000..17d48bdee619 --- /dev/null +++ b/texinfo/testsuite/makeinfo.0/mini.exp @@ -0,0 +1,17 @@ +# Lessons: +# 1) may use \ to continue long lines +# 2) Careful in specifying string end on string match, to be sure +# to exclude errors! (cf output from nonsense.exp) + +catch "exec $MAKEINFO -o ./mini.info $srcdir/text/minimal.texi" maki_out + +verbose "Makeinfo output: $maki_out" 1 + +if [string match \ + "Making*file*mini*from*minimal.texi'." \ + "$maki_out" \ + ] then { + pass "minimal source file" +} else { + fail "minimal source file" +} diff --git a/texinfo/testsuite/makeinfo.0/missnode.exp b/texinfo/testsuite/makeinfo.0/missnode.exp new file mode 100644 index 000000000000..fb278f08cfb9 --- /dev/null +++ b/texinfo/testsuite/makeinfo.0/missnode.exp @@ -0,0 +1,25 @@ +#set real_verbose [set verbose] +#set verbose 2 +catch "exec $MAKEINFO -o ./missnode.info $srcdir/text/missnode.texi" maki_out + +verbose "Makeinfo output: $maki_out" 1 + +if [string match \ + "*Validation error*Next*doesn't exist*" \ + "$maki_out" \ + ] then { + pass "missing Next detection" +} else { + fail "missing Next detection" +} + +if [string match \ + "*Validation error*Menu*doesn't exist*" \ + "$maki_out" \ + ] then { + pass "missing menu entry detection" +} else { + fail "missing menu entry detection" +} + +#set verbose [set real_verbose] diff --git a/texinfo/testsuite/makeinfo.0/nonsense.exp b/texinfo/testsuite/makeinfo.0/nonsense.exp new file mode 100644 index 000000000000..3b19f2680fc3 --- /dev/null +++ b/texinfo/testsuite/makeinfo.0/nonsense.exp @@ -0,0 +1,12 @@ +catch "exec $MAKEINFO -o ./nonsense.info $srcdir/text/nonsense.texi" maki_out + +verbose "Makeinfo output: $maki_out" 1 + +if [string match \ + "*Unknown info command*" \ + "$maki_out" \ + ] then { + pass "unknown command detection" +} else { + fail "unknown command detection" +} diff --git a/texinfo/testsuite/makeinfo.0/not.exp b/texinfo/testsuite/makeinfo.0/not.exp new file mode 100644 index 000000000000..3c5ac5a59646 --- /dev/null +++ b/texinfo/testsuite/makeinfo.0/not.exp @@ -0,0 +1,15 @@ +# lessons: +# 1) ALL expected args to a cmd on one line! +# 2) `*' at end of string match pattern essential---match *complete* string! +# 3) $srcdir (at least when .) expanded in dir where runtest invoked--- +# NOT dir where test lives! +# 4) stderr already folded into stdout; no need for 2>&1 or such things + +catch "exec $MAKEINFO $srcdir/text/not.texi" maki_out +verbose "Makeinfo output: $maki_out" 1 + +if [string match "No*setfilename*found*in*" "$maki_out"] then { + pass "@setfilename required" +} else { + fail "@setfilename required" +} diff --git a/texinfo/testsuite/makeinfo.0/smstruct.exp b/texinfo/testsuite/makeinfo.0/smstruct.exp new file mode 100644 index 000000000000..1a0c00f275c0 --- /dev/null +++ b/texinfo/testsuite/makeinfo.0/smstruct.exp @@ -0,0 +1,14 @@ +catch "exec $MAKEINFO -o ./smstruct.info $srcdir/text/smstruct.texi" maki_out + +verbose "Makeinfo output: $maki_out" 1 + +if [string match \ + "Making*file*smstruct*from*smstruct.texi'." \ + "$maki_out" \ + ] then { + pass "structured source file" +} else { + fail "structured source file" +} + + diff --git a/texinfo/testsuite/text/atnode.texi b/texinfo/testsuite/text/atnode.texi new file mode 100644 index 000000000000..443738d19aa5 --- /dev/null +++ b/texinfo/testsuite/text/atnode.texi @@ -0,0 +1,21 @@ +@setfilename atnode + +@node Top +@c @top Toity + +@menu +* @@string:: A node with an at sign in its name +* Joke:: A node without an at sign in its name +@end menu + +@node @@string +@chapter On the Nature of Strings + +They can be thick or thin. + +@node Joke +@chapter Stop me if You've Heard this One + +These three strings (@pxref{@@string}), walked into a bar, and... + +@bye diff --git a/texinfo/testsuite/text/conditions.texi b/texinfo/testsuite/text/conditions.texi new file mode 100644 index 000000000000..5c4a32097201 --- /dev/null +++ b/texinfo/testsuite/text/conditions.texi @@ -0,0 +1,26 @@ +@setfilename conditions +@set foo1 +@clear foo2 +@clear bar +@node Top +@top Test of conditions +@menu +@ifclear bar +@ifset foo1 +* Foo1:: This text should be included. +@end ifset +@ifset foo2 +* Foo2:: This text should not be included. +@end ifset +@end ifclear +* Foo3:: And we have no blank line here. +@end menu +@node Foo1 +@chapter Foo1 +@ifset foo2 +@node Foo2 +@chapter Foo2 +@end ifset +@node Foo3 +@chapter Foo3 +@bye diff --git a/texinfo/testsuite/text/dfltnode.texi b/texinfo/testsuite/text/dfltnode.texi new file mode 100644 index 000000000000..3800f42d8530 --- /dev/null +++ b/texinfo/testsuite/text/dfltnode.texi @@ -0,0 +1,21 @@ +@setfilename smstruct + +@node Top +@top Hoity + +@menu +* First:: The Very First Node +* Second:: Another Whole Node +@end menu + +@node First +@chapter The Very First Node + +This node is a real node, yes indeed. + +@node Second +@chapter Another Whole Node + +Will wonders never cease? + +@bye diff --git a/texinfo/testsuite/text/minimal.texi b/texinfo/testsuite/text/minimal.texi new file mode 100644 index 000000000000..682881d4fd37 --- /dev/null +++ b/texinfo/testsuite/text/minimal.texi @@ -0,0 +1,2 @@ +@setfilename mini +@bye diff --git a/texinfo/testsuite/text/missnode.texi b/texinfo/testsuite/text/missnode.texi new file mode 100644 index 000000000000..db997de86325 --- /dev/null +++ b/texinfo/testsuite/text/missnode.texi @@ -0,0 +1,22 @@ +@setfilename missingnode + +@node Top, First,, +@top Hoity + +@menu +* First:: The very first node +* Second:: Another whole node +* Third:: No such thing +@end menu + +@node First, Second, Top, Top +@chapter The Very First Node + +This node is a real node, yes indeed. + +@node Second, Third, First, Top +@chapter Another Whole Node + +Will wonders never cease? + +@bye diff --git a/texinfo/testsuite/text/nonsense.texi b/texinfo/testsuite/text/nonsense.texi new file mode 100644 index 000000000000..b84fb3d7080e --- /dev/null +++ b/texinfo/testsuite/text/nonsense.texi @@ -0,0 +1,3 @@ +@setfilename mini +@nonsense +@bye diff --git a/texinfo/testsuite/text/not.texi b/texinfo/testsuite/text/not.texi new file mode 100644 index 000000000000..a8d29b95088b --- /dev/null +++ b/texinfo/testsuite/text/not.texi @@ -0,0 +1 @@ +Ceci n'est pas un fichier Texinfo. diff --git a/texinfo/testsuite/text/smstruct.texi b/texinfo/testsuite/text/smstruct.texi new file mode 100644 index 000000000000..64f98ea23377 --- /dev/null +++ b/texinfo/testsuite/text/smstruct.texi @@ -0,0 +1,21 @@ +@setfilename smstruct + +@node Top, First,, +@top Hoity + +@menu +* First:: The Very First Node +* Second:: Another Whole Node +@end menu + +@node First, Second, Top, Top +@chapter The Very First Node + +This node is a real node, yes indeed. + +@node Second,,First,Top +@chapter Another Whole Node + +Will wonders never cease? + +@bye diff --git a/texinfo/texinfo.tex b/texinfo/texinfo.tex new file mode 100644 index 000000000000..96345315e30f --- /dev/null +++ b/texinfo/texinfo.tex @@ -0,0 +1,4800 @@ +%% TeX macros to handle Texinfo files. +%% $Id: texinfo.tex,v 1.1 1997/08/21 22:57:53 jason Exp $ + +% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, +% 94, 95, 96, 97 Free Software Foundation, Inc. + +%This texinfo.tex file 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 texinfo.tex file 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 texinfo.tex file; see the file COPYING. If not, write +%to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +%Boston, MA 02111-1307, USA. + + +%In other words, you are welcome to use, share and improve this program. +%You are forbidden to forbid anyone else to use, share and improve +%what you give them. Help stamp out software-hoarding! + + +% Send bug reports to bug-texinfo@prep.ai.mit.edu. +% Please include a *precise* test case in each bug report. + + +% Make it possible to create a .fmt file just by loading this file: +% if the underlying format is not loaded, start by loading it now. +% Added by gildea November 1993. +\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi + +% This automatically updates the version number based on RCS. +\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} +\deftexinfoversion$Revision: 1.1 $ +\message{Loading texinfo package [Version \texinfoversion]:} + +% If in a .fmt file, print the version number +% and turn on active characters that we couldn't do earlier because +% they might have appeared in the input file name. +\everyjob{\message{[Texinfo version \texinfoversion]}\message{} + \catcode`+=\active \catcode`\_=\active} + +% Save some parts of plain tex whose names we will redefine. + +\let\ptexb=\b +\let\ptexbullet=\bullet +\let\ptexc=\c +\let\ptexcomma=\, +\let\ptexdot=\. +\let\ptexdots=\dots +\let\ptexend=\end +\let\ptexequiv = \equiv +\let\ptexi=\i +\let\ptexlbrace=\{ +\let\ptexrbrace=\} +\let\ptexstar=\* +\let\ptext=\t + +% Be sure we're in horizontal mode when doing a tie, since we make space +% equivalent to this in @example-like environments. Otherwise, a space +% at the beginning of a line will start with \penalty -- and +% since \penalty is valid in vertical mode, we'd end up putting the +% penalty on the vertical list instead of in the new paragraph. +{\catcode`@ = 11 + % Avoid using \@M directly, because that causes trouble + % if the definition is written into an index file. + \global\let\tiepenalty = \@M + \gdef\tie{\leavevmode\penalty\tiepenalty\ } +} + + +\message{Basics,} +\chardef\other=12 + +% If this character appears in an error message or help string, it +% starts a new line in the output. +\newlinechar = `^^J + +% Set up fixed words for English. +\ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi% +\def\putwordInfo{Info}% +\ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi% +\ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi% +\ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi% +\ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi% +\ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi% +\ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi% +\ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi% +\ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi% +\ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi% + +% Ignore a token. +% +\def\gobble#1{} + +\hyphenation{ap-pen-dix} +\hyphenation{mini-buf-fer mini-buf-fers} +\hyphenation{eshell} + +% Margin to add to right of even pages, to left of odd pages. +\newdimen \bindingoffset +\newdimen \normaloffset +\newdimen\pagewidth \newdimen\pageheight + +% Sometimes it is convenient to have everything in the transcript file +% and nothing on the terminal. We don't just call \tracingall here, +% since that produces some useless output on the terminal. +% +\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% +\def\loggingall{\tracingcommands2 \tracingstats2 + \tracingpages1 \tracingoutput1 \tracinglostchars1 + \tracingmacros2 \tracingparagraphs1 \tracingrestores1 + \showboxbreadth\maxdimen\showboxdepth\maxdimen +}% + +% For @cropmarks command. +% Do @cropmarks to get crop marks. +% +\newif\ifcropmarks +\let\cropmarks = \cropmarkstrue +% +% Dimensions to add cropmarks at corners. +% Added by P. A. MacKay, 12 Nov. 1986 +% +\newdimen\cornerlong \newdimen\cornerthick +\newdimen\topandbottommargin +\newdimen\outerhsize \newdimen\outervsize +\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks +\outerhsize=7in +%\outervsize=9.5in +% Alternative @smallbook page size is 9.25in +\outervsize=9.25in +\topandbottommargin=.75in + +% Main output routine. +\chardef\PAGE = 255 +\output = {\onepageout{\pagecontents\PAGE}} + +\newbox\headlinebox +\newbox\footlinebox + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions, but you have to call it yourself. +\def\onepageout#1{% + \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi + % + \ifodd\pageno \advance\hoffset by \bindingoffset + \else \advance\hoffset by -\bindingoffset\fi + % + % Do this outside of the \shipout so @code etc. will be expanded in + % the headline as they should be, not taken literally (outputting ''code). + \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% + \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% + % + {% + % Have to do this stuff outside the \shipout because we want it to + % take effect in \write's, yet the group defined by the \vbox ends + % before the \shipout runs. + % + \escapechar = `\\ % use backslash in output files. + \indexdummies % don't expand commands in the output. + \normalturnoffactive % \ in index entries must not stay \, e.g., if + % the page break happens to be in the middle of an example. + \shipout\vbox{% + \ifcropmarks \vbox to \outervsize\bgroup + \hsize = \outerhsize + \line{\ewtop\hfil\ewtop}% + \nointerlineskip + \line{% + \vbox{\moveleft\cornerthick\nstop}% + \hfill + \vbox{\moveright\cornerthick\nstop}% + }% + \vskip\topandbottommargin + \line\bgroup + \hfil % center the page within the outer (page) hsize. + \ifodd\pageno\hskip\bindingoffset\fi + \vbox\bgroup + \fi + % + \unvbox\headlinebox + \pagebody{#1}% + \unvbox\footlinebox + % + \ifcropmarks + \egroup % end of \vbox\bgroup + \hfil\egroup % end of (centering) \line\bgroup + \vskip\topandbottommargin plus1fill minus1fill + \boxmaxdepth = \cornerthick + \line{% + \vbox{\moveleft\cornerthick\nsbot}% + \hfill + \vbox{\moveright\cornerthick\nsbot}% + }% + \nointerlineskip + \line{\ewbot\hfil\ewbot}% + \egroup % \vbox from first cropmarks clause + \fi + }% end of \shipout\vbox + }% end of group with \turnoffactive + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi +} + +\newinsert\margin \dimen\margin=\maxdimen + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi +% marginal hacks, juha@viisa.uucp (Juha Takala) +\ifvoid\margin\else % marginal info is present + \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi +\dimen@=\dp#1 \unvbox#1 +\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi +\ifr@ggedbottom \kern-\dimen@ \vfil \fi} +} + +% Here are the rules for the cropmarks. Note that they are +% offset so that the space between them is truly \outerhsize or \outervsize +% (P. A. MacKay, 12 November, 1986) +% +\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} +\def\nstop{\vbox + {\hrule height\cornerthick depth\cornerlong width\cornerthick}} +\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} +\def\nsbot{\vbox + {\hrule height\cornerlong depth\cornerthick width\cornerthick}} + +% Parse an argument, then pass it to #1. The argument is the rest of +% the input line (except we remove a trailing comment). #1 should be a +% macro which expects an ordinary undelimited TeX argument. +% +\def\parsearg#1{% + \let\next = #1% + \begingroup + \obeylines + \futurelet\temp\parseargx +} + +% If the next token is an obeyed space (from an @example environment or +% the like), remove it and recurse. Otherwise, we're done. +\def\parseargx{% + % \obeyedspace is defined far below, after the definition of \sepspaces. + \ifx\obeyedspace\temp + \expandafter\parseargdiscardspace + \else + \expandafter\parseargline + \fi +} + +% Remove a single space (as the delimiter token to the macro call). +{\obeyspaces % + \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} + +{\obeylines % + \gdef\parseargline#1^^M{% + \endgroup % End of the group started in \parsearg. + % + % First remove any @c comment, then any @comment. + % Result of each macro is put in \toks0. + \argremovec #1\c\relax % + \expandafter\argremovecomment \the\toks0 \comment\relax % + % + % Call the caller's macro, saved as \next in \parsearg. + \expandafter\next\expandafter{\the\toks0}% + }% +} + +% Since all \c{,omment} does is throw away the argument, we can let TeX +% do that for us. The \relax here is matched by the \relax in the call +% in \parseargline; it could be more or less anything, its purpose is +% just to delimit the argument to the \c. +\def\argremovec#1\c#2\relax{\toks0 = {#1}} +\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} + +% \argremovec{,omment} might leave us with trailing spaces, though; e.g., +% @end itemize @c foo +% will have two active spaces as part of the argument with the +% `itemize'. Here we remove all active spaces from #1, and assign the +% result to \toks0. +% +% This loses if there are any *other* active characters besides spaces +% in the argument -- _ ^ +, for example -- since they get expanded. +% Fortunately, Texinfo does not define any such commands. (If it ever +% does, the catcode of the characters in questionwill have to be changed +% here.) But this means we cannot call \removeactivespaces as part of +% \argremovec{,omment}, since @c uses \parsearg, and thus the argument +% that \parsearg gets might well have any character at all in it. +% +\def\removeactivespaces#1{% + \begingroup + \ignoreactivespaces + \edef\temp{#1}% + \global\toks0 = \expandafter{\temp}% + \endgroup +} + +% Change the active space to expand to nothing. +% +\begingroup + \obeyspaces + \gdef\ignoreactivespaces{\obeyspaces\let =\empty} +\endgroup + + +\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} + +%% These are used to keep @begin/@end levels from running away +%% Call \inENV within environments (after a \begingroup) +\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} +\def\ENVcheck{% +\ifENV\errmessage{Still within an environment. Type Return to continue.} +\endgroup\fi} % This is not perfect, but it should reduce lossage + +% @begin foo is the same as @foo, for now. +\newhelp\EMsimple{Type to continue.} + +\outer\def\begin{\parsearg\beginxxx} + +\def\beginxxx #1{% +\expandafter\ifx\csname #1\endcsname\relax +{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else +\csname #1\endcsname\fi} + +% @end foo executes the definition of \Efoo. +% +\def\end{\parsearg\endxxx} +\def\endxxx #1{% + \removeactivespaces{#1}% + \edef\endthing{\the\toks0}% + % + \expandafter\ifx\csname E\endthing\endcsname\relax + \expandafter\ifx\csname \endthing\endcsname\relax + % There's no \foo, i.e., no ``environment'' foo. + \errhelp = \EMsimple + \errmessage{Undefined command `@end \endthing'}% + \else + \unmatchedenderror\endthing + \fi + \else + % Everything's ok; the right environment has been started. + \csname E\endthing\endcsname + \fi +} + +% There is an environment #1, but it hasn't been started. Give an error. +% +\def\unmatchedenderror#1{% + \errhelp = \EMsimple + \errmessage{This `@end #1' doesn't have a matching `@#1'}% +} + +% Define the control sequence \E#1 to give an unmatched @end error. +% +\def\defineunmatchedend#1{% + \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% +} + + +% Single-spacing is done by various environments (specifically, in +% \nonfillstart and \quotations). +\newskip\singlespaceskip \singlespaceskip = 12.5pt +\def\singlespace{% + % Why was this kern here? It messes up equalizing space above and below + % environments. --karl, 6may93 + %{\advance \baselineskip by -\singlespaceskip + %\kern \baselineskip}% + \setleading \singlespaceskip +} + +%% Simple single-character @ commands + +% @@ prints an @ +% Kludge this until the fonts are right (grr). +\def\@{{\tt \char '100}} + +% This is turned off because it was never documented +% and you can use @w{...} around a quote to suppress ligatures. +%% Define @` and @' to be the same as ` and ' +%% but suppressing ligatures. +%\def\`{{`}} +%\def\'{{'}} + +% Used to generate quoted braces. +\def\mylbrace {{\tt \char '173}} +\def\myrbrace {{\tt \char '175}} +\let\{=\mylbrace +\let\}=\myrbrace +\begingroup + % Definitions to produce actual \{ & \} command in an index. + \catcode`\{ = 12 \catcode`\} = 12 + \catcode`\[ = 1 \catcode`\] = 2 + \catcode`\@ = 0 \catcode`\\ = 12 + @gdef@lbracecmd[\{]% + @gdef@rbracecmd[\}]% +@endgroup + +% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent +% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H. +\let\, = \c +\let\dotaccent = \. +\def\ringaccent#1{{\accent23 #1}} +\let\tieaccent = \t +\let\ubaraccent = \b +\let\udotaccent = \d + +% Other special characters: @questiondown @exclamdown +% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss. +\def\questiondown{?`} +\def\exclamdown{!`} + +% Dotless i and dotless j, used for accents. +\def\imacro{i} +\def\jmacro{j} +\def\dotless#1{% + \def\temp{#1}% + \ifx\temp\imacro \ptexi + \else\ifx\temp\jmacro \j + \else \errmessage{@dotless can be used only with i or j}% + \fi\fi +} + +% @: forces normal size whitespace following. +\def\:{\spacefactor=1000 } + +% @* forces a line break. +\def\*{\hfil\break\hbox{}\ignorespaces} + +% @. is an end-of-sentence period. +\def\.{.\spacefactor=3000 } + +% @enddots{} is an end-of-sentence ellipsis. +\gdef\enddots{$\mathinner{\ldotp\ldotp\ldotp\ldotp}$\spacefactor=3000} + +% @! is an end-of-sentence bang. +\gdef\!{!\spacefactor=3000 } + +% @? is an end-of-sentence query. +\gdef\?{?\spacefactor=3000 } + +% @w prevents a word break. Without the \leavevmode, @w at the +% beginning of a paragraph, when TeX is still in vertical mode, would +% produce a whole line of output instead of starting the paragraph. +\def\w#1{\leavevmode\hbox{#1}} + +% @group ... @end group forces ... to be all on one page, by enclosing +% it in a TeX vbox. We use \vtop instead of \vbox to construct the box +% to keep its height that of a normal line. According to the rules for +% \topskip (p.114 of the TeXbook), the glue inserted is +% max (\topskip - \ht (first item), 0). If that height is large, +% therefore, no glue is inserted, and the space between the headline and +% the text is small, which looks bad. +% +\def\group{\begingroup + \ifnum\catcode13=\active \else + \errhelp = \groupinvalidhelp + \errmessage{@group invalid in context where filling is enabled}% + \fi + % + % The \vtop we start below produces a box with normal height and large + % depth; thus, TeX puts \baselineskip glue before it, and (when the + % next line of text is done) \lineskip glue after it. (See p.82 of + % the TeXbook.) Thus, space below is not quite equal to space + % above. But it's pretty close. + \def\Egroup{% + \egroup % End the \vtop. + \endgroup % End the \group. + }% + % + \vtop\bgroup + % We have to put a strut on the last line in case the @group is in + % the midst of an example, rather than completely enclosing it. + % Otherwise, the interline space between the last line of the group + % and the first line afterwards is too small. But we can't put the + % strut in \Egroup, since there it would be on a line by itself. + % Hence this just inserts a strut at the beginning of each line. + \everypar = {\strut}% + % + % Since we have a strut on every line, we don't need any of TeX's + % normal interline spacing. + \offinterlineskip + % + % OK, but now we have to do something about blank + % lines in the input in @example-like environments, which normally + % just turn into \lisppar, which will insert no space now that we've + % turned off the interline space. Simplest is to make them be an + % empty paragraph. + \ifx\par\lisppar + \edef\par{\leavevmode \par}% + % + % Reset ^^M's definition to new definition of \par. + \obeylines + \fi + % + % Do @comment since we are called inside an environment such as + % @example, where each end-of-line in the input causes an + % end-of-line in the output. We don't want the end-of-line after + % the `@group' to put extra space in the output. Since @group + % should appear on a line by itself (according to the Texinfo + % manual), we don't worry about eating any user text. + \comment +} +% +% TeX puts in an \escapechar (i.e., `@') at the beginning of the help +% message, so this ends up printing `@group can only ...'. +% +\newhelp\groupinvalidhelp{% +group can only be used in environments such as @example,^^J% +where each line of input produces a line of output.} + +% @need space-in-mils +% forces a page break if there is not space-in-mils remaining. + +\newdimen\mil \mil=0.001in + +\def\need{\parsearg\needx} + +% Old definition--didn't work. +%\def\needx #1{\par % +%% This method tries to make TeX break the page naturally +%% if the depth of the box does not fit. +%{\baselineskip=0pt% +%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 +%\prevdepth=-1000pt +%}} + +\def\needx#1{% + % Go into vertical mode, so we don't make a big box in the middle of a + % paragraph. + \par + % + % Don't add any leading before our big empty box, but allow a page + % break, since the best break might be right here. + \allowbreak + \nointerlineskip + \vtop to #1\mil{\vfil}% + % + % TeX does not even consider page breaks if a penalty added to the + % main vertical list is 10000 or more. But in order to see if the + % empty box we just added fits on the page, we must make it consider + % page breaks. On the other hand, we don't want to actually break the + % page after the empty box. So we use a penalty of 9999. + % + % There is an extremely small chance that TeX will actually break the + % page at this \penalty, if there are no other feasible breakpoints in + % sight. (If the user is using lots of big @group commands, which + % almost-but-not-quite fill up a page, TeX will have a hard time doing + % good page breaking, for example.) However, I could not construct an + % example where a page broke at this \penalty; if it happens in a real + % document, then we can reconsider our strategy. + \penalty9999 + % + % Back up by the size of the box, whether we did a page break or not. + \kern -#1\mil + % + % Do not allow a page break right after this kern. + \nobreak +} + +% @br forces paragraph break + +\let\br = \par + +% @dots{} output some dots + +\def\dots{$\ldots$} + +% @page forces the start of a new page + +\def\page{\par\vfill\supereject} + +% @exdent text.... +% outputs text on separate line in roman font, starting at standard page margin + +% This records the amount of indent in the innermost environment. +% That's how much \exdent should take out. +\newskip\exdentamount + +% This defn is used inside fill environments such as @defun. +\def\exdent{\parsearg\exdentyyy} +\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} + +% This defn is used inside nofill environments such as @example. +\def\nofillexdent{\parsearg\nofillexdentyyy} +\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount +\leftline{\hskip\leftskip{\rm#1}}}} + +% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph. + +\def\inmargin#1{% +\strut\vadjust{\nobreak\kern-\strutdepth + \vtop to \strutdepth{\baselineskip\strutdepth\vss + \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}} +\newskip\inmarginspacing \inmarginspacing=1cm +\def\strutdepth{\dp\strutbox} + +%\hbox{{\rm#1}}\hfil\break}} + +% @include file insert text of that file as input. +% Allow normal characters that we make active in the argument (a file name). +\def\include{\begingroup + \catcode`\\=12 + \catcode`~=12 + \catcode`^=12 + \catcode`_=12 + \catcode`|=12 + \catcode`<=12 + \catcode`>=12 + \catcode`+=12 + \parsearg\includezzz} +% Restore active chars for included file. +\def\includezzz#1{\endgroup\begingroup + % Read the included file in a group so nested @include's work. + \def\thisfile{#1}% + \input\thisfile +\endgroup} + +\def\thisfile{} + +% @center line outputs that line, centered + +\def\center{\parsearg\centerzzz} +\def\centerzzz #1{{\advance\hsize by -\leftskip +\advance\hsize by -\rightskip +\centerline{#1}}} + +% @sp n outputs n lines of vertical space + +\def\sp{\parsearg\spxxx} +\def\spxxx #1{\vskip #1\baselineskip} + +% @comment ...line which is ignored... +% @c is the same as @comment +% @ignore ... @end ignore is another way to write a comment + +\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% +\parsearg \commentxxx} + +\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } + +\let\c=\comment + +% @paragraphindent is defined for the Info formatting commands only. +\let\paragraphindent=\comment + +% Prevent errors for section commands. +% Used in @ignore and in failing conditionals. +\def\ignoresections{% +\let\chapter=\relax +\let\unnumbered=\relax +\let\top=\relax +\let\unnumberedsec=\relax +\let\unnumberedsection=\relax +\let\unnumberedsubsec=\relax +\let\unnumberedsubsection=\relax +\let\unnumberedsubsubsec=\relax +\let\unnumberedsubsubsection=\relax +\let\section=\relax +\let\subsec=\relax +\let\subsubsec=\relax +\let\subsection=\relax +\let\subsubsection=\relax +\let\appendix=\relax +\let\appendixsec=\relax +\let\appendixsection=\relax +\let\appendixsubsec=\relax +\let\appendixsubsection=\relax +\let\appendixsubsubsec=\relax +\let\appendixsubsubsection=\relax +\let\contents=\relax +\let\smallbook=\relax +\let\titlepage=\relax +} + +% Used in nested conditionals, where we have to parse the Texinfo source +% and so want to turn off most commands, in case they are used +% incorrectly. +% +\def\ignoremorecommands{% + \let\defcodeindex = \relax + \let\defcv = \relax + \let\deffn = \relax + \let\deffnx = \relax + \let\defindex = \relax + \let\defivar = \relax + \let\defmac = \relax + \let\defmethod = \relax + \let\defop = \relax + \let\defopt = \relax + \let\defspec = \relax + \let\deftp = \relax + \let\deftypefn = \relax + \let\deftypefun = \relax + \let\deftypevar = \relax + \let\deftypevr = \relax + \let\defun = \relax + \let\defvar = \relax + \let\defvr = \relax + \let\ref = \relax + \let\xref = \relax + \let\printindex = \relax + \let\pxref = \relax + \let\settitle = \relax + \let\setchapternewpage = \relax + \let\setchapterstyle = \relax + \let\everyheading = \relax + \let\evenheading = \relax + \let\oddheading = \relax + \let\everyfooting = \relax + \let\evenfooting = \relax + \let\oddfooting = \relax + \let\headings = \relax + \let\include = \relax + \let\lowersections = \relax + \let\down = \relax + \let\raisesections = \relax + \let\up = \relax + \let\set = \relax + \let\clear = \relax + \let\item = \relax +} + +% Ignore @ignore ... @end ignore. +% +\def\ignore{\doignore{ignore}} + +% Also ignore @ifinfo, @ifhtml, @html, @menu, and @direntry text. +% +\def\ifinfo{\doignore{ifinfo}} +\def\ifhtml{\doignore{ifhtml}} +\def\html{\doignore{html}} +\def\menu{\doignore{menu}} +\def\direntry{\doignore{direntry}} + +% Also ignore @macro ... @end macro. The user must run texi2dvi, +% which runs makeinfo to do macro expansion. Ignore @unmacro, too. +\def\macro{\doignore{macro}} +\let\unmacro = \comment + + +% @dircategory CATEGORY -- specify a category of the dir file +% which this file should belong to. Ignore this in TeX. +\let\dircategory = \comment + +% Ignore text until a line `@end #1'. +% +\def\doignore#1{\begingroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define a command to swallow text until we reach `@end #1'. + \long\def\doignoretext##1\end #1{\enddoignore}% + % + % Make sure that spaces turn into tokens that match what \doignoretext wants. + \catcode32 = 10 + % + % And now expand that command. + \doignoretext +} + +% What we do to finish off ignored text. +% +\def\enddoignore{\endgroup\ignorespaces}% + +\newif\ifwarnedobs\warnedobsfalse +\def\obstexwarn{% + \ifwarnedobs\relax\else + % We need to warn folks that they may have trouble with TeX 3.0. + % This uses \immediate\write16 rather than \message to get newlines. + \immediate\write16{} + \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} + \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} + \immediate\write16{If you are running another version of TeX, relax.} + \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} + \immediate\write16{ Then upgrade your TeX installation if you can.} + \immediate\write16{ (See ftp://ftp.gnu.ai.mit.edu/pub/gnu/TeX.README.)} + \immediate\write16{If you are stuck with version 3.0, run the} + \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} + \immediate\write16{ to use a workaround.} + \immediate\write16{} + \global\warnedobstrue + \fi +} + +% **In TeX 3.0, setting text in \nullfont hangs tex. For a +% workaround (which requires the file ``dummy.tfm'' to be installed), +% uncomment the following line: +%%%%%\font\nullfont=dummy\let\obstexwarn=\relax + +% Ignore text, except that we keep track of conditional commands for +% purposes of nesting, up to an `@end #1' command. +% +\def\nestedignore#1{% + \obstexwarn + % We must actually expand the ignored text to look for the @end + % command, so that nested ignore constructs work. Thus, we put the + % text into a \vbox and then do nothing with the result. To minimize + % the change of memory overflow, we follow the approach outlined on + % page 401 of the TeXbook: make the current font be a dummy font. + % + \setbox0 = \vbox\bgroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define `@end #1' to end the box, which will in turn undefine the + % @end command again. + \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% + % + % We are going to be parsing Texinfo commands. Most cause no + % trouble when they are used incorrectly, but some commands do + % complicated argument parsing or otherwise get confused, so we + % undefine them. + % + % We can't do anything about stray @-signs, unfortunately; + % they'll produce `undefined control sequence' errors. + \ignoremorecommands + % + % Set the current font to be \nullfont, a TeX primitive, and define + % all the font commands to also use \nullfont. We don't use + % dummy.tfm, as suggested in the TeXbook, because not all sites + % might have that installed. Therefore, math mode will still + % produce output, but that should be an extremely small amount of + % stuff compared to the main input. + % + \nullfont + \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont + \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont + \let\tensf = \nullfont + % Similarly for index fonts (mostly for their use in + % smallexample) + \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont + \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont + \let\indsf = \nullfont + % + % Don't complain when characters are missing from the fonts. + \tracinglostchars = 0 + % + % Don't bother to do space factor calculations. + \frenchspacing + % + % Don't report underfull hboxes. + \hbadness = 10000 + % + % Do minimal line-breaking. + \pretolerance = 10000 + % + % Do not execute instructions in @tex + \def\tex{\doignore{tex}} +} + +% @set VAR sets the variable VAR to an empty value. +% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. +% +% Since we want to separate VAR from REST-OF-LINE (which might be +% empty), we can't just use \parsearg; we have to insert a space of our +% own to delimit the rest of the line, and then take it out again if we +% didn't need it. Make sure the catcode of space is correct to avoid +% losing inside @example, for instance. +% +\def\set{\begingroup\catcode` =10 + \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. + \parsearg\setxxx} +\def\setxxx#1{\setyyy#1 \endsetyyy} +\def\setyyy#1 #2\endsetyyy{% + \def\temp{#2}% + \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty + \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. + \fi + \endgroup +} +% Can't use \xdef to pre-expand #2 and save some time, since \temp or +% \next or other control sequences that we've defined might get us into +% an infinite loop. Consider `@set foo @cite{bar}'. +\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} + +% @clear VAR clears (i.e., unsets) the variable VAR. +% +\def\clear{\parsearg\clearxxx} +\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} + +% @value{foo} gets the text saved in variable foo. +% +\def\value{\begingroup + \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. + \valuexxx} +\def\valuexxx#1{% + \expandafter\ifx\csname SET#1\endcsname\relax + {\{No value for ``#1''\}}% + \else + \csname SET#1\endcsname + \fi +\endgroup} + +% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined +% with @set. +% +\def\ifset{\parsearg\ifsetxxx} +\def\ifsetxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifsetfail + \else + \expandafter\ifsetsucceed + \fi +} +\def\ifsetsucceed{\conditionalsucceed{ifset}} +\def\ifsetfail{\nestedignore{ifset}} +\defineunmatchedend{ifset} + +% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been +% defined with @set, or has been undefined with @clear. +% +\def\ifclear{\parsearg\ifclearxxx} +\def\ifclearxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifclearsucceed + \else + \expandafter\ifclearfail + \fi +} +\def\ifclearsucceed{\conditionalsucceed{ifclear}} +\def\ifclearfail{\nestedignore{ifclear}} +\defineunmatchedend{ifclear} + +% @iftex always succeeds; we read the text following, through @end +% iftex). But `@end iftex' should be valid only after an @iftex. +% +\def\iftex{\conditionalsucceed{iftex}} +\defineunmatchedend{iftex} + +% We can't just want to start a group at @iftex (for example) and end it +% at @end iftex, since then @set commands inside the conditional have no +% effect (they'd get reverted at the end of the group). So we must +% define \Eiftex to redefine itself to be its previous value. (We can't +% just define it to fail again with an ``unmatched end'' error, since +% the @ifset might be nested.) +% +\def\conditionalsucceed#1{% + \edef\temp{% + % Remember the current value of \E#1. + \let\nece{prevE#1} = \nece{E#1}% + % + % At the `@end #1', redefine \E#1 to be its previous value. + \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% + }% + \temp +} + +% We need to expand lots of \csname's, but we don't want to expand the +% control sequences after we've constructed them. +% +\def\nece#1{\expandafter\noexpand\csname#1\endcsname} + +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math means output in math mode. +% We don't use $'s directly in the definition of \math because control +% sequences like \math are expanded when the toc file is written. Then, +% we read the toc file back, the $'s will be normal characters (as they +% should be, according to the definition of Texinfo). So we must use a +% control sequence to switch into and out of math mode. +% +% This isn't quite enough for @math to work properly in indices, but it +% seems unlikely it will ever be needed there. +% +\let\implicitmath = $ +\def\math#1{\implicitmath #1\implicitmath} + +% @bullet and @minus need the same treatment as @math, just above. +\def\bullet{\implicitmath\ptexbullet\implicitmath} +\def\minus{\implicitmath-\implicitmath} + +\def\node{\ENVcheck\parsearg\nodezzz} +\def\nodezzz#1{\nodexxx [#1,]} +\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} +\let\nwnode=\node +\let\lastnode=\relax + +\def\donoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\setref{\lastnode}\fi +\global\let\lastnode=\relax} + +\def\unnumbnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi +\global\let\lastnode=\relax} + +\def\appendixnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi +\global\let\lastnode=\relax} + +% @refill is a no-op. +\let\refill=\relax + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \readauxfile + \opencontents + \openindices + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \global\let\setfilename=\comment % Ignore extra @setfilename cmds. + \comment % Ignore the actual filename. +} + +% @bye. +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + +% \def\macro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\macroxxx} +% \def\macroxxx#1#2 \end macro{% +% \expandafter\gdef\macrotemp#1{#2}% +% \endgroup} + +%\def\linemacro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\linemacroxxx} +%\def\linemacroxxx#1#2 \end linemacro{% +%\let\parsearg=\relax +%\edef\macrotempx{\csname M\butfirst\expandafter\string\macrotemp\endcsname}% +%\expandafter\xdef\macrotemp{\parsearg\macrotempx}% +%\expandafter\gdef\macrotempx#1{#2}% +%\endgroup} + +%\def\butfirst#1{} + + +\message{fonts,} + +% Font-change commands. + +% Texinfo supports the sans serif font style, which plain TeX does not. +% So we set up a \sf analogous to plain's \rm, etc. +\newfam\sffam +\def\sf{\fam=\sffam \tensf} +\let\li = \sf % Sometimes we call it \li, not \sf. + +% We don't need math for this one. +\def\ttsl{\tenttsl} + +%% Try out Computer Modern fonts at \magstephalf +\let\mainmagstep=\magstephalf + +% Set the font macro #1 to the font named #2, adding on the +% specified font prefix (normally `cm'). +% #3 is the font's design size, #4 is a scale factor +\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} + +% Use cm as the default font prefix. +% To specify the font prefix, you must define \fontprefix +% before you read in texinfo.tex. +\ifx\fontprefix\undefined +\def\fontprefix{cm} +\fi +% Support font families that don't use the same naming scheme as CM. +\def\rmshape{r} +\def\rmbshape{bx} %where the normal face is bold +\def\bfshape{b} +\def\bxshape{bx} +\def\ttshape{tt} +\def\ttbshape{tt} +\def\ttslshape{sltt} +\def\itshape{ti} +\def\itbshape{bxti} +\def\slshape{sl} +\def\slbshape{bxsl} +\def\sfshape{ss} +\def\sfbshape{ss} +\def\scshape{csc} +\def\scbshape{csc} + +\ifx\bigger\relax +\let\mainmagstep=\magstep1 +\setfont\textrm\rmshape{12}{1000} +\setfont\texttt\ttshape{12}{1000} +\else +\setfont\textrm\rmshape{10}{\mainmagstep} +\setfont\texttt\ttshape{10}{\mainmagstep} +\fi +% Instead of cmb10, you many want to use cmbx10. +% cmbx10 is a prettier font on its own, but cmb10 +% looks better when embedded in a line with cmr10. +\setfont\textbf\bfshape{10}{\mainmagstep} +\setfont\textit\itshape{10}{\mainmagstep} +\setfont\textsl\slshape{10}{\mainmagstep} +\setfont\textsf\sfshape{10}{\mainmagstep} +\setfont\textsc\scshape{10}{\mainmagstep} +\setfont\textttsl\ttslshape{10}{\mainmagstep} +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep + +% A few fonts for @defun, etc. +\setfont\defbf\bxshape{10}{\magstep1} %was 1314 +\setfont\deftt\ttshape{10}{\magstep1} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} + +% Fonts for indices and small examples (9pt). +% We actually use the slanted font rather than the italic, +% because texinfo normally uses the slanted fonts for that. +% Do not make many font distinctions in general in the index, since they +% aren't very useful. +\setfont\ninett\ttshape{9}{1000} +\setfont\indrm\rmshape{9}{1000} +\setfont\indit\slshape{9}{1000} +\let\indsl=\indit +\let\indtt=\ninett +\let\indttsl=\ninett +\let\indsf=\indrm +\let\indbf=\indrm +\setfont\indsc\scshape{10}{900} +\font\indi=cmmi9 +\font\indsy=cmsy9 + +% Chapter (and unnumbered) fonts (17.28pt). +\setfont\chaprm\rmbshape{12}{\magstep2} +\setfont\chapit\itbshape{10}{\magstep3} +\setfont\chapsl\slbshape{10}{\magstep3} +\setfont\chaptt\ttbshape{12}{\magstep2} +\setfont\chapttsl\ttslshape{10}{\magstep3} +\setfont\chapsf\sfbshape{12}{\magstep2} +\let\chapbf=\chaprm +\setfont\chapsc\scbshape{10}{\magstep3} +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 + +% Section fonts (14.4pt). +\setfont\secrm\rmbshape{12}{\magstep1} +\setfont\secit\itbshape{10}{\magstep2} +\setfont\secsl\slbshape{10}{\magstep2} +\setfont\sectt\ttbshape{12}{\magstep1} +\setfont\secttsl\ttslshape{10}{\magstep2} +\setfont\secsf\sfbshape{12}{\magstep1} +\let\secbf\secrm +\setfont\secsc\scbshape{10}{\magstep2} +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 + +% \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad. +% \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded. +% \setfont\ssecsl\slshape{10}{\magstep1} +% \setfont\ssectt\ttshape{10}{\magstep1} +% \setfont\ssecsf\sfshape{10}{\magstep1} + +%\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx. +%\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than +%\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1. +%\setfont\ssectt\ttshape{10}{1315} +%\setfont\ssecsf\sfshape{10}{1315} + +%\let\ssecbf=\ssecrm + +% Subsection fonts (13.15pt). +\setfont\ssecrm\rmbshape{12}{\magstephalf} +\setfont\ssecit\itbshape{10}{1315} +\setfont\ssecsl\slbshape{10}{1315} +\setfont\ssectt\ttbshape{12}{\magstephalf} +\setfont\ssecttsl\ttslshape{10}{\magstep1} +\setfont\ssecsf\sfbshape{12}{\magstephalf} +\let\ssecbf\ssecrm +\setfont\ssecsc\scbshape{10}{\magstep1} +\font\sseci=cmmi12 scaled \magstephalf +\font\ssecsy=cmsy10 scaled \magstep1 +% The smallcaps and symbol fonts should actually be scaled \magstep1.5, +% but that is not a standard magnification. + +% Fonts for title page: +\setfont\titlerm\rmbshape{12}{\magstep3} +\let\authorrm = \secrm + +% In order for the font changes to affect most math symbols and letters, +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts, we +% don't bother to reset \scriptfont and \scriptscriptfont (which would +% also require loading a lot more fonts). +% +\def\resetmathfonts{% + \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy + \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf + \textfont\ttfam = \tentt \textfont\sffam = \tensf +} + + +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this so that font changes will continue to work +% in math mode, where it is the current \fam that is relevant in most +% cases, not the current font. Plain TeX does \def\bf{\fam=\bffam +% \tenbf}, for example. By redefining \tenbf, we obviate the need to +% redefine \bf itself. +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl + \resetmathfonts} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl + \resetmathfonts \setleading{19pt}} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl + \resetmathfonts \setleading{16pt}} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl + \resetmathfonts \setleading{15pt}} +\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? +\def\indexfonts{% + \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl + \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc + \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl + \resetmathfonts \setleading{12pt}} + +% Set up the default fonts, so we can use them for creating boxes. +% +\textfonts + +% Count depth in font-changes, for error checks +\newcount\fontdepth \fontdepth=0 + +% Fonts for short table of contents. +\setfont\shortcontrm\rmshape{12}{1000} +\setfont\shortcontbf\bxshape{12}{1000} +\setfont\shortcontsl\slshape{12}{1000} + +%% Add scribe-like font environments, plus @l for inline lisp (usually sans +%% serif) and @ii for TeX italic + +% \smartitalic{ARG} outputs arg in italics, followed by an italic correction +% unless the following character is such as not to need one. +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} +\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} + +\let\i=\smartitalic +\let\var=\smartitalic +\let\dfn=\smartitalic +\let\emph=\smartitalic +\let\cite=\smartitalic + +\def\b#1{{\bf #1}} +\let\strong=\b + +% We can't just use \exhyphenpenalty, because that only has effect at +% the end of a paragraph. Restore normal hyphenation at the end of the +% group within which \nohyphenation is presumably called. +% +\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} +\def\restorehyphenation{\hyphenchar\font = `- } + +\def\t#1{% + {\tt \rawbackslash \frenchspacing #1}% + \null +} +\let\ttfont=\t +\def\samp #1{`\tclose{#1}'\null} +\setfont\smallrm\rmshape{8}{1000} +\font\smallsy=cmsy9 +\def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{% + \raise0.4pt\hbox{$\langle$}\kern-.08em\vtop{% + \vbox{\hrule\kern-0.4pt + \hbox{\raise0.4pt\hbox{\vphantom{$\langle$}}#1}}% + \kern-0.4pt\hrule}% + \kern-.06em\raise0.4pt\hbox{$\rangle$}}}} +% The old definition, with no lozenge: +%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +\let\file=\samp + +% @code is a modification of @t, +% which makes spaces the same size as normal in the surrounding text. +\def\tclose#1{% + {% + % Change normal interword space to be same as for the current font. + \spaceskip = \fontdimen2\font + % + % Switch to typewriter. + \tt + % + % But `\ ' produces the large typewriter interword space. + \def\ {{\spaceskip = 0pt{} }}% + % + % Turn off hyphenation. + \nohyphenation + % + \rawbackslash + \frenchspacing + #1% + }% + \null +} + +% We *must* turn on hyphenation at `-' and `_' in \code. +% Otherwise, it is too hard to avoid overfull hboxes +% in the Emacs manual, the Library manual, etc. + +% Unfortunately, TeX uses one parameter (\hyphenchar) to control +% both hyphenation at - and hyphenation within words. +% We must therefore turn them both off (\tclose does that) +% and arrange explicitly to hyphenate at a dash. +% -- rms. +{ +\catcode`\-=\active +\catcode`\_=\active +\catcode`\|=\active +\global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex} +% The following is used by \doprintindex to insure that long function names +% wrap around. It is necessary for - and _ to be active before the index is +% read from the file, as \entry parses the arguments long before \code is +% ever called. -- mycroft +% _ is always active; and it shouldn't be \let = to an _ that is a +% subscript character anyway. Then, @cindex @samp{_} (for example) +% fails. --karl +\global\def\indexbreaks{% + \catcode`\-=\active \let-\realdash +} +} + +\def\realdash{-} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}} +\def\codex #1{\tclose{#1}\endgroup} + +%\let\exp=\tclose %Was temporary + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. +% +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else{\tclose{\ttsl\look}}\fi +\else{\tclose{\ttsl\look}}\fi} + +% @url, @email. Quotes do not seem necessary. +\let\url=\code % perhaps include a hypertex \special eventually +% rms does not like the angle brackets --karl, 17may97. +%\def\email#1{$\langle${\tt #1}$\rangle$} +\let\email=\code + +% Check if we are currently using a typewriter font. Since all the +% Computer Modern typewriter fonts have zero interword stretch (and +% shrink), and it is reasonable to expect all typewriter fonts to have +% this property, we can check that font parameter. +% +\def\ifmonospace{\ifdim\fontdimen3\font=0pt } + +% Typeset a dimension, e.g., `in' or `pt'. The only reason for the +% argument is to make the input look right: @dmn{pt} instead of +% @dmn{}pt. +% +\def\dmn#1{\thinspace #1} + +\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} + +% @l was never documented to mean ``switch to the Lisp font'', +% and it is not used as such in any manual I can find. We need it for +% Polish suppressed-l. --karl, 22sep96. +%\def\l#1{{\li #1}\null} + +\def\r#1{{\rm #1}} % roman font +% Use of \lowercase was suggested. +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + +% @pounds{} is a sterling sign. +\def\pounds{{\it\$}} + + +\message{page headings,} + +\newskip\titlepagetopglue \titlepagetopglue = 1.5in +\newskip\titlepagebottomglue \titlepagebottomglue = 2pc + +% First the title page. Must do @settitle before @titlepage. +\def\titlefont#1{{\titlerm #1}} + +\newif\ifseenauthor +\newif\iffinishedtitlepage + +\def\shorttitlepage{\parsearg\shorttitlepagezzz} +\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} + +\def\titlepage{\begingroup \parindent=0pt \textfonts + \let\subtitlerm=\tenrm +% I deinstalled the following change because \cmr12 is undefined. +% This change was not in the ChangeLog anyway. --rms. +% \let\subtitlerm=\cmr12 + \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% + % + \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% + % + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % + % Now you can print the title using @title. + \def\title{\parsearg\titlezzz}% + \def\titlezzz##1{\leftline{\titlefont{##1}} + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Now you can put text using @subtitle. + \def\subtitle{\parsearg\subtitlezzz}% + \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% + % + % @author should come last, but may come many times. + \def\author{\parsearg\authorzzz}% + \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi + {\authorfont \leftline{##1}}}% + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + \oldpage + \let\page = \oldpage + \hbox{}}% +% \def\page{\oldpage \hbox{}} +} + +\def\Etitlepage{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + \HEADINGSon +} + +\def\finishtitlepage{% + \vskip4pt \hrule height 2pt width \hsize + \vskip\titlepagebottomglue + \finishedtitlepagetrue +} + +%%% Set up page headings and footings. + +\let\thispage=\folio + +\newtoks \evenheadline % Token sequence for heading line of even pages +\newtoks \oddheadline % Token sequence for heading line of odd pages +\newtoks \evenfootline % Token sequence for footing line of even pages +\newtoks \oddfootline % Token sequence for footing line of odd pages + +% Now make Tex use those variables +\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline + \else \the\evenheadline \fi}} +\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline + \else \the\evenfootline \fi}\HEADINGShook} +\let\HEADINGShook=\relax + +% Commands to set those variables. +% For example, this is what @headings on does +% @evenheading @thistitle|@thispage|@thischapter +% @oddheading @thischapter|@thispage|@thistitle +% @evenfooting @thisfile|| +% @oddfooting ||@thisfile + +\def\evenheading{\parsearg\evenheadingxxx} +\def\oddheading{\parsearg\oddheadingxxx} +\def\everyheading{\parsearg\everyheadingxxx} + +\def\evenfooting{\parsearg\evenfootingxxx} +\def\oddfooting{\parsearg\oddfootingxxx} +\def\everyfooting{\parsearg\everyfootingxxx} + +{\catcode`\@=0 % + +\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} +\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} +\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} +\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} +\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} +\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} +\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} +% +}% unbind the catcode of @. + +% @headings double turns headings on for double-sided printing. +% @headings single turns headings on for single-sided printing. +% @headings off turns them off. +% @headings on same as @headings double, retained for compatibility. +% @headings after turns on double-sided headings after this page. +% @headings doubleafter turns on double-sided headings after this page. +% @headings singleafter turns on single-sided headings after this page. +% By default, they are off at the start of a document, +% and turned `on' after @end titlepage. + +\def\headings #1 {\csname HEADINGS#1\endcsname} + +\def\HEADINGSoff{ +\global\evenheadline={\hfil} \global\evenfootline={\hfil} +\global\oddheadline={\hfil} \global\oddfootline={\hfil}} +\HEADINGSoff +% When we turn headings on, set the page number to 1. +% For double-sided printing, put current file name in lower left corner, +% chapter name on inside top of right hand pages, document +% title on inside top of left hand pages, and page numbers on outside top +% edge of all pages. +\def\HEADINGSdouble{ +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} +\let\contentsalignmacro = \chappager + +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{ +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} +\def\HEADINGSon{\HEADINGSdouble} + +\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} +\let\HEADINGSdoubleafter=\HEADINGSafter +\def\HEADINGSdoublex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} + +\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} +\def\HEADINGSsinglex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} + +% Subroutines used in generating headings +% Produces Day Month Year style of output. +\def\today{\number\day\space +\ifcase\month\or +January\or February\or March\or April\or May\or June\or +July\or August\or September\or October\or November\or December\fi +\space\number\year} + +% Use this if you want the Month Day, Year style of output. +%\def\today{\ifcase\month\or +%January\or February\or March\or April\or May\or June\or +%July\or August\or September\or October\or November\or December\fi +%\space\number\day, \number\year} + +% @settitle line... specifies the title of the document, for headings +% It generates no output of its own + +\def\thistitle{No Title} +\def\settitle{\parsearg\settitlezzz} +\def\settitlezzz #1{\gdef\thistitle{#1}} + + +\message{tables,} + +% @tabs -- simple alignment + +% These don't work. For one thing, \+ is defined as outer. +% So these macros cannot even be defined. + +%\def\tabs{\parsearg\tabszzz} +%\def\tabszzz #1{\settabs\+#1\cr} +%\def\tabline{\parsearg\tablinezzz} +%\def\tablinezzz #1{\+#1\cr} +%\def\&{&} + +% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). + +% default indentation of table text +\newdimen\tableindent \tableindent=.8in +% default indentation of @itemize and @enumerate text +\newdimen\itemindent \itemindent=.3in +% margin between end of table item and start of table text. +\newdimen\itemmargin \itemmargin=.1in + +% used internally for \itemindent minus \itemmargin +\newdimen\itemmax + +% Note @table, @vtable, and @vtable define @item, @itemx, etc., with +% these defs. +% They also define \itemindex +% to index the item name in whatever manner is desired (perhaps none). + +\newif\ifitemxneedsnegativevskip + +\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} + +\def\internalBitem{\smallbreak \parsearg\itemzzz} +\def\internalBitemx{\itemxpar \parsearg\itemzzz} + +\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} +\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} + +\def\internalBkitem{\smallbreak \parsearg\kitemzzz} +\def\internalBkitemx{\itemxpar \parsearg\kitemzzz} + +\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% + \itemzzz {#1}} + +\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% + \itemzzz {#1}} + +\def\itemzzz #1{\begingroup % + \advance\hsize by -\rightskip + \advance\hsize by -\tableindent + \setbox0=\hbox{\itemfont{#1}}% + \itemindex{#1}% + \nobreak % This prevents a break before @itemx. + % + % Be sure we are not still in the middle of a paragraph. + %{\parskip = 0in + %\par + %}% + % + % If the item text does not fit in the space we have, put it on a line + % by itself, and do not allow a page break either before or after that + % line. We do not start a paragraph here because then if the next + % command is, e.g., @kindex, the whatsit would get put into the + % horizontal list on a line by itself, resulting in extra blank space. + \ifdim \wd0>\itemmax + % + % Make this a paragraph so we get the \parskip glue and wrapping, + % but leave it ragged-right. + \begingroup + \advance\leftskip by-\tableindent + \advance\hsize by\tableindent + \advance\rightskip by0pt plus1fil + \leavevmode\unhbox0\par + \endgroup + % + % We're going to be starting a paragraph, but we don't want the + % \parskip glue -- logically it's part of the @item we just started. + \nobreak \vskip-\parskip + % + % Stop a page break at the \parskip glue coming up. Unfortunately + % we can't prevent a possible page break at the following + % \baselineskip glue. + \nobreak + \endgroup + \itemxneedsnegativevskipfalse + \else + % The item text fits into the space. Start a paragraph, so that the + % following text (if any) will end up on the same line. Since that + % text will be indented by \tableindent, we make the item text be in + % a zero-width box. + \noindent + \rlap{\hskip -\tableindent\box0}\ignorespaces% + \endgroup% + \itemxneedsnegativevskiptrue% + \fi +} + +\def\item{\errmessage{@item while not in a table}} +\def\itemx{\errmessage{@itemx while not in a table}} +\def\kitem{\errmessage{@kitem while not in a table}} +\def\kitemx{\errmessage{@kitemx while not in a table}} +\def\xitem{\errmessage{@xitem while not in a table}} +\def\xitemx{\errmessage{@xitemx while not in a table}} + +%% Contains a kludge to get @end[description] to work +\def\description{\tablez{\dontindex}{1}{}{}{}{}} + +\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} +{\obeylines\obeyspaces% +\gdef\tablex #1^^M{% +\tabley\dontindex#1 \endtabley}} + +\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} +{\obeylines\obeyspaces% +\gdef\ftablex #1^^M{% +\tabley\fnitemindex#1 \endtabley +\def\Eftable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} +{\obeylines\obeyspaces% +\gdef\vtablex #1^^M{% +\tabley\vritemindex#1 \endtabley +\def\Evtable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\dontindex #1{} +\def\fnitemindex #1{\doind {fn}{\code{#1}}}% +\def\vritemindex #1{\doind {vr}{\code{#1}}}% + +{\obeyspaces % +\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% +\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} + +\def\tablez #1#2#3#4#5#6{% +\aboveenvbreak % +\begingroup % +\def\Edescription{\Etable}% Necessary kludge. +\let\itemindex=#1% +\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % +\ifnum 0#4>0 \tableindent=#4\mil \fi % +\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % +\def\itemfont{#2}% +\itemmax=\tableindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \tableindent % +\exdentamount=\tableindent +\parindent = 0pt +\parskip = \smallskipamount +\ifdim \parskip=0pt \parskip=2pt \fi% +\def\Etable{\endgraf\afterenvbreak\endgroup}% +\let\item = \internalBitem % +\let\itemx = \internalBitemx % +\let\kitem = \internalBkitem % +\let\kitemx = \internalBkitemx % +\let\xitem = \internalBxitem % +\let\xitemx = \internalBxitemx % +} + +% This is the counter used by @enumerate, which is really @itemize + +\newcount \itemno + +\def\itemize{\parsearg\itemizezzz} + +\def\itemizezzz #1{% + \begingroup % ended by the @end itemsize + \itemizey {#1}{\Eitemize} +} + +\def\itemizey #1#2{% +\aboveenvbreak % +\itemmax=\itemindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \itemindent % +\exdentamount=\itemindent +\parindent = 0pt % +\parskip = \smallskipamount % +\ifdim \parskip=0pt \parskip=2pt \fi% +\def#2{\endgraf\afterenvbreak\endgroup}% +\def\itemcontents{#1}% +\let\item=\itemizeitem} + +% Set sfcode to normal for the chars that usually have another value. +% These are `.?!:;,' +\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 + \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } + +% \splitoff TOKENS\endmark defines \first to be the first token in +% TOKENS, and \rest to be the remainder. +% +\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% + +% Allow an optional argument of an uppercase letter, lowercase letter, +% or number, to specify the first label in the enumerated list. No +% argument is the same as `1'. +% +\def\enumerate{\parsearg\enumeratezzz} +\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} +\def\enumeratey #1 #2\endenumeratey{% + \begingroup % ended by the @end enumerate + % + % If we were given no argument, pretend we were given `1'. + \def\thearg{#1}% + \ifx\thearg\empty \def\thearg{1}\fi + % + % Detect if the argument is a single token. If so, it might be a + % letter. Otherwise, the only valid thing it can be is a number. + % (We will always have one token, because of the test we just made. + % This is a good thing, since \splitoff doesn't work given nothing at + % all -- the first parameter is undelimited.) + \expandafter\splitoff\thearg\endmark + \ifx\rest\empty + % Only one token in the argument. It could still be anything. + % A ``lowercase letter'' is one whose \lccode is nonzero. + % An ``uppercase letter'' is one whose \lccode is both nonzero, and + % not equal to itself. + % Otherwise, we assume it's a number. + % + % We need the \relax at the end of the \ifnum lines to stop TeX from + % continuing to look for a . + % + \ifnum\lccode\expandafter`\thearg=0\relax + \numericenumerate % a number (we hope) + \else + % It's a letter. + \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax + \lowercaseenumerate % lowercase letter + \else + \uppercaseenumerate % uppercase letter + \fi + \fi + \else + % Multiple tokens in the argument. We hope it's a number. + \numericenumerate + \fi +} + +% An @enumerate whose labels are integers. The starting integer is +% given in \thearg. +% +\def\numericenumerate{% + \itemno = \thearg + \startenumeration{\the\itemno}% +} + +% The starting (lowercase) letter is in \thearg. +\def\lowercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more lowercase letters in @enumerate; get a bigger + alphabet}% + \fi + \char\lccode\itemno + }% +} + +% The starting (uppercase) letter is in \thearg. +\def\uppercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more uppercase letters in @enumerate; get a bigger + alphabet} + \fi + \char\uccode\itemno + }% +} + +% Call itemizey, adding a period to the first argument and supplying the +% common last two arguments. Also subtract one from the initial value in +% \itemno, since @item increments \itemno. +% +\def\startenumeration#1{% + \advance\itemno by -1 + \itemizey{#1.}\Eenumerate\flushcr +} + +% @alphaenumerate and @capsenumerate are abbreviations for giving an arg +% to @enumerate. +% +\def\alphaenumerate{\enumerate{a}} +\def\capsenumerate{\enumerate{A}} +\def\Ealphaenumerate{\Eenumerate} +\def\Ecapsenumerate{\Eenumerate} + +% Definition of @item while inside @itemize. + +\def\itemizeitem{% +\advance\itemno by 1 +{\let\par=\endgraf \smallbreak}% +\ifhmode \errmessage{In hmode at itemizeitem}\fi +{\parskip=0in \hskip 0pt +\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% +\vadjust{\penalty 1200}}% +\flushcr} + +% @multitable macros +% Amy Hendrickson, 8/18/94, 3/6/96 +% +% @multitable ... @end multitable will make as many columns as desired. +% Contents of each column will wrap at width given in preamble. Width +% can be specified either with sample text given in a template line, +% or in percent of \hsize, the current width of text on page. + +% Table can continue over pages but will only break between lines. + +% To make preamble: +% +% Either define widths of columns in terms of percent of \hsize: +% @multitable @columnfractions .25 .3 .45 +% @item ... +% +% Numbers following @columnfractions are the percent of the total +% current hsize to be used for each column. You may use as many +% columns as desired. + + +% Or use a template: +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item ... +% using the widest term desired in each column. +% +% For those who want to use more than one line's worth of words in +% the preamble, break the line within one argument and it +% will parse correctly, i.e., +% +% @multitable {Column 1 template} {Column 2 template} {Column 3 +% template} +% Not: +% @multitable {Column 1 template} {Column 2 template} +% {Column 3 template} + +% Each new table line starts with @item, each subsequent new column +% starts with @tab. Empty columns may be produced by supplying @tab's +% with nothing between them for as many times as empty columns are needed, +% ie, @tab@tab@tab will produce two empty columns. + +% @item, @tab, @multitable or @end multitable do not need to be on their +% own lines, but it will not hurt if they are. + +% Sample multitable: + +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item first col stuff @tab second col stuff @tab third col +% @item +% first col stuff +% @tab +% second col stuff +% @tab +% third col +% @item first col stuff @tab second col stuff +% @tab Many paragraphs of text may be used in any column. +% +% They will wrap at the width determined by the template. +% @item@tab@tab This will be in third column. +% @end multitable + +% Default dimensions may be reset by user. +% @multitableparskip is vertical space between paragraphs in table. +% @multitableparindent is paragraph indent in table. +% @multitablecolmargin is horizontal space to be left between columns. +% @multitablelinespace is space to leave between table items, baseline +% to baseline. +% 0pt means it depends on current normal line spacing. + +%%%% +% Dimensions + +\newskip\multitableparskip +\newskip\multitableparindent +\newdimen\multitablecolspace +\newskip\multitablelinespace +\multitableparskip=0pt +\multitableparindent=6pt +\multitablecolspace=12pt +\multitablelinespace=0pt + +%%%% +% Macros used to set up halign preamble: +\let\endsetuptable\relax +\def\xendsetuptable{\endsetuptable} +\let\columnfractions\relax +\def\xcolumnfractions{\columnfractions} +\newif\ifsetpercent + +%% 2/1/96, to allow fractions to be given with more than one digit. +\def\pickupwholefraction#1 {\global\advance\colcount by1 % +\expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}% +\setuptable} + +\newcount\colcount +\def\setuptable#1{\def\firstarg{#1}% +\ifx\firstarg\xendsetuptable\let\go\relax% +\else + \ifx\firstarg\xcolumnfractions\global\setpercenttrue% + \else + \ifsetpercent + \let\go\pickupwholefraction % In this case arg of setuptable + % is the decimal point before the + % number given in percent of hsize. + % We don't need this so we don't use it. + \else + \global\advance\colcount by1 + \setbox0=\hbox{#1 }% Add a normal word space as a separator; + % typically that is always in the input, anyway. + \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% + \fi% + \fi% +\ifx\go\pickupwholefraction\else\let\go\setuptable\fi% +\fi\go} + +%%%% +% multitable syntax +\def\tab{&\hskip1sp\relax} % 2/2/96 + % tiny skip here makes sure this column space is + % maintained, even if it is never used. + + +%%%% +% @multitable ... @end multitable definitions: + +\def\multitable{\parsearg\dotable} + +\def\dotable#1{\bgroup +\let\item\cr +\tolerance=9500 +\hbadness=9500 +\setmultitablespacing +\parskip=\multitableparskip +\parindent=\multitableparindent +\overfullrule=0pt +\global\colcount=0\relax% +\def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}% + % To parse everything between @multitable and @item : +\setuptable#1 \endsetuptable + % Need to reset this to 0 after \setuptable. +\global\colcount=0\relax% + % + % This preamble sets up a generic column definition, which will + % be used as many times as user calls for columns. + % \vtop will set a single line and will also let text wrap and + % continue for many paragraphs if desired. +\halign\bgroup&\global\advance\colcount by 1\relax% +\multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname + % In order to keep entries from bumping into each other + % we will add a \leftskip of \multitablecolspace to all columns after + % the first one. + % If a template has been used, we will add \multitablecolspace + % to the width of each template entry. + % If user has set preamble in terms of percent of \hsize + % we will use that dimension as the width of the column, and + % the \leftskip will keep entries from bumping into each other. + % Table will start at left margin and final column will justify at + % right margin. +\ifnum\colcount=1 +\else + \ifsetpercent + \else + % If user has set preamble in terms of percent of \hsize + % we will advance \hsize by \multitablecolspace + \advance\hsize by \multitablecolspace + \fi + % In either case we will make \leftskip=\multitablecolspace: +\leftskip=\multitablecolspace +\fi + % Ignoring space at the beginning and end avoids an occasional spurious + % blank line, when TeX decides to break the line at the space before the + % box from the multistrut, so the strut ends up on a line by itself. + % For example: + % @multitable @columnfractions .11 .89 + % @item @code{#} + % @tab Legal holiday which is valid in major parts of the whole country. + % Is automatically provided with highlighting sequences respectively marking + % characters. + \noindent\ignorespaces##\unskip\multistrut}\cr + % \everycr will reset column counter, \colcount, at the end of + % each line. Every column entry will cause \colcount to advance by one. + % The table preamble + % looks at the current \colcount to find the correct column width. +\global\everycr{\noalign{% +% \filbreak%% keeps underfull box messages off when table breaks over pages. +% Maybe so, but it also creates really weird page breaks when the table +% breaks over pages Wouldn't \vfil be better? Wait until the problem +% manifests itself, so it can be fixed for real --karl. +\global\colcount=0\relax}} +} + +\def\setmultitablespacing{% test to see if user has set \multitablelinespace. +% If so, do nothing. If not, give it an appropriate dimension based on +% current baselineskip. +\ifdim\multitablelinespace=0pt +%% strut to put in table in case some entry doesn't have descenders, +%% to keep lines equally spaced +\let\multistrut = \strut +%% Test to see if parskip is larger than space between lines of +%% table. If not, do nothing. +%% If so, set to same dimension as multitablelinespace. +\else +\gdef\multistrut{\vrule height\multitablelinespace depth\dp0 +width0pt\relax} \fi +\ifdim\multitableparskip>\multitablelinespace +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. +\fi% +\ifdim\multitableparskip=0pt +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. +\fi} + + +\message{indexing,} +% Index generation facilities + +% Define \newwrite to be identical to plain tex's \newwrite +% except not \outer, so it can be used within \newindex. +{\catcode`\@=11 +\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} + +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. +% The name of an index should be no more than 2 characters long +% for the sake of vms. + +\def\newindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#1}} +} + +% @defindex foo == \newindex{foo} + +\def\defindex{\parsearg\newindex} + +% Define @defcodeindex, like @defindex except put all entries in @code. + +\def\newcodeindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#1}} +} + +\def\defcodeindex{\parsearg\newcodeindex} + +% @synindex foo bar makes index foo feed into index bar. +% Do this instead of @defindex foo if you don't want it as a separate index. +\def\synindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#2}}% +} + +% @syncodeindex foo bar similar, but put all entries made for index foo +% inside @code. +\def\syncodeindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#2}}% +} + +% Define \doindex, the driver for all \fooindex macros. +% Argument #1 is generated by the calling \fooindex macro, +% and it is "foo", the name of the index. + +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} + +% like the previous two, but they put @code around the argument. +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} + +\def\indexdummies{% +% Take care of the plain tex accent commands. +\def\"{\realbackslash "}% +\def\`{\realbackslash `}% +\def\'{\realbackslash '}% +\def\^{\realbackslash ^}% +\def\~{\realbackslash ~}% +\def\={\realbackslash =}% +\def\b{\realbackslash b}% +\def\c{\realbackslash c}% +\def\d{\realbackslash d}% +\def\u{\realbackslash u}% +\def\v{\realbackslash v}% +\def\H{\realbackslash H}% +% Take care of the plain tex special European modified letters. +\def\oe{\realbackslash oe}% +\def\ae{\realbackslash ae}% +\def\aa{\realbackslash aa}% +\def\OE{\realbackslash OE}% +\def\AE{\realbackslash AE}% +\def\AA{\realbackslash AA}% +\def\o{\realbackslash o}% +\def\O{\realbackslash O}% +\def\l{\realbackslash l}% +\def\L{\realbackslash L}% +\def\ss{\realbackslash ss}% +% Take care of texinfo commands likely to appear in an index entry. +% (Must be a way to avoid doing expansion at all, and thus not have to +% laboriously list every single command here.) +\def\@{@}% will be @@ when we switch to @ as escape char. +%\let\{ = \lbracecmd +%\let\} = \rbracecmd +\def\_{{\realbackslash _}}% +\def\w{\realbackslash w }% +\def\bf{\realbackslash bf }% +%\def\rm{\realbackslash rm }% +\def\sl{\realbackslash sl }% +\def\sf{\realbackslash sf}% +\def\tt{\realbackslash tt}% +\def\gtr{\realbackslash gtr}% +\def\less{\realbackslash less}% +\def\hat{\realbackslash hat}% +%\def\char{\realbackslash char}% +\def\TeX{\realbackslash TeX}% +\def\dots{\realbackslash dots }% +\def\copyright{\realbackslash copyright }% +\def\tclose##1{\realbackslash tclose {##1}}% +\def\code##1{\realbackslash code {##1}}% +\def\dotless##1{\realbackslash dotless {##1}}% +\def\samp##1{\realbackslash samp {##1}}% +\def\,##1{\realbackslash ,{##1}}% +\def\t##1{\realbackslash t {##1}}% +\def\r##1{\realbackslash r {##1}}% +\def\i##1{\realbackslash i {##1}}% +\def\b##1{\realbackslash b {##1}}% +\def\sc##1{\realbackslash sc {##1}}% +\def\cite##1{\realbackslash cite {##1}}% +\def\key##1{\realbackslash key {##1}}% +\def\file##1{\realbackslash file {##1}}% +\def\var##1{\realbackslash var {##1}}% +\def\kbd##1{\realbackslash kbd {##1}}% +\def\dfn##1{\realbackslash dfn {##1}}% +\def\emph##1{\realbackslash emph {##1}}% +\unsepspaces +} + +% If an index command is used in an @example environment, any spaces +% therein should become regular spaces in the raw index file, not the +% expansion of \tie (\\leavevmode \penalty \@M \ ). +{\obeyspaces + \gdef\unsepspaces{\obeyspaces\let =\space}} + +% \indexnofonts no-ops all font-change commands. +% This is used when outputting the strings to sort the index by. +\def\indexdummyfont#1{#1} +\def\indexdummytex{TeX} +\def\indexdummydots{...} + +\def\indexnofonts{% +% Just ignore accents. +\let\,=\indexdummyfont +\let\"=\indexdummyfont +\let\`=\indexdummyfont +\let\'=\indexdummyfont +\let\^=\indexdummyfont +\let\~=\indexdummyfont +\let\==\indexdummyfont +\let\b=\indexdummyfont +\let\c=\indexdummyfont +\let\d=\indexdummyfont +\let\u=\indexdummyfont +\let\v=\indexdummyfont +\let\H=\indexdummyfont +\let\dotless=\indexdummyfont +% Take care of the plain tex special European modified letters. +\def\oe{oe}% +\def\ae{ae}% +\def\aa{aa}% +\def\OE{OE}% +\def\AE{AE}% +\def\AA{AA}% +\def\o{o}% +\def\O{O}% +\def\l{l}% +\def\L{L}% +\def\ss{ss}% +\let\w=\indexdummyfont +\let\t=\indexdummyfont +\let\r=\indexdummyfont +\let\i=\indexdummyfont +\let\b=\indexdummyfont +\let\emph=\indexdummyfont +\let\strong=\indexdummyfont +\let\cite=\indexdummyfont +\let\sc=\indexdummyfont +%Don't no-op \tt, since it isn't a user-level command +% and is used in the definitions of the active chars like <, >, |... +%\let\tt=\indexdummyfont +\let\tclose=\indexdummyfont +\let\code=\indexdummyfont +\let\file=\indexdummyfont +\let\samp=\indexdummyfont +\let\kbd=\indexdummyfont +\let\key=\indexdummyfont +\let\var=\indexdummyfont +\let\TeX=\indexdummytex +\let\dots=\indexdummydots +\def\@{@}% +} + +% To define \realbackslash, we must make \ not be an escape. +% We must first make another character (@) an escape +% so we do not become unable to do a definition. + +{\catcode`\@=0 \catcode`\\=\other +@gdef@realbackslash{\}} + +\let\indexbackslash=0 %overridden during \printindex. + +\let\SETmarginindex=\relax %initialize! +% workhorse for all \fooindexes +% #1 is name of index, #2 is stuff to put there +\def\doind #1#2{% + % Put the index entry in the margin if desired. + \ifx\SETmarginindex\relax\else + \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% + \fi + {% + \count255=\lastpenalty + {% + \indexdummies % Must do this here, since \bf, etc expand at this stage + \escapechar=`\\ + {% + \let\folio=0% We will expand all macros now EXCEPT \folio. + \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now + % so it will be output as is; and it will print as backslash. + % + % First process the index-string with all font commands turned off + % to get the string to sort by. + {\indexnofonts \xdef\indexsorttmp{#2}}% + % + % Now produce the complete index entry, with both the sort key and the + % original text, including any font commands. + \toks0 = {#2}% + \edef\temp{% + \write\csname#1indfile\endcsname{% + \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% + }% + \temp + }% + }% + \penalty\count255 + }% +} + +\def\dosubind #1#2#3{% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% +\def\rawbackslashxx{\indexbackslash}% +% +% Now process the index-string once, with all font commands turned off, +% to get the string to sort the index by. +{\indexnofonts +\xdef\temp1{#2 #3}% +}% +% Now produce the complete index entry. We process the index-string again, +% this time with font commands expanded, to get what to print in the index. +\edef\temp{% +\write \csname#1indfile\endcsname{% +\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% +\temp }% +}\penalty\count10}} + +% The index entry written in the file actually looks like +% \entry {sortstring}{page}{topic} +% or +% \entry {sortstring}{page}{topic}{subtopic} +% The texindex program reads in these files and writes files +% containing these kinds of lines: +% \initial {c} +% before the first topic whose initial is c +% \entry {topic}{pagelist} +% for a topic that is used without subtopics +% \primary {topic} +% for the beginning of a topic that is used with subtopics +% \secondary {subtopic}{pagelist} +% for each subtopic. + +% Define the user-accessible indexing commands +% @findex, @vindex, @kindex, @cindex. + +\def\findex {\fnindex} +\def\kindex {\kyindex} +\def\cindex {\cpindex} +\def\vindex {\vrindex} +\def\tindex {\tpindex} +\def\pindex {\pgindex} + +\def\cindexsub {\begingroup\obeylines\cindexsub} +{\obeylines % +\gdef\cindexsub "#1" #2^^M{\endgroup % +\dosubind{cp}{#2}{#1}}} + +% Define the macros used in formatting output of the sorted index material. + +% @printindex causes a particular index (the ??s file) to get printed. +% It does not print any chapter heading (usually an @unnumbered). +% +\def\printindex{\parsearg\doprintindex} +\def\doprintindex#1{\begingroup + \dobreak \chapheadingskip{10000}% + % + \indexfonts \rm + \tolerance = 9500 + \indexbreaks + % + % See if the index file exists and is nonempty. + \openin 1 \jobname.#1s + \ifeof 1 + % \enddoublecolumns gets confused if there is no text in the index, + % and it loses the chapter title and the aux file entries for the + % index. The easiest way to prevent this problem is to make sure + % there is some text. + (Index is nonexistent) + \else + % + % If the index file exists but is empty, then \openin leaves \ifeof + % false. We have to make TeX try to read something from the file, so + % it can discover if there is anything in it. + \read 1 to \temp + \ifeof 1 + (Index is empty) + \else + % Index files are almost Texinfo source, but we use \ as the escape + % character. It would be better to use @, but that's too big a change + % to make right now. + \def\indexbackslash{\rawbackslashxx}% + \catcode`\\ = 0 + \catcode`\@ = 11 + \escapechar = `\\ + \begindoublecolumns + \input \jobname.#1s + \enddoublecolumns + \fi + \fi + \closein 1 +\endgroup} + +% These macros are used by the sorted index file itself. +% Change them to control the appearance of the index. + +% Same as \bigskipamount except no shrink. +% \balancecolumns gets confused if there is any shrink. +\newskip\initialskipamount \initialskipamount 12pt plus4pt + +\def\initial #1{% +{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt +\ifdim\lastskip<\initialskipamount +\removelastskip \penalty-200 \vskip \initialskipamount\fi +\line{\secbf#1\hfill}\kern 2pt\penalty10000}} + +% This typesets a paragraph consisting of #1, dot leaders, and then #2 +% flush to the right margin. It is used for index and table of contents +% entries. The paragraph is indented by \leftskip. +% +\def\entry #1#2{\begingroup + % + % Start a new paragraph if necessary, so our assignments below can't + % affect previous text. + \par + % + % Do not fill out the last line with white space. + \parfillskip = 0in + % + % No extra space above this paragraph. + \parskip = 0in + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent=2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % Start a ``paragraph'' for the index entry so the line breaking + % parameters we've set above will have an effect. + \noindent + % + % Insert the text of the index entry. TeX will do line-breaking on it. + #1% + % The following is kludged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \def\tempa{{\rm }}% + \def\tempb{#2}% + \edef\tempc{\tempa}% + \edef\tempd{\tempb}% + \ifx\tempc\tempd\ \else% + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. + \ #2% The page number ends the paragraph. + \fi% + \par +\endgroup} + +% Like \dotfill except takes at least 1 em. +\def\indexdotfill{\cleaders + \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} + +\def\primary #1{\line{#1\hfil}} + +\newskip\secondaryindent \secondaryindent=0.5cm + +\def\secondary #1#2{ +{\parfillskip=0in \parskip=0in +\hangindent =1in \hangafter=1 +\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par +}} + +% Define two-column mode, which we use to typeset indexes. +% Adapted from the TeXbook, page 416, which is to say, +% the manmac.tex format used to print the TeXbook itself. +\catcode`\@=11 + +\newbox\partialpage +\newdimen\doublecolumnhsize + +\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns + % Grab any single-column material above us. + \output = {\global\setbox\partialpage = \vbox{% + % + % Here is a possibility not foreseen in manmac: if we accumulate a + % whole lot of material, we might end up calling this \output + % routine twice in a row (see the doublecol-lose test, which is + % essentially a couple of indexes with @setchapternewpage off). In + % that case, we must prevent the second \partialpage from + % simply overwriting the first, causing us to lose the page. + % This will preserve it until a real output routine can ship it + % out. Generally, \partialpage will be empty when this runs and + % this will be a no-op. + \unvbox\partialpage + % + % Unvbox the main output page. + \unvbox255 + \kern-\topskip \kern\baselineskip + }}% + \eject + % + % Use the double-column output routine for subsequent pages. + \output = {\doublecolumnout}% + % + % Change the page size parameters. We could do this once outside this + % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 + % format, but then we repeat the same computation. Repeating a couple + % of assignments once per index is clearly meaningless for the + % execution time, so we may as well do it in one place. + % + % First we halve the line length, less a little for the gutter between + % the columns. We compute the gutter based on the line length, so it + % changes automatically with the paper format. The magic constant + % below is chosen so that the gutter has the same value (well, +-<1pt) + % as it did when we hard-coded it. + % + % We put the result in a separate register, \doublecolumhsize, so we + % can restore it in \pagesofar, after \hsize itself has (potentially) + % been clobbered. + % + \doublecolumnhsize = \hsize + \advance\doublecolumnhsize by -.04154\hsize + \divide\doublecolumnhsize by 2 + \hsize = \doublecolumnhsize + % + % Double the \vsize as well. (We don't need a separate register here, + % since nobody clobbers \vsize.) + \vsize = 2\vsize +} +\def\doublecolumnout{% + \splittopskip=\topskip \splitmaxdepth=\maxdepth + % Get the available space for the double columns -- the normal + % (undoubled) page height minus any material left over from the + % previous page. + \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage + % box0 will be the left-hand column, box2 the right. + \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ + \onepageout\pagesofar + \unvbox255 + \penalty\outputpenalty +} +\def\pagesofar{% + % Re-output the contents of the output page -- any previous material, + % followed by the two boxes we just split. + \unvbox\partialpage + \hsize = \doublecolumnhsize + \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}% +} +\def\enddoublecolumns{% + \output = {\balancecolumns}\eject % split what we have + \endgroup % started in \begindoublecolumns + % + % Back to normal single-column typesetting, but take account of the + % fact that we just accumulated some stuff on the output page. + \pagegoal = \vsize +} +\def\balancecolumns{% + % Called at the end of the double column material. + \setbox0 = \vbox{\unvbox255}% + \dimen@ = \ht0 + \advance\dimen@ by \topskip + \advance\dimen@ by-\baselineskip + \divide\dimen@ by 2 + \splittopskip = \topskip + % Loop until we get a decent breakpoint. + {\vbadness=10000 \loop + \global\setbox3=\copy0 + \global\setbox1=\vsplit3 to\dimen@ + \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt + \repeat}% + \setbox0=\vbox to\dimen@{\unvbox1}% + \setbox2=\vbox to\dimen@{\unvbox3}% + \pagesofar +} +\catcode`\@ = \other + + +\message{sectioning,} +% Define chapters, sections, etc. + +\newcount\chapno +\newcount\secno \secno=0 +\newcount\subsecno \subsecno=0 +\newcount\subsubsecno \subsubsecno=0 + +% This counter is funny since it counts through charcodes of letters A, B, ... +\newcount\appendixno \appendixno = `\@ +\def\appendixletter{\char\the\appendixno} + +\newwrite\contentsfile +% This is called from \setfilename. +\def\opencontents{\openout\contentsfile = \jobname.toc } + +% Each @chapter defines this as the name of the chapter. +% page headings and footings can use it. @section does likewise + +\def\thischapter{} \def\thissection{} +\def\seccheck#1{\ifnum \pageno<0 + \errmessage{@#1 not allowed after generating table of contents}% +\fi} + +\def\chapternofonts{% + \let\rawbackslash=\relax + \let\frenchspacing=\relax + \def\result{\realbackslash result}% + \def\equiv{\realbackslash equiv}% + \def\expansion{\realbackslash expansion}% + \def\print{\realbackslash print}% + \def\TeX{\realbackslash TeX}% + \def\dots{\realbackslash dots}% + \def\copyright{\realbackslash copyright}% + \def\tt{\realbackslash tt}% + \def\bf{\realbackslash bf}% + \def\w{\realbackslash w}% + \def\less{\realbackslash less}% + \def\gtr{\realbackslash gtr}% + \def\hat{\realbackslash hat}% + \def\char{\realbackslash char}% + \def\tclose##1{\realbackslash tclose{##1}}% + \def\code##1{\realbackslash code{##1}}% + \def\samp##1{\realbackslash samp{##1}}% + \def\r##1{\realbackslash r{##1}}% + \def\b##1{\realbackslash b{##1}}% + \def\key##1{\realbackslash key{##1}}% + \def\file##1{\realbackslash file{##1}}% + \def\kbd##1{\realbackslash kbd{##1}}% + % These are redefined because @smartitalic wouldn't work inside xdef. + \def\i##1{\realbackslash i{##1}}% + \def\cite##1{\realbackslash cite{##1}}% + \def\var##1{\realbackslash var{##1}}% + \def\emph##1{\realbackslash emph{##1}}% + \def\dfn##1{\realbackslash dfn{##1}}% +} + +\newcount\absseclevel % used to calculate proper heading level +\newcount\secbase\secbase=0 % @raise/lowersections modify this count + +% @raisesections: treat @section as chapter, @subsection as section, etc. +\def\raisesections{\global\advance\secbase by -1} +\let\up=\raisesections % original BFox name + +% @lowersections: treat @chapter as section, @section as subsection, etc. +\def\lowersections{\global\advance\secbase by 1} +\let\down=\lowersections % original BFox name + +% Choose a numbered-heading macro +% #1 is heading level if unmodified by @raisesections or @lowersections +% #2 is text for heading +\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \chapterzzz{#2} +\or + \seczzz{#2} +\or + \numberedsubseczzz{#2} +\or + \numberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \chapterzzz{#2} + \else + \numberedsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses appendix heading levels +\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \appendixzzz{#2} +\or + \appendixsectionzzz{#2} +\or + \appendixsubseczzz{#2} +\or + \appendixsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \appendixzzz{#2} + \else + \appendixsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses numberless heading levels +\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \unnumberedzzz{#2} +\or + \unnumberedseczzz{#2} +\or + \unnumberedsubseczzz{#2} +\or + \unnumberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \unnumberedzzz{#2} + \else + \unnumberedsubsubseczzz{#2} + \fi +\fi +} + + +\def\thischaptername{No Chapter Title} +\outer\def\chapter{\parsearg\chapteryyy} +\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz +\def\chapterzzz #1{\seccheck{chapter}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \chapno by 1 \message{\putwordChapter \the\chapno}% +\chapmacro {#1}{\the\chapno}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +% We don't substitute the actual chapter name into \thischapter +% because we don't want its macros evaluated now. +\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash chapentry{\the\toks0}{\the\chapno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec +}} + +\outer\def\appendix{\parsearg\appendixyyy} +\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz +\def\appendixzzz #1{\seccheck{appendix}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \appendixno by 1 \message{Appendix \appendixletter}% +\chapmacro {#1}{\putwordAppendix{} \appendixletter}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash chapentry{\the\toks0}% + {\putwordAppendix{} \appendixletter}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\global\let\section = \appendixsec +\global\let\subsection = \appendixsubsec +\global\let\subsubsection = \appendixsubsubsec +}} + +% @centerchap is like @unnumbered, but the heading is centered. +\outer\def\centerchap{\parsearg\centerchapyyy} +\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} + +\outer\def\top{\parsearg\unnumberedyyy} +\outer\def\unnumbered{\parsearg\unnumberedyyy} +\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz +\def\unnumberedzzz #1{\seccheck{unnumbered}% +\secno=0 \subsecno=0 \subsubsecno=0 +% +% This used to be simply \message{#1}, but TeX fully expands the +% argument to \message. Therefore, if #1 contained @-commands, TeX +% expanded them. For example, in `@unnumbered The @cite{Book}', TeX +% expanded @cite (which turns out to cause errors because \cite is meant +% to be executed, not expanded). +% +% Anyway, we don't want the fully-expanded definition of @cite to appear +% as a result of the \message, we just want `@cite' itself. We use +% \the to achieve this: TeX expands \the only once, +% simply yielding the contents of the . +\toks0 = {#1}\message{(\the\toks0)}% +% +\unnumbchapmacro {#1}% +\gdef\thischapter{#1}\gdef\thissection{#1}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash unnumbchapentry{\the\toks0}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\global\let\section = \unnumberedsec +\global\let\subsection = \unnumberedsubsec +\global\let\subsubsection = \unnumberedsubsubsec +}} + +\outer\def\numberedsec{\parsearg\secyyy} +\def\secyyy #1{\numhead1{#1}} % normally calls seczzz +\def\seczzz #1{\seccheck{section}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash secentry % +{\the\toks0}{\the\chapno}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsection{\parsearg\appendixsecyyy} +\outer\def\appendixsec{\parsearg\appendixsecyyy} +\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz +\def\appendixsectionzzz #1{\seccheck{appendixsection}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash secentry % +{\the\toks0}{\appendixletter}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} +\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz +\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash unnumbsecentry{\the\toks0}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} +\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz +\def\numberedsubseczzz #1{\seccheck{subsection}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash subsecentry % +{\the\toks0}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} +\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz +\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash subsecentry % +{\the\toks0}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} +\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz +\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% +\plainsubsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash unnumbsubsecentry{\the\toks0}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} +\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz +\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash subsubsecentry{\the\toks0} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} + {\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} +\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz +\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash subsubsecentry{\the\toks0}% + {\appendixletter} + {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} +\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz +\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% +\plainsubsubsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\toks0 = {#1}% +\edef\temp{{\realbackslash unnumbsubsubsecentry{\the\toks0}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +% These are variants which are not "outer", so they can appear in @ifinfo. +% Actually, they should now be obsolete; ordinary section commands should work. +\def\infotop{\parsearg\unnumberedzzz} +\def\infounnumbered{\parsearg\unnumberedzzz} +\def\infounnumberedsec{\parsearg\unnumberedseczzz} +\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} +\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} + +\def\infoappendix{\parsearg\appendixzzz} +\def\infoappendixsec{\parsearg\appendixseczzz} +\def\infoappendixsubsec{\parsearg\appendixsubseczzz} +\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} + +\def\infochapter{\parsearg\chapterzzz} +\def\infosection{\parsearg\sectionzzz} +\def\infosubsection{\parsearg\subsectionzzz} +\def\infosubsubsection{\parsearg\subsubsectionzzz} + +% These macros control what the section commands do, according +% to what kind of chapter we are in (ordinary, appendix, or unnumbered). +% Define them by default for a numbered chapter. +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec + +% Define @majorheading, @heading and @subheading + +% NOTE on use of \vbox for chapter headings, section headings, and +% such: +% 1) We use \vbox rather than the earlier \line to permit +% overlong headings to fold. +% 2) \hyphenpenalty is set to 10000 because hyphenation in a +% heading is obnoxious; this forbids it. +% 3) Likewise, headings look best if no \parindent is used, and +% if justification is not attempted. Hence \raggedright. + + +\def\majorheading{\parsearg\majorheadingzzz} +\def\majorheadingzzz #1{% +{\advance\chapheadingskip by 10pt \chapbreak }% +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\chapheading{\parsearg\chapheadingzzz} +\def\chapheadingzzz #1{\chapbreak % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +% @heading, @subheading, @subsubheading. +\def\heading{\parsearg\plainsecheading} +\def\subheading{\parsearg\plainsubsecheading} +\def\subsubheading{\parsearg\plainsubsubsecheading} + +% These macros generate a chapter, section, etc. heading only +% (including whitespace, linebreaking, etc. around it), +% given all the information in convenient, parsed form. + +%%% Args are the skip and penalty (usually negative) +\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} + +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} + +%%% Define plain chapter starts, and page on/off switching for it +% Parameter controlling skip before chapter headings (if needed) + +\newskip\chapheadingskip + +\def\chapbreak{\dobreak \chapheadingskip {-4000}} +\def\chappager{\par\vfill\supereject} +\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} + +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} + +\def\CHAPPAGoff{ +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{ +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{ +\global\let\contentsalignmacro = \chapoddpage +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +\def\CHAPFplain{ +\global\let\chapmacro=\chfplain +\global\let\unnumbchapmacro=\unnchfplain +\global\let\centerchapmacro=\centerchfplain} + +% Plain chapter opening. +% #1 is the text, #2 the chapter number or empty if unnumbered. +\def\chfplain#1#2{% + \pchapsepmacro + {% + \chapfonts \rm + \def\chapnum{#2}% + \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright + \hangindent = \wd0 \centerparametersmaybe + \unhbox0 #1\par}% + }% + \nobreak\bigskip % no page break after a chapter title + \nobreak +} + +% Plain opening for unnumbered. +\def\unnchfplain#1{\chfplain{#1}{}} + +% @centerchap -- centered and unnumbered. +\let\centerparametersmaybe = \relax +\def\centerchfplain#1{{% + \def\centerparametersmaybe{% + \advance\rightskip by 3\rightskip + \leftskip = \rightskip + \parfillskip = 0pt + }% + \chfplain{#1}{}% +}} + +\CHAPFplain % The default + +\def\unnchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} + +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} + +\def\centerchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt + \hfill {\rm #1}\hfill}}\bigskip \par\penalty 10000 % +} + +\def\CHAPFopen{ +\global\let\chapmacro=\chfopen +\global\let\unnumbchapmacro=\unnchfopen +\global\let\centerchapmacro=\centerchfopen} + + +% Section titles. +\newskip\secheadingskip +\def\secheadingbreak{\dobreak \secheadingskip {-1000}} +\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} +\def\plainsecheading#1{\sectionheading{sec}{}{#1}} + +% Subsection titles. +\newskip \subsecheadingskip +\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} +\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} +\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} + +% Subsubsection titles. +\let\subsubsecheadingskip = \subsecheadingskip +\let\subsubsecheadingbreak = \subsecheadingbreak +\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} +\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} + + +% Print any size section title. +% +% #1 is the section type (sec/subsec/subsubsec), #2 is the section +% number (maybe empty), #3 the text. +\def\sectionheading#1#2#3{% + {% + \expandafter\advance\csname #1headingskip\endcsname by \parskip + \csname #1headingbreak\endcsname + }% + {% + % Switch to the right set of fonts. + \csname #1fonts\endcsname \rm + % + % Only insert the separating space if we have a section number. + \def\secnum{#2}% + \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% + % + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright + \hangindent = \wd0 % zero if no section number + \unhbox0 #3}% + }% + \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak +} + + +\message{toc printing,} +% Finish up the main text and prepare to read what we've written +% to \contentsfile. + +\newskip\contentsrightmargin \contentsrightmargin=1in +\def\startcontents#1{% + % If @setchapternewpage on, and @headings double, the contents should + % start on an odd page, unlike chapters. Thus, we maintain + % \contentsalignmacro in parallel with \pagealignmacro. + % From: Torbjorn Granlund + \contentsalignmacro + \immediate\closeout \contentsfile + \ifnum \pageno>0 + \pageno = -1 % Request roman numbered pages. + \fi + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \unnumbchapmacro{#1}\def\thischapter{}% + \begingroup % Set up to handle contents files properly. + \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 + \catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. +} + + +% Normal (long) toc. +\outer\def\contents{% + \startcontents{\putwordTableofContents}% + \input \jobname.toc + \endgroup + \vfill \eject +} + +% And just the chapters. +\outer\def\summarycontents{% + \startcontents{\putwordShortContents}% + % + \let\chapentry = \shortchapentry + \let\unnumbchapentry = \shortunnumberedentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl + \rm + \hyphenpenalty = 10000 + \advance\baselineskip by 1pt % Open it up a little. + \def\secentry ##1##2##3##4{} + \def\unnumbsecentry ##1##2{} + \def\subsecentry ##1##2##3##4##5{} + \def\unnumbsubsecentry ##1##2{} + \def\subsubsecentry ##1##2##3##4##5##6{} + \def\unnumbsubsubsecentry ##1##2{} + \input \jobname.toc + \endgroup + \vfill \eject +} +\let\shortcontents = \summarycontents + +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Chapter-level things, for both the long and short contents. +\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} + +% See comments in \dochapentry re vbox and related settings +\def\shortchapentry#1#2#3{% + \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% +} + +% Typeset the label for a chapter or appendix for the short contents. +% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. +% We could simplify the code here by writing out an \appendixentry +% command in the toc file for appendices, instead of using \chapentry +% for both, but it doesn't seem worth it. +\setbox0 = \hbox{\shortcontrm \putwordAppendix } +\newdimen\shortappendixwidth \shortappendixwidth = \wd0 + +\def\shortchaplabel#1{% + % We typeset #1 in a box of constant width, regardless of the text of + % #1, so the chapter titles will come out aligned. + \setbox0 = \hbox{#1}% + \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi + % + % This space should be plenty, since a single number is .5em, and the + % widest letter (M) is 1em, at least in the Computer Modern fonts. + % (This space doesn't include the extra space that gets added after + % the label; that gets put in by \shortchapentry above.) + \advance\dimen0 by 1.1em + \hbox to \dimen0{#1\hfil}% +} + +\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} +\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} + +% Sections. +\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} +\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} + +% Subsections. +\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} +\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} + +% And subsubsections. +\def\subsubsecentry#1#2#3#4#5#6{% + \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} +\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} + +% This parameter controls the indentation of the various levels. +\newdimen\tocindent \tocindent = 3pc + +% Now for the actual typesetting. In all these, #1 is the text and #2 is the +% page number. +% +% If the toc has to be broken over pages, we want it to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip + \begingroup + \chapentryfonts + \tocentry{#1}{\dopageno{#2}}% + \endgroup + \nobreak\vskip .25\baselineskip plus.1\baselineskip +} + +\def\dosecentry#1#2{\begingroup + \secentryfonts \leftskip=\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsecentry#1#2{\begingroup + \subsecentryfonts \leftskip=2\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsubsecentry#1#2{\begingroup + \subsubsecentryfonts \leftskip=3\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +% Final typesetting of a toc entry; we use the same \entry macro as for +% the index entries, but we want to suppress hyphenation here. (We +% can't do that in the \entry macro, since index entries might consist +% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) +% +% \turnoffactive is for the sake of @" used for umlauts. +\def\tocentry#1#2{\begingroup + \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks + \entry{\turnoffactive #1}{\turnoffactive #2}% +\endgroup} + +% Space between chapter (or whatever) number and the title. +\def\labelspace{\hskip1em \relax} + +\def\dopageno#1{{\rm #1}} +\def\doshortpageno#1{{\rm #1}} + +\def\chapentryfonts{\secfonts \rm} +\def\secentryfonts{\textfonts} +\let\subsecentryfonts = \textfonts +\let\subsubsecentryfonts = \textfonts + + +\message{environments,} + +% Since these characters are used in examples, it should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% Furthermore, these definitions must come after we define our fonts. +\newbox\dblarrowbox \newbox\longdblarrowbox +\newbox\pushcharbox \newbox\bullbox +\newbox\equivbox \newbox\errorbox + +%{\tentt +%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} +%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} +%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} +%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} +% Adapted from the manmac format (p.420 of TeXbook) +%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex +% depth .1ex\hfil} +%} + +% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. +\def\point{$\star$} +\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} +\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% Adapted from the TeXbook's \boxit. +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} + +\global\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{ + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} + +% The @error{} command. +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @tex ... @end tex escapes into raw Tex temporarily. +% One exception: @ is still an escape character, so that @end tex works. +% But \@ or @@ will get a plain tex @ character. + +\def\tex{\begingroup +\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 +\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 +\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie +\catcode `\%=14 +\catcode 43=12 % plus +\catcode`\"=12 +\catcode`\==12 +\catcode`\|=12 +\catcode`\<=12 +\catcode`\>=12 +\escapechar=`\\ +% +\let\,=\ptexcomma +\let\{=\ptexlbrace +\let\}=\ptexrbrace +\let\.=\ptexdot +\let\*=\ptexstar +\let\dots=\ptexdots +\def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% +\def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% +\def\@{@}% +\let\bullet=\ptexbullet +\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext +% +\let\Etex=\endgroup} + +% Define @lisp ... @endlisp. +% @lisp does a \begingroup so it can rebind things, +% including the definition of @endlisp (which normally is erroneous). + +% Amount to narrow the margins by for @lisp. +\newskip\lispnarrowing \lispnarrowing=0.4in + +% This is the definition that ^^M gets inside @lisp, @example, and other +% such environments. \null is better than a space, since it doesn't +% have any width. +\def\lisppar{\null\endgraf} + +% Make each space character in the input produce a normal interword +% space in the output. Don't allow a line break at this space, as this +% is used only in environments like @example, where each line of input +% should produce a line of output anyway. +% +{\obeyspaces % +\gdef\sepspaces{\obeyspaces\let =\tie}} + +% Define \obeyedspace to be our active space, whatever it is. This is +% for use in \parsearg. +{\sepspaces% +\global\let\obeyedspace= } + +% This space is always present above and below environments. +\newskip\envskipamount \envskipamount = 0pt + +% Make spacing and below environment symmetrical. We use \parskip here +% to help in doing that, since in @example-like environments \parskip +% is reset to zero; thus the \afterenvbreak inserts no space -- but the +% start of the next paragraph will insert \parskip +% +\def\aboveenvbreak{{\advance\envskipamount by \parskip +\endgraf \ifdim\lastskip<\envskipamount +\removelastskip \penalty-50 \vskip\envskipamount \fi}} + +\let\afterenvbreak = \aboveenvbreak + +% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. +\let\nonarrowing=\relax + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \cartouche: draw rectangle w/rounded corners around argument +\font\circle=lcircle10 +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip +\circthick=\fontdimen8\circle +% +\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth +\def\ctr{{\hskip 6pt\circle\char'010}} +\def\cbl{{\circle\char'012\hskip -6pt}} +\def\cbr{{\hskip 6pt\circle\char'011}} +\def\carttop{\hbox to \cartouter{\hskip\lskip + \ctl\leaders\hrule height\circthick\hfil\ctr + \hskip\rskip}} +\def\cartbot{\hbox to \cartouter{\hskip\lskip + \cbl\leaders\hrule height\circthick\hfil\cbr + \hskip\rskip}} +% +\newskip\lskip\newskip\rskip + +\long\def\cartouche{% +\begingroup + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt %we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18pt % allow for 3pt kerns on either +% side, and for 6pt waste from +% each corner char + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing=\comment + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \hsize=\cartinner + \kern3pt + \begingroup + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip +\def\Ecartouche{% + \endgroup + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup +\endgroup +}} + + +% This macro is called at the beginning of all the @example variants, +% inside a group. +\def\nonfillstart{% + \aboveenvbreak + \inENV % This group ends at the end of the body + \hfuzz = 12pt % Don't be fussy + \sepspaces % Make spaces be word-separators rather than space tokens. + \singlespace + \let\par = \lisppar % don't ignore blank lines + \obeylines % each line of input is a line of output + \parskip = 0pt + \parindent = 0pt + \emergencystretch = 0pt % don't try to avoid overfull boxes + % @cartouche defines \nonarrowing to inhibit narrowing + % at next level down. + \ifx\nonarrowing\relax + \advance \leftskip by \lispnarrowing + \exdentamount=\lispnarrowing + \let\exdent=\nofillexdent + \let\nonarrowing=\relax + \fi +} + +% To ending an @example-like environment, we first end the paragraph +% (via \afterenvbreak's vertical glue), and then the group. That way we +% keep the zero \parskip that the environments set -- \parskip glue +% will be inserted at the beginning of the next paragraph in the +% document, after the environment. +% +\def\nonfillfinish{\afterenvbreak\endgroup}% + +% This macro is +\def\lisp{\begingroup + \nonfillstart + \let\Elisp = \nonfillfinish + \tt + \rawbackslash % have \ input char produce \ char from current font + \gobble +} + +% Define the \E... control sequence only if we are inside the +% environment, so the error checking in \end will work. +% +% We must call \lisp last in the definition, since it reads the +% return following the @example (or whatever) command. +% +\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} +\def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp} +\def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp} + +% @smallexample and @smalllisp. This is not used unless the @smallbook +% command is given. Originally contributed by Pavel@xerox. +% +\def\smalllispx{\begingroup + \nonfillstart + \let\Esmalllisp = \nonfillfinish + \let\Esmallexample = \nonfillfinish + % + % Smaller fonts for small examples. + \indexfonts \tt + \rawbackslash % make \ output the \ character from the current font (tt) + \gobble +} + +% This is @display; same as @lisp except use roman font. +% +\def\display{\begingroup + \nonfillstart + \let\Edisplay = \nonfillfinish + \gobble +} + +% This is @format; same as @display except don't narrow margins. +% +\def\format{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eformat = \nonfillfinish + \gobble +} + +% @flushleft (same as @format) and @flushright. +% +\def\flushleft{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eflushleft = \nonfillfinish + \gobble +} +\def\flushright{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eflushright = \nonfillfinish + \advance\leftskip by 0pt plus 1fill + \gobble} + +% @quotation does normal linebreaking (hence we can't use \nonfillstart) +% and narrows the margins. +% +\def\quotation{% + \begingroup\inENV %This group ends at the end of the @quotation body + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \singlespace + \parindent=0pt + % We have retained a nonzero parskip for the environment, since we're + % doing normal filling. So to avoid extra space below the environment... + \def\Equotation{\parskip = 0pt \nonfillfinish}% + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \advance\rightskip by \lispnarrowing + \exdentamount = \lispnarrowing + \let\nonarrowing = \relax + \fi +} + +\message{defuns,} +% Define formatter for defuns +% First, allow user to change definition object font (\df) internally +\def\setdeffont #1 {\csname DEF#1\endcsname} + +\newskip\defbodyindent \defbodyindent=.4in +\newskip\defargsindent \defargsindent=50pt +\newskip\deftypemargin \deftypemargin=12pt +\newskip\deflastargmargin \deflastargmargin=18pt + +\newcount\parencount +% define \functionparens, which makes ( and ) and & do special things. +% \functionparens affects the group it is contained in. +\def\activeparens{% +\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active +\catcode`\[=\active \catcode`\]=\active} + +% Make control sequences which act like normal parenthesis chars. +\let\lparen = ( \let\rparen = ) + +{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) + +% Be sure that we always have a definition for `(', etc. For example, +% if the fn name has parens in it, \boldbrax will not be in effect yet, +% so TeX would otherwise complain about undefined control sequence. +\global\let(=\lparen \global\let)=\rparen +\global\let[=\lbrack \global\let]=\rbrack + +\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } +\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} +% This is used to turn on special parens +% but make & act ordinary (given that it's active). +\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} + +% Definitions of (, ) and & used in args for functions. +% This is the definition of ( outside of all parentheses. +\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested + \global\advance\parencount by 1 +} +% +% This is the definition of ( when already inside a level of parens. +\gdef\opnested{\char`\(\global\advance\parencount by 1 } +% +\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. + % also in that case restore the outer-level definition of (. + \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi + \global\advance \parencount by -1 } +% If we encounter &foo, then turn on ()-hacking afterwards +\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } +% +\gdef\normalparens{\boldbrax\let&=\ampnr} +} % End of definition inside \activeparens +%% These parens (in \boldbrax) actually are a little bolder than the +%% contained text. This is especially needed for [ and ] +\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 } +\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } +\def\ampnr{\&} +\def\lbrb{{\bf\char`\[}} +\def\rbrb{{\bf\char`\]}} + +% First, defname, which formats the header line itself. +% #1 should be the function name. +% #2 should be the type of definition, such as "Function". + +\def\defname #1#2{% +% Get the values of \leftskip and \rightskip as they were +% outside the @def... +\dimen2=\leftskip +\advance\dimen2 by -\defbodyindent +\dimen3=\rightskip +\advance\dimen3 by -\defbodyindent +\noindent % +\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% +\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line +\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations +\parshape 2 0in \dimen0 \defargsindent \dimen1 % +% Now output arg 2 ("Function" or some such) +% ending at \deftypemargin from the right margin, +% but stuck inside a box of width 0 so it does not interfere with linebreaking +{% Adjust \hsize to exclude the ambient margins, +% so that \rightline will obey them. +\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 +\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% +% Make all lines underfull and no complaints: +\tolerance=10000 \hbadness=10000 +\advance\leftskip by -\defbodyindent +\exdentamount=\defbodyindent +{\df #1}\enskip % Generate function name +} + +% Actually process the body of a definition +% #1 should be the terminating control sequence, such as \Edefun. +% #2 should be the "another name" control sequence, such as \defunx. +% #3 should be the control sequence that actually processes the header, +% such as \defunheader. + +\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % 61 is `=' +\obeylines\activeparens\spacesplit#3} + +\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} + +\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} + +% These parsing functions are similar to the preceding ones +% except that they do not make parens into active characters. +% These are used for "variables" since they have no arguments. + +\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % +\obeylines\spacesplit#3} + +% This is used for \def{tp,vr}parsebody. It could probably be used for +% some of the others, too, with some judicious conditionals. +% +\def\parsebodycommon#1#2#3{% + \begingroup\inENV % + \medbreak % + % Define the end token that this defining construct specifies + % so that it will exit this group. + \def#1{\endgraf\endgroup\medbreak}% + \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% + \parindent=0in + \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent + \exdentamount=\defbodyindent + \begingroup\obeylines +} + +\def\defvrparsebody#1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{#3{#4}}% +} + +% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the +% type is just `struct', because we lose the braces in `{struct +% termios}' when \spacesplit reads its undelimited argument. Sigh. +% \let\deftpparsebody=\defvrparsebody +% +% So, to get around this, we put \empty in with the type name. That +% way, TeX won't find exactly `{...}' as an undelimited argument, and +% won't strip off the braces. +% +\def\deftpparsebody #1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{\parsetpheaderline{#3{#4}}}\empty +} + +% Fine, but then we have to eventually remove the \empty *and* the +% braces (if any). That's what this does. +% +\def\removeemptybraces\empty#1\relax{#1} + +% After \spacesplit has done its work, this is called -- #1 is the final +% thing to call, #2 the type name (which starts with \empty), and #3 +% (which might be empty) the arguments. +% +\def\parsetpheaderline#1#2#3{% + #1{\removeemptybraces#2\relax}{#3}% +}% + +\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\spacesplit{#3{#5}}} + +% Split up #2 at the first space token. +% call #1 with two arguments: +% the first is all of #2 before the space token, +% the second is all of #2 after that space token. +% If #2 contains no space token, all of it is passed as the first arg +% and the second is passed as empty. + +{\obeylines +\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% +\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% +\ifx\relax #3% +#1{#2}{}\else #1{#2}{#3#4}\fi}} + +% So much for the things common to all kinds of definitions. + +% Define @defun. + +% First, define the processing that is wanted for arguments of \defun +% Use this to expand the args and terminate the paragraph they make up + +\def\defunargs #1{\functionparens \sl +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +\hyphenchar\tensl=0 +#1% +\hyphenchar\tensl=45 +\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +\def\deftypefunargs #1{% +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +% Use \boldbraxnoamp, not \functionparens, so that & is not special. +\boldbraxnoamp +\tclose{#1}% avoid \code because of side effects on active chars +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +% Do complete processing of one @defun or @defunx line already parsed. + +% @deffn Command forward-char nchars + +\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} + +\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% +\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defun == @deffn Function + +\def\defun{\defparsebody\Edefun\defunx\defunheader} + +\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Function}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefun int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} + +% #1 is the data type. #2 is the name and args. +\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} +% #1 is the data type, #2 the name, #3 the args. +\def\deftypefunheaderx #1#2 #3\relax{% +\doind {fn}{\code{#2}}% Make entry in function index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}% +\deftypefunargs {#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} + +% \defheaderxcond#1\relax$$$ +% puts #1 in @code, followed by a space, but does nothing if #1 is null. +\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} + +% #1 is the classification. #2 is the data type. #3 is the name and args. +\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} +% #1 is the classification, #2 the data type, #3 the name, #4 the args. +\def\deftypefnheaderx #1#2#3 #4\relax{% +\doind {fn}{\code{#3}}% Make entry in function index +\begingroup +\normalparens % notably, turn off `&' magic, which prevents +% at least some C++ text from working +\defname {\defheaderxcond#2\relax$$$#3}{#1}% +\deftypefunargs {#4}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defmac == @deffn Macro + +\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} + +\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Macro}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defspec == @deffn Special Form + +\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} + +\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Special Form}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% This definition is run if you use @defunx +% anywhere other than immediately after a @defun or @defunx. + +\def\deffnx #1 {\errmessage{@deffnx in invalid context}} +\def\defunx #1 {\errmessage{@defunx in invalid context}} +\def\defmacx #1 {\errmessage{@defmacx in invalid context}} +\def\defspecx #1 {\errmessage{@defspecx in invalid context}} +\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} +\def\deftypemethodx #1 {\errmessage{@deftypemethodx in invalid context}} +\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} + +% @defmethod, and so on + +% @defop {Funny Method} foo-class frobnicate argument + +\def\defop #1 {\def\defoptype{#1}% +\defopparsebody\Edefop\defopx\defopheader\defoptype} + +\def\defopheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index +\begingroup\defname {#2}{\defoptype{} on #1}% +\defunargs {#3}\endgroup % +} + +% @deftypemethod foo-class return-type foo-method args +% +\def\deftypemethod{% + \defmethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} +% +% #1 is the class name, #2 the data type, #3 the method name, #4 the args. +\def\deftypemethodheader#1#2#3#4{% + \deftypefnheaderx{Method on #1}{#2}#3 #4\relax +} + +% @defmethod == @defop Method + +\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} + +\def\defmethodheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% entry in function index +\begingroup\defname {#2}{Method on #1}% +\defunargs {#3}\endgroup % +} + +% @defcv {Class Option} foo-class foo-flag + +\def\defcv #1 {\def\defcvtype{#1}% +\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} + +\def\defcvarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{\defcvtype{} of #1}% +\defvarargs {#3}\endgroup % +} + +% @defivar == @defcv {Instance Variable} + +\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} + +\def\defivarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{Instance Variable of #1}% +\defvarargs {#3}\endgroup % +} + +% These definitions are run if you use @defmethodx, etc., +% anywhere other than immediately after a @defmethod, etc. + +\def\defopx #1 {\errmessage{@defopx in invalid context}} +\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} +\def\defcvx #1 {\errmessage{@defcvx in invalid context}} +\def\defivarx #1 {\errmessage{@defivarx in invalid context}} + +% Now @defvar + +% First, define the processing that is wanted for arguments of @defvar. +% This is actually simple: just print them in roman. +% This must expand the args and terminate the paragraph they make up +\def\defvarargs #1{\normalparens #1% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000} + +% @defvr Counter foo-count + +\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} + +\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% +\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} + +% @defvar == @defvr Variable + +\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} + +\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{Variable}% +\defvarargs {#2}\endgroup % +} + +% @defopt == @defvr {User Option} + +\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} + +\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{User Option}% +\defvarargs {#2}\endgroup % +} + +% @deftypevar int foobar + +\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} + +% #1 is the data type. #2 is the name, perhaps followed by text that +% is actually part of the data type, which should not be put into the index. +\def\deftypevarheader #1#2{% +\dovarind#2 \relax% Make entry in variables index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} +\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} + +% @deftypevr {Global Flag} int enable + +\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} + +\def\deftypevrheader #1#2#3{\dovarind#3 \relax% +\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% This definition is run if you use @defvarx +% anywhere other than immediately after a @defvar or @defvarx. + +\def\defvrx #1 {\errmessage{@defvrx in invalid context}} +\def\defvarx #1 {\errmessage{@defvarx in invalid context}} +\def\defoptx #1 {\errmessage{@defoptx in invalid context}} +\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} +\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} + +% Now define @deftp +% Args are printed in bold, a slight difference from @defvar. + +\def\deftpargs #1{\bf \defvarargs{#1}} + +% @deftp Class window height width ... + +\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} + +\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% +\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} + +% This definition is run if you use @deftpx, etc +% anywhere other than immediately after a @deftp, etc. + +\def\deftpx #1 {\errmessage{@deftpx in invalid context}} + + +\message{cross reference,} +% Define cross-reference macros +\newwrite \auxfile + +\newif\ifhavexrefs % True if xref values are known. +\newif\ifwarnedxrefs % True if we warned once that they aren't known. + +% @inforef is simple. +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, + node \samp{\ignorespaces#1{}}} + +% \setref{foo} defines a cross-reference point named foo. + +\def\setref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ysectionnumberandtype}} + +\def\unnumbsetref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ynothing}} + +\def\appendixsetref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Yappendixletterandtype}} + +% \xref, \pxref, and \ref generate cross-references to specified points. +% For \xrefX, #1 is the node name, #2 the name of the Info +% cross-reference, #3 the printed node name, #4 the name of the Info +% file, #5 the name of the printed manual. All but the node name can be +% omitted. +% +\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} +\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup + \def\printedmanual{\ignorespaces #5}% + \def\printednodename{\ignorespaces #3}% + \setbox1=\hbox{\printedmanual}% + \setbox0=\hbox{\printednodename}% + \ifdim \wd0 = 0pt + % No printed node name was explicitly given. + \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax + % Use the node name inside the square brackets. + \def\printednodename{\ignorespaces #1}% + \else + % Use the actual chapter/section title appear inside + % the square brackets. Use the real section title if we have it. + \ifdim \wd1>0pt% + % It is in another manual, so we don't have it. + \def\printednodename{\ignorespaces #1}% + \else + \ifhavexrefs + % We know the real title if we have the xref values. + \def\printednodename{\refx{#1-title}{}}% + \else + % Otherwise just copy the Info node name. + \def\printednodename{\ignorespaces #1}% + \fi% + \fi + \fi + \fi + % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifdim \wd1 > 0pt + \putwordsection{} ``\printednodename'' in \cite{\printedmanual}% + \else + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\turnoffactive \refx{#1-snt}{}}% + \space [\printednodename],\space + \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + \fi +\endgroup} + +% \dosetq is the interface for calls from other macros + +% Use \turnoffactive so that punctuation chars such as underscore +% work in node names. +\def\dosetq #1#2{{\let\folio=0 \turnoffactive +\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% +\next}} + +% \internalsetq {foo}{page} expands into +% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} +% When the aux file is read, ' is the escape character + +\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} + +% Things to be expanded by \internalsetq + +\def\Ypagenumber{\folio} + +\def\Ytitle{\thissection} + +\def\Ynothing{} + +\def\Ysectionnumberandtype{% +\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % +\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\def\Yappendixletterandtype{% +\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% +\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\gdef\xreftie{'tie} + +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Non-3.0. +\else + \def\linenumber{\the\inputlineno:\space} +\fi + +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. + +\def\refx#1#2{% + \expandafter\ifx\csname X#1\endcsname\relax + % If not defined, say something at least. + $\langle$un\-de\-fined$\rangle$% + \ifhavexrefs + \message{\linenumber Undefined cross reference `#1'.}% + \else + \ifwarnedxrefs\else + \global\warnedxrefstrue + \message{Cross reference values unknown; you must run TeX again.}% + \fi + \fi + \else + % It's defined, so just use it. + \csname X#1\endcsname + \fi + #2% Output the suffix in any case. +} + +% This is the macro invoked by entries in the aux file. +\def\xrdef #1#2{{% + \catcode`\'=\other + \expandafter\gdef\csname X#1\endcsname{#2}% +}} + +% Read the last existing aux file, if any. No error if none exists. +\def\readauxfile{\begingroup + \catcode`\^^@=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\^^C=\other + \catcode`\^^D=\other + \catcode`\^^E=\other + \catcode`\^^F=\other + \catcode`\^^G=\other + \catcode`\^^H=\other + \catcode`\ =\other + \catcode`\^^L=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode`\=\other + \catcode26=\other + \catcode`\^^[=\other + \catcode`\^^\=\other + \catcode`\^^]=\other + \catcode`\^^^=\other + \catcode`\^^_=\other + \catcode`\@=\other + \catcode`\^=\other + % It was suggested to define this as 7, which would allow ^^e4 etc. + % in xref tags, i.e., node names. But since ^^e4 notation isn't + % supported in the main text, it doesn't seem desirable. Furthermore, + % that is not enough: for node names that actually contain a ^ + % character, we would end up writing a line like this: 'xrdef {'hat + % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first + % argument, and \hat is not an expandable control sequence. It could + % all be worked out, but why? Either we support ^^ or we don't. + % + % The other change necessary for this was to define \auxhat: + % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter + % and then to call \auxhat in \setq. + % + \catcode`\~=\other + \catcode`\[=\other + \catcode`\]=\other + \catcode`\"=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\$=\other + \catcode`\#=\other + \catcode`\&=\other + % `\+ does not work, so use 43. + \catcode43=\other + % Make the characters 128-255 be printing characters + {% + \count 1=128 + \def\loop{% + \catcode\count 1=\other + \advance\count 1 by 1 + \ifnum \count 1<256 \loop \fi + }% + }% + % The aux file uses ' as the escape (for now). + % Turn off \ as an escape so we do not lose on + % entries which were dumped with control sequences in their names. + % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ + % Reference to such entries still does not work the way one would wish, + % but at least they do not bomb out when the aux file is read in. + \catcode`\{=1 + \catcode`\}=2 + \catcode`\%=\other + \catcode`\'=0 + \catcode`\\=\other + % + \openin 1 \jobname.aux + \ifeof 1 \else + \closein 1 + \input \jobname.aux + \global\havexrefstrue + \global\warnedobstrue + \fi + % Open the new aux file. TeX will close it automatically at exit. + \openout\auxfile=\jobname.aux +\endgroup} + + +% Footnotes. + +\newcount \footnoteno + +% The trailing space in the following definition for supereject is +% vital for proper filling; pages come out unaligned when you do a +% pagealignmacro call if that space before the closing brace is +% removed. (Generally, numeric constants should always be followed by a +% space to prevent strange expansion errors.) +\def\supereject{\par\penalty -20000\footnoteno =0 } + +% @footnotestyle is meaningful for info output only.. +\let\footnotestyle=\comment + +\let\ptexfootnote=\footnote + +{\catcode `\@=11 +% +% Auto-number footnotes. Otherwise like plain. +\gdef\footnote{% + \global\advance\footnoteno by \@ne + \edef\thisfootno{$^{\the\footnoteno}$}% + % + % In case the footnote comes at the end of a sentence, preserve the + % extra spacing after we do the footnote number. + \let\@sf\empty + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi + % + % Remove inadvertent blank space before typesetting the footnote number. + \unskip + \thisfootno\@sf + \footnotezzz +}% + +% Don't bother with the trickery in plain.tex to not require the +% footnote text as a parameter. Our footnotes don't need to be so general. +% +% Oh yes, they do; otherwise, @ifset and anything else that uses +% \parseargline fail inside footnotes because the tokens are fixed when +% the footnote is read. --karl, 16nov96. +% +\long\gdef\footnotezzz{\insert\footins\bgroup + % We want to typeset this text as a normal paragraph, even if the + % footnote reference occurs in (for example) a display environment. + % So reset some parameters. + \interlinepenalty\interfootnotelinepenalty + \splittopskip\ht\strutbox % top baseline for broken footnotes + \splitmaxdepth\dp\strutbox + \floatingpenalty\@MM + \leftskip\z@skip + \rightskip\z@skip + \spaceskip\z@skip + \xspaceskip\z@skip + \parindent\defaultparindent + % + % Hang the footnote text off the number. + \hang + \textindent{\thisfootno}% + % + % Don't crash into the line above the footnote text. Since this + % expands into a box, it must come within the paragraph, lest it + % provide a place where TeX can split the footnote. + \footstrut + \futurelet\next\fo@t +} +\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t + \else\let\next\f@t\fi \next} +\def\f@@t{\bgroup\aftergroup\@foot\let\next} +\def\f@t#1{#1\@foot} +\def\@foot{\strut\egroup} + +}%end \catcode `\@=11 + +% Set the baselineskip to #1, and the lineskip and strut size +% correspondingly. There is no deep meaning behind these magic numbers +% used as factors; they just match (closely enough) what Knuth defined. +% +\def\lineskipfactor{.08333} +\def\strutheightpercent{.70833} +\def\strutdepthpercent {.29167} +% +\def\setleading#1{% + \normalbaselineskip = #1\relax + \normallineskip = \lineskipfactor\normalbaselineskip + \normalbaselines + \setbox\strutbox =\hbox{% + \vrule width0pt height\strutheightpercent\baselineskip + depth \strutdepthpercent \baselineskip + }% +} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt} + + +% End of control word definitions. + +\message{and turning on texinfo input format.} + +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} + +% Set some numeric style parameters, for 8.5 x 11 format. + +\hsize = 6in +\hoffset = .25in +\newdimen\defaultparindent \defaultparindent = 15pt +\parindent = \defaultparindent +\parskip 3pt plus 2pt minus 1pt +\setleading{13.2pt} +\advance\topskip by 1.2cm + +\chapheadingskip = 15pt plus 4pt minus 2pt +\secheadingskip = 12pt plus 3pt minus 2pt +\subsecheadingskip = 9pt plus 2pt minus 2pt + +% Prevent underfull vbox error messages. +\vbadness=10000 + +% Following George Bush, just get rid of widows and orphans. +\widowpenalty=10000 +\clubpenalty=10000 + +% Use TeX 3.0's \emergencystretch to help line breaking, but if we're +% using an old version of TeX, don't do anything. We want the amount of +% stretch added to depend on the line length, hence the dependence on +% \hsize. This makes it come to about 9pt for the 8.5x11 format. +% +\ifx\emergencystretch\thisisundefined + % Allow us to assign to \emergencystretch anyway. + \def\emergencystretch{\dimen0}% +\else + \emergencystretch = \hsize + \divide\emergencystretch by 45 +\fi + +% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) +\def\smallbook{ + \global\chapheadingskip = 15pt plus 4pt minus 2pt + \global\secheadingskip = 12pt plus 3pt minus 2pt + \global\subsecheadingskip = 9pt plus 2pt minus 2pt + % + \global\lispnarrowing = 0.3in + \setleading{12pt} + \advance\topskip by -1cm + \global\parskip 2pt plus 1pt + \global\hsize = 5in + \global\vsize=7.5in + \global\tolerance=700 + \global\hfuzz=1pt + \global\contentsrightmargin=0pt + \global\deftypemargin=0pt + \global\defbodyindent=.5cm + % + \global\pagewidth=\hsize + \global\pageheight=\vsize + % + \global\let\smalllisp=\smalllispx + \global\let\smallexample=\smalllispx + \global\def\Esmallexample{\Esmalllisp} +} + +% Use @afourpaper to print on European A4 paper. +\def\afourpaper{ +\global\tolerance=700 +\global\hfuzz=1pt +\setleading{12pt} +\global\parskip 15pt plus 1pt + +\global\vsize= 53\baselineskip +\advance\vsize by \topskip +%\global\hsize= 5.85in % A4 wide 10pt +\global\hsize= 6.5in +\global\outerhsize=\hsize +\global\advance\outerhsize by 0.5in +\global\outervsize=\vsize +\global\advance\outervsize by 0.6in + +\global\pagewidth=\hsize +\global\pageheight=\vsize +} + +\bindingoffset=0pt +\normaloffset=\hoffset +\pagewidth=\hsize +\pageheight=\vsize + +% Allow control of the text dimensions. Parameters in order: textheight; +% textwidth; voffset; hoffset; binding offset; topskip. +% All require a dimension; +% header is additional; added length extends the bottom of the page. + +\def\changepagesizes#1#2#3#4#5#6{ + \global\vsize= #1 + \global\topskip= #6 + \advance\vsize by \topskip + \global\voffset= #3 + \global\hsize= #2 + \global\outerhsize=\hsize + \global\advance\outerhsize by 0.5in + \global\outervsize=\vsize + \global\advance\outervsize by 0.6in + \global\pagewidth=\hsize + \global\pageheight=\vsize + \global\normaloffset= #4 + \global\bindingoffset= #5} + +% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin +% 29mm, hence bottom margin 28mm, nominal side margin 3cm. +\def\afourlatex + {\global\tolerance=700 + \global\hfuzz=1pt + \setleading{12pt} + \global\parskip 15pt plus 1pt + \advance\baselineskip by 1.6pt + \changepagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm} + } + +% Use @afourwide to print on European A4 paper in wide format. +\def\afourwide{\afourpaper +\changepagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}} + +% Define macros to output various characters with catcode for normal text. +\catcode`\"=\other +\catcode`\~=\other +\catcode`\^=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode`\+=\other +\def\normaldoublequote{"} +\def\normaltilde{~} +\def\normalcaret{^} +\def\normalunderscore{_} +\def\normalverticalbar{|} +\def\normalless{<} +\def\normalgreater{>} +\def\normalplus{+} + +% This macro is used to make a character print one way in ttfont +% where it can probably just be output, and another way in other fonts, +% where something hairier probably needs to be done. +% +% #1 is what to print if we are indeed using \tt; #2 is what to print +% otherwise. Since all the Computer Modern typewriter fonts have zero +% interword stretch (and shrink), and it is reasonable to expect all +% typewriter fonts to have this, we can check that font parameter. +% +\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} + +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). +% Most of these we simply print from the \tt font, but for some, we can +% use math or other variants that look better in normal text. + +\catcode`\"=\active +\def\activedoublequote{{\tt \char '042}} +\let"=\activedoublequote +\catcode`\~=\active +\def~{{\tt \char '176}} +\chardef\hat=`\^ +\catcode`\^=\active +\def^{{\tt \hat}} + +\catcode`\_=\active +\def_{\ifusingtt\normalunderscore\_} +% Subroutine for the previous macro. +\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}} + +\catcode`\|=\active +\def|{{\tt \char '174}} +\chardef \less=`\< +\catcode`\<=\active +\def<{{\tt \less}} +\chardef \gtr=`\> +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +%\catcode 27=\active +%\def^^[{$\diamondsuit$} + +% Set up an active definition for =, but don't enable it most of the time. +{\catcode`\==\active +\global\def={{\tt \char 61}}} + +\catcode`+=\active +\catcode`\_=\active + +% If a .fmt file is being used, characters that might appear in a file +% name cannot be active until we have parsed the command line. +% So turn them off again, and have \everyjob (or @setfilename) turn them on. +% \otherifyactive is called near the end of this file. +\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} + +\catcode`\@=0 + +% \rawbackslashxx output one backslash character in current font +\global\chardef\rawbackslashxx=`\\ +%{\catcode`\\=\other +%@gdef@rawbackslashxx{\}} + +% \rawbackslash redefines \ as input to do \rawbackslashxx. +{\catcode`\\=\active +@gdef@rawbackslash{@let\=@rawbackslashxx }} + +% \normalbackslash outputs one backslash in fixed width font. +\def\normalbackslash{{\tt\rawbackslashxx}} + +% Say @foo, not \foo, in error messages. +\escapechar=`\@ + +% \catcode 17=0 % Define control-q +\catcode`\\=\active + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +@def@turnoffactive{@let"=@normaldoublequote +@let\=@realbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} + +@def@normalturnoffactive{@let"=@normaldoublequote +@let\=@normalbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} + +% Make _ and + \other characters, temporarily. +% This is canceled by @fixbackslash. +@otherifyactive + +% If a .fmt file is being used, we don't want the `\input texinfo' to show up. +% That is what \eatinput is for; after that, the `\' should revert to printing +% a backslash. +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput + +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\{ in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% Also back turn on active characters that might appear in the input +% file name, in case not using a pre-dumped format. +% +@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi + @catcode`+=@active @catcode`@_=@active} + +%% These look ok in all fonts, so just make them not special. The @rm below +%% makes sure that the current font starts out as the newly loaded cmr10 +@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other + +@textfonts +@rm + +@c Local variables: +@c page-delimiter: "^\\\\message" +@c End: diff --git a/texinfo/texinfo.texi b/texinfo/texinfo.texi new file mode 100644 index 000000000000..0f55da09901c --- /dev/null +++ b/texinfo/texinfo.texi @@ -0,0 +1,16886 @@ +\input texinfo.tex @c -*-texinfo-*- +@comment %**start of header +@setfilename texinfo +@settitle Texinfo @value{edition} +@c Define a new index for options. +@defcodeindex op +@c Put everything except function (command, in this case) names in one +index (arbitrarily chosen to be the concept index). +@syncodeindex op cp +@syncodeindex vr cp +@syncodeindex pg cp +@footnotestyle separate +@paragraphindent 2 +@finalout +@comment %**end of header +@comment $Id: texinfo.texi,v 1.1 1997/08/21 22:57:54 jason Exp $ + +@c Before release, run C-u C-c C-u C-a (texinfo-all-menus-update with a +@c prefix arg). This updates the node pointers, which texinfmt.el needs. + +@dircategory Texinfo documentation system +@direntry +* Texinfo: (texinfo). The GNU documentation format. +* install-info: (texinfo)Invoking install-info. Updating info/dir entries. +* texi2dvi: (texinfo)Format with texi2dvi. Printing Texinfo documentation. +* texindex: (texinfo)Format with tex/texindex. Sorting Texinfo index files. +@end direntry + +@c Set smallbook if printing in smallbook format so the example of the +@c smallbook font is actually written using smallbook; in bigbook, a kludge +@c is used for TeX output. +@smallbook +@set smallbook +@c @@clear smallbook + +@set edition 2.23 +@set update-month October 1996 +@set update-date 1 @value{update-month} + +@c Currently undocumented command, 5 December 1993: +@c +@c nwnode (Same as node, but no warnings; for `makeinfo'.) + +@ifinfo +This file documents Texinfo, a documentation system that can produce +both on-line information and a printed manual from a single source file. + +Copyright (C) 1988, 90, 91, 92, 93, 95, 1996 Free Software Foundation, Inc. + +This is the second edition of the Texinfo documentation,@* +and is consistent with version 2 of @file{texinfo.tex}. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@end ifinfo + +@setchapternewpage odd + +@shorttitlepage Texinfo + +@titlepage +@c use the new format for titles +@title Texinfo +@subtitle The GNU Documentation Format +@subtitle Edition @value{edition}, for Texinfo Version Three +@subtitle @value{update-month} + +@author Robert J.@: Chassell +@author Richard M.@: Stallman + +@c Include the Distribution inside the titlepage so +@c that headings are turned off. + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1988, 1990, 1991, 1992, 1993, 1995, 1996 Free Software Foundation, Inc. + +@sp 2 +This is the second edition of the Texinfo documentation,@* +and is consistent with version 2 of @file{texinfo.tex}. +@sp 2 + +Published by the Free Software Foundation @* +59 Temple Place Suite 330, @* +Boston, MA 02111-1307 USA @* +Printed copies are available for $15 each.@* +ISBN 1-882114-64-7 +@c ISBN 1-882114-63-9 is for edition 2.20 of 28 February 1995 +@c ISBN 1-882114-64-7 is for edition 2.23 of 1 October 1996. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Free Software Foundation. +@sp 2 +Cover art by Etienne Suvasa. +@end titlepage + +@ifinfo +@node Top, Copying, (dir), (dir) +@top Texinfo + +Texinfo is a documentation system that uses a single source file to +produce both on-line information and printed output.@refill + +The first part of this master menu lists the major nodes in this Info +document, including the @@-command and concept indices. The rest of +the menu lists all the lower level nodes in the document.@refill + +This is Edition @value{edition} of the Texinfo documentation, +@w{@value{update-date},} for Texinfo Version Three. +@end ifinfo + +@c Here is a spare copy of the chapter menu entry descriptions, +@c in case they are accidently deleted +@ignore +Your rights. +Texinfo in brief. +How to use Texinfo mode. +What is at the beginning of a Texinfo file? +What is at the end of a Texinfo file? +How to create chapters, sections, subsections, + appendices, and other parts. +How to provide structure for a document. +How to write nodes. +How to write menus. +How to write cross references. +How to mark words and phrases as code, + keyboard input, meta-syntactic + variables, and the like. +How to write quotations, examples, etc. +How to write lists and tables. +How to create indices. +How to insert @@-signs, braces, etc. +How to indicate results of evaluation, + expansion of macros, errors, etc. +How to force and prevent line and page breaks. +How to describe functions and the like in a uniform manner. +How to write footnotes. +How to specify text for either @TeX{} or Info. +How to print hardcopy. +How to create an Info file. +How to install an Info file +A list of all the Texinfo @@-commands. +Hints on how to write a Texinfo document. +A sample Texinfo file to look at. +Tell readers they have the right to copy + and distribute. +How to incorporate other Texinfo files. +How to write page headings and footings. +How to find formatting mistakes. +All about paragraph refilling. +A description of @@-Command syntax. +Texinfo second edition features. +A menu containing commands and variables. +A menu covering many topics. +@end ignore + +@menu +* Copying:: Your rights. +* Overview:: Texinfo in brief. +* Texinfo Mode:: How to use Texinfo mode. +* Beginning a File:: What is at the beginning of a Texinfo file? +* Ending a File:: What is at the end of a Texinfo file? +* Structuring:: How to create chapters, sections, subsections, + appendices, and other parts. +* Nodes:: How to write nodes. +* Menus:: How to write menus. +* Cross References:: How to write cross references. +* Marking Text:: How to mark words and phrases as code, + keyboard input, meta-syntactic + variables, and the like. +* Quotations and Examples:: How to write quotations, examples, etc. +* Lists and Tables:: How to write lists and tables. +* Indices:: How to create indices. +* Insertions:: How to insert @@-signs, braces, etc. +* Glyphs:: How to indicate results of evaluation, + expansion of macros, errors, etc. +* Breaks:: How to force and prevent line and page breaks. +* Definition Commands:: How to describe functions and the like + in a uniform manner. +* Footnotes:: How to write footnotes. +* Conditionals:: How to specify text for either @TeX{} or Info. +* Macros:: Defining new Texinfo commands. +* Format/Print Hardcopy:: How to convert a Texinfo file to a file + for printing and how to print that file. +* Create an Info File:: Convert a Texinfo file into an Info file. +* Install an Info File:: Make an Info file accessible to users. +* Command List:: All the Texinfo @@-commands. +* Tips:: Hints on how to write a Texinfo document. +* Sample Texinfo File:: A sample Texinfo file to look at. +* Sample Permissions:: Tell readers they have the right to copy + and distribute. +* Include Files:: How to incorporate other Texinfo files. +* Headings:: How to write page headings and footings. +* Catching Mistakes:: How to find formatting mistakes. +* Refilling Paragraphs:: All about paragraph refilling. +* Command Syntax:: A description of @@-Command syntax. +* Obtaining TeX:: How to Obtain @TeX{}. +* New Features:: Texinfo second edition features. +* Command and Variable Index:: A menu containing commands and variables. +* Concept Index:: A menu covering many topics. + +@detailmenu + + --- The Detailed Node Listing --- + +Overview of Texinfo + +* Using Texinfo:: Create a conventional printed book + or an Info file. +* Info Files:: What is an Info file? +* Printed Books:: Characteristics of a printed book or manual. +* Formatting Commands:: @@-commands are used for formatting. +* Conventions:: General rules for writing a Texinfo file. +* Comments:: How to write comments and mark regions that + the formatting commands will ignore. +* Minimum:: What a Texinfo file must have. +* Six Parts:: Usually, a Texinfo file has six parts. +* Short Sample:: A short sample Texinfo file. +* Acknowledgements:: + +Using Texinfo Mode + +* Texinfo Mode Overview:: How Texinfo mode can help you. +* Emacs Editing:: Texinfo mode adds to GNU Emacs' general + purpose editing features. +* Inserting:: How to insert frequently used @@-commands. +* Showing the Structure:: How to show the structure of a file. +* Updating Nodes and Menus:: How to update or create new nodes and menus. +* Info Formatting:: How to format for Info. +* Printing:: How to format and print part or all of a file. +* Texinfo Mode Summary:: Summary of all the Texinfo mode commands. + +Updating Nodes and Menus + +* Updating Commands:: Five major updating commands. +* Updating Requirements:: How to structure a Texinfo file for + using the updating command. +* Other Updating Commands:: How to indent descriptions, insert + missing nodes lines, and update + nodes in sequence. + +Beginning a Texinfo File + +* Four Parts:: Four parts begin a Texinfo file. +* Sample Beginning:: Here is a sample beginning for a Texinfo file. +* Header:: The very beginning of a Texinfo file. +* Info Summary and Permissions:: Summary and copying permissions for Info. +* Titlepage & Copyright Page:: Creating the title and copyright pages. +* The Top Node:: Creating the `Top' node and master menu. +* Software Copying Permissions:: Ensure that you and others continue to + have the right to use and share software. + +The Texinfo File Header + +* First Line:: The first line of a Texinfo file. +* Start of Header:: Formatting a region requires this. +* setfilename:: Tell Info the name of the Info file. +* settitle:: Create a title for the printed work. +* setchapternewpage:: Start chapters on right-hand pages. +* paragraphindent:: An option to specify paragraph indentation. +* End of Header:: Formatting a region requires this. + +The Title and Copyright Pages + +* titlepage:: Create a title for the printed document. +* titlefont center sp:: The @code{@@titlefont}, @code{@@center}, + and @code{@@sp} commands. +* title subtitle author:: The @code{@@title}, @code{@@subtitle}, + and @code{@@author} commands. +* Copyright & Permissions:: How to write the copyright notice and + include copying permissions. +* end titlepage:: Turn on page headings after the title and + copyright pages. +* headings on off:: An option for turning headings on and off + and double or single sided printing. + +The `Top' Node and Master Menu + +* Title of Top Node:: Sketch what the file is about. +* Master Menu Parts:: A master menu has three or more parts. + +Ending a Texinfo File + +* Printing Indices & Menus:: How to print an index in hardcopy and + generate index menus in Info. +* Contents:: How to create a table of contents. +* File End:: How to mark the end of a file. + +Chapter Structuring + +* Tree Structuring:: A manual is like an upside down tree @dots{} +* Structuring Command Types:: How to divide a manual into parts. +* makeinfo top:: The @code{@@top} command, part of the `Top' node. +* chapter:: +* unnumbered & appendix:: +* majorheading & chapheading:: +* section:: +* unnumberedsec appendixsec heading:: +* subsection:: +* unnumberedsubsec appendixsubsec subheading:: +* subsubsection:: Commands for the lowest level sections. +* Raise/lower sections:: How to change commands' hierarchical level. + +Nodes + +* Two Paths:: Different commands to structure + Info output and printed output. +* Node Menu Illustration:: A diagram, and sample nodes and menus. +* node:: How to write a node, in detail. +* makeinfo Pointer Creation:: How to create node pointers with @code{makeinfo}. + +The @code{@@node} Command + +* Node Names:: How to choose node and pointer names. +* Writing a Node:: How to write an @code{@@node} line. +* Node Line Tips:: Keep names short. +* Node Line Requirements:: Keep names unique, without @@-commands. +* First Node:: How to write a `Top' node. +* makeinfo top command:: How to use the @code{@@top} command. +* Top Node Summary:: Write a brief description for readers. + +Menus + +* Menu Location:: Put a menu in a short node. +* Writing a Menu:: What is a menu? +* Menu Parts:: A menu entry has three parts. +* Less Cluttered Menu Entry:: Two part menu entry. +* Menu Example:: Two and three part menu entries. +* Other Info Files:: How to refer to a different Info file. + +Cross References + +* References:: What cross references are for. +* Cross Reference Commands:: A summary of the different commands. +* Cross Reference Parts:: A cross reference has several parts. +* xref:: Begin a reference with `See' @dots{} +* Top Node Naming:: How to refer to the beginning of another file. +* ref:: A reference for the last part of a sentence. +* pxref:: How to write a parenthetical cross reference. +* inforef:: How to refer to an Info-only file. + +@code{@@xref} + +* Reference Syntax:: What a reference looks like and requires. +* One Argument:: @code{@@xref} with one argument. +* Two Arguments:: @code{@@xref} with two arguments. +* Three Arguments:: @code{@@xref} with three arguments. +* Four and Five Arguments:: @code{@@xref} with four and five arguments. + +Marking Words and Phrases + +* Indicating:: How to indicate definitions, files, etc. +* Emphasis:: How to emphasize text. + +Indicating Definitions, Commands, etc. + +* Useful Highlighting:: Highlighting provides useful information. +* code:: How to indicate code. +* kbd:: How to show keyboard input. +* key:: How to specify keys. +* samp:: How to show a literal sequence of characters. +* var:: How to indicate a metasyntactic variable. +* file:: How to indicate the name of a file. +* dfn:: How to specify a definition. +* cite:: How to refer to a book that is not in Info. +* url:: How to indicate a world wide web reference. +* email:: How to indicate an electronic mail address. + +Emphasizing Text + +* emph & strong:: How to emphasize text in Texinfo. +* Smallcaps:: How to use the small caps font. +* Fonts:: Various font commands for printed output. +* Customized Highlighting:: How to define highlighting commands. + +Quotations and Examples + +* Block Enclosing Commands:: Use different constructs for + different purposes. +* quotation:: How to write a quotation. +* example:: How to write an example in a fixed-width font. +* noindent:: How to prevent paragraph indentation. +* Lisp Example:: How to illustrate Lisp code. +* smallexample & smalllisp:: Forms for the @code{@@smallbook} option. +* display:: How to write an example in the current font. +* format:: How to write an example that does not narrow + the margins. +* exdent:: How to undo the indentation of a line. +* flushleft & flushright:: How to push text flushleft or flushright. +* cartouche:: How to draw cartouches around examples. + +Making Lists and Tables + +* Introducing Lists:: Texinfo formats lists for you. +* itemize:: How to construct a simple list. +* enumerate:: How to construct a numbered list. +* Two-column Tables:: How to construct a two-column table. +* Multi-column Tables:: How to construct generalized tables. + +Making a Two-column Table + +* table:: How to construct a two-column table. +* ftable vtable:: How to construct a two-column table + with automatic indexing. +* itemx:: How to put more entries in the first column. + +Multi-column Tables + +* Multitable Column Widths:: Defining multitable column widths. +* Multitable Rows:: Defining multitable rows, with examples. + +Creating Indices + +* Index Entries:: Choose different words for index entries. +* Predefined Indices:: Use different indices for different kinds + of entry. +* Indexing Commands:: How to make an index entry. +* Combining Indices:: How to combine indices. +* New Indices:: How to define your own indices. + +Combining Indices + +* syncodeindex:: How to merge two indices, using @code{@@code} + font for the merged-from index. +* synindex:: How to merge two indices, using the + default font of the merged-to index. + +Special Insertions + +* Braces Atsigns:: How to insert braces, @samp{@@}. +* Inserting Space:: How to insert the right amount of space + within a sentence. +* Inserting Accents:: How to insert accents and special characters. +* Dots Bullets:: How to insert dots and bullets. +* TeX and copyright:: How to insert the @TeX{} logo + and the copyright symbol. +* pounds:: How to insert the pounds currency symbol. +* minus:: How to insert a minus sign. +* math:: How to format a mathematical expression. + +Inserting @@ and Braces + +* Inserting An Atsign:: How to insert @samp{@@}. +* Inserting Braces:: How to insert @samp{@{} and @samp{@}}. + +Inserting Space + +* Not Ending a Sentence:: Sometimes a . doesn't end a sentence. +* Ending a Sentence:: Sometimes it does. +* Multiple Spaces:: Inserting multiple spaces. +* dmn:: How to format a dimension. + +Inserting Ellipsis, Dots, and Bullets + +* dots:: How to insert dots @dots{} +* bullet:: How to insert a bullet. + +Inserting @TeX{} and the Copyright Symbol + +* tex:: How to insert the @TeX{} logo. +* copyright symbol:: How to use @code{@@copyright}@{@}. + +Glyphs for Examples + +* Glyphs Summary:: +* result:: How to show the result of expression. +* expansion:: How to indicate an expansion. +* Print Glyph:: How to indicate printed output. +* Error Glyph:: How to indicate an error message. +* Equivalence:: How to indicate equivalence. +* Point Glyph:: How to indicate the location of point. + +Making and Preventing Breaks + +* Break Commands:: Cause and prevent splits. +* Line Breaks:: How to force a single line to use two lines. +* - and hyphenation:: How to tell TeX about hyphenation points. +* w:: How to prevent unwanted line breaks. +* sp:: How to insert blank lines. +* page:: How to force the start of a new page. +* group:: How to prevent unwanted page breaks. +* need:: Another way to prevent unwanted page breaks. + +Definition Commands + +* Def Cmd Template:: How to structure a description using a + definition command. +* Optional Arguments:: How to handle optional and repeated arguments. +* deffnx:: How to group two or more `first' lines. +* Def Cmds in Detail:: All the definition commands. +* Def Cmd Conventions:: Conventions for writing definitions. +* Sample Function Definition:: + +The Definition Commands + +* Functions Commands:: Commands for functions and similar entities. +* Variables Commands:: Commands for variables and similar entities. +* Typed Functions:: Commands for functions in typed languages. +* Typed Variables:: Commands for variables in typed languages. +* Abstract Objects:: Commands for object-oriented programming. +* Data Types:: The definition command for data types. + +Footnotes + +* Footnote Commands:: How to write a footnote in Texinfo. +* Footnote Styles:: Controlling how footnotes appear in Info. + +Conditionally Visible Text + +* Conditional Commands:: How to specify text for HTML, Info, or @TeX{}. +* Using Ordinary TeX Commands:: You can use any and all @TeX{} commands. +* set clear value:: How to designate which text to format (for + both Info and @TeX{}); and how to set a + flag to a string that you can insert. + +@code{@@set}, @code{@@clear}, and @code{@@value} + +* ifset ifclear:: Format a region if a flag is set. +* value:: Replace a flag with a string. +* value Example:: An easy way to update edition information. + +Macros: Defining New Texinfo Commands + +* Defining Macros:: Both defining and undefining new commands. +* Invoking Macros:: Using a macro, once you've defined it. + +Format and Print Hardcopy + +* Use TeX:: Use @TeX{} to format for hardcopy. +* Format with tex/texindex:: How to format in a shell. +* Format with texi2dvi:: A simpler way to use the shell. +* Print with lpr:: How to print. +* Within Emacs:: How to format and print from an Emacs shell. +* Texinfo Mode Printing:: How to format and print in Texinfo mode. +* Compile-Command:: How to print using Emacs's compile command. +* Requirements Summary:: @TeX{} formatting requirements summary. +* Preparing for TeX:: What you need to do to use @TeX{}. +* Overfull hboxes:: What are and what to do with overfull hboxes. +* smallbook:: How to print small format books and manuals. +* A4 Paper:: How to print on European A4 paper. +* Cropmarks and Magnification:: How to print marks to indicate the size + of pages and how to print scaled up output. + +Creating an Info File + +* makeinfo advantages:: @code{makeinfo} provides better error checking. +* Invoking makeinfo:: How to run @code{makeinfo} from a shell. +* makeinfo options:: Specify fill-column and other options. +* Pointer Validation:: How to check that pointers point somewhere. +* makeinfo in Emacs:: How to run @code{makeinfo} from Emacs. +* texinfo-format commands:: Two Info formatting commands written + in Emacs Lisp are an alternative + to @code{makeinfo}. +* Batch Formatting:: How to format for Info in Emacs Batch mode. +* Tag and Split Files:: How tagged and split files help Info + to run better. + +Installing an Info File + +* Directory file:: The top level menu for all Info files. +* New Info File:: Listing a new info file. +* Other Info Directories:: How to specify Info files that are + located in other directories. +* Installing Dir Entries:: How to specify what menu entry to add + to the Info directory. +* Invoking install-info:: @code{install-info} options. + +Sample Permissions + +* Inserting Permissions:: How to put permissions in your document. +* ifinfo Permissions:: Sample @samp{ifinfo} copying permissions. +* Titlepage Permissions:: Sample Titlepage copying permissions. + +Include Files + +* Using Include Files:: How to use the @code{@@include} command. +* texinfo-multiple-files-update:: How to create and update nodes and + menus when using included files. +* Include File Requirements:: What @code{texinfo-multiple-files-update} expects. +* Sample Include File:: A sample outer file with included files + within it; and a sample included file. +* Include Files Evolution:: How use of the @code{@@include} command + has changed over time. + +Page Headings + +* Headings Introduced:: Conventions for using page headings. +* Heading Format:: Standard page heading formats. +* Heading Choice:: How to specify the type of page heading. +* Custom Headings:: How to create your own headings and footings. + +Formatting Mistakes + +* makeinfo preferred:: @code{makeinfo} finds errors. +* Debugging with Info:: How to catch errors with Info formatting. +* Debugging with TeX:: How to catch errors with @TeX{} formatting. +* Using texinfo-show-structure:: How to use @code{texinfo-show-structure}. +* Using occur:: How to list all lines containing a pattern. +* Running Info-Validate:: How to find badly referenced nodes. + +Finding Badly Referenced Nodes + +* Using Info-validate:: How to run @code{Info-validate}. +* Unsplit:: How to create an unsplit file. +* Tagifying:: How to tagify a file. +* Splitting:: How to split a file manually. + +Second Edition Features + +* New Texinfo Mode Commands:: The updating commands are especially useful. +* New Commands:: Many newly described @@-commands. +@end detailmenu +@end menu + +@node Copying, Overview, Top, Top +@comment node-name, next, previous, up +@unnumbered Texinfo Copying Conditions +@cindex Copying conditions +@cindex Conditions for copying Texinfo + +The programs currently being distributed that relate to Texinfo include +portions of GNU Emacs, plus other separate programs (including +@code{makeinfo}, @code{info}, @code{texindex}, and @file{texinfo.tex}). +These programs are @dfn{free}; this means that everyone is free to use +them and free to redistribute them on a free basis. The Texinfo-related +programs are not in the public domain; they are copyrighted and there +are restrictions on their distribution, but these restrictions are +designed to permit everything that a good cooperating citizen would want +to do. What is not allowed is to try to prevent others from further +sharing any version of these programs that they might get from +you.@refill + + Specifically, we want to make sure that you have the right to give +away copies of the programs that relate to Texinfo, that you receive +source code or else can get it if you want it, that you can change these +programs or use pieces of them in new free programs, and that you know +you can do these things.@refill + + To make sure that everyone has such rights, we have to forbid you to +deprive anyone else of these rights. For example, if you distribute +copies of the Texinfo related programs, 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 tell them their rights.@refill + + Also, for our own protection, we must make certain that everyone finds +out that there is no warranty for the programs that relate to Texinfo. +If these programs are modified by someone else and passed on, we want +their recipients to know that what they have is not what we distributed, +so that any problems introduced by others will not reflect on our +reputation.@refill + + The precise conditions of the licenses for the programs currently +being distributed that relate to Texinfo are found in the General Public +Licenses that accompany them.@refill + +@node Overview, Texinfo Mode, Copying, Top +@comment node-name, next, previous, up +@chapter Overview of Texinfo +@cindex Overview of Texinfo +@cindex Texinfo overview + +@dfn{Texinfo}@footnote{Note that the first syllable of ``Texinfo'' is +pronounced like ``speck'', not ``hex''. This odd pronunciation is +derived from, but is not the same as, the pronunciation of @TeX{}. In +the word @TeX{}, the @samp{X} is actually the Greek letter ``chi'' +rather than the English letter ``ex''. Pronounce @TeX{} as if the +@samp{X} were the last sound in the name `Bach'; but pronounce Texinfo +as if the @samp{x} were a `k'. Spell ``Texinfo'' with a capital ``T'' +and write the other letters in lower case.} +is a documentation system that uses a single source file to produce both +on-line information and printed output. This means that instead of +writing two different documents, one for the on-line help or other on-line +information and the other for a typeset manual or other printed work, you +need write only one document. When the work is revised, you need revise +only one document. (You can read the on-line information, known as an +@dfn{Info file}, with an Info documentation-reading program.)@refill + +@menu +* Using Texinfo:: Create a conventional printed book + or an Info file. +* Info Files:: What is an Info file? +* Printed Books:: Characteristics of a printed book or manual. +* Formatting Commands:: @@-commands are used for formatting. +* Conventions:: General rules for writing a Texinfo file. +* Comments:: How to write comments and mark regions that + the formatting commands will ignore. +* Minimum:: What a Texinfo file must have. +* Six Parts:: Usually, a Texinfo file has six parts. +* Short Sample:: A short sample Texinfo file. +* Acknowledgements:: +@end menu + +@node Using Texinfo, Info Files, Overview, Overview +@ifinfo +@heading Using Texinfo +@end ifinfo + +Using Texinfo, you can create a printed document with the normal +features of a book, including chapters, sections, cross references, +and indices. From the same Texinfo source file, you can create a +menu-driven, on-line Info file with nodes, menus, cross references, +and indices. You can, if you wish, make the chapters and sections of +the printed document correspond to the nodes of the on-line +information; and you use the same cross references and indices for +both the Info file and the printed work. @cite{The GNU +Emacs Manual} is a good example of a Texinfo file, as is this manual.@refill + +To make a printed document, you process a Texinfo source file with the +@TeX{} typesetting program. This creates a @sc{dvi} file that you can +typeset and print as a book or report. (Note that the Texinfo language +is completely different from @TeX{}'s usual language, plain @TeX{}.) If +you do not have @TeX{}, but do have @code{troff} or @code{nroff}, you +can use the @code{texi2roff} program instead.@refill + +To make an Info file, you process a Texinfo source file with the +@code{makeinfo} utility or Emacs's @code{texinfo-format-buffer} command; +this creates an Info file that you can install on-line.@refill + +@TeX{} and @code{texi2roff} work with many types of printer; similarly, +Info works with almost every type of computer terminal. This power +makes Texinfo a general purpose system, but brings with it a constraint, +which is that a Texinfo file may contain only the customary +``typewriter'' characters (letters, numbers, spaces, and punctuation +marks) but no special graphics.@refill + +A Texinfo file is a plain @sc{ascii} file containing text and +@dfn{@@-commands} (words preceded by an @samp{@@}) that tell the +typesetting and formatting programs what to do. You may edit a +Texinfo file with any text editor; but it is especially convenient to +use GNU Emacs since that editor has a special mode, called Texinfo +mode, that provides various Texinfo-related features. (@xref{Texinfo +Mode}.)@refill + +Before writing a Texinfo source file, you should become familiar with +the Info documentation reading program and learn about nodes, +menus, cross references, and the rest. (@inforef{Top, info, info}, +for more information.)@refill + +You can use Texinfo to create both on-line help and printed manuals; +moreover, Texinfo is freely redistributable. For these reasons, Texinfo +is the format in which documentation for GNU utilities and libraries is +written.@refill + +@node Info Files, Printed Books, Using Texinfo, Overview +@comment node-name, next, previous, up +@section Info files +@cindex Info files + +An Info file is a Texinfo file formatted so that the Info documentation +reading program can operate on it. (@code{makeinfo} +and @code{texinfo-format-buffer} are two commands that convert a Texinfo file +into an Info file.)@refill + +Info files are divided into pieces called @dfn{nodes}, each of which +contains the discussion of one topic. Each node has a name, and +contains both text for the user to read and pointers to other nodes, +which are identified by their names. The Info program displays one node +at a time, and provides commands with which the user can move to other +related nodes.@refill + +@ifinfo +@inforef{Top, info, info}, for more information about using Info.@refill +@end ifinfo + +Each node of an Info file may have any number of child nodes that +describe subtopics of the node's topic. The names of child +nodes are listed in a @dfn{menu} within the parent node; this +allows you to use certain Info commands to move to one of the child +nodes. Generally, an Info file is organized like a book. If a node +is at the logical level of a chapter, its child nodes are at the level +of sections; likewise, the child nodes of sections are at the level +of subsections.@refill + +All the children of any one parent are linked together in a +bidirectional chain of `Next' and `Previous' pointers. The `Next' +pointer provides a link to the next section, and the `Previous' pointer +provides a link to the previous section. This means that all the nodes +that are at the level of sections within a chapter are linked together. +Normally the order in this chain is the same as the order of the +children in the parent's menu. Each child node records the parent node +name as its `Up' pointer. The last child has no `Next' pointer, and the +first child has the parent both as its `Previous' and as its `Up' +pointer.@footnote{In some documents, the first child has no `Previous' +pointer. Occasionally, the last child has the node name of the next +following higher level node as its `Next' pointer.}@refill + +The book-like structuring of an Info file into nodes that correspond +to chapters, sections, and the like is a matter of convention, not a +requirement. The `Up', `Previous', and `Next' pointers of a node can +point to any other nodes, and a menu can contain any other nodes. +Thus, the node structure can be any directed graph. But it is usually +more comprehensible to follow a structure that corresponds to the +structure of chapters and sections in a printed book or report.@refill + +In addition to menus and to `Next', `Previous', and `Up' pointers, Info +provides pointers of another kind, called references, that can be +sprinkled throughout the text. This is usually the best way to +represent links that do not fit a hierarchical structure.@refill + +Usually, you will design a document so that its nodes match the +structure of chapters and sections in the printed output. But there +are times when this is not right for the material being discussed. +Therefore, Texinfo uses separate commands to specify the node +structure for the Info file and the section structure for the printed +output.@refill + +Generally, you enter an Info file through a node that by convention is +called @samp{Top}. This node normally contains just a brief summary +of the file's purpose, and a large menu through which the rest of the +file is reached. From this node, you can either traverse the file +systematically by going from node to node, or you can go to a specific +node listed in the main menu, or you can search the index menus and +then go directly to the node that has the information you want.@refill +@c !!! With the standalone Info system you may go to specific nodes +@c directly.. + +If you want to read through an Info file in sequence, as if it were a +printed manual, you can get the whole file with the advanced Info +command @kbd{g* @key{RET}}. (@inforef{Expert, Advanced Info commands, +info}.)@refill + +@c !!! dir file may be located in one of many places: +@c /usr/local/emacs/info mentioned in info.c DEFAULT_INFOPATH +@c /usr/local/lib/emacs/info mentioned in info.c DEFAULT_INFOPATH +@c /usr/gnu/info mentioned in info.c DEFAULT_INFOPATH +@c /usr/local/info +@c /usr/local/lib/info +The @file{dir} file in the @file{info} directory serves as the +departure point for the whole Info system. From it, you can reach the +`Top' nodes of each of the documents in a complete Info system.@refill + +@node Printed Books, Formatting Commands, Info Files, Overview +@comment node-name, next, previous, up +@section Printed Books +@cindex Printed book and manual characteristics +@cindex Manual characteristics, printed +@cindex Book characteristics, printed +@cindex Texinfo printed book characteristics +@cindex Characteristics, printed books or manuals + +@cindex Knuth, Donald +A Texinfo file can be formatted and typeset as a printed book or manual. +To do this, you need @TeX{}, a powerful, sophisticated typesetting +program written by Donald Knuth.@footnote{You can also use the +@code{texi2roff} program if you do not have @TeX{}; since Texinfo is +designed for use with @TeX{}, @code{texi2roff} is not described here. +@code{texi2roff} is part of the standard GNU distribution.}@refill + +A Texinfo-based book is similar to any other typeset, printed work: it +can have a title page, copyright page, table of contents, and preface, +as well as chapters, numbered or unnumbered sections and subsections, +page headers, cross references, footnotes, and indices.@refill + +You can use Texinfo to write a book without ever having the intention +of converting it into on-line information. You can use Texinfo for +writing a printed novel, and even to write a printed memo, although +this latter application is not recommended since electronic mail is so +much easier.@refill + +@TeX{} is a general purpose typesetting program. Texinfo provides a +file called @file{texinfo.tex} that contains information (definitions or +@dfn{macros}) that @TeX{} uses when it typesets a Texinfo file. +(@file{texinfo.tex} tells @TeX{} how to convert the Texinfo @@-commands +to @TeX{} commands, which @TeX{} can then process to create the typeset +document.) @file{texinfo.tex} contains the specifications for printing +a document.@refill + +Most often, documents are printed on 8.5 inch by 11 inch +pages (216@dmn{mm} by 280@dmn{mm}; this is the default size), but you +can also print for 7 inch by 9.25 inch pages (178@dmn{mm} by +235@dmn{mm}; the @code{@@smallbook} size) or on European A4 size paper +(@code{@@afourpaper}). (@xref{smallbook, , Printing ``Small'' Books}. +Also, see @ref{A4 Paper, ,Printing on A4 Paper}.)@refill + +By changing the parameters in @file{texinfo.tex}, you can change the +size of the printed document. In addition, you can change the style in +which the printed document is formatted; for example, you can change the +sizes and fonts used, the amount of indentation for each paragraph, the +degree to which words are hyphenated, and the like. By changing the +specifications, you can make a book look dignified, old and serious, or +light-hearted, young and cheery.@refill + +@TeX{} is freely distributable. It is written in a dialect of Pascal +called WEB and can be compiled either in Pascal or (by using a +conversion program that comes with the @TeX{} distribution) in C. +(@xref{TeX Mode, ,@TeX{} Mode, emacs, The GNU Emacs Manual}, for information +about @TeX{}.)@refill + +@TeX{} is very powerful and has a great many features. Because a +Texinfo file must be able to present information both on a +character-only terminal in Info form and in a typeset book, the +formatting commands that Texinfo supports are necessarily +limited.@refill + +@xref{Obtaining TeX, , How to Obtain @TeX{}}. + + +@node Formatting Commands, Conventions, Printed Books, Overview +@comment node-name, next, previous, up +@section @@-commands +@cindex @@-commands +@cindex Formatting commands + +In a Texinfo file, the commands that tell @TeX{} how to typeset the +printed manual and tell @code{makeinfo} and +@code{texinfo-format-buffer} how to create an Info file are preceded +by @samp{@@}; they are called @dfn{@@-commands}. For example, +@code{@@node} is the command to indicate a node and @code{@@chapter} +is the command to indicate the start of a chapter.@refill + +@quotation +@strong{Please note:} All the @@-commands, with the exception of the +@code{@@TeX@{@}} command, must be written entirely in lower +case.@refill +@end quotation + +The Texinfo @@-commands are a strictly limited set of constructs. The +strict limits make it possible for Texinfo files to be understood both +by @TeX{} and by the code that converts them into Info files. You can +display Info files on any terminal that displays alphabetic and +numeric characters. Similarly, you can print the output generated by +@TeX{} on a wide variety of printers.@refill + +Depending on what they do or what arguments@footnote{The word +@dfn{argument} comes from the way it is used in mathematics and does +not refer to a disputation between two people; it refers to the +information presented to the command. According to the @cite{Oxford +English Dictionary}, the word derives from the Latin for @dfn{to make +clear, prove}; thus it came to mean `the evidence offered as proof', +which is to say, `the information offered', which led to its +mathematical meaning. In its other thread of derivation, the word +came to mean `to assert in a manner against which others may make +counter assertions', which led to the meaning of `argument' as a +disputation.} they take, you need to write @@-commands on lines of +their own or as part of sentences:@refill + +@itemize @bullet +@item +Write a command such as @code{@@noindent} at the beginning of a line as +the only text on the line. (@code{@@noindent} prevents the beginning of +the next line from being indented as the beginning of a +paragraph.)@refill + +@item +Write a command such as @code{@@chapter} at the beginning of a line +followed by the command's arguments, in this case the chapter title, on +the rest of the line. (@code{@@chapter} creates chapter titles.)@refill + +@item +Write a command such as @code{@@dots@{@}} wherever you wish but usually +within a sentence. (@code{@@dots@{@}} creates dots @dots{})@refill + +@item +Write a command such as @code{@@code@{@var{sample-code}@}} wherever you +wish (but usually within a sentence) with its argument, +@var{sample-code} in this example, between the braces. (@code{@@code} +marks text as being code.)@refill + +@item +Write a command such as @code{@@example} at the beginning of a line of +its own; write the body-text on following lines; and write the matching +@code{@@end} command, @code{@@end example} in this case, at the +beginning of a line of its own after the body-text. (@code{@@example} +@dots{} @code{@@end example} indents and typesets body-text as an +example.)@refill +@end itemize + +@noindent +@cindex Braces, when to use +As a general rule, a command requires braces if it mingles among other +text; but it does not need braces if it starts a line of its own. The +non-alphabetic commands, such as @code{@@:}, are exceptions to the rule; +they do not need braces.@refill + +As you gain experience with Texinfo, you will rapidly learn how to +write the different commands: the different ways to write commands +make it easier to write and read Texinfo files than if all commands +followed exactly the same syntax. (For details about @@-command +syntax, see @ref{Command Syntax, , @@-Command Syntax}.)@refill + +@node Conventions, Comments, Formatting Commands, Overview +@comment node-name, next, previous, up +@section General Syntactic Conventions +@cindex General syntactic conventions +@cindex Syntactic conventions +@cindex Conventions, syntactic + +All printable @sc{ascii} characters except @samp{@@}, @samp{@{} and +@samp{@}} can appear in a Texinfo file and stand for themselves. +@samp{@@} is the escape character which introduces commands. +@samp{@{} and @samp{@}} should be used only to surround arguments to +certain commands. To put one of these special characters into the +document, put an @samp{@@} character in front of it, like this: +@samp{@@@@}, @samp{@@@{}, and @samp{@@@}}.@refill + +@ifinfo +It is customary in @TeX{} to use doubled single-quote characters to +begin and end quotations: ` ` and ' ' (but without a space between the +two single-quote characters). This convention should be followed in +Texinfo files. @TeX{} converts doubled single-quote characters to +left- and right-hand doubled quotation marks and Info converts doubled +single-quote characters to @sc{ascii} double-quotes: ` ` and ' ' to " .@refill +@end ifinfo +@iftex +It is customary in @TeX{} to use doubled single-quote characters to +begin and end quotations: @w{@tt{ `` }} and @w{@tt{ '' }}. This +convention should be followed in Texinfo files. @TeX{} converts +doubled single-quote characters to left- and right-hand doubled +quotation marks, ``like this'', and Info converts doubled single-quote +characters to @sc{ascii} double-quotes: @w{@tt{ `` }} and +@w{@tt{ '' }} to @w{@tt{ " }}.@refill +@end iftex + +Use three hyphens in a row, @samp{---}, for a dash---like this. In +@TeX{}, a single or even a double hyphen produces a printed dash that +is shorter than the usual typeset dash. Info reduces three hyphens to two for +display on the screen.@refill + +To prevent a paragraph from being indented in the printed manual, put +the command @code{@@noindent} on a line by itself before the +paragraph.@refill + +If you mark off a region of the Texinfo file with the @code{@@iftex} +and @w{@code{@@end iftex}} commands, that region will appear only in +the printed copy; in that region, you can use certain commands +borrowed from plain @TeX{} that you cannot use in Info. Likewise, if +you mark off a region with the @code{@@ifinfo} and @code{@@end ifinfo} +commands, that region will appear only in the Info file; in that +region, you can use Info commands that you cannot use in @TeX{}. +Similarly for @code{@@ifhtml} and @code{@@end ifhtml}. +@xref{Conditionals}. + +@cindex Tabs; don't use! +@quotation +@strong{Caution:} Do not use tabs in a Texinfo file! @TeX{} uses +variable-width fonts, which means that it cannot predefine a tab to work +in all circumstances. Consequently, @TeX{} treats tabs like single +spaces, and that is not what they look like.@refill + +@noindent +To avoid this problem, Texinfo mode causes GNU Emacs to insert multiple +spaces when you press the @key{TAB} key.@refill + +@noindent +Also, you can run @code{untabify} in Emacs to convert tabs in a region +to multiple spaces.@refill +@end quotation + +@node Comments, Minimum, Conventions, Overview +@comment node-name, next, previous, up +@section Comments + +You can write comments in a Texinfo file that will not appear in +either the Info file or the printed manual by using the +@code{@@comment} command (which may be abbreviated to @code{@@c}). +Such comments are for the person who reads the Texinfo file. All the +text on a line that follows either @code{@@comment} or @code{@@c} is a +comment; the rest of the line does not appear in either the Info file +or the printed manual. (Often, you can write the @code{@@comment} or +@code{@@c} in the middle of a line, and only the text that follows after +the @code{@@comment} or @code{@@c} command does not appear; but some +commands, such as @code{@@settitle} and @code{@@setfilename}, work on a +whole line. You cannot use @code{@@comment} or @code{@@c} in a line +beginning with such a command.)@refill +@cindex Comments +@findex comment +@findex c @r{(comment)} + +You can write long stretches of text that will not appear in either +the Info file or the printed manual by using the @code{@@ignore} and +@code{@@end ignore} commands. Write each of these commands on a line +of its own, starting each command at the beginning of the line. Text +between these two commands does not appear in the processed output. +You can use @code{@@ignore} and @code{@@end ignore} for writing +comments. Often, @code{@@ignore} and @code{@@end ignore} is used +to enclose a part of the copying permissions that applies to the +Texinfo source file of a document, but not to the Info or printed +version of the document.@refill +@cindex Ignored text +@cindex Unprocessed text +@findex ignore +@c !!! Perhaps include this comment about ignore and ifset: +@ignore +Text enclosed by @code{@@ignore} or by failing @code{@@ifset} or +@code{@@ifclear} conditions is ignored in the sense that it will not +contribute to the formatted output. However, TeX and makeinfo must +still parse the ignored text, in order to understand when to +@emph{stop} ignoring text from the source file; that means that you +will still get error messages if you have invalid Texinfo markup +within ignored text. +@end ignore + +@node Minimum, Six Parts, Comments, Overview +@comment node-name, next, previous, up +@section What a Texinfo File Must Have +@cindex Minimal Texinfo file (requirements) +@cindex Must have in Texinfo file +@cindex Required in Texinfo file +@cindex Texinfo file minimum + +By convention, the names of Texinfo files end with one of the +extensions @file{.texinfo}, @file{.texi}, or @file{.tex}. The longer +extension is preferred since it describes more clearly to a human +reader the nature of the file. The shorter extensions are for +operating systems that cannot handle long file names.@refill + +In order to be made into a printed manual and an Info file, a Texinfo +file @strong{must} begin with lines like this:@refill + +@example +@group +\input texinfo +@@setfilename @var{info-file-name} +@@settitle @var{name-of-manual} +@end group +@end example + +@noindent +The contents of the file follow this beginning, and then you @strong{must} end +a Texinfo file with a line like this:@refill + +@example +@@bye +@end example + +@findex input @r{(@TeX{} command)} +@noindent +The @samp{\input texinfo} line tells @TeX{} to use the +@file{texinfo.tex} file, which tells @TeX{} how to translate the Texinfo +@@-commands into @TeX{} typesetting commands. (Note the use of the +backslash, @samp{\}; this is correct for @TeX{}.) The +@samp{@@setfilename} line provides a name for the Info file and tells +@TeX{} to open auxiliary files. The @samp{@@settitle} line specifies a +title for the page headers (or footers) of the printed manual.@refill + +The @code{@@bye} line at the end of the file on a line of its own tells +the formatters that the file is ended and to stop formatting.@refill + +Usually, you will not use quite such a spare format, but will include +mode setting and start-of-header and end-of-header lines at the +beginning of a Texinfo file, like this:@refill + +@example +@group +\input texinfo @@c -*-texinfo-*- +@@c %**start of header +@@setfilename @var{info-file-name} +@@settitle @var{name-of-manual} +@@c %**end of header +@end group +@end example + +@noindent +In the first line, @samp{-*-texinfo-*-} causes Emacs to switch into +Texinfo mode when you edit the file. + +The @code{@@c} lines which surround the @samp{@@setfilename} and +@samp{@@settitle} lines are optional, but you need them in order to +run @TeX{} or Info on just part of the file. (@xref{Start of Header}, +for more information.)@refill + +Furthermore, you will usually provide a Texinfo file with a title +page, indices, and the like. But the minimum, which can be useful +for short documents, is just the three lines at the beginning and the +one line at the end.@refill + +@node Six Parts, Short Sample, Minimum, Overview +@comment node-name, next, previous, up +@section Six Parts of a Texinfo File + +Generally, a Texinfo file contains more than the minimal +beginning and end---it usually contains six parts:@refill + +@table @r +@item 1. Header +The @dfn{Header} names the file, tells @TeX{} which definitions' file to +use, and performs other ``housekeeping'' tasks.@refill + +@item 2. Summary Description and Copyright +The @dfn{Summary Description and Copyright} segment describes the document +and contains the copyright notice and copying permissions for the Info +file. The segment must be enclosed between @code{@@ifinfo} and +@code{@@end ifinfo} commands so that the formatters place it only in the Info +file.@refill + +@item 3. Title and Copyright +The @dfn{Title and Copyright} segment contains the title and copyright pages +and copying permissions for the printed manual. The segment must be +enclosed between @code{@@titlepage} and @code{@@end titlepage} commands. +The title and copyright page appear only in the printed @w{manual}.@refill + +@item 4. `Top' Node and Master Menu +The @dfn{Master Menu} contains a complete menu of all the nodes in the whole +Info file. It appears only in the Info file, in the `Top' node.@refill + +@item 5. Body +The @dfn{Body} of the document may be structured like a traditional book or +encyclopedia or it may be free form.@refill + +@item 6. End +The @dfn{End} contains commands for printing indices and generating +the table of contents, and the @code{@@bye} command on a line of its +own.@refill +@end table + +@node Short Sample, Acknowledgements, Six Parts, Overview +@comment node-name, next, previous, up +@section A Short Sample Texinfo File +@cindex Sample Texinfo file + +Here is a complete but very short Texinfo file, in 6 parts. The first +three parts of the file, from @samp{\input texinfo} through to +@samp{@@end titlepage}, look more intimidating than they are. Most of +the material is standard boilerplate; when you write a manual, simply +insert the names for your own manual in this segment. (@xref{Beginning a +File}.)@refill + +@noindent +In the following, the sample text is @emph{indented}; comments on it are +not. The complete file, without any comments, is shown in +@ref{Sample Texinfo File}. + +@subheading Part 1: Header + +@noindent +The header does not appear in either the Info file or the@* +printed output. It sets various parameters, including the@* +name of the Info file and the title used in the header. + +@example +@group +\input texinfo @@c -*-texinfo-*- +@@c %**start of header +@@setfilename sample.info +@@settitle Sample Document +@@c %**end of header + +@@setchapternewpage odd +@end group +@end example + +@subheading Part 2: Summary Description and Copyright + +@noindent +The summary description and copyright segment does not@* +appear in the printed document. + +@example +@group +@@ifinfo +This is a short example of a complete Texinfo file. + +Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. +@@end ifinfo +@end group +@end example + +@subheading Part 3: Titlepage and Copyright + +@noindent +The titlepage segment does not appear in the Info file. + +@example +@group +@@titlepage +@@sp 10 +@@comment The title is printed in a large font. +@@center @@titlefont@{Sample Title@} +@end group + +@group +@@c The following two commands start the copyright page. +@@page +@@vskip 0pt plus 1filll +Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. +@@end titlepage +@end group +@end example + +@subheading Part 4: `Top' Node and Master Menu + +@noindent +The `Top' node contains the master menu for the Info file.@* +Since a printed manual uses a table of contents rather than@* +a menu, the master menu appears only in the Info file. + +@example +@group +@@node Top, First Chapter, (dir), (dir) +@@comment node-name, next, previous, up +@end group +@end example + +@example +@group +@@menu +* First Chapter:: The first chapter is the + only chapter in this sample. +* Concept Index:: This index has two entries. +@@end menu +@end group +@end example + +@subheading Part 5: The Body of the Document + +@noindent +The body segment contains all the text of the document, but not the +indices or table of contents. This example illustrates a node and a +chapter containing an enumerated list.@refill + +@example +@group +@@node First Chapter, Concept Index, Top, Top +@@comment node-name, next, previous, up +@@chapter First Chapter +@@cindex Sample index entry +@end group + +@group +This is the contents of the first chapter. +@@cindex Another sample index entry +@end group + +@group +Here is a numbered list. + +@@enumerate +@@item +This is the first item. + +@@item +This is the second item. +@@end enumerate +@end group + +@group +The @@code@{makeinfo@} and @@code@{texinfo-format-buffer@} +commands transform a Texinfo file such as this into +an Info file; and @@TeX@{@} typesets it for a printed +manual. +@end group +@end example + +@subheading Part 6: The End of the Document + +@noindent +The end segment contains commands both for generating an index in a node +and unnumbered chapter of its own and for generating the table of +contents; and it contains the @code{@@bye} command that marks the end of +the document.@refill + +@example +@group +@@node Concept Index, , First Chapter, Top +@@comment node-name, next, previous, up +@@unnumbered Concept Index +@end group + +@group +@@printindex cp + +@@contents +@@bye +@end group +@end example + +@subheading The Results + +Here is what the contents of the first chapter of the sample look like: + +@sp 1 +@need 700 +@quotation +This is the contents of the first chapter. + +Here is a numbered list. + +@enumerate +@item +This is the first item. + +@item +This is the second item. +@end enumerate + +The @code{makeinfo} and @code{texinfo-format-buffer} +commands transform a Texinfo file such as this into +an Info file; and @TeX{} typesets it for a printed +manual. +@end quotation + +@node Acknowledgements, , Short Sample, Overview +@comment node-name, next, previous, up +@section Acknowledgements + +@cindex Stallman, Richard M. +@cindex Chassell, Robert J. +@cindex Berry, Karl +Richard M.@: Stallman wrote Edition 1.0 of this manual. @w{Robert J.@: +Chassell} revised and extended it, starting with Edition 1.1. Karl +Berry made updates for the Texinfo 3.8 and subsequent releases, starting +with Edition 2.22. + +@cindex Pinard, Fran@,{c}ois +@cindex Zuhn, David D. +@cindex Weisshaus, Melissa +Our thanks go out to all who helped improve this work, particularly to +Fran@,{c}ois Pinard and @w{David D.@: Zuhn}, who tirelessly recorded and +reported mistakes and obscurities; our special thanks go to Melissa +Weisshaus for her frequent and often tedious reviews of nearly similar +editions. Our mistakes are our own. + +Please send suggestions and corrections to: + +@example +@group +@r{Internet address:} + bug-texinfo@@prep.ai.mit.edu +@end group +@end example + +@noindent +Please include the manual's edition number and update date in your messages. + +@node Texinfo Mode, Beginning a File, Overview, Top +@comment node-name, next, previous, up +@chapter Using Texinfo Mode +@cindex Texinfo mode +@cindex Mode, using Texinfo +@cindex GNU Emacs +@cindex Emacs + +You may edit a Texinfo file with any text editor you choose. A Texinfo +file is no different from any other @sc{ascii} file. However, GNU Emacs +comes with a special mode, called Texinfo +mode, that provides Emacs commands and tools to help ease your work.@refill + +This chapter describes features of GNU Emacs' Texinfo mode but not any +features of the Texinfo formatting language. If you are reading this +manual straight through from the beginning, you may want to skim through +this chapter briefly and come back to it after reading succeeding +chapters which describe the Texinfo formatting language in +detail.@refill + +@menu +* Texinfo Mode Overview:: How Texinfo mode can help you. +* Emacs Editing:: Texinfo mode adds to GNU Emacs' general + purpose editing features. +* Inserting:: How to insert frequently used @@-commands. +* Showing the Structure:: How to show the structure of a file. +* Updating Nodes and Menus:: How to update or create new nodes and menus. +* Info Formatting:: How to format for Info. +* Printing:: How to format and print part or all of a file. +* Texinfo Mode Summary:: Summary of all the Texinfo mode commands. +@end menu + +@node Texinfo Mode Overview, Emacs Editing, Texinfo Mode, Texinfo Mode +@ifinfo +@heading Texinfo Mode Overview +@end ifinfo + +Texinfo mode provides special features for working with Texinfo +files:@refill + +@itemize @bullet +@item +Insert frequently used @@-commands. @refill + +@item +Automatically create @code{@@node} lines. + +@item +Show the structure of a Texinfo source file.@refill + +@item +Automatically create or update the `Next',@* +`Previous', and `Up' pointers of a node. + +@item +Automatically create or update menus.@refill + +@item +Automatically create a master menu.@refill + +@item +Format a part or all of a file for Info.@refill + +@item +Typeset and print part or all of a file.@refill +@end itemize + +Perhaps the two most helpful features are those for inserting frequently +used @@-commands and for creating node pointers and menus.@refill + +@node Emacs Editing, Inserting, Texinfo Mode Overview, Texinfo Mode +@section The Usual GNU Emacs Editing Commands + +In most cases, the usual Text mode commands work the same in Texinfo +mode as they do in Text mode. Texinfo mode adds new editing commands +and tools to GNU Emacs' general purpose editing features. The major +difference concerns filling. In Texinfo mode, the paragraph +separation variable and syntax table are redefined so that Texinfo +commands that should be on lines of their own are not inadvertently +included in paragraphs. Thus, the @kbd{M-q} (@code{fill-paragraph}) +command will refill a paragraph but not mix an indexing command on a +line adjacent to it into the paragraph.@refill + +In addition, Texinfo mode sets the @code{page-delimiter} variable to +the value of @code{texinfo-chapter-level-regexp}; by default, this is +a regular expression matching the commands for chapters and their +equivalents, such as appendices. With this value for the page +delimiter, you can jump from chapter title to chapter title with the +@kbd{C-x ]} (@code{forward-page}) and @kbd{C-x [} +(@code{backward-page}) commands and narrow to a chapter with the +@kbd{C-x p} (@code{narrow-to-page}) command. (@xref{Pages, , ,emacs, +The GNU Emacs Manual}, for details about the page commands.)@refill + +You may name a Texinfo file however you wish, but the convention is to +end a Texinfo file name with one of the three extensions +@file{.texinfo}, @file{.texi}, or @file{.tex}. A longer extension is +preferred, since it is explicit, but a shorter extension may be +necessary for operating systems that limit the length of file names. +GNU Emacs automatically enters Texinfo mode when you visit a file with +a @file{.texinfo} or @file{.texi} +extension. Also, Emacs switches to Texinfo mode +when you visit a +file that has @samp{-*-texinfo-*-} in its first line. If ever you are +in another mode and wish to switch to Texinfo mode, type @code{M-x +texinfo-mode}.@refill + +Like all other Emacs features, you can customize or enhance Texinfo +mode as you wish. In particular, the keybindings are very easy to +change. The keybindings described here are the default or standard +ones.@refill + +@node Inserting, Showing the Structure, Emacs Editing, Texinfo Mode +@comment node-name, next, previous, up +@section Inserting Frequently Used Commands +@cindex Inserting frequently used commands +@cindex Frequently used commands, inserting +@cindex Commands, inserting them + +Texinfo mode provides commands to insert various frequently used +@@-commands into the buffer. You can use these commands to save +keystrokes.@refill + +The insert commands are invoked by typing @kbd{C-c} twice and then the +first letter of the @@-command:@refill + +@table @kbd +@item C-c C-c c +@itemx M-x texinfo-insert-@@code +@findex texinfo-insert-@@code +Insert @code{@@code@{@}} and put the +cursor between the braces.@refill + +@item C-c C-c d +@itemx M-x texinfo-insert-@@dfn +@findex texinfo-insert-@@dfn +Insert @code{@@dfn@{@}} and put the +cursor between the braces.@refill + +@item C-c C-c e +@itemx M-x texinfo-insert-@@end +@findex texinfo-insert-@@end +Insert @code{@@end} and attempt to insert the correct following word, +such as @samp{example} or @samp{table}. (This command does not handle +nested lists correctly, but inserts the word appropriate to the +immediately preceding list.)@refill + +@item C-c C-c i +@itemx M-x texinfo-insert-@@item +@findex texinfo-insert-@@item +Insert @code{@@item} and put the +cursor at the beginning of the next line.@refill + +@item C-c C-c k +@itemx M-x texinfo-insert-@@kbd +@findex texinfo-insert-@@kbd +Insert @code{@@kbd@{@}} and put the +cursor between the braces.@refill + +@item C-c C-c n +@itemx M-x texinfo-insert-@@node +@findex texinfo-insert-@@node +Insert @code{@@node} and a comment line +listing the sequence for the `Next', +`Previous', and `Up' nodes. +Leave point after the @code{@@node}.@refill + +@item C-c C-c o +@itemx M-x texinfo-insert-@@noindent +@findex texinfo-insert-@@noindent +Insert @code{@@noindent} and put the +cursor at the beginning of the next line.@refill + +@item C-c C-c s +@itemx M-x texinfo-insert-@@samp +@findex texinfo-insert-@@samp +Insert @code{@@samp@{@}} and put the +cursor between the braces.@refill + +@item C-c C-c t +@itemx M-x texinfo-insert-@@table +@findex texinfo-insert-@@table +Insert @code{@@table} followed by a @key{SPC} +and leave the cursor after the @key{SPC}.@refill + +@item C-c C-c v +@itemx M-x texinfo-insert-@@var +@findex texinfo-insert-@@var +Insert @code{@@var@{@}} and put the +cursor between the braces.@refill + +@item C-c C-c x +@itemx M-x texinfo-insert-@@example +@findex texinfo-insert-@@example +Insert @code{@@example} and put the +cursor at the beginning of the next line.@refill + +@c M-@{ was the binding for texinfo-insert-braces; +@c in Emacs 19, backward-paragraph will take this binding. +@item C-c C-c @{ +@itemx M-x texinfo-insert-braces +@findex texinfo-insert-braces +Insert @code{@{@}} and put the cursor between the braces.@refill + +@item C-c C-c @} +@itemx C-c C-c ] +@itemx M-x up-list +@findex up-list +Move from between a pair of braces forward past the closing brace. +Typing @kbd{C-c C-c ]} is easier than typing @kbd{C-c C-c @}}, which +is, however, more mnemonic; hence the two keybindings. (Also, you can +move out from between braces by typing @kbd{C-f}.)@refill +@end table + +To put a command such as @w{@code{@@code@{@dots{}@}}} around an +@emph{existing} word, position the cursor in front of the word and type +@kbd{C-u 1 C-c C-c c}. This makes it easy to edit existing plain text. +The value of the prefix argument tells Emacs how many words following +point to include between braces---1 for one word, 2 for two words, and +so on. Use a negative argument to enclose the previous word or words. +If you do not specify a prefix argument, Emacs inserts the @@-command +string and positions the cursor between the braces. This feature works +only for those @@-commands that operate on a word or words within one +line, such as @code{@@kbd} and @code{@@var}.@refill + +This set of insert commands was created after analyzing the frequency +with which different @@-commands are used in the @cite{GNU Emacs +Manual} and the @cite{GDB Manual}. If you wish to add your own insert +commands, you can bind a keyboard macro to a key, use abbreviations, +or extend the code in @file{texinfo.el}.@refill + +@findex texinfo-start-menu-description +@cindex Menu description, start +@cindex Description for menu, start +@kbd{C-c C-c C-d} (@code{texinfo-start-menu-description}) is an insert +command that works differently from the other insert commands. It +inserts a node's section or chapter title in the space for the +description in a menu entry line. (A menu entry has three parts, the +entry name, the node name, and the description. Only the node name is +required, but a description helps explain what the node is about. +@xref{Menu Parts, , The Parts of a Menu}.)@refill + +To use @code{texinfo-start-menu-description}, position point in a menu +entry line and type @kbd{C-c C-c C-d}. The command looks for and copies +the title that goes with the node name, and inserts the title as a +description; it positions point at beginning of the inserted text so you +can edit it. The function does not insert the title if the menu entry +line already contains a description.@refill + +This command is only an aid to writing descriptions; it does not do the +whole job. You must edit the inserted text since a title tends to use +the same words as a node name but a useful description uses different +words.@refill + +@node Showing the Structure, Updating Nodes and Menus, Inserting, Texinfo Mode +@comment node-name, next, previous, up +@section Showing the Section Structure of a File +@cindex Showing the section structure of a file +@cindex Section structure of a file, showing it +@cindex Structure of a file, showing it +@cindex Outline of file structure, showing it +@cindex Contents-like outline of file structure +@cindex File section structure, showing it +@cindex Texinfo file section structure, showing it + +You can show the section structure of a Texinfo file by using the +@kbd{C-c C-s} command (@code{texinfo-show-structure}). This command +shows the section structure of a Texinfo file by listing the lines +that begin with the @@-commands for @code{@@chapter}, +@code{@@section}, and the like. It constructs what amounts +to a table of contents. These lines are displayed in another buffer +called the @samp{*Occur*} buffer. In that buffer, you can position +the cursor over one of the lines and use the @kbd{C-c C-c} command +(@code{occur-mode-goto-occurrence}), to jump to the corresponding spot +in the Texinfo file.@refill + +@table @kbd +@item C-c C-s +@itemx M-x texinfo-show-structure +@findex texinfo-show-structure +Show the @code{@@chapter}, @code{@@section}, and such lines of a +Texinfo file.@refill + +@item C-c C-c +@itemx M-x occur-mode-goto-occurrence +@findex occur-mode-goto-occurrence +Go to the line in the Texinfo file corresponding to the line under the +cursor in the @file{*Occur*} buffer.@refill +@end table + +If you call @code{texinfo-show-structure} with a prefix argument by +typing @w{@kbd{C-u C-c C-s}}, it will list not only those lines with the +@@-commands for @code{@@chapter}, @code{@@section}, and the like, +but also the @code{@@node} lines. (This is how the +@code{texinfo-show-structure} command worked without an argument in +the first version of Texinfo. It was changed because @code{@@node} +lines clutter up the @samp{*Occur*} buffer and are usually not +needed.) You can use @code{texinfo-show-structure} with a prefix +argument to check whether the `Next', `Previous', and `Up' pointers of +an @code{@@node} line are correct.@refill + +Often, when you are working on a manual, you will be interested only +in the structure of the current chapter. In this case, you can mark +off the region of the buffer that you are interested in by using the +@kbd{C-x n n} (@code{narrow-to-region}) command and +@code{texinfo-show-structure} will work on only that region. To see +the whole buffer again, use @w{@kbd{C-x n w}} (@code{widen}). +(@xref{Narrowing, , , emacs, The GNU Emacs Manual}, for more +information about the narrowing commands.)@refill + +@vindex page-delimiter +@cindex Page delimiter in Texinfo mode +In addition to providing the @code{texinfo-show-structure} command, +Texinfo mode sets the value of the page delimiter variable to match +the chapter-level @@-commands. This enables you to use the @kbd{C-x +]} (@code{forward-page}) and @kbd{C-x [} (@code{backward-page}) +commands to move forward and backward by chapter, and to use the +@kbd{C-x p} (@code{narrow-to-page}) command to narrow to a chapter. +@xref{Pages, , , emacs, The GNU Emacs Manual}, for more information +about the page commands.@refill + +@node Updating Nodes and Menus, Info Formatting, Showing the Structure, Texinfo Mode +@comment node-name, next, previous, up +@section Updating Nodes and Menus +@cindex Updating nodes and menus +@cindex Create nodes, menus automatically +@cindex Insert nodes, menus automatically +@cindex Automatically insert nodes, menus + +Texinfo mode provides commands for automatically creating or updating +menus and node pointers. The commands are called ``update'' commands +because their most frequent use is for updating a Texinfo file after +you have worked on it; but you can use them to insert the `Next', +`Previous', and `Up' pointers into an @code{@@node} line that has none and to +create menus in a file that has none.@refill + +If you do not use the updating commands, you need to write menus and +node pointers by hand, which is a tedious task.@refill + +@menu +* Updating Commands:: Five major updating commands. +* Updating Requirements:: How to structure a Texinfo file for + using the updating command. +* Other Updating Commands:: How to indent descriptions, insert + missing nodes lines, and update + nodes in sequence. +@end menu + +@node Updating Commands, Updating Requirements, Updating Nodes and Menus, Updating Nodes and Menus +@ifinfo +@subheading The Updating Commands +@end ifinfo + +You can use the updating commands@refill + +@itemize @bullet +@item +to insert or update the `Next', `Previous', and `Up' pointers of a +node,@refill + +@item +to insert or update the menu for a section, and@refill + +@item +to create a master menu for a Texinfo source file.@refill +@end itemize + +You can also use the commands to update all the nodes and menus in a +region or in a whole Texinfo file.@refill + +The updating commands work only with conventional Texinfo files, which +are structured hierarchically like books. In such files, a structuring +command line must follow closely after each @code{@@node} line, except +for the `Top' @code{@@node} line. (A @dfn{structuring command line} is +a line beginning with @code{@@chapter}, @code{@@section}, or other +similar command.) + +You can write the structuring command line on the line that follows +immediately after an @code{@@node} line or else on the line that +follows after a single @code{@@comment} line or a single +@code{@@ifinfo} line. You cannot interpose more than one line between +the @code{@@node} line and the structuring command line; and you may +interpose only an @code{@@comment} line or an @code{@@ifinfo} line. + +Commands which work on a whole buffer require that the `Top' node be +followed by a node with an @code{@@chapter} or equivalent-level command. +Note that the menu updating commands will not create a main or master +menu for a Texinfo file that has only @code{@@chapter}-level nodes! The +menu updating commands only create menus @emph{within} nodes for lower level +nodes. To create a menu of chapters, you must provide a `Top' +node.@refill + +The menu updating commands remove menu entries that refer to other Info +files since they do not refer to nodes within the current buffer. This +is a deficiency. Rather than use menu entries, you can use cross +references to refer to other Info files. None of the updating commands +affect cross references.@refill + +Texinfo mode has five updating commands that are used most often: two +are for updating the node pointers or menu of a single node (or a +region); two are for updating every node pointer and menu in a file; +and one, the @code{texinfo-master-menu} command, is for creating a +master menu for a complete file, and optionally, for updating every +node and menu in the whole Texinfo file.@refill + +The @code{texinfo-master-menu} command is the primary command:@refill + +@table @kbd +@item C-c C-u m +@itemx M-x texinfo-master-menu +@findex texinfo-master-menu +Create or update a master menu that includes all the other menus +(incorporating the descriptions from pre-existing menus, if +any).@refill + +With an argument (prefix argument, @kbd{C-u,} if interactive), first create or +update all the nodes and all the regular menus in the buffer before +constructing the master menu. (@xref{The Top Node, , The Top Node and +Master Menu}, for more about a master menu.)@refill + +For @code{texinfo-master-menu} to work, the Texinfo file must have a +`Top' node and at least one subsequent node.@refill + +After extensively editing a Texinfo file, you can type the following: + +@example +C-u M-x texinfo-master-menu +@exdent or +C-u C-c C-u m +@end example + +@noindent +This updates all the nodes and menus completely and all at once.@refill +@end table + +The other major updating commands do smaller jobs and are designed for +the person who updates nodes and menus as he or she writes a Texinfo +file.@refill + +@need 1000 +The commands are:@refill + +@table @kbd +@item C-c C-u C-n +@itemx M-x texinfo-update-node +@findex texinfo-update-node +Insert the `Next', `Previous', and `Up' pointers for the node that point is +within (i.e., for the @code{@@node} line preceding point). If the +@code{@@node} line has pre-existing `Next', `Previous', or `Up' +pointers in it, the old pointers are removed and new ones inserted. +With an argument (prefix argument, @kbd{C-u}, if interactive), this command +updates all @code{@@node} lines in the region (which is the text +between point and mark).@refill + +@item C-c C-u C-m +@itemx M-x texinfo-make-menu +@findex texinfo-make-menu +Create or update the menu in the node that point is within. +With an argument (@kbd{C-u} as prefix argument, if +interactive), the command makes or updates menus for the +nodes which are either within or a part of the +region.@refill + +Whenever @code{texinfo-make-menu} updates an existing menu, the +descriptions from that menu are incorporated into the new menu. This +is done by copying descriptions from the existing menu to the entries +in the new menu that have the same node names. If the node names are +different, the descriptions are not copied to the new menu.@refill + +@item C-c C-u C-e +@itemx M-x texinfo-every-node-update +@findex texinfo-every-node-update +Insert or update the `Next', `Previous', and `Up' pointers for every +node in the buffer.@refill + +@item C-c C-u C-a +@itemx M-x texinfo-all-menus-update +@findex texinfo-all-menus-update +Create or update all the menus in the buffer. With an argument +(@kbd{C-u} as prefix argument, if interactive), first insert +or update all the node +pointers before working on the menus.@refill + +If a master menu exists, the @code{texinfo-all-menus-update} command +updates it; but the command does not create a new master menu if none +already exists. (Use the @code{texinfo-master-menu} command for +that.)@refill + +When working on a document that does not merit a master menu, you can +type the following: + +@example +C-u C-c C-u C-a +@exdent or +C-u M-x texinfo-all-menus-update +@end example + +@noindent +This updates all the nodes and menus.@refill +@end table + +The @code{texinfo-column-for-description} variable specifies the +column to which menu descriptions are indented. By default, the value +is 32 although it is often useful to reduce it to as low as 24. You +can set the variable with the @kbd{M-x edit-options} command +(@pxref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs +Manual}) or with the @kbd{M-x set-variable} command (@pxref{Examining, +, Examining and Setting Variables, emacs, The GNU Emacs +Manual}).@refill + +Also, the @code{texinfo-indent-menu-description} command may be used to +indent existing menu descriptions to a specified column. Finally, if +you wish, you can use the @code{texinfo-insert-node-lines} command to +insert missing @code{@@node} lines into a file. (@xref{Other Updating +Commands}, for more information.)@refill + +@node Updating Requirements, Other Updating Commands, Updating Commands, Updating Nodes and Menus +@comment node-name, next, previous, up +@subsection Updating Requirements +@cindex Updating requirements +@cindex Requirements for updating commands + +To use the updating commands, you must organize the Texinfo file +hierarchically with chapters, sections, subsections, and the like. +When you construct the hierarchy of the manual, do not `jump down' +more than one level at a time: you can follow the `Top' node with a +chapter, but not with a section; you can follow a chapter with a +section, but not with a subsection. However, you may `jump up' any +number of levels at one time---for example, from a subsection to a +chapter.@refill + +Each @code{@@node} line, with the exception of the line for the `Top' +node, must be followed by a line with a structuring command such as +@code{@@chapter}, @code{@@section}, or +@code{@@unnumberedsubsec}.@refill + +Each @code{@@node} line/structuring-command line combination +must look either like this:@refill + +@example +@group +@@node Comments, Minimum, Conventions, Overview +@@comment node-name, next, previous, up +@@section Comments +@end group +@end example + +or like this (without the @code{@@comment} line): + +@example +@group +@@node Comments, Minimum, Conventions, Overview +@@section Comments +@end group +@end example + +@noindent +In this example, `Comments' is the name of both the node and the +section. The next node is called `Minimum' and the previous node is +called `Conventions'. The `Comments' section is within the `Overview' +node, which is specified by the `Up' pointer. (Instead of an +@code{@@comment} line, you can write an @code{@@ifinfo} line.)@refill + +If a file has a `Top' node, it must be called @samp{top} or @samp{Top} +and be the first node in the file.@refill + +The menu updating commands create a menu of sections within a chapter, +a menu of subsections within a section, and so on. This means that +you must have a `Top' node if you want a menu of chapters.@refill + +Incidentally, the @code{makeinfo} command will create an Info file for +a hierarchically organized Texinfo file that lacks `Next', `Previous' +and `Up' pointers. Thus, if you can be sure that your Texinfo file +will be formatted with @code{makeinfo}, you have no need for the +`update node' commands. (@xref{Create an Info File, , Creating an +Info File}, for more information about @code{makeinfo}.) However, +both @code{makeinfo} and the @code{texinfo-format-@dots{}} commands +require that you insert menus in the file.@refill + +@node Other Updating Commands, , Updating Requirements, Updating Nodes and Menus +@comment node-name, next, previous, up +@subsection Other Updating Commands + +In addition to the five major updating commands, Texinfo mode +possesses several less frequently used updating commands:@refill + +@table @kbd +@item M-x texinfo-insert-node-lines +@findex texinfo-insert-node-lines +Insert @code{@@node} lines before the @code{@@chapter}, +@code{@@section}, and other sectioning commands wherever they are +missing throughout a region in a Texinfo file.@refill + +With an argument (@kbd{C-u} as prefix argument, if interactive), the +@code{texinfo-insert-node-lines} command not only inserts +@code{@@node} lines but also inserts the chapter or section titles as +the names of the corresponding nodes. In addition, it inserts the +titles as node names in pre-existing @code{@@node} lines that lack +names. Since node names should be more concise than section or +chapter titles, you must manually edit node names so inserted.@refill + +For example, the following marks a whole buffer as a region and inserts +@code{@@node} lines and titles throughout:@refill + +@example +C-x h C-u M-x texinfo-insert-node-lines +@end example + +(Note that this command inserts titles as node names in @code{@@node} +lines; the @code{texinfo-start-menu-description} command +(@pxref{Inserting, Inserting Frequently Used Commands}) inserts titles +as descriptions in menu entries, a different action. However, in both +cases, you need to edit the inserted text.)@refill + +@item M-x texinfo-multiple-files-update +@findex texinfo-multiple-files-update @r{(in brief)} +Update nodes and menus in a document built from several separate files. +With @kbd{C-u} as a prefix argument, create and insert a master menu in +the outer file. With a numeric prefix argument, such as @kbd{C-u 2}, first +update all the menus and all the `Next', `Previous', and `Up' pointers +of all the included files before creating and inserting a master menu in +the outer file. The @code{texinfo-multiple-files-update} command is +described in the appendix on @code{@@include} files. +@ifinfo +@xref{texinfo-multiple-files-update}.@refill +@end ifinfo +@iftex +@xref{texinfo-multiple-files-update, , +@code{texinfo-multiple-files-update}}.@refill +@end iftex + +@item M-x texinfo-indent-menu-description +@findex texinfo-indent-menu-description +Indent every description in the menu following point to the specified +column. You can use this command to give yourself more space for +descriptions. With an argument (@kbd{C-u} as prefix argument, if +interactive), the @code{texinfo-indent-menu-description} command indents +every description in every menu in the region. However, this command +does not indent the second and subsequent lines of a multi-line +description.@refill + +@item M-x texinfo-sequential-node-update +@findex texinfo-sequential-node-update +Insert the names of the nodes immediately following and preceding the +current node as the `Next' or `Previous' pointers regardless of those +nodes' hierarchical level. This means that the `Next' node of a +subsection may well be the next chapter. Sequentially ordered nodes are +useful for novels and other documents that you read through +sequentially. (However, in Info, the @code{g* @key{RET}} command lets +you look through the file sequentially, so sequentially ordered nodes +are not strictly necessary.) With an argument (prefix argument, if +interactive), the @code{texinfo-sequential-node-update} command +sequentially updates all the nodes in the region.@refill +@end table + +@node Info Formatting, Printing, Updating Nodes and Menus, Texinfo Mode +@comment node-name, next, previous, up +@section Formatting for Info +@cindex Formatting for Info +@cindex Running an Info formatter +@cindex Info formatting + +Texinfo mode provides several commands for formatting part or all of a +Texinfo file for Info. Often, when you are writing a document, you +want to format only part of a file---that is, a region.@refill + +You can use either the @code{texinfo-format-region} or the +@code{makeinfo-region} command to format a region:@refill + +@table @kbd +@findex texinfo-format-region +@item C-c C-e C-r +@itemx M-x texinfo-format-region +@itemx C-c C-m C-r +@itemx M-x makeinfo-region +Format the current region for Info.@refill +@end table + +You can use either the @code{texinfo-format-buffer} or the +@code{makeinfo-buffer} command to format a whole buffer:@refill + +@table @kbd +@findex texinfo-format-buffer +@item C-c C-e C-b +@itemx M-x texinfo-format-buffer +@itemx C-c C-m C-b +@itemx M-x makeinfo-buffer +Format the current buffer for Info.@refill +@end table + +@need 1000 +For example, after writing a Texinfo file, you can type the following: + +@example +C-u C-c C-u m +@exdent or +C-u M-x texinfo-master-menu +@end example + +@noindent +This updates all the nodes and menus. Then type the following to create +an Info file: + +@example +C-c C-m C-b +@exdent or +M-x makeinfo-buffer +@end example + +For @TeX{} or the Info formatting commands to work, the file @emph{must} +include a line that has @code{@@setfilename} in its header.@refill + +@xref{Create an Info File}, for details about Info formatting.@refill + +@node Printing, Texinfo Mode Summary, Info Formatting, Texinfo Mode +@comment node-name, next, previous, up +@section Formatting and Printing +@cindex Formatting for printing +@cindex Printing a region or buffer +@cindex Region formatting and printing +@cindex Buffer formatting and printing +@cindex Part of file formatting and printing + +Typesetting and printing a Texinfo file is a multi-step process in which +you first create a file for printing (called a @sc{dvi} file), and then +print the file. Optionally, you may also create indices. To do this, +you must run the @code{texindex} command after first running the +@code{tex} typesetting command; and then you must run the @code{tex} +command again. Or else run the @code{texi2dvi} command which +automatically creates indices as needed.@refill + +Often, when you are writing a document, you want to typeset and print +only part of a file to see what it will look like. You can use the +@code{texinfo-tex-region} and related commands for this purpose. Use +the @code{texinfo-tex-buffer} command to format all of a +buffer.@refill + +@table @kbd +@item C-c C-t C-b +@itemx M-x texinfo-tex-buffer +@findex texinfo-tex-buffer +Run @code{texi2dvi} on the buffer. In addition to running @TeX{} on the +buffer, this command automatically creates or updates indices as +needed.@refill + +@item C-c C-t C-r +@itemx M-x texinfo-tex-region +@findex texinfo-tex-region +Run @TeX{} on the region.@refill + +@item C-c C-t C-i +@itemx M-x texinfo-texindex +Run @code{texindex} to sort the indices of a Texinfo file formatted with +@code{texinfo-tex-region}. The @code{texinfo-tex-region} command does +not run @code{texindex} automatically; it only runs the @code{tex} +typesetting command. You must run the @code{texinfo-tex-region} command +a second time after sorting the raw index files with the @code{texindex} +command. (Usually, you do not format an index when you format a region, +only when you format a buffer. Now that the @code{texi2dvi} command +exists, there is no little need for this command.)@refill + +@item C-c C-t C-p +@itemx M-x texinfo-tex-print +@findex texinfo-tex-print +Print the file (or the part of the file) previously formatted with +@code{texinfo-tex-buffer} or @code{texinfo-tex-region}.@refill +@end table + +For @code{texinfo-tex-region} or @code{texinfo-tex-buffer} to work, the +file @emph{must} start with a @samp{\input texinfo} line and must +include an @code{@@settitle} line. The file must end with @code{@@bye} +on a line by itself. (When you use @code{texinfo-tex-region}, you must +surround the @code{@@settitle} line with start-of-header and +end-of-header lines.)@refill + +@xref{Format/Print Hardcopy}, for a description of the other @TeX{} related +commands, such as @code{tex-show-print-queue}.@refill + +@node Texinfo Mode Summary, , Printing, Texinfo Mode +@comment node-name, next, previous, up +@section Texinfo Mode Summary + +In Texinfo mode, each set of commands has default keybindings that +begin with the same keys. All the commands that are custom-created +for Texinfo mode begin with @kbd{C-c}. The keys are somewhat +mnemonic.@refill + +@subheading Insert Commands + +The insert commands are invoked by typing @kbd{C-c} twice and then the +first letter of the @@-command to be inserted. (It might make more +sense mnemonically to use @kbd{C-c C-i}, for `custom insert', but +@kbd{C-c C-c} is quick to type.)@refill + +@example +C-c C-c c @r{Insert} @samp{@@code}. +C-c C-c d @r{Insert} @samp{@@dfn}. +C-c C-c e @r{Insert} @samp{@@end}. +C-c C-c i @r{Insert} @samp{@@item}. +C-c C-c n @r{Insert} @samp{@@node}. +C-c C-c s @r{Insert} @samp{@@samp}. +C-c C-c v @r{Insert} @samp{@@var}. +C-c C-c @{ @r{Insert braces.} +C-c C-c ] +C-c C-c @} @r{Move out of enclosing braces.} + +@group +C-c C-c C-d @r{Insert a node's section title} + @r{in the space for the description} + @r{in a menu entry line.} +@end group +@end example + +@subheading Show Structure + +The @code{texinfo-show-structure} command is often used within a +narrowed region.@refill + +@example +C-c C-s @r{List all the headings.} +@end example + +@subheading The Master Update Command + +The @code{texinfo-master-menu} command creates a master menu; and can +be used to update every node and menu in a file as well.@refill + +@example +@group +C-c C-u m +M-x texinfo-master-menu + @r{Create or update a master menu.} +@end group + +@group +C-u C-c C-u m @r{With @kbd{C-u} as a prefix argument, first} + @r{create or update all nodes and regular} + @r{menus, and then create a master menu.} +@end group +@end example + +@subheading Update Pointers + +The update pointer commands are invoked by typing @kbd{C-c C-u} and +then either @kbd{C-n} for @code{texinfo-update-node} or @kbd{C-e} for +@code{texinfo-every-node-update}.@refill + +@example +C-c C-u C-n @r{Update a node.} +C-c C-u C-e @r{Update every node in the buffer.} +@end example + +@subheading Update Menus + +Invoke the update menu commands by typing @kbd{C-c C-u} +and then either @kbd{C-m} for @code{texinfo-make-menu} or +@kbd{C-a} for @code{texinfo-all-menus-update}. To update +both nodes and menus at the same time, precede @kbd{C-c C-u +C-a} with @kbd{C-u}.@refill + +@example +C-c C-u C-m @r{Make or update a menu.} + +@group +C-c C-u C-a @r{Make or update all} + @r{menus in a buffer.} +@end group + +@group +C-u C-c C-u C-a @r{With @kbd{C-u} as a prefix argument,} + @r{first create or update all nodes and} + @r{then create or update all menus.} +@end group +@end example + +@subheading Format for Info + +The Info formatting commands that are written in Emacs Lisp are +invoked by typing @kbd{C-c C-e} and then either @kbd{C-r} for a region +or @kbd{C-b} for the whole buffer.@refill + +The Info formatting commands that are written in C and based on the +@code{makeinfo} program are invoked by typing @kbd{C-c C-m} and then +either @kbd{C-r} for a region or @kbd{C-b} for the whole buffer.@refill + +@need 800 +@noindent +Use the @code{texinfo-format@dots{}} commands: + +@example +@group +C-c C-e C-r @r{Format the region.} +C-c C-e C-b @r{Format the buffer.} +@end group +@end example + +@need 750 +@noindent +Use @code{makeinfo}: + +@example +C-c C-m C-r @r{Format the region.} +C-c C-m C-b @r{Format the buffer.} +C-c C-m C-l @r{Recenter the @code{makeinfo} output buffer.} +C-c C-m C-k @r{Kill the @code{makeinfo} formatting job.} +@end example + +@subheading Typeset and Print + +The @TeX{} typesetting and printing commands are invoked by typing +@kbd{C-c C-t} and then another control command: @kbd{C-r} for +@code{texinfo-tex-region}, @kbd{C-b} for @code{texinfo-tex-buffer}, +and so on.@refill + +@example +C-c C-t C-r @r{Run @TeX{} on the region.} +C-c C-t C-b @r{Run} @code{texi2dvi} @r{on the buffer.} +C-c C-t C-i @r{Run} @code{texindex}. +C-c C-t C-p @r{Print the @sc{dvi} file.} +C-c C-t C-q @r{Show the print queue.} +C-c C-t C-d @r{Delete a job from the print queue.} +C-c C-t C-k @r{Kill the current @TeX{} formatting job.} +C-c C-t C-x @r{Quit a currently stopped @TeX{} formatting job.} +C-c C-t C-l @r{Recenter the output buffer.} +@end example + +@subheading Other Updating Commands + +The `other updating commands' do not have standard keybindings because +they are rarely used. + +@example +@group +M-x texinfo-insert-node-lines + @r{Insert missing @code{@@node} lines in region.} + @r{With @kbd{C-u} as a prefix argument,} + @r{use section titles as node names.} +@end group + +@group +M-x texinfo-multiple-files-update + @r{Update a multi-file document.} + @r{With @kbd{C-u 2} as a prefix argument,} + @r{create or update all nodes and menus} + @r{in all included files first.} +@end group + +@group +M-x texinfo-indent-menu-description + @r{Indent descriptions.} +@end group + +@group +M-x texinfo-sequential-node-update + @r{Insert node pointers in strict sequence.} +@end group +@end example + +@node Beginning a File, Ending a File, Texinfo Mode, Top +@comment node-name, next, previous, up +@chapter Beginning a Texinfo File +@cindex Beginning a Texinfo file +@cindex Texinfo file beginning +@cindex File beginning + +Certain pieces of information must be provided at the beginning of a +Texinfo file, such as the name of the file and the title of the +document.@refill + +@menu +* Four Parts:: Four parts begin a Texinfo file. +* Sample Beginning:: Here is a sample beginning for a Texinfo file. +* Header:: The very beginning of a Texinfo file. +* Info Summary and Permissions:: Summary and copying permissions for Info. +* Titlepage & Copyright Page:: Creating the title and copyright pages. +* The Top Node:: Creating the `Top' node and master menu. +* Software Copying Permissions:: Ensure that you and others continue to + have the right to use and share software. +@end menu + +@node Four Parts, Sample Beginning, Beginning a File, Beginning a File +@ifinfo +@heading Four Parts Begin a File +@end ifinfo + +Generally, the beginning of a Texinfo file has four parts:@refill + +@enumerate +@item +The header, delimited by special comment lines, that includes the +commands for naming the Texinfo file and telling @TeX{} what +definitions' file to use when processing the Texinfo file.@refill + +@item +A short statement of what the file is about, with a copyright notice +and copying permissions. This is enclosed in @code{@@ifinfo} and +@code{@@end ifinfo} commands so that the formatters place it only +in the Info file.@refill + +@item +A title page and copyright page, with a copyright notice and copying +permissions. This is enclosed between @code{@@titlepage} and +@code{@@end titlepage} commands. The title and copyright page appear +only in the printed @w{manual}.@refill + +@item +The `Top' node that contains a menu for the whole Info file. The +contents of this node appear only in the Info file.@refill +@end enumerate + +Also, optionally, you may include the copying conditions for a program +and a warranty disclaimer. The copying section will be followed by an +introduction or else by the first chapter of the manual.@refill + +Since the copyright notice and copying permissions for the Texinfo +document (in contrast to the copying permissions for a program) are in +parts that appear only in the Info file or only in the printed manual, +this information must be given twice.@refill + +@node Sample Beginning, Header, Four Parts, Beginning a File +@comment node-name, next, previous, up +@section Sample Texinfo File Beginning + +The following sample shows what is needed.@refill + +@example +\input texinfo @@c -*-texinfo-*- +@@c %**start of header +@@setfilename @var{name-of-info-file} +@@settitle @var{name-of-manual} +@@setchapternewpage odd +@@c %**end of header + +@@ifinfo +This file documents @dots{} + +Copyright @var{year} @var{copyright-owner} + +@group +Permission is granted to @dots{} +@@end ifinfo +@end group + +@group +@@c This title page illustrates only one of the +@@c two methods of forming a title page. +@end group + +@group +@@titlepage +@@title @var{name-of-manual-when-printed} +@@subtitle @var{subtitle-if-any} +@@subtitle @var{second-subtitle} +@@author @var{author} +@end group + +@group +@@c The following two commands +@@c start the copyright page. +@@page +@@vskip 0pt plus 1filll +Copyright @@copyright@{@} @var{year} @var{copyright-owner} +@end group + +Published by @dots{} + +Permission is granted to @dots{} +@@end titlepage + +@@node Top, Overview, (dir), (dir) + +@@ifinfo +This document describes @dots{} + +This document applies to version @dots{} +of the program named @dots{} +@@end ifinfo + +@group +@@menu +* Copying:: Your rights and freedoms. +* First Chapter:: Getting started @dots{} +* Second Chapter:: @dots{} + @dots{} + @dots{} +@@end menu +@end group + +@group +@@node First Chapter, Second Chapter, top, top +@@comment node-name, next, previous, up +@@chapter First Chapter +@@cindex Index entry for First Chapter +@end group +@end example + +@node Header, Info Summary and Permissions, Sample Beginning, Beginning a File +@comment node-name, next, previous, up +@section The Texinfo File Header +@cindex Header for Texinfo files +@cindex Texinfo file header + +Texinfo files start with at least three lines that provide Info and +@TeX{} with necessary information. These are the @code{\input +texinfo} line, the @code{@@settitle} line, and the +@code{@@setfilename} line. If you want to run @TeX{} on just a part +of the Texinfo File, you must write the @code{@@settitle} +and @code{@@setfilename} lines between start-of-header and end-of-header +lines.@refill + +Thus, the beginning of a Texinfo file looks like this: + +@example +@group +\input texinfo @@c -*-texinfo-*- +@@setfilename sample.info +@@settitle Sample Document +@end group +@end example + +@noindent +or else like this: + +@example +@group +\input texinfo @@c -*-texinfo-*- +@@c %**start of header +@@setfilename sample.info +@@settitle Sample Document +@@c %**end of header +@end group +@end example + +@menu +* First Line:: The first line of a Texinfo file. +* Start of Header:: Formatting a region requires this. +* setfilename:: Tell Info the name of the Info file. +* settitle:: Create a title for the printed work. +* setchapternewpage:: Start chapters on right-hand pages. +* paragraphindent:: An option to specify paragraph indentation. +* End of Header:: Formatting a region requires this. +@end menu + +@node First Line, Start of Header, Header, Header +@comment node-name, next, previous, up +@subsection The First Line of a Texinfo File +@cindex First line of a Texinfo file +@cindex Beginning line of a Texinfo file +@cindex Header of a Texinfo file + +Every Texinfo file that is to be the top-level input to @TeX{} must begin +with a line that looks like this:@refill + +@example +\input texinfo @@c -*-texinfo-*- +@end example + +@noindent +This line serves two functions: + +@enumerate +@item +When the file is processed by @TeX{}, the @code{\input texinfo} command +tells @TeX{} to load the macros needed for processing a Texinfo file. +These are in a file called @file{texinfo.tex}, which is usually located +in the @file{/usr/lib/tex/macros} directory. @TeX{} uses the backslash, +@samp{\}, to mark the beginning of a command, just as Texinfo uses +@code{@@}. The @file{texinfo.tex} file causes the switch from @samp{\} +to @samp{@@}; before the switch occurs, @TeX{} requires @samp{\}, which +is why it appears at the beginning of the file.@refill + +@item +When the file is edited in GNU Emacs, the @samp{-*-texinfo-*-} mode +specification tells Emacs to use Texinfo mode.@refill +@end enumerate + +@node Start of Header, setfilename, First Line, Header +@comment node-name, next, previous, up +@subsection Start of Header +@cindex Start of header line + +Write a start-of-header line on the second line of a Texinfo file. +Follow the start-of-header line with @code{@@setfilename} and +@code{@@settitle} lines and, optionally, with other command lines, such +as @code{@@smallbook} or @code{@@footnotestyle}; and then by an +end-of-header line (@pxref{End of Header}).@refill + +With these lines, you can format part of a Texinfo file for Info or +typeset part for printing.@refill + +A start-of-header line looks like this:@refill + +@example +@@c %**start of header +@end example + +The odd string of characters, @samp{%**}, is to ensure that no other +comment is accidentally taken for a start-of-header line.@refill + +@node setfilename, settitle, Start of Header, Header +@comment node-name, next, previous, up +@subsection @code{@@setfilename} +@cindex Info file requires @code{@@setfilename} +@findex setfilename + +In order to serve as the primary input file for either @code{makeinfo} +or @TeX{}, a Texinfo file must contain a line that looks like this: + +@example +@@setfilename @var{info-file-name} +@end example + +Write the @code{@@setfilename} command at the beginning of a line and +follow it on the same line by the Info file name. Do not write +anything else on the line; anything on the line after the command is +considered part of the file name, including a comment.@refill + +The @code{@@setfilename} line specifies the name of the Info file to be +generated. This name should be different from the name of the Texinfo +file. There are two conventions for choosing the name: you can either +remove the @samp{.tex} extension from the input file name, or replace it +with the @samp{.info} extension. + +Some operating systems cannot handle long file names. You can run into +a problem even when the file name you specify is itself short enough. +This occurs because the Info formatters split a long Info file into +short indirect subfiles, and name them by appending `-1', `-2', @dots{}, +`-10', `-11', and so on, to the original file name. (@xref{Tag and +Split Files, , Tag Files and Split Files}.) The subfile name +@file{texinfo.info-10}, for example, is too long for some systems; so +the Info file name for this document is @file{texinfo} rather than +@file{texinfo.info}.@refill + +The Info formatting commands ignore everything written before the +@code{@@setfilename} line, which is why the very first line of +the file (the @code{\input} line) does not need to be commented out. + +The @code{@@setfilename} line produces no output when you typeset a +printed manual, but is does an essential job: it opens the index, +cross-reference, and other auxiliary files used by Texinfo. + +@node settitle, setchapternewpage, setfilename, Header +@comment node-name, next, previous, up +@subsection @code{@@settitle} +@findex settitle + +In order to be made into a printed manual, a Texinfo file must contain +a line that looks like this:@refill + +@example +@@settitle @var{title} +@end example + +Write the @code{@@settitle} command at the beginning of a line and +follow it on the same line by the title. This tells @TeX{} the title +to use in a header or footer. Do not write anything else on the line; +anything on the line after the command is considered part of the +title, including a comment.@refill + +Conventionally, when @TeX{} formats a Texinfo file for double-sided +output, the title is printed in the left-hand (even-numbered) page +headings and the current chapter title is printed in the right-hand +(odd-numbered) page headings. (@TeX{} learns the title of each chapter +from each @code{@@chapter} command.) Page footers are not +printed.@refill + +Even if you are printing in a single-sided style, @TeX{} looks for an +@code{@@settitle} command line, in case you include the manual title +in the heading. @refill + +The @code{@@settitle} command should precede everything that generates +actual output in @TeX{}.@refill + +Although the title in the @code{@@settitle} command is usually the +same as the title on the title page, it does not affect the title as +it appears on the title page. Thus, the two do not need not match +exactly; and the title in the @code{@@settitle} command can be a +shortened or expanded version of the title as it appears on the title +page. (@xref{titlepage, , @code{@@titlepage}}.)@refill + +@TeX{} prints page headings only for that text that comes after the +@code{@@end titlepage} command in the Texinfo file, or that comes +after an @code{@@headings} command that turns on headings. +(@xref{headings on off, , The @code{@@headings} Command}, for more +information.)@refill + +You may, if you wish, create your own, customized headings and +footings. @xref{Headings, , Page Headings}, for a detailed discussion +of this process.@refill + +@node setchapternewpage, paragraphindent, settitle, Header +@comment node-name, next, previous, up +@subsection @code{@@setchapternewpage} +@cindex Starting chapters +@cindex Pages, starting odd +@findex setchapternewpage + +In a book or a manual, text is usually printed on both sides of the +paper, chapters start on right-hand pages, and right-hand pages have +odd numbers. But in short reports, text often is printed only on one +side of the paper. Also in short reports, chapters sometimes do not +start on new pages, but are printed on the same page as the end of the +preceding chapter, after a small amount of vertical whitespace.@refill + +You can use the @code{@@setchapternewpage} command with various +arguments to specify how @TeX{} should start chapters and whether it +should typeset pages for printing on one or both sides of the paper +(single-sided or double-sided printing).@refill + +Write the @code{@@setchapternewpage} command at the beginning of a +line followed by its argument.@refill + +For example, you would write the following to cause each chapter to +start on a fresh odd-numbered page:@refill + +@example +@@setchapternewpage odd +@end example + +You can specify one of three alternatives with the +@code{@@setchapternewpage} command:@refill + +@table @asis +@ignore +@item No @code{@@setchapternewpage} command +If the Texinfo file does not contain an @code{@@setchapternewpage} +command before the @code{@@titlepage} command, @TeX{} automatically +begins chapters on new pages and prints headings in the standard +format for single-sided printing. This is the conventional format for +single-sided printing.@refill + +The result is exactly the same as when you write +@code{@@setchapternewpage on}.@refill +@end ignore +@item @code{@@setchapternewpage off} +Cause @TeX{} to typeset a new chapter on the same page as the last +chapter, after skipping some vertical whitespace. Also, cause @TeX{} to +format page headers for single-sided printing. (You can override the +headers format with the @code{@@headings double} command; see +@ref{headings on off, , The @code{@@headings} Command}.)@refill + +@item @code{@@setchapternewpage on} +Cause @TeX{} to start new chapters on new pages and to typeset page +headers for single-sided printing. This is the form most often +used for short reports.@refill + +This alternative is the default.@refill + +@item @code{@@setchapternewpage odd} +Cause @TeX{} to start new chapters on new, odd-numbered pages +(right-handed pages) and to typeset for double-sided printing. This is +the form most often used for books and manuals.@refill +@end table + +@noindent +Texinfo does not have an @code{@@setchapternewpage even} command.@refill + +@noindent +(You can countermand or modify an @code{@@setchapternewpage} command +with an @code{@@headings} command. @xref{headings on off, , The +@code{@@headings} Command}.)@refill + +At the beginning of a manual or book, pages are not numbered---for +example, the title and copyright pages of a book are not numbered. +By convention, table of contents pages are numbered with roman +numerals and not in sequence with the rest of the document.@refill + +Since an Info file does not have pages, the @code{@@setchapternewpage} +command has no effect on it.@refill + +Usually, you do not write an @code{@@setchapternewpage} command for +single-sided printing, but accept the default which is to typeset for +single-sided printing and to start new chapters on new pages. Usually, +you write an @code{@@setchapternewpage odd} command for double-sided +printing.@refill + +@node paragraphindent, End of Header, setchapternewpage, Header +@comment node-name, next, previous, up +@subsection Paragraph Indenting +@cindex Indenting paragraphs +@cindex Paragraph indentation +@findex paragraphindent + +The Info formatting commands may insert spaces at the beginning of the +first line of each paragraph, thereby indenting that paragraph. You +can use the @code{@@paragraphindent} command to specify the +indentation. Write an @code{@@paragraphindent} command at the +beginning of a line followed by either @samp{asis} or a number. The +template is:@refill + +@example +@@paragraphindent @var{indent} +@end example + +The Info formatting commands indent according to the value of +@var{indent}:@refill + +@itemize @bullet +@item +If the value of @var{indent} is @samp{asis}, the Info formatting +commands do not change the existing indentation.@refill + +@item +If the value of @var{indent} is 0, the Info formatting commands delete +existing indentation.@refill + +@item +If the value of @var{indent} is greater than 0, the Info formatting +commands indent the paragraph by that number of spaces.@refill +@end itemize + +The default value of @var{indent} is @samp{asis}.@refill + +Write the @code{@@paragraphindent} command before or shortly after the +end-of-header line at the beginning of a Texinfo file. (If you write +the command between the start-of-header and end-of-header lines, the +region formatting commands indent paragraphs as specified.)@refill + +A peculiarity of the @code{texinfo-format-buffer} and +@code{texinfo-format-region} commands is that they do not indent (nor +fill) paragraphs that contain @code{@@w} or @code{@@*} commands. +@xref{Refilling Paragraphs}, for a detailed description of what goes +on.@refill + +@node End of Header, , paragraphindent, Header +@comment node-name, next, previous, up +@subsection End of Header +@cindex End of header line + +Follow the header lines with an @w{end-of-header} line. +An end-of-header line looks like this:@refill + +@example +@@c %**end of header +@end example + +If you include the @code{@@setchapternewpage} command between the +start-of-header and end-of-header lines, @TeX{} will typeset a region as +that command specifies. Similarly, if you include an @code{@@smallbook} +command between the start-of-header and end-of-header lines, @TeX{} will +typeset a region in the ``small'' book format.@refill + +@ifinfo +The reason for the odd string of characters (@samp{%**}) is so that the +@code{texinfo-tex-region} command does not accidentally find +something that it should not when it is looking for the header.@refill + +The start-of-header line and the end-of-header line are Texinfo mode +variables that you can change.@refill +@end ifinfo + +@iftex +@xref{Start of Header}. +@end iftex + +@node Info Summary and Permissions, Titlepage & Copyright Page, Header, Beginning a File +@comment node-name, next, previous, up +@section Summary and Copying Permissions for Info + +The title page and the copyright page appear only in the printed copy of +the manual; therefore, the same information must be inserted in a +section that appears only in the Info file. This section usually +contains a brief description of the contents of the Info file, a +copyright notice, and copying permissions.@refill + +The copyright notice should read:@refill + +@example +Copyright @var{year} @var{copyright-owner} +@end example + +@noindent +and be put on a line by itself.@refill + +Standard text for the copyright permissions is contained in an appendix +to this manual; see @ref{ifinfo Permissions, , @samp{ifinfo} Copying +Permissions}, for the complete text.@refill + +The permissions text appears in an Info file @emph{before} the first +node. This mean that a reader does @emph{not} see this text when +reading the file using Info, except when using the advanced Info command +@kbd{g *}. + +@node Titlepage & Copyright Page, The Top Node, Info Summary and Permissions, Beginning a File +@comment node-name, next, previous, up +@section The Title and Copyright Pages + +A manual's name and author are usually printed on a title page. +Sometimes copyright information is printed on the title page as well; +more often, copyright information is printed on the back of the title +page. + +The title and copyright pages appear in the printed manual, but not in the +Info file. Because of this, it is possible to use several slightly +obscure @TeX{} typesetting commands that cannot be used in an Info file. +In addition, this part of the beginning of a Texinfo file contains the text +of the copying permissions that will appear in the printed manual.@refill + +@xref{Titlepage Permissions, , Titlepage Copying Permissions}, for the +standard text for the copyright permissions.@refill + +@menu +* titlepage:: Create a title for the printed document. +* titlefont center sp:: The @code{@@titlefont}, @code{@@center}, + and @code{@@sp} commands. +* title subtitle author:: The @code{@@title}, @code{@@subtitle}, + and @code{@@author} commands. +* Copyright & Permissions:: How to write the copyright notice and + include copying permissions. +* end titlepage:: Turn on page headings after the title and + copyright pages. +* headings on off:: An option for turning headings on and off + and double or single sided printing. +@end menu + +@node titlepage, titlefont center sp, Titlepage & Copyright Page, Titlepage & Copyright Page +@comment node-name, next, previous, up +@subsection @code{@@titlepage} +@cindex Title page +@findex titlepage + +Start the material for the title page and following copyright page +with @code{@@titlepage} on a line by itself and end it with +@code{@@end titlepage} on a line by itself.@refill + +The @code{@@end titlepage} command starts a new page and turns on page +numbering. (@xref{Headings, , Page Headings}, for details about how to +generate page headings.) All the material that you want to +appear on unnumbered pages should be put between the +@code{@@titlepage} and @code{@@end titlepage} commands. By using the +@code{@@page} command you can force a page break within the region +delineated by the @code{@@titlepage} and @code{@@end titlepage} +commands and thereby create more than one unnumbered page. This is +how the copyright page is produced. (The @code{@@titlepage} command +might perhaps have been better named the +@code{@@titleandadditionalpages} command, but that would have been +rather long!)@refill + +@c !!! append refill to footnote when makeinfo can handle it. +When you write a manual about a computer program, you should write the +version of the program to which the manual applies on the title +page. If the manual changes more frequently than the program or is +independent of it, you should also include an edition +number@footnote{We have found that it is helpful to refer to versions +of manuals as `editions' and versions of programs as `versions'; +otherwise, we find we are liable to confuse each other in conversation +by referring to both the documentation and the software with the same +words.} for the manual. This helps readers keep track of which manual +is for which version of the program. (The `Top' node +should also contain this information; see @ref{makeinfo top, , +@code{@@top}}.)@refill + +Texinfo provides two main methods for creating a title page. One method +uses the @code{@@titlefont}, @code{@@sp}, and @code{@@center} commands +to generate a title page in which the words on the page are +centered.@refill + +The second method uses the @code{@@title}, @code{@@subtitle}, and +@code{@@author} commands to create a title page with black rules under +the title and author lines and the subtitle text set flush to the +right hand side of the page. With this method, you do not specify any +of the actual formatting of the title page. You specify the text +you want, and Texinfo does the formatting. You may use either +method.@refill + +@findex shorttitlepage +For extremely simple applications, Texinfo also provides a command +@code{@@shorttitlepage} which takes a single argument as the title. +The argument is typeset on a page by itself and followed by a blank +page. + + +@node titlefont center sp, title subtitle author, titlepage, Titlepage & Copyright Page +@comment node-name, next, previous, up +@subsection @code{@@titlefont}, @code{@@center}, and @code{@@sp} +@findex titlefont +@findex center +@findex sp @r{(titlepage line spacing)} + +You can use the @code{@@titlefont}, @code{@@sp}, and @code{@@center} +commands to create a title page for a printed document. (This is the +first of the two methods for creating a title page in Texinfo.)@refill + +Use the @code{@@titlefont} command to select a large font suitable for +the title itself.@refill + +@need 700 +For example: + +@example +@@titlefont@{Texinfo@} +@end example + +Use the @code{@@center} command at the beginning of a line to center +the remaining text on that line. Thus,@refill + +@example +@@center @@titlefont@{Texinfo@} +@end example + +@noindent +centers the title, which in this example is ``Texinfo'' printed +in the title font.@refill + +Use the @code{@@sp} command to insert vertical space. For example:@refill + +@example +@@sp 2 +@end example + +@noindent +This inserts two blank lines on the printed page. (@xref{sp, , +@code{@@sp}}, for more information about the @code{@@sp} +command.)@refill + +A template for this method looks like this:@refill + +@example +@group +@@titlepage +@@sp 10 +@@center @@titlefont@{@var{name-of-manual-when-printed}@} +@@sp 2 +@@center @var{subtitle-if-any} +@@sp 2 +@@center @var{author} +@dots{} +@@end titlepage +@end group +@end example + +The spacing of the example fits an 8 1/2 by 11 inch manual.@refill + +@node title subtitle author, Copyright & Permissions, titlefont center sp, Titlepage & Copyright Page +@comment node-name, next, previous, up +@subsection @code{@@title}, @code{@@subtitle}, and @code{@@author} +@findex title +@findex subtitle +@findex author + +You can use the @code{@@title}, @code{@@subtitle}, and @code{@@author} +commands to create a title page in which the vertical and horizontal +spacing is done for you automatically. This contrasts with the method +described in +the previous section, in which the @code{@@sp} command is needed to +adjust vertical spacing.@refill + +Write the @code{@@title}, @code{@@subtitle}, or @code{@@author} +commands at the beginning of a line followed by the title, subtitle, +or author.@refill + +The @code{@@title} command produces a line in which the title is set +flush to the left-hand side of the page in a larger than normal font. +The title is underlined with a black rule.@refill + +The @code{@@subtitle} command sets subtitles in a normal-sized font +flush to the right-hand side of the page.@refill + +The @code{@@author} command sets the names of the author or authors in +a middle-sized font flush to the left-hand side of the page on a line +near the bottom of the title page. The names are underlined with a +black rule that is thinner than the rule that underlines the title. +(The black rule only occurs if the @code{@@author} command line is +followed by an @code{@@page} command line.)@refill + +There are two ways to use the @code{@@author} command: you can write +the name or names on the remaining part of the line that starts with +an @code{@@author} command:@refill + +@example +@@author by Jane Smith and John Doe +@end example + +@noindent +or you can write the names one above each other by using two (or more) +@code{@@author} commands:@refill + +@example +@group +@@author Jane Smith +@@author John Doe +@end group +@end example + +@noindent +(Only the bottom name is underlined with a black rule.)@refill + +@need 950 +A template for this method looks like this:@refill + +@example +@group +@@titlepage +@@title @var{name-of-manual-when-printed} +@@subtitle @var{subtitle-if-any} +@@subtitle @var{second-subtitle} +@@author @var{author} +@@page +@dots{} +@@end titlepage +@end group +@end example + +@ifinfo +@noindent +Contrast this form with the form of a title page written using the +@code{@@sp}, @code{@@center}, and @code{@@titlefont} commands:@refill + +@example +@@titlepage +@@sp 10 +@@center @@titlefont@{Name of Manual When Printed@} +@@sp 2 +@@center Subtitle, If Any +@@sp 1 +@@center Second subtitle +@@sp 2 +@@center Author +@@page +@dots{} +@@end titlepage +@end example +@end ifinfo + +@node Copyright & Permissions, end titlepage, title subtitle author, Titlepage & Copyright Page +@comment node-name, next, previous, up +@subsection Copyright Page and Permissions +@cindex Copyright page +@cindex Printed permissions +@cindex Permissions, printed + +By international treaty, the copyright notice for a book should be +either on the title page or on the back of the title page. The +copyright notice should include the year followed by the name of the +organization or person who owns the copyright.@refill + +When the copyright notice is on the back of the title page, that page +is customarily not numbered. Therefore, in Texinfo, the information +on the copyright page should be within @code{@@titlepage} and +@code{@@end titlepage} commands.@refill + +@findex vskip +@findex filll +@cindex Vertical whitespace (@samp{vskip}) +Use the @code{@@page} command to cause a page break. To push the +copyright notice and the other text on the copyright page towards the +bottom of the page, you can write a somewhat mysterious line after the +@code{@@page} command that reads like this:@refill + +@example +@@vskip 0pt plus 1filll +@end example + +@noindent +This is a @TeX{} command that is not supported by the Info formatting +commands. The @code{@@vskip} command inserts whitespace. The +@samp{0pt plus 1filll} means to put in zero points of mandatory whitespace, +and as much optional whitespace as needed to push the +following text to the bottom of the page. Note the use of three +@samp{l}s in the word @samp{filll}; this is the correct usage in +@TeX{}.@refill + +@findex copyright +In a printed manual, the @code{@@copyright@{@}} command generates a +@samp{c} inside a circle. (In Info, it generates @samp{(C)}.) The +copyright notice itself has the following legally defined sequence:@refill + +@example +Copyright @copyright{} @var{year} @var{copyright-owner} +@end example + +It is customary to put information on how to get a manual after the +copyright notice, followed by the copying permissions for the +manual.@refill + +Note that permissions must be given here as well as in the summary +segment within @code{@@ifinfo} and @code{@@end ifinfo} that +immediately follows the header since this text appears only in the +printed manual and the @samp{ifinfo} text appears only in the Info +file.@refill + +@xref{Sample Permissions}, for the standard text.@refill + +@node end titlepage, headings on off, Copyright & Permissions, Titlepage & Copyright Page +@comment node-name, next, previous, up +@subsection Heading Generation +@findex end titlepage +@cindex Headings, page, begin to appear +@cindex Titlepage end starts headings +@cindex End titlepage starts headings + +An @code{@@end titlepage} command on a line by itself not only marks +the end of the title and copyright pages, but also causes @TeX{} to start +generating page headings and page numbers. + +To repeat what is said elsewhere, Texinfo has two standard page heading +formats, one for documents which are printed on one side of each sheet of paper +(single-sided printing), and the other for documents which are printed on both +sides of each sheet (double-sided printing). +(@xref{setchapternewpage, ,@code{@@setchapternewpage}}.) +You can specify these formats in different ways:@refill + +@itemize @bullet +@item +The conventional way is to write an @code{@@setchapternewpage} command +before the title page commands, and then have the @code{@@end +titlepage} command start generating page headings in the manner desired. +(@xref{setchapternewpage, , @code{@@setchapternewpage}}.)@refill + +@item +Alternatively, you can use the @code{@@headings} command to prevent page +headings from being generated or to start them for either single or +double-sided printing. (Write an @code{@@headings} command immediately +after the @code{@@end titlepage} command. @xref{headings on off, , The +@code{@@headings} Command}, for more information.)@refill + +@item +Or, you may specify your own page heading and footing format. +@xref{Headings, , Page Headings}, for detailed +information about page headings and footings.@refill +@end itemize + +Most documents are formatted with the standard single-sided or +double-sided format, using @code{@@setchapternewpage odd} for +double-sided printing and no @code{@@setchapternewpage} command for +single-sided printing.@refill + +@node headings on off, , end titlepage, Titlepage & Copyright Page +@comment node-name, next, previous, up +@subsection The @code{@@headings} Command +@findex headings + +The @code{@@headings} command is rarely used. It specifies what kind of +page headings and footings to print on each page. Usually, this is +controlled by the @code{@@setchapternewpage} command. You need the +@code{@@headings} command only if the @code{@@setchapternewpage} command +does not do what you want, or if you want to turn off pre-defined page +headings prior to defining your own. Write an @code{@@headings} command +immediately after the @code{@@end titlepage} command.@refill + +You can use @code{@@headings} as follows:@refill + +@table @code +@item @@headings off +Turn off printing of page headings.@refill + +@item @@headings single +Turn on page headings appropriate for single-sided printing. +@refill + +@item @@headings double +Turn on page headings appropriate for double-sided printing. The two +commands, @code{@@headings on} and @code{@@headings double}, are +synonymous.@refill + +@item @@headings singleafter +@itemx @@headings doubleafter +Turn on @code{single} or @code{double} headings, respectively, after the +current page is output. + +@item @@headings on +Turn on page headings: @code{single} if @samp{@@setchapternewpage +on}, @code{double} otherwise. +@end table + +For example, suppose you write @code{@@setchapternewpage off} before the +@code{@@titlepage} command to tell @TeX{} to start a new chapter on the +same page as the end of the last chapter. This command also causes +@TeX{} to typeset page headers for single-sided printing. To cause +@TeX{} to typeset for double sided printing, write @code{@@headings +double} after the @code{@@end titlepage} command. + +You can stop @TeX{} from generating any page headings at all by +writing @code{@@headings off} on a line of its own immediately after the +line containing the @code{@@end titlepage} command, like this:@refill + +@example +@@end titlepage +@@headings off +@end example + +@noindent +The @code{@@headings off} command overrides the @code{@@end titlepage} +command, which would otherwise cause @TeX{} to print page +headings.@refill + +You can also specify your own style of page heading and footing. +@xref{Headings, , Page Headings}, for more information.@refill + +@node The Top Node, Software Copying Permissions, Titlepage & Copyright Page, Beginning a File +@comment node-name, next, previous, up +@section The `Top' Node and Master Menu +@cindex @samp{@r{Top}} node +@cindex Master menu +@cindex Node, `Top' + +The `Top' node is the node from which you enter an Info file.@refill + +A `Top' node should contain a brief description of the Info file and an +extensive, master menu for the whole Info file. +This helps the reader understand what the Info file is +about. Also, you should write the version number of the program to +which the Info file applies; or, at least, the edition number.@refill + +The contents of the `Top' node should appear only in the Info file; none +of it should appear in printed output, so enclose it between +@code{@@ifinfo} and @code{@@end ifinfo} commands. (@TeX{} does not +print either an @code{@@node} line or a menu; they appear only in Info; +strictly speaking, you are not required to enclose these parts between +@code{@@ifinfo} and @code{@@end ifinfo}, but it is simplest to do so. +@xref{Conditionals, , Conditionally Visible Text}.)@refill + +@menu +* Title of Top Node:: Sketch what the file is about. +* Master Menu Parts:: A master menu has three or more parts. +@end menu + +@node Title of Top Node, Master Menu Parts, The Top Node, The Top Node +@ifinfo +@subheading `Top' Node Title +@end ifinfo + +Sometimes, you will want to place an @code{@@top} sectioning command +line containing the title of the document immediately after the +@code{@@node Top} line (@pxref{makeinfo top command, , The @code{@@top} +Sectioning Command}, for more information).@refill + +For example, the beginning of the Top node of this manual contains an +@code{@@top} sectioning command, a short description, and edition and +version information. It looks like this:@refill + +@example +@group +@dots{} +@@end titlepage + +@@ifinfo +@@node Top, Copying, (dir), (dir) +@@top Texinfo + +Texinfo is a documentation system@dots{} +@end group + +@group +This is edition@dots{} +@dots{} +@@end ifinfo +@end group + +@group +@@menu +* Copying:: Texinfo is freely + redistributable. +* Overview:: What is Texinfo? +@dots{} +@end group +@@end menu +@end example + +In a `Top' node, the `Previous', and `Up' nodes usually refer to the top +level directory of the whole Info system, which is called @samp{(dir)}. +The `Next' node refers to the first node that follows the main or master +menu, which is usually the copying permissions, introduction, or first +chapter.@refill + +@node Master Menu Parts, , Title of Top Node, The Top Node +@subsection Parts of a Master Menu +@cindex Master menu parts +@cindex Parts of a master menu + +A @dfn{master menu} is a detailed main menu listing all the nodes in a +file. + +A master menu is enclosed in @code{@@menu} and @code{@@end menu} +commands and does not appear in the printed document.@refill + +Generally, a master menu is divided into parts.@refill + +@itemize @bullet +@item +The first part contains the major nodes in the Texinfo file: the nodes +for the chapters, chapter-like sections, and the appendices.@refill + +@item +The second part contains nodes for the indices.@refill + +@item +The third and subsequent parts contain a listing of the other, lower +level nodes, often ordered by chapter. This way, rather than go +through an intermediary menu, an inquirer can go directly to a +particular node when searching for specific information. These menu +items are not required; add them if you think they are a +convenience. If you do use them, put @code{@@detailmenu} before the +first one, and @code{@@end detailmenu} after the last; otherwise, +@code{makeinfo} will get confused. +@end itemize + +Each section in the menu can be introduced by a descriptive line. So +long as the line does not begin with an asterisk, it will not be +treated as a menu entry. (@xref{Writing a Menu}, for more +information.)@refill + +For example, the master menu for this manual looks like the following +(but has many more entries):@refill + +@example +@group +@@menu +* Copying:: Texinfo is freely + redistributable. +* Overview:: What is Texinfo? +* Texinfo Mode:: Special features in GNU Emacs. +@dots{} +@dots{} +@end group +@group +* Command and Variable Index:: + An entry for each @@-command. +* Concept Index:: An entry for each concept. +@end group + +@group +@@detailmenu + --- The Detailed Node Listing --- + +Overview of Texinfo + +* Info Files:: What is an Info file? +* Printed Manuals:: Characteristics of + a printed manual. +@dots{} +@dots{} +@end group + +@group +Using Texinfo Mode + +* Info on a Region:: Formatting part of a file + for Info. +@dots{} +@dots{} +@@end detailmenu +@@end menu +@end group +@end example + +@node Software Copying Permissions, , The Top Node, Beginning a File +@comment node-name, next, previous, up +@section Software Copying Permissions +@cindex Software copying permissions +@cindex Copying software +@cindex Distribution +@cindex License agreement + +If the Texinfo file has a section containing the ``General Public +License'' and the distribution information and a warranty disclaimer +for the software that is documented, this section usually follows the +`Top' node. The General Public License is very important to Project +GNU software. It ensures that you and others will continue to have a +right to use and share the software.@refill + +The copying and distribution information and the disclaimer are +followed by an introduction or else by the first chapter of the +manual.@refill + +@cindex Introduction, as part of file +Although an introduction is not a required part of a Texinfo file, it +is very helpful. Ideally, it should state clearly and concisely what +the file is about and who would be interested in reading it. In +general, an introduction would follow the licensing and distribution +information, although sometimes people put it earlier in the document. +Usually, an introduction is put in an @code{@@unnumbered} section. +(@xref{unnumbered & appendix, , The @code{@@unnumbered} and +@code{@@appendix} Commands}.)@refill + +@node Ending a File, Structuring, Beginning a File, Top +@comment node-name, next, previous, up +@chapter Ending a Texinfo File +@cindex Ending a Texinfo file +@cindex Texinfo file ending +@cindex File ending +@findex bye + +The end of a Texinfo file should include the commands that create +indices and generate detailed and summary tables of contents. +And it must include the @code{@@bye} command that marks the last line +processed by @TeX{}.@refill + +@need 700 +For example: + +@example +@@node Concept Index, , Variables Index, Top +@@c node-name, next, previous, up +@@unnumbered Concept Index + +@@printindex cp + +@@contents +@@bye +@end example + +@menu +* Printing Indices & Menus:: How to print an index in hardcopy and + generate index menus in Info. +* Contents:: How to create a table of contents. +* File End:: How to mark the end of a file. +@end menu + +@node Printing Indices & Menus, Contents, Ending a File, Ending a File +@comment node-name, next, previous, up +@section Index Menus and Printing an Index +@findex printindex +@cindex Printing an index +@cindex Indices, printing and menus +@cindex Generating menus with indices +@cindex Menus generated with indices + +To print an index means to include it as part of a manual or Info +file. This does not happen automatically just because you use +@code{@@cindex} or other index-entry generating commands in the +Texinfo file; those just cause the raw data for the index to be +accumulated. To generate an index, you must include the +@code{@@printindex} command at the place in the document where you +want the index to appear. Also, as part of the process of creating a +printed manual, you must run a program called @code{texindex} +(@pxref{Format/Print Hardcopy}) to sort the raw data to produce a sorted +index file. The sorted index file is what is actually used to +print the index.@refill + +Texinfo offers six different types of predefined index: the concept +index, the function index, the variables index, the keystroke index, the +program index, and the data type index (@pxref{Predefined Indices}). Each +index type has a two-letter name: @samp{cp}, @samp{fn}, @samp{vr}, +@samp{ky}, @samp{pg}, and @samp{tp}. You may merge indices, or put them +into separate sections (@pxref{Combining Indices}); or you may define +your own indices (@pxref{New Indices, , Defining New Indices}).@refill + +The @code{@@printindex} command takes a two-letter index name, reads +the corresponding sorted index file and formats it appropriately into +an index.@refill + +@ignore +The two-letter index names are: + +@table @samp +@item cp +concept index +@item fn +function index +@item vr +variable index +@item ky +key index +@item pg +program index +@item tp +data type index +@end table +@end ignore +The @code{@@printindex} command does not generate a chapter heading +for the index. Consequently, you should precede the +@code{@@printindex} command with a suitable section or chapter command +(usually @code{@@unnumbered}) to supply the chapter heading and put +the index into the table of contents. Precede the @code{@@unnumbered} +command with an @code{@@node} line.@refill + +@need 1200 +For example: + +@smallexample +@group +@@node Variable Index, Concept Index, Function Index, Top +@@comment node-name, next, previous, up +@@unnumbered Variable Index + +@@printindex vr +@end group + +@group +@@node Concept Index, , Variable Index, Top +@@comment node-name, next, previous, up +@@unnumbered Concept Index + +@@printindex cp +@end group + +@group +@@summarycontents +@@contents +@@bye +@end group +@end smallexample + +@noindent +(Readers often prefer that the concept index come last in a book, +since that makes it easiest to find.)@refill + +@ignore +In @TeX{}, the @code{@@printindex} command needs a sorted index file +to work from. @TeX{} does not know how to do sorting; this is a +deficiency. @TeX{} writes output files of raw index data; use the +@code{texindex} program to convert these files to sorted index files. +(@xref{Format/Print Hardcopy}, for more information.)@refill +@end ignore +@node Contents, File End, Printing Indices & Menus, Ending a File +@comment node-name, next, previous, up +@section Generating a Table of Contents +@cindex Table of contents +@cindex Contents, Table of +@findex contents +@findex summarycontents +@findex shortcontents + +The @code{@@chapter}, @code{@@section}, and other structuring commands +supply the information to make up a table of contents, but they do not +cause an actual table to appear in the manual. To do this, you must +use the @code{@@contents} and @code{@@summarycontents} +commands:@refill + +@table @code +@item @@contents +Generate a table of contents in a printed manual, including all +chapters, sections, subsections, etc., as well as appendices and +unnumbered chapters. (Headings generated by the @code{@@heading} +series of commands do not appear in the table of contents.) The +@code{@@contents} command should be written on a line by +itself.@refill + +@item @@shortcontents +@itemx @@summarycontents +(@code{@@summarycontents} is a synonym for @code{@@shortcontents}; the +two commands are exactly the same.)@refill + +Generate a short or summary table of contents that lists only the +chapters (and appendices and unnumbered chapters). Omit sections, subsections +and subsubsections. Only a long manual needs a short table +of contents in addition to the full table of contents.@refill + +Write the @code{@@shortcontents} command on a line by itself right +@emph{before} the @code{@@contents} command.@refill +@end table + +The table of contents commands automatically generate a chapter-like +heading at the top of the first table of contents page. Write the table +of contents commands at the very end of a Texinfo file, just before the +@code{@@bye} command, following any index sections---anything in the +Texinfo file after the table of contents commands will be omitted from +the table of contents.@refill + +When you print a manual with a table of contents, the table of +contents are printed last and numbered with roman numerals. You need +to place those pages in their proper place, after the title page, +yourself. (This is the only collating you need to do for a printed +manual. The table of contents is printed last because it is generated +after the rest of the manual is typeset.)@refill + +@need 700 +Here is an example of where to write table of contents commands:@refill + +@example +@group +@var{indices}@dots{} +@@shortcontents +@@contents +@@bye +@end group +@end example + +Since an Info file uses menus instead of tables of contents, the Info +formatting commands ignore the @code{@@contents} and +@code{@@shortcontents} commands.@refill + +@node File End, , Contents, Ending a File +@comment node-name, next, previous, up +@section @code{@@bye} File Ending +@findex bye + +An @code{@@bye} command terminates @TeX{} or Info formatting. None of +the formatting commands see any of the file following @code{@@bye}. +The @code{@@bye} command should be on a line by itself.@refill + +If you wish, you may follow the @code{@@bye} line with notes. These notes +will not be formatted and will not appear in either Info or a printed +manual; it is as if text after @code{@@bye} were within @code{@@ignore} +@dots{} @code{@@end ignore}. Also, you may follow the @code{@@bye} line +with a local variables list. @xref{Compile-Command, , Using Local +Variables and the Compile Command}, for more information.@refill + +@node Structuring, Nodes, Ending a File, Top +@comment node-name, next, previous, up +@chapter Chapter Structuring +@cindex Chapter structuring +@cindex Structuring of chapters + +The @dfn{chapter structuring} commands divide a document into a hierarchy of +chapters, sections, subsections, and subsubsections. These commands +generate large headings; they also provide information for the table +of contents of a printed manual (@pxref{Contents, , Generating a Table +of Contents}).@refill + +The chapter structuring commands do not create an Info node structure, +so normally you should put an @code{@@node} command immediately before +each chapter structuring command (@pxref{Nodes}). The only time you +are likely to use the chapter structuring commands without using the +node structuring commands is if you are writing a document that +contains no cross references and will never be transformed into Info +format.@refill + +It is unlikely that you will ever write a Texinfo file that is +intended only as an Info file and not as a printable document. If you +do, you might still use chapter structuring commands to create a +heading at the top of each node---but you don't need to.@refill + +@menu +* Tree Structuring:: A manual is like an upside down tree @dots{} +* Structuring Command Types:: How to divide a manual into parts. +* makeinfo top:: The @code{@@top} command, part of the `Top' node. +* chapter:: +* unnumbered & appendix:: +* majorheading & chapheading:: +* section:: +* unnumberedsec appendixsec heading:: +* subsection:: +* unnumberedsubsec appendixsubsec subheading:: +* subsubsection:: Commands for the lowest level sections. +* Raise/lower sections:: How to change commands' hierarchical level. +@end menu + +@node Tree Structuring, Structuring Command Types, Structuring, Structuring +@comment node-name, next, previous, up +@section Tree Structure of Sections +@cindex Tree structuring + +A Texinfo file is usually structured like a book with chapters, +sections, subsections, and the like. This structure can be visualized +as a tree (or rather as an upside-down tree) with the root at the top +and the levels corresponding to chapters, sections, subsection, and +subsubsections.@refill + +Here is a diagram that shows a Texinfo file with three chapters, +each of which has two sections.@refill + +@example +@group + Top + | + ------------------------------------- + | | | + Chapter 1 Chapter 2 Chapter 3 + | | | + -------- -------- -------- + | | | | | | + Section Section Section Section Section Section + 1.1 1.2 2.1 2.2 3.1 3.2 + +@end group +@end example + +In a Texinfo file that has this structure, the beginning of Chapter 2 +looks like this:@refill + +@example +@group +@@node Chapter 2, Chapter 3, Chapter 1, top +@@chapter Chapter 2 +@end group +@end example + +The chapter structuring commands are described in the sections that +follow; the @code{@@node} and @code{@@menu} commands are described in +following chapters. (@xref{Nodes}, and see @ref{Menus}.)@refill + +@node Structuring Command Types, makeinfo top, Tree Structuring, Structuring +@comment node-name, next, previous, up +@section Types of Structuring Command + +The chapter structuring commands fall into four groups or series, each +of which contains structuring commands corresponding to the +hierarchical levels of chapters, sections, subsections, and +subsubsections.@refill + +The four groups are the @code{@@chapter} series, the +@code{@@unnumbered} series, the @code{@@appendix} series, and the +@code{@@heading} series.@refill + +Each command produces titles that have a different appearance on the +printed page or Info file; only some of the commands produce +titles that are listed in the table of contents of a printed book or +manual.@refill + +@itemize @bullet +@item +The @code{@@chapter} and @code{@@appendix} series of commands produce +numbered or lettered entries both in the body of a printed work and in +its table of contents.@refill + +@item +The @code{@@unnumbered} series of commands produce unnumbered entries +both in the body of a printed work and in its table of contents. The +@code{@@top} command, which has a special use, is a member of this +series (@pxref{makeinfo top, , @code{@@top}}).@refill + +@item +The @code{@@heading} series of commands produce unnumbered headings +that do not appear in a table of contents. The heading commands never +start a new page.@refill + +@item +The @code{@@majorheading} command produces results similar to using +the @code{@@chapheading} command but generates a larger vertical +whitespace before the heading.@refill + +@item +When an @code{@@setchapternewpage} command says to do so, the +@code{@@chapter}, @code{@@unnumbered}, and @code{@@appendix} commands +start new pages in the printed manual; the @code{@@heading} commands +do not.@refill +@end itemize + +@need 1000 +Here are the four groups of chapter structuring commands:@refill + +@c Slightly different formatting for regular sized books and smallbooks. +@ifset smallbook +@sp 1 +@tex +{\let\rm=\indrm \let\tt=\indtt +\halign{\hskip\itemindent#\hfil& \hskip.5em#\hfil& \hskip.5em#\hfil& +\hskip.5em#\hfil\cr + +& & & \rm No new pages\cr +\rm Numbered& \rm Unnumbered& \rm Lettered and numbered& \rm Unnumbered\cr +\rm In contents& \rm In contents& \rm In contents& \rm Not in contents\cr + +& & & \cr + & \tt @@top& & \tt @@majorheading\cr +\tt @@chapter& \tt @@unnumbered& \tt @@appendix& \tt @@chapheading\cr +\tt @@section& \tt @@unnumberedsec& \tt @@appendixsec& \tt @@heading\cr +\tt @@subsection&\tt @@unnumberedsubsec&\tt @@appendixsubsec& +\tt @@subheading\cr +\tt @@subsubsection& \tt @@unnumberedsubsubsec& \tt @@appendixsubsubsec& +\tt @@subsubheading\cr}} +@end tex +@end ifset +@ifclear smallbook +@sp 1 +@tex +\vbox{ +\halign{\hskip\itemindent\hskip.5em#\hfil& \hskip.5em#\hfil& +\hskip.5em#\hfil& \hskip.5em #\hfil\cr + +& & & \cr +& & & \rm No new pages\cr +\rm Numbered& \rm Unnumbered& \rm Lettered and numbered& \rm Unnumbered\cr +\rm In contents& \rm In contents& \rm In contents& \rm Not in contents\cr + +& & & \cr + & \tt @@top& & \tt @@majorheading\cr +\tt @@chapter& \tt @@unnumbered& \tt @@appendix& \tt @@chapheading\cr +\tt @@section& \tt @@unnumberedsec& \tt @@appendixsec& \tt @@heading\cr +\tt @@subsection&\tt @@unnumberedsubsec&\tt @@appendixsubsec& +\tt @@subheading\cr +\tt @@subsubsection& \tt @@unnumberedsubsubsec& \tt @@appendixsubsubsec& +\tt @@subsubheading\cr}} +@end tex +@end ifclear +@ifinfo +@example +@group + @r{No new pages} +@r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} +@r{In contents} @r{In contents} @r{In contents} @r{Not in contents} + + @@top @@majorheading +@@chapter @@unnumbered @@appendix @@chapheading +@@section @@unnumberedsec @@appendixsec @@heading +@@subsection @@unnumberedsubsec @@appendixsubsec @@subheading +@@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading +@end group +@end example +@end ifinfo + +@c Cannot line up columns properly inside of an example because of roman +@c proportional fonts. +@ignore +@ifset smallbook +@iftex +@smallexample +@group + @r{No new pages} +@r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} +@r{In contents} @r{In contents} @r{In contents} @r{Not in contents} + + @@top @@majorheading +@@chapter @@unnumbered @@appendix @@chapheading +@@section @@unnumberedsec @@appendixsec @@heading +@@subsection @@unnumberedsubsec @@appendixsubsec @@subheading +@@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading +@end group +@end smallexample +@end iftex +@end ifset +@ifclear smallbook +@iftex +@smallexample +@group + @r{No new pages} +@r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} +@r{In contents} @r{In contents} @r{In contents} @r{Not in contents} + + @@top @@majorheading +@@chapter @@unnumbered @@appendix @@chapheading +@@section @@unnumberedsec @@appendixsec @@heading +@@subsection @@unnumberedsubsec @@appendixsubsec @@subheading +@@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading +@end group +@end smallexample +@end iftex +@end ignore + +@node makeinfo top, chapter, Structuring Command Types, Structuring +@comment node-name, next, previous, up +@section @code{@@top} + +The @code{@@top} command is a special sectioning command that you use +only after an @code{@@node Top} line at the beginning of a Texinfo file. +The @code{@@top} command tells the @code{makeinfo} formatter +which node is the `Top' +node. It has the same typesetting effect as @code{@@unnumbered} +(@pxref{unnumbered & appendix, , @code{@@unnumbered}, @code{@@appendix}}). +For detailed information, see +@ref{makeinfo top command, , The @code{@@top} Command}.@refill + +@node chapter, unnumbered & appendix, makeinfo top, Structuring +@comment node-name, next, previous, up +@section @code{@@chapter} +@findex chapter + +@code{@@chapter} identifies a chapter in the document. Write the +command at the beginning of a line and follow it on the same line by +the title of the chapter.@refill + +For example, this chapter in this manual is entitled ``Chapter +Structuring''; the @code{@@chapter} line looks like this:@refill + +@example +@@chapter Chapter Structuring +@end example + +In @TeX{}, the @code{@@chapter} command creates a chapter in the +document, specifying the chapter title. The chapter is numbered +automatically.@refill + +In Info, the @code{@@chapter} command causes the title to appear on a +line by itself, with a line of asterisks inserted underneath. Thus, +in Info, the above example produces the following output:@refill + +@example +Chapter Structuring +******************* +@end example + +@findex centerchap +Texinfo also provides a command @code{@@centerchap}, which is analogous +to @code{@@unnumbered}, but centers its argument in the printed output. +This kind of stylistic choice is not usually offered by Texinfo. +@c but the Hacker's Dictionary wanted it ... + + +@node unnumbered & appendix, majorheading & chapheading, chapter, Structuring +@comment node-name, next, previous, up +@section @code{@@unnumbered}, @code{@@appendix} +@findex unnumbered +@findex appendix + +Use the @code{@@unnumbered} command to create a chapter that appears +in a printed manual without chapter numbers of any kind. Use the +@code{@@appendix} command to create an appendix in a printed manual +that is labelled by letter instead of by number.@refill + +For Info file output, the @code{@@unnumbered} and @code{@@appendix} +commands are equivalent to @code{@@chapter}: the title is printed on a +line by itself with a line of asterisks underneath. (@xref{chapter, , +@code{@@chapter}}.)@refill + +To create an appendix or an unnumbered chapter, write an +@code{@@appendix} or @code{@@unnumbered} command at the beginning of a +line and follow it on the same line by the title, as you would if you +were creating a chapter.@refill + + +@node majorheading & chapheading, section, unnumbered & appendix, Structuring +@section @code{@@majorheading}, @code{@@chapheading} +@findex majorheading +@findex chapheading + +The @code{@@majorheading} and @code{@@chapheading} commands put +chapter-like headings in the body of a document.@refill + +However, neither command causes @TeX{} to produce a numbered heading +or an entry in the table of contents; and neither command causes +@TeX{} to start a new page in a printed manual.@refill + +In @TeX{}, an @code{@@majorheading} command generates a larger vertical +whitespace before the heading than an @code{@@chapheading} command but +is otherwise the same.@refill + +In Info, +the @code{@@majorheading} and +@code{@@chapheading} commands are equivalent to +@code{@@chapter}: the title is printed on a line by itself with a line +of asterisks underneath. (@xref{chapter, , @code{@@chapter}}.)@refill + +@node section, unnumberedsec appendixsec heading, majorheading & chapheading, Structuring +@comment node-name, next, previous, up +@section @code{@@section} +@findex section + +In a printed manual, an @code{@@section} command identifies a +numbered section within a chapter. The section title appears in the +table of contents. In Info, an @code{@@section} command provides a +title for a segment of text, underlined with @samp{=}.@refill + +This section is headed with an @code{@@section} command and looks like +this in the Texinfo file:@refill + +@example +@@section @@code@{@@@@section@} +@end example + +To create a section, write the @code{@@section} command at the +beginning of a line and follow it on the same line by the section +title.@refill + +Thus, + +@example +@@section This is a section +@end example + +@noindent +produces + +@example +@group +This is a section +================= +@end group +@end example + +@noindent +in Info. + +@node unnumberedsec appendixsec heading, subsection, section, Structuring +@comment node-name, next, previous, up +@section @code{@@unnumberedsec}, @code{@@appendixsec}, @code{@@heading} +@findex unnumberedsec +@findex appendixsec +@findex heading + +The @code{@@unnumberedsec}, @code{@@appendixsec}, and @code{@@heading} +commands are, respectively, the unnumbered, appendix-like, and +heading-like equivalents of the @code{@@section} command. +(@xref{section, , @code{@@section}}.)@refill + +@table @code +@item @@unnumberedsec +The @code{@@unnumberedsec} command may be used within an +unnumbered chapter or within a regular chapter or appendix to +provide an unnumbered section.@refill + +@item @@appendixsec +@itemx @@appendixsection +@code{@@appendixsection} is a longer spelling of the +@code{@@appendixsec} command; the two are synonymous.@refill +@findex appendixsection + +Conventionally, the @code{@@appendixsec} or @code{@@appendixsection} +command is used only within appendices.@refill + +@item @@heading +You may use the @code{@@heading} command anywhere you wish for a +section-style heading that will not appear in the table of contents.@refill +@end table + +@node subsection, unnumberedsubsec appendixsubsec subheading, unnumberedsec appendixsec heading, Structuring +@comment node-name, next, previous, up +@section The @code{@@subsection} Command +@findex subsection + +Subsections are to sections as sections are to chapters. +(@xref{section, , @code{@@section}}.) In Info, subsection titles are +underlined with @samp{-}. For example,@refill + +@example +@@subsection This is a subsection +@end example + +@noindent +produces + +@example +@group +This is a subsection +-------------------- +@end group +@end example + +In a printed manual, subsections are listed in the table of contents +and are numbered three levels deep.@refill + +@node unnumberedsubsec appendixsubsec subheading, subsubsection, subsection, Structuring +@comment node-name, next, previous, up +@section The @code{@@subsection}-like Commands +@cindex Subsection-like commands +@findex unnumberedsubsec +@findex appendixsubsec +@findex subheading + +The @code{@@unnumberedsubsec}, @code{@@appendixsubsec}, and +@code{@@subheading} commands are, respectively, the unnumbered, +appendix-like, and heading-like equivalents of the @code{@@subsection} +command. (@xref{subsection, , @code{@@subsection}}.)@refill + +In Info, the @code{@@subsection}-like commands generate a title +underlined with hyphens. In a printed manual, an @code{@@subheading} +command produces a heading like that of a subsection except that it is +not numbered and does not appear in the table of contents. Similarly, +an @code{@@unnumberedsubsec} command produces an unnumbered heading like +that of a subsection and an @code{@@appendixsubsec} command produces a +subsection-like heading labelled with a letter and numbers; both of +these commands produce headings that appear in the table of +contents.@refill + +@node subsubsection, Raise/lower sections, unnumberedsubsec appendixsubsec subheading, Structuring +@comment node-name, next, previous, up +@section The `subsub' Commands +@cindex Subsub commands +@findex subsubsection +@findex unnumberedsubsubsec +@findex appendixsubsubsec +@findex subsubheading + +The fourth and lowest level sectioning commands in Texinfo are the +`subsub' commands. They are:@refill + +@table @code +@item @@subsubsection +Subsubsections are to subsections as subsections are to sections. +(@xref{subsection, , @code{@@subsection}}.) In a printed manual, +subsubsection titles appear in the table of contents and are numbered +four levels deep.@refill + +@item @@unnumberedsubsubsec +Unnumbered subsubsection titles appear in the table of contents of a +printed manual, but lack numbers. Otherwise, unnumbered +subsubsections are the same as subsubsections. In Info, unnumbered +subsubsections look exactly like ordinary subsubsections.@refill + +@item @@appendixsubsubsec +Conventionally, appendix commands are used only for appendices and are +lettered and numbered appropriately in a printed manual. They also +appear in the table of contents. In Info, appendix subsubsections look +exactly like ordinary subsubsections.@refill + +@item @@subsubheading +The @code{@@subsubheading} command may be used anywhere that you need +a small heading that will not appear in the table of contents. In +Info, subsubheadings look exactly like ordinary subsubsection +headings.@refill +@end table + +In Info, `subsub' titles are underlined with periods. +For example,@refill + +@example +@@subsubsection This is a subsubsection +@end example + +@noindent +produces + +@example +@group +This is a subsubsection +....................... +@end group +@end example + +@node Raise/lower sections, , subsubsection, Structuring +@comment node-name, next, previous, up +@section @code{@@raisesections} and @code{@@lowersections} +@findex raisesections +@findex lowersections +@cindex Raising and lowering sections +@cindex Sections, raising and lowering + +The @code{@@raisesections} and @code{@@lowersections} commands raise and +lower the hierarchical level of chapters, sections, subsections and the +like. The @code{@@raisesections} command changes sections to chapters, +subsections to sections, and so on. The @code{@@lowersections} command +changes chapters to sections, sections to subsections, and so on. + +An @code{@@lowersections} command is useful if you wish to include text +that is written as an outer or standalone Texinfo file in another +Texinfo file as an inner, included file. If you write the command at +the beginning of the file, all your @code{@@chapter} commands are +formatted as if they were @code{@@section} commands, all your +@code{@@section} command are formatted as if they were +@code{@@subsection} commands, and so on. + +@need 1000 +@code{@@raisesections} raises a command one level in the chapter +structuring hierarchy:@refill + +@example +@group + @r{Change} @r{To} + +@@subsection @@section, +@@section @@chapter, +@@heading @@chapheading, + @r{etc.} +@end group +@end example + +@need 1000 +@code{@@lowersections} lowers a command one level in the chapter +structuring hierarchy:@refill + +@example +@group + @r{Change} @r{To} + +@@chapter @@section, +@@subsection @@subsubsection, +@@heading @@subheading, + @r{etc.} +@end group +@end example + +An @code{@@raisesections} or @code{@@lowersections} command changes only +those structuring commands that follow the command in the Texinfo file. +Write an @code{@@raisesections} or @code{@@lowersections} command on a +line of its own. + +An @code{@@lowersections} command cancels an @code{@@raisesections} +command, and vice versa. + +Repeated use of the commands continue to raise or lower the hierarchical +level a step at a time. + +An attempt to raise above `chapters' reproduces chapter commands; an +attempt to lower below `subsubsections' reproduces subsubsection +commands. + +@node Nodes, Menus, Structuring, Top +@comment node-name, next, previous, up +@chapter Nodes + +@dfn{Nodes} are the primary segments of a Texinfo file. They do not +themselves impose a hierarchic or any other kind of structure on a file. +Nodes contain @dfn{node pointers} that name other nodes, and can contain +@dfn{menus} which are lists of nodes. In Info, the movement commands +can carry you to a pointed-to node or to a node listed in a menu. Node +pointers and menus provide structure for Info files just as chapters, +sections, subsections, and the like, provide structure for printed +books.@refill + +@menu +* Two Paths:: Different commands to structure + Info output and printed output. +* Node Menu Illustration:: A diagram, and sample nodes and menus. +* node:: How to write a node, in detail. +* makeinfo Pointer Creation:: How to create node pointers with @code{makeinfo}. +@end menu + +@node Two Paths, Node Menu Illustration, Nodes, Nodes +@ifinfo +@heading Two Paths +@end ifinfo + +The node and menu commands and the chapter structuring commands are +independent of each other: + +@itemize @bullet +@item +In Info, node and menu commands provide structure. The chapter +structuring commands generate headings with different kinds of +underlining---asterisks for chapters, hyphens for sections, and so on; +they do nothing else.@refill + +@item +In @TeX{}, the chapter structuring commands generate chapter and section +numbers and tables of contents. The node and menu commands provide +information for cross references; they do nothing else.@refill +@end itemize + +You can use node pointers and menus to structure an Info file any way +you want; and you can write a Texinfo file so that its Info output has a +different structure than its printed output. However, most Texinfo +files are written such that the structure for the Info output +corresponds to the structure for the printed output. It is not +convenient to do otherwise.@refill + +Generally, printed output is structured in a tree-like hierarchy in +which the chapters are the major limbs from which the sections branch +out. Similarly, node pointers and menus are organized to create a +matching structure in the Info output.@refill + +@node Node Menu Illustration, node, Two Paths, Nodes +@comment node-name, next, previous, up +@section Node and Menu Illustration + +Here is a copy of the diagram shown earlier that illustrates a Texinfo +file with three chapters, each of which contains two sections.@refill + +Note that the ``root'' is at the top of the diagram and the ``leaves'' +are at the bottom. This is how such a diagram is drawn conventionally; +it illustrates an upside-down tree. For this reason, the root node is +called the `Top' node, and `Up' node pointers carry you closer to the +root.@refill + +@example +@group + Top + | + ------------------------------------- + | | | + Chapter 1 Chapter 2 Chapter 3 + | | | + -------- -------- -------- + | | | | | | + Section Section Section Section Section Section + 1.1 1.2 2.1 2.2 3.1 3.2 + +@end group +@end example + +Write the beginning of the node for Chapter 2 like this:@refill + +@example +@group +@@node Chapter 2, Chapter 3, Chapter 1, top +@@comment node-name, next, previous, up +@end group +@end example + +@noindent +This @code{@@node} line says that the name of this node is ``Chapter 2'', the +name of the `Next' node is ``Chapter 3'', the name of the `Previous' +node is ``Chapter 1'', and the name of the `Up' node is ``Top''. + +@quotation +@strong{Please Note:} `Next' refers to the next node at the same +hierarchical level in the manual, not necessarily to the next node +within the Texinfo file. In the Texinfo file, the subsequent node may +be at a lower level---a section-level node may follow a chapter-level +node, and a subsection-level node may follow a section-level node. +`Next' and `Previous' refer to nodes at the @emph{same} hierarchical +level. (The `Top' node contains the exception to this rule. Since the +`Top' node is the only node at that level, `Next' refers to the first +following node, which is almost always a chapter or chapter-level +node.)@refill +@end quotation + +To go to Sections 2.1 and 2.2 using Info, you need a menu inside Chapter +2. (@xref{Menus}.) You would write the menu just +before the beginning of Section 2.1, like this:@refill + +@example +@group + @@menu + * Sect. 2.1:: Description of this section. + * Sect. 2.2:: + @@end menu +@end group +@end example + +Write the node for Sect. 2.1 like this:@refill + +@example +@group + @@node Sect. 2.1, Sect. 2.2, Chapter 2, Chapter 2 + @@comment node-name, next, previous, up +@end group +@end example + +In Info format, the `Next' and `Previous' pointers of a node usually +lead to other nodes at the same level---from chapter to chapter or from +section to section (sometimes, as shown, the `Previous' pointer points +up); an `Up' pointer usually leads to a node at the level above (closer +to the `Top' node); and a `Menu' leads to nodes at a level below (closer +to `leaves'). (A cross reference can point to a node at any level; +see @ref{Cross References}.)@refill + +Usually, an @code{@@node} command and a chapter structuring command are +used in sequence, along with indexing commands. (You may follow the +@code{@@node} line with a comment line that reminds you which pointer is +which.)@refill + +Here is the beginning of the chapter in this manual called ``Ending a +Texinfo File''. This shows an @code{@@node} line followed by a comment +line, an @code{@@chapter} line, and then by indexing lines.@refill + +@example +@group +@@node Ending a File, Structuring, Beginning a File, Top +@@comment node-name, next, previous, up +@@chapter Ending a Texinfo File +@@cindex Ending a Texinfo file +@@cindex Texinfo file ending +@@cindex File ending +@end group +@end example + +@node node, makeinfo Pointer Creation, Node Menu Illustration, Nodes +@comment node-name, next, previous, up +@section The @code{@@node} Command + +@cindex Node, defined +A @dfn{node} is a segment of text that begins at an @code{@@node} +command and continues until the next @code{@@node} command. The +definition of node is different from that for chapter or section. A +chapter may contain sections and a section may contain subsections; +but a node cannot contain subnodes; the text of a node continues only +until the next @code{@@node} command in the file. A node usually +contains only one chapter structuring command, the one that follows +the @code{@@node} line. On the other hand, in printed output nodes +are used only for cross references, so a chapter or section may +contain any number of nodes. Indeed, a chapter usually contains +several nodes, one for each section, subsection, and +subsubsection.@refill + +To create a node, write an @code{@@node} command at the beginning of a +line, and follow it with four arguments, separated by commas, on the +rest of the same line. These arguments are the name of the node, and +the names of the `Next', `Previous', and `Up' pointers, in that order. +You may insert spaces before each pointer if you wish; the spaces are +ignored. You must write the name of the node, and the names of the +`Next', `Previous', and `Up' pointers, all on the same line. Otherwise, +the formatters fail. (@inforef{Top, info, info}, for more information +about nodes in Info.)@refill + +Usually, you write one of the chapter-structuring command lines +immediately after an @code{@@node} line---for example, an +@code{@@section} or @code{@@subsection} line. (@xref{Structuring +Command Types, , Types of Structuring Command}.)@refill + +@quotation +@strong{Please note:} The GNU Emacs Texinfo mode updating commands work +only with Texinfo files in which @code{@@node} lines are followed by chapter +structuring lines. @xref{Updating Requirements}.@refill +@end quotation + +@TeX{} uses @code{@@node} lines to identify the names to use for cross +references. For this reason, you must write @code{@@node} lines in a +Texinfo file that you intend to format for printing, even if you do not +intend to format it for Info. (Cross references, such as the one at the +end of this sentence, are made with @code{@@xref} and its related +commands; see @ref{Cross References}.)@refill + +@menu +* Node Names:: How to choose node and pointer names. +* Writing a Node:: How to write an @code{@@node} line. +* Node Line Tips:: Keep names short. +* Node Line Requirements:: Keep names unique, without @@-commands. +* First Node:: How to write a `Top' node. +* makeinfo top command:: How to use the @code{@@top} command. +* Top Node Summary:: Write a brief description for readers. +@end menu + +@node Node Names, Writing a Node, node, node +@ifinfo +@subheading Choosing Node and Pointer Names +@end ifinfo + +The name of a node identifies the node. The pointers enable +you to reach other nodes and consist of the names of those nodes.@refill + +Normally, a node's `Up' pointer contains the name of the node whose menu +mentions that node. The node's `Next' pointer contains the name of the +node that follows that node in that menu and its `Previous' pointer +contains the name of the node that precedes it in that menu. When a +node's `Previous' node is the same as its `Up' node, both node pointers +name the same node.@refill + +Usually, the first node of a Texinfo file is the `Top' node, and its +`Up' and `Previous' pointers point to the @file{dir} file, which +contains the main menu for all of Info.@refill + +The `Top' node itself contains the main or master menu for the manual. +Also, it is helpful to include a brief description of the manual in the +`Top' node. @xref{First Node}, for information on how to write the +first node of a Texinfo file.@refill + +@node Writing a Node, Node Line Tips, Node Names, node +@comment node-name, next, previous, up +@subsection How to Write an @code{@@node} Line +@cindex Writing an @code{@@node} line +@cindex @code{@@node} line writing +@cindex Node line writing + +The easiest way to write an @code{@@node} line is to write @code{@@node} +at the beginning of a line and then the name of the node, like +this:@refill + +@example +@@node @var{node-name} +@end example + +If you are using GNU Emacs, you can use the update node commands +provided by Texinfo mode to insert the names of the pointers; or you +can leave the pointers out of the Texinfo file and let @code{makeinfo} +insert node pointers into the Info file it creates. (@xref{Texinfo +Mode}, and @ref{makeinfo Pointer Creation}.)@refill + +Alternatively, you can insert the `Next', `Previous', and `Up' +pointers yourself. If you do this, you may find it helpful to use the +Texinfo mode keyboard command @kbd{C-c C-c n}. This command inserts +@samp{@@node} and a comment line listing the names of the pointers in +their proper order. The comment line helps you keep track of which +arguments are for which pointers. This comment line is especially useful +if you are not familiar with Texinfo.@refill + +The template for a node line with `Next', `Previous', and `Up' pointers +looks like this:@refill + +@example +@@node @var{node-name}, @var{next}, @var{previous}, @var{up} +@end example + +If you wish, you can ignore @code{@@node} lines altogether in your first +draft and then use the @code{texinfo-insert-node-lines} command to +create @code{@@node} lines for you. However, we do not +recommend this practice. It is better to name the node itself +at the same time that you +write a segment so you can easily make cross references. A large number +of cross references are an especially important feature of a good Info +file.@refill + +After you have inserted an @code{@@node} line, you should immediately +write an @@-command for the chapter or section and insert its name. +Next (and this is important!), put in several index entries. Usually, +you will find at least two and often as many as four or five ways of +referring to the node in the index. Use them all. This will make it +much easier for people to find the node.@refill + +@node Node Line Tips, Node Line Requirements, Writing a Node, node +@comment node-name, next, previous, up +@subsection @code{@@node} Line Tips + +Here are three suggestions: + +@itemize @bullet +@item +Try to pick node names that are informative but short.@refill + +In the Info file, the file name, node name, and pointer names are all +inserted on one line, which may run into the right edge of the window. +(This does not cause a problem with Info, but is ugly.)@refill + +@item +Try to pick node names that differ from each other near the beginnings +of their names. This way, it is easy to use automatic name completion in +Info.@refill + +@item +By convention, node names are capitalized just as they would be for +section or chapter titles---initial and significant words are +capitalized; others are not.@refill +@end itemize + +@node Node Line Requirements, First Node, Node Line Tips, node +@comment node-name, next, previous, up +@subsection @code{@@node} Line Requirements + +@cindex Node line requirements +Here are several requirements for @code{@@node} lines: + +@itemize @bullet +@cindex Unique nodename requirement +@cindex Nodename must be unique +@item +All the node names for a single Info file must be unique.@refill + +Duplicates confuse the Info movement commands. This means, for +example, that if you end every chapter with a summary, you must name +each summary node differently. You cannot just call each one +``Summary''. You may, however, duplicate the titles of chapters, sections, +and the like. Thus you can end each chapter in a book with a section +called ``Summary'', so long as the node names for those sections are all +different.@refill + +@item +A pointer name must be the name of a node.@refill + +The node to which a pointer points may come before or after the +node containing the pointer.@refill + +@cindex @@-command in nodename +@cindex Nodename, cannot contain +@item +You cannot use any of the Texinfo @@-commands in a node name; +@w{@@-commands} confuse Info.@refill + +@need 750 +Thus, the beginning of the section called @code{@@chapter} looks like +this:@refill + +@smallexample +@group +@@node chapter, unnumbered & appendix, makeinfo top, Structuring +@@comment node-name, next, previous, up +@@section @@code@{@@@@chapter@} +@@findex chapter +@end group +@end smallexample + +@cindex Comma in nodename +@cindex Colon in nodename +@cindex Apostrophe in nodename +@item +You cannot use commas, colons, or apostrophes within a node name; these +confuse @TeX{} or the Info formatters.@refill + +@need 700 +For example, the following is a section title: + +@smallexample +@@code@{@@@@unnumberedsec@}, @@code@{@@@@appendixsec@}, @@code@{@@@@heading@} +@end smallexample + +@noindent +The corresponding node name is: + +@smallexample +unnumberedsec appendixsec heading +@end smallexample + +@cindex Case in nodename +@item +Case is significant. +@end itemize + +@node First Node, makeinfo top command, Node Line Requirements, node +@comment node-name, next, previous, up +@subsection The First Node +@cindex @samp{@r{Top}} node is first +@cindex First node + +The first node of a Texinfo file is the `Top' node, except in an +included file (@pxref{Include Files}). + +The `Top' node (which must be named @samp{top} or @samp{Top}) should +have as its `Up' and `Previous' nodes the name of a node in another +file, where there is a menu that leads to this file. Specify the file +name in parentheses. If the file is to be installed directly in the +Info directory file, use @samp{(dir)} as the parent of the `Top' node; +this is short for @samp{(dir)top}, and specifies the `Top' node in the +@file{dir} file, which contains the main menu for Info. For example, +the @code{@@node Top} line of this manual looks like this:@refill + +@example +@@node Top, Overview, (dir), (dir) +@end example + +@noindent +(You may use the Texinfo updating commands or the @code{makeinfo} +utility to insert these `Next' and @samp{(dir)} pointers +automatically.)@refill + +@xref{Install an Info File}, for more information about installing +an Info file in the @file{info} directory.@refill + +The `Top' node contains the main or master menu for the document. + +@node makeinfo top command, Top Node Summary, First Node, node +@comment node-name, next, previous, up +@subsection The @code{@@top} Sectioning Command +@findex top @r{(@@-command)} + +A special sectioning command, @code{@@top}, has been created for use +with the @code{@@node Top} line. The @code{@@top} sectioning command tells +@code{makeinfo} that it marks the `Top' node in the file. It provides +the information that @code{makeinfo} needs to insert node +pointers automatically. Write the @code{@@top} command at the +beginning of the line immediately following the @code{@@node Top} +line. Write the title on the remaining part of the same line as the +@code{@@top} command.@refill + +In Info, the @code{@@top} sectioning command causes the title to appear on a +line by itself, with a line of asterisks inserted underneath.@refill + +In @TeX{} and @code{texinfo-format-buffer}, the @code{@@top} +sectioning command is merely a synonym for @code{@@unnumbered}. +Neither of these formatters require an @code{@@top} command, and do +nothing special with it. You can use @code{@@chapter} or +@code{@@unnumbered} after the @code{@@node Top} line when you use +these formatters. Also, you can use @code{@@chapter} or +@code{@@unnumbered} when you use the Texinfo updating commands to +create or update pointers and menus.@refill + +@node Top Node Summary, , makeinfo top command, node +@subsection The `Top' Node Summary +@cindex @samp{@r{Top}} node summary + +You can help readers by writing a summary in the `Top' node, after the +@code{@@top} line, before the main or master menu. The summary should +briefly describe the document. In Info, this summary will appear just +before the master menu. In a printed manual, this summary will appear +on a page of its own.@refill + +If you do not want the summary to appear on a page of its own in a +printed manual, you can enclose the whole of the `Top' node, including +the @code{@@node Top} line and the @code{@@top} sectioning command line +or other sectioning command line between @code{@@ifinfo} and @code{@@end +ifinfo}. This prevents any of the text from appearing in the printed +output. (@pxref{Conditionals, , Conditionally Visible Text}). You can +repeat the brief description from the `Top' node within @code{@@iftex} +@dots{} @code{@@end iftex} at the beginning of the first chapter, for +those who read the printed manual. This saves paper and may look +neater.@refill + +You should write the version number of the program to which the manual +applies in the summary. This helps the reader keep track of which +manual is for which version of the program. If the manual changes more +frequently than the program or is independent of it, you should also +include an edition number for the manual. (The title page should also +contain this information: see @ref{titlepage, , +@code{@@titlepage}}.)@refill + +@node makeinfo Pointer Creation, , node, Nodes +@section Creating Pointers with @code{makeinfo} +@cindex Creating pointers with @code{makeinfo} +@cindex Pointer creation with @code{makeinfo} +@cindex Automatic pointer creation with @code{makeinfo} + +The @code{makeinfo} program has a feature for automatically creating +node pointers for a hierarchically organized file that lacks +them.@refill + +When you take advantage of this feature, you do not need to write the +`Next', `Previous', and `Up' pointers after the name of a node. +However, you must write a sectioning command, such as @code{@@chapter} +or @code{@@section}, on the line immediately following each truncated +@code{@@node} line. You cannot write a comment line after a node +line; the section line must follow it immediately.@refill + +In addition, you must follow the `Top' @code{@@node} line with a line beginning +with @code{@@top} to mark the `Top' node in the file. @xref{makeinfo +top, , @code{@@top}}. + +Finally, you must write the name of each node (except for the `Top' +node) in a menu that is one or more hierarchical levels above the +node's hierarchical level.@refill + +This node pointer insertion feature in @code{makeinfo} is an +alternative to the menu and pointer creation and update commands in +Texinfo mode. (@xref{Updating Nodes and Menus}.) It is especially +helpful to people who do not use GNU Emacs for writing Texinfo +documents.@refill + +@node Menus, Cross References, Nodes, Top +@comment node-name, next, previous, up +@chapter Menus +@cindex Menus +@findex menu + +@dfn{Menus} contain pointers to subordinate +nodes.@footnote{Menus can carry you to any node, regardless +of the hierarchical structure; even to nodes in a different +Info file. However, the GNU Emacs Texinfo mode updating +commands work only to create menus of subordinate nodes. +Conventionally, cross references are used to refer to other +nodes.} In Info, you use menus to go to such nodes. Menus +have no effect in printed manuals and do not appear in +them.@refill + +By convention, a menu is put at the end of a node since a reader who +uses the menu may not see text that follows it.@refill + +@ifinfo +A node that has a menu should @emph{not} contain much text. If you +have a lot of text and a menu, move most of the text into a new +subnode---all but a few lines.@refill +@end ifinfo +@iftex +@emph{A node that has a menu should not contain much text.} If you +have a lot of text and a menu, move most of the text into a new +subnode---all but a few lines. Otherwise, a reader with a terminal +that displays only a few lines may miss the menu and its associated +text. As a practical matter, you should locate a menu within 20 lines +of the beginning of the node.@refill +@end iftex + +@menu +* Menu Location:: Put a menu in a short node. +* Writing a Menu:: What is a menu? +* Menu Parts:: A menu entry has three parts. +* Less Cluttered Menu Entry:: Two part menu entry. +* Menu Example:: Two and three part menu entries. +* Other Info Files:: How to refer to a different Info file. +@end menu + +@node Menu Location, Writing a Menu, Menus, Menus +@ifinfo +@heading Menus Need Short Nodes +@end ifinfo +@cindex Menu location +@cindex Location of menus +@cindex Nodes for menus are short +@cindex Short nodes for menus + +@ifinfo +A reader can easily see a menu that is close to the beginning of the +node. The node should be short. As a practical matter, you should +locate a menu within 20 lines of the beginning of the node. +Otherwise, a reader with a terminal that displays only a few lines may +miss the menu and its associated text.@refill +@end ifinfo + +The short text before a menu may look awkward in a printed manual. To +avoid this, you can write a menu near the beginning of its node and +follow the menu by an @code{@@node} line, and then an @code{@@heading} +line located within @code{@@ifinfo} and @code{@@end ifinfo}. This way, +the menu, @code{@@node} line, and title appear only in the Info file, +not the printed document.@refill + +For example, the preceding two paragraphs follow an Info-only menu, +@code{@@node} line, and heading, and look like this:@refill + +@example +@group +@@menu +* Menu Location:: Put a menu in a short node. +* Writing a Menu:: What is a menu? +* Menu Parts:: A menu entry has three parts. +* Less Cluttered Menu Entry:: Two part menu entry. +* Menu Example:: Two and three part entries. +* Other Info Files:: How to refer to a different + Info file. +@@end menu + +@@node Menu Location, Writing a Menu, , Menus +@@ifinfo +@@heading Menus Need Short Nodes +@@end ifinfo +@end group +@end example + +The Texinfo file for this document contains more than a dozen +examples of this procedure. One is at the beginning of this chapter; +another is at the beginning of the ``Cross References'' chapter.@refill + +@node Writing a Menu, Menu Parts, Menu Location, Menus +@section Writing a Menu +@cindex Writing a menu +@cindex Menu writing + +A menu consists of an @code{@@menu} command on a line by +itself followed by menu entry lines or menu comment lines +and then by an @code{@@end menu} command on a line by +itself.@refill + +A menu looks like this:@refill + +@example +@group +@@menu +Larger Units of Text + +* Files:: All about handling files. +* Multiples: Buffers. Multiple buffers; editing + several files at once. +@@end menu +@end group +@end example + +In a menu, every line that begins with an @w{@samp{* }} is a +@dfn{menu entry}. (Note the space after the asterisk.) A +line that does not start with an @w{@samp{* }} may also +appear in a menu. Such a line is not a menu entry but is a +menu comment line that appears in the Info file. In +the example above, the line @samp{Larger Units of Text} is a +menu comment line; the two lines starting with @w{@samp{* }} +are menu entries. + +@node Menu Parts, Less Cluttered Menu Entry, Writing a Menu, Menus +@section The Parts of a Menu +@cindex Parts of a menu +@cindex Menu parts +@cindex @code{@@menu} parts + +A menu entry has three parts, only the second of which is +required:@refill + +@enumerate +@item +The menu entry name. + +@item +The name of the node (required). + +@item +A description of the item. +@end enumerate + +The template for a menu entry looks like this:@refill + +@example +* @var{menu-entry-name}: @var{node-name}. @var{description} +@end example + +Follow the menu entry name with a single colon and follow the node name +with tab, comma, period, or newline.@refill + +In Info, a user selects a node with the @kbd{m} (@code{Info-menu}) +command. The menu entry name is what the user types after the @kbd{m} +command.@refill + +The third part of a menu entry is a descriptive phrase or +sentence. Menu entry names and node names are often short; the +description explains to the reader what the node is about. The +description, which is optional, can spread over two or more lines. A +useful description complements the node name rather than repeats +it.@refill + +@node Less Cluttered Menu Entry, Menu Example, Menu Parts, Menus +@comment node-name, next, previous, up +@section Less Cluttered Menu Entry +@cindex Two part menu entry +@cindex Double-colon menu entries +@cindex Menu entries with two colons +@cindex Less cluttered menu entry +@cindex Uncluttered menu entry + +When the menu entry name and node name are the same, you can write +the name immediately after the asterisk and space at the beginning of +the line and follow the name with two colons.@refill + +@need 800 +For example, write + +@example +* Name:: @var{description} +@end example + +@need 800 +@noindent +instead of + +@example +* Name: Name. @var{description} +@end example + +You should use the node name for the menu entry name whenever possible, +since it reduces visual clutter in the menu.@refill + +@node Menu Example, Other Info Files, Less Cluttered Menu Entry, Menus +@comment node-name, next, previous, up +@section A Menu Example +@cindex Menu example +@cindex Example menu + +A menu looks like this in Texinfo:@refill + +@example +@group +@@menu +* menu entry name: Node name. A short description. +* Node name:: This form is preferred. +@@end menu +@end group +@end example + +@need 800 +@noindent +This produces: + +@example +@group +* menu: + +* menu entry name: Node name. A short description. +* Node name:: This form is preferred. +@end group +@end example + +@need 700 +Here is an example as you might see it in a Texinfo file:@refill + +@example +@group +@@menu +Larger Units of Text + +* Files:: All about handling files. +* Multiples: Buffers. Multiple buffers; editing + several files at once. +@@end menu +@end group +@end example + +@need 800 +@noindent +This produces: + +@example +@group +* menu: +Larger Units of Text + +* Files:: All about handling files. +* Multiples: Buffers. Multiple buffers; editing + several files at once. +@end group +@end example + +In this example, the menu has two entries. @samp{Files} is both a menu +entry name and the name of the node referred to by that name. +@samp{Multiples} is the menu entry name; it refers to the node named +@samp{Buffers}. The line @samp{Larger Units of Text} is a comment; it +appears in the menu, but is not an entry.@refill + +Since no file name is specified with either @samp{Files} or +@samp{Buffers}, they must be the names of nodes in the same Info file +(@pxref{Other Info Files, , Referring to Other Info Files}).@refill + +@node Other Info Files, , Menu Example, Menus +@comment node-name, next, previous, up +@section Referring to Other Info Files +@cindex Referring to other Info files +@cindex Nodes in other Info files +@cindex Other Info files' nodes +@cindex Going to other Info files' nodes +@cindex Info; other files' nodes + +You can create a menu entry that enables a reader in Info to go to a +node in another Info file by writing the file name in parentheses just +before the node name. In this case, you should use the three-part menu +entry format, which saves the reader from having to type the file +name.@refill + +@need 800 +The format looks like this:@refill + +@example +@group +@@menu +* @var{first-entry-name}:(@var{filename})@var{nodename}. @var{description} +* @var{second-entry-name}:(@var{filename})@var{second-node}. @var{description} +@@end menu +@end group +@end example + +For example, to refer directly to the @samp{Outlining} and +@samp{Rebinding} nodes in the @cite{Emacs Manual}, you would write a +menu like this:@refill + +@example +@group +@@menu +* Outlining: (emacs)Outline Mode. The major mode for + editing outlines. +* Rebinding: (emacs)Rebinding. How to redefine the + meaning of a key. +@@end menu +@end group +@end example + +If you do not list the node name, but only name the file, then Info +presumes that you are referring to the `Top' node.@refill + +The @file{dir} file that contains the main menu for Info has menu +entries that list only file names. These take you directly to the `Top' +nodes of each Info document. (@xref{Install an Info File}.)@refill + +@need 700 +For example: + +@example +@group +* Info: (info). Documentation browsing system. +* Emacs: (emacs). The extensible, self-documenting + text editor. +@end group +@end example + +@noindent +(The @file{dir} top level directory for the Info system is an Info file, +not a Texinfo file, but a menu entry looks the same in both types of +file.)@refill + +Note that the GNU Emacs Texinfo mode menu updating commands only work +with nodes within the current buffer, so you cannot use them to create +menus that refer to other files. You must write such menus by hand.@refill + +@node Cross References, Marking Text, Menus, Top +@comment node-name, next, previous, up +@chapter Cross References +@cindex Making cross references +@cindex Cross references +@cindex References + +@dfn{Cross references} are used to refer the reader to other parts of the +same or different Texinfo files. In Texinfo, nodes are the +places to which cross references can refer.@refill + +@menu +* References:: What cross references are for. +* Cross Reference Commands:: A summary of the different commands. +* Cross Reference Parts:: A cross reference has several parts. +* xref:: Begin a reference with `See' @dots{} +* Top Node Naming:: How to refer to the beginning of another file. +* ref:: A reference for the last part of a sentence. +* pxref:: How to write a parenthetical cross reference. +* inforef:: How to refer to an Info-only file. +@end menu + +@node References, Cross Reference Commands, Cross References, Cross References +@ifinfo +@heading What References Are For +@end ifinfo + +Often, but not always, a printed document should be designed so that +it can be read sequentially. People tire of flipping back and forth +to find information that should be presented to them as they need +it.@refill + +However, in any document, some information will be too detailed for +the current context, or incidental to it; use cross references to +provide access to such information. Also, an on-line help system or a +reference manual is not like a novel; few read such documents in +sequence from beginning to end. Instead, people look up what they +need. For this reason, such creations should contain many cross +references to help readers find other information that they may not +have read.@refill + +In a printed manual, a cross reference results in a page reference, +unless it is to another manual altogether, in which case the cross +reference names that manual.@refill + +In Info, a cross reference results in an entry that you can follow using +the Info @samp{f} command. (@inforef{Help-Adv, Some advanced Info +commands, info}.)@refill + +The various cross reference commands use nodes to define cross +reference locations. This is evident in Info, in which a cross +reference takes you to the specified node. @TeX{} also uses nodes to +define cross reference locations, but the action is less obvious. When +@TeX{} generates a @sc{dvi} file, it records nodes' page numbers and +uses the page numbers in making references. Thus, if you are writing +a manual that will only be printed, and will not be used on-line, you +must nonetheless write @code{@@node} lines to name the places to which +you make cross references.@refill + +@need 800 +@node Cross Reference Commands, Cross Reference Parts, References, Cross References +@comment node-name, next, previous, up +@section Different Cross Reference Commands +@cindex Different cross reference commands + +There are four different cross reference commands:@refill + +@table @code +@item @@xref +Used to start a sentence in the printed manual saying @w{`See @dots{}'} +or an Info cross-reference saying @samp{*Note @var{name}: @var{node}.}. + +@item @@ref +Used within or, more often, at the end of a sentence; same as +@code{@@xref} for Info; produces just the reference in the printed +manual without a preceding `See'.@refill + +@item @@pxref +Used within parentheses to make a reference that suits both an Info +file and a printed book. Starts with a lower case `see' within the +printed manual. (@samp{p} is for `parenthesis'.)@refill + +@item @@inforef +Used to make a reference to an Info file for which there is no printed +manual.@refill +@end table + +@noindent +(The @code{@@cite} command is used to make references to books and +manuals for which there is no corresponding Info file and, therefore, +no node to which to point. @xref{cite, , @code{@@cite}}.)@refill + +@node Cross Reference Parts, xref, Cross Reference Commands, Cross References +@comment node-name, next, previous, up +@section Parts of a Cross Reference +@cindex Cross reference parts +@cindex Parts of a cross reference + +A cross reference command requires only one argument, which is the +name of the node to which it refers. But a cross reference command +may contain up to four additional arguments. By using these +arguments, you can provide a cross reference name for Info, a topic +description or section title for the printed output, the name of a +different Info file, and the name of a different printed +manual.@refill + +Here is a simple cross reference example:@refill + +@example +@@xref@{Node name@}. +@end example + +@noindent +which produces + +@example +*Note Node name::. +@end example + +@noindent +and + +@quotation +See Section @var{nnn} [Node name], page @var{ppp}. +@end quotation + +@need 700 +Here is an example of a full five-part cross reference:@refill + +@example +@group +@@xref@{Node name, Cross Reference Name, Particular Topic, +info-file-name, A Printed Manual@}, for details. +@end group +@end example + +@noindent +which produces + +@example +*Note Cross Reference Name: (info-file-name)Node name, +for details. +@end example + +@noindent +in Info and + +@quotation +See section ``Particular Topic'' in @i{A Printed Manual}, for details. +@end quotation + +@noindent +in a printed book. + +The five possible arguments for a cross reference are:@refill + +@enumerate +@item +The node name (required). This is the node to which the +cross reference takes you. In a printed document, the location of the +node provides the page reference only for references within the same +document.@refill + +@item +The cross reference name for the Info reference, if it is to be different +from the node name. If you include this argument, it argument becomes +the first part of the cross reference. It is usually omitted.@refill + +@item +A topic description or section name. Often, this is the title of the +section. This is used as the name of the reference in the printed +manual. If omitted, the node name is used.@refill + +@item +The name of the Info file in which the reference is located, if it is +different from the current file.@refill + +@item +The name of a printed manual from a different Texinfo file.@refill +@end enumerate + +The template for a full five argument cross reference looks like +this:@refill + +@example +@group +@@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}, +@var{info-file-name}, @var{printed-manual-title}@}. +@end group +@end example + +Cross references with one, two, three, four, and five arguments are +described separately following the description of @code{@@xref}.@refill + +Write a node name in a cross reference in exactly the same way as in +the @code{@@node} line, including the same capitalization; otherwise, the +formatters may not find the reference.@refill + +You can write cross reference commands within a paragraph, but note +how Info and @TeX{} format the output of each of the various commands: +write @code{@@xref} at the beginning of a sentence; write +@code{@@pxref} only within parentheses, and so on.@refill + +@node xref, Top Node Naming, Cross Reference Parts, Cross References +@comment node-name, next, previous, up +@section @code{@@xref} +@findex xref +@cindex Cross references using @code{@@xref} +@cindex References using @code{@@xref} + +The @code{@@xref} command generates a cross reference for the +beginning of a sentence. The Info formatting commands convert it into +an Info cross reference, which the Info @samp{f} command can use to +bring you directly to another node. The @TeX{} typesetting commands +convert it into a page reference, or a reference to another book or +manual.@refill + +@menu +* Reference Syntax:: What a reference looks like and requires. +* One Argument:: @code{@@xref} with one argument. +* Two Arguments:: @code{@@xref} with two arguments. +* Three Arguments:: @code{@@xref} with three arguments. +* Four and Five Arguments:: @code{@@xref} with four and five arguments. +@end menu + +@node Reference Syntax, One Argument, xref, xref +@ifinfo +@subheading What a Reference Looks Like and Requires +@end ifinfo + +Most often, an Info cross reference looks like this:@refill + +@example +*Note @var{node-name}::. +@end example + +@noindent +or like this + +@example +*Note @var{cross-reference-name}: @var{node-name}. +@end example + +@noindent +In @TeX{}, a cross reference looks like this: + +@example +See Section @var{section-number} [@var{node-name}], page @var{page}. +@end example + +@noindent +or like this + +@example +See Section @var{section-number} [@var{title-or-topic}], page @var{page}. +@end example + +The @code{@@xref} command does not generate a period or comma to end +the cross reference in either the Info file or the printed output. +You must write that period or comma yourself; otherwise, Info will not +recognize the end of the reference. (The @code{@@pxref} command works +differently. @xref{pxref, , @code{@@pxref}}.)@refill + +@quotation +@strong{Please note:} A period or comma @strong{must} follow the closing +brace of an @code{@@xref}. It is required to terminate the cross +reference. This period or comma will appear in the output, both in +the Info file and in the printed manual.@refill +@end quotation + +@code{@@xref} must refer to an Info node by name. Use @code{@@node} +to define the node (@pxref{Writing a Node}).@refill + +@code{@@xref} is followed by several arguments inside braces, separated by +commas. Whitespace before and after these commas is ignored.@refill + +A cross reference requires only the name of a node; but it may contain +up to four additional arguments. Each of these variations produces a +cross reference that looks somewhat different.@refill + +@quotation +@strong{Please note:} Commas separate arguments in a cross reference; +avoid including them in the title or other part lest the formatters +mistake them for separators.@refill +@end quotation + +@node One Argument, Two Arguments, Reference Syntax, xref +@subsection @code{@@xref} with One Argument + +The simplest form of @code{@@xref} takes one argument, the name of +another node in the same Info file. The Info formatters produce +output that the Info readers can use to jump to the reference; @TeX{} +produces output that specifies the page and section number for you.@refill + +@need 700 +@noindent +For example, + +@example +@@xref@{Tropical Storms@}. +@end example + +@noindent +produces + +@example +*Note Tropical Storms::. +@end example + +@noindent +and + +@quotation +See Section 3.1 [Tropical Storms], page 24. +@end quotation + +@noindent +(Note that in the preceding example the closing brace is followed by a +period.)@refill + +You can write a clause after the cross reference, like this:@refill + +@example +@@xref@{Tropical Storms@}, for more info. +@end example + +@noindent +which produces + +@example +*Note Tropical Storms::, for more info. +@end example + +@quotation +See Section 3.1 [Tropical Storms], page 24, for more info. +@end quotation + +@noindent +(Note that in the preceding example the closing brace is followed by a +comma, and then by the clause, which is followed by a period.)@refill + +@node Two Arguments, Three Arguments, One Argument, xref +@subsection @code{@@xref} with Two Arguments + +With two arguments, the second is used as the name of the Info cross +reference, while the first is still the name of the node to which the +cross reference points.@refill + +@need 750 +@noindent +The template is like this: + +@example +@@xref@{@var{node-name}, @var{cross-reference-name}@}. +@end example + +@need 700 +@noindent +For example, + +@example +@@xref@{Electrical Effects, Lightning@}. +@end example + +@noindent +produces: + +@example +*Note Lightning: Electrical Effects. +@end example + +@noindent +and + +@quotation +See Section 5.2 [Electrical Effects], page 57. +@end quotation + +@noindent +(Note that in the preceding example the closing brace is followed by a +period; and that the node name is printed, not the cross reference name.)@refill + +You can write a clause after the cross reference, like this:@refill + +@example +@@xref@{Electrical Effects, Lightning@}, for more info. +@end example + +@noindent +which produces +@example +*Note Lightning: Electrical Effects, for more info. +@end example + +@noindent +and + +@quotation +See Section 5.2 [Electrical Effects], page 57, for more info. +@end quotation + +@noindent +(Note that in the preceding example the closing brace is followed by a +comma, and then by the clause, which is followed by a period.)@refill + +@node Three Arguments, Four and Five Arguments, Two Arguments, xref +@subsection @code{@@xref} with Three Arguments + +A third argument replaces the node name in the @TeX{} output. The third +argument should be the name of the section in the printed output, or +else state the topic discussed by that section. Often, you will want to +use initial upper case letters so it will be easier to read when the +reference is printed. Use a third argument when the node name is +unsuitable because of syntax or meaning.@refill + +Remember to avoid placing a comma within the title or topic section of +a cross reference, or within any other section. The formatters divide +cross references into arguments according to the commas; a comma +within a title or other section will divide it into two arguments. In +a reference, you need to write a title such as ``Clouds, Mist, and +Fog'' without the commas.@refill + +Also, remember to write a comma or period after the closing brace of a +@code{@@xref} to terminate the cross reference. In the following +examples, a clause follows a terminating comma.@refill + + +@need 750 +@noindent +The template is like this: + +@example +@group +@@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}@}. +@end group +@end example + +@need 700 +@noindent +For example, + +@example +@group +@@xref@{Electrical Effects, Lightning, Thunder and Lightning@}, +for details. +@end group +@end example + +@noindent +produces + +@example +*Note Lightning: Electrical Effects, for details. +@end example + +@noindent +and + +@quotation +See Section 5.2 [Thunder and Lightning], page 57, for details. +@end quotation + +If a third argument is given and the second one is empty, then the +third argument serves both. (Note how two commas, side by side, mark +the empty second argument.)@refill + +@example +@group +@@xref@{Electrical Effects, , Thunder and Lightning@}, +for details. +@end group +@end example + +@noindent +produces + +@example +*Note Thunder and Lightning: Electrical Effects, for details. +@end example + +@noindent +and + +@quotation +See Section 5.2 [Thunder and Lightning], page 57, for details. +@end quotation + +As a practical matter, it is often best to write cross references with +just the first argument if the node name and the section title are the +same, and with the first and third arguments if the node name and title +are different.@refill + +Here are several examples from @cite{The GAWK Manual}:@refill + +@smallexample +@@xref@{Sample Program@}. +@@xref@{Glossary@}. +@@xref@{Case-sensitivity, ,Case-sensitivity in Matching@}. +@@xref@{Close Output, , Closing Output Files and Pipes@}, + for more information. +@@xref@{Regexp, , Regular Expressions as Patterns@}. +@end smallexample + +@node Four and Five Arguments, , Three Arguments, xref +@subsection @code{@@xref} with Four and Five Arguments + +In a cross reference, a fourth argument specifies the name of another +Info file, different from the file in which the reference appears, and +a fifth argument specifies its title as a printed manual.@refill + +Remember that a comma or period must follow the closing brace of an +@code{@@xref} command to terminate the cross reference. In the +following examples, a clause follows a terminating comma.@refill + +@need 800 +@noindent +The template is: + +@example +@group +@@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}, +@var{info-file-name}, @var{printed-manual-title}@}. +@end group +@end example + +@need 700 +@noindent +For example, + +@example +@@xref@{Electrical Effects, Lightning, Thunder and Lightning, +weather, An Introduction to Meteorology@}, for details. +@end example + +@noindent +produces + +@example +*Note Lightning: (weather)Electrical Effects, for details. +@end example + +@noindent +The name of the Info file is enclosed in parentheses and precedes +the name of the node. + +@noindent +In a printed manual, the reference looks like this:@refill + +@quotation +See section ``Thunder and Lightning'' in @i{An Introduction to +Meteorology}, for details. +@end quotation + +@noindent +The title of the printed manual is typeset in italics; and the +reference lacks a page number since @TeX{} cannot know to which page a +reference refers when that reference is to another manual.@refill + +Often, you will leave out the second argument when you use the long +version of @code{@@xref}. In this case, the third argument, the topic +description, will be used as the cross reference name in Info.@refill + +@noindent +The template looks like this: + +@example +@@xref@{@var{node-name}, , @var{title-or-topic}, @var{info-file-name}, +@var{printed-manual-title}@}, for details. +@end example + +@noindent +which produces + +@example +*Note @var{title-or-topic}: (@var{info-file-name})@var{node-name}, for details. +@end example + +@noindent +and + +@quotation +See section @var{title-or-topic} in @var{printed-manual-title}, for details. +@end quotation + +@need 700 +@noindent +For example, + +@example +@@xref@{Electrical Effects, , Thunder and Lightning, +weather, An Introduction to Meteorology@}, for details. +@end example + +@noindent +produces + +@example +@group +*Note Thunder and Lightning: (weather)Electrical Effects, +for details. +@end group +@end example + +@noindent +and + +@quotation +See section ``Thunder and Lightning'' in @i{An Introduction to +Meteorology}, for details. +@end quotation + +On rare occasions, you may want to refer to another Info file that +is within a single printed manual---when multiple Texinfo files are +incorporated into the same @TeX{} run but make separate Info files. +In this case, you need to specify only the fourth argument, and not +the fifth.@refill + +@node Top Node Naming, ref, xref, Cross References +@section Naming a `Top' Node +@cindex Naming a `Top' Node in references +@cindex @samp{@r{Top}} node naming for references + +In a cross reference, you must always name a node. This means that in +order to refer to a whole manual, you must identify the `Top' node by +writing it as the first argument to the @code{@@xref} command. (This +is different from the way you write a menu entry; see @ref{Other Info +Files, , Referring to Other Info Files}.) At the same time, to +provide a meaningful section topic or title in the printed cross +reference (instead of the word `Top'), you must write an appropriate +entry for the third argument to the @code{@@xref} command. +@refill + +@noindent +Thus, to make a cross reference to @cite{The GNU Make Manual}, +write:@refill + +@example +@@xref@{Top, , Overview, make, The GNU Make Manual@}. +@end example + +@noindent +which produces + +@example +*Note Overview: (make)Top. +@end example + +@noindent +and + +@quotation +See section ``Overview'' in @i{The GNU Make Manual}. +@end quotation + +@noindent +In this example, @samp{Top} is the name of the first node, and +@samp{Overview} is the name of the first section of the manual.@refill +@node ref, pxref, Top Node Naming, Cross References +@comment node-name, next, previous, up +@section @code{@@ref} +@cindex Cross references using @code{@@ref} +@cindex References using @code{@@ref} +@findex ref + +@code{@@ref} is nearly the same as @code{@@xref} except that it does +not generate a `See' in the printed output, just the reference itself. +This makes it useful as the last part of a sentence.@refill + +@need 700 +@noindent +For example, + +@example +For more information, see @@ref@{Hurricanes@}. +@end example + +@noindent +produces + +@example +For more information, see *Note Hurricanes. +@end example + +@noindent +and + +@quotation +For more information, see Section 8.2 [Hurricanes], page 123. +@end quotation + +The @code{@@ref} command sometimes leads writers to express themselves +in a manner that is suitable for a printed manual but looks awkward +in the Info format. Bear in mind that your audience will be using +both the printed and the Info format.@refill + +@need 800 +@noindent +For example, + +@example +@group +Sea surges are described in @@ref@{Hurricanes@}. +@end group +@end example + +@need 800 +@noindent +produces + +@quotation +Sea surges are described in Section 6.7 [Hurricanes], page 72. +@end quotation + +@need 800 +@noindent +in a printed document, and the following in Info: + +@example +Sea surges are described in *Note Hurricanes::. +@end example + +@quotation +@strong{Caution:} You @emph{must} write a period or comma immediately +after an @code{@@ref} command with two or more arguments. Otherwise, +Info will not find the end of the cross reference entry and its +attempt to follow the cross reference will fail. As a general rule, +you should write a period or comma after every @code{@@ref} command. +This looks best in both the printed and the Info output.@refill +@end quotation + +@node pxref, inforef, ref, Cross References +@comment node-name, next, previous, up +@section @code{@@pxref} +@cindex Cross references using @code{@@pxref} +@cindex References using @code{@@pxref} +@findex pxref + +The parenthetical reference command, @code{@@pxref}, is nearly the +same as @code{@@xref}, but you use it @emph{only} inside parentheses +and you do @emph{not} type a comma or period after the command's +closing brace. The command differs from @code{@@xref} in two +ways:@refill + +@enumerate +@item +@TeX{} typesets the reference for the printed manual with a lower case +`see' rather than an upper case `See'.@refill + +@item +The Info formatting commands automatically end the reference with a +closing colon or period.@refill +@end enumerate + +Because one type of formatting automatically inserts closing +punctuation and the other does not, you should use @code{@@pxref} +@emph{only} inside parentheses as part of another sentence. Also, you +yourself should not insert punctuation after the reference, as you do +with @code{@@xref}.@refill + +@code{@@pxref} is designed so that the output looks right and works +right between parentheses both in printed output and in an Info file. +In a printed manual, a closing comma or period should not follow a +cross reference within parentheses; such punctuation is wrong. But in +an Info file, suitable closing punctuation must follow the cross +reference so Info can recognize its end. @code{@@pxref} spares you +the need to use complicated methods to put a terminator into one form +of the output and not the other.@refill + +@noindent +With one argument, a parenthetical cross reference looks like +this:@refill + +@example +@dots{} storms cause flooding (@@pxref@{Hurricanes@}) @dots{} +@end example + +@need 800 +@noindent +which produces + +@example +@group +@dots{} storms cause flooding (*Note Hurricanes::) @dots{} +@end group +@end example + +@noindent +and + +@quotation +@dots{} storms cause flooding (see Section 6.7 [Hurricanes], page 72) @dots{} +@end quotation + +With two arguments, a parenthetical cross reference has this +template:@refill + +@example +@dots{} (@@pxref@{@var{node-name}, @var{cross-reference-name}@}) @dots{} +@end example + +@noindent +which produces + +@example +@dots{} (*Note @var{cross-reference-name}: @var{node-name}.) @dots{} +@end example + +@noindent +and + +@need 1500 +@quotation +@dots{} (see Section @var{nnn} [@var{node-name}], page @var{ppp}) @dots{} +@end quotation + +@code{@@pxref} can be used with up to five arguments just like +@code{@@xref} (@pxref{xref, , @code{@@xref}}).@refill + +@quotation +@strong{Please note:} Use @code{@@pxref} only as a parenthetical +reference. Do not try to use @code{@@pxref} as a clause in a sentence. +It will look bad in either the Info file, the printed output, or +both.@refill + +Also, parenthetical cross references look best at the ends of sentences. +Although you may write them in the middle of a sentence, that location +breaks up the flow of text.@refill +@end quotation + +@node inforef, , pxref, Cross References +@comment node-name, next, previous, up +@section @code{@@inforef} +@cindex Cross references using @code{@@inforef} +@cindex References using @code{@@inforef} +@findex inforef + +@code{@@inforef} is used for cross references to Info files for which +there are no printed manuals. Even in a printed manual, +@code{@@inforef} generates a reference directing the user to look in +an Info file.@refill + +The command takes either two or three arguments, in the following +order:@refill + +@enumerate +@item +The node name. + +@item +The cross reference name (optional). + +@item +The Info file name. +@end enumerate + +@noindent +Separate the arguments with commas, as with @code{@@xref}. Also, you +must terminate the reference with a comma or period after the +@samp{@}}, as you do with @code{@@xref}.@refill + +@noindent +The template is: + +@example +@@inforef@{@var{node-name}, @var{cross-reference-name}, @var{info-file-name}@}, +@end example + +@need 800 +@noindent +Thus, + +@example +@group +@@inforef@{Expert, Advanced Info commands, info@}, +for more information. +@end group +@end example + +@need 800 +@noindent +produces + +@example +@group +*Note Advanced Info commands: (info)Expert, +for more information. +@end group +@end example + +@need 800 +@noindent +and + +@quotation +See Info file @file{info}, node @samp{Expert}, for more information. +@end quotation + +@need 800 +@noindent +Similarly, + +@example +@group +@@inforef@{Expert, , info@}, for more information. +@end group +@end example + +@need 800 +@noindent +produces + +@example +*Note (info)Expert::, for more information. +@end example + +@need 800 +@noindent +and + +@quotation +See Info file @file{info}, node @samp{Expert}, for more information. +@end quotation + +The converse of @code{@@inforef} is @code{@@cite}, which is used to +refer to printed works for which no Info form exists. @xref{cite, , +@code{@@cite}}.@refill + +@node Marking Text, Quotations and Examples, Cross References, Top +@comment node-name, next, previous, up +@chapter Marking Words and Phrases +@cindex Paragraph, marking text within +@cindex Marking words and phrases +@cindex Words and phrases, marking them +@cindex Marking text within a paragraph + +In Texinfo, you can mark words and phrases in a variety of ways. +The Texinfo formatters use this information to determine how to +highlight the text. +You can specify, for example, whether a word or phrase is a +defining occurrence, a metasyntactic variable, or a symbol used in a +program. Also, you can emphasize text.@refill + +@menu +* Indicating:: How to indicate definitions, files, etc. +* Emphasis:: How to emphasize text. +@end menu + +@node Indicating, Emphasis, Marking Text, Marking Text +@comment node-name, next, previous, up +@section Indicating Definitions, Commands, etc. +@cindex Highlighting text +@cindex Indicating commands, definitions, etc. + +Texinfo has commands for indicating just what kind of object a piece of +text refers to. For example, metasyntactic variables are marked by +@code{@@var}, and code by @code{@@code}. Since the pieces of text are +labelled by commands that tell what kind of object they are, it is easy +to change the way the Texinfo formatters prepare such text. (Texinfo is +an @emph{intentional} formatting language rather than a @emph{typesetting} +formatting language.)@refill + +For example, in a printed manual, +code is usually illustrated in a typewriter font; +@code{@@code} tells @TeX{} to typeset this text in this font. But it +would be easy to change the way @TeX{} highlights code to use another +font, and this change would not effect how keystroke examples are +highlighted. If straight typesetting commands were used in the body +of the file and you wanted to make a change, you would need to check +every single occurrence to make sure that you were changing code and +not something else that should not be changed.@refill + +@menu +* Useful Highlighting:: Highlighting provides useful information. +* code:: How to indicate code. +* kbd:: How to show keyboard input. +* key:: How to specify keys. +* samp:: How to show a literal sequence of characters. +* var:: How to indicate a metasyntactic variable. +* file:: How to indicate the name of a file. +* dfn:: How to specify a definition. +* cite:: How to refer to a book that is not in Info. +* url:: How to indicate a world wide web reference. +* email:: How to indicate an electronic mail address. +@end menu + +@node Useful Highlighting, code, Indicating, Indicating +@ifinfo +@subheading Highlighting Commands are Useful +@end ifinfo + +The highlighting commands can be used to generate useful information +from the file, such as lists of functions or file names. It is +possible, for example, to write a program in Emacs Lisp (or a keyboard +macro) to insert an index entry after every paragraph that contains +words or phrases marked by a specified command. You could do this to +construct an index of functions if you had not already made the +entries.@refill + +The commands serve a variety of purposes:@refill + +@table @code +@item @@code@{@var{sample-code}@} +Indicate text that is a literal example of a piece of a program.@refill + +@item @@kbd@{@var{keyboard-characters}@} +Indicate keyboard input.@refill + +@item @@key@{@var{key-name}@} +Indicate the conventional name for a key on a keyboard.@refill + +@item @@samp@{@var{text}@} +Indicate text that is a literal example of a sequence of characters.@refill + +@item @@var@{@var{metasyntactic-variable}@} +Indicate a metasyntactic variable.@refill + +@item @@url@{@var{uniform-resource-locator}@} +Indicate a uniform resource locator for the World Wide Web. + +@item @@file@{@var{file-name}@} +Indicate the name of a file.@refill + +@item @@email@{@var{email-address}@} +Indicate an electronic mail address. + +@item @@dfn@{@var{term}@} +Indicate the introductory or defining use of a term.@refill + +@item @@cite@{@var{reference}@} +Indicate the name of a book.@refill + +@ignore +@item @@ctrl@{@var{ctrl-char}@} +Use for an @sc{ascii} control character.@refill +@end ignore +@end table + +@node code, kbd, Useful Highlighting, Indicating +@comment node-name, next, previous, up +@subsection @code{@@code}@{@var{sample-code}@} +@findex code + +Use the @code{@@code} command to indicate text that is a piece of a +program and which consists of entire syntactic tokens. Enclose the +text in braces.@refill + +Thus, you should use @code{@@code} for an expression in a program, for +the name of a variable or function used in a program, or for a +keyword. Also, you should use @code{@@code} for the name of a +program, such as @code{diff}, that is a name used in the machine. (You +should write the name of a program in the ordinary text font if you +regard it as a new English word, such as `Emacs' or `Bison'.)@refill + +Use @code{@@code} for environment variables such as @code{TEXINPUTS}, +and other variables.@refill + +Use @code{@@code} for command names in command languages that +resemble programming languages, such as Texinfo or the shell. +For example, @code{@@code} and @code{@@samp} are produced by writing +@samp{@@code@{@@@@code@}} and @samp{@@code@{@@@@samp@}} in the Texinfo +source, respectively.@refill + +Note, however, that you should not use @code{@@code} for shell options +such as @samp{-c} when such options stand alone. (Use @code{@@samp}.) +Also, an entire shell command often looks better if written using +@code{@@samp} rather than @code{@@code}. In this case, the rule is to +choose the more pleasing format.@refill + +It is incorrect to alter the case of a word inside an @code{@@code} +command when it appears at the beginning of a sentence. Most computer +languages are case sensitive. In C, for example, @code{Printf} is +different from the identifier @code{printf}, and most likely is a +misspelling of it. Even in languages which are not case sensitive, it +is confusing to a human reader to see identifiers spelled in different +ways. Pick one spelling and always use that. If you do not want to +start a sentence with a command written all in lower case, you should +rearrange the sentence.@refill + +Do not use the @code{@@code} command for a string of characters shorter +than a syntactic token. If you are writing about @samp{TEXINPU}, which +is just a part of the name for the @code{TEXINPUTS} environment +variable, you should use @code{@@samp}.@refill + +In particular, you should not use the @code{@@code} command when writing +about the characters used in a token; do not, for example, use +@code{@@code} when you are explaining what letters or printable symbols +can be used in the names of functions. (Use @code{@@samp}.) Also, you +should not use @code{@@code} to mark text that is considered input to +programs unless the input is written in a language that is like a +programming language. For example, you should not use @code{@@code} for +the keystroke commands of GNU Emacs (use @code{@@kbd} instead) although +you may use @code{@@code} for the names of the Emacs Lisp functions that +the keystroke commands invoke.@refill + +In the printed manual, @code{@@code} causes @TeX{} to typeset the +argument in a typewriter face. In the Info file, it causes the Info +formatting commands to use single quotation marks around the text. + +@need 700 +For example, + +@example +Use @@code@{diff@} to compare two files. +@end example + +@noindent +produces this in the printed manual:@refill + +@quotation +Use @code{diff} to compare two files. +@end quotation +@iftex + +@noindent +and this in the Info file:@refill + +@example +Use `diff' to compare two files. +@end example +@end iftex + +@node kbd, key, code, Indicating +@comment node-name, next, previous, up +@subsection @code{@@kbd}@{@var{keyboard-characters}@} +@findex kbd + +Use the @code{@@kbd} command for characters of input to be typed by +users. For example, to refer to the characters @kbd{M-a}, +write@refill + +@example +@@kbd@{M-a@} +@end example + +@noindent +and to refer to the characters @kbd{M-x shell}, write@refill + +@example +@@kbd@{M-x shell@} +@end example + +The @code{@@kbd} command has the same effect as @code{@@code} in Info, +but may produce a different font in a printed manual.@refill + +You can embed another @@-command inside the braces of an @code{@@kbd} +command. Here, for example, is the way to describe a command that +would be described more verbosely as ``press an @samp{r} and then +press the @key{RET} key'':@refill + +@example +@@kbd@{r @@key@{RET@}@} +@end example + +@noindent +This produces: @kbd{r @key{RET}} + +You also use the @code{@@kbd} command if you are spelling out the letters +you type; for example:@refill + +@example +To give the @@code@{logout@} command, +type the characters @@kbd@{l o g o u t @@key@{RET@}@}. +@end example + +@noindent +This produces: + +@quotation +To give the @code{logout} command, +type the characters @kbd{l o g o u t @key{RET}}. +@end quotation + +(Also, this example shows that you can add spaces for clarity. If you +really want to mention a space character as one of the characters of +input, write @kbd{@@key@{SPC@}} for it.)@refill + +@node key, samp, kbd, Indicating +@comment node-name, next, previous, up +@subsection @code{@@key}@{@var{key-name}@} +@findex key + +Use the @code{@@key} command for the conventional name for a key on a +keyboard, as in:@refill + +@example +@@key@{RET@} +@end example + +You can use the @code{@@key} command within the argument of an +@code{@@kbd} command when the sequence of characters to be typed +includes one or more keys that are described by name.@refill + +@need 700 +For example, to produce @kbd{C-x @key{ESC}} you would type:@refill + +@example +@@kbd@{C-x @@key@{ESC@}@} +@end example + +Here is a list of the recommended names for keys: +@cindex Recommended names for keys +@cindex Keys, recommended names +@cindex Names recommended for keys +@cindex Abbreviations for keys + +@quotation +@table @t +@item SPC +Space +@item RET +Return +@item LFD +Linefeed (however, since most keyboards nowadays do not have a Linefeed key, +it might be better to call this character @kbd{C-j}. +@item TAB +Tab +@item BS +Backspace +@item ESC +Escape +@item DEL +Delete +@item SHIFT +Shift +@item CTRL +Control +@item META +Meta +@end table +@end quotation + +@cindex META key +There are subtleties to handling words like `meta' or `ctrl' that are +names of shift keys. When mentioning a character in which the shift key +is used, such as @kbd{Meta-a}, use the @code{@@kbd} command alone; do +not use the @code{@@key} command; but when you are referring to the +shift key in isolation, use the @code{@@key} command. For example, +write @samp{@@kbd@{Meta-a@}} to produce @kbd{Meta-a} and +@samp{@@key@{META@}} to produce @key{META}. + +@c I don't think this is a good explanation. +@c I think it will puzzle readers more than it clarifies matters. -- rms. +@c In other words, use @code{@@kbd} for what you do, and use @code{@@key} +@c for what you talk about: ``Press @code{@@kbd@{M-a@}} to move point to +@c the beginning of the sentence. The @code{@@key@{META@}} key is often in +@c the lower left of the keyboard.''@refill + +@node samp, var, key, Indicating +@comment node-name, next, previous, up +@subsection @code{@@samp}@{@var{text}@} +@findex samp + +Use the @code{@@samp} command to indicate text that is a literal example +or `sample' of a sequence of characters in a file, string, pattern, etc. +Enclose the text in braces. The argument appears within single +quotation marks in both the Info file and the printed manual; in +addition, it is printed in a fixed-width font.@refill + +@example +To match @@samp@{foo@} at the end of the line, +use the regexp @@samp@{foo$@}. +@end example + +@noindent +produces + +@quotation +To match @samp{foo} at the end of the line, use the regexp +@samp{foo$}.@refill +@end quotation + +Any time you are referring to single characters, you should use +@code{@@samp} unless @code{@@kbd} is more appropriate. Use +@code{@@samp} for the names of command-line options. Also, you may use +@code{@@samp} for entire statements in C and for entire shell +commands---in this case, @code{@@samp} often looks better than +@code{@@code}. Basically, @code{@@samp} is a catchall for whatever is +not covered by @code{@@code}, @code{@@kbd}, or @code{@@key}.@refill + +Only include punctuation marks within braces if they are part of the +string you are specifying. Write punctuation marks outside the braces +if those punctuation marks are part of the English text that surrounds +the string. In the following sentence, for example, the commas and +period are outside of the braces:@refill + +@example +@group +In English, the vowels are @@samp@{a@}, @@samp@{e@}, +@@samp@{i@}, @@samp@{o@}, @@samp@{u@}, and sometimes +@@samp@{y@}. +@end group +@end example + +@noindent +This produces: + +@quotation +In English, the vowels are @samp{a}, @samp{e}, +@samp{i}, @samp{o}, @samp{u}, and sometimes +@samp{y}. +@end quotation + +@node var, file, samp, Indicating +@comment node-name, next, previous, up +@subsection @code{@@var}@{@var{metasyntactic-variable}@} +@findex var + +Use the @code{@@var} command to indicate metasyntactic variables. A +@dfn{metasyntactic variable} is something that stands for another piece of +text. For example, you should use a metasyntactic variable in the +documentation of a function to describe the arguments that are passed +to that function.@refill + +Do not use @code{@@var} for the names of particular variables in +programming languages. These are specific names from a program, so +@code{@@code} is correct for them. For example, the Lisp variable +@code{texinfo-tex-command} is not a metasyntactic variable; it is +properly formatted using @code{@@code}.@refill + +The effect of @code{@@var} in the Info file is to change the case of +the argument to all upper case; in the printed manual, to italicize it. + +@need 700 +For example, + +@example +To delete file @@var@{filename@}, +type @@code@{rm @@var@{filename@}@}. +@end example + +@noindent +produces + +@quotation +To delete file @var{filename}, type @code{rm @var{filename}}. +@end quotation + +@noindent +(Note that @code{@@var} may appear inside @code{@@code}, +@code{@@samp}, @code{@@file}, etc.)@refill + +Write a metasyntactic variable all in lower case without spaces, and +use hyphens to make it more readable. Thus, the Texinfo source for +the illustration of how to begin a Texinfo manual looks like +this:@refill + +@example +@group +\input texinfo +@@@@setfilename @@var@{info-file-name@} +@@@@settitle @@var@{name-of-manual@} +@end group +@end example + +@noindent +This produces: + +@example +@group +\input texinfo +@@setfilename @var{info-file-name} +@@settitle @var{name-of-manual} +@end group +@end example + +In some documentation styles, metasyntactic variables are shown with +angle brackets, for example:@refill + +@example +@dots{}, type rm +@end example + +@noindent +However, that is not the style that Texinfo uses. (You can, of +course, modify the sources to @TeX{} and the Info formatting commands +to output the @code{<@dots{}>} format if you wish.)@refill + +@node file, dfn, var, Indicating +@comment node-name, next, previous, up +@subsection @code{@@file}@{@var{file-name}@} +@findex file + +Use the @code{@@file} command to indicate text that is the name of a +file, buffer, or directory, or is the name of a node in Info. You can +also use the command for file name suffixes. Do not use @code{@@file} +for symbols in a programming language; use @code{@@code}. + +Currently, @code{@@file} is equivalent to @code{@@samp} in its effects. +For example,@refill + +@example +The @@file@{.el@} files are in +the @@file@{/usr/local/emacs/lisp@} directory. +@end example + +@noindent +produces + +@quotation +The @file{.el} files are in +the @file{/usr/local/emacs/lisp} directory. +@end quotation + +@node dfn, cite, file, Indicating +@comment node-name, next, previous, up +@subsection @code{@@dfn}@{@var{term}@} +@findex dfn + +Use the @code{@@dfn} command to identify the introductory or defining +use of a technical term. Use the command only in passages whose +purpose is to introduce a term which will be used again or which the +reader ought to know. Mere passing mention of a term for the first +time does not deserve @code{@@dfn}. The command generates italics in +the printed manual, and double quotation marks in the Info file. For +example:@refill + +@example +Getting rid of a file is called @@dfn@{deleting@} it. +@end example + +@noindent +produces + +@quotation +Getting rid of a file is called @dfn{deleting} it. +@end quotation + +As a general rule, a sentence containing the defining occurrence of a +term should be a definition of the term. The sentence does not need +to say explicitly that it is a definition, but it should contain the +information of a definition---it should make the meaning clear. + +@node cite, url, dfn, Indicating +@comment node-name, next, previous, up +@subsection @code{@@cite}@{@var{reference}@} +@findex cite + +Use the @code{@@cite} command for the name of a book that lacks a +companion Info file. The command produces italics in the printed +manual, and quotation marks in the Info file.@refill + +(If a book is written in Texinfo, it is better to use a cross reference +command since a reader can easily follow such a reference in Info. +@xref{xref, , @code{@@xref}}.)@refill + +@ignore +@c node ctrl, , cite, Indicating +@comment node-name, next, previous, up +@c subsection @code{@@ctrl}@{@var{ctrl-char}@} +@findex ctrl + +The @code{@@ctrl} command is seldom used. It describes an @sc{ascii} +control character by inserting the actual character into the Info +file. + +Usually, in Texinfo, you talk what you type as keyboard entry by +describing it with @code{@@kbd}: thus, @samp{@@kbd@{C-a@}} for +@kbd{C-a}. Use @code{@@kbd} in this way when talking about a control +character that is typed on the keyboard by the user. When talking +about a control character appearing in a file or a string, do not use +@code{@@kbd} since the control character is not typed. Also, do not +use @samp{C-} but spell out @code{control-}, as in @samp{control-a}, +to make it easier for a reader to understand.@refill + +@code{@@ctrl} is an idea from the beginnings of Texinfo which may not +really fit in to the scheme of things. But there may be times when +you want to use the command. The pattern is +@code{@@ctrl@{@var{ch}@}}, where @var{ch} is an @sc{ascii} character +whose control-equivalent is wanted. For example, to specify +@samp{control-f}, you would enter@refill + +@example +@@ctrl@{f@} +@end example + +@noindent +produces + +@quotation +@ctrl{f} +@end quotation + +In the Info file, this generates the specified control character, output +literally into the file. This is done so a user can copy the specified +control character (along with whatever else he or she wants) into another +Emacs buffer and use it. Since the `control-h',`control-i', and +`control-j' characters are formatting characters, they should not be +indicated with @code{@@ctrl}.@refill + +In a printed manual, @code{@@ctrl} generates text to describe or +identify that control character: an uparrow followed by the character +@var{ch}.@refill +@end ignore + +@node url, email, cite, Indicating +@subsection @code{@@url}@{@var{uniform-resource-locator}@} +@findex url + +Use the @code{@@url} command to indicate a uniform resource locator on +the World Wide Web. For example: + +@c Two lines because one is too long for smallbook format. +@example +The official GNU ftp site is +@@url@{ftp://ftp.gnu.ai.mit.edu/pub/gnu@}. +@end example + +In Info and @TeX{}, this acts like @code{@@samp}. When +Texinfo is converted to HTML, this produces a link you can follow. + +@node email, , url, Indicating +@subsection @code{@@email}@{@var{email-address}@} +@findex email + +Use the @code{@@email} command to indicate an electronic mail address. +For example: + +@example +Send bug reports to @email{bug-texinfo@@prep.ai.mit.edu}. +@end example + +In Info and @TeX{}, this acts like @code{@@samp}. When we have support +for conversion of Texinfo to HTML, this will produce a link you can +follow to bring up a mail composition window initialized with +@var{email-address}. + +@node Emphasis, , Indicating, Marking Text +@comment node-name, next, previous, up +@section Emphasizing Text +@cindex Emphasizing text + +Usually, Texinfo changes the font to mark words in the text according to +what category the words belong to; an example is the @code{@@code} command. +Most often, this is the best way to mark words. +However, sometimes you will want to emphasize text without indicating a +category. Texinfo has two commands to do this. Also, Texinfo has +several commands that specify the font in which @TeX{} will typeset +text. These commands have no affect on Info and only one of them, +the @code{@@r} command, has any regular use.@refill + +@menu +* emph & strong:: How to emphasize text in Texinfo. +* Smallcaps:: How to use the small caps font. +* Fonts:: Various font commands for printed output. +* Customized Highlighting:: How to define highlighting commands. +@end menu + +@node emph & strong, Smallcaps, Emphasis, Emphasis +@comment node-name, next, previous, up +@subsection @code{@@emph}@{@var{text}@} and @code{@@strong}@{@var{text}@} +@cindex Emphasizing text, font for +@findex emph +@findex strong + +The @code{@@emph} and @code{@@strong} commands are for emphasis; +@code{@@strong} is stronger. In printed output, @code{@@emph} +produces @emph{italics} and @code{@@strong} produces +@strong{bold}.@refill + +@need 800 +For example, + +@example +@group +@@quotation +@@strong@{Caution:@} @@code@{rm * .[^.]*@} removes @@emph@{all@} +files in the directory. +@@end quotation +@end group +@end example + +@iftex +@noindent +produces the following in printed output: + +@quotation +@strong{Caution}: @code{rm * .[^.]*} removes @emph{all} +files in the directory. +@end quotation + +@noindent +and the following in Info: +@end iftex +@ifinfo +@noindent +produces: +@end ifinfo + +@example + *Caution*: `rm * .[^.]*' removes *all* + files in the directory. +@end example + +The @code{@@strong} command is seldom used except to mark what is, in +effect, a typographical element, such as the word `Caution' in the +preceding example. + +In the Info file, both @code{@@emph} and @code{@@strong} put asterisks +around the text.@refill + +@quotation +@strong{Caution:} Do not use @code{@@emph} or @code{@@strong} with the +word @samp{Note}; Info will mistake the combination for a cross +reference. Use a phrase such as @strong{Please note} or +@strong{Caution} instead.@refill +@end quotation + +@node Smallcaps, Fonts, emph & strong, Emphasis +@subsection @code{@@sc}@{@var{text}@}: The Small Caps Font +@cindex Small caps font +@findex sc @r{(small caps font)} + +@iftex +Use the @samp{@@sc} command to set text in the printed output in @sc{a +small caps font} and set text in the Info file in upper case letters.@refill +@end iftex +@ifinfo +Use the @samp{@@sc} command to set text in the printed output in a +small caps font and set text in the Info file in upper case letters.@refill +@end ifinfo + +Write the text between braces in lower case, like this:@refill + +@example +The @@sc@{acm@} and @@sc@{ieee@} are technical societies. +@end example + +@noindent +This produces: + +@display +The @sc{acm} and @sc{ieee} are technical societies. +@end display + +@TeX{} typesets the small caps font in a manner that prevents the +letters from `jumping out at you on the page'. This makes small caps +text easier to read than text in all upper case. The Info formatting +commands set all small caps text in upper case.@refill + +@ifinfo +If the text between the braces of an @code{@@sc} command is upper case, +@TeX{} typesets in full-size capitals. Use full-size capitals +sparingly.@refill +@end ifinfo +@iftex +If the text between the braces of an @code{@@sc} command is upper case, +@TeX{} typesets in @sc{FULL-SIZE CAPITALS}. Use full-size capitals +sparingly.@refill +@end iftex + +You may also use the small caps font for a jargon word such as +@sc{ato} (a @sc{nasa} word meaning `abort to orbit').@refill + +There are subtleties to using the small caps font with a jargon word +such as @sc{cdr}, a word used in Lisp programming. In this case, you +should use the small caps font when the word refers to the second and +subsequent elements of a list (the @sc{cdr} of the list), but you +should use @samp{@@code} when the word refers to the Lisp function of +the same spelling.@refill + +@node Fonts, Customized Highlighting, Smallcaps, Emphasis +@comment node-name, next, previous, up +@subsection Fonts for Printing, Not Info +@cindex Fonts for printing, not for Info +@findex i @r{(italic font)} +@findex b @r{(bold font)} +@findex t @r{(typewriter font)} +@findex r @r{(Roman font)} + +Texinfo provides four font commands that specify font changes in the +printed manual but have no effect in the Info file. @code{@@i} +requests @i{italic} font (in some versions of @TeX{}, a slanted font +is used), @code{@@b} requests @b{bold} face, @code{@@t} requests the +@t{fixed-width}, typewriter-style font used by @code{@@code}, and @code{@@r} requests a +@r{roman} font, which is the usual font in which text is printed. All +four commands apply to an argument that follows, surrounded by +braces.@refill + +Only the @code{@@r} command has much use: in example programs, you +can use the @code{@@r} command to convert code comments from the +fixed-width font to a roman font. This looks better in printed +output.@refill + +@need 700 +For example, + +@example +@group +@@lisp +(+ 2 2) ; @@r@{Add two plus two.@} +@@end lisp +@end group +@end example + +@noindent +produces + +@lisp +(+ 2 2) ; @r{Add two plus two.} +@end lisp + +If possible, you should avoid using the other three font commands. If +you need to use one, it probably indicates a gap in the Texinfo +language.@refill + +@node Customized Highlighting, , Fonts, Emphasis +@comment node-name, next, previous, up +@subsection Customized Highlighting +@cindex Highlighting, customized +@cindex Customized highlighting + +@c I think this whole section is obsolete with the advent of macros +@c --karl, 15sep96. +You can use regular @TeX{} commands inside of @code{@@iftex} @dots{} +@code{@@end iftex} to create your own customized highlighting commands +for Texinfo. The easiest way to do this is to equate your customized +commands with pre-existing commands, such as those for italics. Such +new commands work only with @TeX{}.@refill + +@findex definfoenclose +@cindex Enclosure command for Info +You can use the @code{@@definfoenclose} command inside of +@code{@@ifinfo} @dots{} @code{@@end ifinfo} to define commands for Info +with the same names as new commands for @TeX{}. +@code{@@definfoenclose} creates new commands for Info that mark text by +enclosing it in strings that precede and follow the text. +@footnote{Currently, @code{@@definfoenclose} works only with +@code{texinfo-format-buffer} and @code{texinfo-format-region}, not with +@code{makeinfo}.}@refill + +Here is how to create a new @@-command called @code{@@phoo} that causes +@TeX{} to typeset its argument in italics and causes Info to display the +argument between @samp{//} and @samp{\\}.@refill + +@need 1300 +For @TeX{}, write the following to equate the @code{@@phoo} command with +the existing @code{@@i} italics command:@refill + +@example +@group +@@iftex +@@global@@let@@phoo=@@i +@@end iftex +@end group +@end example + +@noindent +This defines @code{@@phoo} as a command that causes @TeX{} to typeset +the argument to @code{@@phoo} in italics. @code{@@global@@let} tells +@TeX{} to equate the next argument with the argument that follows the +equals sign. + +@need 1300 +For Info, write the following to tell the Info formatters to enclose the +argument between @samp{//} and @samp{\\}: + +@example +@group +@@ifinfo +@@definfoenclose phoo, //, \\ +@@end ifinfo +@end group +@end example + +@noindent +Write the @code{@@definfoenclose} command on a line and follow it with +three arguments separated by commas (commas are used as separators in an +@code{@@node} line in the same way).@refill + +@itemize @bullet +@item +The first argument to @code{@@definfoenclose} is the @@-command name +@strong{without} the @samp{@@}; + +@item +the second argument is the Info start delimiter string; and, + +@item +the third argument is the Info end delimiter string. +@end itemize + +@noindent +The latter two arguments enclose the highlighted text in the Info file. +A delimiter string may contain spaces. Neither the start nor end +delimiter is required. However, if you do not provide a start +delimiter, you must follow the command name with two commas in a row; +otherwise, the Info formatting commands will misinterpret the end +delimiter string as a start delimiter string.@refill + +After you have defined @code{@@phoo} both for @TeX{} and for Info, you +can then write @code{@@phoo@{bar@}} to see @samp{//bar\\} +in Info and see +@ifinfo +@samp{bar} in italics in printed output. +@end ifinfo +@iftex +@i{bar} in italics in printed output. +@end iftex + +Note that each definition applies to its own formatter: one for @TeX{}, +the other for Info. + +@need 1200 +Here is another example: + +@example +@group +@@ifinfo +@@definfoenclose headword, , : +@@end ifinfo +@@iftex +@@global@@let@@headword=@@b +@@end iftex +@end group +@end example + +@noindent +This defines @code{@@headword} as an Info formatting command that +inserts nothing before and a colon after the argument and as a @TeX{} +formatting command to typeset its argument in bold. + +@node Quotations and Examples, Lists and Tables, Marking Text, Top +@comment node-name, next, previous, up +@chapter Quotations and Examples + +Quotations and examples are blocks of text consisting of one or more +whole paragraphs that are set off from the bulk of the text and +treated differently. They are usually indented.@refill + +In Texinfo, you always begin a quotation or example by writing an +@@-command at the beginning of a line by itself, and end it by writing +an @code{@@end} command that is also at the beginning of a line by +itself. For instance, you begin an example by writing @code{@@example} +by itself at the beginning of a line and end the example by writing +@code{@@end example} on a line by itself, at the beginning of that +line.@refill +@findex end + +@menu +* Block Enclosing Commands:: Use different constructs for + different purposes. +* quotation:: How to write a quotation. +* example:: How to write an example in a fixed-width font. +* noindent:: How to prevent paragraph indentation. +* Lisp Example:: How to illustrate Lisp code. +* smallexample & smalllisp:: Forms for the @code{@@smallbook} option. +* display:: How to write an example in the current font. +* format:: How to write an example that does not narrow + the margins. +* exdent:: How to undo the indentation of a line. +* flushleft & flushright:: How to push text flushleft or flushright. +* cartouche:: How to draw cartouches around examples. +@end menu + +@node Block Enclosing Commands, quotation, Quotations and Examples, Quotations and Examples +@section The Block Enclosing Commands + +Here are commands for quotations and examples:@refill + +@table @code +@item @@quotation +Indicate text that is quoted. The text is filled, indented, and +printed in a roman font by default.@refill + +@item @@example +Illustrate code, commands, and the like. The text is printed +in a fixed-width font, and indented but not filled.@refill + +@item @@lisp +Illustrate Lisp code. The text is printed in a fixed-width font, +and indented but not filled.@refill + +@item @@smallexample +Illustrate code, commands, and the like. Similar to +@code{@@example}, except that in @TeX{} this command typesets text in +a smaller font for the smaller @code{@@smallbook} format than for the +8.5 by 11 inch format.@refill + +@item @@smalllisp +Illustrate Lisp code. Similar to @code{@@lisp}, except that +in @TeX{} this command typesets text in a smaller font for the smaller +@code{@@smallbook} format than for the 8.5 by 11 inch format.@refill + +@item @@display +Display illustrative text. The text is indented but not filled, and +no font is specified (so, by default, the font is roman).@refill + +@item @@format +Print illustrative text. The text is not indented and not filled +and no font is specified (so, by default, the font is roman).@refill +@end table + +The @code{@@exdent} command is used within the above constructs to +undo the indentation of a line. + +The @code{@@flushleft} and @code{@@flushright} commands are used to line +up the left or right margins of unfilled text.@refill + +The @code{@@noindent} command may be used after one of the above +constructs to prevent the following text from being indented as a new +paragraph.@refill + +You can use the @code{@@cartouche} command within one of the above +constructs to highlight the example or quotation by drawing a box with +rounded corners around it. (The @code{@@cartouche} command affects +only the printed manual; it has no effect in the Info file; see +@ref{cartouche, , Drawing Cartouches Around Examples}.)@refill + +@node quotation, example, Block Enclosing Commands, Quotations and Examples +@comment node-name, next, previous, up +@section @code{@@quotation} +@cindex Quotations +@findex quotation + +The text of a quotation is +processed normally except that:@refill + +@itemize @bullet +@item +the margins are closer to the center of the page, so the whole of the +quotation is indented;@refill + +@item +the first lines of paragraphs are indented no more than other +lines;@refill + +@item +in the printed output, interparagraph spacing is reduced.@refill +@end itemize + +@quotation +This is an example of text written between an @code{@@quotation} +command and an @code{@@end quotation} command. An @code{@@quotation} +command is most often used to indicate text that is excerpted from +another (real or hypothetical) printed work.@refill +@end quotation + +Write an @code{@@quotation} command as text on a line by itself. This +line will disappear from the output. Mark the end of the quotation +with a line beginning with and containing only @code{@@end quotation}. +The @code{@@end quotation} line will likewise disappear from the +output. Thus, the following,@refill + +@example +@@quotation +This is +a foo. +@@end quotation +@end example + +@noindent +produces + +@quotation +This is a foo. +@end quotation + +@node example, noindent, quotation, Quotations and Examples +@comment node-name, next, previous, up +@section @code{@@example} +@cindex Examples, formatting them +@cindex Formatting examples +@findex example + +The @code{@@example} command is used to indicate an example that is +not part of the running text, such as computer input or output.@refill + +@example +@group +This is an example of text written between an +@code{@@example} command +and an @code{@@end example} command. +The text is indented but not filled. +@end group + +@group +In the printed manual, the text is typeset in a +fixed-width font, and extra spaces and blank lines are +significant. In the Info file, an analogous result is +obtained by indenting each line with five spaces. +@end group +@end example + +Write an @code{@@example} command at the beginning of a line by itself. +This line will disappear from the output. Mark the end of the example +with an @code{@@end example} command, also written at the beginning of a +line by itself. The @code{@@end example} will disappear from the +output.@refill + +@need 700 +For example, + +@example +@@example +mv foo bar +@@end example +@end example + +@noindent +produces + +@example +mv foo bar +@end example + +Since the lines containing @code{@@example} and @code{@@end example} +will disappear, you should put a blank line before the +@code{@@example} and another blank line after the @code{@@end +example}. (Remember that blank lines between the beginning +@code{@@example} and the ending @code{@@end example} will appear in +the output.)@refill + +@quotation +@strong{Caution:} Do not use tabs in the lines of an example (or anywhere +else in Texinfo, for that matter)! @TeX{} treats tabs as single +spaces, and that is not what they look like. This is a problem with +@TeX{}. (If necessary, in Emacs, you can use @kbd{M-x untabify} to +convert tabs in a region to multiple spaces.)@refill +@end quotation + +Examples are often, logically speaking, ``in the middle'' of a +paragraph, and the text continues after an example should not be +indented. The @code{@@noindent} command prevents a piece of text from +being indented as if it were a new paragraph. +@ifinfo +(@xref{noindent}.) +@end ifinfo + +(The @code{@@code} command is used for examples of code that are +embedded within sentences, not set off from preceding and following +text. @xref{code, , @code{@@code}}.) + +@node noindent, Lisp Example, example, Quotations and Examples +@comment node-name, next, previous, up +@section @code{@@noindent} +@findex noindent + +An example or other inclusion can break a paragraph into segments. +Ordinarily, the formatters indent text that follows an example as a new +paragraph. However, you can prevent this by writing @code{@@noindent} +at the beginning of a line by itself preceding the continuation +text.@refill + +@need 1500 +For example: + +@example +@group +@@example +This is an example +@@end example + +@@noindent +This line is not indented. As you can see, the +beginning of the line is fully flush left with the line +that follows after it. (This whole example is between +@@code@{@@@@display@} and @@code@{@@@@end display@}.) +@end group +@end example + +@noindent +produces + +@display +@example +This is an example +@end example +@tex +% Remove extra vskip; this is a kludge to counter the effect of display +\vskip-3.5\baselineskip +@end tex + +@noindent +This line is not indented. As you can see, the +beginning of the line is fully flush left with the line +that follows after it. (This whole example is between +@code{@@display} and @code{@@end display}.) +@end display + +To adjust the number of blank lines properly in the Info file output, +remember that the line containing @code{@@noindent} does not generate a +blank line, and neither does the @code{@@end example} line.@refill + +In the Texinfo source file for this manual, each line that says +`produces' is preceded by a line containing @code{@@noindent}.@refill + +Do not put braces after an @code{@@noindent} command; they are not +necessary, since @code{@@noindent} is a command used outside of +paragraphs (@pxref{Command Syntax}).@refill + +@node Lisp Example, smallexample & smalllisp, noindent, Quotations and Examples +@comment node-name, next, previous, up +@section @code{@@lisp} +@cindex Lisp example +@findex lisp + +The @code{@@lisp} command is used for Lisp code. It is synonymous +with the @code{@@example} command. + +@lisp +This is an example of text written between an +@code{@@lisp} command and an @code{@@end lisp} command. +@end lisp + +Use @code{@@lisp} instead of @code{@@example} so as to preserve +information regarding the nature of the example. This is useful, for +example, if you write a function that evaluates only and all the Lisp +code in a Texinfo file. Then you can use the Texinfo file as a Lisp +library.@footnote{It would be straightforward to extend Texinfo to +work in a similar fashion for C, @sc{fortran}, or other languages.}@refill + +Mark the end of @code{@@lisp} with @code{@@end lisp} on a line by +itself.@refill + +@node smallexample & smalllisp, display, Lisp Example, Quotations and Examples +@comment node-name, next, previous, up +@section @code{@@smallexample} and @code{@@smalllisp} +@cindex Small book example +@cindex Example for a small book +@cindex Lisp example for a small book +@findex smallexample +@findex smalllisp + +In addition to the regular @code{@@example} and @code{@@lisp} commands, +Texinfo has two other ``example-style'' commands. These are the +@code{@@smallexample} and @code{@@smalllisp} commands. Both these +commands are designed for use with the @code{@@smallbook} command that +causes @TeX{} to produce a printed manual in a 7 by 9.25 inch format +rather than the regular 8.5 by 11 inch format.@refill + +In @TeX{}, the @code{@@smallexample} and @code{@@smalllisp} commands +typeset text in a smaller font for the smaller @code{@@smallbook} +format than for the 8.5 by 11 inch format. Consequently, many examples +containing long lines fit in a narrower, @code{@@smallbook} page +without needing to be shortened. Both commands typeset in the normal +font size when you format for the 8.5 by 11 inch size; indeed, +in this situation, the @code{@@smallexample} and @code{@@smalllisp} +commands are defined to be the @code{@@example} and @code{@@lisp} +commands.@refill + +In Info, the @code{@@smallexample} and @code{@@smalllisp} commands are +equivalent to the @code{@@example} and @code{@@lisp} commands, and work +exactly the same.@refill + +Mark the end of @code{@@smallexample} or @code{@@smalllisp} with +@code{@@end smallexample} or @code{@@end smalllisp}, +respectively.@refill + +@iftex +Here is an example written in the small font used by the +@code{@@smallexample} and @code{@@smalllisp} commands: + +@ifclear smallbook +@display +@tex +% Remove extra vskip; this is a kludge to counter the effect of display +\vskip-3\baselineskip +{\ninett +\dots{} 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.} +@end tex +@end display +@end ifclear +@end iftex +@ifset smallbook +@iftex +@smallexample +This is an example of text written between @code{@@smallexample} and +@code{@@end smallexample}. In Info and in an 8.5 by 11 inch manual, +this text appears in its normal size; but in a 7 by 9.25 inch manual, +this text appears in a smaller font. +@end smallexample +@end iftex +@end ifset +@ifinfo +@smallexample +This is an example of text written between @code{@@smallexample} and +@code{@@end smallexample}. In Info and in an 8.5 by 11 inch manual, +this text appears in its normal size; but in a 7 by 9.25 inch manual, +this text appears in a smaller font. +@end smallexample +@end ifinfo + +The @code{@@smallexample} and @code{@@smalllisp} commands make it +easier to prepare smaller format manuals without forcing you to edit +examples by hand to fit them onto narrower pages.@refill + +As a general rule, a printed document looks better if you write all the +examples in a chapter consistently in @code{@@example} or in +@code{@@smallexample}. Only occasionally should you mix the two +formats.@refill + +@xref{smallbook, , Printing ``Small'' Books}, for more information +about the @code{@@smallbook} command.@refill + +@node display, format, smallexample & smalllisp, Quotations and Examples +@comment node-name, next, previous, up +@section @code{@@display} +@cindex Display formatting +@findex display + +The @code{@@display} command begins a kind of example. It is like the +@code{@@example} command +except that, in +a printed manual, @code{@@display} does not select the fixed-width +font. In fact, it does not specify the font at all, so that the text +appears in the same font it would have appeared in without the +@code{@@display} command.@refill + +@display +This is an example of text written between an @code{@@display} command +and an @code{@@end display} command. The @code{@@display} command +indents the text, but does not fill it. +@end display + +@node format, exdent, display, Quotations and Examples +@comment node-name, next, previous, up +@section @code{@@format} +@findex format + +The @code{@@format} command is similar to @code{@@example} except +that, in the printed manual, @code{@@format} does not select the +fixed-width font and does not narrow the margins.@refill + +@format +This is an example of text written between an @code{@@format} command +and an @code{@@end format} command. As you can see +from this example, +the @code{@@format} command does not fill the text. +@end format + +@node exdent, flushleft & flushright, format, Quotations and Examples +@section @code{@@exdent}: Undoing a Line's Indentation +@cindex Indentation undoing +@findex exdent + +The @code{@@exdent} command removes any indentation a line might have. +The command is written at the beginning of a line and applies only to +the text that follows the command that is on the same line. Do not use +braces around the text. In a printed manual, the text on an +@code{@@exdent} line is printed in the roman font.@refill + +@code{@@exdent} is usually used within examples. Thus,@refill + +@example +@group +@@example +This line follows an @@@@example command. +@@exdent This line is exdented. +This line follows the exdented line. +The @@@@end example comes on the next line. +@@end group +@end group +@end example + +@noindent +produces + +@example +@group +This line follows an @@example command. +@exdent This line is exdented. +This line follows the exdented line. +The @@end example comes on the next line. +@end group +@end example + +In practice, the @code{@@exdent} command is rarely used. +Usually, you un-indent text by ending the example and +returning the page to its normal width.@refill + +@node flushleft & flushright, cartouche, exdent, Quotations and Examples +@section @code{@@flushleft} and @code{@@flushright} +@findex flushleft +@findex flushright + +The @code{@@flushleft} and @code{@@flushright} commands line up the +ends of lines on the left and right margins of a page, +but do not fill the text. The commands are written on lines of their +own, without braces. The @code{@@flushleft} and @code{@@flushright} +commands are ended by @code{@@end flushleft} and @code{@@end +flushright} commands on lines of their own.@refill + +@need 1500 +For example, + +@example +@group +@@flushleft +This text is +written flushleft. +@@end flushleft +@end group +@end example + +@noindent +produces + +@quotation +@flushleft +This text is +written flushleft. +@end flushleft +@end quotation + + +Flushright produces the type of indentation often used in the return +address of letters.@refill + +@need 1500 +@noindent +For example, + +@example +@group +@@flushright +Here is an example of text written +flushright. The @@code@{@@flushright@} command +right justifies every line but leaves the +left end ragged. +@@end flushright +@end group +@end example + +@noindent +produces + +@flushright +Here is an example of text written +flushright. The @code{@@flushright} command +right justifies every line but leaves the +left end ragged. +@end flushright + +@node cartouche, , flushleft & flushright, Quotations and Examples +@section Drawing Cartouches Around Examples +@findex cartouche +@cindex Box with rounded corners + +In a printed manual, the @code{@@cartouche} command draws a box with +rounded corners around its contents. You can use this command to +further highlight an example or quotation. For instance, you could +write a manual in which one type of example is surrounded by a cartouche +for emphasis.@refill + +The @code{@@cartouche} command affects only the printed manual; it has +no effect in the Info file.@refill + +@need 1500 +For example, + +@example +@group +@@example +@@cartouche +% pwd +/usr/local/lib/emacs/info +@@end cartouche +@@end example +@end group +@end example + +@noindent +surrounds the two-line example with a box with rounded corners, in the +printed manual. + +@iftex +In a printed manual, the example looks like this:@refill + +@example +@group +@cartouche +% pwd +/usr/local/lib/emacs/info +@end cartouche +@end group +@end example +@end iftex + +@node Lists and Tables, Indices, Quotations and Examples, Top +@comment node-name, next, previous, up +@chapter Making Lists and Tables +@cindex Making lists and tables +@cindex Lists and tables, making them +@cindex Tables and lists, making them + +Texinfo has several ways of making lists and two-column tables. Lists can +be bulleted or numbered, while two-column tables can highlight the items in +the first column.@refill + +@menu +* Introducing Lists:: Texinfo formats lists for you. +* itemize:: How to construct a simple list. +* enumerate:: How to construct a numbered list. +* Two-column Tables:: How to construct a two-column table. +* Multi-column Tables:: How to construct generalized tables. +@end menu + +@ifinfo +@node Introducing Lists, itemize, Lists and Tables, Lists and Tables +@heading Introducing Lists +@end ifinfo + +Texinfo automatically indents the text in lists or tables, and numbers +an enumerated list. This last feature is useful if you modify the +list, since you do not need to renumber it yourself.@refill + +Numbered lists and tables begin with the appropriate @@-command at the +beginning of a line, and end with the corresponding @code{@@end} +command on a line by itself. The table and itemized-list commands +also require that you write formatting information on the same line as +the beginning @@-command.@refill + +Begin an enumerated list, for example, with an @code{@@enumerate} +command and end the list with an @code{@@end enumerate} command. +Begin an itemized list with an @code{@@itemize} command, followed on +the same line by a formatting command such as @code{@@bullet}, and end +the list with an @code{@@end itemize} command.@refill +@findex end + +Precede each element of a list with an @code{@@item} or @code{@@itemx} +command.@refill + +@sp 1 +@noindent +Here is an itemized list of the different kinds of table and lists:@refill + +@itemize @bullet +@item +Itemized lists with and without bullets. + +@item +Enumerated lists, using numbers or letters. + +@item +Two-column tables with highlighting. +@end itemize + +@sp 1 +@noindent +Here is an enumerated list with the same items:@refill + +@enumerate +@item +Itemized lists with and without bullets. + +@item +Enumerated lists, using numbers or letters. + +@item +Two-column tables with highlighting. +@end enumerate + +@sp 1 +@noindent +And here is a two-column table with the same items and their +@w{@@-commands}:@refill + +@table @code +@item @@itemize +Itemized lists with and without bullets. + +@item @@enumerate +Enumerated lists, using numbers or letters. + +@item @@table +@itemx @@ftable +@itemx @@vtable +Two-column tables with indexing. +@end table + +@node itemize, enumerate, Introducing Lists, Lists and Tables +@comment node-name, next, previous, up +@section Making an Itemized List +@cindex Itemization +@findex itemize + +The @code{@@itemize} command produces sequences of indented +paragraphs, with a bullet or other mark inside the left margin +at the beginning of each paragraph for which such a mark is desired.@refill + +Begin an itemized list by writing @code{@@itemize} at the beginning of +a line. Follow the command, on the same line, with a character or a +Texinfo command that generates a mark. Usually, you will write +@code{@@bullet} after @code{@@itemize}, but you can use +@code{@@minus}, or any character or any special symbol that results in +a single character in the Info file. (When you write @code{@@bullet} +or @code{@@minus} after an @code{@@itemize} command, you may omit the +@samp{@{@}}.)@refill + +Write the text of the indented paragraphs themselves after the +@code{@@itemize}, up to another line that says @code{@@end +itemize}.@refill + +Before each paragraph for which a mark in the margin is desired, write +a line that says just @code{@@item}. Do not write any other text on this +line.@refill +@findex item + +Usually, you should put a blank line before an @code{@@item}. This +puts a blank line in the Info file. (@TeX{} inserts the proper +interline whitespace in either case.) Except when the entries are +very brief, these blank lines make the list look better.@refill + +Here is an example of the use of @code{@@itemize}, followed by the +output it produces. Note that @code{@@bullet} produces an @samp{*} in +Info and a round dot in @TeX{}.@refill + +@example +@group +@@itemize @@bullet +@@item +Some text for foo. + +@@item +Some text +for bar. +@@end itemize +@end group +@end example + +@noindent +This produces: + +@quotation +@itemize @bullet +@item +Some text for foo. + +@item +Some text +for bar. +@end itemize +@end quotation + +Itemized lists may be embedded within other itemized lists. Here is a +list marked with dashes embedded in a list marked with bullets:@refill + +@example +@group +@@itemize @@bullet +@@item +First item. + +@@itemize @@minus +@@item +Inner item. + +@@item +Second inner item. +@@end itemize + +@@item +Second outer item. +@@end itemize +@end group +@end example + +@noindent +This produces: + +@quotation +@itemize @bullet +@item +First item. + +@itemize @minus +@item +Inner item. + +@item +Second inner item. +@end itemize + +@item +Second outer item. +@end itemize +@end quotation + +@node enumerate, Two-column Tables, itemize, Lists and Tables +@comment node-name, next, previous, up +@section Making a Numbered or Lettered List +@cindex Enumeration +@findex enumerate + +@code{@@enumerate} is like @code{@@itemize} except that the marks in +the left margin contain successive integers or letters. +(@xref{itemize, , @code{@@itemize}}.)@refill + +Write the @code{@@enumerate} command at the beginning of a line. +The command does not require an argument, but accepts either a number or +a letter as an option. +Without an argument, @code{@@enumerate} starts the list +with the number 1. With a numeric argument, such as 3, +the command starts the list with that number. +With an upper or lower case letter, such as @kbd{a} or @kbd{A}, +the command starts the list with that letter.@refill + +Write the text of the enumerated list in the same way you write an +itemized list: put @code{@@item} on a line of its own before the start of +each paragraph that you want enumerated. Do not write any other text on +the line beginning with @code{@@item}.@refill + +You should put a blank line between entries in the list. +This generally makes it easier to read the Info file.@refill + +@need 1500 +Here is an example of @code{@@enumerate} without an argument:@refill + +@example +@group +@@enumerate +@@item +Underlying causes. + +@@item +Proximate causes. +@@end enumerate +@end group +@end example + +@noindent +This produces: + +@enumerate +@item +Underlying causes. + +@item +Proximate causes. +@end enumerate +@sp 1 +Here is an example with an argument of @kbd{3}:@refill +@sp 1 +@example +@group +@@enumerate 3 +@@item +Predisposing causes. + +@@item +Precipitating causes. + +@@item +Perpetuating causes. +@@end enumerate +@end group +@end example + +@noindent +This produces: + +@enumerate 3 +@item +Predisposing causes. + +@item +Precipitating causes. + +@item +Perpetuating causes. +@end enumerate +@sp 1 +Here is a brief summary of the alternatives. The summary is constructed +using @code{@@enumerate} with an argument of @kbd{a}.@refill +@sp 1 +@enumerate a +@item +@code{@@enumerate} + +Without an argument, produce a numbered list, starting with the number +1.@refill + +@item +@code{@@enumerate @var{positive-integer}} + +With a (positive) numeric argument, start a numbered list with that +number. You can use this to continue a list that you interrupted with +other text.@refill + +@item +@code{@@enumerate @var{upper-case-letter}} + +With an upper case letter as argument, start a list +in which each item is marked +by a letter, beginning with that upper case letter.@refill + +@item +@code{@@enumerate @var{lower-case-letter}} + +With a lower case letter as argument, start a list +in which each item is marked by +a letter, beginning with that lower case letter.@refill +@end enumerate + +You can also nest enumerated lists, as in an outline.@refill + +@node Two-column Tables, Multi-column Tables, enumerate, Lists and Tables +@section Making a Two-column Table +@cindex Tables, making two-column +@findex table + +@code{@@table} is similar to @code{@@itemize}, but the command allows +you to specify a name or heading line for each item. (@xref{itemize, +, @code{@@itemize}}.) The @code{@@table} command is used to produce +two-column tables, and is especially useful for glossaries and +explanatory exhibits.@refill + +@menu +* table:: How to construct a two-column table. +* ftable vtable:: How to construct a two-column table + with automatic indexing. +* itemx:: How to put more entries in the first column. +@end menu + +@ifinfo +@node table, ftable vtable, Two-column Tables, Two-column Tables +@subheading Using the @code{@@table} Command + +Use the @code{@@table} command to produce two-column tables.@refill +@end ifinfo + +Write the @code{@@table} command at the beginning of a line and follow +it on the same line with an argument that is a Texinfo command such as +@code{@@code}, @code{@@samp}, @code{@@var}, or @code{@@kbd}. +Although these commands are usually followed by arguments in braces, +in this case you use the command name without an argument because +@code{@@item} will supply the argument. This command will be applied +to the text that goes into the first column of each item and +determines how it will be highlighted. For example, @code{@@samp} +will cause the text in the first column to be highlighted with an +@code{@@samp} command.@refill + +You may also choose to use the @code{@@asis} command as an argument to +@code{@@table}. @code{@@asis} is a command that does nothing; if you use this +command after @code{@@table}, @TeX{} and the Info formatting commands +output the first column entries without added highlighting (`as +is').@refill + +(The @code{@@table} command may work with other commands besides those +listed here. However, you can only use commands +that normally take arguments in braces.)@refill + +Begin each table entry with an @code{@@item} command at the beginning +of a line. Write the first column text on the same line as the +@code{@@item} command. Write the second column text on the line +following the @code{@@item} line and on subsequent lines. (You do not +need to type anything for an empty second column entry.) You may +write as many lines of supporting text as you wish, even several +paragraphs. But only text on the same line as the @code{@@item} will +be placed in the first column.@refill +@findex item + +Normally, you should put a blank line before an @code{@@item} line. +This puts a blank like in the Info file. Except when the entries are +very brief, a blank line looks better.@refill + +@need 1500 +The following table, for example, highlights the text in the first +column with an @code{@@samp} command:@refill + +@example +@group +@@table @@samp +@@item foo +This is the text for +@@samp@{foo@}. + +@@item bar +Text for @@samp@{bar@}. +@@end table +@end group +@end example + +@noindent +This produces: + +@table @samp +@item foo +This is the text for +@samp{foo}. +@item bar +Text for @samp{bar}. +@end table + +If you want to list two or more named items with a single block of +text, use the @code{@@itemx} command. (@xref{itemx, , +@code{@@itemx}}.)@refill + +@node ftable vtable, itemx, table, Two-column Tables +@comment node-name, next, previous, up +@subsection @code{@@ftable} and @code{@@vtable} +@cindex Tables with indexes +@cindex Indexing table entries automatically +@findex ftable +@findex vtable + +The @code{@@ftable} and @code{@@vtable} commands are the same as the +@code{@@table} command except that @code{@@ftable} automatically enters +each of the items in the first column of the table into the index of +functions and @code{@@vtable} automatically enters each of the items in +the first column of the table into the index of variables. This +simplifies the task of creating indices. Only the items on the same +line as the @code{@@item} commands are indexed, and they are indexed in +exactly the form that they appear on that line. @xref{Indices, , +Creating Indices}, for more information about indices.@refill + +Begin a two-column table using @code{@@ftable} or @code{@@vtable} by +writing the @@-command at the beginning of a line, followed on the same +line by an argument that is a Texinfo command such as @code{@@code}, +exactly as you would for an @code{@@table} command; and end the table +with an @code{@@end ftable} or @code{@@end vtable} command on a line by +itself. + +See the example for @code{@@table} in the previous section. + +@node itemx, , ftable vtable, Two-column Tables +@comment node-name, next, previous, up +@subsection @code{@@itemx} +@cindex Two named items for @code{@@table} +@findex itemx + +Use the @code{@@itemx} command inside a table when you have two or +more first column entries for the same item, each of which should +appear on a line of its own. Use @code{@@itemx} for all but the first +entry. The @code{@@itemx} command works exactly like @code{@@item} +except that it does not generate extra vertical space above the first +column text.@refill + +@need 1000 +For example, + +@example +@group +@@table @@code +@@item upcase +@@itemx downcase +These two functions accept a character or a string as +argument, and return the corresponding upper case (lower +case) character or string. +@@end table +@end group +@end example + +@noindent +This produces: + +@table @code +@item upcase +@itemx downcase +These two functions accept a character or a string as +argument, and return the corresponding upper case (lower +case) character or string.@refill +@end table + +@noindent +(Note also that this example illustrates multi-line supporting text in +a two-column table.)@refill + + +@node Multi-column Tables, , Two-column Tables, Lists and Tables +@section Multi-column Tables +@cindex Tables, making multi-column +@findex multitable + +@code{@@multitable} allows you to construct tables with any number of +columns, with each column having any width you like. + +You define the column widths on the @code{@@multitable} line itself, and +write each row of the actual table following an @code{@@item} command, +with columns separated by an @code{@@tab} command. Finally, @code{@@end +multitable} completes the table. Details in the sections below. + +@menu +* Multitable Column Widths:: Defining multitable column widths. +* Multitable Rows:: Defining multitable rows, with examples. +@end menu + +@node Multitable Column Widths, Multitable Rows, Multi-column Tables, Multi-column Tables +@subsection Multitable Column Widths +@cindex Multitable column widths +@cindex Column widths, defining for multitables +@cindex Widths, defining multitable column + +You can define the column widths for a multitable in two ways: as +fractions of the line length; or with a prototype row. Mixing the two +methods is not supported. In either case, the widths are defined +entirely on the same line as the @code{@@multitable} command. + +@enumerate +@item +@findex columnfractions +@cindex Line length, column widths as fraction of +To specify column widths as fractions of the line length, write +@code{@@columnfractions} and the decimal numbers (presumably less than +1) after the @code{@@multitable} command, as in: + +@example +@@multitable @@columnfractions .33 .33 .33 +@end example + +@noindent The fractions need not add up exactly to 1.0, as these do +not. This allows you to produce tables that do not need the full line +length. + +@item +@cindex Prototype row, column widths defined by +To specify a prototype row, write the longest entry for each column +enclosed in braces after the @code{@@multitable} command. For example: + +@example +@@multitable @{some text for column one@} @{for column two@} +@end example + +@noindent +The first column will then have the width of the typeset `some text for +column one', and the second column the width of `for column two'. + +The prototype entries need not appear in the table itself. + +Although we used simple text in this example, the prototype entries can +contain Texinfo commands; markup commands such as @code{@@code} are +particularly likely to be useful. + +@end enumerate + + +@node Multitable Rows, , Multitable Column Widths, Multi-column Tables +@subsection Multitable Rows +@cindex Multitable rows +@cindex Rows, of a multitable + +@findex item +@cindex tab +After the @code{@@multitable} command defining the column widths (see +the previous section), you begin each row in the body of a multitable +with @code{@@item}, and separate the column entries with @code{@@tab}. +Line breaks are not special within the table body, and you may break +input lines in your source file as necessary. + +Here is a complete example of a multi-column table (the text is from +the GNU Emacs manual): + +@example +@@multitable @@columnfractions .15 .45 .4 +@@item Key @@tab Command @@tab Description +@@item C-x 2 +@@tab @@code@{split-window-vertically@} +@@tab Split the selected window into two windows, +with one above the other. +@@item C-x 3 +@@tab @@code@{split-window-horizontally@} +@@tab Split the selected window into two windows +positioned side by side. +@@item C-Mouse-2 +@@tab +@@tab In the mode line or scroll bar of a window, +split that window. +@@end multitable +@end example + +@noindent produces: + +@multitable @columnfractions .15 .45 .4 +@item Key @tab Command @tab Description +@item C-x 2 +@tab @code{split-window-vertically} +@tab Split the selected window into two windows, +with one above the other. +@item C-x 3 +@tab @code{split-window-horizontally} +@tab Split the selected window into two windows +positioned side by side. +@item C-Mouse-2 +@tab +@tab In the mode line or scroll bar of a window, +split that window. +@end multitable + + +@node Indices, Insertions, Lists and Tables, Top +@comment node-name, next, previous, up +@chapter Creating Indices +@cindex Indices +@cindex Creating indices + +Using Texinfo, you can generate indices without having to sort and +collate entries manually. In an index, the entries are listed in +alphabetical order, together with information on how to find the +discussion of each entry. In a printed manual, this information +consists of page numbers. In an Info file, this information is a menu +entry leading to the first node referenced.@refill + +Texinfo provides several predefined kinds of index: an index +for functions, an index for variables, an index for concepts, and so +on. You can combine indices or use them for other than their +canonical purpose. If you wish, you can define your own indices.@refill + +@menu +* Index Entries:: Choose different words for index entries. +* Predefined Indices:: Use different indices for different kinds + of entry. +* Indexing Commands:: How to make an index entry. +* Combining Indices:: How to combine indices. +* New Indices:: How to define your own indices. +@end menu + +@node Index Entries, Predefined Indices, Indices, Indices +@comment node-name, next, previous, up +@section Making Index Entries +@cindex Index entries, making +@cindex Entries, making index + +When you are making index entries, it is good practice to think of the +different ways people may look for something. Different people +@emph{do not} think of the same words when they look something up. A +helpful index will have items indexed under all the different words +that people may use. For example, one reader may think it obvious that +the two-letter names for indices should be listed under ``Indices, +two-letter names'', since the word ``Index'' is the general concept. +But another reader may remember the specific concept of two-letter +names and search for the entry listed as ``Two letter names for +indices''. A good index will have both entries and will help both +readers.@refill + +Like typesetting, the construction of an index is a highly skilled, +professional art, the subtleties of which are not appreciated until you +need to do it yourself.@refill + +@xref{Printing Indices & Menus}, for information about printing an index +at the end of a book or creating an index menu in an Info file.@refill + +@node Predefined Indices, Indexing Commands, Index Entries, Indices +@comment node-name, next, previous, up +@section Predefined Indices + +Texinfo provides six predefined indices:@refill + +@itemize @bullet +@item +A @dfn{concept index} listing concepts that are discussed.@refill + +@item +A @dfn{function index} listing functions (such as entry points of +libraries).@refill + +@item +A @dfn{variables index} listing variables (such as global variables +of libraries).@refill + +@item +A @dfn{keystroke index} listing keyboard commands.@refill + +@item +A @dfn{program index} listing names of programs.@refill + +@item +A @dfn{data type index} listing data types (such as structures defined in +header files).@refill +@end itemize + +@noindent +Not every manual needs all of these, and most manuals use two or three +of them. This manual has two indices: a +concept index and an @@-command index (that is actually the function +index but is called a command index in the chapter heading). Two or +more indices can be combined into one using the @code{@@synindex} or +@code{@@syncodeindex} commands. @xref{Combining Indices}.@refill + +@node Indexing Commands, Combining Indices, Predefined Indices, Indices +@comment node-name, next, previous, up +@section Defining the Entries of an Index +@cindex Defining indexing entries +@cindex Index entries +@cindex Entries for an index +@cindex Specifying index entries +@cindex Creating index entries + +The data to make an index come from many individual indexing commands +scattered throughout the Texinfo source file. Each command says to add +one entry to a particular index; after formatting, the index will give +the current page number or node name as the reference.@refill + +An index entry consists of an indexing command at the beginning of a +line followed, on the rest of the line, by the entry.@refill + +For example, this section begins with the following five entries for +the concept index:@refill + +@example +@@cindex Defining indexing entries +@@cindex Index entries +@@cindex Entries for an index +@@cindex Specifying index entries +@@cindex Creating index entries +@end example + +Each predefined index has its own indexing command---@code{@@cindex} +for the concept index, @code{@@findex} for the function index, and so +on.@refill + +@cindex Writing index entries +@cindex Index entry writing +Concept index entries consist of text. The best way to write an index +is to choose entries that are terse yet clear. If you can do this, +the index often looks better if the entries are not capitalized, but +written just as they would appear in the middle of a sentence. +(Capitalize proper names and acronyms that always call for upper case +letters.) This is the case convention we use in most GNU manuals' +indices. + +If you don't see how to make an entry terse yet clear, make it longer +and clear---not terse and confusing. If many of the entries are several +words long, the index may look better if you use a different convention: +to capitalize the first word of each entry. But do not capitalize a +case-sensitive name such as a C or Lisp function name or a shell +command; that would be a spelling error. + +Whichever case convention you use, please use it consistently! + +@ignore +Concept index entries consist of English text. The usual convention +is to capitalize the first word of each such index entry, unless that +word is the name of a function, variable, or other such entity that +should not be capitalized. However, if your concept index entries are +consistently short (one or two words each) it may look better for each +regular entry to start with a lower case letter, aside from proper +names and acronyms that always call for upper case letters. Whichever +convention you adapt, please be consistent! +@end ignore + +Entries in indices other than the concept index are symbol names in +programming languages, or program names; these names are usually +case-sensitive, so use upper and lower case as required for them. + +By default, entries for a concept index are printed in a small roman +font and entries for the other indices are printed in a small +@code{@@code} font. You may change the way part of an entry is +printed with the usual Texinfo commands, such as @code{@@file} for +file names and @code{@@emph} for emphasis (@pxref{Marking +Text}).@refill +@cindex Index font types + +@cindex Predefined indexing commands +@cindex Indexing commands, predefined +The six indexing commands for predefined indices are: + +@table @code +@item @@cindex @var{concept} +@findex cindex +Make an entry in the concept index for @var{concept}.@refill + +@item @@findex @var{function} +@findex findex +Make an entry in the function index for @var{function}.@refill + +@item @@vindex @var{variable} +@findex vindex +Make an entry in the variable index for @var{variable}.@refill + +@item @@kindex @var{keystroke} +@findex kindex +Make an entry in the key index for @var{keystroke}.@refill + +@item @@pindex @var{program} +@findex pindex +Make an entry in the program index for @var{program}.@refill + +@item @@tindex @var{data type} +@findex tindex +Make an entry in the data type index for @var{data type}.@refill +@end table + +@quotation +@strong{Caution:} Do not use a colon in an index entry. In Info, a +colon separates the menu entry name from the node name. An extra +colon confuses Info. +@xref{Menu Parts, , The Parts of a Menu}, +for more information about the structure of a menu entry.@refill +@end quotation + +If you write several identical index entries in different places in a +Texinfo file, the index in the printed manual will list all the pages to +which those entries refer. However, the index in the Info file will +list @strong{only} the node that references the @strong{first} of those +index entries. Therefore, it is best to write indices in which each +entry refers to only one place in the Texinfo file. Fortunately, this +constraint is a feature rather than a loss since it means that the index +will be easy to use. Otherwise, you could create an index that lists +several pages for one entry and your reader would not know to which page +to turn. If you have two identical entries for one topic, change the +topics slightly, or qualify them to indicate the difference.@refill + +You are not actually required to use the predefined indices for their +canonical purposes. For example, suppose you wish to index some C +preprocessor macros. You could put them in the function index along +with actual functions, just by writing @code{@@findex} commands for +them; then, when you print the ``Function Index'' as an unnumbered +chapter, you could give it the title `Function and Macro Index' and +all will be consistent for the reader. Or you could put the macros in +with the data types by writing @code{@@tindex} commands for them, and +give that index a suitable title so the reader will understand. +(@xref{Printing Indices & Menus}.)@refill + +@node Combining Indices, New Indices, Indexing Commands, Indices +@comment node-name, next, previous, up +@section Combining Indices +@cindex Combining indices +@cindex Indices, combining them + +Sometimes you will want to combine two disparate indices such as functions +and concepts, perhaps because you have few enough of one of them that +a separate index for them would look silly.@refill + +You could put functions into the concept index by writing +@code{@@cindex} commands for them instead of @code{@@findex} commands, +and produce a consistent manual by printing the concept index with the +title `Function and Concept Index' and not printing the `Function +Index' at all; but this is not a robust procedure. It works only if +your document is never included as part of another +document that is designed to have a separate function index; if your +document were to be included with such a document, the functions from +your document and those from the other would not end up together. +Also, to make your function names appear in the right font in the +concept index, you would need to enclose every one of them between +the braces of @code{@@code}.@refill + +@menu +* syncodeindex:: How to merge two indices, using @code{@@code} + font for the merged-from index. +* synindex:: How to merge two indices, using the + default font of the merged-to index. +@end menu + +@node syncodeindex, synindex, Combining Indices, Combining Indices +@subsection @code{@@syncodeindex} +@findex syncodeindex + +When you want to combine functions and concepts into one index, you +should index the functions with @code{@@findex} and index the concepts +with @code{@@cindex}, and use the @code{@@syncodeindex} command to +redirect the function index entries into the concept index.@refill +@findex syncodeindex + +The @code{@@syncodeindex} command takes two arguments; they are the name +of the index to redirect, and the name of the index to redirect it to. +The template looks like this:@refill + +@example +@@syncodeindex @var{from} @var{to} +@end example + +@cindex Predefined names for indices +@cindex Two letter names for indices +@cindex Indices, two letter names +@cindex Names for indices +For this purpose, the indices are given two-letter names:@refill + +@table @samp +@item cp +concept index +@item fn +function index +@item vr +variable index +@item ky +key index +@item pg +program index +@item tp +data type index +@end table + +Write an @code{@@syncodeindex} command before or shortly after the +end-of-header line at the beginning of a Texinfo file. For example, +to merge a function index with a concept index, write the +following:@refill + +@example +@@syncodeindex fn cp +@end example + +@noindent +This will cause all entries designated for the function index to merge +in with the concept index instead.@refill + +To merge both a variables index and a function index into a concept +index, write the following:@refill + +@example +@group +@@syncodeindex vr cp +@@syncodeindex fn cp +@end group +@end example + +@cindex Fonts for indices +The @code{@@syncodeindex} command puts all the entries from the `from' +index (the redirected index) into the @code{@@code} font, overriding +whatever default font is used by the index to which the entries are +now directed. This way, if you direct function names from a function +index into a concept index, all the function names are printed in the +@code{@@code} font as you would expect.@refill + +@node synindex, , syncodeindex, Combining Indices +@subsection @code{@@synindex} +@findex synindex + +The @code{@@synindex} command is nearly the same as the +@code{@@syncodeindex} command, except that it does not put the +`from' index entries into the @code{@@code} font; rather it puts +them in the roman font. Thus, you use @code{@@synindex} when you +merge a concept index into a function index.@refill + +@xref{Printing Indices & Menus}, for information about printing an index +at the end of a book or creating an index menu in an Info file.@refill + +@node New Indices, , Combining Indices, Indices +@section Defining New Indices +@cindex Defining new indices +@cindex Indices, defining new +@cindex New index defining +@findex defindex +@findex defcodeindex + +In addition to the predefined indices, you may use the +@code{@@defindex} and @code{@@defcodeindex} commands to define new +indices. These commands create new indexing @@-commands with which +you mark index entries. The @code{@@defindex }command is used like +this:@refill + +@example +@@defindex @var{name} +@end example + +The name of an index should be a two letter word, such as @samp{au}. +For example:@refill + +@example +@@defindex au +@end example + +This defines a new index, called the @samp{au} index. At the same +time, it creates a new indexing command, @code{@@auindex}, that you +can use to make index entries. Use the new indexing command just as +you would use a predefined indexing command.@refill + +For example, here is a section heading followed by a concept index +entry and two @samp{au} index entries.@refill + +@example +@@section Cognitive Semantics +@@cindex kinesthetic image schemas +@@auindex Johnson, Mark +@@auindex Lakoff, George +@end example + +@noindent +(Evidently, @samp{au} serves here as an abbreviation for ``author''.) +Texinfo constructs the new indexing command by concatenating the name +of the index with @samp{index}; thus, defining an @samp{au} index +leads to the automatic creation of an @code{@@auindex} command.@refill + +Use the @code{@@printindex} command to print the index, as you do with +the predefined indices. For example:@refill + +@example +@group +@@node Author Index, Subject Index, , Top +@@unnumbered Author Index + +@@printindex au +@end group +@end example + +The @code{@@defcodeindex} is like the @code{@@defindex} command, except +that, in the printed output, it prints entries in an @code{@@code} font +instead of a roman font. Thus, it parallels the @code{@@findex} command +rather than the @code{@@cindex} command.@refill + +You should define new indices within or right after the end-of-header +line of a Texinfo file, before any @code{@@synindex} or +@code{@@syncodeindex} commands (@pxref{Header}).@refill + +@node Insertions, Glyphs, Indices, Top +@comment node-name, next, previous, up +@chapter Special Insertions +@cindex Inserting special characters and symbols +@cindex Special insertions + +Texinfo provides several commands for formatting dimensions, for +inserting single characters that have special meaning in Texinfo, such +as braces, and for inserting special graphic symbols that do not +correspond to characters, such as dots and bullets.@refill + +@iftex +These are: + +@itemize @bullet +@item +Braces, @samp{@@} and periods. + +@item +Format a dimension, such as @samp{12@dmn{pt}}. + +@item +Dots and bullets. + +@item +The @TeX{} logo and the copyright symbol. + +@item +A minus sign. +@end itemize +@end iftex + +@menu +* Braces Atsigns:: How to insert braces, @samp{@@}. +* Inserting Space:: How to insert the right amount of space + within a sentence. +* Inserting Accents:: How to insert accents and special characters. +* Dots Bullets:: How to insert dots and bullets. +* TeX and copyright:: How to insert the @TeX{} logo + and the copyright symbol. +* pounds:: How to insert the pounds currency symbol. +* minus:: How to insert a minus sign. +* math:: How to format a mathematical expression. +@end menu + + +@node Braces Atsigns, Inserting Space, Insertions, Insertions +@section Inserting @@ and Braces +@cindex Inserting @@, braces +@cindex Braces, inserting +@cindex Special characters, commands to insert +@cindex Commands to insert special characters + +@samp{@@} and curly braces are special characters in Texinfo. To insert +these characters so they appear in text, you must put an @samp{@@} in +front of these characters to prevent Texinfo from misinterpreting +them. + +Do not put braces after any of these commands; they are not +necessary. + +@menu +* Inserting An Atsign:: How to insert @samp{@@}. +* Inserting Braces:: How to insert @samp{@{} and @samp{@}}. +@end menu + +@node Inserting An Atsign, Inserting Braces, Braces Atsigns, Braces Atsigns +@subsection Inserting @samp{@@} with @@@@ +@findex @@ @r{(single @samp{@@})} + +@code{@@@@} stands for a single @samp{@@} in either printed or Info +output. + +Do not put braces after an @code{@@@@} command. + +@node Inserting Braces, , Inserting An Atsign, Braces Atsigns +@subsection Inserting @samp{@{} and @samp{@}}with @@@{ and @@@} +@findex @{ @r{(single @samp{@{})} +@findex @} @r{(single @samp{@}})} + +@code{@@@{} stands for a single @samp{@{} in either printed or Info +output. + +@code{@@@}} stands for a single @samp{@}} in either printed or Info +output. + +Do not put braces after either an @code{@@@{} or an @code{@@@}} +command. + + +@node Inserting Space, Inserting Accents, Braces Atsigns, Insertions +@section Inserting Space + +@cindex Inserting space +@cindex Spacing, inserting +@cindex Whitespace, inserting +The following sections describe commands that control spacing of various +kinds within and after sentences. + +@menu +* Not Ending a Sentence:: Sometimes a . doesn't end a sentence. +* Ending a Sentence:: Sometimes it does. +* Multiple Spaces:: Inserting multiple spaces. +* dmn:: How to format a dimension. +@end menu + +@node Not Ending a Sentence, Ending a Sentence, Inserting Space, Inserting Space +@subsection Not Ending a Sentence + +@cindex Not ending a sentence +@cindex Sentence non-ending punctuation +@cindex Periods, inserting +Depending on whether a period or exclamation point or question mark is +inside or at the end of a sentence, less or more space is inserted after +a period in a typeset manual. Since it is not always possible for +Texinfo to determine when a period ends a sentence and when it is used +in an abbreviation, special commands are needed in some circumstances. +(Usually, Texinfo can guess how to handle periods, so you do not need to +use the special commands; you just enter a period as you would if you +were using a typewriter, which means you put two spaces after the +period, question mark, or exclamation mark that ends a sentence.) + +@findex : @r{(suppress widening)} +Use the @code{@@:}@: command after a period, question mark, +exclamation mark, or colon that should not be followed by extra space. +For example, use @code{@@:}@: after periods that end abbreviations +which are not at the ends of sentences. @code{@@:}@: has no effect on +the Info file output. + +@need 700 +For example, + +@example +The s.o.p.@@: has three parts @dots{} +The s.o.p. has three parts @dots{} +@end example + +@noindent +@ifinfo +produces +@end ifinfo +@iftex +produces the following. If you look carefully at this printed output, +you will see a little more whitespace after @samp{s.o.p.} in the second +line.@refill +@end iftex + +@quotation +The s.o.p.@: has three parts @dots{}@* +The s.o.p. has three parts @dots{} +@end quotation + +@noindent +@kbd{@@:} has no effect on the Info output. (@samp{s.o.p.} is an +abbreviation for ``Standard Operating Procedure''.) + +Do not put braces after @code{@@:}. + + +@node Ending a Sentence, Multiple Spaces, Not Ending a Sentence, Inserting Space +@subsection Ending a Sentence + +@cindex Ending a Sentence +@cindex Sentence ending punctuation + +@findex . @r{(end of sentence)} +@findex ! @r{(end of sentence)} +@findex ? @r{(end of sentence)} +Use @code{@@.}@: instead of a period, @code{@@!}@: instead of an +exclamation point, and @code{@@?}@: instead of a question mark at the end +of a sentence that ends with a single capital letter. Otherwise, @TeX{} +will think the letter is an abbreviation and will not insert the correct +end-of-sentence spacing. Here is an example: + +@example +Give it to M.I.B. and to M.E.W@@. Also, give it to R.J.C@@. +Give it to M.I.B. and to M.E.W. Also, give it to R.J.C. +@end example + +@noindent +@ifinfo +produces +@end ifinfo +@iftex +produces the following. If you look carefully at this printed output, +you will see a little more whitespace after the @samp{W} in the first +line. +@end iftex + +@quotation +Give it to M.I.B. and to M.E.W@. Also, give it to R.J.C@.@* +Give it to M.I.B. and to M.E.W. Also, give it to R.J.C. +@end quotation + +In the Info file output, @code{@@.}@: is equivalent to a simple +@samp{.}; likewise for @code{@@!}@: and @code{@@?}@:. + +The meanings of @code{@@:} and @code{@@.}@: in Texinfo are designed to +work well with the Emacs sentence motion commands (@pxref{Sentences,,, +emacs, GNU Emacs}). This made it necessary for them to be incompatible +with some other formatting systems that use @@-commands. + +Do not put braces after any of these commands. + + +@node Multiple Spaces, dmn, Ending a Sentence, Inserting Space +@subsection Multiple Spaces + +@cindex Multiple spaces +@cindex Whitespace, inserting +@findex (space) +@findex (tab) +@findex (newline) + +Ordinarily, @TeX{} collapses multiple whitespace characters (space, tab, +and newline) into a single space. (Info output, on the other hand, +preserves whitespace as you type it, except for changing a newline into +a space; this is why it is important to put two spaces at the end of +sentences in Texinfo documents.) + +Occasionally, you may want to actually insert several consecutive +spaces, either for purposes of example (what your program does with +multiple spaces as input), or merely for purposes of appearance in +headings or lists. Texinfo supports three commands: @code{@@ }, +@code{@@@kbd{TAB}}, and @code{@@@kbd{NL}}, all of which insert a single +space into the output. (Here, @kbd{TAB} and @kbd{NL} represent the tab +character and end-of-line, i.e., when @samp{@@} is the last character on +a line.) + +For example, +@example +Spacey@@ @@ @@ @@ +example. +@end example + +@noindent produces + +@example +Spacey@ @ @ @ +example. +@end example + +Other possible uses of @code{@@ } have been subsumed by @code{@@multitable} +(@pxref{Multi-column Tables}). + +Do not follow any of these commands with braces. + + +@node dmn, , Multiple Spaces, Inserting Space +@subsection @code{@@dmn}@{@var{dimension}@}: Format a Dimension +@cindex Thin space between number, dimension +@cindex Dimension formatting +@cindex Format a dimension +@findex dmn + +At times, you may want to write @samp{12@dmn{pt}} or +@samp{8.5@dmn{in}} with little or no space between the number and the +abbreviation for the dimension. You can use the @code{@@dmn} command +to do this. On seeing the command, @TeX{} inserts just enough space +for proper typesetting; the Info formatting commands insert no space +at all, since the Info file does not require it.@refill + +To use the @code{@@dmn} command, write the number and then follow it +immediately, with no intervening space, by @code{@@dmn}, and then by +the dimension within braces.@refill + +@need 700 +@noindent +For example, + +@example +A4 paper is 8.27@@dmn@{in@} wide. +@end example + +@noindent +produces + +@quotation +A4 paper is 8.27@dmn{in} wide. +@end quotation + +Not everyone uses this style. Instead of writing +@w{@samp{8.27@@dmn@{in@}}} in the Texinfo file, you may write +@w{@samp{8.27 in.}} or @w{@samp{8.27 inches}}. (In these cases, the +formatters may insert a line break between the number and the +dimension. Also, if you write a period after an abbreviation within a +sentence, you should write @samp{@@:} after the period to prevent +@TeX{} from inserting extra whitespace. @xref{Inserting Space}. + + +@node Inserting Accents, Dots Bullets, Inserting Space, Insertions +@section Inserting Accents + +@cindex Inserting accents +@cindex Accents, inserting +@cindex Floating accents, inserting + +Here is a table with the commands Texinfo provides for inserting +floating accents. The commands with non-alphabetic names do not take +braces around their argument (which is taken to be the next character). +(Exception: @code{@@,} @emph{does} take braces around its argument.) +This is so as to make the source as convenient to type and read as +possible, since accented characters are very common in some languages. + +@findex " +@cindex Umlaut accent +@findex ' +@cindex Acute accent +@findex = +@cindex Macron accent +@findex ^ +@cindex Circumflex accent +@findex ` +@cindex Grave accent +@findex ~ +@cindex Tilde accent +@findex , +@cindex Cedilla accent +@findex dotaccent +@cindex Dot accent +@findex H +@cindex Hungariam umlaut accent +@findex ringaccent +@cindex Ring accent +@findex tieaccent +@cindex Tie-after accent +@findex u +@cindex Breve accent +@findex ubaraccent +@cindex Underbar accent +@findex udotaccent +@cindex Underdot accent +@findex v +@cindex Check accent +@multitable {@@questiondown@{@}} {Output} {macron/overbar accent} +@item Command @tab Output @tab What +@item @t{@@"o} @tab @"o @tab umlaut accent +@item @t{@@'o} @tab @'o @tab acute accent +@item @t{@@,@{c@}} @tab @,{c} @tab cedilla accent +@item @t{@@=o} @tab @=o @tab macron/overbar accent +@item @t{@@^o} @tab @^o @tab circumflex accent +@item @t{@@`o} @tab @`o @tab grave accent +@item @t{@@~o} @tab @~o @tab tilde accent +@item @t{@@dotaccent@{o@}} @tab @dotaccent{o} @tab overdot accent +@item @t{@@H@{o@}} @tab @H{o} @tab long Hungarian umlaut +@item @t{@@ringaccent@{o@}} @tab @ringaccent{o} @tab ring accent +@item @t{@@tieaccent@{oo@}} @tab @tieaccent{oo} @tab tie-after accent +@item @t{@@u@{o@}} @tab @u{o} @tab breve accent +@item @t{@@ubaraccent@{o@}} @tab @ubaraccent{o} @tab underbar accent +@item @t{@@udotaccent@{o@}} @tab @udotaccent{o} @tab underdot accent +@item @t{@@v@{o@}} @tab @v{o} @tab hacek or check accent +@end multitable + +This table lists the Texinfo commands for inserting other characters +commonly used in languages other than English. + +@findex questiondown +@cindex @questiondown{} +@findex exclamdown +@cindex @exclamdown{} +@findex aa +@cindex @aa{} +@findex AA +@cindex @AA{} +@findex ae +@cindex @ae{} +@findex AE +@cindex @AE{} +@findex dotless +@cindex @dotless{i} +@cindex @dotless{j} +@cindex Dotless i, j +@findex l +@cindex @l{} +@findex L +@cindex @L{} +@findex o +@cindex @o{} +@findex O +@cindex @O{} +@findex oe +@cindex @oe{} +@findex OE +@cindex @OE{} +@findex ss +@cindex @ss{} +@cindex Es-zet +@cindex Sharp S +@cindex German S +@multitable {@@questiondown@{@}} {oe,OE} {es-zet or sharp S} +@item @t{@@exclamdown@{@}} @tab @exclamdown{} @tab upside-down ! +@item @t{@@questiondown@{@}} @tab @questiondown{} @tab upside-down ? +@item @t{@@aa@{@},@@AA@{@}} @tab @aa{},@AA{} @tab A,a with circle +@item @t{@@ae@{@},@@AE@{@}} @tab @ae{},@AE{} @tab ae,AE ligatures +@item @t{@@dotless@{i@}} @tab @dotless{i} @tab dotless i +@item @t{@@dotless@{j@}} @tab @dotless{j} @tab dotless j +@item @t{@@l@{@},@@L@{@}} @tab @l{},@L{} @tab suppressed-L,l +@item @t{@@o@{@},@@O@{@}} @tab @o{},@O{} @tab O,o with slash +@item @t{@@oe@{@},@@OE@{@}} @tab @oe{},@OE{} @tab OE,oe ligatures +@item @t{@@ss@{@}} @tab @ss{} @tab es-zet or sharp S +@end multitable + + +@node Dots Bullets, TeX and copyright, Inserting Accents, Insertions +@section Inserting Ellipsis, Dots, and Bullets +@cindex Dots, inserting +@cindex Bullets, inserting +@cindex Ellipsis, inserting +@cindex Inserting ellipsis +@cindex Inserting dots +@cindex Special typesetting commands +@cindex Typesetting commands for dots, etc. + +An @dfn{ellipsis} (a line of dots) is not typeset as a string of +periods, so a special command is used for ellipsis in Texinfo. The +@code{@@bullet} command is special, too. Each of these commands is +followed by a pair of braces, @samp{@{@}}, without any whitespace +between the name of the command and the braces. (You need to use braces +with these commands because you can use them next to other text; without +the braces, the formatters would be confused. @xref{Command Syntax, , +@@-Command Syntax}, for further information.)@refill + +@menu +* dots:: How to insert dots @dots{} +* bullet:: How to insert a bullet. +@end menu + +@node dots, bullet, Dots Bullets, Dots Bullets +@comment node-name, next, previous, up +@subsection @code{@@dots}@{@} +@findex dots +@cindex Inserting dots +@cindex Dots, inserting + +Use the @code{@@dots@{@}} command to generate an ellipsis, which is +three dots in a row, appropriately spaced, like this: `@dots{}'. Do +not simply write three periods in the input file; that would work for +the Info file output, but would produce the wrong amount of space +between the periods in the printed manual. + +Similarly, the @code{@@enddots@{@}} command generates an +end-of-sentence ellipsis (four dots) @enddots{} + +@iftex +Here is an ellipsis: @dots{} +Here are three periods in a row: ... + +In printed output, the three periods in a row are closer together than +the dots in the ellipsis. +@end iftex + +@node bullet, , dots, Dots Bullets +@comment node-name, next, previous, up +@subsection @code{@@bullet}@{@} +@findex bullet + +Use the @code{@@bullet@{@}} command to generate a large round dot, or +the closest possible thing to one. In Info, an asterisk is used.@refill + +Here is a bullet: @bullet{} + +When you use @code{@@bullet} in @code{@@itemize}, you do not need to +type the braces, because @code{@@itemize} supplies them. +(@xref{itemize, , @code{@@itemize}}.)@refill + +@node TeX and copyright, pounds, Dots Bullets, Insertions +@comment node-name, next, previous, up +@section Inserting @TeX{} and the Copyright Symbol + +The logo `@TeX{}' is typeset in a special fashion and it needs an +@@-command. The copyright symbol, `@copyright{}', is also special. +Each of these commands is followed by a pair of braces, @samp{@{@}}, +without any whitespace between the name of the command and the +braces.@refill + +@menu +* tex:: How to insert the @TeX{} logo. +* copyright symbol:: How to use @code{@@copyright}@{@}. +@end menu + +@node tex, copyright symbol, TeX and copyright, TeX and copyright +@comment node-name, next, previous, up +@subsection @code{@@TeX}@{@} +@findex tex (command) + +Use the @code{@@TeX@{@}} command to generate `@TeX{}'. In a printed +manual, this is a special logo that is different from three ordinary +letters. In Info, it just looks like @samp{TeX}. The +@code{@@TeX@{@}} command is unique among Texinfo commands in that the +@kbd{T} and the @kbd{X} are in upper case.@refill + +@node copyright symbol, , tex, TeX and copyright +@comment node-name, next, previous, up +@subsection @code{@@copyright}@{@} +@findex copyright + +Use the @code{@@copyright@{@}} command to generate `@copyright{}'. In +a printed manual, this is a @samp{c} inside a circle, and in Info, +this is @samp{(C)}.@refill + +@node pounds, minus, TeX and copyright, Insertions +@section @code{@@pounds}@{@} +@findex pounds + +Use the @code{@@pounds@{@}} command to generate `@pounds{}'. In a +printed manual, this is the symbol for the currency pounds sterling. +In Info, it is a @samp{#}. Other currency symbols are unfortunately not +available. + +@node minus, math, pounds, Insertions +@section @code{@@minus}@{@}: Inserting a Minus Sign +@findex minus + +Use the @code{@@minus@{@}} command to generate a minus sign. In a +fixed-width font, this is a single hyphen, but in a proportional font, +the symbol is the customary length for a minus sign---a little longer +than a hyphen.@refill + +You can compare the two forms: + +@display +@samp{@minus{}} is a minus sign generated with @samp{@@minus@{@}}, + +`-' is a hyphen generated with the character @samp{-}. +@end display + +@noindent +In the fixed-width font used by Info, @code{@@minus@{@}} is the same +as a hyphen.@refill + +You should not use @code{@@minus@{@}} inside @code{@@code} or +@code{@@example} because the width distinction is not made in the +fixed-width font they use.@refill + +When you use @code{@@minus} to specify the mark beginning each entry in +an itemized list, you do not need to type the braces +(@pxref{itemize, , @code{@@itemize}}.)@refill + +@node math, , minus, Insertions +@comment node-name, next, previous, up +@section @code{@@math}: Inserting Mathematical Expressions +@findex math +@cindex Mathematical expressions + +You can write a short mathematical expression with the @code{@@math} +command. Write the mathematical expression between braces, like this: + +@example +@@math@{(a + b)(a + b) = a^2 + 2ab + b^2@} +@end example + +@iftex +@need 1000 +@noindent +This produces the following in @TeX{}: + +@display +@math{(a + b)(a + b) = a^2 + 2ab + b^2} +@end display + +@noindent +and the following in Info: +@end iftex +@ifinfo +@noindent +This produces the following in Info: +@end ifinfo + +@example +(a + b)(a + b) = a^2 + 2ab + b^2 +@end example + +The @code{@@math} command has no effect on the Info output. Currently, +it has limited effect on typeset output. However, this may change since +@TeX{} itself is designed for mathematical typesetting and does a +splendid job. + +Certainly, for complex mathematical expressions, you could use @TeX{} +directly. @xref{Using Ordinary TeX Commands, , Using Ordinary @TeX{} +Commands}. When you use @TeX{} directly, remember to write the +mathematical expression between one or two @samp{$} (dollar-signs) as +appropriate. + +@node Glyphs, Breaks, Insertions, Top +@comment node-name, next, previous, up +@chapter Glyphs for Examples +@cindex Glyphs + +In Texinfo, code is often illustrated in examples that are delimited +by @code{@@example} and @code{@@end example}, or by @code{@@lisp} and +@code{@@end lisp}. In such examples, you can indicate the results of +evaluation or an expansion using @samp{@result{}} or +@samp{@expansion{}}. Likewise, there are commands to insert glyphs +to indicate +printed output, error messages, equivalence of expressions, and the +location of point.@refill + +The glyph-insertion commands do not need to be used within an example, but +most often they are. Every glyph-insertion command is followed by a pair of +left- and right-hand braces.@refill + +@menu +* Glyphs Summary:: +* result:: How to show the result of expression. +* expansion:: How to indicate an expansion. +* Print Glyph:: How to indicate printed output. +* Error Glyph:: How to indicate an error message. +* Equivalence:: How to indicate equivalence. +* Point Glyph:: How to indicate the location of point. +@end menu + +@node Glyphs Summary, result, Glyphs, Glyphs +@ifinfo +@heading Glyphs Summary + +Here are the different glyph commands:@refill +@end ifinfo + +@table @asis +@item @result{} +@code{@@result@{@}} points to the result of an expression.@refill + +@item @expansion{} +@code{@@expansion@{@}} shows the results of a macro expansion.@refill + +@item @print{} +@code{@@print@{@}} indicates printed output.@refill + +@item @error{} +@code{@@error@{@}} indicates that the following text is an error +message.@refill + +@item @equiv{} +@code{@@equiv@{@}} indicates the exact equivalence of two forms.@refill + +@item @point{} +@code{@@point@{@}} shows the location of point.@refill +@end table + +@node result, expansion, Glyphs Summary, Glyphs +@section @result{}: Indicating Evaluation +@cindex Result of an expression +@cindex Indicating evaluation +@cindex Evaluation glyph +@cindex Value of an expression, indicating + +Use the @code{@@result@{@}} command to indicate the result of +evaluating an expression.@refill + +@iftex +The @code{@@result@{@}} command is displayed as @samp{=>} in Info and +as @samp{@result{}} in the printed output. +@end iftex +@ifinfo +The @code{@@result@{@}} command is displayed as @samp{@result{}} in Info +and as a double stemmed arrow in the printed output.@refill +@end ifinfo + +Thus, the following, + +@lisp +(cdr '(1 2 3)) + @result{} (2 3) +@end lisp + +@noindent +may be read as ``@code{(cdr '(1 2 3))} evaluates to @code{(2 3)}''. + +@node expansion, Print Glyph, result, Glyphs +@section @expansion{}: Indicating an Expansion +@cindex Expansion, indicating it + +When an expression is a macro call, it expands into a new expression. +You can indicate the result of the expansion with the +@code{@@expansion@{@}} command.@refill + +@iftex +The @code{@@expansion@{@}} command is displayed as @samp{==>} in Info and +as @samp{@expansion{}} in the printed output. +@end iftex +@ifinfo +The @code{@@expansion@{@}} command is displayed as @samp{@expansion{}} +in Info and as a long arrow with a flat base in the printed output.@refill +@end ifinfo + +@need 700 +For example, the following + +@example +@group +@@lisp +(third '(a b c)) + @@expansion@{@} (car (cdr (cdr '(a b c)))) + @@result@{@} c +@@end lisp +@end group +@end example + +@noindent +produces + +@lisp +@group +(third '(a b c)) + @expansion{} (car (cdr (cdr '(a b c)))) + @result{} c +@end group +@end lisp + +@noindent +which may be read as: + +@quotation +@code{(third '(a b c))} expands to @code{(car (cdr (cdr '(a b c))))}; +the result of evaluating the expression is @code{c}. +@end quotation + +@noindent +Often, as in this case, an example looks better if the +@code{@@expansion@{@}} and @code{@@result@{@}} commands are indented +five spaces.@refill + +@node Print Glyph, Error Glyph, expansion, Glyphs +@section @print{}: Indicating Printed Output +@cindex Printed output, indicating it + +Sometimes an expression will print output during its execution. You +can indicate the printed output with the @code{@@print@{@}} command.@refill + +@iftex +The @code{@@print@{@}} command is displayed as @samp{-|} in Info and +as @samp{@print{}} in the printed output. +@end iftex +@ifinfo +The @code{@@print@{@}} command is displayed as @samp{@print{}} in Info +and similarly, as a horizontal dash butting against a vertical bar, in +the printed output.@refill +@end ifinfo + +In the following example, the printed text is indicated with +@samp{@print{}}, and the value of the expression follows on the +last line.@refill + +@lisp +@group +(progn (print 'foo) (print 'bar)) + @print{} foo + @print{} bar + @result{} bar +@end group +@end lisp + +@noindent +In a Texinfo source file, this example is written as follows: + +@lisp +@group +@@lisp +(progn (print 'foo) (print 'bar)) + @@print@{@} foo + @@print@{@} bar + @@result@{@} bar +@@end lisp +@end group +@end lisp + +@node Error Glyph, Equivalence, Print Glyph, Glyphs +@section @error{}: Indicating an Error Message +@cindex Error message, indicating it + +A piece of code may cause an error when you evaluate it. You can +designate the error message with the @code{@@error@{@}} command.@refill + +@iftex +The @code{@@error@{@}} command is displayed as @samp{error-->} in Info +and as @samp{@error{}} in the printed output. +@end iftex +@ifinfo +The @code{@@error@{@}} command is displayed as @samp{@error{}} in Info +and as the word `error' in a box in the printed output.@refill +@end ifinfo + +@need 700 +Thus, + +@example +@@lisp +(+ 23 'x) +@@error@{@} Wrong type argument: integer-or-marker-p, x +@@end lisp +@end example + +@noindent +produces + +@lisp +(+ 23 'x) +@error{} Wrong type argument: integer-or-marker-p, x +@end lisp + +@noindent +This indicates that the following error message is printed +when you evaluate the expression: + +@lisp +Wrong type argument: integer-or-marker-p, x +@end lisp + +Note that @samp{@error{}} itself is not part of the error +message. + +@node Equivalence, Point Glyph, Error Glyph, Glyphs +@section @equiv{}: Indicating Equivalence +@cindex Equivalence, indicating it + +Sometimes two expressions produce identical results. You can indicate the +exact equivalence of two forms with the @code{@@equiv@{@}} command.@refill + +@iftex +The @code{@@equiv@{@}} command is displayed as @samp{==} in Info and +as @samp{@equiv{}} in the printed output. +@end iftex +@ifinfo +The @code{@@equiv@{@}} command is displayed as @samp{@equiv{}} in Info +and as a three parallel horizontal lines in the printed output.@refill +@end ifinfo + +Thus, + +@example +@@lisp +(make-sparse-keymap) @@equiv@{@} (list 'keymap) +@@end lisp +@end example + +@noindent +produces + +@lisp +(make-sparse-keymap) @equiv{} (list 'keymap) +@end lisp + +@noindent +This indicates that evaluating @code{(make-sparse-keymap)} produces +identical results to evaluating @code{(list 'keymap)}. + +@c Cannot write point command here because it causes trouble with TOC. +@node Point Glyph, , Equivalence, Glyphs +@section Indicating Point in a Buffer +@cindex Point, indicating it in a buffer + +Sometimes you need to show an example of text in an Emacs buffer. In +such examples, the convention is to include the entire contents of the +buffer in question between two lines of dashes containing the buffer +name.@refill + +You can use the @samp{@@point@{@}} command to show the location of point +in the text in the buffer. (The symbol for point, of course, is not +part of the text in the buffer; it indicates the place @emph{between} +two characters where point is located.)@refill + +@iftex +The @code{@@point@{@}} command is displayed as @samp{-!-} in Info and +as @samp{@point{}} in the printed output. +@end iftex +@ifinfo +The @code{@@point@{@}} command is displayed as @samp{@point{}} in Info +and as a small five pointed star in the printed output.@refill +@end ifinfo + +The following example shows the contents of buffer @file{foo} before +and after evaluating a Lisp command to insert the word @code{changed}.@refill + +@example +@group +---------- Buffer: foo ---------- +This is the @point{}contents of foo. +---------- Buffer: foo ---------- + +@end group +@end example + +@example +@group +(insert "changed ") + @result{} nil +---------- Buffer: foo ---------- +This is the changed @point{}contents of foo. +---------- Buffer: foo ---------- + +@end group +@end example + +In a Texinfo source file, the example is written like this:@refill + +@example +@@example +---------- Buffer: foo ---------- +This is the @@point@{@}contents of foo. +---------- Buffer: foo ---------- + +(insert "changed ") + @@result@{@} nil +---------- Buffer: foo ---------- +This is the changed @@point@{@}contents of foo. +---------- Buffer: foo ---------- +@@end example +@end example + +@node Breaks, Definition Commands, Glyphs, Top +@comment node-name, next, previous, up +@chapter Making and Preventing Breaks +@cindex Making line and page breaks +@cindex Preventing line and page breaks + +Usually, a Texinfo file is processed both by @TeX{} and by one of the +Info formatting commands. Line, paragraph, or page breaks sometimes +occur in the `wrong' place in one or other form of output. You must +ensure that text looks right both in the printed manual and in the +Info file.@refill + +For example, in a printed manual, page breaks may occur awkwardly in +the middle of an example; to prevent this, you can hold text together +using a grouping command that keeps the text from being split across +two pages. Conversely, you may want to force a page break where none +would occur normally. Fortunately, problems like these do not often +arise. When they do, use the break, break prevention, or pagination +commands.@refill + +@menu +* Break Commands:: Cause and prevent splits. +* Line Breaks:: How to force a single line to use two lines. +* - and hyphenation:: How to tell TeX about hyphenation points. +* w:: How to prevent unwanted line breaks. +* sp:: How to insert blank lines. +* page:: How to force the start of a new page. +* group:: How to prevent unwanted page breaks. +* need:: Another way to prevent unwanted page breaks. +@end menu + +@ifinfo +@node Break Commands, Line Breaks, Breaks, Breaks +@heading The Break Commands +@end ifinfo +@iftex +@sp 1 +@end iftex + +The break commands create or allow line and paragraph breaks:@refill + +@table @code +@item @@* +Force a line break. + +@item @@sp @var{n} +Skip @var{n} blank lines.@refill + +@item @@- +Insert a discretionary hyphen. + +@item @@hyphenation@{@var{hy-phen-a-ted words}@} +Define hyphen points in @var{hy-phen-a-ted words}. +@end table + +The line-break-prevention command holds text together all on one +line:@refill + +@table @code +@item @@w@{@var{text}@} +Prevent @var{text} from being split and hyphenated across two lines.@refill +@end table +@iftex +@sp 1 +@end iftex + +The pagination commands apply only to printed output, since Info +files do not have pages.@refill + +@table @code +@item @@page +Start a new page in the printed manual.@refill + +@item @@group +Hold text together that must appear on one printed page.@refill + +@item @@need @var{mils} +Start a new printed page if not enough space on this one.@refill +@end table + +@node Line Breaks, - and hyphenation, Break Commands, Breaks +@comment node-name, next, previous, up +@section @code{@@*}: Generate Line Breaks +@findex * @r{(force line break)} +@cindex Line breaks +@cindex Breaks in a line + +The @code{@@*} command forces a line break in both the printed manual and +in Info.@refill + +@need 700 +For example, + +@example +This line @@* is broken @@*in two places. +@end example + +@noindent +produces + +@example +@group +This line + is broken +in two places. +@end group +@end example + +@noindent +(Note that the space after the first @code{@@*} command is faithfully +carried down to the next line.)@refill + +@need 800 +The @code{@@*} command is often used in a file's copyright page:@refill + +@example +@group +This is edition 2.0 of the Texinfo documentation,@@* +and is for @dots{} +@end group +@end example + +@noindent +In this case, the @code{@@*} command keeps @TeX{} from stretching the +line across the whole page in an ugly manner.@refill + +@quotation +@strong{Please note:} Do not write braces after an @code{@@*} command; +they are not needed.@refill + +Do not write an @code{@@refill} command at the end of a paragraph +containing an @code{@@*} command; it will cause the paragraph to be +refilled after the line break occurs, negating the effect of the line +break.@refill +@end quotation + +@node - and hyphenation, w, Line Breaks, Breaks +@section @code{@@-} and @code{@@hyphenation}: Helping @TeX{} hyphenate + +@findex - +@findex hyphenation +@cindex Hyphenation, helping @TeX{} do +@cindex Fine-tuning, and hyphenation + +Although @TeX{}'s hyphenation algorithm is generally pretty good, it +does miss useful hyphenation points from time to time. (Or, far more +rarely, insert an incorrect hyphenation.) So, for documents with an +unusual vocabulary or when fine-tuning for a printed edition, you may +wish to help @TeX{} out. Texinfo supports two commands for this: + +@table @code +@item @@- +Insert a discretionary hyphen, i.e., a place where @TeX{} can (but does +not have to) hyphenate. This is especially useful when you notice +an overfull hbox is due to @TeX{} missing a hyphenation (@pxref{Overfull +hboxes}). @TeX{} will not insert any hyphenation points in a word +containing @code{@@-}. + +@item @@hyphenation@{@var{hy-phen-a-ted words}@} +Tell @TeX{} how to hyphenate @var{hy-phen-a-ted words}. As shown, you +put a @samp{-} at each hyphenation point. For example: +@example +@@hyphenation@{man-u-script man-u-scripts@} +@end example +@noindent @TeX{} only uses the specified hyphenation points when the +words match exactly, so give all necessary variants. +@end table + +Info output is not hyphenated, so these commands have no effect there. + +@node w, sp, - and hyphenation, Breaks +@comment node-name, next, previous, up +@section @code{@@w}@{@var{text}@}: Prevent Line Breaks +@findex w @r{(prevent line break)} +@cindex Line breaks, preventing +@cindex Hyphenation, preventing + +@code{@@w@{@var{text}@}} outputs @var{text} and prohibits line breaks +within @var{text}.@refill + +You can use the @code{@@w} command to prevent @TeX{} from automatically +hyphenating a long name or phrase that accidentally falls near the end +of a line.@refill + +@example +You can copy GNU software from @@w@{@@file@{prep.ai.mit.edu@}@}. +@end example + +@noindent +produces + +@quotation +You can copy GNU software from @w{@file{prep.ai.mit.edu}}. +@end quotation + +@quotation +@strong{Caution:} Do not write an @code{@@refill} command at the end +of a paragraph containing an @code{@@w} command; it will cause the +paragraph to be refilled and may thereby negate the effect of the +@code{@@w} command.@refill +@end quotation + +@node sp, page, w, Breaks +@comment node-name, next, previous, up +@section @code{@@sp} @var{n}: Insert Blank Lines +@findex sp @r{(line spacing)} +@cindex Spaces (blank lines) +@cindex Blank lines +@cindex Line spacing + +A line beginning with and containing only @code{@@sp @var{n}} +generates @var{n} blank lines of space in both the printed manual and +the Info file. @code{@@sp} also forces a paragraph break. For +example,@refill + +@example +@@sp 2 +@end example + +@noindent +generates two blank lines. + +The @code{@@sp} command is most often used in the title page.@refill + +@ignore +@c node br, page, sp, Breaks +@comment node-name, next, previous, up +@c section @code{@@br}: Generate Paragraph Breaks +@findex br @r{(paragraph breaks)} +@cindex Paragraph breaks +@cindex Breaks in a paragraph + +The @code{@@br} command forces a paragraph break. It inserts a blank +line. You can use the command within or at the end of a line. If +used within a line, the @code{@@br@{@}} command must be followed by +left and right braces (as shown here) to mark the end of the +command.@refill + +@need 700 +For example, + +@example +@group +This line @@br@{@}contains and is ended by paragraph breaks@@br +and is followed by another line. +@end group +@end example + +@noindent +produces + +@example +@group +This line + +contains and is ended by paragraph breaks + +and is followed by another line. +@end group +@end example + +The @code{@@br} command is seldom used. +@end ignore + +@node page, group, sp, Breaks +@comment node-name, next, previous, up +@section @code{@@page}: Start a New Page +@cindex Page breaks +@findex page + +A line containing only @code{@@page} starts a new page in a printed +manual. The command has no effect on Info files since they are not +paginated. An @code{@@page} command is often used in the @code{@@titlepage} +section of a Texinfo file to start the copyright page.@refill + +@node group, need, page, Breaks +@comment node-name, next, previous, up +@section @code{@@group}: Prevent Page Breaks +@cindex Group (hold text together vertically) +@cindex Holding text together vertically +@cindex Vertically holding text together +@findex group + +The @code{@@group} command (on a line by itself) is used inside an +@code{@@example} or similar construct to begin an unsplittable vertical +group, which will appear entirely on one page in the printed output. +The group is terminated by a line containing only @code{@@end group}. +These two lines produce no output of their own, and in the Info file +output they have no effect at all.@refill + +@c Once said that these environments +@c turn off vertical spacing between ``paragraphs''. +@c Also, quotation used to work, but doesn't in texinfo-2.72 +Although @code{@@group} would make sense conceptually in a wide +variety of contexts, its current implementation works reliably only +within @code{@@example} and variants, and within @code{@@display}, +@code{@@format}, @code{@@flushleft} and @code{@@flushright}. +@xref{Quotations and Examples}. (What all these commands have in +common is that each line of input produces a line of output.) In +other contexts, @code{@@group} can cause anomalous vertical +spacing.@refill + +@need 750 +This formatting requirement means that you should write: + +@example +@group +@@example +@@group +@dots{} +@@end group +@@end example +@end group +@end example + +@noindent +with the @code{@@group} and @code{@@end group} commands inside the +@code{@@example} and @code{@@end example} commands. + +The @code{@@group} command is most often used to hold an example +together on one page. In this Texinfo manual, more than 100 examples +contain text that is enclosed between @code{@@group} and @code{@@end +group}. + +If you forget to end a group, you may get strange and unfathomable +error messages when you run @TeX{}. This is because @TeX{} keeps +trying to put the rest of the Texinfo file onto the one page and does +not start to generate error messages until it has processed +considerable text. It is a good rule of thumb to look for a missing +@code{@@end group} if you get incomprehensible error messages in +@TeX{}.@refill + +@node need, , group, Breaks +@comment node-name, next, previous, up +@section @code{@@need @var{mils}}: Prevent Page Breaks +@cindex Need space at page bottom +@findex need + +A line containing only @code{@@need @var{n}} starts +a new page in a printed manual if fewer than @var{n} mils (thousandths +of an inch) remain on the current page. Do not use +braces around the argument @var{n}. The @code{@@need} command has no +effect on Info files since they are not paginated.@refill + +@need 800 +This paragraph is preceded by an @code{@@need} command that tells +@TeX{} to start a new page if fewer than 800 mils (eight-tenths +inch) remain on the page. It looks like this:@refill + +@example +@group +@@need 800 +This paragraph is preceded by @dots{} +@end group +@end example + +The @code{@@need} command is useful for preventing orphans (single +lines at the bottoms of printed pages).@refill + +@node Definition Commands, Footnotes, Breaks, Top +@chapter Definition Commands +@cindex Definition commands + +The @code{@@deffn} command and the other @dfn{definition commands} +enable you to describe functions, variables, macros, commands, user +options, special forms and other such artifacts in a uniform +format.@refill + +In the Info file, a definition causes the entity +category---`Function', `Variable', or whatever---to appear at the +beginning of the first line of the definition, followed by the +entity's name and arguments. In the printed manual, the command +causes @TeX{} to print the entity's name and its arguments on the left +margin and print the category next to the right margin. In both +output formats, the body of the definition is indented. Also, the +name of the entity is entered into the appropriate index: +@code{@@deffn} enters the name into the index of functions, +@code{@@defvr} enters it into the index of variables, and so +on.@refill + +A manual need not and should not contain more than one definition for +a given name. An appendix containing a summary should use +@code{@@table} rather than the definition commands.@refill + +@menu +* Def Cmd Template:: How to structure a description using a + definition command. +* Optional Arguments:: How to handle optional and repeated arguments. +* deffnx:: How to group two or more `first' lines. +* Def Cmds in Detail:: All the definition commands. +* Def Cmd Conventions:: Conventions for writing definitions. +* Sample Function Definition:: +@end menu + +@node Def Cmd Template, Optional Arguments, Definition Commands, Definition Commands +@section The Template for a Definition +@cindex Definition template +@cindex Template for a definition + +The @code{@@deffn} command is used for definitions of entities that +resemble functions. To write a definition using the @code{@@deffn} +command, write the @code{@@deffn} command at the beginning of a line +and follow it on the same line by the category of the entity, the name +of the entity itself, and its arguments (if any). Then write the body +of the definition on succeeding lines. (You may embed examples in the +body.) Finally, end the definition with an @code{@@end deffn} command +written on a line of its own. (The other definition commands follow +the same format.)@refill + +The template for a definition looks like this: + +@example +@group +@@deffn @var{category} @var{name} @var{arguments}@dots{} +@var{body-of-definition} +@@end deffn +@end group +@end example + +@need 700 +@noindent +For example, + +@example +@group +@@deffn Command forward-word count +This command moves point forward @@var@{count@} words +(or backward if @@var@{count@} is negative). @dots{} +@@end deffn +@end group +@end example + +@noindent +produces + +@quotation +@deffn Command forward-word count +This function moves point forward @var{count} words +(or backward if @var{count} is negative). @dots{} +@end deffn +@end quotation + +Capitalize the category name like a title. If the name of the +category contains spaces, as in the phrase `Interactive Command', +write braces around it. For example:@refill + +@example +@group +@@deffn @{Interactive Command@} isearch-forward +@dots{} +@@end deffn +@end group +@end example + +@noindent +Otherwise, the second word will be mistaken for the name of the +entity.@refill + +Some of the definition commands are more general than others. The +@code{@@deffn} command, for example, is the general definition command +for functions and the like---for entities that may take arguments. When +you use this command, you specify the category to which the entity +belongs. The @code{@@deffn} command possesses three predefined, +specialized variations, @code{@@defun}, @code{@@defmac}, and +@code{@@defspec}, that specify the category for you: ``Function'', +``Macro'', and ``Special Form'' respectively. The @code{@@defvr} +command also is accompanied by several predefined, specialized +variations for describing particular kinds of variables.@refill + +The template for a specialized definition, such as @code{@@defun}, is +similar to the template for a generalized definition, except that you +do not need to specify the category:@refill + +@example +@group +@@defun @var{name} @var{arguments}@dots{} +@var{body-of-definition} +@@end defun +@end group +@end example + +@noindent +Thus, + +@example +@group +@@defun buffer-end flag +This function returns @@code@{(point-min)@} if @@var@{flag@} +is less than 1, @@code@{(point-max)@} otherwise. +@dots{} +@@end defun +@end group +@end example + +@noindent +produces + +@quotation +@defun buffer-end flag +This function returns @code{(point-min)} if @var{flag} is less than 1, +@code{(point-max)} otherwise. @dots{} +@end defun +@end quotation + +@noindent +@xref{Sample Function Definition, Sample Function Definition, A Sample +Function Definition}, for a more detailed example of a function +definition, including the use of @code{@@example} inside the +definition.@refill + +The other specialized commands work like @code{@@defun}.@refill + +@node Optional Arguments, deffnx, Def Cmd Template, Definition Commands +@section Optional and Repeated Arguments +@cindex Optional and repeated arguments +@cindex Repeated and optional arguments +@cindex Arguments, repeated and optional +@cindex Syntax, optional & repeated arguments +@cindex Meta-syntactic chars for arguments + +Some entities take optional or repeated arguments, which may be +specified by a distinctive glyph that uses square brackets and +ellipses. For @w{example}, a special form often breaks its argument list +into separate arguments in more complicated ways than a +straightforward function.@refill + +@iftex +An argument enclosed within square brackets is optional. +Thus, the phrase +@samp{@code{@r{[}@var{optional-arg}@r{]}}} means that +@var{optional-arg} is optional. +An argument followed by an ellipsis is optional +and may be repeated more than once. +@c This is consistent with Emacs Lisp Reference manual +Thus, @samp{@var{repeated-args}@dots{}} stands for zero or more arguments. +Parentheses are used when several arguments are grouped +into additional levels of list structure in Lisp. +@end iftex +@c The following looks better in Info (no `r', `samp' and `code'): +@ifinfo +An argument enclosed within square brackets is optional. +Thus, [@var{optional-arg}] means that @var{optional-arg} is optional. +An argument followed by an ellipsis is optional +and may be repeated more than once. +@c This is consistent with Emacs Lisp Reference manual +Thus, @var{repeated-args}@dots{} stands for zero or more arguments. +Parentheses are used when several arguments are grouped +into additional levels of list structure in Lisp. +@end ifinfo + +Here is the @code{@@defspec} line of an example of an imaginary +special form:@refill + +@quotation +@defspec foobar (@var{var} [@var{from} @var{to} [@var{inc}]]) @var{body}@dots{} +@end defspec +@tex +\vskip \parskip +@end tex +@end quotation + +@noindent +In this example, the arguments @var{from} and @var{to} are optional, +but must both be present or both absent. If they are present, +@var{inc} may optionally be specified as well. These arguments are +grouped with the argument @var{var} into a list, to distinguish them +from @var{body}, which includes all remaining elements of the +form.@refill + +In a Texinfo source file, this @code{@@defspec} line is written like +this (except it would not be split over two lines, as it is in this +example).@refill + +@example +@group +@@defspec foobar (@@var@{var@} [@@var@{from@} @@var@{to@} + [@@var@{inc@}]]) @@var@{body@}@@dots@{@} +@end group +@end example + +@noindent +The function is listed in the Command and Variable Index under +@samp{foobar}.@refill + +@node deffnx, Def Cmds in Detail, Optional Arguments, Definition Commands +@section Two or More `First' Lines +@cindex Two `First' Lines for @code{@@deffn} +@cindex Grouping two definitions together +@cindex Definitions grouped together +@findex deffnx + +To create two or more `first' or header lines for a definition, follow +the first @code{@@deffn} line by a line beginning with @code{@@deffnx}. +The @code{@@deffnx} command works exactly like @code{@@deffn} +except that it does not generate extra vertical white space between it +and the preceding line.@refill + +@need 1000 +For example, + +@example +@group +@@deffn @{Interactive Command@} isearch-forward +@@deffnx @{Interactive Command@} isearch-backward +These two search commands are similar except @dots{} +@@end deffn +@end group +@end example + +@noindent +produces + +@deffn {Interactive Command} isearch-forward +@deffnx {Interactive Command} isearch-backward +These two search commands are similar except @dots{} +@end deffn + +Each of the other definition commands has an `x' form: @code{@@defunx}, +@code{@@defvrx}, @code{@@deftypefunx}, etc. + +The `x' forms work just like @code{@@itemx}; see @ref{itemx, , @code{@@itemx}}. + +@node Def Cmds in Detail, Def Cmd Conventions, deffnx, Definition Commands +@section The Definition Commands + +Texinfo provides more than a dozen definition commands, all of which +are described in this section.@refill + +The definition commands automatically enter the name of the entity in +the appropriate index: for example, @code{@@deffn}, @code{@@defun}, +and @code{@@defmac} enter function names in the index of functions; +@code{@@defvr} and @code{@@defvar} enter variable names in the index +of variables.@refill + +Although the examples that follow mostly illustrate Lisp, the commands +can be used for other programming languages.@refill + +@menu +* Functions Commands:: Commands for functions and similar entities. +* Variables Commands:: Commands for variables and similar entities. +* Typed Functions:: Commands for functions in typed languages. +* Typed Variables:: Commands for variables in typed languages. +* Abstract Objects:: Commands for object-oriented programming. +* Data Types:: The definition command for data types. +@end menu + +@node Functions Commands, Variables Commands, Def Cmds in Detail, Def Cmds in Detail +@subsection Functions and Similar Entities + +This section describes the commands for describing functions and similar +entities:@refill + +@table @code +@findex deffn +@item @@deffn @var{category} @var{name} @var{arguments}@dots{} +The @code{@@deffn} command is the general definition command for +functions, interactive commands, and similar entities that may take +arguments. You must choose a term to describe the category of entity +being defined; for example, ``Function'' could be used if the entity is +a function. The @code{@@deffn} command is written at the beginning of a +line and is followed on the same line by the category of entity being +described, the name of this particular entity, and its arguments, if +any. Terminate the definition with @code{@@end deffn} on a line of its +own.@refill + +@need 750 +For example, here is a definition: + +@example +@group +@@deffn Command forward-char nchars +Move point forward @@var@{nchars@} characters. +@@end deffn +@end group +@end example + +@noindent +This shows a rather terse definition for a ``command'' named +@code{forward-char} with one argument, @var{nchars}. + +@code{@@deffn} prints argument names such as @var{nchars} in italics or +upper case, as if @code{@@var} had been used, because we think of these +names as metasyntactic variables---they stand for the actual argument +values. Within the text of the description, write an argument name +explicitly with @code{@@var} to refer to the value of the argument. In +the example above, we used @samp{@@var@{nchars@}} in this way. + +The template for @code{@@deffn} is: + +@example +@group +@@deffn @var{category} @var{name} @var{arguments}@dots{} +@var{body-of-definition} +@@end deffn +@end group +@end example + +@findex defun +@item @@defun @var{name} @var{arguments}@dots{} +The @code{@@defun} command is the definition command for functions. +@code{@@defun} is equivalent to @samp{@@deffn Function +@dots{}}.@refill + +@need 800 +@noindent +For example, + +@example +@group +@@defun set symbol new-value +Change the value of the symbol @@var@{symbol@} +to @@var@{new-value@}. +@@end defun +@end group +@end example + +@noindent +shows a rather terse definition for a function @code{set} whose +arguments are @var{symbol} and @var{new-value}. The argument names on +the @code{@@defun} line automatically appear in italics or upper case as +if they were enclosed in @code{@@var}. Terminate the definition with +@code{@@end defun} on a line of its own.@refill + +The template is: + +@example +@group +@@defun @var{function-name} @var{arguments}@dots{} +@var{body-of-definition} +@@end defun +@end group +@end example + +@code{@@defun} creates an entry in the index of functions. + +@findex defmac +@item @@defmac @var{name} @var{arguments}@dots{} +The @code{@@defmac} command is the definition command for macros. +@code{@@defmac} is equivalent to @samp{@@deffn Macro @dots{}} and +works like @code{@@defun}.@refill + +@findex defspec +@item @@defspec @var{name} @var{arguments}@dots{} +The @code{@@defspec} command is the definition command for special +forms. (In Lisp, a special form is an entity much like a function.) +@code{@@defspec} is equivalent to @samp{@@deffn @{Special Form@} +@dots{}} and works like @code{@@defun}.@refill +@end table + +@node Variables Commands, Typed Functions, Functions Commands, Def Cmds in Detail +@subsection Variables and Similar Entities + +Here are the commands for defining variables and similar +entities:@refill + +@table @code +@findex defvr +@item @@defvr @var{category} @var{name} +The @code{@@defvr} command is a general definition command for +something like a variable---an entity that records a value. You must +choose a term to describe the category of entity being defined; for +example, ``Variable'' could be used if the entity is a variable. +Write the @code{@@defvr} command at the beginning of a line and +followed it on the same line by the category of the entity and the +name of the entity.@refill + +Capitalize the category name like a title. If the name of the +category contains spaces, as in the name `User Option', write braces +around it. Otherwise, the second word will be mistaken for the name +of the entity, for example: + +@example +@group +@@defvr @{User Option@} fill-column +This buffer-local variable specifies +the maximum width of filled lines. +@dots{} +@@end defvr +@end group +@end example + +Terminate the definition with @code{@@end defvr} on a line of its +own.@refill + +The template is: + +@example +@group +@@defvr @var{category} @var{name} +@var{body-of-definition} +@@end defvr +@end group +@end example + +@code{@@defvr} creates an entry in the index of variables for @var{name}. + +@findex defvar +@item @@defvar @var{name} +The @code{@@defvar} command is the definition command for variables. +@code{@@defvar} is equivalent to @samp{@@defvr Variable +@dots{}}.@refill + +@need 750 +For example: + +@example +@group +@@defvar kill-ring +@dots{} +@@end defvar +@end group +@end example + +The template is: + +@example +@group +@@defvar @var{name} +@var{body-of-definition} +@@end defvar +@end group +@end example + +@code{@@defvar} creates an entry in the index of variables for +@var{name}.@refill + +@findex defopt +@item @@defopt @var{name} +The @code{@@defopt} command is the definition command for user +options. @code{@@defopt} is equivalent to @samp{@@defvr @{User +Option@} @dots{}} and works like @code{@@defvar}.@refill +@end table + +@node Typed Functions, Typed Variables, Variables Commands, Def Cmds in Detail +@subsection Functions in Typed Languages + +The @code{@@deftypefn} command and its variations are for describing +functions in C or any other language in which you must declare types +of variables and functions.@refill + +@table @code +@findex deftypefn +@item @@deftypefn @var{category} @var{data-type} @var{name} @var{arguments}@dots{} +The @code{@@deftypefn} command is the general definition command for +functions and similar entities that may take arguments and that are +typed. The @code{@@deftypefn} command is written at the beginning of +a line and is followed on the same line by the category of entity +being described, the type of the returned value, the name of this +particular entity, and its arguments, if any.@refill + +@need 800 +@noindent +For example, + +@example +@group +@@deftypefn @{Library Function@} int foobar + (int @@var@{foo@}, float @@var@{bar@}) +@dots{} +@@end deftypefn +@end group +@end example + +@need 1000 +@noindent +(where the text before the ``@dots{}'', shown above as two lines, would +actually be a single line in a real Texinfo file) produces the following +in Info: + +@smallexample +@group +-- Library Function: int foobar (int FOO, float BAR) +@dots{} +@end group +@end smallexample +@iftex + +In a printed manual, it produces: + +@quotation +@deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) +@dots{} +@end deftypefn +@end quotation +@end iftex + +This means that @code{foobar} is a ``library function'' that returns an +@code{int}, and its arguments are @var{foo} (an @code{int}) and +@var{bar} (a @code{float}).@refill + +The argument names that you write in @code{@@deftypefn} are not subject +to an implicit @code{@@var}---since the actual names of the arguments in +@code{@@deftypefn} are typically scattered among data type names and +keywords, Texinfo cannot find them without help. Instead, you must write +@code{@@var} explicitly around the argument names. In the example +above, the argument names are @samp{foo} and @samp{bar}.@refill + +The template for @code{@@deftypefn} is:@refill + +@example +@group +@@deftypefn @var{category} @var{data-type} @var{name} @var{arguments} @dots{} +@var{body-of-description} +@@end deftypefn +@end group +@end example + +@noindent +Note that if the @var{category} or @var{data type} is more than one +word then it must be enclosed in braces to make it a single argument.@refill + +If you are describing a procedure in a language that has packages, +such as Ada, you might consider using @code{@@deftypefn} in a manner +somewhat contrary to the convention described in the preceding +paragraphs.@refill + +@need 800 +@noindent +For example: + +@example +@group +@@deftypefn stacks private push + (@@var@{s@}:in out stack; + @@var@{n@}:in integer) +@dots{} +@@end deftypefn +@end group +@end example + +@noindent +(The @code{@@deftypefn} arguments are shown split into three lines, but +would be a single line in a real Texinfo file.) + +In this instance, the procedure is classified as belonging to the +package @code{stacks} rather than classified as a `procedure' and its +data type is described as @code{private}. (The name of the procedure +is @code{push}, and its arguments are @var{s} and @var{n}.)@refill + +@code{@@deftypefn} creates an entry in the index of functions for +@var{name}.@refill + +@findex deftypefun +@item @@deftypefun @var{data-type} @var{name} @var{arguments}@dots{} +The @code{@@deftypefun} command is the specialized definition command +for functions in typed languages. The command is equivalent to +@samp{@@deftypefn Function @dots{}}.@refill + +@need 800 +@noindent +Thus, + +@smallexample +@group +@@deftypefun int foobar (int @@var@{foo@}, float @@var@{bar@}) +@dots{} +@@end deftypefun +@end group +@end smallexample + +@noindent +produces the following in Info: + +@example +@group +-- Function: int foobar (int FOO, float BAR) +@dots{} +@end group +@end example +@iftex + +@need 800 +@noindent +and the following in a printed manual: + +@quotation +@deftypefun int foobar (int @var{foo}, float @var{bar}) +@dots{} +@end deftypefun +@end quotation +@end iftex + +@need 800 +The template is: + +@example +@group +@@deftypefun @var{type} @var{name} @var{arguments}@dots{} +@var{body-of-description} +@@end deftypefun +@end group +@end example + +@code{@@deftypefun} creates an entry in the index of functions for +@var{name}.@refill +@end table + +@node Typed Variables, Abstract Objects, Typed Functions, Def Cmds in Detail +@subsection Variables in Typed Languages + +Variables in typed languages are handled in a manner similar to +functions in typed languages. @xref{Typed Functions}. The general +definition command @code{@@deftypevr} corresponds to +@code{@@deftypefn} and the specialized definition command +@code{@@deftypevar} corresponds to @code{@@deftypefun}.@refill + +@table @code +@findex deftypevr +@item @@deftypevr @var{category} @var{data-type} @var{name} +The @code{@@deftypevr} command is the general definition command for +something like a variable in a typed language---an entity that records +a value. You must choose a term to describe the category of the +entity being defined; for example, ``Variable'' could be used if the +entity is a variable.@refill + +The @code{@@deftypevr} command is written at the beginning of a line +and is followed on the same line by the category of the entity +being described, the data type, and the name of this particular +entity.@refill + +@need 800 +@noindent +For example: + +@example +@group +@@deftypevr @{Global Flag@} int enable +@dots{} +@@end deftypevr +@end group +@end example + +@noindent +produces the following in Info: + +@example +@group +-- Global Flag: int enable +@dots{} +@end group +@end example +@iftex + +@noindent +and the following in a printed manual: + +@quotation +@deftypevr {Global Flag} int enable +@dots{} +@end deftypevr +@end quotation +@end iftex + +@need 800 +The template is: + +@example +@@deftypevr @var{category} @var{data-type} @var{name} +@var{body-of-description} +@@end deftypevr +@end example + +@code{@@deftypevr} creates an entry in the index of variables for +@var{name}.@refill + +@findex deftypevar +@item @@deftypevar @var{data-type} @var{name} +The @code{@@deftypevar} command is the specialized definition command +for variables in typed languages. @code{@@deftypevar} is equivalent +to @samp{@@deftypevr Variable @dots{}}.@refill + +@need 800 +@noindent +For example: + +@example +@group +@@deftypevar int fubar +@dots{} +@@end deftypevar +@end group +@end example + +@noindent +produces the following in Info: + +@example +@group +-- Variable: int fubar +@dots{} +@end group +@end example +@iftex + +@need 800 +@noindent +and the following in a printed manual: + +@quotation +@deftypevar int fubar +@dots{} +@end deftypevar +@end quotation +@end iftex + +@need 800 +@noindent +The template is: + +@example +@group +@@deftypevar @var{data-type} @var{name} +@var{body-of-description} +@@end deftypevar +@end group +@end example + +@code{@@deftypevar} creates an entry in the index of variables for +@var{name}.@refill +@end table + +@node Abstract Objects, Data Types, Typed Variables, Def Cmds in Detail +@subsection Object-Oriented Programming + +Here are the commands for formatting descriptions about abstract +objects, such as are used in object-oriented programming. A class is +a defined type of abstract object. An instance of a class is a +particular object that has the type of the class. An instance +variable is a variable that belongs to the class but for which each +instance has its own value.@refill + +In a definition, if the name of a class is truly a name defined in the +programming system for a class, then you should write an @code{@@code} +around it. Otherwise, it is printed in the usual text font.@refill + +@table @code +@findex defcv +@item @@defcv @var{category} @var{class} @var{name} +The @code{@@defcv} command is the general definition command for +variables associated with classes in object-oriented programming. The +@code{@@defcv} command is followed by three arguments: the category of +thing being defined, the class to which it belongs, and its +name. Thus,@refill + +@example +@group +@@defcv @{Class Option@} Window border-pattern +@dots{} +@@end defcv +@end group +@end example + +@noindent +illustrates how you would write the first line of a definition of the +@code{border-pattern} class option of the class @code{Window}.@refill + +The template is + +@example +@group +@@defcv @var{category} @var{class} @var{name} +@dots{} +@@end defcv +@end group +@end example + +@code{@@defcv} creates an entry in the index of variables. + +@findex defivar +@item @@defivar @var{class} @var{name} +The @code{@@defivar} command is the definition command for instance +variables in object-oriented programming. @code{@@defivar} is +equivalent to @samp{@@defcv @{Instance Variable@} @dots{}}@refill + +The template is: + +@example +@group +@@defivar @var{class} @var{instance-variable-name} +@var{body-of-definition} +@@end defivar +@end group +@end example + +@code{@@defivar} creates an entry in the index of variables. + +@findex defop +@item @@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} +The @code{@@defop} command is the general definition command for +entities that may resemble methods in object-oriented programming. +These entities take arguments, as functions do, but are associated +with particular classes of objects.@refill + +For example, some systems have constructs called @dfn{wrappers} that +are associated with classes as methods are, but that act more like +macros than like functions. You could use @code{@@defop Wrapper} to +describe one of these.@refill + +Sometimes it is useful to distinguish methods and @dfn{operations}. +You can think of an operation as the specification for a method. +Thus, a window system might specify that all window classes have a +method named @code{expose}; we would say that this window system +defines an @code{expose} operation on windows in general. Typically, +the operation has a name and also specifies the pattern of arguments; +all methods that implement the operation must accept the same +arguments, since applications that use the operation do so without +knowing which method will implement it.@refill + +Often it makes more sense to document operations than methods. For +example, window application developers need to know about the +@code{expose} operation, but need not be concerned with whether a +given class of windows has its own method to implement this operation. +To describe this operation, you would write:@refill + +@example +@@defop Operation windows expose +@end example + +The @code{@@defop} command is written at the beginning of a line and +is followed on the same line by the overall name of the category of +operation, the name of the class of the operation, the name of the +operation, and its arguments, if any.@refill + +@need 800 +@noindent +The template is: + +@example +@group +@@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} +@var{body-of-definition} +@@end defop +@end group +@end example + +@code{@@defop} creates an entry, such as `@code{expose} on +@code{windows}', in the index of functions.@refill + +@findex defmethod +@item @@defmethod @var{class} @var{name} @var{arguments}@dots{} +The @code{@@defmethod} command is the definition command for methods +in object-oriented programming. A method is a kind of function that +implements an operation for a particular class of objects and its +subclasses. In the Lisp Machine, methods actually were functions, but +they were usually defined with @code{defmethod}. + +@code{@@defmethod} is equivalent to @samp{@@defop Method @dots{}}. +The command is written at the beginning of a line and is followed by +the name of the class of the method, the name of the method, and its +arguments, if any.@refill + +@need 800 +@noindent +For example, + +@example +@group +@@defmethod @code{bar-class} bar-method argument +@dots{} +@@end defmethod +@end group +@end example + +@noindent +illustrates the definition for a method called @code{bar-method} of +the class @code{bar-class}. The method takes an argument.@refill + +The template is: + +@example +@group +@@defmethod @var{class} @var{method-name} @var{arguments}@dots{} +@var{body-of-definition} +@@end defmethod +@end group +@end example + +@code{@@defmethod} creates an entry, such as `@code{bar-method} on +@code{bar-class}', in the index of functions.@refill +@end table + +@node Data Types, , Abstract Objects, Def Cmds in Detail +@subsection Data Types + +Here is the command for data types:@refill + +@table @code +@findex deftp +@item @@deftp @var{category} @var{name} @var{attributes}@dots{} +The @code{@@deftp} command is the generic definition command for data +types. The command is written at the beginning of a line and is +followed on the same line by the category, by the name of the type +(which is a word like @code{int} or @code{float}), and then by names of +attributes of objects of that type. Thus, you could use this command +for describing @code{int} or @code{float}, in which case you could use +@code{data type} as the category. (A data type is a category of +certain objects for purposes of deciding which operations can be +performed on them.)@refill + +In Lisp, for example, @dfn{pair} names a particular data +type, and an object of that type has two slots called the +@sc{car} and the @sc{cdr}. Here is how you would write the first line +of a definition of @code{pair}.@refill + +@example +@group +@@deftp @{Data type@} pair car cdr +@dots{} +@@end deftp +@end group +@end example + +@need 950 +The template is: + +@example +@group +@@deftp @var{category} @var{name-of-type} @var{attributes}@dots{} +@var{body-of-definition} +@@end deftp +@end group +@end example + +@code{@@deftp} creates an entry in the index of data types. +@end table + +@node Def Cmd Conventions, Sample Function Definition, Def Cmds in Detail, Definition Commands +@section Conventions for Writing Definitions +@cindex Definition conventions +@cindex Conventions for writing definitions + +When you write a definition using @code{@@deffn}, @code{@@defun}, or +one of the other definition commands, please take care to use +arguments that indicate the meaning, as with the @var{count} argument +to the @code{forward-word} function. Also, if the name of an argument +contains the name of a type, such as @var{integer}, take care that the +argument actually is of that type.@refill + +@node Sample Function Definition, , Def Cmd Conventions, Definition Commands +@section A Sample Function Definition +@cindex Function definitions +@cindex Command definitions +@cindex Macro definitions +@cindex Sample function definition + +A function definition uses the @code{@@defun} and @code{@@end defun} +commands. The name of the function follows immediately after the +@code{@@defun} command and it is followed, on the same line, by the +parameter list.@refill + +Here is a definition from @cite{The GNU Emacs Lisp Reference Manual}. +(@xref{Calling Functions, , Calling Functions, elisp, The GNU Emacs +Lisp Reference Manual}.) + +@quotation +@defun apply function &rest arguments +@code{apply} calls @var{function} with @var{arguments}, just +like @code{funcall} but with one difference: the last of +@var{arguments} is a list of arguments to give to +@var{function}, rather than a single argument. We also say +that this list is @dfn{appended} to the other arguments. + +@code{apply} returns the result of calling @var{function}. +As with @code{funcall}, @var{function} must either be a Lisp +function or a primitive function; special forms and macros +do not make sense in @code{apply}. + +@example +(setq f 'list) + @result{} list +(apply f 'x 'y 'z) +@error{} Wrong type argument: listp, z +(apply '+ 1 2 '(3 4)) + @result{} 10 +(apply '+ '(1 2 3 4)) + @result{} 10 + +(apply 'append '((a b c) nil (x y z) nil)) + @result{} (a b c x y z) +@end example + +An interesting example of using @code{apply} is found in the description +of @code{mapcar}.@refill +@end defun +@end quotation + +@need 1200 +In the Texinfo source file, this example looks like this: + +@example +@group +@@defun apply function &rest arguments + +@@code@{apply@} calls @@var@{function@} with +@@var@{arguments@}, just like @@code@{funcall@} but with one +difference: the last of @@var@{arguments@} is a list of +arguments to give to @@var@{function@}, rather than a single +argument. We also say that this list is @@dfn@{appended@} +to the other arguments. +@end group + +@group +@@code@{apply@} returns the result of calling +@@var@{function@}. As with @@code@{funcall@}, +@@var@{function@} must either be a Lisp function or a +primitive function; special forms and macros do not make +sense in @@code@{apply@}. +@end group + +@group +@@example +(setq f 'list) + @@result@{@} list +(apply f 'x 'y 'z) +@@error@{@} Wrong type argument: listp, z +(apply '+ 1 2 '(3 4)) + @@result@{@} 10 +(apply '+ '(1 2 3 4)) + @@result@{@} 10 + +(apply 'append '((a b c) nil (x y z) nil)) + @@result@{@} (a b c x y z) +@@end example +@end group + +@group +An interesting example of using @@code@{apply@} is found +in the description of @@code@{mapcar@}.@@refill +@@end defun +@end group +@end example + +@noindent +In this manual, this function is listed in the Command and Variable +Index under @code{apply}.@refill + +Ordinary variables and user options are described using a format like +that for functions except that variables do not take arguments. + +@node Footnotes, Conditionals, Definition Commands, Top +@comment node-name, next, previous, up +@chapter Footnotes +@cindex Footnotes +@findex footnote + +A @dfn{footnote} is for a reference that documents or elucidates the +primary text.@footnote{A footnote should complement or expand upon +the primary text, but a reader should not need to read a footnote to +understand the primary text. For a thorough discussion of footnotes, +see @cite{The Chicago Manual of Style}, which is published by the +University of Chicago Press.}@refill + +@menu +* Footnote Commands:: How to write a footnote in Texinfo. +* Footnote Styles:: Controlling how footnotes appear in Info. +@end menu + +@node Footnote Commands, Footnote Styles, Footnotes, Footnotes +@section Footnote Commands + +In Texinfo, footnotes are created with the @code{@@footnote} command. +This command is followed immediately by a left brace, then by the text +of the footnote, and then by a terminating right brace. The template +is: + +@example +@@footnote@{@var{text}@} +@end example + +Footnotes may be of any length, but are usually short.@refill + +For example, this clause is followed by a sample +footnote@footnote{Here is the sample footnote.}; in the Texinfo +source, it looks like this:@refill + +@example +@dots{}a sample footnote @@footnote@{Here is the sample +footnote.@}; in the Texinfo source@dots{} +@end example + +@strong{Warning:} Don't use footnotes in the argument of the +@code{@@item} command for a @code{@@table} table. This doesn't work; +because of limitations of @TeX{}, there is no way to fix it. To avoid +the problem, move the footnote into the body text of the table. + +In a printed manual or book, the reference mark for a footnote is a +small, superscripted number; the text of the footnote appears at the +bottom of the page, below a horizontal line.@refill + +In Info, the reference mark for a footnote is a pair of parentheses +with the footnote number between them, like this: @samp{(1)}.@refill + +@node Footnote Styles, , Footnote Commands, Footnotes +@section Footnote Styles + +Info has two footnote styles, which determine where the text of the +footnote is located:@refill + +@itemize @bullet +@cindex @samp{@r{End}} node footnote style +@item +In the `End' node style, all the footnotes for a single node +are placed at the end of that node. The footnotes are separated from +the rest of the node by a line of dashes with the word +@samp{Footnotes} within it. Each footnote begins with an +@samp{(@var{n})} reference mark.@refill + +@need 700 +@noindent +Here is an example of a single footnote in the end of node style:@refill + +@example +@group + --------- Footnotes --------- + +(1) Here is a sample footnote. +@end group +@end example + +@cindex @samp{@r{Separate}} footnote style +@item +In the `Separate' node style, all the footnotes for a single +node are placed in an automatically constructed node of +their own. In this style, a ``footnote reference'' follows +each @samp{(@var{n})} reference mark in the body of the +node. The footnote reference is actually a cross reference +which you use to reach the footnote node.@refill + +The name of the node containing the footnotes is constructed +by appending @w{@samp{-Footnotes}} to the name of the node +that contains the footnotes. (Consequently, the footnotes' +node for the @file{Footnotes} node is +@w{@file{Footnotes-Footnotes}}!) The footnotes' node has an +`Up' node pointer that leads back to its parent node.@refill + +@noindent +Here is how the first footnote in this manual looks after being +formatted for Info in the separate node style:@refill + +@smallexample +@group +File: texinfo.info Node: Overview-Footnotes, Up: Overview + +(1) Note that the first syllable of "Texinfo" is +pronounced like "speck", not "hex". @dots{} +@end group +@end smallexample +@end itemize + +A Texinfo file may be formatted into an Info file with either footnote +style.@refill + +@findex footnotestyle +Use the @code{@@footnotestyle} command to specify an Info file's +footnote style. Write this command at the beginning of a line followed +by an argument, either @samp{end} for the end node style or +@samp{separate} for the separate node style. + +@need 700 +For example, + +@example +@@footnotestyle end +@end example +@noindent +or +@example +@@footnotestyle separate +@end example + +Write an @code{@@footnotestyle} command before or shortly after the +end-of-header line at the beginning of a Texinfo file. (If you +include the @code{@@footnotestyle} command between the start-of-header +and end-of-header lines, the region formatting commands will format +footnotes as specified.)@refill + +If you do not specify a footnote style, the formatting commands use +their default style. Currently, @code{texinfo-format-buffer} and +@code{texinfo-format-region} use the `separate' style and +@code{makeinfo} uses the `end' style.@refill + +@c !!! note: makeinfo's --footnote-style option overrides footnotestyle +@ignore +If you use @code{makeinfo} to create the Info file, the +@samp{--footnote-style} option determines which style is used, +@samp{end} for the end of node style or @samp{separate} for the +separate node style. Thus, to format the Texinfo manual in the +separate node style, you would use the following shell command:@refill + +@example +makeinfo --footnote-style=separate texinfo.texi +@end example + +@noindent +To format the Texinfo manual in the end of node style, you would +type:@refill + +@example +makeinfo --footnote-style=end texinfo.texi +@end example +@end ignore +@ignore +If you use @code{texinfo-format-buffer} or +@code{texinfo-format-region} to create the Info file, the value of the +@code{texinfo-footnote-style} variable controls the footnote style. +It can be either @samp{"separate"} for the separate node style or +@samp{"end"} for the end of node style. (You can change the value of +this variable with the @kbd{M-x edit-options} command (@pxref{Edit +Options, , Editing Variable Values, emacs, The GNU Emacs Manual}), or +with the @kbd{M-x set-variable} command (@pxref{Examining, , Examining +and Setting Variables, emacs, The GNU Emacs Manual}).@refill + +The @code{texinfo-footnote-style} variable also controls the style if +you use the @kbd{M-x makeinfo-region} or @kbd{M-x makeinfo-buffer} +command in Emacs.@refill +@end ignore +This chapter contains two footnotes.@refill + +@node Conditionals, Macros, Footnotes, Top +@comment node-name, next, previous, up +@chapter Conditionally Visible Text +@cindex Conditionally visible text +@cindex Text, conditionally visible +@cindex Visibility of conditional text +@cindex If text conditionally visible +@findex ifhtml +@findex ifinfo +@findex iftex + +Sometimes it is good to use different text for a printed manual and +its corresponding Info file. In this case, you can use the +@dfn{conditional commands} to specify which text is for the printed manual +and which is for the Info file.@refill + +@menu +* Conditional Commands:: How to specify text for HTML, Info, or @TeX{}. +* Using Ordinary TeX Commands:: You can use any and all @TeX{} commands. +* set clear value:: How to designate which text to format (for + both Info and @TeX{}); and how to set a + flag to a string that you can insert. +@end menu + +@node Conditional Commands, Using Ordinary TeX Commands, Conditionals, Conditionals +@ifinfo +@heading Using @code{@@ifinfo} and @code{@@iftex} +@end ifinfo + +@code{@@ifinfo} begins segments of text that should be ignored +by @TeX{} when it +typesets the printed manual. The segment of text appears only +in the Info file. +The @code{@@ifinfo} command should appear on a line by itself; end +the Info-only text with a line containing @code{@@end ifinfo} by +itself. At the beginning of a Texinfo file, the Info permissions are +contained within a region marked by @code{@@ifinfo} and @code{@@end +ifinfo}. (@xref{Info Summary and Permissions}.)@refill + +The @code{@@iftex} and @code{@@end iftex} commands are similar to the +@code{@@ifinfo} and @code{@@end ifinfo} commands, except that they +specify text that will appear in the printed manual but not in the Info +file. Likewise for @code{@@ifhtml} and @code{@@end ifhtml}, which +specify text to appear only in HTML output.@refill + +@need 700 +For example, + +@example +@@iftex +This text will appear only in the printed manual. +@@end iftex + +@@ifinfo +However, this text will appear only in Info. +@@end ifinfo +@end example + +@noindent +The preceding example produces the following line: + +@iftex +This text will appear only in the printed manual. +@end iftex + +@ifinfo +However, this text will appear only in Info. +@end ifinfo + +@noindent +Note how you only see one of the two lines, depending on whether you +are reading the Info version or the printed version of this +manual.@refill + +The @code{@@titlepage} command is a special variant of @code{@@iftex} that +is used for making the title and copyright pages of the printed +manual. (@xref{titlepage, , @code{@@titlepage}}.) @refill + +@node Using Ordinary TeX Commands, set clear value, Conditional Commands, Conditionals +@comment node-name, next, previous, up +@section Using Ordinary @TeX{} Commands +@cindex @TeX{} commands, using ordinary +@cindex Ordinary @TeX{} commands, using +@cindex Commands using ordinary @TeX{} +@cindex plain @TeX{} + +Inside a region delineated by @code{@@iftex} and @code{@@end iftex}, +you can embed some plain @TeX{} commands. Info will ignore these +commands since they are only in that part of the file which is seen by +@TeX{}. You can write the @TeX{} commands as you would write them in +a normal @TeX{} file, except that you must replace the @samp{\} used +by @TeX{} with an @samp{@@}. For example, in the @code{@@titlepage} +section of a Texinfo file, you can use the @TeX{} command +@code{@@vskip} to format the copyright page. (The @code{@@titlepage} +command causes Info to ignore the region automatically, as it does +with the @code{@@iftex} command.)@refill + +However, many features of plain @TeX{} will not work, as they are +overridden by features of Texinfo. + +@findex tex +You can enter plain @TeX{} completely, and use @samp{\} in the @TeX{} +commands, by delineating a region with the @code{@@tex} and @code{@@end +tex} commands. (The @code{@@tex} command also causes Info to ignore the +region, like the @code{@@iftex} +command.)@refill + +@cindex Mathematical expressions +For example, here is a mathematical expression written in +plain @TeX{}:@refill + +@example +@@tex +$$ \chi^2 = \sum_@{i=1@}^N + \left (y_i - (a + b x_i) + \over \sigma_i\right)^2 $$ +@@end tex +@end example + +@noindent +The output of this example will appear only in a printed manual. If +you are reading this in Info, you will not see anything after this +paragraph. +@iftex +In a printed manual, the above expression looks like +this: +@end iftex + +@tex +$$ \chi^2 = \sum_{i=1}^N + \left(y_i - (a + b x_i) + \over \sigma_i\right)^2 $$ +@end tex + +@node set clear value, , Using Ordinary TeX Commands, Conditionals +@comment node-name, next, previous, up +@section @code{@@set}, @code{@@clear}, and @code{@@value} + +You can direct the Texinfo formatting commands to format or ignore parts +of a Texinfo file with the @code{@@set}, @code{@@clear}, @code{@@ifset}, +and @code{@@ifclear} commands.@refill + +In addition, you can use the @code{@@set @var{flag}} command to set the +value of @var{flag} to a string of characters; and use +@code{@@value@{@var{flag}@}} to insert that string. You can use +@code{@@set}, for example, to set a date and use @code{@@value} to +insert the date in several places in the Texinfo file.@refill + +@menu +* ifset ifclear:: Format a region if a flag is set. +* value:: Replace a flag with a string. +* value Example:: An easy way to update edition information. +@end menu + +@node ifset ifclear, value, set clear value, set clear value +@subsection @code{@@ifset} and @code{@@ifclear} + +@findex ifset +When a @var{flag} is set, the Texinfo formatting commands format text +between subsequent pairs of @code{@@ifset @var{flag}} and @code{@@end +ifset} commands. When the @var{flag} is cleared, the Texinfo formatting +commands do @emph{not} format the text. + +Use the @code{@@set @var{flag}} command to turn on, or @dfn{set}, a +@var{flag}; a @dfn{flag} can be any single word. The format for the +command looks like this:@refill +@findex set + +@example +@@set @var{flag} +@end example + +Write the conditionally formatted text between @code{@@ifset @var{flag}} +and @code{@@end ifset} commands, like this:@refill + +@example +@group +@@ifset @var{flag} +@var{conditional-text} +@@end ifset +@end group +@end example + +For example, you can create one document that has two variants, such as +a manual for a `large' and `small' model:@refill + +@example +You can use this machine to dig up shrubs +without hurting them. + +@@set large + +@@ifset large +It can also dig up fully grown trees. +@@end ifset + +Remember to replant promptly @dots{} +@end example + +@noindent +In the example, the formatting commands will format the text between +@code{@@ifset large} and @code{@@end ifset} because the @code{large} +flag is set.@refill + +@findex clear +Use the @code{@@clear @var{flag}} command to turn off, or @dfn{clear}, +a flag. Clearing a flag is the opposite of setting a flag. The +command looks like this:@refill + +@example +@@clear @var{flag} +@end example + +@noindent +Write the command on a line of its own. + +When @var{flag} is cleared, the Texinfo formatting commands do +@emph{not} format the text between @code{@@ifset @var{flag}} and +@code{@@end ifset}; that text is ignored and does not appear in either +printed or Info output.@refill + +For example, if you clear the flag of the preceding example by writing +an @code{@@clear large} command after the @code{@@set large} command +(but before the conditional text), then the Texinfo formatting commands +ignore the text between the @code{@@ifset large} and @code{@@end ifset} +commands. In the formatted output, that text does not appear; in both +printed and Info output, you see only the lines that say, ``You can use +this machine to dig up shrubs without hurting them. Remember to replant +promptly @dots{}''. + +@findex ifclear +If a flag is cleared with an @code{@@clear @var{flag}} command, then +the formatting commands format text between subsequent pairs of +@code{@@ifclear} and @code{@@end ifclear} commands. But if the flag +is set with @code{@@set @var{flag}}, then the formatting commands do +@emph{not} format text between an @code{@@ifclear} and an @code{@@end +ifclear} command; rather, they ignore that text. An @code{@@ifclear} +command looks like this:@refill + +@example +@@ifclear @var{flag} +@end example + +@need 700 +In brief, the commands are:@refill + +@table @code +@item @@set @var{flag} +Tell the Texinfo formatting commands that @var{flag} is set.@refill + +@item @@clear @var{flag} +Tell the Texinfo formatting commands that @var{flag} is cleared.@refill + +@item @@ifset @var{flag} +If @var{flag} is set, tell the Texinfo formatting commands to format +the text up to the following @code{@@end ifset} command.@refill + +If @var{flag} is cleared, tell the Texinfo formatting commands to +ignore text up to the following @code{@@end ifset} command.@refill + +@item @@ifclear @var{flag} +If @var{flag} is set, tell the Texinfo formatting commands to ignore +the text up to the following @code{@@end ifclear} command.@refill + +If @var{flag} is cleared, tell the Texinfo formatting commands to +format the text up to the following @code{@@end ifclear} +command.@refill +@end table + +@node value, value Example, ifset ifclear, set clear value +@subsection @code{@@value} +@findex value + +You can use the @code{@@set} command to specify a value for a flag, +which is expanded by the @code{@@value} command. The value is a string +a characters. + +Write the @code{@@set} command like this: + +@example +@@set foo This is a string. +@end example + +@noindent +This sets the value of @code{foo} to ``This is a string.'' + +The Texinfo formatters replace an @code{@@value@{@var{flag}@}} command with +the string to which @var{flag} is set.@refill + +Thus, when @code{foo} is set as shown above, the Texinfo formatters convert + +@example +@group +@@value@{foo@} +@exdent @r{to} +This is a string. +@end group +@end example + +You can write an @code{@@value} command within a paragraph; but you +must write an @code{@@set} command on a line of its own. + +If you write the @code{@@set} command like this: + +@example +@@set foo +@end example + +@noindent +without specifying a string, the value of @code{foo} is an empty string. + +If you clear a previously set flag with an @code{@@clear @var{flag}} +command, a subsequent @code{@@value@{flag@}} command is invalid and the +string is replaced with an error message that says @samp{@{No value for +"@var{flag}"@}}. + +For example, if you set @code{foo} as follows:@refill + +@example +@@set how-much very, very, very +@end example + +@noindent +then the formatters transform + +@example +@group +It is a @@value@{how-much@} wet day. +@exdent @r{into} +It is a very, very, very wet day. +@end group +@end example + +If you write + +@example +@@clear how-much +@end example + +@noindent +then the formatters transform + +@example +@group +It is a @@value@{how-much@} wet day. +@exdent @r{into} +It is a @{No value for "how-much"@} wet day. +@end group +@end example + +@node value Example, , value, set clear value +@subsection @code{@@value} Example + +You can use the @code{@@value} command to limit the number of places you +need to change when you record an update to a manual. +Here is how it is done in @cite{The GNU Make Manual}: + +@need 1000 +@noindent +Set the flags: + +@example +@group +@@set EDITION 0.35 Beta +@@set VERSION 3.63 Beta +@@set UPDATED 14 August 1992 +@@set UPDATE-MONTH August 1992 +@end group +@end example + +@need 750 +@noindent +Write text for the first @code{@@ifinfo} section, for people reading the +Texinfo file: + +@example +@group +This is Edition @@value@{EDITION@}, +last updated @@value@{UPDATED@}, +of @@cite@{The GNU Make Manual@}, +for @@code@{make@}, Version @@value@{VERSION@}. +@end group +@end example + +@need 1000 +@noindent +Write text for the title page, for people reading the printed manual: +@c List only the month and the year since that looks less fussy on a +@c printed cover than a date that lists the day as well. + +@example +@group +@@title GNU Make +@@subtitle A Program for Directing Recompilation +@@subtitle Edition @@value@{EDITION@}, @dots{} +@@subtitle @@value@{UPDATE-MONTH@} +@end group +@end example + +@noindent +(On a printed cover, a date listing the month and the year looks less +fussy than a date listing the day as well as the month and year.) + +@need 750 +@noindent +Write text for the Top node, for people reading the Info file: + +@example +@group +This is Edition @@value@{EDITION@} +of the @@cite@{GNU Make Manual@}, +last updated @@value@{UPDATED@} +for @@code@{make@} Version @@value@{VERSION@}. +@end group +@end example + +@need 950 +After you format the manual, the text in the first @code{@@ifinfo} +section looks like this: + +@example +@group +This is Edition 0.35 Beta, last updated 14 August 1992, +of `The GNU Make Manual', for `make', Version 3.63 Beta. +@end group +@end example + +When you update the manual, change only the values of the flags; you do +not need to rewrite the three sections. + + +@node Macros, Format/Print Hardcopy, Conditionals, Top +@chapter Macros: Defining New Texinfo Commands +@cindex Macros +@cindex Defining new Texinfo commands +@cindex New Texinfo commands, defining +@cindex Texinfo commands, defining new +@cindex User-defined Texinfo commands + +A Texinfo @dfn{macro} allows you to define a new Texinfo command as any +sequence of text and/or existing commands (including other macros). The +macro can have any number of @dfn{parameters}---text you supply each +time you use the macro. (This has nothing to do with the +@code{@@defmac} command, which is for documenting macros in the subject +of the manual; @pxref{Def Cmd Template}.) + +@menu +* Defining Macros:: Both defining and undefining new commands. +* Invoking Macros:: Using a macro, once you've defined it. +@end menu + + +@node Defining Macros, Invoking Macros, Macros, Macros +@section Defining Macros +@cindex Defining macros +@cindex Macro definitions + +@findex macro +You use the Texinfo @code{@@macro} command to define a macro. For example: + +@example +@@macro @var{macro-name}@{@var{param1}, @var{param2}, @dots{}@} +@var{text} @dots{} \@var{param1}\ @dots{} +@@end macro +@end example + +The @dfn{parameters} @var{param1}, @var{param2}, @dots{} correspond to +arguments supplied when the macro is subsequently used in the document +(see the next section). + +If a macro needs no parameters, you can define it either with an empty +list (@samp{@@macro foo @{@}}) or with no braces at all (@samp{@@macro +foo}). + +@cindex Body of a macro +@cindex Mutually recursive macros +@cindex Recursion, mutual +The definition or @dfn{body} of the macro can contain any Texinfo +commands, including previously-defined macros. (It is not possible to +have mutually recursive Texinfo macros.) In the body, instances of a +parameter name surrounded by backslashes, as in @samp{\@var{param1}\} in +the example above, are replaced by the corresponding argument from the +macro invocation. + +@findex unmacro +@cindex Macros, undefining +@cindex Undefining macros +You can undefine a macro @var{foo} with @code{@@unmacro @var{foo}}. +It is not an error to undefine a macro that is already undefined. +For example: + +@example +@@unmacro foo +@end example + + +@node Invoking Macros, , Defining Macros, Macros +@section Invoking Macros +@cindex Invoking macros +@cindex Macro invocation + +After a macro is defined (see the previous section), you can use +(@dfn{invoke}) it in your document like this: + +@example +@@@var{macro-name} @{@var{arg1}, @var{arg2}, @dots{}@} +@end example + +@noindent and the result will be just as if you typed the body of +@var{macro-name} at that spot. For example: + +@example +@@macro foo @{p, q@} +Together: \p\ & \q\. +@@end macro +@@foo@{a, b@} +@end example + +@noindent produces: + +@display +Together: a & b. +@end display + +@cindex Backslash, and macros +Thus, the arguments and parameters are separated by commas and delimited +by braces; any whitespace after (but not before) a comma is ignored. To +insert a comma, brace, or backslash in an argument, prepend a backslash, +as in + +@example +@@@var{macro-name} @{\\\@{\@}\,@} +@end example + +@noindent +which will pass the (almost certainly error-producing) argument +@samp{\@{@},} to @var{macro-name}. + +If the macro is defined to take a single argument, and is invoked +without any braces, the entire rest of the line after the macro name is +supplied as the argument. For example: + +@example +@@macro bar @{p@} +Twice: \p\, \p\. +@@end macro +@@bar aah +@end example + +@noindent produces: + +@display +Twice: aah, aah. +@end display + + +@node Format/Print Hardcopy, Create an Info File, Macros, Top +@comment node-name, next, previous, up +@chapter Format and Print Hardcopy +@cindex Format and print hardcopy +@cindex Hardcopy, printing it +@cindex Making a printed manual +@cindex Sorting indices +@cindex Indices, sorting +@cindex @TeX{} index sorting +@pindex texindex + +There are three major shell commands for making a printed manual from a +Texinfo file: one for converting the Texinfo file into a file that will be +printed, a second for sorting indices, and a third for printing the +formatted document. When you use the shell commands, you can either +work directly in the operating system shell or work within a shell +inside GNU Emacs.@refill + +If you are using GNU Emacs, you can use commands provided by Texinfo +mode instead of shell commands. In addition to the three commands to +format a file, sort the indices, and print the result, Texinfo mode +offers key bindings for commands to recenter the output buffer, show the +print queue, and delete a job from the print queue.@refill + +@menu +* Use TeX:: Use @TeX{} to format for hardcopy. +* Format with tex/texindex:: How to format in a shell. +* Format with texi2dvi:: A simpler way to use the shell. +* Print with lpr:: How to print. +* Within Emacs:: How to format and print from an Emacs shell. +* Texinfo Mode Printing:: How to format and print in Texinfo mode. +* Compile-Command:: How to print using Emacs's compile command. +* Requirements Summary:: @TeX{} formatting requirements summary. +* Preparing for TeX:: What you need to do to use @TeX{}. +* Overfull hboxes:: What are and what to do with overfull hboxes. +* smallbook:: How to print small format books and manuals. +* A4 Paper:: How to print on European A4 paper. +* Cropmarks and Magnification:: How to print marks to indicate the size + of pages and how to print scaled up output. +@end menu + +@node Use TeX, Format with tex/texindex, Format/Print Hardcopy, Format/Print Hardcopy +@ifinfo +@heading Use @TeX{} +@end ifinfo + +The typesetting program called @TeX{} is used for formatting a Texinfo +file. @TeX{} is a very powerful typesetting program and, if used right, +does an exceptionally good job. @xref{Obtaining TeX, , How to Obtain +@TeX{}}, for information on how to obtain @TeX{}.@refill + +The @code{makeinfo}, @code{texinfo-format-region}, and +@code{texinfo-format-buffer} commands read the very same @@-commands +in the Texinfo file as does @TeX{}, but process them differently to +make an Info file; see @ref{Create an Info File}.@refill + +@node Format with tex/texindex, Format with texi2dvi, Use TeX, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Format using @code{tex} and @code{texindex} +@cindex Shell formatting with @code{tex} and @code{texindex} +@cindex Formatting with @code{tex} and @code{texindex} +@cindex DVI file + +Format the Texinfo file with the shell command @code{tex} followed by +the name of the Texinfo file. This command produces a formatted +@sc{dvi} file as well as several auxiliary files containing indices, +cross references, etc. The @sc{dvi} file (for @dfn{DeVice Independent} +file) can be printed on a wide variety of printers.@refill + +The @code{tex} formatting command itself does not sort the indices; it +writes an output file of unsorted index data. This is a misfeature of +@TeX{}. (The @code{texi2dvi} command automatically generates indices; +see @ref{Format with texi2dvi, , Format using @code{texi2dvi}}.) To +generate a printed index after running the @code{tex} command, you first +need a sorted index to work from. The @code{texindex} command sorts +indices. (The source file @file{texindex.c} comes as part of the +standard GNU distribution and is usually installed when Emacs is +installed.)@refill +@pindex texindex +@ignore +Usage: texindex [-k] [-T tempdir] infile [-o outfile] ... + +Each infile arg can optionally be followed by a `-o outfile' arg; +for each infile that is not followed by a -o arg, the infile name with +`s' (for `sorted') appended is used for the outfile. + +-T dir is the directory to put temp files in, instead of /tmp. +-k means `keep tempfiles', for debugging. +@end ignore + +The @code{tex} formatting command outputs unsorted index files under +names that obey a standard convention. These names are the name of +your main input file to the @code{tex} formatting command, with +everything after the first period thrown away, and the two letter +names of indices added at the end. For example, the raw index output +files for the input file @file{foo.texinfo} would be @file{foo.cp}, +@file{foo.vr}, @file{foo.fn}, @file{foo.tp}, @file{foo.pg} and +@file{foo.ky}. Those are exactly the arguments to give to +@code{texindex}.@refill + +@need 1000 +Or else, you can use @samp{??} as ``wild-cards'' and give the command in +this form:@refill + +@example +texindex foo.?? +@end example + +@noindent +This command will run @code{texindex} on all the unsorted index files, +including any that you have defined yourself using @code{@@defindex} +or @code{@@defcodeindex}. (You may execute @samp{texindex foo.??} +even if there are similarly named files with two letter extensions +that are not index files, such as @samp{foo.el}. The @code{texindex} +command reports but otherwise ignores such files.)@refill + +For each file specified, @code{texindex} generates a sorted index file +whose name is made by appending @samp{s} to the input file name. The +@code{@@printindex} command knows to look for a file of that name. +@code{texindex} does not alter the raw index output file.@refill + +After you have sorted the indices, you need to rerun the @code{tex} +formatting command on the Texinfo file. This regenerates a formatted +@sc{dvi} file with up-to-date index entries.@footnote{If you use more +than one index and have cross references to an index other than the +first, you must run @code{tex} @emph{three times} to get correct output: +once to generate raw index data; again (after @code{texindex}) to output +the text of the indices and determine their true page numbers; and a +third time to output correct page numbers in cross references to them. +However, cross references to indices are rare.}@refill + +To summarize, this is a three step process: + +@enumerate +@item +Run the @code{tex} formatting command on the Texinfo file. This +generates the formatted @sc{dvi} file as well as the raw index files +with two letter extensions.@refill + +@item +Run the shell command @code{texindex} on the raw index files to sort +them. This creates the corresponding sorted index files.@refill + +@item +Rerun the @code{tex} formatting command on the Texinfo file. This +regenerates a formatted @sc{dvi} file with the index entries in the +correct order. This second run also corrects the page numbers for +the cross references. (The tables of contents are always correct.)@refill +@end enumerate + +You need not run @code{texindex} each time after you run the +@code{tex} formatting. If you do not, on the next run, the @code{tex} +formatting command will use whatever sorted index files happen to +exist from the previous use of @code{texindex}. This is usually +@sc{ok} while you are debugging.@refill + +@node Format with texi2dvi, Print with lpr, Format with tex/texindex, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Format using @code{texi2dvi} +@pindex texi2dvi @r{(shell script)} + +The @code{texi2dvi} command is a shell script that automatically runs +both @code{tex} and @code{texindex} as many times as necessary to +produce a @sc{dvi} file with up-to-date, sorted indices. It simplifies +the @code{tex}---@code{texindex}---@code{tex} sequence described in the +previous section. + +@need 1000 +The syntax for @code{texi2dvi} is like this (where @samp{prompt$} is the +shell prompt):@refill + +@example +prompt$ @kbd{texi2dvi @var{filename}@dots{}} +@end example + +@node Print with lpr, Within Emacs, Format with texi2dvi, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Shell Print Using @code{lpr -d} +@pindex lpr @r{(@sc{dvi} print command)} + +You can print a @sc{dvi} file with the @sc{dvi} print command. The +precise printing command to use depends on your system; @samp{lpr -d} is +common. The @sc{dvi} print command may require a file name without any +extension or with a @samp{.dvi} extension.@refill + +@need 1200 +The following commands, for example, sort the indices, format, and +print the @cite{Bison Manual} (where @samp{%} is the shell +prompt):@refill + +@example +@group +% tex bison.texinfo +% texindex bison.?? +% tex bison.texinfo +% lpr -d bison.dvi +@end group +@end example + +@noindent +(Remember that the shell commands may be different at your site; but +these are commonly used versions.)@refill + +@need 1000 +Using the @code{texi2dvi} shell script, you simply need type:@refill + +@example +@group +% texi2dvi bison.texinfo +% lpr -d bison.dvi +@end group +@end example + +@node Within Emacs, Texinfo Mode Printing, Print with lpr, Format/Print Hardcopy +@comment node-name, next, previous, up +@section From an Emacs Shell @dots{} +@cindex Print, format from Emacs shell +@cindex Format, print from Emacs shell +@cindex Shell, format, print from +@cindex Emacs shell, format, print from +@cindex GNU Emacs shell, format, print from + +You can give formatting and printing commands from a shell within GNU +Emacs. To create a shell within Emacs, type @kbd{M-x shell}. In this +shell, you can format and print the document. @xref{Format/Print +Hardcopy, , Format and Print Hardcopy}, for details.@refill + +You can switch to and from the shell buffer while @code{tex} is +running and do other editing. If you are formatting a long document +on a slow machine, this can be very convenient.@refill + +You can also use @code{texi2dvi} from an Emacs shell. For example, +here is how to use @code{texi2dvi} to format and print @cite{Using and +Porting GNU CC} from a shell within Emacs (where @samp{%} is the shell +prompt):@refill + +@example +@group +% texi2dvi gcc.texinfo +% lpr -d gcc.dvi +@end group +@end example +@ifinfo + +@xref{Texinfo Mode Printing}, for more information about formatting +and printing in Texinfo mode.@refill +@end ifinfo + +@node Texinfo Mode Printing, Compile-Command, Within Emacs, Format/Print Hardcopy +@section Formatting and Printing in Texinfo Mode +@cindex Region printing in Texinfo mode +@cindex Format and print in Texinfo mode +@cindex Print and format in Texinfo mode + +Texinfo mode provides several predefined key commands for @TeX{} +formatting and printing. These include commands for sorting indices, +looking at the printer queue, killing the formatting job, and +recentering the display of the buffer in which the operations +occur.@refill + +@table @kbd +@item C-c C-t C-b +@itemx M-x texinfo-tex-buffer +Run @code{texi2dvi} on the current buffer.@refill + +@item C-c C-t C-r +@itemx M-x texinfo-tex-region +Run @TeX{} on the current region.@refill + +@item C-c C-t C-i +@itemx M-x texinfo-texindex +Sort the indices of a Texinfo file formatted with +@code{texinfo-tex-region}.@refill + +@item C-c C-t C-p +@itemx M-x texinfo-tex-print +Print a @sc{dvi} file that was made with @code{texinfo-tex-region} or +@code{texinfo-tex-buffer}.@refill + +@item C-c C-t C-q +@itemx M-x tex-show-print-queue +Show the print queue.@refill + +@item C-c C-t C-d +@itemx M-x texinfo-delete-from-print-queue +Delete a job from the print queue; you will be prompted for the job +number shown by a preceding @kbd{C-c C-t C-q} command +(@code{texinfo-show-tex-print-queue}).@refill + +@item C-c C-t C-k +@itemx M-x tex-kill-job +Kill the currently running @TeX{} job started by +@code{texinfo-tex-region} or @code{texinfo-tex-buffer}, or any other +process running in the Texinfo shell buffer.@refill + +@item C-c C-t C-x +@itemx M-x texinfo-quit-job +Quit a @TeX{} formatting job that has stopped because of an error by +sending an @key{x} to it. When you do this, @TeX{} preserves a record +of what it did in a @file{.log} file.@refill + +@item C-c C-t C-l +@itemx M-x tex-recenter-output-buffer +Redisplay the shell buffer in which the @TeX{} printing and formatting +commands are run to show its most recent output.@refill +@end table + +@need 1000 +Thus, the usual sequence of commands for formatting a buffer is as +follows (with comments to the right):@refill + +@example +@group +C-c C-t C-b @r{Run @code{texi2dvi} on the buffer.} +C-c C-t C-p @r{Print the @sc{dvi} file.} +C-c C-t C-q @r{Display the printer queue.} +@end group +@end example + +The Texinfo mode @TeX{} formatting commands start a subshell in Emacs +called the @file{*tex-shell*}. The @code{texinfo-tex-command}, +@code{texinfo-texindex-command}, and @code{tex-dvi-print-command} +commands are all run in this shell. + +You can watch the commands operate in the @samp{*tex-shell*} buffer, +and you can switch to and from and use the @samp{*tex-shell*} buffer +as you would any other shell buffer.@refill + +@need 1500 +The formatting and print commands depend on the values of several variables. +The default values are:@refill + +@example +@group + @r{Variable} @r{Default value} + +texinfo-texi2dvi-command "texi2dvi" +texinfo-tex-command "tex" +texinfo-texindex-command "texindex" +texinfo-delete-from-print-queue-command "lprm" +texinfo-tex-trailer "@@bye" +tex-start-of-header "%**start" +tex-end-of-header "%**end" +tex-dvi-print-command "lpr -d" +tex-show-queue-command "lpq" +@end group +@end example + +You can change the values of these variables with the @kbd{M-x +edit-options} command (@pxref{Edit Options, , Editing Variable Values, +emacs, The GNU Emacs Manual}), with the @kbd{M-x set-variable} command +(@pxref{Examining, , Examining and Setting Variables, emacs, The GNU +Emacs Manual}), or with your @file{.emacs} initialization file +(@pxref{Init File, , , emacs, The GNU Emacs Manual}).@refill + +@node Compile-Command, Requirements Summary, Texinfo Mode Printing, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Using the Local Variables List +@cindex Local variables +@cindex Compile command for formatting +@cindex Format with the compile command + +Yet another way to apply the @TeX{} formatting command to a Texinfo file +is to put that command in a @dfn{local variables list} at the end of the +Texinfo file. You can then specify the @code{tex} or @code{texi2dvi} +commands as a @code{compile-command} and have Emacs run it by typing +@kbd{M-x compile}. This creates a special shell called the +@file{*compilation*} buffer in which Emacs runs the compile command. +For example, at the end of the @file{gdb.texinfo} file, after the +@code{@@bye}, you could put the following:@refill + +@example +@group +@@c Local Variables: +@@c compile-command: "texi2dvi gdb.texinfo" +@@c End: +@end group +@end example + +@noindent +This technique is most often used by programmers who also compile programs +this way; see @ref{Compilation, , , emacs, The GNU Emacs Manual}.@refill + +@node Requirements Summary, Preparing for TeX, Compile-Command, Format/Print Hardcopy +@comment node-name, next, previous, up +@section @TeX{} Formatting Requirements Summary +@cindex Requirements for formatting +@cindex Formatting requirements + +Every Texinfo file that is to be input to @TeX{} must begin with a +@code{\input} command and must contain an @code{@@setfilename} command and +an @code{@@settitle} command:@refill + +@example +\input texinfo +@@setfilename @var{arg-not-used-by-@TeX{}} +@@settitle @var{name-of-manual} +@end example + +@noindent +The first command instructs @TeX{} to load the macros it needs to +process a Texinfo file, the second command opens auxiliary files, and +the third specifies the title of printed manual. + +@need 1000 +Every Texinfo file must end with a line that terminates @TeX{} +processing and forces out unfinished pages:@refill + +@example +@@bye +@end example + +Strictly speaking, these four lines are all a Texinfo file needs for +@TeX{}, besides the body. (The @code{@@setfilename} line is the only +line that a Texinfo file needs for Info formatting.)@refill + +Usually, the file's first line contains an @samp{@@c -*-texinfo-*-} +comment that causes Emacs to switch to Texinfo mode when you edit the +file. In addition, the beginning usually includes an +@code{@@setchapternewpage} command, a title page, a copyright page, and +permissions. Besides an @code{@@bye}, the end of a file usually +includes indices and a table of contents.@refill + +@iftex +For more information, see +@ref{setchapternewpage, , @code{@@setchapternewpage}}, +@ref{Headings, ,Page Headings}, +@ref{Titlepage & Copyright Page}, +@ref{Printing Indices & Menus}, and +@ref{Contents}. +@end iftex +@noindent +@ifinfo +For more information, see@* +@ref{setchapternewpage, , @code{@@setchapternewpage}},@* +@ref{Headings, ,Page Headings},@* +@ref{Titlepage & Copyright Page},@* +@ref{Printing Indices & Menus}, and@* +@ref{Contents}. +@end ifinfo + +@node Preparing for TeX, Overfull hboxes, Requirements Summary, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Preparing to Use @TeX{} +@cindex Preparing to use @TeX{} +@cindex @TeX{} input initialization +@cindex @code{TEXINPUTS} environment variable +@vindex TEXINPUTS +@cindex @b{.profile} initialization file +@cindex @b{.cshrc} initialization file +@cindex Initialization file for @TeX{} input + +@TeX{} needs to know where to find the @file{texinfo.tex} file +that you have told it to input with the @samp{\input texinfo} command +at the beginning of the first line. The @file{texinfo.tex} file tells +@TeX{} how to handle @@-commands. (@file{texinfo.tex} is +included in the standard GNU distributions.)@refill + +Usually, the @file{texinfo.tex} file is put in the default directory +that contains @TeX{} macros (the @file{/usr/lib/tex/macros} +directory) when GNU Emacs or other GNU software is installed. +In this case, @TeX{} will +find the file and you do not need to do anything special. +Alternatively, you can put @file{texinfo.tex} in the directory in +which the Texinfo source file is located, and @TeX{} will find it +there.@refill + +However, you may want to specify the location of the @code{\input} file +yourself. One way to do this is to write the complete path for the file +after the @code{\input} command. Another way is to set the +@code{TEXINPUTS} environment variable in your @file{.cshrc} or +@file{.profile} file. The @code{TEXINPUTS} environment variable will tell +@TeX{} where to find the @file{texinfo.tex} file and any other file that +you might want @TeX{} to use.@refill + +Whether you use a @file{.cshrc} or @file{.profile} file depends on +whether you use @code{csh}, @code{sh}, or @code{bash} for your shell +command interpreter. When you use @code{csh}, it looks to the +@file{.cshrc} file for initialization information, and when you use +@code{sh} or @code{bash}, it looks to the @file{.profile} file.@refill + +@need 1000 +In a @file{.cshrc} file, you could use the following @code{csh} command +sequence:@refill + +@example +setenv TEXINPUTS .:/usr/me/mylib:/usr/lib/tex/macros +@end example + +@need 1000 +In a @file{.profile} file, you could use the following @code{sh} command +sequence: + +@example +@group +TEXINPUTS=.:/usr/me/mylib:/usr/lib/tex/macros +export TEXINPUTS +@end group +@end example + +@noindent +This would cause @TeX{} to look for @file{\input} file first in the current +directory, indicated by the @samp{.}, then in a hypothetical user's +@file{me/mylib} directory, and finally in the system library.@refill + +@node Overfull hboxes, smallbook, Preparing for TeX, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Overfull ``hboxes'' +@cindex Overfull @samp{hboxes} +@cindex @samp{hboxes}, overfull +@cindex Final output + +@TeX{} is sometimes unable to typeset a line without extending it into +the right margin. This can occur when @TeX{} comes upon what it +interprets as a long word that it cannot hyphenate, such as an +electronic mail network address or a very long title. When this +happens, @TeX{} prints an error message like this:@refill + +@example +Overfull \hbox (20.76302pt too wide) +@end example + +@noindent +(In @TeX{}, lines are in ``horizontal boxes'', hence the term, ``hbox''. +The backslash, @samp{\}, is the @TeX{} equivalent of @samp{@@}.)@refill + +@TeX{} also provides the line number in the Texinfo source file and +the text of the offending line, which is marked at all the places that +@TeX{} knows how to hyphenate words. +@xref{Debugging with TeX, , Catching Errors with @TeX{} Formatting}, +for more information about typesetting errors.@refill + +If the Texinfo file has an overfull hbox, you can rewrite the sentence +so the overfull hbox does not occur, or you can decide to leave it. A +small excursion into the right margin often does not matter and may not +even be noticeable.@refill + +@cindex Black rectangle in hardcopy +@cindex Rectangle, ugly, black in hardcopy +However, unless told otherwise, @TeX{} will print a large, ugly, black +rectangle beside the line that contains the overfull hbox. This is so +you will notice the location of the problem if you are correcting a +draft.@refill + +@need 1000 +@findex finalout +To prevent such a monstrosity from marring your final printout, write +the following in the beginning of the Texinfo file on a line of its own, +before the @code{@@titlepage} command:@refill + +@example +@@finalout +@end example + +@node smallbook, A4 Paper, Overfull hboxes, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Printing ``Small'' Books +@findex smallbook +@cindex Small book size +@cindex Book, printing small +@cindex Page sizes for books +@cindex Size of printed book + +By default, @TeX{} typesets pages for printing in an 8.5 by 11 inch +format. However, you can direct @TeX{} to typeset a document in a 7 by +9.25 inch format that is suitable for bound books by inserting the +following command on a line by itself at the beginning of the Texinfo +file, before the title page:@refill + +@example +@@smallbook +@end example + +@noindent +(Since regular sized books are often about 7 by 9.25 inches, this +command might better have been called the @code{@@regularbooksize} +command, but it came to be called the @code{@@smallbook} command by +comparison to the 8.5 by 11 inch format.)@refill + +If you write the @code{@@smallbook} command between the +start-of-header and end-of-header lines, the Texinfo mode @TeX{} +region formatting command, @code{texinfo-tex-region}, will format the +region in ``small'' book size (@pxref{Start of Header}).@refill + +The Free Software Foundation distributes printed copies of @cite{The GNU +Emacs Manual} and other manuals in the ``small'' book size. +@xref{smallexample & smalllisp, , @code{@@smallexample} and +@code{@@smalllisp}}, for information about commands that make it easier +to produce examples for a smaller manual.@refill + +@node A4 Paper, Cropmarks and Magnification, smallbook, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Printing on A4 Paper +@cindex A4 paper, printing on +@cindex Paper size, European A4 +@cindex European A4 paper +@findex afourpaper + +You can tell @TeX{} to typeset a document for printing on European size +A4 paper with the @code{@@afourpaper} command. Write the command on a +line by itself between @code{@@iftex} and @code{@@end iftex} lines near +the beginning of the Texinfo file, before the title page:@refill + +For example, this is how you would write the header for this manual:@refill + +@example +@group +\input texinfo @@c -*-texinfo-*- +@@c %**start of header +@@setfilename texinfo +@@settitle Texinfo +@@syncodeindex vr fn +@@iftex +@@afourpaper +@@end iftex +@@c %**end of header +@end group +@end example + +@node Cropmarks and Magnification, , A4 Paper, Format/Print Hardcopy +@comment node-name, next, previous, up +@section Cropmarks and Magnification + +@findex cropmarks +@cindex Cropmarks for printing +@cindex Printing cropmarks +You can attempt to direct @TeX{} to print cropmarks at the corners of +pages with the @code{@@cropmarks} command. Write the @code{@@cropmarks} +command on a line by itself between @code{@@iftex} and @code{@@end +iftex} lines near the beginning of the Texinfo file, before the title +page, like this:@refill + +@example +@group +@@iftex +@@cropmarks +@@end iftex +@end group +@end example + +This command is mainly for printers that typeset several pages on one +sheet of film; but you can attempt to use it to mark the corners of a +book set to 7 by 9.25 inches with the @code{@@smallbook} command. +(Printers will not produce cropmarks for regular sized output that is +printed on regular sized paper.) Since different printing machines work +in different ways, you should explore the use of this command with a +spirit of adventure. You may have to redefine the command in the +@file{texinfo.tex} definitions file.@refill + +@findex mag @r{(@TeX{} command)} +@cindex Magnified printing +@cindex Larger or smaller pages +You can attempt to direct @TeX{} to typeset pages larger or smaller than +usual with the @code{\mag} @TeX{} command. Everything that is typeset +is scaled proportionally larger or smaller. (@code{\mag} stands for +``magnification''.) This is @emph{not} a Texinfo @@-command, but is a +plain @TeX{} command that is prefixed with a backslash. You have to +write this command between @code{@@tex} and @code{@@end tex} +(@pxref{Using Ordinary TeX Commands, , Using Ordinary @TeX{} +Commands}).@refill + +Follow the @code{\mag} command with an @samp{=} and then a number that +is 1000 times the magnification you desire. For example, to print pages +at 1.2 normal size, write the following near the beginning of the +Texinfo file, before the title page:@refill + +@example +@group +@@tex +\mag=1200 +@@end tex +@end group +@end example + +With some printing technologies, you can print normal-sized copies that +look better than usual by using a larger-than-normal master.@refill + +Depending on your system, @code{\mag} may not work or may work only at +certain magnifications. Be prepared to experiment.@refill + +@node Create an Info File, Install an Info File, Format/Print Hardcopy, Top +@comment node-name, next, previous, up +@chapter Creating an Info File +@cindex Creating an Info file +@cindex Info, creating an on-line file +@cindex Formatting a file for Info + +@code{makeinfo} is a utility that converts a Texinfo file into an Info +file; @code{texinfo-format-region} and @code{texinfo-format-buffer} are +GNU Emacs functions that do the same.@refill + +A Texinfo file must possess an @code{@@setfilename} line near its +beginning, otherwise the Info formatting commands will fail.@refill + +For information on installing the Info file in the Info system, see +@ref{Install an Info File}.@refill + +@menu +* makeinfo advantages:: @code{makeinfo} provides better error checking. +* Invoking makeinfo:: How to run @code{makeinfo} from a shell. +* makeinfo options:: Specify fill-column and other options. +* Pointer Validation:: How to check that pointers point somewhere. +* makeinfo in Emacs:: How to run @code{makeinfo} from Emacs. +* texinfo-format commands:: Two Info formatting commands written + in Emacs Lisp are an alternative + to @code{makeinfo}. +* Batch Formatting:: How to format for Info in Emacs Batch mode. +* Tag and Split Files:: How tagged and split files help Info + to run better. +@end menu + +@node makeinfo advantages, Invoking makeinfo, Create an Info File, Create an Info File +@ifinfo +@heading @code{makeinfo} Preferred +@end ifinfo + +The @code{makeinfo} utility creates an Info file from a Texinfo source +file more quickly than either of the Emacs formatting commands and +provides better error messages. We recommend it. @code{makeinfo} is a +C program that is independent of Emacs. You do not need to run Emacs to +use @code{makeinfo}, which means you can use @code{makeinfo} on machines +that are too small to run Emacs. You can run @code{makeinfo} in +any one of three ways: from an operating system shell, from a shell +inside Emacs, or by typing a key command in Texinfo mode in Emacs. +@refill + +The @code{texinfo-format-region} and the @code{texinfo-format-buffer} +commands are useful if you cannot run @code{makeinfo}. Also, in some +circumstances, they format short regions or buffers more quickly than +@code{makeinfo}.@refill + +@node Invoking makeinfo, makeinfo options, makeinfo advantages, Create an Info File +@section Running @code{makeinfo} from a Shell + +To create an Info file from a Texinfo file, type @code{makeinfo} +followed by the name of the Texinfo file. Thus, to create the Info +file for Bison, type the following at the shell prompt (where @samp{%} +is the prompt):@refill + +@example +% makeinfo bison.texinfo +@end example + +(You can run a shell inside Emacs by typing @kbd{M-x +shell}.)@refill + +@ifinfo +Sometimes you will want to specify options. For example, if you wish +to discover which version of @code{makeinfo} you are using, +type:@refill + +@example +% makeinfo --version +@end example + +@xref{makeinfo options}, for more information. +@end ifinfo + +@node makeinfo options, Pointer Validation, Invoking makeinfo, Create an Info File +@comment node-name, next, previous, up +@section Options for @code{makeinfo} +@cindex @code{makeinfo} options +@cindex Options for @code{makeinfo} + +The @code{makeinfo} command takes a number of options. Most often, +options are used to set the value of the fill column and specify the +footnote style. Each command line option is a word preceded by +@samp{--}@footnote{@samp{--} has replaced @samp{+}, the old introductory +character, to maintain POSIX.2 compatibility without losing long-named +options.} or a letter preceded by @samp{-}. You can use abbreviations +for the option names as long as they are unique.@refill + +For example, you could use the following command to create an Info +file for @file{bison.texinfo} in which each line is filled to only 68 +columns (where @samp{%} is the prompt):@refill + +@example +% makeinfo --fill-column=68 bison.texinfo +@end example + +You can write two or more options in sequence, like this:@refill + +@example +% makeinfo --no-split --fill-column=70 @dots{} +@end example + +@noindent +This would keep the Info file together as one possibly very long +file and would also set the fill column to 70.@refill + +@iftex +If you wish to discover which version of @code{makeinfo} +you are using, type:@refill + +@example +% makeinfo --version +@end example +@end iftex + +The options are:@refill + +@need 100 +@table @code +@item -D @var{var} +Cause @var{var} to be defined. This is equivalent to +@code{@@set @var{var}} in the Texinfo file. + +@need 150 +@item --error-limit @var{limit} +Set the maximum number of errors that @code{makeinfo} will report +before exiting (on the assumption that continuing would be useless). +The default number of errors that can be reported before +@code{makeinfo} gives up is 100.@refill + +@need 150 +@item --fill-column @var{width} +Specify the maximum number of columns in a line; this is the right-hand +edge of a line. Paragraphs that are filled will be filled to this +width. (Filling is the process of breaking up and connecting lines so +that lines are the same length as or shorter than the number specified +as the fill column. Lines are broken between words.) The default value +for @code{fill-column} is 72. +@refill + +@item --footnote-style @var{style} +Set the footnote style to @var{style}, either @samp{end} for the end +node style or @samp{separate} for the separate node style. The value +set by this option overrides the value set in a Texinfo file by an +@code{@@footnotestyle} command. When the footnote style is +@samp{separate}, @code{makeinfo} makes a new node containing the +footnotes found in the current node. When the footnote style is +@samp{end}, @code{makeinfo} places the footnote references at the end +of the current node.@refill + +@need 150 +@item -I @var{dir} +Add @code{dir} to the directory search list for finding files that are +included using the @code{@@include} command. By default, +@code{makeinfo} searches only the current directory. + +@need 150 +@item --no-headers +Do not include menus or node lines in the output. This results in an +@sc{ascii} file that you cannot read in Info since it does not contain +the requisite nodes or menus; but you can print such a file in a +single, typewriter-like font and produce acceptable output. + +@need 150 +@item --no-split +Suppress the splitting stage of @code{makeinfo}. Normally, large +output files (where the size is greater than 70k bytes) are split into +smaller subfiles, each one approximately 50k bytes. If you specify +@samp{--no-split}, @code{makeinfo} will not split up the output +file.@refill + +@need 100 +@item --no-pointer-validate +@item --no-validate +Suppress the pointer-validation phase of @code{makeinfo}. Normally, +after a Texinfo file is processed, some consistency checks are made to +ensure that cross references can be resolved, etc. +@xref{Pointer Validation}.@refill + +@need 150 +@item --no-warn +Suppress the output of warning messages. This does @emph{not} +suppress the output of error messages, only warnings. You might +want this if the file you are creating has examples of Texinfo cross +references within it, and the nodes that are referenced do not actually +exist.@refill + +@item --no-number-footnotes +Suppress automatic footnote numbering. By default, @code{makeinfo} +numbers each footnote sequentially in a single node, resetting the +current footnote number to 1 at the start of each node. + +@need 150 +@item --output @var{file} +@itemx -o @var{file} +Specify that the output should be directed to @var{file} and not to the +file name specified in the @code{@@setfilename} command found in the Texinfo +source. @var{file} can be the special token @samp{-}, which specifies +standard output. + +@need 150 +@item --paragraph-indent @var{indent} +Set the paragraph indentation style to @var{indent}. The value set by +this option overrides the value set in a Texinfo file by an +@code{@@paragraphindent} command. The value of @var{indent} is +interpreted as follows:@refill + +@itemize @bullet +@item +If the value of @var{indent} is @samp{asis}, do not change the +existing indentation at the starts of paragraphs.@refill + +@item +If the value of @var{indent} is zero, delete any existing +indentation.@refill + +@item +If the value of @var{indent} is greater than zero, indent each +paragraph by that number of spaces.@refill +@end itemize + +@need 100 +@item --reference-limit @var{limit} +Set the value of the number of references to a node that +@code{makeinfo} will make without reporting a warning. If a node has more +than this number of references in it, @code{makeinfo} will make the +references but also report a warning.@refill + +@need 150 +@item -U @var{var} +Cause @var{var} to be undefined. This is equivalent to +@code{@@clear @var{var}} in the Texinfo file. + +@need 100 +@item --verbose +Cause @code{makeinfo} to display messages saying what it is doing. +Normally, @code{makeinfo} only outputs messages if there are errors or +warnings.@refill + +@need 100 +@item --version +Report the version number of this copy of @code{makeinfo}.@refill +@end table + +@node Pointer Validation, makeinfo in Emacs, makeinfo options, Create an Info File +@section Pointer Validation +@cindex Pointer validation with @code{makeinfo} +@cindex Validation of pointers + +If you do not suppress pointer-validation, @code{makeinfo} will check +the validity of the final Info file. Mostly, this means ensuring that +nodes you have referenced really exist. Here is a complete list of what +is checked:@refill + +@enumerate +@item +If a `Next', `Previous', or `Up' node reference is a reference to a +node in the current file and is not an external reference such as to +@file{(dir)}, then the referenced node must exist.@refill + +@item +In every node, if the `Previous' node is different from the `Up' node, +then the `Previous' node must also be pointed to by a `Next' node.@refill + +@item +Every node except the `Top' node must have an `Up' pointer.@refill + +@item +The node referenced by an `Up' pointer must contain a reference to the +current node in some manner other than through a `Next' reference. +This includes menu entries and cross references.@refill + +@item +If the `Next' reference of a node is not the same as the `Next' reference +of the `Up' reference, then the node referenced by the `Next' pointer +must have a `Previous' pointer that points back to the current node. +This rule allows the last node in a section to point to the first node +of the next chapter.@refill +@end enumerate + +@node makeinfo in Emacs, texinfo-format commands, Pointer Validation, Create an Info File +@section Running @code{makeinfo} inside Emacs +@cindex Running @code{makeinfo} in Emacs +@cindex @code{makeinfo} inside Emacs +@cindex Shell, running @code{makeinfo} in + +You can run @code{makeinfo} in GNU Emacs Texinfo mode by using either the +@code{makeinfo-region} or the @code{makeinfo-buffer} commands. In +Texinfo mode, the commands are bound to @kbd{C-c C-m C-r} and @kbd{C-c +C-m C-b} by default.@refill + +@table @kbd +@item C-c C-m C-r +@itemx M-x makeinfo-region +Format the current region for Info.@refill +@findex makeinfo-region + +@item C-c C-m C-b +@itemx M-x makeinfo-buffer +Format the current buffer for Info.@refill +@findex makeinfo-buffer +@end table + +When you invoke either @code{makeinfo-region} or +@code{makeinfo-buffer}, Emacs prompts for a file name, offering the +name of the visited file as the default. You can edit the default +file name in the minibuffer if you wish, before typing @key{RET} to +start the @code{makeinfo} process.@refill + +The Emacs @code{makeinfo-region} and @code{makeinfo-buffer} commands +run the @code{makeinfo} program in a temporary shell buffer. If +@code{makeinfo} finds any errors, Emacs displays the error messages in +the temporary buffer.@refill + +@cindex Errors, parsing +@cindex Parsing errors +@findex next-error +You can parse the error messages by typing @kbd{C-x `} +(@code{next-error}). This causes Emacs to go to and position the +cursor on the line in the Texinfo source that @code{makeinfo} thinks +caused the error. @xref{Compilation, , Running @code{make} or +Compilers Generally, emacs, The GNU Emacs Manual}, for more +information about using the @code{next-error} command.@refill + +In addition, you can kill the shell in which the @code{makeinfo} +command is running or make the shell buffer display its most recent +output.@refill + +@table @kbd +@item C-c C-m C-k +@itemx M-x makeinfo-kill-job +@findex makeinfo-kill-job +Kill the current running @code{makeinfo} job created by +@code{makeinfo-region} or @code{makeinfo-buffer}.@refill + +@item C-c C-m C-l +@itemx M-x makeinfo-recenter-output-buffer +@findex makeinfo-recenter-output-buffer +Redisplay the @code{makeinfo} shell buffer to display its most recent +output.@refill +@end table + +@noindent +(Note that the parallel commands for killing and recentering a @TeX{} +job are @kbd{C-c C-t C-k} and @kbd{C-c C-t C-l}. @xref{Texinfo Mode +Printing}.)@refill + +You can specify options for @code{makeinfo} by setting the +@code{makeinfo-options} variable with either the @kbd{M-x +edit-options} or the @kbd{M-x set-variable} command, or by setting the +variable in your @file{.emacs} initialization file.@refill + +For example, you could write the following in your @file{.emacs} file:@refill + +@example +@group +(setq makeinfo-options + "--paragraph-indent=0 --no-split + --fill-column=70 --verbose") +@end group +@end example + +@c If you write these three cross references using xref, you see +@c three references to the same named manual, which looks strange. +@iftex +For more information, see @ref{makeinfo options, , Options for +@code{makeinfo}}, as well as ``Editing Variable Values,''``Examining and +Setting Variables,'' and ``Init File'' in the @cite{The GNU Emacs +Manual}. +@end iftex +@noindent +@ifinfo +For more information, see@* +@ref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs Manual},@* +@ref{Examining, , Examining and Setting Variables, emacs, The GNU Emacs Manual},@* +@ref{Init File, , , emacs, The GNU Emacs Manual}, and@* +@ref{makeinfo options, , Options for @code{makeinfo}}. +@end ifinfo + +@node texinfo-format commands, Batch Formatting, makeinfo in Emacs, Create an Info File +@comment node-name, next, previous, up +@section The @code{texinfo-format@dots{}} Commands +@findex texinfo-format-region +@findex texinfo-format-buffer + +In GNU Emacs in Texinfo mode, you can format part or all of a Texinfo +file with the @code{texinfo-format-region} command. This formats the +current region and displays the formatted text in a temporary buffer +called @samp{*Info Region*}.@refill + +Similarly, you can format a buffer with the +@code{texinfo-format-buffer} command. This command creates a new +buffer and generates the Info file in it. Typing @kbd{C-x C-s} will +save the Info file under the name specified by the +@code{@@setfilename} line which must be near the beginning of the +Texinfo file.@refill + +@table @kbd +@item C-c C-e C-r +@itemx @code{texinfo-format-region} +Format the current region for Info. +@findex texinfo-format-region + +@item C-c C-e C-b +@itemx @code{texinfo-format-buffer} +Format the current buffer for Info. +@findex texinfo-format-buffer +@end table + +The @code{texinfo-format-region} and @code{texinfo-format-buffer} +commands provide you with some error checking, and other functions can +provide you with further help in finding formatting errors. These +procedures are described in an appendix; see @ref{Catching Mistakes}. +However, the @code{makeinfo} program is often faster and +provides better error checking (@pxref{makeinfo in Emacs}).@refill + +@node Batch Formatting, Tag and Split Files, texinfo-format commands, Create an Info File +@comment node-name, next, previous, up +@section Batch Formatting +@cindex Batch formatting for Info +@cindex Info batch formatting + +You can format Texinfo files for Info using @code{batch-texinfo-format} +and Emacs Batch mode. You can run Emacs in Batch mode from any shell, +including a shell inside of Emacs. (@xref{Command Switches, , Command +Line Switches and Arguments, emacs, The GNU Emacs Manual}.)@refill + +Here is the command to format all the files that end in @file{.texinfo} +in the current directory (where @samp{%} is the shell prompt):@refill + +@example +% emacs -batch -funcall batch-texinfo-format *.texinfo +@end example + +@noindent +Emacs processes all the files listed on the command line, even if an +error occurs while attempting to format some of them.@refill + +Run @code{batch-texinfo-format} only with Emacs in Batch mode as shown; +it is not interactive. It kills the Batch mode Emacs on completion.@refill + +@code{batch-texinfo-format} is convenient if you lack @code{makeinfo} +and want to format several Texinfo files at once. When you use Batch +mode, you create a new Emacs process. This frees your current Emacs, so +you can continue working in it. (When you run +@code{texinfo-format-region} or @code{texinfo-format-buffer}, you cannot +use that Emacs for anything else until the command finishes.)@refill + +@node Tag and Split Files, , Batch Formatting, Create an Info File +@comment node-name, next, previous, up +@section Tag Files and Split Files +@cindex Making a tag table automatically +@cindex Tag table, making automatically + +If a Texinfo file has more than 30,000 bytes, +@code{texinfo-format-buffer} automatically creates a tag table +for its Info file; @code{makeinfo} always creates a tag table. With +a @dfn{tag table}, Info can jump to new nodes more quickly than it can +otherwise.@refill + +@cindex Indirect subfiles +In addition, if the Texinfo file contains more than about 70,000 +bytes, @code{texinfo-format-buffer} and @code{makeinfo} split the +large Info file into shorter @dfn{indirect} subfiles of about 50,000 +bytes each. Big files are split into smaller files so that Emacs does +not need to make a large buffer to hold the whole of a large Info +file; instead, Emacs allocates just enough memory for the small, split +off file that is needed at the time. This way, Emacs avoids wasting +memory when you run Info. (Before splitting was implemented, Info +files were always kept short and @dfn{include files} were designed as +a way to create a single, large printed manual out of the smaller Info +files. @xref{Include Files}, for more information. Include files are +still used for very large documents, such as @cite{The Emacs Lisp +Reference Manual}, in which each chapter is a separate file.)@refill + +When a file is split, Info itself makes use of a shortened version of +the original file that contains just the tag table and references to +the files that were split off. The split off files are called +@dfn{indirect} files.@refill + +The split off files have names that are created by appending @w{@samp{-1}}, +@w{@samp{-2}}, @w{@samp{-3}} and so on to the file name specified by the +@code{@@setfilename} command. The shortened version of the original file +continues to have the name specified by @code{@@setfilename}.@refill + +At one stage in writing this document, for example, the Info file was saved +as @file{test-texinfo} and that file looked like this:@refill + +@example +@group +Info file: test-texinfo, -*-Text-*- +produced by texinfo-format-buffer +from file: new-texinfo-manual.texinfo + +^_ +Indirect: +test-texinfo-1: 102 +test-texinfo-2: 50422 +@end group +@group +test-texinfo-3: 101300 +^_^L +Tag table: +(Indirect) +Node: overview^?104 +Node: info file^?1271 +@end group +@group +Node: printed manual^?4853 +Node: conventions^?6855 +@dots{} +@end group +@end example + +@noindent +(But @file{test-texinfo} had far more nodes than are shown here.) Each of +the split off, indirect files, @file{test-texinfo-1}, +@file{test-texinfo-2}, and @file{test-texinfo-3}, is listed in this file +after the line that says @samp{Indirect:}. The tag table is listed after +the line that says @samp{Tag table:}. @refill + +In the list of indirect files, the number following the file name +records the cumulative number of bytes in the preceding indirect files, +not counting the file list itself, the tag table, or the permissions +text in each file. In the tag table, the number following the node name +records the location of the beginning of the node, in bytes from the +beginning.@refill + +If you are using @code{texinfo-format-buffer} to create Info files, +you may want to run the @code{Info-validate} command. (The +@code{makeinfo} command does such a good job on its own, you do not +need @code{Info-validate}.) However, you cannot run the @kbd{M-x +Info-validate} node-checking command on indirect files. For +information on how to prevent files from being split and how to +validate the structure of the nodes, see @ref{Using +Info-validate}.@refill + + +@node Install an Info File, Command List, Create an Info File, Top +@comment node-name, next, previous, up +@chapter Installing an Info File +@cindex Installing an Info file +@cindex Info file installation +@cindex @file{dir} directory for Info installation + +Info files are usually kept in the @file{info} directory. You can read +Info files using the standalone Info program or the Info reader built +into Emacs. (@inforef{Top, info, info}, for an introduction to Info.) + +@menu +* Directory file:: The top level menu for all Info files. +* New Info File:: Listing a new info file. +* Other Info Directories:: How to specify Info files that are + located in other directories. +* Installing Dir Entries:: How to specify what menu entry to add + to the Info directory. +* Invoking install-info:: @code{install-info} options. +@end menu + +@node Directory file, New Info File, Install an Info File, Install an Info File +@ifinfo +@heading The @file{dir} File +@end ifinfo + +For Info to work, the @file{info} directory must contain a file that +serves as a top level directory for the Info system. By convention, +this file is called @file{dir}. (You can find the location of this file +within Emacs by typing @kbd{C-h i} to enter Info and then typing +@kbd{C-x C-f} to see the pathname to the @file{info} directory.) + +The @file{dir} file is itself an Info file. It contains the top level +menu for all the Info files in the system. The menu looks like +this:@refill + +@example +@group +* Menu: + +* Info: (info). Documentation browsing system. +* Emacs: (emacs). The extensible, self-documenting + text editor. +* Texinfo: (texinfo). With one source file, make + either a printed manual using + TeX or an Info file. +@dots{} +@end group +@end example + +Each of these menu entries points to the `Top' node of the Info file +that is named in parentheses. (The menu entry does not need to +specify the `Top' node, since Info goes to the `Top' node if no node +name is mentioned. @xref{Other Info Files, , Nodes in Other Info +Files}.)@refill + +Thus, the @samp{Info} entry points to the `Top' node of the +@file{info} file and the @samp{Emacs} entry points to the `Top' node +of the @file{emacs} file.@refill + +In each of the Info files, the `Up' pointer of the `Top' node refers +back to the @code{dir} file. For example, the line for the `Top' +node of the Emacs manual looks like this in Info:@refill + +@example +File: emacs Node: Top, Up: (DIR), Next: Distrib +@end example + +@noindent +(Note that in this case, the @file{dir} file name is written in upper +case letters---it can be written in either upper or lower case. Info +has a feature that it will change the case of the file name to lower +case if it cannot find the name as written.)@refill +@c !!! Can any file name be written in upper or lower case, +@c or is dir a special case? +@c Yes, apparently so, at least with Gillespie's Info. --rjc 24mar92 + + +@node New Info File, Other Info Directories, Directory file, Install an Info File +@section Listing a New Info File +@cindex Adding a new info file +@cindex Listing a new info file +@cindex New info file, listing it in @file{dir} file +@cindex Info file, listing new one +@cindex @file{dir} file listing + +To add a new Info file to your system, you must write a menu entry to +add to the menu in the @file{dir} file in the @file{info} directory. +For example, if you were adding documentation for GDB, you would write +the following new entry:@refill + +@example +* GDB: (gdb). The source-level C debugger. +@end example + +@noindent +The first part of the menu entry is the menu entry name, followed by a +colon. The second part is the name of the Info file, in parentheses, +followed by a period. The third part is the description. + +The name of an Info file often has a @file{.info} extension. Thus, the +Info file for GDB might be called either @file{gdb} or @file{gdb.info}. +The Info reader programs automatically try the file name both with and +without @file{.info}; so it is better to avoid clutter and not to write +@samp{.info} explicitly in the menu entry. For example, the GDB menu +entry should use just @samp{gdb} for the file name, not @samp{gdb.info}. + + +@node Other Info Directories, Installing Dir Entries, New Info File, Install an Info File +@comment node-name, next, previous, up +@section Info Files in Other Directories +@cindex Installing Info in another directory +@cindex Info installed in another directory +@cindex Another Info directory + +If an Info file is not in the @file{info} directory, there are three +ways to specify its location:@refill + +@itemize @bullet +@item +Write the pathname in the @file{dir} file as the second part of the +menu.@refill + +@item +If you are using Emacs, list the name of the file in a second @file{dir} +file, in its directory; and then add the name of that directory to the +@code{Info-directory-list} variable in your personal or site +initialization file. + +This tells Emacs's Info reader where to look for @file{dir} +files. Emacs merges the files named @file{dir} from each of the listed +directories. (In Emacs Version 18, you can set the +@code{Info-directory} variable to the name of only one +directory.)@refill + +@item +Specify the @file{info} directory name in the @code{INFOPATH} +environment variable in your @file{.profile} or @file{.cshrc} +initialization file. (Only you and others who set this environment +variable will be able to find Info files whose location is specified +this way.)@refill +@end itemize + +For example, to reach a test file in the @file{~bob/manuals} +directory, you could add an entry like this to the menu in the +@file{dir} file:@refill + +@example +* Test: (/home/bob/manuals/info-test). Bob's own test file. +@end example + +@noindent +In this case, the absolute file name of the @file{info-test} file is +written as the second part of the menu entry.@refill + +@vindex Info-directory-list +Alternatively, you could write the following in your @file{.emacs} +file:@refill + +@example +@group +(setq Info-directory-list + '("/home/bob/manuals" + "/usr/local/emacs/info")) +@end group +@end example + +@c reworded to avoid overfill hbox +This tells Emacs to merge the @file{dir} file from the +@file{/home/bob/manuals} directory with the @file{dir} file from the +@file{"/usr/local/emacs/info}" directory. Info will list the +@file{/home/bob/manuals/info-test} file as a menu entry in the +@file{/home/bob/manuals/dir} file.@refill + +@vindex INFOPATH +Finally, you can tell Info where to look by setting the +@code{INFOPATH} environment variable in your @file{.cshrc} or +@file{.profile} file.@refill + +If you use @code{sh} or @code{bash} for your shell command interpreter, +you must set the @code{INFOPATH} environment variable in the +@file{.profile} initialization file; but if you use @code{csh}, you must +set the variable in the @file{.cshrc} initialization file. The two +files use slightly different command formats.@refill + +@itemize @bullet +@item +In a @file{.cshrc} file, you could set the @code{INFOPATH} +variable as follows:@refill + +@smallexample +setenv INFOPATH .:~bob/manuals:/usr/local/emacs/info +@end smallexample + +@item +In a @file{.profile} file, you would achieve the same effect by +writing:@refill + +@smallexample +INFOPATH=.:~bob/manuals:/usr/local/emacs/info +export INFOPATH +@end smallexample +@end itemize + +@noindent +The @samp{.} indicates the current directory. Emacs uses the +@code{INFOPATH} environment variable to initialize the value of Emacs's +own @code{Info-directory-list} variable. + + +@node Installing Dir Entries, Invoking install-info, Other Info Directories, Install an Info File +@section Installing Info Directory Files + +When you install an Info file onto your system, you can use the program +@code{install-info} to update the Info directory file @file{dir}. +Normally the makefile for the package runs @code{install-info}, just +after copying the Info file into its proper installed location. + +@findex dircategory +@findex direntry +In order for the Info file to work with @code{install-info}, you should +use the commands @code{@@dircategory} and @code{@@direntry} in the +Texinfo source file. Use @code{@@direntry} to specify the menu entry to +add to the Info directory file, and use @code{@@dircategory} to specify +which part of the Info directory to put it in. Here is how these +commands are used in this manual: + +@smallexample +@@dircategory Texinfo documentation system +@@direntry +* Texinfo: (texinfo). The GNU documentation format. +* install-info: (texinfo)Invoking install-info. @dots{} +@dots{} +@@end direntry +@end smallexample + +Here's what this produces in the Info file: + +@smallexample +INFO-DIR-SECTION Texinfo documentation system +START-INFO-DIR-ENTRY +* Texinfo: (texinfo). The GNU documentation format. +* install-info: (texinfo)Invoking install-info. @dots{} +@dots{} +END-INFO-DIR-ENTRY +@end smallexample + +@noindent +The @code{install-info} program sees these lines in the Info file, and +that is how it knows what to do. + +Always use the @code{@@direntry} and @code{@@dircategory} commands near +the beginning of the Texinfo input, before the first @code{@@node} +command. If you use them later on in the input, @code{install-info} +will not notice them. + +If you use @code{@@dircategory} more than once in the Texinfo source, +each usage specifies one category; the new menu entry is added to the +Info directory file in each of the categories you specify. If you use +@code{@@direntry} more than once, each usage specifies one menu entry; +each of these menu entries is added to the directory in each of the +specified categories. + + +@node Invoking install-info, , Installing Dir Entries, Install an Info File +@section Invoking install-info + +@pindex install-info + +@code{install-info} inserts menu entries from an Info file into the +top-level @file{dir} file in the Info system (see the previous sections +for an explanation of how the @file{dir} file works). It's most often +run as part of software installation, or when constructing a dir file +for all manuals on a system. Synopsis: + +@example +install-info [@var{option}]@dots{} [@var{info-file} [@var{dir-file}]] +@end example + +If @var{info-file} or @var{dir-file} are not specified, the various +options (described below) that define them must be. There are no +compile-time defaults, and standard input is never used. +@code{install-info} can read only one info file and write only one dir +file per invocation. + +Options: + +@table @samp +@item --delete +@opindex --delete +Only delete existing entries in @var{info-file}; don't insert any new +entries. + +@item --dir-file=@var{name} +@opindex --dir-file=@var{name} +Specify file name of the Info directory file. This is equivalent to +using the @var{dir-file} argument. + +@item --entry=@var{text} +@opindex --entry=@var{text} +Insert @var{text} as an Info directory entry; @var{text} should have the +form of an Info menu item line plus zero or more extra lines starting +with whitespace. If you specify more than one entry, they are all +added. If you don't specify any entries, they are determined from +information in the Info file itself. + +@item --help +@opindex --help +Display a usage message listing basic usage and all available options, +then exit successfully. + +@item --info-file=@var{file} +@opindex --info-file=@var{file} +Specify Info file to install in the directory. +This is equivalent to using the @var{info-file} argument. + +@item --info-dir=@var{dir} +@opindex --info-dir=@var{dir} +Equivalent to @samp{--dir-file=@var{dir}/dir}. + +@item --item=@var{text} +@opindex --item=@var{text} +Same as --entry=@var{text}. An Info directory entry is actually a menu +item. + +@item --quiet +@opindex --quiet +Suppress warnings. + +@item --remove +@opindex --remove +Same as --delete. + +@item --section=@var{sec} +@opindex --section=@var{sec} +Put this file's entries in section @var{sec} of the directory. If you +specify more than one section, all the entries are added in each of the +sections. If you don't specify any sections, they are determined from +information in the Info file itself. + +@item --version +@opindex --version +@cindex version number, finding +Display version information and exit successfully. + +@end table + + +@c ================ Appendix starts here ================ + +@node Command List, Tips, Install an Info File, Top +@appendix @@-Command List +@cindex Alphabetical @@-command list +@cindex List of @@-commands +@cindex @@-command list + +Here is an alphabetical list of the @@-commands in Texinfo. Square +brackets, @t{[}@w{ }@t{]}, indicate optional arguments; an ellipsis, +@samp{@dots{}}, indicates repeated text.@refill + +@sp 1 +@table @code +@item @@@var{whitespace} +An @code{@@} followed by a space, tab, or newline produces a normal, +stretchable, interword space. @xref{Multiple Spaces}. + +@item @@! +Generate an exclamation point that really does end a sentence (usually +after an end-of-sentence capital letter). @xref{Ending a Sentence}. + +@item @@" +@itemx @@' +Generate an umlaut or acute accent, respectively, over the next +character, as in @"o and @'o. @xref{Inserting Accents}. + +@item @@* +Force a line break. Do not end a paragraph that uses @code{@@*} with +an @code{@@refill} command. @xref{Line Breaks}.@refill + +@item @@,@{@var{c}@} +Generate a cedilla accent under @var{c}, as in @,{c}. @xref{Inserting +Accents}. + +@item @@- +Insert a discretionary hyphenation point. @xref{- and hyphenation}. + +@item @@. +Produce a period that really does end a sentence (usually after an +end-of-sentence capital letter). @xref{Ending a Sentence}. + +@item @@: +Indicate to @TeX{} that an immediately preceding period, question +mark, exclamation mark, or colon does not end a sentence. Prevent +@TeX{} from inserting extra whitespace as it does at the end of a +sentence. The command has no effect on the Info file output. +@xref{Not Ending a Sentence}.@refill + +@item @@= +Generate a macro (bar) accent over the next character, as in @=o. +@xref{Inserting Accents}. + +@item @@? +Generate a question mark that really does end a sentence (usually after +an end-of-sentence capital letter). @xref{Ending a Sentence}. + +@item @@@@ +Stands for an at sign, @samp{@@}.@* +@xref{Braces Atsigns, , Inserting @@ and braces}. + +@item @@^ +@itemx @@` +Generate a circumflex (hat) or grave accent, respectively, over the next +character, as in @^o. +@xref{Inserting Accents}. + +@item @@@{ +Stands for a left brace, @samp{@{}.@* +@xref{Braces Atsigns, , Inserting @@ and braces}. + +@item @@@} +Stands for a right-hand brace, @samp{@}}.@* +@xref{Braces Atsigns, , Inserting @@ and braces}. + +@item @@= +Generate a tilde accent over the next character, as in @~N. +@xref{Inserting Accents}. + +@item @@AA@{@} +@itemx @@aa@{@} +Generate the uppercase and lowercase Scandinavian A-ring letters, +respectively: @AA{}, @aa{}. @xref{Inserting Accents}. + +@item @@AE@{@} +@itemx @@ae@{@} +Generate the uppercase and lowercase AE ligatures, respectively: +@AE{}, @ae{}. @xref{Inserting Accents}. + +@item @@appendix @var{title} +Begin an appendix. The title appears in the table +of contents of a printed manual. In Info, the title is +underlined with asterisks. @xref{unnumbered & appendix, , The +@code{@@unnumbered} and @code{@@appendix} Commands}.@refill + +@item @@appendixsec @var{title} +@itemx @@appendixsection @var{title} +Begin an appendix section within an appendix. The section title appears +in the table of contents of a printed manual. In Info, the title is +underlined with equal signs. @code{@@appendixsection} is a longer +spelling of the @code{@@appendixsec} command. @xref{unnumberedsec +appendixsec heading, , Section Commands}.@refill + +@item @@appendixsubsec @var{title} +Begin an appendix subsection within an appendix. The title appears +in the table of contents of a printed manual. In Info, the title is +underlined with hyphens. @xref{unnumberedsubsec appendixsubsec +subheading, , Subsection Commands}.@refill + +@item @@appendixsubsubsec @var{title} +Begin an appendix subsubsection within a subappendix. The title +appears in the table of contents of a printed manual. In Info, the +title is underlined with periods. @xref{subsubsection,, The `subsub' +Commands}.@refill + +@item @@asis +Used following @code{@@table}, @code{@@ftable}, and @code{@@vtable} to +print the table's first column without highlighting (``as is''). +@xref{Two-column Tables, , Making a Two-column Table}.@refill + +@item @@author @var{author} +Typeset @var{author} flushleft and underline it. @xref{title +subtitle author, , The @code{@@title} and @code{@@author} +Commands}.@refill + +@item @@b@{@var{text}@} +Print @var{text} in @b{bold} font. No effect in Info. @xref{Fonts}.@refill + +@ignore +@item @@br +Force a paragraph break. If used within a line, follow @code{@@br} +with braces. @xref{br, , @code{@@br}}.@refill +@end ignore + +@item @@bullet@{@} +Generate a large round dot, or the closest possible +thing to one. @xref{bullet, , @code{@@bullet}}.@refill + +@item @@bye +Stop formatting a file. The formatters do not see the contents of a +file following an @code{@@bye} command. @xref{Ending a File}.@refill + +@item @@c @var{comment} +Begin a comment in Texinfo. The rest of the line does not appear in +either the Info file or the printed manual. A synonym for +@code{@@comment}. @xref{Comments, , Comments}.@refill + +@item @@cartouche +Highlight an example or quotation by drawing a box with rounded +corners around it. Pair with @code{@@end cartouche}. No effect in +Info. @xref{cartouche, , Drawing Cartouches Around Examples}.)@refill + +@item @@center @var{line-of-text} +Center the line of text following the command. +@xref{titlefont center sp, , @code{@@center}}.@refill + +@item @@centerchap @var{line-of-text} +Like @code{@@chapter}, but centers the chapter title. @xref{chapter,, +@code{@@chapter}}. + +@item @@chapheading @var{title} +Print a chapter-like heading in the text, but not in the table of +contents of a printed manual. In Info, the title is underlined with +asterisks. @xref{majorheading & chapheading, , @code{@@majorheading} +and @code{@@chapheading}}.@refill + +@item @@chapter @var{title} +Begin a chapter. The chapter title appears in the table of +contents of a printed manual. In Info, the title is underlined with +asterisks. @xref{chapter, , @code{@@chapter}}.@refill + +@item @@cindex @var{entry} +Add @var{entry} to the index of concepts. @xref{Index Entries, , +Defining the Entries of an Index}.@refill + +@item @@cite@{@var{reference}@} +Highlight the name of a book or other reference that lacks a +companion Info file. @xref{cite, , @code{@@cite}}.@refill + +@item @@clear @var{flag} +Unset @var{flag}, preventing the Texinfo formatting commands from +formatting text between subsequent pairs of @code{@@ifset @var{flag}} +and @code{@@end ifset} commands, and preventing +@code{@@value@{@var{flag}@}} from expanding to the value to which +@var{flag} is set. +@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill + +@item @@code@{@var{sample-code}@} +Highlight text that is an expression, a syntactically complete token +of a program, or a program name. @xref{code, , @code{@@code}}.@refill + +@item @@comment @var{comment} +Begin a comment in Texinfo. The rest of the line does not appear in +either the Info file or the printed manual. A synonym for @code{@@c}. +@xref{Comments, , Comments}.@refill + +@item @@contents +Print a complete table of contents. Has no effect in Info, which uses +menus instead. @xref{Contents, , Generating a Table of +Contents}.@refill + +@item @@copyright@{@} +Generate a copyright symbol. @xref{copyright symbol, , +@code{@@copyright}}.@refill + +@ignore +@item @@ctrl@{@var{ctrl-char}@} +Describe an @sc{ascii} control character. Insert actual control character +into Info file. @xref{ctrl, , @code{@@ctrl}}.@refill +@end ignore + +@item @@defcodeindex @var{index-name} +Define a new index and its indexing command. Print entries in an +@code{@@code} font. @xref{New Indices, , Defining New +Indices}.@refill + +@item @@defcv @var{category} @var{class} @var{name} +@itemx @@defcvx @var{category} @var{class} @var{name} +Format a description for a variable associated with a class in +object-oriented programming. Takes three arguments: the category of +thing being defined, the class to which it belongs, and its name. +@xref{Definition Commands}, and @ref{deffnx,, Def Cmds in Detail}. + +@item @@deffn @var{category} @var{name} @var{arguments}@dots{} +@itemx @@deffnx @var{category} @var{name} @var{arguments}@dots{} +Format a description for a function, interactive command, or similar +entity that may take arguments. @code{@@deffn} takes as arguments the +category of entity being described, the name of this particular +entity, and its arguments, if any. @xref{Definition Commands}.@refill + +@item @@defindex @var{index-name} +Define a new index and its indexing command. Print entries in a roman +font. @xref{New Indices, , Defining New Indices}.@refill + +@c Unused so far as I can see and unsupported by makeinfo -- karl, 15sep96. +@item @@definfoenclose @var{new-command}, @var{before}, @var{after}, +Create new @@-command for Info that marks text by enclosing it in +strings that precede and follow the text. Write definition inside of +@code{@@ifinfo} @dots{} @code{@@end ifinfo}. @xref{Customized +Highlighting}.@refill + +@item @@defivar @var{class} @var{instance-variable-name} +@itemx @@defivarx @var{class} @var{instance-variable-name} +This command formats a description for an instance variable in +object-oriented programming. The command is equivalent to @samp{@@defcv +@{Instance Variable@} @dots{}}. @xref{Definition Commands}, and +@ref{deffnx,, Def Cmds in Detail}. + +@item @@defmac @var{macro-name} @var{arguments}@dots{} +@itemx @@defmacx @var{macro-name} @var{arguments}@dots{} +Format a description for a macro. The command is equivalent to +@samp{@@deffn Macro @dots{}}. @xref{Definition Commands}, and +@ref{deffnx,, Def Cmds in Detail}. + +@item @@defmethod @var{class} @var{method-name} @var{arguments}@dots{} +@itemx @@defmethodx @var{class} @var{method-name} @var{arguments}@dots{} +Format a description for a method in object-oriented programming. The +command is equivalent to @samp{@@defop Method @dots{}}. Takes as +arguments the name of the class of the method, the name of the +method, and its arguments, if any. @xref{Definition Commands}, and +@ref{deffnx,, Def Cmds in Detail}. + +@item @@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} +@itemx @@defopx @var{category} @var{class} @var{name} @var{arguments}@dots{} +Format a description for an operation in object-oriented programming. +@code{@@defop} takes as arguments the overall name of the category of +operation, the name of the class of the operation, the name of the +operation, and its arguments, if any. @xref{Definition +Commands}, and @ref{deffnx,, Def Cmds in Detail}. + +@item @@defopt @var{option-name} +@itemx @@defoptx @var{option-name} +Format a description for a user option. The command is equivalent to +@samp{@@defvr @{User Option@} @dots{}}. @xref{Definition Commands}, and +@ref{deffnx,, Def Cmds in Detail}. + +@item @@defspec @var{special-form-name} @var{arguments}@dots{} +@itemx @@defspecx @var{special-form-name} @var{arguments}@dots{} +Format a description for a special form. The command is equivalent to +@samp{@@deffn @{Special Form@} @dots{}}. @xref{Definition Commands}, +and @ref{deffnx,, Def Cmds in Detail}. + +@item @@deftp @var{category} @var{name-of-type} @var{attributes}@dots{} +@itemx @@deftpx @var{category} @var{name-of-type} @var{attributes}@dots{} +Format a description for a data type. @code{@@deftp} takes as arguments +the category, the name of the type (which is a word like @samp{int} or +@samp{float}), and then the names of attributes of objects of that type. +@xref{Definition Commands}, and @ref{deffnx,, Def Cmds in Detail}. + +@item @@deftypefn @var{classification} @var{data-type} @var{name} @var{arguments}@dots{} +@itemx @@deftypefnx @var{classification} @var{data-type} @var{name} @var{arguments}@dots{} +Format a description for a function or similar entity that may take +arguments and that is typed. @code{@@deftypefn} takes as arguments the +classification of entity being described, the type, the name of the +entity, and its arguments, if any. @xref{Definition Commands}, and +@ref{deffnx,, Def Cmds in Detail}. + +@item @@deftypefun @var{data-type} @var{function-name} @var{arguments}@dots{} +@itemx @@deftypefunx @var{data-type} @var{function-name} @var{arguments}@dots{} +Format a description for a function in a typed language. +The command is equivalent to @samp{@@deftypefn Function @dots{}}. +@xref{Definition Commands}, +and @ref{deffnx,, Def Cmds in Detail}. + +@item @@deftypevr @var{classification} @var{data-type} @var{name} +@itemx @@deftypevrx @var{classification} @var{data-type} @var{name} +Format a description for something like a variable in a typed +language---an entity that records a value. Takes as arguments the +classification of entity being described, the type, and the name of the +entity. @xref{Definition Commands}, and @ref{deffnx,, Def Cmds in +Detail}. + +@item @@deftypevar @var{data-type} @var{variable-name} +@itemx @@deftypevarx @var{data-type} @var{variable-name} +Format a description for a variable in a typed language. The command is +equivalent to @samp{@@deftypevr Variable @dots{}}. @xref{Definition +Commands}, and @ref{deffnx,, Def Cmds in Detail}. + +@item @@defun @var{function-name} @var{arguments}@dots{} +@itemx @@defunx @var{function-name} @var{arguments}@dots{} +Format a description for functions. The command is equivalent to +@samp{@@deffn Function @dots{}}. @xref{Definition Commands}, and +@ref{deffnx,, Def Cmds in Detail}. + +@item @@defvar @var{variable-name} +@itemx @@defvarx @var{variable-name} +Format a description for variables. The command is equivalent to +@samp{@@defvr Variable @dots{}}. @xref{Definition Commands}, and +@ref{deffnx,, Def Cmds in Detail}. + +@item @@defvr @var{category} @var{name} +@itemx @@defvrx @var{category} @var{name} +Format a description for any kind of variable. @code{@@defvr} takes +as arguments the category of the entity and the name of the entity. +@xref{Definition Commands}, +and @ref{deffnx,, Def Cmds in Detail}. + +@item @@detailmenu@{@} +Use to avoid Makeinfo confusion stemming from the detailed node listing +in a master menu. @xref{Master Menu Parts}. + +@item @@dfn@{@var{term}@} +Highlight the introductory or defining use of a term. +@xref{dfn, , @code{@@dfn}}.@refill + +@item @@dircategory @var{dirpart} +Specify a part of the Info directory menu where this file's entry should +go. @xref{Installing Dir Entries}. + +@item @@direntry +Begin the Info directory menu entry for this file. +@xref{Installing Dir Entries}. + +@need 100 +@item @@display +Begin a kind of example. Indent text, do not fill, do not select a +new font. Pair with @code{@@end display}. @xref{display, , +@code{@@display}}.@refill + +@item @@dmn@{@var{dimension}@} +Format a unit of measure, as in 12@dmn{pt}. Causes @TeX{} to insert a +thin space before @var{dimension}. No effect in Info. +@xref{dmn, , @code{@@dmn}}.@refill + +@need 100 +@item @@dots@{@} +Insert an ellipsis: @samp{@dots{}}. +@xref{dots, , @code{@@dots}}.@refill + +@item @@email@{@var{address}@} +Indicate an electronic mail address. +@xref{email, , @code{@@email}}.@refill + +@need 100 +@item @@emph@{@var{text}@} +Highlight @var{text}; text is displayed in @emph{italics} in printed +output, and surrounded by asterisks in Info. @xref{Emphasis, , Emphasizing Text}.@refill + +@item @@end @var{environment} +Ends @var{environment}, as in @samp{@@end example}. @xref{Formatting +Commands,,@@-commands}. + +@item @@enddots@{@} +Generate an end-of-sentence of ellipsis, like this @enddots{} +@xref{dots,,@code{@@dots@{@}}}. + +@need 100 +@item @@enumerate [@var{number-or-letter}] +Begin a numbered list, using @code{@@item} for each entry. +Optionally, start list with @var{number-or-letter}. Pair with +@code{@@end enumerate}. @xref{enumerate, , +@code{@@enumerate}}.@refill + +@need 100 +@item @@equiv@{@} +Indicate to the reader the exact equivalence of two forms with a +glyph: @samp{@equiv{}}. @xref{Equivalence}.@refill + +@item @@error@{@} +Indicate to the reader with a glyph that the following text is +an error message: @samp{@error{}}. @xref{Error Glyph}.@refill + +@item @@evenfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] +Specify page footings for even-numbered (left-hand) pages. Not relevant to +Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill + +@item @@evenheading [@var{left}] @@| [@var{center}] @@| [@var{right}] +Specify page headings for even-numbered (left-hand) pages. Only +supported within @code{@@iftex}. @xref{Custom Headings, , How to Make +Your Own Headings}.@refill + +@item @@everyfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] +@itemx @@everyheading [@var{left}] @@| [@var{center}] @@| [@var{right}] +Specify page footings resp.@: headings for every page. Not relevant to +Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill + +@item @@example +Begin an example. Indent text, do not fill, and select fixed-width font. +Pair with @code{@@end example}. @xref{example, , +@code{@@example}}.@refill + +@item @@exclamdown@{@} +Generate an upside-down exclamation point. @xref{Inserting Accents}. + +@item @@exdent @var{line-of-text} +Remove any indentation a line might have. @xref{exdent, , +Undoing the Indentation of a Line}.@refill + +@item @@expansion@{@} +Indicate the result of a macro expansion to the reader with a special +glyph: @samp{@expansion{}}. +@xref{expansion, , @expansion{} Indicating an Expansion}.@refill + +@item @@file@{@var{filename}@} +Highlight the name of a file, buffer, node, or directory. @xref{file, , +@code{@@file}}.@refill + +@item @@finalout +Prevent @TeX{} from printing large black warning rectangles beside +over-wide lines. @xref{Overfull hboxes}.@refill + +@need 100 +@item @@findex @var{entry} +Add @var{entry} to the index of functions. @xref{Index Entries, , +Defining the Entries of an Index}.@refill + +@need 200 +@item @@flushleft +@itemx @@flushright +Left justify every line but leave the right end ragged. +Leave font as is. Pair with @code{@@end flushleft}. +@code{@@flushright} analogous. +@xref{flushleft & flushright, , @code{@@flushleft} and +@code{@@flushright}}.@refill + +@need 200 +@item @@footnote@{@var{text-of-footnote}@} +Enter a footnote. Footnote text is printed at the bottom of the page +by @TeX{}; Info may format in either `End' node or `Separate' node style. +@xref{Footnotes}.@refill + +@item @@footnotestyle @var{style} +Specify an Info file's footnote style, either @samp{end} for the end +node style or @samp{separate} for the separate node style. +@xref{Footnotes}.@refill + +@item @@format +Begin a kind of example. Like @code{@@example} or @code{@@display}, +but do not narrow the margins and do not select the fixed-width font. +Pair with @code{@@end format}. @xref{example, , +@code{@@example}}.@refill + +@item @@ftable @var{formatting-command} +Begin a two-column table, using @code{@@item} for each entry. +Automatically enter each of the items in the first column into the +index of functions. Pair with @code{@@end ftable}. The same as +@code{@@table}, except for indexing. @xref{ftable vtable, , +@code{@@ftable} and @code{@@vtable}}.@refill + +@item @@group +Hold text together that must appear on one printed page. Pair with +@code{@@end group}. Not relevant to Info. @xref{group, , +@code{@@group}}.@refill + +@item @@H@{@var{c}@} +Generate the long Hungarian umlaut accent over @var{c}, as in @H{o}. + +@item @@heading @var{title} +Print an unnumbered section-like heading in the text, but not in the +table of contents of a printed manual. In Info, the title is +underlined with equal signs. @xref{unnumberedsec appendixsec heading, +, Section Commands}.@refill + +@item @@headings @var{on-off-single-double} +Turn page headings on or off, and/or specify single-sided or double-sided +page headings for printing. @xref{headings on off, , The +@code{@@headings} Command}. + +@item @@i@{@var{text}@} +Print @var{text} in @i{italic} font. No effect in Info. +@xref{Fonts}.@refill + +@item @@ifclear @var{flag} +If @var{flag} is cleared, the Texinfo formatting commands format text +between @code{@@ifclear @var{flag}} and the following @code{@@end +ifclear} command. +@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill + +@item @@ifhtml +@itemx @@ifinfo +Begin a stretch of text that will be ignored by @TeX{} when it typesets +the printed manual. The text appears only in the HTML resp.@: Info +file. Pair with @code{@@end ifhtml} resp.@: @code{@@end ifinfo}. +@xref{Conditionals, , Conditionally Visible Text}.@refill + +@item @@ifset @var{flag} +If @var{flag} is set, the Texinfo formatting commands format text +between @code{@@ifset @var{flag}} and the following @code{@@end ifset} +command. +@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill + +@item @@iftex +Begin a stretch of text that will not appear in the Info file, but +will be processed only by @TeX{}. Pair with @code{@@end iftex}. +@xref{Conditionals, , Conditionally Visible Text}.@refill + +@item @@ignore +Begin a stretch of text that will not appear in either the Info file +or the printed output. Pair with @code{@@end ignore}. +@xref{Comments, , Comments and Ignored Text}.@refill + +@item @@include @var{filename} +Incorporate the contents of the file @var{filename} into the Info file +or printed document. @xref{Include Files}.@refill + +@item @@inforef@{@var{node-name}, [@var{entry-name}], @var{info-file-name}@} +Make a cross reference to an Info file for which there is no printed +manual. @xref{inforef, , Cross references using +@code{@@inforef}}.@refill + +@item \input @var{macro-definitions-file} +Use the specified macro definitions file. This command is used only +in the first line of a Texinfo file to cause @TeX{} to make use of the +@file{texinfo} macro definitions file. The backslash in @code{\input} +is used instead of an @code{@@} because @TeX{} does not +recognize @code{@@} until after it has read the definitions file. +@xref{Header, , The Texinfo File Header}.@refill + +@item @@item +Indicate the beginning of a marked paragraph for @code{@@itemize} and +@code{@@enumerate}; indicate the beginning of the text of a first column +entry for @code{@@table}, @code{@@ftable}, and @code{@@vtable}. +@xref{Lists and Tables}.@refill + +@item @@itemize @var{mark-generating-character-or-command} +Produce a sequence of indented paragraphs, with a mark inside the left +margin at the beginning of each paragraph. Pair with @code{@@end +itemize}. @xref{itemize, , @code{@@itemize}}.@refill + +@item @@itemx +Like @code{@@item} but do not generate extra vertical space above the +item text. @xref{itemx, , @code{@@itemx}}.@refill + +@item @@kbd@{@var{keyboard-characters}@} +Indicate text that is characters of input to be typed by +users. @xref{kbd, , @code{@@kbd}}.@refill + +@item @@key@{@var{key-name}@} +Highlight @var{key-name}, a name for a key on a keyboard. +@xref{key, , @code{@@key}}.@refill + +@item @@kindex @var{entry} +Add @var{entry} to the index of keys. @xref{Index Entries, , Defining the +Entries of an Index}.@refill + +@item @@L@{@} +@itemx @@l@{@} +Generate the uppercase and lowercase Polish suppressed-L letters, +respectively: @L{}, @l{}. + +@c Possibly this can be tossed now that we have macros. --karl, 16sep96. +@item @@global@@let@var{new-command}=@var{existing-command} +Equate a new highlighting command with an existing one. Only for +@TeX{}. Write definition inside of @code{@@iftex} @dots{} @code{@@end +iftex}. @xref{Customized Highlighting}.@refill + +@item @@lisp +Begin an example of Lisp code. Indent text, do not fill, and select +fixed-width font. Pair with @code{@@end lisp}. @xref{Lisp Example, , +@code{@@lisp}}.@refill + +@item @@lowersections +Change subsequent chapters to sections, sections to subsections, and so +on. @xref{Raise/lower sections, , @code{@@raisesections} and +@code{@@lowersections}}.@refill + +@item @@macro @var{macro-name} @{@var{params}@} +Define a new Texinfo command @code{@@@var{macro-name}@{@var{params}@}}. +Only supported by Makeinfo and Texi2dvi. @xref{Defining Macros}. + +@item @@majorheading @var{title} +Print a chapter-like heading in the text, but not in the table of +contents of a printed manual. Generate more vertical whitespace before +the heading than the @code{@@chapheading} command. In Info, the chapter +heading line is underlined with asterisks. @xref{majorheading & +chapheading, , @code{@@majorheading} and @code{@@chapheading}}.@refill + +@item @@math@{@var{mathematical-expression}@} +Format a mathematical expression. +@xref{math, , @code{@@math}: Inserting Mathematical Expressions}. + +@item @@menu +Mark the beginning of a menu of nodes in Info. No effect in a printed +manual. Pair with @code{@@end menu}. @xref{Menus}.@refill + +@item @@minus@{@} +Generate a minus sign, `@minus{}'. @xref{minus, , @code{@@minus}}.@refill + +@item @@multitable @var{column-width-spec} +Begin a multi-column table. Pair with @code{@@end multitable}. +@xref{Multitable Column Widths}. + +@item @@need @var{n} +Start a new page in a printed manual if fewer than @var{n} mils +(thousandths of an inch) remain on the current page. @xref{need, , +@code{@@need}}.@refill + +@item @@node @var{name, next, previous, up} +Define the beginning of a new node in Info, and serve as a locator for +references for @TeX{}. @xref{node, , @code{@@node}}.@refill + +@item @@noindent +Prevent text from being indented as if it were a new paragraph. +@xref{noindent, , @code{@@noindent}}.@refill + +@item @@O@{@} +@itemx @@o@{@} +Generate the uppercase and lowercase Owith-slash letters, respectively: +@O{}, @o{}. + +@item @@oddfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] +@itemx @@oddheading [@var{left}] @@| [@var{center}] @@| [@var{right}] +Specify page footings resp.@: headings for odd-numbered (right-hand) +pages. Only allowed inside @code{@@iftex}. @xref{Custom Headings, , +How to Make Your Own Headings}.@refill + +@item @@OE@{@} +@itemx @@oe@{@} +Generate the uppercase and lowercase OE ligatures, respectively: +@OE{}, @oe{}. @xref{Inserting Accents}. + +@item @@page +Start a new page in a printed manual. No effect in Info. +@xref{page, , @code{@@page}}.@refill + +@item @@paragraphindent @var{indent} +Indent paragraphs by @var{indent} number of spaces; delete indentation +if the value of @var{indent} is 0; and do not change indentation if +@var{indent} is @code{asis}. @xref{paragraphindent, , Paragraph +Indenting}.@refill + +@item @@pindex @var{entry} +Add @var{entry} to the index of programs. @xref{Index Entries, , Defining +the Entries of an Index}.@refill + +@item @@point@{@} +Indicate the position of point in a buffer to the reader with a +glyph: @samp{@point{}}. @xref{Point Glyph, , Indicating +Point in a Buffer}.@refill + +@item @@pounds@{@} +Generate the pounds sterling currency sign. +@xref{pounds,,@code{@@pounds@{@}}}. + +@item @@print@{@} +Indicate printed output to the reader with a glyph: +@samp{@print{}}. @xref{Print Glyph}.@refill + +@item @@printindex @var{index-name} +Print an alphabetized two-column index in a printed manual or generate +an alphabetized menu of index entries for Info. @xref{Printing +Indices & Menus}.@refill + +@item @@pxref@{@var{node-name}, [@var{entry}], [@var{topic-or-title}], [@var{info-file}], [@var{manual}]@} +Make a reference that starts with a lower case `see' in a printed +manual. Use within parentheses only. Do not follow command with a +punctuation mark---the Info formatting commands automatically insert +terminating punctuation as needed. Only the first argument is mandatory. +@xref{pxref, , @code{@@pxref}}.@refill + +@item @@questiondown@{@} +Generate an upside-down question mark. @xref{Inserting Accents}. + +@item @@quotation +Narrow the margins to indicate text that is quoted from another real +or imaginary work. Write command on a line of its own. Pair with +@code{@@end quotation}. @xref{quotation, , +@code{@@quotation}}.@refill + +@need 100 +@item @@r@{@var{text}@} +Print @var{text} in @r{roman} font. No effect in Info. +@xref{Fonts}.@refill + +@item @@raisesections +Change subsequent sections to chapters, subsections to sections, and so +on. @xref{Raise/lower sections, , @code{@@raisesections} and +@code{@@lowersections}}.@refill + +@need 300 +@item @@ref@{@var{node-name}, [@var{entry}], [@var{topic-or-title}], [@var{info-file}], [@var{manual}]@} +Make a reference. In a printed manual, the reference does not start +with a `See'. Follow command with a punctuation mark. Only the first +argument is mandatory. @xref{ref, , @code{@@ref}}.@refill + +@need 300 +@item @@refill +In Info, refill and indent the paragraph after all the other processing +has been done. No effect on @TeX{}, which always refills. This command +is no longer needed, since all formatters now automatically refill. +@xref{Refilling Paragraphs}.@refill + +@need 300 +@item @@result@{@} +Indicate the result of an expression to the reader with a special +glyph: @samp{@result{}}. @xref{result, , @code{@@result}}.@refill + +@item @@ringaccent@{@var{c}@} +Generate a ring accent over the next character, as in @ringaccent{o}. +@xref{Inserting Accents}. + +@item @@samp@{@var{text}@} +Highlight @var{text} that is a literal example of a sequence of +characters. Used for single characters, for statements, and often for +entire shell commands. @xref{samp, , @code{@@samp}}.@refill + +@item @@sc@{@var{text}@} +Set @var{text} in a printed output in @sc{the small caps font} and +set text in the Info file in uppercase letters. +@xref{Smallcaps}.@refill + +@item @@section @var{title} +Begin a section within a chapter. In a printed manual, the section +title is numbered and appears in the table of contents. In Info, the +title is underlined with equal signs. @xref{section, , +@code{@@section}}.@refill + +@item @@set @var{flag} [@var{string}] +Make @var{flag} active, causing the Texinfo formatting commands to +format text between subsequent pairs of @code{@@ifset @var{flag}} and +@code{@@end ifset} commands. Optionally, set value of @var{flag} to +@var{string}. +@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill + +@item @@setchapternewpage @var{on-off-odd} +Specify whether chapters start on new pages, and if so, whether on +odd-numbered (right-hand) new pages. @xref{setchapternewpage, , +@code{@@setchapternewpage}}.@refill + +@item @@setfilename @var{info-file-name} +Provide a name to be used by the Info file. This command is essential +for @TeX{} formatting as well, even though it produces no output. +@xref{setfilename, , @code{@@setfilename}}.@refill + +@item @@settitle @var{title} +Provide a title for page headers in a printed manual. +@xref{settitle, , @code{@@settitle}}.@refill + +@item @@shortcontents +Print a short table of contents. Not relevant to Info, which uses +menus rather than tables of contents. A synonym for +@code{@@summarycontents}. @xref{Contents, , Generating a Table of +Contents}.@refill + +@item @@shorttitlepage@{@var{title}@} +Generate a minimal title page. @xref{titlepage,,@code{@@titlepage}}. + +@need 400 +@item @@smallbook +Cause @TeX{} to produce a printed manual in a 7 by 9.25 inch format +rather than the regular 8.5 by 11 inch format. @xref{smallbook, , +Printing Small Books}. Also, see @ref{smallexample & smalllisp, , +@code{@@smallexample} and @code{@@smalllisp}}.@refill + +@need 400 +@item @@smallexample +Indent text to indicate an example. Do not fill, select fixed-width +font. In @code{@@smallbook} format, print text in a smaller font than +with @code{@@example}. Pair with @code{@@end smallexample}. +@xref{smallexample & smalllisp, , @code{@@smallexample} and +@code{@@smalllisp}}.@refill + +@need 400 +@item @@smalllisp +Begin an example of Lisp code. Indent text, do not fill, select +fixed-width font. In @code{@@smallbook} format, print text in a +smaller font. Pair with @code{@@end smalllisp}. @xref{smallexample & +smalllisp, , @code{@@smallexample} and @code{@@smalllisp}}.@refill + +@need 700 +@item @@sp @var{n} +Skip @var{n} blank lines. @xref{sp, , @code{@@sp}}.@refill + +@item @@ss@{@} +Generate the German sharp-S es-zet letter, @ss{}. @xref{Inserting Accents}. + +@need 700 +@item @@strong @var{text} +Emphasize @var{text} by typesetting it in a @strong{bold} font for the +printed manual and by surrounding it with asterisks for Info. +@xref{emph & strong, , Emphasizing Text}.@refill + +@item @@subheading @var{title} +Print an unnumbered subsection-like heading in the text, but not in +the table of contents of a printed manual. In Info, the title is +underlined with hyphens. @xref{unnumberedsubsec appendixsubsec +subheading, , @code{@@unnumberedsubsec} @code{@@appendixsubsec} +@code{@@subheading}}.@refill + +@item @@subsection @var{title} +Begin a subsection within a section. In a printed manual, the +subsection title is numbered and appears in the table of contents. In +Info, the title is underlined with hyphens. @xref{subsection, , +@code{@@subsection}}.@refill + +@item @@subsubheading @var{title} +Print an unnumbered subsubsection-like heading in the text, but not in +the table of contents of a printed manual. In Info, the title is +underlined with periods. @xref{subsubsection, , The `subsub' +Commands}.@refill + +@item @@subsubsection @var{title} +Begin a subsubsection within a subsection. In a printed manual, +the subsubsection title is numbered and appears in the table of +contents. In Info, the title is underlined with periods. +@xref{subsubsection, , The `subsub' Commands}.@refill + +@item @@subtitle @var{title} +In a printed manual, set a subtitle in a normal sized font flush to +the right-hand side of the page. Not relevant to Info, which does not +have title pages. @xref{title subtitle author, , @code{@@title} +@code{@@subtitle} and @code{@@author} Commands}.@refill + +@item @@summarycontents +Print a short table of contents. Not relevant to Info, which uses +menus rather than tables of contents. A synonym for +@code{@@shortcontents}. @xref{Contents, , Generating a Table of +Contents}.@refill + +@need 300 +@item @@syncodeindex @var{from-index} @var{into-index} +Merge the index named in the first argument into the index named in +the second argument, printing the entries from the first index in +@code{@@code} font. @xref{Combining Indices}.@refill + +@need 300 +@item @@synindex @var{from-index} @var{into-index} +Merge the index named in the first argument into the index named in +the second argument. Do not change the font of @var{from-index} +entries. @xref{Combining Indices}.@refill + +@need 100 +@item @@t@{@var{text}@} +Print @var{text} in a @t{fixed-width}, typewriter-like font. +No effect in Info. @xref{Fonts}.@refill + +@item @@tab +Separate columns in a multitable. @xref{Multitable Rows}. + +@need 400 +@item @@table @var{formatting-command} +Begin a two-column table, using @code{@@item} for each entry. Write +each first column entry on the same line as @code{@@item}. First +column entries are printed in the font resulting from +@var{formatting-command}. Pair with @code{@@end table}. +@xref{Two-column Tables, , Making a Two-column Table}. +Also see @ref{ftable vtable, , @code{@@ftable} and @code{@@vtable}}, +and @ref{itemx, , @code{@@itemx}}.@refill + +@item @@TeX@{@} +Insert the logo @TeX{}. @xref{TeX and copyright, , Inserting @TeX{} +and @copyright{}}.@refill + +@item @@tex +Enter @TeX{} completely. Pair with @code{@@end tex}. @xref{Using +Ordinary TeX Commands, , Using Ordinary @TeX{} Commands}.@refill + +@item @@thischapter +@itemx @@thischaptername +@itemx @@thisfile +@itemx @@thispage +@itemx @@thistitle +Only allowed in a heading or footing. Stands for the number and name of +the current chapter (in the format `Chapter 1: Title'), the chapter name +only, the filename, the current page number, and the title of the +document, respectively. @xref{Custom Headings, , How to Make Your Own +Headings}.@refill + +@item @@tindex @var{entry} +Add @var{entry} to the index of data types. @xref{Index Entries, , +Defining the Entries of an Index}.@refill + +@item @@title @var{title} +In a printed manual, set a title flush to the left-hand side of the +page in a larger than normal font and underline it with a black rule. +Not relevant to Info, which does not have title pages. @xref{title +subtitle author, , The @code{@@title} @code{@@subtitle} and +@code{@@author} Commands}.@refill + +@need 400 +@item @@titlefont@{@var{text}@} +In a printed manual, print @var{text} in a larger than normal font. +Not relevant to Info, which does not have title pages. +@xref{titlefont center sp, , The @code{@@titlefont} @code{@@center} +and @code{@@sp} Commands}.@refill + +@need 300 +@item @@titlepage +Indicate to Texinfo the beginning of the title page. Write command on +a line of its own. Pair with @code{@@end titlepage}. Nothing between +@code{@@titlepage} and @code{@@end titlepage} appears in Info. +@xref{titlepage, , @code{@@titlepage}}.@refill + +@need 150 +@item @@today@{@} +Insert the current date, in `1 Jan 1900' style. @xref{Custom +Headings, , How to Make Your Own Headings}.@refill + +@item @@top @var{title} +In a Texinfo file to be formatted with @code{makeinfo}, identify the +topmost @code{@@node} line in the file, which must be written on the line +immediately preceding the @code{@@top} command. Used for +@code{makeinfo}'s node pointer insertion feature. The title is +underlined with asterisks. Both the @code{@@node} line and the @code{@@top} +line normally should be enclosed by @code{@@ifinfo} and @code{@@end +ifinfo}. In @TeX{} and @code{texinfo-format-buffer}, the @code{@@top} +command is merely a synonym for @code{@@unnumbered}. @xref{makeinfo +Pointer Creation, , Creating Pointers with @code{makeinfo}}. + +@item @@u@var{c} +@itemx @@ubaraccent@var{c} +@itemx @@udotaccent@var{c} +Generate a breve, underbar, or underdot accent, respectively, over or +under the character @var{c}, as in @u{o}, @ubaraccent{o}, +@udotaccent{o}. @xref{Inserting Accents}. + +@item @@unnumbered @var{title} +In a printed manual, begin a chapter that appears without chapter +numbers of any kind. The title appears in the table of contents of a +printed manual. In Info, the title is underlined with asterisks. +@xref{unnumbered & appendix, , @code{@@unnumbered} and +@code{@@appendix}}.@refill + +@item @@unnumberedsec @var{title} +In a printed manual, begin a section that appears without section +numbers of any kind. The title appears in the table of contents of a +printed manual. In Info, the title is underlined with equal signs. +@xref{unnumberedsec appendixsec heading, , Section Commands}.@refill + +@item @@unnumberedsubsec @var{title} +In a printed manual, begin an unnumbered subsection within a +chapter. The title appears in the table of contents of a printed +manual. In Info, the title is underlined with hyphens. +@xref{unnumberedsubsec appendixsubsec subheading, , +@code{@@unnumberedsubsec} @code{@@appendixsubsec} +@code{@@subheading}}.@refill + +@item @@unnumberedsubsubsec @var{title} +In a printed manual, begin an unnumbered subsubsection within a +chapter. The title appears in the table of contents of a printed +manual. In Info, the title is underlined with periods. +@xref{subsubsection, , The `subsub' Commands}.@refill + +@item @@url@{@var{url}@} +Highlight text that is a uniform resource locator for the World Wide +Web. @xref{url, , @code{@@url}}.@refill + +@item @@v@var{c} +Generate check accent over the character @var{c}, as in @v{o}. +@xref{Inserting Accents}. + +@item @@value@{@var{flag}@} +Replace @var{flag} with the value to which it is set by @code{@@set +@var{flag}}. +@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill + +@item @@var@{@var{metasyntactic-variable}@} +Highlight a metasyntactic variable, which is something that stands for +another piece of text. @xref{var, , Indicating Metasyntactic +Variables}.@refill + +@need 400 +@item @@vindex @var{entry} +Add @var{entry} to the index of variables. @xref{Index Entries, , +Defining the Entries of an Index}.@refill + +@need 400 +@item @@vskip @var{amount} +In a printed manual, insert whitespace so as to push text on the +remainder of the page towards the bottom of the page. Used in +formatting the copyright page with the argument @samp{0pt plus +1filll}. (Note spelling of @samp{filll}.) @code{@@vskip} may be used +only in contexts ignored for Info. @xref{Copyright & Permissions, , +The Copyright Page and Printed Permissions}.@refill + +@need 400 +@item @@vtable @var{formatting-command} +Begin a two-column table, using @code{@@item} for each entry. +Automatically enter each of the items in the first column into the +index of variables. Pair with @code{@@end vtable}. The same as +@code{@@table}, except for indexing. @xref{ftable vtable, , +@code{@@ftable} and @code{@@vtable}}.@refill + +@need 400 +@item @@w@{@var{text}@} +Prevent @var{text} from being split across two lines. Do not end a +paragraph that uses @code{@@w} with an @code{@@refill} command. +@xref{w, , @code{@@w}}.@refill + +@need 400 +@item @@xref@{@var{node-name}, [@var{entry}], [@var{topic-or-title}], [@var{info-file}], [@var{manual}]@} +Make a reference that starts with `See' in a printed manual. Follow +command with a punctuation mark. Only the first argument is +mandatory. @xref{xref, , @code{@@xref}}.@refill +@end table + +@node Tips, Sample Texinfo File, Command List, Top +@comment node-name, next, previous, up +@appendix Tips and Hints + +Here are some tips for writing Texinfo documentation:@refill + +@cindex Tips +@cindex Usage tips +@cindex Hints +@itemize @bullet +@item +Write in the present tense, not in the past or the future. + +@item +Write actively! For example, write ``We recommend that @dots{}'' rather +than ``It is recommended that @dots{}''. + +@item +Use 70 or 72 as your fill column. Longer lines are hard to read. + +@item +Include a copyright notice and copying permissions. +@end itemize + +@subsubheading Index, index, index! + +Write many index entries, in different ways. +Readers like indices; they are helpful and convenient. + +Although it is easiest to write index entries as you write the body of +the text, some people prefer to write entries afterwards. In either +case, write an entry before the paragraph to which it applies. This +way, an index entry points to the first page of a paragraph that is +split across pages. + +Here are more hints we have found valuable: + +@itemize @bullet +@item +Write each index entry differently, so each entry refers to a different +place in the document. + +@item +Write index entries only where a topic is discussed significantly. For +example, it is not useful to index ``debugging information'' in a +chapter on reporting bugs. Someone who wants to know about debugging +information will certainly not find it in that chapter. + +@item +Consistently capitalize the first word of every concept index entry, +or else consistently use lower case. Terse entries often call for +lower case; longer entries for capitalization. Whichever case +convention you use, please use one or the other consistently! Mixing +the two styles looks bad. + +@item +Always capitalize or use upper case for those words in an index for +which this is proper, such as names of countries or acronyms. Always +use the appropriate case for case-sensitive names, such as those in C or +Lisp. + +@item +Write the indexing commands that refer to a whole section immediately +after the section command, and write the indexing commands that refer to +the paragraph before the paragraph. + +@need 1000 +In the example that follows, a blank line comes after the index +entry for ``Leaping'': + +@example +@group +@@section The Dog and the Fox +@@cindex Jumping, in general +@@cindex Leaping + +@@cindex Dog, lazy, jumped over +@@cindex Lazy dog jumped over +@@cindex Fox, jumps over dog +@@cindex Quick fox jumps over dog +The quick brown fox jumps over the lazy dog. +@end group +@end example + +@noindent +(Note that the example shows entries for the same concept that are +written in different ways---@samp{Lazy dog}, and @samp{Dog, lazy}---so +readers can look up the concept in different ways.) +@end itemize + +@subsubheading Blank lines + +@itemize @bullet +@item +Insert a blank line between a sectioning command and the first following +sentence or paragraph, or between the indexing commands associated with +the sectioning command and the first following sentence or paragraph, as +shown in the tip on indexing. Otherwise, a formatter may fold title and +paragraph together. + +@item +Always insert a blank line before an @code{@@table} command and after an +@code{@@end table} command; but never insert a blank line after an +@code{@@table} command or before an @code{@@end table} command. + +@need 1000 +For example, + +@example +@group +Types of fox: + +@@table @@samp +@@item Quick +Jump over lazy dogs. +@end group + +@group +@@item Brown +Also jump over lazy dogs. +@@end table + +@end group +@group +@@noindent +On the other hand, @dots{} +@end group +@end example + +Insert blank lines before and after @code{@@itemize} @dots{} @code{@@end +itemize} and @code{@@enumerate} @dots{} @code{@@end enumerate} in the +same way. +@end itemize + +@subsubheading Complete phrases + +Complete phrases are easier to read than @dots{} + +@itemize @bullet +@item +Write entries in an itemized list as complete sentences; or at least, as +complete phrases. Incomplete expressions @dots{} awkward @dots{} like +this. + +@item +Write the prefatory sentence or phrase for a multi-item list or table as +a complete expression. Do not write ``You can set:''; instead, write +``You can set these variables:''. The former expression sounds cut off. +@end itemize + +@subsubheading Editions, dates and versions + +Write the edition and version numbers and date in three places in every +manual: + +@enumerate +@item +In the first @code{@@ifinfo} section, for people reading the Texinfo file. + +@item +In the @code{@@titlepage} section, for people reading the printed manual. + +@item +In the `Top' node, for people reading the Info file. +@end enumerate + +@noindent +Also, it helps to write a note before the first @code{@@ifinfo} +section to explain what you are doing. + +@need 800 +@noindent +For example: + +@example +@group +@@c ===> NOTE! <== +@@c Specify the edition and version numbers and date +@@c in *three* places: +@@c 1. First ifinfo section 2. title page 3. top node +@@c To find the locations, search for !!set +@end group + +@group +@@ifinfo +@@c !!set edition, date, version +This is Edition 4.03, January 1992, +of the @@cite@{GDB Manual@} for GDB Version 4.3. +@dots{} +@end group +@end example + +@noindent +---or use @code{@@set} and @code{@@value} +(@pxref{value Example, , @code{@@value} Example}). + +@subsubheading Definition Commands + +Definition commands are @code{@@deffn}, @code{@@defun}, +@code{@@defmac}, and the like, and enable you to write descriptions in +a uniform format.@refill + +@itemize @bullet +@item +Write just one definition command for each entity you define with a +definition command. The automatic indexing feature creates an index +entry that leads the reader to the definition. + +@item +Use @code{@@table} @dots{} @code{@@end table} in an appendix that +contains a summary of functions, not @code{@@deffn} or other definition +commands. +@end itemize + +@subsubheading Capitalization + +@itemize @bullet +@item +Capitalize @samp{Texinfo}; it is a name. Do not write the @samp{x} or +@samp{i} in upper case. + +@item +Capitalize @samp{Info}; it is a name. + +@item +Write @TeX{} using the @code{@@TeX@{@}} command. Note the uppercase +@samp{T} and @samp{X}. This command causes the formatters to +typeset the name according to the wishes of Donald Knuth, who wrote +@TeX{}. +@end itemize + +@subsubheading Spaces + +Do not use spaces to format a Texinfo file, except inside of +@code{@@example} @dots{} @code{@@end example} and similar commands. + +@need 700 +For example, @TeX{} fills the following: + +@example +@group + @@kbd@{C-x v@} + @@kbd@{M-x vc-next-action@} + Perform the next logical operation + on the version-controlled file + corresponding to the current buffer. +@end group +@end example + +@need 950 +@noindent +so it looks like this: + +@iftex +@quotation + @kbd{C-x v} + @kbd{M-x vc-next-action} + Perform the next logical operation on the version-controlled file + corresponding to the current buffer. +@end quotation +@end iftex +@ifinfo +@quotation +`C-x v' `M-x vc-next-action' Perform the next logical operation on the +version-controlled file corresponding to the current buffer. +@end quotation +@end ifinfo + +@noindent +In this case, the text should be formatted with +@code{@@table}, @code{@@item}, and @code{@@itemx}, to create a table. + +@subsubheading @@code, @@samp, @@var, and @samp{---} + +@itemize @bullet +@item +Use @code{@@code} around Lisp symbols, including command names. +For example, + +@example +The main function is @@code@{vc-next-action@}, @dots{} +@end example + +@item +Avoid putting letters such as @samp{s} immediately after an +@samp{@@code}. Such letters look bad. + +@item +Use @code{@@var} around meta-variables. Do not write angle brackets +around them. + +@item +Use three hyphens in a row, @samp{---}, to indicate a long dash. @TeX{} +typesets these as a long dash and the Info formatters reduce three +hyphens to two. +@end itemize + +@subsubheading Periods Outside of Quotes + +Place periods and other punctuation marks @emph{outside} of quotations, +unless the punctuation is part of the quotation. This practice goes +against publishing conventions in the United States, but enables the +reader to distinguish between the contents of the quotation and the +whole passage. + +For example, you should write the following sentence with the period +outside the end quotation marks: + +@example +Evidently, @samp{au} is an abbreviation for ``author''. +@end example + +@noindent +since @samp{au} does @emph{not} serve as an abbreviation for +@samp{author.} (with a period following the word). + +@subsubheading Introducing New Terms + +@itemize @bullet +@item +Introduce new terms so that a reader who does not know them can +understand them from context; or write a definition for the term. + +For example, in the following, the terms ``check in'', ``register'' and +``delta'' are all appearing for the first time; the example sentence should be +rewritten so they are understandable. + +@quotation +The major function assists you in checking in a file to your +version control system and registering successive sets of changes to +it as deltas. +@end quotation + +@item +Use the @code{@@dfn} command around a word being introduced, to indicate +that the reader should not expect to know the meaning already, and +should expect to learn the meaning from this passage. +@end itemize + +@subsubheading @@pxref + +@c !!! maybe include this in the tips on pxref +@ignore +By the way, it is okay to use pxref with something else in front of +it within the parens, as long as the pxref is followed by the close +paren, and the material inside the parens is not part of a larger +sentence. Also, you can use xref inside parens as part of a complete +sentence so long as you terminate the cross reference with punctuation. +@end ignore +Absolutely never use @code{@@pxref} except in the special context for +which it is designed: inside parentheses, with the closing parenthesis +following immediately after the closing brace. One formatter +automatically inserts closing punctuation and the other does not. This +means that the output looks right both in printed output and in an Info +file, but only when the command is used inside parentheses. + +@subsubheading Invoking from a Shell + +You can invoke programs such as Emacs, GCC, and GAWK from a shell. +The documentation for each program should contain a section that +describes this. Unfortunately, if the node names and titles for these +sections are all different, readers find it hard to search for the +section.@refill + +Name such sections with a phrase beginning with the word +@w{`Invoking @dots{}'}, as in `Invoking Emacs'; this way +users can find the section easily. + +@subsubheading @sc{ansi c} Syntax + +When you use @code{@@example} to describe a C function's calling +conventions, use the @sc{ansi c} syntax, like this:@refill + +@example +void dld_init (char *@@var@{path@}); +@end example + +@noindent +And in the subsequent discussion, refer to the argument values by +writing the same argument names, again highlighted with +@code{@@var}.@refill + +@need 800 +Avoid the obsolete style that looks like this:@refill + +@example +#include + +dld_init (path) +char *path; +@end example + +Also, it is best to avoid writing @code{#include} above the +declaration just to indicate that the function is declared in a +header file. The practice may give the misimpression that the +@code{#include} belongs near the declaration of the function. Either +state explicitly which header file holds the declaration or, better +yet, name the header file used for a group of functions at the +beginning of the section that describes the functions.@refill + +@subsubheading Bad Examples + +Here are several examples of bad writing to avoid: + +In this example, say, `` @dots{} you must @code{@@dfn}@{check +in@} the new version.'' That flows better. + +@quotation +When you are done editing the file, you must perform a +@code{@@dfn}@{check in@}. +@end quotation + +In the following example, say, ``@dots{} makes a unified interface such as VC +mode possible.'' + +@quotation +SCCS, RCS and other version-control systems all perform similar +functions in broadly similar ways (it is this resemblance which makes +a unified control mode like this possible). +@end quotation + +And in this example, you should specify what `it' refers to: + +@quotation +If you are working with other people, it assists in coordinating +everyone's changes so they do not step on each other. +@end quotation + +@subsubheading And Finally @dots{} + +@itemize @bullet +@item +Pronounce @TeX{} as if the @samp{X} were a Greek `chi', as the last +sound in the name `Bach'. But pronounce Texinfo as in `speck': +@samp{teckinfo}. + +@item +Write notes for yourself at the very end of a Texinfo file after the +@code{@@bye}. None of the formatters process text after the +@code{@@bye}; it is as if the text were within @code{@@ignore} @dots{} +@code{@@end ignore}. +@end itemize + +@node Sample Texinfo File, Sample Permissions, Tips, Top +@comment node-name, next, previous, up +@appendix A Sample Texinfo File +@cindex Sample Texinfo file, no comments + +Here is a complete, short sample Texinfo file, without any commentary. +You can see this file, with comments, in the first chapter. +@xref{Short Sample, , A Short Sample Texinfo File}. + +@sp 1 +@example +\input texinfo @@c -*-texinfo-*- +@@c %**start of header +@@setfilename sample.info +@@settitle Sample Document +@@c %**end of header + +@@setchapternewpage odd + +@@ifinfo +This is a short example of a complete Texinfo file. + +Copyright 1990 Free Software Foundation, Inc. +@@end ifinfo + +@@titlepage +@@sp 10 +@@comment The title is printed in a large font. +@@center @@titlefont@{Sample Title@} + +@@c The following two commands start the copyright page. +@@page +@@vskip 0pt plus 1filll +Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. +@@end titlepage + +@@node Top, First Chapter, (dir), (dir) +@@comment node-name, next, previous, up + +@@menu +* First Chapter:: The first chapter is the + only chapter in this sample. +* Concept Index:: This index has two entries. +@@end menu + +@@node First Chapter, Concept Index, Top, Top +@@comment node-name, next, previous, up +@@chapter First Chapter +@@cindex Sample index entry + +This is the contents of the first chapter. +@@cindex Another sample index entry + +Here is a numbered list. + +@@enumerate +@@item +This is the first item. + +@@item +This is the second item. +@@end enumerate + +The @@code@{makeinfo@} and @@code@{texinfo-format-buffer@} +commands transform a Texinfo file such as this into +an Info file; and @@TeX@{@} typesets it for a printed +manual. + +@@node Concept Index, , First Chapter, Top +@@comment node-name, next, previous, up +@@unnumbered Concept Index + +@@printindex cp + +@@contents +@@bye +@end example + +@node Sample Permissions, Include Files, Sample Texinfo File, Top +@appendix Sample Permissions +@cindex Permissions +@cindex Copying permissions + +Texinfo files should contain sections that tell the readers that they +have the right to copy and distribute the Texinfo file, the Info file, +and the printed manual.@refill + +Also, if you are writing a manual about software, you should explain +that the software is free and either include the GNU General Public +License (GPL) or provide a reference to it. @xref{Distrib, , +Distribution, emacs, The GNU Emacs Manual}, for an example of the text +that could be used in the software ``Distribution'', ``General Public +License'', and ``NO WARRANTY'' sections of a document. @xref{Copying, +, Texinfo Copying Conditions}, for an example of a brief explanation +of how the copying conditions provide you with rights. @refill + +@menu +* Inserting Permissions:: How to put permissions in your document. +* ifinfo Permissions:: Sample @samp{ifinfo} copying permissions. +* Titlepage Permissions:: Sample Titlepage copying permissions. +@end menu + +@node Inserting Permissions, ifinfo Permissions, Sample Permissions, Sample Permissions +@ifinfo +@appendixsec Inserting Permissions +@end ifinfo + +In a Texinfo file, the first @code{@@ifinfo} section usually begins +with a line that says what the file documents. This is what a person +reading the unprocessed Texinfo file or using the advanced Info +command @kbd{g *} sees first. @inforef{Expert, Advanced Info +commands, info}, for more information. (A reader using the regular +Info commands usually starts reading at the first node and skips +this first section, which is not in a node.)@refill + +In the @code{@@ifinfo} section, the summary sentence is followed by a +copyright notice and then by the copying permission notice. One of +the copying permission paragraphs is enclosed in @code{@@ignore} and +@code{@@end ignore} commands. This paragraph states that the Texinfo +file can be processed through @TeX{} and printed, provided the printed +manual carries the proper copying permission notice. This paragraph +is not made part of the Info file since it is not relevant to the Info +file; but it is a mandatory part of the Texinfo file since it permits +people to process the Texinfo file in @TeX{} and print the +results.@refill + +In the printed manual, the Free Software Foundation copying permission +notice follows the copyright notice and publishing information and is +located within the region delineated by the @code{@@titlepage} and +@code{@@end titlepage} commands. The copying permission notice is exactly +the same as the notice in the @code{@@ifinfo} section except that the +paragraph enclosed in @code{@@ignore} and @code{@@end ignore} commands is +not part of the notice.@refill + +To make it simple to insert a permission notice into each section of +the Texinfo file, sample permission notices for each section are +reproduced in full below.@refill + +Note that you may need to specify the correct name of a section +mentioned in the permission notice. For example, in @cite{The GDB +Manual}, the name of the section referring to the General Public +License is called the ``GDB General Public License'', but in the +sample shown below, that section is referred to generically as the +``GNU General Public License''. If the Texinfo file does not carry a +copy of the General Public License, leave out the reference to it, but +be sure to include the rest of the sentence.@refill + +@node ifinfo Permissions, Titlepage Permissions, Inserting Permissions, Sample Permissions +@comment node-name, next, previous, up +@appendixsec @samp{ifinfo} Copying Permissions +@cindex @samp{ifinfo} permissions + +In the @code{@@ifinfo} section of a Texinfo file, the standard Free +Software Foundation permission notice reads as follows:@refill + +@example +This file documents @dots{} + +Copyright 1992 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim +copies of this manual provided the copyright notice and +this permission notice are preserved on all copies. + +@@ignore +Permission is granted to process this file through TeX +and print the results, provided the printed document +carries a copying permission notice identical to this +one except for the removal of this paragraph (this +paragraph not being relevant to the printed manual). + +@@end ignore +Permission is granted to copy and distribute modified +versions of this manual under the conditions for +verbatim copying, provided also that the sections +entitled ``Copying'' and ``GNU General Public License'' +are included exactly as in the original, and provided +that the entire resulting derived work is distributed +under the terms of a permission notice identical to this +one. + +Permission is granted to copy and distribute +translations of this manual into another language, +under the above conditions for modified versions, +except that this permission notice may be stated in a +translation approved by the Free Software Foundation. +@end example + +@node Titlepage Permissions, , ifinfo Permissions, Sample Permissions +@comment node-name, next, previous, up +@appendixsec Titlepage Copying Permissions +@cindex Titlepage permissions + +In the @code{@@titlepage} section of a Texinfo file, the standard Free +Software Foundation copying permission notice follows the copyright +notice and publishing information. The standard phrasing is as +follows:@refill + +@example +Permission is granted to make and distribute verbatim +copies of this manual provided the copyright notice and +this permission notice are preserved on all copies. + +Permission is granted to copy and distribute modified +versions of this manual under the conditions for +verbatim copying, provided also that the sections +entitled ``Copying'' and ``GNU General Public License'' +are included exactly as in the original, and provided +that the entire resulting derived work is distributed +under the terms of a permission notice identical to this +one. + +Permission is granted to copy and distribute +translations of this manual into another language, +under the above conditions for modified versions, +except that this permission notice may be stated in a +translation approved by the Free Software Foundation. +@end example + +@node Include Files, Headings, Sample Permissions, Top +@comment node-name, next, previous, up +@appendix Include Files +@cindex Include files + +When @TeX{} or an Info formatting command sees an @code{@@include} +command in a Texinfo file, it processes the contents of the file named +by the command and incorporates them into the @sc{dvi} or Info file being +created. Index entries from the included file are incorporated into +the indices of the output file.@refill + +Include files let you keep a single large document as a collection of +conveniently small parts.@refill + +@menu +* Using Include Files:: How to use the @code{@@include} command. +* texinfo-multiple-files-update:: How to create and update nodes and + menus when using included files. +* Include File Requirements:: What @code{texinfo-multiple-files-update} expects. +* Sample Include File:: A sample outer file with included files + within it; and a sample included file. +* Include Files Evolution:: How use of the @code{@@include} command + has changed over time. +@end menu + +@node Using Include Files, texinfo-multiple-files-update, Include Files, Include Files +@appendixsec How to Use Include Files +@findex include + +To include another file within a Texinfo file, write the +@code{@@include} command at the beginning of a line and follow it on +the same line by the name of a file to be included. For +example:@refill + +@example +@@include buffers.texi +@end example + +An included file should simply be a segment of text that you expect to +be included as is into the overall or @dfn{outer} Texinfo file; it +should not contain the standard beginning and end parts of a Texinfo +file. In particular, you should not start an included file with a +line saying @samp{\input texinfo}; if you do, that phrase is inserted +into the output file as is. Likewise, you should not end an included +file with an @code{@@bye} command; nothing after @code{@@bye} is +formatted.@refill + +In the past, you were required to write an @code{@@setfilename} line at the +beginning of an included file, but no longer. Now, it does not matter +whether you write such a line. If an @code{@@setfilename} line exists +in an included file, it is ignored.@refill + +Conventionally, an included file begins with an @code{@@node} line that +is followed by an @code{@@chapter} line. Each included file is one +chapter. This makes it easy to use the regular node and menu creating +and updating commands to create the node pointers and menus within the +included file. However, the simple Emacs node and menu creating and +updating commands do not work with multiple Texinfo files. Thus you +cannot use these commands to fill in the `Next', `Previous', and `Up' +pointers of the @code{@@node} line that begins the included file. Also, +you cannot use the regular commands to create a master menu for the +whole file. Either you must insert the menus and the `Next', +`Previous', and `Up' pointers by hand, or you must use the GNU Emacs +Texinfo mode command, @code{texinfo-multiple-files-update}, that is +designed for @code{@@include} files.@refill + +@node texinfo-multiple-files-update, Include File Requirements, Using Include Files, Include Files +@appendixsec @code{texinfo-multiple-files-update} +@findex texinfo-multiple-files-update + +GNU Emacs Texinfo mode provides the @code{texinfo-multiple-files-update} +command. This command creates or updates `Next', `Previous', and `Up' +pointers of included files as well as those in the outer or overall +Texinfo file, and it creates or updates a main menu in the outer file. +Depending whether you call it with optional arguments, the command +updates only the pointers in the first @code{@@node} line of the +included files or all of them:@refill + +@table @kbd +@item M-x texinfo-multiple-files-update +Called without any arguments:@refill + +@itemize @minus +@item +Create or update the `Next', `Previous', and `Up' pointers of the +first @code{@@node} line in each file included in an outer or overall +Texinfo file.@refill + +@item +Create or update the `Top' level node pointers of the outer or +overall file.@refill + +@item +Create or update a main menu in the outer file.@refill +@end itemize + +@item C-u M-x texinfo-multiple-files-update +Called with @kbd{C-u} as a prefix argument: + +@itemize @minus{} +@item +Create or update pointers in the first @code{@@node} line in each +included file. + +@item +Create or update the `Top' level node pointers of the outer file. + +@item +Create and insert a master menu in the outer file. The master menu +is made from all the menus in all the included files.@refill +@end itemize + +@item C-u 8 M-x texinfo-multiple-files-update +Called with a numeric prefix argument, such as @kbd{C-u 8}: + +@itemize @minus +@item +Create or update @strong{all} the `Next', `Previous', and `Up' pointers +of all the included files.@refill + +@item +Create or update @strong{all} the menus of all the included +files.@refill + +@item +Create or update the `Top' level node pointers of the outer or +overall file.@refill + +@item +And then create a master menu in the outer file. This is similar to +invoking @code{texinfo-master-menu} with an argument when you are +working with just one file.@refill +@end itemize +@end table + +Note the use of the prefix argument in interactive use: with a regular +prefix argument, just @w{@kbd{C-u}}, the +@code{texinfo-multiple-files-update} command inserts a master menu; +with a numeric prefix argument, such as @kbd{C-u 8}, the command +updates @strong{every} pointer and menu in @strong{all} the files and then inserts a +master menu.@refill + +@node Include File Requirements, Sample Include File, texinfo-multiple-files-update, Include Files +@appendixsec Include File Requirements +@cindex Include file requirements +@cindex Requirements for include files + +If you plan to use the @code{texinfo-multiple-files-update} command, +the outer Texinfo file that lists included files within it should +contain nothing but the beginning and end parts of a Texinfo file, and +a number of @code{@@include} commands listing the included files. It +should not even include indices, which should be listed in an included +file of their own.@refill + +Moreover, each of the included files must contain exactly one highest +level node (conventionally, @code{@@chapter} or equivalent), +and this node must be the first node in the included file. +Furthermore, each of these highest level nodes in each included file +must be at the same hierarchical level in the file structure. +Usually, each is an @code{@@chapter}, an @code{@@appendix}, or an +@code{@@unnumbered} node. Thus, normally, each included file contains +one, and only one, chapter or equivalent-level node.@refill + +The outer file should contain only @emph{one} node, the `Top' node. It +should @emph{not} contain any nodes besides the single `Top' node. The +@code{texinfo-multiple-files-update} command will not process +them.@refill + +@node Sample Include File, Include Files Evolution, Include File Requirements, Include Files +@appendixsec Sample File with @code{@@include} +@cindex Sample @code{@@include} file +@cindex Include file sample +@cindex @code{@@include} file sample + +Here is an example of a complete outer Texinfo file with @code{@@include} files +within it before running @code{texinfo-multiple-files-update}, which +would insert a main or master menu:@refill + +@example +@group +\input texinfo @@c -*-texinfo-*- +@c %**start of header +@@setfilename include-example.info +@@settitle Include Example +@c %**end of header +@end group + +@group +@@setchapternewpage odd +@@titlepage +@@sp 12 +@@center @@titlefont@{Include Example@} +@@sp 2 +@@center by Whom Ever +@end group + +@group +@@page +@@vskip 0pt plus 1filll +Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. +@@end titlepage +@end group + +@group +@@ifinfo +@@node Top, First, (dir), (dir) +@@top Master Menu +@@end ifinfo +@end group + +@group +@@include foo.texinfo +@@include bar.texinfo +@@include concept-index.texinfo +@end group + +@group +@@summarycontents +@@contents + +@@bye +@end group +@end example + +An included file, such as @file{foo.texinfo}, might look like +this:@refill + +@example +@group +@@node First, Second, , Top +@@chapter First Chapter + +Contents of first chapter @dots{} +@end group +@end example + +The full contents of @file{concept-index.texinfo} might be as simple as this: + +@example +@group +@@node Concept Index, , Second, Top +@@unnumbered Concept Index + +@@printindex cp +@end group +@end example + +The outer Texinfo source file for @cite{The GNU Emacs Lisp Reference +Manual} is named @file{elisp.texi}. This outer file contains a master +menu with 417 entries and a list of 41 @code{@@include} +files.@refill + +@node Include Files Evolution, , Sample Include File, Include Files +@comment node-name, next, previous, up +@appendixsec Evolution of Include Files + +When Info was first created, it was customary to create many small +Info files on one subject. Each Info file was formatted from its own +Texinfo source file. This custom meant that Emacs did not need to +make a large buffer to hold the whole of a large Info file when +someone wanted information; instead, Emacs allocated just enough +memory for the small Info file that contained the particular +information sought. This way, Emacs could avoid wasting memory.@refill + +References from one file to another were made by referring to the file +name as well as the node name. (@xref{Other Info Files, , Referring to +Other Info Files}. Also, see @ref{Four and Five Arguments, , +@code{@@xref} with Four and Five Arguments}.)@refill + +Include files were designed primarily as a way to create a single, +large printed manual out of several smaller Info files. In a printed +manual, all the references were within the same document, so @TeX{} +could automatically determine the references' page numbers. The Info +formatting commands used include files only for creating joint +indices; each of the individual Texinfo files had to be formatted for +Info individually. (Each, therefore, required its own +@code{@@setfilename} line.)@refill + +However, because large Info files are now split automatically, it is +no longer necessary to keep them small.@refill + +Nowadays, multiple Texinfo files are used mostly for large documents, +such as @cite{The GNU Emacs Lisp Reference Manual}, and for projects +in which several different people write different sections of a +document simultaneously.@refill + +In addition, the Info formatting commands have been extended to work +with the @code{@@include} command so as to create a single large Info +file that is split into smaller files if necessary. This means that +you can write menus and cross references without naming the different +Texinfo files.@refill + +@node Headings, Catching Mistakes, Include Files, Top +@comment node-name, next, previous, up +@appendix Page Headings +@cindex Headings +@cindex Footings +@cindex Page numbering +@cindex Page headings +@cindex Formatting headings and footings + +Most printed manuals contain headings along the top of every page +except the title and copyright pages. Some manuals also contain +footings. (Headings and footings have no meaning to Info, which is +not paginated.)@refill + +@menu +* Headings Introduced:: Conventions for using page headings. +* Heading Format:: Standard page heading formats. +* Heading Choice:: How to specify the type of page heading. +* Custom Headings:: How to create your own headings and footings. +@end menu + +@node Headings Introduced, Heading Format, Headings, Headings +@ifinfo +@heading Headings Introduced +@end ifinfo + +Texinfo provides standard page heading formats for manuals that are printed +on one side of each sheet of paper and for manuals that are printed on +both sides of the paper. Usually, you will use one or other of these +formats, but you can specify your own format, if you wish.@refill + +In addition, you can specify whether chapters should begin on a new +page, or merely continue the same page as the previous chapter; and if +chapters begin on new pages, you can specify whether they must be +odd-numbered pages.@refill + +By convention, a book is printed on both sides of each sheet of paper. +When you open a book, the right-hand page is odd-numbered, and +chapters begin on right-hand pages---a preceding left-hand page is +left blank if necessary. Reports, however, are often printed on just +one side of paper, and chapters begin on a fresh page immediately +following the end of the preceding chapter. In short or informal +reports, chapters often do not begin on a new page at all, but are +separated from the preceding text by a small amount of whitespace.@refill + +The @code{@@setchapternewpage} command controls whether chapters begin +on new pages, and whether one of the standard heading formats is used. +In addition, Texinfo has several heading and footing commands that you +can use to generate your own heading and footing formats.@refill + +In Texinfo, headings and footings are single lines at the tops and +bottoms of pages; you cannot create multiline headings or footings. +Each header or footer line is divided into three parts: a left part, a +middle part, and a right part. Any part, or a whole line, may be left +blank. Text for the left part of a header or footer line is set +flushleft; text for the middle part is centered; and, text for the +right part is set flushright.@refill + +@node Heading Format, Heading Choice, Headings Introduced, Headings +@comment node-name, next, previous, up +@appendixsec Standard Heading Formats + +Texinfo provides two standard heading formats, one for manuals printed +on one side of each sheet of paper, and the other for manuals printed +on both sides of the paper. + +By default, nothing is specified for the footing of a Texinfo file, +so the footing remains blank.@refill + +The standard format for single-sided printing consists of a header +line in which the left-hand part contains the name of the chapter, the +central part is blank, and the right-hand part contains the page +number.@refill + +@need 950 +A single-sided page looks like this: + +@example +@group + _______________________ + | | + | chapter page number | + | | + | Start of text ... | + | ... | + | | + +@end group +@end example + +The standard format for two-sided printing depends on whether the page +number is even or odd. By convention, even-numbered pages are on the +left- and odd-numbered pages are on the right. (@TeX{} will adjust the +widths of the left- and right-hand margins. Usually, widths are +correct, but during double-sided printing, it is wise to check that +pages will bind properly---sometimes a printer will produce output in +which the even-numbered pages have a larger right-hand margin than the +odd-numbered pages.)@refill + +In the standard double-sided format, the left part of the left-hand +(even-numbered) page contains the page number, the central part is +blank, and the right part contains the title (specified by the +@code{@@settitle} command). The left part of the right-hand +(odd-numbered) page contains the name of the chapter, the central part +is blank, and the right part contains the page number.@refill + +@need 750 +Two pages, side by side as in an open book, look like this:@refill + +@example +@group + _______________________ _______________________ + | | | | + | page number title | | chapter page number | + | | | | + | Start of text ... | | More text ... | + | ... | | ... | + | | | | + +@end group +@end example + +@noindent +The chapter name is preceded by the word @samp{Chapter}, the chapter +number and a colon. This makes it easier to keep track of where you +are in the manual.@refill + +@node Heading Choice, Custom Headings, Heading Format, Headings +@comment node-name, next, previous, up +@appendixsec Specifying the Type of Heading + +@TeX{} does not begin to generate page headings for a standard Texinfo +file until it reaches the @code{@@end titlepage} command. Thus, the +title and copyright pages are not numbered. The @code{@@end +titlepage} command causes @TeX{} to begin to generate page headings +according to a standard format specified by the +@code{@@setchapternewpage} command that precedes the +@code{@@titlepage} section.@refill + +@need 1000 +There are four possibilities:@refill + +@table @asis +@item No @code{@@setchapternewpage} command +Cause @TeX{} to specify the single-sided heading format, with chapters +on new pages. This is the same as @code{@@setchapternewpage on}.@refill + +@item @code{@@setchapternewpage on} +Specify the single-sided heading format, with chapters on new pages.@refill + +@item @code{@@setchapternewpage off} +Cause @TeX{} to start a new chapter on the same page as the last page of +the preceding chapter, after skipping some vertical whitespace. Also +cause @TeX{} to typeset for single-sided printing. (You can override +the headers format with the @code{@@headings double} command; see +@ref{headings on off, , The @code{@@headings} Command}.)@refill + +@item @code{@@setchapternewpage odd} +Specify the double-sided heading format, with chapters on new pages.@refill +@end table + +@noindent +Texinfo lacks an @code{@@setchapternewpage even} command.@refill + +@node Custom Headings, , Heading Choice, Headings +@comment node-name, next, previous, up +@appendixsec How to Make Your Own Headings + +You can use the standard headings provided with Texinfo or specify +your own.@refill + +@c Following paragraph is verbose to prevent overfull hboxes. +Texinfo provides six commands for specifying headings and +footings. The @code{@@everyheading} command and +@code{@@everyfooting} command generate page headers and footers +that are the same for both even- and odd-numbered pages. +The @code{@@evenheading} command and @code{@@evenfooting} +command generate headers and footers for even-numbered +(left-hand) pages; and the @code{@@oddheading} command and +@code{@@oddfooting} command generate headers and footers for +odd-numbered (right-hand) pages.@refill + +Write custom heading specifications in the Texinfo file immediately +after the @code{@@end titlepage} command. Enclose your specifications +between @code{@@iftex} and @code{@@end iftex} commands since the +@code{texinfo-format-buffer} command may not recognize them. Also, +you must cancel the predefined heading commands with the +@code{@@headings off} command before defining your own +specifications.@refill + +@need 1000 +Here is how to tell @TeX{} to place the chapter name at the left, the +page number in the center, and the date at the right of every header +for both even- and odd-numbered pages:@refill + +@example +@group +@@iftex +@@headings off +@@everyheading @@thischapter @@| @@thispage @@| @@today@{@} +@@end iftex +@end group +@end example + +@noindent +You need to divide the left part from the central part and the central +part from the right had part by inserting @samp{@@|} between parts. +Otherwise, the specification command will not be able to tell where +the text for one part ends and the next part begins.@refill + +Each part can contain text or @@-commands. The text +is printed as if the part were within an ordinary paragraph in the +body of the page. The @@-commands replace +themselves with the page number, date, chapter name, or +whatever.@refill + +@need 950 +Here are the six heading and footing commands:@refill + +@findex everyheading +@findex everyfooting +@table @code +@item @@everyheading @var{left} @@| @var{center} @@| @var{right} +@itemx @@everyfooting @var{left} @@| @var{center} @@| @var{right} + +The `every' commands specify the format for both even- and odd-numbered +pages. These commands are for documents that are printed on one side +of each sheet of paper, or for documents in which you want symmetrical +headers or footers.@refill + +@findex evenheading +@findex evenfooting +@findex oddheading +@findex oddfooting +@item @@evenheading @var{left} @@| @var{center} @@| @var{right} +@itemx @@oddheading @var{left} @@| @var{center} @@| @var{right} + +@itemx @@evenfooting @var{left} @@| @var{center} @@| @var{right} +@itemx @@oddfooting @var{left} @@| @var{center} @@| @var{right} + +The `even' and `odd' commands specify the format for even-numbered +pages and odd-numbered pages. These commands are for books and +manuals that are printed on both sides of each sheet of paper.@refill +@end table + +Use the @samp{@@this@dots{}} series of @@-commands to +provide the names of chapters +and sections and the page number. You can use the +@samp{@@this@dots{}} commands in the left, center, or right portions +of headers and footers, or anywhere else in a Texinfo file so long as +they are between @code{@@iftex} and @code{@@end iftex} commands.@refill + +@need 1000 +Here are the @samp{@@this@dots{}} commands:@refill + +@table @code +@findex thispage +@item @@thispage +Expands to the current page number.@refill +@c !!! Karl Berry says that `thissection' fails on page breaks. +@ignore +@item @@thissection +Expands to the name of the current section.@refill +@end ignore + +@findex thischaptername +@item @@thischaptername +Expands to the name of the current chapter.@refill + +@findex thischapter +@item @@thischapter +Expands to the number and name of the current +chapter, in the format `Chapter 1: Title'.@refill + +@findex thistitle +@item @@thistitle +Expands to the name of the document, as specified by the +@code{@@settitle} command.@refill + +@findex thisfile +@item @@thisfile +For @code{@@include} files only: expands to the name of the current +@code{@@include} file. If the current Texinfo source file is not an +@code{@@include} file, this command has no effect. This command does +@emph{not} provide the name of the current Texinfo source file unless +it is an @code{@@include} file. (@xref{Include Files}, for more +information about @code{@@include} files.)@refill +@end table + +@noindent +You can also use the @code{@@today@{@}} command, which expands to the +current date, in `1 Jan 1900' format.@refill +@findex today + +Other @@-commands and text are printed in a header or footer just as +if they were in the body of a page. It is useful to incorporate text, +particularly when you are writing drafts:@refill + +@example +@group +@@iftex +@@headings off +@@everyheading @@emph@{Draft!@} @@| @@thispage @@| @@thischapter +@@everyfooting @@| @@| Version: 0.27: @@today@{@} +@@end iftex +@end group +@end example + +Beware of overlong titles: they may overlap another part of the +header or footer and blot it out.@refill + +@node Catching Mistakes, Refilling Paragraphs, Headings, Top +@comment node-name, next, previous, up +@appendix Formatting Mistakes +@cindex Structure, catching mistakes in +@cindex Nodes, catching mistakes +@cindex Catching mistakes +@cindex Correcting mistakes +@cindex Mistakes, catching +@cindex Problems, catching +@cindex Debugging the Texinfo structure + +Besides mistakes in the content of your documentation, there +are two kinds of mistake you can make with Texinfo: you can make mistakes +with @@-commands, and you can make mistakes with the structure of the +nodes and chapters.@refill + +Emacs has two tools for catching the @@-command mistakes and two for +catching structuring mistakes.@refill + +For finding problems with @@-commands, you can run @TeX{} or a region +formatting command on the region that has a problem; indeed, you can +run these commands on each region as you write it.@refill + +For finding problems with the structure of nodes and chapters, you can use +@kbd{C-c C-s} (@code{texinfo-show-structure}) and the related @code{occur} +command and you can use the @kbd{M-x Info-validate} command.@refill + +@menu +* makeinfo preferred:: @code{makeinfo} finds errors. +* Debugging with Info:: How to catch errors with Info formatting. +* Debugging with TeX:: How to catch errors with @TeX{} formatting. +* Using texinfo-show-structure:: How to use @code{texinfo-show-structure}. +* Using occur:: How to list all lines containing a pattern. +* Running Info-Validate:: How to find badly referenced nodes. +@end menu + +@node makeinfo preferred, Debugging with Info, Catching Mistakes, Catching Mistakes +@ifinfo +@heading @code{makeinfo} Find Errors +@end ifinfo + +The @code{makeinfo} program does an excellent job of catching errors +and reporting them---far better than @code{texinfo-format-region} or +@code{texinfo-format-buffer}. In addition, the various functions for +automatically creating and updating node pointers and menus remove +many opportunities for human error.@refill + +If you can, use the updating commands to create and insert pointers +and menus. These prevent many errors. Then use @code{makeinfo} (or +its Texinfo mode manifestations, @code{makeinfo-region} and +@code{makeinfo-buffer}) to format your file and check for other +errors. This is the best way to work with Texinfo. But if you +cannot use @code{makeinfo}, or your problem is very puzzling, then you +may want to use the tools described in this appendix.@refill + +@node Debugging with Info, Debugging with TeX, makeinfo preferred, Catching Mistakes +@comment node-name, next, previous, up +@appendixsec Catching Errors with Info Formatting +@cindex Catching errors with Info formatting +@cindex Debugging with Info formatting + +After you have written part of a Texinfo file, you can use the +@code{texinfo-format-region} or the @code{makeinfo-region} command to +see whether the region formats properly.@refill + +Most likely, however, you are reading this section because for some +reason you cannot use the @code{makeinfo-region} command; therefore, the +rest of this section presumes that you are using +@code{texinfo-format-region}.@refill + +If you have made a mistake with an @@-command, +@code{texinfo-format-region} will stop processing at or after the +error and display an error message. To see where in the buffer the +error occurred, switch to the @samp{*Info Region*} buffer; the cursor +will be in a position that is after the location of the error. Also, +the text will not be formatted after the place where the error +occurred (or more precisely, where it was detected).@refill + +For example, if you accidentally end a menu with the command @code{@@end +menus} with an `s' on the end, instead of with @code{@@end menu}, you +will see an error message that says:@refill + +@example +@@end menus is not handled by texinfo +@end example + +@noindent +The cursor will stop at the point in the buffer where the error +occurs, or not long after it. The buffer will look like this:@refill + +@example +@group +---------- Buffer: *Info Region* ---------- +* Menu: + +* Using texinfo-show-structure:: How to use + `texinfo-show-structure' + to catch mistakes. +* Running Info-Validate:: How to check for + unreferenced nodes. +@@end menus +@point{} +---------- Buffer: *Info Region* ---------- +@end group +@end example + +The @code{texinfo-format-region} command sometimes provides slightly +odd error messages. For example, the following cross reference fails to format:@refill + +@example +(@@xref@{Catching Mistakes, for more info.) +@end example + +@noindent +In this case, @code{texinfo-format-region} detects the missing closing +brace but displays a message that says @samp{Unbalanced parentheses} +rather than @samp{Unbalanced braces}. This is because the formatting +command looks for mismatches between braces as if they were +parentheses.@refill + +Sometimes @code{texinfo-format-region} fails to detect mistakes. For +example, in the following, the closing brace is swapped with the +closing parenthesis:@refill + +@example +(@@xref@{Catching Mistakes), for more info.@} +@end example + +@noindent +Formatting produces: +@example +(*Note for more info.: Catching Mistakes) +@end example + +The only way for you to detect this error is to realize that the +reference should have looked like this:@refill + +@example +(*Note Catching Mistakes::, for more info.) +@end example + +Incidentally, if you are reading this node in Info and type @kbd{f +@key{RET}} (@code{Info-follow-reference}), you will generate an error +message that says: + +@example +No such node: "Catching Mistakes) The only way @dots{} +@end example + +@noindent +This is because Info perceives the example of the error as the first +cross reference in this node and if you type a @key{RET} immediately +after typing the Info @kbd{f} command, Info will attempt to go to the +referenced node. If you type @kbd{f catch @key{TAB} @key{RET}}, Info +will complete the node name of the correctly written example and take +you to the `Catching Mistakes' node. (If you try this, you can return +from the `Catching Mistakes' node by typing @kbd{l} +(@code{Info-last}).) + +@c !!! section on using Elisp debugger ignored. +@ignore +Sometimes @code{texinfo-format-region} will stop long after the +original error; this is because it does not discover the problem until +then. In this case, you will need to backtrack.@refill + +@c menu +@c * Using the Emacs Lisp Debugger:: How to use the Emacs Lisp debugger. +@c end menu + +@c node Using the Emacs Lisp Debugger +@c appendixsubsec Using the Emacs Lisp Debugger +@c index Using the Emacs Lisp debugger +@c index Emacs Lisp debugger +@c index Debugger, using the Emacs Lisp + +If an error is especially elusive, you can turn on the Emacs Lisp +debugger and look at the backtrace; this tells you where in the +@code{texinfo-format-region} function the problem occurred. You can +turn on the debugger with the command:@refill + +@example +M-x set-variable @key{RET} debug-on-error @key{RET} t @key{RET} +@end example + +@noindent +and turn it off with + +@example +M-x set-variable @key{RET} debug-on-error @key{RET} nil @key{RET} +@end example + +Often, when you are using the debugger, it is easier to follow what is +going on if you use the Emacs Lisp files that are not byte-compiled. +The byte-compiled sources send octal numbers to the debugger that may +look mysterious. To use the uncompiled source files, load +@file{texinfmt.el} and @file{texinfo.el} with the @kbd{M-x load-file} +command.@refill + +The debugger will not catch an error if @code{texinfo-format-region} +does not detect one. In the example shown above, +@code{texinfo-format-region} did not find the error when the whole +list was formatted, but only when part of the list was formatted. +When @code{texinfo-format-region} did not find an error, the debugger +did not find one either. @refill + +However, when @code{texinfo-format-region} did report an error, it +invoked the debugger. This is the backtrace it produced:@refill + +@example +---------- Buffer: *Backtrace* ---------- +Signalling: (search-failed "[@},]") + re-search-forward("[@},]") + (while ...) + (let ...) + texinfo-format-parse-args() + (let ...) + texinfo-format-xref() + funcall(texinfo-format-xref) + (if ...) + (let ...) + (if ...) + (while ...) + texinfo-format-scan() + (save-excursion ...) + (let ...) + texinfo-format-region(103370 103631) +* call-interactively(texinfo-format-region) +---------- Buffer: *Backtrace* ---------- +@end example + +The backtrace is read from the bottom up. +@code{texinfo-format-region} was called interactively; and it, in +turn, called various functions, including @code{texinfo-format-scan}, +@code{texinfo-format-xref} and @code{texinfo-format-parse-args}. +Inside the function @code{texinfo-format-parse-args}, the function +@code{re-search-forward} was called; it was this function that could +not find the missing right-hand brace.@refill + +@xref{Lisp Debug, , Debugging Emacs Lisp, emacs, The GNU Emacs +Manual}, for more information.@refill +@end ignore + +@node Debugging with TeX, Using texinfo-show-structure, Debugging with Info, Catching Mistakes +@comment node-name, next, previous, up +@appendixsec Catching Errors with @TeX{} Formatting +@cindex Catching errors with @TeX{} formatting +@cindex Debugging with @TeX{} formatting + +You can also catch mistakes when you format a file with @TeX{}.@refill + +Usually, you will want to do this after you have run +@code{texinfo-format-buffer} (or, better, @code{makeinfo-buffer}) on +the same file, because @code{texinfo-format-buffer} sometimes displays +error messages that make more sense than @TeX{}. (@xref{Debugging +with Info}, for more information.)@refill + +For example, @TeX{} was run on a Texinfo file, part of which is shown +here:@refill + +@example +---------- Buffer: texinfo.texi ---------- +name of the Texinfo file as an extension. The +@@samp@{??@} are `wildcards' that cause the shell to +substitute all the raw index files. (@@xref@{sorting +indices, for more information about sorting +indices.)@@refill +---------- Buffer: texinfo.texi ---------- +@end example + +@noindent +(The cross reference lacks a closing brace.) +@TeX{} produced the following output, after which it stopped:@refill + +@example +---------- Buffer: *tex-shell* ---------- +Runaway argument? +@{sorting indices, for more information about sorting +indices.) @@refill @@ETC. +! Paragraph ended before @@xref was complete. + + @@par +l.27 + +? +---------- Buffer: *tex-shell* ---------- +@end example + +In this case, @TeX{} produced an accurate and +understandable error message: + +@example +Paragraph ended before @@xref was complete. +@end example + +@noindent +@samp{@@par} is an internal @TeX{} command of no relevance to Texinfo. +@samp{l.27} means that @TeX{} detected the problem on line 27 of the +Texinfo file. The @samp{?} is the prompt @TeX{} uses in this +circumstance.@refill + +Unfortunately, @TeX{} is not always so helpful, and sometimes you must +truly be a Sherlock Holmes to discover what went wrong.@refill + +In any case, if you run into a problem like this, you can do one of three +things.@refill + +@enumerate +@item +You can tell @TeX{} to continue running and ignore just this error by +typing @key{RET} at the @samp{?} prompt.@refill + +@item +You can tell @TeX{} to continue running and to ignore all errors as best +it can by typing @kbd{r @key{RET}} at the @samp{?} prompt.@refill + +This is often the best thing to do. However, beware: the one error +may produce a cascade of additional error messages as its consequences +are felt through the rest of the file. (To stop @TeX{} when it is +producing such an avalanche of error messages, type @kbd{C-d} (or +@kbd{C-c C-d}, if you are running a shell inside Emacs.))@refill + +@item +You can tell @TeX{} to stop this run by typing @kbd{x @key{RET}} +at the @samp{?} prompt.@refill +@end enumerate + +Please note that if you are running @TeX{} inside Emacs, you need to +switch to the shell buffer and line at which @TeX{} offers the @samp{?} +prompt.@refill + +Sometimes @TeX{} will format a file without producing error messages even +though there is a problem. This usually occurs if a command is not ended +but @TeX{} is able to continue processing anyhow. For example, if you fail +to end an itemized list with the @code{@@end itemize} command, @TeX{} will +write a @sc{dvi} file that you can print out. The only error message that +@TeX{} will give you is the somewhat mysterious comment that@refill + +@example +(@@end occurred inside a group at level 1) +@end example + +@noindent +However, if you print the @sc{dvi} file, you will find that the text +of the file that follows the itemized list is entirely indented as if +it were part of the last item in the itemized list. The error message +is the way @TeX{} says that it expected to find an @code{@@end} +command somewhere in the file; but that it could not determine where +it was needed.@refill + +Another source of notoriously hard-to-find errors is a missing +@code{@@end group} command. If you ever are stumped by +incomprehensible errors, look for a missing @code{@@end group} command +first.@refill + +If the Texinfo file lacks header lines, +@TeX{} may stop in the +beginning of its run and display output that looks like the following. +The @samp{*} indicates that @TeX{} is waiting for input.@refill + +@example +This is TeX, Version 3.14159 (Web2c 7.0) +(test.texinfo [1]) +* +@end example + +@noindent +In this case, simply type @kbd{\end @key{RET}} after the asterisk. Then +write the header lines in the Texinfo file and run the @TeX{} command +again. (Note the use of the backslash, @samp{\}. @TeX{} uses @samp{\} +instead of @samp{@@}; and in this circumstance, you are working +directly with @TeX{}, not with Texinfo.)@refill + +@node Using texinfo-show-structure, Using occur, Debugging with TeX, Catching Mistakes +@comment node-name, next, previous, up +@appendixsec Using @code{texinfo-show-structure} +@cindex Showing the structure of a file +@findex texinfo-show-structure + +It is not always easy to keep track of the nodes, chapters, sections, and +subsections of a Texinfo file. This is especially true if you are revising +or adding to a Texinfo file that someone else has written.@refill + +In GNU Emacs, in Texinfo mode, the @code{texinfo-show-structure} +command lists all the lines that begin with the @@-commands that +specify the structure: @code{@@chapter}, @code{@@section}, +@code{@@appendix}, and so on. With an argument (@w{@kbd{C-u}} +as prefix argument, if interactive), +the command also shows the @code{@@node} lines. The +@code{texinfo-show-structure} command is bound to @kbd{C-c C-s} in +Texinfo mode, by default.@refill + +The lines are displayed in a buffer called the @samp{*Occur*} buffer, +indented by hierarchical level. For example, here is a part of what was +produced by running @code{texinfo-show-structure} on this manual:@refill + +@example +@group + Lines matching "^@@\\(chapter \\|sect\\|subs\\|subh\\| + unnum\\|major\\|chapheading \\|heading \\|appendix\\)" + in buffer texinfo.texi. + @dots{} + 4177:@@chapter Nodes + 4198: @@heading Two Paths + 4231: @@section Node and Menu Illustration + 4337: @@section The @@code@{@@@@node@} Command + 4393: @@subheading Choosing Node and Pointer Names + 4417: @@subsection How to Write an @@code@{@@@@node@} Line + 4469: @@subsection @@code@{@@@@node@} Line Tips + @dots{} +@end group +@end example + +This says that lines 4337, 4393, and 4417 of @file{texinfo.texi} begin +with the @code{@@section}, @code{@@subheading}, and @code{@@subsection} +commands respectively. If you move your cursor into the @samp{*Occur*} +window, you can position the cursor over one of the lines and use the +@kbd{C-c C-c} command (@code{occur-mode-goto-occurrence}), to jump to +the corresponding spot in the Texinfo file. @xref{Other Repeating +Search, , Using Occur, emacs, The GNU Emacs Manual}, for more +information about @code{occur-mode-goto-occurrence}.@refill + +The first line in the @samp{*Occur*} window describes the @dfn{regular +expression} specified by @var{texinfo-heading-pattern}. This regular +expression is the pattern that @code{texinfo-show-structure} looks for. +@xref{Regexps, , Using Regular Expressions, emacs, The GNU Emacs Manual}, +for more information.@refill + +When you invoke the @code{texinfo-show-structure} command, Emacs will +display the structure of the whole buffer. If you want to see the +structure of just a part of the buffer, of one chapter, for example, +use the @kbd{C-x n n} (@code{narrow-to-region}) command to mark the +region. (@xref{Narrowing, , , emacs, The GNU Emacs Manual}.) This is +how the example used above was generated. (To see the whole buffer +again, use @kbd{C-x n w} (@code{widen}).)@refill + +If you call @code{texinfo-show-structure} with a prefix argument by +typing @w{@kbd{C-u C-c C-s}}, it will list lines beginning with +@code{@@node} as well as the lines beginning with the @@-sign commands +for @code{@@chapter}, @code{@@section}, and the like.@refill + +You can remind yourself of the structure of a Texinfo file by looking at +the list in the @samp{*Occur*} window; and if you have mis-named a node +or left out a section, you can correct the mistake.@refill + +@node Using occur, Running Info-Validate, Using texinfo-show-structure, Catching Mistakes +@comment node-name, next, previous, up +@appendixsec Using @code{occur} +@cindex Occurrences, listing with @code{@@occur} +@findex occur + +Sometimes the @code{texinfo-show-structure} command produces too much +information. Perhaps you want to remind yourself of the overall structure +of a Texinfo file, and are overwhelmed by the detailed list produced by +@code{texinfo-show-structure}. In this case, you can use the @code{occur} +command directly. To do this, type@refill + +@example +@kbd{M-x occur} +@end example + +@noindent +and then, when prompted, type a @dfn{regexp}, a regular expression for +the pattern you want to match. (@xref{Regexps, , Regular Expressions, +emacs, The GNU Emacs Manual}.) The @code{occur} command works from +the current location of the cursor in the buffer to the end of the +buffer. If you want to run @code{occur} on the whole buffer, place +the cursor at the beginning of the buffer.@refill + +For example, to see all the lines that contain the word +@samp{@@chapter} in them, just type @samp{@@chapter}. This will +produce a list of the chapters. It will also list all the sentences +with @samp{@@chapter} in the middle of the line.@refill + +If you want to see only those lines that start with the word +@samp{@@chapter}, type @samp{^@@chapter} when prompted by +@code{occur}. If you want to see all the lines that end with a word +or phrase, end the last word with a @samp{$}; for example, +@samp{catching mistakes$}. This can be helpful when you want to see +all the nodes that are part of the same chapter or section and +therefore have the same `Up' pointer.@refill + +@xref{Other Repeating Search, , Using Occur, emacs , The GNU Emacs Manual}, +for more information.@refill + +@node Running Info-Validate, , Using occur, Catching Mistakes +@comment node-name, next, previous, up +@appendixsec Finding Badly Referenced Nodes +@findex Info-validate +@cindex Nodes, checking for badly referenced +@cindex Checking for badly referenced nodes +@cindex Looking for badly referenced nodes +@cindex Finding badly referenced nodes +@cindex Badly referenced nodes + +You can use the @code{Info-validate} command to check whether any of +the `Next', `Previous', `Up' or other node pointers fail to point to a +node. This command checks that every node pointer points to an +existing node. The @code{Info-validate} command works only on Info +files, not on Texinfo files.@refill + +The @code{makeinfo} program validates pointers automatically, so you +do not need to use the @code{Info-validate} command if you are using +@code{makeinfo}. You only may need to use @code{Info-validate} if you +are unable to run @code{makeinfo} and instead must create an Info file +using @code{texinfo-format-region} or @code{texinfo-format-buffer}, or +if you write an Info file from scratch.@refill + +@menu +* Using Info-validate:: How to run @code{Info-validate}. +* Unsplit:: How to create an unsplit file. +* Tagifying:: How to tagify a file. +* Splitting:: How to split a file manually. +@end menu + +@node Using Info-validate, Unsplit, Running Info-Validate, Running Info-Validate +@appendixsubsec Running @code{Info-validate} +@cindex Running @code{Info-validate} +@cindex Info validating a large file +@cindex Validating a large file + +To use @code{Info-validate}, visit the Info file you wish to check and +type:@refill + +@example +M-x Info-validate +@end example + +@noindent +(Note that the @code{Info-validate} command requires an upper case +`I'. You may also need to create a tag table before running +@code{Info-validate}. @xref{Tagifying}.)@refill + +If your file is valid, you will receive a message that says ``File appears +valid''. However, if you have a pointer that does not point to a node, +error messages will be displayed in a buffer called @samp{*problems in +info file*}.@refill + +For example, @code{Info-validate} was run on a test file that contained +only the first node of this manual. One of the messages said:@refill + +@example +In node "Overview", invalid Next: Texinfo Mode +@end example + +@noindent +This meant that the node called @samp{Overview} had a `Next' pointer that +did not point to anything (which was true in this case, since the test file +had only one node in it).@refill + +Now suppose we add a node named @samp{Texinfo Mode} to our test case +but we do not specify a `Previous' for this node. Then we will get +the following error message:@refill + +@example +In node "Texinfo Mode", should have Previous: Overview +@end example + +@noindent +This is because every `Next' pointer should be matched by a +`Previous' (in the node where the `Next' points) which points back.@refill + +@code{Info-validate} also checks that all menu entries and cross references +point to actual nodes.@refill + +Note that @code{Info-validate} requires a tag table and does not work +with files that have been split. (The @code{texinfo-format-buffer} +command automatically splits large files.) In order to use +@code{Info-validate} on a large file, you must run +@code{texinfo-format-buffer} with an argument so that it does not split +the Info file; and you must create a tag table for the unsplit +file.@refill + +@node Unsplit, Tagifying, Using Info-validate, Running Info-Validate +@comment node-name, next, previous, up +@appendixsubsec Creating an Unsplit File +@cindex Creating an unsplit file +@cindex Unsplit file creation + +You can run @code{Info-validate} only on a single Info file that has a +tag table. The command will not work on the indirect subfiles that +are generated when a master file is split. If you have a large file +(longer than 70,000 bytes or so), you need to run the +@code{texinfo-format-buffer} or @code{makeinfo-buffer} command in such +a way that it does not create indirect subfiles. You will also need +to create a tag table for the Info file. After you have done this, +you can run @code{Info-validate} and look for badly referenced +nodes.@refill + +The first step is to create an unsplit Info file. To prevent +@code{texinfo-format-buffer} from splitting a Texinfo file into +smaller Info files, give a prefix to the @kbd{M-x +texinfo-format-buffer} command:@refill + +@example +C-u M-x texinfo-format-buffer +@end example + +@noindent +or else + +@example +C-u C-c C-e C-b +@end example + +@noindent +When you do this, Texinfo will not split the file and will not create +a tag table for it. @refill +@cindex Making a tag table manually +@cindex Tag table, making manually + +@node Tagifying, Splitting, Unsplit, Running Info-Validate +@appendixsubsec Tagifying a File + +After creating an unsplit Info file, you must create a tag table for +it. Visit the Info file you wish to tagify and type:@refill + +@example +M-x Info-tagify +@end example + +@noindent +(Note the upper case @samp{I} in @code{Info-tagify}.) This creates an +Info file with a tag table that you can validate.@refill + +The third step is to validate the Info file:@refill + +@example +M-x Info-validate +@end example + +@noindent +(Note the upper case @samp{I} in @code{Info-validate}.) +In brief, the steps are:@refill + +@example +@group +C-u M-x texinfo-format-buffer +M-x Info-tagify +M-x Info-validate +@end group +@end example + +After you have validated the node structure, you can rerun +@code{texinfo-format-buffer} in the normal way so it will construct a +tag table and split the file automatically, or you can make the tag +table and split the file manually.@refill + +@node Splitting, , Tagifying, Running Info-Validate +@comment node-name, next, previous, up +@appendixsubsec Splitting a File Manually +@cindex Splitting an Info file manually +@cindex Info file, splitting manually + +You should split a large file or else let the +@code{texinfo-format-buffer} or @code{makeinfo-buffer} command do it +for you automatically. (Generally you will let one of the formatting +commands do this job for you. @xref{Create an Info File}.)@refill + +The split-off files are called the indirect subfiles.@refill + +Info files are split to save memory. With smaller files, Emacs does not +have make such a large buffer to hold the information.@refill + +If an Info file has more than 30 nodes, you should also make a tag +table for it. @xref{Using Info-validate}, for information +about creating a tag table. (Again, tag tables are usually created +automatically by the formatting command; you only need to create a tag +table yourself if you are doing the job manually. Most likely, you +will do this for a large, unsplit file on which you have run +@code{Info-validate}.)@refill + +@c Info-split is autoloaded in `loaddefs.el' in Emacs 18.51 +@ignore +Before running @code{Info-split}, you need to load the @code{info} library +into Emacs by giving the command @kbd{M-x load-library @key{RET} info +@key{RET}}. +@end ignore + +Visit the Info file you wish to tagify and split and type the two +commands:@refill + +@example +M-x Info-tagify +M-x Info-split +@end example + +@noindent +(Note that the @samp{I} in @samp{Info} is upper case.)@refill + +When you use the @code{Info-split} command, the buffer is modified into a +(small) Info file which lists the indirect subfiles. This file should be +saved in place of the original visited file. The indirect subfiles are +written in the same directory the original file is in, with names generated +by appending @samp{-} and a number to the original file name.@refill + +The primary file still functions as an Info file, but it contains just +the tag table and a directory of subfiles.@refill + +@node Refilling Paragraphs, Command Syntax, Catching Mistakes, Top +@comment node-name, next, previous, up +@appendix Refilling Paragraphs +@cindex Refilling paragraphs +@cindex Filling paragraphs +@findex refill + +The @code{@@refill} command refills and, optionally, indents the first +line of a paragraph.@footnote{Perhaps the command should have been +called the @code{@@refillandindent} command, but @code{@@refill} is +shorter and the name was chosen before indenting was possible.} The +@code{@@refill} command is no longer important, but we describe it here +because you once needed it. You will see it in many old Texinfo +files.@refill + +Without refilling, paragraphs containing long @@-constructs may look +bad after formatting because the formatter removes @@-commands and +shortens some lines more than others. In the past, neither the +@code{texinfo-format-region} command nor the +@code{texinfo-format-buffer} command refilled paragraphs +automatically. The @code{@@refill} command had to be written at the +end of every paragraph to cause these formatters to fill them. (Both +@TeX{} and @code{makeinfo} have always refilled paragraphs +automatically.) Now, all the Info formatters automatically fill and +indent those paragraphs that need to be filled and indented.@refill + +The @code{@@refill} command causes @code{texinfo-format-region} and +@code{texinfo-format-buffer} to refill a paragraph in the Info file +@emph{after} all the other processing has been done. For this reason, +you can not use @code{@@refill} with a paragraph containing either +@code{@@*} or @code{@@w@{ @dots{} @}} since the refilling action will +override those two commands.@refill + +The @code{texinfo-format-region} and @code{texinfo-format-buffer} +commands now automatically append @code{@@refill} to the end of each +paragraph that should be filled. They do not append @code{@@refill} to +the ends of paragraphs that contain @code{@@*} or @w{@code{@@w@{ @dots{}@}}} +and therefore do not refill or indent them.@refill + +@node Command Syntax, Obtaining TeX, Refilling Paragraphs, Top +@comment node-name, next, previous, up +@appendix @@-Command Syntax +@cindex @@-command syntax + +The character @samp{@@} is used to start special Texinfo commands. +(It has the same meaning that @samp{\} has in plain @TeX{}.) Texinfo +has four types of @@-command:@refill + +@table @asis +@item 1. Non-alphabetic commands. +These commands consist of an @@ followed by a punctuation mark or other +character that is not part of the alphabet. Non-alphabetic commands +are almost always part of the text within a paragraph, and never take +any argument. The two characters (@@ and the other one) are complete +in themselves; none is followed by braces. The non-alphabetic +commands are: @code{@@.}, @code{@@:}, @code{@@*}, @code{@@@@}, +@code{@@@{}, and @code{@@@}}.@refill + +@item 2. Alphabetic commands that do not require arguments. +These commands start with @@ followed by a word followed by left- and +right-hand braces. These commands insert special symbols in the +document; they do not require arguments. For example, +@code{@@dots@{@}} @result{} @samp{@dots{}}, @code{@@equiv@{@}} +@result{} @samp{@equiv{}}, @code{@@TeX@{@}} @result{} `@TeX{}', +and @code{@@bullet@{@}} @result{} @samp{@bullet{}}.@refill + +@item 3. Alphabetic commands that require arguments within braces. +These commands start with @@ followed by a letter or a word, followed by an +argument within braces. For example, the command @code{@@dfn} indicates +the introductory or defining use of a term; it is used as follows: @samp{In +Texinfo, @@@@-commands are @@dfn@{mark-up@} commands.}@refill + +@item 4. Alphabetic commands that occupy an entire line. +These commands occupy an entire line. The line starts with @@, +followed by the name of the command (a word); for example, @code{@@center} +or @code{@@cindex}. If no argument is needed, the word is followed by +the end of the line. If there is an argument, it is separated from +the command name by a space. Braces are not used.@refill +@end table + +@cindex Braces and argument syntax +Thus, the alphabetic commands fall into classes that have +different argument syntaxes. You cannot tell to which class a command +belongs by the appearance of its name, but you can tell by the +command's meaning: if the command stands for a glyph, it is in +class 2 and does not require an argument; if it makes sense to use the +command together with other text as part of a paragraph, the command +is in class 3 and must be followed by an argument in braces; +otherwise, it is in class 4 and uses the rest of the line as its +argument.@refill + +The purpose of having a different syntax for commands of classes 3 and +4 is to make Texinfo files easier to read, and also to help the GNU +Emacs paragraph and filling commands work properly. There is only one +exception to this rule: the command @code{@@refill}, which is always +used at the end of a paragraph immediately following the final period +or other punctuation character. @code{@@refill} takes no argument and +does @emph{not} require braces. @code{@@refill} never confuses the +Emacs paragraph commands because it cannot appear at the beginning of +a line.@refill + +@node Obtaining TeX, New Features, Command Syntax, Top +@appendix How to Obtain @TeX{} +@cindex Obtaining @TeX{} +@cindex @TeX{}, how to obtain + +@c !!! Here is information about obtaining TeX. Update it whenever. +@c !!! Also consider updating TeX.README on prep. +@c Updated by RJC on 1 March 1995, conversation with MacKay. +@c Updated by kb@cs.umb.edu on 29 July 1996. +@TeX{} is freely redistributable. You can obtain @TeX{} for Unix +systems via anonymous ftp or on tape or CD-ROM. The core material +consists of Karl Berry's Web2c @TeX{} distribution. + +On-line retrieval instructions are available from either: +@example +@url{ftp://ftp.tug.org/tex/unixtex.ftp} +@url{http://www.tug.org/unixtex.ftp} +@end example + +The Free Software Foundation provides a core distribution on its Source +Code CD-ROM suitable for printing Texinfo manuals; the University of +Washington maintains and supports a tape distribution; the @TeX{} Users +Group co-sponsors a complete CD-ROM @TeX{} distribution. + +For the FSF Source Code CD-ROM, please contact: + +@iftex +@display +@group +Free Software Foundation, Inc. +59 Temple Place Suite 330 +Boston, MA w{ } 02111-1307 +USA + +Telephone: @w{@t{+}1--617--542--5942} +Fax: (including Japan) @w{@t{+}1--617--542--2652} +Free Dial Fax (in Japan): +@w{ } @w{ } @w{ } 0031--13--2473 (KDD) +@w{ } @w{ } @w{ } 0066--3382--0158 (IDC) +Electronic mail: @code{gnu@@prep.ai.mit.edu} +@end group +@end display +@end iftex +@ifinfo +@display +@group +Free Software Foundation, Inc. +59 Temple Place Suite 330 +Boston, MA @w{ } 02111-1307 +USA + +Telephone: @w{@t{+}1-617-542-5942} +Fax: (including Japan) @w{@t{+}1-617-542-2652} +Free Dial Fax (in Japan): +@w{ } @w{ } @w{ } 0031-13-2473 (KDD) +@w{ } @w{ } @w{ } 0066-3382-0158 (IDC) +Electronic mail: @code{gnu@@prep.ai.mit.edu} +@end group +@end display +@end ifinfo + +To order a full distribution on CD-ROM, please see: +@display +@url{http://www.tug.org/tex-live.html} +@end display + +@noindent +(The distribution is also available by FTP; see the URL's above.) + +To order a full distribution from the University of Washington on either a +1/4@dmn{in} 4-track QIC-24 cartridge or a 4@dmn{mm} DAT cartridge, send +$210 to: + +@display +@group +Pierre A. MacKay +Denny Hall, Mail Stop DH-10 +University of Washington +Seattle, WA @w{ } 98195 +USA + +Telephone: @t{+}1--206--543--2268 +Electronic mail: @code{mackay@@cs.washington.edu} +@end group +@end display + +Please make checks payable to the University of Washington. +Checks must be in U.S.@: dollars, drawn on a U.S.@: bank. + +Prepaid orders are the only orders that can now be handled. Overseas +sites: please add to the base cost, if desired, $20.00 for shipment +via air parcel post, or $30.00 for shipment via courier. + +Please check with the above for current prices and formats. + + +@node New Features, Command and Variable Index, Obtaining TeX, Top +@appendix Second Edition Features + +@tex +% Widen the space for the first column so three control-character +% strings fit in the first column. Switched back to default .8in +% value at end of chapter. +\global\tableindent=1.0in +@end tex + +The second edition of the Texinfo manual describes more than 20 new +Texinfo mode commands and more than 50 previously undocumented Texinfo +@@-commands. This edition is more than twice the length of the first +edition.@refill + +Here is a brief description of the new commands.@refill + +@menu +* New Texinfo Mode Commands:: The updating commands are especially useful. +* New Commands:: Many newly described @@-commands. +@end menu + +@node New Texinfo Mode Commands, New Commands, New Features, New Features +@appendixsec New Texinfo Mode Commands + +Texinfo mode provides commands and features especially designed for +working with Texinfo files. More than 20 new commands have been +added, including commands for automatically creating and updating +both nodes and menus. This is a tedious task when done by hand.@refill + +The keybindings are intended to be somewhat mnemonic.@refill + +@subheading Update all nodes and menus + +The @code{texinfo-master-menu} command is the primary command: + +@table @kbd +@item C-c C-u m +@itemx M-x texinfo-master-menu +Create or update a master menu. +With @kbd{C-u} as a prefix argument, +first create or update all nodes +and regular menus. +@end table + +@subheading Update Pointers + +@noindent +Create or update `Next', `Previous', and `Up' node pointers.@refill + +@noindent +@xref{Updating Nodes and Menus}. + +@table @kbd +@item C-c C-u C-n +@itemx M-x texinfo-update-node +Update a node. + +@item C-c C-u C-e +@itemx M-x texinfo-every-node-update +Update every node in the buffer. +@end table + +@subheading Update Menus + +@noindent +Create or update menus.@refill + +@noindent +@xref{Updating Nodes and Menus}. + +@table @kbd +@item C-c C-u C-m +@itemx M-x texinfo-make-menu +Make or update a menu. + +@item C-c C-u C-a +@itemx M-x texinfo-all-menus-update +Make or update all the menus in a buffer. +With @kbd{C-u} as a prefix argument, +first update all the nodes. +@end table + +@subheading Insert Title as Description + +@noindent +Insert a node's chapter or section title in the space for the +description in a menu entry line; position point so you can edit the +insert. (This command works somewhat differently than the other +insertion commands, which insert only a predefined string.)@refill + +@noindent +@xref{Inserting, Inserting Frequently Used Commands}. + +@table @kbd +@item C-c C-c C-d +Insert title. +@end table + +@subheading Format for Info + +@noindent +Provide keybindings both for the Info formatting commands that are +written in Emacs Lisp and for @code{makeinfo} that is written in +C.@refill + +@noindent +@xref{Info Formatting}. + +@noindent +Use the Emacs lisp @code{texinfo-format@dots{}} commands: + +@table @kbd +@item C-c C-e C-r +Format the region. + +@item C-c C-e C-b +Format the buffer. +@end table + +@noindent +Use @code{makeinfo}: + +@table @kbd +@item C-c C-m C-r +Format the region. + +@item C-c C-m C-b +Format the buffer. + +@item C-c C-m C-l +Recenter the @code{makeinfo} output buffer. + +@item C-c C-m C-k +Kill the @code{makeinfo} formatting job. +@end table + +@subheading Typeset and Print + +@noindent +Typeset and print Texinfo documents from within Emacs.@refill + +@ifinfo +@noindent +@xref{Printing}. +@end ifinfo +@iftex +@noindent +@xref{Printing, , Formatting and Printing}. +@end iftex + +@table @kbd +@item C-c C-t C-b +Run @code{texi2dvi} on the buffer. + +@item C-c C-t C-r +Run @TeX{} on the region. + +@item C-c C-t C-i +Run @code{texindex}. + +@item C-c C-t C-p +Print the @sc{dvi} file. + +@item C-c C-t C-q +Show the print queue. + +@item C-c C-t C-d +Delete a job from the print queue. + +@item C-c C-t C-k +Kill the current @TeX{} formatting job. + +@item C-c C-t C-x +Quit a currently stopped @TeX{} formatting job. + +@item C-c C-t C-l +Recenter the output buffer. +@end table + +@subheading Other Updating Commands + +@noindent +The ``other updating commands'' do not have standard keybindings because +they are used less frequently.@refill + +@noindent +@xref{Other Updating Commands}. + +@table @kbd +@item M-x texinfo-insert-node-lines +Insert missing @code{@@node} lines using +section titles as node names. + +@item M-x texinfo-multiple-files-update +Update a multi-file document. +With a numeric prefix, such as @kbd{C-u 8}, +update @strong{every} pointer and +menu in @strong{all} the files and +then insert a master menu. + +@item M-x texinfo-indent-menu-description +Indent descriptions in menus. + +@item M-x texinfo-sequential-node-update +Insert node pointers in strict sequence. +@end table + +@node New Commands, , New Texinfo Mode Commands, New Features +@appendixsec New Texinfo @@-Commands + +The second edition of the Texinfo manual describes more than 50 +commands that were not described in the first edition. A third or so +of these commands existed in Texinfo but were not documented in the +manual; the others are new. Here is a listing, with brief +descriptions of them:@refill + +@subheading Indexing + +@noindent +Create your own index, and merge indices.@refill + +@noindent +@xref{Indices}. + +@table @kbd +@item @@defindex @var{index-name} +Define a new index and its indexing command. +See also the @code{@@defcodeindex} command. + +@c written verbosely to avoid overfull hbox +@item @@synindex @var{from-index} @var{into-index} +Merge the @var{from-index} index into the @var{into-index} index. +See also the @code{@@syncodeindex} command. +@end table + +@subheading Definitions + +@noindent +Describe functions, variables, macros, +commands, user options, special forms, and other such artifacts in a +uniform format.@refill + +@noindent +@xref{Definition Commands}. + +@table @kbd +@item @@deffn @var{category} @var{name} @var{arguments}@dots{} +Format a description for functions, interactive +commands, and similar entities. + +@item @@defvr, @@defop, @dots{} +15 other related commands. +@end table + +@subheading Glyphs + +@noindent +Indicate the results of evaluation, expansion, +printed output, an error message, equivalence of expressions, and the +location of point.@refill + +@noindent +@xref{Glyphs}. + +@table @kbd +@item @@equiv@{@} +@itemx @equiv{} +Equivalence: + +@item @@error@{@} +@itemx @error{} +Error message + +@item @@expansion@{@} +@itemx @expansion{} +Macro expansion + +@item @@point@{@} +@itemx @point{} +Position of point + +@item @@print@{@} +@itemx @print{} +Printed output + +@item @@result@{@} +@itemx @result{} +Result of an expression +@end table + +@subheading Page Headings + +@noindent +Customize page headings. + +@noindent +@xref{Headings}. + +@table @kbd +@item @@headings @var{on-off-single-double} +Headings on or off, single, or double-sided. + +@item @@evenfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] +Footings for even-numbered (left-hand) pages. + +@item @@evenheading, @@everyheading, @@oddheading, @dots{} +Five other related commands. + +@item @@thischapter +Insert name of chapter and chapter number. + +@item @@thischaptername, @@thisfile, @@thistitle, @@thispage +Related commands. +@end table + +@subheading Formatting + +@noindent +Format blocks of text. + +@noindent +@xref{Quotations and Examples}, and@* +@ref{Lists and Tables, , Making Lists and Tables}. + +@table @kbd +@item @@cartouche +Draw rounded box surrounding text (not in Info). + +@item @@enumerate @var{optional-arg} +Enumerate a list with letters or numbers. + +@item @@exdent @var{line-of-text} +Remove indentation. + +@item @@flushleft +Left justify. + +@item @@flushright +Right justify. + +@item @@format +Do not narrow nor change font. + +@item @@ftable @var{formatting-command} +@itemx @@vtable @var{formatting-command} +Two-column table with indexing. + +@item @@lisp +For an example of Lisp code. + +@item @@smallexample +@itemx @@smalllisp +Like @@table and @@lisp @r{but for} @@smallbook. +@end table + +@subheading Conditionals + +@noindent +Conditionally format text. + +@noindent +@xref{set clear value, , @code{@@set} @code{@@clear} @code{@@value}}.@refill + +@table @kbd +@item @@set @var{flag} [@var{string}] +Set a flag. Optionally, set value +of @var{flag} to @var{string}. + +@item @@clear @var{flag} +Clear a flag. + +@item @@value@{@var{flag}@} +Replace with value to which @var{flag} is set. + +@item @@ifset @var{flag} +Format, if @var{flag} is set. + +@item @@ifclear @var{flag} +Ignore, if @var{flag} is set. +@end table + +@subheading @@heading series for Titles + +@noindent +Produce unnumbered headings that do not appear in a table of contents. + +@noindent +@xref{Structuring}. + +@table @kbd +@item @@heading @var{title} +Unnumbered section-like heading not listed +in the table of contents of a printed manual. + +@item @@chapheading, @@majorheading, @@subheading, @@subsubheading +Related commands. +@end table + +@need 1000 +@subheading Font commands + +@need 1000 +@noindent +@xref{Smallcaps}, and @* +@ref{Fonts}. + +@table @kbd +@item @@r@{@var{text}@} +Print in roman font. + +@item @@sc@{@var{text}@} +Print in @sc{small caps} font. +@end table + +@subheading Miscellaneous + +@noindent +See @ref{title subtitle author, , @code{@@title} @code{@@subtitle} and @code{@@author} Commands},@* +see @ref{Customized Highlighting},@* +see @ref{Overfull hboxes},@* +see @ref{Footnotes},@* +see @ref{dmn, , Format a Dimension},@* +see @ref{Raise/lower sections, , @code{@@raisesections} and @code{@@lowersections}},@* +see @ref{math, , @code{@@math}: Inserting Mathematical Expressions}.@* +see @ref{minus, , Inserting a Minus Sign},@* +see @ref{paragraphindent, , Paragraph Indenting},@* +see @ref{Cross Reference Commands},@* +see @ref{title subtitle author, , @code{@@title} @code{@@subtitle} and @code{@@author}}, and@* +see @ref{Custom Headings, , How to Make Your Own Headings}. + +@table @kbd +@item @@author @var{author} +Typeset author's name. + +@ignore +@item @@definfoenclose @var{new-command}, @var{before}, @var{after}, +Define a highlighting command for Info. (Info only.) +@end ignore + +@item @@finalout +Produce cleaner printed output. + +@item @@footnotestyle @var{end-or-separate} +Specify footnote style. + +@item @@dmn@{@var{dimension}@} +Format a dimension. + +@item @@global@@let@var{new-cmd}=@var{existing-cmd} +Define a highlighting command for @TeX{}. (@TeX{} only.) + +@item @@lowersections +Reduce hierarchical level of sectioning commands. + +@item @@math@{@var{mathematical-expression}@} +Format a mathematical expression. + +@item @@minus@{@} +Generate a minus sign. + +@item @@paragraphindent @var{asis-or-number} +Specify paragraph indentation. + +@item @@raisesections +Raise hierarchical level of sectioning commands. + +@item @@ref@{@var{node-name}, @r{[}@var{entry}@r{]}, @r{[}@var{topic-or-title}@r{]}, @r{[}@var{info-file}@r{]}, @r{[}@var{manual}@r{]}@} +Make a reference. In the printed manual, the +reference does not start with the word `see'. + +@item @@title @var{title} +Typeset @var{title} in the alternative +title page format. + +@item @@subtitle @var{subtitle} +Typeset @var{subtitle} in the alternative +title page format. + +@item @@today@{@} +Insert the current date. +@end table +@tex +% Switch width of first column of tables back to default value +\global\tableindent=.8in +@end tex + + +@node Command and Variable Index, Concept Index, New Features, Top +@comment node-name, next, previous, up +@unnumbered Command and Variable Index + +This is an alphabetical list of all the @@-commands, assorted Emacs Lisp +functions, and several variables. To make the list easier to use, the +commands are listed without their preceding @samp{@@}.@refill + +@printindex fn + + +@node Concept Index, , Command and Variable Index, Top +@unnumbered Concept Index + +@printindex cp + + +@summarycontents +@contents +@bye diff --git a/texinfo/util/Makefile.in b/texinfo/util/Makefile.in new file mode 100644 index 000000000000..9108632535fc --- /dev/null +++ b/texinfo/util/Makefile.in @@ -0,0 +1,105 @@ +# Makefile for GNU Texindex and other utilities. +# $Id: Makefile.in,v 1.1 1997/08/21 22:58:12 jason Exp $ +# +# Copyright (C) 1990, 91, 92, 96 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. + +#### Start of system configuration section. #### + +srcdir = @srcdir@ +VPATH = $(srcdir):$(common) + +common = $(srcdir)/../libtxi + +EXEEXT = @EXEEXT@ +CC = @CC@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +LN = ln +RM = rm -f +MKDIR = mkdir + +DEFS = @DEFS@ +LIBS = -L../libtxi -ltxi @LIBS@ +LOADLIBES = $(LIBS) + +SHELL = /bin/sh + +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +# Prefix for each installed program, normally empty or `g'. +binprefix = +# Prefix for each installed man page, normally empty or `g'. +manprefix = +mandir = @mandir@/man1 +manext = 1 +infodir = @infodir@ + +#### End of system configuration section. #### + +all: texindex$(EXEEXT) install-info$(EXEEXT) +sub-all: all + +.c.o: + $(CC) -c $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -I$(common) $(CFLAGS) $< + + +install: all + $(INSTALL_PROGRAM) texindex$(EXEEXT) $(bindir)/texindex$(EXEEXT) + $(INSTALL_PROGRAM) $(srcdir)/texi2dvi $(bindir)/texi2dvi + $(INSTALL_PROGRAM) install-info$(EXEEXT) $(bindir)/install-info$(EXEEXT) + +install-info: +dvi: + +uninstall: + rm -f $(bindir)/texindex$(EXEEXT) $(bindir)/texi2dvi $(bindir)/install-info$(EXEEXT) + +Makefile: Makefile.in ../config.status + cd ..; $(SHELL) config.status + +TAGS: + etags *.c *.h $(common)/getopt*.c $(common)/getopt.h + +clean: + rm -f *.o a.out core core.* texindex install-info + +mostlyclean: clean + +distclean: clean + rm -f Makefile config.status + +realclean: distclean + rm -f TAGS + +texindex: texindex.o ../libtxi/libtxi.a + $(CC) $(LDFLAGS) -o texindex texindex.o $(LOADLIBES) + +texindex.o: texindex.c $(common)/getopt.h + +install-info: install-info.o + $(CC) $(LDFLAGS) -o install-info install-info.o $(LOADLIBES) + +install-info.o: install-info.c $(common)/getopt.h + +# Prevent GNU make v3 from overflowing arg limit on SysV. +.NOEXPORT: diff --git a/texinfo/util/deref.c b/texinfo/util/deref.c new file mode 100644 index 000000000000..c15bc1abcf15 --- /dev/null +++ b/texinfo/util/deref.c @@ -0,0 +1,238 @@ +/* + * deref.c + + * compile command: gcc -g -o deref deref.c + + * execute command: deref filename.texi > newfile.texi + + * To: bob@gnu.ai.mit.edu + * Subject: another tool + * Date: 18 Dec 91 16:03:13 EST (Wed) + * From: gatech!skeeve!arnold@eddie.mit.edu (Arnold D. Robbins) + * + * Here is deref.c. It turns texinfo cross references back into the + * one argument form. It has the same limitations as fixref; one xref per + * line and can't cross lines. You can use it to find references that do + * cross a line boundary this way: + * + * deref < manual > /dev/null 2>errs + * + * (This assumes bash or /bin/sh.) The file errs will have list of lines + * where deref could not find matching braces. + * + * A gawk manual processed by deref goes through makeinfo without complaint. + * Compile with gcc and you should be set. + * + * Enjoy, + * + * Arnold + * ----------- + */ + +/* + * deref.c + * + * Make all texinfo references into the one argument form. + * + * Arnold Robbins + * arnold@skeeve.atl.ga.us + * December, 1991 + * + * Copyright, 1991, Arnold Robbins + */ + +/* + * LIMITATIONS: + * One texinfo cross reference per line. + * Cross references may not cross newlines. + * Use of fgets for input (to be fixed). + */ + +#include +#include +#include + +/* for gcc on the 3B1, delete if this gives you grief */ +extern int fclose (FILE * fp); +extern int fprintf (FILE * fp, const char *str,...); + +extern char *strerror (int errno); +extern char *strchr (char *cp, int ch); +extern int strncmp (const char *s1, const char *s2, int count); + +extern int errno; + +void process (FILE * fp); +void repair (char *line, char *ref, int toffset); + +int Errs = 0; +char *Name = "stdin"; +int Line = 0; +char *Me; + +/* main --- handle arguments, global vars for errors */ + +int +main (int argc, char **argv) +{ + FILE *fp; + + Me = argv[0]; + + if (argc == 1) + process (stdin); + else + for (argc--, argv++; *argv != NULL; argc--, argv++) + { + if (argv[0][0] == '-' && argv[0][1] == '\0') + { + Name = "stdin"; + Line = 0; + process (stdin); + } + else if ((fp = fopen (*argv, "r")) != NULL) + { + Name = *argv; + Line = 0; + process (fp); + fclose (fp); + } + else + { + fprintf (stderr, "%s: can not open: %s\n", + *argv, strerror (errno)); + Errs++; + } + } + return Errs != 0; +} + +/* isref --- decide if we've seen a texinfo cross reference */ + +int +isref (char *cp) +{ + if (strncmp (cp, "@ref{", 5) == 0) + return 5; + if (strncmp (cp, "@xref{", 6) == 0) + return 6; + if (strncmp (cp, "@pxref{", 7) == 0) + return 7; + return 0; +} + +/* process --- read files, look for references, fix them up */ + +void +process (FILE * fp) +{ + char buf[BUFSIZ]; + char *cp; + int count; + + while (fgets (buf, sizeof buf, fp) != NULL) + { + Line++; + cp = strchr (buf, '@'); + if (cp == NULL) + { + fputs (buf, stdout); + continue; + } + do + { + count = isref (cp); + if (count == 0) + { + cp++; + cp = strchr (cp, '@'); + if (cp == NULL) + { + fputs (buf, stdout); + goto next; + } + continue; + } + /* got one */ + repair (buf, cp, count); + break; + } + while (cp != NULL); + next:; + } +} + +/* repair --- turn all texinfo cross references into the one argument form */ + +void +repair (char *line, char *ref, int toffset) +{ + int braces = 1; /* have seen first left brace */ + char *cp; + + ref += toffset; + + /* output line up to and including left brace in reference */ + for (cp = line; cp <= ref; cp++) + putchar (*cp); + + /* output node name */ + for (; *cp && *cp != '}' && *cp != ',' && *cp != '\n'; cp++) + putchar (*cp); + + if (*cp != '}') + { /* could have been one arg xref */ + /* skip to matching right brace */ + for (; braces > 0; cp++) + { + switch (*cp) + { + case '@': + cp++; /* blindly skip next character */ + break; + case '{': + braces++; + break; + case '}': + braces--; + break; + case '\n': + case '\0': + Errs++; + fprintf (stderr, + "%s: %s: %d: mismatched braces\n", + Me, Name, Line); + goto out; + default: + break; + } + } + out: + ; + } + + putchar ('}'); + if (*cp == '}') + cp++; + + /* now the rest of the line */ + for (; *cp; cp++) + putchar (*cp); + return; +} + +/* strerror --- return error string, delete if in your library */ + +char * +strerror (int errno) +{ + static char buf[100]; + extern int sys_nerr; + extern char *sys_errlist[]; + + if (errno < sys_nerr && errno >= 0) + return sys_errlist[errno]; + + sprintf (buf, "unknown error %d", errno); + return buf; +} diff --git a/texinfo/util/fixfonts b/texinfo/util/fixfonts new file mode 100755 index 000000000000..ee2ea7192198 --- /dev/null +++ b/texinfo/util/fixfonts @@ -0,0 +1,84 @@ +#!/bin/sh +# Make links named `lcircle10' for all TFM and GF/PK files, if no +# lcircle10 files already exist. + +# Don't override definition of prefix and/or libdir if they are +# already defined in the environment. +if test "z${prefix}" = "z" ; then + prefix=/usr/local +else + # prefix may contain references to other variables, thanks to make. + eval prefix=\""${prefix}"\" +fi + +if test "z${libdir}" = "z" ; then + libdir="${prefix}/lib/tex" +else + # libdir may contain references to other variables, thanks to make. + eval libdir=\""${libdir}"\" +fi + +texlibdir="${libdir}" +texfontdir="${texlibdir}/fonts" + +# Directories for the different font formats, in case they're not all +# stored in one place. +textfmdir="${textfmdir-${texfontdir}}" +texpkdir="${texpkdir-${texfontdir}}" +texgfdir="${texgfdir-${texfontdir}}" + +test "z${TMPDIR}" = "z" && TMPDIR="/tmp" + +tempfile="${TMPDIR}/circ$$" +tempfile2="${TMPDIR}/circ2$$" + +# EXIT SIGHUP SIGINT SIGQUIT SIGTERM +#trap 'rm -f "${tempfile}" "${tempfile2}"' 0 1 2 3 15 + +# Find all the fonts with names that include `circle'. +(cd "${texfontdir}"; find . -name '*circle*' -print > "${tempfile}") + +# If they have lcircle10.tfm, assume everything is there, and quit. +if grep 'lcircle10\.tfm' "${tempfile}" > /dev/null 2>&1 ; then + echo "Found lcircle10.tfm." + exit 0 +fi + +# No TFM file for lcircle. Make a link to circle10.tfm if it exists, +# and then make a link to the bitmap files. +grep 'circle10\.tfm' "${tempfile}" > "${tempfile2}" \ + || { + echo "I can't find any circle fonts in ${texfontdir}. +If it isn't installed somewhere else, you need to get the Metafont sources +from somewhere, e.g., labrea.stanford.edu:pub/tex/latex/circle10.mf, and +run Metafont on them." + exit 1 + } + +# We have circle10.tfm. (If we have it more than once, take the first +# one.) Make the link. +tempfile2_line1="`sed -ne '1p;q' \"${tempfile2}\"`" +ln "${tempfile2_line1}" "${textfmdir}/lcircle10.tfm" +echo "Linked to ${tempfile2_line1}." + +# Now make a link for the PK files, if any. +(cd "${texpkdir}" + for f in `grep 'circle10.*pk' "${tempfile}"` ; do + set - `echo "$f" \ + | sed -ne '/\//!s/^/.\//;s/\(.*\)\/\([^\/][^\/]*\)$/\1 \2/;p'` + ln "$f" "${1}/l${2}" + echo "Linked to $f." + done +) + +# And finally for the GF files. +(cd "${texgfdir}" + for f in `grep 'circle10.*gf' "${tempfile}"` ; do + set - `echo "$f" \ + | sed -ne '/\//!s/^/.\//;s/\(.*\)\/\([^\/][^\/]*\)$/\1 \2/;p'` + ln "$f" "${1}/l${2}" + echo "Linked to $f." + done +) + +# eof diff --git a/texinfo/util/gen-dir-node b/texinfo/util/gen-dir-node new file mode 100755 index 000000000000..ed825043db6e --- /dev/null +++ b/texinfo/util/gen-dir-node @@ -0,0 +1,176 @@ +#!/bin/sh +# $Id: gen-dir-node,v 1.1 1997/08/21 22:58:12 jason Exp $ +# Generate the top-level Info node, given a directory of Info files +# and (optionally) a skeleton file. The output will be suitable for a +# top-level dir file. The skeleton file contains info topic names in the +# order they should appear in the output. There are three special +# lines that alter the behavior: a line consisting of just "--" causes +# the next line to be echoed verbatim to the output. A line +# containing just "%%" causes all the remaining filenames (wildcards +# allowed) in the rest of the file to be ignored. A line containing +# just "!!" exits the script when reached (unless preceded by a line +# containing just "--"). Once the script reaches the end of the +# skeleton file, it goes through the remaining files in the directory +# in order, putting their entries at the end. The script will use the +# ENTRY information in each info file if it exists. Otherwise it will +# make a minimal entry. + +# sent by Jeffrey Osier , who thinks it came from +# zoo@winternet.com (david d `zoo' zuhn) + +# modified 7 April 1995 by Joe Harrington to +# take special flags + +INFODIR=$1 +if [ $# = 2 ] ; then + SKELETON=$2 +else + SKELETON=/dev/null +fi + +skip= + +if [ $# -gt 2 ] ; then + echo usage: $0 info-directory [ skeleton-file ] 1>&2 + exit 1 +else + true +fi + +if [ ! -d ${INFODIR} ] ; then + echo "$0: first argument must specify a directory" + exit 1 +fi + +### output the dir header +echo "-*- Text -*-" +echo "This file was generated automatically by $0." +echo "This version was generated on `date`" +echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`" + +cat << moobler + +This is the file .../info/dir, which contains the topmost node of the +Info hierarchy. The first time you invoke Info you start off +looking at that node, which is (dir)Top. + +File: dir Node: Top This is the top of the INFO tree + This (the Directory node) gives a menu of major topics. + Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" + gives a primer for first-timers, "mTexinfo" visits Texinfo topic, + etc. + Or click mouse button 2 on a menu item or cross reference to select it. + --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) --- + +* Menu: The list of major topics begins on the next line. + +moobler + +### go through the list of files in the skeleton. If an info file +### exists, grab the ENTRY information from it. If an entry exists +### use it, otherwise create a minimal dir entry. +### +### Then remove that file from the list of existing files. If any +### additional files remain (ones that don't have a skeleton entry), +### then generate entries for those in the same way, putting the info for +### those at the end.... + +infofiles=`(cd ${INFODIR}; ls | egrep -v '\-|^dir$|^dir\.info$|^dir\.orig$')` + +# echoing gets clobbered by backquotes; we do it the hard way... +lines=`wc $SKELETON | awk '{print $1}'` +line=1 +while [ $lines -ge $line ] ; do + # Read one line from the file. This is so that we can echo lines with + # whitespace and quoted characters in them. + fileline=`awk NR==$line $SKELETON` + + # flag fancy features + if [ ! -z "$echoline" ] ; then # echo line + echo "$fileline" + fileline= + echoline= + elif [ "${fileline}" = "--" ] ; then # should we echo the next line? + echoline=1 + elif [ "${fileline}" = "%%" ] ; then # eliminate remaining files from dir? + skip=1 + elif [ "${fileline}" = "!!" ] ; then # quit now + exit 0 + fi + + # handle files if they exist + for file in $fileline"" ; do # expand wildcards ("" handles blank lines) + + fname= + + if [ -z "$echoline" -a ! -z "$file" ] ; then + + # Find the file to operate upon. Check both possible names. + infoname=`echo $file | sed 's/\.info$//'` + noext= + ext= + if [ -f ${INFODIR}/$infoname ] ; then + noext=$infoname + fi + if [ -f ${INFODIR}/${infoname}.info ] ; then + ext=${infoname}.info + fi + + # If it exists with both names take what was said in the file. + if [ ! -z "$ext" -a ! -z "$noext" ]; then + fname=$file + warn="### Warning: $ext and $noext both exist! Using ${file}. ###" + elif [ ! \( -z "$ext" -a -z "$noext" \) ]; then + # just take the name if it exists only once + fname=${noext}${ext} + fi + + # if we found something and aren't skipping, do the entry + if [ ! -z "$fname" ] ; then + if [ -z "$skip" ] ; then + + if [ ! -z "$warn" ] ; then # issue any warning + echo $warn + warn= + fi + + entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \ + -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/$fname` + if [ ! -z "${entry}" ] ; then + echo "${entry}" + else + echo "* ${infoname}: (${fname})." + fi + fi + + # remove the name from the directory listing + infofiles=`echo ${infofiles} | sed -e "s/ ${fname} / /" \ + -e "s/^${fname} //" \ + -e "s/ ${fname}$//"` + + fi + + fi + + done + + line=`expr $line + 1` +done + +if [ -z "${infofiles}" ] ; then + exit 0 +else + echo +fi + +for file in ${infofiles}; do + infoname=`echo $file | sed 's/\.info$//'` + entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \ + -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}` + + if [ ! -z "${entry}" ] ; then + echo "${entry}" + else + echo "* ${infoname}: (${file})." + fi +done diff --git a/texinfo/util/install-info.c b/texinfo/util/install-info.c new file mode 100644 index 000000000000..53fa4aa11164 --- /dev/null +++ b/texinfo/util/install-info.c @@ -0,0 +1,1111 @@ +/* install-info -- create Info directory entry(ies) for an Info file. + Copyright (C) 1996 Free Software Foundation, Inc. + +$Id: install-info.c,v 1.12 1996/10/03 23:13:36 karl Exp $ + +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. */ + +#define INSTALL_INFO_VERSION_STRING "GNU install-info (Texinfo 3.9) 1.2" + +#include +#include +#include +#include + +/* Get O_RDONLY. */ +#ifdef HAVE_SYS_FCNTL_H +#include +#else +#include +#endif /* !HAVE_SYS_FCNTL_H */ +#ifdef HAVE_SYS_FILE_H +#include +#endif + +/* Name this program was invoked with. */ +char *progname; + +char *readfile (); +struct line_data *findlines (); +char *my_strerror (); +void fatal (); +void insert_entry_here (); +int compare_section_names (); + +struct spec_entry; + +/* Data structures. */ + +/* Record info about a single line from a file + as read into core. */ + +struct line_data +{ + /* The start of the line. */ + char *start; + /* The number of characters in the line, + excluding the terminating newline. */ + int size; + /* Vector containing pointers to the entries to add before this line. + The vector is null-terminated. */ + struct spec_entry **add_entries_before; + /* 1 means output any needed new sections before this line. */ + int add_sections_before; + /* 1 means don't output this line. */ + int delete; +}; + +/* This is used for a list of the specified menu section names + in which entries should be added. */ + +struct spec_section +{ + struct spec_section *next; + char *name; + /* 1 means we have not yet found an existing section with this name + in the dir file--so we will need to add a new section. */ + int missing; +}; + +/* This is used for a list of the entries specified to be added. */ + +struct spec_entry +{ + struct spec_entry *next; + char *text; +}; + +/* This is used for a list of nodes found by parsing the dir file. */ + +struct node +{ + struct node *next; + /* The node name. */ + char *name; + /* The line number of the line where the node starts. + This is the line that contains control-underscore. */ + int start_line; + /* The line number of the line where the node ends, + which is the end of the file or where the next line starts. */ + int end_line; + /* Start of first line in this node's menu + (the line after the * Menu: line). */ + char *menu_start; + /* The start of the chain of sections in this node's menu. */ + struct menu_section *sections; + /* The last menu section in the chain. */ + struct menu_section *last_section; +}; + +/* This is used for a list of sections found in a node's menu. + Each struct node has such a list in the sections field. */ + +struct menu_section +{ + struct menu_section *next; + char *name; + /* Line number of start of section. */ + int start_line; + /* Line number of end of section. */ + int end_line; +}; + +/* Memory allocation and string operations. */ + +/* Like malloc but get fatal error if memory is exhausted. */ + +void * +xmalloc (size) + unsigned int size; +{ + extern void *malloc (); + void *result = malloc (size); + if (result == NULL) + fatal ("virtual memory exhausted", 0); + return result; +} + +/* Like malloc but get fatal error if memory is exhausted. */ + +void * +xrealloc (obj, size) + void *obj; + unsigned int size; +{ + extern void *realloc (); + void *result = realloc (obj, size); + if (result == NULL) + fatal ("virtual memory exhausted", 0); + return result; +} + +/* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */ + +char * +concat (s1, s2, s3) + char *s1, *s2, *s3; +{ + int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); + char *result = (char *) xmalloc (len1 + len2 + len3 + 1); + + strcpy (result, s1); + strcpy (result + len1, s2); + strcpy (result + len1 + len2, s3); + *(result + len1 + len2 + len3) = 0; + + return result; +} + +/* Return a string containing SIZE characters + copied from starting at STRING. */ + +char * +copy_string (string, size) + char *string; + int size; +{ + int i; + char *copy = (char *) xmalloc (size + 1); + for (i = 0; i < size; i++) + copy[i] = string[i]; + copy[size] = 0; + return copy; +} + +/* Error message functions. */ + +/* Print error message. `s1' is printf control string, `s2' is arg for it. */ + +/* VARARGS1 */ +void +error (s1, s2, s3) + char *s1, *s2, *s3; +{ + fprintf (stderr, "%s: ", progname); + fprintf (stderr, s1, s2, s3); + fprintf (stderr, "\n"); +} + +/* VARARGS1 */ +void +warning (s1, s2, s3) + char *s1, *s2, *s3; +{ + fprintf (stderr, "%s: Warning: ", progname); + fprintf (stderr, s1, s2, s3); + fprintf (stderr, "\n"); +} + +/* Print error message and exit. */ + +void +fatal (s1, s2, s3) + char *s1, *s2, *s3; +{ + error (s1, s2, s3); + exit (1); +} + +/* Print fatal error message based on errno, with file name NAME. */ + +void +pfatal_with_name (name) + char *name; +{ + char *s = concat ("", my_strerror (errno), " for %s"); + fatal (s, name); +} + +/* Given the full text of a menu entry, null terminated, + return just the menu item name (copied). */ + +char * +extract_menu_item_name (item_text) + char *item_text; +{ + char *p; + + if (*item_text == '*') + item_text++; + while (*item_text == ' ') + item_text++; + + p = item_text; + while (*p && *p != ':') p++; + return copy_string (item_text, p - item_text); +} + +/* Given the full text of a menu entry, terminated by null or newline, + return just the menu item file (copied). */ + +char * +extract_menu_file_name (item_text) + char *item_text; +{ + char *p = item_text; + + /* If we have text that looks like * ITEM: (FILE)NODE..., + extract just FILE. Otherwise return "(none)". */ + + if (*p == '*') + p++; + while (*p == ' ') + p++; + + /* Skip to and past the colon. */ + while (*p && *p != '\n' && *p != ':') p++; + if (*p == ':') p++; + + /* Skip past the open-paren. */ + while (1) + { + if (*p == '(') + break; + else if (*p == ' ' || *p == '\t') + p++; + else + return "(none)"; + } + p++; + + item_text = p; + + /* File name ends just before the close-paren. */ + while (*p && *p != '\n' && *p != ')') p++; + if (*p != ')') + return "(none)"; + + return copy_string (item_text, p - item_text); +} + +void +suggest_asking_for_help () +{ + fprintf (stderr, "\tTry `%s --help' for a complete list of options.\n", + progname); + exit (1); +} + +void +print_help () +{ + printf ("%s [OPTION]... [INFO-FILE [DIR-FILE]]\n\ + Install INFO-FILE in the Info directory file DIR-FILE.\n\ +\n\ +Options:\n\ +--delete Delete existing entries in INFO-FILE;\n\ + don't insert any new entries.\n\ +--dir-file=NAME Specify file name of Info directory file.\n\ + This is equivalent to using the DIR-FILE argument.\n\ +--entry=TEXT Insert TEXT as an Info directory entry.\n\ + TEXT should have the form of an Info menu item line\n\ + plus zero or more extra lines starting with whitespace.\n\ + If you specify more than one entry, they are all added.\n\ + If you don't specify any entries, they are determined\n\ + from information in the Info file itself.\n\ +--help Display this help and exit.\n\ +--info-file=FILE Specify Info file to install in the directory.\n\ + This is equivalent to using the INFO-FILE argument.\n\ +--info-dir=DIR Same as --dir-file=DIR/dir.\n\ +--item=TEXT Same as --entry TEXT.\n\ + An Info directory entry is actually a menu item.\n\ +--quiet Suppress warnings.\n\ +--remove Same as --delete.\n\ +--section=SEC Put this file's entries in section SEC of the directory.\n\ + If you specify more than one section, all the entries\n\ + are added in each of the sections.\n\ + If you don't specify any sections, they are determined\n\ + from information in the Info file itself.\n\ +--version Display version information and exit.\n\ +\n\ +Email bug reports to bug-texinfo@prep.ai.mit.edu.\n\ +", progname); +} + +/* Convert an errno value into a string describing the error. + We define this function here rather than using strerror + because not all systems have strerror. */ + +char * +my_strerror (errnum) + int errnum; +{ + extern char *sys_errlist[]; + extern int sys_nerr; + + if (errnum >= 0 && errnum < sys_nerr) + return sys_errlist[errnum]; + return (char *) "Unknown error"; +} + +/* This table defines all the long-named options, says whether they + use an argument, and maps them into equivalent single-letter options. */ + +struct option longopts[] = +{ + { "delete", no_argument, NULL, 'r' }, + { "dir-file", required_argument, NULL, 'd' }, + { "entry", required_argument, NULL, 'e' }, + { "help", no_argument, NULL, 'h' }, + { "info-dir", required_argument, NULL, 'D' }, + { "info-file", required_argument, NULL, 'i' }, + { "item", required_argument, NULL, 'e' }, + { "quiet", no_argument, NULL, 'q' }, + { "remove", no_argument, NULL, 'r' }, + { "section", required_argument, NULL, 's' }, + { "version", no_argument, NULL, 'V' }, + { 0 } +}; + +main (argc, argv) + int argc; + char **argv; +{ + char *infile = 0, *dirfile = 0; + char *infile_sans_info; + unsigned infilelen_sans_info; + FILE *output; + + /* Record the text of the Info file, as a sequence of characters + and as a sequence of lines. */ + char *input_data; + int input_size; + struct line_data *input_lines; + int input_nlines; + + /* Record here the specified section names and directory entries. */ + struct spec_section *input_sections = NULL; + struct spec_entry *entries_to_add = NULL; + int n_entries_to_add = 0; + + /* Record the old text of the dir file, as plain characters, + as lines, and as nodes. */ + char *dir_data; + int dir_size; + int dir_nlines; + struct line_data *dir_lines; + struct node *dir_nodes; + + /* Nonzero means --delete was specified (just delete existing entries). */ + int delete_flag = 0; + int something_deleted = 0; + /* Nonzero means -q was specified. */ + int quiet_flag = 0; + + int node_header_flag; + int prefix_length; + int i; + + progname = argv[0]; + + while (1) + { + int opt = getopt_long (argc, argv, "i:d:e:s:hHr", longopts, 0); + + if (opt == EOF) + break; + + switch (opt) + { + case 0: + /* If getopt returns 0, then it has already processed a + long-named option. We should do nothing. */ + break; + + case 1: + abort (); + + case 'd': + if (dirfile) + { + fprintf (stderr, "%s: Specify the Info directory only once.\n", + progname); + suggest_asking_for_help (); + } + dirfile = optarg; + break; + + case 'D': + if (dirfile) + { + fprintf (stderr, "%s: Specify the Info directory only once.\n", + progname); + suggest_asking_for_help (); + } + dirfile = concat (optarg, "", "/dir"); + break; + + case 'e': + { + struct spec_entry *next + = (struct spec_entry *) xmalloc (sizeof (struct spec_entry)); + if (! (*optarg != 0 && optarg[strlen (optarg) - 1] == '\n')) + optarg = concat (optarg, "\n", ""); + next->text = optarg; + next->next = entries_to_add; + entries_to_add = next; + n_entries_to_add++; + } + break; + + case 'h': + case 'H': + print_help (); + exit (0); + + case 'i': + if (infile) + { + fprintf (stderr, "%s: Specify the Info file only once.\n", + progname); + suggest_asking_for_help (); + } + infile = optarg; + break; + + case 'q': + quiet_flag = 1; + break; + + case 'r': + delete_flag = 1; + break; + + case 's': + { + struct spec_section *next + = (struct spec_section *) xmalloc (sizeof (struct spec_section)); + next->name = optarg; + next->next = input_sections; + next->missing = 1; + input_sections = next; + } + break; + + case 'V': + puts (INSTALL_INFO_VERSION_STRING); +puts ("Copyright (C) 1996 Free Software Foundation, Inc.\n\ +There is NO warranty. You may redistribute this software\n\ +under the terms of the GNU General Public License.\n\ +For more information about these matters, see the files named COPYING."); + exit (0); + + default: + suggest_asking_for_help (); + } + } + + /* Interpret the non-option arguments as file names. */ + for (; optind < argc; ++optind) + { + if (infile == 0) + infile = argv[optind]; + else if (dirfile == 0) + dirfile = argv[optind]; + else + error ("excess command line argument `%s'", argv[optind]); + } + + if (!infile) + fatal ("No input file specified"); + if (!dirfile) + fatal ("No dir file specified"); + + /* Read the Info file and parse it into lines. */ + + input_data = readfile (infile, &input_size); + input_lines = findlines (input_data, input_size, &input_nlines); + + /* Parse the input file to find the section names it specifies. */ + + if (input_sections == 0) + { + prefix_length = strlen ("INFO-DIR-SECTION "); + for (i = 0; i < input_nlines; i++) + { + if (!strncmp ("INFO-DIR-SECTION ", input_lines[i].start, + prefix_length)) + { + struct spec_section *next + = (struct spec_section *) xmalloc (sizeof (struct spec_section)); + next->name = copy_string (input_lines[i].start + prefix_length, + input_lines[i].size - prefix_length); + next->next = input_sections; + next->missing = 1; + input_sections = next; + } + } + } + + /* Default to section "Miscellaneous" if no sections specified. */ + if (input_sections == 0) + { + input_sections + = (struct spec_section *) xmalloc (sizeof (struct spec_section)); + input_sections->name = "Miscellaneous"; + input_sections->next = 0; + input_sections->missing = 1; + } + + /* Now find the directory entries specified in the file + and put them on entries_to_add. But not if entries + were specified explicitly with command options. */ + + if (entries_to_add == 0) + { + char *start_of_this_entry = 0; + for (i = 0; i < input_nlines; i++) + { + if (!strncmp ("START-INFO-DIR-ENTRY", input_lines[i].start, + input_lines[i].size) + && sizeof ("START-INFO-DIR-ENTRY") - 1 == input_lines[i].size) + { + if (start_of_this_entry != 0) + fatal ("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY"); + start_of_this_entry = input_lines[i + 1].start; + } + if (!strncmp ("END-INFO-DIR-ENTRY", input_lines[i].start, + input_lines[i].size) + && sizeof ("END-INFO-DIR-ENTRY") - 1 == input_lines[i].size) + { + if (start_of_this_entry != 0) + { + struct spec_entry *next + = (struct spec_entry *) xmalloc (sizeof (struct spec_entry)); + next->text = copy_string (start_of_this_entry, + input_lines[i].start - start_of_this_entry); + next->next = entries_to_add; + entries_to_add = next; + n_entries_to_add++; + start_of_this_entry = 0; + } + else + fatal ("END-INFO-DIR-ENTRY without matching START-INFO-DIR-ENTRY"); + } + } + if (start_of_this_entry != 0) + fatal ("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY"); + } + + if (!delete_flag) + if (entries_to_add == 0) + fatal ("no info dir entry in `%s'", infile); + + /* Now read in the Info dir file. */ + dir_data = readfile (dirfile, &dir_size); + dir_lines = findlines (dir_data, dir_size, &dir_nlines); + + /* We will be comparing the entries in the dir file against the + current filename, so need to strip off any directory prefix and any + .info suffix. */ + { + unsigned basename_len; + extern char *strrchr (); + char *infile_basename = strrchr (infile, '/'); + if (infile_basename) + infile_basename++; + else + infile_basename = infile; + + basename_len = strlen (infile_basename); + infile_sans_info + = (strlen (infile_basename) > 5 + && strcmp (infile_basename + basename_len - 5, ".info") == 0) + ? copy_string (infile_basename, basename_len - 5) + : infile_basename; + + infilelen_sans_info = strlen (infile_sans_info); + } + + /* Parse the dir file. Find all the nodes, and their menus, + and the sections of their menus. */ + + dir_nodes = 0; + node_header_flag = 0; + for (i = 0; i < dir_nlines; i++) + { + /* Parse node header lines. */ + if (node_header_flag) + { + int j, end; + for (j = 0; j < dir_lines[i].size; j++) + /* Find the node name and store it in the `struct node'. */ + if (!strncmp ("Node:", dir_lines[i].start + j, 5)) + { + char *line = dir_lines[i].start; + /* Find the start of the node name. */ + j += 5; + while (line[j] == ' ' || line[j] == '\t') + j++; + /* Find the end of the node name. */ + end = j; + while (line[end] != 0 && line[end] != ',' && line[end] != '\n' + && line[end] != '\t') + end++; + dir_nodes->name = copy_string (line + j, end - j); + } + node_header_flag = 0; + } + + /* Notice the start of a node. */ + if (*dir_lines[i].start == 037) + { + struct node *next + = (struct node *) xmalloc (sizeof (struct node)); + next->next = dir_nodes; + next->name = NULL; + next->start_line = i; + next->end_line = 0; + next->menu_start = NULL; + next->sections = NULL; + next->last_section = NULL; + + if (dir_nodes != 0) + dir_nodes->end_line = i; + /* Fill in the end of the last menu section + of the previous node. */ + if (dir_nodes != 0 && dir_nodes->last_section != 0) + dir_nodes->last_section->end_line = i; + + dir_nodes = next; + + /* The following line is the header of this node; + parse it. */ + node_header_flag = 1; + } + + /* Notice the lines that start menus. */ + if (dir_nodes != 0 + && !strncmp ("* Menu:", dir_lines[i].start, 7)) + dir_nodes->menu_start = dir_lines[i + 1].start; + + /* Notice sections in menus. */ + if (dir_nodes != 0 + && dir_nodes->menu_start != 0 + && *dir_lines[i].start != '\n' + && *dir_lines[i].start != '*' + && *dir_lines[i].start != ' ' + && *dir_lines[i].start != '\t') + { + /* Add this menu section to the node's list. + This list grows in forward order. */ + struct menu_section *next + = (struct menu_section *) xmalloc (sizeof (struct menu_section)); + next->start_line = i + 1; + next->next = 0; + next->end_line = 0; + next->name = copy_string (dir_lines[i].start, dir_lines[i].size); + if (dir_nodes->sections) + { + dir_nodes->last_section->next = next; + dir_nodes->last_section->end_line = i; + } + else + dir_nodes->sections = next; + dir_nodes->last_section = next; + } + + /* Check for an existing entry that should be deleted. + Delete all entries which specify this file name. */ + if (*dir_lines[i].start == '*') + { + char *p = dir_lines[i].start; + + while (*p != 0 && *p != ':') + p++; + p++; + while (*p == ' ') p++; + if (*p == '(') + { + p++; + if ((dir_lines[i].size + > (p - dir_lines[i].start + infilelen_sans_info)) + && !strncmp (p, infile_sans_info, infilelen_sans_info) + && p[infilelen_sans_info] == ')') + dir_lines[i].delete = 1; + } + } + /* Treat lines that start with whitespace + as continuations; if we are deleting an entry, + delete all its continuations as well. */ + else if (i > 0 + && (*dir_lines[i].start == ' ' + || *dir_lines[i].start == '\t')) + { + dir_lines[i].delete = dir_lines[i - 1].delete; + something_deleted = 1; + } + } + + /* Finish the info about the end of the last node. */ + if (dir_nodes != 0) + { + dir_nodes->end_line = dir_nlines; + if (dir_nodes->last_section != 0) + dir_nodes->last_section->end_line = dir_nlines; + } + + /* Decide where to add the new entries (unless --delete was used). + Find the menu sections to add them in. + In each section, find the proper alphabetical place to add + each of the entries. */ + + if (!delete_flag) + { + struct node *node; + struct menu_section *section; + struct spec_section *spec; + + for (node = dir_nodes; node; node = node->next) + for (section = node->sections; section; section = section->next) + { + for (i = section->end_line; i > section->start_line; i--) + if (dir_lines[i - 1].size != 0) + break; + section->end_line = i; + + for (spec = input_sections; spec; spec = spec->next) + if (!strcmp (spec->name, section->name)) + break; + if (spec) + { + int add_at_line = section->end_line; + struct spec_entry *entry; + /* Say we have found at least one section with this name, + so we need not add such a section. */ + spec->missing = 0; + /* For each entry, find the right place in this section + to add it. */ + for (entry = entries_to_add; entry; entry = entry->next) + { + int textlen = strlen (entry->text); + /* Subtract one because dir_lines is zero-based, + but the `end_line' and `start_line' members are + one-based. */ + for (i = section->end_line - 1; + i >= section->start_line - 1; i--) + { + /* If an entry exists with the same name, + and was not marked for deletion + (which means it is for some other file), + we are in trouble. */ + if (dir_lines[i].start[0] == '*' + && menu_line_equal (entry->text, textlen, + dir_lines[i].start, + dir_lines[i].size) + && !dir_lines[i].delete) + fatal ("menu item `%s' already exists, for file `%s'", + extract_menu_item_name (entry->text), + extract_menu_file_name (dir_lines[i].start)); + if (dir_lines[i].start[0] == '*' + && menu_line_lessp (entry->text, textlen, + dir_lines[i].start, + dir_lines[i].size)) + add_at_line = i; + } + insert_entry_here (entry, add_at_line, + dir_lines, n_entries_to_add); + } + } + } + + /* Mark the end of the Top node as the place to add any + new sections that are needed. */ + for (node = dir_nodes; node; node = node->next) + if (node->name && strcmp (node->name, "Top") == 0) + dir_lines[node->end_line].add_sections_before = 1; + } + + if (delete_flag && !something_deleted && !quiet_flag) + warning ("no entries found for `%s'; nothing deleted", infile); + + /* Output the old dir file, interpolating the new sections + and/or new entries where appropriate. */ + + output = fopen (dirfile, "w"); + if (!output) + { + perror (dirfile); + exit (1); + } + + for (i = 0; i <= dir_nlines; i++) + { + int j; + + /* If we decided to output some new entries before this line, + output them now. */ + if (dir_lines[i].add_entries_before) + for (j = 0; j < n_entries_to_add; j++) + { + struct spec_entry *this = dir_lines[i].add_entries_before[j]; + if (this == 0) + break; + fputs (this->text, output); + } + /* If we decided to add some sections here + because there are no such sections in the file, + output them now. */ + if (dir_lines[i].add_sections_before) + { + struct spec_section *spec; + struct spec_section **sections; + int n_sections = 0; + + /* Count the sections and allocate a vector for all of them. */ + for (spec = input_sections; spec; spec = spec->next) + n_sections++; + sections = ((struct spec_section **) + xmalloc (n_sections * sizeof (struct spec_section *))); + + /* Fill the vector SECTIONS with pointers to all the sections, + and sort them. */ + j = 0; + for (spec = input_sections; spec; spec = spec->next) + sections[j++] = spec; + qsort (sections, n_sections, sizeof (struct spec_section *), + compare_section_names); + + /* Generate the new sections in alphabetical order. + In each new section, output all of our entries. */ + for (j = 0; j < n_sections; j++) + { + spec = sections[j]; + if (spec->missing) + { + struct spec_entry *entry; + + putc ('\n', output); + fputs (spec->name, output); + putc ('\n', output); + for (entry = entries_to_add; entry; entry = entry->next) + fputs (entry->text, output); + } + } + + free (sections); + } + + /* Output the original dir lines unless marked for deletion. */ + if (i < dir_nlines && !dir_lines[i].delete) + { + fwrite (dir_lines[i].start, 1, dir_lines[i].size, output); + putc ('\n', output); + } + } + + fclose (output); + + exit (0); +} + +/* Read all of file FILNAME into memory + and return the address of the data. + Store the size into SIZEP. + If there is trouble, do a fatal error. */ + +char * +readfile (filename, sizep) + char *filename; + int *sizep; +{ + int data_size = 1024; + char *data = (char *) xmalloc (data_size); + int filled = 0; + int nread = 0; + + int desc = open (filename, O_RDONLY); + + if (desc < 0) + pfatal_with_name (filename); + + while (1) + { + nread = read (desc, data + filled, data_size - filled); + if (nread < 0) + pfatal_with_name (filename); + if (nread == 0) + break; + + filled += nread; + if (filled == data_size) + { + data_size *= 2; + data = (char *) xrealloc (data, data_size); + } + } + + *sizep = filled; + return data; +} + +/* Divide the text at DATA (of SIZE bytes) into lines. + Return a vector of struct line_data describing the lines. + Store the length of that vector into *NLINESP. */ + +struct line_data * +findlines (data, size, nlinesp) + char *data; + int size; + int *nlinesp; +{ + struct line_data *lines; + int lines_allocated = 512; + int filled = 0; + int i = 0; + int lineflag; + + lines = (struct line_data *) xmalloc (lines_allocated * sizeof (struct line_data)); + + lineflag = 1; + for (i = 0; i < size; i++) + { + if (lineflag) + { + if (filled == lines_allocated) + { + lines_allocated *= 2; + lines = (struct line_data *) xrealloc (lines, lines_allocated * sizeof (struct line_data)); + } + lines[filled].start = &data[i]; + lines[filled].add_entries_before = 0; + lines[filled].add_sections_before = 0; + lines[filled].delete = 0; + if (filled > 0) + lines[filled - 1].size + = lines[filled].start - lines[filled - 1].start - 1; + filled++; + } + lineflag = (data[i] == '\n'); + } + if (filled > 0) + lines[filled - 1].size = &data[i] - lines[filled - 1].start - lineflag; + + /* Do not leave garbage in the last element. */ + lines[filled].start = NULL; + lines[filled].add_entries_before = NULL; + lines[filled].add_sections_before = 0; + lines[filled].delete = 0; + lines[filled].size = 0; + + *nlinesp = filled; + return lines; +} + +/* Compare the menu item names in LINE1 (line length LEN1) + and LINE2 (line length LEN2). Return 1 if the item name + in LINE1 is less, 0 otherwise. */ + +int +menu_line_lessp (line1, len1, line2, len2) + char *line1; + int len1; + char *line2; + int len2; +{ + int minlen = (len1 < len2 ? len1 : len2); + int i; + + for (i = 0; i < minlen; i++) + { + /* If one item name is a prefix of the other, + the former one is less. */ + if (line1[i] == ':' && line2[i] != ':') + return 1; + if (line2[i] == ':' && line1[i] != ':') + return 0; + /* If they both continue and differ, one is less. */ + if (line1[i] < line2[i]) + return 1; + if (line1[i] > line2[i]) + return 0; + } + /* With a properly formatted dir file, + we can only get here if the item names are equal. */ + return 0; +} + +/* Compare the menu item names in LINE1 (line length LEN1) + and LINE2 (line length LEN2). Return 1 if the item names are equal, + 0 otherwise. */ + +int +menu_line_equal (line1, len1, line2, len2) + char *line1; + int len1; + char *line2; + int len2; +{ + int minlen = (len1 < len2 ? len1 : len2); + int i; + + for (i = 0; i < minlen; i++) + { + /* If both item names end here, they are equal. */ + if (line1[i] == ':' && line2[i] == ':') + return 1; + /* If they both continue and differ, one is less. */ + if (line1[i] != line2[i]) + return 0; + } + /* With a properly formatted dir file, + we can only get here if the item names are equal. */ + return 1; +} + +/* This is the comparison function for qsort + for a vector of pointers to struct spec_section. + Compare the section names. */ + +int +compare_section_names (sec1, sec2) + struct spec_section **sec1, **sec2; +{ + char *name1 = (*sec1)->name; + char *name2 = (*sec2)->name; + return strcmp (name1, name2); +} + +/* Insert ENTRY into the add_entries_before vector + for line number LINE_NUMBER of the dir file. + DIR_LINES and N_ENTRIES carry information from like-named variables + in main. */ + +void +insert_entry_here (entry, line_number, dir_lines, n_entries) + struct spec_entry *entry; + int line_number; + struct line_data *dir_lines; + int n_entries; +{ + int i; + + if (dir_lines[line_number].add_entries_before == 0) + { + dir_lines[line_number].add_entries_before + = (struct spec_entry **) xmalloc (n_entries * sizeof (struct spec_entry *)); + for (i = 0; i < n_entries; i++) + dir_lines[line_number].add_entries_before[i] = 0; + } + + for (i = 0; i < n_entries; i++) + if (dir_lines[line_number].add_entries_before[i] == 0) + break; + + if (i == n_entries) + abort (); + + dir_lines[line_number].add_entries_before[i] = entry; +} diff --git a/texinfo/util/mkinstalldirs b/texinfo/util/mkinstalldirs new file mode 100755 index 000000000000..934c67149230 --- /dev/null +++ b/texinfo/util/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1 1997/08/21 22:58:12 jason 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" 1>&2 + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/texinfo/util/tex3patch b/texinfo/util/tex3patch new file mode 100755 index 000000000000..1708c7588bbb --- /dev/null +++ b/texinfo/util/tex3patch @@ -0,0 +1,71 @@ +#!/bin/sh +# Auxiliary script to work around TeX 3.0 bug. ---- tex3patch ---- +# patches texinfo.tex in current directory, or in directory given as arg. + +ANYVERSION=no + +for arg in $1 $2 +do + case $arg in + --dammit | -d ) ANYVERSION=yes ;; + + * ) dir=$arg + esac +done + +if [ -z "$dir" ]; then + dir='.' +fi + +if [ \( 2 -lt $# \) -o \ + \( ! -f $dir/texinfo.tex \) ]; then + echo "To patch texinfo.tex for peaceful coexistence with Unix TeX 3.0," + echo "run $0" + echo "with no arguments in the same directory as texinfo.tex; or run" + echo " $0 DIRECTORY" + echo "(where DIRECTORY is a path leading to texinfo.tex)." + exit +fi + +if [ -z "$TMPDIR" ]; then + TMPDIR=/tmp +fi + +echo "Checking for \`dummy.tfm'" + +( cd $TMPDIR; tex '\relax \batchmode \font\foo=dummy \bye' ) + +grep -s '3.0' $TMPDIR/texput.log +if [ 1 = "$?" -a "$ANYVERSION" != "yes" ]; then + echo "You probably do not need this patch," + echo "since your TeX does not seem to be version 3.0." + echo "If you insist on applying the patch, run $0" + echo "again with the option \`--dammit'" + exit +fi + +grep -s 'file not found' $TMPDIR/texput.log +if [ 0 = $? ]; then + echo "This patch requires the dummy font metric file \`dummy.tfm'," + echo "which does not seem to be part of your TeX installation." + echo "Please get your TeX maintainer to install \`dummy.tfm'," + echo "then run this script again." + exit +fi +rm $TMPDIR/texput.log + +echo "Patching $dir/texinfo.tex" + +sed -e 's/%%*\\font\\nullfont/\\font\\nullfont/' \ + $dir/texinfo.tex >$TMPDIR/texinfo.tex +mv $dir/texinfo.tex $dir/texinfo.tex-distrib; mv $TMPDIR/texinfo.tex $dir + +if [ 0 = $? ]; then + echo "Patched $dir/texinfo.tex to avoid TeX 3.0 bug." + echo "The original version is saved as $dir/texinfo.tex-distrib." +else + echo "Patch failed. Sorry." +fi +----------------------------------------tex3patch ends + + diff --git a/texinfo/util/texi2dvi b/texinfo/util/texi2dvi new file mode 100755 index 000000000000..d9f1b3e1a51e --- /dev/null +++ b/texinfo/util/texi2dvi @@ -0,0 +1,367 @@ +#! /bin/sh +# texi2dvi --- smartly produce DVI files from texinfo sources + +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. + +# $Id: texi2dvi,v 1.1 1997/08/21 22:58:13 jason Exp $ + +# 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, you can either send email to this +# program's maintainer or write to: The Free Software Foundation, +# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. + +# Commentary: + +# Author: Noah Friedman + +# Please send bug reports, etc. to bug-texinfo@prep.ai.mit.edu +# If possible, please send a copy of the output of the script called with +# the `--debug' option when making a bug report. + +# In the interest of general portability, some common bourne shell +# constructs were avoided because they weren't guaranteed to be available +# in some earlier implementations. I've tried to make this program as +# portable as possible. Welcome to unix, where the lowest common +# denominator is rapidly diminishing. +# +# Among the more interesting lossages I noticed with some bourne shells +# are: +# * No shell functions. +# * No `unset' builtin. +# * `shift' cannot take a numeric argument, and signals an error if +# there are no arguments to shift. + +# Code: + +# Name by which this script was invoked. +progname=`echo "$0" | sed -e 's/[^\/]*\///g'` + +# This string is expanded by rcs automatically when this file is checked out. +rcs_revision='$Revision: 1.1 $' +version=`set - $rcs_revision; echo $2` + +# To prevent hairy quoting and escaping later. +bq='`' +eq="'" + +usage="Usage: $0 [OPTION]... FILE... +Run a Texinfo document through TeX. + +Options: +-D, --debug Turn on shell debugging ($bq${bq}set -x$eq$eq). +-t, --texinfo CMD Insert CMD after @setfilename before running TeX. +--verbose Report on what is done. +-h, --help Display this help and exit. +-v, --version Display version information and exit. + +The values of the TEX, TEXINDEX, and MAKEINFO environment variables are +used to run those commands, if they are set. + +Email bug reports to bug-texinfo@prep.ai.mit.edu. +" + +# Initialize variables. +# Don't use `unset' since old bourne shells don't have this command. +# Instead, assign them an empty value. +# Some of these, like TEX and TEXINDEX, may be inherited from the environment. +backup_extension=.bak # these files get deleted if all goes well. +debug= +orig_pwd="`pwd`" +textra= +verbose=false +makeinfo="${MAKEINFO-makeinfo}" +texindex="${TEXINDEX-texindex}" +tex="${TEX-tex}" + +# Save this so we can construct a new TEXINPUTS path for each file. +TEXINPUTS_orig="$TEXINPUTS" +export TEXINPUTS + +# Parse command line arguments. +# Make sure that all wildcarded options are long enough to be unambiguous. +# It's a good idea to document the full long option name in each case. +# Long options which take arguments will need a `*' appended to the +# canonical name to match the value appended after the `=' character. +while : ; do + case $# in 0) break ;; esac + case "$1" in + -D | --debug | --d* ) debug=t; shift ;; + -h | --help | --h* ) echo "$usage"; exit 0 ;; + # OK, we should do real option parsing here, but be lazy for now. + -t | --texinfo | --t*) shift; textra="$textra $1"; shift ;; + -v | --vers* ) + echo "$progname (Texinfo 3.9) $version" + echo "Copyright (C) 1996 Free Software Foundation, Inc. +There is NO warranty. You may redistribute this software +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING." + exit 0 ;; + --verb* ) verbose=echo; shift ;; + -- ) # Stop option processing + shift + break + ;; + -* ) + case "$1" in + --*=* ) arg=`echo "$1" | sed -e 's/=.*//'` ;; + * ) arg="$1" ;; + esac + exec 1>&2 + echo "$progname: Unknown or ambiguous option $bq$arg$eq." + echo "$progname: Try $bq--help$eq for more information." + exit 1 + ;; + * ) + break + ;; + esac +done + +# See if there are any command line args left (which will be interpreted as +# filename arguments). +if test $# -eq 0; then + exec 1>&2 + echo "$progname: At least one file name is required as an argument." + echo "$progname: Try $bq--help$eq for more information." + exit 2 +fi + +test "$debug" = t && set -x + +# Texify files +for command_line_filename in ${1+"$@"} ; do + $verbose "Processing $command_line_filename ..." + + # See if file exists. If it doesn't we're in trouble since, even + # though the user may be able to reenter a valid filename at the tex + # prompt (assuming they're attending the terminal), this script won't + # be able to find the right index files and so forth. + if test ! -r "${command_line_filename}" ; then + echo "$0: Could not read ${command_line_filename}." >&2 + continue + fi + + # Roughly equivalent to `dirname ...`, but more portable + directory="`echo ${command_line_filename} | sed 's/\/[^\/]*$//'`" + filename_texi="`basename ${command_line_filename}`" + # Strip off the last extension part (probably .texinfo or .texi) + filename_noext="`echo ${filename_texi} | sed 's/\.[^.]*$//'`" + + # Use same basename since we want to generate aux files with the same + # basename as the manual. Use extension .texi for the temp file so + # that TeX will ignore it. Thus, we must use a subdirectory. + # + # Output the macro-expanded file to here. + tmp_dir=${TMPDIR-/tmp}/$$ + filename_tmp=$tmp_dir/$filename_noext.texi + # Output the file with the user's extra commands to here. + filename_tmp2=$tmp_dir.2/$filename_noext.texi + mkdir $tmp_dir $tmp_dir.2 + + # If directory and file are the same, then it's probably because there's + # no pathname component. Set dirname to `.', the current directory. + if test "z${directory}" = "z${command_line_filename}" ; then + directory=. + fi + + # Source file might @include additional texinfo sources. Put `.' and + # directory where source file(s) reside in TEXINPUTS before anything + # else. `.' goes first to ensure that any old .aux, .cps, etc. files in + # ${directory} don't get used in preference to fresher files in `.'. + TEXINPUTS=".:${directory}:${TEXINPUTS_orig}" + + # Expand macro commands in the original source file using Makeinfo; + # the macro syntax bfox implemented is impossible to implement in TeX. + # Always use `end' footnote style, since the `separate' style + # generates different output (arguably this is a bug in -E). + # Discard main info output, the user asked to run TeX, not makeinfo. + # Redirect output to /dev/null to throw away `Making info file...' msg. + $verbose "Macro-expanding $command_line_filename to $filename_tmp ..." + $makeinfo --footnote-style=end -E $filename_tmp -o /dev/null \ + $command_line_filename >/dev/null + + # But if there were no macros, or makeinfo failed for some reason, + # just use the original file. (It shouldn't make any difference, but + # let's be safe.) + if test $? -ne 0 || cmp -s $filename_tmp $command_line_filename; then + $verbose "Reverting to $command_line_filename ..." + filename_input=$command_line_filename + else + filename_input=$filename_tmp + fi + + # Used most commonly for @finalout, @smallbook, etc. + if test -n "$textra"; then + $verbose "Inserting extra commands: $textra." + sed '/^@setfilename/a\ +'"$textra" $filename_input >$filename_tmp2 + filename_input=$filename_tmp2 + fi + + while true; do # will break out of loop below + # "Unset" variables that might have values from previous iterations and + # which won't be completely reset later. + definite_index_files= + + # Find all files having root filename with a two-letter extension, + # determine whether they're really index files, and save them. Foo.aux + # is actually the cross-references file, but we need to keep track of + # that too. + possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" + for this_file in ${possible_index_files} ; do + # If file is empty, forget it. + test -s "${this_file}" || continue + + # Examine first character of file. If it's not suitable to be an + # index or xref file, don't process it. + first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" + if test "x${first_character}" = "x\\" \ + || test "x${first_character}" = "x'"; then + definite_index_files="${definite_index_files} ${this_file}" + fi + done + orig_index_files="${definite_index_files}" + orig_index_files_sans_aux="`echo ${definite_index_files} \ + | sed 's/'${filename_noext}'\.aux//; + s/^[ ]*//;s/[ ]*$//;'`" + + # Now save copies of original index files so we have some means of + # comparison later. + $verbose "Backing up current index files: $orig_index_files ..." + for index_file_to_save in ${orig_index_files} ; do + cp "${index_file_to_save}" "${index_file_to_save}${backup_extension}" + done + + # Run texindex on current index files. If they already exist, and + # after running TeX a first time the index files don't change, then + # there's no reason to run TeX again. But we won't know that if the + # index files are out of date or nonexistent. + if test -n "${orig_index_files_sans_aux}" ; then + $verbose "Running $texindex $orig_index_files_sans_aux ..." + ${texindex} ${orig_index_files_sans_aux} + fi + + # Finally, run TeX. + $verbose "Running $tex $filename_input ..." + ${tex} "$filename_input" + + # Check if index files changed. + # + definite_index_files= + # Get list of new index files. + possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" + for this_file in ${possible_index_files} ; do + # If file is empty, forget it. + test -s "${this_file}" || continue + + # Examine first character of file. If it's not a backslash or + # single quote, then it's definitely not an index or xref file. + # (Will have to check for @ when we switch to Texinfo syntax in + # all these files...) + first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" + if test "x${first_character}" = "x\\" \ + || test "x${first_character}" = "x'"; then + definite_index_files="${definite_index_files} ${this_file}" + fi + done + new_index_files="${definite_index_files}" + new_index_files_sans_aux="`echo ${definite_index_files} \ + | sed 's/'${filename_noext}'\.aux//; + s/^[ ]*//;s/[ ]*$//;'`" + + # If old and new list don't at least have the same file list, then one + # file or another has definitely changed. + $verbose "Original index files =$orig_index_files" + $verbose "New index files =$new_index_files" + if test "z${orig_index_files}" != "z${new_index_files}" ; then + index_files_changed_p=t + else + # File list is the same. We must compare each file until we find a + # difference. + index_files_changed_p= + for this_file in ${new_index_files} ; do + $verbose "Comparing index file $this_file ..." + # cmp -s will return nonzero exit status if files differ. + cmp -s "${this_file}" "${this_file}${backup_extension}" + if test $? -ne 0 ; then + # We only need to keep comparing until we find *one* that + # differs, because we'll have to run texindex & tex no + # matter what. + index_files_changed_p=t + $verbose "Index file $this_file differed:" + test $verbose = echo \ + && diff -c "${this_file}${backup_extension}" "${this_file}" + break + fi + done + fi + + # If index files have changed since TeX has been run, or if the aux + # file wasn't present originally, run texindex and TeX again. + if test "${index_files_changed_p}" ; then :; else + # Nothing changed. We're done with TeX. + break + fi + done + + # Generate list of files to delete, then call rm once with the entire + # list. This is significantly faster than multiple executions of rm. + file_list= + for file in ${orig_index_files} ; do + file_list="${file_list} ${file}${backup_extension}" + done + if test -n "${file_list}" ; then + $verbose "Removing $file_list $tmp_dir $tmp_dir.2 ..." + rm -f ${file_list} + rm -rf $tmp_dir $tmp_dir.2 + fi +done + +$verbose "$0 done." +true # exit successfully. + +# texi2dvi ends here +# $Log: texi2dvi,v $ +# Revision 1.1 1997/08/21 22:58:13 jason +# Initial revision +# +# Revision 1.10 1996/10/04 18:21:55 karl +# Include only the current year in the copyright message. +# +# Revision 1.9 1996/10/04 11:49:48 karl +# Exit successfully. From arnold. +# +# Revision 1.8 1996/10/03 23:14:26 karl +# Only show diff if verbose. +# Update version number. +# +# Revision 1.7 1996/09/29 22:56:08 karl +# Use $progname instead of $0 for --version. +# +# Revision 1.6 1996/09/28 21:01:23 karl +# Recompute original index files each time through loop. +# Make indentation uniform. +# Use same basename for the temp input files. +# Standardize --version output. +# +# Revision 1.5 1996/09/26 14:46:34 karl +# (texi2dvi): Run TeX until the aux/index files stabilize, instead of just +# twice. From: David Shaw . +# +# Revision 1.4 1996/08/27 18:59:26 karl +# Include bug reporting address. +# +# Revision 1.3 1996/07/26 18:20:56 karl +# Do macro expansion with makeinfo before running TeX. +# Various expansion safety measures added for test; avoid use of -o. +# diff --git a/texinfo/util/texindex.c b/texinfo/util/texindex.c new file mode 100644 index 000000000000..306aa1fd601e --- /dev/null +++ b/texinfo/util/texindex.c @@ -0,0 +1,1793 @@ +/* Prepare TeX index dribble output into an actual index. + $Id: texindex.c,v 1.1 1997/08/21 22:58:13 jason Exp $ + + Copyright (C) 1987, 91, 92, 96 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. */ + +#include +#include +#include +#include "getopt.h" + +#define TEXINDEX_VERSION_STRING "GNU Texindex (Texinfo 3.9) 2.1" + +#if defined (emacs) +# include "../src/config.h" +/* Some s/os.h files redefine these. */ +# undef read +# undef close +# undef write +# undef open +#endif + +#if defined (HAVE_STRING_H) +# include +#endif /* HAVE_STRING_H */ + +#if !defined (HAVE_STRCHR) +char *strrchr (); +#endif /* !HAVE_STRCHR */ + +#if defined (STDC_HEADERS) +# include +#else /* !STDC_HEADERS */ +char *getenv (), *malloc (), *realloc (); +#endif /* !STDC_HEADERS */ + +#if defined (HAVE_UNISTD_H) +# include +#else /* !HAVE_UNISTD_H */ +off_t lseek (); +#endif /* !HAVE_UNISTD_H */ + +#if !defined (HAVE_MEMSET) +#undef memset +#define memset(ptr, ignore, count) bzero (ptr, count) +#endif + + +char *mktemp (); + +#if defined (VMS) +# include +# define TI_NO_ERROR ((1 << 28) | 1) +# define TI_FATAL_ERROR ((1 << 28) | 4) +# define unlink delete +#else /* !VMS */ +# if defined (HAVE_SYS_FCNTL_H) +# include +# include +# endif /* HAVE_SYS_FCNTL_H */ + +# if defined (_AIX) || !defined (_POSIX_VERSION) +# include +# else /* !AIX && _POSIX_VERSION */ +# if !defined (HAVE_SYS_FCNTL_H) +# include +# endif /* !HAVE_FCNTL_H */ +# endif /* !_AIX && _POSIX_VERSION */ +# define TI_NO_ERROR 0 +# define TI_FATAL_ERROR 1 +#endif /* !VMS */ + +#if !defined (SEEK_SET) +# define SEEK_SET 0 +# define SEEK_CUR 1 +# define SEEK_END 2 +#endif /* !SEEK_SET */ + +#ifndef errno +extern int errno; +#endif +#ifndef strerror +extern char *strerror (); +#endif + +/* When sorting in core, this structure describes one line + and the position and length of its first keyfield. */ +struct lineinfo +{ + char *text; /* The actual text of the line. */ + union { + char *text; /* The start of the key (for textual comparison). */ + long number; /* The numeric value (for numeric comparison). */ + } key; + long keylen; /* Length of KEY field. */ +}; + +/* This structure describes a field to use as a sort key. */ +struct keyfield +{ + int startwords; /* Number of words to skip. */ + int startchars; /* Number of additional chars to skip. */ + int endwords; /* Number of words to ignore at end. */ + int endchars; /* Ditto for characters of last word. */ + char ignore_blanks; /* Non-zero means ignore spaces and tabs. */ + char fold_case; /* Non-zero means case doesn't matter. */ + char reverse; /* Non-zero means compare in reverse order. */ + char numeric; /* Non-zeros means field is ASCII numeric. */ + char positional; /* Sort according to file position. */ + char braced; /* Count balanced-braced groupings as fields. */ +}; + +/* Vector of keyfields to use. */ +struct keyfield keyfields[3]; + +/* Number of keyfields stored in that vector. */ +int num_keyfields = 3; + +/* Vector of input file names, terminated with a null pointer. */ +char **infiles; + +/* Vector of corresponding output file names, or NULL, meaning default it + (add an `s' to the end). */ +char **outfiles; + +/* Length of `infiles'. */ +int num_infiles; + +/* Pointer to the array of pointers to lines being sorted. */ +char **linearray; + +/* The allocated length of `linearray'. */ +long nlines; + +/* Directory to use for temporary files. On Unix, it ends with a slash. */ +char *tempdir; + +/* Start of filename to use for temporary files. */ +char *tempbase; + +/* Number of last temporary file. */ +int tempcount; + +/* Number of last temporary file already deleted. + Temporary files are deleted by `flush_tempfiles' in order of creation. */ +int last_deleted_tempcount; + +/* During in-core sort, this points to the base of the data block + which contains all the lines of data. */ +char *text_base; + +/* Additional command switches .*/ + +/* Nonzero means do not delete tempfiles -- for debugging. */ +int keep_tempfiles; + +/* The name this program was run with. */ +char *program_name; + +/* Forward declarations of functions in this file. */ + +void decode_command (); +void sort_in_core (); +void sort_offline (); +char **parsefile (); +char *find_field (); +char *find_pos (); +long find_value (); +char *find_braced_pos (); +char *find_braced_end (); +void writelines (); +int compare_field (); +int compare_full (); +long readline (); +int merge_files (); +int merge_direct (); +void pfatal_with_name (); +void fatal (); +void error (); +void *xmalloc (), *xrealloc (); +char *concat (); +char *maketempname (); +void flush_tempfiles (); +char *tempcopy (); + +#define MAX_IN_CORE_SORT 500000 + +int +main (argc, argv) + int argc; + char **argv; +{ + int i; + + tempcount = 0; + last_deleted_tempcount = 0; + + program_name = strrchr (argv[0], '/'); + if (program_name != (char *)NULL) + program_name++; + else + program_name = argv[0]; + + /* Describe the kind of sorting to do. */ + /* The first keyfield uses the first braced field and folds case. */ + keyfields[0].braced = 1; + keyfields[0].fold_case = 1; + keyfields[0].endwords = -1; + keyfields[0].endchars = -1; + + /* The second keyfield uses the second braced field, numerically. */ + keyfields[1].braced = 1; + keyfields[1].numeric = 1; + keyfields[1].startwords = 1; + keyfields[1].endwords = -1; + keyfields[1].endchars = -1; + + /* The third keyfield (which is ignored while discarding duplicates) + compares the whole line. */ + keyfields[2].endwords = -1; + keyfields[2].endchars = -1; + + decode_command (argc, argv); + + tempbase = mktemp (concat ("txiXXXXXX", "", "")); + + /* Process input files completely, one by one. */ + + for (i = 0; i < num_infiles; i++) + { + int desc; + long ptr; + char *outfile; + + desc = open (infiles[i], O_RDONLY, 0); + if (desc < 0) + pfatal_with_name (infiles[i]); + lseek (desc, (off_t) 0, SEEK_END); + ptr = (long) lseek (desc, (off_t) 0, SEEK_CUR); + + close (desc); + + outfile = outfiles[i]; + if (!outfile) + { + outfile = concat (infiles[i], "s", ""); + } + + if (ptr < MAX_IN_CORE_SORT) + /* Sort a small amount of data. */ + sort_in_core (infiles[i], ptr, outfile); + else + sort_offline (infiles[i], ptr, outfile); + } + + flush_tempfiles (tempcount); + exit (TI_NO_ERROR); +} + +typedef struct +{ + char *long_name; + char *short_name; + int *variable_ref; + int variable_value; + char *arg_name; + char *doc_string; +} TEXINDEX_OPTION; + +TEXINDEX_OPTION texindex_options[] = { + { "--keep", "-k", &keep_tempfiles, 1, (char *)NULL, + "keep temporary files around after processing" }, + { "--no-keep", 0, &keep_tempfiles, 0, (char *)NULL, + "do not keep temporary files around after processing (default)" }, + { "--output", "-o", (int *)NULL, 0, "FILE", + "send output to FILE" }, + { "--version", (char *)NULL, (int *)NULL, 0, (char *)NULL, + "display version information and exit" }, + { "--help", "-h", (int *)NULL, 0, (char *)NULL, + "display this help and exit" }, + { (char *)NULL, (char *)NULL, (int *)NULL, 0, (char *)NULL } +}; + +void +usage (result_value) + int result_value; +{ + register int i; + FILE *f = result_value ? stderr : stdout; + + fprintf (f, "Usage: %s [OPTION]... FILE...\n", program_name); + fprintf (f, "Generate a sorted index for each TeX output FILE.\n"); + /* Avoid trigraph nonsense. */ + fprintf (f, "Usually FILE... is `foo.??\' for a document `foo.texi'.\n"); + fprintf (f, "\nOptions:\n"); + + for (i = 0; texindex_options[i].long_name; i++) + { + if (texindex_options[i].short_name) + fprintf (f, "%s, ", texindex_options[i].short_name); + + fprintf (f, "%s %s", + texindex_options[i].long_name, + texindex_options[i].arg_name + ? texindex_options[i].arg_name : ""); + + fprintf (f, "\t%s\n", texindex_options[i].doc_string); + } + puts ("\nEmail bug reports to bug-texinfo@prep.ai.mit.edu."); + + exit (result_value); +} + +/* Decode the command line arguments to set the parameter variables + and set up the vector of keyfields and the vector of input files. */ + +void +decode_command (argc, argv) + int argc; + char **argv; +{ + int arg_index = 1; + int optc; + char **ip; + char **op; + + /* Store default values into parameter variables. */ + + tempdir = getenv ("TMPDIR"); +#ifdef VMS + if (tempdir == NULL) + tempdir = "sys$scratch:"; +#else + if (tempdir == NULL) + tempdir = "/tmp/"; + else + tempdir = concat (tempdir, "/", ""); +#endif + + keep_tempfiles = 0; + + /* Allocate ARGC input files, which must be enough. */ + + infiles = (char **) xmalloc (argc * sizeof (char *)); + outfiles = (char **) xmalloc (argc * sizeof (char *)); + ip = infiles; + op = outfiles; + + while (arg_index < argc) + { + char *arg = argv[arg_index++]; + + if (*arg == '-') + { + if (strcmp (arg, "--version") == 0) + { + puts (TEXINDEX_VERSION_STRING); +puts ("Copyright (C) 1996 Free Software Foundation, Inc.\n\ +There is NO warranty. You may redistribute this software\n\ +under the terms of the GNU General Public License.\n\ +For more information about these matters, see the files named COPYING."); + exit (0); + } + else if ((strcmp (arg, "--keep") == 0) || + (strcmp (arg, "-k") == 0)) + { + keep_tempfiles = 1; + } + else if ((strcmp (arg, "--help") == 0) || + (strcmp (arg, "-h") == 0)) + { + usage (0); + } + else if ((strcmp (arg, "--output") == 0) || + (strcmp (arg, "-o") == 0)) + { + if (argv[arg_index] != (char *)NULL) + { + arg_index++; + if (op > outfiles) + *(op - 1) = argv[arg_index]; + } + else + usage (1); + } + else + usage (1); + } + else + { + *ip++ = arg; + *op++ = (char *)NULL; + } + } + + /* Record number of keyfields and terminate list of filenames. */ + num_infiles = ip - infiles; + *ip = (char *)NULL; + if (num_infiles == 0) + usage (1); +} + +/* Return a name for a temporary file. */ + +char * +maketempname (count) + int count; +{ + char tempsuffix[10]; + sprintf (tempsuffix, "%d", count); + return concat (tempdir, tempbase, tempsuffix); +} + +/* Delete all temporary files up to TO_COUNT. */ + +void +flush_tempfiles (to_count) + int to_count; +{ + if (keep_tempfiles) + return; + while (last_deleted_tempcount < to_count) + unlink (maketempname (++last_deleted_tempcount)); +} + +/* Copy the input file open on IDESC into a temporary file + and return the temporary file name. */ + +#define BUFSIZE 1024 + +char * +tempcopy (idesc) + int idesc; +{ + char *outfile = maketempname (++tempcount); + int odesc; + char buffer[BUFSIZE]; + + odesc = open (outfile, O_WRONLY | O_CREAT, 0666); + + if (odesc < 0) + pfatal_with_name (outfile); + + while (1) + { + int nread = read (idesc, buffer, BUFSIZE); + write (odesc, buffer, nread); + if (!nread) + break; + } + + close (odesc); + + return outfile; +} + +/* Compare LINE1 and LINE2 according to the specified set of keyfields. */ + +int +compare_full (line1, line2) + char **line1, **line2; +{ + int i; + + /* Compare using the first keyfield; + if that does not distinguish the lines, try the second keyfield; + and so on. */ + + for (i = 0; i < num_keyfields; i++) + { + long length1, length2; + char *start1 = find_field (&keyfields[i], *line1, &length1); + char *start2 = find_field (&keyfields[i], *line2, &length2); + int tem = compare_field (&keyfields[i], start1, length1, *line1 - text_base, + start2, length2, *line2 - text_base); + if (tem) + { + if (keyfields[i].reverse) + return -tem; + return tem; + } + } + + return 0; /* Lines match exactly. */ +} + +/* Compare LINE1 and LINE2, described by structures + in which the first keyfield is identified in advance. + For positional sorting, assumes that the order of the lines in core + reflects their nominal order. */ + +int +compare_prepared (line1, line2) + struct lineinfo *line1, *line2; +{ + int i; + int tem; + char *text1, *text2; + + /* Compare using the first keyfield, which has been found for us already. */ + if (keyfields->positional) + { + if (line1->text - text_base > line2->text - text_base) + tem = 1; + else + tem = -1; + } + else if (keyfields->numeric) + tem = line1->key.number - line2->key.number; + else + tem = compare_field (keyfields, line1->key.text, line1->keylen, 0, + line2->key.text, line2->keylen, 0); + if (tem) + { + if (keyfields->reverse) + return -tem; + return tem; + } + + text1 = line1->text; + text2 = line2->text; + + /* Compare using the second keyfield; + if that does not distinguish the lines, try the third keyfield; + and so on. */ + + for (i = 1; i < num_keyfields; i++) + { + long length1, length2; + char *start1 = find_field (&keyfields[i], text1, &length1); + char *start2 = find_field (&keyfields[i], text2, &length2); + int tem = compare_field (&keyfields[i], start1, length1, text1 - text_base, + start2, length2, text2 - text_base); + if (tem) + { + if (keyfields[i].reverse) + return -tem; + return tem; + } + } + + return 0; /* Lines match exactly. */ +} + +/* Like compare_full but more general. + You can pass any strings, and you can say how many keyfields to use. + POS1 and POS2 should indicate the nominal positional ordering of + the two lines in the input. */ + +int +compare_general (str1, str2, pos1, pos2, use_keyfields) + char *str1, *str2; + long pos1, pos2; + int use_keyfields; +{ + int i; + + /* Compare using the first keyfield; + if that does not distinguish the lines, try the second keyfield; + and so on. */ + + for (i = 0; i < use_keyfields; i++) + { + long length1, length2; + char *start1 = find_field (&keyfields[i], str1, &length1); + char *start2 = find_field (&keyfields[i], str2, &length2); + int tem = compare_field (&keyfields[i], start1, length1, pos1, + start2, length2, pos2); + if (tem) + { + if (keyfields[i].reverse) + return -tem; + return tem; + } + } + + return 0; /* Lines match exactly. */ +} + +/* Find the start and length of a field in STR according to KEYFIELD. + A pointer to the starting character is returned, and the length + is stored into the int that LENGTHPTR points to. */ + +char * +find_field (keyfield, str, lengthptr) + struct keyfield *keyfield; + char *str; + long *lengthptr; +{ + char *start; + char *end; + char *(*fun) (); + + if (keyfield->braced) + fun = find_braced_pos; + else + fun = find_pos; + + start = (*fun) (str, keyfield->startwords, keyfield->startchars, + keyfield->ignore_blanks); + if (keyfield->endwords < 0) + { + if (keyfield->braced) + end = find_braced_end (start); + else + { + end = start; + while (*end && *end != '\n') + end++; + } + } + else + { + end = (*fun) (str, keyfield->endwords, keyfield->endchars, 0); + if (end - str < start - str) + end = start; + } + *lengthptr = end - start; + return start; +} + +/* Return a pointer to a specified place within STR, + skipping (from the beginning) WORDS words and then CHARS chars. + If IGNORE_BLANKS is nonzero, we skip all blanks + after finding the specified word. */ + +char * +find_pos (str, words, chars, ignore_blanks) + char *str; + int words, chars; + int ignore_blanks; +{ + int i; + char *p = str; + + for (i = 0; i < words; i++) + { + char c; + /* Find next bunch of nonblanks and skip them. */ + while ((c = *p) == ' ' || c == '\t') + p++; + while ((c = *p) && c != '\n' && !(c == ' ' || c == '\t')) + p++; + if (!*p || *p == '\n') + return p; + } + + while (*p == ' ' || *p == '\t') + p++; + + for (i = 0; i < chars; i++) + { + if (!*p || *p == '\n') + break; + p++; + } + return p; +} + +/* Like find_pos but assumes that each field is surrounded by braces + and that braces within fields are balanced. */ + +char * +find_braced_pos (str, words, chars, ignore_blanks) + char *str; + int words, chars; + int ignore_blanks; +{ + int i; + int bracelevel; + char *p = str; + char c; + + for (i = 0; i < words; i++) + { + bracelevel = 1; + while ((c = *p++) != '{' && c != '\n' && c) + /* Do nothing. */ ; + if (c != '{') + return p - 1; + while (bracelevel) + { + c = *p++; + if (c == '{') + bracelevel++; + if (c == '}') + bracelevel--; + if (c == 0 || c == '\n') + return p - 1; + } + } + + while ((c = *p++) != '{' && c != '\n' && c) + /* Do nothing. */ ; + + if (c != '{') + return p - 1; + + if (ignore_blanks) + while ((c = *p) == ' ' || c == '\t') + p++; + + for (i = 0; i < chars; i++) + { + if (!*p || *p == '\n') + break; + p++; + } + return p; +} + +/* Find the end of the balanced-brace field which starts at STR. + The position returned is just before the closing brace. */ + +char * +find_braced_end (str) + char *str; +{ + int bracelevel; + char *p = str; + char c; + + bracelevel = 1; + while (bracelevel) + { + c = *p++; + if (c == '{') + bracelevel++; + if (c == '}') + bracelevel--; + if (c == 0 || c == '\n') + return p - 1; + } + return p - 1; +} + +long +find_value (start, length) + char *start; + long length; +{ + while (length != 0L) + { + if (isdigit (*start)) + return atol (start); + length--; + start++; + } + return 0l; +} + +/* Vector used to translate characters for comparison. + This is how we make all alphanumerics follow all else, + and ignore case in the first sorting. */ +int char_order[256]; + +void +init_char_order () +{ + int i; + for (i = 1; i < 256; i++) + char_order[i] = i; + + for (i = '0'; i <= '9'; i++) + char_order[i] += 512; + + for (i = 'a'; i <= 'z'; i++) + { + char_order[i] = 512 + i; + char_order[i + 'A' - 'a'] = 512 + i; + } +} + +/* Compare two fields (each specified as a start pointer and a character count) + according to KEYFIELD. + The sign of the value reports the relation between the fields. */ + +int +compare_field (keyfield, start1, length1, pos1, start2, length2, pos2) + struct keyfield *keyfield; + char *start1; + long length1; + long pos1; + char *start2; + long length2; + long pos2; +{ + if (keyfields->positional) + { + if (pos1 > pos2) + return 1; + else + return -1; + } + if (keyfield->numeric) + { + long value = find_value (start1, length1) - find_value (start2, length2); + if (value > 0) + return 1; + if (value < 0) + return -1; + return 0; + } + else + { + char *p1 = start1; + char *p2 = start2; + char *e1 = start1 + length1; + char *e2 = start2 + length2; + + while (1) + { + int c1, c2; + + if (p1 == e1) + c1 = 0; + else + c1 = *p1++; + if (p2 == e2) + c2 = 0; + else + c2 = *p2++; + + if (char_order[c1] != char_order[c2]) + return char_order[c1] - char_order[c2]; + if (!c1) + break; + } + + /* Strings are equal except possibly for case. */ + p1 = start1; + p2 = start2; + while (1) + { + int c1, c2; + + if (p1 == e1) + c1 = 0; + else + c1 = *p1++; + if (p2 == e2) + c2 = 0; + else + c2 = *p2++; + + if (c1 != c2) + /* Reverse sign here so upper case comes out last. */ + return c2 - c1; + if (!c1) + break; + } + + return 0; + } +} + +/* A `struct linebuffer' is a structure which holds a line of text. + `readline' reads a line from a stream into a linebuffer + and works regardless of the length of the line. */ + +struct linebuffer +{ + long size; + char *buffer; +}; + +/* Initialize LINEBUFFER for use. */ + +void +initbuffer (linebuffer) + struct linebuffer *linebuffer; +{ + linebuffer->size = 200; + linebuffer->buffer = (char *) xmalloc (200); +} + +/* Read a line of text from STREAM into LINEBUFFER. + Return the length of the line. */ + +long +readline (linebuffer, stream) + struct linebuffer *linebuffer; + FILE *stream; +{ + char *buffer = linebuffer->buffer; + char *p = linebuffer->buffer; + char *end = p + linebuffer->size; + + while (1) + { + int c = getc (stream); + if (p == end) + { + buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); + p += buffer - linebuffer->buffer; + end += buffer - linebuffer->buffer; + linebuffer->buffer = buffer; + } + if (c < 0 || c == '\n') + { + *p = 0; + break; + } + *p++ = c; + } + + return p - buffer; +} + +/* Sort an input file too big to sort in core. */ + +void +sort_offline (infile, nfiles, total, outfile) + char *infile; + int nfiles; + long total; + char *outfile; +{ + /* More than enough. */ + int ntemps = 2 * (total + MAX_IN_CORE_SORT - 1) / MAX_IN_CORE_SORT; + char **tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); + FILE *istream = fopen (infile, "r"); + int i; + struct linebuffer lb; + long linelength; + int failure = 0; + + initbuffer (&lb); + + /* Read in one line of input data. */ + + linelength = readline (&lb, istream); + + if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') + { + error ("%s: not a texinfo index file", infile); + return; + } + + /* Split up the input into `ntemps' temporary files, or maybe fewer, + and put the new files' names into `tempfiles' */ + + for (i = 0; i < ntemps; i++) + { + char *outname = maketempname (++tempcount); + FILE *ostream = fopen (outname, "w"); + long tempsize = 0; + + if (!ostream) + pfatal_with_name (outname); + tempfiles[i] = outname; + + /* Copy lines into this temp file as long as it does not make file + "too big" or until there are no more lines. */ + + while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT) + { + tempsize += linelength + 1; + fputs (lb.buffer, ostream); + putc ('\n', ostream); + + /* Read another line of input data. */ + + linelength = readline (&lb, istream); + if (!linelength && feof (istream)) + break; + + if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') + { + error ("%s: not a texinfo index file", infile); + failure = 1; + goto fail; + } + } + fclose (ostream); + if (feof (istream)) + break; + } + + free (lb.buffer); + +fail: + /* Record number of temp files we actually needed. */ + + ntemps = i; + + /* Sort each tempfile into another tempfile. + Delete the first set of tempfiles and put the names of the second + into `tempfiles'. */ + + for (i = 0; i < ntemps; i++) + { + char *newtemp = maketempname (++tempcount); + sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp); + if (!keep_tempfiles) + unlink (tempfiles[i]); + tempfiles[i] = newtemp; + } + + if (failure) + return; + + /* Merge the tempfiles together and indexify. */ + + merge_files (tempfiles, ntemps, outfile); +} + +/* Sort INFILE, whose size is TOTAL, + assuming that is small enough to be done in-core, + then indexify it and send the output to OUTFILE (or to stdout). */ + +void +sort_in_core (infile, total, outfile) + char *infile; + long total; + char *outfile; +{ + char **nextline; + char *data = (char *) xmalloc (total + 1); + char *file_data; + long file_size; + int i; + FILE *ostream = stdout; + struct lineinfo *lineinfo; + + /* Read the contents of the file into the moby array `data'. */ + + int desc = open (infile, O_RDONLY, 0); + + if (desc < 0) + fatal ("failure reopening %s", infile); + for (file_size = 0;;) + { + i = read (desc, data + file_size, total - file_size); + if (i <= 0) + break; + file_size += i; + } + file_data = data; + data[file_size] = 0; + + close (desc); + + if (file_size > 0 && data[0] != '\\' && data[0] != '@') + { + error ("%s: not a texinfo index file", infile); + return; + } + + init_char_order (); + + /* Sort routines want to know this address. */ + + text_base = data; + + /* Create the array of pointers to lines, with a default size + frequently enough. */ + + nlines = total / 50; + if (!nlines) + nlines = 2; + linearray = (char **) xmalloc (nlines * sizeof (char *)); + + /* `nextline' points to the next free slot in this array. + `nlines' is the allocated size. */ + + nextline = linearray; + + /* Parse the input file's data, and make entries for the lines. */ + + nextline = parsefile (infile, nextline, file_data, file_size); + if (nextline == 0) + { + error ("%s: not a texinfo index file", infile); + return; + } + + /* Sort the lines. */ + + /* If we have enough space, find the first keyfield of each line in advance. + Make a `struct lineinfo' for each line, which records the keyfield + as well as the line, and sort them. */ + + lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo)); + + if (lineinfo) + { + struct lineinfo *lp; + char **p; + + for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) + { + lp->text = *p; + lp->key.text = find_field (keyfields, *p, &lp->keylen); + if (keyfields->numeric) + lp->key.number = find_value (lp->key.text, lp->keylen); + } + + qsort (lineinfo, nextline - linearray, sizeof (struct lineinfo), + compare_prepared); + + for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) + *p = lp->text; + + free (lineinfo); + } + else + qsort (linearray, nextline - linearray, sizeof (char *), compare_full); + + /* Open the output file. */ + + if (outfile) + { + ostream = fopen (outfile, "w"); + if (!ostream) + pfatal_with_name (outfile); + } + + writelines (linearray, nextline - linearray, ostream); + if (outfile) + fclose (ostream); + + free (linearray); + free (data); +} + +/* Parse an input string in core into lines. + DATA is the input string, and SIZE is its length. + Data goes in LINEARRAY starting at NEXTLINE. + The value returned is the first entry in LINEARRAY still unused. + Value 0 means input file contents are invalid. */ + +char ** +parsefile (filename, nextline, data, size) + char *filename; + char **nextline; + char *data; + long size; +{ + char *p, *end; + char **line = nextline; + + p = data; + end = p + size; + *end = 0; + + while (p != end) + { + if (p[0] != '\\' && p[0] != '@') + return 0; + + *line = p; + while (*p && *p != '\n') + p++; + if (p != end) + p++; + + line++; + if (line == linearray + nlines) + { + char **old = linearray; + linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); + line += linearray - old; + } + } + + return line; +} + +/* Indexification is a filter applied to the sorted lines + as they are being written to the output file. + Multiple entries for the same name, with different page numbers, + get combined into a single entry with multiple page numbers. + The first braced field, which is used for sorting, is discarded. + However, its first character is examined, folded to lower case, + and if it is different from that in the previous line fed to us + a \initial line is written with one argument, the new initial. + + If an entry has four braced fields, then the second and third + constitute primary and secondary names. + In this case, each change of primary name + generates a \primary line which contains only the primary name, + and in between these are \secondary lines which contain + just a secondary name and page numbers. */ + +/* The last primary name we wrote a \primary entry for. + If only one level of indexing is being done, this is the last name seen. */ +char *lastprimary; +/* Length of storage allocated for lastprimary. */ +int lastprimarylength; + +/* Similar, for the secondary name. */ +char *lastsecondary; +int lastsecondarylength; + +/* Zero if we are not in the middle of writing an entry. + One if we have written the beginning of an entry but have not + yet written any page numbers into it. + Greater than one if we have written the beginning of an entry + plus at least one page number. */ +int pending; + +/* The initial (for sorting purposes) of the last primary entry written. + When this changes, a \initial {c} line is written */ + +char *lastinitial; + +int lastinitiallength; + +/* When we need a string of length 1 for the value of lastinitial, + store it here. */ + +char lastinitial1[2]; + +/* Initialize static storage for writing an index. */ + +void +init_index () +{ + pending = 0; + lastinitial = lastinitial1; + lastinitial1[0] = 0; + lastinitial1[1] = 0; + lastinitiallength = 0; + lastprimarylength = 100; + lastprimary = (char *) xmalloc (lastprimarylength + 1); + memset (lastprimary, '\0', lastprimarylength + 1); + lastsecondarylength = 100; + lastsecondary = (char *) xmalloc (lastsecondarylength + 1); + memset (lastsecondary, '\0', lastsecondarylength + 1); +} + +/* Indexify. Merge entries for the same name, + insert headers for each initial character, etc. */ + +void +indexify (line, ostream) + char *line; + FILE *ostream; +{ + char *primary, *secondary, *pagenumber; + int primarylength, secondarylength = 0, pagelength; + int nosecondary; + int initiallength; + char *initial; + char initial1[2]; + register char *p; + + /* First, analyze the parts of the entry fed to us this time. */ + + p = find_braced_pos (line, 0, 0, 0); + if (*p == '{') + { + initial = p; + /* Get length of inner pair of braces starting at `p', + including that inner pair of braces. */ + initiallength = find_braced_end (p + 1) + 1 - p; + } + else + { + initial = initial1; + initial1[0] = *p; + initial1[1] = 0; + initiallength = 1; + + if (initial1[0] >= 'a' && initial1[0] <= 'z') + initial1[0] -= 040; + } + + pagenumber = find_braced_pos (line, 1, 0, 0); + pagelength = find_braced_end (pagenumber) - pagenumber; + if (pagelength == 0) + abort (); + + primary = find_braced_pos (line, 2, 0, 0); + primarylength = find_braced_end (primary) - primary; + + secondary = find_braced_pos (line, 3, 0, 0); + nosecondary = !*secondary; + if (!nosecondary) + secondarylength = find_braced_end (secondary) - secondary; + + /* If the primary is different from before, make a new primary entry. */ + if (strncmp (primary, lastprimary, primarylength)) + { + /* Close off current secondary entry first, if one is open. */ + if (pending) + { + fputs ("}\n", ostream); + pending = 0; + } + + /* If this primary has a different initial, include an entry for + the initial. */ + if (initiallength != lastinitiallength || + strncmp (initial, lastinitial, initiallength)) + { + fprintf (ostream, "\\initial {"); + fwrite (initial, 1, initiallength, ostream); + fprintf (ostream, "}\n", initial); + if (initial == initial1) + { + lastinitial = lastinitial1; + *lastinitial1 = *initial1; + } + else + { + lastinitial = initial; + } + lastinitiallength = initiallength; + } + + /* Make the entry for the primary. */ + if (nosecondary) + fputs ("\\entry {", ostream); + else + fputs ("\\primary {", ostream); + fwrite (primary, primarylength, 1, ostream); + if (nosecondary) + { + fputs ("}{", ostream); + pending = 1; + } + else + fputs ("}\n", ostream); + + /* Record name of most recent primary. */ + if (lastprimarylength < primarylength) + { + lastprimarylength = primarylength + 100; + lastprimary = (char *) xrealloc (lastprimary, + 1 + lastprimarylength); + } + strncpy (lastprimary, primary, primarylength); + lastprimary[primarylength] = 0; + + /* There is no current secondary within this primary, now. */ + lastsecondary[0] = 0; + } + + /* Should not have an entry with no subtopic following one with a subtopic. */ + + if (nosecondary && *lastsecondary) + error ("entry %s follows an entry with a secondary name", line); + + /* Start a new secondary entry if necessary. */ + if (!nosecondary && strncmp (secondary, lastsecondary, secondarylength)) + { + if (pending) + { + fputs ("}\n", ostream); + pending = 0; + } + + /* Write the entry for the secondary. */ + fputs ("\\secondary {", ostream); + fwrite (secondary, secondarylength, 1, ostream); + fputs ("}{", ostream); + pending = 1; + + /* Record name of most recent secondary. */ + if (lastsecondarylength < secondarylength) + { + lastsecondarylength = secondarylength + 100; + lastsecondary = (char *) xrealloc (lastsecondary, + 1 + lastsecondarylength); + } + strncpy (lastsecondary, secondary, secondarylength); + lastsecondary[secondarylength] = 0; + } + + /* Here to add one more page number to the current entry. */ + if (pending++ != 1) + fputs (", ", ostream); /* Punctuate first, if this is not the first. */ + fwrite (pagenumber, pagelength, 1, ostream); +} + +/* Close out any unfinished output entry. */ + +void +finish_index (ostream) + FILE *ostream; +{ + if (pending) + fputs ("}\n", ostream); + free (lastprimary); + free (lastsecondary); +} + +/* Copy the lines in the sorted order. + Each line is copied out of the input file it was found in. */ + +void +writelines (linearray, nlines, ostream) + char **linearray; + int nlines; + FILE *ostream; +{ + char **stop_line = linearray + nlines; + char **next_line; + + init_index (); + + /* Output the text of the lines, and free the buffer space. */ + + for (next_line = linearray; next_line != stop_line; next_line++) + { + /* If -u was specified, output the line only if distinct from previous one. */ + if (next_line == linearray + /* Compare previous line with this one, using only the + explicitly specd keyfields. */ + || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1)) + { + char *p = *next_line; + char c; + + while ((c = *p++) && c != '\n') + /* Do nothing. */ ; + *(p - 1) = 0; + indexify (*next_line, ostream); + } + } + + finish_index (ostream); +} + +/* Assume (and optionally verify) that each input file is sorted; + merge them and output the result. + Returns nonzero if any input file fails to be sorted. + + This is the high-level interface that can handle an unlimited + number of files. */ + +#define MAX_DIRECT_MERGE 10 + +int +merge_files (infiles, nfiles, outfile) + char **infiles; + int nfiles; + char *outfile; +{ + char **tempfiles; + int ntemps; + int i; + int value = 0; + int start_tempcount = tempcount; + + if (nfiles <= MAX_DIRECT_MERGE) + return merge_direct (infiles, nfiles, outfile); + + /* Merge groups of MAX_DIRECT_MERGE input files at a time, + making a temporary file to hold each group's result. */ + + ntemps = (nfiles + MAX_DIRECT_MERGE - 1) / MAX_DIRECT_MERGE; + tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); + for (i = 0; i < ntemps; i++) + { + int nf = MAX_DIRECT_MERGE; + if (i + 1 == ntemps) + nf = nfiles - i * MAX_DIRECT_MERGE; + tempfiles[i] = maketempname (++tempcount); + value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]); + } + + /* All temporary files that existed before are no longer needed + since their contents have been merged into our new tempfiles. + So delete them. */ + flush_tempfiles (start_tempcount); + + /* Now merge the temporary files we created. */ + + merge_files (tempfiles, ntemps, outfile); + + free (tempfiles); + + return value; +} + +/* Assume (and optionally verify) that each input file is sorted; + merge them and output the result. + Returns nonzero if any input file fails to be sorted. + + This version of merging will not work if the number of + input files gets too high. Higher level functions + use it only with a bounded number of input files. */ + +int +merge_direct (infiles, nfiles, outfile) + char **infiles; + int nfiles; + char *outfile; +{ + struct linebuffer *lb1, *lb2; + struct linebuffer **thisline, **prevline; + FILE **streams; + int i; + int nleft; + int lossage = 0; + int *file_lossage; + struct linebuffer *prev_out = 0; + FILE *ostream = stdout; + + if (outfile) + { + ostream = fopen (outfile, "w"); + } + if (!ostream) + pfatal_with_name (outfile); + + init_index (); + + if (nfiles == 0) + { + if (outfile) + fclose (ostream); + return 0; + } + + /* For each file, make two line buffers. + Also, for each file, there is an element of `thisline' + which points at any time to one of the file's two buffers, + and an element of `prevline' which points to the other buffer. + `thisline' is supposed to point to the next available line from the file, + while `prevline' holds the last file line used, + which is remembered so that we can verify that the file is properly sorted. */ + + /* lb1 and lb2 contain one buffer each per file. */ + lb1 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); + lb2 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); + + /* thisline[i] points to the linebuffer holding the next available line in file i, + or is zero if there are no lines left in that file. */ + thisline = (struct linebuffer **) + xmalloc (nfiles * sizeof (struct linebuffer *)); + /* prevline[i] points to the linebuffer holding the last used line + from file i. This is just for verifying that file i is properly + sorted. */ + prevline = (struct linebuffer **) + xmalloc (nfiles * sizeof (struct linebuffer *)); + /* streams[i] holds the input stream for file i. */ + streams = (FILE **) xmalloc (nfiles * sizeof (FILE *)); + /* file_lossage[i] is nonzero if we already know file i is not + properly sorted. */ + file_lossage = (int *) xmalloc (nfiles * sizeof (int)); + + /* Allocate and initialize all that storage. */ + + for (i = 0; i < nfiles; i++) + { + initbuffer (&lb1[i]); + initbuffer (&lb2[i]); + thisline[i] = &lb1[i]; + prevline[i] = &lb2[i]; + file_lossage[i] = 0; + streams[i] = fopen (infiles[i], "r"); + if (!streams[i]) + pfatal_with_name (infiles[i]); + + readline (thisline[i], streams[i]); + } + + /* Keep count of number of files not at eof. */ + nleft = nfiles; + + while (nleft) + { + struct linebuffer *best = 0; + struct linebuffer *exch; + int bestfile = -1; + int i; + + /* Look at the next avail line of each file; choose the least one. */ + + for (i = 0; i < nfiles; i++) + { + if (thisline[i] && + (!best || + 0 < compare_general (best->buffer, thisline[i]->buffer, + (long) bestfile, (long) i, num_keyfields))) + { + best = thisline[i]; + bestfile = i; + } + } + + /* Output that line, unless it matches the previous one and we + don't want duplicates. */ + + if (!(prev_out && + !compare_general (prev_out->buffer, + best->buffer, 0L, 1L, num_keyfields - 1))) + indexify (best->buffer, ostream); + prev_out = best; + + /* Now make the line the previous of its file, and fetch a new + line from that file. */ + + exch = prevline[bestfile]; + prevline[bestfile] = thisline[bestfile]; + thisline[bestfile] = exch; + + while (1) + { + /* If the file has no more, mark it empty. */ + + if (feof (streams[bestfile])) + { + thisline[bestfile] = 0; + /* Update the number of files still not empty. */ + nleft--; + break; + } + readline (thisline[bestfile], streams[bestfile]); + if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) + break; + } + } + + finish_index (ostream); + + /* Free all storage and close all input streams. */ + + for (i = 0; i < nfiles; i++) + { + fclose (streams[i]); + free (lb1[i].buffer); + free (lb2[i].buffer); + } + free (file_lossage); + free (lb1); + free (lb2); + free (thisline); + free (prevline); + free (streams); + + if (outfile) + fclose (ostream); + + return lossage; +} + +/* Print error message and exit. */ + +void +fatal (format, arg) + char *format, *arg; +{ + error (format, arg); + exit (TI_FATAL_ERROR); +} + +/* Print error message. FORMAT is printf control string, ARG is arg for it. */ +void +error (format, arg) + char *format, *arg; +{ + printf ("%s: ", program_name); + printf (format, arg); + if (format[strlen (format) -1] != '\n') + printf ("\n"); +} + +void +perror_with_name (name) + char *name; +{ + char *s; + + s = strerror (errno); + printf ("%s: ", program_name); + printf ("%s; for file `%s'.\n", s, name); +} + +void +pfatal_with_name (name) + char *name; +{ + char *s; + + s = strerror (errno); + printf ("%s: ", program_name); + printf ("%s; for file `%s'.\n", s, name); + exit (TI_FATAL_ERROR); +} + +/* Return a newly-allocated string whose contents concatenate those of + S1, S2, S3. */ + +char * +concat (s1, s2, s3) + char *s1, *s2, *s3; +{ + int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); + char *result = (char *) xmalloc (len1 + len2 + len3 + 1); + + strcpy (result, s1); + strcpy (result + len1, s2); + strcpy (result + len1 + len2, s3); + *(result + len1 + len2 + len3) = 0; + + return result; +} + +#if !defined (HAVE_STRERROR) +extern char *sys_errlist[]; +extern int sys_nerr; + +char * +strerror (num) + int num; +{ + if (num >= sys_nerr) + return (""); + else + return (sys_errlist[num]); +} +#endif /* !HAVE_STRERROR */ + +#if !defined (HAVE_STRCHR) +char * +strrchr (string, character) + char *string; + int character; +{ + register int i; + + for (i = strlen (string) - 1; i > -1; i--) + if (string[i] == character) + return (string + i); + + return ((char *)NULL); +} +#endif /* HAVE_STRCHR */ + +/* Just like malloc, but kills the program in case of fatal error. */ +void * +xmalloc (nbytes) + int nbytes; +{ + void *temp = (void *) malloc (nbytes); + + if (nbytes && temp == (void *)NULL) + memory_error ("xmalloc", nbytes); + + return (temp); +} + +/* Like realloc (), but barfs if there isn't enough memory. */ +void * +xrealloc (pointer, nbytes) + void *pointer; + int nbytes; +{ + void *temp; + + if (!pointer) + temp = (void *)xmalloc (nbytes); + else + temp = (void *)realloc (pointer, nbytes); + + if (nbytes && !temp) + memory_error ("xrealloc", nbytes); + + return (temp); +} + +memory_error (callers_name, bytes_wanted) + char *callers_name; + int bytes_wanted; +{ + char printable_string[80]; + + sprintf (printable_string, + "Virtual memory exhausted in %s ()! Needed %d bytes.", + callers_name, bytes_wanted); + + error (printable_string); + abort (); +} + diff --git a/xiberty/configure.in b/xiberty/configure.in new file mode 100644 index 000000000000..2729c096a495 --- /dev/null +++ b/xiberty/configure.in @@ -0,0 +1,101 @@ +# This file is a shell script fragment that supplies the information +# necessary for a configure script to process the program in +# this directory. For more information, look at ../configure. + +# We need multilib support. +. ${srcdir}/../cfg-ml-com.in + +configdirs= +srctrigger=../libiberty/getopt1.c +srcname="cross -liberty library" +Makefile_in=../libiberty/Makefile.in + +case "$srcdir" in + ".") ;; + *) srcdir=${srcdir}/../libiberty ;; +esac + +# per-host: + +# per-target: + +files="../libiberty/alloca-norm.h" +links="alloca-conf.h" + +xhost=${target} +xsrcdir=../libiberty/ +. ${srcdir}/../libiberty/config.table +target_makefile_frag=${frag} + +case "$srcdir" in + ".") + # Make sure we also make links to all the source files + source_files=`echo ../libiberty/*.[ch] ../libiberty/functions.def` + files="${files} ${source_files}" + source_links=`echo "$source_files" | sed -e 's|../libiberty/||g'` + links="${links} ${source_links}" + ;; + *) + ;; +esac + +# post-target: + +# if we are candian crossing the we need to pick up host copies of +# the tools, otherwise we can look in the current tree +# but we shouldn't build xiberty if we're not canadian crossing. +if [ "${host}" != "${target}" ] ; then + echo "CC = ${target_alias}-gcc" > Makefile.tem + echo "AR = ${target_alias}-ar " >> Makefile.tem + echo "RANLIB = ${target_alias}-ranlib " >> Makefile.tem +else + echo > Makefile.tem +fi + +echo "INSTALL_DEST = tooldir" >> Makefile.tem + +# If we are cross-compiling, check at compile time whether we are +# using newlib. If we are, we already know the files we need, since +# the linker will fail when run on some of the newlib targets. +if [ "${host}" != "${target}" ] ; then + cat > Makefile.tem2 <<'!EOF!' +CONFIG_H = xconfig.h +NEEDED_LIST = xneeded-list + +xconfig.h: Makefile + if [ -f ../newlib/Makefile ]; then \ + echo "#define NEED_sys_nerr 1" >xconfig.h; \ + echo "#define NEED_sys_errlist 1" >>xconfig.h; \ + echo "#define NEED_sys_siglist 1" >>xconfig.h; \ + echo "#define NEED_psignal 1" >>xconfig.h; \ + else \ + $(MAKE) $(FLAGS_TO_PASS) lconfig.h; \ + cp lconfig.h xconfig.h; \ + fi + +xneeded-list: Makefile + if [ -f ../newlib/Makefile ]; then \ + echo insque.o random.o strdup.o alloca.o >xneeded-list; \ + else \ + $(MAKE) $(FLAGS_TO_PASS) lneeded-list; \ + cp lneeded-list xneeded-list; \ + fi +!EOF! +fi +sed -e "/^####/ r Makefile.tem" -e "/^####/ r Makefile.tem2" ${Makefile} > Makefile.tem3 +mv Makefile.tem3 ${Makefile} +rm -f Makefile.tem Makefile.tem2 + +if [ "${srcdir}" = "." ] ; then + echo "EXTRA_LINKS = ${source_links}" >>Makefile +fi +mv Makefile Makefile.tmp +# Patch 'install' and 'Makefile' rules in Makefile +# (The latter is only needed when "$srcdir" = ".".) +sed Makefile +rm -f Makefile.tmp + +# We need multilib support. +. ${srcdir}/../cfg-ml-pos.in diff --git a/ylwrap b/ylwrap new file mode 100755 index 000000000000..b5b62184383c --- /dev/null +++ b/ylwrap @@ -0,0 +1,107 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# 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. + +# Usage: +# ylwrap PROGRAM INPUT [OUTPUT DESIRED]... -- [ARGS]... +# * PROGRAM is program to run. +# * INPUT is the input file +# * OUTPUT is file PROG generates +# * DESIRED is file we actually want +# * ARGS are passed to PROG +# Any number of OUTPUT,DESIRED pairs may be used. + +# The program to run. +prog="$1" +shift +# Make any relative path in $prog absolute. +case "$prog" in + /*) ;; + */*) prog="`pwd`/$prog" ;; +esac + +# The input. +input="$1" +shift +case "$input" in + /*) + # Absolute path; do nothing. + ;; + *) + # Relative path. Make it absolute. Why? Because otherwise any + # debugging info in the generated file will point to the wrong + # place. This is really gross. + input="`pwd`/$input" + ;; +esac + +pairlist= +while test "$#" -ne 0; do + if test "$1" = "--"; then + shift + break + fi + pairlist="$pairlist $1" + shift +done + +# FIXME: add hostname here for parallel makes that run commands on +# other machines. But that might take us over the 14-char limit. +dirname=ylwrap$$ +trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 +mkdir $dirname || exit 1 + +cd $dirname +$prog ${1+"$@"} "$input" +status=$? + +if test $status -eq 0; then + set X $pairlist + shift + first=yes + while test "$#" -ne 0; do + if test -f "$1"; then + # If $2 is an absolute path name, then just use that, + # otherwise prepend `../'. + case "$2" in + /*) target="$2";; + *) target="../$2";; + esac + mv "$1" "$target" || status=$? + else + # A missing file is only an error for the first file. This + # is a blatant hack to let us support using "yacc -d". If -d + # is not specified, we don't want an error when the header + # file is "missing". + if test $first = yes; then + status=1 + fi + fi + shift + shift + first=no + done +else + status=$? +fi + +# Remove the directory. +cd .. +rm -rf $dirname + +exit $status -- 2.43.5